@onecx/integration-interface 8.0.0-rc.9 → 9.0.0-rc.1

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.
Files changed (50) hide show
  1. package/README.md +0 -1
  2. package/dist/index.cjs +351 -68
  3. package/dist/index.mjs +351 -68
  4. package/package.json +2 -9
  5. package/src/index.d.ts +8 -0
  6. package/src/index.js +8 -0
  7. package/src/index.js.map +1 -1
  8. package/src/lib/services/notification.service.d.ts +7 -0
  9. package/src/lib/services/notification.service.js +15 -0
  10. package/src/lib/services/notification.service.js.map +1 -0
  11. package/src/lib/topics/notification/v1/notification.model.d.ts +21 -0
  12. package/src/lib/topics/notification/v1/notification.model.js +1 -0
  13. package/src/lib/topics/notification/v1/notification.model.js.map +1 -0
  14. package/src/lib/topics/notification/v1/notification.topic.d.ts +5 -0
  15. package/src/lib/topics/notification/v1/notification.topic.js +7 -0
  16. package/src/lib/topics/notification/v1/notification.topic.js.map +1 -0
  17. package/src/lib/topics/remote-components/v1/remote-component.model.d.ts +1 -0
  18. package/src/lib/utils/configuration.utils.d.ts +41 -0
  19. package/src/lib/utils/configuration.utils.js +52 -0
  20. package/src/lib/utils/configuration.utils.js.map +1 -0
  21. package/src/lib/utils/parameters.utils.d.ts +14 -0
  22. package/src/lib/utils/parameters.utils.js +15 -0
  23. package/src/lib/utils/parameters.utils.js.map +1 -0
  24. package/src/lib/utils/portal-message.utils.d.ts +54 -0
  25. package/src/lib/utils/portal-message.utils.js +49 -0
  26. package/src/lib/utils/portal-message.utils.js.map +1 -0
  27. package/src/lib/utils/shell-capability.utils.d.ts +20 -1
  28. package/src/lib/utils/shell-capability.utils.js +29 -3
  29. package/src/lib/utils/shell-capability.utils.js.map +1 -1
  30. package/src/lib/utils/user-language.utils.d.ts +30 -0
  31. package/src/lib/utils/user-language.utils.js +56 -0
  32. package/src/lib/utils/user-language.utils.js.map +1 -0
  33. package/src/lib/utils/workspace.utils.d.ts +76 -0
  34. package/src/lib/utils/workspace.utils.js +199 -0
  35. package/src/lib/utils/workspace.utils.js.map +1 -0
  36. package/src/version.d.ts +1 -1
  37. package/src/version.js +1 -1
  38. package/migrations/index.d.ts +0 -3
  39. package/migrations/index.js +0 -4
  40. package/migrations/index.js.map +0 -1
  41. package/migrations/v5/warn-for-events-publisher-navigated.d.ts +0 -2
  42. package/migrations/v5/warn-for-events-publisher-navigated.js +0 -30
  43. package/migrations/v5/warn-for-events-publisher-navigated.js.map +0 -1
  44. package/migrations/v5/warn-for-events-topic-navigated.d.ts +0 -2
  45. package/migrations/v5/warn-for-events-topic-navigated.js +0 -31
  46. package/migrations/v5/warn-for-events-topic-navigated.js.map +0 -1
  47. package/migrations/v6/migrate-onecx-to-v6.d.ts +0 -2
  48. package/migrations/v6/migrate-onecx-to-v6.js +0 -5
  49. package/migrations/v6/migrate-onecx-to-v6.js.map +0 -1
  50. package/migrations.json +0 -46
@@ -0,0 +1,7 @@
1
+ import { Topic } from '@onecx/accelerator';
2
+ export class NotificationTopic extends Topic {
3
+ constructor() {
4
+ super('notification', 1);
5
+ }
6
+ }
7
+ //# sourceMappingURL=notification.topic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.topic.js","sourceRoot":"","sources":["../../../../../../../../libs/integration-interface/src/lib/topics/notification/v1/notification.topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAG1C,MAAM,OAAO,iBAAkB,SAAQ,KAAmB;IACxD;QACE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF"}
@@ -12,4 +12,5 @@ export type RemoteComponent = {
12
12
  exposedModule: string;
13
13
  remoteName: string;
14
14
  technology: Technologies;
15
+ shareScope?: string;
15
16
  };
@@ -0,0 +1,41 @@
1
+ import type { Config } from '../topics/configuration/v1/configuration.topic';
2
+ type LoadRemoteConfig = (url: string) => Promise<Config>;
3
+ type ConfigSource = 'inlined' | 'default' | 'remote';
4
+ interface ResolveConfigOptions {
5
+ defaultConfig?: Config;
6
+ skipRemoteConfigLoad?: boolean;
7
+ remoteConfigURL?: string;
8
+ loadRemoteConfig: LoadRemoteConfig;
9
+ }
10
+ interface ResolveConfigPayloadOptions {
11
+ defaultConfig?: Config;
12
+ skipRemoteConfigLoad?: boolean;
13
+ remoteConfigURL?: string;
14
+ loadRemoteConfig: LoadRemoteConfig;
15
+ }
16
+ interface ResolveConfigResult {
17
+ config: Config;
18
+ source: ConfigSource;
19
+ }
20
+ /**
21
+ * Returns configuration inlined into the global scope, when available.
22
+ *
23
+ * @returns Inlined configuration payload or undefined.
24
+ */
25
+ declare const getInlinedConfig: () => Config | undefined;
26
+ /**
27
+ * Resolves the configuration payload, preferring inlined config and falling back to default/remote sources.
28
+ *
29
+ * @param options - Configuration resolution inputs.
30
+ * @returns Resolved config and the source it came from.
31
+ */
32
+ declare const resolveConfig: ({ defaultConfig, skipRemoteConfigLoad, remoteConfigURL, loadRemoteConfig, }: ResolveConfigOptions) => Promise<ResolveConfigResult>;
33
+ /**
34
+ * Resolves configuration payload without merging defaults (callers can merge as needed).
35
+ *
36
+ * @param options - Configuration resolution inputs.
37
+ * @returns Resolved config payload and source.
38
+ */
39
+ declare const resolveConfigPayload: ({ defaultConfig, skipRemoteConfigLoad, remoteConfigURL, loadRemoteConfig, }: ResolveConfigPayloadOptions) => Promise<ResolveConfigResult>;
40
+ export type { ConfigSource, LoadRemoteConfig, ResolveConfigOptions, ResolveConfigPayloadOptions, ResolveConfigResult };
41
+ export { getInlinedConfig, resolveConfig, resolveConfigPayload };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Returns configuration inlined into the global scope, when available.
3
+ *
4
+ * @returns Inlined configuration payload or undefined.
5
+ */
6
+ const getInlinedConfig = () => {
7
+ return globalThis.APP_CONFIG;
8
+ };
9
+ /**
10
+ * Resolves the configuration payload, preferring inlined config and falling back to default/remote sources.
11
+ *
12
+ * @param options - Configuration resolution inputs.
13
+ * @returns Resolved config and the source it came from.
14
+ */
15
+ const resolveConfig = async ({ defaultConfig = {}, skipRemoteConfigLoad, remoteConfigURL, loadRemoteConfig, }) => {
16
+ const inlinedConfig = getInlinedConfig();
17
+ if (inlinedConfig) {
18
+ return { config: inlinedConfig, source: 'inlined' };
19
+ }
20
+ if (skipRemoteConfigLoad) {
21
+ return { config: defaultConfig, source: 'default' };
22
+ }
23
+ const resolvedUrl = remoteConfigURL || 'assets/env.json';
24
+ const remoteConfig = await loadRemoteConfig(resolvedUrl);
25
+ return {
26
+ config: { ...defaultConfig, ...(remoteConfig ?? {}) },
27
+ source: 'remote',
28
+ };
29
+ };
30
+ /**
31
+ * Resolves configuration payload without merging defaults (callers can merge as needed).
32
+ *
33
+ * @param options - Configuration resolution inputs.
34
+ * @returns Resolved config payload and source.
35
+ */
36
+ const resolveConfigPayload = async ({ defaultConfig = {}, skipRemoteConfigLoad, remoteConfigURL, loadRemoteConfig, }) => {
37
+ const inlinedConfig = getInlinedConfig();
38
+ if (inlinedConfig) {
39
+ return { config: inlinedConfig, source: 'inlined' };
40
+ }
41
+ if (skipRemoteConfigLoad) {
42
+ return { config: defaultConfig, source: 'default' };
43
+ }
44
+ const resolvedUrl = remoteConfigURL || 'assets/env.json';
45
+ const remoteConfig = await loadRemoteConfig(resolvedUrl);
46
+ return {
47
+ config: remoteConfig ?? {},
48
+ source: 'remote',
49
+ };
50
+ };
51
+ export { getInlinedConfig, resolveConfig, resolveConfigPayload };
52
+ //# sourceMappingURL=configuration.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/configuration.utils.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,GAAuB,EAAE;IAChD,OAAQ,UAA0D,CAAC,UAAU,CAAA;AAC/E,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,aAAa,GAAG,KAAK,EAAE,EAC3B,aAAa,GAAG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AAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { ParametersTopicPayload } from '../topics/parameters/v1/parameters.topic';
2
+ type ParameterValue = boolean | number | string | object;
3
+ /**
4
+ * Finds a parameter value for the given product/app identifiers.
5
+ *
6
+ * @param payload - Parameters topic payload.
7
+ * @param key - Parameter key to resolve.
8
+ * @param productName - Product name identifier.
9
+ * @param appId - Application identifier.
10
+ * @returns Resolved parameter value or undefined.
11
+ */
12
+ declare const findParameterValue: (payload: ParametersTopicPayload, key: string, productName: string, appId: string) => ParameterValue | undefined;
13
+ export { findParameterValue };
14
+ export type { ParameterValue };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Finds a parameter value for the given product/app identifiers.
3
+ *
4
+ * @param payload - Parameters topic payload.
5
+ * @param key - Parameter key to resolve.
6
+ * @param productName - Product name identifier.
7
+ * @param appId - Application identifier.
8
+ * @returns Resolved parameter value or undefined.
9
+ */
10
+ const findParameterValue = (payload, key, productName, appId) => {
11
+ return payload.parameters.find((parameter) => parameter.productName === productName && parameter.appId === appId)
12
+ ?.parameters[key];
13
+ };
14
+ export { findParameterValue };
15
+ //# sourceMappingURL=parameters.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/parameters.utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,CACzB,OAA+B,EAC/B,GAAW,EACX,WAAmB,EACnB,KAAa,EACe,EAAE;IAC9B,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,KAAK,WAAW,IAAI,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC;QAC/G,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;AACrB,CAAC,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,54 @@
1
+ export type PortalMessage = {
2
+ summaryKey?: string;
3
+ summaryParameters?: object;
4
+ detailKey?: string;
5
+ detailParameters?: object;
6
+ id?: any;
7
+ key?: string;
8
+ life?: number;
9
+ sticky?: boolean;
10
+ closable?: boolean;
11
+ data?: any;
12
+ icon?: string;
13
+ contentStyleClass?: string;
14
+ styleClass?: string;
15
+ };
16
+ type TranslateFn = (key: string, params?: object) => Promise<string> | string | undefined;
17
+ /**
18
+ * Builds a portal message payload with resolved summary and detail.
19
+ *
20
+ * @param severity - Message severity.
21
+ * @param message - Original message payload.
22
+ * @param summary - Resolved summary string.
23
+ * @param detail - Resolved detail string.
24
+ * @returns Message payload ready for publish.
25
+ */
26
+ declare const buildPortalMessagePayload: (severity: string, message: PortalMessage, summary?: string, detail?: string) => PortalMessage & {
27
+ severity: string;
28
+ summary?: string;
29
+ detail?: string;
30
+ };
31
+ /**
32
+ * Resolves a translated string for the given message key.
33
+ *
34
+ * @param translate - Translation function to use.
35
+ * @param key - Translation key.
36
+ * @param params - Translation parameters.
37
+ * @returns Translated string or undefined when no key exists.
38
+ */
39
+ declare const resolveTranslation: (translate: TranslateFn | undefined, key?: string, params?: object) => Promise<string | undefined>;
40
+ /**
41
+ * Builds a translated message payload with resolved summary and detail.
42
+ *
43
+ * @param severity - Message severity.
44
+ * @param message - Original message payload.
45
+ * @param translate - Optional translation helper.
46
+ * @returns Message payload ready for publish.
47
+ */
48
+ declare const buildTranslatedMessage: (severity: string, message: PortalMessage, translate?: TranslateFn) => Promise<PortalMessage & {
49
+ severity: string;
50
+ summary?: string;
51
+ detail?: string;
52
+ }>;
53
+ export { buildPortalMessagePayload, buildTranslatedMessage, resolveTranslation };
54
+ export type { TranslateFn };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Builds a portal message payload with resolved summary and detail.
3
+ *
4
+ * @param severity - Message severity.
5
+ * @param message - Original message payload.
6
+ * @param summary - Resolved summary string.
7
+ * @param detail - Resolved detail string.
8
+ * @returns Message payload ready for publish.
9
+ */
10
+ const buildPortalMessagePayload = (severity, message, summary, detail) => ({
11
+ ...message,
12
+ severity,
13
+ summary,
14
+ detail,
15
+ });
16
+ /**
17
+ * Resolves a translated string for the given message key.
18
+ *
19
+ * @param translate - Translation function to use.
20
+ * @param key - Translation key.
21
+ * @param params - Translation parameters.
22
+ * @returns Translated string or undefined when no key exists.
23
+ */
24
+ const resolveTranslation = async (translate, key, params) => {
25
+ if (!key) {
26
+ return undefined;
27
+ }
28
+ if (!translate) {
29
+ return key;
30
+ }
31
+ return await translate(key, params);
32
+ };
33
+ /**
34
+ * Builds a translated message payload with resolved summary and detail.
35
+ *
36
+ * @param severity - Message severity.
37
+ * @param message - Original message payload.
38
+ * @param translate - Optional translation helper.
39
+ * @returns Message payload ready for publish.
40
+ */
41
+ const buildTranslatedMessage = async (severity, message, translate) => {
42
+ const [summary, detail] = await Promise.all([
43
+ resolveTranslation(translate, message.summaryKey, message.summaryParameters),
44
+ resolveTranslation(translate, message.detailKey, message.detailParameters),
45
+ ]);
46
+ return buildPortalMessagePayload(severity, message, summary, detail);
47
+ };
48
+ export { buildPortalMessagePayload, buildTranslatedMessage, resolveTranslation };
49
+ //# sourceMappingURL=portal-message.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-message.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/portal-message.utils.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,MAAM,yBAAyB,GAAG,CAChC,QAAgB,EAChB,OAAsB,EACtB,OAAgB,EAChB,MAAe,EAC0D,EAAE,CAAC,CAAC;IAC7E,GAAG,OAAO;IACV,QAAQ;IACR,OAAO;IACP,MAAM;CACP,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAC9B,SAAkC,EAClC,GAAY,EACZ,MAAe,EACc,EAAE;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,OAAO,MAAM,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACrC,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,KAAK,EAClC,QAAgB,EAChB,OAAsB,EACtB,SAAuB,EAC2D,EAAE;IACpF,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC;QAC5E,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC;KAC3E,CAAC,CAAA;IAEF,OAAO,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,CAAA"}
@@ -1,2 +1,21 @@
1
1
  import { ShellCapability } from '../models/shell-capability.model';
2
- export declare function hasShellCapability(capability: ShellCapability): boolean;
2
+ /**
3
+ * Registers shell capabilities globally for the host application.
4
+ *
5
+ * @param capabilities - List of capabilities provided by the host shell.
6
+ */
7
+ declare const setShellCapabilities: (capabilities: ShellCapability[]) => void;
8
+ /**
9
+ * Returns currently registered shell capabilities.
10
+ *
11
+ * @returns Capability list or undefined.
12
+ */
13
+ declare const getShellCapabilities: () => ShellCapability[] | undefined;
14
+ /**
15
+ * Checks if the host application provides a capability.
16
+ *
17
+ * @param capability - Capability to verify.
18
+ * @returns True if capability is present.
19
+ */
20
+ declare const hasShellCapability: (capability: ShellCapability) => boolean;
21
+ export { getShellCapabilities, hasShellCapability, setShellCapabilities };
@@ -1,4 +1,30 @@
1
- export function hasShellCapability(capability) {
2
- return window['onecx-shell-capabilities']?.includes(capability) ?? false;
3
- }
1
+ const SHELL_CAPABILITIES_KEY = 'onecx-shell-capabilities';
2
+ /**
3
+ * Registers shell capabilities globally for the host application.
4
+ *
5
+ * @param capabilities - List of capabilities provided by the host shell.
6
+ */
7
+ const setShellCapabilities = (capabilities) => {
8
+ ;
9
+ globalThis[SHELL_CAPABILITIES_KEY] =
10
+ capabilities;
11
+ };
12
+ /**
13
+ * Returns currently registered shell capabilities.
14
+ *
15
+ * @returns Capability list or undefined.
16
+ */
17
+ const getShellCapabilities = () => {
18
+ return globalThis[SHELL_CAPABILITIES_KEY];
19
+ };
20
+ /**
21
+ * Checks if the host application provides a capability.
22
+ *
23
+ * @param capability - Capability to verify.
24
+ * @returns True if capability is present.
25
+ */
26
+ const hasShellCapability = (capability) => {
27
+ return getShellCapabilities()?.includes(capability) ?? false;
28
+ };
29
+ export { getShellCapabilities, hasShellCapability, setShellCapabilities };
4
30
  //# sourceMappingURL=shell-capability.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell-capability.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/shell-capability.utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,UAA2B;IAC5D,OAAO,MAAM,CAAC,0BAA0B,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;AAC3E,CAAC"}
1
+ {"version":3,"file":"shell-capability.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/shell-capability.utils.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,0BAA0B,CAAA;AAEzD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,YAA+B,EAAQ,EAAE;IACrE,CAAC;IAAC,UAAmF,CAAC,sBAAsB,CAAC;QAC3G,YAAY,CAAA;AAChB,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,GAAkC,EAAE;IAC/D,OAAQ,UAAmF,CAAC,sBAAsB,CAAC,CAAA;AACrH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,UAA2B,EAAW,EAAE;IAClE,OAAO,oBAAoB,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAA;AAC9D,CAAC,CAAA;AAED,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,CAAA"}
@@ -0,0 +1,30 @@
1
+ import type { UserProfile } from '../topics/user-profile/v1/user-profile.model';
2
+ type GetNormalizedBrowserLocales = () => string[];
3
+ type DetermineBrowserLanguage = () => string | undefined;
4
+ /**
5
+ * Determines the browser language using globalThis.
6
+ *
7
+ * @returns Browser language code or undefined when unavailable.
8
+ */
9
+ declare const determineBrowserLanguage: () => string | undefined;
10
+ /**
11
+ * Resolves legacy language settings from the profile.
12
+ *
13
+ * @param profile - User profile payload.
14
+ * @param defaultLang - Default language fallback.
15
+ * @param determineLang - Optional browser language resolver.
16
+ * @returns Resolved language code.
17
+ */
18
+ declare const resolveLegacyLanguage: (profile: UserProfile, defaultLang: string, determineLang?: DetermineBrowserLanguage) => string;
19
+ /**
20
+ * Resolves the preferred language from the profile settings.
21
+ *
22
+ * @param profile - User profile payload.
23
+ * @param defaultLang - Default language fallback.
24
+ * @param getNormalizedLocales - Function returning normalized browser locales.
25
+ * @param determineLang - Optional browser language resolver.
26
+ * @returns Resolved language code.
27
+ */
28
+ declare const resolveProfileLanguage: (profile: UserProfile, defaultLang: string, getNormalizedLocales: GetNormalizedBrowserLocales, determineLang?: DetermineBrowserLanguage) => string;
29
+ export { determineBrowserLanguage, resolveLegacyLanguage, resolveProfileLanguage };
30
+ export type { DetermineBrowserLanguage, GetNormalizedBrowserLocales };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Determines the browser language using globalThis.
3
+ *
4
+ * @returns Browser language code or undefined when unavailable.
5
+ */
6
+ const determineBrowserLanguage = () => {
7
+ const windowRef = globalThis.window;
8
+ if (!windowRef || !windowRef.navigator) {
9
+ return undefined;
10
+ }
11
+ let browserLang = windowRef.navigator.languages?.[0];
12
+ browserLang = browserLang || windowRef.navigator.language;
13
+ if (!browserLang) {
14
+ return undefined;
15
+ }
16
+ if (browserLang.includes('-')) {
17
+ browserLang = browserLang.split('-')[0];
18
+ }
19
+ if (browserLang.includes('_')) {
20
+ browserLang = browserLang.split('_')[0];
21
+ }
22
+ return browserLang;
23
+ };
24
+ /**
25
+ * Resolves legacy language settings from the profile.
26
+ *
27
+ * @param profile - User profile payload.
28
+ * @param defaultLang - Default language fallback.
29
+ * @param determineLang - Optional browser language resolver.
30
+ * @returns Resolved language code.
31
+ */
32
+ const resolveLegacyLanguage = (profile, defaultLang, determineLang = determineBrowserLanguage) => {
33
+ return profile.accountSettings?.localeAndTimeSettings?.locale ?? determineLang() ?? defaultLang;
34
+ };
35
+ /**
36
+ * Resolves the preferred language from the profile settings.
37
+ *
38
+ * @param profile - User profile payload.
39
+ * @param defaultLang - Default language fallback.
40
+ * @param getNormalizedLocales - Function returning normalized browser locales.
41
+ * @param determineLang - Optional browser language resolver.
42
+ * @returns Resolved language code.
43
+ */
44
+ const resolveProfileLanguage = (profile, defaultLang, getNormalizedLocales, determineLang = determineBrowserLanguage) => {
45
+ let locales = profile.settings?.locales;
46
+ if (!locales) {
47
+ return resolveLegacyLanguage(profile, defaultLang, determineLang);
48
+ }
49
+ if (locales.length === 0) {
50
+ locales = getNormalizedLocales();
51
+ }
52
+ const firstLang = locales.find((lang) => lang.length === 2);
53
+ return firstLang ?? defaultLang;
54
+ };
55
+ export { determineBrowserLanguage, resolveLegacyLanguage, resolveProfileLanguage };
56
+ //# sourceMappingURL=user-language.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-language.utils.js","sourceRoot":"","sources":["../../../../../../libs/integration-interface/src/lib/utils/user-language.utils.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,wBAAwB,G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AC,CAAA;IACnE,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,GAAG,oBAAoB,EAAE,CAAA;IAClC,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;IAC3D,OAAO,SAAS,IAAI,WAAW,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAA"}
@@ -0,0 +1,76 @@
1
+ import { Endpoint } from '../topics/current-workspace/v1/endpoint.model';
2
+ import { Route } from '../topics/current-workspace/v1/route.model';
3
+ import type { Workspace } from '../topics/current-workspace/v1/workspace.model';
4
+ type EndpointParameters = Record<string, unknown>;
5
+ type WarnHandler = (message: string) => void;
6
+ /**
7
+ * Builds the base URL from the workspace, with warnings on missing values.
8
+ *
9
+ * @param workspace - Workspace definition.
10
+ * @returns Base URL string or empty string if missing.
11
+ */
12
+ declare const constructBaseUrlFromWorkspace: (workspace: Workspace, warn: WarnHandler) => string;
13
+ /**
14
+ * Finds a route entry for a product/app pair.
15
+ *
16
+ * @param routes - Available route definitions.
17
+ * @param appId - Application identifier.
18
+ * @param productName - Product name identifier.
19
+ * @returns Matched route or undefined.
20
+ */
21
+ declare const filterRouteFromList: (routes: Array<Route> | undefined, appId: string, productName: string, warn: WarnHandler) => Route | undefined;
22
+ /**
23
+ * Resolves endpoint aliases to the final endpoint definition.
24
+ *
25
+ * @param endpointName - Endpoint name or alias.
26
+ * @param endpoints - Available endpoint definitions.
27
+ * @returns Resolved endpoint or undefined.
28
+ */
29
+ declare const dissolveEndpoint: (endpointName: string, endpoints: Array<Endpoint>) => Endpoint | undefined;
30
+ /**
31
+ * Normalizes parameter values into strings for URL interpolation.
32
+ *
33
+ * @param value - Parameter value to normalize.
34
+ * @returns Normalized string value.
35
+ */
36
+ declare const getStringFromUnknown: (value: unknown) => string;
37
+ /**
38
+ * Replaces path parameters with the provided endpoint parameter values.
39
+ *
40
+ * @param path - Endpoint path template.
41
+ * @param endpointParameters - Parameters to inject.
42
+ * @returns Path with parameters resolved, or empty string on failure.
43
+ */
44
+ declare const fillParamsForPath: (path: string, endpointParameters: EndpointParameters, warn: WarnHandler) => string;
45
+ /**
46
+ * Constructs a URL path for a concrete endpoint, resolving aliases and params.
47
+ *
48
+ * @param route - Route definition.
49
+ * @param endpointName - Endpoint name or alias.
50
+ * @param endpointParameters - Endpoint parameters for interpolation.
51
+ * @returns Endpoint URL path string.
52
+ */
53
+ declare const constructEndpointUrl: (route: Route, endpointName: string, endpointParameters: EndpointParameters | undefined, warn?: WarnHandler) => string;
54
+ /**
55
+ * Constructs a full route URL for a workspace, app, and optional endpoint.
56
+ *
57
+ * @param workspace - Workspace definition.
58
+ * @param appId - Application identifier.
59
+ * @param productName - Product name identifier.
60
+ * @param endpointName - Optional endpoint name.
61
+ * @param endpointParameters - Optional endpoint parameters.
62
+ * @returns Resolved route URL string.
63
+ */
64
+ declare const constructRouteUrl: (workspace: Workspace, appId: string, productName: string, endpointName?: string, endpointParameters?: EndpointParameters, warn?: WarnHandler) => string;
65
+ /**
66
+ * Checks whether a route or endpoint URL exists for the given identifiers.
67
+ *
68
+ * @param workspace - Workspace definition.
69
+ * @param productName - Product name identifier.
70
+ * @param appId - Application identifier.
71
+ * @param endpointName - Optional endpoint name to validate.
72
+ * @returns True if the URL exists.
73
+ */
74
+ declare const doesUrlExistForWorkspace: (workspace: Workspace, productName: string, appId: string, endpointName?: string, warn?: WarnHandler) => boolean;
75
+ export type { EndpointParameters };
76
+ export { constructBaseUrlFromWorkspace, constructEndpointUrl, constructRouteUrl, doesUrlExistForWorkspace, dissolveEndpoint, fillParamsForPath, filterRouteFromList, getStringFromUnknown, };