@@ -2,11 +2,18 @@ import {AppError} from '@gravity-ui/nodekit';
22import { transaction } from 'objection' ;
33
44import { makeSchemaValidator } from '../../../components/validation-schema-compiler' ;
5- import { BiTrackingLogs , DEFAULT_QUERY_TIMEOUT , RETURN_COLUMNS , US_ERRORS } from '../../../const' ;
5+ import {
6+ ALLOWED_SCOPE_VALUES ,
7+ BiTrackingLogs ,
8+ DEFAULT_QUERY_TIMEOUT ,
9+ RETURN_COLUMNS ,
10+ US_ERRORS ,
11+ } from '../../../const' ;
612import Entry from '../../../db/models/entry' ;
713import Lock from '../../../db/models/lock' ;
14+ import { EntryColumn } from '../../../db/models/new/entry' ;
815import { WorkbookPermission } from '../../../entities/workbook' ;
9- import { DlsActions , EntryColumns , UsPermissions } from '../../../types/models' ;
16+ import { DlsActions , EntryColumns , EntryScope , UsPermissions } from '../../../types/models' ;
1017import Utils , { makeUserId } from '../../../utils' ;
1118import { ServiceArgs } from '../../new/types' ;
1219import { getWorkbook } from '../../new/workbook/get-workbook' ;
@@ -28,20 +35,32 @@ const validateArgs = makeSchemaValidator({
2835 useLegacyLogin : {
2936 type : 'boolean' ,
3037 } ,
38+ scope : {
39+ type : 'string' ,
40+ enum : ALLOWED_SCOPE_VALUES ,
41+ } ,
42+ types : {
43+ type : 'array' ,
44+ items : {
45+ type : 'string' ,
46+ } ,
47+ } ,
3148 } ,
3249} ) ;
3350
3451export type DeleteEntryData = {
3552 entryId : string ;
3653 lockToken ?: string ;
3754 useLegacyLogin ?: boolean ;
55+ scope ?: EntryScope ;
56+ types ?: string [ ] ;
3857} ;
3958
4059export async function deleteEntry (
4160 { ctx, skipValidation = false } : ServiceArgs ,
4261 args : DeleteEntryData ,
4362) {
44- const { entryId, lockToken, useLegacyLogin = false } = args ;
63+ const { entryId, lockToken, useLegacyLogin = false , scope , types } = args ;
4564
4665 ctx . log ( 'DELETE_ENTRY_REQUEST' , {
4766 entryId : Utils . encodeId ( entryId ) ,
@@ -66,6 +85,15 @@ export async function deleteEntry(
6685 entryId,
6786 isDeleted : false ,
6887 } )
88+ . where ( ( builder ) => {
89+ if ( scope ) {
90+ builder . andWhere ( { [ `${ Entry . tableName } .${ EntryColumn . Scope } ` ] : scope } ) ;
91+ }
92+
93+ if ( types ) {
94+ builder . whereIn ( [ `${ Entry . tableName } .${ EntryColumn . Type } ` ] , types ) ;
95+ }
96+ } )
6997 . first ( )
7098 . timeout ( DEFAULT_QUERY_TIMEOUT ) ;
7199
0 commit comments