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

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.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 1b9c7a9: Fix select field placeholders not using localized texts.
8
+
9
+ ## 1.0.5-next.0
10
+
11
+ ### Patch Changes
12
+
13
+ - 1b9c7a9: Fix select field placeholders not using localized texts.
14
+
3
15
  ## 1.0.4
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -114,7 +114,7 @@ type VocaOption = {
114
114
  };
115
115
  declare function getVocaIcon(vocaIcons: any, name: string): VocaIcon;
116
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[];
117
+ declare function mapToVocaOptions<T>(items: T, mapper: (item: Unpacked<T>) => VocaOption, placeholder?: string): VocaOption[];
118
118
  declare function onEnter(fn: (e: KeyboardEvent) => void): (e: KeyboardEvent) => void;
119
119
  declare function friendlyUserName(user: {
120
120
  email: string;
package/dist/index.js CHANGED
@@ -1,9 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/exceptions.ts
5
- var FrameworkErrorCodes;
6
- (function(FrameworkErrorCodes2) {
2
+ var FrameworkErrorCodes = /* @__PURE__ */ ((FrameworkErrorCodes2) => {
7
3
  FrameworkErrorCodes2[FrameworkErrorCodes2["AlreadyInitialized"] = 1e3] = "AlreadyInitialized";
8
4
  FrameworkErrorCodes2[FrameworkErrorCodes2["NoAppName"] = 1001] = "NoAppName";
9
5
  FrameworkErrorCodes2[FrameworkErrorCodes2["MissingAppController"] = 1002] = "MissingAppController";
@@ -18,48 +14,44 @@ var FrameworkErrorCodes;
18
14
  FrameworkErrorCodes2[FrameworkErrorCodes2["StorageCategoryNotAllowed"] = 1011] = "StorageCategoryNotAllowed";
19
15
  FrameworkErrorCodes2[FrameworkErrorCodes2["LocalizationTemplateNotDefined"] = 1012] = "LocalizationTemplateNotDefined";
20
16
  FrameworkErrorCodes2[FrameworkErrorCodes2["NonViewOperation"] = 1013] = "NonViewOperation";
21
- })(FrameworkErrorCodes || (FrameworkErrorCodes = {}));
22
- var UtilitiesErrorCodes;
23
- (function(UtilitiesErrorCodes2) {
17
+ return FrameworkErrorCodes2;
18
+ })(FrameworkErrorCodes || {});
19
+ var UtilitiesErrorCodes = /* @__PURE__ */ ((UtilitiesErrorCodes2) => {
24
20
  UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingProvider"] = 2e3] = "CurrentUserMissingProvider";
25
21
  UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserGatewayNotStarted"] = 2001] = "CurrentUserGatewayNotStarted";
26
22
  UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingBackend"] = 2002] = "CurrentUserMissingBackend";
27
23
  UtilitiesErrorCodes2[UtilitiesErrorCodes2["CurrentUserMissingInDatabase"] = 2003] = "CurrentUserMissingInDatabase";
28
- })(UtilitiesErrorCodes || (UtilitiesErrorCodes = {}));
24
+ return UtilitiesErrorCodes2;
25
+ })(UtilitiesErrorCodes || {});
29
26
  function parseTemplates(message, variables) {
30
27
  return Object.entries(variables).reduce((acc, [key, value]) => {
31
28
  return acc.replaceAll(`{{${key}}}`, value);
32
29
  }, message);
33
30
  }
34
- __name(parseTemplates, "parseTemplates");
35
31
  var allianceErrors = {
36
32
  // framework
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.",
33
+ [1e3 /* AlreadyInitialized */]: "The runtime has already been initialized",
34
+ [1001 /* NoAppName */]: "App name is not defined on global scope",
35
+ [1002 /* MissingAppController */]: "No app controller registered for app '{{app}}'",
36
+ [1003 /* MissingCapabilityOnApp */]: "No capability '{{capability}}' enabled for app '{{app}}'",
37
+ [1004 /* MissingManagedObjectProvider */]: "No managed object provider registered for object '{{object}}'",
38
+ [1005 /* NoManifest */]: "The current apps manifest is not defined on global scope",
39
+ [1006 /* NoRootElement */]: "Could not find the root element in the DOM",
40
+ [1007 /* NoView */]: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
41
+ [1008 /* CookieKeyNotDefined */]: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
42
+ [1009 /* CookieCategoryNotAllowed */]: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
43
+ [1010 /* StorageKeyNotDefined */]: "Storage key '{{key}}' not present in manifest, item has not been stored",
44
+ [1011 /* StorageCategoryNotAllowed */]: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
45
+ [1012 /* LocalizationTemplateNotDefined */]: "The translation template, referred by the key '{{key}}' is being used in app, but is not defined in the manifest.",
46
+ [1013 /* NonViewOperation */]: "The capability '{{capability}}', requested by an alliance-view element, did not return a View Operation.",
51
47
  // utilities
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"
48
+ [2e3 /* CurrentUserMissingProvider */]: "No managed object provider registered for object 'currentUser'",
49
+ [2001 /* CurrentUserGatewayNotStarted */]: "Could not access the gateway when querying 'currentUser'",
50
+ [2002 /* CurrentUserMissingBackend */]: "Could not access the required backend when querying 'currentUser'",
51
+ [2003 /* CurrentUserMissingInDatabase */]: "Could not locate the authenticated user in the Alliance database"
56
52
  };
57
53
  var ALLIANCE_ERROR_NAME = "AllianceError";
58
54
  var AllianceError = class extends Error {
59
- static {
60
- __name(this, "AllianceError");
61
- }
62
- code;
63
55
  constructor(code, variables = {}) {
64
56
  const message = parseTemplates(allianceErrors[code], variables);
65
57
  const info = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${code}`;
@@ -73,7 +65,6 @@ var AllianceError = class extends Error {
73
65
  function isAllianceError(error) {
74
66
  return !!error.code && error.name === ALLIANCE_ERROR_NAME;
75
67
  }
76
- __name(isAllianceError, "isAllianceError");
77
68
 
78
69
  // src/routing.ts
79
70
  function createQueryString(args) {
@@ -94,13 +85,11 @@ function createQueryString(args) {
94
85
  }
95
86
  return `?${new URLSearchParams(filteredArgs)}`;
96
87
  }
97
- __name(createQueryString, "createQueryString");
98
88
  function getCurrentPath() {
99
89
  const runtimeRootUrl = getRuntimeRootUrl();
100
90
  const { href, search } = window.location;
101
91
  return href.replace(runtimeRootUrl, "").replace(search, "");
102
92
  }
103
- __name(getCurrentPath, "getCurrentPath");
104
93
  function createCapabilityPath(app = "", capability = "", args = {}) {
105
94
  const rootPath = getRuntimeRootUrl().replace(location.origin, "");
106
95
  const queryString = createQueryString(args);
@@ -112,7 +101,6 @@ function createCapabilityPath(app = "", capability = "", args = {}) {
112
101
  }
113
102
  return `${rootPath}/${app}/${capability}${queryString}`;
114
103
  }
115
- __name(createCapabilityPath, "createCapabilityPath");
116
104
  function getCurrentLocationInfo() {
117
105
  const currentPath = getCurrentPath();
118
106
  const [app = "", capability = ""] = currentPath.split("/").filter((part) => !!part);
@@ -121,18 +109,15 @@ function getCurrentLocationInfo() {
121
109
  capability
122
110
  };
123
111
  }
124
- __name(getCurrentLocationInfo, "getCurrentLocationInfo");
125
112
  function getRuntimeRootUrl() {
126
113
  if (globalThis.__ALLIANCE_RUNTIME_ROOT_URL) {
127
114
  return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;
128
115
  }
129
116
  return window.origin;
130
117
  }
131
- __name(getRuntimeRootUrl, "getRuntimeRootUrl");
132
118
 
133
119
  // src/translations.ts
134
- var TranslationsKey;
135
- (function(TranslationsKey2) {
120
+ var TranslationsKey = /* @__PURE__ */ ((TranslationsKey2) => {
136
121
  TranslationsKey2[TranslationsKey2["AlreadyExists"] = 0] = "AlreadyExists";
137
122
  TranslationsKey2[TranslationsKey2["ApiGatewayPortDescription"] = 1] = "ApiGatewayPortDescription";
138
123
  TranslationsKey2[TranslationsKey2["ApiServerModeDescription"] = 2] = "ApiServerModeDescription";
@@ -169,63 +154,70 @@ var TranslationsKey;
169
154
  TranslationsKey2[TranslationsKey2["UnrecognizedCommand"] = 33] = "UnrecognizedCommand";
170
155
  TranslationsKey2[TranslationsKey2["WorkspaceCreated"] = 34] = "WorkspaceCreated";
171
156
  TranslationsKey2[TranslationsKey2["WorkspaceNameInquiry"] = 35] = "WorkspaceNameInquiry";
172
- })(TranslationsKey || (TranslationsKey = {}));
157
+ return TranslationsKey2;
158
+ })(TranslationsKey || {});
173
159
  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"
160
+ [15 /* Done */]: "Done",
161
+ [22 /* NoWorkspaceName */]: "No workspace name provided!",
162
+ [19 /* NoAppName */]: "No app name provided!",
163
+ [0 /* AlreadyExists */]: "File or directory '{0}' already exists!",
164
+ [21 /* NoAppOrWorkspaceInCurrentDirectory */]: "Could not find any app entry file at '{0}'!",
165
+ [33 /* UnrecognizedCommand */]: "Unrecognized command(s) {0}!",
166
+ [34 /* WorkspaceCreated */]: "Workspace was created at path '{0}'!",
167
+ [4 /* AppCreated */]: "App was created at path '{0}'!",
168
+ [25 /* ServedStopped */]: "Server stopped.",
169
+ [11 /* CreateWorkspaceDescription */]: "Creates an Alliance Workspace in the current directory.",
170
+ [10 /* CreateAppDescription */]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
171
+ [24 /* ServeDescription */]: "Starts a Alliance development server using the current directory package.json.",
172
+ [7 /* BuildDescription */]: "Builds an Alliance Application using Vite.",
173
+ [35 /* WorkspaceNameInquiry */]: "Enter the name of your workspace",
174
+ [28 /* ServerModeInquiry */]: "Which server mode do you want to use?",
175
+ [6 /* AppNameInquiry */]: "Enter the name of your app",
176
+ [18 /* MissingTranslationKey */]: "No translation key provided!",
177
+ [23 /* OperationCancelled */]: "Operation cancelled.",
178
+ [30 /* StopServerInstructions */]: "Press CTRL + C to stop the server.\n",
179
+ [32 /* TemplateLanguageInquiry */]: "Select preferred language",
180
+ [31 /* TemplateFrameworkInquiry */]: "Select preferred framework template",
181
+ [13 /* DevServerPortDescription */]: "The port that the dev server should use.",
182
+ [14 /* DevServerLoggingDescription */]: "Whether the dev server and browser console should output more log information or not (false).",
183
+ [1 /* ApiGatewayPortDescription */]: "The port that the api gateway should use.",
184
+ [2 /* ApiServerModeDescription */]: "Which components to start. [server|server-proxy|server-gateway].",
185
+ [12 /* DevServerOpenDescription */]: "Whether the dev server should automatically open in your browser or not.",
186
+ [9 /* BuildWatchDescription */]: "Whether the build should start watching and rebuild when files change or not.",
187
+ [5 /* AppEntryBuildOptionDescription */]: "The entry file for the app (./src/app).",
188
+ [17 /* ManifestEntryBuildOptionDescription */]: "The entry file for the app manifest (./src/manifest).",
189
+ [8 /* BuildModeOptionDescription */]: "Which mode to use when building the app.",
190
+ [16 /* FetchPackageVersionError */]: "Failed to fetch package info from the NPM registry for package '${0}'!",
191
+ [20 /* NoAppNameFound */]: "Could not find app name in manifest.",
192
+ [3 /* AppConfigurationPath */]: "The path to the app configuration file.",
193
+ [27 /* ServerMode */]: "Server",
194
+ [29 /* ServerProxyMode */]: "Server with proxy",
195
+ [26 /* ServerGatewayMode */]: "Server with gateway"
210
196
  };
211
197
 
212
198
  // src/texts.ts
213
199
  var Texts = class _Texts {
214
200
  static {
215
- __name(this, "Texts");
201
+ this.getTranslations = () => {
202
+ return en;
203
+ };
204
+ }
205
+ static {
206
+ this.getTranslation = (key, ...args) => {
207
+ const translations = _Texts.getTranslations();
208
+ const translation = translations[key];
209
+ if (!translation)
210
+ throw new Error(`Could not find text with given key '${key}'.`);
211
+ const formattedTranslation = args.reduce(
212
+ (acc, curr, index) => acc.toString().replace(`{${index}}`, curr.toString()),
213
+ translation
214
+ );
215
+ return formattedTranslation.toString();
216
+ };
217
+ }
218
+ static {
219
+ this.get = (key = 18 /* MissingTranslationKey */, ...args) => this.getTranslation(key, ...args);
216
220
  }
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
221
  };
230
222
  var texts_default = Texts;
231
223
 
@@ -237,9 +229,7 @@ function vocaIconsToOptions(vocaIcons, selected) {
237
229
  selected: selected === name
238
230
  }));
239
231
  }
240
- __name(vocaIconsToOptions, "vocaIconsToOptions");
241
- var VocaButtonVariant;
242
- (function(VocaButtonVariant2) {
232
+ var VocaButtonVariant = /* @__PURE__ */ ((VocaButtonVariant2) => {
243
233
  VocaButtonVariant2["Primary"] = "primary";
244
234
  VocaButtonVariant2["Secondary"] = "secondary";
245
235
  VocaButtonVariant2["Expressive"] = "expressive";
@@ -249,30 +239,32 @@ var VocaButtonVariant;
249
239
  VocaButtonVariant2["SecondaryWhite"] = "secondary-white";
250
240
  VocaButtonVariant2["ExpressiveWhite"] = "expressive-white";
251
241
  VocaButtonVariant2["TertiaryPurple"] = "tertiary-purple";
252
- })(VocaButtonVariant || (VocaButtonVariant = {}));
242
+ return VocaButtonVariant2;
243
+ })(VocaButtonVariant || {});
253
244
  function getVocaIcon(vocaIcons, name) {
254
245
  const icon = Object.values(vocaIcons).find((icon2) => icon2.name === name);
255
246
  return icon;
256
247
  }
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
- ]);
248
+ function mapToVocaOptions(items, mapper, placeholder) {
249
+ return items.reduce(
250
+ (acc, item) => {
251
+ acc.push({
252
+ disabled: false,
253
+ selected: false,
254
+ ...mapper(item)
255
+ });
256
+ return acc;
257
+ },
258
+ placeholder ? [
259
+ {
260
+ label: placeholder,
261
+ value: "",
262
+ disabled: true,
263
+ selected: true
264
+ }
265
+ ] : []
266
+ );
274
267
  }
275
- __name(mapToVocaOptions, "mapToVocaOptions");
276
268
  function onEnter(fn) {
277
269
  return (e) => {
278
270
  if (e.key === "Enter") {
@@ -280,7 +272,6 @@ function onEnter(fn) {
280
272
  }
281
273
  };
282
274
  }
283
- __name(onEnter, "onEnter");
284
275
  function friendlyUserName(user, format = "all") {
285
276
  const { email, displayName } = user;
286
277
  const hasDisplayName = displayName && displayName !== "unknown";
@@ -307,20 +298,20 @@ function friendlyUserName(user, format = "all") {
307
298
  }
308
299
  return "<UNKNOWN USER>";
309
300
  }
310
- __name(friendlyUserName, "friendlyUserName");
311
301
  function classNames(...classes) {
312
302
  return classes.filter((c) => !!c).join(" ");
313
303
  }
314
- __name(classNames, "classNames");
315
304
  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
- }, {});
305
+ return Object.entries(properties).reduce(
306
+ (acc, [key, value]) => {
307
+ if (typeof value !== "object" && typeof value !== "function") {
308
+ acc[key] = value;
309
+ }
310
+ return acc;
311
+ },
312
+ {}
313
+ );
322
314
  }
323
- __name(props, "props");
324
315
 
325
316
  export { AllianceError, FrameworkErrorCodes, texts_default as Texts, TranslationsKey, UtilitiesErrorCodes, VocaButtonVariant, classNames, createCapabilityPath, friendlyUserName, getCurrentLocationInfo, getRuntimeRootUrl, getVocaIcon, isAllianceError, mapToVocaOptions, onEnter, props, vocaIconsToOptions };
326
317
  //# sourceMappingURL=out.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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,OAAOC,QAAQF,SAAAA,EAAWG,OAAO,CAACC,KAAK,CAACC,KAAKC,KAAAA,MAAM;AACtD,WAAOF,IAAIG,WAAW,KAAKF,GAAAA,MAASC,KAAAA;EACxC,GAAGP,OAAAA;AACP;AAJSD;AAMT,IAAMU,iBA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AAW,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"]}
1
+ {"version":3,"sources":["../src/exceptions.ts","../src/routing.ts","../src/translations.ts","../src/texts.ts","../src/ui.ts"],"names":["FrameworkErrorCodes","UtilitiesErrorCodes","TranslationsKey","VocaButtonVariant","icon"],"mappings":";AAAO,IAAK,sBAAL,kBAAKA,yBAAL;AACH,EAAAA,0CAAA,wBAAqB,OAArB;AACA,EAAAA,0CAAA,eAAY,QAAZ;AACA,EAAAA,0CAAA,0BAAuB,QAAvB;AACA,EAAAA,0CAAA,4BAAyB,QAAzB;AACA,EAAAA,0CAAA,kCAA+B,QAA/B;AACA,EAAAA,0CAAA,gBAAa,QAAb;AACA,EAAAA,0CAAA,mBAAgB,QAAhB;AACA,EAAAA,0CAAA,YAAS,QAAT;AACA,EAAAA,0CAAA,yBAAsB,QAAtB;AACA,EAAAA,0CAAA,8BAA2B,QAA3B;AACA,EAAAA,0CAAA,0BAAuB,QAAvB;AACA,EAAAA,0CAAA,+BAA4B,QAA5B;AACA,EAAAA,0CAAA,oCAAiC,QAAjC;AACA,EAAAA,0CAAA,sBAAmB,QAAnB;AAdQ,SAAAA;AAAA,GAAA;AAiBL,IAAK,sBAAL,kBAAKC,yBAAL;AACH,EAAAA,0CAAA,gCAA6B,OAA7B;AACA,EAAAA,0CA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ACJ,IACA,CAAC;AAAA,EACX;AACJ;AAEO,SAAS,QAAQ,IAAgC;AACpD,SAAO,CAAC,MAAqB;AACzB,QAAI,EAAE,QAAQ,SAAS;AACnB,SAAG,CAAC;AAAA,IACR;AAAA,EACJ;AACJ;AAEO,SAAS,iBACZ,MACA,SAA2B,OAC7B;AACE,QAAM,EAAE,OAAO,YAAY,IAAI;AAE/B,QAAM,iBAAiB,eAAe,gBAAgB;AACtD,QAAM,WAAW,CAAC,CAAC;AAEnB,UAAQ,QAAQ;AAAA,IACZ,KAAK,OAAO;AACR,UAAI,kBAAkB,UAAU;AAC5B,eAAO,GAAG,WAAW,KAAK,KAAK;AAAA,MACnC,WAAW,gBAAgB;AACvB,eAAO;AAAA,MACX,WAAW,UAAU;AACjB,eAAO;AAAA,MACX;AACA;AAAA,IACJ;AAAA,IACA,KAAK,UAAU;AACX,UAAI,gBAAgB;AAChB,eAAO;AAAA,MACX,WAAW,UAAU;AACjB,eAAO;AAAA,MACX;AACA;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO;AACX;AAEO,SAAS,cAAc,SAAmB;AAC7C,SAAO,QAAQ,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG;AAC9C;AAEO,SAAS,MAAM,YAAoB;AACtC,SAAO,OAAO,QAAQ,UAAU,EAAE;AAAA,IAC9B,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACnB,UAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY;AAC1D,YAAI,GAAG,IAAI;AAAA,MACf;AAEA,aAAO;AAAA,IACX;AAAA,IACA,CAAC;AAAA,EACL;AACJ","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 placeholder?: string,\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 placeholder\n ? [\n {\n label: placeholder,\n value: '',\n disabled: true,\n selected: true,\n },\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.4",
3
+ "version": "1.0.5",
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,8 +14,8 @@
14
14
  "dist"
15
15
  ],
16
16
  "devDependencies": {
17
- "@telia-ace/alliance-internal-node-utilities": "1.0.4",
18
- "tsup": "^7.2.0"
17
+ "tsup": "^7.2.0",
18
+ "@telia-ace/alliance-internal-node-utilities": "^1.0.5"
19
19
  },
20
20
  "publishConfig": {
21
21
  "access": "public"