runid-lys 0.4.3 → 0.6.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/CHANGELOG.md +14 -0
- package/dist/{constants-DwLaT5eN.js → constants-BMsk7KvD.js} +32 -10
- package/dist/constants-BMsk7KvD.js.map +1 -0
- package/dist/i18nTools-C1k2y9xe.js +50 -0
- package/dist/i18nTools-C1k2y9xe.js.map +1 -0
- package/dist/index.js +39 -38
- package/dist/providers/hooks/useRestrictedLink.d.ts +24 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +8 -7
- package/dist/tools/index.js +16 -16
- package/dist/{routeTools-BVJY3epS.js → translationTools-CKk0l3jr.js} +122 -55
- package/dist/translationTools-CKk0l3jr.js.map +1 -0
- package/dist/types/descriptionTypes.d.ts +4 -0
- package/dist/types/routeTypes.d.ts +8 -0
- package/package.json +1 -1
- package/dist/constants-DwLaT5eN.js.map +0 -1
- package/dist/routeTools-BVJY3epS.js.map +0 -1
- package/dist/translationTools-CSKULpZZ.js +0 -114
- package/dist/translationTools-CSKULpZZ.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { l as isEmpty } from "./translationTools-CKk0l3jr.js";
|
|
2
|
+
const generateI18nTable = (locale, table, prefix = "") => {
|
|
3
|
+
let generatedTable = {};
|
|
4
|
+
Object.entries(table).forEach(([key, value]) => {
|
|
5
|
+
if (key === locale)
|
|
6
|
+
generatedTable[prefix] = value;
|
|
7
|
+
else if (typeof value == "object" && !isEmpty(value)) {
|
|
8
|
+
let newPrefix;
|
|
9
|
+
if (key !== "translation") {
|
|
10
|
+
newPrefix = prefix ? prefix + "." + key : key;
|
|
11
|
+
} else {
|
|
12
|
+
newPrefix = prefix;
|
|
13
|
+
}
|
|
14
|
+
generatedTable = {
|
|
15
|
+
...generateI18nTable(locale, value, newPrefix),
|
|
16
|
+
...generatedTable
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return generatedTable;
|
|
21
|
+
};
|
|
22
|
+
const generateI18nMessage = (locales, table, prefix = "") => {
|
|
23
|
+
const translationTable = {};
|
|
24
|
+
locales.forEach((locale) => {
|
|
25
|
+
translationTable[locale] = generateI18nTable(locale, table, prefix);
|
|
26
|
+
});
|
|
27
|
+
return translationTable;
|
|
28
|
+
};
|
|
29
|
+
const mergeI18nMessages = (locales, ...messages) => {
|
|
30
|
+
const mergedMessage = {};
|
|
31
|
+
locales.forEach((locale) => {
|
|
32
|
+
messages.forEach((message) => {
|
|
33
|
+
if (!(locale in mergedMessage)) {
|
|
34
|
+
mergedMessage[locale] = {};
|
|
35
|
+
}
|
|
36
|
+
if (locale in message) {
|
|
37
|
+
mergedMessage[locale] = {
|
|
38
|
+
...mergedMessage[locale],
|
|
39
|
+
...message[locale]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return mergedMessage;
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
generateI18nMessage as g,
|
|
48
|
+
mergeI18nMessages as m
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=i18nTools-C1k2y9xe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18nTools-C1k2y9xe.js","sources":["../src/tools/i18nTools.ts"],"sourcesContent":["/**\n * Centralized i18n utility functions\n */\nimport {isEmpty} from \"./validationTools\";\n\n/**\n * Generate translation table for a specified language\n * @param locale - Target language code\n * @param table - Translation data structure to traverse (heterogeneous nested object)\n * @param prefix - Translation key prefix for namespacing\n */\nconst generateI18nTable = (\n locale: string,\n table: Record<string, unknown>,\n prefix: string=''\n) => {\n let generatedTable: { [key: string] : string} = {};\n Object.entries(table).forEach(([key, value]) => {\n // ending condition\n if(key === locale)\n generatedTable[prefix] = value as string\n // recursive loop\n else if (typeof value == 'object' && !isEmpty(value)) {\n let newPrefix: string;\n if(key !== \"translation\") {\n newPrefix = prefix ? prefix + '.' + key : key;\n } else {\n newPrefix = prefix;\n }\n\n generatedTable = {\n ...generateI18nTable(locale, value as Record<string, unknown>, newPrefix),\n ...generatedTable\n }\n }\n });\n\n return generatedTable\n};\n\n/**\n * Generate translation table for all specified languages\n * @param locales - Array of language codes to generate translations for\n * @param table - Translation data structure to traverse (any nested object structure)\n * @param prefix - Translation key prefix for namespacing\n */\nexport const generateI18nMessage = (\n locales: string[],\n table: Record<string, unknown>,\n prefix: string=''\n) => {\n\n const translationTable: {[local: string] : { [key: string] : string}} = {};\n\n locales.forEach((locale: string)=>{\n translationTable[locale] = generateI18nTable(locale, table, prefix);\n });\n return translationTable;\n};\n\n/**\n * Merge multiple translation tables for specified languages\n * @param locales - Array of language codes\n * @param messages - Translation tables to merge\n */\nexport const mergeI18nMessages = (\n locales: string[],\n ...messages: {[p: string]: {[p: string]: string}}[]\n) => {\n const mergedMessage: {[p: string]: {[p: string]: string}} = {};\n\n locales.forEach((locale)=>{\n messages.forEach((message)=>{\n if (!(locale in mergedMessage)) {\n mergedMessage[locale] = {};\n }\n\n if(locale in message) {\n mergedMessage[locale] = {\n ...mergedMessage[locale],\n ...message[locale]\n }\n }\n });\n });\n\n return mergedMessage;\n};\n"],"names":[],"mappings":";AAWA,MAAM,oBAAoB,CACtB,QACA,OACA,SAAe,OACd;AACD,MAAI,iBAA4C,CAAA;AAChD,SAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAO;AAE7C,QAAG,QAAQ;AACP,qBAAe,MAAM,IAAI;AAAA,aAEpB,OAAO,SAAS,YAAY,CAAC,QAAQ,KAAK,GAAG;AAClD,UAAI;AACJ,UAAG,QAAQ,eAAe;AACtB,oBAAY,SAAS,SAAS,MAAM,MAAM;AAAA,MAC9C,OAAO;AACH,oBAAY;AAAA,MAChB;AAEA,uBAAiB;AAAA,QACb,GAAG,kBAAkB,QAAQ,OAAkC,SAAS;AAAA,QACxE,GAAG;AAAA,MAAA;AAAA,IAEX;AAAA,EACJ,CAAC;AAED,SAAO;AACX;AAQO,MAAM,sBAAsB,CAC/B,SACA,OACA,SAAe,OACd;AAED,QAAM,mBAAkE,CAAA;AAExE,UAAQ,QAAQ,CAAC,WAAiB;AAC9B,qBAAiB,MAAM,IAAI,kBAAkB,QAAQ,OAAO,MAAM;AAAA,EACtE,CAAC;AACD,SAAO;AACX;AAOO,MAAM,oBAAoB,CAC7B,YACG,aACF;AACD,QAAM,gBAAsD,CAAA;AAE5D,UAAQ,QAAQ,CAAC,WAAS;AACtB,aAAS,QAAQ,CAAC,YAAU;AACxB,UAAI,EAAE,UAAU,gBAAgB;AAC5B,sBAAc,MAAM,IAAI,CAAA;AAAA,MAC5B;AAEA,UAAG,UAAU,SAAS;AAClB,sBAAc,MAAM,IAAI;AAAA,UACpB,GAAG,cAAc,MAAM;AAAA,UACvB,GAAG,QAAQ,MAAM;AAAA,QAAA;AAAA,MAEzB;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,SAAO;AACX;"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { I18nLocaleEnum } from "./types/index.js";
|
|
2
|
-
import { c, a, b, e, l, n, t } from "./translationTools-
|
|
3
|
-
import {
|
|
4
|
-
import { A, C, a as
|
|
5
|
-
import { u as u2, a as
|
|
6
|
-
import { R as R2, c as
|
|
2
|
+
import { c, a, b, d, e, f, g, h, i, j, k, l, m, n, p, s, t, v } from "./translationTools-CKk0l3jr.js";
|
|
3
|
+
import { g as g2, m as m2 } from "./i18nTools-C1k2y9xe.js";
|
|
4
|
+
import { A, C, a as a2, b as b2, c as c2, E, F, G, L, d as d2, e as e2, f as f2, g as g3, P, R, S, U, W, u, h as h2, i as i2, j as j2, k as k2, l as l2, m as m3, n as n2, o, p as p2, q, r, s as s2, t as t2, v as v2, w, x, y, z } from "./constants-BMsk7KvD.js";
|
|
5
|
+
import { u as u2, a as a3 } from "./hooks-CvhFUowR.js";
|
|
6
|
+
import { R as R2, c as c3, a as a4 } from "./RelayEnvironment-D880U9SM.js";
|
|
7
7
|
import { P as P2 } from "./PublicAppTemplate-B93G2Smc.js";
|
|
8
|
-
import { e as
|
|
8
|
+
import { e as e3, i as i3 } from "./errors-BOacmKM0.js";
|
|
9
9
|
import { messagesTranslations } from "./i18n/index.js";
|
|
10
10
|
export {
|
|
11
11
|
A as AlertMessageProvider,
|
|
12
12
|
C as ChatbotProvider,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
a2 as ClientProvider,
|
|
14
|
+
b2 as ConnectedUserFragment,
|
|
15
|
+
c2 as ConnectedUserProvider,
|
|
16
16
|
E as ErrorBoundaryProvider,
|
|
17
17
|
F as FilterLabelsProvider,
|
|
18
18
|
G as GRAPHQL_ERROR,
|
|
19
19
|
I18nLocaleEnum,
|
|
20
20
|
L as LocaleProvider,
|
|
21
21
|
d2 as LysDialogProvider,
|
|
22
|
-
|
|
22
|
+
e2 as LysLoadingContext,
|
|
23
23
|
f2 as LysMutationProvider,
|
|
24
|
-
|
|
24
|
+
g3 as LysQueryProvider,
|
|
25
25
|
P as PageContextProvider,
|
|
26
26
|
P2 as PublicAppTemplate,
|
|
27
27
|
R as RefreshSignalContext,
|
|
@@ -30,24 +30,24 @@ export {
|
|
|
30
30
|
U as UrlQueriesProvider,
|
|
31
31
|
W as WebserviceAccessProvider,
|
|
32
32
|
c as checkOperationsPermission,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
a as cleanParameters,
|
|
34
|
+
c3 as clearRelayCache,
|
|
35
|
+
b as cn,
|
|
36
|
+
a4 as configureRelayEndpoint,
|
|
37
|
+
d as createComponentTranslations,
|
|
38
|
+
e as emailRegex,
|
|
39
|
+
e3 as errorTranslations,
|
|
40
|
+
f as extractOperationNames,
|
|
41
|
+
g2 as generateI18nMessage,
|
|
42
|
+
g as generateRouteFromDescription,
|
|
43
|
+
h as generateRouteTable,
|
|
44
|
+
i as generateUrl,
|
|
45
|
+
j as generateUrlByRoute,
|
|
46
|
+
k as getNestedValue,
|
|
47
|
+
l as isEmpty,
|
|
48
48
|
i3 as isErrorKey,
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
m as lowerCaseFirstLetter,
|
|
50
|
+
m2 as mergeI18nMessages,
|
|
51
51
|
messagesTranslations,
|
|
52
52
|
n as numberToString,
|
|
53
53
|
p as passwordRegex,
|
|
@@ -56,23 +56,24 @@ export {
|
|
|
56
56
|
u as useAlertMessages,
|
|
57
57
|
u2 as useChatbot,
|
|
58
58
|
h2 as useClientId,
|
|
59
|
-
|
|
59
|
+
a3 as useConnectedUserInfo,
|
|
60
60
|
i2 as useDialogWithUpdates,
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
j2 as useFilterLabels,
|
|
62
|
+
k2 as useLocale,
|
|
63
63
|
l2 as useLysDialog,
|
|
64
|
-
|
|
64
|
+
m3 as useLysLoadingFallback,
|
|
65
65
|
n2 as useLysMutation,
|
|
66
66
|
o as useLysQuery,
|
|
67
67
|
p2 as usePageContext,
|
|
68
68
|
q as usePermissionCheck,
|
|
69
69
|
r as useRefreshSignal,
|
|
70
|
-
s2 as
|
|
71
|
-
t2 as
|
|
72
|
-
v2 as
|
|
73
|
-
w as
|
|
74
|
-
x as
|
|
70
|
+
s2 as useRestrictedLink,
|
|
71
|
+
t2 as useSignal,
|
|
72
|
+
v2 as useSignalRefresh,
|
|
73
|
+
w as useSignalSubscription,
|
|
74
|
+
x as useUrlQueries,
|
|
75
|
+
y as useWebserviceAccess,
|
|
75
76
|
v as validators,
|
|
76
|
-
|
|
77
|
+
z as webserviceAccessProviderConfig
|
|
77
78
|
};
|
|
78
79
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RouteInterface } from '../../types/routeTypes';
|
|
2
|
+
export interface RestrictedLink {
|
|
3
|
+
hasPermission: boolean;
|
|
4
|
+
navigate: (() => void) | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Hook to check route permission and provide navigation callback.
|
|
8
|
+
*
|
|
9
|
+
* Combines permission checking (via WebserviceAccessProvider) with
|
|
10
|
+
* navigation (via react-router) for a given route.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const link = useRestrictedLink(route);
|
|
15
|
+
* if (link.hasPermission) {
|
|
16
|
+
* <button onClick={link.navigate}>Go</button>
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useRestrictedLink(route: RouteInterface | undefined, parameters?: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
}, queryParameters?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
}): RestrictedLink;
|
|
@@ -26,6 +26,8 @@ export { useSignal, useSignalSubscription, useSignalRefresh } from './SignalProv
|
|
|
26
26
|
export { useLysQuery } from './LysQueryProvider/hooks';
|
|
27
27
|
export { useLysMutation } from './LysMutationProvider/hooks';
|
|
28
28
|
export { usePermissionCheck } from './hooks/usePermissionCheck';
|
|
29
|
+
export { useRestrictedLink } from './hooks/useRestrictedLink';
|
|
30
|
+
export type { RestrictedLink } from './hooks/useRestrictedLink';
|
|
29
31
|
export { useClientId } from './ClientProvider/hooks';
|
|
30
32
|
export type { ClientContextValue, ClientProviderProps } from './ClientProvider/types';
|
|
31
33
|
export { default as LysLoadingContext, useLysLoadingFallback } from './LysQueryProvider/LysLoadingContext';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, C, a, b, c, E, F, G, L, d, e, f, g, P, R, S, U, W, u, h, i, j, k, l, m, n, o, p, q, r, s, t, v, w, x, y } from "../constants-
|
|
1
|
+
import { A, C, a, b, c, E, F, G, L, d, e, f, g, P, R, S, U, W, u, h, i, j, k, l, m, n, o, p, q, r, s, t, v, w, x, y, z } from "../constants-BMsk7KvD.js";
|
|
2
2
|
import { u as u2, a as a2 } from "../hooks-CvhFUowR.js";
|
|
3
3
|
import { c as c2 } from "../RelayEnvironment-D880U9SM.js";
|
|
4
4
|
export {
|
|
@@ -35,11 +35,12 @@ export {
|
|
|
35
35
|
p as usePageContext,
|
|
36
36
|
q as usePermissionCheck,
|
|
37
37
|
r as useRefreshSignal,
|
|
38
|
-
s as
|
|
39
|
-
t as
|
|
40
|
-
v as
|
|
41
|
-
w as
|
|
42
|
-
x as
|
|
43
|
-
y as
|
|
38
|
+
s as useRestrictedLink,
|
|
39
|
+
t as useSignal,
|
|
40
|
+
v as useSignalRefresh,
|
|
41
|
+
w as useSignalSubscription,
|
|
42
|
+
x as useUrlQueries,
|
|
43
|
+
y as useWebserviceAccess,
|
|
44
|
+
z as webserviceAccessProviderConfig
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { c, a, b, e, l, n, t } from "../translationTools-
|
|
2
|
-
import {
|
|
1
|
+
import { c, a, b, d, e, f, g, h, i, j, k, l, m, n, p, s, t, v } from "../translationTools-CKk0l3jr.js";
|
|
2
|
+
import { g as g2, m as m2 } from "../i18nTools-C1k2y9xe.js";
|
|
3
3
|
export {
|
|
4
4
|
c as checkOperationsPermission,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
a as cleanParameters,
|
|
6
|
+
b as cn,
|
|
7
|
+
d as createComponentTranslations,
|
|
8
|
+
e as emailRegex,
|
|
9
|
+
f as extractOperationNames,
|
|
10
|
+
g2 as generateI18nMessage,
|
|
11
|
+
g as generateRouteFromDescription,
|
|
12
|
+
h as generateRouteTable,
|
|
13
|
+
i as generateUrl,
|
|
14
|
+
j as generateUrlByRoute,
|
|
15
|
+
k as getNestedValue,
|
|
16
|
+
l as isEmpty,
|
|
17
|
+
m as lowerCaseFirstLetter,
|
|
18
|
+
m2 as mergeI18nMessages,
|
|
19
19
|
n as numberToString,
|
|
20
20
|
p as passwordRegex,
|
|
21
21
|
s as setNestedValue,
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
const lowerCaseFirstLetter = (str) => {
|
|
4
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5
|
+
};
|
|
6
|
+
const cn = (...classes) => {
|
|
7
|
+
return classes.filter(Boolean).join(" ");
|
|
8
|
+
};
|
|
9
|
+
const toSnakeCase = (str) => {
|
|
10
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
11
|
+
};
|
|
12
|
+
const numberToString = (value) => {
|
|
13
|
+
if (value == null) return "";
|
|
14
|
+
const num = typeof value === "string" ? parseFloat(value) : value;
|
|
15
|
+
if (isNaN(num)) return "";
|
|
16
|
+
return num.toLocaleString("fullwide", { useGrouping: false, maximumFractionDigits: 20 });
|
|
17
|
+
};
|
|
2
18
|
const isEmpty = (value) => {
|
|
3
19
|
if (value === null || value === void 0) return true;
|
|
4
20
|
if (typeof value === "string") return value.trim() === "";
|
|
@@ -139,50 +155,28 @@ const setNestedValue = (obj, path, value) => {
|
|
|
139
155
|
});
|
|
140
156
|
return newObj;
|
|
141
157
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
newPrefix = prefix;
|
|
153
|
-
}
|
|
154
|
-
generatedTable = {
|
|
155
|
-
...generateI18nTable(locale, value, newPrefix),
|
|
156
|
-
...generatedTable
|
|
157
|
-
};
|
|
158
|
+
function extractOperationNames(node) {
|
|
159
|
+
const operationNames = [];
|
|
160
|
+
if ("operation" in node && node.operation) {
|
|
161
|
+
const operation = node.operation;
|
|
162
|
+
if ("selections" in operation && Array.isArray(operation.selections)) {
|
|
163
|
+
operation.selections.forEach((selection) => {
|
|
164
|
+
if (selection && typeof selection === "object" && "name" in selection) {
|
|
165
|
+
operationNames.push(selection.name);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
158
168
|
}
|
|
159
|
-
}
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const mergedMessage = {};
|
|
171
|
-
locales.forEach((locale) => {
|
|
172
|
-
messages.forEach((message) => {
|
|
173
|
-
if (!(locale in mergedMessage)) {
|
|
174
|
-
mergedMessage[locale] = {};
|
|
175
|
-
}
|
|
176
|
-
if (locale in message) {
|
|
177
|
-
mergedMessage[locale] = {
|
|
178
|
-
...mergedMessage[locale],
|
|
179
|
-
...message[locale]
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
return mergedMessage;
|
|
185
|
-
};
|
|
169
|
+
}
|
|
170
|
+
return operationNames;
|
|
171
|
+
}
|
|
172
|
+
function checkOperationsPermission(operationNames, checkWebserviceAccess) {
|
|
173
|
+
if (!operationNames.length) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return operationNames.every(
|
|
177
|
+
(operationName) => checkWebserviceAccess(operationName)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
186
180
|
const generateUrl = (path, parameters = {}, queryParameters = {}) => {
|
|
187
181
|
if (!isEmpty(parameters) && !isEmpty(path)) {
|
|
188
182
|
const splitPath = path.split("/");
|
|
@@ -205,6 +199,7 @@ const generateUrlByRoute = (route, parameters = {}, queryParameters = {}) => {
|
|
|
205
199
|
return generateUrl(route.path, parameters, queryParameters);
|
|
206
200
|
};
|
|
207
201
|
const generateRouteFromDescription = (pageDescription, defaultTransPrefix = "lys.components.pages.") => {
|
|
202
|
+
var _a, _b;
|
|
208
203
|
return {
|
|
209
204
|
name: pageDescription.name,
|
|
210
205
|
transPrefix: defaultTransPrefix + lowerCaseFirstLetter(pageDescription.name) + ".",
|
|
@@ -214,7 +209,9 @@ const generateRouteFromDescription = (pageDescription, defaultTransPrefix = "lys
|
|
|
214
209
|
type: pageDescription.type,
|
|
215
210
|
breadcrumbs: pageDescription.breadcrumbs,
|
|
216
211
|
options: pageDescription.options,
|
|
217
|
-
mainWebserviceName: pageDescription.mainWebserviceName
|
|
212
|
+
mainWebserviceName: pageDescription.mainWebserviceName,
|
|
213
|
+
autoOpenChatbot: (_a = pageDescription.chatbotBehaviour) == null ? void 0 : _a.autoOpenOnEnter,
|
|
214
|
+
showChatbotWelcome: (_b = pageDescription.chatbotBehaviour) == null ? void 0 : _b.showWelcomeMessage
|
|
218
215
|
};
|
|
219
216
|
};
|
|
220
217
|
const generateRouteTable = (appDescription, defaultTransPrefix = "lys.components.pages.") => {
|
|
@@ -225,19 +222,89 @@ const generateRouteTable = (appDescription, defaultTransPrefix = "lys.components
|
|
|
225
222
|
return generateRouteFromDescription(pageDescription, defaultTransPrefix);
|
|
226
223
|
});
|
|
227
224
|
};
|
|
225
|
+
const inferComponentType = (componentName) => {
|
|
226
|
+
if (componentName.endsWith("Feature")) return "features";
|
|
227
|
+
if (componentName.endsWith("Element")) return "elements";
|
|
228
|
+
if (componentName.endsWith("Page")) return "pages";
|
|
229
|
+
if (componentName.endsWith("Restricted")) return "restrictedFeatures";
|
|
230
|
+
if (componentName.endsWith("Provider")) return "providers";
|
|
231
|
+
throw new Error(
|
|
232
|
+
`Cannot infer component type from "${componentName}". Component name must end with: Feature, Element, Page, Restricted, or Provider`
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
const toTranslationKey = (componentName) => {
|
|
236
|
+
return componentName.charAt(0).toLowerCase() + componentName.slice(1);
|
|
237
|
+
};
|
|
238
|
+
const createComponentTranslations = (componentName, translations, pathBase = "lys.components.") => {
|
|
239
|
+
const componentType = inferComponentType(componentName);
|
|
240
|
+
const translationKey = toTranslationKey(componentName);
|
|
241
|
+
const translationPath = `${pathBase}${componentType}.${translationKey}`;
|
|
242
|
+
return {
|
|
243
|
+
/**
|
|
244
|
+
* Configuration object for the i18n system
|
|
245
|
+
* Export this in your features/elements/pages/restrictedFeatures index
|
|
246
|
+
*/
|
|
247
|
+
config: {
|
|
248
|
+
translation: translations
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
* React hook to use translations in your component
|
|
252
|
+
* Returns an object with type-safe `t()` and `common()` functions
|
|
253
|
+
*
|
|
254
|
+
* @returns Object containing:
|
|
255
|
+
* - t(key, values?): Component-specific translations with optional interpolation
|
|
256
|
+
* - common(key, values?): Shared common translations with optional interpolation
|
|
257
|
+
*/
|
|
258
|
+
useTranslations: () => {
|
|
259
|
+
const intl = useIntl();
|
|
260
|
+
return useMemo(() => {
|
|
261
|
+
const t = (key, options) => {
|
|
262
|
+
const id = `${translationPath}.${String(key)}`;
|
|
263
|
+
const result = intl.formatMessage({ id }, options == null ? void 0 : options.values);
|
|
264
|
+
if ((options == null ? void 0 : options.fallbackToKey) && result === id) {
|
|
265
|
+
return String(key);
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
};
|
|
269
|
+
const common = (key, options) => {
|
|
270
|
+
const id = `lys.services.i18n.common.${String(key)}`;
|
|
271
|
+
const result = intl.formatMessage({ id }, options == null ? void 0 : options.values);
|
|
272
|
+
if ((options == null ? void 0 : options.fallbackToKey) && result === id) {
|
|
273
|
+
return String(key);
|
|
274
|
+
}
|
|
275
|
+
return result;
|
|
276
|
+
};
|
|
277
|
+
return { t, common };
|
|
278
|
+
}, [intl]);
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* Generated translation path (for debugging)
|
|
282
|
+
*/
|
|
283
|
+
translationPath,
|
|
284
|
+
/**
|
|
285
|
+
* Available translation keys (for reference)
|
|
286
|
+
*/
|
|
287
|
+
translationKeys: Object.keys(translations)
|
|
288
|
+
};
|
|
289
|
+
};
|
|
228
290
|
export {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
291
|
+
cleanParameters as a,
|
|
292
|
+
cn as b,
|
|
293
|
+
checkOperationsPermission as c,
|
|
294
|
+
createComponentTranslations as d,
|
|
233
295
|
emailRegex as e,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
296
|
+
extractOperationNames as f,
|
|
297
|
+
generateRouteFromDescription as g,
|
|
298
|
+
generateRouteTable as h,
|
|
299
|
+
generateUrl as i,
|
|
300
|
+
generateUrlByRoute as j,
|
|
301
|
+
getNestedValue as k,
|
|
302
|
+
isEmpty as l,
|
|
303
|
+
lowerCaseFirstLetter as m,
|
|
304
|
+
numberToString as n,
|
|
239
305
|
passwordRegex as p,
|
|
240
306
|
setNestedValue as s,
|
|
307
|
+
toSnakeCase as t,
|
|
241
308
|
validators as v
|
|
242
309
|
};
|
|
243
|
-
//# sourceMappingURL=
|
|
310
|
+
//# sourceMappingURL=translationTools-CKk0l3jr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translationTools-CKk0l3jr.js","sources":["../src/tools/stringTools.ts","../src/tools/validationTools.ts","../src/tools/relayTools.ts","../src/tools/routeTools.ts","../src/tools/translationTools.ts"],"sourcesContent":["/**\n * Convert first letter of string to lowercase\n */\nexport const lowerCaseFirstLetter = (str: string) => {\n return str.charAt(0).toLowerCase() + str.slice(1);\n}\n\n/**\n * Combine multiple classnames into a single string\n * Filters out falsy values\n */\nexport const cn = (...classes: (string | undefined | null | false)[]) => {\n return classes.filter(Boolean).join(' ');\n}\n\n/**\n * Convert camelCase string to snake_case\n */\nexport const toSnakeCase = (str: string): string => {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n}\n\n/**\n * Convert number to string without scientific notation\n */\nexport const numberToString = (value: number | string | null | undefined): string => {\n if (value == null) return \"\";\n const num = typeof value === \"string\" ? parseFloat(value) : value;\n if (isNaN(num)) return \"\";\n return num.toLocaleString(\"fullwide\", {useGrouping: false, maximumFractionDigits: 20});\n}\n","/**\n * Validation utilities for form fields\n */\n\n/**\n * Check if a value is empty\n */\nexport const isEmpty = (value: unknown): boolean => {\n if (value === null || value === undefined) return true;\n if (typeof value === 'string') return value.trim() === '';\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === 'object') return Object.keys(value).length === 0;\n return false;\n};\n\n/**\n * Password validation regex patterns\n * Exported for reuse in other components\n */\nexport const passwordRegex = {\n lowercase: /^(?=.*[a-z]).*$/,\n uppercase: /^(?=.*[A-Z]).*$/,\n number: /^(?=.*[0-9]).*$/,\n minLength8: /^.{8,}$/,\n minLength12: /^.{12,}$/,\n specialChar: /[#?!@$%^&*-]/,\n};\n\n/**\n * Email validation regex\n */\nexport const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n/**\n * Validator function type\n */\nexport type ValidatorFunction = (value: string | number | string[] | undefined) => boolean;\n\n/**\n * Validator with error message\n */\nexport interface Validator {\n method: ValidatorFunction;\n errorMessage: string;\n}\n\n/**\n * Pre-built validators\n */\nexport const validators = {\n /**\n * Validate that a field is not empty\n */\n required: (errorMessage: string): Validator => ({\n method: (value) => !isEmpty(value),\n errorMessage,\n }),\n\n /**\n * Validate email format\n */\n email: (errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true; // Use required validator separately\n return emailRegex.test(String(value));\n },\n errorMessage,\n }),\n\n /**\n * Validate minimum length\n */\n minLength: (min: number, errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true;\n return String(value).length >= min;\n },\n errorMessage,\n }),\n\n /**\n * Validate maximum length\n */\n maxLength: (max: number, errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true;\n return String(value).length <= max;\n },\n errorMessage,\n }),\n\n /**\n * Validate pattern\n */\n pattern: (regex: RegExp, errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true;\n return regex.test(String(value));\n },\n errorMessage,\n }),\n\n /**\n * Validate minimum value for numbers\n */\n min: (min: number, errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true;\n return Number(value) >= min;\n },\n errorMessage,\n }),\n\n /**\n * Validate maximum value for numbers\n */\n max: (max: number, errorMessage: string): Validator => ({\n method: (value) => {\n if (isEmpty(value)) return true;\n return Number(value) <= max;\n },\n errorMessage,\n }),\n\n /**\n * Custom validator\n */\n custom: (method: ValidatorFunction, errorMessage: string): Validator => ({\n method,\n errorMessage,\n }),\n};\n\n/**\n * Clean parameters by trimming strings and converting empty strings to undefined\n */\nexport const cleanParameters = (parameters: Record<string, unknown>): Record<string, unknown> => {\n const newParameters: Record<string, unknown> = {};\n\n Object.keys(parameters).forEach((key) => {\n const element = parameters[key];\n if (typeof element === \"object\" && element !== null && !Array.isArray(element)) {\n newParameters[key] = cleanParameters(element as Record<string, unknown>);\n } else if (typeof element === \"string\") {\n if (isEmpty(element)) {\n newParameters[key] = undefined;\n } else {\n newParameters[key] = element.trim();\n }\n } else {\n newParameters[key] = element;\n }\n });\n\n return newParameters;\n};\n\n/**\n * Get nested value from object using dot notation\n */\nexport const getNestedValue = (\n obj: Record<string, unknown>,\n path: string\n): string | number | string[] | undefined => {\n const keys = path.split(\".\");\n let result: unknown = obj;\n\n for (const key of keys) {\n if (result !== undefined && typeof result === \"object\" && result !== null && !Array.isArray(result)) {\n result = (result as Record<string, unknown>)[key];\n } else {\n return undefined;\n }\n }\n\n return result as string | number | string[] | undefined;\n};\n\n/**\n * Set nested value in object using dot notation\n */\nexport const setNestedValue = (\n obj: Record<string, unknown>,\n path: string,\n value: unknown\n): Record<string, unknown> => {\n const keys = path.split(\".\");\n const newObj: Record<string, unknown> = { ...obj };\n let current: Record<string, unknown> = newObj;\n\n keys.forEach((key, index) => {\n if (index === keys.length - 1) {\n current[key] = value;\n } else {\n if (!current[key] || typeof current[key] !== \"object\") {\n current[key] = {};\n } else {\n current[key] = { ...(current[key] as Record<string, unknown>) };\n }\n current = current[key] as Record<string, unknown>;\n }\n });\n\n return newObj;\n};\n","import {GraphQLTaggedNode} from \"relay-runtime\";\n\n/**\n * Extract operation names from a GraphQL query or mutation\n * Used for permission checking based on webservice names\n */\nexport function extractOperationNames(node: GraphQLTaggedNode): string[] {\n const operationNames: string[] = [];\n\n if ('operation' in node && node.operation) {\n const operation = node.operation as unknown as Record<string, unknown>;\n if ('selections' in operation && Array.isArray(operation.selections)) {\n operation.selections.forEach((selection) => {\n if (selection && typeof selection === 'object' && 'name' in selection) {\n operationNames.push(selection.name as string);\n }\n });\n }\n }\n\n return operationNames;\n}\n\n/**\n * Check if user has permission to access all operations\n * Note: checkWebserviceAccess handles snake_case conversion internally\n */\nexport function checkOperationsPermission(\n operationNames: string[],\n checkWebserviceAccess: (name: string) => boolean\n): boolean {\n if (!operationNames.length) {\n return false;\n }\n\n return operationNames.every(operationName =>\n checkWebserviceAccess(operationName)\n );\n}\n","import {RouteInterface} from \"../types/routeTypes\";\nimport {PageDescriptionType} from \"../types/descriptionTypes\";\nimport {lowerCaseFirstLetter} from \"./stringTools\";\nimport {isEmpty} from \"./validationTools\";\nimport type {AppDescription} from \"../types/relayTypes\";\n\n/**\n * Generate URL by replacing path parameters with provided values\n * @param path - URL path with placeholders (e.g., \"/user/:id\")\n * @param parameters - Object with path parameter values to substitute\n * @param queryParameters - Object with query parameter values to append\n * @returns Generated URL with replaced parameters and query string\n */\nexport const generateUrl = (\n path: string,\n parameters: {[key: string]: string} = {},\n queryParameters: {[key: string]: string} = {}\n) => {\n if (!isEmpty(parameters) && !isEmpty(path)) {\n const splitPath = path.split('/');\n Object.keys(splitPath).forEach(pathKey => {\n Object.keys(parameters).forEach(key => {\n if ( splitPath[parseInt(pathKey)] === ':' + key) {\n splitPath[parseInt(pathKey)] = parameters[key];\n }\n });\n });\n path = splitPath.join('/');\n }\n\n // Append query parameters if provided\n if (!isEmpty(queryParameters)) {\n const queryString = new URLSearchParams(queryParameters).toString();\n path = `${path}?${queryString}`;\n }\n\n return path;\n}\n\n/**\n * Generate URL from route using path and query parameters\n */\nexport const generateUrlByRoute = (\n route: RouteInterface,\n parameters: {[key: string]: string} = {},\n queryParameters: {[key: string]: string} = {}\n) => {\n return generateUrl(route.path, parameters, queryParameters)\n}\n\n/**\n * Convert page description to route interface\n */\nexport const generateRouteFromDescription = (\n pageDescription: PageDescriptionType,\n defaultTransPrefix: string = \"lys.components.pages.\"\n): RouteInterface => {\n return {\n name: pageDescription.name,\n transPrefix: defaultTransPrefix + lowerCaseFirstLetter(pageDescription.name) + \".\",\n path: pageDescription.path,\n component: pageDescription.component,\n template: pageDescription.template,\n type: pageDescription.type,\n breadcrumbs: pageDescription.breadcrumbs,\n options: pageDescription.options,\n mainWebserviceName: pageDescription.mainWebserviceName,\n autoOpenChatbot: pageDescription.chatbotBehaviour?.autoOpenOnEnter,\n showChatbotWelcome: pageDescription.chatbotBehaviour?.showWelcomeMessage,\n }\n}\n\n/**\n * Generate route table from app description\n */\nexport const generateRouteTable = (\n appDescription: AppDescription,\n defaultTransPrefix: string = \"lys.components.pages.\"\n): RouteInterface[] => {\n const pages: {[key: string]: PageDescriptionType} = appDescription?.components?.pages ?? {}\n\n return Object.keys(pages).map((pageName) => {\n const pageDescription: PageDescriptionType = pages[pageName];\n\n return generateRouteFromDescription(pageDescription, defaultTransPrefix)\n })\n}\n","import {useMemo} from \"react\";\nimport {useIntl} from \"react-intl\";\nimport {ComponentDescriptionType} from \"../types/descriptionTypes\";\nimport {TranslationType} from \"../types/i18nTypes\";\nimport {I18nLocaleEnum} from \"../types/i18nTypes\";\n\n/**\n * Infers component type from component name based on naming convention\n * - ends with \"Feature\" -> \"features\"\n * - ends with \"Element\" -> \"elements\"\n * - ends with \"Page\" -> \"pages\"\n * - ends with \"Restricted\" -> \"restrictedFeatures\"\n * - ends with \"Provider\" -> \"providers\"\n */\nconst inferComponentType = (componentName: string): string => {\n if (componentName.endsWith(\"Feature\")) return \"features\";\n if (componentName.endsWith(\"Element\")) return \"elements\";\n if (componentName.endsWith(\"Page\")) return \"pages\";\n if (componentName.endsWith(\"Restricted\")) return \"restrictedFeatures\";\n if (componentName.endsWith(\"Provider\")) return \"providers\";\n\n throw new Error(\n `Cannot infer component type from \"${componentName}\". ` +\n `Component name must end with: Feature, Element, Page, Restricted, or Provider`\n );\n};\n\n/**\n * Converts component name to translation key format\n * LoginFeature -> loginFeature\n * ButtonElement -> buttonElement\n */\nconst toTranslationKey = (componentName: string): string => {\n return componentName.charAt(0).toLowerCase() + componentName.slice(1);\n};\n\n/**\n * Creates a component translation configuration with typed helper hook\n *\n * Supports all languages defined in I18nLocaleEnum. TypeScript will enforce\n * that all translations include every language.\n *\n * @param componentName - Component name (e.g., \"LoginFeature\", \"ButtonElement\")\n * @param translations - Translation object with keys in format {key: Record<I18nLocaleEnum, string>}\n * @param pathBase - Base path for translations (default: \"lys.components.\")\n * @returns Object with config for i18n system and useTranslations hook\n *\n * @example\n * ```typescript\n * // In LoginFeature/translations.ts\n * const {config, useTranslations} = createComponentTranslations(\n * \"LoginFeature\",\n * {\n * email: {en: \"Email\", fr: \"Email\"},\n * password: {en: \"Password\", fr: \"Mot de passe\"}\n * }\n * );\n *\n * export const loginFeatureConfig = config;\n * export const useLoginTranslations = useTranslations;\n *\n * // In LoginFeature/index.tsx\n * const {t} = useLoginTranslations();\n * const label = t(\"email\"); // Type-safe!\n * ```\n */\nexport const createComponentTranslations = <\n T extends Record<string, Record<I18nLocaleEnum, string>>,\n TCommonKey extends string = string\n>(\n componentName: string,\n translations: T,\n pathBase: string = \"lys.components.\"\n) => {\n const componentType = inferComponentType(componentName);\n const translationKey = toTranslationKey(componentName);\n const translationPath = `${pathBase}${componentType}.${translationKey}`;\n\n return {\n /**\n * Configuration object for the i18n system\n * Export this in your features/elements/pages/restrictedFeatures index\n */\n config: {\n translation: translations as TranslationType\n } satisfies ComponentDescriptionType,\n\n /**\n * React hook to use translations in your component\n * Returns an object with type-safe `t()` and `common()` functions\n *\n * @returns Object containing:\n * - t(key, values?): Component-specific translations with optional interpolation\n * - common(key, values?): Shared common translations with optional interpolation\n */\n useTranslations: () => {\n const intl = useIntl();\n\n return useMemo(() => {\n /**\n * Translate a component-specific key\n * @param key - Translation key (autocompleted)\n * @param options - Optional: values for interpolation, fallbackToKey to return raw key if not found\n */\n const t = (key: keyof T, options?: {\n values?: Record<string, string | number>,\n fallbackToKey?: boolean\n }): string => {\n const id = `${translationPath}.${String(key)}`;\n const result = intl.formatMessage({id}, options?.values);\n if (options?.fallbackToKey && result === id) {\n return String(key);\n }\n return result;\n };\n\n /**\n * Translate a common/shared key\n * @param key - Common translation key (autocompleted)\n * @param options - Optional: values for interpolation, fallbackToKey to return raw key if not found\n */\n const common = (key: TCommonKey, options?: {\n values?: Record<string, string | number>,\n fallbackToKey?: boolean\n }): string => {\n const id = `lys.services.i18n.common.${String(key)}`;\n const result = intl.formatMessage({id}, options?.values);\n if (options?.fallbackToKey && result === id) {\n return String(key);\n }\n return result;\n };\n\n return {t, common};\n }, [intl]);\n },\n\n /**\n * Generated translation path (for debugging)\n */\n translationPath,\n\n /**\n * Available translation keys (for reference)\n */\n translationKeys: Object.keys(translations) as Array<keyof T>\n };\n};\n"],"names":[],"mappings":";;AAGO,MAAM,uBAAuB,CAAC,QAAgB;AACjD,SAAO,IAAI,OAAO,CAAC,EAAE,gBAAgB,IAAI,MAAM,CAAC;AACpD;AAMO,MAAM,KAAK,IAAI,YAAmD;AACrE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AAC3C;AAKO,MAAM,cAAc,CAAC,QAAwB;AAChD,SAAO,IAAI,QAAQ,UAAU,C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AM;AACnB,YAAM,OAAO,QAAA;AAEb,aAAO,QAAQ,MAAM;AAMjB,cAAM,IAAI,CAAC,KAAc,YAGX;AACV,gBAAM,KAAK,GAAG,eAAe,IAAI,OAAO,GAAG,CAAC;AAC5C,gBAAM,SAAS,KAAK,cAAc,EAAC,GAAA,GAAK,mCAAS,MAAM;AACvD,eAAI,mCAAS,kBAAiB,WAAW,IAAI;AACzC,mBAAO,OAAO,GAAG;AAAA,UACrB;AACA,iBAAO;AAAA,QACX;AAOA,cAAM,SAAS,CAAC,KAAiB,YAGnB;AACV,gBAAM,KAAK,4BAA4B,OAAO,GAAG,CAAC;AAClD,gBAAM,SAAS,KAAK,cAAc,EAAC,GAAA,GAAK,mCAAS,MAAM;AACvD,eAAI,mCAAS,kBAAiB,WAAW,IAAI;AACzC,mBAAO,OAAO,GAAG;AAAA,UACrB;AACA,iBAAO;AAAA,QACX;AAEA,eAAO,EAAC,GAAG,OAAA;AAAA,MACf,GAAG,CAAC,IAAI,CAAC;AAAA,IACb;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA;AAAA;AAAA;AAAA,IAKA,iBAAiB,OAAO,KAAK,YAAY;AAAA,EAAA;AAEjD;"}
|
|
@@ -7,6 +7,10 @@ export interface ComponentDescriptionType {
|
|
|
7
7
|
export interface ChatbotBehaviourType {
|
|
8
8
|
prompt?: string;
|
|
9
9
|
contextTools?: Record<string, string>;
|
|
10
|
+
/** Mapped to `RouteInterface.autoOpenChatbot`. */
|
|
11
|
+
autoOpenOnEnter?: boolean;
|
|
12
|
+
/** Mapped to `RouteInterface.showChatbotWelcome`. */
|
|
13
|
+
showWelcomeMessage?: boolean;
|
|
10
14
|
}
|
|
11
15
|
export type PageDescriptionType = ComponentDescriptionType & {
|
|
12
16
|
name: string;
|
|
@@ -16,4 +16,12 @@ export interface RouteInterface {
|
|
|
16
16
|
};
|
|
17
17
|
mainWebserviceName?: string | undefined;
|
|
18
18
|
description?: string;
|
|
19
|
+
/** If true, the chatbot is automatically opened when the user enters this route. */
|
|
20
|
+
autoOpenChatbot?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If true, an empty-conversation welcome message is shown in the chatbot.
|
|
23
|
+
* The message is resolved against the translation key `<transPrefix>chatbotWelcome`;
|
|
24
|
+
* if no translation exists, react-intl displays the key as-is.
|
|
25
|
+
*/
|
|
26
|
+
showChatbotWelcome?: boolean;
|
|
19
27
|
}
|