@telia-ace/alliance-internal-client-utilities 1.0.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE.txt +9 -0
- package/README.md +3 -0
- package/dist/exceptions.d.ts +27 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +353 -0
- package/dist/index.js.map +1 -0
- package/dist/routing.d.ts +8 -0
- package/dist/texts.d.ts +8 -0
- package/dist/translations.d.ts +42 -0
- package/dist/types.d.ts +6 -0
- package/dist/ui.d.ts +31 -0
- package/package.json +29 -0
package/CHANGELOG.md
ADDED
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(c) Copyright Telia Company AB 2023
|
|
2
|
+
|
|
3
|
+
This software may be used and/or copied only with the written
|
|
4
|
+
permission from Telia Company AB, or in accordance with
|
|
5
|
+
the terms and conditions stipulated in the agreement/contract
|
|
6
|
+
under which the software has been supplied.
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Software packages under the scopes @telia-ace, @webprovisions and @webprovisions-registry are also subjected to the above statement.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
15
|
+
export declare enum UtilitiesErrorCodes {
|
|
16
|
+
CurrentUserMissingProvider = 2000,
|
|
17
|
+
CurrentUserGatewayNotStarted = 2001,
|
|
18
|
+
CurrentUserMissingBackend = 2002,
|
|
19
|
+
CurrentUserMissingInDatabase = 2003
|
|
20
|
+
}
|
|
21
|
+
type ErrorCodes = UtilitiesErrorCodes | FrameworkErrorCodes;
|
|
22
|
+
export declare class AllianceError extends Error {
|
|
23
|
+
code: ErrorCodes;
|
|
24
|
+
constructor(code: ErrorCodes, variables?: Record<string, string>);
|
|
25
|
+
}
|
|
26
|
+
export declare function isAllianceError(error: any): error is AllianceError;
|
|
27
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var v = (e, t, r) => t in e ? f(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))(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);
|
|
7
|
+
}
|
|
8
|
+
const S = {
|
|
9
|
+
// framework
|
|
10
|
+
[
|
|
11
|
+
1e3
|
|
12
|
+
/* AlreadyInitialized */
|
|
13
|
+
]: "The runtime has already been initialized",
|
|
14
|
+
[
|
|
15
|
+
1001
|
|
16
|
+
/* NoAppNameOrKey */
|
|
17
|
+
]: "App name and/or app key is not defined on global scope",
|
|
18
|
+
[
|
|
19
|
+
1002
|
|
20
|
+
/* MissingAppController */
|
|
21
|
+
]: "No app controller registered for app '{{app}}'",
|
|
22
|
+
[
|
|
23
|
+
1003
|
|
24
|
+
/* MissingCapabilityOnApp */
|
|
25
|
+
]: "No capability '{{capability}}' enabled for app '{{app}}'",
|
|
26
|
+
[
|
|
27
|
+
1004
|
|
28
|
+
/* MissingManagedObjectProvider */
|
|
29
|
+
]: "No managed object provider registered for object '{{object}}'",
|
|
30
|
+
[
|
|
31
|
+
1005
|
|
32
|
+
/* NoManifest */
|
|
33
|
+
]: "The current apps manifest is not defined on global scope",
|
|
34
|
+
[
|
|
35
|
+
1006
|
|
36
|
+
/* NoRootElement */
|
|
37
|
+
]: "Could not find the root element in the DOM",
|
|
38
|
+
[
|
|
39
|
+
1007
|
|
40
|
+
/* NoView */
|
|
41
|
+
]: "Could not find view with id '{{id}}' on view controller for app '{{app}}'",
|
|
42
|
+
[
|
|
43
|
+
1008
|
|
44
|
+
/* CookieKeyNotDefined */
|
|
45
|
+
]: "Cookie key '{{key}}' not present in manifest, cookie has not been set",
|
|
46
|
+
[
|
|
47
|
+
1009
|
|
48
|
+
/* CookieCategoryNotAllowed */
|
|
49
|
+
]: "Cookies categorized as '{{category}}' are not allowed by the user, cookie '{{key}}' has not been set",
|
|
50
|
+
[
|
|
51
|
+
1010
|
|
52
|
+
/* StorageKeyNotDefined */
|
|
53
|
+
]: "Storage key '{{key}}' not present in manifest, item has not been stored",
|
|
54
|
+
[
|
|
55
|
+
1011
|
|
56
|
+
/* StorageCategoryNotAllowed */
|
|
57
|
+
]: "Storage categorized as '{{category}}' is not allowed by the user, item '{{key}}' has not been stored",
|
|
58
|
+
// utilities
|
|
59
|
+
[
|
|
60
|
+
2e3
|
|
61
|
+
/* CurrentUserMissingProvider */
|
|
62
|
+
]: "No managed object provider registered for object 'currentUser'",
|
|
63
|
+
[
|
|
64
|
+
2001
|
|
65
|
+
/* CurrentUserGatewayNotStarted */
|
|
66
|
+
]: "Could not access the gateway when querying 'currentUser'",
|
|
67
|
+
[
|
|
68
|
+
2002
|
|
69
|
+
/* CurrentUserMissingBackend */
|
|
70
|
+
]: "Could not access the required backend when querying 'currentUser'",
|
|
71
|
+
[
|
|
72
|
+
2003
|
|
73
|
+
/* CurrentUserMissingInDatabase */
|
|
74
|
+
]: "Could not locate the authenticated user in the Alliance database"
|
|
75
|
+
}, d = "AllianceError";
|
|
76
|
+
class C extends Error {
|
|
77
|
+
constructor(t, r = {}) {
|
|
78
|
+
const i = m(S[t], r), n = `https://github.com/telia-company/ace-alliance-sdk/wiki/error-codes#${t}`;
|
|
79
|
+
super(i), this.code = t, this.name = d, this.stack = `[${t}] - ${i}
|
|
80
|
+
` + n;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function I(e) {
|
|
84
|
+
return !!e.code && e.name === d;
|
|
85
|
+
}
|
|
86
|
+
function D(e) {
|
|
87
|
+
const r = Object.entries(e).reduce((i, n) => {
|
|
88
|
+
const [o, p] = n;
|
|
89
|
+
return typeof p > "u" || (typeof p == "object" && p !== null ? i[o] = JSON.stringify(p) : i[o] = p), i;
|
|
90
|
+
}, {});
|
|
91
|
+
return Object.keys(r).length ? `?${new URLSearchParams(r)}` : "";
|
|
92
|
+
}
|
|
93
|
+
function b() {
|
|
94
|
+
const e = l(), { href: t, search: r } = window.location;
|
|
95
|
+
return t.replace(e, "").replace(r, "");
|
|
96
|
+
}
|
|
97
|
+
function k(e = "", t = "", r = {}) {
|
|
98
|
+
const i = l().replace(location.origin, ""), n = D(r);
|
|
99
|
+
return e ? t ? `${i}/${e}/${t}${n}` : `${i}/${e}${n}` : `${i}${n}`;
|
|
100
|
+
}
|
|
101
|
+
function W() {
|
|
102
|
+
const e = b(), [t = "", r = ""] = e.split("/").filter((i) => !!i);
|
|
103
|
+
return {
|
|
104
|
+
app: t,
|
|
105
|
+
capability: r
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function P(e) {
|
|
109
|
+
const { origin: t, pathname: r } = window.location;
|
|
110
|
+
if (e === "production") {
|
|
111
|
+
const [i] = r.split("/").filter((n) => !!n);
|
|
112
|
+
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = `${t}/${i}`;
|
|
113
|
+
}
|
|
114
|
+
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = t;
|
|
115
|
+
}
|
|
116
|
+
function l() {
|
|
117
|
+
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;
|
|
118
|
+
}
|
|
119
|
+
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 || {});
|
|
120
|
+
const M = {
|
|
121
|
+
[
|
|
122
|
+
15
|
|
123
|
+
/* Done */
|
|
124
|
+
]: "Done",
|
|
125
|
+
[
|
|
126
|
+
22
|
|
127
|
+
/* NoWorkspaceName */
|
|
128
|
+
]: "No workspace name provided!",
|
|
129
|
+
[
|
|
130
|
+
19
|
|
131
|
+
/* NoAppName */
|
|
132
|
+
]: "No app name provided!",
|
|
133
|
+
[
|
|
134
|
+
0
|
|
135
|
+
/* AlreadyExists */
|
|
136
|
+
]: "File or directory '{0}' already exists!",
|
|
137
|
+
[
|
|
138
|
+
21
|
|
139
|
+
/* NoAppOrWorkspaceInCurrentDirectory */
|
|
140
|
+
]: "Could not find any app entry file at '{0}'!",
|
|
141
|
+
[
|
|
142
|
+
33
|
|
143
|
+
/* UnrecognizedCommand */
|
|
144
|
+
]: "Unrecognized command(s) {0}!",
|
|
145
|
+
[
|
|
146
|
+
34
|
|
147
|
+
/* WorkspaceCreated */
|
|
148
|
+
]: "Workspace was created at path '{0}'!",
|
|
149
|
+
[
|
|
150
|
+
4
|
|
151
|
+
/* AppCreated */
|
|
152
|
+
]: "App was created at path '{0}'!",
|
|
153
|
+
[
|
|
154
|
+
25
|
|
155
|
+
/* ServedStopped */
|
|
156
|
+
]: "Server stopped.",
|
|
157
|
+
[
|
|
158
|
+
11
|
|
159
|
+
/* CreateWorkspaceDescription */
|
|
160
|
+
]: "Creates an Alliance Workspace in the current directory.",
|
|
161
|
+
[
|
|
162
|
+
10
|
|
163
|
+
/* CreateAppDescription */
|
|
164
|
+
]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
|
|
165
|
+
[
|
|
166
|
+
24
|
|
167
|
+
/* ServeDescription */
|
|
168
|
+
]: "Starts a Alliance development server using the current directory package.json.",
|
|
169
|
+
[
|
|
170
|
+
7
|
|
171
|
+
/* BuildDescription */
|
|
172
|
+
]: "Builds an Alliance Application using Vite.",
|
|
173
|
+
[
|
|
174
|
+
35
|
|
175
|
+
/* WorkspaceNameInquiry */
|
|
176
|
+
]: "Enter the name of your workspace",
|
|
177
|
+
[
|
|
178
|
+
28
|
|
179
|
+
/* ServerModeInquiry */
|
|
180
|
+
]: "Which server mode do you want to use?",
|
|
181
|
+
[
|
|
182
|
+
6
|
|
183
|
+
/* AppNameInquiry */
|
|
184
|
+
]: "Enter the name of your app",
|
|
185
|
+
[
|
|
186
|
+
18
|
|
187
|
+
/* MissingTranslationKey */
|
|
188
|
+
]: "No translation key provided!",
|
|
189
|
+
[
|
|
190
|
+
23
|
|
191
|
+
/* OperationCancelled */
|
|
192
|
+
]: "Operation cancelled.",
|
|
193
|
+
[
|
|
194
|
+
30
|
|
195
|
+
/* StopServerInstructions */
|
|
196
|
+
]: `Press CTRL + C to stop the server.
|
|
197
|
+
`,
|
|
198
|
+
[
|
|
199
|
+
32
|
|
200
|
+
/* TemplateLanguageInquiry */
|
|
201
|
+
]: "Select preferred language",
|
|
202
|
+
[
|
|
203
|
+
31
|
|
204
|
+
/* TemplateFrameworkInquiry */
|
|
205
|
+
]: "Select preferred framework template",
|
|
206
|
+
[
|
|
207
|
+
13
|
|
208
|
+
/* DevServerPortDescription */
|
|
209
|
+
]: "The port that the dev server should use.",
|
|
210
|
+
[
|
|
211
|
+
14
|
|
212
|
+
/* DevServerLoggingDescription */
|
|
213
|
+
]: "Whether the dev server and browser console should output more log information or not (false).",
|
|
214
|
+
[
|
|
215
|
+
1
|
|
216
|
+
/* ApiGatewayPortDescription */
|
|
217
|
+
]: "The port that the api gateway should use.",
|
|
218
|
+
[
|
|
219
|
+
2
|
|
220
|
+
/* ApiServerModeDescription */
|
|
221
|
+
]: "Which components to start. [server|server-proxy|server-gateway].",
|
|
222
|
+
[
|
|
223
|
+
12
|
|
224
|
+
/* DevServerOpenDescription */
|
|
225
|
+
]: "Whether the dev server should automatically open in your browser or not.",
|
|
226
|
+
[
|
|
227
|
+
9
|
|
228
|
+
/* BuildWatchDescription */
|
|
229
|
+
]: "Whether the build should start watching and rebuild when files change or not.",
|
|
230
|
+
[
|
|
231
|
+
5
|
|
232
|
+
/* AppEntryBuildOptionDescription */
|
|
233
|
+
]: "The entry file for the app (./src/app).",
|
|
234
|
+
[
|
|
235
|
+
17
|
|
236
|
+
/* ManifestEntryBuildOptionDescription */
|
|
237
|
+
]: "The entry file for the app manifest (./src/manifest).",
|
|
238
|
+
[
|
|
239
|
+
8
|
|
240
|
+
/* BuildModeOptionDescription */
|
|
241
|
+
]: "Which mode to use when building the app.",
|
|
242
|
+
[
|
|
243
|
+
16
|
|
244
|
+
/* FetchPackageVersionError */
|
|
245
|
+
]: "Failed to fetch package info from the NPM registry for package '${0}'!",
|
|
246
|
+
[
|
|
247
|
+
20
|
|
248
|
+
/* NoAppNameFound */
|
|
249
|
+
]: "Could not find app name in manifest.",
|
|
250
|
+
[
|
|
251
|
+
3
|
|
252
|
+
/* AppConfigurationPath */
|
|
253
|
+
]: "The path to the app configuration file.",
|
|
254
|
+
[
|
|
255
|
+
27
|
|
256
|
+
/* ServerMode */
|
|
257
|
+
]: "Server",
|
|
258
|
+
[
|
|
259
|
+
29
|
|
260
|
+
/* ServerProxyMode */
|
|
261
|
+
]: "Server with proxy",
|
|
262
|
+
[
|
|
263
|
+
26
|
|
264
|
+
/* ServerGatewayMode */
|
|
265
|
+
]: "Server with gateway"
|
|
266
|
+
}, u = class {
|
|
267
|
+
};
|
|
268
|
+
let c = u;
|
|
269
|
+
a(c, "getTranslations", () => M), a(c, "getTranslation", (t, ...r) => {
|
|
270
|
+
const n = u.getTranslations()[t];
|
|
271
|
+
if (!n)
|
|
272
|
+
throw new Error(`Could not find text with given key '${t}'.`);
|
|
273
|
+
return r.reduce(
|
|
274
|
+
(p, h, g) => p.toString().replace(`{${g}}`, h.toString()),
|
|
275
|
+
n
|
|
276
|
+
).toString();
|
|
277
|
+
}), a(c, "get", (t = s.MissingTranslationKey, ...r) => u.getTranslation(t, ...r));
|
|
278
|
+
function R(e, t) {
|
|
279
|
+
return y(Object.values(e), ({ name: r }) => ({
|
|
280
|
+
label: r,
|
|
281
|
+
value: r,
|
|
282
|
+
selected: t === r
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
var O = /* @__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))(O || {});
|
|
286
|
+
function $(e, t) {
|
|
287
|
+
return Object.values(e).find((i) => i.name === t);
|
|
288
|
+
}
|
|
289
|
+
function y(e, t) {
|
|
290
|
+
return e.reduce(
|
|
291
|
+
(r, i) => (r.push({
|
|
292
|
+
disabled: !1,
|
|
293
|
+
selected: !1,
|
|
294
|
+
...t(i)
|
|
295
|
+
}), r),
|
|
296
|
+
[
|
|
297
|
+
{
|
|
298
|
+
label: "Choose...",
|
|
299
|
+
value: "",
|
|
300
|
+
disabled: !0,
|
|
301
|
+
selected: !0
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
function U(e) {
|
|
307
|
+
return (t) => {
|
|
308
|
+
t.key === "Enter" && e(t);
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function L(e, t = "all") {
|
|
312
|
+
const { email: r, displayName: i } = e, n = i && i !== "unknown", o = !!r;
|
|
313
|
+
switch (t) {
|
|
314
|
+
case "all": {
|
|
315
|
+
if (n && o)
|
|
316
|
+
return `${i} (${r})`;
|
|
317
|
+
if (n)
|
|
318
|
+
return i;
|
|
319
|
+
if (o)
|
|
320
|
+
return r;
|
|
321
|
+
}
|
|
322
|
+
case "single": {
|
|
323
|
+
if (n)
|
|
324
|
+
return i;
|
|
325
|
+
if (o)
|
|
326
|
+
return r;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return "<UNKNOWN USER>";
|
|
330
|
+
}
|
|
331
|
+
function j(...e) {
|
|
332
|
+
return e.filter((t) => !!t).join(" ");
|
|
333
|
+
}
|
|
334
|
+
export {
|
|
335
|
+
C as AllianceError,
|
|
336
|
+
N as FrameworkErrorCodes,
|
|
337
|
+
c as Texts,
|
|
338
|
+
s as TranslationsKey,
|
|
339
|
+
A as UtilitiesErrorCodes,
|
|
340
|
+
O as VocaButtonVariant,
|
|
341
|
+
j as classNames,
|
|
342
|
+
k as createCapabilityPath,
|
|
343
|
+
L as friendlyUserName,
|
|
344
|
+
W as getCurrentLocationInfo,
|
|
345
|
+
l as getRuntimeRootUrl,
|
|
346
|
+
$ as getVocaIcon,
|
|
347
|
+
I as isAllianceError,
|
|
348
|
+
y as mapToVocaOptions,
|
|
349
|
+
U as onEnter,
|
|
350
|
+
P as setRuntimeRootUrl,
|
|
351
|
+
R as vocaIconsToOptions
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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}\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\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): 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: 'Choose...',\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"],"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","Texts","__publicField","translation","curr","index","vocaIconsToOptions","vocaIcons","selected","mapToVocaOptions","name","VocaButtonVariant","getVocaIcon","icon","items","mapper","item","onEnter","fn","e","friendlyUserName","user","format","email","displayName","hasDisplayName","hasEmail","classNames","classes","c"],"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,6BAZQA,IAAAA,KAAA,CAAA,CAAA,GAeAC,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;AACj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H;AAAA,IAEf;AAAA,IACA,KAAK,UAAU;AACX,UAAIE;AACO,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;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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): 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;
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/alliance-internal-client-utilities",
|
|
3
|
+
"version": "1.0.1-next.0",
|
|
4
|
+
"description": "Utilities used internally by packages developed by team Alliance.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"LICENSE.txt",
|
|
12
|
+
"README.md",
|
|
13
|
+
"CHANGELOG.md",
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"vite": "^4.3.5"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build:dev": "tsc && vite build --mode development",
|
|
24
|
+
"build:prod": "rimraf dist && tsc && vite build --mode prod",
|
|
25
|
+
"build:test": "rimraf dist && tsc && vite build --mode test",
|
|
26
|
+
"build:docker": "vite build",
|
|
27
|
+
"dev": "tsc && vite build --mode development --watch"
|
|
28
|
+
}
|
|
29
|
+
}
|