diff --git a/src/components/features/types.ts b/src/components/features/types.ts index 4f8654a5..a1425481 100644 --- a/src/components/features/types.ts +++ b/src/components/features/types.ts @@ -3,7 +3,6 @@ export enum Feature { CollectionsEnabled = 'CollectionsEnabled', ColorPalettesEnabled = 'ColorPalettesEnabled', UseIpV6 = 'UseIpV6', - UseLimitedView = 'UseLimitedView', WorkbookIsolationEnabled = 'WorkbookIsolationEnabled', } diff --git a/src/configs/opensource/common.ts b/src/configs/opensource/common.ts index b9e804f5..a5af33a7 100644 --- a/src/configs/opensource/common.ts +++ b/src/configs/opensource/common.ts @@ -8,7 +8,6 @@ export const features: FeaturesConfig = { [Feature.CollectionsEnabled]: true, [Feature.ColorPalettesEnabled]: true, [Feature.UseIpV6]: false, - [Feature.UseLimitedView]: true, [Feature.WorkbookIsolationEnabled]: true, }; diff --git a/src/db/migrations/20250116093622_make_entry_scope_not_nullable.ts b/src/db/migrations/20250116093622_make_entry_scope_not_nullable.ts new file mode 100644 index 00000000..ddb302ae --- /dev/null +++ b/src/db/migrations/20250116093622_make_entry_scope_not_nullable.ts @@ -0,0 +1,15 @@ +import type {Knex} from 'knex'; + +export async function up(knex: Knex): Promise { + return knex.raw(` + ALTER TABLE entries + ALTER COLUMN scope SET NOT NULL; + `); +} + +export async function down(knex: Knex): Promise { + return knex.raw(` + ALTER TABLE entries + ALTER COLUMN scope DROP NOT NULL; + `); +} diff --git a/src/db/models/lock/index.ts b/src/db/models/lock/index.ts index 2465ebee..5c79f40f 100644 --- a/src/db/models/lock/index.ts +++ b/src/db/models/lock/index.ts @@ -4,7 +4,6 @@ import {DBError, transaction} from 'objection'; import PG_ERRORS from 'pg-error-constants'; import {Model} from '../..'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {CURRENT_TIMESTAMP} from '../../../const'; import US_ERRORS from '../../../const/us-error-constants'; import {WorkbookPermission} from '../../../entities/workbook'; @@ -444,9 +443,7 @@ class Lock extends Model { if (permission === 'edit') { workbookPermission = WorkbookPermission.Update; } else { - workbookPermission = isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View; + workbookPermission = WorkbookPermission.LimitedView; } await checkWorkbookPermission({ diff --git a/src/db/models/new/entry/index.ts b/src/db/models/new/entry/index.ts index 6c0d0dd0..7f3930cc 100644 --- a/src/db/models/new/entry/index.ts +++ b/src/db/models/new/entry/index.ts @@ -110,7 +110,7 @@ export class Entry extends Model { }; } - [EntryColumn.Scope]!: Nullable; + [EntryColumn.Scope]!: EntryScope; [EntryColumn.Type]!: string; [EntryColumn.Key]!: Nullable; [EntryColumn.InnerMeta]!: Nullable>; diff --git a/src/services/entry/actions/create-in-workbook.ts b/src/services/entry/actions/create-in-workbook.ts index 87051d5a..1e4546b4 100644 --- a/src/services/entry/actions/create-in-workbook.ts +++ b/src/services/entry/actions/create-in-workbook.ts @@ -201,7 +201,6 @@ export async function createEntryInWorkbook( if (includePermissionsInfo) { permissions = getEntryPermissionsByWorkbook({ - ctx, workbook, scope: resultEntry.scope, }); diff --git a/src/services/entry/actions/get-entry-relations.ts b/src/services/entry/actions/get-entry-relations.ts index 9f840a1b..66ac561e 100644 --- a/src/services/entry/actions/get-entry-relations.ts +++ b/src/services/entry/actions/get-entry-relations.ts @@ -141,7 +141,6 @@ export async function getEntryRelations( return { ...item, permissions: getEntryPermissionsByWorkbook({ - ctx, workbook, scope: item.scope, }), diff --git a/src/services/new/collection/get-collection-breadcrumbs.ts b/src/services/new/collection/get-collection-breadcrumbs.ts index 5e6b6991..12389e89 100644 --- a/src/services/new/collection/get-collection-breadcrumbs.ts +++ b/src/services/new/collection/get-collection-breadcrumbs.ts @@ -1,6 +1,5 @@ import {AppError} from '@gravity-ui/nodekit'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {US_ERRORS} from '../../../const'; import {CollectionPermission} from '../../../entities/collection'; import Utils from '../../../utils'; @@ -59,9 +58,7 @@ export const getCollectionBreadcrumbs = async ( await collectionInstance.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); if (includePermissionsInfo) { diff --git a/src/services/new/collection/get-collection-content.ts b/src/services/new/collection/get-collection-content.ts index d63ae347..d91212d9 100644 --- a/src/services/new/collection/get-collection-content.ts +++ b/src/services/new/collection/get-collection-content.ts @@ -1,6 +1,5 @@ import {AppError} from '@gravity-ui/nodekit'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {US_ERRORS} from '../../../const'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {CollectionPermission} from '../../../entities/collection'; @@ -93,9 +92,7 @@ export const getCollectionContent = async ( await collection.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); } } @@ -149,9 +146,7 @@ export const getCollectionContent = async ( try { await collection.checkPermission({ parentIds: contentParentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); return collection; diff --git a/src/services/new/collection/get-collections-list-by-ids.ts b/src/services/new/collection/get-collections-list-by-ids.ts index 0cfbcf49..0f6ad67d 100644 --- a/src/services/new/collection/get-collections-list-by-ids.ts +++ b/src/services/new/collection/get-collections-list-by-ids.ts @@ -1,4 +1,3 @@ -import {Feature, isEnabledFeature} from '../../../components/features'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {CollectionPermission} from '../../../entities/collection'; import {CollectionInstance} from '../../../registry/common/entities/collection/types'; @@ -60,9 +59,7 @@ export const getCollectionsListByIds = async ( const promise = collection .checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }) .then(() => { acceptedCollectionsMap.set(collection.model, parentIds); diff --git a/src/services/new/collection/utils/check-and-set-collections-permission.ts b/src/services/new/collection/utils/check-and-set-collections-permission.ts index 0dccb3e7..1f9a057a 100644 --- a/src/services/new/collection/utils/check-and-set-collections-permission.ts +++ b/src/services/new/collection/utils/check-and-set-collections-permission.ts @@ -1,4 +1,3 @@ -import {Feature, isEnabledFeature} from '../../../../components/features'; import {CollectionPermission} from '../../../../entities/collection'; import {CollectionInstance} from '../../../../registry/common/entities/collection/types'; import {ServiceArgs} from '../../types'; @@ -38,10 +37,8 @@ export const checkAndSetCollectionPermission = async ( if (permission) { localPermission = permission; - } else if (isEnabledFeature(ctx, Feature.UseLimitedView)) { - localPermission = CollectionPermission.LimitedView; } else { - localPermission = CollectionPermission.View; + localPermission = CollectionPermission.LimitedView; } if (collectionInstance.model.parentId !== null) { diff --git a/src/services/new/entry/get-entry-by-key.ts b/src/services/new/entry/get-entry-by-key.ts index bc6c8682..f475e4f1 100644 --- a/src/services/new/entry/get-entry-by-key.ts +++ b/src/services/new/entry/get-entry-by-key.ts @@ -125,7 +125,6 @@ export const getEntryByKey = async ( if (includePermissionsInfo) { iamPermissions = getEntryPermissionsByWorkbook({ - ctx, workbook, scope: joinedEntryRevision[EntryColumn.Scope], }); diff --git a/src/services/new/entry/get-entry.ts b/src/services/new/entry/get-entry.ts index 6954a171..961a68d1 100644 --- a/src/services/new/entry/get-entry.ts +++ b/src/services/new/entry/get-entry.ts @@ -147,7 +147,6 @@ export const getEntry = async ( if (includePermissionsInfo) { iamPermissions = getEntryPermissionsByWorkbook({ - ctx, workbook, scope: joinedEntryRevisionFavorite[EntryColumn.Scope], }); diff --git a/src/services/new/entry/utils/filter-entries-by-permission.ts b/src/services/new/entry/utils/filter-entries-by-permission.ts index 31b642a4..70d3fb6a 100644 --- a/src/services/new/entry/utils/filter-entries-by-permission.ts +++ b/src/services/new/entry/utils/filter-entries-by-permission.ts @@ -104,7 +104,6 @@ export const filterEntriesByPermission = async ( if (workbook) { const permissions = getEntryPermissionsByWorkbook({ - ctx, workbook, scope: entry.scope, }); diff --git a/src/services/new/structure-item/get-structure-items.ts b/src/services/new/structure-item/get-structure-items.ts index c45a1a5b..99f5de06 100644 --- a/src/services/new/structure-item/get-structure-items.ts +++ b/src/services/new/structure-item/get-structure-items.ts @@ -1,4 +1,3 @@ -import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CollectionModel} from '../../../db/models/new/collection'; import {CollectionPermission} from '../../../entities/collection'; @@ -118,9 +117,7 @@ export const getStructureItems = async ( await collection.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); } } diff --git a/src/services/new/structure-item/utils.ts b/src/services/new/structure-item/utils.ts index aa20ff37..ab93c50e 100644 --- a/src/services/new/structure-item/utils.ts +++ b/src/services/new/structure-item/utils.ts @@ -1,7 +1,6 @@ import {AppContext, AppError} from '@gravity-ui/nodekit'; import {raw} from 'objection'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {US_ERRORS} from '../../../const'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; @@ -140,16 +139,12 @@ export const processPermissions = async ({ if (isWorkbookInstance(item)) { await item.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View, + permission: WorkbookPermission.LimitedView, }); } else { await item.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); } diff --git a/src/services/new/workbook/get-workbook-content.ts b/src/services/new/workbook/get-workbook-content.ts index aa7eb06a..729c7d7c 100644 --- a/src/services/new/workbook/get-workbook-content.ts +++ b/src/services/new/workbook/get-workbook-content.ts @@ -1,4 +1,3 @@ -import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {DEFAULT_PAGE, DEFAULT_PAGE_SIZE} from '../../../const'; import {EntryScope} from '../../../db/models/new/entry/types'; @@ -131,7 +130,7 @@ export const getWorkbookContent = async ( isDeleted: false, }); - if (isEnabledFeature(ctx, Feature.UseLimitedView) && !workbook.permissions?.view) { + if (!workbook.permissions?.view) { builder.whereNotIn('scope', ['dataset', 'connection']); } if (createdBy) { @@ -178,7 +177,6 @@ export const getWorkbookContent = async ( if (includePermissionsInfo) { permissions = getEntryPermissionsByWorkbook({ - ctx, workbook, scope: entry.scope, }); diff --git a/src/services/new/workbook/get-workbook.ts b/src/services/new/workbook/get-workbook.ts index b0df3183..d73539f5 100644 --- a/src/services/new/workbook/get-workbook.ts +++ b/src/services/new/workbook/get-workbook.ts @@ -1,6 +1,5 @@ import {AppError} from '@gravity-ui/nodekit'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; @@ -93,9 +92,7 @@ export const getWorkbook = async await workbook.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View, + permission: WorkbookPermission.LimitedView, }); if (includePermissionsInfo) { diff --git a/src/services/new/workbook/get-workbooks-list-by-ids.ts b/src/services/new/workbook/get-workbooks-list-by-ids.ts index c957740f..20d6adfe 100644 --- a/src/services/new/workbook/get-workbooks-list-by-ids.ts +++ b/src/services/new/workbook/get-workbooks-list-by-ids.ts @@ -1,4 +1,3 @@ -import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import {WorkbookPermission} from '../../../entities/workbook'; @@ -82,9 +81,7 @@ export const getWorkbooksListByIds = async ( const promise = workbook .checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View, + permission: WorkbookPermission.LimitedView, }) .then(() => { acceptedWorkbooksMap.set(workbook.model, parentIds); diff --git a/src/services/new/workbook/get-workbooks-list.ts b/src/services/new/workbook/get-workbooks-list.ts index 7aef0cb4..9751c759 100644 --- a/src/services/new/workbook/get-workbooks-list.ts +++ b/src/services/new/workbook/get-workbooks-list.ts @@ -1,6 +1,5 @@ import {AppError} from '@gravity-ui/nodekit'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {DEFAULT_PAGE, DEFAULT_PAGE_SIZE, US_ERRORS} from '../../../const'; import {CollectionModel} from '../../../db/models/new/collection'; @@ -123,9 +122,7 @@ export const getWorkbooksList = async ( await collection.checkPermission({ parentIds: parents.slice(1).map((model) => model.collectionId), - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? CollectionPermission.LimitedView - : CollectionPermission.View, + permission: CollectionPermission.LimitedView, }); } } @@ -177,9 +174,7 @@ export const getWorkbooksList = async ( try { await workbook.checkPermission({ parentIds, - permission: isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View, + permission: WorkbookPermission.LimitedView, }); return workbook; diff --git a/src/services/new/workbook/utils/get-entry-permissions-by-workbook.ts b/src/services/new/workbook/utils/get-entry-permissions-by-workbook.ts index 83502f49..fa2e88ba 100644 --- a/src/services/new/workbook/utils/get-entry-permissions-by-workbook.ts +++ b/src/services/new/workbook/utils/get-entry-permissions-by-workbook.ts @@ -1,25 +1,18 @@ -import {AppContext} from '@gravity-ui/nodekit'; - -import {Feature, isEnabledFeature} from '../../../../components/features'; import {EntryScope} from '../../../../db/models/new/entry/types'; import {Permissions} from '../../../../entities/workbook'; import type {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import type {EntryScope as EntryScopeType} from '../../../../types/models'; export const getEntryPermissionsByWorkbook = ({ - ctx, workbook, scope, }: { - ctx: AppContext; workbook: WorkbookInstance; scope?: EntryScopeType | null; }) => { const permissions = workbook.permissions as Permissions; - const view = isEnabledFeature(ctx, Feature.UseLimitedView) - ? permissions.limitedView - : permissions.view; + const view = permissions.limitedView; const mappedPermission = { execute: view, diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 969c904f..367c7561 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -473,7 +473,7 @@ export class Utils { .join(''); } - static isFileConnection(entry: {scope: Nullable; type: string}) { + static isFileConnection(entry: {scope: EntryScope; type: string}) { const fileConnectionTypes: string[] = [ EntryType.File, EntryType.GsheetsV2, @@ -485,7 +485,7 @@ export class Utils { ); } - static checkFileConnectionsExistence(entries: {scope: Nullable; type: string}[]) { + static checkFileConnectionsExistence(entries: {scope: EntryScope; type: string}[]) { return entries.some((entry) => { return Utils.isFileConnection(entry); });