diff --git a/.eslintrc b/.eslintrc index 3efbe7a5..85c7c03d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,15 +4,5 @@ "node": true, "jest": true }, - "root": true, - "overrides": [ - { - "files": ["*.ts"], - "rules": { - "@typescript-eslint/member-ordering": [0], - "import/order": [0], - "sort-imports": [0] - } - } - ] + "root": true } diff --git a/src/components/app-context.ts b/src/components/app-context.ts index 191c48a8..3fc23bcc 100644 --- a/src/components/app-context.ts +++ b/src/components/app-context.ts @@ -1,4 +1,5 @@ import type {NodeKit} from '@gravity-ui/nodekit'; + import type {Registry} from '../registry'; export function setRegistryToContext(nodekit: NodeKit, registry: R) { diff --git a/src/components/error-response-presenter.ts b/src/components/error-response-presenter.ts index 9609e27f..138c5045 100644 --- a/src/components/error-response-presenter.ts +++ b/src/components/error-response-presenter.ts @@ -2,9 +2,11 @@ // However the types described there are incorrect: const DBError: typeof dbErrors.DBError; // Due to incorrect types Typescript casts DBError as a constant. // DBError cannot be used as a type and typeof DBError does not infer the original type -import {DBError} from 'db-errors'; import {AppError} from '@gravity-ui/nodekit'; +import {DBError} from 'db-errors'; + import US_ERRORS from '../const/us-error-constants'; + const PG_ERRORS = require('pg-error-constants'); function getDBErrorCode(error: DBError): string { diff --git a/src/components/gateway/index.ts b/src/components/gateway/index.ts index e0240722..2eeee6c0 100644 --- a/src/components/gateway/index.ts +++ b/src/components/gateway/index.ts @@ -1,8 +1,9 @@ -import {NodeKit, AppError, AppContext} from '@gravity-ui/nodekit'; import {Request, Response} from '@gravity-ui/expresskit'; -import {GatewayConfig, Headers as DebugHeaders, GatewayError} from '@gravity-ui/gateway'; +import {Headers as DebugHeaders, GatewayConfig, GatewayError} from '@gravity-ui/gateway'; +import {AppContext, AppError, NodeKit} from '@gravity-ui/nodekit'; + import {IPV6_AXIOS_OPTIONS} from '../../utils/axios'; -import {isEnabledFeature, Feature} from '../features'; +import {Feature, isEnabledFeature} from '../features'; export const getGatewayConfig = ( nodekit: NodeKit, diff --git a/src/components/middlewares/auth-zitadel.ts b/src/components/middlewares/auth-zitadel.ts index ffb26719..8e58d047 100644 --- a/src/components/middlewares/auth-zitadel.ts +++ b/src/components/middlewares/auth-zitadel.ts @@ -1,8 +1,10 @@ -import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; -import {introspect} from '../../utils/zitadel'; import {IncomingHttpHeaders} from 'http'; + +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import {DL_AUTH_HEADER_KEY, DL_SERVICE_USER_ACCESS_TOKEN} from '../../const'; import {ZitadelServiceUser} from '../../types/zitadel'; +import {introspect} from '../../utils/zitadel'; export const authZitadel = async (req: Request, res: Response, next: NextFunction) => { const {ctx} = req; diff --git a/src/components/middlewares/check-read-only-mode.ts b/src/components/middlewares/check-read-only-mode.ts index 21176621..8d11f72c 100644 --- a/src/components/middlewares/check-read-only-mode.ts +++ b/src/components/middlewares/check-read-only-mode.ts @@ -1,4 +1,5 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import {US_ERRORS} from '../../const'; import {Feature, isEnabledFeature} from '../features'; diff --git a/src/components/middlewares/ctx.ts b/src/components/middlewares/ctx.ts index 39edd712..f726978b 100644 --- a/src/components/middlewares/ctx.ts +++ b/src/components/middlewares/ctx.ts @@ -1,6 +1,7 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; -import {resolvePrivatePermissions} from '../private-permissions'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import {DL_COMPONENT_HEADER} from '../../const'; +import {resolvePrivatePermissions} from '../private-permissions'; export const ctx = async (req: Request, res: Response, next: NextFunction) => { const { diff --git a/src/components/middlewares/decode-id.ts b/src/components/middlewares/decode-id.ts index abdcd953..1dca6f3a 100644 --- a/src/components/middlewares/decode-id.ts +++ b/src/components/middlewares/decode-id.ts @@ -1,7 +1,8 @@ -import Utils from '../../utils'; -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; import {AppError} from '@gravity-ui/nodekit'; + import US_ERRORS from '../../const/us-error-constants'; +import Utils from '../../utils'; export const decodeId = async (req: Request, _res: Response, next: NextFunction) => { try { diff --git a/src/components/middlewares/final-request-handler.ts b/src/components/middlewares/final-request-handler.ts index 6e611dc0..609c88a6 100644 --- a/src/components/middlewares/final-request-handler.ts +++ b/src/components/middlewares/final-request-handler.ts @@ -1,5 +1,6 @@ import {Request, Response} from '@gravity-ui/expresskit'; import {AppError} from '@gravity-ui/nodekit'; + import prepareErrorResponse from '../error-response-presenter'; export function logError(error: AppError, req: Request) { diff --git a/src/components/middlewares/resolve-special-tokens.ts b/src/components/middlewares/resolve-special-tokens.ts index d1d89ec3..9691c709 100644 --- a/src/components/middlewares/resolve-special-tokens.ts +++ b/src/components/middlewares/resolve-special-tokens.ts @@ -1,4 +1,5 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import {SYSTEM_USER, US_MASTER_TOKEN_HEADER} from '../../const'; function replaceDotsInLogin(login: string) { diff --git a/src/components/middlewares/resolve-tenant-id.ts b/src/components/middlewares/resolve-tenant-id.ts index 2ea5cf7f..509589a3 100644 --- a/src/components/middlewares/resolve-tenant-id.ts +++ b/src/components/middlewares/resolve-tenant-id.ts @@ -1,4 +1,4 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; export const resolveTenantId = async (req: Request, res: Response, next: NextFunction) => { const {tenantIdOverride} = req.ctx.config; diff --git a/src/components/middlewares/resolve-workbook-id.ts b/src/components/middlewares/resolve-workbook-id.ts index 61b5dc3a..4c5ef79d 100644 --- a/src/components/middlewares/resolve-workbook-id.ts +++ b/src/components/middlewares/resolve-workbook-id.ts @@ -1,8 +1,9 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; import {AppError} from '@gravity-ui/nodekit'; -import {US_ERRORS, DL_WORKBOOK_ID_HEADER} from '../../const'; -import Utils from '../../utils'; + import {Feature, isEnabledFeature} from '../../components/features'; +import {DL_WORKBOOK_ID_HEADER, US_ERRORS} from '../../const'; +import Utils from '../../utils'; export const resolveWorkbookId = (req: Request, res: Response, next: NextFunction) => { if (isEnabledFeature(req.ctx, Feature.WorkbookIsolationEnabled)) { diff --git a/src/components/middlewares/set-ci-env.ts b/src/components/middlewares/set-ci-env.ts index 979a4db2..aa91c961 100644 --- a/src/components/middlewares/set-ci-env.ts +++ b/src/components/middlewares/set-ci-env.ts @@ -1,4 +1,4 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; export const setCiEnv = (req: Request, res: Response, next: NextFunction) => { res.locals.userId = 'dev-user-id'; diff --git a/src/components/middlewares/wait-database.ts b/src/components/middlewares/wait-database.ts index ae29fe2a..f1c2af58 100644 --- a/src/components/middlewares/wait-database.ts +++ b/src/components/middlewares/wait-database.ts @@ -1,4 +1,5 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import {db} from '../../db'; export const waitDatabase = async (_req: Request, _res: Response, next: NextFunction) => { diff --git a/src/components/middlewares/x-dl-context.ts b/src/components/middlewares/x-dl-context.ts index 81374ed2..63891b87 100644 --- a/src/components/middlewares/x-dl-context.ts +++ b/src/components/middlewares/x-dl-context.ts @@ -1,4 +1,4 @@ -import {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import {NextFunction, Request, Response} from '@gravity-ui/expresskit'; export const dlContext = (req: Request, res: Response, next: NextFunction) => { res.locals.dlContext = req.headers['x-dl-context'] || '{}'; diff --git a/src/components/validation-schema-compiler.ts b/src/components/validation-schema-compiler.ts index 21026339..7b2b0dc6 100644 --- a/src/components/validation-schema-compiler.ts +++ b/src/components/validation-schema-compiler.ts @@ -1,14 +1,15 @@ 'use strict'; +import {AppError} from '@gravity-ui/nodekit'; import Ajv from 'ajv'; + import { + MAX_BRANDING_OBJECT_SYMBOLS, MAX_META_OBJECT_SYMBOLS, - MAX_UNVERSIONED_DATA_OBJECT_SYMBOLS, MAX_PRESET_DATA_OBJECT_SYMBOLS, - MAX_BRANDING_OBJECT_SYMBOLS, + MAX_UNVERSIONED_DATA_OBJECT_SYMBOLS, } from '../const'; import US_ERRORS from '../const/us-error-constants'; -import {AppError} from '@gravity-ui/nodekit'; const ajv = new Ajv({ allErrors: true, diff --git a/src/configs/common.ts b/src/configs/common.ts index 572cc8b0..6d909f18 100644 --- a/src/configs/common.ts +++ b/src/configs/common.ts @@ -1,5 +1,6 @@ -import {AppConfig} from '@gravity-ui/nodekit'; import {AuthPolicy} from '@gravity-ui/expresskit'; +import {AppConfig} from '@gravity-ui/nodekit'; + import {US_MASTER_TOKEN_HEADER} from '../const'; import Utils from '../utils'; diff --git a/src/configs/opensource/common.ts b/src/configs/opensource/common.ts index 719b6eba..57e85817 100644 --- a/src/configs/opensource/common.ts +++ b/src/configs/opensource/common.ts @@ -1,4 +1,5 @@ import {AppConfig} from '@gravity-ui/nodekit'; + import {Feature, FeaturesConfig} from '../../components/features/types'; import {DL_SERVICE_USER_ACCESS_TOKEN} from '../../const'; diff --git a/src/configs/opensource/development.ts b/src/configs/opensource/development.ts index 0c7b29a4..3050806b 100644 --- a/src/configs/opensource/development.ts +++ b/src/configs/opensource/development.ts @@ -1,4 +1,5 @@ import {AppConfig} from '@gravity-ui/nodekit'; + import {features} from './common'; export default { diff --git a/src/configs/opensource/int-testing.ts b/src/configs/opensource/int-testing.ts index 0c7b29a4..3050806b 100644 --- a/src/configs/opensource/int-testing.ts +++ b/src/configs/opensource/int-testing.ts @@ -1,4 +1,5 @@ import {AppConfig} from '@gravity-ui/nodekit'; + import {features} from './common'; export default { diff --git a/src/configs/opensource/prod.ts b/src/configs/opensource/prod.ts index 0c7b29a4..3050806b 100644 --- a/src/configs/opensource/prod.ts +++ b/src/configs/opensource/prod.ts @@ -1,4 +1,5 @@ import {AppConfig} from '@gravity-ui/nodekit'; + import {features} from './common'; export default { diff --git a/src/console.ts b/src/console.ts index 74f6158a..3f2c8fe6 100644 --- a/src/console.ts +++ b/src/console.ts @@ -1,9 +1,11 @@ import repl = require('repl'); + +import {raw, transaction} from 'objection'; + +import {Model, db, getId} from './db'; import Entry from './db/models/entry'; import Tenant from './db/models/tenant'; import Utils from './utils'; -import {raw, transaction} from 'objection'; -import {db, Model, getId} from './db'; async function runConsole(): Promise { process.env.REPL_MODE = '1'; diff --git a/src/controllers/collections.ts b/src/controllers/collections.ts index 90a97dd0..58d71090 100644 --- a/src/controllers/collections.ts +++ b/src/controllers/collections.ts @@ -1,29 +1,30 @@ import {Request, Response} from '@gravity-ui/expresskit'; + import {prepareResponseAsync} from '../components/response-presenter'; -import Utils from '../utils'; import { + Mode, + OrderDirection, + OrderField, createCollection, + deleteCollections, getCollection, + getCollectionBreadcrumbs, getCollectionContent, + getCollectionsListByIds, getRootCollectionPermissions, - getCollectionBreadcrumbs, moveCollection, moveCollectionsList, updateCollection, - OrderField, - OrderDirection, - Mode, - deleteCollections, - getCollectionsListByIds, } from '../services/new/collection'; import { - formatCollectionModel, - formatCollectionModelsList, formatCollection, - formatGetCollectionBreadcrumbs, formatCollectionContent, + formatCollectionModel, + formatCollectionModelsList, formatCollectionWithOperation, + formatGetCollectionBreadcrumbs, } from '../services/new/collection/formatters'; +import Utils from '../utils'; export default { create: async (req: Request, res: Response) => { diff --git a/src/controllers/color-palettes.ts b/src/controllers/color-palettes.ts index 186d1540..922dea40 100644 --- a/src/controllers/color-palettes.ts +++ b/src/controllers/color-palettes.ts @@ -1,13 +1,14 @@ import {Request, Response} from '@gravity-ui/expresskit'; + import {prepareResponseAsync} from '../components/response-presenter'; import { deleteColorPalette, - getColorPalettesList, getColorPalette, + getColorPalettesList, updateColorPalette, } from '../services/color-palettes'; import {createColorPalette} from '../services/color-palettes/create-color-palette'; -import {formatColorPaletteList, formatColorPalette} from '../services/color-palettes/formatters'; +import {formatColorPalette, formatColorPaletteList} from '../services/color-palettes/formatters'; export default { create: async (req: Request, res: Response) => { diff --git a/src/controllers/entries.ts b/src/controllers/entries.ts index 8fa417b7..ac3b55b7 100644 --- a/src/controllers/entries.ts +++ b/src/controllers/entries.ts @@ -1,37 +1,38 @@ -import EntryService from '../services/entry.service'; import {Request, Response} from '@gravity-ui/expresskit'; + import {prepareResponseAsync} from '../components/response-presenter'; -import Utils from '../utils'; import {US_MASTER_TOKEN_HEADER} from '../const'; -import NavigationService from '../services/navigation.service'; -import * as ST from '../types/services.types'; +import {EntryScope} from '../db/models/new/entry/types'; import { - deleteEntry, DeleteEntryData, - renameEntry, - updateEntry, - getEntryRevisions, GetEntryRevisionsData, + RelationDirection, + deleteEntry, getEntryRelations, + getEntryRevisions, + renameEntry, switchRevisionEntry, - RelationDirection, + updateEntry, } from '../services/entry'; +import EntryService from '../services/entry.service'; +import NavigationService from '../services/navigation.service'; import { - getEntry, GetEntryArgs, - getEntryMeta, - getEntryMetaPrivate, GetEntryMetaPrivateArgs, - copyEntryToWorkbook, copyEntriesToWorkbook, + copyEntryToWorkbook, + getEntry, + getEntryMeta, + getEntryMetaPrivate, } from '../services/new/entry'; import { - formatGetEntryResponse, - formatGetEntryMetaResponse, - formatGetEntryMetaPrivateResponse, formatEntryModel, + formatGetEntryMetaPrivateResponse, + formatGetEntryMetaResponse, + formatGetEntryResponse, } from '../services/new/entry/formatters'; -import {EntryScope} from '../db/models/new/entry/types'; +import * as ST from '../types/services.types'; +import Utils from '../utils'; export default { getEntry: async (req: Request, res: Response) => { diff --git a/src/controllers/favorites.ts b/src/controllers/favorites.ts index 10bba9d3..8f827dd7 100644 --- a/src/controllers/favorites.ts +++ b/src/controllers/favorites.ts @@ -1,9 +1,10 @@ -import FavoriteService from '../services/favorite.service'; import {Request, Response} from '@gravity-ui/expresskit'; -import Utils from '../utils'; + import {prepareResponseAsync} from '../components/response-presenter'; -import * as ST from '../types/services.types'; import Entry from '../db/models/entry'; +import FavoriteService from '../services/favorite.service'; +import * as ST from '../types/services.types'; +import Utils from '../utils'; export default { getFavorites: async (req: Request, res: Response) => { diff --git a/src/controllers/helpers.ts b/src/controllers/helpers.ts index c4da43b8..58c2d4e0 100644 --- a/src/controllers/helpers.ts +++ b/src/controllers/helpers.ts @@ -1,6 +1,7 @@ -import {db} from '../db'; import {Request, Response} from '@gravity-ui/expresskit'; +import {db} from '../db'; + export default { ping: async (_: Request, res: Response) => { res.send({result: 'pong'}); diff --git a/src/controllers/locks.ts b/src/controllers/locks.ts index 53733b27..81c5cce2 100644 --- a/src/controllers/locks.ts +++ b/src/controllers/locks.ts @@ -1,6 +1,7 @@ import {Request, Response} from '@gravity-ui/expresskit'; -import LockService from '../services/lock.service'; + import {prepareResponseAsync} from '../components/response-presenter'; +import LockService from '../services/lock.service'; import * as ST from '../types/services.types'; export default { diff --git a/src/controllers/states.ts b/src/controllers/states.ts index b523fb5b..65880c18 100644 --- a/src/controllers/states.ts +++ b/src/controllers/states.ts @@ -1,4 +1,5 @@ import {Request, Response} from '@gravity-ui/expresskit'; + import {prepareResponseAsync} from '../components/response-presenter'; import {createState, getState} from '../services/new/state'; import {formatCreateStateResponse, formatGetStateResponse} from '../services/new/state/formatters'; diff --git a/src/controllers/structure-items.ts b/src/controllers/structure-items.ts index df8c72d5..174155d0 100644 --- a/src/controllers/structure-items.ts +++ b/src/controllers/structure-items.ts @@ -1,8 +1,9 @@ import {Request, Response} from '@gravity-ui/expresskit'; -import {getStructureItems, Mode, OrderDirection, OrderField} from '../services/new/structure-item'; -import Utils from '../utils'; + import {prepareResponseAsync} from '../components/response-presenter'; +import {Mode, OrderDirection, OrderField, getStructureItems} from '../services/new/structure-item'; import {formatStructureItems} from '../services/new/structure-item/formatters/format-structure-items'; +import Utils from '../utils'; export default { getStructureItems: async (req: Request, res: Response) => { diff --git a/src/controllers/workbooks.ts b/src/controllers/workbooks.ts index b9d85c1f..fb947906 100644 --- a/src/controllers/workbooks.ts +++ b/src/controllers/workbooks.ts @@ -1,35 +1,36 @@ import {Request, Response} from '@gravity-ui/expresskit'; + import {prepareResponseAsync} from '../components/response-presenter'; -import Utils from '../utils'; import { + OrderDirection, + OrderField, + copyWorkbook, + copyWorkbookTemplate, createWorkbook, + deleteWorkbooks, + getAllWorkbooks, getWorkbook, getWorkbookContent, getWorkbooksList, - updateWorkbook, moveWorkbook, moveWorkbooksList, - setWorkbookIsTemplate, - copyWorkbook, - copyWorkbookTemplate, - getAllWorkbooks, - OrderField, - OrderDirection, restoreWorkbook, - deleteWorkbooks, + setWorkbookIsTemplate, + updateWorkbook, } from '../services/new/workbook'; import { + formatGetWorkbookContent, + formatRestoreWorkbook, + formatSetWorkbookIsTemplate, + formatWorkbook, formatWorkbookModel, + formatWorkbookModelWithOperation, formatWorkbookModelsList, - formatWorkbook, formatWorkbookWithOperation, - formatWorkbookModelWithOperation, formatWorkbooksList, - formatSetWorkbookIsTemplate, - formatRestoreWorkbook, - formatGetWorkbookContent, } from '../services/new/workbook/formatters'; import {getWorkbooksListByIds} from '../services/new/workbook/get-workbooks-list-by-ids'; +import Utils from '../utils'; export default { create: async (req: Request, res: Response) => { diff --git a/src/db/init-db.ts b/src/db/init-db.ts index 6824fa40..b085ed23 100644 --- a/src/db/init-db.ts +++ b/src/db/init-db.ts @@ -1,6 +1,8 @@ import * as path from 'path'; + import type {NodeKit} from '@gravity-ui/nodekit'; import {initDB as initPosgresDB} from '@gravity-ui/postgreskit'; + import {AppEnv, DEFAULT_QUERY_TIMEOUT} from '../const'; import {getTestDsnList} from '../tests/int/db'; import Utils from '../utils'; diff --git a/src/db/models/entry/index.ts b/src/db/models/entry/index.ts index 9dd1b701..b6a1e17a 100644 --- a/src/db/models/entry/index.ts +++ b/src/db/models/entry/index.ts @@ -1,13 +1,15 @@ +import {AppError} from '@gravity-ui/nodekit'; import {transaction} from 'objection'; + import {Model, getId} from '../..'; +import {BiTrackingLogs, RETURN_COLUMNS, US_ERRORS} from '../../../const'; +import * as MT from '../../../types/models'; import Utils, {makeUserId} from '../../../utils'; +import Link from '../links'; import Revision from '../revision'; import Tenant from '../tenant'; -import Link from '../links'; -import {AppError} from '@gravity-ui/nodekit'; -import * as MT from '../../../types/models'; + import {validateCreateEntry, validateResolveTenantIdByEntryId} from './scheme'; -import {RETURN_COLUMNS, BiTrackingLogs, US_ERRORS} from '../../../const'; interface Entry extends MT.EntryColumns { revisions: any; // TODO: Figure out how to type a upsertGraph diff --git a/src/db/models/entry/scheme.ts b/src/db/models/entry/scheme.ts index bd37a522..00947348 100644 --- a/src/db/models/entry/scheme.ts +++ b/src/db/models/entry/scheme.ts @@ -1,5 +1,5 @@ import compileSchema from '../../../components/validation-schema-compiler'; -import {ALLOWED_SCOPE_VALUES, AJV_PATTERN_KEYS_NOT_OBJECT, ModeValues} from '../../../const'; +import {AJV_PATTERN_KEYS_NOT_OBJECT, ALLOWED_SCOPE_VALUES, ModeValues} from '../../../const'; export const validateCreateEntry = compileSchema({ type: 'object', diff --git a/src/db/models/favorite/index.ts b/src/db/models/favorite/index.ts index 7997232d..8c4bc244 100644 --- a/src/db/models/favorite/index.ts +++ b/src/db/models/favorite/index.ts @@ -1,21 +1,22 @@ +import {AppError} from '@gravity-ui/nodekit'; import {raw} from 'objection'; + import {Model} from '../..'; -import Entry from '../entry'; -import {Entry as EntryModel} from '../new/entry'; -import {AppError} from '@gravity-ui/nodekit'; +import {RETURN_FAVORITES_COLUMNS, US_ERRORS} from '../../../const'; +import {filterEntriesByPermission} from '../../../services/new/entry/utils'; +import {getWorkbook} from '../../../services/new/workbook'; import * as MT from '../../../types/models'; import {DlsActions} from '../../../types/models'; import Utils from '../../../utils'; +import Entry from '../entry'; +import {Entry as EntryModel} from '../new/entry'; + import { - validateGetFavorites, validateAddFavorite, validateDeleteFavorite, + validateGetFavorites, validateRenameFavorite, } from './scheme'; -import {RETURN_FAVORITES_COLUMNS, US_ERRORS} from '../../../const'; - -import {getWorkbook} from '../../../services/new/workbook'; -import {filterEntriesByPermission} from '../../../services/new/entry/utils'; interface FavoriteFields extends MT.FavoriteColumns { isLocked?: boolean; diff --git a/src/db/models/links/index.ts b/src/db/models/links/index.ts index 733b9e96..b26e0fb8 100644 --- a/src/db/models/links/index.ts +++ b/src/db/models/links/index.ts @@ -1,9 +1,11 @@ -import {Model} from '../..'; -import Utils from '../../../utils'; import {AppError} from '@gravity-ui/nodekit'; + +import {Model} from '../..'; +import {US_ERRORS} from '../../../const'; import * as MT from '../../../types/models'; +import Utils from '../../../utils'; + import {validateCreateLink} from './scheme'; -import {US_ERRORS} from '../../../const'; interface Links extends MT.LinksColumns {} class Links extends Model { diff --git a/src/db/models/lock/index.ts b/src/db/models/lock/index.ts index c90a1329..2465ebee 100644 --- a/src/db/models/lock/index.ts +++ b/src/db/models/lock/index.ts @@ -1,23 +1,25 @@ -import {transaction, DBError} from 'objection'; +import {AppContext, AppError} from '@gravity-ui/nodekit'; +import moment from 'moment'; +import {DBError, transaction} from 'objection'; import PG_ERRORS from 'pg-error-constants'; + import {Model} from '../..'; -import Utils from '../../../utils'; -import moment from 'moment'; -import {AppContext, AppError} from '@gravity-ui/nodekit'; -import * as MT from '../../../types/models'; -import US_ERRORS from '../../../const/us-error-constants'; +import {Feature, isEnabledFeature} from '../../../components/features'; import {CURRENT_TIMESTAMP} from '../../../const'; -import {Entry} from '../new/entry'; +import US_ERRORS from '../../../const/us-error-constants'; import {WorkbookPermission} from '../../../entities/workbook'; import {getWorkbook} from '../../../services/new/workbook'; import {checkWorkbookPermission} from '../../../services/new/workbook/utils/check-workbook-permission'; +import * as MT from '../../../types/models'; +import Utils from '../../../utils'; +import {Entry} from '../new/entry'; + import { - validateVerifyExistenceEntry, + validateExtendLockEntry, validateLockEntry, validateUnlockEntry, - validateExtendLockEntry, + validateVerifyExistenceEntry, } from './scheme'; -import {Feature, isEnabledFeature} from '../../../components/features'; interface Lock extends MT.LockColumns {} class Lock extends Model { @@ -70,69 +72,6 @@ class Lock extends Model { return result; } - private static async checkLockPermission({ - ctx, - entryId, - tenantId, - permission, - }: { - ctx: AppContext; - entryId: string; - tenantId: string; - permission: 'read' | 'edit'; - }) { - const registry = ctx.get('registry'); - const {accessServiceEnabled} = ctx.config; - - const entry = await Entry.query(Entry.replica) - .where({ - entryId, - tenantId, - isDeleted: false, - }) - .first() - .timeout(Entry.DEFAULT_QUERY_TIMEOUT); - - if (!entry) { - throw new AppError(US_ERRORS.NOT_EXIST_ENTRY, { - code: US_ERRORS.NOT_EXIST_ENTRY, - }); - } - - if (entry.workbookId) { - if (accessServiceEnabled) { - const workbook = await getWorkbook( - {ctx, skipCheckPermissions: true}, - {workbookId: entry.workbookId}, - ); - - let workbookPermission: WorkbookPermission; - if (permission === 'edit') { - workbookPermission = WorkbookPermission.Update; - } else { - workbookPermission = isEnabledFeature(ctx, Feature.UseLimitedView) - ? WorkbookPermission.LimitedView - : WorkbookPermission.View; - } - - await checkWorkbookPermission({ - ctx, - workbook, - permission: workbookPermission, - }); - } - } else if (ctx.config.dlsEnabled) { - const {DLS} = registry.common.classes.get(); - await DLS.checkPermission( - {ctx}, - { - entryId, - action: permission, - }, - ); - } - } - static async verifyExistence( {tenantId, entryId, requestedBy, isPrivateRoute, dlContext}: MT.VerifyExistenceConfig, ctx: MT.CTX, @@ -464,6 +403,69 @@ class Lock extends Model { return result; } + + private static async checkLockPermission({ + ctx, + entryId, + tenantId, + permission, + }: { + ctx: AppContext; + entryId: string; + tenantId: string; + permission: 'read' | 'edit'; + }) { + const registry = ctx.get('registry'); + const {accessServiceEnabled} = ctx.config; + + const entry = await Entry.query(Entry.replica) + .where({ + entryId, + tenantId, + isDeleted: false, + }) + .first() + .timeout(Entry.DEFAULT_QUERY_TIMEOUT); + + if (!entry) { + throw new AppError(US_ERRORS.NOT_EXIST_ENTRY, { + code: US_ERRORS.NOT_EXIST_ENTRY, + }); + } + + if (entry.workbookId) { + if (accessServiceEnabled) { + const workbook = await getWorkbook( + {ctx, skipCheckPermissions: true}, + {workbookId: entry.workbookId}, + ); + + let workbookPermission: WorkbookPermission; + if (permission === 'edit') { + workbookPermission = WorkbookPermission.Update; + } else { + workbookPermission = isEnabledFeature(ctx, Feature.UseLimitedView) + ? WorkbookPermission.LimitedView + : WorkbookPermission.View; + } + + await checkWorkbookPermission({ + ctx, + workbook, + permission: workbookPermission, + }); + } + } else if (ctx.config.dlsEnabled) { + const {DLS} = registry.common.classes.get(); + await DLS.checkPermission( + {ctx}, + { + entryId, + action: permission, + }, + ); + } + } } export default Lock; diff --git a/src/db/models/navigation/index.ts b/src/db/models/navigation/index.ts index 0b89a234..5a3cc064 100644 --- a/src/db/models/navigation/index.ts +++ b/src/db/models/navigation/index.ts @@ -1,14 +1,16 @@ +import {AppError} from '@gravity-ui/nodekit'; import {raw} from 'objection'; + import {Model} from '../..'; +import {RETURN_NAVIGATION_COLUMNS, US_ERRORS} from '../../../const'; +import {filterEntriesByPermission} from '../../../services/new/entry/utils'; +import * as MT from '../../../types/models'; import Utils from '../../../utils'; -import Revision from '../revision'; import Favorite from '../favorite'; -import {AppError} from '@gravity-ui/nodekit'; -import * as MT from '../../../types/models'; -import {RETURN_NAVIGATION_COLUMNS, US_ERRORS} from '../../../const'; +import Revision from '../revision'; + import {validateGetEntries, validateInterTenantGetEntries} from './scheme'; import {whereBuilderInterTenantGetEntries} from './utils'; -import {filterEntriesByPermission} from '../../../services/new/entry/utils'; interface NavigationFields extends MT.EntryColumns { isLocked?: boolean; diff --git a/src/db/models/navigation/utils.ts b/src/db/models/navigation/utils.ts index 7d6b599f..f4f154c6 100644 --- a/src/db/models/navigation/utils.ts +++ b/src/db/models/navigation/utils.ts @@ -1,5 +1,6 @@ -import {raw} from 'objection'; import type {Knex} from 'knex'; +import {raw} from 'objection'; + import {COMPARISON_OPERATORS} from '../../../const'; import {InterTenantGetEntriesConfig} from '../../../types/models'; diff --git a/src/db/models/new/entry/index.ts b/src/db/models/new/entry/index.ts index e687304b..6c0d0dd0 100644 --- a/src/db/models/new/entry/index.ts +++ b/src/db/models/new/entry/index.ts @@ -1,9 +1,10 @@ import {Model} from '../../..'; +import {EntryPermissions} from '../../../../services/new/entry/types'; +import {Favorite} from '../favorite'; import {RevisionModel} from '../revision'; import {WorkbookModel} from '../workbook'; -import {Favorite} from '../favorite'; + import {EntryScope} from './types'; -import {EntryPermissions} from '../../../../services/new/entry/types'; export const EntryColumn = { Scope: 'scope', diff --git a/src/db/models/revision/index.ts b/src/db/models/revision/index.ts index 52bcd721..98796fca 100644 --- a/src/db/models/revision/index.ts +++ b/src/db/models/revision/index.ts @@ -1,4 +1,5 @@ import {Model} from 'objection'; + import {RevisionColumns} from '../../../types/models'; interface Revision extends RevisionColumns {} diff --git a/src/db/models/template/index.ts b/src/db/models/template/index.ts index 403c7046..c2d50245 100644 --- a/src/db/models/template/index.ts +++ b/src/db/models/template/index.ts @@ -1,8 +1,10 @@ -import {Model} from '../..'; import {AppError} from '@gravity-ui/nodekit'; -import * as MT from '../../../types/models'; -import {validateGet, validateCreate, validateUpdate, validateDelete} from './scheme'; + +import {Model} from '../..'; import {US_ERRORS} from '../../../const'; +import * as MT from '../../../types/models'; + +import {validateCreate, validateDelete, validateGet, validateUpdate} from './scheme'; interface Template extends MT.TemplateColumns {} class Template extends Model { diff --git a/src/db/models/tenant/index.ts b/src/db/models/tenant/index.ts index 9d610f7c..7a7f46fc 100644 --- a/src/db/models/tenant/index.ts +++ b/src/db/models/tenant/index.ts @@ -1,7 +1,9 @@ -import {Model} from '../..'; import {AppError} from '@gravity-ui/nodekit'; + +import {Model} from '../..'; import {US_ERRORS} from '../../../const'; import * as MT from '../../../types/models'; + import {validateGet} from './scheme'; interface Tenant extends MT.TenantColumns {} diff --git a/src/db/presentations/joined-embed-embedding-secret/index.ts b/src/db/presentations/joined-embed-embedding-secret/index.ts index f5b8b809..14782e4f 100644 --- a/src/db/presentations/joined-embed-embedding-secret/index.ts +++ b/src/db/presentations/joined-embed-embedding-secret/index.ts @@ -1,5 +1,6 @@ import type {Knex} from 'knex'; import {TransactionOrKnex} from 'objection'; + import {EmbedModel, EmbedModelColumn} from '../../models/new/embed'; import {EmbeddingSecretModel, EmbeddingSecretModelColumn} from '../../models/new/embedding-secret'; diff --git a/src/db/presentations/joined-entry-favorite/index.ts b/src/db/presentations/joined-entry-favorite/index.ts index 97bfd6ea..3a934f89 100644 --- a/src/db/presentations/joined-entry-favorite/index.ts +++ b/src/db/presentations/joined-entry-favorite/index.ts @@ -1,12 +1,11 @@ import type {Knex} from 'knex'; -import {TransactionOrKnex, raw, Modifier} from 'objection'; +import {Modifier, TransactionOrKnex, raw} from 'objection'; + import {Model} from '../..'; import {Entry} from '../../models/new/entry'; import {Favorite} from '../../models/new/favorite'; - -import {leftJoinFavorite} from '../utils'; - import {selectedEntryColumns} from '../constants'; +import {leftJoinFavorite} from '../utils'; const selectedColumns = [ ...selectedEntryColumns.map((col) => `${Entry.tableName}.${col}`), diff --git a/src/db/presentations/joined-entry-revision-favorite/index.ts b/src/db/presentations/joined-entry-revision-favorite/index.ts index 306a085f..9983a750 100644 --- a/src/db/presentations/joined-entry-revision-favorite/index.ts +++ b/src/db/presentations/joined-entry-revision-favorite/index.ts @@ -1,18 +1,16 @@ import type {Knex} from 'knex'; -import {TransactionOrKnex, raw, Modifier} from 'objection'; +import {Modifier, TransactionOrKnex, raw} from 'objection'; + +import {Entry} from '../../models/new/entry'; +import {Favorite} from '../../models/new/favorite'; +import {RevisionModel} from '../../models/new/revision'; import { - selectedColumns as joinedEntryRevisionColumns, - joinRevision, + JoinRevisionArgs, JoinedEntryRevision, JoinedEntryRevisionColumns, - JoinRevisionArgs, + joinRevision, + selectedColumns as joinedEntryRevisionColumns, } from '../joined-entry-revision'; - -import {Entry} from '../../models/new/entry'; - -import {RevisionModel} from '../../models/new/revision'; -import {Favorite} from '../../models/new/favorite'; - import {leftJoinFavorite} from '../utils'; const selectedColumns = [ diff --git a/src/db/presentations/joined-entry-revision/index.ts b/src/db/presentations/joined-entry-revision/index.ts index d32dc55c..9e2f45f0 100644 --- a/src/db/presentations/joined-entry-revision/index.ts +++ b/src/db/presentations/joined-entry-revision/index.ts @@ -1,11 +1,11 @@ import type {Knex} from 'knex'; import {TransactionOrKnex, raw} from 'objection'; + import {Model} from '../..'; +import {EntriesOrderByFilter} from '../../../types/models'; import {Entry} from '../../models/new/entry'; import {RevisionModel} from '../../models/new/revision'; - import {selectedEntryColumns} from '../constants'; -import {EntriesOrderByFilter} from '../../../types/models'; const selectedRevisionColumns = [ 'data', diff --git a/src/db/presentations/utils.ts b/src/db/presentations/utils.ts index fdf05146..7696f24e 100644 --- a/src/db/presentations/utils.ts +++ b/src/db/presentations/utils.ts @@ -1,7 +1,6 @@ import type {Knex} from 'knex'; import {Entry} from '../models/new/entry'; - import {Favorite} from '../models/new/favorite'; export const leftJoinFavorite = (userLogin: string) => (builder: Knex.JoinClause) => { diff --git a/src/db/scripts/clear-and-prepare.ts b/src/db/scripts/clear-and-prepare.ts index 7de7c08e..f750137b 100644 --- a/src/db/scripts/clear-and-prepare.ts +++ b/src/db/scripts/clear-and-prepare.ts @@ -1,7 +1,7 @@ require('dotenv').config(); require('../../index'); -import {helpers} from '../index'; import {Utils} from '../../utils/utils'; +import {helpers} from '../index'; let dsnList; diff --git a/src/db/scripts/demo/d3.ts b/src/db/scripts/demo/d3.ts index 709189b2..98fc973b 100644 --- a/src/db/scripts/demo/d3.ts +++ b/src/db/scripts/demo/d3.ts @@ -1,6 +1,7 @@ require('dotenv').config(); require('../../../index'); import * as fs from 'fs'; + import {db} from '../../index'; const DEMO_WORKBOOK_ID = '1507164764046888724'; diff --git a/src/db/scripts/demo/hc.ts b/src/db/scripts/demo/hc.ts index 46886726..c415bcca 100644 --- a/src/db/scripts/demo/hc.ts +++ b/src/db/scripts/demo/hc.ts @@ -1,6 +1,7 @@ require('dotenv').config(); require('../../../index'); import * as fs from 'fs'; + import {db} from '../../index'; const DEMO_WORKBOOK_ID = '1507164764046888724'; diff --git a/src/db/scripts/e2e/init-united-storage-data.ts b/src/db/scripts/e2e/init-united-storage-data.ts index 983773b6..c45013d0 100644 --- a/src/db/scripts/e2e/init-united-storage-data.ts +++ b/src/db/scripts/e2e/init-united-storage-data.ts @@ -1,6 +1,7 @@ require('dotenv').config(); require('../../../index'); import * as fs from 'fs'; + import {db} from '../../index'; const E2E_WORKBOOK_ID = '1540491943966934028'; diff --git a/src/index.ts b/src/index.ts index fde2d1db..9cd7db5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,19 @@ +/* eslint-disable import/order */ import {nodekit} from './nodekit'; import {registerAppPlugins} from './registry/register-app-plugins'; -import {ExpressKit, AppMiddleware, AuthPolicy, AppRoutes} from '@gravity-ui/expresskit'; +import {AppMiddleware, AppRoutes, AuthPolicy, ExpressKit} from '@gravity-ui/expresskit'; import { + authZitadel, + checkReadOnlyMode, + ctx, decodeId, - resolveTenantId, - resolveSpecialTokens, - waitDatabase, - setCiEnv, dlContext, - ctx, finalRequestHandler, - checkReadOnlyMode, + resolveSpecialTokens, + resolveTenantId, resolveWorkbookId, - authZitadel, + setCiEnv, + waitDatabase, } from './components/middlewares'; import {AppEnv} from './const'; import {registry} from './registry'; diff --git a/src/nodekit.ts b/src/nodekit.ts index 206272ef..43c91a4d 100644 --- a/src/nodekit.ts +++ b/src/nodekit.ts @@ -1,10 +1,13 @@ +/* eslint-disable import/order */ import dotenv from 'dotenv'; dotenv.config(); import * as path from 'path'; + import {NodeKit} from '@gravity-ui/nodekit'; -import {schema} from './components/gateway/schema'; + import {getGatewayConfig} from './components/gateway'; +import {schema} from './components/gateway/schema'; import {initDB} from './db/init-db'; import {registry} from './registry'; diff --git a/src/registry/common/classes-map.ts b/src/registry/common/classes-map.ts index 19c9e7b5..b9c43fac 100644 --- a/src/registry/common/classes-map.ts +++ b/src/registry/common/classes-map.ts @@ -1,8 +1,8 @@ import {makeClassTemplate} from '../utils/make-class-template'; -import type {DLSConstructor} from './components/dls/types'; -import type {WorkbookConstructor} from './entities/workbook/types'; +import type {DLSConstructor} from './components/dls/types'; import type {CollectionConstructor} from './entities/collection/types'; +import type {WorkbookConstructor} from './entities/workbook/types'; export const commonClassesMap = { DLS: makeClassTemplate(), diff --git a/src/registry/common/components/dls/types.ts b/src/registry/common/components/dls/types.ts index c0da7315..2dfabff6 100644 --- a/src/registry/common/components/dls/types.ts +++ b/src/registry/common/components/dls/types.ts @@ -1,5 +1,6 @@ import type {AppContext} from '@gravity-ui/nodekit'; import {TransactionOrKnex} from 'objection'; + import * as MT from '../../../../types/models'; export interface DLSConstructor { diff --git a/src/registry/common/components/iam/types.ts b/src/registry/common/components/iam/types.ts index dec2dd14..f1e14af3 100644 --- a/src/registry/common/components/iam/types.ts +++ b/src/registry/common/components/iam/types.ts @@ -1,4 +1,5 @@ import type {AppContext} from '@gravity-ui/nodekit'; + import type {OrganizationPermission, ProjectPermission} from '../../../../components/iam'; export type CheckOrganizationPermission = (args: { diff --git a/src/registry/common/components/iam/utils.ts b/src/registry/common/components/iam/utils.ts index a7f448e5..db332887 100644 --- a/src/registry/common/components/iam/utils.ts +++ b/src/registry/common/components/iam/utils.ts @@ -1,9 +1,11 @@ import {AppContext, AppError} from '@gravity-ui/nodekit'; -import type {CheckOrganizationPermission, CheckProjectPermission} from './types'; + import {OrganizationPermission, ProjectPermission} from '../../../../components/iam'; import {US_ERRORS} from '../../../../const'; import {ZitadelUserRole} from '../../../../types/zitadel'; +import type {CheckOrganizationPermission, CheckProjectPermission} from './types'; + const throwAccessServicePermissionDenied = () => { throw new AppError(US_ERRORS.ACCESS_SERVICE_PERMISSION_DENIED, { code: US_ERRORS.ACCESS_SERVICE_PERMISSION_DENIED, diff --git a/src/registry/common/entities/collection/collection.ts b/src/registry/common/entities/collection/collection.ts index ab77f199..4b9dfbed 100644 --- a/src/registry/common/entities/collection/collection.ts +++ b/src/registry/common/entities/collection/collection.ts @@ -1,13 +1,15 @@ import type {AppContext} from '@gravity-ui/nodekit'; -import type {CollectionModel} from '../../../../db/models/new/collection'; import {AppError} from '@gravity-ui/nodekit'; -import {CollectionConstructor, CollectionInstance} from './types'; -import {CollectionPermission, Permissions} from '../../../../entities/collection/types'; + import {US_ERRORS} from '../../../../const'; -import {ZitadelUserRole} from '../../../../types/zitadel'; +import type {CollectionModel} from '../../../../db/models/new/collection'; +import {CollectionPermission, Permissions} from '../../../../entities/collection/types'; import {getMockedOperation} from '../../../../entities/utils'; +import {ZitadelUserRole} from '../../../../types/zitadel'; import Utils from '../../../../utils'; +import {CollectionConstructor, CollectionInstance} from './types'; + export const Collection: CollectionConstructor = class Collection implements CollectionInstance { ctx: AppContext; model: CollectionModel; @@ -18,30 +20,6 @@ export const Collection: CollectionConstructor = class Collection implements Col this.model = model; } - private isEditorOrAdmin() { - const {zitadelUserRole: role} = this.ctx.get('info'); - return role === ZitadelUserRole.Editor || role === ZitadelUserRole.Admin; - } - - private getAllPermissions() { - const isEditorOrAdmin = this.isEditorOrAdmin(); - - const permissions = { - listAccessBindings: true, - updateAccessBindings: isEditorOrAdmin, - createCollection: isEditorOrAdmin, - createWorkbook: isEditorOrAdmin, - limitedView: true, - view: true, - update: isEditorOrAdmin, - copy: isEditorOrAdmin, - move: isEditorOrAdmin, - delete: isEditorOrAdmin, - }; - - return permissions; - } - async register() { const isEditorOrAdmin = this.isEditorOrAdmin(); @@ -96,4 +74,28 @@ export const Collection: CollectionConstructor = class Collection implements Col this.permissions = this.getAllPermissions(); return Promise.resolve(); } + + private isEditorOrAdmin() { + const {zitadelUserRole: role} = this.ctx.get('info'); + return role === ZitadelUserRole.Editor || role === ZitadelUserRole.Admin; + } + + private getAllPermissions() { + const isEditorOrAdmin = this.isEditorOrAdmin(); + + const permissions = { + listAccessBindings: true, + updateAccessBindings: isEditorOrAdmin, + createCollection: isEditorOrAdmin, + createWorkbook: isEditorOrAdmin, + limitedView: true, + view: true, + update: isEditorOrAdmin, + copy: isEditorOrAdmin, + move: isEditorOrAdmin, + delete: isEditorOrAdmin, + }; + + return permissions; + } }; diff --git a/src/registry/common/entities/collection/types.ts b/src/registry/common/entities/collection/types.ts index ce2f1441..318f9278 100644 --- a/src/registry/common/entities/collection/types.ts +++ b/src/registry/common/entities/collection/types.ts @@ -1,4 +1,5 @@ import type {AppContext} from '@gravity-ui/nodekit'; + import type {CollectionModel} from '../../../../db/models/new/collection'; import type {CollectionPermission, Permissions} from '../../../../entities/collection/types'; import {StructureItemInstance} from '../structure-item/types'; diff --git a/src/registry/common/entities/collection/utils.ts b/src/registry/common/entities/collection/utils.ts index f932e371..8a82d3ea 100644 --- a/src/registry/common/entities/collection/utils.ts +++ b/src/registry/common/entities/collection/utils.ts @@ -1,5 +1,5 @@ -import type {BulkFetchCollectionsAllPermissions} from './types'; import {Collection} from './collection'; +import type {BulkFetchCollectionsAllPermissions} from './types'; export const bulkFetchCollectionsAllPermissions: BulkFetchCollectionsAllPermissions = async ( ctx, diff --git a/src/registry/common/entities/structure-item/types.ts b/src/registry/common/entities/structure-item/types.ts index 845cb39b..abb5ddb9 100644 --- a/src/registry/common/entities/structure-item/types.ts +++ b/src/registry/common/entities/structure-item/types.ts @@ -1,10 +1,11 @@ import type {AppContext} from '@gravity-ui/nodekit'; + import type {CollectionModel} from '../../../../db/models/new/collection'; +import {WorkbookModel} from '../../../../db/models/new/workbook'; import type { CollectionPermission, Permissions as CollectionPermissions, } from '../../../../entities/collection/types'; -import {WorkbookModel} from '../../../../db/models/new/workbook'; import { WorkbookPermission, Permissions as WorkbookPermissions, diff --git a/src/registry/common/entities/workbook/types.ts b/src/registry/common/entities/workbook/types.ts index b1a1dd9a..2d7b785e 100644 --- a/src/registry/common/entities/workbook/types.ts +++ b/src/registry/common/entities/workbook/types.ts @@ -1,6 +1,7 @@ import type {AppContext} from '@gravity-ui/nodekit'; + import type {WorkbookModel} from '../../../../db/models/new/workbook'; -import type {WorkbookPermission, Permissions} from '../../../../entities/workbook/types'; +import type {Permissions, WorkbookPermission} from '../../../../entities/workbook/types'; import {StructureItemInstance} from '../structure-item/types'; export interface WorkbookConstructor { diff --git a/src/registry/common/entities/workbook/workbook.ts b/src/registry/common/entities/workbook/workbook.ts index 2fb066a1..b241c0c1 100644 --- a/src/registry/common/entities/workbook/workbook.ts +++ b/src/registry/common/entities/workbook/workbook.ts @@ -1,13 +1,15 @@ import type {AppContext} from '@gravity-ui/nodekit'; -import type {WorkbookModel} from '../../../../db/models/new/workbook'; import {AppError} from '@gravity-ui/nodekit'; -import {WorkbookConstructor, WorkbookInstance} from './types'; -import {Permissions, WorkbookPermission} from '../../../../entities/workbook/types'; + import {US_ERRORS} from '../../../../const'; -import {ZitadelUserRole} from '../../../../types/zitadel'; +import type {WorkbookModel} from '../../../../db/models/new/workbook'; import {getMockedOperation} from '../../../../entities/utils'; +import {Permissions, WorkbookPermission} from '../../../../entities/workbook/types'; +import {ZitadelUserRole} from '../../../../types/zitadel'; import Utils from '../../../../utils'; +import {WorkbookConstructor, WorkbookInstance} from './types'; + export const Workbook: WorkbookConstructor = class Workbook implements WorkbookInstance { @@ -20,30 +22,6 @@ export const Workbook: WorkbookConstructor = class Workbook this.model = model; } - private isEditorOrAdmin() { - const {zitadelUserRole: role} = this.ctx.get('info'); - return role === ZitadelUserRole.Editor || role === ZitadelUserRole.Admin; - } - - private getAllPermissions() { - const isEditorOrAdmin = this.isEditorOrAdmin(); - - const permissions = { - listAccessBindings: true, - updateAccessBindings: isEditorOrAdmin, - limitedView: true, - view: true, - update: isEditorOrAdmin, - copy: isEditorOrAdmin, - move: isEditorOrAdmin, - publish: isEditorOrAdmin, - embed: isEditorOrAdmin, - delete: isEditorOrAdmin, - }; - - return permissions; - } - async register() { const isEditorOrAdmin = this.isEditorOrAdmin(); @@ -98,4 +76,28 @@ export const Workbook: WorkbookConstructor = class Workbook delete: true, }; } + + private isEditorOrAdmin() { + const {zitadelUserRole: role} = this.ctx.get('info'); + return role === ZitadelUserRole.Editor || role === ZitadelUserRole.Admin; + } + + private getAllPermissions() { + const isEditorOrAdmin = this.isEditorOrAdmin(); + + const permissions = { + listAccessBindings: true, + updateAccessBindings: isEditorOrAdmin, + limitedView: true, + view: true, + update: isEditorOrAdmin, + copy: isEditorOrAdmin, + move: isEditorOrAdmin, + publish: isEditorOrAdmin, + embed: isEditorOrAdmin, + delete: isEditorOrAdmin, + }; + + return permissions; + } }; diff --git a/src/registry/common/functions-map.ts b/src/registry/common/functions-map.ts index 0adb1c78..e5970ea6 100644 --- a/src/registry/common/functions-map.ts +++ b/src/registry/common/functions-map.ts @@ -1,15 +1,16 @@ import {makeFunctionTemplate} from '../utils/make-function-template'; +import type {GetZitadelUserRole} from '../zitadel/types'; + +import type {CheckOrganizationPermission, CheckProjectPermission} from './components/iam/types'; import type {BulkFetchCollectionsAllPermissions} from './entities/collection/types'; import type {BulkFetchWorkbooksAllPermissions} from './entities/workbook/types'; -import type {CheckOrganizationPermission, CheckProjectPermission} from './components/iam/types'; +import type {ColorPalettesAdminValidator} from './utils/color-palettes/types'; +import type {CheckEmbedding} from './utils/embedding/types'; import type { - IsNeedBypassEntryByKey, - GetEntryBeforeDbRequestHook, GetEntryAddFormattedFieldsHook, + GetEntryBeforeDbRequestHook, + IsNeedBypassEntryByKey, } from './utils/entry/types'; -import type {ColorPalettesAdminValidator} from './utils/color-palettes/types'; -import type {CheckEmbedding} from './utils/embedding/types'; -import type {GetZitadelUserRole} from '../zitadel/types'; export const commonFunctionsMap = { bulkFetchWorkbooksAllPermissions: makeFunctionTemplate(), diff --git a/src/registry/common/register.ts b/src/registry/common/register.ts index 5f4697cd..0be2632d 100644 --- a/src/registry/common/register.ts +++ b/src/registry/common/register.ts @@ -1,19 +1,19 @@ +import {registry} from '../index'; +import {getZitadelUserRole} from '../zitadel/utils'; + import {DLS} from './components/dls/dls'; -import {Workbook} from './entities/workbook/workbook'; +import {checkOrganizationPermission, checkProjectPermission} from './components/iam/utils'; import {Collection} from './entities/collection/collection'; -import {bulkFetchWorkbooksAllPermissions} from './entities/workbook/utils'; import {bulkFetchCollectionsAllPermissions} from './entities/collection/utils'; -import {checkOrganizationPermission, checkProjectPermission} from './components/iam/utils'; +import {bulkFetchWorkbooksAllPermissions} from './entities/workbook/utils'; +import {Workbook} from './entities/workbook/workbook'; +import {colorPalettesAdminValidator} from './utils/color-palettes/utils'; +import {checkEmbedding} from './utils/embedding/utils'; import { - isNeedBypassEntryByKey, - getEntryBeforeDbRequestHook, getEntryAddFormattedFieldsHook, + getEntryBeforeDbRequestHook, + isNeedBypassEntryByKey, } from './utils/entry/utils'; -import {colorPalettesAdminValidator} from './utils/color-palettes/utils'; -import {checkEmbedding} from './utils/embedding/utils'; -import {getZitadelUserRole} from '../zitadel/utils'; - -import {registry} from '../index'; export const registerCommonPlugins = () => { registry.common.classes.register({ diff --git a/src/registry/common/utils/entry/types.ts b/src/registry/common/utils/entry/types.ts index 2f1ff336..befbfc16 100644 --- a/src/registry/common/utils/entry/types.ts +++ b/src/registry/common/utils/entry/types.ts @@ -1,4 +1,5 @@ import type {AppContext} from '@gravity-ui/nodekit'; + import type {GetEntryResult} from '../../../../services/new/entry/get-entry'; export type IsNeedBypassEntryByKey = (ctx: AppContext, key?: string) => boolean; diff --git a/src/registry/common/utils/entry/utils.ts b/src/registry/common/utils/entry/utils.ts index 075691a3..7ad397f9 100644 --- a/src/registry/common/utils/entry/utils.ts +++ b/src/registry/common/utils/entry/utils.ts @@ -1,7 +1,7 @@ import type { - IsNeedBypassEntryByKey, - GetEntryBeforeDbRequestHook, GetEntryAddFormattedFieldsHook, + GetEntryBeforeDbRequestHook, + IsNeedBypassEntryByKey, } from './types'; export const isNeedBypassEntryByKey: IsNeedBypassEntryByKey = () => false; diff --git a/src/registry/index.ts b/src/registry/index.ts index e4abc6a6..c6c6654e 100644 --- a/src/registry/index.ts +++ b/src/registry/index.ts @@ -1,11 +1,13 @@ import type {ExpressKit, Request, Response} from '@gravity-ui/expresskit'; -import type {AppContext} from '@gravity-ui/nodekit'; import getGatewayControllers, { ApiWithRoot, GatewayConfig, SchemasByScope, } from '@gravity-ui/gateway'; +import type {AppContext} from '@gravity-ui/nodekit'; + import type {initDB} from '../db/init-db'; + import {commonRegistry} from './common'; type DbInstance = ReturnType; diff --git a/src/registry/zitadel/utils.ts b/src/registry/zitadel/utils.ts index 9c9fe0b0..7aa021b6 100644 --- a/src/registry/zitadel/utils.ts +++ b/src/registry/zitadel/utils.ts @@ -1,4 +1,5 @@ import {ZitadelUserRole} from '../../types/zitadel'; + import {GetZitadelUserRole} from './types'; export const getZitadelUserRole: GetZitadelUserRole = (data: any): ZitadelUserRole => { diff --git a/src/routes.ts b/src/routes.ts index 5e72c85b..f6418521 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,18 +1,18 @@ -import type {NodeKit} from '@gravity-ui/nodekit'; -import {AuthPolicy, AppMiddleware, AppRouteDescription} from '@gravity-ui/expresskit'; +import {AppMiddleware, AppRouteDescription, AuthPolicy} from '@gravity-ui/expresskit'; import type {HttpMethod} from '@gravity-ui/expresskit/dist/types'; -import {Feature} from './components/features'; +import type {NodeKit} from '@gravity-ui/nodekit'; -import homeController from './controllers/home'; -import helpersController from './controllers/helpers'; +import {Feature} from './components/features'; +import collectionsController from './controllers/collections'; +import colorPalettesController from './controllers/color-palettes'; import entriesController from './controllers/entries'; +import favoritesController from './controllers/favorites'; +import helpersController from './controllers/helpers'; +import homeController from './controllers/home'; import locksController from './controllers/locks'; import statesController from './controllers/states'; -import favoritesController from './controllers/favorites'; -import workbooksController from './controllers/workbooks'; -import collectionsController from './controllers/collections'; -import colorPalettesController from './controllers/color-palettes'; import structureItemsController from './controllers/structure-items'; +import workbooksController from './controllers/workbooks'; export type GetRoutesOptions = { beforeAuth: AppMiddleware[]; diff --git a/src/services/color-palettes/create-color-palette.ts b/src/services/color-palettes/create-color-palette.ts index 06e03cdd..32f96f9d 100644 --- a/src/services/color-palettes/create-color-palette.ts +++ b/src/services/color-palettes/create-color-palette.ts @@ -1,11 +1,13 @@ import {AppError} from '@gravity-ui/nodekit'; import {transaction} from 'objection'; -import {ServiceArgs} from '../../services/new/types'; + import {makeSchemaValidator} from '../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../const'; import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; +import {ServiceArgs} from '../../services/new/types'; import Utils from '../../utils'; + import {getColorPalettesCount} from './get-color-palettes-count'; -import {US_ERRORS} from '../../const'; const MAX_PALETTES_COUNT = 50; diff --git a/src/services/color-palettes/delete-color-palette.ts b/src/services/color-palettes/delete-color-palette.ts index 5debd78f..8bd9bbc3 100644 --- a/src/services/color-palettes/delete-color-palette.ts +++ b/src/services/color-palettes/delete-color-palette.ts @@ -1,6 +1,6 @@ -import {ServiceArgs} from '../../services/new/types'; import {makeSchemaValidator} from '../../components/validation-schema-compiler'; import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; +import {ServiceArgs} from '../../services/new/types'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/color-palettes/get-color-palette.ts b/src/services/color-palettes/get-color-palette.ts index 334c5e5b..783c1843 100644 --- a/src/services/color-palettes/get-color-palette.ts +++ b/src/services/color-palettes/get-color-palette.ts @@ -1,5 +1,5 @@ -import {ServiceArgs} from '../../services/new/types'; import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; +import {ServiceArgs} from '../../services/new/types'; type GetColorPaletteArgs = { colorPaletteId: string; diff --git a/src/services/color-palettes/get-color-palettes-count.ts b/src/services/color-palettes/get-color-palettes-count.ts index e1ffe14e..518a1262 100644 --- a/src/services/color-palettes/get-color-palettes-count.ts +++ b/src/services/color-palettes/get-color-palettes-count.ts @@ -1,8 +1,7 @@ -import {CountAggregation, ServiceArgs} from '../../services/new/types'; -import {getReplica} from '../../services/new/utils'; import {makeSchemaValidator} from '../../components/validation-schema-compiler'; - import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; +import {CountAggregation, ServiceArgs} from '../../services/new/types'; +import {getReplica} from '../../services/new/utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/color-palettes/get-color-palettes-list.ts b/src/services/color-palettes/get-color-palettes-list.ts index e90f2edd..b98376f1 100644 --- a/src/services/color-palettes/get-color-palettes-list.ts +++ b/src/services/color-palettes/get-color-palettes-list.ts @@ -1,5 +1,5 @@ -import {ServiceArgs} from '../../services/new/types'; import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; +import {ServiceArgs} from '../../services/new/types'; import Utils from '../../utils'; const PAGE = 0; diff --git a/src/services/color-palettes/update-color-palette.ts b/src/services/color-palettes/update-color-palette.ts index 78feb8e7..97f87645 100644 --- a/src/services/color-palettes/update-color-palette.ts +++ b/src/services/color-palettes/update-color-palette.ts @@ -1,12 +1,13 @@ import {AppError} from '@gravity-ui/nodekit'; -import {ServiceArgs} from '../../services/new/types'; -import {getPrimary} from '../../services/new/utils'; +import {transaction} from 'objection'; + import {makeSchemaValidator} from '../../components/validation-schema-compiler'; -import {WorkbookModel} from '../../db/models/new/workbook'; -import Utils from '../../utils'; import {US_ERRORS} from '../../const'; import {ColorPaletteModel, ColorPaletteModelColumn} from '../../db/models/new/color-palette'; -import {transaction} from 'objection'; +import {WorkbookModel} from '../../db/models/new/workbook'; +import {ServiceArgs} from '../../services/new/types'; +import {getPrimary} from '../../services/new/utils'; +import Utils from '../../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/entry.service.ts b/src/services/entry.service.ts index 14cb0c5f..cb9aa9c6 100644 --- a/src/services/entry.service.ts +++ b/src/services/entry.service.ts @@ -1,7 +1,8 @@ +import {SYSTEM_USER} from '../const'; import Entry from '../db/models/entry'; import * as ST from '../types/services.types'; + import {createEntryInWorkbook} from './entry'; -import {SYSTEM_USER} from '../const'; export default class EntryService { static async _getEntriesByKey({key, branch, ctx}: ST.PrivateGetEntriesByKey) { diff --git a/src/services/entry/actions/check-entry.ts b/src/services/entry/actions/check-entry.ts index 6d9dce99..f61f4634 100644 --- a/src/services/entry/actions/check-entry.ts +++ b/src/services/entry/actions/check-entry.ts @@ -1,10 +1,11 @@ -import {TransactionOrKnex} from 'objection'; import {AppError} from '@gravity-ui/nodekit'; +import {TransactionOrKnex} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {DEFAULT_QUERY_TIMEOUT, US_ERRORS} from '../../../const'; import Entry from '../../../db/models/entry'; import {CTX, EntryColumns} from '../../../types/models'; -import {US_ERRORS, DEFAULT_QUERY_TIMEOUT} from '../../../const'; import {getWorkbook} from '../../new/workbook/get-workbook'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; const validateVerifiableEntry = makeSchemaValidator({ type: 'object', diff --git a/src/services/entry/actions/copy-to-workbook.ts b/src/services/entry/actions/copy-to-workbook.ts index 685d1551..31851f1c 100644 --- a/src/services/entry/actions/copy-to-workbook.ts +++ b/src/services/entry/actions/copy-to-workbook.ts @@ -1,19 +1,17 @@ -import {TransactionOrKnex} from 'objection'; import {AppError} from '@gravity-ui/nodekit'; +import {TransactionOrKnex} from 'objection'; +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {BiTrackingLogs, US_ERRORS} from '../../../const'; import {getId} from '../../../db'; +import Link from '../../../db/models/links'; import {Entry, EntryColumn} from '../../../db/models/new/entry'; -import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; import {WorkbookModel} from '../../../db/models/new/workbook'; +import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; +import {WorkbookPermission} from '../../../entities/workbook'; import {CTX} from '../../../types/models'; -import {US_ERRORS, BiTrackingLogs} from '../../../const'; import Utils, {makeUserId} from '../../../utils'; -import {WorkbookPermission} from '../../../entities/workbook'; import {getParentIds} from '../../new/collection/utils/get-parents'; - -import Link from '../../../db/models/links'; - -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {resolveEntriesNameCollisions} from '../../new/entry/utils/resolveNameCollisions'; interface Params { diff --git a/src/services/entry/actions/create-in-workbook.ts b/src/services/entry/actions/create-in-workbook.ts index af289d67..0c131b3f 100644 --- a/src/services/entry/actions/create-in-workbook.ts +++ b/src/services/entry/actions/create-in-workbook.ts @@ -1,29 +1,30 @@ import {transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import { + AJV_PATTERN_KEYS_NOT_OBJECT, + BiTrackingLogs, + DEFAULT_QUERY_TIMEOUT, + ModeValues, + RETURN_COLUMNS, +} from '../../../const'; +import {getId} from '../../../db'; import Entry from '../../../db/models/entry'; import Revision from '../../../db/models/revision'; +import {WorkbookPermission} from '../../../entities/workbook'; import { CTX, - WorkbookColumns, - EntryScope, - SyncLinks, EntryColumns, + EntryScope, + Mode, RevisionColumns, + SyncLinks, UsPermission, - Mode, + WorkbookColumns, } from '../../../types/models'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import { - AJV_PATTERN_KEYS_NOT_OBJECT, - DEFAULT_QUERY_TIMEOUT, - RETURN_COLUMNS, - BiTrackingLogs, - ModeValues, -} from '../../../const'; +import Utils, {makeUserId} from '../../../utils'; import {getWorkbook} from '../../new/workbook/get-workbook'; import {checkWorkbookPermission, getEntryPermissionsByWorkbook} from '../../new/workbook/utils'; -import {WorkbookPermission} from '../../../entities/workbook'; -import Utils, {makeUserId} from '../../../utils'; -import {getId} from '../../../db'; export const validateCreateEntryInWorkbook = makeSchemaValidator({ type: 'object', diff --git a/src/services/entry/actions/delete-entry.ts b/src/services/entry/actions/delete-entry.ts index 54fff132..9adbb1f2 100644 --- a/src/services/entry/actions/delete-entry.ts +++ b/src/services/entry/actions/delete-entry.ts @@ -1,17 +1,19 @@ import {AppError} from '@gravity-ui/nodekit'; import {transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {BiTrackingLogs, DEFAULT_QUERY_TIMEOUT, RETURN_COLUMNS, US_ERRORS} from '../../../const'; import Entry from '../../../db/models/entry'; import Lock from '../../../db/models/lock'; -import {EntryColumns, DlsActions, UsPermissions} from '../../../types/models'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {RETURN_COLUMNS, BiTrackingLogs, DEFAULT_QUERY_TIMEOUT, US_ERRORS} from '../../../const'; +import {WorkbookPermission} from '../../../entities/workbook'; +import {DlsActions, EntryColumns, UsPermissions} from '../../../types/models'; import Utils, {makeUserId} from '../../../utils'; +import {ServiceArgs} from '../../new/types'; import {getWorkbook} from '../../new/workbook/get-workbook'; -import {WorkbookPermission} from '../../../entities/workbook'; import {checkWorkbookPermission} from '../../new/workbook/utils'; import {markEntryAsDeleted} from '../crud'; + import {checkEntry} from './check-entry'; -import {ServiceArgs} from '../../new/types'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/entry/actions/entries-by-key-pattern.ts b/src/services/entry/actions/entries-by-key-pattern.ts index e8a9c6e2..c686e758 100644 --- a/src/services/entry/actions/entries-by-key-pattern.ts +++ b/src/services/entry/actions/entries-by-key-pattern.ts @@ -1,6 +1,6 @@ -import Entry from '../../../db/models/entry'; -import {DEFAULT_QUERY_TIMEOUT} from '../../../const'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {DEFAULT_QUERY_TIMEOUT} from '../../../const'; +import Entry from '../../../db/models/entry'; import {ServiceArgs} from '../../new/types'; const validateArgs = makeSchemaValidator({ diff --git a/src/services/entry/actions/get-entry-by-key.ts b/src/services/entry/actions/get-entry-by-key.ts index 9c949a97..f6044505 100644 --- a/src/services/entry/actions/get-entry-by-key.ts +++ b/src/services/entry/actions/get-entry-by-key.ts @@ -1,10 +1,12 @@ import {AppError} from '@gravity-ui/nodekit'; -import Entry from '../../../db/models/entry'; import {Optional as OptionalFields} from 'utility-types'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {DEFAULT_QUERY_TIMEOUT, RETURN_COLUMNS, US_ERRORS} from '../../../const'; +import Entry from '../../../db/models/entry'; import {CTX, DlsActions, RevisionColumns} from '../../../types/models'; -import {RETURN_COLUMNS, DEFAULT_QUERY_TIMEOUT, US_ERRORS} from '../../../const'; import Utils from '../../../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; + import {checkEntry} from './check-entry'; const validateGetEntryByKey = makeSchemaValidator({ diff --git a/src/services/entry/actions/get-entry-relations.ts b/src/services/entry/actions/get-entry-relations.ts index ab0a808a..9f840a1b 100644 --- a/src/services/entry/actions/get-entry-relations.ts +++ b/src/services/entry/actions/get-entry-relations.ts @@ -1,15 +1,17 @@ import {AppError} from '@gravity-ui/nodekit'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {ALLOWED_ENTRIES_SCOPE, US_ERRORS} from '../../../const'; import {Entry, EntryColumn} from '../../../db/models/new/entry'; +import {EntryScope} from '../../../db/models/new/entry/types'; import {DlsActions} from '../../../types/models'; -import {ServiceArgs} from '../../new/types'; import Utils from '../../../utils'; -import {ALLOWED_ENTRIES_SCOPE, US_ERRORS} from '../../../const'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {ServiceArgs} from '../../new/types'; +import {getReplica} from '../../new/utils'; import {getWorkbook} from '../../new/workbook/get-workbook'; import {getEntryPermissionsByWorkbook} from '../../new/workbook/utils'; -import {getRelatedEntries, RelationDirection} from './get-related-entries'; -import {getReplica} from '../../new/utils'; -import {EntryScope} from '../../../db/models/new/entry/types'; + +import {RelationDirection, getRelatedEntries} from './get-related-entries'; export type GetEntryRelationsArgs = { entryId: string; diff --git a/src/services/entry/actions/get-entry-revisions.ts b/src/services/entry/actions/get-entry-revisions.ts index 06276089..545ed73a 100644 --- a/src/services/entry/actions/get-entry-revisions.ts +++ b/src/services/entry/actions/get-entry-revisions.ts @@ -1,19 +1,21 @@ import {AppError} from '@gravity-ui/nodekit'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import Entry from '../../../db/models/entry'; -import {CTX, DlsActions} from '../../../types/models'; import { - RETURN_NAVIGATION_COLUMNS, - RETURN_COLUMNS, - DEFAULT_QUERY_TIMEOUT, - US_ERRORS, DEFAULT_PAGE, DEFAULT_PAGE_SIZE, + DEFAULT_QUERY_TIMEOUT, + RETURN_COLUMNS, + RETURN_NAVIGATION_COLUMNS, + US_ERRORS, } from '../../../const'; +import Entry from '../../../db/models/entry'; +import {CTX, DlsActions} from '../../../types/models'; import Utils from '../../../utils'; -import {checkEntry} from './check-entry'; -import {getWorkbook} from '../../new/workbook'; import {ServiceArgs} from '../../new/types'; +import {getWorkbook} from '../../new/workbook'; + +import {checkEntry} from './check-entry'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/entry/actions/get-related-entries.ts b/src/services/entry/actions/get-related-entries.ts index e7225b48..e6b04d96 100644 --- a/src/services/entry/actions/get-related-entries.ts +++ b/src/services/entry/actions/get-related-entries.ts @@ -1,14 +1,15 @@ import {raw} from 'objection'; -import Entry from '../../../db/models/entry'; -import {ServiceArgs} from '../../new/types'; + import { DEFAULT_QUERY_TIMEOUT, EXTENDED_QUERY_TIMEOUT, RETURN_RELATION_COLUMNS, } from '../../../const'; -import {getReplica} from '../../new/utils'; -import {EntryScope} from '../../../db/models/new/entry/types'; +import Entry from '../../../db/models/entry'; import {EntryColumn} from '../../../db/models/new/entry'; +import {EntryScope} from '../../../db/models/new/entry/types'; +import {ServiceArgs} from '../../new/types'; +import {getReplica} from '../../new/utils'; export enum RelationDirection { Parent = 'parent', diff --git a/src/services/entry/actions/rename-entry.ts b/src/services/entry/actions/rename-entry.ts index 85df1398..16778354 100644 --- a/src/services/entry/actions/rename-entry.ts +++ b/src/services/entry/actions/rename-entry.ts @@ -1,13 +1,15 @@ import {AppError} from '@gravity-ui/nodekit'; import {raw, transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {BiTrackingLogs, CURRENT_TIMESTAMP, RETURN_COLUMNS, US_ERRORS} from '../../../const'; import Entry from '../../../db/models/entry'; +import {WorkbookPermission} from '../../../entities/workbook'; import {CTX, DlsActions} from '../../../types/models'; -import {RETURN_COLUMNS, BiTrackingLogs, US_ERRORS, CURRENT_TIMESTAMP} from '../../../const'; import Utils, {makeUserId} from '../../../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {getWorkbook} from '../../new/workbook/get-workbook'; import {checkWorkbookPermission} from '../../new/workbook/utils'; -import {WorkbookPermission} from '../../../entities/workbook'; + import {checkEntry} from './check-entry'; const validateRenameEntry = makeSchemaValidator({ diff --git a/src/services/entry/actions/switch-revision-entry.ts b/src/services/entry/actions/switch-revision-entry.ts index 58bda4eb..013f0606 100644 --- a/src/services/entry/actions/switch-revision-entry.ts +++ b/src/services/entry/actions/switch-revision-entry.ts @@ -1,13 +1,14 @@ import {AppError} from '@gravity-ui/nodekit'; import {raw} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import Entry from '../../../db/models/entry'; import {CURRENT_TIMESTAMP, DEFAULT_QUERY_TIMEOUT, SYSTEM_USER, US_ERRORS} from '../../../const'; +import Entry from '../../../db/models/entry'; +import {EntryColumn} from '../../../db/models/new/entry'; +import {RevisionModelColumn} from '../../../db/models/new/revision'; +import Revision from '../../../db/models/revision'; import Utils, {makeUserId} from '../../../utils'; import {ServiceArgs} from '../../new/types'; -import Revision from '../../../db/models/revision'; -import {RevisionModelColumn} from '../../../db/models/new/revision'; -import {EntryColumn} from '../../../db/models/new/entry'; import {getPrimary, getReplica} from '../../new/utils'; const validateArgs = makeSchemaValidator({ diff --git a/src/services/entry/actions/update-entry.ts b/src/services/entry/actions/update-entry.ts index a63a9917..338381d7 100644 --- a/src/services/entry/actions/update-entry.ts +++ b/src/services/entry/actions/update-entry.ts @@ -1,33 +1,35 @@ import {AppError} from '@gravity-ui/nodekit'; -import {raw, transaction, TransactionOrKnex} from 'objection'; +import {TransactionOrKnex, raw, transaction} from 'objection'; +import {Optional} from 'utility-types'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import { + AJV_PATTERN_KEYS_NOT_OBJECT, + BiTrackingLogs, + CURRENT_TIMESTAMP, + DEFAULT_QUERY_TIMEOUT, + RETURN_COLUMNS, + US_ERRORS, +} from '../../../const'; import Entry from '../../../db/models/entry'; import Lock from '../../../db/models/lock'; +import {EntryColumn} from '../../../db/models/new/entry'; +import {EntryScope} from '../../../db/models/new/entry/types'; import Revision from '../../../db/models/revision'; +import {WorkbookPermission} from '../../../entities/workbook'; import { CTX, + DlsActions, EntryColumns, RevisionColumns, SyncLinks, - DlsActions, SyncLinksConf, } from '../../../types/models'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import { - RETURN_COLUMNS, - BiTrackingLogs, - DEFAULT_QUERY_TIMEOUT, - US_ERRORS, - AJV_PATTERN_KEYS_NOT_OBJECT, - CURRENT_TIMESTAMP, -} from '../../../const'; import Utils, {makeUserId} from '../../../utils'; import {getWorkbook} from '../../new/workbook/get-workbook'; import {checkWorkbookPermission} from '../../new/workbook/utils'; -import {WorkbookPermission} from '../../../entities/workbook'; -import {Optional} from 'utility-types'; + import {checkEntry} from './check-entry'; -import {EntryScope} from '../../../db/models/new/entry/types'; -import {EntryColumn} from '../../../db/models/new/entry'; type Mode = 'save' | 'publish' | 'recover'; const ModeValues: Mode[] = ['save', 'publish', 'recover']; diff --git a/src/services/entry/crud/update/mark-entry-as-deleted.ts b/src/services/entry/crud/update/mark-entry-as-deleted.ts index 38985c0d..44eeb00b 100644 --- a/src/services/entry/crud/update/mark-entry-as-deleted.ts +++ b/src/services/entry/crud/update/mark-entry-as-deleted.ts @@ -1,7 +1,8 @@ import {TransactionOrKnex, raw} from 'objection'; -import {EntryColumns} from '../../../../types/models'; + +import {CURRENT_TIMESTAMP, DEFAULT_QUERY_TIMEOUT, TRASH_FOLDER} from '../../../../const'; import Entry from '../../../../db/models/entry'; -import {DEFAULT_QUERY_TIMEOUT, TRASH_FOLDER, CURRENT_TIMESTAMP} from '../../../../const'; +import {EntryColumns} from '../../../../types/models'; export type MarkEntryDeletedData = { entryId: EntryColumns['entryId']; diff --git a/src/services/new/collection/check-collection-by-title.ts b/src/services/new/collection/check-collection-by-title.ts index e8c4cf42..41fa96e4 100644 --- a/src/services/new/collection/check-collection-by-title.ts +++ b/src/services/new/collection/check-collection-by-title.ts @@ -1,9 +1,10 @@ -import {getCollection} from './'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; + +import {getCollection} from './'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/create-collection.ts b/src/services/new/collection/create-collection.ts index b09c3948..8e447770 100644 --- a/src/services/new/collection/create-collection.ts +++ b/src/services/new/collection/create-collection.ts @@ -1,13 +1,15 @@ import {AppError} from '@gravity-ui/nodekit'; -import {checkCollectionByTitle} from './check-collection-by-title'; -import {getParentIds} from './utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkCollectionByTitle} from './check-collection-by-title'; +import {getParentIds} from './utils/get-parents'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/delete-collections.ts b/src/services/new/collection/delete-collections.ts index 71944b93..ac1bbb6a 100644 --- a/src/services/new/collection/delete-collections.ts +++ b/src/services/new/collection/delete-collections.ts @@ -1,17 +1,19 @@ -import {ServiceArgs} from '../types'; -import {getPrimary, getReplica} from '../utils'; -import {deleteWorkbooks} from '../workbook'; +import {AppError} from '@gravity-ui/nodekit'; +import {transaction} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; -import {transaction} from 'objection'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; -import Utils from '../../../utils'; import {CollectionPermission} from '../../../entities/collection'; -import {AppError} from '@gravity-ui/nodekit'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary, getReplica} from '../utils'; +import {deleteWorkbooks} from '../workbook'; + import {getCollectionsListByIds} from './get-collections-list-by-ids'; +import {checkAndSetCollectionPermission, makeCollectionsWithParentsMap} from './utils'; import {markCollectionsAsDeleted} from './utils/mark-collections-as-deleted'; -import {makeCollectionsWithParentsMap, checkAndSetCollectionPermission} from './utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/formatters/format-collection-breadcrumbs.ts b/src/services/new/collection/formatters/format-collection-breadcrumbs.ts index 680afe75..936cb7f8 100644 --- a/src/services/new/collection/formatters/format-collection-breadcrumbs.ts +++ b/src/services/new/collection/formatters/format-collection-breadcrumbs.ts @@ -1,4 +1,5 @@ import type {CollectionInstance} from '../../../../registry/common/entities/collection/types'; + import {formatCollection} from './format-collection'; export const formatGetCollectionBreadcrumbs = (collections: CollectionInstance[]) => { diff --git a/src/services/new/collection/formatters/format-collection-content.ts b/src/services/new/collection/formatters/format-collection-content.ts index c3fa84d4..9d09c124 100644 --- a/src/services/new/collection/formatters/format-collection-content.ts +++ b/src/services/new/collection/formatters/format-collection-content.ts @@ -1,6 +1,7 @@ import type {CollectionInstance} from '../../../../registry/common/entities/collection/types'; import type {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {formatWorkbook} from '../../workbook/formatters'; + import {formatCollection} from './format-collection'; export const formatCollectionContent = ({ diff --git a/src/services/new/collection/formatters/format-collection-model-with-operation.ts b/src/services/new/collection/formatters/format-collection-model-with-operation.ts index 5ff60ce2..630ee57a 100644 --- a/src/services/new/collection/formatters/format-collection-model-with-operation.ts +++ b/src/services/new/collection/formatters/format-collection-model-with-operation.ts @@ -1,6 +1,7 @@ -import {formatCollectionModel} from './format-collection-model'; -import {formatOperation, Operation} from '../../formatters/format-operation'; import {CollectionModel} from '../../../../db/models/new/collection'; +import {Operation, formatOperation} from '../../formatters/format-operation'; + +import {formatCollectionModel} from './format-collection-model'; export const formatCollectionModelWithOperation = ( collectionModel: CollectionModel, diff --git a/src/services/new/collection/formatters/format-collection-models-list.ts b/src/services/new/collection/formatters/format-collection-models-list.ts index 199fe7ef..f912adc4 100644 --- a/src/services/new/collection/formatters/format-collection-models-list.ts +++ b/src/services/new/collection/formatters/format-collection-models-list.ts @@ -1,4 +1,5 @@ import {CollectionModel} from '../../../../db/models/new/collection'; + import {formatCollectionModel} from './format-collection-model'; export const formatCollectionModelsList = ({ diff --git a/src/services/new/collection/formatters/format-collection-with-operation.ts b/src/services/new/collection/formatters/format-collection-with-operation.ts index 6c8e4398..c2d909be 100644 --- a/src/services/new/collection/formatters/format-collection-with-operation.ts +++ b/src/services/new/collection/formatters/format-collection-with-operation.ts @@ -1,6 +1,7 @@ -import {formatCollection} from './format-collection'; -import {formatOperation, Operation} from '../../formatters/format-operation'; import type {CollectionInstance} from '../../../../registry/common/entities/collection/types'; +import {Operation, formatOperation} from '../../formatters/format-operation'; + +import {formatCollection} from './format-collection'; export const formatCollectionWithOperation = ( collection: CollectionInstance, diff --git a/src/services/new/collection/formatters/format-collections-list.ts b/src/services/new/collection/formatters/format-collections-list.ts index bedf66e0..97ee8a16 100644 --- a/src/services/new/collection/formatters/format-collections-list.ts +++ b/src/services/new/collection/formatters/format-collections-list.ts @@ -1,4 +1,5 @@ import type {CollectionInstance} from '../../../../registry/common/entities/collection/types'; + import {formatCollection} from './format-collection'; export const formatCollectionsList = ({ diff --git a/src/services/new/collection/get-collection-breadcrumbs.ts b/src/services/new/collection/get-collection-breadcrumbs.ts index 98824cbc..65309b57 100644 --- a/src/services/new/collection/get-collection-breadcrumbs.ts +++ b/src/services/new/collection/get-collection-breadcrumbs.ts @@ -1,12 +1,14 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getParents} from './utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; -import {US_ERRORS} from '../../../const'; + +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import Utils from '../../../utils'; +import {US_ERRORS} from '../../../const'; import {CollectionPermission} from '../../../entities/collection'; -import {Feature, isEnabledFeature} from '../../../components/features'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; + +import {getParents} from './utils/get-parents'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/get-collection-content.ts b/src/services/new/collection/get-collection-content.ts index 35f63b24..a6ff0b41 100644 --- a/src/services/new/collection/get-collection-content.ts +++ b/src/services/new/collection/get-collection-content.ts @@ -1,15 +1,17 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getParentIds} from './utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; -import {CollectionPermission} from '../../../entities/collection'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; +import {CollectionPermission} from '../../../entities/collection'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; import {getWorkbooksList} from '../workbook'; + import {getCollection} from './get-collection'; -import {Feature, isEnabledFeature} from '../../../components/features'; +import {getParentIds} from './utils/get-parents'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/get-collection-root-permissions.ts b/src/services/new/collection/get-collection-root-permissions.ts index a45f8c6c..f081b879 100644 --- a/src/services/new/collection/get-collection-root-permissions.ts +++ b/src/services/new/collection/get-collection-root-permissions.ts @@ -1,8 +1,9 @@ -import {AppError, AppContext} from '@gravity-ui/nodekit'; -import {ServiceArgs} from '../types'; -import {US_ERRORS} from '../../../const'; -import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; +import {AppContext, AppError} from '@gravity-ui/nodekit'; + import {Feature, isEnabledFeature} from '../../../components/features'; +import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; +import {US_ERRORS} from '../../../const'; +import {ServiceArgs} from '../types'; export const getRootCollectionPermissions = async ({ctx}: ServiceArgs) => { ctx.log('GET_ROOT_COLLECTION_PERMISSIONS_START'); diff --git a/src/services/new/collection/get-collection.ts b/src/services/new/collection/get-collection.ts index 43d8a554..d431325c 100644 --- a/src/services/new/collection/get-collection.ts +++ b/src/services/new/collection/get-collection.ts @@ -1,13 +1,14 @@ import {AppError} from '@gravity-ui/nodekit'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {CollectionPermission} from '../../../entities/collection'; +import type {CollectionInstance} from '../../../registry/common/entities/collection/types'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; -import type {CollectionInstance} from '../../../registry/common/entities/collection/types'; import {checkAndSetCollectionPermission} from './utils'; const validateArgs = makeSchemaValidator({ 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 e99c1430..74f10058 100644 --- a/src/services/new/collection/get-collections-list-by-ids.ts +++ b/src/services/new/collection/get-collections-list-by-ids.ts @@ -1,12 +1,13 @@ -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; -import Utils from '../../../utils'; -import {makeCollectionsWithParentsMap} from './utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {CollectionPermission} from '../../../entities/collection'; import {CollectionInstance} from '../../../registry/common/entities/collection/types'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; + +import {makeCollectionsWithParentsMap} from './utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/move-collection.ts b/src/services/new/collection/move-collection.ts index 62122a53..46be7ee7 100644 --- a/src/services/new/collection/move-collection.ts +++ b/src/services/new/collection/move-collection.ts @@ -1,17 +1,19 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getCollection} from './get-collection'; -import {checkCollectionByTitle} from './check-collection-by-title'; -import {getParentIds} from './utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; +import {raw} from 'objection'; + +import {Feature, isEnabledFeature} from '../../../components/features'; +import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CURRENT_TIMESTAMP, US_ERRORS} from '../../../const'; -import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; -import {raw} from 'objection'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; -import Utils from '../../../utils'; import {CollectionPermission} from '../../../entities/collection'; -import {Feature, isEnabledFeature} from '../../../components/features'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkCollectionByTitle} from './check-collection-by-title'; +import {getCollection} from './get-collection'; +import {getParentIds} from './utils/get-parents'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/collection/move-collections-list.ts b/src/services/new/collection/move-collections-list.ts index dce1377b..0dff3117 100644 --- a/src/services/new/collection/move-collections-list.ts +++ b/src/services/new/collection/move-collections-list.ts @@ -1,11 +1,9 @@ -import {getPrimary} from '../utils'; import {transaction} from 'objection'; -import {ServiceArgs} from '../types'; - import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; - import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; import {moveCollection} from './move-collection'; diff --git a/src/services/new/collection/update-collection.ts b/src/services/new/collection/update-collection.ts index ed0142c7..71654c0c 100644 --- a/src/services/new/collection/update-collection.ts +++ b/src/services/new/collection/update-collection.ts @@ -1,15 +1,17 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getCollection} from './get-collection'; -import {checkCollectionByTitle} from './check-collection-by-title'; -import {getParentIds} from './utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; +import {raw} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CURRENT_TIMESTAMP, US_ERRORS} from '../../../const'; -import {raw} from 'objection'; import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; -import Utils from '../../../utils'; import {CollectionPermission} from '../../../entities/collection'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkCollectionByTitle} from './check-collection-by-title'; +import {getCollection} from './get-collection'; +import {getParentIds} from './utils/get-parents'; const validateArgs = makeSchemaValidator({ type: 'object', 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 bbb06e3c..0dccb3e7 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,10 +1,10 @@ -import {getParentIds} from './get-parents'; +import {Feature, isEnabledFeature} from '../../../../components/features'; +import {CollectionPermission} from '../../../../entities/collection'; +import {CollectionInstance} from '../../../../registry/common/entities/collection/types'; import {ServiceArgs} from '../../types'; import {getReplica} from '../../utils'; -import {CollectionPermission} from '../../../../entities/collection'; -import {Feature, isEnabledFeature} from '../../../../components/features'; -import {CollectionInstance} from '../../../../registry/common/entities/collection/types'; +import {getParentIds} from './get-parents'; export interface CheckAndSetCollectionPermissionArgs { collectionInstance: CollectionInstance; diff --git a/src/services/new/collection/utils/get-parents.ts b/src/services/new/collection/utils/get-parents.ts index 14f6285d..a0b6677e 100644 --- a/src/services/new/collection/utils/get-parents.ts +++ b/src/services/new/collection/utils/get-parents.ts @@ -1,11 +1,12 @@ -import {TransactionOrKnex} from 'objection'; import {AppContext} from '@gravity-ui/nodekit'; -import {getReplica} from '../../utils'; +import {TransactionOrKnex} from 'objection'; + import {CollectionModel, CollectionModelColumn} from '../../../../db/models/new/collection'; -import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; +import {WorkbookModel} from '../../../../db/models/new/workbook'; import {CollectionInstance} from '../../../../registry/common/entities/collection/types'; +import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {ServiceArgs} from '../../types'; -import {WorkbookModel} from '../../../../db/models/new/workbook'; +import {getReplica} from '../../utils'; interface Ctx { ctx: AppContext; diff --git a/src/services/new/collection/utils/mark-collections-as-deleted.ts b/src/services/new/collection/utils/mark-collections-as-deleted.ts index 844decd5..fbd29b77 100644 --- a/src/services/new/collection/utils/mark-collections-as-deleted.ts +++ b/src/services/new/collection/utils/mark-collections-as-deleted.ts @@ -1,9 +1,10 @@ import {raw} from 'objection'; + import {CURRENT_TIMESTAMP} from '../../../../const'; -import {ServiceArgs} from '../../types'; -import {getPrimary} from '../../utils'; import {CollectionModel, CollectionModelColumn} from '../../../../db/models/new/collection'; import {CollectionInstance} from '../../../../registry/common/entities/collection/types'; +import {ServiceArgs} from '../../types'; +import {getPrimary} from '../../utils'; export const markCollectionsAsDeleted = async ( {ctx, trx, skipCheckPermissions}: ServiceArgs, diff --git a/src/services/new/entry/copy-entries-to-workbook.ts b/src/services/new/entry/copy-entries-to-workbook.ts index 10dd5562..90b34ec6 100644 --- a/src/services/new/entry/copy-entries-to-workbook.ts +++ b/src/services/new/entry/copy-entries-to-workbook.ts @@ -1,11 +1,12 @@ -import {ServiceArgs} from '../types'; +import {transaction} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {JoinedEntryRevisionColumns} from '../../../db/presentations'; import Utils, {makeUserId} from '../../../utils'; -import {crossSyncCopiedJoinedEntryRevisions} from '../workbook'; -import {transaction} from 'objection'; -import {getPrimary} from '../utils'; import {copyToWorkbook} from '../../entry/actions'; -import {JoinedEntryRevisionColumns} from '../../../db/presentations'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; +import {crossSyncCopiedJoinedEntryRevisions} from '../workbook'; export type CopyEntriesToWorkbookParams = { entryIds: string[]; diff --git a/src/services/new/entry/copy-entry-to-workbook.ts b/src/services/new/entry/copy-entry-to-workbook.ts index 2afd716b..15dd1345 100644 --- a/src/services/new/entry/copy-entry-to-workbook.ts +++ b/src/services/new/entry/copy-entry-to-workbook.ts @@ -1,19 +1,20 @@ import {AppError} from '@gravity-ui/nodekit'; import {transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {BiTrackingLogs, US_ERRORS} from '../../../const'; import {getId} from '../../../db'; import OldEntry from '../../../db/models/entry'; -import {EntryScope} from '../../../db/models/new/entry/types'; import {Entry} from '../../../db/models/new/entry'; +import {EntryScope} from '../../../db/models/new/entry/types'; import {RevisionModel, RevisionModelColumn} from '../../../db/models/new/revision'; +import {WorkbookPermission} from '../../../entities/workbook'; import {SyncLinks} from '../../../types/models/link'; -import {US_ERRORS, BiTrackingLogs} from '../../../const'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import Utils, {makeUserId} from '../../../utils'; -import {WorkbookPermission} from '../../../entities/workbook'; import {ServiceArgs} from '../../new/types'; import {checkWorkbookPermission} from '../../new/workbook/utils/check-workbook-permission'; -import {getWorkbook} from '../workbook'; import {getPrimary} from '../utils'; +import {getWorkbook} from '../workbook'; const validateCopyEntryToWorkbook = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/entry/formatters/format-get-entry-by-key-response.ts b/src/services/new/entry/formatters/format-get-entry-by-key-response.ts index dcd7023f..25d48f91 100644 --- a/src/services/new/entry/formatters/format-get-entry-by-key-response.ts +++ b/src/services/new/entry/formatters/format-get-entry-by-key-response.ts @@ -1,6 +1,6 @@ -import {EntryPermissions} from '../types'; import {JoinedEntryRevisionColumns} from '../../../../db/presentations/joined-entry-revision'; import {CTX} from '../../../../types/models'; +import {EntryPermissions} from '../types'; interface GetEntryByKeyResult { joinedEntryRevision: JoinedEntryRevisionColumns; diff --git a/src/services/new/entry/formatters/format-get-entry-meta-private-response.ts b/src/services/new/entry/formatters/format-get-entry-meta-private-response.ts index 3e03b2da..5ded8bcf 100644 --- a/src/services/new/entry/formatters/format-get-entry-meta-private-response.ts +++ b/src/services/new/entry/formatters/format-get-entry-meta-private-response.ts @@ -1,4 +1,5 @@ import {JoinedEntryRevisionColumns} from '../../../../db/presentations/joined-entry-revision'; + import {formatGetEntryMetaResponse} from './format-get-entry-meta-response'; export const formatGetEntryMetaPrivateResponse = ({ diff --git a/src/services/new/entry/formatters/format-get-entry-response.ts b/src/services/new/entry/formatters/format-get-entry-response.ts index ae98fe5f..832bb048 100644 --- a/src/services/new/entry/formatters/format-get-entry-response.ts +++ b/src/services/new/entry/formatters/format-get-entry-response.ts @@ -1,5 +1,5 @@ -import {CTX} from '../../../../types/models'; import {GetEntryResult} from '../../../../services/new/entry/get-entry'; +import {CTX} from '../../../../types/models'; export const formatGetEntryResponse = async (ctx: CTX, result: GetEntryResult) => { const {joinedEntryRevisionFavorite, permissions, includePermissionsInfo, includeLinks} = result; diff --git a/src/services/new/entry/get-entry-by-key.ts b/src/services/new/entry/get-entry-by-key.ts index 96d2c284..bc6c8682 100644 --- a/src/services/new/entry/get-entry-by-key.ts +++ b/src/services/new/entry/get-entry-by-key.ts @@ -1,18 +1,20 @@ import {AppError} from '@gravity-ui/nodekit'; -import {checkFetchedEntry} from './utils'; -import {EntryPermissions} from './types'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../../const'; +import OldEntry from '../../../db/models/entry'; import {Entry, EntryColumn} from '../../../db/models/new/entry'; +import {RevisionModel} from '../../../db/models/new/revision'; +import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; import {DlsActions} from '../../../types/models'; -import {US_ERRORS} from '../../../const'; import Utils from '../../../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; -import {RevisionModel} from '../../../db/models/new/revision'; -import OldEntry from '../../../db/models/entry'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; import {getWorkbook} from '../workbook'; import {getEntryPermissionsByWorkbook} from '../workbook/utils'; + +import {EntryPermissions} from './types'; +import {checkFetchedEntry} from './utils'; import {validateTenantId} from './validators'; const validateGetEntryByKey = makeSchemaValidator({ diff --git a/src/services/new/entry/get-entry-meta-private.ts b/src/services/new/entry/get-entry-meta-private.ts index 4912f420..8b5aa206 100644 --- a/src/services/new/entry/get-entry-meta-private.ts +++ b/src/services/new/entry/get-entry-meta-private.ts @@ -1,12 +1,14 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getEntryMeta} from './get-entry-meta'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; -import {DlsActions} from '../../../types/models'; + import {US_ERRORS} from '../../../const'; +import {DlsActions} from '../../../types/models'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; import {getWorkbook} from '../workbook'; +import {getEntryMeta} from './get-entry-meta'; + export type GetEntryMetaPrivateArgs = { entryId: string; masterToken: string; diff --git a/src/services/new/entry/get-entry-meta.ts b/src/services/new/entry/get-entry-meta.ts index f7753b83..8db0d3be 100644 --- a/src/services/new/entry/get-entry-meta.ts +++ b/src/services/new/entry/get-entry-meta.ts @@ -1,15 +1,17 @@ import {AppError} from '@gravity-ui/nodekit'; -import {checkFetchedEntry} from './utils'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../../const'; import {Entry} from '../../../db/models/new/entry'; +import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; import {DlsActions} from '../../../types/models'; -import {US_ERRORS} from '../../../const'; import Utils from '../../../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {JoinedEntryRevision} from '../../../db/presentations/joined-entry-revision'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; import {getWorkbook} from '../workbook'; +import {checkFetchedEntry} from './utils'; + const validateArgs = makeSchemaValidator({ type: 'object', required: ['entryId'], diff --git a/src/services/new/entry/get-entry.ts b/src/services/new/entry/get-entry.ts index 96e4adb0..6954a171 100644 --- a/src/services/new/entry/get-entry.ts +++ b/src/services/new/entry/get-entry.ts @@ -1,8 +1,9 @@ import {AppError} from '@gravity-ui/nodekit'; -import {EntryPermissions} from './types'; -import {checkFetchedEntry, checkWorkbookIsolation} from './utils'; -import {getReplica} from '../utils'; -import {ServiceArgs} from '../types'; + +import {Feature, isEnabledFeature} from '../../../components/features'; +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../../const'; +import OldEntry from '../../../db/models/entry'; import {Entry, EntryColumn} from '../../../db/models/new/entry'; import { JoinedEntryRevisionFavorite, @@ -10,12 +11,13 @@ import { } from '../../../db/presentations/joined-entry-revision-favorite'; import {DlsActions} from '../../../types/models'; import Utils from '../../../utils'; -import {US_ERRORS} from '../../../const'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import OldEntry from '../../../db/models/entry'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; import {getWorkbook} from '../workbook'; import {getEntryPermissionsByWorkbook} from '../workbook/utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; + +import {EntryPermissions} from './types'; +import {checkFetchedEntry, checkWorkbookIsolation} from './utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/entry/utils/check-entry.ts b/src/services/new/entry/utils/check-entry.ts index d2296344..4e408784 100644 --- a/src/services/new/entry/utils/check-entry.ts +++ b/src/services/new/entry/utils/check-entry.ts @@ -1,8 +1,10 @@ -import {TransactionOrKnex} from 'objection'; import {AppError} from '@gravity-ui/nodekit'; +import {TransactionOrKnex} from 'objection'; + +import {DEFAULT_QUERY_TIMEOUT, US_ERRORS} from '../../../../const'; import {Entry} from '../../../../db/models/new/entry'; import {CTX} from '../../../../types/models'; -import {US_ERRORS, DEFAULT_QUERY_TIMEOUT} from '../../../../const'; + import {checkFetchedEntry} from './check-fetched-entry'; export const checkEntry = async (ctx: CTX, entryId: string, trx: TransactionOrKnex) => { diff --git a/src/services/new/entry/utils/check-fetched-entry.ts b/src/services/new/entry/utils/check-fetched-entry.ts index 8ca2611c..deab3a7f 100644 --- a/src/services/new/entry/utils/check-fetched-entry.ts +++ b/src/services/new/entry/utils/check-fetched-entry.ts @@ -1,10 +1,11 @@ -import {TransactionOrKnex} from 'objection'; import {AppError} from '@gravity-ui/nodekit'; +import {TransactionOrKnex} from 'objection'; + +import {makeSchemaValidator} from '../../../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../../../const'; import {Entry} from '../../../../db/models/new/entry'; import {CTX} from '../../../../types/models'; -import {US_ERRORS} from '../../../../const'; import {getWorkbook} from '../../../new/workbook/get-workbook'; -import {makeSchemaValidator} from '../../../../components/validation-schema-compiler'; const validateVerifiableEntry = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/entry/utils/check-workbook-isolation.ts b/src/services/new/entry/utils/check-workbook-isolation.ts index 282a53f5..fc7e72a0 100644 --- a/src/services/new/entry/utils/check-workbook-isolation.ts +++ b/src/services/new/entry/utils/check-workbook-isolation.ts @@ -1,4 +1,5 @@ import {AppError} from '@gravity-ui/nodekit'; + import {US_ERRORS} from '../../../../const'; import {CTX} from '../../../../types/models'; 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 38db57cc..31b642a4 100644 --- a/src/services/new/entry/utils/filter-entries-by-permission.ts +++ b/src/services/new/entry/utils/filter-entries-by-permission.ts @@ -1,10 +1,10 @@ +import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {DlsActions, EntryScope} from '../../../../types/models'; +import {ServiceArgs} from '../../types'; +import {getReplica} from '../../utils'; import {getWorkbooksListByIds} from '../../workbook/get-workbooks-list-by-ids'; -import {EntryPermissions} from '../types'; -import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {getEntryPermissionsByWorkbook} from '../../workbook/utils'; -import {getReplica} from '../../utils'; -import {ServiceArgs} from '../../types'; +import {EntryPermissions} from '../types'; type Permission = 'execute' | 'read' | 'edit' | 'admin'; diff --git a/src/services/new/state/create-state.ts b/src/services/new/state/create-state.ts index 256727e6..c8178ba7 100644 --- a/src/services/new/state/create-state.ts +++ b/src/services/new/state/create-state.ts @@ -1,7 +1,7 @@ -import {ServiceArgs} from '../types'; import hashGenerator from '../../../components/hash-generator'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {State} from '../../../db/models/new/state'; +import {ServiceArgs} from '../types'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/state/get-state.ts b/src/services/new/state/get-state.ts index 9b8155ae..65fc3de9 100644 --- a/src/services/new/state/get-state.ts +++ b/src/services/new/state/get-state.ts @@ -1,7 +1,8 @@ -import {ServiceArgs} from '../types'; import {AppError} from '@gravity-ui/nodekit'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {State} from '../../../db/models/new/state'; +import {ServiceArgs} from '../types'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/structure-item/formatters/format-structure-items.ts b/src/services/new/structure-item/formatters/format-structure-items.ts index 733a67e4..43fb7ed2 100644 --- a/src/services/new/structure-item/formatters/format-structure-items.ts +++ b/src/services/new/structure-item/formatters/format-structure-items.ts @@ -1,8 +1,8 @@ import type {CollectionInstance} from '../../../../registry/common/entities/collection/types'; import {isWorkbookInstance} from '../../../../registry/common/entities/structure-item/types'; +import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {formatCollection} from '../../collection/formatters'; import {formatWorkbook} from '../../workbook/formatters'; -import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; export const formatStructureItems = ({ items, diff --git a/src/services/new/structure-item/get-structure-items.ts b/src/services/new/structure-item/get-structure-items.ts index bb6e657e..c45a1a5b 100644 --- a/src/services/new/structure-item/get-structure-items.ts +++ b/src/services/new/structure-item/get-structure-items.ts @@ -1,12 +1,13 @@ -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {CollectionPermission} from '../../../entities/collection'; import {CollectionModel} from '../../../db/models/new/collection'; +import {CollectionPermission} from '../../../entities/collection'; import Utils from '../../../utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; import {getCollection} from '../collection'; import {getParentIds} from '../collection/utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; + import {getCollectionsQuery, getWorkbooksQuery, processPermissions} from './utils'; const validateArgs = makeSchemaValidator({ diff --git a/src/services/new/structure-item/utils.ts b/src/services/new/structure-item/utils.ts index e68ebfb8..4721f7ca 100644 --- a/src/services/new/structure-item/utils.ts +++ b/src/services/new/structure-item/utils.ts @@ -1,17 +1,18 @@ -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; -import {raw} from 'objection'; -import Utils from '../../../utils'; -import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; -import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; import {AppContext, AppError} from '@gravity-ui/nodekit'; -import {isWorkbookInstance} from '../../../registry/common/entities/structure-item/types'; +import {raw} from 'objection'; + import {Feature, isEnabledFeature} from '../../../components/features'; -import {WorkbookPermission} from '../../../entities/workbook'; -import {CollectionPermission} from '../../../entities/collection'; import {US_ERRORS} from '../../../const'; +import {CollectionModel, CollectionModelColumn} from '../../../db/models/new/collection'; +import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; +import {CollectionPermission} from '../../../entities/collection'; +import {WorkbookPermission} from '../../../entities/workbook'; import {CollectionInstance} from '../../../registry/common/entities/collection/types'; +import {isWorkbookInstance} from '../../../registry/common/entities/structure-item/types'; import {WorkbookInstance} from '../../../registry/common/entities/workbook/types'; +import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; interface GetWorkbooksQueryArgs { collectionId: Nullable; diff --git a/src/services/new/types.ts b/src/services/new/types.ts index 3378cfb0..4145842a 100644 --- a/src/services/new/types.ts +++ b/src/services/new/types.ts @@ -1,5 +1,5 @@ -import {TransactionOrKnex} from 'objection'; import {AppContext} from '@gravity-ui/nodekit'; +import {TransactionOrKnex} from 'objection'; export interface ServiceArgs { ctx: AppContext; diff --git a/src/services/new/utils/get-trx.ts b/src/services/new/utils/get-trx.ts index c495b26d..bdfb47bf 100644 --- a/src/services/new/utils/get-trx.ts +++ b/src/services/new/utils/get-trx.ts @@ -1,4 +1,5 @@ import {TransactionOrKnex} from 'objection'; + import {Model} from '../../../db'; export const getPrimary = (trx?: TransactionOrKnex) => { diff --git a/src/services/new/workbook/check-workbook-by-title.ts b/src/services/new/workbook/check-workbook-by-title.ts index 35c0d064..f97feeb3 100644 --- a/src/services/new/workbook/check-workbook-by-title.ts +++ b/src/services/new/workbook/check-workbook-by-title.ts @@ -1,9 +1,9 @@ -import {getCollection} from '../collection'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import Utils from '../../../utils'; +import {getCollection} from '../collection'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/copy-workbook-template.ts b/src/services/new/workbook/copy-workbook-template.ts index 2095b618..a54a2e9b 100644 --- a/src/services/new/workbook/copy-workbook-template.ts +++ b/src/services/new/workbook/copy-workbook-template.ts @@ -1,11 +1,13 @@ import {AppError} from '@gravity-ui/nodekit'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {US_ERRORS} from '../../../const'; import {WorkbookModel} from '../../../db/models/new/workbook'; +import Utils from '../../../utils'; import {ServiceArgs} from '../types'; import {getReplica} from '../utils'; -import Utils from '../../../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; + import {copyWorkbook} from './copy-workbook'; -import {US_ERRORS} from '../../../const'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/copy-workbook.ts b/src/services/new/workbook/copy-workbook.ts index 11d9a32c..555d9371 100644 --- a/src/services/new/workbook/copy-workbook.ts +++ b/src/services/new/workbook/copy-workbook.ts @@ -1,19 +1,20 @@ +import {AppContext, AppError} from '@gravity-ui/nodekit'; import {TransactionOrKnex, transaction} from 'objection'; -import {AppError, AppContext} from '@gravity-ui/nodekit'; -import {getParentIds} from '../collection/utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary, getReplica} from '../utils'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; -import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; -import {JoinedEntryRevisionColumns} from '../../../db/presentations/joined-entry-revision'; -import {RevisionModel} from '../../../db/models/new/revision'; import Link from '../../../db/models/links'; import {Entry} from '../../../db/models/new/entry'; +import {RevisionModel} from '../../../db/models/new/revision'; +import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; +import {JoinedEntryRevisionColumns} from '../../../db/presentations/joined-entry-revision'; import {WorkbookPermission} from '../../../entities/workbook'; import Utils from '../../../utils'; import {copyToWorkbook} from '../../entry/actions'; import {getCollection} from '../collection'; +import {getParentIds} from '../collection/utils/get-parents'; +import {ServiceArgs} from '../types'; +import {getPrimary, getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/create-workbook.ts b/src/services/new/workbook/create-workbook.ts index f56a8dd3..885d2d76 100644 --- a/src/services/new/workbook/create-workbook.ts +++ b/src/services/new/workbook/create-workbook.ts @@ -1,13 +1,15 @@ import {AppError} from '@gravity-ui/nodekit'; -import {checkWorkbookByTitle} from './check-workbook-by-title'; -import {getParentIds} from '../collection/utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; -import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {transaction} from 'objection'; + +import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import Utils from '../../../utils'; +import {getParentIds} from '../collection/utils/get-parents'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkWorkbookByTitle} from './check-workbook-by-title'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/delete-workbooks.ts b/src/services/new/workbook/delete-workbooks.ts index ffec8af6..16d4ae9c 100644 --- a/src/services/new/workbook/delete-workbooks.ts +++ b/src/services/new/workbook/delete-workbooks.ts @@ -1,18 +1,20 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getParentIds} from '../collection/utils/get-parents'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; +import {transaction} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {US_ERRORS} from '../../../const'; -import {transaction} from 'objection'; import Lock from '../../../db/models/lock'; import {Entry, EntryColumn} from '../../../db/models/new/entry'; -import Utils, {makeUserId} from '../../../utils'; import {WorkbookPermission} from '../../../entities/workbook'; +import {WorkbookInstance} from '../../../registry/common/entities/workbook/types'; +import Utils, {makeUserId} from '../../../utils'; import {markEntryAsDeleted} from '../../entry/crud'; +import {getParentIds} from '../collection/utils/get-parents'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + import {getWorkbooksListByIds} from './get-workbooks-list-by-ids'; import {markWorkbooksAsDeleted} from './utils'; -import {WorkbookInstance} from '../../../registry/common/entities/workbook/types'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/formatters/format-get-workbook-content.ts b/src/services/new/workbook/formatters/format-get-workbook-content.ts index 2cc9dc8e..54e85205 100644 --- a/src/services/new/workbook/formatters/format-get-workbook-content.ts +++ b/src/services/new/workbook/formatters/format-get-workbook-content.ts @@ -1,5 +1,5 @@ -import {EntryPermissions} from '../../entry/types'; import {JoinedEntryRevisionFavoriteColumns} from '../../../../db/presentations/joined-entry-revision-favorite'; +import {EntryPermissions} from '../../entry/types'; export type GetContentResult = { permissions?: EntryPermissions; diff --git a/src/services/new/workbook/formatters/format-workbook-model-with-operation.ts b/src/services/new/workbook/formatters/format-workbook-model-with-operation.ts index 6fc28bf5..a857c3e7 100644 --- a/src/services/new/workbook/formatters/format-workbook-model-with-operation.ts +++ b/src/services/new/workbook/formatters/format-workbook-model-with-operation.ts @@ -1,6 +1,7 @@ -import {formatWorkbookModel} from './format-workbook-model'; -import {formatOperation, Operation} from '../../formatters/format-operation'; import {WorkbookModel} from '../../../../db/models/new/workbook'; +import {Operation, formatOperation} from '../../formatters/format-operation'; + +import {formatWorkbookModel} from './format-workbook-model'; export const formatWorkbookModelWithOperation = ( workbookModel: WorkbookModel, diff --git a/src/services/new/workbook/formatters/format-workbook-models-list.ts b/src/services/new/workbook/formatters/format-workbook-models-list.ts index 780c4e1b..dfbaa2ce 100644 --- a/src/services/new/workbook/formatters/format-workbook-models-list.ts +++ b/src/services/new/workbook/formatters/format-workbook-models-list.ts @@ -1,4 +1,5 @@ import {WorkbookModel} from '../../../../db/models/new/workbook'; + import {formatWorkbookModel} from './format-workbook-model'; export const formatWorkbookModelsList = ({ diff --git a/src/services/new/workbook/formatters/format-workbook-with-operation.ts b/src/services/new/workbook/formatters/format-workbook-with-operation.ts index 1b6459e9..5cf9162c 100644 --- a/src/services/new/workbook/formatters/format-workbook-with-operation.ts +++ b/src/services/new/workbook/formatters/format-workbook-with-operation.ts @@ -1,6 +1,7 @@ -import {formatWorkbook} from './format-workbook'; -import {formatOperation, Operation} from '../../formatters/format-operation'; import type {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; +import {Operation, formatOperation} from '../../formatters/format-operation'; + +import {formatWorkbook} from './format-workbook'; export const formatWorkbookWithOperation = (workbook: WorkbookInstance, operation?: unknown) => { return { diff --git a/src/services/new/workbook/formatters/format-workbooks-list.ts b/src/services/new/workbook/formatters/format-workbooks-list.ts index 632d554b..1afd2721 100644 --- a/src/services/new/workbook/formatters/format-workbooks-list.ts +++ b/src/services/new/workbook/formatters/format-workbooks-list.ts @@ -1,4 +1,5 @@ import type {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; + import {formatWorkbook} from './format-workbook'; export const formatWorkbooksList = ({ diff --git a/src/services/new/workbook/get-all-workbooks.ts b/src/services/new/workbook/get-all-workbooks.ts index cc23d541..b09a7a48 100644 --- a/src/services/new/workbook/get-all-workbooks.ts +++ b/src/services/new/workbook/get-all-workbooks.ts @@ -1,9 +1,9 @@ -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {DEFAULT_PAGE, DEFAULT_PAGE_SIZE} from '../../../const'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/get-workbook-content.ts b/src/services/new/workbook/get-workbook-content.ts index fb3f56a4..aa7eb06a 100644 --- a/src/services/new/workbook/get-workbook-content.ts +++ b/src/services/new/workbook/get-workbook-content.ts @@ -1,15 +1,15 @@ +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'; -import Utils from '../../../utils'; +import {JoinedEntryRevisionFavorite} from '../../../db/presentations'; import {UsPermission} from '../../../types/models'; +import Utils from '../../../utils'; import {ServiceArgs} from '../types'; import {getReplica} from '../utils'; + import {getWorkbook} from './get-workbook'; import {getEntryPermissionsByWorkbook} from './utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; - -import {JoinedEntryRevisionFavorite} from '../../../db/presentations'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/get-workbook.ts b/src/services/new/workbook/get-workbook.ts index ecb101e0..d0ea83df 100644 --- a/src/services/new/workbook/get-workbook.ts +++ b/src/services/new/workbook/get-workbook.ts @@ -1,14 +1,15 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getParentIds} from '../collection/utils'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + +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'; import {WorkbookPermission} from '../../../entities/workbook'; -import Utils from '../../../utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; import type {WorkbookInstance} from '../../../registry/common/entities/workbook/types'; +import Utils from '../../../utils'; +import {getParentIds} from '../collection/utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', 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 2ffea732..0d598b6a 100644 --- a/src/services/new/workbook/get-workbooks-list-by-ids.ts +++ b/src/services/new/workbook/get-workbooks-list-by-ids.ts @@ -1,16 +1,12 @@ -import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; -import Utils from '../../../utils'; - -import {makeWorkbooksWithParentsMap} from '../collection/utils'; - +import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import {WorkbookPermission} from '../../../entities/workbook'; - -import {Feature, isEnabledFeature} from '../../../components/features'; - import {WorkbookInstance} from '../../../registry/common/entities/workbook/types'; +import Utils from '../../../utils'; +import {makeWorkbooksWithParentsMap} from '../collection/utils'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/get-workbooks-list.ts b/src/services/new/workbook/get-workbooks-list.ts index 6d9bdffc..4acaef0b 100644 --- a/src/services/new/workbook/get-workbooks-list.ts +++ b/src/services/new/workbook/get-workbooks-list.ts @@ -1,15 +1,16 @@ import {AppError} from '@gravity-ui/nodekit'; -import {ServiceArgs} from '../types'; -import {getReplica} from '../utils'; + +import {Feature, isEnabledFeature} from '../../../components/features'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; -import {US_ERRORS, DEFAULT_PAGE, DEFAULT_PAGE_SIZE} from '../../../const'; -import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; +import {DEFAULT_PAGE, DEFAULT_PAGE_SIZE, US_ERRORS} from '../../../const'; import {CollectionModel} from '../../../db/models/new/collection'; -import Utils from '../../../utils'; -import {WorkbookPermission} from '../../../entities/workbook'; +import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import {CollectionPermission} from '../../../entities/collection'; +import {WorkbookPermission} from '../../../entities/workbook'; +import Utils from '../../../utils'; import {getParents} from '../collection/utils'; -import {Feature, isEnabledFeature} from '../../../components/features'; +import {ServiceArgs} from '../types'; +import {getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/move-workbook.ts b/src/services/new/workbook/move-workbook.ts index bd7b592b..22ab149e 100644 --- a/src/services/new/workbook/move-workbook.ts +++ b/src/services/new/workbook/move-workbook.ts @@ -1,19 +1,21 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getWorkbook} from './get-workbook'; -import {checkWorkbookByTitle} from './check-workbook-by-title'; -import {getParentIds} from '../collection/utils'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; +import {raw} from 'objection'; + +import {Feature, isEnabledFeature} from '../../../components/features'; +import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CURRENT_TIMESTAMP, US_ERRORS} from '../../../const'; -import {OrganizationPermission, ProjectPermission} from '../../../components/iam'; -import {raw} from 'objection'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; -import Utils from '../../../utils'; -import {WorkbookPermission} from '../../../entities/workbook'; import {CollectionPermission} from '../../../entities/collection'; +import {WorkbookPermission} from '../../../entities/workbook'; +import Utils from '../../../utils'; import {getCollection} from '../collection'; -import {Feature, isEnabledFeature} from '../../../components/features'; +import {getParentIds} from '../collection/utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkWorkbookByTitle} from './check-workbook-by-title'; +import {getWorkbook} from './get-workbook'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/move-workbooks-list.ts b/src/services/new/workbook/move-workbooks-list.ts index 833dff1f..2cf94659 100644 --- a/src/services/new/workbook/move-workbooks-list.ts +++ b/src/services/new/workbook/move-workbooks-list.ts @@ -1,11 +1,9 @@ -import {getPrimary} from '../utils'; import {transaction} from 'objection'; -import {ServiceArgs} from '../types'; - import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; - import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; import {moveWorkbook} from './move-workbook'; diff --git a/src/services/new/workbook/restore-workbook.ts b/src/services/new/workbook/restore-workbook.ts index ea2f731d..27a0a1c9 100644 --- a/src/services/new/workbook/restore-workbook.ts +++ b/src/services/new/workbook/restore-workbook.ts @@ -1,13 +1,13 @@ -import {transaction, raw} from 'objection'; import {AppError} from '@gravity-ui/nodekit'; -import {ServiceArgs} from '../types'; -import {getReplica, getPrimary} from '../utils'; +import {raw, transaction} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; +import {CURRENT_TIMESTAMP, DEFAULT_QUERY_TIMEOUT, TRASH_FOLDER, US_ERRORS} from '../../../const'; +import {Entry, EntryColumn} from '../../../db/models/new/entry'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; import Utils from '../../../utils'; -import {Entry, EntryColumn} from '../../../db/models/new/entry'; - -import {US_ERRORS, CURRENT_TIMESTAMP, DEFAULT_QUERY_TIMEOUT, TRASH_FOLDER} from '../../../const'; +import {ServiceArgs} from '../types'; +import {getPrimary, getReplica} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/set-workbook-is-template.ts b/src/services/new/workbook/set-workbook-is-template.ts index db228e5e..172856ee 100644 --- a/src/services/new/workbook/set-workbook-is-template.ts +++ b/src/services/new/workbook/set-workbook-is-template.ts @@ -1,8 +1,8 @@ -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {WorkbookModel} from '../../../db/models/new/workbook'; import Utils from '../../../utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/update-workbook.ts b/src/services/new/workbook/update-workbook.ts index 8b1cf743..9877b4b9 100644 --- a/src/services/new/workbook/update-workbook.ts +++ b/src/services/new/workbook/update-workbook.ts @@ -1,15 +1,17 @@ import {AppError} from '@gravity-ui/nodekit'; -import {getWorkbook} from './get-workbook'; -import {checkWorkbookByTitle} from './check-workbook-by-title'; -import {getParentIds} from '../collection/utils'; -import {ServiceArgs} from '../types'; -import {getPrimary} from '../utils'; +import {raw} from 'objection'; + import {makeSchemaValidator} from '../../../components/validation-schema-compiler'; import {CURRENT_TIMESTAMP, US_ERRORS} from '../../../const'; -import {raw} from 'objection'; import {WorkbookModel, WorkbookModelColumn} from '../../../db/models/new/workbook'; -import Utils from '../../../utils'; import {WorkbookPermission} from '../../../entities/workbook'; +import Utils from '../../../utils'; +import {getParentIds} from '../collection/utils'; +import {ServiceArgs} from '../types'; +import {getPrimary} from '../utils'; + +import {checkWorkbookByTitle} from './check-workbook-by-title'; +import {getWorkbook} from './get-workbook'; const validateArgs = makeSchemaValidator({ type: 'object', diff --git a/src/services/new/workbook/utils/check-workbook-permission.ts b/src/services/new/workbook/utils/check-workbook-permission.ts index c7143927..df373ce8 100644 --- a/src/services/new/workbook/utils/check-workbook-permission.ts +++ b/src/services/new/workbook/utils/check-workbook-permission.ts @@ -1,8 +1,9 @@ import {AppContext} from '@gravity-ui/nodekit'; import {TransactionOrKnex} from 'objection'; + import {WorkbookPermission} from '../../../../entities/workbook'; -import {getParentIds} from '../../collection/utils'; import type {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; +import {getParentIds} from '../../collection/utils'; export const checkWorkbookPermission = async ({ ctx, 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 bebcab0d..83502f49 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,9 +1,10 @@ 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 {Feature, isEnabledFeature} from '../../../../components/features'; import type {EntryScope as EntryScopeType} from '../../../../types/models'; -import {EntryScope} from '../../../../db/models/new/entry/types'; export const getEntryPermissionsByWorkbook = ({ ctx, diff --git a/src/services/new/workbook/utils/mark-workbooks-as-deleted.ts b/src/services/new/workbook/utils/mark-workbooks-as-deleted.ts index f31a29b3..3abf7e84 100644 --- a/src/services/new/workbook/utils/mark-workbooks-as-deleted.ts +++ b/src/services/new/workbook/utils/mark-workbooks-as-deleted.ts @@ -1,9 +1,10 @@ import {raw} from 'objection'; + import {CURRENT_TIMESTAMP} from '../../../../const'; +import {WorkbookModel, WorkbookModelColumn} from '../../../../db/models/new/workbook'; +import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; import {ServiceArgs} from '../../types'; import {getPrimary} from '../../utils'; -import {WorkbookInstance} from '../../../../registry/common/entities/workbook/types'; -import {WorkbookModel, WorkbookModelColumn} from '../../../../db/models/new/workbook'; export const markWorkbooksAsDeleted = async ( {ctx, trx, skipCheckPermissions}: ServiceArgs, diff --git a/src/tests/int/auth.ts b/src/tests/int/auth.ts index aee32b42..1d2e2bfd 100644 --- a/src/tests/int/auth.ts +++ b/src/tests/int/auth.ts @@ -1,6 +1,7 @@ import request from 'supertest'; -import {US_ERRORS, US_MASTER_TOKEN_HEADER} from '../../const'; + import usApp from '../..'; +import {US_ERRORS, US_MASTER_TOKEN_HEADER} from '../../const'; export type CommonAuthArgs = { userId?: string; diff --git a/src/tests/int/env/opensource/auth.ts b/src/tests/int/env/opensource/auth.ts index 7f5e4c87..70802616 100644 --- a/src/tests/int/env/opensource/auth.ts +++ b/src/tests/int/env/opensource/auth.ts @@ -1,9 +1,11 @@ import request from 'supertest'; + +import {AUTHORIZATION_HEADER, DL_AUTH_HEADER_KEY} from '../../../../const'; +import {ZitadelUserRole} from '../../../../types/zitadel'; import type {CommonAuthArgs} from '../../auth'; import {testUserId, testUserLogin} from '../../constants'; -import {AUTHORIZATION_HEADER, DL_AUTH_HEADER_KEY} from '../../../../const'; + import {OpensourceRole} from './roles'; -import {ZitadelUserRole} from '../../../../types/zitadel'; export {US_ERRORS, app, appConfig, testTenantId, testProjectId, authMasterToken} from '../../auth'; diff --git a/src/tests/int/env/opensource/helpers.ts b/src/tests/int/env/opensource/helpers.ts index 457933d2..18e77565 100644 --- a/src/tests/int/env/opensource/helpers.ts +++ b/src/tests/int/env/opensource/helpers.ts @@ -1,6 +1,8 @@ import request from 'supertest'; -import {app, auth, testTenantId, authMasterToken, AuthArgs} from './auth'; + import {routes} from '../../routes'; + +import {AuthArgs, app, auth, authMasterToken, testTenantId} from './auth'; import {OpensourceRole} from './roles'; export const mockWorkbookEntry = { diff --git a/src/tests/int/env/opensource/suites/collections/create-get.test.ts b/src/tests/int/env/opensource/suites/collections/create-get.test.ts index f5958c8c..8c819029 100644 --- a/src/tests/int/env/opensource/suites/collections/create-get.test.ts +++ b/src/tests/int/env/opensource/suites/collections/create-get.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS, OPERATION_DEFAULT_FIELDS} from '../../../../models'; import {routes} from '../../../../routes'; -import {OpensourceRole} from '../../roles'; import {app, auth} from '../../auth'; -import {OPERATION_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {OpensourceRole} from '../../roles'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/opensource/suites/collections/delete-list.test.ts b/src/tests/int/env/opensource/suites/collections/delete-list.test.ts index f9633a15..5c9812b4 100644 --- a/src/tests/int/env/opensource/suites/collections/delete-list.test.ts +++ b/src/tests/int/env/opensource/suites/collections/delete-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const emptyRootCollection = { diff --git a/src/tests/int/env/opensource/suites/collections/delete.test.ts b/src/tests/int/env/opensource/suites/collections/delete.test.ts index 1977e40a..6b5a27ac 100644 --- a/src/tests/int/env/opensource/suites/collections/delete.test.ts +++ b/src/tests/int/env/opensource/suites/collections/delete.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const emptyRootCollection = { diff --git a/src/tests/int/env/opensource/suites/collections/get-breadcrumbs.test.ts b/src/tests/int/env/opensource/suites/collections/get-breadcrumbs.test.ts index e178bd25..f2fbbddb 100644 --- a/src/tests/int/env/opensource/suites/collections/get-breadcrumbs.test.ts +++ b/src/tests/int/env/opensource/suites/collections/get-breadcrumbs.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/opensource/suites/collections/get-content.test.ts b/src/tests/int/env/opensource/suites/collections/get-content.test.ts index 69577d7a..7478af9c 100644 --- a/src/tests/int/env/opensource/suites/collections/get-content.test.ts +++ b/src/tests/int/env/opensource/suites/collections/get-content.test.ts @@ -1,13 +1,14 @@ import request from 'supertest'; -import {app, auth} from '../../auth'; -import {createMockCollection, createMockWorkbook} from '../../helpers'; + import {testOtherUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import { COLLECTIONS_DEFAULT_FIELDS, - WORKBOOK_DEFAULT_FIELDS, GET_COLLECTION_CONTENT_DEFAULT_FIELDS, + WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, auth} from '../../auth'; +import {createMockCollection, createMockWorkbook} from '../../helpers'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/opensource/suites/collections/get-root-permissions.test.ts b/src/tests/int/env/opensource/suites/collections/get-root-permissions.test.ts index 5450ea91..53e5ee61 100644 --- a/src/tests/int/env/opensource/suites/collections/get-root-permissions.test.ts +++ b/src/tests/int/env/opensource/suites/collections/get-root-permissions.test.ts @@ -1,6 +1,7 @@ import request from 'supertest'; -import {app, auth} from '../../auth'; + import {routes} from '../../../../routes'; +import {app, auth} from '../../auth'; import {OpensourceRole} from '../../roles'; describe('Getting root collection permissions', () => { diff --git a/src/tests/int/env/opensource/suites/collections/get-structure-items.test.ts b/src/tests/int/env/opensource/suites/collections/get-structure-items.test.ts index fb618f83..fa03ca2c 100644 --- a/src/tests/int/env/opensource/suites/collections/get-structure-items.test.ts +++ b/src/tests/int/env/opensource/suites/collections/get-structure-items.test.ts @@ -1,13 +1,14 @@ import request from 'supertest'; -import {app, auth} from '../../auth'; -import {createMockCollection, createMockWorkbook} from '../../helpers'; + import {testOtherUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import { COLLECTIONS_DEFAULT_FIELDS, - WORKBOOK_DEFAULT_FIELDS, GET_STRUCTURE_ITEMS_DEFAULT_FIELDS, + WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, auth} from '../../auth'; +import {createMockCollection, createMockWorkbook} from '../../helpers'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/opensource/suites/collections/move-list.test.ts b/src/tests/int/env/opensource/suites/collections/move-list.test.ts index bc5e6eeb..43d86ccb 100644 --- a/src/tests/int/env/opensource/suites/collections/move-list.test.ts +++ b/src/tests/int/env/opensource/suites/collections/move-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const rootCollection = { diff --git a/src/tests/int/env/opensource/suites/collections/move.test.ts b/src/tests/int/env/opensource/suites/collections/move.test.ts index c2d4acaf..9e671aa4 100644 --- a/src/tests/int/env/opensource/suites/collections/move.test.ts +++ b/src/tests/int/env/opensource/suites/collections/move.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const rootCollection = { diff --git a/src/tests/int/env/opensource/suites/collections/private.test.ts b/src/tests/int/env/opensource/suites/collections/private.test.ts index b4609fdc..fa8e3b26 100644 --- a/src/tests/int/env/opensource/suites/collections/private.test.ts +++ b/src/tests/int/env/opensource/suites/collections/private.test.ts @@ -1,7 +1,8 @@ import request from 'supertest'; -import {app, authMasterToken} from '../../auth'; -import {routes} from '../../../../routes'; + import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, authMasterToken} from '../../auth'; const testCollection = { collectionId: '', diff --git a/src/tests/int/env/opensource/suites/collections/update.test.ts b/src/tests/int/env/opensource/suites/collections/update.test.ts index c3dc7dd5..03842738 100644 --- a/src/tests/int/env/opensource/suites/collections/update.test.ts +++ b/src/tests/int/env/opensource/suites/collections/update.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const testCollection = { diff --git a/src/tests/int/env/opensource/suites/favorites.test.ts b/src/tests/int/env/opensource/suites/favorites.test.ts index cfa18aa3..237be02d 100644 --- a/src/tests/int/env/opensource/suites/favorites.test.ts +++ b/src/tests/int/env/opensource/suites/favorites.test.ts @@ -1,10 +1,11 @@ import request from 'supertest'; -import {testUserLogin, testUserId} from '../../../constants'; + +import {makeUserId} from '../../../../../utils'; +import {testUserId, testUserLogin} from '../../../constants'; +import {GET_FAVORITES_ENTRY_DEFAULT_FIELDS, MODIFY_FAVORITES_DEFAULT_FIELDS} from '../../../models'; import {routes} from '../../../routes'; import {app, auth, testTenantId} from '../auth'; import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; -import {makeUserId} from '../../../../../utils'; -import {MODIFY_FAVORITES_DEFAULT_FIELDS, GET_FAVORITES_ENTRY_DEFAULT_FIELDS} from '../../../models'; import {OpensourceRole} from '../roles'; let workbookId: string; diff --git a/src/tests/int/env/opensource/suites/health-check.test.ts b/src/tests/int/env/opensource/suites/health-check.test.ts index 38b6cef4..7d72531e 100644 --- a/src/tests/int/env/opensource/suites/health-check.test.ts +++ b/src/tests/int/env/opensource/suites/health-check.test.ts @@ -1,4 +1,5 @@ import request from 'supertest'; + import {app} from '../auth'; describe('Check ping endpoints', () => { diff --git a/src/tests/int/env/opensource/suites/locks.test.ts b/src/tests/int/env/opensource/suites/locks.test.ts index 1890fff8..51452a13 100644 --- a/src/tests/int/env/opensource/suites/locks.test.ts +++ b/src/tests/int/env/opensource/suites/locks.test.ts @@ -1,9 +1,10 @@ import request from 'supertest'; -import {app, auth, US_ERRORS} from '../auth'; -import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; + import {testUserLogin} from '../../../constants'; -import {routes} from '../../../routes'; import {LOCK_DEFAULT_FIELDS} from '../../../models'; +import {routes} from '../../../routes'; +import {US_ERRORS, app, auth} from '../auth'; +import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; import {OpensourceRole} from '../roles'; let workbookId: string; diff --git a/src/tests/int/env/opensource/suites/states.test.ts b/src/tests/int/env/opensource/suites/states.test.ts index 4df71075..a08562c5 100644 --- a/src/tests/int/env/opensource/suites/states.test.ts +++ b/src/tests/int/env/opensource/suites/states.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth} from '../auth'; + +import {STATE_DEFAULT_FIELDS} from '../../../models'; import {routes} from '../../../routes'; +import {app, auth} from '../auth'; import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; -import {STATE_DEFAULT_FIELDS} from '../../../models'; const stateData = { 'test-key': 'test-value1', diff --git a/src/tests/int/env/opensource/suites/workbooks/basic.test.ts b/src/tests/int/env/opensource/suites/workbooks/basic.test.ts index 0a60b0a5..ad615c45 100644 --- a/src/tests/int/env/opensource/suites/workbooks/basic.test.ts +++ b/src/tests/int/env/opensource/suites/workbooks/basic.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth, testTenantId, authMasterToken} from '../../auth'; + import {testUserId} from '../../../../constants'; -import {WORKBOOK_DEFAULT_FIELDS, OPERATION_DEFAULT_FIELDS} from '../../../../models'; +import {OPERATION_DEFAULT_FIELDS, WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; import {routes} from '../../../../routes'; +import {app, auth, authMasterToken, testTenantId} from '../../auth'; import {OpensourceRole} from '../../roles'; const workbooksData = [ diff --git a/src/tests/int/env/opensource/suites/workbooks/create-get.test.ts b/src/tests/int/env/opensource/suites/workbooks/create-get.test.ts index b30a5965..c21e1fa0 100644 --- a/src/tests/int/env/opensource/suites/workbooks/create-get.test.ts +++ b/src/tests/int/env/opensource/suites/workbooks/create-get.test.ts @@ -1,11 +1,12 @@ import request from 'supertest'; -import {app, auth} from '../../auth'; + import { - OPERATION_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_FIELDS, + OPERATION_DEFAULT_FIELDS, WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; import {routes} from '../../../../routes'; +import {app, auth} from '../../auth'; import {OpensourceRole} from '../../roles'; let rootWorkbookId: string; diff --git a/src/tests/int/env/opensource/suites/workbooks/delete-list.test.ts b/src/tests/int/env/opensource/suites/workbooks/delete-list.test.ts index d7a6eed1..895bf64d 100644 --- a/src/tests/int/env/opensource/suites/workbooks/delete-list.test.ts +++ b/src/tests/int/env/opensource/suites/workbooks/delete-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const emptyRootWorkbook = { diff --git a/src/tests/int/env/opensource/suites/workbooks/move-list.test.ts b/src/tests/int/env/opensource/suites/workbooks/move-list.test.ts index 082b6a30..6b8b9c5a 100644 --- a/src/tests/int/env/opensource/suites/workbooks/move-list.test.ts +++ b/src/tests/int/env/opensource/suites/workbooks/move-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth} from '../../auth'; import {createMockCollection, createMockWorkbook} from '../../helpers'; -import {routes} from '../../../../routes'; -import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; import {OpensourceRole} from '../../roles'; const rootCollection = { diff --git a/src/tests/int/env/opensource/suites/workbooks/private.test.ts b/src/tests/int/env/opensource/suites/workbooks/private.test.ts index 99897c9a..9c75094d 100644 --- a/src/tests/int/env/opensource/suites/workbooks/private.test.ts +++ b/src/tests/int/env/opensource/suites/workbooks/private.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, authMasterToken} from '../../auth'; + import {systemUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, authMasterToken} from '../../auth'; const workbooksData = { id: null, diff --git a/src/tests/int/env/platform/auth.ts b/src/tests/int/env/platform/auth.ts index c8daccb7..6ed2bfcc 100644 --- a/src/tests/int/env/platform/auth.ts +++ b/src/tests/int/env/platform/auth.ts @@ -1,12 +1,14 @@ import request from 'supertest'; -import {PlatformRole} from './roles'; -import type {CommonAuthArgs} from '../../auth'; -import {testUserId, testUserLogin} from '../../constants'; + import {AUTHORIZATION_HEADER, DL_AUTH_HEADER_KEY} from '../../../../const'; -import {ZitadelUserRole} from '../../../../types/zitadel'; import {CollectionPermission} from '../../../../entities/collection/types'; -import {WorkbookPermission} from '../../../../entities/workbook/types'; import {ResourceType} from '../../../../entities/types'; +import {WorkbookPermission} from '../../../../entities/workbook/types'; +import {ZitadelUserRole} from '../../../../types/zitadel'; +import type {CommonAuthArgs} from '../../auth'; +import {testUserId, testUserLogin} from '../../constants'; + +import {PlatformRole} from './roles'; export {US_ERRORS, app, appConfig, testTenantId, testProjectId, authMasterToken} from '../../auth'; diff --git a/src/tests/int/env/platform/helpers.ts b/src/tests/int/env/platform/helpers.ts index 503e4404..a89b1261 100644 --- a/src/tests/int/env/platform/helpers.ts +++ b/src/tests/int/env/platform/helpers.ts @@ -1,15 +1,17 @@ import request from 'supertest'; + +import {routes} from '../../routes'; + import { + AccessBinding, + AuthArgs, app, auth, - testTenantId, authMasterToken, getCollectionBinding, getWorkbookBinding, - AuthArgs, - AccessBinding, + testTenantId, } from './auth'; -import {routes} from '../../routes'; import {PlatformRole} from './roles'; export const mockWorkbookEntry = { diff --git a/src/tests/int/env/platform/suites/collections/create-get.test.ts b/src/tests/int/env/platform/suites/collections/create-get.test.ts index c9c58431..7c5ce98f 100644 --- a/src/tests/int/env/platform/suites/collections/create-get.test.ts +++ b/src/tests/int/env/platform/suites/collections/create-get.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS, OPERATION_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding} from '../../auth'; import {PlatformRole} from '../../roles'; -import {routes} from '../../../../routes'; -import {OPERATION_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/platform/suites/collections/delete-list.test.ts b/src/tests/int/env/platform/suites/collections/delete-list.test.ts index 66e7acd9..0894a3cd 100644 --- a/src/tests/int/env/platform/suites/collections/delete-list.test.ts +++ b/src/tests/int/env/platform/suites/collections/delete-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; const emptyRootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/delete.test.ts b/src/tests/int/env/platform/suites/collections/delete.test.ts index 185f320a..e15722d1 100644 --- a/src/tests/int/env/platform/suites/collections/delete.test.ts +++ b/src/tests/int/env/platform/suites/collections/delete.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; const emptyRootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/get-breadcrumbs.test.ts b/src/tests/int/env/platform/suites/collections/get-breadcrumbs.test.ts index d0004b9b..06f2d05e 100644 --- a/src/tests/int/env/platform/suites/collections/get-breadcrumbs.test.ts +++ b/src/tests/int/env/platform/suites/collections/get-breadcrumbs.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_PERMISSIONS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_PERMISSIONS} from '../../../../models'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/get-collections-list-by-ids.test.ts b/src/tests/int/env/platform/suites/collections/get-collections-list-by-ids.test.ts index 30992c39..01b736a4 100644 --- a/src/tests/int/env/platform/suites/collections/get-collections-list-by-ids.test.ts +++ b/src/tests/int/env/platform/suites/collections/get-collections-list-by-ids.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth, getCollectionBinding, US_ERRORS} from '../../auth'; -import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; + import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {US_ERRORS, app, auth, getCollectionBinding} from '../../auth'; +import {createMockCollection} from '../../helpers'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/get-content.test.ts b/src/tests/int/env/platform/suites/collections/get-content.test.ts index 54219c80..f65f740f 100644 --- a/src/tests/int/env/platform/suites/collections/get-content.test.ts +++ b/src/tests/int/env/platform/suites/collections/get-content.test.ts @@ -1,15 +1,16 @@ import request from 'supertest'; -import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; -import {createMockCollection, createMockWorkbook} from '../../helpers'; + import {testOtherUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import { COLLECTIONS_DEFAULT_FIELDS, - WORKBOOK_DEFAULT_FIELDS, - GET_COLLECTION_CONTENT_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_PERMISSIONS, + GET_COLLECTION_CONTENT_DEFAULT_FIELDS, WORKBOOKS_DEFAULT_PERMISSIONS, + WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; +import {createMockCollection, createMockWorkbook} from '../../helpers'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/get-root-permissions.test.ts b/src/tests/int/env/platform/suites/collections/get-root-permissions.test.ts index 74a7f184..cf8251fa 100644 --- a/src/tests/int/env/platform/suites/collections/get-root-permissions.test.ts +++ b/src/tests/int/env/platform/suites/collections/get-root-permissions.test.ts @@ -1,6 +1,7 @@ import request from 'supertest'; -import {app, auth} from '../../auth'; + import {routes} from '../../../../routes'; +import {app, auth} from '../../auth'; import {PlatformRole} from '../../roles'; describe('Getting root collection permissions', () => { diff --git a/src/tests/int/env/platform/suites/collections/get-structure-items.test.ts b/src/tests/int/env/platform/suites/collections/get-structure-items.test.ts index 84c83555..a17c25fd 100644 --- a/src/tests/int/env/platform/suites/collections/get-structure-items.test.ts +++ b/src/tests/int/env/platform/suites/collections/get-structure-items.test.ts @@ -1,15 +1,16 @@ import request from 'supertest'; -import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; -import {createMockCollection, createMockWorkbook} from '../../helpers'; + import {testOtherUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import { COLLECTIONS_DEFAULT_FIELDS, - WORKBOOK_DEFAULT_FIELDS, - GET_STRUCTURE_ITEMS_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_PERMISSIONS, + GET_STRUCTURE_ITEMS_DEFAULT_FIELDS, WORKBOOKS_DEFAULT_PERMISSIONS, + WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; +import {createMockCollection, createMockWorkbook} from '../../helpers'; const rootCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/move-list.test.ts b/src/tests/int/env/platform/suites/collections/move-list.test.ts index d03ea280..eac82268 100644 --- a/src/tests/int/env/platform/suites/collections/move-list.test.ts +++ b/src/tests/int/env/platform/suites/collections/move-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {PlatformRole} from '../../roles'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/platform/suites/collections/move.test.ts b/src/tests/int/env/platform/suites/collections/move.test.ts index 6d4308c6..e76be118 100644 --- a/src/tests/int/env/platform/suites/collections/move.test.ts +++ b/src/tests/int/env/platform/suites/collections/move.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; import {PlatformRole} from '../../roles'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/platform/suites/collections/private.test.ts b/src/tests/int/env/platform/suites/collections/private.test.ts index b4609fdc..fa8e3b26 100644 --- a/src/tests/int/env/platform/suites/collections/private.test.ts +++ b/src/tests/int/env/platform/suites/collections/private.test.ts @@ -1,7 +1,8 @@ import request from 'supertest'; -import {app, authMasterToken} from '../../auth'; -import {routes} from '../../../../routes'; + import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, authMasterToken} from '../../auth'; const testCollection = { collectionId: '', diff --git a/src/tests/int/env/platform/suites/collections/update.test.ts b/src/tests/int/env/platform/suites/collections/update.test.ts index 7e1c57ff..373536b9 100644 --- a/src/tests/int/env/platform/suites/collections/update.test.ts +++ b/src/tests/int/env/platform/suites/collections/update.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding} from '../../auth'; import {createMockCollection} from '../../helpers'; -import {routes} from '../../../../routes'; -import {COLLECTIONS_DEFAULT_FIELDS} from '../../../../models'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/platform/suites/favorites.test.ts b/src/tests/int/env/platform/suites/favorites.test.ts index 6d636910..46d2f51a 100644 --- a/src/tests/int/env/platform/suites/favorites.test.ts +++ b/src/tests/int/env/platform/suites/favorites.test.ts @@ -1,10 +1,11 @@ import request from 'supertest'; -import {testUserLogin, testUserId} from '../../../constants'; + +import {makeUserId} from '../../../../../utils'; +import {testUserId, testUserLogin} from '../../../constants'; +import {GET_FAVORITES_ENTRY_DEFAULT_FIELDS, MODIFY_FAVORITES_DEFAULT_FIELDS} from '../../../models'; import {routes} from '../../../routes'; import {app, auth, getWorkbookBinding, testTenantId} from '../auth'; import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; -import {makeUserId} from '../../../../../utils'; -import {MODIFY_FAVORITES_DEFAULT_FIELDS, GET_FAVORITES_ENTRY_DEFAULT_FIELDS} from '../../../models'; let workbookId: string; let entryId: string; diff --git a/src/tests/int/env/platform/suites/health-check.test.ts b/src/tests/int/env/platform/suites/health-check.test.ts index 38b6cef4..7d72531e 100644 --- a/src/tests/int/env/platform/suites/health-check.test.ts +++ b/src/tests/int/env/platform/suites/health-check.test.ts @@ -1,4 +1,5 @@ import request from 'supertest'; + import {app} from '../auth'; describe('Check ping endpoints', () => { diff --git a/src/tests/int/env/platform/suites/locks.test.ts b/src/tests/int/env/platform/suites/locks.test.ts index a5cde010..fc839c77 100644 --- a/src/tests/int/env/platform/suites/locks.test.ts +++ b/src/tests/int/env/platform/suites/locks.test.ts @@ -1,9 +1,10 @@ import request from 'supertest'; -import {app, auth, getWorkbookBinding, US_ERRORS} from '../auth'; -import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; + import {testUserLogin} from '../../../constants'; -import {routes} from '../../../routes'; import {LOCK_DEFAULT_FIELDS} from '../../../models'; +import {routes} from '../../../routes'; +import {US_ERRORS, app, auth, getWorkbookBinding} from '../auth'; +import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; let workbookId: string; let entryId: string; diff --git a/src/tests/int/env/platform/suites/states.test.ts b/src/tests/int/env/platform/suites/states.test.ts index 4df71075..a08562c5 100644 --- a/src/tests/int/env/platform/suites/states.test.ts +++ b/src/tests/int/env/platform/suites/states.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth} from '../auth'; + +import {STATE_DEFAULT_FIELDS} from '../../../models'; import {routes} from '../../../routes'; +import {app, auth} from '../auth'; import {createMockWorkbook, createMockWorkbookEntry} from '../helpers'; -import {STATE_DEFAULT_FIELDS} from '../../../models'; const stateData = { 'test-key': 'test-value1', diff --git a/src/tests/int/env/platform/suites/workbooks/basic.test.ts b/src/tests/int/env/platform/suites/workbooks/basic.test.ts index a45eb98b..7ce981c7 100644 --- a/src/tests/int/env/platform/suites/workbooks/basic.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/basic.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth, testTenantId, authMasterToken, getWorkbookBinding} from '../../auth'; + import {testUserId} from '../../../../constants'; -import {WORKBOOK_DEFAULT_FIELDS, OPERATION_DEFAULT_FIELDS} from '../../../../models'; +import {OPERATION_DEFAULT_FIELDS, WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; import {routes} from '../../../../routes'; +import {app, auth, authMasterToken, getWorkbookBinding, testTenantId} from '../../auth'; import {PlatformRole} from '../../roles'; const workbooksData = [ diff --git a/src/tests/int/env/platform/suites/workbooks/create-get.test.ts b/src/tests/int/env/platform/suites/workbooks/create-get.test.ts index b26ff296..d47a6ef6 100644 --- a/src/tests/int/env/platform/suites/workbooks/create-get.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/create-get.test.ts @@ -1,11 +1,12 @@ import request from 'supertest'; -import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; + import { - OPERATION_DEFAULT_FIELDS, COLLECTIONS_DEFAULT_FIELDS, + OPERATION_DEFAULT_FIELDS, WORKBOOK_DEFAULT_FIELDS, } from '../../../../models'; import {routes} from '../../../../routes'; +import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; import {PlatformRole} from '../../roles'; const otherWorkbookId = 'other-workbook-id'; diff --git a/src/tests/int/env/platform/suites/workbooks/delete-list.test.ts b/src/tests/int/env/platform/suites/workbooks/delete-list.test.ts index 90d63bd9..151c1aa9 100644 --- a/src/tests/int/env/platform/suites/workbooks/delete-list.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/delete-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getWorkbookBinding} from '../../auth'; import {createMockCollection, createMockWorkbook, createMockWorkbookEntry} from '../../helpers'; -import {routes} from '../../../../routes'; -import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; const emptyRootWorkbook = { collectionId: null, diff --git a/src/tests/int/env/platform/suites/workbooks/get-workbooks-list-by-ids.test.ts b/src/tests/int/env/platform/suites/workbooks/get-workbooks-list-by-ids.test.ts index 32855fd0..a0427f26 100644 --- a/src/tests/int/env/platform/suites/workbooks/get-workbooks-list-by-ids.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/get-workbooks-list-by-ids.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, auth, getWorkbookBinding, US_ERRORS} from '../../auth'; -import {createMockWorkbook} from '../../helpers'; -import {routes} from '../../../../routes'; + import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {US_ERRORS, app, auth, getWorkbookBinding} from '../../auth'; +import {createMockWorkbook} from '../../helpers'; const rootWorkbook = { workbookId: '', diff --git a/src/tests/int/env/platform/suites/workbooks/move-list.test.ts b/src/tests/int/env/platform/suites/workbooks/move-list.test.ts index 06e7dbee..ce7f6815 100644 --- a/src/tests/int/env/platform/suites/workbooks/move-list.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/move-list.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; + +import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; import {app, auth, getCollectionBinding, getWorkbookBinding} from '../../auth'; import {createMockCollection, createMockWorkbook} from '../../helpers'; -import {routes} from '../../../../routes'; -import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; import {PlatformRole} from '../../roles'; const unexistedCollectionId = 'unexisted-collection-id'; diff --git a/src/tests/int/env/platform/suites/workbooks/private.test.ts b/src/tests/int/env/platform/suites/workbooks/private.test.ts index 99897c9a..9c75094d 100644 --- a/src/tests/int/env/platform/suites/workbooks/private.test.ts +++ b/src/tests/int/env/platform/suites/workbooks/private.test.ts @@ -1,8 +1,9 @@ import request from 'supertest'; -import {app, authMasterToken} from '../../auth'; + import {systemUserId} from '../../../../constants'; -import {routes} from '../../../../routes'; import {WORKBOOK_DEFAULT_FIELDS} from '../../../../models'; +import {routes} from '../../../../routes'; +import {app, authMasterToken} from '../../auth'; const workbooksData = { id: null, diff --git a/src/tests/int/mocks/auth-zitadel.ts b/src/tests/int/mocks/auth-zitadel.ts index cc0f3111..4ff3e1e7 100644 --- a/src/tests/int/mocks/auth-zitadel.ts +++ b/src/tests/int/mocks/auth-zitadel.ts @@ -1,4 +1,5 @@ -import type {Request, Response, NextFunction} from '@gravity-ui/expresskit'; +import type {NextFunction, Request, Response} from '@gravity-ui/expresskit'; + import type {AuthArgs as OpensourceAuth} from '../env/opensource/auth'; import type {AuthArgs as PlatformAuth} from '../env/platform/auth'; diff --git a/src/tests/int/models/workbooks.ts b/src/tests/int/models/workbooks.ts index 977e8c0a..4bfd5854 100644 --- a/src/tests/int/models/workbooks.ts +++ b/src/tests/int/models/workbooks.ts @@ -1,4 +1,4 @@ -import {testTenantId, testProjectId} from '../auth'; +import {testProjectId, testTenantId} from '../auth'; export const WORKBOOK_DEFAULT_FIELDS = { workbookId: expect.any(String), diff --git a/src/types/models/entries.ts b/src/types/models/entries.ts index e47a3c6f..d0694937 100644 --- a/src/types/models/entries.ts +++ b/src/types/models/entries.ts @@ -1,11 +1,13 @@ import {TransactionOrKnex} from 'objection'; -import {EntryType, Mode} from './entry'; + +import {EntryPermissions} from '../../services/new/entry/types'; + import {BasicRequestParams, RequestedBy} from './common'; import {CTX} from './core'; -import {UsPermissions} from './permission'; import {DlsPermission} from './dls'; +import {EntryType, Mode} from './entry'; import {SyncLinks} from './link'; -import {EntryPermissions} from '../../services/new/entry/types'; +import {UsPermissions} from './permission'; export interface OriginatePermissionsConf { isPrivateRoute?: boolean; diff --git a/src/types/models/favorite.ts b/src/types/models/favorite.ts index 36228dde..feb6b04b 100644 --- a/src/types/models/favorite.ts +++ b/src/types/models/favorite.ts @@ -1,6 +1,6 @@ import {BasicRequestParams} from './common'; import {CTX} from './core'; -import {EntriesOrderByFilter, EntriesFilters} from './filters'; +import {EntriesFilters, EntriesOrderByFilter} from './filters'; export interface GetFavoriteConfig extends BasicRequestParams { tenantId?: any; diff --git a/src/types/models/link.ts b/src/types/models/link.ts index 027f9f23..a039d4d3 100644 --- a/src/types/models/link.ts +++ b/src/types/models/link.ts @@ -1,4 +1,5 @@ import {TransactionOrKnex} from 'objection'; + import {CTX} from './core'; export type SyncLinks = Record; diff --git a/src/types/models/navigation.ts b/src/types/models/navigation.ts index 8c56b377..6b894170 100644 --- a/src/types/models/navigation.ts +++ b/src/types/models/navigation.ts @@ -1,7 +1,8 @@ import {OrderByDirection} from 'objection'; -import {EntriesOrderByFilter, EntriesFilters} from './filters'; -import {EntryScope} from './entry'; + import {BasicRequestParams, RequestedBy} from './common'; +import {EntryScope} from './entry'; +import {EntriesFilters, EntriesOrderByFilter} from './filters'; export interface PaginationEntriesResponse { nextPageToken?: string; diff --git a/src/types/models/tables-columns.ts b/src/types/models/tables-columns.ts index 0b878a84..ab24b7dc 100644 --- a/src/types/models/tables-columns.ts +++ b/src/types/models/tables-columns.ts @@ -1,7 +1,7 @@ -import {TenantMeta} from './tenant'; -import {TemplateData} from './template'; -import {EntryScope, EntryInnerMeta} from './entry'; +import {EntryInnerMeta, EntryScope} from './entry'; import {SyncLinks} from './link'; +import {TemplateData} from './template'; +import {TenantMeta} from './tenant'; export interface TenantColumns { tenantId: string; diff --git a/src/types/services.types.ts b/src/types/services.types.ts index 25decb91..eb4f9756 100644 --- a/src/types/services.types.ts +++ b/src/types/services.types.ts @@ -1,15 +1,16 @@ import type {OrderByDirection} from 'objection'; + import { CTX, - EntriesOrderByFilter, + DlsPermissionsMode, EntriesFilters, - TemplateData, - EntryScope, - WorkbookColumns, + EntriesOrderByFilter, EntryColumns, + EntryScope, RevisionColumns, SyncLinks, - DlsPermissionsMode, + TemplateData, + WorkbookColumns, } from './models'; export interface ServiceResponse { diff --git a/src/utils/axios.ts b/src/utils/axios.ts index ec4bee11..ae0e17d4 100644 --- a/src/utils/axios.ts +++ b/src/utils/axios.ts @@ -1,5 +1,6 @@ import http from 'http'; import https from 'https'; + import axios from 'axios'; import axiosRetry from 'axios-retry'; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 15bb0edb..969c904f 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,13 +1,12 @@ -const fs = require('fs'); -const PowerRadix = require('power-radix'); - import chunk from 'lodash/chunk'; +import {CODING_BASE, COPY_END, COPY_START, ID_VARIABLES, TRUE_FLAGS} from '../const'; +import {EntryScope as EntryScopeEnum, EntryType} from '../db/models/new/entry/types'; import {EntryScope, USAPIResponse} from '../types/models'; -import {ID_VARIABLES, CODING_BASE, TRUE_FLAGS, COPY_START, COPY_END} from '../const'; +const fs = require('fs'); -import {EntryScope as EntryScopeEnum, EntryType} from '../db/models/new/entry/types'; +const PowerRadix = require('power-radix'); const MAX_PAGE_LIMIT = 10000; diff --git a/src/utils/zitadel.ts b/src/utils/zitadel.ts index dc9f8a72..ae457646 100644 --- a/src/utils/zitadel.ts +++ b/src/utils/zitadel.ts @@ -1,9 +1,11 @@ import {AppContext} from '@gravity-ui/nodekit'; -import {Utils} from './utils'; import axios from 'axios'; import axiosRetry from 'axios-retry'; + import {ZitadelUserRole} from '../types/zitadel'; +import {Utils} from './utils'; + type IntrospectionResult = { active: boolean; userId?: string; diff --git a/typings/nodekit.d.ts b/typings/nodekit.d.ts index 9da2b62c..c19ef0d6 100644 --- a/typings/nodekit.d.ts +++ b/typings/nodekit.d.ts @@ -1,6 +1,6 @@ -import {CtxInfo} from '../src/types/ctx'; import {FeaturesConfig} from '../src/components/features/types'; import type {Registry} from '../src/registry'; +import {CtxInfo} from '../src/types/ctx'; export interface SharedAppConfig { features: FeaturesConfig;