@telia-ace/alliance-internal-client-utilities 1.0.3 → 1.0.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @telia-ace/alliance-internal-client-utilities
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - c2335bc: Replace Vite with Tsup when building packages.
8
+
9
+ ## 1.0.4-next.0
10
+
11
+ ### Patch Changes
12
+
13
+ - cd44395: Replace Vite with Tsup when building packages.
14
+
3
15
  ## 1.0.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,126 @@
1
- export { AllianceError, FrameworkErrorCodes, UtilitiesErrorCodes, isAllianceError, } from './exceptions';
2
- export * from './routing';
3
- export { default as Texts, type TextArgs } from './texts';
4
- export { TranslationsKey } from './translations';
5
- export type * from './types';
6
- export * from './ui';
1
+ declare enum FrameworkErrorCodes {
2
+ AlreadyInitialized = 1000,
3
+ NoAppName = 1001,
4
+ MissingAppController = 1002,
5
+ MissingCapabilityOnApp = 1003,
6
+ MissingManagedObjectProvider = 1004,
7
+ NoManifest = 1005,
8
+ NoRootElement = 1006,
9
+ NoView = 1007,
10
+ CookieKeyNotDefined = 1008,
11
+ CookieCategoryNotAllowed = 1009,
12
+ StorageKeyNotDefined = 1010,
13
+ StorageCategoryNotAllowed = 1011,
14
+ LocalizationTemplateNotDefined = 1012,
15
+ NonViewOperation = 1013
16
+ }
17
+ declare enum UtilitiesErrorCodes {
18
+ CurrentUserMissingProvider = 2000,
19
+ CurrentUserGatewayNotStarted = 2001,
20
+ CurrentUserMissingBackend = 2002,
21
+ CurrentUserMissingInDatabase = 2003
22
+ }
23
+ type ErrorCodes = UtilitiesErrorCodes | FrameworkErrorCodes;
24
+ declare class AllianceError extends Error {
25
+ code: ErrorCodes;
26
+ constructor(code: ErrorCodes, variables?: Record<string, string>);
27
+ }
28
+ declare function isAllianceError(error: any): error is AllianceError;
29
+
30
+ type Promisable<T> = Promise<T> | T;
31
+ type ValueTypes = string | number | boolean | undefined | null;
32
+ type Serializeable = ValueTypes | SerializeableObject | ValueTypes[] | SerializeableObject[];
33
+ interface SerializeableObject {
34
+ [key: string]: Serializeable;
35
+ }
36
+
37
+ declare function createCapabilityPath(app?: string, capability?: string, args?: SerializeableObject): string;
38
+ declare function getCurrentLocationInfo(): {
39
+ app: string;
40
+ capability: string;
41
+ };
42
+ declare function getRuntimeRootUrl(): string;
43
+
44
+ type Translations = {
45
+ [key in TranslationsKey]: string;
46
+ };
47
+ declare enum TranslationsKey {
48
+ AlreadyExists = 0,
49
+ ApiGatewayPortDescription = 1,
50
+ ApiServerModeDescription = 2,
51
+ AppConfigurationPath = 3,
52
+ AppCreated = 4,
53
+ AppEntryBuildOptionDescription = 5,
54
+ AppNameInquiry = 6,
55
+ BuildDescription = 7,
56
+ BuildModeOptionDescription = 8,
57
+ BuildWatchDescription = 9,
58
+ CreateAppDescription = 10,
59
+ CreateWorkspaceDescription = 11,
60
+ DevServerOpenDescription = 12,
61
+ DevServerPortDescription = 13,
62
+ DevServerLoggingDescription = 14,
63
+ Done = 15,
64
+ FetchPackageVersionError = 16,
65
+ ManifestEntryBuildOptionDescription = 17,
66
+ MissingTranslationKey = 18,
67
+ NoAppName = 19,
68
+ NoAppNameFound = 20,
69
+ NoAppOrWorkspaceInCurrentDirectory = 21,
70
+ NoWorkspaceName = 22,
71
+ OperationCancelled = 23,
72
+ ServeDescription = 24,
73
+ ServedStopped = 25,
74
+ ServerGatewayMode = 26,
75
+ ServerMode = 27,
76
+ ServerModeInquiry = 28,
77
+ ServerProxyMode = 29,
78
+ StopServerInstructions = 30,
79
+ TemplateFrameworkInquiry = 31,
80
+ TemplateLanguageInquiry = 32,
81
+ UnrecognizedCommand = 33,
82
+ WorkspaceCreated = 34,
83
+ WorkspaceNameInquiry = 35
84
+ }
85
+
86
+ type TextArgs = (string | number)[];
87
+ declare class Texts {
88
+ protected static getTranslations: () => Translations;
89
+ protected static getTranslation: (key: TranslationsKey, ...args: TextArgs) => string;
90
+ static get: (key?: TranslationsKey, ...args: TextArgs) => string;
91
+ }
92
+
93
+ declare function vocaIconsToOptions(vocaIcons: any, selected: string): VocaOption[];
94
+ type VocaIcon = {
95
+ name: string;
96
+ svg: string;
97
+ };
98
+ declare enum VocaButtonVariant {
99
+ Primary = "primary",
100
+ Secondary = "secondary",
101
+ Expressive = "expressive",
102
+ Destructive = "destructive",
103
+ Text = "text",
104
+ PrimaryWhite = "primary-white",
105
+ SecondaryWhite = "secondary-white",
106
+ ExpressiveWhite = "expressive-white",
107
+ TertiaryPurple = "tertiary-purple"
108
+ }
109
+ type VocaOption = {
110
+ label: string;
111
+ value: string;
112
+ disabled?: boolean;
113
+ selected?: boolean;
114
+ };
115
+ declare function getVocaIcon(vocaIcons: any, name: string): VocaIcon;
116
+ type Unpacked<T> = T extends (infer U)[] ? U : T;
117
+ declare function mapToVocaOptions<T>(items: T, mapper: (item: Unpacked<T>) => VocaOption, label?: string): VocaOption[];
118
+ declare function onEnter(fn: (e: KeyboardEvent) => void): (e: KeyboardEvent) => void;
119
+ declare function friendlyUserName(user: {
120
+ email: string;
121
+ displayName: string;
122
+ }, format?: 'single' | 'all'): string;
123
+ declare function classNames(...classes: string[]): string;
124
+ declare function props(properties: object): Record<string, string | number | boolean>;
125
+
126
+ export { AllianceError, FrameworkErrorCodes, Promisable, Serializeable, SerializeableObject, TextArgs, Texts, TranslationsKey, Unpacked, UtilitiesErrorCodes, ValueTypes, VocaButtonVariant, VocaIcon, VocaOption, classNames, createCapabilityPath, friendlyUserName, getCurrentLocationInfo, getRuntimeRootUrl, getVocaIcon, isAllianceError, mapToVocaOptions, onEnter, props, vocaIconsToOptions };
package/dist/index.js CHANGED
@@ -1,205 +1,327 @@
1
- var g = Object.defineProperty;
2
- var v = (e, t, r) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var a = (e, t, r) => (v(e, typeof t != "symbol" ? t + "" : t, r), r);
4
- var N = /* @__PURE__ */ ((e) => (e[e.AlreadyInitialized = 1e3] = "AlreadyInitialized", e[e.NoAppNameOrKey = 1001] = "NoAppNameOrKey", e[e.MissingAppController = 1002] = "MissingAppController", e[e.MissingCapabilityOnApp = 1003] = "MissingCapabilityOnApp", e[e.MissingManagedObjectProvider = 1004] = "MissingManagedObjectProvider", e[e.NoManifest = 1005] = "NoManifest", e[e.NoRootElement = 1006] = "NoRootElement", e[e.NoView = 1007] = "NoView", e[e.CookieKeyNotDefined = 1008] = "CookieKeyNotDefined", e[e.CookieCategoryNotAllowed = 1009] = "CookieCategoryNotAllowed", e[e.StorageKeyNotDefined = 1010] = "StorageKeyNotDefined", e[e.StorageCategoryNotAllowed = 1011] = "StorageCategoryNotAllowed", e[e.LocalizationTemplateNotDefined = 1012] = "LocalizationTemplateNotDefined", e))(N || {}), A = /* @__PURE__ */ ((e) => (e[e.CurrentUserMissingProvider = 2e3] = "CurrentUserMissingProvider", e[e.CurrentUserGatewayNotStarted = 2001] = "CurrentUserGatewayNotStarted", e[e.CurrentUserMissingBackend = 2002] = "CurrentUserMissingBackend", e[e.CurrentUserMissingInDatabase = 2003] = "CurrentUserMissingInDatabase", e))(A || {});
5
- function m(e, t) {
6
- return Object.entries(t).reduce((r, [i, n]) => r.replaceAll(`{{${i}}}`, n), e);
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/exceptions.ts
5
+ var FrameworkErrorCodes;
6
+ (function(FrameworkErrorCodes2) {
7
+ FrameworkErrorCodes2[FrameworkErrorCodes2["AlreadyInitialized"] = 1e3] = "AlreadyInitialized";
8
+ FrameworkErrorCodes2[FrameworkErrorCodes2["NoAppName"] = 1001] = "NoAppName";
9
+ FrameworkErrorCodes2[FrameworkErrorCodes2["MissingAppController"] = 1002] = "MissingAppController";
10
+ FrameworkErrorCodes2[FrameworkErrorCodes2["MissingCapabilityOnApp"] = 1003] = "MissingCapabilityOnApp";
11
+ FrameworkErrorCodes2[FrameworkErrorCodes2["MissingManagedObjectProvider"] = 1004] = "MissingManagedObjectProvider";
12
+ FrameworkErrorCodes2[FrameworkErrorCodes2["NoManifest"] = 1005] = "NoManifest";
13
+ FrameworkErrorCodes2[FrameworkErrorCodes2["NoRootElement"] = 1006] = "NoRootElement";
14
+ FrameworkErrorCodes2[FrameworkErrorCodes2["NoView"] = 1007] = "NoView";
15
+ FrameworkErrorCodes2[FrameworkErrorCodes2["CookieKeyNotDefined"] = 1008] = "CookieKeyNotDefined";
16
+ FrameworkErrorCodes2[FrameworkErrorCodes2["CookieCategoryNotAllowed"] = 1009] = "CookieCategoryNotAllowed";
17
+ FrameworkErrorCodes2[FrameworkErrorCodes2["StorageKeyNotDefined"] = 1010] = "StorageKeyNotDefined";
18
+ FrameworkErrorCodes2[FrameworkErrorCodes2["StorageCategoryNotAllowed"] = 1011] = "StorageCategoryNotAllowed";
19
+ FrameworkErrorCodes2[FrameworkErrorCodes2["LocalizationTemplateNotDefined"] = 1012] = "LocalizationTemplateNotDefined";
20
+ FrameworkErrorCodes2[FrameworkErrorCodes2["NonViewOperation"] = 1013] = "NonViewOperation";
21
+ })(FrameworkErrorCodes || (FrameworkErrorCodes = {}));
22
+ var UtilitiesErrorCodes;
23
+ (function(UtilitiesErrorCodes2) {
24
+ UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingProvider"] = 2e3] = "CurrentUserMissingProvider";
25
+ UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserGatewayNotStarted"] = 2001] = "CurrentUserGatewayNotStarted";
26
+ UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingBackend"] = 2002] = "CurrentUserMissingBackend";
27
+ UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingInDatabase"] = 2003] = "CurrentUserMissingInDatabase";
28
+ })(UtilitiesErrorCodes || (UtilitiesErrorCodes = {}));
29
+ function parseTemplates(message, variables) {
30
+ return Object.entries(variables).reduce((acc, [key, value]) => {
31
+ return acc.replaceAll(`{{${key}}}`, value);
32
+ }, message);
7
33
  }
8
- const S = {
34
+ __name(parseTemplates, "parseTemplates");
35
+ var allianceErrors = {
9
36
  // framework
10
- 1e3: "The runtime has already been initialized",
11
- 1001: "App name and/or app key is not defined on global scope",
12
- 1002: "No app controller registered for app '{{app}}'",
13
- 1003: "No capability '{{capability}}' enabled for app '{{app}}'",
14
- 1004: "No managed object provider registered for object '{{object}}'",
15
- 1005: "The current apps manifest is not defined on global scope",
16
- 1006: "Could not find the root element in the DOM",
17
- 1007: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
18
- 1008: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
19
- 1009: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
20
- 1010: "Storage key '{{key}}' not present in manifest, item has not been stored",
21
- 1011: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
22
- 1012: "The translation template, referred by the key '{{key}}' is being used in app, but is not defined in the manifest.",
37
+ [1e3]: "The runtime has already been initialized",
38
+ [1001]: "App name is not defined on global scope",
39
+ [1002]: "No app controller registered for app '{{app}}'",
40
+ [1003]: "No capability '{{capability}}' enabled for app '{{app}}'",
41
+ [1004]: "No managed object provider registered for object '{{object}}'",
42
+ [1005]: "The current apps manifest is not defined on global scope",
43
+ [1006]: "Could not find the root element in the DOM",
44
+ [1007]: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
45
+ [1008]: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
46
+ [1009]: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
47
+ [1010]: "Storage key '{{key}}' not present in manifest, item has not been stored",
48
+ [1011]: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
49
+ [1012]: "The translation template, referred by the key '{{key}}' is being used in app, but is not defined in the manifest.",
50
+ [1013]: "The capability '{{capability}}', requested by an alliance-view element, did not return a View Operation.",
23
51
  // utilities
24
- 2e3: "No managed object provider registered for object 'currentUser'",
25
- 2001: "Could not access the gateway when querying 'currentUser'",
26
- 2002: "Could not access the required backend when querying 'currentUser'",
27
- 2003: "Could not locate the authenticated user in the Alliance database"
28
- }, d = "AllianceError";
29
- class I extends Error {
30
- constructor(t, r = {}) {
31
- const i = m(S[t], r), n = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${t}`;
32
- super(i), this.code = t, this.name = d, this.stack = `[${t}] - ${i}
33
- ` + n;
52
+ [2e3]: "No managed object provider registered for object 'currentUser'",
53
+ [2001]: "Could not access the gateway when querying 'currentUser'",
54
+ [2002]: "Could not access the required backend when querying 'currentUser'",
55
+ [2003]: "Could not locate the authenticated user in the Alliance database"
56
+ };
57
+ var ALLIANCE_ERROR_NAME = "AllianceError";
58
+ var AllianceError = class extends Error {
59
+ static {
60
+ __name(this, "AllianceError");
34
61
  }
62
+ code;
63
+ constructor(code, variables = {}) {
64
+ const message = parseTemplates(allianceErrors[code], variables);
65
+ const info = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${code}`;
66
+ super(message);
67
+ this.code = code;
68
+ this.name = ALLIANCE_ERROR_NAME;
69
+ this.stack = `[${code}] - ${message}
70
+ ` + info;
71
+ }
72
+ };
73
+ function isAllianceError(error) {
74
+ return !!error.code && error.name === ALLIANCE_ERROR_NAME;
35
75
  }
36
- function k(e) {
37
- return !!e.code && e.name === d;
38
- }
39
- function b(e) {
40
- const r = Object.entries(e).reduce((i, n) => {
41
- const [o, p] = n;
42
- return typeof p > "u" || (typeof p == "object" && p !== null ? i[o] = JSON.stringify(p) : i[o] = p), i;
76
+ __name(isAllianceError, "isAllianceError");
77
+
78
+ // src/routing.ts
79
+ function createQueryString(args) {
80
+ const entries = Object.entries(args);
81
+ const filteredArgs = entries.reduce((acc, entry) => {
82
+ const [key, value] = entry;
83
+ if (typeof value === "undefined") {
84
+ return acc;
85
+ } else if (typeof value === "object" && value !== null) {
86
+ acc[key] = JSON.stringify(value);
87
+ } else {
88
+ acc[key] = value;
89
+ }
90
+ return acc;
43
91
  }, {});
44
- return Object.keys(r).length ? `?${new URLSearchParams(r)}` : "";
92
+ if (!Object.keys(filteredArgs).length) {
93
+ return "";
94
+ }
95
+ return `?${new URLSearchParams(filteredArgs)}`;
45
96
  }
46
- function D() {
47
- const e = l(), { href: t, search: r } = window.location;
48
- return t.replace(e, "").replace(r, "");
97
+ __name(createQueryString, "createQueryString");
98
+ function getCurrentPath() {
99
+ const runtimeRootUrl = getRuntimeRootUrl();
100
+ const { href, search } = window.location;
101
+ return href.replace(runtimeRootUrl, "").replace(search, "");
49
102
  }
50
- function C(e = "", t = "", r = {}) {
51
- const i = l().replace(location.origin, ""), n = b(r);
52
- return e ? t ? `${i}/${e}/${t}${n}` : `${i}/${e}${n}` : `${i}${n}`;
103
+ __name(getCurrentPath, "getCurrentPath");
104
+ function createCapabilityPath(app = "", capability = "", args = {}) {
105
+ const rootPath = getRuntimeRootUrl().replace(location.origin, "");
106
+ const queryString = createQueryString(args);
107
+ if (!app) {
108
+ return `${rootPath}${queryString}`;
109
+ }
110
+ if (!capability) {
111
+ return `${rootPath}/${app}${queryString}`;
112
+ }
113
+ return `${rootPath}/${app}/${capability}${queryString}`;
53
114
  }
54
- function W() {
55
- const e = D(), [t = "", r = ""] = e.split("/").filter((i) => !!i);
115
+ __name(createCapabilityPath, "createCapabilityPath");
116
+ function getCurrentLocationInfo() {
117
+ const currentPath = getCurrentPath();
118
+ const [app = "", capability = ""] = currentPath.split("/").filter((part) => !!part);
56
119
  return {
57
- app: t,
58
- capability: r
120
+ app,
121
+ capability
59
122
  };
60
123
  }
61
- function P(e) {
62
- const { origin: t, pathname: r } = window.location;
63
- if (e === "production") {
64
- const [i] = r.split("/").filter((n) => !!n);
65
- return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = `${t}/${i}`;
124
+ __name(getCurrentLocationInfo, "getCurrentLocationInfo");
125
+ function getRuntimeRootUrl() {
126
+ if (globalThis.__ALLIANCE_RUNTIME_ROOT_URL) {
127
+ return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;
66
128
  }
67
- return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = t;
68
- }
69
- function l() {
70
- return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;
129
+ return window.origin;
71
130
  }
72
- var s = /* @__PURE__ */ ((e) => (e[e.AlreadyExists = 0] = "AlreadyExists", e[e.ApiGatewayPortDescription = 1] = "ApiGatewayPortDescription", e[e.ApiServerModeDescription = 2] = "ApiServerModeDescription", e[e.AppConfigurationPath = 3] = "AppConfigurationPath", e[e.AppCreated = 4] = "AppCreated", e[e.AppEntryBuildOptionDescription = 5] = "AppEntryBuildOptionDescription", e[e.AppNameInquiry = 6] = "AppNameInquiry", e[e.BuildDescription = 7] = "BuildDescription", e[e.BuildModeOptionDescription = 8] = "BuildModeOptionDescription", e[e.BuildWatchDescription = 9] = "BuildWatchDescription", e[e.CreateAppDescription = 10] = "CreateAppDescription", e[e.CreateWorkspaceDescription = 11] = "CreateWorkspaceDescription", e[e.DevServerOpenDescription = 12] = "DevServerOpenDescription", e[e.DevServerPortDescription = 13] = "DevServerPortDescription", e[e.DevServerLoggingDescription = 14] = "DevServerLoggingDescription", e[e.Done = 15] = "Done", e[e.FetchPackageVersionError = 16] = "FetchPackageVersionError", e[e.ManifestEntryBuildOptionDescription = 17] = "ManifestEntryBuildOptionDescription", e[e.MissingTranslationKey = 18] = "MissingTranslationKey", e[e.NoAppName = 19] = "NoAppName", e[e.NoAppNameFound = 20] = "NoAppNameFound", e[e.NoAppOrWorkspaceInCurrentDirectory = 21] = "NoAppOrWorkspaceInCurrentDirectory", e[e.NoWorkspaceName = 22] = "NoWorkspaceName", e[e.OperationCancelled = 23] = "OperationCancelled", e[e.ServeDescription = 24] = "ServeDescription", e[e.ServedStopped = 25] = "ServedStopped", e[e.ServerGatewayMode = 26] = "ServerGatewayMode", e[e.ServerMode = 27] = "ServerMode", e[e.ServerModeInquiry = 28] = "ServerModeInquiry", e[e.ServerProxyMode = 29] = "ServerProxyMode", e[e.StopServerInstructions = 30] = "StopServerInstructions", e[e.TemplateFrameworkInquiry = 31] = "TemplateFrameworkInquiry", e[e.TemplateLanguageInquiry = 32] = "TemplateLanguageInquiry", e[e.UnrecognizedCommand = 33] = "UnrecognizedCommand", e[e.WorkspaceCreated = 34] = "WorkspaceCreated", e[e.WorkspaceNameInquiry = 35] = "WorkspaceNameInquiry", e))(s || {});
73
- const M = {
74
- 15: "Done",
75
- 22: "No workspace name provided!",
76
- 19: "No app name provided!",
77
- 0: "File or directory '{0}' already exists!",
78
- 21: "Could not find any app entry file at '{0}'!",
79
- 33: "Unrecognized command(s) {0}!",
80
- 34: "Workspace was created at path '{0}'!",
81
- 4: "App was created at path '{0}'!",
82
- 25: "Server stopped.",
83
- 11: "Creates an Alliance Workspace in the current directory.",
84
- 10: "Creates an Alliance Application in the current directory or Alliance Workspace.",
85
- 24: "Starts a Alliance development server using the current directory package.json.",
86
- 7: "Builds an Alliance Application using Vite.",
87
- 35: "Enter the name of your workspace",
88
- 28: "Which server mode do you want to use?",
89
- 6: "Enter the name of your app",
90
- 18: "No translation key provided!",
91
- 23: "Operation cancelled.",
92
- 30: `Press CTRL + C to stop the server.
93
- `,
94
- 32: "Select preferred language",
95
- 31: "Select preferred framework template",
96
- 13: "The port that the dev server should use.",
97
- 14: "Whether the dev server and browser console should output more log information or not (false).",
98
- 1: "The port that the api gateway should use.",
99
- 2: "Which components to start. [server|server-proxy|server-gateway].",
100
- 12: "Whether the dev server should automatically open in your browser or not.",
101
- 9: "Whether the build should start watching and rebuild when files change or not.",
102
- 5: "The entry file for the app (./src/app).",
103
- 17: "The entry file for the app manifest (./src/manifest).",
104
- 8: "Which mode to use when building the app.",
105
- 16: "Failed to fetch package info from the NPM registry for package '${0}'!",
106
- 20: "Could not find app name in manifest.",
107
- 3: "The path to the app configuration file.",
108
- 27: "Server",
109
- 29: "Server with proxy",
110
- 26: "Server with gateway"
111
- }, c = class c {
131
+ __name(getRuntimeRootUrl, "getRuntimeRootUrl");
132
+
133
+ // src/translations.ts
134
+ var TranslationsKey;
135
+ (function(TranslationsKey2) {
136
+ TranslationsKey2[TranslationsKey2["AlreadyExists"] = 0] = "AlreadyExists";
137
+ TranslationsKey2[TranslationsKey2["ApiGatewayPortDescription"] = 1] = "ApiGatewayPortDescription";
138
+ TranslationsKey2[TranslationsKey2["ApiServerModeDescription"] = 2] = "ApiServerModeDescription";
139
+ TranslationsKey2[TranslationsKey2["AppConfigurationPath"] = 3] = "AppConfigurationPath";
140
+ TranslationsKey2[TranslationsKey2["AppCreated"] = 4] = "AppCreated";
141
+ TranslationsKey2[TranslationsKey2["AppEntryBuildOptionDescription"] = 5] = "AppEntryBuildOptionDescription";
142
+ TranslationsKey2[TranslationsKey2["AppNameInquiry"] = 6] = "AppNameInquiry";
143
+ TranslationsKey2[TranslationsKey2["BuildDescription"] = 7] = "BuildDescription";
144
+ TranslationsKey2[TranslationsKey2["BuildModeOptionDescription"] = 8] = "BuildModeOptionDescription";
145
+ TranslationsKey2[TranslationsKey2["BuildWatchDescription"] = 9] = "BuildWatchDescription";
146
+ TranslationsKey2[TranslationsKey2["CreateAppDescription"] = 10] = "CreateAppDescription";
147
+ TranslationsKey2[TranslationsKey2["CreateWorkspaceDescription"] = 11] = "CreateWorkspaceDescription";
148
+ TranslationsKey2[TranslationsKey2["DevServerOpenDescription"] = 12] = "DevServerOpenDescription";
149
+ TranslationsKey2[TranslationsKey2["DevServerPortDescription"] = 13] = "DevServerPortDescription";
150
+ TranslationsKey2[TranslationsKey2["DevServerLoggingDescription"] = 14] = "DevServerLoggingDescription";
151
+ TranslationsKey2[TranslationsKey2["Done"] = 15] = "Done";
152
+ TranslationsKey2[TranslationsKey2["FetchPackageVersionError"] = 16] = "FetchPackageVersionError";
153
+ TranslationsKey2[TranslationsKey2["ManifestEntryBuildOptionDescription"] = 17] = "ManifestEntryBuildOptionDescription";
154
+ TranslationsKey2[TranslationsKey2["MissingTranslationKey"] = 18] = "MissingTranslationKey";
155
+ TranslationsKey2[TranslationsKey2["NoAppName"] = 19] = "NoAppName";
156
+ TranslationsKey2[TranslationsKey2["NoAppNameFound"] = 20] = "NoAppNameFound";
157
+ TranslationsKey2[TranslationsKey2["NoAppOrWorkspaceInCurrentDirectory"] = 21] = "NoAppOrWorkspaceInCurrentDirectory";
158
+ TranslationsKey2[TranslationsKey2["NoWorkspaceName"] = 22] = "NoWorkspaceName";
159
+ TranslationsKey2[TranslationsKey2["OperationCancelled"] = 23] = "OperationCancelled";
160
+ TranslationsKey2[TranslationsKey2["ServeDescription"] = 24] = "ServeDescription";
161
+ TranslationsKey2[TranslationsKey2["ServedStopped"] = 25] = "ServedStopped";
162
+ TranslationsKey2[TranslationsKey2["ServerGatewayMode"] = 26] = "ServerGatewayMode";
163
+ TranslationsKey2[TranslationsKey2["ServerMode"] = 27] = "ServerMode";
164
+ TranslationsKey2[TranslationsKey2["ServerModeInquiry"] = 28] = "ServerModeInquiry";
165
+ TranslationsKey2[TranslationsKey2["ServerProxyMode"] = 29] = "ServerProxyMode";
166
+ TranslationsKey2[TranslationsKey2["StopServerInstructions"] = 30] = "StopServerInstructions";
167
+ TranslationsKey2[TranslationsKey2["TemplateFrameworkInquiry"] = 31] = "TemplateFrameworkInquiry";
168
+ TranslationsKey2[TranslationsKey2["TemplateLanguageInquiry"] = 32] = "TemplateLanguageInquiry";
169
+ TranslationsKey2[TranslationsKey2["UnrecognizedCommand"] = 33] = "UnrecognizedCommand";
170
+ TranslationsKey2[TranslationsKey2["WorkspaceCreated"] = 34] = "WorkspaceCreated";
171
+ TranslationsKey2[TranslationsKey2["WorkspaceNameInquiry"] = 35] = "WorkspaceNameInquiry";
172
+ })(TranslationsKey || (TranslationsKey = {}));
173
+ var en = {
174
+ [15]: "Done",
175
+ [22]: "No workspace name provided!",
176
+ [19]: "No app name provided!",
177
+ [0]: "File or directory '{0}' already exists!",
178
+ [21]: "Could not find any app entry file at '{0}'!",
179
+ [33]: "Unrecognized command(s) {0}!",
180
+ [34]: "Workspace was created at path '{0}'!",
181
+ [4]: "App was created at path '{0}'!",
182
+ [25]: "Server stopped.",
183
+ [11]: "Creates an Alliance Workspace in the current directory.",
184
+ [10]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
185
+ [24]: "Starts a Alliance development server using the current directory package.json.",
186
+ [7]: "Builds an Alliance Application using Vite.",
187
+ [35]: "Enter the name of your workspace",
188
+ [28]: "Which server mode do you want to use?",
189
+ [6]: "Enter the name of your app",
190
+ [18]: "No translation key provided!",
191
+ [23]: "Operation cancelled.",
192
+ [30]: "Press CTRL + C to stop the server.\n",
193
+ [32]: "Select preferred language",
194
+ [31]: "Select preferred framework template",
195
+ [13]: "The port that the dev server should use.",
196
+ [14]: "Whether the dev server and browser console should output more log information or not (false).",
197
+ [1]: "The port that the api gateway should use.",
198
+ [2]: "Which components to start. [server|server-proxy|server-gateway].",
199
+ [12]: "Whether the dev server should automatically open in your browser or not.",
200
+ [9]: "Whether the build should start watching and rebuild when files change or not.",
201
+ [5]: "The entry file for the app (./src/app).",
202
+ [17]: "The entry file for the app manifest (./src/manifest).",
203
+ [8]: "Which mode to use when building the app.",
204
+ [16]: "Failed to fetch package info from the NPM registry for package '${0}'!",
205
+ [20]: "Could not find app name in manifest.",
206
+ [3]: "The path to the app configuration file.",
207
+ [27]: "Server",
208
+ [29]: "Server with proxy",
209
+ [26]: "Server with gateway"
112
210
  };
113
- a(c, "getTranslations", () => M), a(c, "getTranslation", (t, ...r) => {
114
- const n = c.getTranslations()[t];
115
- if (!n)
116
- throw new Error(`Could not find text with given key '${t}'.`);
117
- return r.reduce(
118
- (p, h, f) => p.toString().replace(`{${f}}`, h.toString()),
119
- n
120
- ).toString();
121
- }), a(c, "get", (t = s.MissingTranslationKey, ...r) => c.getTranslation(t, ...r));
122
- let u = c;
123
- function R(e, t) {
124
- return O(Object.values(e), ({ name: r }) => ({
125
- label: r,
126
- value: r,
127
- selected: t === r
211
+
212
+ // src/texts.ts
213
+ var Texts = class _Texts {
214
+ static {
215
+ __name(this, "Texts");
216
+ }
217
+ static getTranslations = () => {
218
+ return en;
219
+ };
220
+ static getTranslation = (key, ...args) => {
221
+ const translations = _Texts.getTranslations();
222
+ const translation = translations[key];
223
+ if (!translation)
224
+ throw new Error(`Could not find text with given key '${key}'.`);
225
+ const formattedTranslation = args.reduce((acc, curr, index) => acc.toString().replace(`{${index}}`, curr.toString()), translation);
226
+ return formattedTranslation.toString();
227
+ };
228
+ static get = (key = TranslationsKey.MissingTranslationKey, ...args) => this.getTranslation(key, ...args);
229
+ };
230
+ var texts_default = Texts;
231
+
232
+ // src/ui.ts
233
+ function vocaIconsToOptions(vocaIcons, selected) {
234
+ return mapToVocaOptions(Object.values(vocaIcons), ({ name }) => ({
235
+ label: name,
236
+ value: name,
237
+ selected: selected === name
128
238
  }));
129
239
  }
130
- var y = /* @__PURE__ */ ((e) => (e.Primary = "primary", e.Secondary = "secondary", e.Expressive = "expressive", e.Destructive = "destructive", e.Text = "text", e.PrimaryWhite = "primary-white", e.SecondaryWhite = "secondary-white", e.ExpressiveWhite = "expressive-white", e.TertiaryPurple = "tertiary-purple", e))(y || {});
131
- function $(e, t) {
132
- return Object.values(e).find((i) => i.name === t);
240
+ __name(vocaIconsToOptions, "vocaIconsToOptions");
241
+ var VocaButtonVariant;
242
+ (function(VocaButtonVariant2) {
243
+ VocaButtonVariant2["Primary"] = "primary";
244
+ VocaButtonVariant2["Secondary"] = "secondary";
245
+ VocaButtonVariant2["Expressive"] = "expressive";
246
+ VocaButtonVariant2["Destructive"] = "destructive";
247
+ VocaButtonVariant2["Text"] = "text";
248
+ VocaButtonVariant2["PrimaryWhite"] = "primary-white";
249
+ VocaButtonVariant2["SecondaryWhite"] = "secondary-white";
250
+ VocaButtonVariant2["ExpressiveWhite"] = "expressive-white";
251
+ VocaButtonVariant2["TertiaryPurple"] = "tertiary-purple";
252
+ })(VocaButtonVariant || (VocaButtonVariant = {}));
253
+ function getVocaIcon(vocaIcons, name) {
254
+ const icon = Object.values(vocaIcons).find((icon2) => icon2.name === name);
255
+ return icon;
133
256
  }
134
- function O(e, t, r = "Choose...") {
135
- return e.reduce(
136
- (i, n) => (i.push({
137
- disabled: !1,
138
- selected: !1,
139
- ...t(n)
140
- }), i),
141
- [
142
- {
143
- label: r,
144
- value: "",
145
- disabled: !0,
146
- selected: !0
147
- }
148
- ]
149
- );
257
+ __name(getVocaIcon, "getVocaIcon");
258
+ function mapToVocaOptions(items, mapper, label = "Choose...") {
259
+ return items.reduce((acc, item) => {
260
+ acc.push({
261
+ disabled: false,
262
+ selected: false,
263
+ ...mapper(item)
264
+ });
265
+ return acc;
266
+ }, [
267
+ {
268
+ label,
269
+ value: "",
270
+ disabled: true,
271
+ selected: true
272
+ }
273
+ ]);
150
274
  }
151
- function L(e) {
152
- return (t) => {
153
- t.key === "Enter" && e(t);
275
+ __name(mapToVocaOptions, "mapToVocaOptions");
276
+ function onEnter(fn) {
277
+ return (e) => {
278
+ if (e.key === "Enter") {
279
+ fn(e);
280
+ }
154
281
  };
155
282
  }
156
- function U(e, t = "all") {
157
- const { email: r, displayName: i } = e, n = i && i !== "unknown", o = !!r;
158
- switch (t) {
283
+ __name(onEnter, "onEnter");
284
+ function friendlyUserName(user, format = "all") {
285
+ const { email, displayName } = user;
286
+ const hasDisplayName = displayName && displayName !== "unknown";
287
+ const hasEmail = !!email;
288
+ switch (format) {
159
289
  case "all": {
160
- if (n && o)
161
- return `${i} (${r})`;
162
- if (n)
163
- return i;
164
- if (o)
165
- return r;
290
+ if (hasDisplayName && hasEmail) {
291
+ return `${displayName} (${email})`;
292
+ } else if (hasDisplayName) {
293
+ return displayName;
294
+ } else if (hasEmail) {
295
+ return email;
296
+ }
297
+ break;
166
298
  }
167
299
  case "single": {
168
- if (n)
169
- return i;
170
- if (o)
171
- return r;
300
+ if (hasDisplayName) {
301
+ return displayName;
302
+ } else if (hasEmail) {
303
+ return email;
304
+ }
305
+ break;
172
306
  }
173
307
  }
174
308
  return "<UNKNOWN USER>";
175
309
  }
176
- function j(...e) {
177
- return e.filter((t) => !!t).join(" ");
310
+ __name(friendlyUserName, "friendlyUserName");
311
+ function classNames(...classes) {
312
+ return classes.filter((c) => !!c).join(" ");
178
313
  }
179
- function q(e) {
180
- return Object.entries(e).reduce(
181
- (t, [r, i]) => (typeof i != "object" && typeof i != "function" && (t[r] = i), t),
182
- {}
183
- );
314
+ __name(classNames, "classNames");
315
+ function props(properties) {
316
+ return Object.entries(properties).reduce((acc, [key, value]) => {
317
+ if (typeof value !== "object" && typeof value !== "function") {
318
+ acc[key] = value;
319
+ }
320
+ return acc;
321
+ }, {});
184
322
  }
185
- export {
186
- I as AllianceError,
187
- N as FrameworkErrorCodes,
188
- u as Texts,
189
- s as TranslationsKey,
190
- A as UtilitiesErrorCodes,
191
- y as VocaButtonVariant,
192
- j as classNames,
193
- C as createCapabilityPath,
194
- U as friendlyUserName,
195
- W as getCurrentLocationInfo,
196
- l as getRuntimeRootUrl,
197
- $ as getVocaIcon,
198
- k as isAllianceError,
199
- O as mapToVocaOptions,
200
- L as onEnter,
201
- q as props,
202
- P as setRuntimeRootUrl,
203
- R as vocaIconsToOptions
204
- };
205
- //# sourceMappingURL=index.js.map
323
+ __name(props, "props");
324
+
325
+ export { AllianceError, FrameworkErrorCodes, texts_default as Texts, TranslationsKey, UtilitiesErrorCodes, VocaButtonVariant, classNames, createCapabilityPath, friendlyUserName, getCurrentLocationInfo, getRuntimeRootUrl, getVocaIcon, isAllianceError, mapToVocaOptions, onEnter, props, vocaIconsToOptions };
326
+ //# sourceMappingURL=out.js.map
327
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/exceptions.ts","../src/routing.ts","../src/translations.ts","../src/texts.ts","../src/ui.ts"],"sourcesContent":["export enum FrameworkErrorCodes {\n AlreadyInitialized = 1000,\n NoAppNameOrKey = 1001,\n MissingAppController = 1002,\n MissingCapabilityOnApp = 1003,\n MissingManagedObjectProvider = 1004,\n NoManifest = 1005,\n NoRootElement = 1006,\n NoView = 1007,\n CookieKeyNotDefined = 1008,\n CookieCategoryNotAllowed = 1009,\n StorageKeyNotDefined = 1010,\n StorageCategoryNotAllowed = 1011,\n LocalizationTemplateNotDefined = 1012,\n}\n\nexport enum UtilitiesErrorCodes {\n CurrentUserMissingProvider = 2000,\n CurrentUserGatewayNotStarted = 2001,\n CurrentUserMissingBackend = 2002,\n CurrentUserMissingInDatabase = 2003,\n}\n\ntype ErrorCodes = UtilitiesErrorCodes | FrameworkErrorCodes;\n\nfunction parseTemplates(message: string, variables: Record<string, string>) {\n return Object.entries(variables).reduce((acc, [key, value]) => {\n return acc.replaceAll(`{{${key}}}`, value);\n }, message);\n}\n\nconst allianceErrors: Record<ErrorCodes, string> = {\n // framework\n [FrameworkErrorCodes.AlreadyInitialized]: 'The runtime has already been initialized',\n [FrameworkErrorCodes.NoAppNameOrKey]: 'App name and/or app key is not defined on global scope',\n [FrameworkErrorCodes.MissingAppController]: \"No app controller registered for app '{{app}}'\",\n [FrameworkErrorCodes.MissingCapabilityOnApp]:\n \"No capability '{{capability}}' enabled for app '{{app}}'\",\n [FrameworkErrorCodes.MissingManagedObjectProvider]:\n \"No managed object provider registered for object '{{object}}'\",\n [FrameworkErrorCodes.NoManifest]: 'The current apps manifest is not defined on global scope',\n [FrameworkErrorCodes.NoRootElement]: 'Could not find the root element in the DOM',\n [FrameworkErrorCodes.NoView]:\n \"Could not find view with id '{{id}}' on view controller for app '{{app}}'\",\n [FrameworkErrorCodes.CookieKeyNotDefined]:\n \"Cookie key '{{key}}' not present in manifest, cookie has not been set\",\n [FrameworkErrorCodes.CookieCategoryNotAllowed]:\n \"Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set\",\n [FrameworkErrorCodes.StorageKeyNotDefined]:\n \"Storage key '{{key}}' not present in manifest, item has not been stored\",\n [FrameworkErrorCodes.StorageCategoryNotAllowed]:\n \"Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored\",\n [FrameworkErrorCodes.LocalizationTemplateNotDefined]:\n \"The translation template, referred by the key '{{key}}' is being used in app, but is not defined in the manifest.\",\n\n // utilities\n [UtilitiesErrorCodes.CurrentUserMissingProvider]:\n \"No managed object provider registered for object 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserGatewayNotStarted]:\n \"Could not access the gateway when querying 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserMissingBackend]:\n \"Could not access the required backend when querying 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserMissingInDatabase]:\n 'Could not locate the authenticated user in the Alliance database',\n};\n\nconst ALLIANCE_ERROR_NAME = 'AllianceError';\n\nexport class AllianceError extends Error {\n constructor(public code: ErrorCodes, variables: Record<string, string> = {}) {\n const message = parseTemplates(allianceErrors[code], variables);\n const info = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${code}`;\n super(message);\n\n this.name = ALLIANCE_ERROR_NAME;\n this.stack = `[${code}] - ${message}` + '\\n' + info;\n }\n}\n\nexport function isAllianceError(error: any): error is AllianceError {\n return !!error.code && error.name === ALLIANCE_ERROR_NAME;\n}\n","import { SerializeableObject } from './types';\n\nfunction createQueryString(args: SerializeableObject) {\n const entries = Object.entries(args);\n\n const filteredArgs = entries.reduce<SerializeableObject>((acc, entry) => {\n const [key, value] = entry;\n\n if (typeof value === 'undefined') {\n return acc;\n } else if (typeof value === 'object' && value !== null) {\n acc[key] = JSON.stringify(value);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n\n if (!Object.keys(filteredArgs).length) {\n return '';\n }\n\n return `?${new URLSearchParams(filteredArgs as Record<string, any>)}`;\n}\n\nfunction getCurrentPath() {\n const runtimeRootUrl = getRuntimeRootUrl();\n const { href, search } = window.location;\n\n return href.replace(runtimeRootUrl, '').replace(search, '');\n}\n\nexport function createCapabilityPath(\n app: string = '',\n capability: string = '',\n args: SerializeableObject = {}\n) {\n const rootPath = getRuntimeRootUrl().replace(location.origin, '');\n const queryString = createQueryString(args);\n\n if (!app) {\n return `${rootPath}${queryString}`;\n }\n\n if (!capability) {\n return `${rootPath}/${app}${queryString}`;\n }\n\n return `${rootPath}/${app}/${capability}${queryString}`;\n}\n\nexport function getCurrentLocationInfo() {\n const currentPath = getCurrentPath();\n const [app = '', capability = ''] = currentPath.split('/').filter((part) => !!part);\n\n return {\n app,\n capability,\n };\n}\n\nexport function setRuntimeRootUrl(environment: 'production' | 'development') {\n const { origin, pathname } = window.location;\n\n // If on Alliance cloud environment - the first part of path is workspace\n if (environment === 'production') {\n const [workspace] = pathname.split('/').filter((part) => !!part);\n\n return (globalThis.__ALLIANCE_RUNTIME_ROOT_URL = `${origin}/${workspace}`);\n }\n\n return (globalThis.__ALLIANCE_RUNTIME_ROOT_URL = origin);\n}\n\nexport function getRuntimeRootUrl() {\n return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;\n}\n","export type Translations = {\n [key in TranslationsKey]: string;\n};\n\nexport enum TranslationsKey {\n AlreadyExists,\n ApiGatewayPortDescription,\n ApiServerModeDescription,\n AppConfigurationPath,\n AppCreated,\n AppEntryBuildOptionDescription,\n AppNameInquiry,\n BuildDescription,\n BuildModeOptionDescription,\n BuildWatchDescription,\n CreateAppDescription,\n CreateWorkspaceDescription,\n DevServerOpenDescription,\n DevServerPortDescription,\n DevServerLoggingDescription,\n Done,\n FetchPackageVersionError,\n ManifestEntryBuildOptionDescription,\n MissingTranslationKey,\n NoAppName,\n NoAppNameFound,\n NoAppOrWorkspaceInCurrentDirectory,\n NoWorkspaceName,\n OperationCancelled,\n ServeDescription,\n ServedStopped,\n ServerGatewayMode,\n ServerMode,\n ServerModeInquiry,\n ServerProxyMode,\n StopServerInstructions,\n TemplateFrameworkInquiry,\n TemplateLanguageInquiry,\n UnrecognizedCommand,\n WorkspaceCreated,\n WorkspaceNameInquiry,\n}\n\nexport const en: Translations = {\n [TranslationsKey.Done]: 'Done',\n [TranslationsKey.NoWorkspaceName]: 'No workspace name provided!',\n [TranslationsKey.NoAppName]: 'No app name provided!',\n [TranslationsKey.AlreadyExists]: \"File or directory '{0}' already exists!\",\n [TranslationsKey.NoAppOrWorkspaceInCurrentDirectory]:\n \"Could not find any app entry file at '{0}'!\",\n [TranslationsKey.UnrecognizedCommand]: 'Unrecognized command(s) {0}!',\n [TranslationsKey.WorkspaceCreated]: \"Workspace was created at path '{0}'!\",\n [TranslationsKey.AppCreated]: \"App was created at path '{0}'!\",\n [TranslationsKey.ServedStopped]: 'Server stopped.',\n [TranslationsKey.CreateWorkspaceDescription]:\n 'Creates an Alliance Workspace in the current directory.',\n [TranslationsKey.CreateAppDescription]:\n 'Creates an Alliance Application in the current directory or Alliance Workspace.',\n [TranslationsKey.ServeDescription]:\n 'Starts a Alliance development server using the current directory package.json.',\n [TranslationsKey.BuildDescription]: 'Builds an Alliance Application using Vite.',\n [TranslationsKey.WorkspaceNameInquiry]: 'Enter the name of your workspace',\n [TranslationsKey.ServerModeInquiry]: 'Which server mode do you want to use?',\n [TranslationsKey.AppNameInquiry]: 'Enter the name of your app',\n [TranslationsKey.MissingTranslationKey]: 'No translation key provided!',\n [TranslationsKey.OperationCancelled]: 'Operation cancelled.',\n [TranslationsKey.StopServerInstructions]: 'Press CTRL + C to stop the server.\\n',\n [TranslationsKey.TemplateLanguageInquiry]: 'Select preferred language',\n [TranslationsKey.TemplateFrameworkInquiry]: 'Select preferred framework template',\n [TranslationsKey.DevServerPortDescription]: 'The port that the dev server should use.',\n [TranslationsKey.DevServerLoggingDescription]: `Whether the dev server and browser console should output more log information or not (false).`,\n [TranslationsKey.ApiGatewayPortDescription]: 'The port that the api gateway should use.',\n [TranslationsKey.ApiServerModeDescription]:\n 'Which components to start. [server|server-proxy|server-gateway].',\n [TranslationsKey.DevServerOpenDescription]:\n 'Whether the dev server should automatically open in your browser or not.',\n [TranslationsKey.BuildWatchDescription]:\n 'Whether the build should start watching and rebuild when files change or not.',\n [TranslationsKey.AppEntryBuildOptionDescription]: 'The entry file for the app (./src/app).',\n [TranslationsKey.ManifestEntryBuildOptionDescription]:\n 'The entry file for the app manifest (./src/manifest).',\n [TranslationsKey.BuildModeOptionDescription]: 'Which mode to use when building the app.',\n [TranslationsKey.FetchPackageVersionError]:\n \"Failed to fetch package info from the NPM registry for package '${0}'!\",\n [TranslationsKey.NoAppNameFound]: 'Could not find app name in manifest.',\n [TranslationsKey.AppConfigurationPath]: 'The path to the app configuration file.',\n [TranslationsKey.ServerMode]: 'Server',\n [TranslationsKey.ServerProxyMode]: 'Server with proxy',\n [TranslationsKey.ServerGatewayMode]: 'Server with gateway',\n};\n","import { en, TranslationsKey, type Translations } from './translations';\n\nexport type TextArgs = (string | number)[];\n\nexport class Texts {\n protected static getTranslations = (): Translations => {\n return en;\n };\n\n protected static getTranslation = (key: TranslationsKey, ...args: TextArgs): string => {\n const translations = Texts.getTranslations();\n const translation = translations[key];\n\n if (!translation) throw new Error(`Could not find text with given key '${key}'.`);\n\n const formattedTranslation = args.reduce(\n (acc, curr, index) => acc.toString().replace(`{${index}}`, curr.toString()),\n translation\n );\n\n return formattedTranslation.toString();\n };\n\n public static get = (\n key: TranslationsKey = TranslationsKey.MissingTranslationKey,\n ...args: TextArgs\n ) => this.getTranslation(key, ...args);\n}\n\nexport default Texts;\n","export function vocaIconsToOptions(vocaIcons: any, selected: string) {\n return mapToVocaOptions(Object.values(vocaIcons), ({ name }: any) => ({\n label: name,\n value: name,\n selected: selected === name,\n }));\n}\n\nexport type VocaIcon = { name: string; svg: string };\n\nexport enum VocaButtonVariant {\n Primary = 'primary',\n Secondary = 'secondary',\n Expressive = 'expressive',\n Destructive = 'destructive',\n Text = 'text',\n PrimaryWhite = 'primary-white',\n SecondaryWhite = 'secondary-white',\n ExpressiveWhite = 'expressive-white',\n TertiaryPurple = 'tertiary-purple',\n}\n\nexport type VocaOption = { label: string; value: string; disabled?: boolean; selected?: boolean };\n\nexport function getVocaIcon(vocaIcons: any, name: string) {\n const icon = Object.values(vocaIcons).find((icon: any) => icon.name === name);\n return icon as VocaIcon;\n}\n\nexport type Unpacked<T> = T extends (infer U)[] ? U : T;\n\nexport function mapToVocaOptions<T>(\n items: T,\n mapper: (item: Unpacked<T>) => VocaOption,\n label: string = 'Choose...'\n): VocaOption[] {\n return (items as []).reduce<VocaOption[]>(\n (acc, item) => {\n acc.push({\n disabled: false,\n selected: false,\n ...mapper(item),\n });\n\n return acc;\n },\n [\n {\n label,\n value: '',\n disabled: true,\n selected: true,\n },\n ]\n );\n}\n\nexport function onEnter(fn: Function) {\n return (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n fn(e);\n }\n };\n}\n\nexport function friendlyUserName(\n user: { email: string; displayName: string },\n format: 'single' | 'all' = 'all'\n) {\n const { email, displayName } = user;\n\n const hasDisplayName = displayName && displayName !== 'unknown';\n const hasEmail = !!email;\n\n switch (format) {\n case 'all': {\n if (hasDisplayName && hasEmail) {\n return `${displayName} (${email})`;\n } else if (hasDisplayName) {\n return displayName;\n } else if (hasEmail) {\n return email;\n }\n }\n case 'single': {\n if (hasDisplayName) {\n return displayName;\n } else if (hasEmail) {\n return email;\n }\n }\n }\n\n return '<UNKNOWN USER>';\n}\n\nexport function classNames(...classes: string[]) {\n return classes.filter((c) => !!c).join(' ');\n}\n\nexport function props(properties: Object) {\n return Object.entries(properties).reduce<Record<string, string | boolean | number>>(\n (acc, [key, value]) => {\n if (typeof value !== 'object' && typeof value !== 'function') {\n acc[key] = value;\n }\n\n return acc;\n },\n {}\n );\n}\n"],"names":["FrameworkErrorCodes","UtilitiesErrorCodes","parseTemplates","message","variables","acc","key","value","allianceErrors","ALLIANCE_ERROR_NAME","AllianceError","code","info","isAllianceError","error","createQueryString","args","filteredArgs","entry","getCurrentPath","runtimeRootUrl","getRuntimeRootUrl","href","search","createCapabilityPath","app","capability","rootPath","queryString","getCurrentLocationInfo","currentPath","part","setRuntimeRootUrl","environment","origin","pathname","workspace","TranslationsKey","TranslationsKey2","en","_Texts","__publicField","translation","curr","index","Texts","vocaIconsToOptions","vocaIcons","selected","mapToVocaOptions","name","VocaButtonVariant","getVocaIcon","icon","items","mapper","label","item","onEnter","fn","e","friendlyUserName","user","format","email","displayName","hasDisplayName","hasEmail","classNames","classes","c","props","properties"],"mappings":";;;AAAY,IAAAA,sBAAAA,OACRA,EAAAA,EAAA,qBAAqB,GAArB,IAAA,sBACAA,EAAAA,EAAA,iBAAiB,IAAjB,IAAA,kBACAA,EAAAA,EAAA,uBAAuB,IAAvB,IAAA,wBACAA,EAAAA,EAAA,yBAAyB,IAAzB,IAAA,0BACAA,EAAAA,EAAA,+BAA+B,IAA/B,IAAA,gCACAA,EAAAA,EAAA,aAAa,IAAb,IAAA,cACAA,EAAAA,EAAA,gBAAgB,IAAhB,IAAA,iBACAA,EAAAA,EAAA,SAAS,IAAT,IAAA,UACAA,EAAAA,EAAA,sBAAsB,IAAtB,IAAA,uBACAA,EAAAA,EAAA,2BAA2B,IAA3B,IAAA,4BACAA,EAAAA,EAAA,uBAAuB,IAAvB,IAAA,wBACAA,EAAAA,EAAA,4BAA4B,IAA5B,IAAA,6BACAA,EAAAA,EAAA,iCAAiC,IAAjC,IAAA,kCAbQA,IAAAA,KAAA,CAAA,CAAA,GAgBAC,sBAAAA,OACRA,EAAAA,EAAA,6BAA6B,GAA7B,IAAA,8BACAA,EAAAA,EAAA,+BAA+B,IAA/B,IAAA,gCACAA,EAAAA,EAAA,4BAA4B,IAA5B,IAAA,6BACAA,EAAAA,EAAA,+BAA+B,IAA/B,IAAA,gCAJQA,IAAAA,KAAA,CAAA,CAAA;AASZ,SAASC,EAAeC,GAAiBC,GAAmC;AACjE,SAAA,OAAO,QAAQA,CAAS,EAAE,OAAO,CAACC,GAAK,CAACC,GAAKC,CAAK,MAC9CF,EAAI,WAAW,KAAKC,CAAG,MAAMC,CAAK,GAC1CJ,CAAO;AACd;AAEA,MAAMK,IAA6C;AA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,eAAAD;UACAE;AACA,eAAAH;AAAA,IAEf;AAAA,EACJ;AAEO,SAAA;AACX;AAEO,SAASI,KAAcC,GAAmB;AACtC,SAAAA,EAAQ,OAAO,CAACC,MAAM,CAAC,CAACA,CAAC,EAAE,KAAK,GAAG;AAC9C;AAEO,SAASC,EAAMC,GAAoB;AAC/B,SAAA,OAAO,QAAQA,CAAU,EAAE;AAAA,IAC9B,CAACnE,GAAK,CAACC,GAAKC,CAAK,OACT,OAAOA,KAAU,YAAY,OAAOA,KAAU,eAC9CF,EAAIC,CAAG,IAAIC,IAGRF;AAAA,IAEX,CAAC;AAAA,EAAA;AAET;"}
1
+ {"version":3,"sources":["../src/exceptions.ts","../src/routing.ts","../src/translations.ts","../src/texts.ts","../src/ui.ts"],"names":["FrameworkErrorCodes","UtilitiesErrorCodes","parseTemplates","message","variables","Object","entries","reduce","acc","key","value","replaceAll","allianceErrors","ALLIANCE_ERROR_NAME","AllianceError","Error","constructor","code","info","name","stack","isAllianceError","error","createQueryString","args","filteredArgs","entry","JSON","stringify","keys","length","URLSearchParams","getCurrentPath","runtimeRootUrl","getRuntimeRootUrl","href","search","window","location","replace","createCapabilityPath","app","capability","rootPath","origin","queryString","getCurrentLocationInfo","currentPath","split","filter","part","globalThis","__ALLIANCE_RUNTIME_ROOT_URL","TranslationsKey","en","Texts","getTranslations","getTranslation","translations","translation","formattedTranslation","curr","index","toString","get","MissingTranslationKey","vocaIconsToOptions","vocaIcons","selected","mapToVocaOptions","values","label","VocaButtonVariant","getVocaIcon","icon","find","items","mapper","item","push","disabled","onEnter","fn","e","friendlyUserName","user","format","email","displayName","hasDisplayName","hasEmail","classNames","classes","c","join","props","properties"],"mappings":";;;;;UAAYA,sBAAAA;;;;;;;;;;;;;;;GAAAA,wBAAAA,sBAAAA,CAAAA,EAAAA;;UAiBAC,sBAAAA;;;;;GAAAA,wBAAAA,sBAAAA,CAAAA,EAAAA;AASZ,SAASC,eAAeC,SAAiBC,WAAiC;AACtE,SAAOC,O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nByE,SAAGC,CAAAA;IACP;EACJ;AACJ;AANgBF;AAQT,SAASG,iBACZC,MACAC,SAA2B,OAAK;AAEhC,QAAM,EAAEC,OAAOC,YAAW,IAAKH;AAE/B,QAAMI,iBAAiBD,eAAeA,gBAAgB;AACtD,QAAME,WAAW,CAAC,CAACH;AAEnB,UAAQD,QAAAA;IACJ,KAAK,OAAO;AACR,UAAIG,kBAAkBC,UAAU;AAC5B,eAAO,GAAGF,WAAAA,KAAgBD,KAAAA;MAC9B,WAAWE,gBAAgB;AACvB,eAAOD;MACX,WAAWE,UAAU;AACjB,eAAOH;MACX;AACA;IACJ;IACA,KAAK,UAAU;AACX,UAAIE,gBAAgB;AAChB,eAAOD;MACX,WAAWE,UAAU;AACjB,eAAOH;MACX;AACA;IACJ;EACJ;AAEA,SAAO;AACX;AA/BgBH;AAiCT,SAASO,cAAcC,SAAiB;AAC3C,SAAOA,QAAQ3C,OAAO,CAAC4C,MAAM,CAAC,CAACA,CAAAA,EAAGC,KAAK,GAAA;AAC3C;AAFgBH;AAIT,SAASI,MAAMC,YAAkB;AACpC,SAAO3F,OAAOC,QAAQ0F,UAAAA,EAAYzF,OAC9B,CAACC,KAAK,CAACC,KAAKC,KAAAA,MAAM;AACd,QAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,YAAY;AAC1DF,UAAIC,GAAAA,IAAOC;IACf;AAEA,WAAOF;EACX,GACA,CAAC,CAAA;AAET;AAXgBuF","sourcesContent":["export enum FrameworkErrorCodes {\n AlreadyInitialized = 1000,\n NoAppName = 1001,\n MissingAppController = 1002,\n MissingCapabilityOnApp = 1003,\n MissingManagedObjectProvider = 1004,\n NoManifest = 1005,\n NoRootElement = 1006,\n NoView = 1007,\n CookieKeyNotDefined = 1008,\n CookieCategoryNotAllowed = 1009,\n StorageKeyNotDefined = 1010,\n StorageCategoryNotAllowed = 1011,\n LocalizationTemplateNotDefined = 1012,\n NonViewOperation = 1013,\n}\n\nexport enum UtilitiesErrorCodes {\n CurrentUserMissingProvider = 2000,\n CurrentUserGatewayNotStarted = 2001,\n CurrentUserMissingBackend = 2002,\n CurrentUserMissingInDatabase = 2003,\n}\n\ntype ErrorCodes = UtilitiesErrorCodes | FrameworkErrorCodes;\n\nfunction parseTemplates(message: string, variables: Record<string, string>) {\n return Object.entries(variables).reduce((acc, [key, value]) => {\n return acc.replaceAll(`{{${key}}}`, value);\n }, message);\n}\n\nconst allianceErrors: Record<ErrorCodes, string> = {\n // framework\n [FrameworkErrorCodes.AlreadyInitialized]: 'The runtime has already been initialized',\n [FrameworkErrorCodes.NoAppName]: 'App name is not defined on global scope',\n [FrameworkErrorCodes.MissingAppController]: \"No app controller registered for app '{{app}}'\",\n [FrameworkErrorCodes.MissingCapabilityOnApp]:\n \"No capability '{{capability}}' enabled for app '{{app}}'\",\n [FrameworkErrorCodes.MissingManagedObjectProvider]:\n \"No managed object provider registered for object '{{object}}'\",\n [FrameworkErrorCodes.NoManifest]: 'The current apps manifest is not defined on global scope',\n [FrameworkErrorCodes.NoRootElement]: 'Could not find the root element in the DOM',\n [FrameworkErrorCodes.NoView]:\n \"Could not find view with id '{{id}}' on view controller for app '{{app}}'\",\n [FrameworkErrorCodes.CookieKeyNotDefined]:\n \"Cookie key '{{key}}' not present in manifest, cookie has not been set\",\n [FrameworkErrorCodes.CookieCategoryNotAllowed]:\n \"Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set\",\n [FrameworkErrorCodes.StorageKeyNotDefined]:\n \"Storage key '{{key}}' not present in manifest, item has not been stored\",\n [FrameworkErrorCodes.StorageCategoryNotAllowed]:\n \"Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored\",\n [FrameworkErrorCodes.LocalizationTemplateNotDefined]:\n \"The translation template, referred by the key '{{key}}' is being used in app, but is not defined in the manifest.\",\n [FrameworkErrorCodes.NonViewOperation]:\n \"The capability '{{capability}}', requested by an alliance-view element, did not return a View Operation.\",\n // utilities\n [UtilitiesErrorCodes.CurrentUserMissingProvider]:\n \"No managed object provider registered for object 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserGatewayNotStarted]:\n \"Could not access the gateway when querying 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserMissingBackend]:\n \"Could not access the required backend when querying 'currentUser'\",\n [UtilitiesErrorCodes.CurrentUserMissingInDatabase]:\n 'Could not locate the authenticated user in the Alliance database',\n};\n\nconst ALLIANCE_ERROR_NAME = 'AllianceError';\n\nexport class AllianceError extends Error {\n constructor(\n public code: ErrorCodes,\n variables: Record<string, string> = {},\n ) {\n const message = parseTemplates(allianceErrors[code], variables);\n const info = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${code}`;\n super(message);\n\n this.name = ALLIANCE_ERROR_NAME;\n this.stack = `[${code}] - ${message}` + '\\n' + info;\n }\n}\n\nexport function isAllianceError(error: any): error is AllianceError {\n return !!error.code && error.name === ALLIANCE_ERROR_NAME;\n}\n","import type { SerializeableObject } from './types';\n\nfunction createQueryString(args: SerializeableObject) {\n const entries = Object.entries(args);\n\n const filteredArgs = entries.reduce<SerializeableObject>((acc, entry) => {\n const [key, value] = entry;\n\n if (typeof value === 'undefined') {\n return acc;\n } else if (typeof value === 'object' && value !== null) {\n acc[key] = JSON.stringify(value);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n\n if (!Object.keys(filteredArgs).length) {\n return '';\n }\n\n return `?${new URLSearchParams(filteredArgs as Record<string, any>)}`;\n}\n\nfunction getCurrentPath() {\n const runtimeRootUrl = getRuntimeRootUrl();\n const { href, search } = window.location;\n\n return href.replace(runtimeRootUrl, '').replace(search, '');\n}\n\nexport function createCapabilityPath(\n app: string = '',\n capability: string = '',\n args: SerializeableObject = {},\n) {\n const rootPath = getRuntimeRootUrl().replace(location.origin, '');\n const queryString = createQueryString(args);\n\n if (!app) {\n return `${rootPath}${queryString}`;\n }\n\n if (!capability) {\n return `${rootPath}/${app}${queryString}`;\n }\n\n return `${rootPath}/${app}/${capability}${queryString}`;\n}\n\nexport function getCurrentLocationInfo() {\n const currentPath = getCurrentPath();\n const [app = '', capability = ''] = currentPath.split('/').filter((part) => !!part);\n\n return {\n app,\n capability,\n };\n}\n\nexport function getRuntimeRootUrl(): string {\n // @ts-ignore\n if (globalThis.__ALLIANCE_RUNTIME_ROOT_URL) {\n // @ts-ignore\n return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;\n }\n return window.origin;\n}\n","export type Translations = {\n [key in TranslationsKey]: string;\n};\n\nexport enum TranslationsKey {\n AlreadyExists,\n ApiGatewayPortDescription,\n ApiServerModeDescription,\n AppConfigurationPath,\n AppCreated,\n AppEntryBuildOptionDescription,\n AppNameInquiry,\n BuildDescription,\n BuildModeOptionDescription,\n BuildWatchDescription,\n CreateAppDescription,\n CreateWorkspaceDescription,\n DevServerOpenDescription,\n DevServerPortDescription,\n DevServerLoggingDescription,\n Done,\n FetchPackageVersionError,\n ManifestEntryBuildOptionDescription,\n MissingTranslationKey,\n NoAppName,\n NoAppNameFound,\n NoAppOrWorkspaceInCurrentDirectory,\n NoWorkspaceName,\n OperationCancelled,\n ServeDescription,\n ServedStopped,\n ServerGatewayMode,\n ServerMode,\n ServerModeInquiry,\n ServerProxyMode,\n StopServerInstructions,\n TemplateFrameworkInquiry,\n TemplateLanguageInquiry,\n UnrecognizedCommand,\n WorkspaceCreated,\n WorkspaceNameInquiry,\n}\n\nexport const en: Translations = {\n [TranslationsKey.Done]: 'Done',\n [TranslationsKey.NoWorkspaceName]: 'No workspace name provided!',\n [TranslationsKey.NoAppName]: 'No app name provided!',\n [TranslationsKey.AlreadyExists]: \"File or directory '{0}' already exists!\",\n [TranslationsKey.NoAppOrWorkspaceInCurrentDirectory]:\n \"Could not find any app entry file at '{0}'!\",\n [TranslationsKey.UnrecognizedCommand]: 'Unrecognized command(s) {0}!',\n [TranslationsKey.WorkspaceCreated]: \"Workspace was created at path '{0}'!\",\n [TranslationsKey.AppCreated]: \"App was created at path '{0}'!\",\n [TranslationsKey.ServedStopped]: 'Server stopped.',\n [TranslationsKey.CreateWorkspaceDescription]:\n 'Creates an Alliance Workspace in the current directory.',\n [TranslationsKey.CreateAppDescription]:\n 'Creates an Alliance Application in the current directory or Alliance Workspace.',\n [TranslationsKey.ServeDescription]:\n 'Starts a Alliance development server using the current directory package.json.',\n [TranslationsKey.BuildDescription]: 'Builds an Alliance Application using Vite.',\n [TranslationsKey.WorkspaceNameInquiry]: 'Enter the name of your workspace',\n [TranslationsKey.ServerModeInquiry]: 'Which server mode do you want to use?',\n [TranslationsKey.AppNameInquiry]: 'Enter the name of your app',\n [TranslationsKey.MissingTranslationKey]: 'No translation key provided!',\n [TranslationsKey.OperationCancelled]: 'Operation cancelled.',\n [TranslationsKey.StopServerInstructions]: 'Press CTRL + C to stop the server.\\n',\n [TranslationsKey.TemplateLanguageInquiry]: 'Select preferred language',\n [TranslationsKey.TemplateFrameworkInquiry]: 'Select preferred framework template',\n [TranslationsKey.DevServerPortDescription]: 'The port that the dev server should use.',\n [TranslationsKey.DevServerLoggingDescription]:\n 'Whether the dev server and browser console should output more log information or not (false).',\n [TranslationsKey.ApiGatewayPortDescription]: 'The port that the api gateway should use.',\n [TranslationsKey.ApiServerModeDescription]:\n 'Which components to start. [server|server-proxy|server-gateway].',\n [TranslationsKey.DevServerOpenDescription]:\n 'Whether the dev server should automatically open in your browser or not.',\n [TranslationsKey.BuildWatchDescription]:\n 'Whether the build should start watching and rebuild when files change or not.',\n [TranslationsKey.AppEntryBuildOptionDescription]: 'The entry file for the app (./src/app).',\n [TranslationsKey.ManifestEntryBuildOptionDescription]:\n 'The entry file for the app manifest (./src/manifest).',\n [TranslationsKey.BuildModeOptionDescription]: 'Which mode to use when building the app.',\n [TranslationsKey.FetchPackageVersionError]:\n \"Failed to fetch package info from the NPM registry for package '${0}'!\",\n [TranslationsKey.NoAppNameFound]: 'Could not find app name in manifest.',\n [TranslationsKey.AppConfigurationPath]: 'The path to the app configuration file.',\n [TranslationsKey.ServerMode]: 'Server',\n [TranslationsKey.ServerProxyMode]: 'Server with proxy',\n [TranslationsKey.ServerGatewayMode]: 'Server with gateway',\n};\n","import { type Translations, TranslationsKey, en } from './translations';\n\nexport type TextArgs = (string | number)[];\n\nexport class Texts {\n protected static getTranslations = (): Translations => {\n return en;\n };\n\n protected static getTranslation = (key: TranslationsKey, ...args: TextArgs): string => {\n const translations = Texts.getTranslations();\n const translation = translations[key];\n\n if (!translation) throw new Error(`Could not find text with given key '${key}'.`);\n\n const formattedTranslation = args.reduce(\n (acc, curr, index) => acc.toString().replace(`{${index}}`, curr.toString()),\n translation,\n );\n\n return formattedTranslation.toString();\n };\n\n public static get = (\n key: TranslationsKey = TranslationsKey.MissingTranslationKey,\n ...args: TextArgs\n ) => this.getTranslation(key, ...args);\n}\n\nexport default Texts;\n","export function vocaIconsToOptions(vocaIcons: any, selected: string) {\n return mapToVocaOptions(Object.values(vocaIcons), ({ name }: any) => ({\n label: name,\n value: name,\n selected: selected === name,\n }));\n}\n\nexport type VocaIcon = { name: string; svg: string };\n\nexport enum VocaButtonVariant {\n Primary = 'primary',\n Secondary = 'secondary',\n Expressive = 'expressive',\n Destructive = 'destructive',\n Text = 'text',\n PrimaryWhite = 'primary-white',\n SecondaryWhite = 'secondary-white',\n ExpressiveWhite = 'expressive-white',\n TertiaryPurple = 'tertiary-purple',\n}\n\nexport type VocaOption = { label: string; value: string; disabled?: boolean; selected?: boolean };\n\nexport function getVocaIcon(vocaIcons: any, name: string) {\n const icon = Object.values(vocaIcons).find((icon: any) => icon.name === name);\n return icon as VocaIcon;\n}\n\nexport type Unpacked<T> = T extends (infer U)[] ? U : T;\n\nexport function mapToVocaOptions<T>(\n items: T,\n mapper: (item: Unpacked<T>) => VocaOption,\n label: string = 'Choose...',\n): VocaOption[] {\n return (items as []).reduce<VocaOption[]>(\n (acc, item) => {\n acc.push({\n disabled: false,\n selected: false,\n ...mapper(item),\n });\n\n return acc;\n },\n [\n {\n label,\n value: '',\n disabled: true,\n selected: true,\n },\n ],\n );\n}\n\nexport function onEnter(fn: (e: KeyboardEvent) => void) {\n return (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n fn(e);\n }\n };\n}\n\nexport function friendlyUserName(\n user: { email: string; displayName: string },\n format: 'single' | 'all' = 'all',\n) {\n const { email, displayName } = user;\n\n const hasDisplayName = displayName && displayName !== 'unknown';\n const hasEmail = !!email;\n\n switch (format) {\n case 'all': {\n if (hasDisplayName && hasEmail) {\n return `${displayName} (${email})`;\n } else if (hasDisplayName) {\n return displayName;\n } else if (hasEmail) {\n return email;\n }\n break;\n }\n case 'single': {\n if (hasDisplayName) {\n return displayName;\n } else if (hasEmail) {\n return email;\n }\n break;\n }\n }\n\n return '<UNKNOWN USER>';\n}\n\nexport function classNames(...classes: string[]) {\n return classes.filter((c) => !!c).join(' ');\n}\n\nexport function props(properties: object) {\n return Object.entries(properties).reduce<Record<string, string | boolean | number>>(\n (acc, [key, value]) => {\n if (typeof value !== 'object' && typeof value !== 'function') {\n acc[key] = value;\n }\n\n return acc;\n },\n {},\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/alliance-internal-client-utilities",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Utilities used internally by packages developed by team Alliance.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -14,14 +14,15 @@
14
14
  "dist"
15
15
  ],
16
16
  "devDependencies": {
17
- "vite": "^4.4.6"
17
+ "@telia-ace/alliance-internal-node-utilities": "1.0.4",
18
+ "tsup": "^7.2.0"
18
19
  },
19
20
  "publishConfig": {
20
21
  "access": "public"
21
22
  },
22
23
  "scripts": {
23
- "build:dev": "tsc && vite build --mode development",
24
- "build:prod": "rimraf dist && tsc && vite build",
25
- "dev": "tsc && vite build --mode development --watch"
24
+ "build:dev": "tsup",
25
+ "build:prod": "tsup",
26
+ "dev": "tsup --watch"
26
27
  }
27
28
  }
@@ -1,28 +0,0 @@
1
- export declare enum FrameworkErrorCodes {
2
- AlreadyInitialized = 1000,
3
- NoAppNameOrKey = 1001,
4
- MissingAppController = 1002,
5
- MissingCapabilityOnApp = 1003,
6
- MissingManagedObjectProvider = 1004,
7
- NoManifest = 1005,
8
- NoRootElement = 1006,
9
- NoView = 1007,
10
- CookieKeyNotDefined = 1008,
11
- CookieCategoryNotAllowed = 1009,
12
- StorageKeyNotDefined = 1010,
13
- StorageCategoryNotAllowed = 1011,
14
- LocalizationTemplateNotDefined = 1012
15
- }
16
- export declare enum UtilitiesErrorCodes {
17
- CurrentUserMissingProvider = 2000,
18
- CurrentUserGatewayNotStarted = 2001,
19
- CurrentUserMissingBackend = 2002,
20
- CurrentUserMissingInDatabase = 2003
21
- }
22
- type ErrorCodes = UtilitiesErrorCodes | FrameworkErrorCodes;
23
- export declare class AllianceError extends Error {
24
- code: ErrorCodes;
25
- constructor(code: ErrorCodes, variables?: Record<string, string>);
26
- }
27
- export declare function isAllianceError(error: any): error is AllianceError;
28
- export {};
package/dist/routing.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { SerializeableObject } from './types';
2
- export declare function createCapabilityPath(app?: string, capability?: string, args?: SerializeableObject): string;
3
- export declare function getCurrentLocationInfo(): {
4
- app: string;
5
- capability: string;
6
- };
7
- export declare function setRuntimeRootUrl(environment: 'production' | 'development'): string;
8
- export declare function getRuntimeRootUrl(): string;
package/dist/texts.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { TranslationsKey, type Translations } from './translations';
2
- export type TextArgs = (string | number)[];
3
- export declare class Texts {
4
- protected static getTranslations: () => Translations;
5
- protected static getTranslation: (key: TranslationsKey, ...args: TextArgs) => string;
6
- static get: (key?: TranslationsKey, ...args: TextArgs) => string;
7
- }
8
- export default Texts;
@@ -1,42 +0,0 @@
1
- export type Translations = {
2
- [key in TranslationsKey]: string;
3
- };
4
- export declare enum TranslationsKey {
5
- AlreadyExists = 0,
6
- ApiGatewayPortDescription = 1,
7
- ApiServerModeDescription = 2,
8
- AppConfigurationPath = 3,
9
- AppCreated = 4,
10
- AppEntryBuildOptionDescription = 5,
11
- AppNameInquiry = 6,
12
- BuildDescription = 7,
13
- BuildModeOptionDescription = 8,
14
- BuildWatchDescription = 9,
15
- CreateAppDescription = 10,
16
- CreateWorkspaceDescription = 11,
17
- DevServerOpenDescription = 12,
18
- DevServerPortDescription = 13,
19
- DevServerLoggingDescription = 14,
20
- Done = 15,
21
- FetchPackageVersionError = 16,
22
- ManifestEntryBuildOptionDescription = 17,
23
- MissingTranslationKey = 18,
24
- NoAppName = 19,
25
- NoAppNameFound = 20,
26
- NoAppOrWorkspaceInCurrentDirectory = 21,
27
- NoWorkspaceName = 22,
28
- OperationCancelled = 23,
29
- ServeDescription = 24,
30
- ServedStopped = 25,
31
- ServerGatewayMode = 26,
32
- ServerMode = 27,
33
- ServerModeInquiry = 28,
34
- ServerProxyMode = 29,
35
- StopServerInstructions = 30,
36
- TemplateFrameworkInquiry = 31,
37
- TemplateLanguageInquiry = 32,
38
- UnrecognizedCommand = 33,
39
- WorkspaceCreated = 34,
40
- WorkspaceNameInquiry = 35
41
- }
42
- export declare const en: Translations;
package/dist/types.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export type Promisable<T> = Promise<T> | T;
2
- export type ValueTypes = string | number | boolean | undefined | null;
3
- export type Serializeable = ValueTypes | SerializeableObject | ValueTypes[] | SerializeableObject[];
4
- export interface SerializeableObject {
5
- [key: string]: Serializeable;
6
- }
package/dist/ui.d.ts DELETED
@@ -1,32 +0,0 @@
1
- export declare function vocaIconsToOptions(vocaIcons: any, selected: string): VocaOption[];
2
- export type VocaIcon = {
3
- name: string;
4
- svg: string;
5
- };
6
- export declare enum VocaButtonVariant {
7
- Primary = "primary",
8
- Secondary = "secondary",
9
- Expressive = "expressive",
10
- Destructive = "destructive",
11
- Text = "text",
12
- PrimaryWhite = "primary-white",
13
- SecondaryWhite = "secondary-white",
14
- ExpressiveWhite = "expressive-white",
15
- TertiaryPurple = "tertiary-purple"
16
- }
17
- export type VocaOption = {
18
- label: string;
19
- value: string;
20
- disabled?: boolean;
21
- selected?: boolean;
22
- };
23
- export declare function getVocaIcon(vocaIcons: any, name: string): VocaIcon;
24
- export type Unpacked<T> = T extends (infer U)[] ? U : T;
25
- export declare function mapToVocaOptions<T>(items: T, mapper: (item: Unpacked<T>) => VocaOption, label?: string): VocaOption[];
26
- export declare function onEnter(fn: Function): (e: KeyboardEvent) => void;
27
- export declare function friendlyUserName(user: {
28
- email: string;
29
- displayName: string;
30
- }, format?: 'single' | 'all'): string;
31
- export declare function classNames(...classes: string[]): string;
32
- export declare function props(properties: Object): Record<string, string | number | boolean>;