@telia-ace/alliance-utilities 1.0.10-next.2 → 1.0.10-next.3
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 +6 -0
- package/frontend/index.js +70 -90
- package/frontend/index.js.map +1 -1
- package/frontend/translations.d.ts +35 -40
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/frontend/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (e, r, t) => (
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var g = (e, r, t) => r in e ? s(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var u = (e, r, t) => (g(e, typeof r != "symbol" ? r + "" : r, t), t);
|
|
4
4
|
function m(e) {
|
|
5
5
|
const t = Object.entries(e).reduce((i, o) => {
|
|
6
6
|
const [p, c] = o;
|
|
@@ -8,7 +8,7 @@ function m(e) {
|
|
|
8
8
|
}, {});
|
|
9
9
|
return Object.keys(t).length ? `?${new URLSearchParams(t)}` : "";
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function v() {
|
|
12
12
|
const e = a(), { href: r, search: t } = window.location;
|
|
13
13
|
return r.replace(e, "").replace(t, "");
|
|
14
14
|
}
|
|
@@ -19,215 +19,195 @@ function E(e = "", r = "", t = {}) {
|
|
|
19
19
|
const i = a().replace(location.origin, ""), o = m(t);
|
|
20
20
|
return e ? r ? `${i}/${e}/${r}${o}` : `${i}/${e}${o}` : `${i}${o}`;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const e =
|
|
22
|
+
function O() {
|
|
23
|
+
const e = v(), [r = "", t = ""] = e.split("/").filter((i) => !!i);
|
|
24
24
|
return {
|
|
25
25
|
app: r,
|
|
26
26
|
capability: t
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function S(e, r) {
|
|
30
30
|
const t = A(e);
|
|
31
31
|
return new RegExp(`^${t.replaceAll("\\?", ".?").replaceAll("\\*", ".*")}`, "i").test(r);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function N() {
|
|
34
34
|
const { origin: e, pathname: r } = window.location;
|
|
35
|
-
if (
|
|
35
|
+
if (S("https://alliance*.ace.teliacompany.net", e)) {
|
|
36
36
|
const [t] = r.split("/").filter((i) => !!i);
|
|
37
37
|
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = `${e}/${t}`;
|
|
38
38
|
}
|
|
39
39
|
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL = e;
|
|
40
40
|
}
|
|
41
41
|
function a() {
|
|
42
|
-
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL ||
|
|
42
|
+
return globalThis.__ALLIANCE_RUNTIME_ROOT_URL || N(), globalThis.__ALLIANCE_RUNTIME_ROOT_URL;
|
|
43
43
|
}
|
|
44
|
-
var
|
|
45
|
-
const
|
|
44
|
+
var h = /* @__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.Done = 14] = "Done", e[e.FetchPackageVersionError = 15] = "FetchPackageVersionError", e[e.ManifestEntryBuildOptionDescription = 16] = "ManifestEntryBuildOptionDescription", e[e.MissingTranslationKey = 17] = "MissingTranslationKey", e[e.NoAppName = 18] = "NoAppName", e[e.NoAppNameFound = 19] = "NoAppNameFound", e[e.NoAppOrWorkspaceInCurrentDirectory = 20] = "NoAppOrWorkspaceInCurrentDirectory", e[e.NoWorkspaceName = 21] = "NoWorkspaceName", e[e.OperationCancelled = 22] = "OperationCancelled", e[e.ServeDescription = 23] = "ServeDescription", e[e.ServedStopped = 24] = "ServedStopped", e[e.ServerGatewayMode = 25] = "ServerGatewayMode", e[e.ServerMode = 26] = "ServerMode", e[e.ServerModeInquiry = 27] = "ServerModeInquiry", e[e.ServerProxyMode = 28] = "ServerProxyMode", e[e.StopServerInstructions = 29] = "StopServerInstructions", e[e.TemplateFrameworkInquiry = 30] = "TemplateFrameworkInquiry", e[e.TemplateLanguageInquiry = 31] = "TemplateLanguageInquiry", e[e.UnrecognizedCommand = 32] = "UnrecognizedCommand", e[e.WorkspaceCreated = 33] = "WorkspaceCreated", e[e.WorkspaceNameInquiry = 34] = "WorkspaceNameInquiry", e))(h || {});
|
|
45
|
+
const w = {
|
|
46
46
|
[
|
|
47
|
-
|
|
47
|
+
14
|
|
48
48
|
/* Done */
|
|
49
49
|
]: "Done",
|
|
50
50
|
[
|
|
51
|
-
|
|
51
|
+
21
|
|
52
52
|
/* NoWorkspaceName */
|
|
53
53
|
]: "No workspace name provided!",
|
|
54
54
|
[
|
|
55
|
-
|
|
55
|
+
18
|
|
56
56
|
/* NoAppName */
|
|
57
57
|
]: "No app name provided!",
|
|
58
58
|
[
|
|
59
|
-
|
|
59
|
+
0
|
|
60
60
|
/* AlreadyExists */
|
|
61
61
|
]: "File or directory '{0}' already exists!",
|
|
62
62
|
[
|
|
63
|
-
|
|
63
|
+
20
|
|
64
64
|
/* NoAppOrWorkspaceInCurrentDirectory */
|
|
65
|
-
]: "Could not find any app entry file at '{0}'
|
|
65
|
+
]: "Could not find any app entry file at '{0}'!",
|
|
66
66
|
[
|
|
67
|
-
|
|
67
|
+
32
|
|
68
68
|
/* UnrecognizedCommand */
|
|
69
69
|
]: "Unrecognized command(s) {0}!",
|
|
70
70
|
[
|
|
71
|
-
|
|
71
|
+
33
|
|
72
72
|
/* WorkspaceCreated */
|
|
73
73
|
]: "Workspace was created at path '{0}'!",
|
|
74
74
|
[
|
|
75
|
-
|
|
75
|
+
4
|
|
76
76
|
/* AppCreated */
|
|
77
77
|
]: "App was created at path '{0}'!",
|
|
78
78
|
[
|
|
79
|
-
|
|
79
|
+
24
|
|
80
80
|
/* ServedStopped */
|
|
81
81
|
]: "Server stopped.",
|
|
82
82
|
[
|
|
83
|
-
|
|
83
|
+
11
|
|
84
84
|
/* CreateWorkspaceDescription */
|
|
85
85
|
]: "Creates an Alliance Workspace in the current directory.",
|
|
86
86
|
[
|
|
87
|
-
|
|
87
|
+
10
|
|
88
88
|
/* CreateAppDescription */
|
|
89
89
|
]: "Creates an Alliance Application in the current directory or Alliance Workspace.",
|
|
90
90
|
[
|
|
91
|
-
|
|
91
|
+
23
|
|
92
92
|
/* ServeDescription */
|
|
93
93
|
]: "Starts a Alliance development server using the current directory package.json.",
|
|
94
94
|
[
|
|
95
|
-
|
|
95
|
+
7
|
|
96
96
|
/* BuildDescription */
|
|
97
97
|
]: "Builds an Alliance Application using Vite.",
|
|
98
98
|
[
|
|
99
|
-
|
|
99
|
+
34
|
|
100
100
|
/* WorkspaceNameInquiry */
|
|
101
101
|
]: "Enter the name of your workspace",
|
|
102
102
|
[
|
|
103
|
-
|
|
103
|
+
27
|
|
104
104
|
/* ServerModeInquiry */
|
|
105
105
|
]: "Which server mode do you want to use?",
|
|
106
106
|
[
|
|
107
|
-
|
|
107
|
+
6
|
|
108
108
|
/* AppNameInquiry */
|
|
109
109
|
]: "Enter the name of your app",
|
|
110
110
|
[
|
|
111
|
-
|
|
111
|
+
17
|
|
112
112
|
/* MissingTranslationKey */
|
|
113
113
|
]: "No translation key provided!",
|
|
114
114
|
[
|
|
115
|
-
|
|
115
|
+
22
|
|
116
116
|
/* OperationCancelled */
|
|
117
117
|
]: "Operation cancelled.",
|
|
118
118
|
[
|
|
119
|
-
|
|
119
|
+
29
|
|
120
120
|
/* StopServerInstructions */
|
|
121
121
|
]: `Press CTRL + C to stop the server.
|
|
122
122
|
`,
|
|
123
123
|
[
|
|
124
|
-
|
|
124
|
+
31
|
|
125
125
|
/* TemplateLanguageInquiry */
|
|
126
126
|
]: "Select preferred language",
|
|
127
127
|
[
|
|
128
|
-
|
|
128
|
+
30
|
|
129
129
|
/* TemplateFrameworkInquiry */
|
|
130
130
|
]: "Select preferred framework template",
|
|
131
131
|
[
|
|
132
|
-
|
|
132
|
+
13
|
|
133
133
|
/* DevServerPortDescription */
|
|
134
134
|
]: "The port that the dev server should use.",
|
|
135
135
|
[
|
|
136
|
-
|
|
136
|
+
1
|
|
137
137
|
/* ApiGatewayPortDescription */
|
|
138
138
|
]: "The port that the api gateway should use.",
|
|
139
139
|
[
|
|
140
|
-
|
|
140
|
+
2
|
|
141
141
|
/* ApiServerModeDescription */
|
|
142
142
|
]: "Which components to start. [server|server-proxy|server-gateway].",
|
|
143
143
|
[
|
|
144
|
-
|
|
144
|
+
12
|
|
145
145
|
/* DevServerOpenDescription */
|
|
146
146
|
]: "Whether the dev server should automatically open in your browser or not.",
|
|
147
147
|
[
|
|
148
|
-
|
|
148
|
+
9
|
|
149
149
|
/* BuildWatchDescription */
|
|
150
150
|
]: "Whether the build should start watching and rebuild when files change or not.",
|
|
151
151
|
[
|
|
152
|
-
|
|
153
|
-
/* CouldNotStartGatewayInDocker */
|
|
154
|
-
]: "Could not start Docker container with Alliance gateway.",
|
|
155
|
-
[
|
|
156
|
-
27
|
|
157
|
-
/* PullingLatestImage */
|
|
158
|
-
]: "Pulling latest image...",
|
|
159
|
-
[
|
|
160
|
-
28
|
|
152
|
+
5
|
|
161
153
|
/* AppEntryBuildOptionDescription */
|
|
162
154
|
]: "The entry file for the app (./src/app).",
|
|
163
155
|
[
|
|
164
|
-
|
|
156
|
+
16
|
|
165
157
|
/* ManifestEntryBuildOptionDescription */
|
|
166
158
|
]: "The entry file for the app manifest (./src/manifest).",
|
|
167
159
|
[
|
|
168
|
-
|
|
160
|
+
8
|
|
169
161
|
/* BuildModeOptionDescription */
|
|
170
|
-
]: "Which mode to use when building the app.
|
|
162
|
+
]: "Which mode to use when building the app.",
|
|
171
163
|
[
|
|
172
|
-
|
|
164
|
+
15
|
|
173
165
|
/* FetchPackageVersionError */
|
|
174
166
|
]: "Failed to fetch package info from the NPM registry for package '${0}'!",
|
|
175
167
|
[
|
|
176
|
-
|
|
177
|
-
/* DockerNotStartedOrInstalled */
|
|
178
|
-
]: "Docker not started or not installed.",
|
|
179
|
-
[
|
|
180
|
-
33
|
|
181
|
-
/* EnableDevAuthentication */
|
|
182
|
-
]: "Whether user authentication should be enabled or not.",
|
|
183
|
-
[
|
|
184
|
-
34
|
|
168
|
+
19
|
|
185
169
|
/* NoAppNameFound */
|
|
186
170
|
]: "Could not find app name in manifest.",
|
|
187
171
|
[
|
|
188
|
-
|
|
172
|
+
3
|
|
189
173
|
/* AppConfigurationPath */
|
|
190
174
|
]: "The path to the app configuration file.",
|
|
191
175
|
[
|
|
192
|
-
|
|
176
|
+
26
|
|
193
177
|
/* ServerMode */
|
|
194
178
|
]: "Server",
|
|
195
179
|
[
|
|
196
|
-
|
|
180
|
+
28
|
|
197
181
|
/* ServerProxyMode */
|
|
198
182
|
]: "Server with proxy",
|
|
199
183
|
[
|
|
200
|
-
|
|
184
|
+
25
|
|
201
185
|
/* ServerGatewayMode */
|
|
202
|
-
]: "Server with gateway"
|
|
203
|
-
[
|
|
204
|
-
39
|
|
205
|
-
/* DevLoginUrl */
|
|
206
|
-
]: "Log in using http://localhost:{0}/-/dev/login"
|
|
186
|
+
]: "Server with gateway"
|
|
207
187
|
}, d = class {
|
|
208
188
|
};
|
|
209
189
|
let n = d;
|
|
210
|
-
u(n, "getTranslations", () =>
|
|
190
|
+
u(n, "getTranslations", () => w), u(n, "getTranslation", (r, ...t) => {
|
|
211
191
|
const o = d.getTranslations()[r];
|
|
212
192
|
if (!o)
|
|
213
193
|
throw new Error(`Could not find text with given key '${r}'.`);
|
|
214
194
|
return t.reduce(
|
|
215
|
-
(c,
|
|
195
|
+
(c, l, f) => c.toString().replace(`{${f}}`, l.toString()),
|
|
216
196
|
o
|
|
217
197
|
).toString();
|
|
218
|
-
}), u(n, "get", (r =
|
|
219
|
-
function
|
|
220
|
-
return
|
|
198
|
+
}), u(n, "get", (r = h.MissingTranslationKey, ...t) => d.getTranslation(r, ...t));
|
|
199
|
+
function I(e, r) {
|
|
200
|
+
return C(Object.values(e), ({ name: t }) => ({
|
|
221
201
|
label: t,
|
|
222
202
|
value: t,
|
|
223
203
|
selected: r === t
|
|
224
204
|
}));
|
|
225
205
|
}
|
|
226
|
-
var
|
|
206
|
+
var D = /* @__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))(D || {});
|
|
227
207
|
function W(e, r) {
|
|
228
208
|
return Object.values(e).find((i) => i.name === r);
|
|
229
209
|
}
|
|
230
|
-
function
|
|
210
|
+
function C(e, r) {
|
|
231
211
|
return e.reduce(
|
|
232
212
|
(t, i) => (t.push({
|
|
233
213
|
disabled: !1,
|
|
@@ -244,12 +224,12 @@ function k(e, r) {
|
|
|
244
224
|
]
|
|
245
225
|
);
|
|
246
226
|
}
|
|
247
|
-
function
|
|
227
|
+
function R(e) {
|
|
248
228
|
return (r) => {
|
|
249
229
|
r.key === "Enter" && e(r);
|
|
250
230
|
};
|
|
251
231
|
}
|
|
252
|
-
function
|
|
232
|
+
function M(e, r = "all") {
|
|
253
233
|
const { email: t, displayName: i } = e, o = i && i !== "unknown", p = !!t;
|
|
254
234
|
switch (r) {
|
|
255
235
|
case "all": {
|
|
@@ -269,23 +249,23 @@ function P(e, r = "all") {
|
|
|
269
249
|
}
|
|
270
250
|
return "<UNKNOWN USER>";
|
|
271
251
|
}
|
|
272
|
-
function
|
|
252
|
+
function P(...e) {
|
|
273
253
|
return e.filter((r) => !!r).join(" ");
|
|
274
254
|
}
|
|
275
255
|
export {
|
|
276
256
|
n as Texts,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
257
|
+
h as TranslationsKey,
|
|
258
|
+
D as VocaButtonVariant,
|
|
259
|
+
P as classNames,
|
|
280
260
|
E as createCapabilityPath,
|
|
281
|
-
|
|
282
|
-
|
|
261
|
+
M as friendlyUserName,
|
|
262
|
+
O as getCurrentLocationInfo,
|
|
283
263
|
a as getRuntimeRootUrl,
|
|
284
264
|
W as getVocaIcon,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
265
|
+
C as mapToVocaOptions,
|
|
266
|
+
S as matchRegExpLike,
|
|
267
|
+
R as onEnter,
|
|
268
|
+
N as setRuntimeRootUrl,
|
|
269
|
+
I as vocaIconsToOptions
|
|
290
270
|
};
|
|
291
271
|
//# sourceMappingURL=index.js.map
|
package/frontend/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/frontend/routing.ts","../src/frontend/translations.ts","../src/frontend/texts.ts","../src/frontend/ui.ts"],"sourcesContent":["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\nfunction escapeRegex(str: string) {\n return str.replaceAll(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\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 matchRegExpLike(regExpLikeStr: string, testStr: string): boolean {\n const escaped = escapeRegex(regExpLikeStr);\n const regExp = new RegExp(`^${escaped.replaceAll('\\\\?', '.?').replaceAll('\\\\*', '.*')}`, 'i');\n return regExp.test(testStr);\n}\n\nexport function setRuntimeRootUrl() {\n const { origin, pathname } = window.location;\n\n // If on Alliance cloud environment - the first part of path is workspace\n if (matchRegExpLike('https://alliance*.ace.teliacompany.net', origin)) {\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 if (!globalThis.__ALLIANCE_RUNTIME_ROOT_URL) {\n setRuntimeRootUrl();\n }\n\n return globalThis.__ALLIANCE_RUNTIME_ROOT_URL;\n}\n","export type Translations = {\n [key in TranslationsKey]: string;\n};\n\nexport enum TranslationsKey {\n Done,\n NoWorkspaceName,\n NoAppName,\n AlreadyExists,\n NoAppOrWorkspaceInCurrentDirectory,\n UnrecognizedCommand,\n WorkspaceCreated,\n AppCreated,\n ServedStopped,\n WorkspaceNameInquiry,\n AppNameInquiry,\n ServerModeInquiry,\n CreateWorkspaceDescription,\n CreateAppDescription,\n ServeDescription,\n BuildDescription,\n MissingTranslationKey,\n OperationCancelled,\n StopServerInstructions,\n TemplateLanguageInquiry,\n TemplateFrameworkInquiry,\n DevServerPortDescription,\n ApiGatewayPortDescription,\n ApiServerModeDescription,\n DevServerOpenDescription,\n BuildWatchDescription,\n CouldNotStartGatewayInDocker,\n PullingLatestImage,\n AppEntryBuildOptionDescription,\n ManifestEntryBuildOptionDescription,\n BuildModeOptionDescription,\n FetchPackageVersionError,\n DockerNotStartedOrInstalled,\n EnableDevAuthentication,\n NoAppNameFound,\n AppConfigurationPath,\n ServerGatewayMode,\n ServerProxyMode,\n ServerMode,\n DevLoginUrl,\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}' or any apps under the alliance.apps property in '{1}'!\",\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.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.CouldNotStartGatewayInDocker]:\n 'Could not start Docker container with Alliance gateway.',\n [TranslationsKey.PullingLatestImage]: 'Pulling latest image...',\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]:\n 'Which mode to use when building the app. [production|development]',\n [TranslationsKey.FetchPackageVersionError]:\n \"Failed to fetch package info from the NPM registry for package '${0}'!\",\n [TranslationsKey.DockerNotStartedOrInstalled]: 'Docker not started or not installed.',\n [TranslationsKey.EnableDevAuthentication]:\n 'Whether user authentication should be enabled or not.',\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 [TranslationsKey.DevLoginUrl]: 'Log in using http://localhost:{0}/-/dev/login',\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":["createQueryString","args","filteredArgs","acc","entry","key","value","getCurrentPath","runtimeRootUrl","getRuntimeRootUrl","href","search","escapeRegex","str","createCapabilityPath","app","capability","rootPath","queryString","getCurrentLocationInfo","currentPath","part","matchRegExpLike","regExpLikeStr","testStr","escaped","setRuntimeRootUrl","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":";;;AAEA,SAASA,EAAkBC,GAA2B;AAGlD,QAAMC,IAFU,OAAO,QAAQD,CAAI,EAEN,OAA4B,CAACE,GAAKC,MAAU;AAC/D,UAAA,CAACC,GAAKC,CAAK,IAAIF;AAEjB,WAAA,OAAOE,IAAU,QAEV,OAAOA,KAAU,YAAYA,MAAU,OAC9CH,EAAIE,CAAG,IAAI,KAAK,UAAUC,CAAK,IAE/BH,EAAIE,CAAG,IAAIC,IAGRH;AAAA,EACX,GAAG,CAAE,CAAA;AAEL,SAAK,OAAO,KAAKD,CAAY,EAAE,SAIxB,IAAI,IAAI,gBAAgBA,CAAmC,MAHvD;AAIf;AAEA,SAASK,IAAiB;AACtB,QAAMC,IAAiBC,KACjB,EAAE,MAAAC,GAAM,QAAAC,MAAW,OAAO;AAEhC,SAAOD,EAAK,QAAQF,GAAgB,EAAE,EAAE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;AAAA,IACZ,KAAK,OAAO;AACR,UAAIG,KAAkBC;AAClB,eAAO,GAAGF,MAAgBD;UACnBE;AACA,eAAAD;UACAE;AACA,eAAAH;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;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/frontend/routing.ts","../src/frontend/translations.ts","../src/frontend/texts.ts","../src/frontend/ui.ts"],"sourcesContent":["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\nfunction escapeRegex(str: string) {\n return str.replaceAll(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\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 matchRegExpLike(regExpLikeStr: string, testStr: string): boolean {\n const escaped = escapeRegex(regExpLikeStr);\n const regExp = new RegExp(`^${escaped.replaceAll('\\\\?', '.?').replaceAll('\\\\*', '.*')}`, 'i');\n return regExp.test(testStr);\n}\n\nexport function setRuntimeRootUrl() {\n const { origin, pathname } = window.location;\n\n // If on Alliance cloud environment - the first part of path is workspace\n if (matchRegExpLike('https://alliance*.ace.teliacompany.net', origin)) {\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 if (!globalThis.__ALLIANCE_RUNTIME_ROOT_URL) {\n setRuntimeRootUrl();\n }\n\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 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.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":["createQueryString","args","filteredArgs","acc","entry","key","value","getCurrentPath","runtimeRootUrl","getRuntimeRootUrl","href","search","escapeRegex","str","createCapabilityPath","app","capability","rootPath","queryString","getCurrentLocationInfo","currentPath","part","matchRegExpLike","regExpLikeStr","testStr","escaped","setRuntimeRootUrl","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":";;;AAEA,SAASA,EAAkBC,GAA2B;AAGlD,QAAMC,IAFU,OAAO,QAAQD,CAAI,EAEN,OAA4B,CAACE,GAAKC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CAAC,CAACH;AAEnB,UAAQD,GAAQ;AAAA,IACZ,KAAK,OAAO;AACR,UAAIG,KAAkBC;AAClB,eAAO,GAAGF,MAAgBD;UACnBE;AACA,eAAAD;UACAE;AACA,eAAAH;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;"}
|
|
@@ -2,45 +2,40 @@ export type Translations = {
|
|
|
2
2
|
[key in TranslationsKey]: string;
|
|
3
3
|
};
|
|
4
4
|
export declare enum TranslationsKey {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
AppConfigurationPath = 35,
|
|
41
|
-
ServerGatewayMode = 36,
|
|
42
|
-
ServerProxyMode = 37,
|
|
43
|
-
ServerMode = 38,
|
|
44
|
-
DevLoginUrl = 39
|
|
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
|
+
Done = 14,
|
|
20
|
+
FetchPackageVersionError = 15,
|
|
21
|
+
ManifestEntryBuildOptionDescription = 16,
|
|
22
|
+
MissingTranslationKey = 17,
|
|
23
|
+
NoAppName = 18,
|
|
24
|
+
NoAppNameFound = 19,
|
|
25
|
+
NoAppOrWorkspaceInCurrentDirectory = 20,
|
|
26
|
+
NoWorkspaceName = 21,
|
|
27
|
+
OperationCancelled = 22,
|
|
28
|
+
ServeDescription = 23,
|
|
29
|
+
ServedStopped = 24,
|
|
30
|
+
ServerGatewayMode = 25,
|
|
31
|
+
ServerMode = 26,
|
|
32
|
+
ServerModeInquiry = 27,
|
|
33
|
+
ServerProxyMode = 28,
|
|
34
|
+
StopServerInstructions = 29,
|
|
35
|
+
TemplateFrameworkInquiry = 30,
|
|
36
|
+
TemplateLanguageInquiry = 31,
|
|
37
|
+
UnrecognizedCommand = 32,
|
|
38
|
+
WorkspaceCreated = 33,
|
|
39
|
+
WorkspaceNameInquiry = 34
|
|
45
40
|
}
|
|
46
41
|
export declare const en: Translations;
|
package/package.json
CHANGED