@telia-ace/alliance-utilities 1.0.10 → 1.0.11-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,979 @@
1
+ /*! js-cookie v3.0.5 | MIT */
2
+ function A(e) {
3
+ for (var t = 1; t < arguments.length; t++) {
4
+ var r = arguments[t];
5
+ for (var a in r)
6
+ e[a] = r[a];
7
+ }
8
+ return e;
9
+ }
10
+ var H = {
11
+ read: function(e) {
12
+ return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
13
+ },
14
+ write: function(e) {
15
+ return encodeURIComponent(e).replace(
16
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
17
+ decodeURIComponent
18
+ );
19
+ }
20
+ };
21
+ function P(e, t) {
22
+ function r(i, d, p) {
23
+ if (!(typeof document > "u")) {
24
+ p = A({}, t, p), typeof p.expires == "number" && (p.expires = new Date(Date.now() + p.expires * 864e5)), p.expires && (p.expires = p.expires.toUTCString()), i = encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
25
+ var l = "";
26
+ for (var c in p)
27
+ p[c] && (l += "; " + c, p[c] !== !0 && (l += "=" + p[c].split(";")[0]));
28
+ return document.cookie = i + "=" + e.write(d, i) + l;
29
+ }
30
+ }
31
+ function a(i) {
32
+ if (!(typeof document > "u" || arguments.length && !i)) {
33
+ for (var d = document.cookie ? document.cookie.split("; ") : [], p = {}, l = 0; l < d.length; l++) {
34
+ var c = d[l].split("="), u = c.slice(1).join("=");
35
+ try {
36
+ var o = decodeURIComponent(c[0]);
37
+ if (p[o] = e.read(u, o), i === o)
38
+ break;
39
+ } catch {
40
+ }
41
+ }
42
+ return i ? p[i] : p;
43
+ }
44
+ }
45
+ return Object.create(
46
+ {
47
+ set: r,
48
+ get: a,
49
+ remove: function(i, d) {
50
+ r(
51
+ i,
52
+ "",
53
+ A({}, d, {
54
+ expires: -1
55
+ })
56
+ );
57
+ },
58
+ withAttributes: function(i) {
59
+ return P(this.converter, A({}, this.attributes, i));
60
+ },
61
+ withConverter: function(i) {
62
+ return P(A({}, this.converter, i), this.attributes);
63
+ }
64
+ },
65
+ {
66
+ attributes: { value: Object.freeze(t) },
67
+ converter: { value: Object.freeze(e) }
68
+ }
69
+ );
70
+ }
71
+ var ee = P(H, { path: "/" }), re = Object.defineProperty, te = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, F = (e, t, r) => (te(e, typeof t != "symbol" ? t + "" : t, r), r), R = /* @__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))(R || {});
72
+ function oe(e, t) {
73
+ return Object.entries(t).reduce((r, [a, i]) => r.replaceAll(`{{${a}}}`, i), e);
74
+ }
75
+ const ne = {
76
+ // framework
77
+ [
78
+ 1e3
79
+ /* AlreadyInitialized */
80
+ ]: "The runtime has already been initialized",
81
+ [
82
+ 1001
83
+ /* NoAppNameOrKey */
84
+ ]: "App name and/or app key is not defined on global scope",
85
+ [
86
+ 1002
87
+ /* MissingAppController */
88
+ ]: "No app controller registered for app '{{app}}'",
89
+ [
90
+ 1003
91
+ /* MissingCapabilityOnApp */
92
+ ]: "No capability '{{capability}}' enabled for app '{{app}}'",
93
+ [
94
+ 1004
95
+ /* MissingManagedObjectProvider */
96
+ ]: "No managed object provider registered for object '{{object}}'",
97
+ [
98
+ 1005
99
+ /* NoManifest */
100
+ ]: "The current apps manifest is not defined on global scope",
101
+ [
102
+ 1006
103
+ /* NoRootElement */
104
+ ]: "Could not find the root element in the DOM",
105
+ [
106
+ 1007
107
+ /* NoView */
108
+ ]: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
109
+ [
110
+ 1008
111
+ /* CookieKeyNotDefined */
112
+ ]: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
113
+ [
114
+ 1009
115
+ /* CookieCategoryNotAllowed */
116
+ ]: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
117
+ [
118
+ 1010
119
+ /* StorageKeyNotDefined */
120
+ ]: "Storage key '{{key}}' not present in manifest, item has not been stored",
121
+ [
122
+ 1011
123
+ /* StorageCategoryNotAllowed */
124
+ ]: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
125
+ // utilities
126
+ [
127
+ 2e3
128
+ /* CurrentUserMissingProvider */
129
+ ]: "No managed object provider registered for object 'currentUser'",
130
+ [
131
+ 2001
132
+ /* CurrentUserGatewayNotStarted */
133
+ ]: "Could not access the gateway when querying 'currentUser'",
134
+ [
135
+ 2002
136
+ /* CurrentUserMissingBackend */
137
+ ]: "Could not access the required backend when querying 'currentUser'",
138
+ [
139
+ 2003
140
+ /* CurrentUserMissingInDatabase */
141
+ ]: "Could not locate the authenticated user in the Alliance database"
142
+ }, ae = "AllianceError";
143
+ class ie extends Error {
144
+ constructor(t, r = {}) {
145
+ const a = oe(ne[t], r), i = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${t}`;
146
+ super(a), this.code = t, this.name = ae, this.stack = `[${t}] - ${a}
147
+ ` + i;
148
+ }
149
+ }
150
+ var z = /* @__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))(z || {});
151
+ const se = {
152
+ [
153
+ 15
154
+ /* Done */
155
+ ]: "Done",
156
+ [
157
+ 22
158
+ /* NoWorkspaceName */
159
+ ]: "No workspace name provided!",
160
+ [
161
+ 19
162
+ /* NoAppName */
163
+ ]: "No app name provided!",
164
+ [
165
+ 0
166
+ /* AlreadyExists */
167
+ ]: "File or directory '{0}' already exists!",
168
+ [
169
+ 21
170
+ /* NoAppOrWorkspaceInCurrentDirectory */
171
+ ]: "Could not find any app entry file at '{0}'!",
172
+ [
173
+ 33
174
+ /* UnrecognizedCommand */
175
+ ]: "Unrecognized command(s) {0}!",
176
+ [
177
+ 34
178
+ /* WorkspaceCreated */
179
+ ]: "Workspace was created at path '{0}'!",
180
+ [
181
+ 4
182
+ /* AppCreated */
183
+ ]: "App was created at path '{0}'!",
184
+ [
185
+ 25
186
+ /* ServedStopped */
187
+ ]: "Server stopped.",
188
+ [
189
+ 11
190
+ /* CreateWorkspaceDescription */
191
+ ]: "Creates an Alliance Workspace in the current directory.",
192
+ [
193
+ 10
194
+ /* CreateAppDescription */
195
+ ]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
196
+ [
197
+ 24
198
+ /* ServeDescription */
199
+ ]: "Starts a Alliance development server using the current directory package.json.",
200
+ [
201
+ 7
202
+ /* BuildDescription */
203
+ ]: "Builds an Alliance Application using Vite.",
204
+ [
205
+ 35
206
+ /* WorkspaceNameInquiry */
207
+ ]: "Enter the name of your workspace",
208
+ [
209
+ 28
210
+ /* ServerModeInquiry */
211
+ ]: "Which server mode do you want to use?",
212
+ [
213
+ 6
214
+ /* AppNameInquiry */
215
+ ]: "Enter the name of your app",
216
+ [
217
+ 18
218
+ /* MissingTranslationKey */
219
+ ]: "No translation key provided!",
220
+ [
221
+ 23
222
+ /* OperationCancelled */
223
+ ]: "Operation cancelled.",
224
+ [
225
+ 30
226
+ /* StopServerInstructions */
227
+ ]: `Press CTRL + C to stop the server.
228
+ `,
229
+ [
230
+ 32
231
+ /* TemplateLanguageInquiry */
232
+ ]: "Select preferred language",
233
+ [
234
+ 31
235
+ /* TemplateFrameworkInquiry */
236
+ ]: "Select preferred framework template",
237
+ [
238
+ 13
239
+ /* DevServerPortDescription */
240
+ ]: "The port that the dev server should use.",
241
+ [
242
+ 14
243
+ /* DevServerLoggingDescription */
244
+ ]: "Whether the dev server and browser console should output more log information or not (false).",
245
+ [
246
+ 1
247
+ /* ApiGatewayPortDescription */
248
+ ]: "The port that the api gateway should use.",
249
+ [
250
+ 2
251
+ /* ApiServerModeDescription */
252
+ ]: "Which components to start. [server|server-proxy|server-gateway].",
253
+ [
254
+ 12
255
+ /* DevServerOpenDescription */
256
+ ]: "Whether the dev server should automatically open in your browser or not.",
257
+ [
258
+ 9
259
+ /* BuildWatchDescription */
260
+ ]: "Whether the build should start watching and rebuild when files change or not.",
261
+ [
262
+ 5
263
+ /* AppEntryBuildOptionDescription */
264
+ ]: "The entry file for the app (./src/app).",
265
+ [
266
+ 17
267
+ /* ManifestEntryBuildOptionDescription */
268
+ ]: "The entry file for the app manifest (./src/manifest).",
269
+ [
270
+ 8
271
+ /* BuildModeOptionDescription */
272
+ ]: "Which mode to use when building the app.",
273
+ [
274
+ 16
275
+ /* FetchPackageVersionError */
276
+ ]: "Failed to fetch package info from the NPM registry for package '${0}'!",
277
+ [
278
+ 20
279
+ /* NoAppNameFound */
280
+ ]: "Could not find app name in manifest.",
281
+ [
282
+ 3
283
+ /* AppConfigurationPath */
284
+ ]: "The path to the app configuration file.",
285
+ [
286
+ 27
287
+ /* ServerMode */
288
+ ]: "Server",
289
+ [
290
+ 29
291
+ /* ServerProxyMode */
292
+ ]: "Server with proxy",
293
+ [
294
+ 26
295
+ /* ServerGatewayMode */
296
+ ]: "Server with gateway"
297
+ }, j = class {
298
+ };
299
+ let M = j;
300
+ F(M, "getTranslations", () => se), F(M, "getTranslation", (e, ...t) => {
301
+ const r = j.getTranslations()[e];
302
+ if (!r)
303
+ throw new Error(`Could not find text with given key '${e}'.`);
304
+ return t.reduce(
305
+ (a, i, d) => a.toString().replace(`{${d}}`, i.toString()),
306
+ r
307
+ ).toString();
308
+ }), F(M, "get", (e = z.MissingTranslationKey, ...t) => j.getTranslation(e, ...t));
309
+ function ce(e) {
310
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
311
+ }
312
+ var x = { exports: {} }, I, B;
313
+ function pe() {
314
+ if (B)
315
+ return I;
316
+ B = 1;
317
+ var e = 1e3, t = e * 60, r = t * 60, a = r * 24, i = a * 7, d = a * 365.25;
318
+ I = function(o, n) {
319
+ n = n || {};
320
+ var s = typeof o;
321
+ if (s === "string" && o.length > 0)
322
+ return p(o);
323
+ if (s === "number" && isFinite(o))
324
+ return n.long ? c(o) : l(o);
325
+ throw new Error(
326
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(o)
327
+ );
328
+ };
329
+ function p(o) {
330
+ if (o = String(o), !(o.length > 100)) {
331
+ var n = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
332
+ o
333
+ );
334
+ if (n) {
335
+ var s = parseFloat(n[1]), C = (n[2] || "ms").toLowerCase();
336
+ switch (C) {
337
+ case "years":
338
+ case "year":
339
+ case "yrs":
340
+ case "yr":
341
+ case "y":
342
+ return s * d;
343
+ case "weeks":
344
+ case "week":
345
+ case "w":
346
+ return s * i;
347
+ case "days":
348
+ case "day":
349
+ case "d":
350
+ return s * a;
351
+ case "hours":
352
+ case "hour":
353
+ case "hrs":
354
+ case "hr":
355
+ case "h":
356
+ return s * r;
357
+ case "minutes":
358
+ case "minute":
359
+ case "mins":
360
+ case "min":
361
+ case "m":
362
+ return s * t;
363
+ case "seconds":
364
+ case "second":
365
+ case "secs":
366
+ case "sec":
367
+ case "s":
368
+ return s * e;
369
+ case "milliseconds":
370
+ case "millisecond":
371
+ case "msecs":
372
+ case "msec":
373
+ case "ms":
374
+ return s;
375
+ default:
376
+ return;
377
+ }
378
+ }
379
+ }
380
+ }
381
+ function l(o) {
382
+ var n = Math.abs(o);
383
+ return n >= a ? Math.round(o / a) + "d" : n >= r ? Math.round(o / r) + "h" : n >= t ? Math.round(o / t) + "m" : n >= e ? Math.round(o / e) + "s" : o + "ms";
384
+ }
385
+ function c(o) {
386
+ var n = Math.abs(o);
387
+ return n >= a ? u(o, n, a, "day") : n >= r ? u(o, n, r, "hour") : n >= t ? u(o, n, t, "minute") : n >= e ? u(o, n, e, "second") : o + " ms";
388
+ }
389
+ function u(o, n, s, C) {
390
+ var v = n >= s * 1.5;
391
+ return Math.round(o / s) + " " + C + (v ? "s" : "");
392
+ }
393
+ return I;
394
+ }
395
+ function de(e) {
396
+ r.debug = r, r.default = r, r.coerce = c, r.disable = d, r.enable = i, r.enabled = p, r.humanize = pe(), r.destroy = u, Object.keys(e).forEach((o) => {
397
+ r[o] = e[o];
398
+ }), r.names = [], r.skips = [], r.formatters = {};
399
+ function t(o) {
400
+ let n = 0;
401
+ for (let s = 0; s < o.length; s++)
402
+ n = (n << 5) - n + o.charCodeAt(s), n |= 0;
403
+ return r.colors[Math.abs(n) % r.colors.length];
404
+ }
405
+ r.selectColor = t;
406
+ function r(o) {
407
+ let n, s = null, C, v;
408
+ function h(...g) {
409
+ if (!h.enabled)
410
+ return;
411
+ const y = h, w = Number(/* @__PURE__ */ new Date()), Q = w - (n || w);
412
+ y.diff = Q, y.prev = n, y.curr = w, n = w, g[0] = r.coerce(g[0]), typeof g[0] != "string" && g.unshift("%O");
413
+ let b = 0;
414
+ g[0] = g[0].replace(/%([a-zA-Z%])/g, (D, Y) => {
415
+ if (D === "%%")
416
+ return "%";
417
+ b++;
418
+ const U = r.formatters[Y];
419
+ if (typeof U == "function") {
420
+ const X = g[b];
421
+ D = U.call(y, X), g.splice(b, 1), b--;
422
+ }
423
+ return D;
424
+ }), r.formatArgs.call(y, g), (y.log || r.log).apply(y, g);
425
+ }
426
+ return h.namespace = o, h.useColors = r.useColors(), h.color = r.selectColor(o), h.extend = a, h.destroy = r.destroy, Object.defineProperty(h, "enabled", {
427
+ enumerable: !0,
428
+ configurable: !1,
429
+ get: () => s !== null ? s : (C !== r.namespaces && (C = r.namespaces, v = r.enabled(o)), v),
430
+ set: (g) => {
431
+ s = g;
432
+ }
433
+ }), typeof r.init == "function" && r.init(h), h;
434
+ }
435
+ function a(o, n) {
436
+ const s = r(this.namespace + (typeof n > "u" ? ":" : n) + o);
437
+ return s.log = this.log, s;
438
+ }
439
+ function i(o) {
440
+ r.save(o), r.namespaces = o, r.names = [], r.skips = [];
441
+ let n;
442
+ const s = (typeof o == "string" ? o : "").split(/[\s,]+/), C = s.length;
443
+ for (n = 0; n < C; n++)
444
+ s[n] && (o = s[n].replace(/\*/g, ".*?"), o[0] === "-" ? r.skips.push(new RegExp("^" + o.slice(1) + "$")) : r.names.push(new RegExp("^" + o + "$")));
445
+ }
446
+ function d() {
447
+ const o = [
448
+ ...r.names.map(l),
449
+ ...r.skips.map(l).map((n) => "-" + n)
450
+ ].join(",");
451
+ return r.enable(""), o;
452
+ }
453
+ function p(o) {
454
+ if (o[o.length - 1] === "*")
455
+ return !0;
456
+ let n, s;
457
+ for (n = 0, s = r.skips.length; n < s; n++)
458
+ if (r.skips[n].test(o))
459
+ return !1;
460
+ for (n = 0, s = r.names.length; n < s; n++)
461
+ if (r.names[n].test(o))
462
+ return !0;
463
+ return !1;
464
+ }
465
+ function l(o) {
466
+ return o.toString().substring(2, o.toString().length - 2).replace(/\.\*\?$/, "*");
467
+ }
468
+ function c(o) {
469
+ return o instanceof Error ? o.stack || o.message : o;
470
+ }
471
+ function u() {
472
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
473
+ }
474
+ return r.enable(r.load()), r;
475
+ }
476
+ var le = de;
477
+ (function(e, t) {
478
+ t.formatArgs = a, t.save = i, t.load = d, t.useColors = r, t.storage = p(), t.destroy = (() => {
479
+ let c = !1;
480
+ return () => {
481
+ c || (c = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
482
+ };
483
+ })(), t.colors = [
484
+ "#0000CC",
485
+ "#0000FF",
486
+ "#0033CC",
487
+ "#0033FF",
488
+ "#0066CC",
489
+ "#0066FF",
490
+ "#0099CC",
491
+ "#0099FF",
492
+ "#00CC00",
493
+ "#00CC33",
494
+ "#00CC66",
495
+ "#00CC99",
496
+ "#00CCCC",
497
+ "#00CCFF",
498
+ "#3300CC",
499
+ "#3300FF",
500
+ "#3333CC",
501
+ "#3333FF",
502
+ "#3366CC",
503
+ "#3366FF",
504
+ "#3399CC",
505
+ "#3399FF",
506
+ "#33CC00",
507
+ "#33CC33",
508
+ "#33CC66",
509
+ "#33CC99",
510
+ "#33CCCC",
511
+ "#33CCFF",
512
+ "#6600CC",
513
+ "#6600FF",
514
+ "#6633CC",
515
+ "#6633FF",
516
+ "#66CC00",
517
+ "#66CC33",
518
+ "#9900CC",
519
+ "#9900FF",
520
+ "#9933CC",
521
+ "#9933FF",
522
+ "#99CC00",
523
+ "#99CC33",
524
+ "#CC0000",
525
+ "#CC0033",
526
+ "#CC0066",
527
+ "#CC0099",
528
+ "#CC00CC",
529
+ "#CC00FF",
530
+ "#CC3300",
531
+ "#CC3333",
532
+ "#CC3366",
533
+ "#CC3399",
534
+ "#CC33CC",
535
+ "#CC33FF",
536
+ "#CC6600",
537
+ "#CC6633",
538
+ "#CC9900",
539
+ "#CC9933",
540
+ "#CCCC00",
541
+ "#CCCC33",
542
+ "#FF0000",
543
+ "#FF0033",
544
+ "#FF0066",
545
+ "#FF0099",
546
+ "#FF00CC",
547
+ "#FF00FF",
548
+ "#FF3300",
549
+ "#FF3333",
550
+ "#FF3366",
551
+ "#FF3399",
552
+ "#FF33CC",
553
+ "#FF33FF",
554
+ "#FF6600",
555
+ "#FF6633",
556
+ "#FF9900",
557
+ "#FF9933",
558
+ "#FFCC00",
559
+ "#FFCC33"
560
+ ];
561
+ function r() {
562
+ return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
563
+ typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
564
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
565
+ typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
566
+ typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
567
+ }
568
+ function a(c) {
569
+ if (c[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + c[0] + (this.useColors ? "%c " : " ") + "+" + e.exports.humanize(this.diff), !this.useColors)
570
+ return;
571
+ const u = "color: " + this.color;
572
+ c.splice(1, 0, u, "color: inherit");
573
+ let o = 0, n = 0;
574
+ c[0].replace(/%[a-zA-Z%]/g, (s) => {
575
+ s !== "%%" && (o++, s === "%c" && (n = o));
576
+ }), c.splice(n, 0, u);
577
+ }
578
+ t.log = console.debug || console.log || (() => {
579
+ });
580
+ function i(c) {
581
+ try {
582
+ c ? t.storage.setItem("debug", c) : t.storage.removeItem("debug");
583
+ } catch {
584
+ }
585
+ }
586
+ function d() {
587
+ let c;
588
+ try {
589
+ c = t.storage.getItem("debug");
590
+ } catch {
591
+ }
592
+ return !c && typeof process < "u" && "env" in process && (c = process.env.DEBUG), c;
593
+ }
594
+ function p() {
595
+ try {
596
+ return localStorage;
597
+ } catch {
598
+ }
599
+ }
600
+ e.exports = le(t);
601
+ const { formatters: l } = e.exports;
602
+ l.j = function(c) {
603
+ try {
604
+ return JSON.stringify(c);
605
+ } catch (u) {
606
+ return "[UnexpectedJSONParseError]: " + u.message;
607
+ }
608
+ };
609
+ })(x, x.exports);
610
+ var ue = x.exports;
611
+ const ge = /* @__PURE__ */ ce(ue);
612
+ function he() {
613
+ try {
614
+ return ALLIANCE_APP_NAME;
615
+ } catch {
616
+ }
617
+ }
618
+ function Ce() {
619
+ const e = {
620
+ environment: "production",
621
+ logging: !1
622
+ };
623
+ try {
624
+ return ALLIANCE_ENVIRONMENT || e;
625
+ } catch {
626
+ return e;
627
+ }
628
+ }
629
+ function K() {
630
+ if ($())
631
+ return Promise.resolve();
632
+ const e = 2e4, t = 5;
633
+ return new Promise((r, a) => {
634
+ const i = () => {
635
+ clearInterval(p), clearTimeout(d);
636
+ }, d = setTimeout(() => {
637
+ i(), a(new Error(`Runtime not initialized after ${e}ms`));
638
+ }, e), p = setInterval(() => {
639
+ $() && (i(), r());
640
+ }, t);
641
+ });
642
+ }
643
+ function $() {
644
+ return S(
645
+ "RUNTIME_INITIALIZED"
646
+ /* RuntimeInitialized */
647
+ );
648
+ }
649
+ function S(e = "") {
650
+ return globalThis[ye(e)];
651
+ }
652
+ function ye(e) {
653
+ return `__ALLIANCE_${e}`;
654
+ }
655
+ function me(e) {
656
+ return `APP_CONTROLLER_KEY_${e}`;
657
+ }
658
+ var _ = /* @__PURE__ */ ((e) => (e.RuntimeInitialized = "RUNTIME_INITIALIZED", e.RuntimeApps = "RUNTIME_APPS", e.RuntimeManifests = "RUNTIME_MANIFESTS", e))(_ || {});
659
+ function fe(e) {
660
+ return {
661
+ capabilities: "#25BCDD",
662
+ "managed-objects": "#FC7A12",
663
+ controller: "#F635C6",
664
+ proxy: "#48E70B",
665
+ views: "#F6D72E",
666
+ system: "#D52C2E"
667
+ }[e];
668
+ }
669
+ const q = /* @__PURE__ */ new Map();
670
+ function m(e) {
671
+ let t = q.get(e);
672
+ return t || (t = ge(e === "system" ? "[system]" : `[${he()}] ${e}`), t.color = fe(e), t.enabled = ve(), q.set(e, t), t);
673
+ }
674
+ function ve() {
675
+ const e = Ce(), t = ee.get("logging");
676
+ return e.environment === "development" && !!e.logging || t === "true";
677
+ }
678
+ m("system");
679
+ m("views");
680
+ m("controller");
681
+ async function we(e) {
682
+ await K();
683
+ const t = me(e), r = S(t);
684
+ if (!r)
685
+ return;
686
+ const a = S(r);
687
+ if (a)
688
+ return a;
689
+ }
690
+ async function be() {
691
+ return await K(), (await Promise.all(
692
+ S(_.RuntimeApps).map((e) => we(e))
693
+ )).filter((e) => !!e);
694
+ }
695
+ m("capabilities");
696
+ const O = m("managed-objects");
697
+ function Ae(e, t) {
698
+ return O("querying objects - object: %o, args: %O", e, t), {
699
+ async resolve() {
700
+ return O("resolving query - object: %o, args: %O", e, t), await (await L(e)).managedObjects.providers.get(e)(t);
701
+ },
702
+ async watch(r) {
703
+ O("adding watcher - object: %o, args: %O", e, t), (await L(e)).managedObjects.watchers.get(e).push(r);
704
+ }
705
+ };
706
+ }
707
+ async function L(e) {
708
+ const t = (await be()).find(
709
+ (r) => r.managedObjects.providers.has(e) && r.managedObjects.watchers.has(e)
710
+ );
711
+ if (!t)
712
+ throw new ie(R.MissingManagedObjectProvider, { object: e });
713
+ return t;
714
+ }
715
+ m("proxy");
716
+ var Ne = Object.defineProperty, ke = (e, t, r) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, E = (e, t, r) => (ke(e, typeof t != "symbol" ? t + "" : t, r), r), G = /* @__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))(G || {}), f = /* @__PURE__ */ ((e) => (e[e.CurrentUserMissingProvider = 2e3] = "CurrentUserMissingProvider", e[e.CurrentUserGatewayNotStarted = 2001] = "CurrentUserGatewayNotStarted", e[e.CurrentUserMissingBackend = 2002] = "CurrentUserMissingBackend", e[e.CurrentUserMissingInDatabase = 2003] = "CurrentUserMissingInDatabase", e))(f || {});
717
+ function Se(e, t) {
718
+ return Object.entries(t).reduce((r, [a, i]) => r.replaceAll(`{{${a}}}`, i), e);
719
+ }
720
+ const De = {
721
+ // framework
722
+ [
723
+ 1e3
724
+ /* AlreadyInitialized */
725
+ ]: "The runtime has already been initialized",
726
+ [
727
+ 1001
728
+ /* NoAppNameOrKey */
729
+ ]: "App name and/or app key is not defined on global scope",
730
+ [
731
+ 1002
732
+ /* MissingAppController */
733
+ ]: "No app controller registered for app '{{app}}'",
734
+ [
735
+ 1003
736
+ /* MissingCapabilityOnApp */
737
+ ]: "No capability '{{capability}}' enabled for app '{{app}}'",
738
+ [
739
+ 1004
740
+ /* MissingManagedObjectProvider */
741
+ ]: "No managed object provider registered for object '{{object}}'",
742
+ [
743
+ 1005
744
+ /* NoManifest */
745
+ ]: "The current apps manifest is not defined on global scope",
746
+ [
747
+ 1006
748
+ /* NoRootElement */
749
+ ]: "Could not find the root element in the DOM",
750
+ [
751
+ 1007
752
+ /* NoView */
753
+ ]: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
754
+ [
755
+ 1008
756
+ /* CookieKeyNotDefined */
757
+ ]: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
758
+ [
759
+ 1009
760
+ /* CookieCategoryNotAllowed */
761
+ ]: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
762
+ [
763
+ 1010
764
+ /* StorageKeyNotDefined */
765
+ ]: "Storage key '{{key}}' not present in manifest, item has not been stored",
766
+ [
767
+ 1011
768
+ /* StorageCategoryNotAllowed */
769
+ ]: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
770
+ // utilities
771
+ [
772
+ 2e3
773
+ /* CurrentUserMissingProvider */
774
+ ]: "No managed object provider registered for object 'currentUser'",
775
+ [
776
+ 2001
777
+ /* CurrentUserGatewayNotStarted */
778
+ ]: "Could not access the gateway when querying 'currentUser'",
779
+ [
780
+ 2002
781
+ /* CurrentUserMissingBackend */
782
+ ]: "Could not access the required backend when querying 'currentUser'",
783
+ [
784
+ 2003
785
+ /* CurrentUserMissingInDatabase */
786
+ ]: "Could not locate the authenticated user in the Alliance database"
787
+ }, V = "AllianceError";
788
+ class N extends Error {
789
+ constructor(t, r = {}) {
790
+ const a = Se(De[t], r), i = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${t}`;
791
+ super(a), this.code = t, this.name = V, this.stack = `[${t}] - ${a}
792
+ ` + i;
793
+ }
794
+ }
795
+ function Fe(e) {
796
+ return !!e.code && e.name === V;
797
+ }
798
+ var Z = /* @__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))(Z || {});
799
+ const Me = {
800
+ [
801
+ 15
802
+ /* Done */
803
+ ]: "Done",
804
+ [
805
+ 22
806
+ /* NoWorkspaceName */
807
+ ]: "No workspace name provided!",
808
+ [
809
+ 19
810
+ /* NoAppName */
811
+ ]: "No app name provided!",
812
+ [
813
+ 0
814
+ /* AlreadyExists */
815
+ ]: "File or directory '{0}' already exists!",
816
+ [
817
+ 21
818
+ /* NoAppOrWorkspaceInCurrentDirectory */
819
+ ]: "Could not find any app entry file at '{0}'!",
820
+ [
821
+ 33
822
+ /* UnrecognizedCommand */
823
+ ]: "Unrecognized command(s) {0}!",
824
+ [
825
+ 34
826
+ /* WorkspaceCreated */
827
+ ]: "Workspace was created at path '{0}'!",
828
+ [
829
+ 4
830
+ /* AppCreated */
831
+ ]: "App was created at path '{0}'!",
832
+ [
833
+ 25
834
+ /* ServedStopped */
835
+ ]: "Server stopped.",
836
+ [
837
+ 11
838
+ /* CreateWorkspaceDescription */
839
+ ]: "Creates an Alliance Workspace in the current directory.",
840
+ [
841
+ 10
842
+ /* CreateAppDescription */
843
+ ]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
844
+ [
845
+ 24
846
+ /* ServeDescription */
847
+ ]: "Starts a Alliance development server using the current directory package.json.",
848
+ [
849
+ 7
850
+ /* BuildDescription */
851
+ ]: "Builds an Alliance Application using Vite.",
852
+ [
853
+ 35
854
+ /* WorkspaceNameInquiry */
855
+ ]: "Enter the name of your workspace",
856
+ [
857
+ 28
858
+ /* ServerModeInquiry */
859
+ ]: "Which server mode do you want to use?",
860
+ [
861
+ 6
862
+ /* AppNameInquiry */
863
+ ]: "Enter the name of your app",
864
+ [
865
+ 18
866
+ /* MissingTranslationKey */
867
+ ]: "No translation key provided!",
868
+ [
869
+ 23
870
+ /* OperationCancelled */
871
+ ]: "Operation cancelled.",
872
+ [
873
+ 30
874
+ /* StopServerInstructions */
875
+ ]: `Press CTRL + C to stop the server.
876
+ `,
877
+ [
878
+ 32
879
+ /* TemplateLanguageInquiry */
880
+ ]: "Select preferred language",
881
+ [
882
+ 31
883
+ /* TemplateFrameworkInquiry */
884
+ ]: "Select preferred framework template",
885
+ [
886
+ 13
887
+ /* DevServerPortDescription */
888
+ ]: "The port that the dev server should use.",
889
+ [
890
+ 14
891
+ /* DevServerLoggingDescription */
892
+ ]: "Whether the dev server and browser console should output more log information or not (false).",
893
+ [
894
+ 1
895
+ /* ApiGatewayPortDescription */
896
+ ]: "The port that the api gateway should use.",
897
+ [
898
+ 2
899
+ /* ApiServerModeDescription */
900
+ ]: "Which components to start. [server|server-proxy|server-gateway].",
901
+ [
902
+ 12
903
+ /* DevServerOpenDescription */
904
+ ]: "Whether the dev server should automatically open in your browser or not.",
905
+ [
906
+ 9
907
+ /* BuildWatchDescription */
908
+ ]: "Whether the build should start watching and rebuild when files change or not.",
909
+ [
910
+ 5
911
+ /* AppEntryBuildOptionDescription */
912
+ ]: "The entry file for the app (./src/app).",
913
+ [
914
+ 17
915
+ /* ManifestEntryBuildOptionDescription */
916
+ ]: "The entry file for the app manifest (./src/manifest).",
917
+ [
918
+ 8
919
+ /* BuildModeOptionDescription */
920
+ ]: "Which mode to use when building the app.",
921
+ [
922
+ 16
923
+ /* FetchPackageVersionError */
924
+ ]: "Failed to fetch package info from the NPM registry for package '${0}'!",
925
+ [
926
+ 20
927
+ /* NoAppNameFound */
928
+ ]: "Could not find app name in manifest.",
929
+ [
930
+ 3
931
+ /* AppConfigurationPath */
932
+ ]: "The path to the app configuration file.",
933
+ [
934
+ 27
935
+ /* ServerMode */
936
+ ]: "Server",
937
+ [
938
+ 29
939
+ /* ServerProxyMode */
940
+ ]: "Server with proxy",
941
+ [
942
+ 26
943
+ /* ServerGatewayMode */
944
+ ]: "Server with gateway"
945
+ }, W = class {
946
+ };
947
+ let T = W;
948
+ E(T, "getTranslations", () => Me), E(T, "getTranslation", (e, ...t) => {
949
+ const r = W.getTranslations()[e];
950
+ if (!r)
951
+ throw new Error(`Could not find text with given key '${e}'.`);
952
+ return t.reduce(
953
+ (a, i, d) => a.toString().replace(`{${d}}`, i.toString()),
954
+ r
955
+ ).toString();
956
+ }), E(T, "get", (e = Z.MissingTranslationKey, ...t) => W.getTranslation(e, ...t));
957
+ let k;
958
+ async function J() {
959
+ try {
960
+ return k || (k = await Ae("currentUser").resolve(), k);
961
+ } catch (e) {
962
+ throw Fe(e) && e.code === G.MissingManagedObjectProvider ? new N(f.CurrentUserMissingProvider) : e.message.includes("GraphQL Error (Code: 404)") ? new N(f.CurrentUserGatewayNotStarted) : e.message.includes("GraphQL Error (Code: 500)") ? new N(f.CurrentUserMissingBackend) : e.message.includes("GraphQL Error (Code: 200)") && e.message.includes("Cannot return null for non-nullable field") ? new N(f.CurrentUserMissingInDatabase) : e;
963
+ }
964
+ }
965
+ async function Ie() {
966
+ const e = await J();
967
+ return !!e && e.type === "super-admin";
968
+ }
969
+ async function Oe(e, t) {
970
+ const r = await J();
971
+ return !!(r != null && r.permissions.find(
972
+ ({ permission: a }) => a.app.name === e && a.name === t
973
+ ));
974
+ }
975
+ export {
976
+ Oe as hasPermission,
977
+ Ie as isSystemAdmin
978
+ };
979
+ //# sourceMappingURL=index.js.map