Skip to content

Commit

Permalink
Merge pull request #1374 from undb-xyz/release/v0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Jul 27, 2023
2 parents f98c4a7 + 72eecc9 commit 4abb36e
Show file tree
Hide file tree
Showing 115 changed files with 2,686 additions and 1,788 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
node-version: 20.2.0

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v2.4.0
with:
version: 8.6.5

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## v0.6.2

## v0.6.1

## v0.6.0
Expand Down
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,26 @@
·
<a href="https://github.com/orgs/undb-xyz/projects/1/views/2?query=is%3Aopen+sort%3Aupdated-desc">Roadmap</a>

> use email `test@example.com` and password `123456` to login
![undb](https://github.com/undb-xyz/undb/assets/22788984/e3495c5f-84ff-4b89-b7ed-2ec25081a990)

![undb](./docs/undb.png)
## 🚀 Quick Start

- Visit out [Live Demo](https://demo.undb.xyz?lng=en) to try `undb`

- Checkout quick install / deployment [document](https://docs.undb.xyz/installation/1installation-with-docker/)

- Checkout [development envionment setup](https://docs.undb.xyz/contribution/development/) to setup local development environment.

- Open `undb` in [gitpod](https://gitpod.io/new/#https://github.com/undb-xyz/undb) to setup development envionment quickly.

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/new/#https://github.com/undb-xyz/undb)

- Join our [discord](https://discord.gg/3rcNdU3y3U) to keep in touch.

<p>
<a href="https://discord.gg/3rcNdU3y3U"><img alt="Discord" src="https://img.shields.io/badge/discord-chat-5865f2?logo=discord&logoColor=f5f5f5" /></a>
</p>

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/new/#https://github.com/undb-xyz/undb)

## ✅ Features

- :closed_lock_with_key: Private first
Expand All @@ -33,6 +43,7 @@
- :sparkles: Multiple built-in field types and variants
- :city_sunset: Different types of views, including grid, kanban, gantt, tree, calendar and more
- 💡 Light / Dark theme
- 🗑️ records trash / restore

## 📚 Tech Stack

Expand All @@ -44,10 +55,6 @@

## Screen Shot

### Light / Dark theme

![image](https://github.com/undb-xyz/undb/assets/22788984/174a7fa3-f2ae-4daa-8901-950251c9e136)

![Create table](./docs/create-new-table.png)

![Create table](./docs/create-new-field.png)
Expand Down Expand Up @@ -88,20 +95,6 @@ docker run -d --name undb -p 4000:4000 --platform linux/x86_64 -v ~/.undb/:/var/

![Alt](https://repobeats.axiom.co/api/embed/4e19a26c5f110e58bbcce4bb6a79c144a481c3dd.svg 'Repobeats analytics image')

## Contribution

Checkout [development documentation](https://docs.undb.xyz/contribution/development/)

## Contact

### email

`nichenqin@hotmail.com`

### wechat

<img width="369" alt="image" src="https://github.com/undb-xyz/undb/assets/22788984/7ccc0e6f-b183-4d67-b241-961c27407189">

## License

undb is open-source under the GNU Affero General Public License Version 3 (AGPLv3). You can find it [here](./LICENSE).
3 changes: 3 additions & 0 deletions apps/backend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ module.exports = {
parserOptions: {
emitDecoratorMetadata: true,
},
rules: {
'@typescript-eslint/consistent-type-imports': 'warn',
},
}
30 changes: 15 additions & 15 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"name": "@undb/backend",
"version": "0.0.0",
"dependencies": {
"@aws-sdk/client-s3": "^3.374.0",
"@aws-sdk/client-s3": "^3.378.0",
"@json2csv/plainjs": "^7.0.1",
"@liaoliaots/nestjs-redis-health": "^9.0.4",
"@mikro-orm/better-sqlite": "^5.7.13",
"@mikro-orm/core": "^5.7.13",
"@mikro-orm/migrations": "^5.7.13",
"@mikro-orm/better-sqlite": "^5.7.14",
"@mikro-orm/core": "^5.7.14",
"@mikro-orm/migrations": "^5.7.14",
"@mikro-orm/nestjs": "^5.2.0",
"@nestjs/common": "^10.1.0",
"@nestjs/common": "^10.1.2",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^10.1.0",
"@nestjs/cqrs": "^10.0.1",
"@nestjs/core": "^10.1.2",
"@nestjs/cqrs": "^10.0.3",
"@nestjs/jwt": "^10.1.0",
"@nestjs/mongoose": "^10.0.1",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.1.0",
"@nestjs/platform-express": "^10.1.2",
"@nestjs/schedule": "^3.0.1",
"@nestjs/serve-static": "^4.0.0",
"@nestjs/terminus": "^10.0.1",
Expand All @@ -42,15 +42,15 @@
"class-validator": "^0.14.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cron": "^2.3.1",
"cron": "^2.4.0",
"got": "^13.0.0",
"helmet": "^7.0.0",
"i18next": "^23.0.0",
"i18next-http-middleware": "^3.3.2",
"ioredis": "^5.3.2",
"joi": "^17.9.2",
"mongodb": "^5.7.0",
"mongoose": "^7.4.0",
"mongoose": "^7.4.1",
"nestjs-cls": "^3.5.0",
"nestjs-pino": "^3.3.0",
"oxide.ts": "^1.1.0",
Expand All @@ -59,7 +59,7 @@
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"pino-http": "^8.3.3",
"pino-pretty": "^10.0.1",
"pino-pretty": "^10.2.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.1",
"rxjs": "^7.8.1",
Expand All @@ -72,17 +72,17 @@
"devDependencies": {
"@nestjs/cli": "^10.1.10",
"@nestjs/schematics": "^10.0.1",
"@nestjs/testing": "^10.1.0",
"@nestjs/testing": "^10.1.2",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.70",
"@swc/core": "^1.3.71",
"@types/bcrypt": "^5.0.0",
"@types/compression": "^1.7.2",
"@types/cookie-parser": "^1.4.3",
"@types/cron": "^2.0.1",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.3",
"@types/multer": "^1.4.7",
"@types/node": "^20.4.2",
"@types/node": "^20.4.5",
"@types/passport": "^1.0.12",
"@types/passport-jwt": "^3.0.9",
"@types/passport-local": "^1.0.35",
Expand All @@ -92,7 +92,7 @@
"eslint": "^8.45.0",
"esm": "^3.2.25",
"express": "^4.18.2",
"jest": "^29.6.1",
"jest": "^29.6.2",
"nodemon": "^3.0.1",
"npm-run-all": "^4.1.5",
"openapi3-ts": "^4.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { MikroORM, UseRequestContext } from '@mikro-orm/core'
import { Inject, Injectable } from '@nestjs/common'
import type { IQueryRecordSchema, IQueryRecords, IRecordQueryModel, IRecordSpec, ViewId } from '@undb/core'
import type {
IQueryRecordSchema,
IQueryRecords,
IRecordQueryModel,
IRecordSpec,
RecordsWithCount,
ViewId,
} from '@undb/core'
import { EntityManager, RecordSqliteQueryModel } from '@undb/sqlite'
import type { Option } from 'oxide.ts'

Expand All @@ -9,7 +16,10 @@ export const InjectRecordQueryModel = () => Inject(RECORD_QUERY_MODEL)

@Injectable()
export class NestRecordSqliteQueryModel extends RecordSqliteQueryModel implements IRecordQueryModel {
constructor(protected readonly orm: MikroORM, public readonly em: EntityManager) {
constructor(
protected readonly orm: MikroORM,
public readonly em: EntityManager,
) {
super(em)
}

Expand All @@ -19,11 +29,7 @@ export class NestRecordSqliteQueryModel extends RecordSqliteQueryModel implement
}

@UseRequestContext()
async findAndCount(
tableId: string,
viewId: ViewId | undefined,
spec: IRecordSpec | null,
): Promise<{ records: IQueryRecords; total: number }> {
async findAndCount(tableId: string, viewId: ViewId | undefined, spec: IRecordSpec | null): Promise<RecordsWithCount> {
return super.findAndCount(tableId, viewId, spec)
}

Expand All @@ -36,4 +42,9 @@ export class NestRecordSqliteQueryModel extends RecordSqliteQueryModel implement
findOneById(tableId: string, id: string): Promise<Option<IQueryRecordSchema>> {
return super.findOneById(tableId, id)
}

@UseRequestContext()
findDeletedAndCount(tableId: string, spec: IRecordSpec | null) {
return super.findDeletedAndCount(tableId, spec)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ export class NestRecordSqliteRepository extends RecordSqliteRepository {
async deleteManyByIds(table: Table, ids: string[]): Promise<void> {
return super.deleteManyByIds(table, ids)
}

@UseRequestContext()
restoreOneById(table: Table, id: string): Promise<void> {
return super.restoreOneById(table, id)
}
}
2 changes: 2 additions & 0 deletions apps/backend/src/core/table/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MoveViewCommandHandler } from './move-view.command.handler.js'
import { RelayoutWidgetsCommandHandler } from './relayout-widgets.command.handler.js'
import { ReorderOptionsCommandHandler } from './reorder-options.command.handler.js'
import { ResetFieldSortCommandHandler } from './reset-field-sort.command.handler.js'
import { RestoreRecordCommandHandler } from './restore-record.command.handler.js'
import { SetCalendarFieldCommandHandler } from './set-calendar-field.command.handler.js'
import { SetFieldSortCommandHandler } from './set-field-sort.command.handler.js'
import { SetFieldVisibilityCommandHandler } from './set-field-visibility.command.handler.js'
Expand Down Expand Up @@ -102,4 +103,5 @@ export const commandHandlers = [
SetFormFieldsOrderCommandHandler,
SetGalleryFieldCommandHandler,
UpdateFormCommandHandler,
RestoreRecordCommandHandler,
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ICommandHandler } from '@nestjs/cqrs'
import { CommandHandler } from '@nestjs/cqrs'
import { type IRecordRepository, type ITableRepository } from '@undb/core'
import { RestoreRecordCommandHandler as DomainHandler, RestoreRecordCommand } from '@undb/cqrs'
import { InjectRecordRepository } from '../adapters/sqlite/record-sqlite.repository.js'
import { InjectTableRepository } from '../adapters/sqlite/table-sqlite.repository.js'

@CommandHandler(RestoreRecordCommand)
export class RestoreRecordCommandHandler extends DomainHandler implements ICommandHandler<RestoreRecordCommand> {
constructor(
@InjectTableRepository()
protected readonly tableRepo: ITableRepository,
@InjectRecordRepository()
protected readonly recordRepo: IRecordRepository,
) {
super(tableRepo, recordRepo)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { IQueryHandler } from '@nestjs/cqrs'
import { QueryHandler } from '@nestjs/cqrs'
import { type IRecordQueryModel, type ITableRepository } from '@undb/core'
import type { IGetTrashRecordsOutput } from '@undb/cqrs'
import { GetTrashRecordsQuery, GetTrashRecordsQueryHandler } from '@undb/cqrs'
import { InjectRecordQueryModel } from '../adapters/sqlite/record-sqlite.query-model.js'
import { InjectTableRepository } from '../adapters/sqlite/table-sqlite.repository.js'

@QueryHandler(GetTrashRecordsQuery)
export class NestGetTrashRecordsQueryHandler
extends GetTrashRecordsQueryHandler
implements IQueryHandler<GetTrashRecordsQuery, IGetTrashRecordsOutput>
{
constructor(
@InjectTableRepository()
protected readonly tableRepo: ITableRepository,
@InjectRecordQueryModel()
protected readonly rm: IRecordQueryModel,
) {
super(tableRepo, rm)
}
}
2 changes: 2 additions & 0 deletions apps/backend/src/core/table/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { NestGetRecordsTreeQueryHandler } from './get-records-tree.query.handler
import { NestGetRecordsQueryHandler } from './get-records.query.handler.js'
import { NestGetTableQueryHandler } from './get-table.query.handler.js'
import { NestGetTablesQueryHandler } from './get-tables.query.handler.js'
import { NestGetTrashRecordsQueryHandler } from './get-trash-records.query.handler.js'
import { NestGetTreeAvailableRecordsQueryHandler } from './get-tree-available-records.query.handler.js'

export const queryHandlers = [
NestGetTableQueryHandler,
NestGetTablesQueryHandler,
NestGetTrashRecordsQueryHandler,
NestGetRecordQueryHandler,
NestGetRecordsQueryHandler,
NestGetForeignRecordsQueryHandler,
Expand Down
7 changes: 7 additions & 0 deletions apps/backend/src/openapi/openapi-record.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
DuplicateRecordCommand,
GetRecordQuery,
GetRecordsQuery,
RestoreRecordCommand,
} from '@undb/cqrs'
import { type IOpenAPIMutateRecordSchema } from '@undb/openapi'
import { InjectPinoLogger, PinoLogger } from 'nestjs-pino'
Expand Down Expand Up @@ -91,6 +92,12 @@ export class OpenAPIRecordController {
await this.commandBus.execute(new DeleteRecordCommand({ tableId, id }))
}

@Version('1')
@Post('tables/:tableId/records/:id/restore')
public async restoreRecord(@Param('tableId') tableId: string, @Param('id') id: string) {
await this.commandBus.execute(new RestoreRecordCommand({ tableId, id }))
}

@Version('1')
@Delete('tables/:tableId/records')
public async deleteRecordsByIds(@Param('tableId') tableId: string, @Body('ids') ids: [string, ...string[]]) {
Expand Down
1 change: 1 addition & 0 deletions apps/backend/src/openapi/openapi-webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class OpenAPIWebhookService {
await this.commandBus.execute(
new CreateWebhookCommand({
tableId,
// @ts-ignore
webhook: {
...values,
target: {
Expand Down
9 changes: 8 additions & 1 deletion apps/backend/src/relay/relay.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ export class RelayService {
async handleCron() {
await this.outboxService.handle((outboxList) => {
for (const outbox of outboxList) {
const event = EventFactory.create(outbox.uuid, outbox.operatorId, outbox.name, outbox.payload)
const event = EventFactory.create(
outbox.uuid,
outbox.operatorId,
outbox.name,
outbox.payload,
outbox.meta,
outbox.timestamp,
)
if (!event) {
this.logger.warn('unknown event name %s', outbox.name)
continue
Expand Down
7 changes: 5 additions & 2 deletions apps/backend/src/webhook/events/webhook.event-handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { IEventHandler } from '@nestjs/cqrs'
import { EventsHandler } from '@nestjs/cqrs'
import type { RecordEvents } from '@undb/core'
import type { ITableRepository, RecordEvents } from '@undb/core'
import { RecordEventsClasses } from '@undb/core'
import { WebhookEventsHandler } from '@undb/cqrs'
import { type IWebhookHttpService, type IWebhookRepository } from '@undb/integrations'
import { InjectPinoLogger, PinoLogger } from 'nestjs-pino'
import { InjectTableRepository } from '../../core/table/adapters/sqlite/table-sqlite.repository.js'
import { InjectWebhookRepository } from '../adapters/webhook-sqlite.repository.js'
import { InjectWebhookHttpService } from '../providers.js'

Expand All @@ -17,7 +18,9 @@ export class NestWebhookEventHandler extends WebhookEventsHandler implements IEv
protected readonly webhookHttpService: IWebhookHttpService,
@InjectWebhookRepository()
protected readonly repo: IWebhookRepository,
@InjectTableRepository()
protected readonly tableRepo: ITableRepository,
) {
super(logger, webhookHttpService, repo)
super(logger, webhookHttpService, repo, tableRepo)
}
}
Loading

0 comments on commit 4abb36e

Please sign in to comment.