diff --git a/package-lock.json b/package-lock.json index e0e4135..4c75444 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "classnames": "^2.3.2", "nanoid": "^4.0.2", "normalize.css": "^8.0.1", - "ostis-ui-lib": "^0.1.1", + "ostis-ui-lib": "^0.4.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.45.4", @@ -8005,9 +8005,10 @@ } }, "node_modules/ostis-ui-lib": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ostis-ui-lib/-/ostis-ui-lib-0.1.1.tgz", - "integrity": "sha512-Xearlh3L2Sk67MIYrH313JngLwE6SaB83iyEvEVKHo88tlewHZ+38RrZP0aAmvT/mQhnoo2nxksxNZw/3bvXDA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/ostis-ui-lib/-/ostis-ui-lib-0.4.0.tgz", + "integrity": "sha512-KjFL6hjcjFkZZg9WJdLQOLLT9IKy3OFC5NKn1KSQlO15gmSQuVuLmO1JXX0nr5TOyDn+mPblebzy3pq76vtQIg==", + "license": "MIT", "dependencies": { "@floating-ui/react": "^0.24.1", "react-intersection-observer": "^9.5.3", @@ -8021,7 +8022,7 @@ "react": ">=16", "react-dom": ">=16", "styled-components": "^5.1.0 || ^6.0.0-rc.1", - "ts-sc-client": ">=0.3.0" + "ts-sc-client": "0.5.0" } }, "node_modules/p-limit": { @@ -10112,9 +10113,10 @@ } }, "node_modules/ts-sc-client": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/ts-sc-client/-/ts-sc-client-0.3.2.tgz", - "integrity": "sha512-KyYuU0H/79mybE0T+kRUGzGVfepACgbj1yO2C/19KUlQnsrou1DCYJL52HM5Js/bqFrJJ3Cm+nzHNO8AtK5ZSQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ts-sc-client/-/ts-sc-client-0.5.0.tgz", + "integrity": "sha512-JKXADYsTYTydUWMgqTGAVyBpUfBzHt0rOVF1wnfDZzv6vyL6KSohBUTK5gBJg8+ZYP3JkhiiLDmX+VKZVzLaZg==", + "license": "MIT", "peer": true }, "node_modules/tsconfig-paths": { @@ -16559,9 +16561,9 @@ } }, "ostis-ui-lib": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ostis-ui-lib/-/ostis-ui-lib-0.1.1.tgz", - "integrity": "sha512-Xearlh3L2Sk67MIYrH313JngLwE6SaB83iyEvEVKHo88tlewHZ+38RrZP0aAmvT/mQhnoo2nxksxNZw/3bvXDA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/ostis-ui-lib/-/ostis-ui-lib-0.4.0.tgz", + "integrity": "sha512-KjFL6hjcjFkZZg9WJdLQOLLT9IKy3OFC5NKn1KSQlO15gmSQuVuLmO1JXX0nr5TOyDn+mPblebzy3pq76vtQIg==", "requires": { "@floating-ui/react": "^0.24.1", "react-intersection-observer": "^9.5.3", @@ -18038,9 +18040,9 @@ "requires": {} }, "ts-sc-client": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/ts-sc-client/-/ts-sc-client-0.3.2.tgz", - "integrity": "sha512-KyYuU0H/79mybE0T+kRUGzGVfepACgbj1yO2C/19KUlQnsrou1DCYJL52HM5Js/bqFrJJ3Cm+nzHNO8AtK5ZSQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ts-sc-client/-/ts-sc-client-0.5.0.tgz", + "integrity": "sha512-JKXADYsTYTydUWMgqTGAVyBpUfBzHt0rOVF1wnfDZzv6vyL6KSohBUTK5gBJg8+ZYP3JkhiiLDmX+VKZVzLaZg==", "peer": true }, "tsconfig-paths": { diff --git a/package.json b/package.json index 940d82c..b942855 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "classnames": "^2.3.2", "nanoid": "^4.0.2", "normalize.css": "^8.0.1", - "ostis-ui-lib": "^0.1.1", + "ostis-ui-lib": "^0.4.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.45.4", diff --git a/src/api/requests/command.ts b/src/api/requests/command.ts index ce412a7..1a93b8d 100644 --- a/src/api/requests/command.ts +++ b/src/api/requests/command.ts @@ -3,7 +3,7 @@ import { API_URL } from '@constants'; import { objectToFormData } from '@utils'; interface IDoComandResult { - question: number; + action: number; } export const doCommand = (cmdAddr: number, ...args: number[]) => { diff --git a/src/api/requests/decomposition.ts b/src/api/requests/decomposition.ts index ae76f7a..7bf1272 100644 --- a/src/api/requests/decomposition.ts +++ b/src/api/requests/decomposition.ts @@ -19,7 +19,7 @@ interface IDecompositionItem { } const getLanguage = async (lang: TLanguage) => { - const keynodes = await scUtils.findKeynodes(langToKeynode[lang]); + const keynodes = await scUtils.searchKeynodes(langToKeynode[lang]); return keynodes[snakeToCamelCase(langToKeynode[lang])]; }; @@ -27,7 +27,7 @@ export const getDecomposition = async (lang: TLanguage): Promise { export const editDecompositionItem = async (addr: number, newContent: string, lang: TLanguage) => { const linkAlias = '_link'; - const { nrelMainIdtf, ...rest } = await scUtils.findKeynodes( + const { nrelMainIdtf, ...rest } = await scUtils.searchKeynodes( 'nrel_main_idtf', langToKeynode[lang], ); @@ -113,17 +113,17 @@ export const editDecompositionItem = async (addr: number, newContent: string, la const foundLang = rest[snakeToCamelCase(langToKeynode[lang])]; const scTemplate = new ScTemplate(); - scTemplate.tripleWithRelation( + scTemplate.quintuple( new ScAddr(addr), - ScType.EdgeDCommonVar, - [ScType.LinkVar, linkAlias], - ScType.EdgeAccessVarPosPerm, + ScType.VarCommonArc, + [ScType.VarNodeLink, linkAlias], + ScType.VarPermPosArc, nrelMainIdtf, ); - scTemplate.triple(foundLang, ScType.EdgeAccessVarPosPerm, linkAlias); + scTemplate.triple(foundLang, ScType.VarPermPosArc, linkAlias); - const result = await client.templateSearch(scTemplate); + const result = await client.searchByTemplate(scTemplate); if (result.length) { client.setLinkContents([ @@ -132,22 +132,22 @@ export const editDecompositionItem = async (addr: number, newContent: string, la return true; } - const link = await scUtils.createLink(newContent); + const link = await scUtils.generateLink(newContent); if (!link) return; const template = new ScTemplate(); - template.tripleWithRelation( + template.quintuple( new ScAddr(addr), - ScType.EdgeDCommonVar, + ScType.VarCommonArc, link, - ScType.EdgeAccessVarPosPerm, + ScType.VarPermPosArc, nrelMainIdtf, ); - template.triple(foundLang, ScType.EdgeAccessVarPosPerm, link); + template.triple(foundLang, ScType.VarPermPosArc, link); - const generateRes = await client.templateGenerate(template); + const generateRes = await client.generateByTemplate(template); return !!generateRes; }; diff --git a/src/api/requests/mock/scn.ts b/src/api/requests/mock/scn.ts index 1ee134a..afaf42d 100644 --- a/src/api/requests/mock/scn.ts +++ b/src/api/requests/mock/scn.ts @@ -31,13 +31,13 @@ const getLinks = (): IScnChild => ({ addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], }, @@ -50,13 +50,13 @@ const getLinks = (): IScnChild => ({ addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessVarPosPerm.value, + type: ScType.VarPermPosArc.value, }, { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessVarPosPerm.value, + type: ScType.VarPermPosArc.value, }, ], }, @@ -69,13 +69,13 @@ const getLinks = (): IScnChild => ({ addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], }, @@ -88,7 +88,7 @@ const getLinks = (): IScnChild => ({ sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, { @@ -98,7 +98,7 @@ const getLinks = (): IScnChild => ({ sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, ], @@ -109,7 +109,7 @@ const decompositionChild: IScnChild = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -123,7 +123,7 @@ const decompositionChild: IScnChild = { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], }, @@ -133,7 +133,7 @@ const decompositionChild: IScnChild = { addr: getId(), content: null, idtf: null, - type: ScType.NodeConstTuple.value, + type: ScType.ConstNodeTuple.value, contentType: null, sourceNode: null, targetNode: null, @@ -143,7 +143,7 @@ const decompositionChild: IScnChild = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'right', }, ], @@ -157,7 +157,7 @@ const decompositionChild: IScnChild = { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], }, @@ -167,14 +167,14 @@ const decompositionChild: IScnChild = { addr: getId(), content: null, idtf: 'Раздел. Предметная область бизнес процессов', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: [ { arcs: [ { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -187,7 +187,7 @@ const decompositionChild: IScnChild = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, ], @@ -204,7 +204,7 @@ const decompositionChild: IScnChild = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'right', }, ], @@ -214,7 +214,7 @@ const decompositionChild: IScnChild = { addr: getId(), content: null, idtf: 'Раздел. Предметная область экономических субъектов', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, contentType: null, sourceNode: null, @@ -227,7 +227,7 @@ const decompositionChild: IScnChild = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'right', }, ], @@ -237,7 +237,7 @@ const decompositionChild: IScnChild = { addr: getId(), content: null, idtf: 'Раздел. Предметная область персон', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, contentType: null, sourceNode: null, @@ -253,7 +253,7 @@ const decompositionChild: IScnChild = { export const tree1: IScnNode = { addr: getId(), idtf: 'База знаний', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, contentType: null, sourceNode: null, @@ -279,7 +279,7 @@ export const tree1: IScnNode = { addr: getId(), idtf: null, content: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], }, @@ -292,7 +292,7 @@ export const tree1: IScnNode = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, ], @@ -315,7 +315,7 @@ export const tree1: IScnNode = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, ], @@ -338,7 +338,7 @@ export const tree1: IScnNode = { sourceNode: null, targetNode: null, idtf: 'Длинная дуга', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, }, ], @@ -348,7 +348,7 @@ export const tree1: IScnNode = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -361,7 +361,7 @@ export const tree1: IScnNode = { sourceNode: null, targetNode: null, idtf: 'стартовый sc-элемент', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, }, ], @@ -371,7 +371,7 @@ export const tree1: IScnNode = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -384,13 +384,13 @@ export const tree1: IScnNode = { sourceNode: { addr: getId(), idtf: 'Авторизованный пользователь*', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, targetNode: { addr: getId(), idtf: 'sc-модель базы знаний', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, idtf: null, @@ -404,7 +404,7 @@ export const tree1: IScnNode = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -417,7 +417,7 @@ export const tree1: IScnNode = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, }, ], @@ -427,7 +427,7 @@ export const tree1: IScnNode = { { addr: getId(), idtf: null, - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, direction: 'left', }, ], @@ -452,7 +452,7 @@ export const tree1: IScnNode = { export const tree2: IScnNode = { addr: getId(), idtf: 'База знаний', - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, content: 'Контент ссылки', contentType: null, sourceNode: null, @@ -464,7 +464,7 @@ export const tree2: IScnNode = { addr: getId(), idtf: null, direction: 'right', - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], modifiers: null, @@ -476,7 +476,7 @@ export const tree2: IScnNode = { sourceNode: null, targetNode: null, idtf: 'стартовый sc-элемент', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, }, ], @@ -491,13 +491,13 @@ export const tree3: IScnNode = { sourceNode: { addr: getId(), idtf: 'Авторизованный пользователь*', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, targetNode: { addr: getId(), idtf: 'sc-модель базы знаний', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, type: ScType.EdgeDCommonConst.value, @@ -509,7 +509,7 @@ export const tree3: IScnNode = { addr: getId(), idtf: null, direction: 'right', - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], modifiers: null, @@ -521,7 +521,7 @@ export const tree3: IScnNode = { sourceNode: null, targetNode: null, idtf: 'стартовый sc-элемент', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, children: null, }, ], @@ -536,13 +536,13 @@ export const tree4: IScnNode = { sourceNode: { addr: getId(), idtf: 'Авторизованный пользователь*', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, targetNode: { addr: getId(), idtf: 'sc-модель базы знаний', - type: ScType.NodeConst.value, + type: ScType.ConstNode.value, content: null, }, type: ScType.EdgeDCommonConst.value, @@ -554,7 +554,7 @@ export const tree4: IScnNode = { addr: getId(), idtf: null, direction: 'right', - type: ScType.EdgeAccessConstPosPerm.value, + type: ScType.ConstPermPosArc.value, }, ], modifiers: null, @@ -566,7 +566,7 @@ export const tree4: IScnNode = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, { @@ -576,7 +576,7 @@ export const tree4: IScnNode = { sourceNode: null, targetNode: null, idtf: null, - type: ScType.LinkConst.value, + type: ScType.ConstNodeLink.value, children: null, }, ], diff --git a/src/api/requests/requests.ts b/src/api/requests/requests.ts index 559a96f..3bb03d5 100644 --- a/src/api/requests/requests.ts +++ b/src/api/requests/requests.ts @@ -12,12 +12,12 @@ type TFormat = 'format_scn_json'; type TLang = 'lang_ru'; export const translate = async (action: number, format: TFormat, lang: TLang) => { - const keynodes = await scUtils.findKeynodes(format, lang); + const keynodes = await scUtils.searchKeynodes(format, lang); return request({ method: 'POST', - url: `${API_URL}/api/question/answer/translate/`, + url: `${API_URL}/api/action/result/translate/`, data: objectToFormData({ - question: action, + action: action, format: keynodes[snakeToCamelCase(format)].value, lang: keynodes[snakeToCamelCase(lang)].value, }), diff --git a/src/api/requests/scn.ts b/src/api/requests/scn.ts index 7ffdad9..ce2042c 100644 --- a/src/api/requests/scn.ts +++ b/src/api/requests/scn.ts @@ -10,8 +10,8 @@ interface IReturnScnTree { tree: IScnNode; } -const requestScnTree = async (question: number): Promise => { - const res = await translate(question, 'format_scn_json', 'lang_ru'); +const requestScnTree = async (action: number): Promise => { + const res = await translate(action, 'format_scn_json', 'lang_ru'); if (isAxiosError(res)) return res; const { link } = res.data; const [{ data }] = await client.getLinkContents([new ScAddr(link)]); @@ -29,17 +29,17 @@ const DEFAULT_CACHE_SIZE = 50; const memoizedScnTree = (cacheSize = DEFAULT_CACHE_SIZE) => { const cache = new Map(); - const removeFromCache = (question: number) => cache.delete(question); + const removeFromCache = (action: number) => cache.delete(action); const request = async ( - question: number, + action: number, onRequestStarted?: () => void, ): Promise => { - const nodeInCache = cache.get(question); + const nodeInCache = cache.get(action); if (nodeInCache) return nodeInCache; onRequestStarted?.(); - const newNode = await requestScnTree(question); + const newNode = await requestScnTree(action); if (newNode === null) { return null; @@ -47,7 +47,7 @@ const memoizedScnTree = (cacheSize = DEFAULT_CACHE_SIZE) => { if (isAxiosError(newNode)) return newNode; - cache.set(question, newNode); + cache.set(action, newNode); if (cache.size > cacheSize) shiftMap(cache, 1); return newNode; diff --git a/src/api/requests/userHistory.ts b/src/api/requests/userHistory.ts index e704bdb..f312352 100644 --- a/src/api/requests/userHistory.ts +++ b/src/api/requests/userHistory.ts @@ -4,7 +4,7 @@ import { client, isAxiosError, scUtils } from '@api'; import { doCommand } from './command'; export const appendHistoryItem = async (itemAddr: number, userAddr: number) => { - const { uiMenuViewAddActionToUserHistory } = await scUtils.findKeynodes( + const { uiMenuViewAddActionToUserHistory } = await scUtils.searchKeynodes( 'ui_menu_view_add_action_to_user_history', ); @@ -12,7 +12,7 @@ export const appendHistoryItem = async (itemAddr: number, userAddr: number) => { }; export const getHistory = async (userAddr: number) => { - const { uiMenuViewGetUserActionHistory } = await scUtils.findKeynodes( + const { uiMenuViewGetUserActionHistory } = await scUtils.searchKeynodes( 'ui_menu_view_get_user_action_history', ); @@ -20,26 +20,26 @@ export const getHistory = async (userAddr: number) => { if (isAxiosError(res)) return null; - const actionNode = new ScAddr(res.data.question); + const actionNode = new ScAddr(res.data.action); - const answer = await scUtils.getAnswer(actionNode); + const result = await scUtils.getResult(actionNode); - if (!answer) return null; + if (!result) return null; const linkAlias = '_link'; const template = new ScTemplate(); - template.triple(answer, ScType.EdgeAccessVarPosPerm, [ScType.LinkVar, linkAlias]); + template.triple(result, ScType.VarPermPosArc, [ScType.VarNodeLink, linkAlias]); - const searchRes = await client.templateSearch(template); + const searchRes = await client.searchByTemplate(template); if (!searchRes.length) return null; - const answerAddr = searchRes[0].get(linkAlias); + const resultAddr = searchRes[0].get(linkAlias); - const contents = await client.getLinkContents([answerAddr]); + const contents = await client.getLinkContents([resultAddr]); const addrs = JSON.parse(String(contents[0].data)) as string[] | null; if (!addrs) return []; - return addrs.map((addr) => ({ question: Number(addr) })).reverse(); + return addrs.map((addr) => ({ action: Number(addr) })).reverse(); }; diff --git a/src/api/sc/actions/Action.ts b/src/api/sc/actions/Action.ts index 43df560..dc77d56 100644 --- a/src/api/sc/actions/Action.ts +++ b/src/api/sc/actions/Action.ts @@ -2,7 +2,7 @@ import { nanoid } from 'nanoid'; import { ScAddr, ScConstruction, - ScEventParams, + ScEventSubscriptionParams, ScEventType, ScTemplate, ScType, @@ -18,7 +18,7 @@ export class Action { private action: string; private template: ScTemplate; - private actionNodeInited: Promise; + private actionNodeInitiated: Promise; private onFirstTripleAdded: () => void; constructor(action: string) { @@ -27,68 +27,69 @@ export class Action { this.template = new ScTemplate(); this.onFirstTripleAdded = () => undefined; - this.actionNodeInited = new Promise((resolve) => (this.onFirstTripleAdded = resolve)); + this.actionNodeInitiated = new Promise((resolve) => (this.onFirstTripleAdded = resolve)); - this.addFirstTripple(); + this.addFirstTriple(); } - private addFirstTripple = async () => { - const { question } = await scUtils.findKeynodes('question'); + private addFirstTriple = async () => { + const { action } = await scUtils.searchKeynodes('action'); this.onFirstTripleAdded(); - this.template.triple(question, ScType.EdgeAccessVarPosPerm, [ - ScType.NodeVar, - this.actionNodeAlias, - ]); + this.template.triple(action, ScType.VarPermPosArc, [ScType.VarNode, this.actionNodeAlias]); }; private initiateAction = async (actionNode: ScAddr) => { - const { questionInitiated } = await scUtils.findKeynodes('question_initiated'); + const { actionInitiated } = await scUtils.searchKeynodes('action_initiated'); const construction = new ScConstruction(); - construction.createEdge(ScType.EdgeAccessConstPosPerm, questionInitiated, actionNode); - client.createElements(construction); + construction.createEdge(ScType.ConstPermPosArc, actionInitiated, actionNode); + client.generateElements(construction); }; - private subscribeToAnswer = async (actionNode: ScAddr, onResponse: () => void) => { - const { questionFinished } = await scUtils.findKeynodes('question_finished'); + private subscribeToResult = async (actionNode: ScAddr, onResponse: () => void) => { + const { actionFinished } = await scUtils.searchKeynodes('action_finished'); const onActionFinished = ( - _subscibedAddr: ScAddr, + _subscribedAddr: ScAddr, _arc: ScAddr, anotherAddr: ScAddr, eventId: number, ) => { - if (anotherAddr.isValid() && anotherAddr.equal(questionFinished)) { + if (anotherAddr.isValid() && anotherAddr.equal(actionFinished)) { client.eventsDestroy(eventId); onResponse(); } }; - const eventParams = new ScEventParams(actionNode, ScEventType.AddIngoingEdge, onActionFinished); + const eventParams = new ScEventSubscriptionParams( + actionNode, + ScEventType.AfterGenerateOutgoingArc, + onActionFinished, + ); client.eventsCreate(eventParams); }; private findResultCircuit = async (actionNode: ScAddr) => { - const { nrelAnswer } = await scUtils.findKeynodes('nrel_answer'); + const { nrelResult } = await scUtils.searchKeynodes('nrel_result'); const circuitAlias = '_circuit'; const template = new ScTemplate(); - template.tripleWithRelation( + template.quintuple( actionNode, - ScType.EdgeDCommonVar, - [ScType.NodeVarStruct, circuitAlias], - ScType.EdgeAccessVarPosPerm, - nrelAnswer, + ScType.VarCommonArc, + [ScType.VarNodeStructure, circuitAlias], + ScType.VarPermPosArc, + nrelResult, ); - const result = await client.templateSearch(template); + const result = await client.searchByTemplate(template); if (result.length) return result[0].get(circuitAlias); return null; }; private generateAction = async () => { - const generationResult = await client.templateGenerate(this.template, {}); + const generationResult = await client.generateByTemplate(this.template, {}); if (generationResult && generationResult.size > 0) { return generationResult.get(this.actionNodeAlias); @@ -97,21 +98,21 @@ export class Action { }; public addToTemplate = async (cb: (template: ScTemplate) => void | Promise) => { - await this.actionNodeInited; + await this.actionNodeInitiated; await cb(this.template); }; public addArgs = async (...args: [ScTemplateParam, ...ScTemplateParam[]]) => { - await this.actionNodeInited; + await this.actionNodeInitiated; const rrelBaseKeynodes = args.map((_, ind) => `rrel_${ind + 1}`) as [string, ...string[]]; - const rrelKeynodes = await scUtils.findKeynodes(...rrelBaseKeynodes); + const rrelKeynodes = await scUtils.searchKeynodes(...rrelBaseKeynodes); args.forEach((rrel, ind) => { - this.template.tripleWithRelation( + this.template.quintuple( this.actionNodeAlias, - ScType.EdgeAccessVarPosPerm, + ScType.VarPermPosArc, rrel, - ScType.EdgeAccessVarPosPerm, + ScType.VarPermPosArc, rrelKeynodes[`rrel${ind + 1}`], ); }); @@ -119,12 +120,12 @@ export class Action { public initiate = () => { return new Promise((resolve) => { - scUtils.findKeynodes(this.action).then(async (keynodes) => { - await this.actionNodeInited; + scUtils.searchKeynodes(this.action).then(async (keynodes) => { + await this.actionNodeInitiated; this.template.triple( keynodes[snakeToCamelCase(this.action)], - ScType.EdgeAccessVarPosPerm, + ScType.VarPermPosArc, this.actionNodeAlias, ); @@ -134,7 +135,7 @@ export class Action { const onResponse = async () => { resolve(await this.findResultCircuit(actionNode)); }; - await this.subscribeToAnswer(actionNode, onResponse); + await this.subscribeToResult(actionNode, onResponse); await this.initiateAction(actionNode); }); }); diff --git a/src/api/sc/search/search.ts b/src/api/sc/search/search.ts index 8dfadd5..03d881f 100644 --- a/src/api/sc/search/search.ts +++ b/src/api/sc/search/search.ts @@ -5,14 +5,14 @@ const searchNodeByIdentifier = async (linkAddr: ScAddr, identification: ScAddr) const nodeAlias = '_node'; const template = new ScTemplate(); - template.tripleWithRelation( + template.quintuple( [ScType.Unknown, nodeAlias], - ScType.EdgeDCommonVar, + ScType.VarCommonArc, linkAddr, - ScType.EdgeAccessVarPosPerm, + ScType.VarPermPosArc, identification, ); - const result = await client.templateSearch(template); + const result = await client.searchByTemplate(template); if (result.length) { return result[0].get(nodeAlias); } @@ -23,7 +23,7 @@ const searchNodeByIdentifier = async (linkAddr: ScAddr, identification: ScAddr) export const searchAddrById = async (str: string) => { const [linkAddrs] = await client.getLinksByContents([str]); - const { nrelMainIdtf, nrelSystemIdentifier } = await scUtils.findKeynodes( + const { nrelMainIdtf, nrelSystemIdentifier } = await scUtils.searchKeynodes( 'nrel_system_identifier', 'nrel_main_idtf', ); diff --git a/src/components/ConfirmAction/ConfirmAction.tsx b/src/components/ConfirmAction/ConfirmAction.tsx index bf5305c..9993bb8 100644 --- a/src/components/ConfirmAction/ConfirmAction.tsx +++ b/src/components/ConfirmAction/ConfirmAction.tsx @@ -11,7 +11,13 @@ interface IProps { className?: string; } -export const ConfirmAction: FC = ({ onComplete, onClose, title, content, completeBtnText = 'Подтвердить' }) => { +export const ConfirmAction: FC = ({ + onComplete, + onClose, + title, + content, + completeBtnText = 'Подтвердить', +}) => { const onCompleteFunc = () => { onComplete(); onClose(); diff --git a/src/components/ErrorBoundary/ErrorBoundary.tsx b/src/components/ErrorBoundary/ErrorBoundary.tsx index 1b8038f..4ad445e 100644 --- a/src/components/ErrorBoundary/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary/ErrorBoundary.tsx @@ -31,7 +31,7 @@ function GoBack() { return ( ); } diff --git a/src/components/HistoryPanel/HistoryPanel.tsx b/src/components/HistoryPanel/HistoryPanel.tsx index 4229b80..f0f8f85 100644 --- a/src/components/HistoryPanel/HistoryPanel.tsx +++ b/src/components/HistoryPanel/HistoryPanel.tsx @@ -15,29 +15,29 @@ interface IProps { } export const HistoryPanel = (props: IProps) => { - const match = useMatch(routes.QUESTION); + const match = useMatch(routes.ACTION); - const { goToActiveFormatQuestion } = useScNavigation(); + const { goToActiveFormatAction } = useScNavigation(); - const onBtnClick = (question: string) => () => { - goToActiveFormatQuestion(question); + const onBtnClick = (action: string) => () => { + goToActiveFormatAction(action); }; return ( <> {!props.isLoading && (
- {props.requests.map(({ question }, ind) => ( + {props.requests.map(({ action }, ind) => ( - + ))}
diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx index a38b529..96d8dda 100644 --- a/src/components/Layout/Layout.tsx +++ b/src/components/Layout/Layout.tsx @@ -1,15 +1,15 @@ import { FC, ReactNode } from 'react'; +import { useDispatch } from 'react-redux'; +import { Link } from 'react-router-dom'; +import Logo from '@assets/images/Logo.svg'; +import { Language } from '@components/Language'; import { ScgPage } from '@components/ScgPage'; import { SidePanel } from '@components/SidePanel'; import { SidePanelWrapper } from '@components/SidePanelWrapper'; -import styles from './Layout.module.scss'; -import { Language } from '@components/Language'; -import { Link } from 'react-router-dom'; -import Logo from '@assets/images/Logo.svg'; import { routes } from '@constants'; import { setActiveLink } from '@store/activeLinkSlice'; -import { useDispatch } from 'react-redux'; +import styles from './Layout.module.scss'; export interface IProps { children?: ReactNode; diff --git a/src/components/RootRedirect/RootRedirect.tsx b/src/components/RootRedirect/RootRedirect.tsx index 5c4c86e..0c4acb9 100644 --- a/src/components/RootRedirect/RootRedirect.tsx +++ b/src/components/RootRedirect/RootRedirect.tsx @@ -9,8 +9,8 @@ export const RootRedirect = () => { if (lastRequest) { return ( { return ( @@ -20,7 +20,7 @@ export const Router = () => { > } /> } /> - } /> + } /> diff --git a/src/components/Scg/Scg.tsx b/src/components/Scg/Scg.tsx index 971ad55..7d518a1 100644 --- a/src/components/Scg/Scg.tsx +++ b/src/components/Scg/Scg.tsx @@ -5,22 +5,22 @@ import { scUtils } from '@api'; import { removeFromCache } from '@api/requests/scn'; import { ConfirmAction } from '@components/ConfirmAction'; import { scgUrl } from '@constants'; +import { useScNavigation } from '@hooks/useScNavigation'; import { addRequest } from '@store/requestHistorySlice'; import { confirmClearScenePopupContent, confirmDeletePopupContent } from './constants'; import { Frame, StyledSpinner, Wrap } from './styled'; import { EWindowEvents, ITarget, IWindowEventData } from './types'; -import { useScNavigation } from '@hooks/useScNavigation'; interface IProps { - question?: number; + action?: number; className?: string; show?: boolean; } const SPINER_COLOR = '#5896C0'; -export const Scg: FC = ({ question, className, show = false }) => { +export const Scg: FC = ({ action, className, show = false }) => { const [isReady, setIsready] = useState(false); const [isLoading, setIsLoading] = useState(false); const [targetNode, setTargetNode] = useState(null); @@ -36,8 +36,8 @@ export const Scg: FC = ({ question, className, show = false }) => { const onCommandExecuted = (data: IWindowEventData) => { if (!data.payload || !data.payload['state'] || !data.payload['response']) return; - dispatch(addRequest({ question: Number(data.payload.response.question) })); - scNavigation.goToActiveFormatQuestion(data.payload.response.question); + dispatch(addRequest({ action: Number(data.payload.response.action) })); + scNavigation.goToActiveFormatAction(data.payload.response.action); }; useEffect(() => { const iframe = ref.current; @@ -60,23 +60,23 @@ export const Scg: FC = ({ question, className, show = false }) => { break; } }; - }, [question]); + }, [action]); useEffect(() => { (async () => { - if (!isReady || !show || !question) return; + if (!isReady || !show || !action) return; const iframe = ref.current; if (!iframe) return; - const { ...rest } = await scUtils.findKeynodes(langToKeynode[lang]); + const { ...rest } = await scUtils.searchKeynodes(langToKeynode[lang]); const activeLangKeynode = rest[snakeToCamelCase(langToKeynode[lang])]; - removeFromCache(question); + removeFromCache(action); iframe.contentWindow && iframe.contentWindow.postMessage( - { type: 'renderScg', addr: question, lang: activeLangKeynode.value }, + { type: 'renderScg', addr: action, lang: activeLangKeynode.value }, '*', ); })(); - }, [isReady, question, show, lang]); + }, [isReady, action, show, lang]); targetRef.current = targetNode?.element || null; diff --git a/src/components/Scg/styled.ts b/src/components/Scg/styled.ts index a07ee5b..5ff49c9 100644 --- a/src/components/Scg/styled.ts +++ b/src/components/Scg/styled.ts @@ -29,15 +29,15 @@ export const Frame = styled.iframe` border: 0; `; -export const Popup = styled.div<{ isClear?: boolean }>` - width: ${(props) => (props.isClear ? '383px' : '344px')}; - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - font-size: 18px; - line-height: 21px; - color: #323232; - b { - font-weight: 500; - } +export const Popup = styled.div<{ isClear?: boolean }>` + width: ${(props) => (props.isClear ? '383px' : '344px')}; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + font-size: 18px; + line-height: 21px; + color: #323232; + b { + font-weight: 500; + } `; diff --git a/src/components/ScgPage/ScgPage.tsx b/src/components/ScgPage/ScgPage.tsx index cc375ed..abdce98 100644 --- a/src/components/ScgPage/ScgPage.tsx +++ b/src/components/ScgPage/ScgPage.tsx @@ -12,14 +12,14 @@ export const ScgPage = () => { const translate = useTranslate(); const scgMatch = location.pathname.match(/^\/q\/(\d+)\/scg$/); - const question = scgMatch ? Number(scgMatch[1]) : undefined; + const action = scgMatch ? Number(scgMatch[1]) : undefined; const pathArray = location.pathname.split('/'); return ( { })} shouldReturn > - + ); }; diff --git a/src/components/Scn/Scn.tsx b/src/components/Scn/Scn.tsx index ecc3ea4..b24cc4c 100644 --- a/src/components/Scn/Scn.tsx +++ b/src/components/Scn/Scn.tsx @@ -5,8 +5,8 @@ import { doCommand } from '@api/requests/command'; import { getScnTree } from '@api/requests/scn'; import { scUtils } from '@api/sc'; import { isAxiosError } from '@api/utils'; +import ArrowIcon from '@assets/images/goBack.svg'; import { Button } from '@components/Button'; -import ErrorBoundary from '@components/ErrorBoundary/ErrorBoundary'; import { Notification } from '@components/Notification'; import { DEFAULT_COMMAND_PATH, @@ -20,29 +20,28 @@ import { useLazyTimeout } from '@hooks/useTimeout'; import styles from './Scn.module.scss'; import boundaryStyle from '../ErrorBoundary/ErrorBoundary.module.scss'; -import ArrowIcon from '@assets/images/goBack.svg'; const timeoutText = { ru: ( <> - Похоже, ответ на ваш вопрос содержит большое количество связей и его загрузка может + Похоже, результат вашего действия содержит большое количество связей и его загрузка может выполняться дольше обычного. Пожалуйста, подождите... ), en: ( <> - Your answer contains a large number of links, loading may take more time. + Result of your action contains a large number of links, loading may take more time. Please wait... ), }; interface IProps { - question: number; + action: number; } -export const Scn = ({ question }: IProps) => { +export const Scn = ({ action }: IProps) => { const [tree, setTree] = useState(null); const [isLoading, setIsLoading] = useState(false); @@ -58,7 +57,7 @@ export const Scn = ({ question }: IProps) => { addToast( , @@ -88,7 +87,7 @@ export const Scn = ({ question }: IProps) => { const requestScn = useCallback(async () => { setTimeout(); - const scnRes = await getScnTree(question, onRequestStarted); + const scnRes = await getScnTree(action, onRequestStarted); if (!scnRes) { setTree(null); @@ -105,18 +104,18 @@ export const Scn = ({ question }: IProps) => { } const isTimeoutError = scnRes.response?.status === 404 && - scnRes.response.data === 'Timeout waiting for answer translation'; + scnRes.response.data === 'Timeout waiting for result translation'; if (!isTimeoutError) { resetTimeoutToast(); return addError({ ru: 'Не удалось получить SCn', en: `It's failed to get SCn` }); } timeoutRequestCountRef.current++; requestScn(); - }, [setTimeout, question, resetTimeoutToast, addError, translate, clearTimeout]); + }, [setTimeout, action, resetTimeoutToast, addError, translate, clearTimeout]); - const onAskQuestion = async (addr: number) => { + const onInitiateAction = async (addr: number) => { const { uiMenuViewFullSemanticNeighborhood } = - await scUtils.findKeynodes(DEFAULT_COMMAND_SYSTEM_ID); + await scUtils.searchKeynodes(DEFAULT_COMMAND_SYSTEM_ID); const cmdRes = await doCommand(uiMenuViewFullSemanticNeighborhood.value, addr); if (isAxiosError(cmdRes)) { @@ -124,7 +123,7 @@ export const Scn = ({ question }: IProps) => { addError({ ru: 'Не удалось выполнить запрос', en: 'Failed to handle the request' }); return null; } - return cmdRes.data.question; + return cmdRes.data.action; }; useEffect(() => { @@ -157,8 +156,8 @@ export const Scn = ({ question }: IProps) => { scgUrl={scgUrl} isLoading={isLoading} renderRequestPanel={renderRequestPanel} - onAskQuestion={onAskQuestion} - question={question} + onInitiateAction={onInitiateAction} + action={action} className={styles.container} /> ); diff --git a/src/components/ScnPage/ScnPage.tsx b/src/components/ScnPage/ScnPage.tsx index 9b00555..cdc505e 100644 --- a/src/components/ScnPage/ScnPage.tsx +++ b/src/components/ScnPage/ScnPage.tsx @@ -8,10 +8,10 @@ import styles from './ScnPage.module.scss'; export const ScnPage = () => { const translate = useTranslate(); - const match = useMatch(routes.QUESTION); + const match = useMatch(routes.ACTION); - const question = match?.params.question; - if (!question) return null; + const action = match?.params.action; + if (!action) return null; return (
@@ -26,7 +26,7 @@ export const ScnPage = () => { })} shouldReturn={true} > - +
); diff --git a/src/constants/common.ts b/src/constants/common.ts index d67f3a4..0e72951 100644 --- a/src/constants/common.ts +++ b/src/constants/common.ts @@ -4,8 +4,8 @@ import { routes } from '@constants'; const defaultApiUrl = 'http://localhost:8000'; const defaultScUrl = 'ws://localhost:8090/ws_json'; -export const SC_URL = process.env.SC_URL? process.env.SC_URL : defaultScUrl; -export const API_URL = process.env.API_URL? process.env.API_URL : defaultApiUrl; +export const SC_URL = process.env.SC_URL ? process.env.SC_URL : defaultScUrl; +export const API_URL = process.env.API_URL ? process.env.API_URL : defaultApiUrl; export const DEFAULT_SYSTEM_ID = 'knowledge_base_IMS' as const; export const DEFAULT_COMMAND_SYSTEM_ID = 'ui_menu_view_full_semantic_neighborhood' as const; diff --git a/src/constants/routes.ts b/src/constants/routes.ts index ca7ceb3..b27762e 100644 --- a/src/constants/routes.ts +++ b/src/constants/routes.ts @@ -1,3 +1,3 @@ export const MAIN = '/' as const; export const COMMAND = '/c/:commandAddr/a/:addr/:format' as const; -export const QUESTION = '/q/:question/:format' as const; +export const ACTION = '/q/:action/:format' as const; diff --git a/src/hooks/useBackNavigation.tsx b/src/hooks/useBackNavigation.tsx index 96f8a57..63fa059 100644 --- a/src/hooks/useBackNavigation.tsx +++ b/src/hooks/useBackNavigation.tsx @@ -11,9 +11,7 @@ export const useBackNavigation = () => { const goBack = useCallback(() => { if (requests.length < 2) navigate(DEFAULT_COMMAND_PATH); - navigate( - generatePath(routes.QUESTION, { question: String(requests[1].question), format: 'scn' }), - ); + navigate(generatePath(routes.ACTION, { action: String(requests[1].action), format: 'scn' })); }, [navigate, requests]); return { goBack }; diff --git a/src/hooks/useScNavigation.ts b/src/hooks/useScNavigation.ts index 3ec3dc3..5c315f1 100644 --- a/src/hooks/useScNavigation.ts +++ b/src/hooks/useScNavigation.ts @@ -15,7 +15,7 @@ export const useScNavigation = () => { const goToPrevHistoryItem = useCallback(() => { if (!firstRequest) return navigate(DEFAULT_COMMAND_PATH); - navigate(generatePath(routes.QUESTION, { question: String(firstRequest.question), format })); + navigate(generatePath(routes.ACTION, { action: String(firstRequest.action), format })); }, [firstRequest, navigate, format]); const goToActiveFormatCommand = useCallback( @@ -25,12 +25,12 @@ export const useScNavigation = () => { [format, navigate], ); - const goToActiveFormatQuestion = useCallback( - (question: string) => { - navigate(generatePath(routes.QUESTION, { question, format })); + const goToActiveFormatAction = useCallback( + (action: string) => { + navigate(generatePath(routes.ACTION, { action, format })); }, [format, navigate], ); - return { goToActiveFormatCommand, goToActiveFormatQuestion, goToPrevHistoryItem }; + return { goToActiveFormatCommand, goToActiveFormatAction, goToPrevHistoryItem }; }; diff --git a/src/index.tsx b/src/index.tsx index 0eab53d..feed92a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,8 +1,3 @@ -import { StrictMode } from 'react'; -import { createRoot } from 'react-dom/client'; -import { App } from '@components/App'; -import { Provider } from 'react-redux'; -import { store } from '@store/index'; import { LanguageProvider, ClientProvider, @@ -10,6 +5,11 @@ import { TLanguage, ToastProvider, } from 'ostis-ui-lib'; +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; +import { Provider } from 'react-redux'; +import { App } from '@components/App'; +import { store } from '@store/index'; import './assets/styles/index.scss'; import { client } from './api'; diff --git a/src/pages/Question/Question.tsx b/src/pages/Action/Action.tsx similarity index 69% rename from src/pages/Question/Question.tsx rename to src/pages/Action/Action.tsx index 1680551..f6e238a 100644 --- a/src/pages/Question/Question.tsx +++ b/src/pages/Action/Action.tsx @@ -2,12 +2,12 @@ import { useMatch } from 'react-router'; import { ScnPage } from '@components/ScnPage'; import { routes } from '@constants'; -const Question = () => { - const match = useMatch(routes.QUESTION); +const Action = () => { + const match = useMatch(routes.ACTION); if (match?.params.format !== 'scn') return null; return ; }; -export default Question; \ No newline at end of file +export default Action; diff --git a/src/pages/Action/index.ts b/src/pages/Action/index.ts new file mode 100644 index 0000000..b13d4a2 --- /dev/null +++ b/src/pages/Action/index.ts @@ -0,0 +1,3 @@ +import { lazy } from 'react'; + +export const Action = lazy(() => import(/* webpackChunkName: "action" */ './Action')); diff --git a/src/pages/Command/Command.tsx b/src/pages/Command/Command.tsx index 7c81eb9..d0e7daa 100644 --- a/src/pages/Command/Command.tsx +++ b/src/pages/Command/Command.tsx @@ -1,3 +1,4 @@ +import { Spinner, useTranslate } from 'ostis-ui-lib'; import { useCallback, useEffect, useState } from 'react'; import { generatePath, useMatch, useNavigate } from 'react-router'; import { appendHistoryItem } from '@api/requests/userHistory'; @@ -7,7 +8,6 @@ import { useDispatch, useErrorToast, useSelector } from '@hooks'; import { selectArgAddrs } from '@store'; import { selectUserAddr } from '@store/commonSlice'; import { addRequest } from '@store/requestHistorySlice'; -import { Spinner, useTranslate } from 'ostis-ui-lib'; import styles from './Command.module.scss'; @@ -30,14 +30,14 @@ const Command = () => { const translate = useTranslate(); const appendToHistory = useCallback( - async (question: number) => { + async (action: number) => { if (!userAddr) return; - const addRes = await appendHistoryItem(question, userAddr); + const addRes = await appendHistoryItem(action, userAddr); if (isAxiosError(addRes)) addError( translate({ - ru: `Не удалось сохранить вопрос ${question} в историю`, - en: `It's failed to save question ${question} in history`, + ru: `Не удалось сохранить действие ${action} в историю`, + en: `It's failed to save action ${action} in history`, }), ); }, @@ -54,19 +54,23 @@ const Command = () => { if (isAxiosError(cmdRes)) { setIsLoading(false); - return addError(translate({ ru: 'Не удалось выполнить запрос', en: `It's failed to get request` })); + return addError( + translate({ ru: 'Не удалось выполнить запрос', en: `It's failed to complete request` }), + ); } - const question = cmdRes.data.question; + const action = cmdRes.data.action; - await appendToHistory(question); + await appendToHistory(action); - dispatch(addRequest({ question })); + dispatch(addRequest({ action })); if (!isLast) return; setIsLoading(false); - navigate(generatePath(routes.QUESTION, { format, question: String(question) }), { replace: true }); + navigate(generatePath(routes.ACTION, { format, action: String(action) }), { + replace: true, + }); }, [addError, appendToHistory, args, dispatch, match, navigate, translate]); useEffect(() => { diff --git a/src/pages/Command/utils.ts b/src/pages/Command/utils.ts index 42346a1..c2253a5 100644 --- a/src/pages/Command/utils.ts +++ b/src/pages/Command/utils.ts @@ -14,4 +14,7 @@ const executeCommandInner = async ({ commandAddr, addr, args }: IArgs) => { return await doCommand(targetCommandAddr, targetAddr, ...args); }; -export const debouncedExecuteCommand = debounceWithReturn(lastInstancePromice(executeCommandInner), 500); +export const debouncedExecuteCommand = debounceWithReturn( + lastInstancePromice(executeCommandInner), + 500, +); diff --git a/src/pages/Main/Main.tsx b/src/pages/Main/Main.tsx index a4412ac..73b18d0 100644 --- a/src/pages/Main/Main.tsx +++ b/src/pages/Main/Main.tsx @@ -18,7 +18,7 @@ const StyledSwitchScgScn = styled(SwitchScgScn)` const Main = () => { const commandMatch = useMatch(routes.COMMAND); - const questionMatch = useMatch(routes.QUESTION); + const actionMatch = useMatch(routes.ACTION); const location = useLocation(); const navigate = useNavigate(); @@ -38,16 +38,16 @@ const Main = () => { return navigate(generatePath(routes.COMMAND, { commandAddr, addr, format: newActiveTab })); } - if (!questionMatch) { + if (!actionMatch) { return; } - const { question } = questionMatch.params; + const { action } = actionMatch.params; - if (!question) { + if (!action) { return; } - navigate(generatePath(routes.QUESTION, { question, format: newActiveTab })); + navigate(generatePath(routes.ACTION, { action, format: newActiveTab })); }; return ( diff --git a/src/pages/Question/index.ts b/src/pages/Question/index.ts deleted file mode 100644 index 1c48b51..0000000 --- a/src/pages/Question/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { lazy } from 'react'; - -export const Question = lazy(() => import(/* webpackChunkName: "question" */ './Question')); diff --git a/src/store/activeLinkSlice.ts b/src/store/activeLinkSlice.ts index 8427d7a..5731cd9 100644 --- a/src/store/activeLinkSlice.ts +++ b/src/store/activeLinkSlice.ts @@ -1,5 +1,5 @@ -import { routes } from '@constants'; import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import { routes } from '@constants'; import { IRootState } from '@store/model'; export interface IRequest { diff --git a/src/store/commonSlice.ts b/src/store/commonSlice.ts index b0095e5..391d455 100644 --- a/src/store/commonSlice.ts +++ b/src/store/commonSlice.ts @@ -28,9 +28,7 @@ interface IInitialState { const initialState: IInitialState = { format: 'scn', user: { - data: localStorage.getItem('user') - ? JSON.parse(localStorage.getItem('user') as string) - : null, + data: localStorage.getItem('user') ? JSON.parse(localStorage.getItem('user') as string) : null, status: { isLoading: false, isError: false, diff --git a/src/store/requestHistorySlice.ts b/src/store/requestHistorySlice.ts index f5eba2e..10b93fc 100644 --- a/src/store/requestHistorySlice.ts +++ b/src/store/requestHistorySlice.ts @@ -2,7 +2,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { IRootState } from '@store/model'; export interface IRequest { - question: number; + action: number; } interface IInitialState { requests: IRequest[]; diff --git a/src/store/store.ts b/src/store/store.ts index 187057b..93af55e 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -1,9 +1,9 @@ import { configureStore } from '@reduxjs/toolkit'; +import { requestActiveLink } from './activeLinkSlice'; import { argsFixingSlice } from './argsFixingSlice'; import { commonSlice } from './commonSlice'; import { requestHistorySlice } from './requestHistorySlice'; -import { requestActiveLink } from './activeLinkSlice'; export const store = configureStore({ reducer: { diff --git a/src/utils/getLang.ts b/src/utils/getLang.ts index 983e3b3..2c7f467 100644 --- a/src/utils/getLang.ts +++ b/src/utils/getLang.ts @@ -2,7 +2,7 @@ import { langToKeynode, snakeToCamelCase, TLanguage } from 'ostis-ui-lib'; import { scUtils } from '@api/sc'; export const getLang = async (lang: TLanguage) => { - const keynodes = await scUtils.findKeynodes(langToKeynode[lang]); + const keynodes = await scUtils.searchKeynodes(langToKeynode[lang]); const foundLang = keynodes[snakeToCamelCase(langToKeynode[lang])]; return foundLang.value; };