Skip to content

Commit

Permalink
Merge pull request #1013 from undb-xyz/release/v0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin authored May 21, 2023
2 parents 4a8609b + fe53fa9 commit 7a23e30
Show file tree
Hide file tree
Showing 80 changed files with 1,415 additions and 518 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE-REQUEST.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Feature request
description: Suggest a feature to improve undb
title: '[feature]: '
labels: [feature]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to request a feature for undb
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue related to this feature request already exists
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Summary
description: One paragraph description of the feature
validations:
required: true
- type: textarea
attributes:
label: Why should this be worked on?
description: A concise description of the problems or use cases for this feature request
validations:
required: true
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN pnpm install -r --offline
ARG PUBLIC_UNDB_ANALYTICS_DOMAIN
ARG PUBLIC_UNDB_ADMIN_EMAIL
ARG PUBLIC_UNDB_ADMIN_PASSWORD
ARG UNDB_SEED

ENV NODE_ENV production
RUN pnpm run build --filter=backend --filter=frontend
Expand All @@ -52,6 +53,7 @@ COPY --from=installer /undb/apps/backend ./apps/backend
COPY --from=installer /undb/apps/frontend/build ./out
COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream
COPY scripts/start.mjs ./scripts/start.mjs
COPY data/data.sql /data/data.sql

COPY litestream/etc/litestream.yml /etc/litestream.yml

Expand Down
12 changes: 6 additions & 6 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"@nestjs/common": "^9.4.1",
"@nestjs/config": "^2.3.2",
"@nestjs/core": "^9.4.1",
"@nestjs/cqrs": "^9.0.3",
"@nestjs/cqrs": "^9.0.4",
"@nestjs/jwt": "^10.0.3",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.4.1",
"@nestjs/serve-static": "^3.0.1",
"@nestjs/terminus": "^9.2.2",
"@trpc/server": "^10.26.0",
"@trpc/server": "^10.27.1",
"@undb/core": "^0.0.0",
"@undb/cqrs": "^0.0.0",
"@undb/domain": "^0.0.0",
Expand All @@ -28,7 +28,7 @@
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"helmet": "^7.0.0",
"i18next": "^22.4.15",
"i18next": "^22.5.0",
"i18next-http-middleware": "^3.3.0",
"joi": "^17.9.2",
"nestjs-cls": "^3.3.1",
Expand All @@ -49,21 +49,21 @@
"@nestjs/schematics": "^9.2.0",
"@nestjs/testing": "^9.4.1",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.58",
"@swc/core": "^1.3.59",
"@types/bcrypt": "^5.0.0",
"@types/compression": "^1.7.2",
"@types/cookie-parser": "^1.4.3",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.1",
"@types/multer": "^1.4.7",
"@types/node": "^20.2.0",
"@types/node": "^20.2.1",
"@types/passport": "^1.0.12",
"@types/passport-jwt": "^3.0.8",
"@types/passport-local": "^1.0.35",
"@types/supertest": "^2.0.12",
"@types/uuid": "^9.0.1",
"@undb/eslint-config": "^0.0.0",
"eslint": "^8.40.0",
"eslint": "^8.41.0",
"esm": "^3.2.25",
"express": "^4.18.2",
"jest": "^29.5.0",
Expand Down
19 changes: 14 additions & 5 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { MikroORM } from '@mikro-orm/core'
import { MikroOrmModule } from '@mikro-orm/nestjs'
import type { OnModuleInit } from '@nestjs/common'
import { Module } from '@nestjs/common'
import { ConfigType } from '@nestjs/config'
import type { ConfigType } from '@nestjs/config'
import { ServeStaticModule } from '@nestjs/serve-static'
import { createConfig } from '@undb/sqlite'
import { EntityManager, createConfig } from '@undb/sqlite'
import { Request } from 'express'
import { ClsModule } from 'nestjs-cls'
import { LoggerModule } from 'nestjs-pino'
Expand All @@ -14,7 +14,7 @@ import { AttachmentModule } from './attachment/attachment.module.js'
import { AuthModule } from './auth/auth.module.js'
import { BaseConfigService } from './configs/base-config.service.js'
import { ConfigModule } from './configs/config.module.js'
import { sqliteConfig } from './configs/sqlite.config.js'
import { InjectSqliteConfig, sqliteConfig } from './configs/sqlite.config.js'
import { HealthModule } from './health/health.module.js'
import { I18nModule } from './i18n/i18n.module.js'
import { modules } from './modules/index.js'
Expand Down Expand Up @@ -56,10 +56,19 @@ import { TrpcModule } from './trpc/trpc.module.js'
],
})
export class AppModule implements OnModuleInit {
constructor(private readonly orm: MikroORM, private readonly userService: UserService) {}
constructor(
private readonly orm: MikroORM,
private readonly userService: UserService,
@InjectSqliteConfig() private readonly config: ConfigType<typeof sqliteConfig>,
) {}

async onModuleInit() {
await this.orm.getMigrator().up()
const em = this.orm.em as EntityManager
if (this.config.seed) {
await em.getConnection().loadFile(path.resolve(process.cwd(), '../../data/data.sql')).catch(console.error)
} else {
await this.orm.getMigrator().up()
}
await this.userService.createAdmin()
}
}
1 change: 1 addition & 0 deletions apps/backend/src/configs/env.validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const configSchema = Joi.object({
PORT: Joi.number().default(4000),
// databse
UNDB_DATABASE_SQLITE_DATA: Joi.string().default(path.resolve(process.cwd(), '../../.undb/data')),
UNDB_SEED: Joi.string().equal('true').optional(),
// storage object
UNDB_OBJECT_STORAGE_PROVIDER: Joi.string().valid('local').default('local'),
UNDB_OBJECT_STORAGE_LOCAL_PATH: Joi.when('UNDB_OBJECT_STORAGE_PROVIDER', {
Expand Down
1 change: 1 addition & 0 deletions apps/backend/src/configs/sqlite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const InjectSqliteConfig = () => Inject(sqliteConfig.KEY)

export const sqliteConfig = registerAs('sqlite', () => ({
data: process.env.UNDB_DATABASE_SQLITE_DATA,
seed: process.env.UNDB_SEED === 'true',
}))
2 changes: 2 additions & 0 deletions apps/backend/src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
User,
UserFactory,
UserSpecification,
WithUserColor,
WithUserEmail,
WithUserId,
WithUserPassword,
Expand Down Expand Up @@ -38,6 +39,7 @@ export class UserService {
WithUserPassword.fromString(hashedPassword),
admin.username ? WithUsername.fromString(admin.username) : WithUsername.fromEmail(admin.email),
WithUserId.create(),
WithUserColor.random(),
)
await this.repo.insert(user)
}
Expand Down
24 changes: 13 additions & 11 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@
"@event-calendar/day-grid": "^1.1.1",
"@event-calendar/interaction": "^1.1.1",
"@event-calendar/time-grid": "^1.1.1",
"@playwright/test": "^1.33.0",
"@playwright/test": "^1.34.0",
"@popperjs/core": "^2.11.7",
"@revolist/revogrid": "^3.6.5",
"@revolist/svelte-datagrid": "^3.2.16",
"@rgossiaux/svelte-headlessui": "^1.0.2",
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/adapter-static": "^2.0.2",
"@sveltejs/kit": "^1.18.0",
"@tabler/icons-webfont": "^2.19.0",
"@tabler/icons-webfont": "^2.20.0",
"@tailwindcss/forms": "^0.5.3",
"@tanstack/svelte-query": "^4.29.7",
"@trpc/client": "^10.26.0",
"@trpc/server": "^10.26.0",
"@trpc/client": "^10.27.1",
"@trpc/server": "^10.27.1",
"@types/js-cookie": "^3.0.3",
"@types/lodash-es": "^4.17.7",
"@types/nprogress": "^0.2.0",
"@types/sortablejs": "^1.15.1",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"@undb/core": "^0.0.0",
Expand All @@ -43,15 +44,15 @@
"classnames": "^2.3.2",
"date-fns": "^2.30.0",
"delay": "^5.0.0",
"eslint": "^8.40.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte3": "^4.0.0",
"flowbite": "^1.6.5",
"flowbite-svelte": "^0.35.4",
"flowbite-svelte": "^0.36.4",
"htm": "^3.1.1",
"i18next": "^22.4.15",
"i18next": "^22.5.0",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-http-backend": "^2.2.0",
"i18next-http-backend": "^2.2.1",
"js-cookie": "^3.0.5",
"keycode": "^2.2.1",
"lodash-es": "^4.17.21",
Expand All @@ -61,6 +62,7 @@
"postcss-load-config": "^4.0.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.0",
"sortablejs": "^1.15.0",
"svelte": "^3.59.1",
"svelte-chartjs": "^3.1.2",
"svelte-check": "^3.3.2",
Expand All @@ -74,9 +76,9 @@
"svelte-tiny-virtual-list": "^2.0.5",
"sveltekit-superforms": "^0.8.6",
"tailwindcss": "^3.3.2",
"trpc-svelte-query": "^0.0.2",
"tslib": "^2.5.1",
"type-fest": "^3.10.0",
"trpc-svelte-query": "^1.0.0",
"tslib": "^2.5.2",
"type-fest": "^3.11.0",
"typescript": "^5.0.4",
"vite": "^4.3.8",
"vitest": "^0.31.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<script lang="ts">
import cx from 'classnames'
import type { IColor } from '@undb/core'
import { Avatar, P } from 'flowbite-svelte'
import { colors } from '$lib/field/helpers'
export let username: string
export let avatar: string | undefined | null
export let color: IColor
export let size: 'xs' | 'sm' | 'lg' | 'xl' | undefined = 'xs'
</script>

<span class="inline-flex gap-2 items-center">
{#if !avatar}
<Avatar {size}>{username.slice(0, 2)}</Avatar>
<Avatar {size} class={cx(colors[color], 'text-white')}>{username.slice(0, 2)}</Avatar>
{:else}
<Avatar {size} src={avatar} alt={username}>{username.slice(0, 2)}</Avatar>
{/if}
Expand Down
12 changes: 8 additions & 4 deletions apps/frontend/src/lib/cell/CellComponents/cell-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type DateRangeField,
type IAttachmentItem,
type ICollaboratorProfile,
type IColor,
type IDateRangeFieldQueryValue,
type IFieldType,
type IOptionSchema,
Expand Down Expand Up @@ -109,9 +110,12 @@ const collaboratorComponent = (h: HyperFunc, collaborator: ICollaboratorProfile)
${!collaborator.avatar
? html`
<div
class="relative inline-flex items-center text-blue-900 justify-center w-5 h-5 overflow-hidden bg-indigo-100 rounded-full dark:bg-indigo-600 border border-gray-300"
class=${cx(
'relative inline-flex items-center !text-white justify-center w-5 h-5 overflow-hidden rounded-full border border-gray-300',
colors[collaborator.color],
)}
>
<span class="font-medium text-gray-600 dark:text-gray-300"> ${collaborator.username.slice(0, 2)} </span>
<span class="font-medium"> ${collaborator.username.slice(0, 2)} </span>
</div>
`
: html` <img class="w-5 h-5 rounded-full" src="${collaborator.avatar}" alt="${collaborator.username}" /> `}
Expand Down Expand Up @@ -204,9 +208,9 @@ const collaborator: TemplateFunc = (h, props) => {

return html`
<div class="flex items-center space-x-2">
${value.map(([username, avatar]) => {
${value.map(([username, avatar, color]) => {
if (!username) return null
return collaboratorComponent(h, { username, avatar })
return collaboratorComponent(h, { username, avatar, color: color as IColor })
})}
</div>
`
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/lib/cell/CellInput/Collaborator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
$: values = field.getDisplayValues(displayValues) ?? []
$: initialMembers = new Map(
value?.map((userId, index) => {
const [username, avatar] = (values ?? [])[index] ?? []
return [userId, { userId, avatar, username: username ?? '' }]
const [username, avatar, color] = (values ?? [])[index] ?? []
return [userId, { userId, avatar, username: username ?? '', color }]
}),
)
</script>
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/lib/cell/CellInput/UserPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<Button color="alternative" class={cx('inline-flex gap-3 max-h-10 max-w-max', $$restProps.class)} {...$$restProps}>
{#if selected}
<CollaboratorComponent username={selected.username} avatar={selected.avatar} />
<CollaboratorComponent username={selected.username} avatar={selected.avatar} color={selected.color} />
{:else}
{$t('Select Collaborator')}
{/if}
Expand All @@ -32,7 +32,7 @@
{#each members as member}
<Radio bind:group={value} value={member.userId} custom on:change={() => (open = false)}>
<span class="inline-flex items-center justify-between px-4 py-2 cursor-pointer w-full hover:bg-gray-100">
<CollaboratorComponent username={member.username} avatar={member.avatar} />
<CollaboratorComponent username={member.username} avatar={member.avatar} color={member.color} />
{#if selected?.userId === member.userId}
<i class="ti ti-check" />
{/if}
Expand Down
11 changes: 8 additions & 3 deletions apps/frontend/src/lib/cell/CellInput/UsersPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
$: {
for (const member of members) {
membersMap.set(member.userId, { userId: member.userId, avatar: member.avatar ?? null, username: member.username })
membersMap.set(member.userId, {
userId: member.userId,
avatar: member.avatar ?? null,
username: member.username,
color: member.color,
})
}
}
Expand All @@ -36,7 +41,7 @@
<Button color="alternative" class="inline-flex gap-3 max-h-10 max-w-max">
{#if selected.length}
{#each selected as member}
<CollaboratorComponent username={member.username} avatar={member.avatar} />
<CollaboratorComponent username={member.username} avatar={member.avatar} color={member.color} />
{/each}
{:else}
{$t('Select Collaborator')}
Expand All @@ -47,7 +52,7 @@
{@const isSelected = selected.some((s) => s.userId === member.userId)}
<Checkbox bind:group={value} value={member.userId} custom>
<span class="inline-flex items-center justify-between px-4 py-2 cursor-pointer w-full hover:bg-gray-100">
<CollaboratorComponent username={member.username} avatar={member.avatar} />
<CollaboratorComponent username={member.username} avatar={member.avatar} color={member.color} />
{#if isSelected}
<i class="ti ti-check" />
{/if}
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/lib/field/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IFieldType, IOptionColorName } from '@undb/core'
import type { IColor, IFieldType } from '@undb/core'
import type { Select } from 'flowbite-svelte'

export function getFilterOperators(type: IFieldType | undefined) {
Expand Down Expand Up @@ -136,7 +136,7 @@ export const icons: Record<IFieldType, string> = {

export const getIconClass = (type: IFieldType) => `ti ti-${icons[type]}`

export const colors: Record<IOptionColorName, string> = {
export const colors: Record<IColor, string> = {
slate: 'bg-slate-500',
gray: 'bg-gray-500',
zinc: 'bg-zinc-500',
Expand Down
3 changes: 0 additions & 3 deletions apps/frontend/src/lib/store/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export const updateFieldModal = createModal(UPDATE_FIELD)
const VIRSUALIZATION_DETAIL = Symbol('VIRSUALIZATION_DETAIL')
export const virsualizationModal = createModal(VIRSUALIZATION_DETAIL)

const CREATE_VIEW = Symbol('CREATE_VIEW')
export const createViewModal = createModal(CREATE_VIEW)

const CONFIG_VIEW = Symbol('CONFIG_VIEW')
export const configViewModal = createModal(CONFIG_VIEW)

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/lib/table/TableIndex.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { getView } from '$lib/store/table'
import type { IViewDisplayType, Records } from '@undb/core'
import type { IViewDisplayType } from '@undb/core'
import type { ComponentType } from 'svelte'
import TableView from './TableView.svelte'
import KanbanIndex from './KanbanIndex.svelte'
Expand Down
Loading

0 comments on commit 7a23e30

Please sign in to comment.