@nice2dev/erp-adapter 1.3.10 → 1.3.11
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 +68 -0
- package/README.md +60 -19
- package/dist/__tests__/omniverk/generator.test.d.ts +1 -0
- package/dist/__tests__/omniverk/kinds.test.d.ts +1 -0
- package/dist/__tests__/omniverk/preset.test.d.ts +1 -0
- package/dist/__tests__/omniverk/restProvider.test.d.ts +1 -0
- package/dist/__tests__/omniverk/seedFolderProvider.test.d.ts +1 -0
- package/dist/__tests__/omniverk/templates.test.d.ts +1 -0
- package/dist/__tests__/omniverk/validate.test.d.ts +1 -0
- package/dist/omniverk/fs/directoryHandle.d.ts +42 -0
- package/dist/omniverk/fs/memory.d.ts +8 -0
- package/dist/omniverk/fs/types.d.ts +33 -0
- package/dist/omniverk/generator.d.ts +98 -0
- package/dist/omniverk/index.d.ts +25 -0
- package/dist/omniverk/kinds.d.ts +33 -0
- package/dist/omniverk/manifestSections.d.ts +10 -0
- package/dist/omniverk/preset.d.ts +19 -0
- package/dist/omniverk/restProvider.d.ts +30 -0
- package/dist/omniverk/seedFolderProvider.d.ts +40 -0
- package/dist/omniverk/templates.d.ts +60 -0
- package/dist/omniverk/validate.d.ts +29 -0
- package/dist/omniverk.cjs +2 -0
- package/dist/omniverk.mjs +2658 -0
- package/package.json +15 -1
|
@@ -0,0 +1,2658 @@
|
|
|
1
|
+
import { objectFileKind as _e, endsWithAny as te, arrayFileKind as ze, i18nFileKind as Be, itemsFileKind as Oe, jsonFileKind as Ae, jsonValuesEqual as Le, keepTextFormat as Je, parseJsonText as _, patchJsonText as De, stringifyJsonText as de } from "@nice2dev/ui-forms/studio";
|
|
2
|
+
const V = (e) => typeof e == "object" && e !== null && !Array.isArray(e), G = (e) => typeof e == "string" && e ? e : void 0, U = (e) => Object.fromEntries(Object.entries(e).filter(([, i]) => i !== void 0)), He = _e({
|
|
3
|
+
id: "manifest",
|
|
4
|
+
label: "Manifest",
|
|
5
|
+
labelKey: "devStudio.kind.manifest",
|
|
6
|
+
icon: "file",
|
|
7
|
+
editor: "manifest",
|
|
8
|
+
match: te(".manifest.json")
|
|
9
|
+
}), Me = [
|
|
10
|
+
["dataType", "type"],
|
|
11
|
+
["isRequired", "required"]
|
|
12
|
+
], le = "$aliases";
|
|
13
|
+
function Ze(e) {
|
|
14
|
+
if (!V(e))
|
|
15
|
+
return e;
|
|
16
|
+
const i = Me.filter(([o, n]) => !(o in e) && n in e);
|
|
17
|
+
if (i.length === 0)
|
|
18
|
+
return e;
|
|
19
|
+
const t = {};
|
|
20
|
+
for (const [o, n] of Object.entries(e)) {
|
|
21
|
+
const s = i.find(([, r]) => r === o);
|
|
22
|
+
t[s ? s[0] : o] = n;
|
|
23
|
+
}
|
|
24
|
+
return t[le] = i.map(([, o]) => o), t;
|
|
25
|
+
}
|
|
26
|
+
function Ye(e) {
|
|
27
|
+
if (!V(e) || !Array.isArray(e[le]))
|
|
28
|
+
return e;
|
|
29
|
+
const i = e[le], t = {};
|
|
30
|
+
for (const [o, n] of Object.entries(e)) {
|
|
31
|
+
if (o === le)
|
|
32
|
+
continue;
|
|
33
|
+
const s = Me.find(([r, l]) => r === o && i.includes(l));
|
|
34
|
+
t[s ? s[1] : o] = n;
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
const Se = (e, i) => V(e) && Array.isArray(e.fields) ? { ...e, fields: e.fields.map(i) } : e, Xe = (() => {
|
|
39
|
+
const e = ze({
|
|
40
|
+
id: "entities",
|
|
41
|
+
label: "Entities",
|
|
42
|
+
labelKey: "devStudio.kind.entities",
|
|
43
|
+
icon: "database",
|
|
44
|
+
editor: "entities",
|
|
45
|
+
match: te(".entities.json"),
|
|
46
|
+
property: "entities",
|
|
47
|
+
itemKey: "name"
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
...e,
|
|
51
|
+
decode: (i, t) => e.decode(i, t).map((o) => Se(o, Ze)),
|
|
52
|
+
encode: (i, t, o) => e.encode(
|
|
53
|
+
i.map((n) => Se(n, Ye)),
|
|
54
|
+
t,
|
|
55
|
+
o
|
|
56
|
+
)
|
|
57
|
+
};
|
|
58
|
+
})(), Qe = Be(), ge = {
|
|
59
|
+
input: "textInput",
|
|
60
|
+
text: "textInput",
|
|
61
|
+
textarea: "textArea",
|
|
62
|
+
number: "numberInput",
|
|
63
|
+
currency: "numberInput",
|
|
64
|
+
toggle: "checkbox",
|
|
65
|
+
checkbox: "checkbox",
|
|
66
|
+
date: "datePicker",
|
|
67
|
+
datetime: "datePicker",
|
|
68
|
+
lookup: "select",
|
|
69
|
+
select: "select"
|
|
70
|
+
};
|
|
71
|
+
function et(e) {
|
|
72
|
+
const i = e.columns.map((t) => ({
|
|
73
|
+
field: String(t.field ?? ""),
|
|
74
|
+
header: String(t.displayName ?? t.header ?? t.label ?? t.field ?? "")
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
id: String(e.name),
|
|
78
|
+
name: String(e.displayName ?? e.name),
|
|
79
|
+
kind: "grid",
|
|
80
|
+
version: 2,
|
|
81
|
+
columns: 12,
|
|
82
|
+
dataSources: [{ key: "rows", type: "entity", entity: String(e.entityName), autoLoad: !0 }],
|
|
83
|
+
rows: [
|
|
84
|
+
{
|
|
85
|
+
id: "list",
|
|
86
|
+
cells: [
|
|
87
|
+
{
|
|
88
|
+
id: "grid",
|
|
89
|
+
controlType: "dataGrid",
|
|
90
|
+
colSpan: 12,
|
|
91
|
+
props: { columns: i },
|
|
92
|
+
bindings: { data: { source: "rows", field: "" } }
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function Fe(e, i) {
|
|
100
|
+
var l, y, c;
|
|
101
|
+
const t = (e.rows ?? []).flatMap((m) => m.cells).find((m) => m.controlType === "dataGrid"), o = ((l = t == null ? void 0 : t.props) == null ? void 0 : l.columns) ?? [], n = i.columns ?? [], s = (c = (y = e.dataSources) == null ? void 0 : y.find((m) => m.type === "entity")) == null ? void 0 : c.entity, r = (m) => "displayName" in m ? "displayName" : "header" in m ? "header" : "label" in m ? "label" : "displayName";
|
|
102
|
+
return U({
|
|
103
|
+
...i,
|
|
104
|
+
displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
|
|
105
|
+
entityName: s ?? i.entityName,
|
|
106
|
+
columns: o.map((m) => {
|
|
107
|
+
const b = n.find((N) => N.field === m.field);
|
|
108
|
+
if (!b)
|
|
109
|
+
return { field: m.field, displayName: m.header ?? m.field };
|
|
110
|
+
const C = r(b), S = m.header ?? m.field;
|
|
111
|
+
return b[C] === void 0 && S === m.field ? b : { ...b, [C]: S };
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function tt(e) {
|
|
116
|
+
const i = [];
|
|
117
|
+
return e.tabs.forEach((o, n) => {
|
|
118
|
+
i.push({
|
|
119
|
+
id: `tab-${n}`,
|
|
120
|
+
cells: [
|
|
121
|
+
{
|
|
122
|
+
id: `tab-${n}`,
|
|
123
|
+
controlType: "heading",
|
|
124
|
+
colSpan: 12,
|
|
125
|
+
props: { text: String(o.displayName ?? o.name ?? ""), level: 2, name: o.name }
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}), (o.sections ?? []).forEach((s, r) => {
|
|
129
|
+
i.push({
|
|
130
|
+
id: `tab-${n}-section-${r}`,
|
|
131
|
+
cells: [
|
|
132
|
+
{
|
|
133
|
+
id: `tab-${n}-section-${r}`,
|
|
134
|
+
controlType: "heading",
|
|
135
|
+
colSpan: 12,
|
|
136
|
+
props: {
|
|
137
|
+
text: String(s.displayName ?? s.name ?? ""),
|
|
138
|
+
level: 3,
|
|
139
|
+
name: s.name
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
let l = [], y = 0;
|
|
145
|
+
const c = () => {
|
|
146
|
+
l.length && (i.push({ id: `tab-${n}-section-${r}-row-${i.length}`, cells: l }), l = [], y = 0);
|
|
147
|
+
};
|
|
148
|
+
(s.controls ?? []).forEach((m, b) => {
|
|
149
|
+
const C = typeof m.colSpan == "number" ? m.colSpan : 6;
|
|
150
|
+
y + C > 12 && c(), l.push({
|
|
151
|
+
id: `c-${n}-${r}-${b}`,
|
|
152
|
+
controlType: ge[String(m.type)] ?? "textInput",
|
|
153
|
+
colSpan: C,
|
|
154
|
+
props: {
|
|
155
|
+
label: String(m.label ?? m.field ?? ""),
|
|
156
|
+
required: m.required === !0,
|
|
157
|
+
field: m.field,
|
|
158
|
+
type: m.type
|
|
159
|
+
},
|
|
160
|
+
bindings: { value: { source: "record", field: String(m.field ?? "") } }
|
|
161
|
+
}), y += C;
|
|
162
|
+
}), c();
|
|
163
|
+
});
|
|
164
|
+
}), {
|
|
165
|
+
id: String(e.name),
|
|
166
|
+
name: String(e.displayName ?? e.name),
|
|
167
|
+
kind: "form",
|
|
168
|
+
version: 2,
|
|
169
|
+
columns: 12,
|
|
170
|
+
dataSources: [{ key: "record", type: "entity", entity: String(e.entityName), autoLoad: !0 }],
|
|
171
|
+
rows: i
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function Pe(e, i) {
|
|
175
|
+
var c, m, b, C, S;
|
|
176
|
+
const t = i.tabs ?? [], o = t.flatMap(
|
|
177
|
+
(N) => (N.sections ?? []).flatMap((x) => x.controls ?? [])
|
|
178
|
+
), n = [];
|
|
179
|
+
let s = null, r = null;
|
|
180
|
+
const l = () => (s || (s = { name: "Main", displayName: e.name, sections: [] }, n.push(s)), r || (r = { name: "Details", displayName: "Details", controls: [] }, s.sections.push(r)), r);
|
|
181
|
+
for (const N of e.rows ?? [])
|
|
182
|
+
for (const x of N.cells) {
|
|
183
|
+
const d = x.props ?? {};
|
|
184
|
+
if (x.controlType === "heading" && (d.level === 2 || d.level === 3)) {
|
|
185
|
+
const I = G(d.name) ?? String(d.text ?? "").replace(/\s+/g, "");
|
|
186
|
+
if (d.level === 2)
|
|
187
|
+
s = { ...t.find((E) => E.name === I) ?? {}, name: I, displayName: String(d.text ?? I), sections: [] }, n.push(s), r = null;
|
|
188
|
+
else {
|
|
189
|
+
s || (s = { name: "Main", displayName: e.name, sections: [] }, n.push(s));
|
|
190
|
+
const M = t.flatMap((j) => j.sections ?? []).find((j) => j.name === I);
|
|
191
|
+
r = { ...M ? Object.fromEntries(Object.entries(M).filter(([j]) => j !== "controls")) : {}, name: I, displayName: String(d.text ?? I), controls: [] }, s.sections.push(r);
|
|
192
|
+
}
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const $ = ((m = (c = x.bindings) == null ? void 0 : c.value) == null ? void 0 : m.field) ?? G(d.field);
|
|
196
|
+
if (!$)
|
|
197
|
+
continue;
|
|
198
|
+
const u = o.find((I) => I.field === $), T = u && ge[String(u.type)] === x.controlType ? u.type : ((b = Object.entries(ge).find(([, I]) => I === x.controlType)) == null ? void 0 : b[0]) ?? "input", L = U({
|
|
199
|
+
...u ?? {},
|
|
200
|
+
field: $,
|
|
201
|
+
type: T,
|
|
202
|
+
label: d.label !== void 0 ? String(d.label) : u == null ? void 0 : u.label,
|
|
203
|
+
colSpan: (u == null ? void 0 : u.colSpan) !== void 0 || x.colSpan !== 6 ? x.colSpan : void 0,
|
|
204
|
+
required: d.required === !0 ? !0 : (u == null ? void 0 : u.required) === !0 ? !1 : u == null ? void 0 : u.required
|
|
205
|
+
});
|
|
206
|
+
l().controls.push(L);
|
|
207
|
+
}
|
|
208
|
+
const y = n.map((N) => {
|
|
209
|
+
const x = t.find((d) => d.name === N.name);
|
|
210
|
+
return x ? { ...x, ...N } : N;
|
|
211
|
+
});
|
|
212
|
+
return U({
|
|
213
|
+
...i,
|
|
214
|
+
displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
|
|
215
|
+
entityName: ((S = (C = e.dataSources) == null ? void 0 : C.find((N) => N.type === "entity")) == null ? void 0 : S.entity) ?? i.entityName,
|
|
216
|
+
tabs: y
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const it = (e) => {
|
|
220
|
+
const i = String(e.type ?? "").toLowerCase();
|
|
221
|
+
return i === "list" && typeof e.entityName == "string" && Array.isArray(e.columns) && e.columns.length > 0 ? "List" : i === "form" && typeof e.entityName == "string" && Array.isArray(e.tabs) ? "Form" : null;
|
|
222
|
+
};
|
|
223
|
+
function nt(e, i) {
|
|
224
|
+
const t = V(e) ? e : {}, o = G(t.name) ?? G(t.id) ?? `#${i}`, n = G(t.displayName) ?? o, s = it(t);
|
|
225
|
+
if (!s)
|
|
226
|
+
return {
|
|
227
|
+
key: o,
|
|
228
|
+
label: n,
|
|
229
|
+
source: e,
|
|
230
|
+
rawReason: String(t.type ?? (t.viewJson ? "viewJson" : "unknown"))
|
|
231
|
+
};
|
|
232
|
+
const r = s === "List" ? et(t) : tt(t), l = s === "List" ? Fe(r, t) : Pe(r, t);
|
|
233
|
+
return Le(l, e) ? { key: o, label: n, definition: r, source: e } : { key: o, label: n, source: e, rawReason: `${s} (round-trip)` };
|
|
234
|
+
}
|
|
235
|
+
function st(e) {
|
|
236
|
+
if (!e.definition)
|
|
237
|
+
return e.source;
|
|
238
|
+
const i = V(e.source) ? e.source : { name: e.definition.id };
|
|
239
|
+
return e.definition.kind === "form" ? Pe(e.definition, {
|
|
240
|
+
type: "Form",
|
|
241
|
+
...i,
|
|
242
|
+
name: i.name ?? e.definition.id
|
|
243
|
+
}) : Fe(e.definition, {
|
|
244
|
+
type: "List",
|
|
245
|
+
...i,
|
|
246
|
+
name: i.name ?? e.definition.id
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const ot = Oe({
|
|
250
|
+
id: "views",
|
|
251
|
+
label: "Views",
|
|
252
|
+
labelKey: "devStudio.kind.views",
|
|
253
|
+
icon: "grid",
|
|
254
|
+
editor: "views",
|
|
255
|
+
match: te(".views.json"),
|
|
256
|
+
property: "views",
|
|
257
|
+
itemKey: "name",
|
|
258
|
+
toItem: nt,
|
|
259
|
+
fromItem: st
|
|
260
|
+
});
|
|
261
|
+
function at(e) {
|
|
262
|
+
const i = e.steps ?? [], t = e.connections ?? [];
|
|
263
|
+
return {
|
|
264
|
+
id: String(e.name),
|
|
265
|
+
name: String(e.displayName ?? e.name),
|
|
266
|
+
entityType: String(e.entityName ?? ""),
|
|
267
|
+
version: 1,
|
|
268
|
+
states: i.map((o, n) => ({
|
|
269
|
+
id: String(o.state),
|
|
270
|
+
name: String(o.displayName ?? o.state),
|
|
271
|
+
type: o.isInitial === !0 ? "initial" : o.isFinal === !0 ? "final" : "intermediate",
|
|
272
|
+
position: { x: 60 + n % 4 * 230, y: 80 + Math.floor(n / 4) * 140 }
|
|
273
|
+
})),
|
|
274
|
+
transitions: t.map((o, n) => ({
|
|
275
|
+
id: `t${n}`,
|
|
276
|
+
fromStateId: String(o.fromState),
|
|
277
|
+
toStateId: String(o.toState),
|
|
278
|
+
name: String(o.actionName ?? ""),
|
|
279
|
+
...typeof o.requiredPermission == "string" ? { requiredPermission: o.requiredPermission } : {}
|
|
280
|
+
}))
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function Re(e, i) {
|
|
284
|
+
const t = i.steps ?? [], o = i.connections ?? [];
|
|
285
|
+
return U({
|
|
286
|
+
...i,
|
|
287
|
+
displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
|
|
288
|
+
entityName: e.entityType || i.entityName,
|
|
289
|
+
steps: e.states.map((n) => {
|
|
290
|
+
const s = t.find((l) => l.state === n.id), r = s ?? { state: n.id };
|
|
291
|
+
return U({
|
|
292
|
+
...r,
|
|
293
|
+
displayName: s && "displayName" in s || n.name !== n.id ? n.name : void 0,
|
|
294
|
+
isInitial: n.type === "initial" ? !0 : (s == null ? void 0 : s.isInitial) === !0 || s == null ? void 0 : s.isInitial,
|
|
295
|
+
isFinal: n.type === "final" ? !0 : (s == null ? void 0 : s.isFinal) === !0 || s == null ? void 0 : s.isFinal
|
|
296
|
+
});
|
|
297
|
+
}),
|
|
298
|
+
connections: e.transitions.map((n) => {
|
|
299
|
+
const s = /^t(\d+)$/.exec(n.id), r = s ? o[Number(s[1])] : o.find((l) => l.fromState === n.fromStateId && l.toState === n.toStateId);
|
|
300
|
+
return U({
|
|
301
|
+
...r ?? {},
|
|
302
|
+
fromState: n.fromStateId,
|
|
303
|
+
toState: n.toStateId,
|
|
304
|
+
actionName: n.name || (r == null ? void 0 : r.actionName),
|
|
305
|
+
requiredPermission: n.requiredPermission
|
|
306
|
+
});
|
|
307
|
+
})
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function rt(e, i) {
|
|
311
|
+
const t = V(e) ? e : {}, o = G(t.name) ?? `#${i}`, n = G(t.displayName) ?? o, s = t.steps;
|
|
312
|
+
if (!(Array.isArray(t.connections) && Array.isArray(s) && s.every((y) => V(y) && typeof y.state == "string")))
|
|
313
|
+
return { key: o, label: n, source: e, rawReason: G(t.triggerType) ?? "automation" };
|
|
314
|
+
const l = at(t);
|
|
315
|
+
return Le(Re(l, t), e) ? { key: o, label: n, definition: l, source: e } : { key: o, label: n, source: e, rawReason: "state machine (round-trip)" };
|
|
316
|
+
}
|
|
317
|
+
function lt(e) {
|
|
318
|
+
if (!e.definition)
|
|
319
|
+
return e.source;
|
|
320
|
+
const i = V(e.source) ? e.source : { name: e.definition.id };
|
|
321
|
+
return Re(e.definition, {
|
|
322
|
+
...i,
|
|
323
|
+
name: i.name ?? e.definition.id
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
const ct = Oe({
|
|
327
|
+
id: "workflows",
|
|
328
|
+
label: "Workflows",
|
|
329
|
+
labelKey: "devStudio.kind.workflows",
|
|
330
|
+
icon: "git-branch",
|
|
331
|
+
editor: "workflows",
|
|
332
|
+
match: te(".workflows.json"),
|
|
333
|
+
property: "workflows",
|
|
334
|
+
itemKey: "name",
|
|
335
|
+
toItem: rt,
|
|
336
|
+
fromItem: lt
|
|
337
|
+
});
|
|
338
|
+
function dt(e) {
|
|
339
|
+
const i = V(e) ? e : {};
|
|
340
|
+
return {
|
|
341
|
+
permissions: (i.permissions ?? []).map(
|
|
342
|
+
(t) => U({
|
|
343
|
+
code: String(t.code ?? ""),
|
|
344
|
+
name: G(t.name),
|
|
345
|
+
description: G(t.description)
|
|
346
|
+
})
|
|
347
|
+
),
|
|
348
|
+
groups: (i.permissionGroups ?? []).map(
|
|
349
|
+
(t) => U({
|
|
350
|
+
id: String(t.name ?? ""),
|
|
351
|
+
label: String(t.name ?? ""),
|
|
352
|
+
description: G(t.description),
|
|
353
|
+
permissions: Array.isArray(t.permissions) ? t.permissions : []
|
|
354
|
+
})
|
|
355
|
+
)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function pt(e, i) {
|
|
359
|
+
const t = V(e) ? e : {}, o = t.permissions ?? [], n = t.permissionGroups ?? [];
|
|
360
|
+
return {
|
|
361
|
+
...t,
|
|
362
|
+
permissions: i.permissions.map((s) => {
|
|
363
|
+
const r = o.find((l) => l.code === s.code);
|
|
364
|
+
return U({ ...r ?? {}, code: s.code, name: s.name, description: s.description });
|
|
365
|
+
}),
|
|
366
|
+
permissionGroups: i.groups.map((s) => {
|
|
367
|
+
const r = n.find((l) => l.name === s.id);
|
|
368
|
+
return U({
|
|
369
|
+
...r ?? {},
|
|
370
|
+
name: s.label,
|
|
371
|
+
description: s.description,
|
|
372
|
+
permissions: s.permissions
|
|
373
|
+
});
|
|
374
|
+
})
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
const mt = Ae({
|
|
378
|
+
id: "permissions",
|
|
379
|
+
label: "Permissions",
|
|
380
|
+
labelKey: "devStudio.kind.permissions",
|
|
381
|
+
icon: "shield",
|
|
382
|
+
editor: "permissions",
|
|
383
|
+
match: te(".permissions.json"),
|
|
384
|
+
select: dt,
|
|
385
|
+
assign: pt,
|
|
386
|
+
arrayKey: (e) => e === "/permissions" ? "code" : e === "/permissionGroups" ? "name" : void 0
|
|
387
|
+
}), ft = Ae({
|
|
388
|
+
id: "seeds",
|
|
389
|
+
label: "Seed data",
|
|
390
|
+
labelKey: "devStudio.kind.seeds",
|
|
391
|
+
icon: "database",
|
|
392
|
+
editor: "seeds",
|
|
393
|
+
match: te(".seeds.json"),
|
|
394
|
+
select: (e) => {
|
|
395
|
+
const i = V(e) ? e : {};
|
|
396
|
+
if (!V(i.seeds) || i.demoSeeds !== void 0 && !V(i.demoSeeds))
|
|
397
|
+
throw new Error("seeds is not an object of rows per entity");
|
|
398
|
+
return U({ seeds: i.seeds, demoSeeds: i.demoSeeds });
|
|
399
|
+
},
|
|
400
|
+
assign: (e, i) => U({ ...V(e) ? e : {}, seeds: i.seeds, demoSeeds: i.demoSeeds }),
|
|
401
|
+
arrayKey: () => "Id"
|
|
402
|
+
}), ut = {
|
|
403
|
+
id: "script",
|
|
404
|
+
label: "Script",
|
|
405
|
+
labelKey: "devStudio.kind.script",
|
|
406
|
+
icon: "code",
|
|
407
|
+
editor: "script",
|
|
408
|
+
match: (e) => /(^|\/)(services|scripts|jobs|handlers)\/[^/]+\.(js|ts|cs)$/i.test(e) || /\.cs$/i.test(e),
|
|
409
|
+
decode: (e) => e[0].text,
|
|
410
|
+
encode: (e, i) => ({
|
|
411
|
+
files: [{ path: i[0].path, text: Je(e, i[0].text) }]
|
|
412
|
+
})
|
|
413
|
+
}, yt = [
|
|
414
|
+
He,
|
|
415
|
+
Xe,
|
|
416
|
+
Qe,
|
|
417
|
+
ot,
|
|
418
|
+
ct,
|
|
419
|
+
mt,
|
|
420
|
+
ft,
|
|
421
|
+
ut
|
|
422
|
+
], gt = (e, i) => i, B = (e) => ({
|
|
423
|
+
type: "array",
|
|
424
|
+
title: e,
|
|
425
|
+
items: { type: "string" }
|
|
426
|
+
});
|
|
427
|
+
function ht(e = gt, i = {}) {
|
|
428
|
+
const t = (s, r) => e(`devStudio.omniverk.${s}`, r), o = {
|
|
429
|
+
type: "object",
|
|
430
|
+
properties: {
|
|
431
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
432
|
+
label: { type: "string", title: t("field.label", "Label") },
|
|
433
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
434
|
+
fieldType: {
|
|
435
|
+
type: "string",
|
|
436
|
+
title: t("field.fieldType", "Field type"),
|
|
437
|
+
enum: ["text", "select", "toggle", "number", "password"]
|
|
438
|
+
},
|
|
439
|
+
defaultValue: { type: "string", title: t("field.defaultValue", "Default value") },
|
|
440
|
+
isRequired: { type: "boolean", title: t("field.isRequired", "Required") },
|
|
441
|
+
isSensitive: { type: "boolean", title: t("field.isSensitive", "Sensitive") },
|
|
442
|
+
group: { type: "string", title: t("field.group", "Group") },
|
|
443
|
+
validationPattern: {
|
|
444
|
+
type: "string",
|
|
445
|
+
title: t("field.validationPattern", "Validation pattern")
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}, n = [
|
|
449
|
+
{
|
|
450
|
+
id: "general",
|
|
451
|
+
title: t("section.general", "General"),
|
|
452
|
+
schema: {
|
|
453
|
+
type: "object",
|
|
454
|
+
properties: {
|
|
455
|
+
packageName: { type: "string", title: t("field.packageName", "Package name") },
|
|
456
|
+
version: { type: "string", title: t("field.version", "Version") },
|
|
457
|
+
displayName: { type: "string", title: t("field.displayName", "Display name") },
|
|
458
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
459
|
+
category: { type: "string", title: t("field.category", "Category") },
|
|
460
|
+
subCategory: { type: "string", title: t("field.subCategory", "Sub-category") },
|
|
461
|
+
icon: { type: "string", title: t("field.icon", "Icon") },
|
|
462
|
+
author: { type: "string", title: t("field.author", "Author") },
|
|
463
|
+
license: { type: "string", title: t("field.license", "License") },
|
|
464
|
+
// seeds use free, standard, premium, pro, professional, core, enterprise, community…
|
|
465
|
+
tier: { type: "string", title: t("field.tier", "Tier") },
|
|
466
|
+
isCore: { type: "boolean", title: t("field.isCore", "Core module") },
|
|
467
|
+
allowMultipleInstances: {
|
|
468
|
+
type: "boolean",
|
|
469
|
+
title: t("field.allowMultipleInstances", "Allow several instances")
|
|
470
|
+
},
|
|
471
|
+
defaultInstanceName: {
|
|
472
|
+
type: "string",
|
|
473
|
+
title: t("field.defaultInstanceName", "Default instance name")
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
required: ["packageName", "version", "category"]
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: "modules",
|
|
481
|
+
title: t("section.modules", "Units"),
|
|
482
|
+
schema: {
|
|
483
|
+
type: "object",
|
|
484
|
+
properties: {
|
|
485
|
+
modules: {
|
|
486
|
+
type: "array",
|
|
487
|
+
title: t("field.modules", "Units"),
|
|
488
|
+
items: {
|
|
489
|
+
type: "object",
|
|
490
|
+
properties: {
|
|
491
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
492
|
+
displayName: { type: "string", title: t("field.displayName", "Display name") },
|
|
493
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
494
|
+
icon: { type: "string", title: t("field.icon", "Icon") },
|
|
495
|
+
color: { type: "string", title: t("field.color", "Colour") },
|
|
496
|
+
parts: B(t("field.parts", "Files"))
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
i18n: B(t("field.i18n", "Translation files"))
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
id: "dependencies",
|
|
506
|
+
title: t("section.dependencies", "Dependencies"),
|
|
507
|
+
schema: {
|
|
508
|
+
type: "object",
|
|
509
|
+
properties: {
|
|
510
|
+
dependencies: B(t("field.dependencies", "Required packages")),
|
|
511
|
+
dependencyRefs: {
|
|
512
|
+
type: "array",
|
|
513
|
+
title: t("field.dependencyRefs", "Dependency details"),
|
|
514
|
+
items: {
|
|
515
|
+
type: "object",
|
|
516
|
+
properties: {
|
|
517
|
+
package: { type: "string", title: t("field.package", "Package") },
|
|
518
|
+
isOptional: { type: "boolean", title: t("field.isOptional", "Optional") },
|
|
519
|
+
minVersion: { type: "string", title: t("field.minVersion", "Minimum version") },
|
|
520
|
+
reason: { type: "string", title: t("field.reason", "Reason") },
|
|
521
|
+
relationKind: {
|
|
522
|
+
type: "string",
|
|
523
|
+
title: t("field.relationKind", "Relation"),
|
|
524
|
+
enum: ["operational", "job", "event", "data-flow", "config"]
|
|
525
|
+
},
|
|
526
|
+
dataFlowDirection: {
|
|
527
|
+
type: "string",
|
|
528
|
+
title: t("field.dataFlowDirection", "Data flow")
|
|
529
|
+
},
|
|
530
|
+
instanceBinding: {
|
|
531
|
+
type: "string",
|
|
532
|
+
title: t("field.instanceBinding", "Instance binding")
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
provides: B(t("field.provides", "Provides")),
|
|
538
|
+
requiredControls: B(t("field.requiredControls", "Required controls"))
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: "setup",
|
|
544
|
+
title: t("section.setup", "Installation"),
|
|
545
|
+
schema: {
|
|
546
|
+
type: "object",
|
|
547
|
+
properties: {
|
|
548
|
+
setupWizard: {
|
|
549
|
+
type: "array",
|
|
550
|
+
title: t("field.setupWizard", "Setup wizard steps"),
|
|
551
|
+
items: {
|
|
552
|
+
type: "object",
|
|
553
|
+
properties: {
|
|
554
|
+
stepId: { type: "string", title: t("field.stepId", "Step id") },
|
|
555
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
556
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
557
|
+
icon: { type: "string", title: t("field.icon", "Icon") },
|
|
558
|
+
isOptional: { type: "boolean", title: t("field.isOptional", "Optional") },
|
|
559
|
+
order: { type: "integer", title: t("field.order", "Order") },
|
|
560
|
+
fields: { type: "array", title: t("field.fields", "Fields"), items: o }
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
installOptions: {
|
|
565
|
+
type: "array",
|
|
566
|
+
title: t("field.installOptions", "Install options"),
|
|
567
|
+
items: {
|
|
568
|
+
type: "object",
|
|
569
|
+
properties: {
|
|
570
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
571
|
+
label: { type: "string", title: t("field.label", "Label") },
|
|
572
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
573
|
+
optionType: {
|
|
574
|
+
type: "string",
|
|
575
|
+
title: t("field.optionType", "Option type"),
|
|
576
|
+
enum: ["toggle", "select"]
|
|
577
|
+
},
|
|
578
|
+
defaultValue: { type: "string", title: t("field.defaultValue", "Default value") },
|
|
579
|
+
isRequired: { type: "boolean", title: t("field.isRequired", "Required") }
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
onInstall: { type: "object", title: t("field.onInstall", "On install") }
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
id: "integrations",
|
|
589
|
+
title: t("section.integrations", "Integrations"),
|
|
590
|
+
schema: {
|
|
591
|
+
type: "object",
|
|
592
|
+
properties: {
|
|
593
|
+
integrations: {
|
|
594
|
+
type: "array",
|
|
595
|
+
title: t("field.integrations", "Integrations"),
|
|
596
|
+
items: {
|
|
597
|
+
type: "object",
|
|
598
|
+
properties: {
|
|
599
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
600
|
+
category: { type: "string", title: t("field.category", "Category") },
|
|
601
|
+
label: { type: "string", title: t("field.label", "Label") },
|
|
602
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
603
|
+
icon: { type: "string", title: t("field.icon", "Icon") },
|
|
604
|
+
selectionMode: {
|
|
605
|
+
type: "string",
|
|
606
|
+
title: t("field.selectionMode", "Selection"),
|
|
607
|
+
enum: ["multi", "single"]
|
|
608
|
+
},
|
|
609
|
+
optional: { type: "boolean", title: t("field.isOptional", "Optional") },
|
|
610
|
+
providers: {
|
|
611
|
+
type: "array",
|
|
612
|
+
title: t("field.providers", "Providers"),
|
|
613
|
+
items: {
|
|
614
|
+
type: "object",
|
|
615
|
+
properties: {
|
|
616
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
617
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
618
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
619
|
+
icon: { type: "string", title: t("field.icon", "Icon") },
|
|
620
|
+
profile: { type: "string", title: t("field.profile", "Profile") },
|
|
621
|
+
fields: {
|
|
622
|
+
type: "array",
|
|
623
|
+
title: t("field.fields", "Fields"),
|
|
624
|
+
items: o
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
id: "runtime",
|
|
637
|
+
title: t("section.runtime", "Runtime"),
|
|
638
|
+
schema: {
|
|
639
|
+
type: "object",
|
|
640
|
+
properties: {
|
|
641
|
+
dataSources: {
|
|
642
|
+
type: "array",
|
|
643
|
+
title: t("field.dataSources", "Data sources"),
|
|
644
|
+
items: {
|
|
645
|
+
type: "object",
|
|
646
|
+
properties: {
|
|
647
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
648
|
+
entity: { type: "string", title: t("field.entity", "Entity") },
|
|
649
|
+
description: { type: "string", title: t("field.description", "Description") }
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
routes: {
|
|
654
|
+
type: "array",
|
|
655
|
+
title: t("field.routes", "Routes"),
|
|
656
|
+
items: { type: "object" }
|
|
657
|
+
},
|
|
658
|
+
eventTriggers: {
|
|
659
|
+
type: "array",
|
|
660
|
+
title: t("field.eventTriggers", "Events"),
|
|
661
|
+
items: {
|
|
662
|
+
type: "object",
|
|
663
|
+
properties: {
|
|
664
|
+
event: { type: "string", title: t("field.event", "Event") },
|
|
665
|
+
description: { type: "string", title: t("field.description", "Description") }
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
actions: {
|
|
670
|
+
type: "array",
|
|
671
|
+
title: t("field.actions", "Actions"),
|
|
672
|
+
items: {
|
|
673
|
+
type: "object",
|
|
674
|
+
properties: {
|
|
675
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
676
|
+
label: { type: "string", title: t("field.label", "Label") },
|
|
677
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
678
|
+
input: { type: "string", title: t("field.input", "Input") }
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
id: "deployment",
|
|
687
|
+
title: t("section.deployment", "Deployment"),
|
|
688
|
+
schema: {
|
|
689
|
+
type: "object",
|
|
690
|
+
properties: {
|
|
691
|
+
envVars: {
|
|
692
|
+
type: "array",
|
|
693
|
+
title: t("field.envVars", "Environment variables"),
|
|
694
|
+
items: {
|
|
695
|
+
type: "object",
|
|
696
|
+
properties: {
|
|
697
|
+
key: { type: "string", title: t("field.key", "Key") },
|
|
698
|
+
defaultValue: { type: "string", title: t("field.defaultValue", "Default value") },
|
|
699
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
700
|
+
boundToField: { type: "string", title: t("field.boundToField", "Bound to field") }
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
dockerServices: {
|
|
705
|
+
type: "array",
|
|
706
|
+
title: t("field.dockerServices", "Docker services"),
|
|
707
|
+
items: {
|
|
708
|
+
type: "object",
|
|
709
|
+
properties: {
|
|
710
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
711
|
+
image: { type: "string", title: t("field.image", "Image") },
|
|
712
|
+
tag: { type: "string", title: t("field.tag", "Tag") },
|
|
713
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
714
|
+
ports: B(t("field.ports", "Ports")),
|
|
715
|
+
volumes: B(t("field.volumes", "Volumes")),
|
|
716
|
+
command: { type: "string", title: t("field.command", "Command") },
|
|
717
|
+
healthCheckCmd: {
|
|
718
|
+
type: "string",
|
|
719
|
+
title: t("field.healthCheckCmd", "Health check")
|
|
720
|
+
},
|
|
721
|
+
restartPolicy: {
|
|
722
|
+
type: "string",
|
|
723
|
+
title: t("field.restartPolicy", "Restart policy")
|
|
724
|
+
},
|
|
725
|
+
requiresOption: {
|
|
726
|
+
type: "string",
|
|
727
|
+
title: t("field.requiresOption", "Requires option")
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
];
|
|
736
|
+
if (i.scripting) {
|
|
737
|
+
const s = {
|
|
738
|
+
type: "string",
|
|
739
|
+
title: t("field.auth", "Access"),
|
|
740
|
+
enum: ["Anonymous", "User", "Admin"]
|
|
741
|
+
};
|
|
742
|
+
n.push({
|
|
743
|
+
id: "scripting",
|
|
744
|
+
title: t("section.scripting", "Server code"),
|
|
745
|
+
schema: {
|
|
746
|
+
type: "object",
|
|
747
|
+
properties: {
|
|
748
|
+
services: {
|
|
749
|
+
type: "array",
|
|
750
|
+
title: t("field.services", "Services"),
|
|
751
|
+
items: {
|
|
752
|
+
type: "object",
|
|
753
|
+
required: ["name", "language", "script"],
|
|
754
|
+
properties: {
|
|
755
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
756
|
+
scope: {
|
|
757
|
+
type: "string",
|
|
758
|
+
title: t("field.scope", "Lifetime"),
|
|
759
|
+
enum: ["scoped", "singleton", "transient"]
|
|
760
|
+
},
|
|
761
|
+
language: {
|
|
762
|
+
type: "string",
|
|
763
|
+
title: t("field.language", "Language"),
|
|
764
|
+
enum: ["js", "csharp"]
|
|
765
|
+
},
|
|
766
|
+
script: { type: "string", title: t("field.script", "Script") }
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
controllers: {
|
|
771
|
+
type: "array",
|
|
772
|
+
title: t("field.controllers", "Controllers"),
|
|
773
|
+
items: {
|
|
774
|
+
type: "object",
|
|
775
|
+
required: ["route"],
|
|
776
|
+
properties: {
|
|
777
|
+
route: { type: "string", title: t("field.route", "Route") },
|
|
778
|
+
auth: s,
|
|
779
|
+
actions: {
|
|
780
|
+
type: "array",
|
|
781
|
+
title: t("field.actions", "Actions"),
|
|
782
|
+
items: {
|
|
783
|
+
type: "object",
|
|
784
|
+
properties: {
|
|
785
|
+
verb: {
|
|
786
|
+
type: "string",
|
|
787
|
+
title: t("field.verb", "Method"),
|
|
788
|
+
enum: ["GET", "POST", "PUT", "PATCH", "DELETE"]
|
|
789
|
+
},
|
|
790
|
+
path: { type: "string", title: t("field.path", "Path") },
|
|
791
|
+
handler: { type: "string", title: t("field.handler", "Handler") },
|
|
792
|
+
auth: s
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
return n;
|
|
804
|
+
}
|
|
805
|
+
const W = "Custom.", Ne = "Core", wt = {
|
|
806
|
+
string: "string",
|
|
807
|
+
varchar: "string",
|
|
808
|
+
nvarchar: "string",
|
|
809
|
+
text: "text",
|
|
810
|
+
longtext: "text",
|
|
811
|
+
int: "int",
|
|
812
|
+
integer: "int",
|
|
813
|
+
int32: "int",
|
|
814
|
+
long: "long",
|
|
815
|
+
bigint: "long",
|
|
816
|
+
int64: "long",
|
|
817
|
+
decimal: "decimal",
|
|
818
|
+
double: "decimal",
|
|
819
|
+
float: "decimal",
|
|
820
|
+
number: "decimal",
|
|
821
|
+
currency: "currency",
|
|
822
|
+
money: "currency",
|
|
823
|
+
bool: "bool",
|
|
824
|
+
boolean: "bool",
|
|
825
|
+
datetime: "DateTime",
|
|
826
|
+
timestamp: "DateTime",
|
|
827
|
+
date: "DateOnly",
|
|
828
|
+
dateonly: "DateOnly",
|
|
829
|
+
time: "TimeOnly",
|
|
830
|
+
timeonly: "TimeOnly",
|
|
831
|
+
json: "json",
|
|
832
|
+
enum: "enum",
|
|
833
|
+
guid: "Guid",
|
|
834
|
+
uuid: "Guid"
|
|
835
|
+
}, vt = [
|
|
836
|
+
"string",
|
|
837
|
+
"text",
|
|
838
|
+
"int",
|
|
839
|
+
"long",
|
|
840
|
+
"decimal",
|
|
841
|
+
"currency",
|
|
842
|
+
"bool",
|
|
843
|
+
"DateTime",
|
|
844
|
+
"DateOnly",
|
|
845
|
+
"TimeOnly",
|
|
846
|
+
"json",
|
|
847
|
+
"enum",
|
|
848
|
+
"Guid"
|
|
849
|
+
], $t = {
|
|
850
|
+
ł: "l",
|
|
851
|
+
Ł: "L",
|
|
852
|
+
ß: "ss",
|
|
853
|
+
æ: "ae",
|
|
854
|
+
Æ: "AE",
|
|
855
|
+
ø: "o",
|
|
856
|
+
Ø: "O"
|
|
857
|
+
};
|
|
858
|
+
function bt(e) {
|
|
859
|
+
return [...e.normalize("NFD")].map((i) => $t[i] ?? (new RegExp("\\p{Mn}", "u").test(i) ? "" : i)).join("").normalize("NFC");
|
|
860
|
+
}
|
|
861
|
+
function R(e) {
|
|
862
|
+
const i = bt(e ?? "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join("");
|
|
863
|
+
return /^[0-9]/.test(i) ? `M${i}` : i;
|
|
864
|
+
}
|
|
865
|
+
const Te = (e) => e !== e.toLowerCase() && e === e.toUpperCase();
|
|
866
|
+
function he(e) {
|
|
867
|
+
return [...e].map(
|
|
868
|
+
(i, t) => t > 0 && Te(i) && !Te(e[t - 1]) ? `_${i.toLowerCase()}` : i.toLowerCase()
|
|
869
|
+
).join("");
|
|
870
|
+
}
|
|
871
|
+
function kt(e) {
|
|
872
|
+
return (e.startsWith(W) ? e.slice(W.length) : e.split(".").pop() ?? e).toLowerCase().replace(/[^a-z0-9_-]+/g, "") || "module";
|
|
873
|
+
}
|
|
874
|
+
async function Ke(e) {
|
|
875
|
+
const i = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
876
|
+
return new Uint8Array(i);
|
|
877
|
+
}
|
|
878
|
+
const ke = (e) => Array.from(e, (i) => i.toString(16).padStart(2, "0")).join("");
|
|
879
|
+
async function qe(e, i) {
|
|
880
|
+
const t = (await Ke(`${e}/${i}`.toLowerCase())).slice(0, 16), o = ke([3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15].map((n) => t[n]));
|
|
881
|
+
return `${o.slice(0, 8)}-${o.slice(8, 12)}-${o.slice(12, 16)}-${o.slice(16, 20)}-${o.slice(20)}`;
|
|
882
|
+
}
|
|
883
|
+
async function Ve(e, i) {
|
|
884
|
+
const t = `custom_${e}_${he(i)}`;
|
|
885
|
+
return t.length <= 63 ? t : `${t.slice(0, 54)}_${ke(await Ke(t)).slice(0, 8)}`;
|
|
886
|
+
}
|
|
887
|
+
function St(e, i) {
|
|
888
|
+
const t = new Set([...i].map((o) => o.toLowerCase()));
|
|
889
|
+
for (let o = 1; o < 100; o++) {
|
|
890
|
+
const n = o === 1 ? e : `${e}${o}`;
|
|
891
|
+
if (!t.has(n.toLowerCase()))
|
|
892
|
+
return n;
|
|
893
|
+
}
|
|
894
|
+
return e + ke(globalThis.crypto.getRandomValues(new Uint8Array(3)));
|
|
895
|
+
}
|
|
896
|
+
const ne = (e) => e.name.toLowerCase() === "id", q = (e) => {
|
|
897
|
+
var i;
|
|
898
|
+
return (((i = e.displayName) == null ? void 0 : i.trim()) || e.name).trim();
|
|
899
|
+
};
|
|
900
|
+
function se(e) {
|
|
901
|
+
return e.isForeignKey ? "Guid" : wt[String(e.dataType ?? "").trim().toLowerCase()] ?? "string";
|
|
902
|
+
}
|
|
903
|
+
function pe(e) {
|
|
904
|
+
if (e.isForeignKey)
|
|
905
|
+
return ["Reference", "lookup"];
|
|
906
|
+
switch (se(e)) {
|
|
907
|
+
case "text":
|
|
908
|
+
case "json":
|
|
909
|
+
return ["Text", "textarea"];
|
|
910
|
+
case "int":
|
|
911
|
+
case "long":
|
|
912
|
+
case "decimal":
|
|
913
|
+
return ["Number", "number"];
|
|
914
|
+
case "currency":
|
|
915
|
+
return ["Currency", "currency"];
|
|
916
|
+
case "bool":
|
|
917
|
+
return ["Boolean", "toggle"];
|
|
918
|
+
case "DateTime":
|
|
919
|
+
return ["DateTime", "datetime"];
|
|
920
|
+
case "DateOnly":
|
|
921
|
+
return ["Date", "date"];
|
|
922
|
+
default:
|
|
923
|
+
return ["Text", "input"];
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
const Nt = {
|
|
927
|
+
lookup: "EntitySelect",
|
|
928
|
+
textarea: "Textarea",
|
|
929
|
+
number: "number",
|
|
930
|
+
currency: "number",
|
|
931
|
+
toggle: "Toggle",
|
|
932
|
+
date: "date",
|
|
933
|
+
datetime: "datetime"
|
|
934
|
+
};
|
|
935
|
+
function Tt(e) {
|
|
936
|
+
var o;
|
|
937
|
+
const i = [];
|
|
938
|
+
(!((o = e.name) != null && o.trim()) || R(e.name).length === 0) && i.push("The module needs a name with letters or digits."), e.entities.length === 0 && i.push("The module has no entities — add at least one.");
|
|
939
|
+
const t = /* @__PURE__ */ new Set();
|
|
940
|
+
for (const n of e.entities) {
|
|
941
|
+
const s = R(n.name);
|
|
942
|
+
if (s.length === 0) {
|
|
943
|
+
i.push(`Entity "${n.name}" needs a name with letters or digits.`);
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
t.has(s.toLowerCase()) && i.push(`Entity ${s} appears twice.`), t.add(s.toLowerCase());
|
|
947
|
+
const r = n.fields.filter((y) => !ne(y));
|
|
948
|
+
r.length === 0 && i.push(`Entity ${s} has no fields — add at least one.`);
|
|
949
|
+
const l = /* @__PURE__ */ new Set();
|
|
950
|
+
for (const y of r) {
|
|
951
|
+
const c = R(y.name);
|
|
952
|
+
c.length === 0 ? i.push(`${s}: field "${y.name}" needs a name with letters or digits.`) : l.has(c.toLowerCase()) ? i.push(`${s}: field ${c} appears twice.`) : l.add(c.toLowerCase());
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return i;
|
|
956
|
+
}
|
|
957
|
+
const jt = (e) => e.toISOString().replace(/\.(\d{3})Z$/, ".$10000Z"), Y = (e) => de(e, { finalNewline: !1 }), J = (e, i) => ({
|
|
958
|
+
icon: { name: e, package: "@nice2dev/icons", style: i }
|
|
959
|
+
});
|
|
960
|
+
function xt(e) {
|
|
961
|
+
const i = e && /^Ntd[A-Z]/.test(e), t = e && /^[A-Z]\w*Icon$/.test(e);
|
|
962
|
+
return {
|
|
963
|
+
module: {
|
|
964
|
+
icon: {
|
|
965
|
+
name: i || t ? e : "NtdGrid",
|
|
966
|
+
package: t ? "@nice2dev/icons-business" : "@nice2dev/icons",
|
|
967
|
+
style: "duotone"
|
|
968
|
+
},
|
|
969
|
+
animation: { type: "none" }
|
|
970
|
+
},
|
|
971
|
+
entities: {},
|
|
972
|
+
views: { list: J("NtdList", "outline"), form: J("NtdEdit", "outline") },
|
|
973
|
+
permissions: {
|
|
974
|
+
read: J("NtdEye", "outline"),
|
|
975
|
+
create: J("NtdPlus", "outline"),
|
|
976
|
+
update: J("NtdEdit", "outline"),
|
|
977
|
+
delete: J("NtdTrash", "outline"),
|
|
978
|
+
admin: J("NtdShield", "solid")
|
|
979
|
+
},
|
|
980
|
+
workflowStates: {}
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
async function Et(e, i = {}) {
|
|
984
|
+
var T, L, I, M;
|
|
985
|
+
const t = Tt(e);
|
|
986
|
+
if (t.length > 0)
|
|
987
|
+
return { problems: t };
|
|
988
|
+
const o = e.name.toLowerCase().startsWith(W.toLowerCase()), n = R(
|
|
989
|
+
o ? e.name.slice(W.length) : e.name
|
|
990
|
+
), s = St(
|
|
991
|
+
W + n,
|
|
992
|
+
i.existingPackageNames ?? /* @__PURE__ */ new Set()
|
|
993
|
+
), r = s.slice(W.length), l = r.toLowerCase(), y = `${s}.${Ne}`, c = o ? r : e.name.trim(), m = ((T = e.description) == null ? void 0 : T.trim()) || void 0, b = e.entities.map((E) => ({ ...E, name: R(E.name) })), C = e.views !== !1, S = e.permissions !== !1, N = [.../* @__PURE__ */ new Set(["en", "pl", ...e.locales ?? []])], x = e.icon ?? "widgets", d = [], $ = [
|
|
994
|
+
`${l}.entities.json`,
|
|
995
|
+
...C ? [`${l}.views.json`] : [],
|
|
996
|
+
...S ? [`${l}.permissions.json`] : []
|
|
997
|
+
];
|
|
998
|
+
d.push({
|
|
999
|
+
path: `${l}.manifest.json`,
|
|
1000
|
+
text: Y({
|
|
1001
|
+
packageName: s,
|
|
1002
|
+
version: "1.0.0",
|
|
1003
|
+
displayName: c,
|
|
1004
|
+
description: m ?? c,
|
|
1005
|
+
author: "OmniVerk Module Builder",
|
|
1006
|
+
license: "Proprietary",
|
|
1007
|
+
category: ((L = e.category) == null ? void 0 : L.trim()) || "Custom",
|
|
1008
|
+
icon: x,
|
|
1009
|
+
exportedAt: jt((i.now ?? (() => /* @__PURE__ */ new Date()))()),
|
|
1010
|
+
modules: [
|
|
1011
|
+
{
|
|
1012
|
+
name: Ne,
|
|
1013
|
+
displayName: c,
|
|
1014
|
+
description: e.description ?? c,
|
|
1015
|
+
icon: x,
|
|
1016
|
+
parts: $
|
|
1017
|
+
}
|
|
1018
|
+
],
|
|
1019
|
+
dependencies: ["Core.Users"],
|
|
1020
|
+
i18n: N.map((E) => `${l}.${E}.i18n.json`),
|
|
1021
|
+
...e.ownerTenantId ? { ownerTenantId: e.ownerTenantId } : {},
|
|
1022
|
+
...e.sourceDefinitionId ? { sourceDefinitionId: e.sourceDefinitionId } : {}
|
|
1023
|
+
})
|
|
1024
|
+
});
|
|
1025
|
+
const u = [];
|
|
1026
|
+
for (const E of b) {
|
|
1027
|
+
const j = [{ name: "Id", displayName: "ID", dataType: "Guid", isPrimaryKey: !0 }];
|
|
1028
|
+
for (const v of E.fields.filter((O) => !ne(O))) {
|
|
1029
|
+
const O = se(v), a = {
|
|
1030
|
+
name: R(v.name),
|
|
1031
|
+
displayName: q(v),
|
|
1032
|
+
dataType: O
|
|
1033
|
+
};
|
|
1034
|
+
O === "string" && (a.maxLength = v.maxLength && v.maxLength > 0 ? v.maxLength : 200), v.isRequired && (a.isRequired = !0), v.isUnique && (a.isUnique = !0), (v.isIndexed || v.isForeignKey) && (a.isIndexed = !0), v.isForeignKey && (a.isForeignKey = !0, v.referencedEntity && (a.referencedEntity = R(v.referencedEntity))), (I = v.defaultValue) != null && I.trim() && (a.defaultValue = v.defaultValue), (M = v.description) != null && M.trim() && (a.description = v.description), j.push(a);
|
|
1035
|
+
}
|
|
1036
|
+
u.push({
|
|
1037
|
+
id: await qe(s, E.name),
|
|
1038
|
+
name: E.name,
|
|
1039
|
+
displayName: q(E),
|
|
1040
|
+
tableName: await Ve(l, E.name),
|
|
1041
|
+
description: E.description ?? q(E),
|
|
1042
|
+
entityIcon: E.icon ?? "table_rows",
|
|
1043
|
+
isAudited: !0,
|
|
1044
|
+
isSoftDeleteEnabled: !1,
|
|
1045
|
+
fields: j
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
if (d.push({
|
|
1049
|
+
path: `${l}.entities.json`,
|
|
1050
|
+
text: Y({ moduleName: y, version: "1.0.0", entities: u })
|
|
1051
|
+
}), C) {
|
|
1052
|
+
const E = (v) => {
|
|
1053
|
+
const O = b.find((p) => p.name === R(v)), a = O == null ? void 0 : O.fields.find(
|
|
1054
|
+
(p) => !ne(p) && !p.isForeignKey && se(p) === "string"
|
|
1055
|
+
);
|
|
1056
|
+
return a ? R(a.name) : "Name";
|
|
1057
|
+
}, j = [];
|
|
1058
|
+
for (const v of b) {
|
|
1059
|
+
const O = v.fields.filter((f) => !ne(f)), a = O.filter((f) => !["text", "json"].includes(se(f))).slice(0, 6), p = (a.length ? a : [O[0]]).map((f) => ({
|
|
1060
|
+
field: R(f.name),
|
|
1061
|
+
displayName: q(f),
|
|
1062
|
+
sortable: !0,
|
|
1063
|
+
type: pe(f)[0],
|
|
1064
|
+
...f.isForeignKey && f.referencedEntity ? { referencedEntity: R(f.referencedEntity) } : {}
|
|
1065
|
+
})), g = O.filter((f) => ["string", "text"].includes(se(f))).map((f) => R(f.name)), h = O.map((f) => ({
|
|
1066
|
+
field: R(f.name),
|
|
1067
|
+
type: Nt[pe(f)[1]] ?? "TextInput",
|
|
1068
|
+
label: q(f),
|
|
1069
|
+
...f.isRequired ? { required: !0 } : {},
|
|
1070
|
+
...f.isForeignKey && f.referencedEntity ? {
|
|
1071
|
+
entity: R(f.referencedEntity),
|
|
1072
|
+
displayField: E(f.referencedEntity)
|
|
1073
|
+
} : {}
|
|
1074
|
+
}));
|
|
1075
|
+
j.push({
|
|
1076
|
+
id: `vw-${l}-${he(v.name)}-list`,
|
|
1077
|
+
name: `${v.name}List`,
|
|
1078
|
+
displayName: q(v),
|
|
1079
|
+
type: "List",
|
|
1080
|
+
icon: "list",
|
|
1081
|
+
entityName: v.name,
|
|
1082
|
+
columns: p,
|
|
1083
|
+
searchFields: g,
|
|
1084
|
+
pageSize: 25,
|
|
1085
|
+
createControls: h,
|
|
1086
|
+
allowEdit: !0,
|
|
1087
|
+
allowDelete: !0
|
|
1088
|
+
});
|
|
1089
|
+
const k = O.map((f) => {
|
|
1090
|
+
const w = pe(f)[1];
|
|
1091
|
+
return {
|
|
1092
|
+
field: R(f.name),
|
|
1093
|
+
type: w,
|
|
1094
|
+
label: q(f),
|
|
1095
|
+
colSpan: w === "textarea" ? 12 : 6,
|
|
1096
|
+
...f.isRequired ? { required: !0 } : {},
|
|
1097
|
+
...f.isForeignKey && f.referencedEntity ? { entity: R(f.referencedEntity) } : {}
|
|
1098
|
+
};
|
|
1099
|
+
});
|
|
1100
|
+
j.push({
|
|
1101
|
+
id: `vw-${l}-${he(v.name)}-form`,
|
|
1102
|
+
name: `${v.name}Form`,
|
|
1103
|
+
displayName: q(v),
|
|
1104
|
+
type: "Form",
|
|
1105
|
+
icon: "edit",
|
|
1106
|
+
entityName: v.name,
|
|
1107
|
+
tabs: [
|
|
1108
|
+
{
|
|
1109
|
+
name: "Main",
|
|
1110
|
+
displayName: q(v),
|
|
1111
|
+
sections: [{ name: "Details", displayName: "Details", controls: k }]
|
|
1112
|
+
}
|
|
1113
|
+
]
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
d.push({
|
|
1117
|
+
path: `${l}.views.json`,
|
|
1118
|
+
text: Y({ moduleName: y, version: "1.0.0", views: j })
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
if (S) {
|
|
1122
|
+
const E = (O) => `${r}.${O}`, j = (O, a) => ({
|
|
1123
|
+
code: E(O),
|
|
1124
|
+
name: `${c} — ${a}`,
|
|
1125
|
+
description: `${a}: ${c}`
|
|
1126
|
+
}), v = (O, a, ...p) => ({
|
|
1127
|
+
name: `${W}${r} ${O}`,
|
|
1128
|
+
description: `${c} — ${a}`,
|
|
1129
|
+
permissions: p.map(E)
|
|
1130
|
+
});
|
|
1131
|
+
d.push({
|
|
1132
|
+
path: `${l}.permissions.json`,
|
|
1133
|
+
text: Y({
|
|
1134
|
+
moduleName: y,
|
|
1135
|
+
version: "1.0.0",
|
|
1136
|
+
permissions: [
|
|
1137
|
+
j("Read", "view records"),
|
|
1138
|
+
j("Create", "add records"),
|
|
1139
|
+
j("Edit", "edit records"),
|
|
1140
|
+
j("Delete", "delete records"),
|
|
1141
|
+
j("Admin", "administer the module")
|
|
1142
|
+
],
|
|
1143
|
+
permissionGroups: [
|
|
1144
|
+
v("Viewer", "read only", "Read"),
|
|
1145
|
+
v("Editor", "read and edit", "Read", "Create", "Edit"),
|
|
1146
|
+
v("Admin", "full access", "Read", "Create", "Edit", "Delete", "Admin")
|
|
1147
|
+
]
|
|
1148
|
+
})
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
for (const E of N) {
|
|
1152
|
+
const j = {
|
|
1153
|
+
"module.displayName": c,
|
|
1154
|
+
"module.description": m ?? c
|
|
1155
|
+
};
|
|
1156
|
+
for (const v of b) {
|
|
1157
|
+
j[`entity.${v.name}.displayName`] = q(v);
|
|
1158
|
+
for (const O of v.fields.filter((a) => !ne(a)))
|
|
1159
|
+
j[`field.${v.name}.${R(O.name)}.displayName`] = q(O);
|
|
1160
|
+
C && (j[`view.${v.name}List.displayName`] = q(v), j[`view.${v.name}Form.displayName`] = q(v), j[`view.${v.name}Form.tab.Main`] = q(v), j[`view.${v.name}Form.section.Details`] = E === "pl" ? "Szczegóły" : "Details");
|
|
1161
|
+
}
|
|
1162
|
+
d.push({
|
|
1163
|
+
path: `${l}.${E}.i18n.json`,
|
|
1164
|
+
text: Y({ moduleName: s, locale: E, version: "1.0.0", translations: j })
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
return e.iconConfig !== !1 && d.push({ path: `${l}.iconconfig.json`, text: Y(xt(e.icon)) }), { package: { packageName: s, folder: `Custom/${r}`, files: d }, problems: [] };
|
|
1168
|
+
}
|
|
1169
|
+
function It(e) {
|
|
1170
|
+
const i = (t) => typeof t == "string" && t ? t : void 0;
|
|
1171
|
+
return {
|
|
1172
|
+
name: e.name,
|
|
1173
|
+
description: e.description,
|
|
1174
|
+
category: e.packageId,
|
|
1175
|
+
icon: e.icon,
|
|
1176
|
+
locales: e.locales,
|
|
1177
|
+
views: e.views,
|
|
1178
|
+
permissions: e.permissions,
|
|
1179
|
+
entities: e.entities.map((t) => ({
|
|
1180
|
+
name: String(t.name ?? ""),
|
|
1181
|
+
displayName: i(t.displayName),
|
|
1182
|
+
description: i(t.description),
|
|
1183
|
+
icon: i(t.entityIcon) ?? i(t.icon),
|
|
1184
|
+
fields: (Array.isArray(t.fields) ? t.fields : []).map((o) => ({
|
|
1185
|
+
name: String(o.name ?? ""),
|
|
1186
|
+
displayName: i(o.displayName),
|
|
1187
|
+
dataType: i(o.dataType) ?? i(o.type),
|
|
1188
|
+
isRequired: o.isRequired === !0 || o.required === !0,
|
|
1189
|
+
maxLength: typeof o.maxLength == "number" ? o.maxLength : void 0,
|
|
1190
|
+
isUnique: o.isUnique === !0,
|
|
1191
|
+
isIndexed: o.isIndexed === !0,
|
|
1192
|
+
isForeignKey: o.isForeignKey === !0,
|
|
1193
|
+
referencedEntity: i(o.referencedEntity),
|
|
1194
|
+
defaultValue: o.defaultValue === void 0 || o.defaultValue === null ? void 0 : String(o.defaultValue),
|
|
1195
|
+
description: i(o.description)
|
|
1196
|
+
}))
|
|
1197
|
+
}))
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
const H = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
|
|
1201
|
+
function we(e, i) {
|
|
1202
|
+
return typeof e == "string" ? i(e) : Array.isArray(e) ? e.map((t) => we(t, i)) : H(e) ? Object.fromEntries(Object.entries(e).map(([t, o]) => [t, we(o, i)])) : e;
|
|
1203
|
+
}
|
|
1204
|
+
const Ct = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1205
|
+
async function Ot(e, i) {
|
|
1206
|
+
const t = e.find(
|
|
1207
|
+
(d) => !d.path.includes("/") && d.path.toLowerCase().endsWith(".manifest.json")
|
|
1208
|
+
);
|
|
1209
|
+
if (!t)
|
|
1210
|
+
throw new Error("The module has no manifest.");
|
|
1211
|
+
const o = _(t.text).value, n = String(o.packageName ?? ""), s = t.path.slice(0, -14), r = i.id, l = kt(r), y = (d) => d.startsWith(W) ? d.slice(W.length) : d.split(".").pop() ?? d, c = y(n), m = y(r), b = (d) => d.startsWith(`${s}.`) ? `${l}${d.slice(s.length)}` : d, C = new Map(e.map((d) => [d.path, b(d.path)])), S = /* @__PURE__ */ new Map();
|
|
1212
|
+
for (const d of e.filter(($) => $.path.toLowerCase().endsWith(".permissions.json")))
|
|
1213
|
+
try {
|
|
1214
|
+
const $ = _(d.text).value;
|
|
1215
|
+
for (const u of H($) && Array.isArray($.permissions) ? $.permissions : []) {
|
|
1216
|
+
const T = typeof u.code == "string" ? u.code : "";
|
|
1217
|
+
T.startsWith(`${c}.`) && S.set(T, `${m}${T.slice(c.length)}`);
|
|
1218
|
+
}
|
|
1219
|
+
} catch {
|
|
1220
|
+
}
|
|
1221
|
+
const N = (d) => n && (d === n || d.startsWith(`${n}.`) || d.startsWith(`${n} `)) ? r + d.slice(n.length) : S.get(d) ?? C.get(d) ?? d, x = [];
|
|
1222
|
+
for (const d of e) {
|
|
1223
|
+
if (d.path.startsWith(".revisions/"))
|
|
1224
|
+
continue;
|
|
1225
|
+
const $ = b(d.path);
|
|
1226
|
+
if (!d.path.toLowerCase().endsWith(".json")) {
|
|
1227
|
+
x.push({ path: $, text: d.text });
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
let u;
|
|
1231
|
+
try {
|
|
1232
|
+
u = _(d.text).value;
|
|
1233
|
+
} catch {
|
|
1234
|
+
x.push({ path: $, text: d.text });
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
let T = we(u, N);
|
|
1238
|
+
if (d === t && H(T)) {
|
|
1239
|
+
const { sourceDefinitionId: L, ...I } = T;
|
|
1240
|
+
T = {
|
|
1241
|
+
...I,
|
|
1242
|
+
packageName: r,
|
|
1243
|
+
...i.name ? { displayName: i.name } : {},
|
|
1244
|
+
...i.packageId ? { category: i.packageId } : {}
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
if (d.path.toLowerCase().endsWith(".entities.json") && H(T) && Array.isArray(T.entities)) {
|
|
1248
|
+
const L = [];
|
|
1249
|
+
for (const I of T.entities) {
|
|
1250
|
+
if (!H(I) || typeof I.name != "string") {
|
|
1251
|
+
L.push(I);
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
L.push({
|
|
1255
|
+
...I,
|
|
1256
|
+
...typeof I.id == "string" && Ct.test(I.id) ? { id: await qe(r, I.name) } : {},
|
|
1257
|
+
...typeof I.tableName == "string" ? { tableName: await Ve(l, I.name) } : {}
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
T = { ...T, entities: L };
|
|
1261
|
+
}
|
|
1262
|
+
i.name && /\.en\.i18n\.json$/i.test(d.path) && H(T) && H(T.translations) && typeof T.translations["module.displayName"] == "string" && (T = {
|
|
1263
|
+
...T,
|
|
1264
|
+
translations: { ...T.translations, "module.displayName": i.name }
|
|
1265
|
+
}), x.push({ path: $, text: De(d.text, T) });
|
|
1266
|
+
}
|
|
1267
|
+
return {
|
|
1268
|
+
id: r,
|
|
1269
|
+
packageId: i.packageId ?? o.category,
|
|
1270
|
+
files: x
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
const F = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Q = (e, i) => F(e) && Array.isArray(e[i]) ? e[i] : [], oe = (e, i) => e.toLowerCase().endsWith(i), ve = (e) => !e.includes("/"), At = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/, Lt = [
|
|
1274
|
+
"ING Bank Śląski",
|
|
1275
|
+
"Bank Śląski",
|
|
1276
|
+
"BOŚ",
|
|
1277
|
+
"e-Zamówienia",
|
|
1278
|
+
"eZamówienia",
|
|
1279
|
+
"Plataforma de Contratación del Sector Público"
|
|
1280
|
+
], ae = (e) => At.test(Lt.reduce((i, t) => i.split(t).join(""), e)), Dt = /* @__PURE__ */ new Set([
|
|
1281
|
+
"module",
|
|
1282
|
+
"entity",
|
|
1283
|
+
"field",
|
|
1284
|
+
"view",
|
|
1285
|
+
"status",
|
|
1286
|
+
"nav",
|
|
1287
|
+
"action",
|
|
1288
|
+
"tutorial"
|
|
1289
|
+
]), Mt = /* @__PURE__ */ new Set(["int", "int32", "int64", "long", "integer"]);
|
|
1290
|
+
function Ft(e) {
|
|
1291
|
+
for (let i = 0; i < e.length; i++) {
|
|
1292
|
+
const t = e.charCodeAt(i);
|
|
1293
|
+
if (t >= 55296 && t <= 56319 || t >= 9728 && t <= 10175)
|
|
1294
|
+
return !0;
|
|
1295
|
+
}
|
|
1296
|
+
return !1;
|
|
1297
|
+
}
|
|
1298
|
+
function je(e) {
|
|
1299
|
+
if (!F(e))
|
|
1300
|
+
return [];
|
|
1301
|
+
const i = F(e.translations) ? e.translations : F(e.keys) ? e.keys : void 0;
|
|
1302
|
+
return i ? Object.entries(i) : [];
|
|
1303
|
+
}
|
|
1304
|
+
const xe = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Pt = /* @__PURE__ */ new Set([
|
|
1305
|
+
"hotel.views.json",
|
|
1306
|
+
"restaurant.views.json",
|
|
1307
|
+
"backup-dr.views.json",
|
|
1308
|
+
"association.views.json",
|
|
1309
|
+
"listings.views.json",
|
|
1310
|
+
"shelf_management.views.json",
|
|
1311
|
+
"psa.views.json"
|
|
1312
|
+
]);
|
|
1313
|
+
function Rt(e, i = {}) {
|
|
1314
|
+
const t = new Set(
|
|
1315
|
+
[...i.legacyListViewFiles ?? Pt].map(
|
|
1316
|
+
(d) => d.toLowerCase()
|
|
1317
|
+
)
|
|
1318
|
+
), o = [], n = (d) => {
|
|
1319
|
+
o.push({ severity: "error", ...d });
|
|
1320
|
+
}, s = [];
|
|
1321
|
+
for (const d of e.files)
|
|
1322
|
+
if (!(!oe(d.path, ".json") || d.path.startsWith(".revisions/")))
|
|
1323
|
+
try {
|
|
1324
|
+
s.push({ file: d, value: _(d.text).value });
|
|
1325
|
+
} catch ($) {
|
|
1326
|
+
n({
|
|
1327
|
+
code: "json.invalid",
|
|
1328
|
+
message: `${d.path} is not valid JSON: ${$ instanceof Error ? $.message : String($)}`,
|
|
1329
|
+
path: d.path
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
const r = (d) => s.filter(($) => ve($.file.path) && oe($.file.path, d)), l = r(".manifest.json");
|
|
1333
|
+
l.length === 0 && n({
|
|
1334
|
+
code: "manifest.missing",
|
|
1335
|
+
message: "The module has no *.manifest.json.",
|
|
1336
|
+
messageKey: "devStudio.issue.manifestMissing"
|
|
1337
|
+
});
|
|
1338
|
+
for (const { file: d, value: $ } of l)
|
|
1339
|
+
for (const u of ["packageName", "version", "category"])
|
|
1340
|
+
(!F($) || !(u in $)) && n({
|
|
1341
|
+
code: "manifest.required",
|
|
1342
|
+
message: `The manifest needs "${u}".`,
|
|
1343
|
+
messageKey: "devStudio.issue.manifestRequired",
|
|
1344
|
+
params: { field: u },
|
|
1345
|
+
path: d.path,
|
|
1346
|
+
pointer: `/${u}`
|
|
1347
|
+
});
|
|
1348
|
+
const y = r(".iconconfig.json");
|
|
1349
|
+
y.length === 0 && n({
|
|
1350
|
+
severity: "info",
|
|
1351
|
+
code: "iconconfig.missing",
|
|
1352
|
+
message: "The module has no *.iconconfig.json: its menu shows a default icon (the CI wants one in every Category/Module folder)."
|
|
1353
|
+
});
|
|
1354
|
+
for (const { file: d, value: $ } of y) {
|
|
1355
|
+
const u = F($) ? $.module : void 0, T = F(u) ? u.icon : void 0, L = [
|
|
1356
|
+
...F(u) ? [] : ["module"],
|
|
1357
|
+
...F(u) && !F(T) ? ["module.icon"] : [],
|
|
1358
|
+
...F(T) && !("name" in T) ? ["module.icon.name"] : [],
|
|
1359
|
+
...F(T) && !("package" in T) ? ["module.icon.package"] : [],
|
|
1360
|
+
...["views", "permissions", "workflowStates"].filter(
|
|
1361
|
+
(I) => !F($) || !(I in $)
|
|
1362
|
+
)
|
|
1363
|
+
];
|
|
1364
|
+
for (const I of L)
|
|
1365
|
+
n({
|
|
1366
|
+
code: "iconconfig.structure",
|
|
1367
|
+
message: `The icon config needs "${I}".`,
|
|
1368
|
+
params: { field: I },
|
|
1369
|
+
path: d.path,
|
|
1370
|
+
pointer: `/${I.split(".").join("/")}`
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
const c = [], m = [];
|
|
1374
|
+
for (const { file: d, value: $ } of r(".entities.json")) {
|
|
1375
|
+
if (!F($) || !("entities" in $))
|
|
1376
|
+
continue;
|
|
1377
|
+
const u = [], T = $.entities;
|
|
1378
|
+
if (!Array.isArray(T) || T.length === 0) {
|
|
1379
|
+
n({
|
|
1380
|
+
code: "entities.empty",
|
|
1381
|
+
message: "The file has no entities.",
|
|
1382
|
+
path: d.path,
|
|
1383
|
+
pointer: "/entities"
|
|
1384
|
+
});
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
T.forEach((L, I) => {
|
|
1388
|
+
const M = `/entities/${I}`, E = F(L) && typeof L.name == "string" ? L.name : void 0;
|
|
1389
|
+
if (E ? c.push(E) : n({
|
|
1390
|
+
code: "entities.name",
|
|
1391
|
+
message: `Entity #${I + 1} has no name.`,
|
|
1392
|
+
path: d.path,
|
|
1393
|
+
pointer: M
|
|
1394
|
+
}), !F(L) || !Array.isArray(L.fields)) {
|
|
1395
|
+
n({
|
|
1396
|
+
code: "entities.fields",
|
|
1397
|
+
message: `Entity ${E ?? `#${I + 1}`} has no fields array.`,
|
|
1398
|
+
path: d.path,
|
|
1399
|
+
pointer: M
|
|
1400
|
+
});
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
F(L) && typeof L.displayName == "string" && ae(L.displayName) && n({
|
|
1404
|
+
code: "labels.polish",
|
|
1405
|
+
message: `Entity ${E}: the display name "${L.displayName}" is Polish — seed labels are English, Polish goes to the .pl bundle.`,
|
|
1406
|
+
path: d.path,
|
|
1407
|
+
pointer: `${M}/displayName`
|
|
1408
|
+
}), L.fields.forEach((j, v) => {
|
|
1409
|
+
if (!F(j))
|
|
1410
|
+
return;
|
|
1411
|
+
const O = typeof j.name == "string" ? j.name : void 0, a = `${M}/fields/${v}`;
|
|
1412
|
+
E && O && j.isPrimaryKey !== !0 && m.push(`field.${E}.${O}`);
|
|
1413
|
+
const p = typeof j.dataType == "string" ? j.dataType.replace(/\?+$/, "") : void 0;
|
|
1414
|
+
p === void 0 && typeof j.type == "string" && u.push({ name: `${E}.${O}`, pointer: `${a}/type` }), p && Mt.has(p.toLowerCase()) && (O === "Id" || j.isForeignKey === !0) && n({
|
|
1415
|
+
code: "entities.keyNotGuid",
|
|
1416
|
+
message: `${E}.${O} is ${p}: keys must be Guid (every row's Id is a uuid).`,
|
|
1417
|
+
path: d.path,
|
|
1418
|
+
pointer: `${a}/dataType`
|
|
1419
|
+
}), typeof j.displayName == "string" && ae(j.displayName) && n({
|
|
1420
|
+
code: "labels.polish",
|
|
1421
|
+
message: `${E}.${O}: the display name "${j.displayName}" is Polish — seed labels are English.`,
|
|
1422
|
+
path: d.path,
|
|
1423
|
+
pointer: `${a}/displayName`
|
|
1424
|
+
});
|
|
1425
|
+
});
|
|
1426
|
+
}), u.length && n({
|
|
1427
|
+
severity: "warning",
|
|
1428
|
+
code: "entities.typeIgnored",
|
|
1429
|
+
message: `${u.length} field(s) give their type as "type", which installing ignores — it reads "dataType": ${u.slice(0, 5).map((L) => L.name).join(", ")}${u.length > 5 ? ", …" : ""}`,
|
|
1430
|
+
params: { count: u.length },
|
|
1431
|
+
path: d.path,
|
|
1432
|
+
pointer: u[0].pointer
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
for (const { file: d, value: $ } of r(".permissions.json"))
|
|
1436
|
+
(!F($) || !Array.isArray($.permissions) || $.permissions.length === 0) && n({
|
|
1437
|
+
code: "permissions.empty",
|
|
1438
|
+
message: 'The file needs a non-empty "permissions" array.',
|
|
1439
|
+
path: d.path,
|
|
1440
|
+
pointer: "/permissions"
|
|
1441
|
+
});
|
|
1442
|
+
const b = [];
|
|
1443
|
+
for (const { file: d, value: $ } of r(".views.json")) {
|
|
1444
|
+
if (!F($) || Object.keys($).length === 0) {
|
|
1445
|
+
n({
|
|
1446
|
+
code: "views.empty",
|
|
1447
|
+
message: "A views file is a JSON object with at least one property.",
|
|
1448
|
+
path: d.path
|
|
1449
|
+
});
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
Q($, "views").forEach((u, T) => {
|
|
1453
|
+
if (!F(u))
|
|
1454
|
+
return;
|
|
1455
|
+
const L = `/views/${T}`, I = typeof u.name == "string" ? u.name : "(unnamed)";
|
|
1456
|
+
typeof u.name == "string" && b.push(u.name), typeof u.type == "string" && u.type.toLowerCase() === "list" && !t.has(d.path.toLowerCase()) && (typeof u.entityName != "string" || !u.entityName.trim() ? n({
|
|
1457
|
+
code: "views.listEntity",
|
|
1458
|
+
message: `List view ${I} needs a top-level "entityName".`,
|
|
1459
|
+
path: d.path,
|
|
1460
|
+
pointer: L
|
|
1461
|
+
}) : (!Array.isArray(u.columns) || u.columns.length === 0) && n({
|
|
1462
|
+
code: "views.listColumns",
|
|
1463
|
+
message: `List view ${I} needs non-empty top-level "columns".`,
|
|
1464
|
+
path: d.path,
|
|
1465
|
+
pointer: L
|
|
1466
|
+
}));
|
|
1467
|
+
const M = [[u, "displayName", L]];
|
|
1468
|
+
Q(u, "columns").forEach((E, j) => {
|
|
1469
|
+
for (const v of ["header", "displayName", "label"])
|
|
1470
|
+
M.push([E, v, `${L}/columns/${j}`]);
|
|
1471
|
+
}), Q(u, "tabs").forEach((E, j) => {
|
|
1472
|
+
M.push([E, "displayName", `${L}/tabs/${j}`]), Q(E, "sections").forEach((v, O) => {
|
|
1473
|
+
M.push([v, "displayName", `${L}/tabs/${j}/sections/${O}`]), Q(v, "controls").forEach(
|
|
1474
|
+
(a, p) => M.push([a, "label", `${L}/tabs/${j}/sections/${O}/controls/${p}`])
|
|
1475
|
+
);
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
for (const [E, j, v] of M) {
|
|
1479
|
+
const O = F(E) ? E[j] : void 0;
|
|
1480
|
+
typeof O == "string" && ae(O) && n({
|
|
1481
|
+
code: "labels.polish",
|
|
1482
|
+
message: `View ${I}: "${O}" is Polish — seed labels are English.`,
|
|
1483
|
+
path: d.path,
|
|
1484
|
+
pointer: `${v}/${j}`
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
const C = s.filter((d) => ve(d.file.path) && xe.test(d.file.path)), S = /* @__PURE__ */ new Map();
|
|
1490
|
+
for (const d of C) {
|
|
1491
|
+
const [, $, u] = xe.exec(d.file.path), T = S.get($) ?? /* @__PURE__ */ new Map();
|
|
1492
|
+
T.set(u.toLowerCase(), d), S.set($, T);
|
|
1493
|
+
}
|
|
1494
|
+
const N = new Set(
|
|
1495
|
+
[...S.keys()].map((d) => d.split(".")[0]).filter((d) => !Dt.has(d))
|
|
1496
|
+
), x = /* @__PURE__ */ new Set();
|
|
1497
|
+
for (const [d, $] of S) {
|
|
1498
|
+
const u = $.get("en"), T = $.get("pl"), L = (I) => new Set(je(I == null ? void 0 : I.value).map(([M]) => M));
|
|
1499
|
+
if (u && !T && n({
|
|
1500
|
+
code: "i18n.polishMissing",
|
|
1501
|
+
message: `${d}.en.i18n.json needs a .pl.i18n.json sibling (English and Polish are mandatory).`,
|
|
1502
|
+
path: u.file.path
|
|
1503
|
+
}), T && !u && n({
|
|
1504
|
+
code: "i18n.englishMissing",
|
|
1505
|
+
message: `${d}.pl.i18n.json needs an .en.i18n.json baseline.`,
|
|
1506
|
+
path: T.file.path
|
|
1507
|
+
}), u && T) {
|
|
1508
|
+
const I = L(u), M = L(T), E = [...I].filter((v) => !M.has(v)), j = [...M].filter((v) => !I.has(v));
|
|
1509
|
+
E.length && n({
|
|
1510
|
+
code: "i18n.keyMissing",
|
|
1511
|
+
message: `${T.file.path} is missing ${E.length} key(s) of English: ${E.slice(0, 10).join(", ")}`,
|
|
1512
|
+
path: T.file.path
|
|
1513
|
+
}), j.length && n({
|
|
1514
|
+
code: "i18n.keyMissing",
|
|
1515
|
+
message: `${u.file.path} is missing ${j.length} key(s) of Polish: ${j.slice(0, 10).join(", ")}`,
|
|
1516
|
+
path: u.file.path
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
for (const [I, M] of $) {
|
|
1520
|
+
const E = je(M.value), j = E.filter(([v]) => N.has(v.split(".")[0])).map(([v]) => v);
|
|
1521
|
+
if (j.length && n({
|
|
1522
|
+
severity: "warning",
|
|
1523
|
+
code: "i18n.fileKey",
|
|
1524
|
+
message: `${M.file.path}: nothing reads keys named after the bundle file — use module./entity./field./view. keys (${j.slice(0, 5).join(", ")}).`,
|
|
1525
|
+
path: M.file.path
|
|
1526
|
+
}), I === "en")
|
|
1527
|
+
for (const [v, O] of E) {
|
|
1528
|
+
x.add(v);
|
|
1529
|
+
const a = v.split(".")[0];
|
|
1530
|
+
["module", "entity", "field", "view"].includes(a) && typeof O == "string" && ae(O) && n({
|
|
1531
|
+
code: "i18n.polishInEnglish",
|
|
1532
|
+
message: `${M.file.path}: ${v} = "${O}" — the English bundle is the English UI.`,
|
|
1533
|
+
path: M.file.path
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (l.length && C.length) {
|
|
1539
|
+
const $ = [
|
|
1540
|
+
"module.displayName",
|
|
1541
|
+
...c.map((u) => `entity.${u}.displayName`),
|
|
1542
|
+
...m.map((u) => `${u}.displayName`),
|
|
1543
|
+
...b.map((u) => `view.${u}.displayName`)
|
|
1544
|
+
].filter(
|
|
1545
|
+
(u) => !x.has(u) && !(u.startsWith("field.") && x.has(`${u.slice(0, -12)}.label`))
|
|
1546
|
+
);
|
|
1547
|
+
$.length && n({
|
|
1548
|
+
code: "i18n.labelMissing",
|
|
1549
|
+
message: `The English bundle has no label for ${$.length} name(s): ${$.slice(0, 10).join(", ")}`
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
for (const { file: d, value: $ } of s)
|
|
1553
|
+
ce(
|
|
1554
|
+
$,
|
|
1555
|
+
void 0,
|
|
1556
|
+
"",
|
|
1557
|
+
(u, T, L) => n({
|
|
1558
|
+
code: "icons.emoji",
|
|
1559
|
+
message: `${T} = "${L}": icon fields take an Ntd* name and column headers are words, never emoji.`,
|
|
1560
|
+
path: d.path,
|
|
1561
|
+
pointer: u
|
|
1562
|
+
})
|
|
1563
|
+
);
|
|
1564
|
+
return o;
|
|
1565
|
+
}
|
|
1566
|
+
function ce(e, i, t, o) {
|
|
1567
|
+
if (Array.isArray(e)) {
|
|
1568
|
+
e.forEach((n, s) => ce(n, i, `${t}/${s}`, o));
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
if (F(e))
|
|
1572
|
+
for (const [n, s] of Object.entries(e)) {
|
|
1573
|
+
const r = `${t}/${n}`;
|
|
1574
|
+
if ((n === "icon" || n === "iconName" || n === "entityIcon" || n === "name" && i === "icon" || i === "cardIcon" || (n === "header" || n === "displayName" && i === "columns")) && typeof s == "string" && Ft(s) && o(r, n, s), n === "optionsJson" && typeof s == "string")
|
|
1575
|
+
try {
|
|
1576
|
+
ce(JSON.parse(s), "optionsJson", r, o);
|
|
1577
|
+
} catch {
|
|
1578
|
+
}
|
|
1579
|
+
ce(s, n, r, o);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
function Kt(e, i = {}) {
|
|
1583
|
+
const t = [], o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1584
|
+
for (const r of e)
|
|
1585
|
+
for (const l of r.files) {
|
|
1586
|
+
if (!ve(l.path) || !oe(l.path, ".json"))
|
|
1587
|
+
continue;
|
|
1588
|
+
let y;
|
|
1589
|
+
try {
|
|
1590
|
+
y = _(l.text).value;
|
|
1591
|
+
} catch {
|
|
1592
|
+
continue;
|
|
1593
|
+
}
|
|
1594
|
+
if (oe(l.path, ".manifest.json") && F(y) && typeof y.packageName == "string" && y.packageName) {
|
|
1595
|
+
const c = y.packageName.toLowerCase();
|
|
1596
|
+
o.set(c, [...o.get(c) ?? [], r.location]);
|
|
1597
|
+
}
|
|
1598
|
+
if (oe(l.path, ".entities.json") && r.group) {
|
|
1599
|
+
for (const c of Q(y, "entities"))
|
|
1600
|
+
if (F(c) && typeof c.name == "string" && c.name) {
|
|
1601
|
+
const m = `${r.group}/${c.name}`.toLowerCase(), b = n.get(m) ?? [];
|
|
1602
|
+
b.includes(r.location) || n.set(m, [...b, r.location]);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
for (const [r, l] of o)
|
|
1607
|
+
l.length > 1 && t.push({
|
|
1608
|
+
severity: "error",
|
|
1609
|
+
code: "workspace.packageName",
|
|
1610
|
+
message: `Package name ${r} is declared by ${l.length} modules: ${l.join(", ")}`
|
|
1611
|
+
});
|
|
1612
|
+
const s = new Set([...i.knownDuplicates ?? []].map((r) => r.toLowerCase()));
|
|
1613
|
+
for (const [r, l] of n)
|
|
1614
|
+
l.length > 1 && !s.has(r) && t.push({
|
|
1615
|
+
severity: "error",
|
|
1616
|
+
code: "workspace.entityName",
|
|
1617
|
+
message: `Entity ${r} is declared by ${l.length} modules of the same group: ${l.join(", ")}`
|
|
1618
|
+
});
|
|
1619
|
+
return t;
|
|
1620
|
+
}
|
|
1621
|
+
const ee = (e) => typeof e == "object" && e !== null && !Array.isArray(e), X = (e) => typeof e == "string" && e ? e : void 0, qt = /* @__PURE__ */ new Set([
|
|
1622
|
+
"slug",
|
|
1623
|
+
"category",
|
|
1624
|
+
"subCategory",
|
|
1625
|
+
"parentSlug",
|
|
1626
|
+
"icon",
|
|
1627
|
+
"sortOrder",
|
|
1628
|
+
"tags",
|
|
1629
|
+
"translations",
|
|
1630
|
+
"modules"
|
|
1631
|
+
]);
|
|
1632
|
+
function Ue(e) {
|
|
1633
|
+
if (Array.isArray(e))
|
|
1634
|
+
return e.filter((i) => typeof i == "string");
|
|
1635
|
+
if (typeof e == "string")
|
|
1636
|
+
return e.split(",").map((i) => i.trim()).filter(Boolean);
|
|
1637
|
+
}
|
|
1638
|
+
function We(e) {
|
|
1639
|
+
const i = {};
|
|
1640
|
+
for (const [t, o] of Object.entries(ee(e) ? e : {}))
|
|
1641
|
+
ee(o) && (i[t] = { ...o, name: String(o.name ?? "") });
|
|
1642
|
+
return i;
|
|
1643
|
+
}
|
|
1644
|
+
function Vt(e, i) {
|
|
1645
|
+
const t = ee(e) ? e : {}, o = Object.fromEntries(Object.entries(t).filter(([n]) => !qt.has(n)));
|
|
1646
|
+
return {
|
|
1647
|
+
id: String(t.slug ?? ""),
|
|
1648
|
+
category: X(t.category),
|
|
1649
|
+
subCategory: X(t.subCategory),
|
|
1650
|
+
parentId: X(t.parentSlug),
|
|
1651
|
+
icon: X(t.icon),
|
|
1652
|
+
sortOrder: typeof t.sortOrder == "number" ? t.sortOrder : void 0,
|
|
1653
|
+
tags: Ue(t.tags),
|
|
1654
|
+
translations: We(t.translations),
|
|
1655
|
+
modules: (Array.isArray(t.modules) ? t.modules : []).filter(ee).map((n) => ({
|
|
1656
|
+
moduleId: String(n.packageName ?? ""),
|
|
1657
|
+
required: n.required === !0,
|
|
1658
|
+
condition: X(n.condition),
|
|
1659
|
+
description: X(n.description)
|
|
1660
|
+
})),
|
|
1661
|
+
...Object.keys(o).length ? { extra: o } : {},
|
|
1662
|
+
...i ? { readOnly: i } : {}
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
const $e = (e) => Object.fromEntries(Object.entries(e).filter(([, i]) => i !== void 0));
|
|
1666
|
+
function Ee(e, i) {
|
|
1667
|
+
var l;
|
|
1668
|
+
const t = ee(i) ? i : {}, o = (Array.isArray(t.modules) ? t.modules : []).filter(ee), s = JSON.stringify(Ue(t.tags) ?? []) === JSON.stringify(e.tags ?? []) ? t.tags : (l = e.tags) != null && l.length ? typeof t.tags == "string" ? e.tags.join(",") : e.tags : void 0, r = (y) => {
|
|
1669
|
+
const c = o.find((m) => m.packageName === y.moduleId);
|
|
1670
|
+
return $e({
|
|
1671
|
+
...c,
|
|
1672
|
+
packageName: y.moduleId,
|
|
1673
|
+
// seed entries spell `required` out, also when it is false
|
|
1674
|
+
required: y.required === !0 ? !0 : !c || "required" in c ? !1 : void 0,
|
|
1675
|
+
condition: y.condition || void 0,
|
|
1676
|
+
description: y.description || void 0
|
|
1677
|
+
});
|
|
1678
|
+
};
|
|
1679
|
+
return $e({
|
|
1680
|
+
...t,
|
|
1681
|
+
slug: e.id,
|
|
1682
|
+
category: e.category,
|
|
1683
|
+
subCategory: e.subCategory,
|
|
1684
|
+
parentSlug: e.parentId,
|
|
1685
|
+
icon: e.icon,
|
|
1686
|
+
sortOrder: e.sortOrder,
|
|
1687
|
+
...e.extra,
|
|
1688
|
+
tags: s,
|
|
1689
|
+
translations: e.translations,
|
|
1690
|
+
modules: e.modules.map(r)
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
function Ie(e, i = "en") {
|
|
1694
|
+
const t = We(e.translations);
|
|
1695
|
+
Object.keys(t).length === 0 && e.name && (t[i] = {
|
|
1696
|
+
name: e.name,
|
|
1697
|
+
...e.description ? { description: e.description } : {}
|
|
1698
|
+
});
|
|
1699
|
+
const o = $e({
|
|
1700
|
+
isActive: e.isActive,
|
|
1701
|
+
compliance: e.compliance,
|
|
1702
|
+
defaultLanguage: e.defaultLanguage ?? void 0,
|
|
1703
|
+
source: e.source
|
|
1704
|
+
});
|
|
1705
|
+
return {
|
|
1706
|
+
id: e.slug,
|
|
1707
|
+
category: e.category ?? void 0,
|
|
1708
|
+
subCategory: e.subCategory ?? void 0,
|
|
1709
|
+
parentId: e.parentSlug ?? void 0,
|
|
1710
|
+
icon: e.icon ?? void 0,
|
|
1711
|
+
sortOrder: e.sortOrder,
|
|
1712
|
+
tags: e.tags,
|
|
1713
|
+
translations: t,
|
|
1714
|
+
modules: (e.modules ?? []).map((n) => ({
|
|
1715
|
+
moduleId: n.packageName,
|
|
1716
|
+
required: n.required === !0,
|
|
1717
|
+
condition: n.condition ?? void 0,
|
|
1718
|
+
description: n.description ?? void 0
|
|
1719
|
+
})),
|
|
1720
|
+
extra: o,
|
|
1721
|
+
readOnly: e.source === "seed" || e.source === "code"
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
function Ut(e) {
|
|
1725
|
+
const i = e.extra ?? {};
|
|
1726
|
+
return {
|
|
1727
|
+
slug: e.id,
|
|
1728
|
+
category: e.category ?? "",
|
|
1729
|
+
subCategory: e.subCategory ?? null,
|
|
1730
|
+
icon: e.icon ?? null,
|
|
1731
|
+
tags: e.tags ?? [],
|
|
1732
|
+
isActive: i.isActive !== !1,
|
|
1733
|
+
translations: e.translations,
|
|
1734
|
+
modules: e.modules.map((t) => ({
|
|
1735
|
+
packageName: t.moduleId,
|
|
1736
|
+
required: t.required === !0,
|
|
1737
|
+
condition: t.condition ?? null,
|
|
1738
|
+
description: t.description ?? null
|
|
1739
|
+
})),
|
|
1740
|
+
...Array.isArray(i.compliance) ? { compliance: i.compliance } : {},
|
|
1741
|
+
...typeof i.defaultLanguage == "string" ? { defaultLanguage: i.defaultLanguage } : {}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
const P = (...e) => e.filter(Boolean).join("/"), Wt = (e) => e.slice(0, Math.max(0, e.lastIndexOf("/"))), Gt = (e) => e.slice(e.lastIndexOf("/") + 1), me = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ie = (e) => typeof e == "string" && e ? e : void 0, _t = /* @__PURE__ */ new Set(["bin", "obj", "node_modules"]), fe = (e) => e.startsWith(".") || _t.has(e), zt = /^wizard-templates-.+\.seed\.json$/i, Bt = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z$/;
|
|
1745
|
+
function ue(e) {
|
|
1746
|
+
const i = (t, o = 2) => String(t).padStart(o, "0");
|
|
1747
|
+
return `${e.getUTCFullYear()}${i(e.getUTCMonth() + 1)}${i(e.getUTCDate())}T${i(e.getUTCHours())}${i(e.getUTCMinutes())}${i(e.getUTCSeconds())}${i(e.getUTCMilliseconds(), 3)}Z`;
|
|
1748
|
+
}
|
|
1749
|
+
function Jt(e) {
|
|
1750
|
+
const i = Bt.exec(e);
|
|
1751
|
+
return i ? Date.UTC(+i[1], +i[2] - 1, +i[3], +i[4], +i[5], +i[6], +i[7]) : void 0;
|
|
1752
|
+
}
|
|
1753
|
+
const Ht = (e, i) => P(Wt(e), ".revisions", `${Gt(e)}.${i}`), Zt = (e) => e.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "custom";
|
|
1754
|
+
function ni(e) {
|
|
1755
|
+
const { roots: i } = e, t = e.revisions !== !1, o = e.now ?? (() => /* @__PURE__ */ new Date()), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
1756
|
+
let r = null;
|
|
1757
|
+
const l = (a) => {
|
|
1758
|
+
const p = i.find((g) => g.id === a);
|
|
1759
|
+
if (!p)
|
|
1760
|
+
throw new Error(`Unknown workspace "${a}"`);
|
|
1761
|
+
return p;
|
|
1762
|
+
}, y = (a) => {
|
|
1763
|
+
const p = l(a);
|
|
1764
|
+
if (p.readOnly)
|
|
1765
|
+
throw new Error(`Workspace "${p.label}" is read-only`);
|
|
1766
|
+
return p;
|
|
1767
|
+
};
|
|
1768
|
+
async function c(a, p) {
|
|
1769
|
+
const g = await a.read(p);
|
|
1770
|
+
try {
|
|
1771
|
+
const h = g ? _(g.text).value : void 0;
|
|
1772
|
+
return me(h) ? h : {};
|
|
1773
|
+
} catch {
|
|
1774
|
+
return {};
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
function m(a, p, g, h, k) {
|
|
1778
|
+
const f = ie(h.packageName) ?? (p || a.id);
|
|
1779
|
+
return {
|
|
1780
|
+
workspaceId: a.id,
|
|
1781
|
+
id: f,
|
|
1782
|
+
packageId: ie(h.category),
|
|
1783
|
+
label: ie(h.displayName) ?? f,
|
|
1784
|
+
description: ie(h.description),
|
|
1785
|
+
version: ie(h.version),
|
|
1786
|
+
location: p,
|
|
1787
|
+
readOnly: a.readOnly,
|
|
1788
|
+
files: k,
|
|
1789
|
+
search: `${p} ${g}`
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
async function b(a) {
|
|
1793
|
+
const p = /* @__PURE__ */ new Map(), g = async (h) => {
|
|
1794
|
+
const k = await a.fs.list(h), f = k.filter((w) => w.kind === "file" && w.name.toLowerCase().endsWith(".manifest.json")).map((w) => w.name).sort()[0];
|
|
1795
|
+
if (f) {
|
|
1796
|
+
const w = k.filter((D) => D.kind === "file").map((D) => D.name), A = m(
|
|
1797
|
+
a,
|
|
1798
|
+
h,
|
|
1799
|
+
f,
|
|
1800
|
+
await c(a.fs, P(h, f)),
|
|
1801
|
+
w
|
|
1802
|
+
);
|
|
1803
|
+
p.has(A.id.toLowerCase()) || (p.set(A.id.toLowerCase(), { ref: A, dir: h }), s.set(`${a.id}:${A.id.toLowerCase()}`, h));
|
|
1804
|
+
}
|
|
1805
|
+
for (const w of k)
|
|
1806
|
+
w.kind === "directory" && !fe(w.name) && !(h === "" && w.name === C(a)) && await g(P(h, w.name));
|
|
1807
|
+
};
|
|
1808
|
+
return await g(""), p;
|
|
1809
|
+
}
|
|
1810
|
+
const C = (a) => a.templatesDir === !1 ? void 0 : a.templatesDir ?? "Templates", S = (a) => {
|
|
1811
|
+
n.delete(a.id), E.clear();
|
|
1812
|
+
}, N = (a) => {
|
|
1813
|
+
let p = n.get(a.id);
|
|
1814
|
+
return p || (p = b(a), n.set(a.id, p), p.catch(() => n.delete(a.id))), p;
|
|
1815
|
+
};
|
|
1816
|
+
async function x(a) {
|
|
1817
|
+
const p = l(a.workspaceId), g = await N(p), h = s.get(`${p.id}:${a.id.toLowerCase()}`), k = g.get(a.id.toLowerCase()) ?? (h === void 0 ? void 0 : [...g.values()].find((f) => f.dir === h));
|
|
1818
|
+
if (!k)
|
|
1819
|
+
throw new Error(`Module "${a.id}" is not in "${p.label}"`);
|
|
1820
|
+
return { root: p, module: k };
|
|
1821
|
+
}
|
|
1822
|
+
async function d(a, p) {
|
|
1823
|
+
const g = [], h = async (k, f) => {
|
|
1824
|
+
const w = await a.list(P(p, k));
|
|
1825
|
+
if (!(f && w.some((A) => A.kind === "file" && A.name.toLowerCase().endsWith(".manifest.json"))))
|
|
1826
|
+
for (const A of w)
|
|
1827
|
+
A.kind === "file" ? g.push(P(k, A.name)) : fe(A.name) || await h(P(k, A.name), !0);
|
|
1828
|
+
};
|
|
1829
|
+
return await h("", !1), g.sort();
|
|
1830
|
+
}
|
|
1831
|
+
async function $(a, p, g, h) {
|
|
1832
|
+
t && await a.write(Ht(p, h), g);
|
|
1833
|
+
}
|
|
1834
|
+
async function u(a, p) {
|
|
1835
|
+
const g = [], h = async (k) => {
|
|
1836
|
+
const f = await a.list(P(p, k));
|
|
1837
|
+
for (const w of f)
|
|
1838
|
+
if (w.kind === "directory" && w.name === ".revisions")
|
|
1839
|
+
for (const A of await a.list(P(p, k, w.name))) {
|
|
1840
|
+
const D = /^(.*)\.(\d{8}T\d{9}Z)$/.exec(A.name);
|
|
1841
|
+
A.kind === "file" && D && g.push({
|
|
1842
|
+
path: P(k, D[1]),
|
|
1843
|
+
stamp: D[2],
|
|
1844
|
+
at: P(k, ".revisions", A.name)
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
else w.kind === "directory" && !fe(w.name) && await h(P(k, w.name));
|
|
1848
|
+
};
|
|
1849
|
+
return await h(""), g;
|
|
1850
|
+
}
|
|
1851
|
+
async function T(a) {
|
|
1852
|
+
const p = C(a);
|
|
1853
|
+
return p ? (await a.fs.list(p)).filter((g) => g.kind === "file" && zt.test(g.name)).map((g) => P(p, g.name)).sort() : [];
|
|
1854
|
+
}
|
|
1855
|
+
async function L(a, p) {
|
|
1856
|
+
const g = await a.fs.read(p);
|
|
1857
|
+
if (!g)
|
|
1858
|
+
return { text: "", entries: [] };
|
|
1859
|
+
const h = _(g.text).value;
|
|
1860
|
+
return { text: g.text, entries: Array.isArray(h) ? h : [] };
|
|
1861
|
+
}
|
|
1862
|
+
const I = {
|
|
1863
|
+
arrayKey: (a) => a === "" ? "slug" : a.endsWith("/modules") ? "packageName" : void 0
|
|
1864
|
+
};
|
|
1865
|
+
async function M(a, p, g, h) {
|
|
1866
|
+
if (g && await $(a.fs, p, g, ue(o())), h.length === 0) {
|
|
1867
|
+
await a.fs.remove(p);
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
await a.fs.write(
|
|
1871
|
+
p,
|
|
1872
|
+
g ? De(g, h, I) : de(h)
|
|
1873
|
+
);
|
|
1874
|
+
}
|
|
1875
|
+
const E = /* @__PURE__ */ new Map();
|
|
1876
|
+
function j(a, p) {
|
|
1877
|
+
const g = `${a.id}:${p.dir}`;
|
|
1878
|
+
let h = E.get(g);
|
|
1879
|
+
if (!h) {
|
|
1880
|
+
const k = (p.ref.files ?? []).filter((f) => /\.(manifest|entities)\.json$/i.test(f));
|
|
1881
|
+
h = Promise.all(
|
|
1882
|
+
k.map(async (f) => {
|
|
1883
|
+
var w;
|
|
1884
|
+
return {
|
|
1885
|
+
path: f,
|
|
1886
|
+
text: ((w = await a.fs.read(P(p.dir, f))) == null ? void 0 : w.text) ?? ""
|
|
1887
|
+
};
|
|
1888
|
+
})
|
|
1889
|
+
).then((f) => ({ location: p.dir, group: p.dir.split("/")[0], files: f })), E.set(g, h);
|
|
1890
|
+
}
|
|
1891
|
+
return h;
|
|
1892
|
+
}
|
|
1893
|
+
async function v(a) {
|
|
1894
|
+
var p;
|
|
1895
|
+
return r || await ((p = O.listTemplates) == null ? void 0 : p.call(O)), r == null ? void 0 : r.get(a.toLowerCase());
|
|
1896
|
+
}
|
|
1897
|
+
const O = {
|
|
1898
|
+
invalidate() {
|
|
1899
|
+
n.clear(), E.clear(), r = null;
|
|
1900
|
+
},
|
|
1901
|
+
async listWorkspaces() {
|
|
1902
|
+
return i.map((a) => ({
|
|
1903
|
+
id: a.id,
|
|
1904
|
+
label: a.label,
|
|
1905
|
+
...a.description ? { description: a.description } : {},
|
|
1906
|
+
...a.icon ? { icon: a.icon } : {},
|
|
1907
|
+
...a.readOnly ? { readOnly: !0 } : {}
|
|
1908
|
+
}));
|
|
1909
|
+
},
|
|
1910
|
+
async listModules(a) {
|
|
1911
|
+
const p = i.findIndex((f) => f.id === a), g = l(a);
|
|
1912
|
+
S(g);
|
|
1913
|
+
const h = await N(g), k = await Promise.all(
|
|
1914
|
+
i.slice(0, p).map(async (f) => ({ r: f, modules: await N(f) }))
|
|
1915
|
+
);
|
|
1916
|
+
return [...h.values()].map(({ ref: f }) => {
|
|
1917
|
+
const w = k.find((A) => A.modules.has(f.id.toLowerCase()));
|
|
1918
|
+
return w ? { ...f, shadowedBy: w.r.id } : f;
|
|
1919
|
+
}).sort((f, w) => f.id.localeCompare(w.id));
|
|
1920
|
+
},
|
|
1921
|
+
async readModule(a) {
|
|
1922
|
+
const { root: p, module: g } = await x(a), h = await d(p.fs, g.dir), k = [];
|
|
1923
|
+
for (const f of h) {
|
|
1924
|
+
const w = await p.fs.read(P(g.dir, f));
|
|
1925
|
+
w && k.push({
|
|
1926
|
+
path: f,
|
|
1927
|
+
text: w.text,
|
|
1928
|
+
version: w.version,
|
|
1929
|
+
...p.readOnly ? { readOnly: !0 } : {}
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
return k;
|
|
1933
|
+
},
|
|
1934
|
+
async writeModule(a, p) {
|
|
1935
|
+
const { module: g } = await x(a), h = y(a.workspaceId), k = /* @__PURE__ */ new Map(), f = [];
|
|
1936
|
+
for (const D of p) {
|
|
1937
|
+
if (D.path.split("/").some((Z) => Z === ".." || Z === "" || Z.startsWith(".")))
|
|
1938
|
+
throw new Error(`Refusing to write outside the module: ${D.path}`);
|
|
1939
|
+
const K = await h.fs.read(P(g.dir, D.path));
|
|
1940
|
+
k.set(D.path, K);
|
|
1941
|
+
const z = D.baseVersion;
|
|
1942
|
+
(z === void 0 ? K !== null && D.type === "write" : (K == null ? void 0 : K.version) !== z) && f.push({ path: D.path, ...K ? { currentVersion: K.version } : {} });
|
|
1943
|
+
}
|
|
1944
|
+
if (f.length)
|
|
1945
|
+
return { ok: !1, conflicts: f };
|
|
1946
|
+
const w = ue(o()), A = {};
|
|
1947
|
+
for (const D of p) {
|
|
1948
|
+
const K = P(g.dir, D.path), z = k.get(D.path);
|
|
1949
|
+
z && await $(h.fs, K, z.text, w), D.type === "write" ? A[D.path] = await h.fs.write(K, D.text) : await h.fs.remove(K);
|
|
1950
|
+
}
|
|
1951
|
+
return S(h), { ok: !0, versions: A, revision: w };
|
|
1952
|
+
},
|
|
1953
|
+
async createModule(a) {
|
|
1954
|
+
var f;
|
|
1955
|
+
const p = y(a.workspaceId), g = a.id.startsWith(W) ? a.id.slice(W.length) : a.id.split(".").pop() ?? a.id, h = ((f = e.moduleFolder) == null ? void 0 : f.call(e, a)) ?? P(
|
|
1956
|
+
R(a.packageId ?? "") || "Custom",
|
|
1957
|
+
R(g) || "Module"
|
|
1958
|
+
);
|
|
1959
|
+
if ((await p.fs.list(h)).length > 0)
|
|
1960
|
+
throw new Error(`The folder ${h} is not empty`);
|
|
1961
|
+
if ((await N(p)).has(a.id.toLowerCase()))
|
|
1962
|
+
throw new Error(`"${a.id}" already exists in ${p.label}`);
|
|
1963
|
+
for (const w of a.files)
|
|
1964
|
+
await p.fs.write(P(h, w.path), w.text);
|
|
1965
|
+
S(p);
|
|
1966
|
+
const k = (await N(p)).get(a.id.toLowerCase());
|
|
1967
|
+
if (!k)
|
|
1968
|
+
throw new Error(`The new module ${a.id} has no manifest naming it`);
|
|
1969
|
+
return k.ref;
|
|
1970
|
+
},
|
|
1971
|
+
async deleteModule(a) {
|
|
1972
|
+
const { module: p } = await x(a), g = y(a.workspaceId);
|
|
1973
|
+
await g.fs.removeDir(p.dir), s.delete(`${g.id}:${a.id.toLowerCase()}`), S(g);
|
|
1974
|
+
},
|
|
1975
|
+
async listTemplates() {
|
|
1976
|
+
const a = /* @__PURE__ */ new Map(), p = [];
|
|
1977
|
+
for (const g of i)
|
|
1978
|
+
for (const h of await T(g)) {
|
|
1979
|
+
let k;
|
|
1980
|
+
try {
|
|
1981
|
+
k = (await L(g, h)).entries;
|
|
1982
|
+
} catch {
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
for (const f of k) {
|
|
1986
|
+
const w = Vt(f, g.readOnly);
|
|
1987
|
+
w.id && !a.has(w.id.toLowerCase()) && (a.set(w.id.toLowerCase(), { rootId: g.id, path: h }), p.push(w));
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
return r = a, p;
|
|
1991
|
+
},
|
|
1992
|
+
async saveTemplate(a, p) {
|
|
1993
|
+
const g = (p == null ? void 0 : p.previousId) ?? a.id, h = await v(g);
|
|
1994
|
+
if (h) {
|
|
1995
|
+
const k = y(h.rootId), { text: f, entries: w } = await L(k, h.path), A = w.findIndex(
|
|
1996
|
+
(K) => me(K) && String(K.slug ?? "").toLowerCase() === g.toLowerCase()
|
|
1997
|
+
), D = [...w];
|
|
1998
|
+
D[A < 0 ? D.length : A] = Ee(
|
|
1999
|
+
a,
|
|
2000
|
+
A < 0 ? void 0 : w[A]
|
|
2001
|
+
), await M(k, h.path, f, D);
|
|
2002
|
+
} else {
|
|
2003
|
+
const k = i.find((D) => !D.readOnly && C(D));
|
|
2004
|
+
if (!k)
|
|
2005
|
+
throw new Error("No writable folder holds templates");
|
|
2006
|
+
const f = P(
|
|
2007
|
+
C(k),
|
|
2008
|
+
`wizard-templates-${Zt(a.category ?? "custom")}.seed.json`
|
|
2009
|
+
), { text: w, entries: A } = await L(k, f);
|
|
2010
|
+
await M(k, f, w, [...A, Ee(a)]);
|
|
2011
|
+
}
|
|
2012
|
+
return r = null, { ...a, extra: a.extra };
|
|
2013
|
+
},
|
|
2014
|
+
async deleteTemplate(a) {
|
|
2015
|
+
const p = await v(a);
|
|
2016
|
+
if (!p)
|
|
2017
|
+
return;
|
|
2018
|
+
const g = y(p.rootId), { text: h, entries: k } = await L(g, p.path);
|
|
2019
|
+
await M(
|
|
2020
|
+
g,
|
|
2021
|
+
p.path,
|
|
2022
|
+
h,
|
|
2023
|
+
k.filter(
|
|
2024
|
+
(f) => !(me(f) && String(f.slug ?? "").toLowerCase() === a.toLowerCase())
|
|
2025
|
+
)
|
|
2026
|
+
), r = null;
|
|
2027
|
+
},
|
|
2028
|
+
async validate(a, p) {
|
|
2029
|
+
const g = l(a.workspaceId), h = [...(await N(g)).values()], k = await Promise.all(
|
|
2030
|
+
h.filter((A) => A.ref.id.toLowerCase() !== a.id.toLowerCase()).map((A) => j(g, A))
|
|
2031
|
+
), f = h.find((A) => A.ref.id.toLowerCase() === a.id.toLowerCase()), w = (f == null ? void 0 : f.dir) ?? a.id;
|
|
2032
|
+
return Kt(
|
|
2033
|
+
[...k, { location: w, group: w.split("/")[0], files: p }],
|
|
2034
|
+
{
|
|
2035
|
+
knownDuplicates: e.knownDuplicates
|
|
2036
|
+
}
|
|
2037
|
+
).filter((A) => A.message.split(/[ ,]+/).includes(w));
|
|
2038
|
+
},
|
|
2039
|
+
async listRevisions(a, p) {
|
|
2040
|
+
const { root: g, module: h } = await x(a), k = (await u(g.fs, h.dir)).filter(
|
|
2041
|
+
(w) => !p || w.path === p
|
|
2042
|
+
), f = /* @__PURE__ */ new Map();
|
|
2043
|
+
for (const w of k)
|
|
2044
|
+
f.set(w.stamp, [...f.get(w.stamp) ?? [], w.path]);
|
|
2045
|
+
return [...f].map(([w, A]) => ({
|
|
2046
|
+
id: w,
|
|
2047
|
+
timestamp: Jt(w) ?? 0,
|
|
2048
|
+
summary: A.sort().join(", "),
|
|
2049
|
+
...p ? { path: p } : {}
|
|
2050
|
+
})).sort((w, A) => A.timestamp - w.timestamp);
|
|
2051
|
+
},
|
|
2052
|
+
async readRevision(a, p, g) {
|
|
2053
|
+
var A;
|
|
2054
|
+
const { root: h, module: k } = await x(a), f = (await u(h.fs, k.dir)).filter(
|
|
2055
|
+
(D) => D.stamp === p && (!g || D.path === g)
|
|
2056
|
+
);
|
|
2057
|
+
if (f.length === 0)
|
|
2058
|
+
throw new Error(`Unknown revision "${p}"`);
|
|
2059
|
+
const w = {};
|
|
2060
|
+
for (const D of f)
|
|
2061
|
+
w[D.path] = ((A = await h.fs.read(P(k.dir, D.at))) == null ? void 0 : A.text) ?? "";
|
|
2062
|
+
return g ? w[g] : JSON.stringify(w, null, 2);
|
|
2063
|
+
},
|
|
2064
|
+
async rollback(a, p, g) {
|
|
2065
|
+
var A;
|
|
2066
|
+
const { module: h } = await x(a), k = y(a.workspaceId), f = (await u(k.fs, h.dir)).filter(
|
|
2067
|
+
(D) => D.stamp === p && (!g || D.path === g)
|
|
2068
|
+
);
|
|
2069
|
+
if (f.length === 0)
|
|
2070
|
+
throw new Error(`Unknown revision "${p}"`);
|
|
2071
|
+
const w = ue(o());
|
|
2072
|
+
for (const D of f) {
|
|
2073
|
+
const K = P(h.dir, D.path), z = ((A = await k.fs.read(P(h.dir, D.at))) == null ? void 0 : A.text) ?? "", Z = await k.fs.read(K);
|
|
2074
|
+
Z && await $(k.fs, K, Z.text, w), await k.fs.write(K, z);
|
|
2075
|
+
}
|
|
2076
|
+
S(k);
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
return O;
|
|
2080
|
+
}
|
|
2081
|
+
class ye extends Error {
|
|
2082
|
+
constructor(i, t, o) {
|
|
2083
|
+
super(i), this.status = t, this.body = o, this.name = "OmniVerkRestError";
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
const Yt = new TextDecoder("utf-8", { ignoreBOM: !0 });
|
|
2087
|
+
function Xt(e) {
|
|
2088
|
+
const i = atob(e), t = new Uint8Array(i.length);
|
|
2089
|
+
for (let o = 0; o < i.length; o++)
|
|
2090
|
+
t[o] = i.charCodeAt(o);
|
|
2091
|
+
return Yt.decode(t);
|
|
2092
|
+
}
|
|
2093
|
+
function Ce(e) {
|
|
2094
|
+
const i = new TextEncoder().encode(e);
|
|
2095
|
+
let t = "";
|
|
2096
|
+
for (let o = 0; o < i.length; o += 32768)
|
|
2097
|
+
t += String.fromCharCode(...i.subarray(o, o + 32768));
|
|
2098
|
+
return btoa(t);
|
|
2099
|
+
}
|
|
2100
|
+
function Qt(e) {
|
|
2101
|
+
let i = 2166136261;
|
|
2102
|
+
for (let t = 0; t < e.length; t++)
|
|
2103
|
+
i = Math.imul(i ^ e.charCodeAt(t), 16777619);
|
|
2104
|
+
return `${e.length}:${(i >>> 0).toString(16)}`;
|
|
2105
|
+
}
|
|
2106
|
+
function si(e = {}) {
|
|
2107
|
+
const i = (e.baseUrl ?? "/api").replace(/\/+$/, ""), t = e.fetch ?? ((c, m) => globalThis.fetch(c, m)), o = e.language ?? "en", n = encodeURIComponent;
|
|
2108
|
+
async function s(c, m, b, C = "json") {
|
|
2109
|
+
const S = typeof e.headers == "function" ? await e.headers() : e.headers ?? {}, N = await t(`${i}${m}`, {
|
|
2110
|
+
method: c,
|
|
2111
|
+
credentials: e.credentials ?? "same-origin",
|
|
2112
|
+
headers: {
|
|
2113
|
+
Accept: C === "json" ? "application/json" : "text/plain, application/json",
|
|
2114
|
+
...b === void 0 ? {} : { "Content-Type": "application/json" },
|
|
2115
|
+
...S
|
|
2116
|
+
},
|
|
2117
|
+
...b === void 0 ? {} : { body: JSON.stringify(b) }
|
|
2118
|
+
}), x = await N.text();
|
|
2119
|
+
let d = x;
|
|
2120
|
+
if (C === "json" || !N.ok)
|
|
2121
|
+
try {
|
|
2122
|
+
d = x ? JSON.parse(x) : void 0;
|
|
2123
|
+
} catch {
|
|
2124
|
+
d = x;
|
|
2125
|
+
}
|
|
2126
|
+
if (!N.ok)
|
|
2127
|
+
throw new ye(
|
|
2128
|
+
`${c} ${m}: ${N.status} ${N.statusText}`,
|
|
2129
|
+
N.status,
|
|
2130
|
+
d
|
|
2131
|
+
);
|
|
2132
|
+
return d;
|
|
2133
|
+
}
|
|
2134
|
+
const r = e.templates === !1 ? {} : {
|
|
2135
|
+
async listTemplates() {
|
|
2136
|
+
const c = await s(
|
|
2137
|
+
"GET",
|
|
2138
|
+
`/module-templates?lang=${n(o)}&hidden=true`
|
|
2139
|
+
);
|
|
2140
|
+
return (await Promise.all(
|
|
2141
|
+
(c ?? []).map(
|
|
2142
|
+
(b) => s(
|
|
2143
|
+
"GET",
|
|
2144
|
+
`/module-templates/${n(b.slug)}?lang=${n(o)}`
|
|
2145
|
+
)
|
|
2146
|
+
)
|
|
2147
|
+
)).map((b) => Ie(b, o));
|
|
2148
|
+
},
|
|
2149
|
+
async saveTemplate(c, m) {
|
|
2150
|
+
const b = (m == null ? void 0 : m.previousId) ?? c.id, C = Ut(c);
|
|
2151
|
+
let S;
|
|
2152
|
+
if ((m == null ? void 0 : m.previousId) === void 0)
|
|
2153
|
+
S = await s(
|
|
2154
|
+
"GET",
|
|
2155
|
+
`/module-templates/${n(c.id)}?lang=${n(o)}`
|
|
2156
|
+
).then(
|
|
2157
|
+
() => !0,
|
|
2158
|
+
(x) => x instanceof ye && x.status === 404 ? !1 : Promise.reject(x)
|
|
2159
|
+
) ? await s(
|
|
2160
|
+
"PUT",
|
|
2161
|
+
`/module-templates/${n(c.id)}?lang=${n(o)}`,
|
|
2162
|
+
C
|
|
2163
|
+
) : await s("POST", `/module-templates?lang=${n(o)}`, C);
|
|
2164
|
+
else {
|
|
2165
|
+
if (b !== c.id)
|
|
2166
|
+
throw new Error(
|
|
2167
|
+
"The OmniVerk API keeps a template's slug: save it as a new template instead."
|
|
2168
|
+
);
|
|
2169
|
+
S = await s(
|
|
2170
|
+
"PUT",
|
|
2171
|
+
`/module-templates/${n(b)}?lang=${n(o)}`,
|
|
2172
|
+
C
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
return Ie(S, o);
|
|
2176
|
+
},
|
|
2177
|
+
async deleteTemplate(c) {
|
|
2178
|
+
await s("DELETE", `/module-templates/${n(c)}`);
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
if ((e.mode ?? "manifest-only") === "manifest-only") {
|
|
2182
|
+
const c = "seed", m = /* @__PURE__ */ new Map(), b = (S) => {
|
|
2183
|
+
var N, x;
|
|
2184
|
+
return ((N = m.get(S)) == null ? void 0 : N.manifestFile) ?? `${(x = S.split(".").pop()) == null ? void 0 : x.toLowerCase()}.manifest.json`;
|
|
2185
|
+
}, C = async (S) => {
|
|
2186
|
+
const N = await s("GET", `/module-manifests/${n(S)}`), x = de(N, { finalNewline: !1 });
|
|
2187
|
+
return { path: b(S), text: x, version: Qt(x) };
|
|
2188
|
+
};
|
|
2189
|
+
return {
|
|
2190
|
+
async listWorkspaces() {
|
|
2191
|
+
return [{ id: c, label: e.workspaceLabel ?? "Seed/Modules" }];
|
|
2192
|
+
},
|
|
2193
|
+
async listModules() {
|
|
2194
|
+
const S = await s("GET", "/module-manifests");
|
|
2195
|
+
return m.clear(), (S ?? []).map((N) => (m.set(N.packageName, N), {
|
|
2196
|
+
workspaceId: c,
|
|
2197
|
+
id: N.packageName,
|
|
2198
|
+
packageId: N.path.split("/")[0] || void 0,
|
|
2199
|
+
label: N.packageName,
|
|
2200
|
+
location: N.path,
|
|
2201
|
+
files: [N.manifestFile],
|
|
2202
|
+
search: N.path
|
|
2203
|
+
}));
|
|
2204
|
+
},
|
|
2205
|
+
async readModule(S) {
|
|
2206
|
+
return [await C(S.id)];
|
|
2207
|
+
},
|
|
2208
|
+
async writeModule(S, N) {
|
|
2209
|
+
const x = b(S.id), d = N.find((I) => I.path !== x || I.type !== "write");
|
|
2210
|
+
if (d)
|
|
2211
|
+
throw new Error(
|
|
2212
|
+
`This OmniVerk API stores only the manifest; "${d.path}" was not saved.`
|
|
2213
|
+
);
|
|
2214
|
+
const $ = N[0];
|
|
2215
|
+
if (!$ || $.type !== "write")
|
|
2216
|
+
return { ok: !0, versions: {} };
|
|
2217
|
+
const u = await C(S.id);
|
|
2218
|
+
if ($.baseVersion !== void 0 && $.baseVersion !== u.version)
|
|
2219
|
+
return { ok: !1, conflicts: [{ path: x, currentVersion: u.version }] };
|
|
2220
|
+
const T = await s(
|
|
2221
|
+
"PUT",
|
|
2222
|
+
`/module-manifests/${n(S.id)}`,
|
|
2223
|
+
{
|
|
2224
|
+
manifest: _($.text).value
|
|
2225
|
+
}
|
|
2226
|
+
), L = await C(S.id);
|
|
2227
|
+
return {
|
|
2228
|
+
ok: !0,
|
|
2229
|
+
versions: { [x]: L.version },
|
|
2230
|
+
...T != null && T.revision ? { revision: T.revision } : {}
|
|
2231
|
+
};
|
|
2232
|
+
},
|
|
2233
|
+
async listRevisions(S) {
|
|
2234
|
+
return (await s(
|
|
2235
|
+
"GET",
|
|
2236
|
+
`/module-manifests/${n(S.id)}/revisions`
|
|
2237
|
+
) ?? []).map((x) => ({
|
|
2238
|
+
id: x.id,
|
|
2239
|
+
timestamp: Date.parse(x.at) || 0,
|
|
2240
|
+
path: b(S.id),
|
|
2241
|
+
...x.sizeBytes !== void 0 ? { summary: `${x.sizeBytes} B` } : {}
|
|
2242
|
+
}));
|
|
2243
|
+
},
|
|
2244
|
+
async readRevision(S, N) {
|
|
2245
|
+
return s(
|
|
2246
|
+
"GET",
|
|
2247
|
+
`/module-manifests/${n(S.id)}/revisions/${n(N)}`,
|
|
2248
|
+
void 0,
|
|
2249
|
+
"text"
|
|
2250
|
+
);
|
|
2251
|
+
},
|
|
2252
|
+
async rollback(S, N) {
|
|
2253
|
+
await s(
|
|
2254
|
+
"POST",
|
|
2255
|
+
`/module-manifests/${n(S.id)}/revisions/${n(N)}/rollback`
|
|
2256
|
+
);
|
|
2257
|
+
},
|
|
2258
|
+
...r
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
const l = (c) => `/module-files/${n(c.workspaceId)}/modules/${n(c.id)}`, y = (c) => c.map((m) => ({ path: m.path, content: Ce(m.text) }));
|
|
2262
|
+
return {
|
|
2263
|
+
async listWorkspaces() {
|
|
2264
|
+
return s("GET", "/module-files/workspaces");
|
|
2265
|
+
},
|
|
2266
|
+
async listModules(c) {
|
|
2267
|
+
return (await s(
|
|
2268
|
+
"GET",
|
|
2269
|
+
`/module-files/${n(c)}/modules`
|
|
2270
|
+
) ?? []).map((b) => ({ ...b, workspaceId: c }));
|
|
2271
|
+
},
|
|
2272
|
+
async readModule(c) {
|
|
2273
|
+
const m = await s("GET", l(c));
|
|
2274
|
+
return ((m == null ? void 0 : m.files) ?? []).map((b) => ({
|
|
2275
|
+
path: b.path,
|
|
2276
|
+
text: Xt(b.content),
|
|
2277
|
+
...b.version ? { version: b.version } : {},
|
|
2278
|
+
...b.readOnly ? { readOnly: !0 } : {}
|
|
2279
|
+
}));
|
|
2280
|
+
},
|
|
2281
|
+
async writeModule(c, m) {
|
|
2282
|
+
var b;
|
|
2283
|
+
try {
|
|
2284
|
+
const C = await s(
|
|
2285
|
+
"PUT",
|
|
2286
|
+
l(c),
|
|
2287
|
+
{
|
|
2288
|
+
changes: m.map(
|
|
2289
|
+
(S) => S.type === "write" ? {
|
|
2290
|
+
type: "write",
|
|
2291
|
+
path: S.path,
|
|
2292
|
+
content: Ce(S.text),
|
|
2293
|
+
baseVersion: S.baseVersion
|
|
2294
|
+
} : { type: "delete", path: S.path, baseVersion: S.baseVersion }
|
|
2295
|
+
)
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
return {
|
|
2299
|
+
ok: !0,
|
|
2300
|
+
versions: C == null ? void 0 : C.versions,
|
|
2301
|
+
...C != null && C.revision ? { revision: C.revision } : {}
|
|
2302
|
+
};
|
|
2303
|
+
} catch (C) {
|
|
2304
|
+
if (C instanceof ye && C.status === 409)
|
|
2305
|
+
return { ok: !1, conflicts: ((b = C.body) == null ? void 0 : b.conflicts) ?? m.map((N) => ({ path: N.path })) };
|
|
2306
|
+
throw C;
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
2309
|
+
async createModule(c) {
|
|
2310
|
+
return { ...await s(
|
|
2311
|
+
"POST",
|
|
2312
|
+
`/module-files/${n(c.workspaceId)}/modules`,
|
|
2313
|
+
{
|
|
2314
|
+
packageId: c.packageId,
|
|
2315
|
+
id: c.id,
|
|
2316
|
+
files: y(c.files)
|
|
2317
|
+
}
|
|
2318
|
+
), workspaceId: c.workspaceId };
|
|
2319
|
+
},
|
|
2320
|
+
async deleteModule(c) {
|
|
2321
|
+
await s("DELETE", l(c));
|
|
2322
|
+
},
|
|
2323
|
+
async listRevisions(c, m) {
|
|
2324
|
+
return s(
|
|
2325
|
+
"GET",
|
|
2326
|
+
`${l(c)}/revisions${m ? `?path=${n(m)}` : ""}`
|
|
2327
|
+
);
|
|
2328
|
+
},
|
|
2329
|
+
async readRevision(c, m, b) {
|
|
2330
|
+
return s(
|
|
2331
|
+
"GET",
|
|
2332
|
+
`${l(c)}/revisions/${n(m)}${b ? `?path=${n(b)}` : ""}`,
|
|
2333
|
+
void 0,
|
|
2334
|
+
"text"
|
|
2335
|
+
);
|
|
2336
|
+
},
|
|
2337
|
+
async rollback(c, m, b) {
|
|
2338
|
+
await s(
|
|
2339
|
+
"POST",
|
|
2340
|
+
`${l(c)}/revisions/${n(m)}/rollback${b ? `?path=${n(b)}` : ""}`
|
|
2341
|
+
);
|
|
2342
|
+
},
|
|
2343
|
+
...e.serverValidation ? {
|
|
2344
|
+
async validate(c, m) {
|
|
2345
|
+
return s("POST", `${l(c)}/validate`, {
|
|
2346
|
+
files: y(m)
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
} : {},
|
|
2350
|
+
...r
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
const ei = [
|
|
2354
|
+
"en",
|
|
2355
|
+
"pl",
|
|
2356
|
+
"de",
|
|
2357
|
+
"fr",
|
|
2358
|
+
"es",
|
|
2359
|
+
"it",
|
|
2360
|
+
"pt",
|
|
2361
|
+
"pt-BR",
|
|
2362
|
+
"cs",
|
|
2363
|
+
"uk",
|
|
2364
|
+
"ar",
|
|
2365
|
+
"ja",
|
|
2366
|
+
"ko",
|
|
2367
|
+
"zh-CN"
|
|
2368
|
+
], be = (e) => {
|
|
2369
|
+
const i = e.find(
|
|
2370
|
+
(t) => !t.path.includes("/") && t.path.toLowerCase().endsWith(".manifest.json")
|
|
2371
|
+
);
|
|
2372
|
+
if (i)
|
|
2373
|
+
try {
|
|
2374
|
+
const t = _(i.text).value;
|
|
2375
|
+
return {
|
|
2376
|
+
path: i.path,
|
|
2377
|
+
value: typeof t == "object" && t !== null ? t : {}
|
|
2378
|
+
};
|
|
2379
|
+
} catch {
|
|
2380
|
+
return { path: i.path, value: {} };
|
|
2381
|
+
}
|
|
2382
|
+
}, ti = (e) => {
|
|
2383
|
+
var i;
|
|
2384
|
+
return ((i = be(e)) == null ? void 0 : i.path.replace(/\.manifest\.json$/i, "")) ?? "module";
|
|
2385
|
+
};
|
|
2386
|
+
function oi(e = {}) {
|
|
2387
|
+
const i = e.t ?? ((s, r) => r), t = (s, r) => i(`devStudio.omniverk.${s}`, r), o = {
|
|
2388
|
+
type: "object",
|
|
2389
|
+
properties: {
|
|
2390
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
2391
|
+
displayName: { type: "string", title: t("field.displayName", "Display name") },
|
|
2392
|
+
dataType: {
|
|
2393
|
+
type: "string",
|
|
2394
|
+
title: t("field.dataType", "Data type"),
|
|
2395
|
+
enum: [...vt]
|
|
2396
|
+
},
|
|
2397
|
+
maxLength: { type: "integer", title: t("field.maxLength", "Max length") },
|
|
2398
|
+
isRequired: { type: "boolean", title: t("field.isRequired", "Required") },
|
|
2399
|
+
isPrimaryKey: { type: "boolean", title: t("field.isPrimaryKey", "Primary key") },
|
|
2400
|
+
isUnique: { type: "boolean", title: t("field.isUnique", "Unique") },
|
|
2401
|
+
isIndexed: { type: "boolean", title: t("field.isIndexed", "Indexed") },
|
|
2402
|
+
isForeignKey: { type: "boolean", title: t("field.isForeignKey", "Foreign key") },
|
|
2403
|
+
referencedEntity: { type: "string", title: t("field.referencedEntity", "Referenced entity") },
|
|
2404
|
+
defaultValue: { type: "string", title: t("field.defaultValue", "Default value") },
|
|
2405
|
+
description: { type: "string", title: t("field.description", "Description") }
|
|
2406
|
+
},
|
|
2407
|
+
required: ["name", "dataType"]
|
|
2408
|
+
}, n = {
|
|
2409
|
+
type: "object",
|
|
2410
|
+
properties: {
|
|
2411
|
+
name: { type: "string", title: t("field.name", "Name") },
|
|
2412
|
+
displayName: { type: "string", title: t("field.displayName", "Display name") },
|
|
2413
|
+
tableName: { type: "string", title: t("field.tableName", "Table") },
|
|
2414
|
+
description: { type: "string", title: t("field.description", "Description") },
|
|
2415
|
+
entityIcon: { type: "string", title: t("field.icon", "Icon") },
|
|
2416
|
+
isAudited: { type: "boolean", title: t("field.isAudited", "Audited") },
|
|
2417
|
+
isSoftDeleteEnabled: {
|
|
2418
|
+
type: "boolean",
|
|
2419
|
+
title: t("field.isSoftDeleteEnabled", "Soft delete")
|
|
2420
|
+
}
|
|
2421
|
+
},
|
|
2422
|
+
required: ["name"]
|
|
2423
|
+
};
|
|
2424
|
+
return {
|
|
2425
|
+
id: "omniverk",
|
|
2426
|
+
kinds: yt,
|
|
2427
|
+
manifestSections: ht(i, { scripting: e.scripting }),
|
|
2428
|
+
entities: { entityMetaSchema: n, fieldSchema: o },
|
|
2429
|
+
locales: e.locales ?? ei,
|
|
2430
|
+
requiredLocales: ["en", "pl"],
|
|
2431
|
+
moduleId: (s) => {
|
|
2432
|
+
var l;
|
|
2433
|
+
const r = (l = be(s)) == null ? void 0 : l.value.packageName;
|
|
2434
|
+
return typeof r == "string" && r ? r : void 0;
|
|
2435
|
+
},
|
|
2436
|
+
validateModule: (s) => Rt(s),
|
|
2437
|
+
generateModule: async (s, { existingIds: r }) => {
|
|
2438
|
+
const l = await Et(
|
|
2439
|
+
{
|
|
2440
|
+
...It(s),
|
|
2441
|
+
iconConfig: e.iconConfig,
|
|
2442
|
+
ownerTenantId: e.ownerTenantId
|
|
2443
|
+
},
|
|
2444
|
+
{ existingPackageNames: r }
|
|
2445
|
+
);
|
|
2446
|
+
if (!l.package)
|
|
2447
|
+
throw new Error(l.problems.join(`
|
|
2448
|
+
`));
|
|
2449
|
+
return {
|
|
2450
|
+
id: l.package.packageName,
|
|
2451
|
+
packageId: s.packageId,
|
|
2452
|
+
files: l.package.files
|
|
2453
|
+
};
|
|
2454
|
+
},
|
|
2455
|
+
duplicateModule: (s, r) => Ot(s, r),
|
|
2456
|
+
newFile: (s, { files: r }) => {
|
|
2457
|
+
var C;
|
|
2458
|
+
const l = ti(r), y = ((C = be(r)) == null ? void 0 : C.value) ?? {}, c = `${String(y.packageName ?? l)}.Core`, b = {
|
|
2459
|
+
entities: ["entities.json", { moduleName: c, version: "1.0.0", entities: [] }],
|
|
2460
|
+
views: ["views.json", { moduleName: c, version: "1.0.0", views: [] }],
|
|
2461
|
+
workflows: ["workflows.json", { moduleName: c, version: "1.0.0", workflows: [] }],
|
|
2462
|
+
permissions: [
|
|
2463
|
+
"permissions.json",
|
|
2464
|
+
{ moduleName: c, version: "1.0.0", permissions: [], permissionGroups: [] }
|
|
2465
|
+
],
|
|
2466
|
+
seeds: ["seeds.json", { moduleName: c, version: "1.0.0", seeds: {} }]
|
|
2467
|
+
}[s];
|
|
2468
|
+
return b ? { path: `${l}.${b[0]}`, text: de(b[1]) } : void 0;
|
|
2469
|
+
},
|
|
2470
|
+
templateSchema: {
|
|
2471
|
+
type: "object",
|
|
2472
|
+
properties: {
|
|
2473
|
+
isActive: { type: "boolean", title: t("template.isActive", "Shown in the setup wizard") },
|
|
2474
|
+
defaultLanguage: {
|
|
2475
|
+
type: "string",
|
|
2476
|
+
title: t("template.defaultLanguage", "Default language")
|
|
2477
|
+
},
|
|
2478
|
+
defaultCurrency: {
|
|
2479
|
+
type: "string",
|
|
2480
|
+
title: t("template.defaultCurrency", "Default currency")
|
|
2481
|
+
},
|
|
2482
|
+
databaseStrategy: { type: "string", title: t("template.databaseStrategy", "Database") },
|
|
2483
|
+
compliance: {
|
|
2484
|
+
type: "array",
|
|
2485
|
+
title: t("template.compliance", "Compliance"),
|
|
2486
|
+
items: { type: "string" }
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
function ai(e = {}) {
|
|
2493
|
+
let i = 0;
|
|
2494
|
+
const t = /* @__PURE__ */ new Map();
|
|
2495
|
+
for (const [n, s] of Object.entries(e))
|
|
2496
|
+
t.set(n, { text: s, version: String(++i) });
|
|
2497
|
+
const o = (n) => n ? `${n}/` : "";
|
|
2498
|
+
return {
|
|
2499
|
+
async list(n) {
|
|
2500
|
+
const s = o(n), r = /* @__PURE__ */ new Map();
|
|
2501
|
+
for (const l of t.keys()) {
|
|
2502
|
+
if (!l.startsWith(s))
|
|
2503
|
+
continue;
|
|
2504
|
+
const y = l.slice(s.length), c = y.indexOf("/");
|
|
2505
|
+
r.set(c < 0 ? y : y.slice(0, c), c < 0 ? "file" : "directory");
|
|
2506
|
+
}
|
|
2507
|
+
return [...r].map(([l, y]) => ({ name: l, kind: y }));
|
|
2508
|
+
},
|
|
2509
|
+
async read(n) {
|
|
2510
|
+
const s = t.get(n);
|
|
2511
|
+
return s ? { ...s } : null;
|
|
2512
|
+
},
|
|
2513
|
+
async write(n, s) {
|
|
2514
|
+
const r = String(++i);
|
|
2515
|
+
return t.set(n, { text: s, version: r }), r;
|
|
2516
|
+
},
|
|
2517
|
+
async remove(n) {
|
|
2518
|
+
t.delete(n);
|
|
2519
|
+
},
|
|
2520
|
+
async removeDir(n) {
|
|
2521
|
+
const s = o(n);
|
|
2522
|
+
for (const r of [...t.keys()])
|
|
2523
|
+
r.startsWith(s) && t.delete(r);
|
|
2524
|
+
},
|
|
2525
|
+
snapshot() {
|
|
2526
|
+
return Object.fromEntries([...t].map(([n, s]) => [n, s.text]));
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
const Ge = () => typeof window > "u" ? void 0 : window.showDirectoryPicker;
|
|
2531
|
+
function ri() {
|
|
2532
|
+
return typeof Ge() == "function";
|
|
2533
|
+
}
|
|
2534
|
+
async function li(e = {}) {
|
|
2535
|
+
const i = Ge();
|
|
2536
|
+
if (!i)
|
|
2537
|
+
throw new Error("This browser cannot open folders (File System Access API).");
|
|
2538
|
+
return i({
|
|
2539
|
+
mode: e.readOnly ? "read" : "readwrite",
|
|
2540
|
+
...e.id ? { id: e.id } : {}
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
const re = (e) => typeof e == "object" && e !== null && (e.name === "NotFoundError" || e.name === "TypeMismatchError");
|
|
2544
|
+
function ci(e) {
|
|
2545
|
+
const i = new TextDecoder("utf-8", { ignoreBOM: !0 });
|
|
2546
|
+
async function t(r, l = !1) {
|
|
2547
|
+
let y = e;
|
|
2548
|
+
for (const c of r.split("/").filter(Boolean))
|
|
2549
|
+
try {
|
|
2550
|
+
y = await y.getDirectoryHandle(c, { create: l });
|
|
2551
|
+
} catch (m) {
|
|
2552
|
+
if (re(m))
|
|
2553
|
+
return null;
|
|
2554
|
+
throw m;
|
|
2555
|
+
}
|
|
2556
|
+
return y;
|
|
2557
|
+
}
|
|
2558
|
+
const o = (r) => {
|
|
2559
|
+
const l = r.lastIndexOf("/");
|
|
2560
|
+
return l < 0 ? ["", r] : [r.slice(0, l), r.slice(l + 1)];
|
|
2561
|
+
};
|
|
2562
|
+
async function n(r, l = !1) {
|
|
2563
|
+
const [y, c] = o(r), m = await t(y, l);
|
|
2564
|
+
if (!m)
|
|
2565
|
+
return null;
|
|
2566
|
+
try {
|
|
2567
|
+
return await m.getFileHandle(c, { create: l });
|
|
2568
|
+
} catch (b) {
|
|
2569
|
+
if (re(b))
|
|
2570
|
+
return null;
|
|
2571
|
+
throw b;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
const s = (r) => `${r.lastModified}:${r.size}`;
|
|
2575
|
+
return {
|
|
2576
|
+
async list(r) {
|
|
2577
|
+
const l = await t(r), y = [];
|
|
2578
|
+
if (l)
|
|
2579
|
+
for await (const c of l.values())
|
|
2580
|
+
y.push({ name: c.name, kind: c.kind });
|
|
2581
|
+
return y;
|
|
2582
|
+
},
|
|
2583
|
+
async read(r) {
|
|
2584
|
+
const l = await n(r);
|
|
2585
|
+
if (!l)
|
|
2586
|
+
return null;
|
|
2587
|
+
const y = await l.getFile();
|
|
2588
|
+
return { text: i.decode(await y.arrayBuffer()), version: s(y) };
|
|
2589
|
+
},
|
|
2590
|
+
async write(r, l) {
|
|
2591
|
+
const y = await n(r, !0);
|
|
2592
|
+
if (!y)
|
|
2593
|
+
throw new Error(`Cannot write ${r}`);
|
|
2594
|
+
const c = await y.createWritable();
|
|
2595
|
+
return await c.write(l), await c.close(), s(await y.getFile());
|
|
2596
|
+
},
|
|
2597
|
+
async remove(r) {
|
|
2598
|
+
const [l, y] = o(r), c = await t(l);
|
|
2599
|
+
try {
|
|
2600
|
+
await (c == null ? void 0 : c.removeEntry(y));
|
|
2601
|
+
} catch (m) {
|
|
2602
|
+
if (!re(m))
|
|
2603
|
+
throw m;
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
async removeDir(r) {
|
|
2607
|
+
const [l, y] = o(r), c = await t(l);
|
|
2608
|
+
try {
|
|
2609
|
+
await (c == null ? void 0 : c.removeEntry(y, { recursive: !0 }));
|
|
2610
|
+
} catch (m) {
|
|
2611
|
+
if (!re(m))
|
|
2612
|
+
throw m;
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
export {
|
|
2618
|
+
W as OMNIVERK_CUSTOM_PREFIX,
|
|
2619
|
+
vt as OMNIVERK_DATA_TYPES,
|
|
2620
|
+
Pt as OMNIVERK_LEGACY_LIST_VIEW_FILES,
|
|
2621
|
+
ei as OMNIVERK_LOCALES,
|
|
2622
|
+
ye as OmniVerkRestError,
|
|
2623
|
+
Et as buildOmniVerkModule,
|
|
2624
|
+
ci as createDirectoryHandleFileSystem,
|
|
2625
|
+
ai as createMemorySeedFileSystem,
|
|
2626
|
+
si as createOmniVerkRestProvider,
|
|
2627
|
+
oi as createOmniVerkStudioPreset,
|
|
2628
|
+
ni as createSeedFolderProvider,
|
|
2629
|
+
Ot as duplicateOmniVerkModule,
|
|
2630
|
+
ri as isSeedFolderPickerSupported,
|
|
2631
|
+
Xe as omniverkEntitiesKind,
|
|
2632
|
+
yt as omniverkFileKinds,
|
|
2633
|
+
kt as omniverkFilePrefix,
|
|
2634
|
+
Qe as omniverkI18nKind,
|
|
2635
|
+
He as omniverkManifestKind,
|
|
2636
|
+
ht as omniverkManifestSections,
|
|
2637
|
+
R as omniverkPascalIdentifier,
|
|
2638
|
+
mt as omniverkPermissionsKind,
|
|
2639
|
+
ue as omniverkRevisionStamp,
|
|
2640
|
+
ut as omniverkScriptKind,
|
|
2641
|
+
ft as omniverkSeedsKind,
|
|
2642
|
+
It as omniverkSpecFromStudio,
|
|
2643
|
+
qe as omniverkStableId,
|
|
2644
|
+
Ve as omniverkTableName,
|
|
2645
|
+
Ie as omniverkTemplateFromDto,
|
|
2646
|
+
Vt as omniverkTemplateFromEntry,
|
|
2647
|
+
Ee as omniverkTemplateToEntry,
|
|
2648
|
+
Ut as omniverkTemplateToInput,
|
|
2649
|
+
st as omniverkViewFromItem,
|
|
2650
|
+
nt as omniverkViewItem,
|
|
2651
|
+
ot as omniverkViewsKind,
|
|
2652
|
+
lt as omniverkWorkflowFromItem,
|
|
2653
|
+
rt as omniverkWorkflowItem,
|
|
2654
|
+
ct as omniverkWorkflowsKind,
|
|
2655
|
+
li as pickSeedDirectory,
|
|
2656
|
+
Rt as validateOmniVerkModule,
|
|
2657
|
+
Kt as validateOmniVerkWorkspace
|
|
2658
|
+
};
|