Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: sharedb work flow #606

Merged
merged 7 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/nestjs-backend/src/features/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class AuthController {

@Get('/user/me')
async me(@Req() request: Express.Request) {
return { ...request.user!, _session_ticket: request.sessionID };
return request.user;
}

@Patch('/change-password')
Expand Down
5 changes: 0 additions & 5 deletions apps/nestjs-backend/src/features/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Module } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { PassportModule } from '@nestjs/passport';
import { AccessTokenModule } from '../access-token/access-token.module';
import { UserModule } from '../user/user.module';
Expand All @@ -26,10 +25,6 @@ import { SessionStrategy } from './strategies/session.strategy';
AuthService,
LocalStrategy,
SessionStrategy,
{
provide: APP_GUARD,
useClass: AuthGuard,
},
AuthGuard,
SessionSerializer,
SessionStoreService,
Expand Down
10 changes: 1 addition & 9 deletions apps/nestjs-backend/src/features/auth/permission.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { Global, Module } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { PermissionGuard } from './guard/permission.guard';
import { PermissionService } from './permission.service';

@Global()
@Module({
providers: [
PermissionService,
PermissionGuard,
{
provide: APP_GUARD,
useClass: PermissionGuard,
},
],
providers: [PermissionService, PermissionGuard],
exports: [PermissionService, PermissionGuard],
})
export class PermissionModule {}
41 changes: 0 additions & 41 deletions apps/nestjs-backend/src/features/field/field-permission.service.ts

This file was deleted.

9 changes: 1 addition & 8 deletions apps/nestjs-backend/src/features/field/field.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type { IClsStore } from '../../types/cls';
import { isNotHiddenField } from '../../utils/is-not-hidden-field';
import { convertNameToValidCharacter } from '../../utils/name-conversion';
import { BatchService } from '../calculation/batch.service';
import { FieldPermissionService } from './field-permission.service';
import type { IFieldInstance } from './model/factory';
import { createFieldInstanceByVo, rawField2FieldObj } from './model/factory';
import { dbType2knexFormat } from './util';
Expand All @@ -38,7 +37,6 @@ export class FieldService implements IReadonlyAdapterService {
private readonly batchService: BatchService,
private readonly prismaService: PrismaService,
private readonly cls: ClsService<IClsStore>,
private readonly fieldPermissionService: FieldPermissionService,
@InjectDbProvider() private readonly dbProvider: IDbProvider,
@InjectModel('CUSTOM_KNEX') private readonly knex: Knex
) {}
Expand Down Expand Up @@ -494,12 +492,7 @@ export class FieldService implements IReadonlyAdapterService {
}

async getDocIdsByQuery(tableId: string, query: IGetFieldsQuery) {
const fieldsQuery = await this.fieldPermissionService.getFieldsQueryWithPermission(
tableId,
query
);
const result = await this.getFieldsByQuery(tableId, fieldsQuery);

const result = await this.getFieldsByQuery(tableId, query);
return {
ids: result.map((field) => field.id),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,19 @@ export class FieldOpenApiController {
async deleteField(@Param('tableId') tableId: string, @Param('fieldId') fieldId: string) {
await this.fieldOpenApiService.deleteField(tableId, fieldId);
}

@Permissions('field|read')
@Get('/socket/snapshot-bulk')
async getSnapshotBulk(@Param('tableId') tableId: string, @Query('ids') ids: string[]) {
return this.fieldService.getSnapshotBulk(tableId, ids);
}

@Permissions('field|read')
@Get('/socket/doc-ids')
async getDocIds(
@Param('tableId') tableId: string,
@Query(new ZodValidationPipe(getFieldsQuerySchema)) query: IGetFieldsQuery
) {
return this.fieldService.getDocIdsByQuery(tableId, query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,23 @@ export class RecordOpenApiController {
): Promise<void> {
return await this.recordOpenApiService.deleteRecords(tableId, query.recordIds);
}

@Permissions('record|read')
@Get('/socket/snapshot-bulk')
async getSnapshotBulk(
@Param('tableId') tableId: string,
@Query('ids') ids: string[],
@Query('projection') projection?: { [fieldNameOrId: string]: boolean }
) {
return this.recordService.getSnapshotBulk(tableId, ids, projection);
}

@Permissions('record|read')
@Get('/socket/doc-ids')
async getDocIds(
@Param('tableId') tableId: string,
@Query(new ZodValidationPipe(getRecordsRoSchema), TqlPipe) query: IGetRecordsRo
) {
return this.recordService.getDocIdsByQuery(tableId, query);
}
}
124 changes: 0 additions & 124 deletions apps/nestjs-backend/src/features/record/record-permission.service.ts

This file was deleted.

Loading