diff --git a/rsconcept/frontend/src/app/urls.ts b/rsconcept/frontend/src/app/urls.ts index 996b192e..d5ce6e11 100644 --- a/rsconcept/frontend/src/app/urls.ts +++ b/rsconcept/frontend/src/app/urls.ts @@ -4,9 +4,7 @@ import { buildConstants } from '@/utils/build-constants'; -/** - * Routes. - */ +/** Routes. */ export const routes = { not_found: 'not-found', login: 'login', @@ -22,11 +20,9 @@ export const routes = { oss: 'oss', icons: 'icons', database_schema: 'database-schema' -}; +} as const; -/** - * Internal navigation URLs. - */ +/** Internal navigation URLs. */ export const urls = { page404: '/not-found', admin: `${buildConstants.backend}/admin`, @@ -66,4 +62,4 @@ export const urls = { oss_props: ({ id, tab }: { id: number | string; tab: number }) => { return `/oss/${id}?tab=${tab}`; } -}; +} as const; diff --git a/rsconcept/frontend/src/backend/configuration.ts b/rsconcept/frontend/src/backend/configuration.ts index d0d42d44..efa5c4fa 100644 --- a/rsconcept/frontend/src/backend/configuration.ts +++ b/rsconcept/frontend/src/backend/configuration.ts @@ -6,7 +6,7 @@ export const DELAYS = { staleShort: 5 * 60 * 1000, staleMedium: 1 * 60 * 60 * 1000, staleLong: 24 * 60 * 60 * 1000 -}; +} as const; /** API keys for local cache. */ export const KEYS = { @@ -19,8 +19,8 @@ export const KEYS = { global_mutation: 'global_mutation', composite: { - libraryList: ['library', 'list'], + libraryList: ['library', 'list'] as const, ossItem: ({ itemID }: { itemID?: number }) => [KEYS.oss, 'item', itemID], rsItem: ({ itemID, version }: { itemID?: number; version?: number }) => [KEYS.rsform, 'item', itemID, version ?? ''] } -}; +} as const; diff --git a/rsconcept/frontend/src/components/data-table/data-table.tsx b/rsconcept/frontend/src/components/data-table/data-table.tsx index 5653905f..cbdf7dd7 100644 --- a/rsconcept/frontend/src/components/data-table/data-table.tsx +++ b/rsconcept/frontend/src/components/data-table/data-table.tsx @@ -78,7 +78,7 @@ export interface DataTableProps paginationPerPage?: number; /** List of options to choose from for pagination. */ - paginationOptions?: number[]; + paginationOptions?: readonly number[]; /** Callback to be called when the pagination option is changed. */ onChangePaginationOption?: (newValue: number) => void; diff --git a/rsconcept/frontend/src/components/data-table/pagination-tools.tsx b/rsconcept/frontend/src/components/data-table/pagination-tools.tsx index 3f0ee03b..3ec602a1 100644 --- a/rsconcept/frontend/src/components/data-table/pagination-tools.tsx +++ b/rsconcept/frontend/src/components/data-table/pagination-tools.tsx @@ -10,7 +10,7 @@ import { SelectPagination } from './select-pagination'; interface PaginationToolsProps { id?: string; table: Table; - paginationOptions: number[]; + paginationOptions: readonly number[]; onChangePaginationOption?: (newValue: number) => void; } diff --git a/rsconcept/frontend/src/components/data-table/select-pagination.tsx b/rsconcept/frontend/src/components/data-table/select-pagination.tsx index a304f1a9..58aea9ff 100644 --- a/rsconcept/frontend/src/components/data-table/select-pagination.tsx +++ b/rsconcept/frontend/src/components/data-table/select-pagination.tsx @@ -11,7 +11,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '. interface SelectPaginationProps { id?: string; table: Table; - paginationOptions: number[]; + paginationOptions: readonly number[]; onChange?: (newValue: number) => void; } diff --git a/rsconcept/frontend/src/features/auth/backend/api.ts b/rsconcept/frontend/src/features/auth/backend/api.ts index 343c4761..e541ed19 100644 --- a/rsconcept/frontend/src/features/auth/backend/api.ts +++ b/rsconcept/frontend/src/features/auth/backend/api.ts @@ -61,4 +61,4 @@ export const authApi = { endpoint: '/users/api/password-reset/confirm', request: { data: data } }) -}; +} as const; diff --git a/rsconcept/frontend/src/features/library/backend/api.ts b/rsconcept/frontend/src/features/library/backend/api.ts index 03927291..11967334 100644 --- a/rsconcept/frontend/src/features/library/backend/api.ts +++ b/rsconcept/frontend/src/features/library/backend/api.ts @@ -169,4 +169,4 @@ export const libraryApi = { successMessage: infoMsg.versionDestroyed } }) -}; +} as const; diff --git a/rsconcept/frontend/src/features/oss/backend/api.ts b/rsconcept/frontend/src/features/oss/backend/api.ts index 69d7da8f..dcf08b8b 100644 --- a/rsconcept/frontend/src/features/oss/backend/api.ts +++ b/rsconcept/frontend/src/features/oss/backend/api.ts @@ -164,4 +164,4 @@ export const ossApi = { endpoint: '/api/oss/get-predecessor', request: { data: { target: cstID } } }) -}; +} as const; diff --git a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/graph/oss-node-types.ts b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/graph/oss-node-types.ts index 79bc87cb..376a6701 100644 --- a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/graph/oss-node-types.ts +++ b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/graph/oss-node-types.ts @@ -8,4 +8,4 @@ export const OssNodeTypes: NodeTypes = { synthesis: OperationNode, input: InputNode, block: BlockNode -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/backend/api.ts b/rsconcept/frontend/src/features/rsform/backend/api.ts index 6abb36fc..cb3415a5 100644 --- a/rsconcept/frontend/src/features/rsform/backend/api.ts +++ b/rsconcept/frontend/src/features/rsform/backend/api.ts @@ -153,4 +153,4 @@ export const rsformsApi = { endpoint: `/api/rsforms/${itemID}/check-constituenta`, request: { data: data } }) -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/backend/cctext/api.ts b/rsconcept/frontend/src/features/rsform/backend/cctext/api.ts index 86c05ff7..688af430 100644 --- a/rsconcept/frontend/src/features/rsform/backend/cctext/api.ts +++ b/rsconcept/frontend/src/features/rsform/backend/cctext/api.ts @@ -30,4 +30,4 @@ export const cctextApi = { endpoint: '/api/cctext/generate-lexeme', request: { data: data } }) -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/colors.ts b/rsconcept/frontend/src/features/rsform/colors.ts index f10a6e7d..505d8ba5 100644 --- a/rsconcept/frontend/src/features/rsform/colors.ts +++ b/rsconcept/frontend/src/features/rsform/colors.ts @@ -17,7 +17,7 @@ export const BRACKETS_THEME = { backgroundColor: APP_COLORS.bgSelected, color: APP_COLORS.fgSelected } -}; +} as const; /** Determines background color for {@link ISyntaxTreeNode} based on its type. */ export function colorBgSyntaxTree(node: ISyntaxTreeNode): string { diff --git a/rsconcept/frontend/src/features/rsform/components/refs-input/parse/index.ts b/rsconcept/frontend/src/features/rsform/components/refs-input/parse/index.ts index 4cc556f7..92a33a2a 100644 --- a/rsconcept/frontend/src/features/rsform/components/refs-input/parse/index.ts +++ b/rsconcept/frontend/src/features/rsform/components/refs-input/parse/index.ts @@ -3,7 +3,7 @@ import { LRLanguage } from '@codemirror/language'; import { parser } from './parser'; import { RefEntity, RefSyntactic } from './parser.terms'; -export const ReferenceTokens: number[] = [RefSyntactic, RefEntity]; +export const ReferenceTokens = [RefSyntactic, RefEntity] as const; export const NaturalLanguage = LRLanguage.define({ parser: parser, diff --git a/rsconcept/frontend/src/features/rsform/components/rs-input/rslang/index.ts b/rsconcept/frontend/src/features/rsform/components/rs-input/rslang/index.ts index de4efece..2ebf28d2 100644 --- a/rsconcept/frontend/src/features/rsform/components/rs-input/rslang/index.ts +++ b/rsconcept/frontend/src/features/rsform/components/rs-input/rslang/index.ts @@ -3,7 +3,7 @@ import { LRLanguage } from '@codemirror/language'; import { parser } from './parser'; import { Function, Global, Predicate } from './parser.terms'; -export const GlobalTokens: number[] = [Global, Function, Predicate]; +export const GlobalTokens = [Global, Function, Predicate] as const; export const RSLanguage = LRLanguage.define({ parser: parser, diff --git a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-edge-types.ts b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-edge-types.ts index 86b1ef3e..15d10da6 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-edge-types.ts +++ b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-edge-types.ts @@ -4,4 +4,4 @@ import { DynamicEdge } from '@/components/flow/dynamic-edge'; export const ASTEdgeTypes: EdgeTypes = { dynamic: DynamicEdge -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-node-types.ts b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-node-types.ts index 9e612cc8..5168f820 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-node-types.ts +++ b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-ast/graph/ast-node-types.ts @@ -4,4 +4,4 @@ import { ASTNode } from './ast-node'; export const ASTNodeTypes: NodeTypes = { token: ASTNode -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-edge-types.ts b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-edge-types.ts index 2e51a235..125901d7 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-edge-types.ts +++ b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-edge-types.ts @@ -6,4 +6,4 @@ import { CartesianEdge } from './cartesian-edge'; export const TMGraphEdgeTypes: EdgeTypes = { boolean: BooleanEdge, cartesian: CartesianEdge -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-node-types.ts b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-node-types.ts index ced4d5b2..39de2b5e 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-node-types.ts +++ b/rsconcept/frontend/src/features/rsform/dialogs/dlg-show-type-graph/graph/mgraph-node-types.ts @@ -4,4 +4,4 @@ import { MGraphNode } from './mgraph-node'; export const TMGraphNodeTypes: NodeTypes = { step: MGraphNode -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-edge-types.ts b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-edge-types.ts index f2a8117f..92441f10 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-edge-types.ts +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-edge-types.ts @@ -4,4 +4,4 @@ import { DynamicEdge } from '@/components/flow/dynamic-edge'; export const TGEdgeTypes: EdgeTypes = { termEdge: DynamicEdge -}; +} as const; diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-node-types.ts b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-node-types.ts index 2ec5ccb6..06bde8e2 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-node-types.ts +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/graph/tg-node-types.ts @@ -4,4 +4,4 @@ import { TGNode } from './tg-node'; export const TGNodeTypes: NodeTypes = { concept: TGNode -}; +} as const; diff --git a/rsconcept/frontend/src/features/users/backend/api.ts b/rsconcept/frontend/src/features/users/backend/api.ts index 37bf0fda..f8d673b4 100644 --- a/rsconcept/frontend/src/features/users/backend/api.ts +++ b/rsconcept/frontend/src/features/users/backend/api.ts @@ -59,4 +59,4 @@ export const usersApi = { successMessage: infoMsg.changesSaved } }) -}; +} as const; diff --git a/rsconcept/frontend/src/styling/colors.ts b/rsconcept/frontend/src/styling/colors.ts index 8f7d5c00..262a3f95 100644 --- a/rsconcept/frontend/src/styling/colors.ts +++ b/rsconcept/frontend/src/styling/colors.ts @@ -36,4 +36,4 @@ export const APP_COLORS = { fgPurple: 'var(--acc-fg-purple)', fgTeal: 'var(--acc-fg-teal)', fgOrange: 'var(--acc-fg-orange)' -} +} as const diff --git a/rsconcept/frontend/src/utils/build-constants.ts b/rsconcept/frontend/src/utils/build-constants.ts index 27a86c5c..d34a4fb6 100644 --- a/rsconcept/frontend/src/utils/build-constants.ts +++ b/rsconcept/frontend/src/utils/build-constants.ts @@ -4,4 +4,4 @@ */ export const buildConstants = { backend: import.meta.env.VITE_PORTAL_BACKEND as string -}; +} as const; diff --git a/rsconcept/frontend/src/utils/codemirror.ts b/rsconcept/frontend/src/utils/codemirror.ts index c5824e0b..be4357cc 100644 --- a/rsconcept/frontend/src/utils/codemirror.ts +++ b/rsconcept/frontend/src/utils/codemirror.ts @@ -72,7 +72,12 @@ export function printTree(tree: Tree): string { } /** Retrieves a list of all nodes, containing given range and corresponding to a filter. */ -export function findEnvelopingNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] { +export function findEnvelopingNodes( + start: number, + finish: number, + tree: Tree, + filter?: readonly number[] +): SyntaxNode[] { const result: SyntaxNode[] = []; tree.cursor().iterate(node => { if ((!filter || filter.includes(node.type.id)) && node.to >= start && node.from <= finish) { @@ -87,7 +92,12 @@ export function findEnvelopingNodes(start: number, finish: number, tree: Tree, f } /** Retrieves a list of all nodes, contained in given range and corresponding to a filter. */ -export function findContainedNodes(start: number, finish: number, tree: Tree, filter?: number[]): SyntaxNode[] { +export function findContainedNodes( + start: number, + finish: number, + tree: Tree, + filter?: readonly number[] +): SyntaxNode[] { const result: SyntaxNode[] = []; tree.cursor().iterate(node => { if ((!filter || filter.includes(node.type.id)) && node.to <= finish && node.from >= start) { @@ -169,7 +179,7 @@ export class CodeMirrorWrapper { /** * Access list of SyntaxNodes contained in current selection. */ - getContainedNodes(tokenFilter?: number[]): SyntaxNode[] { + getContainedNodes(tokenFilter?: readonly number[]): SyntaxNode[] { const selection = this.getSelection(); return findContainedNodes(selection.from, selection.to, syntaxTree(this.ref.view.state), tokenFilter); } @@ -177,7 +187,7 @@ export class CodeMirrorWrapper { /** * Access list of SyntaxNodes enveloping current selection. */ - getEnvelopingNodes(tokenFilter?: number[]): SyntaxNode[] { + getEnvelopingNodes(tokenFilter?: readonly number[]): SyntaxNode[] { const selection = this.getSelection(); return findEnvelopingNodes(selection.from, selection.to, syntaxTree(this.ref.view.state), tokenFilter); } @@ -185,7 +195,7 @@ export class CodeMirrorWrapper { /** * Access list of SyntaxNodes contained in documents. */ - getAllNodes(tokenFilter?: number[]): SyntaxNode[] { + getAllNodes(tokenFilter?: readonly number[]): SyntaxNode[] { return findContainedNodes(0, this.ref.view.state.doc.length, syntaxTree(this.ref.view.state), tokenFilter); } @@ -194,7 +204,7 @@ export class CodeMirrorWrapper { * * If tokenFilter is provided then minimal valid token is selected. */ - fixSelection(tokenFilter?: number[]) { + fixSelection(tokenFilter?: readonly number[]) { const selection = this.getSelection(); if (tokenFilter) { const nodes = findEnvelopingNodes(selection.from, selection.to, syntaxTree(this.ref.view.state), tokenFilter); diff --git a/rsconcept/frontend/src/utils/constants.ts b/rsconcept/frontend/src/utils/constants.ts index 6afbc4c9..16b543d0 100644 --- a/rsconcept/frontend/src/utils/constants.ts +++ b/rsconcept/frontend/src/utils/constants.ts @@ -2,9 +2,7 @@ * Module: Global constants. */ -/** - * Global application Parameters. The place where magic numbers are put to rest. - */ +/** Global application Parameters. The place where magic numbers are put to rest. */ export const PARAMETER = { smallScreen: 640, // == tailwind:sm @@ -26,46 +24,34 @@ export const PARAMETER = { logicLabel: 'LOGIC', errorNodeLabel: '[ERROR]', exteorVersion: '4.9.7' -}; +} as const; -/** - * Numeric limitations. - */ +/** Numeric limitations. */ export const limits = { location_len: 500 -}; +} as const; -/** - * Exteor file extension for RSForm. - */ +/** Exteor file extension for RSForm. */ export const EXTEOR_TRS_FILE = '.trs'; -/** - * Regex patterns for data validation. - */ +/** Regex patterns for data validation. */ export const patterns = { login: '^[a-zA-Z][a-zA-Z0-9_\\-]{1,}[a-zA-Z0-9]$' -}; +} as const; -/** - * Local URIs. - */ +/** Local URIs. */ export const resources = { privacy_policy: '/privacy.pdf', logo: '/logo_full.svg', db_schema: '/db_schema.svg' -}; +} as const; -/** - * Youtube IDs for embedding. - */ +/** Youtube IDs for embedding. */ export const youtube = { intro: '0Ty9mu9sOJo' -}; +} as const; -/** - * External URLs. - */ +/** External URLs. */ export const external_urls = { concept: 'https://www.acconcept.ru/', exteor32: 'https://drive.google.com/open?id=1IHlMMwaYlAUBRSxU1RU_hXM5mFU9-oyK&usp=drive_fs', @@ -81,11 +67,9 @@ export const external_urls = { git_cctext: 'https://github.com/IRBorisov/cctext', mail_portal: 'mailto:portal@acconcept.ru', restAPI: 'https://api.portal.acconcept.ru' -}; +} as const; -/** - * Global element ID. - */ +/** Global element ID. */ export const globalIDs = { tooltip: 'global_tooltip', value_tooltip: 'value_tooltip', @@ -96,11 +80,9 @@ export const globalIDs = { constituenta_editor: 'constituenta_editor', graph_schemas: 'graph_schemas_tooltip', user_dropdown: 'user_dropdown' -}; +} as const; -/** - * Prefixes for generating unique keys for lists. - */ +/** Prefixes for generating unique keys for lists. */ export const prefixes = { page_size: 'page_size_', oss_list: 'oss_list_', @@ -123,4 +105,4 @@ export const prefixes = { user_editors: 'user_editors_', wordform_list: 'wordform_list_', rsedit_btn: 'rsedit_btn_' -}; +} as const; diff --git a/rsconcept/frontend/src/utils/labels.ts b/rsconcept/frontend/src/utils/labels.ts index 41d1cb5b..889bb01f 100644 --- a/rsconcept/frontend/src/utils/labels.ts +++ b/rsconcept/frontend/src/utils/labels.ts @@ -41,7 +41,7 @@ export const infoMsg = { operationExecuted: 'Операция выполнена', allOperationExecuted: 'Все операции выполнены', constituentsDestroyed: (count: number) => `Конституенты удалены: ${count}` -}; +} as const; /** * UI error descriptors. @@ -65,7 +65,7 @@ export const errorMsg = { emptySubstitutions: 'Выберите хотя бы одно отождествление', aliasInvalid: 'Введите незанятое имя, соответствующее типу', invalidResponse: 'Некорректный ответ сервера' -}; +} as const; /** * UI tooltip descriptors. @@ -73,7 +73,7 @@ export const errorMsg = { export const tooltipText = { unsaved: 'Сохраните или отмените изменения', shareItem: (isPublic: boolean) => (isPublic ? 'Поделиться схемой' : 'Поделиться можно только
открытой схемой') -}; +} as const; /** * UI prompt messages. @@ -88,4 +88,4 @@ export const promptText = { restoreArchive: 'При восстановлении архивной версии актуальная схему будет заменена. Продолжить?', ownerChange: 'Вы уверены, что хотите изменить владельца? Вы потеряете право управления данной схемой. Данное действие отменить нельзя' -}; +} as const;