@botonic/plugin-flow-builder 0.27.7-alpha.0 → 0.27.8-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/action/knowledge-bases.js +0 -3
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/user-input/index.js +0 -9
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/webview/contents-context.d.ts +1 -1
- package/lib/cjs/webview/contents-context.js +3 -2
- package/lib/cjs/webview/contents-context.js.map +1 -1
- package/lib/cjs/webview/types.d.ts +8 -6
- package/lib/cjs/webview/use-webview-contents.d.ts +1 -1
- package/lib/cjs/webview/use-webview-contents.js +22 -11
- package/lib/cjs/webview/use-webview-contents.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +0 -3
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/user-input/index.js +0 -9
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/webview/contents-context.d.ts +1 -1
- package/lib/esm/webview/contents-context.js +3 -2
- package/lib/esm/webview/contents-context.js.map +1 -1
- package/lib/esm/webview/types.d.ts +8 -6
- package/lib/esm/webview/use-webview-contents.d.ts +1 -1
- package/lib/esm/webview/use-webview-contents.js +22 -11
- package/lib/esm/webview/use-webview-contents.js.map +1 -1
- package/package.json +1 -1
- package/src/action/knowledge-bases.ts +0 -3
- package/src/user-input/index.ts +2 -9
- package/src/webview/contents-context.ts +8 -7
- package/src/webview/types.ts +8 -6
- package/src/webview/use-webview-contents.ts +35 -16
|
@@ -35,9 +35,6 @@ function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, kno
|
|
|
35
35
|
!knowledgeBaseResponse.isFaithuful) {
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
|
-
console.log('KnowledgeBaseResponse:', knowledgeBaseResponse.answer, {
|
|
39
|
-
knowledgeBaseResponse,
|
|
40
|
-
});
|
|
41
38
|
return updateContentsWithAnswer(contents, knowledgeBaseResponse.answer);
|
|
42
39
|
});
|
|
43
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,sDAAkE;AAClE,0CAA8E;AAE9E,oCAA2C;AAG3C,SAAsB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,QAAQ,CAAA;SAChB;QAED,IACE,iBAAiB,CAAC,wBAAwB;YAC1C,IAAA,wBAAgB,EAAC,OAAO,CAAC,KAAK,CAAC,EAC/B;YACA,MAAM,6BAA6B,GACjC,MAAM,gCAAgC,CACpC,iBAAiB,CAAC,wBAAwB,EAC1C,OAAO,EACP,oBAAoB,EACpB,QAAQ,CACT,CAAA;YAEH,IAAI,6BAA6B,EAAE;gBACjC,OAAO,6BAA6B,CAAA;aACrC;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA3CD,gEA2CC;AAED,SAAe,gCAAgC,CAC7C,wBAA+C,EAC/C,OAAsB,EACtB,oBAAuC,EACvC,QAAuB;;QAEvB,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAC1D,OAAO,EACP,OAAO,CAAC,KAAK,CAAC,IAAK,EACnB,oBAAoB,CAAC,OAAO,CAC7B,CAAA;QACD,MAAM,kBAAkB,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAA;QAExD,IACE,CAAC,qBAAqB,CAAC,YAAY;YACnC,CAAC,qBAAqB,CAAC,WAAW,EAClC;YACA,OAAO,SAAS,CAAA;SACjB;
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,sDAAkE;AAClE,0CAA8E;AAE9E,oCAA2C;AAG3C,SAAsB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,QAAQ,CAAA;SAChB;QAED,IACE,iBAAiB,CAAC,wBAAwB;YAC1C,IAAA,wBAAgB,EAAC,OAAO,CAAC,KAAK,CAAC,EAC/B;YACA,MAAM,6BAA6B,GACjC,MAAM,gCAAgC,CACpC,iBAAiB,CAAC,wBAAwB,EAC1C,OAAO,EACP,oBAAoB,EACpB,QAAQ,CACT,CAAA;YAEH,IAAI,6BAA6B,EAAE;gBACjC,OAAO,6BAA6B,CAAA;aACrC;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA3CD,gEA2CC;AAED,SAAe,gCAAgC,CAC7C,wBAA+C,EAC/C,OAAsB,EACtB,oBAAuC,EACvC,QAAuB;;QAEvB,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAC1D,OAAO,EAC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,EAAE,sBAAW,CAAC,aAAa,EAAE;YACnD,wBAAwB;YACxB,uBAAuB;YACvB,uBAAuB;YACvB,sBAAsB;YACtB,sBAAsB;YACtB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;SAC9B,CAAC,CAAA;IACJ,CAAC;CAAA"}
|
|
@@ -16,24 +16,15 @@ function getNodeByUserInput(cmsApi, locale, request, smartIntentsConfig) {
|
|
|
16
16
|
});
|
|
17
17
|
const keywordNode = yield keywordMatcher.getNodeByInput(request.input.data);
|
|
18
18
|
if (keywordNode) {
|
|
19
|
-
console.log('Keyword node found:', keywordNode.content.title, {
|
|
20
|
-
keywordNode,
|
|
21
|
-
});
|
|
22
19
|
return keywordNode;
|
|
23
20
|
}
|
|
24
21
|
const smartIntentsApi = new smart_intent_1.SmartIntentsApi(cmsApi, request, smartIntentsConfig);
|
|
25
22
|
const smartIntentNode = yield smartIntentsApi.getNodeByInput();
|
|
26
23
|
if (smartIntentNode) {
|
|
27
|
-
console.log('Smart intent node found:', smartIntentNode.content.title, {
|
|
28
|
-
smartIntentNode,
|
|
29
|
-
});
|
|
30
24
|
return smartIntentNode;
|
|
31
25
|
}
|
|
32
26
|
const intentNode = yield (0, intent_1.getIntentNodeByInput)(cmsApi, locale, request);
|
|
33
27
|
if (intentNode) {
|
|
34
|
-
console.log('Intent node found:', intentNode.content.title, {
|
|
35
|
-
intentNode,
|
|
36
|
-
});
|
|
37
28
|
return intentNode;
|
|
38
29
|
}
|
|
39
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";;;;AASA,oCAA2C;AAC3C,qCAA+C;AAC/C,uCAA0C;AAC1C,iDAA6E;AAE7E,SAAsB,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,kBAA+C;;QAE/C,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,cAAc,GAAG,IAAI,wBAAc,CAAC;gBACxC,MAAM;gBACN,MAAM;gBACN,OAAO;aACR,CAAC,CAAA;YACF,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,IAAK,CAAC,CAAA;YAC5E,IAAI,WAAW,EAAE;gBACf,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";;;;AASA,oCAA2C;AAC3C,qCAA+C;AAC/C,uCAA0C;AAC1C,iDAA6E;AAE7E,SAAsB,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,kBAA+C;;QAE/C,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,cAAc,GAAG,IAAI,wBAAc,CAAC;gBACxC,MAAM;gBACN,MAAM;gBACN,OAAO;aACR,CAAC,CAAA;YACF,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,IAAK,CAAC,CAAA;YAC5E,IAAI,WAAW,EAAE;gBACf,OAAO,WAAW,CAAA;aACnB;YAED,MAAM,eAAe,GAAG,IAAI,8BAAe,CACzC,MAAM,EACN,OAAO,EACP,kBAAkB,CACnB,CAAA;YACD,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,CAAA;YAC9D,IAAI,eAAe,EAAE;gBACnB,OAAO,eAAe,CAAA;aACvB;YAED,MAAM,UAAU,GAAG,MAAM,IAAA,6BAAoB,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;YACtE,IAAI,UAAU,EAAE;gBACd,OAAO,UAAU,CAAA;aAClB;SACF;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA;AAlCD,gDAkCC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WebviewContentsContextType } from './types';
|
|
3
|
-
export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType
|
|
3
|
+
export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType<unknown>>;
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WebviewContentsContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
exports.WebviewContentsContext = (0, react_1.createContext)({
|
|
6
|
-
getTextContent: () =>
|
|
7
|
-
getImageSrc: () =>
|
|
6
|
+
getTextContent: () => '',
|
|
7
|
+
getImageSrc: () => '',
|
|
8
8
|
setCurrentLocale: () => undefined,
|
|
9
|
+
contents: {},
|
|
9
10
|
});
|
|
10
11
|
//# sourceMappingURL=contents-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAIxB,QAAA,sBAAsB,GAAG,IAAA,qBAAa,
|
|
1
|
+
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAIxB,QAAA,sBAAsB,GAAG,IAAA,qBAAa,EAEjD;IACA,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAA"}
|
|
@@ -26,21 +26,23 @@ export interface WebviewImageContent {
|
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
export interface UseWebviewContentsProps {
|
|
29
|
+
export interface UseWebviewContentsProps<T> {
|
|
30
30
|
apiUrl?: string;
|
|
31
31
|
version?: FlowBuilderJSONVersion;
|
|
32
32
|
orgId: string;
|
|
33
33
|
botId: string;
|
|
34
34
|
webviewId: string;
|
|
35
35
|
locale: string;
|
|
36
|
+
mapContents: Record<keyof T, string>;
|
|
36
37
|
}
|
|
37
|
-
export interface UseWebviewContents {
|
|
38
|
+
export interface UseWebviewContents<T> {
|
|
38
39
|
isLoading: boolean;
|
|
39
40
|
error: boolean;
|
|
40
|
-
webviewContentsContext: WebviewContentsContextType
|
|
41
|
+
webviewContentsContext: WebviewContentsContextType<T>;
|
|
41
42
|
}
|
|
42
|
-
export interface WebviewContentsContextType {
|
|
43
|
-
getTextContent: (code: string) => string
|
|
44
|
-
getImageSrc: (code: string) => string
|
|
43
|
+
export interface WebviewContentsContextType<T> {
|
|
44
|
+
getTextContent: (code: string) => string;
|
|
45
|
+
getImageSrc: (code: string) => string;
|
|
45
46
|
setCurrentLocale: (locale: string) => void;
|
|
47
|
+
contents: Record<keyof T, string>;
|
|
46
48
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
-
export declare function useWebviewContents({ apiUrl, version, orgId, botId, webviewId, locale, }: UseWebviewContentsProps): UseWebviewContents
|
|
2
|
+
export declare function useWebviewContents<T>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
@@ -7,15 +7,32 @@ const react_1 = require("react");
|
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const types_1 = require("../types");
|
|
9
9
|
const types_2 = require("./types");
|
|
10
|
-
function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, version = types_1.FlowBuilderJSONVersion.LATEST, orgId, botId, webviewId, locale, }) {
|
|
10
|
+
function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, version = types_1.FlowBuilderJSONVersion.LATEST, orgId, botId, webviewId, locale, mapContents, }) {
|
|
11
11
|
const [textContents, setTextContents] = (0, react_1.useState)();
|
|
12
12
|
const [imageContents, setImageContents] = (0, react_1.useState)();
|
|
13
|
+
const [contents, setContents] = (0, react_1.useState)({});
|
|
13
14
|
const [currentLocale, setCurrentLocale] = (0, react_1.useState)(locale);
|
|
14
|
-
const [isLoading, setLoading] = (0, react_1.useState)(
|
|
15
|
+
const [isLoading, setLoading] = (0, react_1.useState)(true);
|
|
15
16
|
const [error, setError] = (0, react_1.useState)(false);
|
|
17
|
+
const getTextContent = (contentID) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
return (((_b = (_a = textContents === null || textContents === void 0 ? void 0 : textContents.find(textContent => textContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.text.find(text => text.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
20
|
+
'');
|
|
21
|
+
};
|
|
22
|
+
const getImageSrc = (contentID) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return (((_b = (_a = imageContents === null || imageContents === void 0 ? void 0 : imageContents.find(imageContent => imageContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.image.find(image => image.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.file) ||
|
|
25
|
+
'');
|
|
26
|
+
};
|
|
27
|
+
const createContentsObject = () => {
|
|
28
|
+
const contentsObject = {};
|
|
29
|
+
for (const [key, value] of Object.entries(mapContents)) {
|
|
30
|
+
contentsObject[key] = getTextContent(value) || getImageSrc(value);
|
|
31
|
+
}
|
|
32
|
+
setContents(contentsObject);
|
|
33
|
+
};
|
|
16
34
|
(0, react_1.useEffect)(() => {
|
|
17
35
|
const getResponseContents = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
setLoading(true);
|
|
19
36
|
const url = `${apiUrl}/webview/${version}`;
|
|
20
37
|
try {
|
|
21
38
|
const response = yield axios_1.default.get(url, {
|
|
@@ -25,6 +42,7 @@ function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, ve
|
|
|
25
42
|
setTextContents(textResponseContents);
|
|
26
43
|
const imageResponseContents = response.data.webview_contents.filter(webviewContent => webviewContent.type === types_2.WebviewContentType.IMAGE);
|
|
27
44
|
setImageContents(imageResponseContents);
|
|
45
|
+
createContentsObject();
|
|
28
46
|
}
|
|
29
47
|
catch (error) {
|
|
30
48
|
console.error('Error fetching webview contents:', error);
|
|
@@ -36,14 +54,6 @@ function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, ve
|
|
|
36
54
|
});
|
|
37
55
|
getResponseContents();
|
|
38
56
|
}, []);
|
|
39
|
-
const getTextContent = (contentID) => {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
return (_b = (_a = textContents === null || textContents === void 0 ? void 0 : textContents.find(textContent => textContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.text.find(text => text.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.message;
|
|
42
|
-
};
|
|
43
|
-
const getImageSrc = (contentID) => {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
return (_b = (_a = imageContents === null || imageContents === void 0 ? void 0 : imageContents.find(imageContent => imageContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.image.find(image => image.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.file;
|
|
46
|
-
};
|
|
47
57
|
return {
|
|
48
58
|
isLoading,
|
|
49
59
|
error,
|
|
@@ -51,6 +61,7 @@ function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, ve
|
|
|
51
61
|
getTextContent,
|
|
52
62
|
getImageSrc,
|
|
53
63
|
setCurrentLocale,
|
|
64
|
+
contents,
|
|
54
65
|
},
|
|
55
66
|
};
|
|
56
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,iCAA2C;AAE3C,4CAAwD;AACxD,oCAAiD;AACjD,mCAOgB;AAEhB,SAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"use-webview-contents.js","s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cAAc,CAAC,IAAI,KAAK,0BAAkB,CAAC,KAAK,CAC1C,CAAA;gBAC1B,gBAAgB,CAAC,qBAAqB,CAAC,CAAA;gBACvC,oBAAoB,EAAE,CAAA;aACvB;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;gBACxD,QAAQ,CAAC,IAAI,CAAC,CAAA;aACf;oBAAS;gBACR,UAAU,CAAC,KAAK,CAAC,CAAA;aAClB;QACH,CAAC,CAAA,CAAA;QACD,mBAAmB,EAAE,CAAA;IACvB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,SAAS;QACT,KAAK;QACL,sBAAsB,EAAE;YACtB,cAAc;YACd,WAAW;YACX,gBAAgB;YAChB,QAAQ;SACT;KACF,CAAA;AACH,CAAC;AAlFD,gDAkFC"}
|
|
@@ -31,9 +31,6 @@ function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, kno
|
|
|
31
31
|
!knowledgeBaseResponse.isFaithuful) {
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
|
-
console.log('KnowledgeBaseResponse:', knowledgeBaseResponse.answer, {
|
|
35
|
-
knowledgeBaseResponse,
|
|
36
|
-
});
|
|
37
34
|
return updateContentsWithAnswer(contents, knowledgeBaseResponse.answer);
|
|
38
35
|
});
|
|
39
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAEA,OAAO,EAAe,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,MAAM,UAAgB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,iBAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,QAAQ,CAAA;SAChB;QAED,IACE,iBAAiB,CAAC,wBAAwB;YAC1C,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAC/B;YACA,MAAM,6BAA6B,GACjC,MAAM,gCAAgC,CACpC,iBAAiB,CAAC,wBAAwB,EAC1C,OAAO,EACP,oBAAoB,EACpB,QAAQ,CACT,CAAA;YAEH,IAAI,6BAA6B,EAAE;gBACjC,OAAO,6BAA6B,CAAA;aACrC;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AAED,SAAe,gCAAgC,CAC7C,wBAA+C,EAC/C,OAAsB,EACtB,oBAAuC,EACvC,QAAuB;;QAEvB,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAC1D,OAAO,EACP,OAAO,CAAC,KAAK,CAAC,IAAK,EACnB,oBAAoB,CAAC,OAAO,CAC7B,CAAA;QACD,MAAM,kBAAkB,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAA;QAExD,IACE,CAAC,qBAAqB,CAAC,YAAY;YACnC,CAAC,qBAAqB,CAAC,WAAW,EAClC;YACA,OAAO,SAAS,CAAA;SACjB;
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAEA,OAAO,EAAe,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EA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+13,15 @@ export function getNodeByUserInput(cmsApi, locale, request, smartIntentsConfig)
|
|
|
13
13
|
});
|
|
14
14
|
const keywordNode = yield keywordMatcher.getNodeByInput(request.input.data);
|
|
15
15
|
if (keywordNode) {
|
|
16
|
-
console.log('Keyword node found:', keywordNode.content.title, {
|
|
17
|
-
keywordNode,
|
|
18
|
-
});
|
|
19
16
|
return keywordNode;
|
|
20
17
|
}
|
|
21
18
|
const smartIntentsApi = new SmartIntentsApi(cmsApi, request, smartIntentsConfig);
|
|
22
19
|
const smartIntentNode = yield smartIntentsApi.getNodeByInput();
|
|
23
20
|
if (smartIntentNode) {
|
|
24
|
-
console.log('Smart intent node found:', smartIntentNode.content.title, {
|
|
25
|
-
smartIntentNode,
|
|
26
|
-
});
|
|
27
21
|
return smartIntentNode;
|
|
28
22
|
}
|
|
29
23
|
const intentNode = yield getIntentNodeByInput(cmsApi, locale, request);
|
|
30
24
|
if (intentNode) {
|
|
31
|
-
console.log('Intent node found:', intentNode.content.title, {
|
|
32
|
-
intentNode,
|
|
33
|
-
});
|
|
34
25
|
return intentNode;
|
|
35
26
|
}
|
|
36
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAA+B,MAAM,gBAAgB,CAAA;AAE7E,MAAM,UAAgB,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,kBAA+C;;QAE/C,IAAI,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC;gBACxC,MAAM;gBACN,MAAM;gBACN,OAAO;aACR,CAAC,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<reference types="react" />
|
|
2
2
|
import { WebviewContentsContextType } from './types';
|
|
3
|
-
export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType
|
|
3
|
+
export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType<unknown>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
export const WebviewContentsContext = createContext({
|
|
3
|
-
getTextContent: () =>
|
|
4
|
-
getImageSrc: () =>
|
|
3
|
+
getTextContent: () => '',
|
|
4
|
+
getImageSrc: () => '',
|
|
5
5
|
setCurrentLocale: () => undefined,
|
|
6
|
+
contents: {},
|
|
6
7
|
});
|
|
7
8
|
//# sourceMappingURL=contents-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAEjD;IACA,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAA"}
|
|
@@ -26,21 +26,23 @@ export interface WebviewImageContent {
|
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
export interface UseWebviewContentsProps {
|
|
29
|
+
export interface UseWebviewContentsProps<T> {
|
|
30
30
|
apiUrl?: string;
|
|
31
31
|
version?: FlowBuilderJSONVersion;
|
|
32
32
|
orgId: string;
|
|
33
33
|
botId: string;
|
|
34
34
|
webviewId: string;
|
|
35
35
|
locale: string;
|
|
36
|
+
mapContents: Record<keyof T, string>;
|
|
36
37
|
}
|
|
37
|
-
export interface UseWebviewContents {
|
|
38
|
+
export interface UseWebviewContents<T> {
|
|
38
39
|
isLoading: boolean;
|
|
39
40
|
error: boolean;
|
|
40
|
-
webviewContentsContext: WebviewContentsContextType
|
|
41
|
+
webviewContentsContext: WebviewContentsContextType<T>;
|
|
41
42
|
}
|
|
42
|
-
export interface WebviewContentsContextType {
|
|
43
|
-
getTextContent: (code: string) => string
|
|
44
|
-
getImageSrc: (code: string) => string
|
|
43
|
+
export interface WebviewContentsContextType<T> {
|
|
44
|
+
getTextContent: (code: string) => string;
|
|
45
|
+
getImageSrc: (code: string) => string;
|
|
45
46
|
setCurrentLocale: (locale: string) => void;
|
|
47
|
+
contents: Record<keyof T, string>;
|
|
46
48
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
-
export declare function useWebviewContents({ apiUrl, version, orgId, botId, webviewId, locale, }: UseWebviewContentsProps): UseWebviewContents
|
|
2
|
+
export declare function useWebviewContents<T>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
@@ -4,15 +4,32 @@ import { useEffect, useState } from 'react';
|
|
|
4
4
|
import { FLOW_BUILDER_API_URL_PROD } from '../constants';
|
|
5
5
|
import { FlowBuilderJSONVersion } from '../types';
|
|
6
6
|
import { WebviewContentType, } from './types';
|
|
7
|
-
export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version = FlowBuilderJSONVersion.LATEST, orgId, botId, webviewId, locale, }) {
|
|
7
|
+
export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version = FlowBuilderJSONVersion.LATEST, orgId, botId, webviewId, locale, mapContents, }) {
|
|
8
8
|
const [textContents, setTextContents] = useState();
|
|
9
9
|
const [imageContents, setImageContents] = useState();
|
|
10
|
+
const [contents, setContents] = useState({});
|
|
10
11
|
const [currentLocale, setCurrentLocale] = useState(locale);
|
|
11
|
-
const [isLoading, setLoading] = useState(
|
|
12
|
+
const [isLoading, setLoading] = useState(true);
|
|
12
13
|
const [error, setError] = useState(false);
|
|
14
|
+
const getTextContent = (contentID) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return (((_b = (_a = textContents === null || textContents === void 0 ? void 0 : textContents.find(textContent => textContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.text.find(text => text.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
17
|
+
'');
|
|
18
|
+
};
|
|
19
|
+
const getImageSrc = (contentID) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (((_b = (_a = imageContents === null || imageContents === void 0 ? void 0 : imageContents.find(imageContent => imageContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.image.find(image => image.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.file) ||
|
|
22
|
+
'');
|
|
23
|
+
};
|
|
24
|
+
const createContentsObject = () => {
|
|
25
|
+
const contentsObject = {};
|
|
26
|
+
for (const [key, value] of Object.entries(mapContents)) {
|
|
27
|
+
contentsObject[key] = getTextContent(value) || getImageSrc(value);
|
|
28
|
+
}
|
|
29
|
+
setContents(contentsObject);
|
|
30
|
+
};
|
|
13
31
|
useEffect(() => {
|
|
14
32
|
const getResponseContents = () => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
setLoading(true);
|
|
16
33
|
const url = `${apiUrl}/webview/${version}`;
|
|
17
34
|
try {
|
|
18
35
|
const response = yield axios.get(url, {
|
|
@@ -22,6 +39,7 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
22
39
|
setTextContents(textResponseContents);
|
|
23
40
|
const imageResponseContents = response.data.webview_contents.filter(webviewContent => webviewContent.type === WebviewContentType.IMAGE);
|
|
24
41
|
setImageContents(imageResponseContents);
|
|
42
|
+
createContentsObject();
|
|
25
43
|
}
|
|
26
44
|
catch (error) {
|
|
27
45
|
console.error('Error fetching webview contents:', error);
|
|
@@ -33,14 +51,6 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
33
51
|
});
|
|
34
52
|
getResponseContents();
|
|
35
53
|
}, []);
|
|
36
|
-
const getTextContent = (contentID) => {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
return (_b = (_a = textContents === null || textContents === void 0 ? void 0 : textContents.find(textContent => textContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.text.find(text => text.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.message;
|
|
39
|
-
};
|
|
40
|
-
const getImageSrc = (contentID) => {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
return (_b = (_a = imageContents === null || imageContents === void 0 ? void 0 : imageContents.find(imageContent => imageContent.code === contentID)) === null || _a === void 0 ? void 0 : _a.content.image.find(image => image.locale === currentLocale)) === null || _b === void 0 ? void 0 : _b.file;
|
|
43
|
-
};
|
|
44
54
|
return {
|
|
45
55
|
isLoading,
|
|
46
56
|
error,
|
|
@@ -48,6 +58,7 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
48
58
|
getTextContent,
|
|
49
59
|
getImageSrc,
|
|
50
60
|
setCurrentLocale,
|
|
61
|
+
contents,
|
|
51
62
|
},
|
|
52
63
|
};
|
|
53
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAC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,CAAC,MAAM,CAChE,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAC1C,CAAA;gBACzB,eAAe,CAAC,oBAAoB,CAAC,CAAA;gBAErC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CACjE,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,KAAK,kBAAkB,CAAC,KAAK,CAC1C,CAAA;gBAC1B,gBAAgB,CAAC,qBAAqB,CAAC,CAAA;gBACvC,oBAAoB,EAAE,CAAA;aACvB;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;gBACxD,QAAQ,CAAC,IAAI,CAAC,CAAA;aACf;oBAAS;gBACR,UAAU,CAAC,KAAK,CAAC,CAAA;aAClB;QACH,CAAC,CAAA,CAAA;QACD,mBAAmB,EAAE,CAAA;IACvB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,SAAS;QACT,KAAK;QACL,sBAAsB,EAAE;YACtB,cAAc;YACd,WAAW;YACX,gBAAgB;YAChB,QAAQ;SACT;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -70,9 +70,6 @@ async function getContentsWithKnowledgeResponse(
|
|
|
70
70
|
) {
|
|
71
71
|
return undefined
|
|
72
72
|
}
|
|
73
|
-
console.log('KnowledgeBaseResponse:', knowledgeBaseResponse.answer, {
|
|
74
|
-
knowledgeBaseResponse,
|
|
75
|
-
})
|
|
76
73
|
|
|
77
74
|
return updateContentsWithAnswer(contents, knowledgeBaseResponse.answer)
|
|
78
75
|
}
|
package/src/user-input/index.ts
CHANGED
|
@@ -26,11 +26,9 @@ export async function getNodeByUserInput(
|
|
|
26
26
|
})
|
|
27
27
|
const keywordNode = await keywordMatcher.getNodeByInput(request.input.data!)
|
|
28
28
|
if (keywordNode) {
|
|
29
|
-
console.log('Keyword node found:', keywordNode.content.title, {
|
|
30
|
-
keywordNode,
|
|
31
|
-
})
|
|
32
29
|
return keywordNode
|
|
33
30
|
}
|
|
31
|
+
|
|
34
32
|
const smartIntentsApi = new SmartIntentsApi(
|
|
35
33
|
cmsApi,
|
|
36
34
|
request,
|
|
@@ -38,19 +36,14 @@ export async function getNodeByUserInput(
|
|
|
38
36
|
)
|
|
39
37
|
const smartIntentNode = await smartIntentsApi.getNodeByInput()
|
|
40
38
|
if (smartIntentNode) {
|
|
41
|
-
console.log('Smart intent node found:', smartIntentNode.content.title, {
|
|
42
|
-
smartIntentNode,
|
|
43
|
-
})
|
|
44
39
|
return smartIntentNode
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
const intentNode = await getIntentNodeByInput(cmsApi, locale, request)
|
|
48
43
|
if (intentNode) {
|
|
49
|
-
console.log('Intent node found:', intentNode.content.title, {
|
|
50
|
-
intentNode,
|
|
51
|
-
})
|
|
52
44
|
return intentNode
|
|
53
45
|
}
|
|
54
46
|
}
|
|
47
|
+
|
|
55
48
|
return undefined
|
|
56
49
|
}
|
|
@@ -2,10 +2,11 @@ import { createContext } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { WebviewContentsContextType } from './types'
|
|
4
4
|
|
|
5
|
-
export const WebviewContentsContext = createContext<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
export const WebviewContentsContext = createContext<
|
|
6
|
+
WebviewContentsContextType<unknown>
|
|
7
|
+
>({
|
|
8
|
+
getTextContent: () => '',
|
|
9
|
+
getImageSrc: () => '',
|
|
10
|
+
setCurrentLocale: () => undefined,
|
|
11
|
+
contents: {},
|
|
12
|
+
})
|
package/src/webview/types.ts
CHANGED
|
@@ -25,23 +25,25 @@ export interface WebviewImageContent {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export interface UseWebviewContentsProps {
|
|
28
|
+
export interface UseWebviewContentsProps<T> {
|
|
29
29
|
apiUrl?: string
|
|
30
30
|
version?: FlowBuilderJSONVersion
|
|
31
31
|
orgId: string
|
|
32
32
|
botId: string
|
|
33
33
|
webviewId: string
|
|
34
34
|
locale: string
|
|
35
|
+
mapContents: Record<keyof T, string>
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export interface UseWebviewContents {
|
|
38
|
+
export interface UseWebviewContents<T> {
|
|
38
39
|
isLoading: boolean
|
|
39
40
|
error: boolean
|
|
40
|
-
webviewContentsContext: WebviewContentsContextType
|
|
41
|
+
webviewContentsContext: WebviewContentsContextType<T>
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export interface WebviewContentsContextType {
|
|
44
|
-
getTextContent: (code: string) => string
|
|
45
|
-
getImageSrc: (code: string) => string
|
|
44
|
+
export interface WebviewContentsContextType<T> {
|
|
45
|
+
getTextContent: (code: string) => string
|
|
46
|
+
getImageSrc: (code: string) => string
|
|
46
47
|
setCurrentLocale: (locale: string) => void
|
|
48
|
+
contents: Record<keyof T, string>
|
|
47
49
|
}
|
|
@@ -12,23 +12,52 @@ import {
|
|
|
12
12
|
WebviewTextContent,
|
|
13
13
|
} from './types'
|
|
14
14
|
|
|
15
|
-
export function useWebviewContents({
|
|
15
|
+
export function useWebviewContents<T>({
|
|
16
16
|
apiUrl = FLOW_BUILDER_API_URL_PROD,
|
|
17
17
|
version = FlowBuilderJSONVersion.LATEST,
|
|
18
18
|
orgId,
|
|
19
19
|
botId,
|
|
20
20
|
webviewId,
|
|
21
21
|
locale,
|
|
22
|
-
|
|
22
|
+
mapContents,
|
|
23
|
+
}: UseWebviewContentsProps<T>): UseWebviewContents<T> {
|
|
23
24
|
const [textContents, setTextContents] = useState<WebviewTextContent[]>()
|
|
24
25
|
const [imageContents, setImageContents] = useState<WebviewImageContent[]>()
|
|
26
|
+
const [contents, setContents] = useState<Record<keyof T, string>>(
|
|
27
|
+
{} as Record<keyof T, string>
|
|
28
|
+
)
|
|
25
29
|
const [currentLocale, setCurrentLocale] = useState(locale)
|
|
26
|
-
const [isLoading, setLoading] = useState(
|
|
30
|
+
const [isLoading, setLoading] = useState(true)
|
|
27
31
|
const [error, setError] = useState(false)
|
|
28
32
|
|
|
33
|
+
const getTextContent = (contentID: string): string => {
|
|
34
|
+
return (
|
|
35
|
+
textContents
|
|
36
|
+
?.find(textContent => textContent.code === contentID)
|
|
37
|
+
?.content.text.find(text => text.locale === currentLocale)?.message ||
|
|
38
|
+
''
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const getImageSrc = (contentID: string): string => {
|
|
43
|
+
return (
|
|
44
|
+
imageContents
|
|
45
|
+
?.find(imageContent => imageContent.code === contentID)
|
|
46
|
+
?.content.image.find(image => image.locale === currentLocale)?.file ||
|
|
47
|
+
''
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const createContentsObject = () => {
|
|
52
|
+
const contentsObject = {} as Record<keyof T, string>
|
|
53
|
+
for (const [key, value] of Object.entries<string>(mapContents)) {
|
|
54
|
+
contentsObject[key] = getTextContent(value) || getImageSrc(value)
|
|
55
|
+
}
|
|
56
|
+
setContents(contentsObject)
|
|
57
|
+
}
|
|
58
|
+
|
|
29
59
|
useEffect(() => {
|
|
30
60
|
const getResponseContents = async () => {
|
|
31
|
-
setLoading(true)
|
|
32
61
|
const url = `${apiUrl}/webview/${version}`
|
|
33
62
|
try {
|
|
34
63
|
const response = await axios.get<WebviewContentsResponse>(url, {
|
|
@@ -44,6 +73,7 @@ export function useWebviewContents({
|
|
|
44
73
|
webviewContent => webviewContent.type === WebviewContentType.IMAGE
|
|
45
74
|
) as WebviewImageContent[]
|
|
46
75
|
setImageContents(imageResponseContents)
|
|
76
|
+
createContentsObject()
|
|
47
77
|
} catch (error) {
|
|
48
78
|
console.error('Error fetching webview contents:', error)
|
|
49
79
|
setError(true)
|
|
@@ -54,18 +84,6 @@ export function useWebviewContents({
|
|
|
54
84
|
getResponseContents()
|
|
55
85
|
}, [])
|
|
56
86
|
|
|
57
|
-
const getTextContent = (contentID: string): string | undefined => {
|
|
58
|
-
return textContents
|
|
59
|
-
?.find(textContent => textContent.code === contentID)
|
|
60
|
-
?.content.text.find(text => text.locale === currentLocale)?.message
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const getImageSrc = (contentID: string): string | undefined => {
|
|
64
|
-
return imageContents
|
|
65
|
-
?.find(imageContent => imageContent.code === contentID)
|
|
66
|
-
?.content.image.find(image => image.locale === currentLocale)?.file
|
|
67
|
-
}
|
|
68
|
-
|
|
69
87
|
return {
|
|
70
88
|
isLoading,
|
|
71
89
|
error,
|
|
@@ -73,6 +91,7 @@ export function useWebviewContents({
|
|
|
73
91
|
getTextContent,
|
|
74
92
|
getImageSrc,
|
|
75
93
|
setCurrentLocale,
|
|
94
|
+
contents,
|
|
76
95
|
},
|
|
77
96
|
}
|
|
78
97
|
}
|