From 31ad975a6cdbbcd1f3c8e0932fc90c4653c58153 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 17 May 2024 18:47:14 +0800 Subject: [PATCH 1/4] fix: add missing parameters --- .../src/features/selection/selection.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/nestjs-backend/src/features/selection/selection.service.ts b/apps/nestjs-backend/src/features/selection/selection.service.ts index eef681078d..8af767099b 100644 --- a/apps/nestjs-backend/src/features/selection/selection.service.ts +++ b/apps/nestjs-backend/src/features/selection/selection.service.ts @@ -90,10 +90,11 @@ export class SelectionService { } private async columnSelectionToIds(tableId: string, query: IRangesToIdQuery): Promise { - const { type, viewId, ranges } = query; + const { type, viewId, ranges, excludeFieldIds } = query; const result = await this.fieldService.getDocIdsByQuery(tableId, { viewId, filterHidden: true, + excludeFieldIds, }); if (type === RangeType.Rows) { @@ -657,6 +658,7 @@ export class SelectionService { const fields = await this.fieldService.getFieldInstances(tableId, { viewId, filterHidden: true, + excludeFieldIds: rangesRo.excludeFieldIds, }); const tableSize: [number, number] = [fields.length, rowCountInView]; From b634a14f70c940bb7225692892d9122434da2cd2 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 17 May 2024 18:48:01 +0800 Subject: [PATCH 2/4] chore: rename error words --- ...permisison.decorator.ts => disabled-permission.decorator.ts} | 0 apps/nestjs-backend/src/features/auth/guard/permission.guard.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename apps/nestjs-backend/src/features/auth/decorators/{disabled-permisison.decorator.ts => disabled-permission.decorator.ts} (100%) diff --git a/apps/nestjs-backend/src/features/auth/decorators/disabled-permisison.decorator.ts b/apps/nestjs-backend/src/features/auth/decorators/disabled-permission.decorator.ts similarity index 100% rename from apps/nestjs-backend/src/features/auth/decorators/disabled-permisison.decorator.ts rename to apps/nestjs-backend/src/features/auth/decorators/disabled-permission.decorator.ts diff --git a/apps/nestjs-backend/src/features/auth/guard/permission.guard.ts b/apps/nestjs-backend/src/features/auth/guard/permission.guard.ts index 3969b0b5c7..e308fdffee 100644 --- a/apps/nestjs-backend/src/features/auth/guard/permission.guard.ts +++ b/apps/nestjs-backend/src/features/auth/guard/permission.guard.ts @@ -4,7 +4,7 @@ import { Reflector } from '@nestjs/core'; import { type PermissionAction } from '@teable/core'; import { ClsService } from 'nestjs-cls'; import type { IClsStore } from '../../../types/cls'; -import { IS_DISABLED_PERMISSION } from '../decorators/disabled-permisison.decorator'; +import { IS_DISABLED_PERMISSION } from '../decorators/disabled-permission.decorator'; import { PERMISSIONS_KEY } from '../decorators/permissions.decorator'; import { IS_PUBLIC_KEY } from '../decorators/public.decorator'; import type { IResourceMeta } from '../decorators/resource_meta.decorator'; From e85d8687fb3eb1c9df82a0b7480cc5b052a0e33c Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 17 May 2024 18:48:31 +0800 Subject: [PATCH 3/4] chore: optimize some bugs and parameters --- apps/nestjs-backend/src/share-db/share-db.adapter.ts | 3 +++ packages/core/src/models/field/field.schema.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/apps/nestjs-backend/src/share-db/share-db.adapter.ts b/apps/nestjs-backend/src/share-db/share-db.adapter.ts index bae5cab8db..1bdb4b5cf0 100644 --- a/apps/nestjs-backend/src/share-db/share-db.adapter.ts +++ b/apps/nestjs-backend/src/share-db/share-db.adapter.ts @@ -79,6 +79,9 @@ export class ShareDbAdapter extends ShareDb.DB { projection, undefined, (error, snapshots) => { + if (error) { + return callback(error, []); + } callback( error, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/packages/core/src/models/field/field.schema.ts b/packages/core/src/models/field/field.schema.ts index ded63a6a3e..fc5a3157f4 100644 --- a/packages/core/src/models/field/field.schema.ts +++ b/packages/core/src/models/field/field.schema.ts @@ -385,6 +385,7 @@ export const getFieldsQuerySchema = z.object({ description: 'The id of the view.', }), filterHidden: z.coerce.boolean().optional(), + filterDenied: z.coerce.boolean().optional(), excludeFieldIds: z.array(z.string().startsWith(IdPrefix.Field)).optional(), }); From 04a5ae517c857cf07d94abc8d0bd40d07fab328d Mon Sep 17 00:00:00 2001 From: Boris Date: Mon, 20 May 2024 10:44:46 +0800 Subject: [PATCH 4/4] fix: getSnapshot trigger getSnapshotBulk --- .../src/share-db/share-db.adapter.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/nestjs-backend/src/share-db/share-db.adapter.ts b/apps/nestjs-backend/src/share-db/share-db.adapter.ts index 1bdb4b5cf0..d081a577fb 100644 --- a/apps/nestjs-backend/src/share-db/share-db.adapter.ts +++ b/apps/nestjs-backend/src/share-db/share-db.adapter.ts @@ -188,6 +188,7 @@ export class ShareDbAdapter extends ShareDb.DB { callback(null, this.snapshots2Map(snapshots)); } } catch (err) { + this.logger.error(err); callback(exceptionParse(err as Error)); } } @@ -196,16 +197,21 @@ export class ShareDbAdapter extends ShareDb.DB { collection: string, id: string, projection: IProjection | undefined, - options: unknown, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options: any, callback: (err: unknown, data?: Snapshot) => void ) { - this.getSnapshotBulk(collection, [id], projection, options, (err, data) => { - if (err) { - callback(err); - } else { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - callback(null, data![id]); - } + await this.cls.runWith(this.cls.get(), async () => { + this.cls.set('cookie', options.cookie); + this.cls.set('shareViewId', options.shareId); + this.getSnapshotBulk(collection, [id], projection, options, (err, data) => { + if (err) { + callback(err); + } else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + callback(null, data![id]); + } + }); }); }