Skip to content

Commit

Permalink
Merge pull request #1458 from undb-xyz/release/v0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Aug 21, 2023
2 parents 35b19e3 + ff7ace0 commit 8cd305e
Show file tree
Hide file tree
Showing 132 changed files with 3,914 additions and 2,310 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## v0.7.2

## v0.7.1

## v0.7.0
Expand Down
1 change: 0 additions & 1 deletion apps/backend/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"decoratorMetadata": true
},
"keepClassNames": true,
"baseUrl": "./",
"experimental": {
"keepImportAssertions": true
}
Expand Down
58 changes: 29 additions & 29 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
"name": "@undb/backend",
"version": "0.0.0",
"dependencies": {
"@aws-sdk/client-s3": "^3.383.0",
"@json2csv/plainjs": "^7.0.1",
"@aws-sdk/client-s3": "^3.391.0",
"@json2csv/plainjs": "^7.0.2",
"@liaoliaots/nestjs-redis-health": "^9.0.4",
"@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",
"@mikro-orm/nestjs": "^5.2.1",
"@nestjs-modules/mailer": "^1.9.1",
"@nestjs/axios": "^3.0.0",
"@nestjs/common": "^10.1.3",
"@nestjs/config": "^3.0.0",
"@nestjs/core": "^10.1.3",
"@nestjs/cqrs": "^10.0.3",
"@nestjs/cqrs": "^10.2.5",
"@nestjs/jwt": "^10.1.0",
"@nestjs/mongoose": "^10.0.1",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.1.3",
"@nestjs/schedule": "^3.0.1",
"@nestjs/schedule": "^3.0.2",
"@nestjs/serve-static": "^4.0.0",
"@nestjs/terminus": "^10.0.1",
"@opentelemetry/auto-instrumentations-node": "^0.38.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.41.1",
"@opentelemetry/resources": "^1.15.1",
"@opentelemetry/sdk-node": "^0.41.1",
"@opentelemetry/semantic-conventions": "^1.15.1",
"@temporalio/activity": "^1.8.2",
"@temporalio/client": "^1.8.2",
"@temporalio/common": "^1.8.2",
"@temporalio/worker": "^1.8.2",
"@temporalio/workflow": "^1.8.2",
"@trpc/server": "^10.36.0",
"@opentelemetry/auto-instrumentations-node": "^0.39.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.41.2",
"@opentelemetry/resources": "^1.15.2",
"@opentelemetry/sdk-node": "^0.41.2",
"@opentelemetry/semantic-conventions": "^1.15.2",
"@temporalio/activity": "^1.8.3",
"@temporalio/client": "^1.8.3",
"@temporalio/common": "^1.8.3",
"@temporalio/worker": "^1.8.3",
"@temporalio/workflow": "^1.8.3",
"@trpc/server": "^10.37.1",
"@undb/authz": "workspace:^",
"@undb/cache": "^0.0.0",
"@undb/core": "^0.0.0",
Expand All @@ -45,13 +45,13 @@
"@undb/trpc": "^0.0.0",
"aws-sdk-v3-nest": "^0.3.0",
"axios": "^1.4.0",
"bcrypt": "^5.1.0",
"better-sqlite3": "^8.5.0",
"bcrypt": "^5.1.1",
"better-sqlite3": "^8.5.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cron": "^2.4.0",
"cron": "^2.4.1",
"got": "^13.0.0",
"handlebars": "^4.7.8",
"helmet": "^7.0.0",
Expand All @@ -60,7 +60,7 @@
"ioredis": "^5.3.2",
"joi": "^17.9.2",
"mongodb": "^5.7.0",
"mongoose": "^7.4.1",
"mongoose": "^7.4.3",
"nestjs-cls": "^3.5.0",
"nestjs-pino": "^3.3.0",
"nodemailer": "^6.9.4",
Expand All @@ -69,39 +69,39 @@
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"pino-http": "^8.3.3",
"pino-http": "^8.4.0",
"pino-pretty": "^10.2.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.1",
"rxjs": "^7.8.1",
"ts-pattern": "^5.0.4",
"ts-pattern": "^5.0.5",
"ufo": "^1.2.0",
"unstorage": "^1.8.0",
"unstorage": "^1.9.0",
"uuid": "^9.0.0",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@nestjs/cli": "^10.1.11",
"@nestjs/schematics": "^10.0.1",
"@nestjs/cli": "^10.1.12",
"@nestjs/schematics": "^10.0.2",
"@nestjs/testing": "^10.1.3",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.74",
"@swc/core": "^1.3.78",
"@types/bcrypt": "^5.0.0",
"@types/compression": "^1.7.2",
"@types/cookie-parser": "^1.4.3",
"@types/cron": "^2.4.0",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.3",
"@types/multer": "^1.4.7",
"@types/node": "^20.4.6",
"@types/node": "^20.5.0",
"@types/nodemailer": "^6.4.9",
"@types/passport": "^1.0.12",
"@types/passport-jwt": "^3.0.9",
"@types/passport-local": "^1.0.35",
"@types/supertest": "^2.0.12",
"@types/uuid": "^9.0.2",
"@undb/eslint-config": "^0.0.0",
"eslint": "^8.46.0",
"eslint": "^8.47.0",
"esm": "^3.2.25",
"express": "^4.18.2",
"jest": "^29.6.2",
Expand All @@ -114,7 +114,7 @@
"ts-node": "^10.9.1",
"tsconfig": "^0.0.0",
"tsconfig-paths": "^4.2.0",
"type-fest": "^4.1.0",
"type-fest": "^4.2.0",
"typescript": "^5.1.6"
},
"jest": {
Expand Down
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 @@ -30,6 +30,7 @@ import { SetFieldSortCommandHandler } from './set-field-sort.command.handler.js'
import { SetFieldVisibilityCommandHandler } from './set-field-visibility.command.handler.js'
import { SetFieldWidthCommandHandler } from './set-field-width.command.handler.js'
import { SetFiltersCommandHandler } from './set-filters.command.handler.js'
import { SetFormFieldFilterCommandHandler } from './set-form-field-filter.command.handler.js'
import { SetFormFieldRequirementsCommandHandler } from './set-form-field-requirements.command.handler.js'
import { SetFormFieldVisibilityCommandHandler } from './set-form-field-visibility.command.handler.js'
import { SetFormFieldsOrderCommandHandler } from './set-form-fields-order.command.handler.js'
Expand Down Expand Up @@ -104,4 +105,5 @@ export const commandHandlers = [
SetGalleryFieldCommandHandler,
UpdateFormCommandHandler,
RestoreRecordCommandHandler,
SetFormFieldFilterCommandHandler,
]
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 ITableRepository } from '@undb/core'
import { SetFormFieldFilterCommandHandler as DomainHandler, SetFormFieldFilterCommand } from '@undb/cqrs'
import { InjectTableRepository } from '../adapters/sqlite/table-sqlite.repository.js'

@CommandHandler(SetFormFieldFilterCommand)
export class SetFormFieldFilterCommandHandler
extends DomainHandler
implements ICommandHandler<SetFormFieldFilterCommand, void>
{
constructor(
@InjectTableRepository()
protected readonly tableRepo: ITableRepository,
) {
super(tableRepo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ export class NestUserSqliteRepository extends UserSqliteRepository {
count(spec: UserSpecification | null): Promise<number> {
return super.count(spec)
}

@UseRequestContext()
updateOneById(id: string, spec: UserSpecification): Promise<void> {
return super.updateOneById(id, spec)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { CommandHandler } from '@nestjs/cqrs'
import type { ClsStore, IClsService } from '@undb/core'
import { type IUserRepository } from '@undb/core'
import { InviteCommand, InviteCommandHandler } from '@undb/cqrs'
import { type IInvitationRepository } from '@undb/integrations'
import { ClsService } from 'nestjs-cls'
import { InjectUserRepository } from '../../core/user/adapters/index.js'
import { InjectInvitationRepository } from '../adapters/invitation-sqlite.repository.js'

@CommandHandler(InviteCommand)
Expand All @@ -12,8 +14,10 @@ export class NestInviteCommandHandler extends InviteCommandHandler {
constructor(
@InjectInvitationRepository()
protected readonly repo: IInvitationRepository,
@InjectUserRepository()
protected readonly userRepo: IUserRepository,
protected readonly cls: ClsService<ClsStore>,
) {
super(repo, cls as IClsService<ClsStore>)
super(repo, userRepo, cls as IClsService<ClsStore>)
}
}
7 changes: 5 additions & 2 deletions apps/backend/src/invitation/invitation-mail.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'
import { getInvitationURL, type IInvitationMailService, type Invitation } from '@undb/integrations'
import { type IInvitationMailService, type Invitation } from '@undb/integrations'
import { InjectPinoLogger, PinoLogger } from 'nestjs-pino'
import { joinURL } from 'ufo'
import { BaseConfigService } from '../configs/base-config.service.js'
import { type IMailService } from '../mail/mail.interface.js'
import { InjectMailService } from '../mail/providers.js'
Expand All @@ -17,13 +18,15 @@ export class InvitationMailService implements IInvitationMailService {
async send(invitation: Invitation): Promise<void> {
try {
const host = this.config.host
const url = joinURL(host, 'api', 'invitations', invitation.id.value, 'accept')
await this.mailService.sendMail({
to: invitation.email.unpack(),
subject: 'Invitation',
template: 'invite',
context: {
email: invitation.email.unpack(),
url: getInvitationURL(host, invitation.id.value),
url,
invitedBy: invitation.invitedByProfile.profile.username,
},
})
} catch (error) {
Expand Down
25 changes: 25 additions & 0 deletions apps/backend/src/invitation/invitation.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Controller, Get, Param, Res } from '@nestjs/common'
import { CommandBus } from '@nestjs/cqrs'
import { AcceptInvitationCommand } from '@undb/cqrs'
import { type IInvitationRepository } from '@undb/integrations'
import { type Response } from 'express'
import { InjectInvitationRepository } from './adapters/invitation-sqlite.repository.js'

@Controller('invitations')
export class InvitationController {
constructor(
private readonly commandBus: CommandBus,
@InjectInvitationRepository()
private readonly repo: IInvitationRepository,
) {}

@Get('/:id/accept')
public async accept(@Res() res: Response, @Param('id') id: string) {
const cmd = new AcceptInvitationCommand({ id })
await this.commandBus.execute(cmd)

const invitation = (await this.repo.findOneById(id)).unwrap()

res.redirect('/register?email=' + invitation.email.unpack())
}
}
5 changes: 4 additions & 1 deletion apps/backend/src/invitation/invitation.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Module } from '@nestjs/common'
import { CqrsModule } from '@nestjs/cqrs'
import { UserModule } from '../core/user/user.module.js'
import { adapters } from './adapters/index.js'
import { commands } from './commands/index.js'
import { InvitationMailService } from './invitation-mail.service.js'
import { InvitationController } from './invitation.controller.js'
import { NestInvitationService } from './invitation.service.js'
import { queries } from './queries/index.js'
import { sagas } from './sagas/index.js'

@Module({
imports: [CqrsModule],
imports: [CqrsModule, UserModule],
controllers: [InvitationController],
providers: [...commands, ...queries, ...sagas, ...adapters, NestInvitationService, InvitationMailService],
})
export class InvitationModule {}
3 changes: 2 additions & 1 deletion apps/backend/src/mail/templates/invite.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<h2 class='text-gray-700 dark:text-gray-200'>Hi {{email}},</h2>

<p class='mt-2 leading-loose text-gray-600 dark:text-gray-300'>
Alicia has invited you to join
{{invitedBy}}
has invited you to join
<span class='font-semibold'>undb</span>.
</p>

Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"@types/detect-port": "^1.3.3",
"@undb/eslint-config": "^0.0.0",
"detect-port": "^1.5.1",
"electron": "^25.4.0",
"electron": "^26.0.0",
"electron-builder": "^24.6.3",
"electron-is-dev": "^2.0.0",
"typescript": "^5.1.6",
"vite": "^4.4.8",
"vite": "^4.4.9",
"vite-plugin-electron": "^0.12.0",
"vite-plugin-electron-renderer": "^0.14.5",
"wait-port": "^1.0.4"
Expand Down
Loading

0 comments on commit 8cd305e

Please sign in to comment.