-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce0a200
commit 79a8651
Showing
3 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ScAddr, ScTemplate, ScType } from 'ts-sc-client'; | ||
import { client, isAxiosError, scUtils } from '@api'; | ||
|
||
import { doCommand } from './command'; | ||
|
||
|
||
export const getWhatIsIMS = async () => { | ||
const { uiMenuSummary } = await scUtils.findKeynodes("ui_menu_summary"); | ||
|
||
const { knowledgebaseIMS } = await scUtils.findKeynodes("knowledge_base_IMS"); | ||
|
||
const commandResult = await doCommand(uiMenuSummary.value, knowledgebaseIMS.value) | ||
|
||
if (isAxiosError(commandResult)) return null; | ||
|
||
const questionNode = commandResult.data.question; | ||
const answer = await scUtils.getAnswer(new ScAddr(questionNode)); | ||
|
||
if (!answer) return null; | ||
|
||
const linkAlias = '_link'; | ||
const linkTemplate = new ScTemplate(); | ||
linkTemplate.triple(answer, ScType.EdgeAccessVarPosPerm, [ScType.LinkVar, linkAlias]); | ||
|
||
const linkRes = await client.templateSearch(linkTemplate); | ||
|
||
if (!linkRes.length) return null; | ||
|
||
const linkAddr = linkRes[0].get(linkAlias) | ||
|
||
const contents = await client.getLinkContents([linkAddr]); | ||
const content = contents[0].data; | ||
|
||
return JSON.parse(String(content)); | ||
}; | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters