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 3969b0b5c..e308fdffe 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'; diff --git a/apps/nestjs-backend/src/features/selection/selection.service.ts b/apps/nestjs-backend/src/features/selection/selection.service.ts index eef681078..8af767099 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]; 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 bae5cab8d..d081a577f 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 @@ -185,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)); } } @@ -193,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]); + } + }); }); } diff --git a/packages/core/src/models/field/field.schema.ts b/packages/core/src/models/field/field.schema.ts index ded63a6a3..fc5a3157f 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(), });