@nice2dev/erp-adapter 1.4.5 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/omniverk.mjs CHANGED
@@ -1,61 +1,61 @@
1
- import { objectFileKind as _e, endsWithAny as te, arrayFileKind as Be, i18nFileKind as ze, itemsFileKind as Oe, jsonFileKind as Ae, jsonValuesEqual as Le, keepTextFormat as Je, parseJsonText as _, patchJsonText as Me, 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({
1
+ import { objectFileKind as Be, endsWithAny as B, arrayFileKind as Oe, i18nFileKind as ze, itemsFileKind as Ae, jsonFileKind as Le, scriptsFileKind as Je, jsonValuesEqual as Ke, keepTextFormat as He, parseJsonText as _, patchJsonText as De, stringifyJsonText as ae } 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)), Ze = Be({
3
3
  id: "manifest",
4
4
  label: "Manifest",
5
5
  labelKey: "devStudio.kind.manifest",
6
6
  icon: "file",
7
7
  editor: "manifest",
8
- match: te(".manifest.json")
9
- }), De = [
8
+ match: B(".manifest.json")
9
+ }), Me = [
10
10
  ["dataType", "type"],
11
11
  ["isRequired", "required"]
12
- ], le = "$aliases";
13
- function Ze(e) {
12
+ ], ce = "$aliases";
13
+ function Ye(e) {
14
14
  if (!V(e))
15
15
  return e;
16
- const i = De.filter(([o, n]) => !(o in e) && n in e);
16
+ const i = Me.filter(([a, n]) => !(a in e) && n in e);
17
17
  if (i.length === 0)
18
18
  return e;
19
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;
20
+ for (const [a, n] of Object.entries(e)) {
21
+ const s = i.find(([, r]) => r === a);
22
+ t[s ? s[0] : a] = n;
23
23
  }
24
- return t[le] = i.map(([, o]) => o), t;
24
+ return t[ce] = i.map(([, a]) => a), t;
25
25
  }
26
- function Ye(e) {
27
- if (!V(e) || !Array.isArray(e[le]))
26
+ function Xe(e) {
27
+ if (!V(e) || !Array.isArray(e[ce]))
28
28
  return e;
29
- const i = e[le], t = {};
30
- for (const [o, n] of Object.entries(e)) {
31
- if (o === le)
29
+ const i = e[ce], t = {};
30
+ for (const [a, n] of Object.entries(e)) {
31
+ if (a === ce)
32
32
  continue;
33
- const s = De.find(([r, l]) => r === o && i.includes(l));
34
- t[s ? s[1] : o] = n;
33
+ const s = Me.find(([r, l]) => r === a && i.includes(l));
34
+ t[s ? s[1] : a] = n;
35
35
  }
36
36
  return t;
37
37
  }
38
- const Se = (e, i) => V(e) && Array.isArray(e.fields) ? { ...e, fields: e.fields.map(i) } : e, Xe = (() => {
39
- const e = Be({
38
+ const Se = (e, i) => V(e) && Array.isArray(e.fields) ? { ...e, fields: e.fields.map(i) } : e, Qe = (() => {
39
+ const e = Oe({
40
40
  id: "entities",
41
41
  label: "Entities",
42
42
  labelKey: "devStudio.kind.entities",
43
43
  icon: "database",
44
44
  editor: "entities",
45
- match: te(".entities.json"),
45
+ match: B(".entities.json"),
46
46
  property: "entities",
47
47
  itemKey: "name"
48
48
  });
49
49
  return {
50
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)),
51
+ decode: (i, t) => e.decode(i, t).map((a) => Se(a, Ye)),
52
+ encode: (i, t, a) => e.encode(
53
+ i.map((n) => Se(n, Xe)),
54
54
  t,
55
- o
55
+ a
56
56
  )
57
57
  };
58
- })(), Qe = ze(), ge = {
58
+ })(), et = ze(), ge = {
59
59
  input: "textInput",
60
60
  text: "textInput",
61
61
  textarea: "textArea",
@@ -68,7 +68,7 @@ const Se = (e, i) => V(e) && Array.isArray(e.fields) ? { ...e, fields: e.fields.
68
68
  lookup: "select",
69
69
  select: "select"
70
70
  };
71
- function et(e) {
71
+ function tt(e) {
72
72
  const i = e.columns.map((t) => ({
73
73
  field: String(t.field ?? ""),
74
74
  header: String(t.displayName ?? t.header ?? t.label ?? t.field ?? "")
@@ -96,25 +96,25 @@ function et(e) {
96
96
  ]
97
97
  };
98
98
  }
99
- function Ke(e, i) {
100
- var l, y, d;
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 = (d = (y = e.dataSources) == null ? void 0 : y.find((m) => m.type === "entity")) == null ? void 0 : d.entity, r = (m) => "displayName" in m ? "displayName" : "header" in m ? "header" : "label" in m ? "label" : "displayName";
99
+ function Fe(e, i) {
100
+ var l, h, d;
101
+ const t = (e.rows ?? []).flatMap((p) => p.cells).find((p) => p.controlType === "dataGrid"), a = ((l = t == null ? void 0 : t.props) == null ? void 0 : l.columns) ?? [], n = i.columns ?? [], s = (d = (h = e.dataSources) == null ? void 0 : h.find((p) => p.type === "entity")) == null ? void 0 : d.entity, r = (p) => "displayName" in p ? "displayName" : "header" in p ? "header" : "label" in p ? "label" : "displayName";
102
102
  return U({
103
103
  ...i,
104
104
  displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
105
105
  entityName: s ?? i.entityName,
106
- columns: o.map((m) => {
107
- const b = n.find((T) => T.field === m.field);
108
- if (!b)
109
- return { field: m.field, displayName: m.header ?? m.field };
110
- const C = r(b), j = m.header ?? m.field;
111
- return b[C] === void 0 && j === m.field ? b : { ...b, [C]: j };
106
+ columns: a.map((p) => {
107
+ const k = n.find((T) => T.field === p.field);
108
+ if (!k)
109
+ return { field: p.field, displayName: p.header ?? p.field };
110
+ const A = r(k), S = p.header ?? p.field;
111
+ return k[A] === void 0 && S === p.field ? k : { ...k, [A]: S };
112
112
  })
113
113
  });
114
114
  }
115
- function tt(e) {
115
+ function it(e) {
116
116
  const i = [];
117
- return e.tabs.forEach((o, n) => {
117
+ return e.tabs.forEach((a, n) => {
118
118
  i.push({
119
119
  id: `tab-${n}`,
120
120
  cells: [
@@ -122,10 +122,10 @@ function tt(e) {
122
122
  id: `tab-${n}`,
123
123
  controlType: "heading",
124
124
  colSpan: 12,
125
- props: { text: String(o.displayName ?? o.name ?? ""), level: 2, name: o.name }
125
+ props: { text: String(a.displayName ?? a.name ?? ""), level: 2, name: a.name }
126
126
  }
127
127
  ]
128
- }), (o.sections ?? []).forEach((s, r) => {
128
+ }), (a.sections ?? []).forEach((s, r) => {
129
129
  i.push({
130
130
  id: `tab-${n}-section-${r}`,
131
131
  cells: [
@@ -141,24 +141,24 @@ function tt(e) {
141
141
  }
142
142
  ]
143
143
  });
144
- let l = [], y = 0;
144
+ let l = [], h = 0;
145
145
  const d = () => {
146
- l.length && (i.push({ id: `tab-${n}-section-${r}-row-${i.length}`, cells: l }), l = [], y = 0);
146
+ l.length && (i.push({ id: `tab-${n}-section-${r}-row-${i.length}`, cells: l }), l = [], h = 0);
147
147
  };
148
- (s.controls ?? []).forEach((m, b) => {
149
- const C = typeof m.colSpan == "number" ? m.colSpan : 6;
150
- y + C > 12 && d(), l.push({
151
- id: `c-${n}-${r}-${b}`,
152
- controlType: ge[String(m.type)] ?? "textInput",
153
- colSpan: C,
148
+ (s.controls ?? []).forEach((p, k) => {
149
+ const A = typeof p.colSpan == "number" ? p.colSpan : 6;
150
+ h + A > 12 && d(), l.push({
151
+ id: `c-${n}-${r}-${k}`,
152
+ controlType: ge[String(p.type)] ?? "textInput",
153
+ colSpan: A,
154
154
  props: {
155
- label: String(m.label ?? m.field ?? ""),
156
- required: m.required === !0,
157
- field: m.field,
158
- type: m.type
155
+ label: String(p.label ?? p.field ?? ""),
156
+ required: p.required === !0,
157
+ field: p.field,
158
+ type: p.type
159
159
  },
160
- bindings: { value: { source: "record", field: String(m.field ?? "") } }
161
- }), y += C;
160
+ bindings: { value: { source: "record", field: String(p.field ?? "") } }
161
+ }), h += A;
162
162
  }), d();
163
163
  });
164
164
  }), {
@@ -171,117 +171,117 @@ function tt(e) {
171
171
  rows: i
172
172
  };
173
173
  }
174
- function Fe(e, i) {
175
- var d, m, b, C, j;
176
- const t = i.tabs ?? [], o = t.flatMap(
174
+ function Pe(e, i) {
175
+ var d, p, k, A, S;
176
+ const t = i.tabs ?? [], a = t.flatMap(
177
177
  (T) => (T.sections ?? []).flatMap((I) => I.controls ?? [])
178
178
  ), n = [];
179
179
  let s = null, r = null;
180
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
181
  for (const T of e.rows ?? [])
182
182
  for (const I of T.cells) {
183
- const c = I.props ?? {};
184
- if (I.controlType === "heading" && (c.level === 2 || c.level === 3)) {
185
- const x = G(c.name) ?? String(c.text ?? "").replace(/\s+/g, "");
186
- if (c.level === 2)
187
- s = { ...t.find((k) => k.name === x) ?? {}, name: x, displayName: String(c.text ?? x), sections: [] }, n.push(s), r = null;
183
+ const b = I.props ?? {};
184
+ if (I.controlType === "heading" && (b.level === 2 || b.level === 3)) {
185
+ const N = G(b.name) ?? String(b.text ?? "").replace(/\s+/g, "");
186
+ if (b.level === 2)
187
+ s = { ...t.find((j) => j.name === N) ?? {}, name: N, displayName: String(b.text ?? N), sections: [] }, n.push(s), r = null;
188
188
  else {
189
189
  s || (s = { name: "Main", displayName: e.name, sections: [] }, n.push(s));
190
- const D = t.flatMap((S) => S.sections ?? []).find((S) => S.name === x);
191
- r = { ...D ? Object.fromEntries(Object.entries(D).filter(([S]) => S !== "controls")) : {}, name: x, displayName: String(c.text ?? x), controls: [] }, s.sections.push(r);
190
+ const C = t.flatMap((O) => O.sections ?? []).find((O) => O.name === N);
191
+ r = { ...C ? Object.fromEntries(Object.entries(C).filter(([O]) => O !== "controls")) : {}, name: N, displayName: String(b.text ?? N), controls: [] }, s.sections.push(r);
192
192
  }
193
193
  continue;
194
194
  }
195
- const v = ((m = (d = I.bindings) == null ? void 0 : d.value) == null ? void 0 : m.field) ?? G(c.field);
196
- if (!v)
195
+ const D = ((p = (d = I.bindings) == null ? void 0 : d.value) == null ? void 0 : p.field) ?? G(b.field);
196
+ if (!D)
197
197
  continue;
198
- const f = o.find((x) => x.field === v), E = f && ge[String(f.type)] === I.controlType ? f.type : ((b = Object.entries(ge).find(([, x]) => x === I.controlType)) == null ? void 0 : b[0]) ?? "input", A = U({
199
- ...f ?? {},
200
- field: v,
201
- type: E,
202
- label: c.label !== void 0 ? String(c.label) : f == null ? void 0 : f.label,
203
- colSpan: (f == null ? void 0 : f.colSpan) !== void 0 || I.colSpan !== 6 ? I.colSpan : void 0,
204
- required: c.required === !0 ? !0 : (f == null ? void 0 : f.required) === !0 ? !1 : f == null ? void 0 : f.required
198
+ const u = a.find((N) => N.field === D), v = u && ge[String(u.type)] === I.controlType ? u.type : ((k = Object.entries(ge).find(([, N]) => N === I.controlType)) == null ? void 0 : k[0]) ?? "input", f = U({
199
+ ...u ?? {},
200
+ field: D,
201
+ type: v,
202
+ label: b.label !== void 0 ? String(b.label) : u == null ? void 0 : u.label,
203
+ colSpan: (u == null ? void 0 : u.colSpan) !== void 0 || I.colSpan !== 6 ? I.colSpan : void 0,
204
+ required: b.required === !0 ? !0 : (u == null ? void 0 : u.required) === !0 ? !1 : u == null ? void 0 : u.required
205
205
  });
206
- l().controls.push(A);
206
+ l().controls.push(f);
207
207
  }
208
- const y = n.map((T) => {
209
- const I = t.find((c) => c.name === T.name);
208
+ const h = n.map((T) => {
209
+ const I = t.find((b) => b.name === T.name);
210
210
  return I ? { ...I, ...T } : T;
211
211
  });
212
212
  return U({
213
213
  ...i,
214
214
  displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
215
- entityName: ((j = (C = e.dataSources) == null ? void 0 : C.find((T) => T.type === "entity")) == null ? void 0 : j.entity) ?? i.entityName,
216
- tabs: y
215
+ entityName: ((S = (A = e.dataSources) == null ? void 0 : A.find((T) => T.type === "entity")) == null ? void 0 : S.entity) ?? i.entityName,
216
+ tabs: h
217
217
  });
218
218
  }
219
- const it = (e) => {
219
+ const nt = (e) => {
220
220
  const i = String(e.type ?? "").toLowerCase();
221
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
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);
223
+ function st(e, i) {
224
+ const t = V(e) ? e : {}, a = G(t.name) ?? G(t.id) ?? `#${i}`, n = G(t.displayName) ?? a, s = nt(t);
225
225
  if (!s)
226
226
  return {
227
- key: o,
227
+ key: a,
228
228
  label: n,
229
229
  source: e,
230
230
  rawReason: String(t.type ?? (t.viewJson ? "viewJson" : "unknown"))
231
231
  };
232
- const r = s === "List" ? et(t) : tt(t), l = s === "List" ? Ke(r, t) : Fe(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)` };
232
+ const r = s === "List" ? tt(t) : it(t), l = s === "List" ? Fe(r, t) : Pe(r, t);
233
+ return Ke(l, e) ? { key: a, label: n, definition: r, source: e } : { key: a, label: n, source: e, rawReason: `${s} (round-trip)` };
234
234
  }
235
- function st(e) {
235
+ function ot(e) {
236
236
  if (!e.definition)
237
237
  return e.source;
238
238
  const i = V(e.source) ? e.source : { name: e.definition.id };
239
- return e.definition.kind === "form" ? Fe(e.definition, {
239
+ return e.definition.kind === "form" ? Pe(e.definition, {
240
240
  type: "Form",
241
241
  ...i,
242
242
  name: i.name ?? e.definition.id
243
- }) : Ke(e.definition, {
243
+ }) : Fe(e.definition, {
244
244
  type: "List",
245
245
  ...i,
246
246
  name: i.name ?? e.definition.id
247
247
  });
248
248
  }
249
- const ot = Oe({
249
+ const at = Ae({
250
250
  id: "views",
251
251
  label: "Views",
252
252
  labelKey: "devStudio.kind.views",
253
253
  icon: "grid",
254
254
  editor: "views",
255
- match: te(".views.json"),
255
+ match: B(".views.json"),
256
256
  property: "views",
257
257
  itemKey: "name",
258
- toItem: nt,
259
- fromItem: st
258
+ toItem: st,
259
+ fromItem: ot
260
260
  });
261
- function at(e) {
261
+ function rt(e) {
262
262
  const i = e.steps ?? [], t = e.connections ?? [];
263
263
  return {
264
264
  id: String(e.name),
265
265
  name: String(e.displayName ?? e.name),
266
266
  entityType: String(e.entityName ?? ""),
267
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",
268
+ states: i.map((a, n) => ({
269
+ id: String(a.state),
270
+ name: String(a.displayName ?? a.state),
271
+ type: a.isInitial === !0 ? "initial" : a.isFinal === !0 ? "final" : "intermediate",
272
272
  position: { x: 60 + n % 4 * 230, y: 80 + Math.floor(n / 4) * 140 }
273
273
  })),
274
- transitions: t.map((o, n) => ({
274
+ transitions: t.map((a, n) => ({
275
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 } : {}
276
+ fromStateId: String(a.fromState),
277
+ toStateId: String(a.toState),
278
+ name: String(a.actionName ?? ""),
279
+ ...typeof a.requiredPermission == "string" ? { requiredPermission: a.requiredPermission } : {}
280
280
  }))
281
281
  };
282
282
  }
283
- function Pe(e, i) {
284
- const t = i.steps ?? [], o = i.connections ?? [];
283
+ function Re(e, i) {
284
+ const t = i.steps ?? [], a = i.connections ?? [];
285
285
  return U({
286
286
  ...i,
287
287
  displayName: "displayName" in i || e.name !== i.name ? e.name : void 0,
@@ -296,7 +296,7 @@ function Pe(e, i) {
296
296
  });
297
297
  }),
298
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);
299
+ const s = /^t(\d+)$/.exec(n.id), r = s ? a[Number(s[1])] : a.find((l) => l.fromState === n.fromStateId && l.toState === n.toStateId);
300
300
  return U({
301
301
  ...r ?? {},
302
302
  fromState: n.fromStateId,
@@ -307,35 +307,35 @@ function Pe(e, i) {
307
307
  })
308
308
  });
309
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(Pe(l, t), e) ? { key: o, label: n, definition: l, source: e } : { key: o, label: n, source: e, rawReason: "state machine (round-trip)" };
310
+ function lt(e, i) {
311
+ const t = V(e) ? e : {}, a = G(t.name) ?? `#${i}`, n = G(t.displayName) ?? a, s = t.steps;
312
+ if (!(Array.isArray(t.connections) && Array.isArray(s) && s.every((h) => V(h) && typeof h.state == "string")))
313
+ return { key: a, label: n, source: e, rawReason: G(t.triggerType) ?? "automation" };
314
+ const l = rt(t);
315
+ return Ke(Re(l, t), e) ? { key: a, label: n, definition: l, source: e } : { key: a, label: n, source: e, rawReason: "state machine (round-trip)" };
316
316
  }
317
- function lt(e) {
317
+ function ct(e) {
318
318
  if (!e.definition)
319
319
  return e.source;
320
320
  const i = V(e.source) ? e.source : { name: e.definition.id };
321
- return Pe(e.definition, {
321
+ return Re(e.definition, {
322
322
  ...i,
323
323
  name: i.name ?? e.definition.id
324
324
  });
325
325
  }
326
- const ct = Oe({
326
+ const dt = Ae({
327
327
  id: "workflows",
328
328
  label: "Workflows",
329
329
  labelKey: "devStudio.kind.workflows",
330
330
  icon: "git-branch",
331
331
  editor: "workflows",
332
- match: te(".workflows.json"),
332
+ match: B(".workflows.json"),
333
333
  property: "workflows",
334
334
  itemKey: "name",
335
- toItem: rt,
336
- fromItem: lt
335
+ toItem: lt,
336
+ fromItem: ct
337
337
  });
338
- function dt(e) {
338
+ function pt(e) {
339
339
  const i = V(e) ? e : {};
340
340
  return {
341
341
  permissions: (i.permissions ?? []).map(
@@ -355,12 +355,12 @@ function dt(e) {
355
355
  )
356
356
  };
357
357
  }
358
- function pt(e, i) {
359
- const t = V(e) ? e : {}, o = t.permissions ?? [], n = t.permissionGroups ?? [];
358
+ function mt(e, i) {
359
+ const t = V(e) ? e : {}, a = t.permissions ?? [], n = t.permissionGroups ?? [];
360
360
  return {
361
361
  ...t,
362
362
  permissions: i.permissions.map((s) => {
363
- const r = o.find((l) => l.code === s.code);
363
+ const r = a.find((l) => l.code === s.code);
364
364
  return U({ ...r ?? {}, code: s.code, name: s.name, description: s.description });
365
365
  }),
366
366
  permissionGroups: i.groups.map((s) => {
@@ -374,23 +374,23 @@ function pt(e, i) {
374
374
  })
375
375
  };
376
376
  }
377
- const mt = Ae({
377
+ const ut = Le({
378
378
  id: "permissions",
379
379
  label: "Permissions",
380
380
  labelKey: "devStudio.kind.permissions",
381
381
  icon: "shield",
382
382
  editor: "permissions",
383
- match: te(".permissions.json"),
384
- select: dt,
385
- assign: pt,
383
+ match: B(".permissions.json"),
384
+ select: pt,
385
+ assign: mt,
386
386
  arrayKey: (e) => e === "/permissions" ? "code" : e === "/permissionGroups" ? "name" : void 0
387
- }), ut = Ae({
387
+ }), ft = Le({
388
388
  id: "seeds",
389
389
  label: "Seed data",
390
390
  labelKey: "devStudio.kind.seeds",
391
391
  icon: "database",
392
392
  editor: "seeds",
393
- match: te(".seeds.json"),
393
+ match: B(".seeds.json"),
394
394
  select: (e) => {
395
395
  const i = V(e) ? e : {};
396
396
  if (!V(i.seeds) || i.demoSeeds !== void 0 && !V(i.demoSeeds))
@@ -399,7 +399,7 @@ const mt = Ae({
399
399
  },
400
400
  assign: (e, i) => U({ ...V(e) ? e : {}, seeds: i.seeds, demoSeeds: i.demoSeeds }),
401
401
  arrayKey: () => "Id"
402
- }), ft = {
402
+ }), yt = {
403
403
  id: "script",
404
404
  label: "Script",
405
405
  labelKey: "devStudio.kind.script",
@@ -408,24 +408,39 @@ const mt = Ae({
408
408
  match: (e) => /(^|\/)(services|scripts|jobs|handlers)\/[^/]+\.(js|ts|cs)$/i.test(e) || /\.cs$/i.test(e),
409
409
  decode: (e) => e[0].text,
410
410
  encode: (e, i) => ({
411
- files: [{ path: i[0].path, text: Je(e, i[0].text) }]
411
+ files: [{ path: i[0].path, text: He(e, i[0].text) }]
412
412
  })
413
- }, yt = [
414
- He,
415
- Xe,
413
+ }, gt = Je({
414
+ match: B(".scripts.json"),
415
+ property: "scripts",
416
+ phasesProperty: "scripts"
417
+ }), ht = Oe({
418
+ id: "dataSources",
419
+ label: "Data sources",
420
+ labelKey: "devStudio.kind.dataSources",
421
+ icon: "database",
422
+ editor: "dataSources",
423
+ match: B(".datasources.json"),
424
+ property: "dataSources",
425
+ itemKey: "key"
426
+ }), wt = [
427
+ Ze,
416
428
  Qe,
417
- ot,
418
- ct,
419
- mt,
429
+ et,
430
+ at,
431
+ dt,
420
432
  ut,
421
- ft
422
- ], gt = (e, i) => i, z = (e) => ({
433
+ ft,
434
+ ht,
435
+ gt,
436
+ yt
437
+ ], vt = (e, i) => i, J = (e) => ({
423
438
  type: "array",
424
439
  title: e,
425
440
  items: { type: "string" }
426
441
  });
427
- function ht(e = gt, i = {}) {
428
- const t = (s, r) => e(`devStudio.omniverk.${s}`, r), o = {
442
+ function $t(e = vt, i = {}) {
443
+ const t = (s, r) => e(`devStudio.omniverk.${s}`, r), a = {
429
444
  type: "object",
430
445
  properties: {
431
446
  key: { type: "string", title: t("field.key", "Key") },
@@ -495,11 +510,11 @@ function ht(e = gt, i = {}) {
495
510
  description: { type: "string", title: t("field.description", "Description") },
496
511
  icon: { type: "string", title: t("field.icon", "Icon") },
497
512
  color: { type: "string", title: t("field.color", "Colour") },
498
- parts: z(t("field.parts", "Files"))
513
+ parts: J(t("field.parts", "Files"))
499
514
  }
500
515
  }
501
516
  },
502
- i18n: z(t("field.i18n", "Translation files"))
517
+ i18n: J(t("field.i18n", "Translation files"))
503
518
  }
504
519
  }
505
520
  },
@@ -509,7 +524,7 @@ function ht(e = gt, i = {}) {
509
524
  schema: {
510
525
  type: "object",
511
526
  properties: {
512
- dependencies: z(t("field.dependencies", "Required packages")),
527
+ dependencies: J(t("field.dependencies", "Required packages")),
513
528
  dependencyRefs: {
514
529
  type: "array",
515
530
  title: t("field.dependencyRefs", "Dependency details"),
@@ -536,8 +551,8 @@ function ht(e = gt, i = {}) {
536
551
  }
537
552
  }
538
553
  },
539
- provides: z(t("field.provides", "Provides")),
540
- requiredControls: z(t("field.requiredControls", "Required controls"))
554
+ provides: J(t("field.provides", "Provides")),
555
+ requiredControls: J(t("field.requiredControls", "Required controls"))
541
556
  }
542
557
  }
543
558
  },
@@ -559,7 +574,7 @@ function ht(e = gt, i = {}) {
559
574
  icon: { type: "string", title: t("field.icon", "Icon") },
560
575
  isOptional: { type: "boolean", title: t("field.isOptional", "Optional") },
561
576
  order: { type: "integer", title: t("field.order", "Order") },
562
- fields: { type: "array", title: t("field.fields", "Fields"), items: o }
577
+ fields: { type: "array", title: t("field.fields", "Fields"), items: a }
563
578
  }
564
579
  }
565
580
  },
@@ -623,7 +638,7 @@ function ht(e = gt, i = {}) {
623
638
  fields: {
624
639
  type: "array",
625
640
  title: t("field.fields", "Fields"),
626
- items: o
641
+ items: a
627
642
  }
628
643
  }
629
644
  }
@@ -713,8 +728,8 @@ function ht(e = gt, i = {}) {
713
728
  image: { type: "string", title: t("field.image", "Image") },
714
729
  tag: { type: "string", title: t("field.tag", "Tag") },
715
730
  description: { type: "string", title: t("field.description", "Description") },
716
- ports: z(t("field.ports", "Ports")),
717
- volumes: z(t("field.volumes", "Volumes")),
731
+ ports: J(t("field.ports", "Ports")),
732
+ volumes: J(t("field.volumes", "Volumes")),
718
733
  command: { type: "string", title: t("field.command", "Command") },
719
734
  healthCheckCmd: {
720
735
  type: "string",
@@ -804,7 +819,7 @@ function ht(e = gt, i = {}) {
804
819
  }
805
820
  return n;
806
821
  }
807
- const W = "Custom.", Ne = "Core", wt = {
822
+ const W = "Custom.", Ne = "Core", bt = {
808
823
  string: "string",
809
824
  varchar: "string",
810
825
  nvarchar: "string",
@@ -834,7 +849,7 @@ const W = "Custom.", Ne = "Core", wt = {
834
849
  enum: "enum",
835
850
  guid: "Guid",
836
851
  uuid: "Guid"
837
- }, vt = [
852
+ }, kt = [
838
853
  "string",
839
854
  "text",
840
855
  "int",
@@ -848,7 +863,7 @@ const W = "Custom.", Ne = "Core", wt = {
848
863
  "json",
849
864
  "enum",
850
865
  "Guid"
851
- ], $t = {
866
+ ], St = {
852
867
  ł: "l",
853
868
  Ł: "L",
854
869
  ß: "ss",
@@ -857,11 +872,11 @@ const W = "Custom.", Ne = "Core", wt = {
857
872
  ø: "o",
858
873
  Ø: "O"
859
874
  };
860
- function bt(e) {
861
- return [...e.normalize("NFD")].map((i) => $t[i] ?? (new RegExp("\\p{Mn}", "u").test(i) ? "" : i)).join("").normalize("NFC");
875
+ function Nt(e) {
876
+ return [...e.normalize("NFD")].map((i) => St[i] ?? (new RegExp("\\p{Mn}", "u").test(i) ? "" : i)).join("").normalize("NFC");
862
877
  }
863
878
  function P(e) {
864
- const i = bt(e ?? "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join("");
879
+ const i = Nt(e ?? "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((t) => t[0].toUpperCase() + t.slice(1)).join("");
865
880
  return /^[0-9]/.test(i) ? `M${i}` : i;
866
881
  }
867
882
  const je = (e) => e !== e.toLowerCase() && e === e.toUpperCase();
@@ -870,26 +885,26 @@ function he(e) {
870
885
  (i, t) => t > 0 && je(i) && !je(e[t - 1]) ? `_${i.toLowerCase()}` : i.toLowerCase()
871
886
  ).join("");
872
887
  }
873
- function kt(e) {
888
+ function jt(e) {
874
889
  return (e.startsWith(W) ? e.slice(W.length) : e.split(".").pop() ?? e).toLowerCase().replace(/[^a-z0-9_-]+/g, "") || "module";
875
890
  }
876
- async function Re(e) {
891
+ async function qe(e) {
877
892
  const i = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
878
893
  return new Uint8Array(i);
879
894
  }
880
895
  const ke = (e) => Array.from(e, (i) => i.toString(16).padStart(2, "0")).join("");
881
- async function qe(e, i) {
882
- const t = (await Re(`${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]));
883
- return `${o.slice(0, 8)}-${o.slice(8, 12)}-${o.slice(12, 16)}-${o.slice(16, 20)}-${o.slice(20)}`;
884
- }
885
896
  async function Ve(e, i) {
897
+ const t = (await qe(`${e}/${i}`.toLowerCase())).slice(0, 16), a = ke([3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15].map((n) => t[n]));
898
+ return `${a.slice(0, 8)}-${a.slice(8, 12)}-${a.slice(12, 16)}-${a.slice(16, 20)}-${a.slice(20)}`;
899
+ }
900
+ async function Ue(e, i) {
886
901
  const t = `custom_${e}_${he(i)}`;
887
- return t.length <= 63 ? t : `${t.slice(0, 54)}_${ke(await Re(t)).slice(0, 8)}`;
902
+ return t.length <= 63 ? t : `${t.slice(0, 54)}_${ke(await qe(t)).slice(0, 8)}`;
888
903
  }
889
- function St(e, i) {
890
- const t = new Set([...i].map((o) => o.toLowerCase()));
891
- for (let o = 1; o < 100; o++) {
892
- const n = o === 1 ? e : `${e}${o}`;
904
+ function Tt(e, i) {
905
+ const t = new Set([...i].map((a) => a.toLowerCase()));
906
+ for (let a = 1; a < 100; a++) {
907
+ const n = a === 1 ? e : `${e}${a}`;
893
908
  if (!t.has(n.toLowerCase()))
894
909
  return n;
895
910
  }
@@ -900,7 +915,7 @@ const ne = (e) => e.name.toLowerCase() === "id", q = (e) => {
900
915
  return (((i = e.displayName) == null ? void 0 : i.trim()) || e.name).trim();
901
916
  };
902
917
  function se(e) {
903
- return e.isForeignKey ? "Guid" : wt[String(e.dataType ?? "").trim().toLowerCase()] ?? "string";
918
+ return e.isForeignKey ? "Guid" : bt[String(e.dataType ?? "").trim().toLowerCase()] ?? "string";
904
919
  }
905
920
  function pe(e) {
906
921
  if (e.isForeignKey)
@@ -925,7 +940,7 @@ function pe(e) {
925
940
  return ["Text", "input"];
926
941
  }
927
942
  }
928
- const Nt = {
943
+ const Et = {
929
944
  lookup: "EntitySelect",
930
945
  textarea: "Textarea",
931
946
  number: "number",
@@ -934,10 +949,10 @@ const Nt = {
934
949
  date: "date",
935
950
  datetime: "datetime"
936
951
  };
937
- function jt(e) {
938
- var o;
952
+ function xt(e) {
953
+ var a;
939
954
  const i = [];
940
- (!((o = e.name) != null && o.trim()) || P(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.");
955
+ (!((a = e.name) != null && a.trim()) || P(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.");
941
956
  const t = /* @__PURE__ */ new Set();
942
957
  for (const n of e.entities) {
943
958
  const s = P(n.name);
@@ -946,20 +961,20 @@ function jt(e) {
946
961
  continue;
947
962
  }
948
963
  t.has(s.toLowerCase()) && i.push(`Entity ${s} appears twice.`), t.add(s.toLowerCase());
949
- const r = n.fields.filter((y) => !ne(y));
964
+ const r = n.fields.filter((h) => !ne(h));
950
965
  r.length === 0 && i.push(`Entity ${s} has no fields — add at least one.`);
951
966
  const l = /* @__PURE__ */ new Set();
952
- for (const y of r) {
953
- const d = P(y.name);
954
- d.length === 0 ? i.push(`${s}: field "${y.name}" needs a name with letters or digits.`) : l.has(d.toLowerCase()) ? i.push(`${s}: field ${d} appears twice.`) : l.add(d.toLowerCase());
967
+ for (const h of r) {
968
+ const d = P(h.name);
969
+ d.length === 0 ? i.push(`${s}: field "${h.name}" needs a name with letters or digits.`) : l.has(d.toLowerCase()) ? i.push(`${s}: field ${d} appears twice.`) : l.add(d.toLowerCase());
955
970
  }
956
971
  }
957
972
  return i;
958
973
  }
959
- const Tt = (e) => e.toISOString().replace(/\.(\d{3})Z$/, ".$10000Z"), Y = (e) => de(e, { finalNewline: !1 }), J = (e, i) => ({
974
+ const It = (e) => e.toISOString().replace(/\.(\d{3})Z$/, ".$10000Z"), X = (e) => ae(e, { finalNewline: !1 }), H = (e, i) => ({
960
975
  icon: { name: e, package: "@nice2dev/icons", style: i }
961
976
  });
962
- function Et(e) {
977
+ function Ct(e) {
963
978
  const i = e && /^Ntd[A-Z]/.test(e), t = e && /^[A-Z]\w*Icon$/.test(e);
964
979
  return {
965
980
  module: {
@@ -971,204 +986,204 @@ function Et(e) {
971
986
  animation: { type: "none" }
972
987
  },
973
988
  entities: {},
974
- views: { list: J("NtdList", "outline"), form: J("NtdEdit", "outline") },
989
+ views: { list: H("NtdList", "outline"), form: H("NtdEdit", "outline") },
975
990
  permissions: {
976
- read: J("NtdEye", "outline"),
977
- create: J("NtdPlus", "outline"),
978
- update: J("NtdEdit", "outline"),
979
- delete: J("NtdTrash", "outline"),
980
- admin: J("NtdShield", "solid")
991
+ read: H("NtdEye", "outline"),
992
+ create: H("NtdPlus", "outline"),
993
+ update: H("NtdEdit", "outline"),
994
+ delete: H("NtdTrash", "outline"),
995
+ admin: H("NtdShield", "solid")
981
996
  },
982
997
  workflowStates: {}
983
998
  };
984
999
  }
985
- async function xt(e, i = {}) {
986
- var E, A, x, D;
987
- const t = jt(e);
1000
+ async function Ot(e, i = {}) {
1001
+ var v, f, N, C;
1002
+ const t = xt(e);
988
1003
  if (t.length > 0)
989
1004
  return { problems: t };
990
- const o = e.name.toLowerCase().startsWith(W.toLowerCase()), n = P(
991
- o ? e.name.slice(W.length) : e.name
992
- ), s = St(
1005
+ const a = e.name.toLowerCase().startsWith(W.toLowerCase()), n = P(
1006
+ a ? e.name.slice(W.length) : e.name
1007
+ ), s = Tt(
993
1008
  W + n,
994
1009
  i.existingPackageNames ?? /* @__PURE__ */ new Set()
995
- ), r = s.slice(W.length), l = r.toLowerCase(), y = `${s}.${Ne}`, d = o ? r : e.name.trim(), m = ((E = e.description) == null ? void 0 : E.trim()) || void 0, b = e.entities.map((k) => ({ ...k, name: P(k.name) })), C = e.views !== !1, j = e.permissions !== !1, T = [.../* @__PURE__ */ new Set(["en", "pl", ...e.locales ?? []])], I = e.icon ?? "widgets", c = [], v = [
1010
+ ), r = s.slice(W.length), l = r.toLowerCase(), h = `${s}.${Ne}`, d = a ? r : e.name.trim(), p = ((v = e.description) == null ? void 0 : v.trim()) || void 0, k = e.entities.map((j) => ({ ...j, name: P(j.name) })), A = e.views !== !1, S = e.permissions !== !1, T = [.../* @__PURE__ */ new Set(["en", "pl", ...e.locales ?? []])], I = e.icon ?? "widgets", b = [], D = [
996
1011
  `${l}.entities.json`,
997
- ...C ? [`${l}.views.json`] : [],
998
- ...j ? [`${l}.permissions.json`] : []
1012
+ ...A ? [`${l}.views.json`] : [],
1013
+ ...S ? [`${l}.permissions.json`] : []
999
1014
  ];
1000
- c.push({
1015
+ b.push({
1001
1016
  path: `${l}.manifest.json`,
1002
- text: Y({
1017
+ text: X({
1003
1018
  packageName: s,
1004
1019
  version: "1.0.0",
1005
1020
  displayName: d,
1006
- description: m ?? d,
1021
+ description: p ?? d,
1007
1022
  author: "OmniVerk Module Builder",
1008
1023
  license: "Proprietary",
1009
- category: ((A = e.category) == null ? void 0 : A.trim()) || "Custom",
1024
+ category: ((f = e.category) == null ? void 0 : f.trim()) || "Custom",
1010
1025
  icon: I,
1011
- exportedAt: Tt((i.now ?? (() => /* @__PURE__ */ new Date()))()),
1026
+ exportedAt: It((i.now ?? (() => /* @__PURE__ */ new Date()))()),
1012
1027
  modules: [
1013
1028
  {
1014
1029
  name: Ne,
1015
1030
  displayName: d,
1016
1031
  description: e.description ?? d,
1017
1032
  icon: I,
1018
- parts: v
1033
+ parts: D
1019
1034
  }
1020
1035
  ],
1021
1036
  dependencies: ["Core.Users"],
1022
- i18n: T.map((k) => `${l}.${k}.i18n.json`),
1037
+ i18n: T.map((j) => `${l}.${j}.i18n.json`),
1023
1038
  ...e.ownerTenantId ? { ownerTenantId: e.ownerTenantId } : {},
1024
1039
  ...e.sourceDefinitionId ? { sourceDefinitionId: e.sourceDefinitionId } : {}
1025
1040
  })
1026
1041
  });
1027
- const f = [];
1028
- for (const k of b) {
1029
- const S = [{ name: "Id", displayName: "ID", dataType: "Guid", isPrimaryKey: !0 }];
1030
- for (const $ of k.fields.filter((O) => !ne(O))) {
1031
- const O = se($), a = {
1032
- name: P($.name),
1033
- displayName: q($),
1034
- dataType: O
1042
+ const u = [];
1043
+ for (const j of k) {
1044
+ const O = [{ name: "Id", displayName: "ID", dataType: "Guid", isPrimaryKey: !0 }];
1045
+ for (const w of j.fields.filter((E) => !ne(E))) {
1046
+ const E = se(w), o = {
1047
+ name: P(w.name),
1048
+ displayName: q(w),
1049
+ dataType: E
1035
1050
  };
1036
- O === "string" && (a.maxLength = $.maxLength && $.maxLength > 0 ? $.maxLength : 200), $.isRequired && (a.isRequired = !0), $.isUnique && (a.isUnique = !0), ($.isIndexed || $.isForeignKey) && (a.isIndexed = !0), $.isForeignKey && (a.isForeignKey = !0, $.referencedEntity && (a.referencedEntity = P($.referencedEntity))), (x = $.defaultValue) != null && x.trim() && (a.defaultValue = $.defaultValue), (D = $.description) != null && D.trim() && (a.description = $.description), S.push(a);
1051
+ E === "string" && (o.maxLength = w.maxLength && w.maxLength > 0 ? w.maxLength : 200), w.isRequired && (o.isRequired = !0), w.isUnique && (o.isUnique = !0), (w.isIndexed || w.isForeignKey) && (o.isIndexed = !0), w.isForeignKey && (o.isForeignKey = !0, w.referencedEntity && (o.referencedEntity = P(w.referencedEntity))), (N = w.defaultValue) != null && N.trim() && (o.defaultValue = w.defaultValue), (C = w.description) != null && C.trim() && (o.description = w.description), O.push(o);
1037
1052
  }
1038
- f.push({
1039
- id: await qe(s, k.name),
1040
- name: k.name,
1041
- displayName: q(k),
1042
- tableName: await Ve(l, k.name),
1043
- description: k.description ?? q(k),
1044
- entityIcon: k.icon ?? "table_rows",
1053
+ u.push({
1054
+ id: await Ve(s, j.name),
1055
+ name: j.name,
1056
+ displayName: q(j),
1057
+ tableName: await Ue(l, j.name),
1058
+ description: j.description ?? q(j),
1059
+ entityIcon: j.icon ?? "table_rows",
1045
1060
  isAudited: !0,
1046
1061
  isSoftDeleteEnabled: !1,
1047
- fields: S
1062
+ fields: O
1048
1063
  });
1049
1064
  }
1050
- if (c.push({
1065
+ if (b.push({
1051
1066
  path: `${l}.entities.json`,
1052
- text: Y({ moduleName: y, version: "1.0.0", entities: f })
1053
- }), C) {
1054
- const k = ($) => {
1055
- const O = b.find((p) => p.name === P($)), a = O == null ? void 0 : O.fields.find(
1056
- (p) => !ne(p) && !p.isForeignKey && se(p) === "string"
1067
+ text: X({ moduleName: h, version: "1.0.0", entities: u })
1068
+ }), A) {
1069
+ const j = (w) => {
1070
+ const E = k.find((c) => c.name === P(w)), o = E == null ? void 0 : E.fields.find(
1071
+ (c) => !ne(c) && !c.isForeignKey && se(c) === "string"
1057
1072
  );
1058
- return a ? P(a.name) : "Name";
1059
- }, S = [];
1060
- for (const $ of b) {
1061
- const O = $.fields.filter((u) => !ne(u)), a = O.filter((u) => !["text", "json"].includes(se(u))).slice(0, 6), p = (a.length ? a : [O[0]]).map((u) => ({
1062
- field: P(u.name),
1063
- displayName: q(u),
1073
+ return o ? P(o.name) : "Name";
1074
+ }, O = [];
1075
+ for (const w of k) {
1076
+ const E = w.fields.filter((m) => !ne(m)), o = E.filter((m) => !["text", "json"].includes(se(m))).slice(0, 6), c = (o.length ? o : [E[0]]).map((m) => ({
1077
+ field: P(m.name),
1078
+ displayName: q(m),
1064
1079
  sortable: !0,
1065
- type: pe(u)[0],
1066
- ...u.isForeignKey && u.referencedEntity ? { referencedEntity: P(u.referencedEntity) } : {}
1067
- })), g = O.filter((u) => ["string", "text"].includes(se(u))).map((u) => P(u.name)), h = O.map((u) => ({
1068
- field: P(u.name),
1069
- type: Nt[pe(u)[1]] ?? "TextInput",
1070
- label: q(u),
1071
- ...u.isRequired ? { required: !0 } : {},
1072
- ...u.isForeignKey && u.referencedEntity ? {
1073
- entity: P(u.referencedEntity),
1074
- displayField: k(u.referencedEntity)
1080
+ type: pe(m)[0],
1081
+ ...m.isForeignKey && m.referencedEntity ? { referencedEntity: P(m.referencedEntity) } : {}
1082
+ })), y = E.filter((m) => ["string", "text"].includes(se(m))).map((m) => P(m.name)), g = E.map((m) => ({
1083
+ field: P(m.name),
1084
+ type: Et[pe(m)[1]] ?? "TextInput",
1085
+ label: q(m),
1086
+ ...m.isRequired ? { required: !0 } : {},
1087
+ ...m.isForeignKey && m.referencedEntity ? {
1088
+ entity: P(m.referencedEntity),
1089
+ displayField: j(m.referencedEntity)
1075
1090
  } : {}
1076
1091
  }));
1077
- S.push({
1078
- id: `vw-${l}-${he($.name)}-list`,
1079
- name: `${$.name}List`,
1080
- displayName: q($),
1092
+ O.push({
1093
+ id: `vw-${l}-${he(w.name)}-list`,
1094
+ name: `${w.name}List`,
1095
+ displayName: q(w),
1081
1096
  type: "List",
1082
1097
  icon: "list",
1083
- entityName: $.name,
1084
- columns: p,
1085
- searchFields: g,
1098
+ entityName: w.name,
1099
+ columns: c,
1100
+ searchFields: y,
1086
1101
  pageSize: 25,
1087
- createControls: h,
1102
+ createControls: g,
1088
1103
  allowEdit: !0,
1089
1104
  allowDelete: !0
1090
1105
  });
1091
- const N = O.map((u) => {
1092
- const w = pe(u)[1];
1106
+ const x = E.map((m) => {
1107
+ const $ = pe(m)[1];
1093
1108
  return {
1094
- field: P(u.name),
1095
- type: w,
1096
- label: q(u),
1097
- colSpan: w === "textarea" ? 12 : 6,
1098
- ...u.isRequired ? { required: !0 } : {},
1099
- ...u.isForeignKey && u.referencedEntity ? { entity: P(u.referencedEntity) } : {}
1109
+ field: P(m.name),
1110
+ type: $,
1111
+ label: q(m),
1112
+ colSpan: $ === "textarea" ? 12 : 6,
1113
+ ...m.isRequired ? { required: !0 } : {},
1114
+ ...m.isForeignKey && m.referencedEntity ? { entity: P(m.referencedEntity) } : {}
1100
1115
  };
1101
1116
  });
1102
- S.push({
1103
- id: `vw-${l}-${he($.name)}-form`,
1104
- name: `${$.name}Form`,
1105
- displayName: q($),
1117
+ O.push({
1118
+ id: `vw-${l}-${he(w.name)}-form`,
1119
+ name: `${w.name}Form`,
1120
+ displayName: q(w),
1106
1121
  type: "Form",
1107
1122
  icon: "edit",
1108
- entityName: $.name,
1123
+ entityName: w.name,
1109
1124
  tabs: [
1110
1125
  {
1111
1126
  name: "Main",
1112
- displayName: q($),
1113
- sections: [{ name: "Details", displayName: "Details", controls: N }]
1127
+ displayName: q(w),
1128
+ sections: [{ name: "Details", displayName: "Details", controls: x }]
1114
1129
  }
1115
1130
  ]
1116
1131
  });
1117
1132
  }
1118
- c.push({
1133
+ b.push({
1119
1134
  path: `${l}.views.json`,
1120
- text: Y({ moduleName: y, version: "1.0.0", views: S })
1135
+ text: X({ moduleName: h, version: "1.0.0", views: O })
1121
1136
  });
1122
1137
  }
1123
- if (j) {
1124
- const k = (O) => `${r}.${O}`, S = (O, a) => ({
1125
- code: k(O),
1126
- name: `${d} — ${a}`,
1127
- description: `${a}: ${d}`
1128
- }), $ = (O, a, ...p) => ({
1129
- name: `${W}${r} ${O}`,
1130
- description: `${d} — ${a}`,
1131
- permissions: p.map(k)
1138
+ if (S) {
1139
+ const j = (E) => `${r}.${E}`, O = (E, o) => ({
1140
+ code: j(E),
1141
+ name: `${d} — ${o}`,
1142
+ description: `${o}: ${d}`
1143
+ }), w = (E, o, ...c) => ({
1144
+ name: `${W}${r} ${E}`,
1145
+ description: `${d} — ${o}`,
1146
+ permissions: c.map(j)
1132
1147
  });
1133
- c.push({
1148
+ b.push({
1134
1149
  path: `${l}.permissions.json`,
1135
- text: Y({
1136
- moduleName: y,
1150
+ text: X({
1151
+ moduleName: h,
1137
1152
  version: "1.0.0",
1138
1153
  permissions: [
1139
- S("Read", "view records"),
1140
- S("Create", "add records"),
1141
- S("Edit", "edit records"),
1142
- S("Delete", "delete records"),
1143
- S("Admin", "administer the module")
1154
+ O("Read", "view records"),
1155
+ O("Create", "add records"),
1156
+ O("Edit", "edit records"),
1157
+ O("Delete", "delete records"),
1158
+ O("Admin", "administer the module")
1144
1159
  ],
1145
1160
  permissionGroups: [
1146
- $("Viewer", "read only", "Read"),
1147
- $("Editor", "read and edit", "Read", "Create", "Edit"),
1148
- $("Admin", "full access", "Read", "Create", "Edit", "Delete", "Admin")
1161
+ w("Viewer", "read only", "Read"),
1162
+ w("Editor", "read and edit", "Read", "Create", "Edit"),
1163
+ w("Admin", "full access", "Read", "Create", "Edit", "Delete", "Admin")
1149
1164
  ]
1150
1165
  })
1151
1166
  });
1152
1167
  }
1153
- for (const k of T) {
1154
- const S = {
1168
+ for (const j of T) {
1169
+ const O = {
1155
1170
  "module.displayName": d,
1156
- "module.description": m ?? d
1171
+ "module.description": p ?? d
1157
1172
  };
1158
- for (const $ of b) {
1159
- S[`entity.${$.name}.displayName`] = q($);
1160
- for (const O of $.fields.filter((a) => !ne(a)))
1161
- S[`field.${$.name}.${P(O.name)}.displayName`] = q(O);
1162
- C && (S[`view.${$.name}List.displayName`] = q($), S[`view.${$.name}Form.displayName`] = q($), S[`view.${$.name}Form.tab.Main`] = q($), S[`view.${$.name}Form.section.Details`] = k === "pl" ? "Szczegóły" : "Details");
1173
+ for (const w of k) {
1174
+ O[`entity.${w.name}.displayName`] = q(w);
1175
+ for (const E of w.fields.filter((o) => !ne(o)))
1176
+ O[`field.${w.name}.${P(E.name)}.displayName`] = q(E);
1177
+ A && (O[`view.${w.name}List.displayName`] = q(w), O[`view.${w.name}Form.displayName`] = q(w), O[`view.${w.name}Form.tab.Main`] = q(w), O[`view.${w.name}Form.section.Details`] = j === "pl" ? "Szczegóły" : "Details");
1163
1178
  }
1164
- c.push({
1165
- path: `${l}.${k}.i18n.json`,
1166
- text: Y({ moduleName: s, locale: k, version: "1.0.0", translations: S })
1179
+ b.push({
1180
+ path: `${l}.${j}.i18n.json`,
1181
+ text: X({ moduleName: s, locale: j, version: "1.0.0", translations: O })
1167
1182
  });
1168
1183
  }
1169
- return e.iconConfig !== !1 && c.push({ path: `${l}.iconconfig.json`, text: Y(Et(e.icon)) }), { package: { packageName: s, folder: `Custom/${r}`, files: c }, problems: [] };
1184
+ return e.iconConfig !== !1 && b.push({ path: `${l}.iconconfig.json`, text: X(Ct(e.icon)) }), { package: { packageName: s, folder: `Custom/${r}`, files: b }, problems: [] };
1170
1185
  }
1171
- function It(e) {
1186
+ function At(e) {
1172
1187
  const i = (t) => typeof t == "string" && t ? t : void 0;
1173
1188
  return {
1174
1189
  name: e.name,
@@ -1183,103 +1198,103 @@ function It(e) {
1183
1198
  displayName: i(t.displayName),
1184
1199
  description: i(t.description),
1185
1200
  icon: i(t.entityIcon) ?? i(t.icon),
1186
- fields: (Array.isArray(t.fields) ? t.fields : []).map((o) => ({
1187
- name: String(o.name ?? ""),
1188
- displayName: i(o.displayName),
1189
- dataType: i(o.dataType) ?? i(o.type),
1190
- isRequired: o.isRequired === !0 || o.required === !0,
1191
- maxLength: typeof o.maxLength == "number" ? o.maxLength : void 0,
1192
- isUnique: o.isUnique === !0,
1193
- isIndexed: o.isIndexed === !0,
1194
- isForeignKey: o.isForeignKey === !0,
1195
- referencedEntity: i(o.referencedEntity),
1196
- defaultValue: o.defaultValue === void 0 || o.defaultValue === null ? void 0 : String(o.defaultValue),
1197
- description: i(o.description)
1201
+ fields: (Array.isArray(t.fields) ? t.fields : []).map((a) => ({
1202
+ name: String(a.name ?? ""),
1203
+ displayName: i(a.displayName),
1204
+ dataType: i(a.dataType) ?? i(a.type),
1205
+ isRequired: a.isRequired === !0 || a.required === !0,
1206
+ maxLength: typeof a.maxLength == "number" ? a.maxLength : void 0,
1207
+ isUnique: a.isUnique === !0,
1208
+ isIndexed: a.isIndexed === !0,
1209
+ isForeignKey: a.isForeignKey === !0,
1210
+ referencedEntity: i(a.referencedEntity),
1211
+ defaultValue: a.defaultValue === void 0 || a.defaultValue === null ? void 0 : String(a.defaultValue),
1212
+ description: i(a.description)
1198
1213
  }))
1199
1214
  }))
1200
1215
  };
1201
1216
  }
1202
- const H = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
1217
+ const Z = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
1203
1218
  function we(e, i) {
1204
- 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;
1219
+ return typeof e == "string" ? i(e) : Array.isArray(e) ? e.map((t) => we(t, i)) : Z(e) ? Object.fromEntries(Object.entries(e).map(([t, a]) => [t, we(a, i)])) : e;
1205
1220
  }
1206
- const Ct = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1207
- async function Ot(e, i) {
1221
+ const Lt = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1222
+ async function Kt(e, i) {
1208
1223
  const t = e.find(
1209
- (c) => !c.path.includes("/") && c.path.toLowerCase().endsWith(".manifest.json")
1224
+ (b) => !b.path.includes("/") && b.path.toLowerCase().endsWith(".manifest.json")
1210
1225
  );
1211
1226
  if (!t)
1212
1227
  throw new Error("The module has no manifest.");
1213
- const o = _(t.text).value, n = String(o.packageName ?? ""), s = t.path.slice(0, -14), r = i.id, l = kt(r), y = (c) => c.startsWith(W) ? c.slice(W.length) : c.split(".").pop() ?? c, d = y(n), m = y(r), b = (c) => c.startsWith(`${s}.`) ? `${l}${c.slice(s.length)}` : c, C = new Map(e.map((c) => [c.path, b(c.path)])), j = /* @__PURE__ */ new Map();
1214
- for (const c of e.filter((v) => v.path.toLowerCase().endsWith(".permissions.json")))
1228
+ const a = _(t.text).value, n = String(a.packageName ?? ""), s = t.path.slice(0, -14), r = i.id, l = jt(r), h = (b) => b.startsWith(W) ? b.slice(W.length) : b.split(".").pop() ?? b, d = h(n), p = h(r), k = (b) => b.startsWith(`${s}.`) ? `${l}${b.slice(s.length)}` : b, A = new Map(e.map((b) => [b.path, k(b.path)])), S = /* @__PURE__ */ new Map();
1229
+ for (const b of e.filter((D) => D.path.toLowerCase().endsWith(".permissions.json")))
1215
1230
  try {
1216
- const v = _(c.text).value;
1217
- for (const f of H(v) && Array.isArray(v.permissions) ? v.permissions : []) {
1218
- const E = typeof f.code == "string" ? f.code : "";
1219
- E.startsWith(`${d}.`) && j.set(E, `${m}${E.slice(d.length)}`);
1231
+ const D = _(b.text).value;
1232
+ for (const u of Z(D) && Array.isArray(D.permissions) ? D.permissions : []) {
1233
+ const v = typeof u.code == "string" ? u.code : "";
1234
+ v.startsWith(`${d}.`) && S.set(v, `${p}${v.slice(d.length)}`);
1220
1235
  }
1221
1236
  } catch {
1222
1237
  }
1223
- const T = (c) => n && (c === n || c.startsWith(`${n}.`) || c.startsWith(`${n} `)) ? r + c.slice(n.length) : j.get(c) ?? C.get(c) ?? c, I = [];
1224
- for (const c of e) {
1225
- if (c.path.startsWith(".revisions/"))
1238
+ const T = (b) => n && (b === n || b.startsWith(`${n}.`) || b.startsWith(`${n} `)) ? r + b.slice(n.length) : S.get(b) ?? A.get(b) ?? b, I = [];
1239
+ for (const b of e) {
1240
+ if (b.path.startsWith(".revisions/"))
1226
1241
  continue;
1227
- const v = b(c.path);
1228
- if (!c.path.toLowerCase().endsWith(".json")) {
1229
- I.push({ path: v, text: c.text });
1242
+ const D = k(b.path);
1243
+ if (!b.path.toLowerCase().endsWith(".json")) {
1244
+ I.push({ path: D, text: b.text });
1230
1245
  continue;
1231
1246
  }
1232
- let f;
1247
+ let u;
1233
1248
  try {
1234
- f = _(c.text).value;
1249
+ u = _(b.text).value;
1235
1250
  } catch {
1236
- I.push({ path: v, text: c.text });
1251
+ I.push({ path: D, text: b.text });
1237
1252
  continue;
1238
1253
  }
1239
- let E = we(f, T);
1240
- if (c === t && H(E)) {
1241
- const { sourceDefinitionId: A, ...x } = E;
1242
- E = {
1243
- ...x,
1254
+ let v = we(u, T);
1255
+ if (b === t && Z(v)) {
1256
+ const { sourceDefinitionId: f, ...N } = v;
1257
+ v = {
1258
+ ...N,
1244
1259
  packageName: r,
1245
1260
  ...i.name ? { displayName: i.name } : {},
1246
1261
  ...i.packageId ? { category: i.packageId } : {}
1247
1262
  };
1248
1263
  }
1249
- if (c.path.toLowerCase().endsWith(".entities.json") && H(E) && Array.isArray(E.entities)) {
1250
- const A = [];
1251
- for (const x of E.entities) {
1252
- if (!H(x) || typeof x.name != "string") {
1253
- A.push(x);
1264
+ if (b.path.toLowerCase().endsWith(".entities.json") && Z(v) && Array.isArray(v.entities)) {
1265
+ const f = [];
1266
+ for (const N of v.entities) {
1267
+ if (!Z(N) || typeof N.name != "string") {
1268
+ f.push(N);
1254
1269
  continue;
1255
1270
  }
1256
- A.push({
1257
- ...x,
1258
- ...typeof x.id == "string" && Ct.test(x.id) ? { id: await qe(r, x.name) } : {},
1259
- ...typeof x.tableName == "string" ? { tableName: await Ve(l, x.name) } : {}
1271
+ f.push({
1272
+ ...N,
1273
+ ...typeof N.id == "string" && Lt.test(N.id) ? { id: await Ve(r, N.name) } : {},
1274
+ ...typeof N.tableName == "string" ? { tableName: await Ue(l, N.name) } : {}
1260
1275
  });
1261
1276
  }
1262
- E = { ...E, entities: A };
1277
+ v = { ...v, entities: f };
1263
1278
  }
1264
- i.name && /\.en\.i18n\.json$/i.test(c.path) && H(E) && H(E.translations) && typeof E.translations["module.displayName"] == "string" && (E = {
1265
- ...E,
1266
- translations: { ...E.translations, "module.displayName": i.name }
1267
- }), I.push({ path: v, text: Me(c.text, E) });
1279
+ i.name && /\.en\.i18n\.json$/i.test(b.path) && Z(v) && Z(v.translations) && typeof v.translations["module.displayName"] == "string" && (v = {
1280
+ ...v,
1281
+ translations: { ...v.translations, "module.displayName": i.name }
1282
+ }), I.push({ path: D, text: De(b.text, v) });
1268
1283
  }
1269
1284
  return {
1270
1285
  id: r,
1271
- packageId: i.packageId ?? o.category,
1286
+ packageId: i.packageId ?? a.category,
1272
1287
  files: I
1273
1288
  };
1274
1289
  }
1275
- const K = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Q = (e, i) => K(e) && Array.isArray(e[i]) ? e[i] : [], oe = (e, i) => e.toLowerCase().endsWith(i), ve = (e) => !e.includes("/"), At = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/, Lt = [
1290
+ const M = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ee = (e, i) => M(e) && Array.isArray(e[i]) ? e[i] : [], oe = (e, i) => e.toLowerCase().endsWith(i), ve = (e) => !e.includes("/"), Dt = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/, Mt = [
1276
1291
  "ING Bank Śląski",
1277
1292
  "Bank Śląski",
1278
1293
  "BOŚ",
1279
1294
  "e-Zamówienia",
1280
1295
  "eZamówienia",
1281
1296
  "Plataforma de Contratación del Sector Público"
1282
- ], ae = (e) => At.test(Lt.reduce((i, t) => i.split(t).join(""), e)), Mt = /* @__PURE__ */ new Set([
1297
+ ], re = (e) => Dt.test(Mt.reduce((i, t) => i.split(t).join(""), e)), Ft = /* @__PURE__ */ new Set([
1283
1298
  "module",
1284
1299
  "entity",
1285
1300
  "field",
@@ -1288,8 +1303,8 @@ const K = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Q = (e
1288
1303
  "nav",
1289
1304
  "action",
1290
1305
  "tutorial"
1291
- ]), Dt = /* @__PURE__ */ new Set(["int", "int32", "int64", "long", "integer"]);
1292
- function Kt(e) {
1306
+ ]), Pt = /* @__PURE__ */ new Set(["int", "int32", "int64", "long", "integer"]);
1307
+ function Rt(e) {
1293
1308
  for (let i = 0; i < e.length; i++) {
1294
1309
  const t = e.charCodeAt(i);
1295
1310
  if (t >= 55296 && t <= 56319 || t >= 9728 && t <= 10175)
@@ -1298,12 +1313,12 @@ function Kt(e) {
1298
1313
  return !1;
1299
1314
  }
1300
1315
  function Te(e) {
1301
- if (!K(e))
1316
+ if (!M(e))
1302
1317
  return [];
1303
- const i = K(e.translations) ? e.translations : K(e.keys) ? e.keys : void 0;
1318
+ const i = M(e.translations) ? e.translations : M(e.keys) ? e.keys : void 0;
1304
1319
  return i ? Object.entries(i) : [];
1305
1320
  }
1306
- const Ee = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Ft = /* @__PURE__ */ new Set([
1321
+ const Ee = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, qt = /* @__PURE__ */ new Set([
1307
1322
  "hotel.views.json",
1308
1323
  "restaurant.views.json",
1309
1324
  "backup-dr.views.json",
@@ -1312,284 +1327,285 @@ const Ee = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Ft = /* @__PU
1312
1327
  "shelf_management.views.json",
1313
1328
  "psa.views.json"
1314
1329
  ]);
1315
- function Pt(e, i = {}) {
1330
+ function Vt(e, i = {}) {
1331
+ var D;
1316
1332
  const t = new Set(
1317
- [...i.legacyListViewFiles ?? Ft].map(
1318
- (c) => c.toLowerCase()
1333
+ [...i.legacyListViewFiles ?? qt].map(
1334
+ (u) => u.toLowerCase()
1319
1335
  )
1320
- ), o = [], n = (c) => {
1321
- o.push({ severity: "error", ...c });
1336
+ ), a = [], n = (u) => {
1337
+ a.push({ severity: "error", ...u });
1322
1338
  }, s = [];
1323
- for (const c of e.files)
1324
- if (!(!oe(c.path, ".json") || c.path.startsWith(".revisions/")))
1339
+ for (const u of e.files)
1340
+ if (!(!oe(u.path, ".json") || u.path.startsWith(".revisions/")))
1325
1341
  try {
1326
- s.push({ file: c, value: _(c.text).value });
1342
+ s.push({ file: u, value: _(u.text).value });
1327
1343
  } catch (v) {
1328
1344
  n({
1329
1345
  code: "json.invalid",
1330
- message: `${c.path} is not valid JSON: ${v instanceof Error ? v.message : String(v)}`,
1346
+ message: `${u.path} is not valid JSON: ${v instanceof Error ? v.message : String(v)}`,
1331
1347
  messageKey: "devStudio.issue.jsonInvalid",
1332
- params: { path: c.path, error: v instanceof Error ? v.message : String(v) },
1333
- path: c.path
1348
+ params: { path: u.path, error: v instanceof Error ? v.message : String(v) },
1349
+ path: u.path
1334
1350
  });
1335
1351
  }
1336
- const r = (c) => s.filter((v) => ve(v.file.path) && oe(v.file.path, c)), l = r(".manifest.json");
1352
+ const r = (u) => s.filter((v) => ve(v.file.path) && oe(v.file.path, u)), l = r(".manifest.json");
1337
1353
  l.length === 0 && n({
1338
1354
  code: "manifest.missing",
1339
1355
  message: "The module has no *.manifest.json.",
1340
1356
  messageKey: "devStudio.issue.manifestMissing"
1341
1357
  });
1342
- for (const { file: c, value: v } of l)
1358
+ for (const { file: u, value: v } of l)
1343
1359
  for (const f of ["packageName", "version", "category"])
1344
- (!K(v) || !(f in v)) && n({
1360
+ (!M(v) || !(f in v)) && n({
1345
1361
  code: "manifest.required",
1346
1362
  message: `The manifest needs "${f}".`,
1347
1363
  messageKey: "devStudio.issue.manifestRequired",
1348
1364
  params: { field: f },
1349
- path: c.path,
1365
+ path: u.path,
1350
1366
  pointer: `/${f}`
1351
1367
  });
1352
- const y = r(".iconconfig.json");
1353
- y.length === 0 && e.contents !== "manifest" && n({
1368
+ const h = r(".iconconfig.json");
1369
+ h.length === 0 && e.contents !== "manifest" && n({
1354
1370
  severity: "info",
1355
1371
  code: "iconconfig.missing",
1356
1372
  message: "The module has no *.iconconfig.json: its menu shows a default icon (the CI wants one in every Category/Module folder).",
1357
1373
  messageKey: "devStudio.issue.iconconfigMissing"
1358
1374
  });
1359
- for (const { file: c, value: v } of y) {
1360
- const f = K(v) ? v.module : void 0, E = K(f) ? f.icon : void 0, A = [
1361
- ...K(f) ? [] : ["module"],
1362
- ...K(f) && !K(E) ? ["module.icon"] : [],
1363
- ...K(E) && !("name" in E) ? ["module.icon.name"] : [],
1364
- ...K(E) && !("package" in E) ? ["module.icon.package"] : [],
1375
+ for (const { file: u, value: v } of h) {
1376
+ const f = M(v) ? v.module : void 0, N = M(f) ? f.icon : void 0, C = [
1377
+ ...M(f) ? [] : ["module"],
1378
+ ...M(f) && !M(N) ? ["module.icon"] : [],
1379
+ ...M(N) && !("name" in N) ? ["module.icon.name"] : [],
1380
+ ...M(N) && !("package" in N) ? ["module.icon.package"] : [],
1365
1381
  ...["views", "permissions", "workflowStates"].filter(
1366
- (x) => !K(v) || !(x in v)
1382
+ (j) => !M(v) || !(j in v)
1367
1383
  )
1368
1384
  ];
1369
- for (const x of A)
1385
+ for (const j of C)
1370
1386
  n({
1371
1387
  code: "iconconfig.structure",
1372
- message: `The icon config needs "${x}".`,
1388
+ message: `The icon config needs "${j}".`,
1373
1389
  messageKey: "devStudio.issue.iconconfigStructure",
1374
- params: { field: x },
1375
- path: c.path,
1376
- pointer: `/${x.split(".").join("/")}`
1390
+ params: { field: j },
1391
+ path: u.path,
1392
+ pointer: `/${j.split(".").join("/")}`
1377
1393
  });
1378
1394
  }
1379
- const d = [], m = [];
1380
- for (const { file: c, value: v } of r(".entities.json")) {
1381
- if (!K(v) || !("entities" in v))
1395
+ const d = [], p = [];
1396
+ for (const { file: u, value: v } of r(".entities.json")) {
1397
+ if (!M(v) || !("entities" in v))
1382
1398
  continue;
1383
- const f = [], E = v.entities;
1384
- if (!Array.isArray(E) || E.length === 0) {
1399
+ const f = [], N = v.entities;
1400
+ if (!Array.isArray(N) || N.length === 0) {
1385
1401
  n({
1386
1402
  code: "entities.empty",
1387
1403
  message: "The file has no entities.",
1388
1404
  messageKey: "devStudio.issue.entitiesEmpty",
1389
- path: c.path,
1405
+ path: u.path,
1390
1406
  pointer: "/entities"
1391
1407
  });
1392
1408
  continue;
1393
1409
  }
1394
- E.forEach((A, x) => {
1395
- const D = `/entities/${x}`, k = K(A) && typeof A.name == "string" ? A.name : void 0;
1396
- if (k ? d.push(k) : n({
1410
+ N.forEach((C, j) => {
1411
+ const O = `/entities/${j}`, w = M(C) && typeof C.name == "string" ? C.name : void 0;
1412
+ if (w ? d.push(w) : n({
1397
1413
  code: "entities.name",
1398
- message: `Entity #${x + 1} has no name.`,
1414
+ message: `Entity #${j + 1} has no name.`,
1399
1415
  messageKey: "devStudio.issue.entitiesName",
1400
- params: { n: x + 1 },
1401
- path: c.path,
1402
- pointer: D
1403
- }), !K(A) || !Array.isArray(A.fields)) {
1416
+ params: { n: j + 1 },
1417
+ path: u.path,
1418
+ pointer: O
1419
+ }), !M(C) || !Array.isArray(C.fields)) {
1404
1420
  n({
1405
1421
  code: "entities.fields",
1406
- message: `Entity ${k ?? `#${x + 1}`} has no fields array.`,
1422
+ message: `Entity ${w ?? `#${j + 1}`} has no fields array.`,
1407
1423
  messageKey: "devStudio.issue.entitiesFields",
1408
- params: { name: k ?? `#${x + 1}` },
1409
- path: c.path,
1410
- pointer: D
1424
+ params: { name: w ?? `#${j + 1}` },
1425
+ path: u.path,
1426
+ pointer: O
1411
1427
  });
1412
1428
  return;
1413
1429
  }
1414
- K(A) && typeof A.displayName == "string" && ae(A.displayName) && n({
1430
+ M(C) && typeof C.displayName == "string" && re(C.displayName) && n({
1415
1431
  code: "labels.polish",
1416
- message: `Entity ${k}: the display name "${A.displayName}" is Polish — seed labels are English, Polish goes to the .pl bundle.`,
1432
+ message: `Entity ${w}: the display name "${C.displayName}" is Polish — seed labels are English, Polish goes to the .pl bundle.`,
1417
1433
  messageKey: "devStudio.issue.polishEntity",
1418
- params: { name: k ?? "", text: A.displayName },
1419
- path: c.path,
1420
- pointer: `${D}/displayName`
1421
- }), A.fields.forEach((S, $) => {
1422
- if (!K(S))
1434
+ params: { name: w ?? "", text: C.displayName },
1435
+ path: u.path,
1436
+ pointer: `${O}/displayName`
1437
+ }), C.fields.forEach((E, o) => {
1438
+ if (!M(E))
1423
1439
  return;
1424
- const O = typeof S.name == "string" ? S.name : void 0, a = `${D}/fields/${$}`;
1425
- k && O && S.isPrimaryKey !== !0 && m.push(`field.${k}.${O}`);
1426
- const p = typeof S.dataType == "string" ? S.dataType.replace(/\?+$/, "") : void 0;
1427
- p === void 0 && typeof S.type == "string" && f.push({ name: `${k}.${O}`, pointer: `${a}/type` }), p && Dt.has(p.toLowerCase()) && (O === "Id" || S.isForeignKey === !0) && n({
1440
+ const c = typeof E.name == "string" ? E.name : void 0, y = `${O}/fields/${o}`;
1441
+ w && c && E.isPrimaryKey !== !0 && p.push(`field.${w}.${c}`);
1442
+ const g = typeof E.dataType == "string" ? E.dataType.replace(/\?+$/, "") : void 0;
1443
+ g === void 0 && typeof E.type == "string" && f.push({ name: `${w}.${c}`, pointer: `${y}/type` }), g && Pt.has(g.toLowerCase()) && (c === "Id" || E.isForeignKey === !0) && n({
1428
1444
  code: "entities.keyNotGuid",
1429
- message: `${k}.${O} is ${p}: keys must be Guid (every row's Id is a uuid).`,
1445
+ message: `${w}.${c} is ${g}: keys must be Guid (every row's Id is a uuid).`,
1430
1446
  messageKey: "devStudio.issue.keyNotGuid",
1431
- params: { name: `${k}.${O}`, type: p },
1432
- path: c.path,
1433
- pointer: `${a}/dataType`
1434
- }), typeof S.displayName == "string" && ae(S.displayName) && n({
1447
+ params: { name: `${w}.${c}`, type: g },
1448
+ path: u.path,
1449
+ pointer: `${y}/dataType`
1450
+ }), typeof E.displayName == "string" && re(E.displayName) && n({
1435
1451
  code: "labels.polish",
1436
- message: `${k}.${O}: the display name "${S.displayName}" is Polish — seed labels are English.`,
1452
+ message: `${w}.${c}: the display name "${E.displayName}" is Polish — seed labels are English.`,
1437
1453
  messageKey: "devStudio.issue.polishField",
1438
- params: { name: `${k}.${O}`, text: S.displayName },
1439
- path: c.path,
1440
- pointer: `${a}/displayName`
1454
+ params: { name: `${w}.${c}`, text: E.displayName },
1455
+ path: u.path,
1456
+ pointer: `${y}/displayName`
1441
1457
  });
1442
1458
  });
1443
1459
  }), f.length && n({
1444
1460
  severity: "warning",
1445
1461
  code: "entities.typeIgnored",
1446
- message: `${f.length} field(s) give their type as "type", which installing ignores — it reads "dataType": ${f.slice(0, 5).map((A) => A.name).join(", ")}${f.length > 5 ? ", …" : ""}`,
1462
+ message: `${f.length} field(s) give their type as "type", which installing ignores — it reads "dataType": ${f.slice(0, 5).map((C) => C.name).join(", ")}${f.length > 5 ? ", …" : ""}`,
1447
1463
  messageKey: "devStudio.issue.typeIgnored",
1448
1464
  params: {
1449
1465
  count: f.length,
1450
- names: `${f.slice(0, 5).map((A) => A.name).join(", ")}${f.length > 5 ? ", …" : ""}`
1466
+ names: `${f.slice(0, 5).map((C) => C.name).join(", ")}${f.length > 5 ? ", …" : ""}`
1451
1467
  },
1452
- path: c.path,
1468
+ path: u.path,
1453
1469
  pointer: f[0].pointer
1454
1470
  });
1455
1471
  }
1456
- for (const { file: c, value: v } of r(".permissions.json"))
1457
- (!K(v) || !Array.isArray(v.permissions) || v.permissions.length === 0) && n({
1472
+ for (const { file: u, value: v } of r(".permissions.json"))
1473
+ (!M(v) || !Array.isArray(v.permissions) || v.permissions.length === 0) && n({
1458
1474
  code: "permissions.empty",
1459
1475
  message: 'The file needs a non-empty "permissions" array.',
1460
1476
  messageKey: "devStudio.issue.permissionsEmpty",
1461
- path: c.path,
1477
+ path: u.path,
1462
1478
  pointer: "/permissions"
1463
1479
  });
1464
- const b = [];
1465
- for (const { file: c, value: v } of r(".views.json")) {
1466
- if (!K(v) || Object.keys(v).length === 0) {
1480
+ const k = [];
1481
+ for (const { file: u, value: v } of r(".views.json")) {
1482
+ if (!M(v) || Object.keys(v).length === 0) {
1467
1483
  n({
1468
1484
  code: "views.empty",
1469
1485
  message: "A views file is a JSON object with at least one property.",
1470
1486
  messageKey: "devStudio.issue.viewsEmpty",
1471
- path: c.path
1487
+ path: u.path
1472
1488
  });
1473
1489
  continue;
1474
1490
  }
1475
- Q(v, "views").forEach((f, E) => {
1476
- if (!K(f))
1491
+ ee(v, "views").forEach((f, N) => {
1492
+ if (!M(f))
1477
1493
  return;
1478
- const A = `/views/${E}`, x = typeof f.name == "string" ? f.name : "(unnamed)";
1479
- typeof f.name == "string" && b.push(f.name), typeof f.type == "string" && f.type.toLowerCase() === "list" && !t.has(c.path.toLowerCase()) && (typeof f.entityName != "string" || !f.entityName.trim() ? n({
1494
+ const C = `/views/${N}`, j = typeof f.name == "string" ? f.name : "(unnamed)";
1495
+ typeof f.name == "string" && k.push(f.name), typeof f.type == "string" && f.type.toLowerCase() === "list" && !t.has(u.path.toLowerCase()) && (typeof f.entityName != "string" || !f.entityName.trim() ? n({
1480
1496
  code: "views.listEntity",
1481
- message: `List view ${x} needs a top-level "entityName".`,
1497
+ message: `List view ${j} needs a top-level "entityName".`,
1482
1498
  messageKey: "devStudio.issue.listEntity",
1483
- params: { name: x },
1484
- path: c.path,
1485
- pointer: A
1499
+ params: { name: j },
1500
+ path: u.path,
1501
+ pointer: C
1486
1502
  }) : (!Array.isArray(f.columns) || f.columns.length === 0) && n({
1487
1503
  code: "views.listColumns",
1488
- message: `List view ${x} needs non-empty top-level "columns".`,
1504
+ message: `List view ${j} needs non-empty top-level "columns".`,
1489
1505
  messageKey: "devStudio.issue.listColumns",
1490
- params: { name: x },
1491
- path: c.path,
1492
- pointer: A
1506
+ params: { name: j },
1507
+ path: u.path,
1508
+ pointer: C
1493
1509
  }));
1494
- const D = [[f, "displayName", A]];
1495
- Q(f, "columns").forEach((k, S) => {
1496
- for (const $ of ["header", "displayName", "label"])
1497
- D.push([k, $, `${A}/columns/${S}`]);
1498
- }), Q(f, "tabs").forEach((k, S) => {
1499
- D.push([k, "displayName", `${A}/tabs/${S}`]), Q(k, "sections").forEach(($, O) => {
1500
- D.push([$, "displayName", `${A}/tabs/${S}/sections/${O}`]), Q($, "controls").forEach(
1501
- (a, p) => D.push([a, "label", `${A}/tabs/${S}/sections/${O}/controls/${p}`])
1510
+ const O = [[f, "displayName", C]];
1511
+ ee(f, "columns").forEach((w, E) => {
1512
+ for (const o of ["header", "displayName", "label"])
1513
+ O.push([w, o, `${C}/columns/${E}`]);
1514
+ }), ee(f, "tabs").forEach((w, E) => {
1515
+ O.push([w, "displayName", `${C}/tabs/${E}`]), ee(w, "sections").forEach((o, c) => {
1516
+ O.push([o, "displayName", `${C}/tabs/${E}/sections/${c}`]), ee(o, "controls").forEach(
1517
+ (y, g) => O.push([y, "label", `${C}/tabs/${E}/sections/${c}/controls/${g}`])
1502
1518
  );
1503
1519
  });
1504
1520
  });
1505
- for (const [k, S, $] of D) {
1506
- const O = K(k) ? k[S] : void 0;
1507
- typeof O == "string" && ae(O) && n({
1521
+ for (const [w, E, o] of O) {
1522
+ const c = M(w) ? w[E] : void 0;
1523
+ typeof c == "string" && re(c) && n({
1508
1524
  code: "labels.polish",
1509
- message: `View ${x}: "${O}" is Polish — seed labels are English.`,
1525
+ message: `View ${j}: "${c}" is Polish — seed labels are English.`,
1510
1526
  messageKey: "devStudio.issue.polishView",
1511
- params: { name: x, text: O },
1512
- path: c.path,
1513
- pointer: `${$}/${S}`
1527
+ params: { name: j, text: c },
1528
+ path: u.path,
1529
+ pointer: `${o}/${E}`
1514
1530
  });
1515
1531
  }
1516
1532
  });
1517
1533
  }
1518
- const C = s.filter((c) => ve(c.file.path) && Ee.test(c.file.path)), j = /* @__PURE__ */ new Map();
1519
- for (const c of C) {
1520
- const [, v, f] = Ee.exec(c.file.path), E = j.get(v) ?? /* @__PURE__ */ new Map();
1521
- E.set(f.toLowerCase(), c), j.set(v, E);
1534
+ const A = s.filter((u) => ve(u.file.path) && Ee.test(u.file.path)), S = /* @__PURE__ */ new Map();
1535
+ for (const u of A) {
1536
+ const [, v, f] = Ee.exec(u.file.path), N = S.get(v) ?? /* @__PURE__ */ new Map();
1537
+ N.set(f.toLowerCase(), u), S.set(v, N);
1522
1538
  }
1523
1539
  const T = new Set(
1524
- [...j.keys()].map((c) => c.split(".")[0]).filter((c) => !Mt.has(c))
1540
+ [...S.keys()].map((u) => u.split(".")[0]).filter((u) => !Ft.has(u))
1525
1541
  ), I = /* @__PURE__ */ new Set();
1526
- for (const [c, v] of j) {
1527
- const f = v.get("en"), E = v.get("pl"), A = (x) => new Set(Te(x == null ? void 0 : x.value).map(([D]) => D));
1528
- if (f && !E && n({
1542
+ for (const [u, v] of S) {
1543
+ const f = v.get("en"), N = v.get("pl"), C = (j) => new Set(Te(j == null ? void 0 : j.value).map(([O]) => O));
1544
+ if (f && !N && n({
1529
1545
  code: "i18n.polishMissing",
1530
- message: `${c}.en.i18n.json needs a .pl.i18n.json sibling (English and Polish are mandatory).`,
1546
+ message: `${u}.en.i18n.json needs a .pl.i18n.json sibling (English and Polish are mandatory).`,
1531
1547
  messageKey: "devStudio.issue.polishBundleMissing",
1532
- params: { group: c },
1548
+ params: { group: u },
1533
1549
  path: f.file.path
1534
- }), E && !f && n({
1550
+ }), N && !f && n({
1535
1551
  code: "i18n.englishMissing",
1536
- message: `${c}.pl.i18n.json needs an .en.i18n.json baseline.`,
1552
+ message: `${u}.pl.i18n.json needs an .en.i18n.json baseline.`,
1537
1553
  messageKey: "devStudio.issue.englishBundleMissing",
1538
- params: { group: c },
1539
- path: E.file.path
1540
- }), f && E) {
1541
- const x = A(f), D = A(E), k = [...x].filter(($) => !D.has($)), S = [...D].filter(($) => !x.has($));
1542
- k.length && n({
1554
+ params: { group: u },
1555
+ path: N.file.path
1556
+ }), f && N) {
1557
+ const j = C(f), O = C(N), w = [...j].filter((o) => !O.has(o)), E = [...O].filter((o) => !j.has(o));
1558
+ w.length && n({
1543
1559
  code: "i18n.keyMissing",
1544
- message: `${E.file.path} is missing ${k.length} key(s) of English: ${k.slice(0, 10).join(", ")}`,
1560
+ message: `${N.file.path} is missing ${w.length} key(s) of English: ${w.slice(0, 10).join(", ")}`,
1545
1561
  messageKey: "devStudio.issue.keysMissingPl",
1546
1562
  params: {
1547
- path: E.file.path,
1548
- count: k.length,
1549
- keys: k.slice(0, 10).join(", ")
1563
+ path: N.file.path,
1564
+ count: w.length,
1565
+ keys: w.slice(0, 10).join(", ")
1550
1566
  },
1551
- path: E.file.path
1552
- }), S.length && n({
1567
+ path: N.file.path
1568
+ }), E.length && n({
1553
1569
  code: "i18n.keyMissing",
1554
- message: `${f.file.path} is missing ${S.length} key(s) of Polish: ${S.slice(0, 10).join(", ")}`,
1570
+ message: `${f.file.path} is missing ${E.length} key(s) of Polish: ${E.slice(0, 10).join(", ")}`,
1555
1571
  messageKey: "devStudio.issue.keysMissingEn",
1556
1572
  params: {
1557
1573
  path: f.file.path,
1558
- count: S.length,
1559
- keys: S.slice(0, 10).join(", ")
1574
+ count: E.length,
1575
+ keys: E.slice(0, 10).join(", ")
1560
1576
  },
1561
1577
  path: f.file.path
1562
1578
  });
1563
1579
  }
1564
- for (const [x, D] of v) {
1565
- const k = Te(D.value), S = k.filter(([$]) => T.has($.split(".")[0])).map(([$]) => $);
1566
- if (S.length && n({
1580
+ for (const [j, O] of v) {
1581
+ const w = Te(O.value), E = w.filter(([o]) => T.has(o.split(".")[0])).map(([o]) => o);
1582
+ if (E.length && n({
1567
1583
  severity: "warning",
1568
1584
  code: "i18n.fileKey",
1569
- message: `${D.file.path}: nothing reads keys named after the bundle file — use module./entity./field./view. keys (${S.slice(0, 5).join(", ")}).`,
1585
+ message: `${O.file.path}: nothing reads keys named after the bundle file — use module./entity./field./view. keys (${E.slice(0, 5).join(", ")}).`,
1570
1586
  messageKey: "devStudio.issue.fileKey",
1571
- params: { path: D.file.path, keys: S.slice(0, 5).join(", ") },
1572
- path: D.file.path
1573
- }), x === "en")
1574
- for (const [$, O] of k) {
1575
- I.add($);
1576
- const a = $.split(".")[0];
1577
- ["module", "entity", "field", "view"].includes(a) && typeof O == "string" && ae(O) && n({
1587
+ params: { path: O.file.path, keys: E.slice(0, 5).join(", ") },
1588
+ path: O.file.path
1589
+ }), j === "en")
1590
+ for (const [o, c] of w) {
1591
+ I.add(o);
1592
+ const y = o.split(".")[0];
1593
+ ["module", "entity", "field", "view"].includes(y) && typeof c == "string" && re(c) && n({
1578
1594
  code: "i18n.polishInEnglish",
1579
- message: `${D.file.path}: ${$} = "${O}" — the English bundle is the English UI.`,
1595
+ message: `${O.file.path}: ${o} = "${c}" — the English bundle is the English UI.`,
1580
1596
  messageKey: "devStudio.issue.polishInEnglish",
1581
- params: { path: D.file.path, key: $, text: O },
1582
- path: D.file.path
1597
+ params: { path: O.file.path, key: o, text: c },
1598
+ path: O.file.path
1583
1599
  });
1584
1600
  }
1585
1601
  }
1586
1602
  }
1587
- if (l.length && C.length) {
1603
+ if (l.length && A.length) {
1588
1604
  const v = [
1589
1605
  "module.displayName",
1590
1606
  ...d.map((f) => `entity.${f}.displayName`),
1591
- ...m.map((f) => `${f}.displayName`),
1592
- ...b.map((f) => `view.${f}.displayName`)
1607
+ ...p.map((f) => `${f}.displayName`),
1608
+ ...k.map((f) => `view.${f}.displayName`)
1593
1609
  ].filter(
1594
1610
  (f) => !I.has(f) && !(f.startsWith("field.") && I.has(`${f.slice(0, -12)}.label`))
1595
1611
  );
@@ -1600,63 +1616,87 @@ function Pt(e, i = {}) {
1600
1616
  params: { count: v.length, keys: v.slice(0, 10).join(", ") }
1601
1617
  });
1602
1618
  }
1603
- for (const { file: c, value: v } of s)
1604
- ce(
1619
+ for (const { file: u, value: v } of s)
1620
+ de(
1605
1621
  v,
1606
1622
  void 0,
1607
1623
  "",
1608
- (f, E, A) => n({
1624
+ (f, N, C) => n({
1609
1625
  code: "icons.emoji",
1610
- message: `${E} = "${A}": icon fields take an Ntd* name and column headers are words, never emoji.`,
1626
+ message: `${N} = "${C}": icon fields take an Ntd* name and column headers are words, never emoji.`,
1611
1627
  messageKey: "devStudio.issue.iconsEmoji",
1612
- params: { key: E, text: A },
1613
- path: c.path,
1628
+ params: { key: N, text: C },
1629
+ path: u.path,
1614
1630
  pointer: f
1615
1631
  })
1616
1632
  );
1617
- return o;
1633
+ const b = r(".datasources.json");
1634
+ if (b.length && l.length) {
1635
+ const u = /* @__PURE__ */ new Set();
1636
+ for (const { value: f } of b) {
1637
+ const N = Array.isArray(f) ? f : f == null ? void 0 : f.dataSources;
1638
+ for (const C of Array.isArray(N) ? N : []) {
1639
+ const j = (C == null ? void 0 : C.key) ?? (C == null ? void 0 : C.name);
1640
+ typeof j == "string" && u.add(j);
1641
+ }
1642
+ }
1643
+ const v = (D = l[0].value) == null ? void 0 : D.dataSources;
1644
+ (Array.isArray(v) ? v : []).forEach((f, N) => {
1645
+ const C = (f == null ? void 0 : f.key) ?? (f == null ? void 0 : f.name);
1646
+ typeof C == "string" && !u.has(C) && n({
1647
+ severity: "warning",
1648
+ code: "dataSources.undefined",
1649
+ message: `The manifest lists the data source "${C}", which no *.datasources.json defines.`,
1650
+ messageKey: "devStudio.issue.dataSourceUndefined",
1651
+ params: { key: C },
1652
+ path: l[0].file.path,
1653
+ pointer: `/dataSources/${N}`
1654
+ });
1655
+ });
1656
+ }
1657
+ return a;
1618
1658
  }
1619
- function ce(e, i, t, o) {
1659
+ function de(e, i, t, a) {
1620
1660
  if (Array.isArray(e)) {
1621
- e.forEach((n, s) => ce(n, i, `${t}/${s}`, o));
1661
+ e.forEach((n, s) => de(n, i, `${t}/${s}`, a));
1622
1662
  return;
1623
1663
  }
1624
- if (K(e))
1664
+ if (M(e))
1625
1665
  for (const [n, s] of Object.entries(e)) {
1626
1666
  const r = `${t}/${n}`;
1627
- if ((n === "icon" || n === "iconName" || n === "entityIcon" || n === "name" && i === "icon" || i === "cardIcon" || (n === "header" || n === "displayName" && i === "columns")) && typeof s == "string" && Kt(s) && o(r, n, s), n === "optionsJson" && typeof s == "string")
1667
+ if ((n === "icon" || n === "iconName" || n === "entityIcon" || n === "name" && i === "icon" || i === "cardIcon" || (n === "header" || n === "displayName" && i === "columns")) && typeof s == "string" && Rt(s) && a(r, n, s), n === "optionsJson" && typeof s == "string")
1628
1668
  try {
1629
- ce(JSON.parse(s), "optionsJson", r, o);
1669
+ de(JSON.parse(s), "optionsJson", r, a);
1630
1670
  } catch {
1631
1671
  }
1632
- ce(s, n, r, o);
1672
+ de(s, n, r, a);
1633
1673
  }
1634
1674
  }
1635
- function Rt(e, i = {}) {
1636
- const t = [], o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1675
+ function Ut(e, i = {}) {
1676
+ const t = [], a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1637
1677
  for (const r of e)
1638
1678
  for (const l of r.files) {
1639
1679
  if (!ve(l.path) || !oe(l.path, ".json"))
1640
1680
  continue;
1641
- let y;
1681
+ let h;
1642
1682
  try {
1643
- y = _(l.text).value;
1683
+ h = _(l.text).value;
1644
1684
  } catch {
1645
1685
  continue;
1646
1686
  }
1647
- if (oe(l.path, ".manifest.json") && K(y) && typeof y.packageName == "string" && y.packageName) {
1648
- const d = y.packageName.toLowerCase();
1649
- o.set(d, [...o.get(d) ?? [], r.location]);
1687
+ if (oe(l.path, ".manifest.json") && M(h) && typeof h.packageName == "string" && h.packageName) {
1688
+ const d = h.packageName.toLowerCase();
1689
+ a.set(d, [...a.get(d) ?? [], r.location]);
1650
1690
  }
1651
1691
  if (oe(l.path, ".entities.json") && r.group) {
1652
- for (const d of Q(y, "entities"))
1653
- if (K(d) && typeof d.name == "string" && d.name) {
1654
- const m = `${r.group}/${d.name}`.toLowerCase(), b = n.get(m) ?? [];
1655
- b.includes(r.location) || n.set(m, [...b, r.location]);
1692
+ for (const d of ee(h, "entities"))
1693
+ if (M(d) && typeof d.name == "string" && d.name) {
1694
+ const p = `${r.group}/${d.name}`.toLowerCase(), k = n.get(p) ?? [];
1695
+ k.includes(r.location) || n.set(p, [...k, r.location]);
1656
1696
  }
1657
1697
  }
1658
1698
  }
1659
- for (const [r, l] of o)
1699
+ for (const [r, l] of a)
1660
1700
  l.length > 1 && t.push({
1661
1701
  severity: "error",
1662
1702
  code: "workspace.packageName",
@@ -1675,7 +1715,7 @@ function Rt(e, i = {}) {
1675
1715
  });
1676
1716
  return t;
1677
1717
  }
1678
- const ee = (e) => typeof e == "object" && e !== null && !Array.isArray(e), X = (e) => typeof e == "string" && e ? e : void 0, qt = /* @__PURE__ */ new Set([
1718
+ const te = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Q = (e) => typeof e == "string" && e ? e : void 0, Wt = /* @__PURE__ */ new Set([
1679
1719
  "slug",
1680
1720
  "category",
1681
1721
  "subCategory",
@@ -1686,51 +1726,51 @@ const ee = (e) => typeof e == "object" && e !== null && !Array.isArray(e), X = (
1686
1726
  "translations",
1687
1727
  "modules"
1688
1728
  ]);
1689
- function Ue(e) {
1729
+ function We(e) {
1690
1730
  if (Array.isArray(e))
1691
1731
  return e.filter((i) => typeof i == "string");
1692
1732
  if (typeof e == "string")
1693
1733
  return e.split(",").map((i) => i.trim()).filter(Boolean);
1694
1734
  }
1695
- function We(e) {
1735
+ function Ge(e) {
1696
1736
  const i = {};
1697
- for (const [t, o] of Object.entries(ee(e) ? e : {}))
1698
- ee(o) && (i[t] = { ...o, name: String(o.name ?? "") });
1737
+ for (const [t, a] of Object.entries(te(e) ? e : {}))
1738
+ te(a) && (i[t] = { ...a, name: String(a.name ?? "") });
1699
1739
  return i;
1700
1740
  }
1701
- function Vt(e, i) {
1702
- const t = ee(e) ? e : {}, o = Object.fromEntries(Object.entries(t).filter(([n]) => !qt.has(n)));
1741
+ function Gt(e, i) {
1742
+ const t = te(e) ? e : {}, a = Object.fromEntries(Object.entries(t).filter(([n]) => !Wt.has(n)));
1703
1743
  return {
1704
1744
  id: String(t.slug ?? ""),
1705
- category: X(t.category),
1706
- subCategory: X(t.subCategory),
1707
- parentId: X(t.parentSlug),
1708
- icon: X(t.icon),
1745
+ category: Q(t.category),
1746
+ subCategory: Q(t.subCategory),
1747
+ parentId: Q(t.parentSlug),
1748
+ icon: Q(t.icon),
1709
1749
  sortOrder: typeof t.sortOrder == "number" ? t.sortOrder : void 0,
1710
- tags: Ue(t.tags),
1711
- translations: We(t.translations),
1712
- modules: (Array.isArray(t.modules) ? t.modules : []).filter(ee).map((n) => ({
1750
+ tags: We(t.tags),
1751
+ translations: Ge(t.translations),
1752
+ modules: (Array.isArray(t.modules) ? t.modules : []).filter(te).map((n) => ({
1713
1753
  moduleId: String(n.packageName ?? ""),
1714
1754
  required: n.required === !0,
1715
- condition: X(n.condition),
1716
- description: X(n.description)
1755
+ condition: Q(n.condition),
1756
+ description: Q(n.description)
1717
1757
  })),
1718
- ...Object.keys(o).length ? { extra: o } : {},
1758
+ ...Object.keys(a).length ? { extra: a } : {},
1719
1759
  ...i ? { readOnly: i } : {}
1720
1760
  };
1721
1761
  }
1722
1762
  const $e = (e) => Object.fromEntries(Object.entries(e).filter(([, i]) => i !== void 0));
1723
1763
  function xe(e, i) {
1724
1764
  var l;
1725
- 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) => {
1726
- const d = o.find((m) => m.packageName === y.moduleId);
1765
+ const t = te(i) ? i : {}, a = (Array.isArray(t.modules) ? t.modules : []).filter(te), s = JSON.stringify(We(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 = (h) => {
1766
+ const d = a.find((p) => p.packageName === h.moduleId);
1727
1767
  return $e({
1728
1768
  ...d,
1729
- packageName: y.moduleId,
1769
+ packageName: h.moduleId,
1730
1770
  // seed entries spell `required` out, also when it is false
1731
- required: y.required === !0 ? !0 : !d || "required" in d ? !1 : void 0,
1732
- condition: y.condition || void 0,
1733
- description: y.description || void 0
1771
+ required: h.required === !0 ? !0 : !d || "required" in d ? !1 : void 0,
1772
+ condition: h.condition || void 0,
1773
+ description: h.description || void 0
1734
1774
  });
1735
1775
  };
1736
1776
  return $e({
@@ -1748,12 +1788,12 @@ function xe(e, i) {
1748
1788
  });
1749
1789
  }
1750
1790
  function Ie(e, i = "en") {
1751
- const t = We(e.translations);
1791
+ const t = Ge(e.translations);
1752
1792
  Object.keys(t).length === 0 && e.name && (t[i] = {
1753
1793
  name: e.name,
1754
1794
  ...e.description ? { description: e.description } : {}
1755
1795
  });
1756
- const o = $e({
1796
+ const a = $e({
1757
1797
  isActive: e.isActive,
1758
1798
  compliance: e.compliance,
1759
1799
  defaultLanguage: e.defaultLanguage ?? void 0,
@@ -1774,11 +1814,11 @@ function Ie(e, i = "en") {
1774
1814
  condition: n.condition ?? void 0,
1775
1815
  description: n.description ?? void 0
1776
1816
  })),
1777
- extra: o,
1817
+ extra: a,
1778
1818
  readOnly: e.source === "seed" || e.source === "code"
1779
1819
  };
1780
1820
  }
1781
- function Ut(e) {
1821
+ function _t(e) {
1782
1822
  const i = e.extra ?? {};
1783
1823
  return {
1784
1824
  slug: e.id,
@@ -1798,458 +1838,458 @@ function Ut(e) {
1798
1838
  ...typeof i.defaultLanguage == "string" ? { defaultLanguage: i.defaultLanguage } : {}
1799
1839
  };
1800
1840
  }
1801
- const F = (...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"]), ue = (e) => e.startsWith(".") || _t.has(e), Bt = /^wizard-templates-.+\.seed\.json$/i, zt = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z$/;
1841
+ const F = (...e) => e.filter(Boolean).join("/"), Bt = (e) => e.slice(0, Math.max(0, e.lastIndexOf("/"))), zt = (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, Jt = /* @__PURE__ */ new Set(["bin", "obj", "node_modules"]), ue = (e) => e.startsWith(".") || Jt.has(e), Ht = /^wizard-templates-.+\.seed\.json$/i, Zt = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z$/;
1802
1842
  function fe(e) {
1803
- const i = (t, o = 2) => String(t).padStart(o, "0");
1843
+ const i = (t, a = 2) => String(t).padStart(a, "0");
1804
1844
  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`;
1805
1845
  }
1806
- function Jt(e) {
1807
- const i = zt.exec(e);
1846
+ function Yt(e) {
1847
+ const i = Zt.exec(e);
1808
1848
  return i ? Date.UTC(+i[1], +i[2] - 1, +i[3], +i[4], +i[5], +i[6], +i[7]) : void 0;
1809
1849
  }
1810
- const Ht = (e, i) => F(Wt(e), ".revisions", `${Gt(e)}.${i}`), Zt = (e) => e.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "custom";
1811
- function ni(e) {
1812
- const { roots: i } = e, t = e.revisions !== !1, o = e.now ?? (() => /* @__PURE__ */ new Date()), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1850
+ const Xt = (e, i) => F(Bt(e), ".revisions", `${zt(e)}.${i}`), Qt = (e) => e.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "custom";
1851
+ function ai(e) {
1852
+ const { roots: i } = e, t = e.revisions !== !1, a = e.now ?? (() => /* @__PURE__ */ new Date()), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1813
1853
  let r = null;
1814
- const l = (a) => {
1815
- const p = i.find((g) => g.id === a);
1816
- if (!p)
1817
- throw new Error(`Unknown workspace "${a}"`);
1818
- return p;
1819
- }, y = (a) => {
1820
- const p = l(a);
1821
- if (p.readOnly)
1822
- throw new Error(`Workspace "${p.label}" is read-only`);
1823
- return p;
1854
+ const l = (o) => {
1855
+ const c = i.find((y) => y.id === o);
1856
+ if (!c)
1857
+ throw new Error(`Unknown workspace "${o}"`);
1858
+ return c;
1859
+ }, h = (o) => {
1860
+ const c = l(o);
1861
+ if (c.readOnly)
1862
+ throw new Error(`Workspace "${c.label}" is read-only`);
1863
+ return c;
1824
1864
  };
1825
- async function d(a, p) {
1826
- const g = await a.read(p);
1865
+ async function d(o, c) {
1866
+ const y = await o.read(c);
1827
1867
  try {
1828
- const h = g ? _(g.text).value : void 0;
1829
- return me(h) ? h : {};
1868
+ const g = y ? _(y.text).value : void 0;
1869
+ return me(g) ? g : {};
1830
1870
  } catch {
1831
1871
  return {};
1832
1872
  }
1833
1873
  }
1834
- function m(a, p, g, h, N) {
1835
- const u = ie(h.packageName) ?? (p || a.id);
1874
+ function p(o, c, y, g, x) {
1875
+ const m = ie(g.packageName) ?? (c || o.id);
1836
1876
  return {
1837
- workspaceId: a.id,
1838
- id: u,
1839
- packageId: ie(h.category),
1840
- label: ie(h.displayName) ?? u,
1841
- description: ie(h.description),
1842
- version: ie(h.version),
1843
- location: p,
1844
- readOnly: a.readOnly,
1845
- files: N,
1846
- search: `${p} ${g}`
1877
+ workspaceId: o.id,
1878
+ id: m,
1879
+ packageId: ie(g.category),
1880
+ label: ie(g.displayName) ?? m,
1881
+ description: ie(g.description),
1882
+ version: ie(g.version),
1883
+ location: c,
1884
+ readOnly: o.readOnly,
1885
+ files: x,
1886
+ search: `${c} ${y}`
1847
1887
  };
1848
1888
  }
1849
- async function b(a) {
1850
- const p = /* @__PURE__ */ new Map(), g = async (h) => {
1851
- const N = await a.fs.list(h), u = N.filter((w) => w.kind === "file" && w.name.toLowerCase().endsWith(".manifest.json")).map((w) => w.name).sort()[0];
1852
- if (u) {
1853
- const w = N.filter((M) => M.kind === "file").map((M) => M.name), L = m(
1854
- a,
1855
- h,
1856
- u,
1857
- await d(a.fs, F(h, u)),
1858
- w
1889
+ async function k(o) {
1890
+ const c = /* @__PURE__ */ new Map(), y = async (g) => {
1891
+ const x = await o.fs.list(g), m = x.filter(($) => $.kind === "file" && $.name.toLowerCase().endsWith(".manifest.json")).map(($) => $.name).sort()[0];
1892
+ if (m) {
1893
+ const $ = x.filter((K) => K.kind === "file").map((K) => K.name), L = p(
1894
+ o,
1895
+ g,
1896
+ m,
1897
+ await d(o.fs, F(g, m)),
1898
+ $
1859
1899
  );
1860
- p.has(L.id.toLowerCase()) || (p.set(L.id.toLowerCase(), { ref: L, dir: h }), s.set(`${a.id}:${L.id.toLowerCase()}`, h));
1900
+ c.has(L.id.toLowerCase()) || (c.set(L.id.toLowerCase(), { ref: L, dir: g }), s.set(`${o.id}:${L.id.toLowerCase()}`, g));
1861
1901
  }
1862
- for (const w of N)
1863
- w.kind === "directory" && !ue(w.name) && !(h === "" && w.name === C(a)) && await g(F(h, w.name));
1902
+ for (const $ of x)
1903
+ $.kind === "directory" && !ue($.name) && !(g === "" && $.name === A(o)) && await y(F(g, $.name));
1864
1904
  };
1865
- return await g(""), p;
1905
+ return await y(""), c;
1866
1906
  }
1867
- const C = (a) => a.templatesDir === !1 ? void 0 : a.templatesDir ?? "Templates", j = (a) => {
1868
- n.delete(a.id), k.clear();
1869
- }, T = (a) => {
1870
- let p = n.get(a.id);
1871
- return p || (p = b(a), n.set(a.id, p), p.catch(() => n.delete(a.id))), p;
1907
+ const A = (o) => o.templatesDir === !1 ? void 0 : o.templatesDir ?? "Templates", S = (o) => {
1908
+ n.delete(o.id), j.clear();
1909
+ }, T = (o) => {
1910
+ let c = n.get(o.id);
1911
+ return c || (c = k(o), n.set(o.id, c), c.catch(() => n.delete(o.id))), c;
1872
1912
  };
1873
- async function I(a) {
1874
- const p = l(a.workspaceId), g = await T(p), h = s.get(`${p.id}:${a.id.toLowerCase()}`), N = g.get(a.id.toLowerCase()) ?? (h === void 0 ? void 0 : [...g.values()].find((u) => u.dir === h));
1875
- if (!N)
1876
- throw new Error(`Module "${a.id}" is not in "${p.label}"`);
1877
- return { root: p, module: N };
1913
+ async function I(o) {
1914
+ const c = l(o.workspaceId), y = await T(c), g = s.get(`${c.id}:${o.id.toLowerCase()}`), x = y.get(o.id.toLowerCase()) ?? (g === void 0 ? void 0 : [...y.values()].find((m) => m.dir === g));
1915
+ if (!x)
1916
+ throw new Error(`Module "${o.id}" is not in "${c.label}"`);
1917
+ return { root: c, module: x };
1878
1918
  }
1879
- async function c(a, p) {
1880
- const g = [], h = async (N, u) => {
1881
- const w = await a.list(F(p, N));
1882
- if (!(u && w.some((L) => L.kind === "file" && L.name.toLowerCase().endsWith(".manifest.json"))))
1883
- for (const L of w)
1884
- L.kind === "file" ? g.push(F(N, L.name)) : ue(L.name) || await h(F(N, L.name), !0);
1919
+ async function b(o, c) {
1920
+ const y = [], g = async (x, m) => {
1921
+ const $ = await o.list(F(c, x));
1922
+ if (!(m && $.some((L) => L.kind === "file" && L.name.toLowerCase().endsWith(".manifest.json"))))
1923
+ for (const L of $)
1924
+ L.kind === "file" ? y.push(F(x, L.name)) : ue(L.name) || await g(F(x, L.name), !0);
1885
1925
  };
1886
- return await h("", !1), g.sort();
1926
+ return await g("", !1), y.sort();
1887
1927
  }
1888
- async function v(a, p, g, h) {
1889
- t && await a.write(Ht(p, h), g);
1928
+ async function D(o, c, y, g) {
1929
+ t && await o.write(Xt(c, g), y);
1890
1930
  }
1891
- async function f(a, p) {
1892
- const g = [], h = async (N) => {
1893
- const u = await a.list(F(p, N));
1894
- for (const w of u)
1895
- if (w.kind === "directory" && w.name === ".revisions")
1896
- for (const L of await a.list(F(p, N, w.name))) {
1897
- const M = /^(.*)\.(\d{8}T\d{9}Z)$/.exec(L.name);
1898
- L.kind === "file" && M && g.push({
1899
- path: F(N, M[1]),
1900
- stamp: M[2],
1901
- at: F(N, ".revisions", L.name)
1931
+ async function u(o, c) {
1932
+ const y = [], g = async (x) => {
1933
+ const m = await o.list(F(c, x));
1934
+ for (const $ of m)
1935
+ if ($.kind === "directory" && $.name === ".revisions")
1936
+ for (const L of await o.list(F(c, x, $.name))) {
1937
+ const K = /^(.*)\.(\d{8}T\d{9}Z)$/.exec(L.name);
1938
+ L.kind === "file" && K && y.push({
1939
+ path: F(x, K[1]),
1940
+ stamp: K[2],
1941
+ at: F(x, ".revisions", L.name)
1902
1942
  });
1903
1943
  }
1904
- else w.kind === "directory" && !ue(w.name) && await h(F(N, w.name));
1944
+ else $.kind === "directory" && !ue($.name) && await g(F(x, $.name));
1905
1945
  };
1906
- return await h(""), g;
1946
+ return await g(""), y;
1907
1947
  }
1908
- async function E(a) {
1909
- const p = C(a);
1910
- return p ? (await a.fs.list(p)).filter((g) => g.kind === "file" && Bt.test(g.name)).map((g) => F(p, g.name)).sort() : [];
1948
+ async function v(o) {
1949
+ const c = A(o);
1950
+ return c ? (await o.fs.list(c)).filter((y) => y.kind === "file" && Ht.test(y.name)).map((y) => F(c, y.name)).sort() : [];
1911
1951
  }
1912
- async function A(a, p) {
1913
- const g = await a.fs.read(p);
1914
- if (!g)
1952
+ async function f(o, c) {
1953
+ const y = await o.fs.read(c);
1954
+ if (!y)
1915
1955
  return { text: "", entries: [] };
1916
- const h = _(g.text).value;
1917
- return { text: g.text, entries: Array.isArray(h) ? h : [] };
1956
+ const g = _(y.text).value;
1957
+ return { text: y.text, entries: Array.isArray(g) ? g : [] };
1918
1958
  }
1919
- const x = {
1920
- arrayKey: (a) => a === "" ? "slug" : a.endsWith("/modules") ? "packageName" : void 0
1959
+ const N = {
1960
+ arrayKey: (o) => o === "" ? "slug" : o.endsWith("/modules") ? "packageName" : void 0
1921
1961
  };
1922
- async function D(a, p, g, h) {
1923
- if (g && await v(a.fs, p, g, fe(o())), h.length === 0) {
1924
- await a.fs.remove(p);
1962
+ async function C(o, c, y, g) {
1963
+ if (y && await D(o.fs, c, y, fe(a())), g.length === 0) {
1964
+ await o.fs.remove(c);
1925
1965
  return;
1926
1966
  }
1927
- await a.fs.write(
1928
- p,
1929
- g ? Me(g, h, x) : de(h)
1967
+ await o.fs.write(
1968
+ c,
1969
+ y ? De(y, g, N) : ae(g)
1930
1970
  );
1931
1971
  }
1932
- const k = /* @__PURE__ */ new Map();
1933
- function S(a, p) {
1934
- const g = `${a.id}:${p.dir}`;
1935
- let h = k.get(g);
1936
- if (!h) {
1937
- const N = (p.ref.files ?? []).filter((u) => /\.(manifest|entities)\.json$/i.test(u));
1938
- h = Promise.all(
1939
- N.map(async (u) => {
1940
- var w;
1972
+ const j = /* @__PURE__ */ new Map();
1973
+ function O(o, c) {
1974
+ const y = `${o.id}:${c.dir}`;
1975
+ let g = j.get(y);
1976
+ if (!g) {
1977
+ const x = (c.ref.files ?? []).filter((m) => /\.(manifest|entities)\.json$/i.test(m));
1978
+ g = Promise.all(
1979
+ x.map(async (m) => {
1980
+ var $;
1941
1981
  return {
1942
- path: u,
1943
- text: ((w = await a.fs.read(F(p.dir, u))) == null ? void 0 : w.text) ?? ""
1982
+ path: m,
1983
+ text: (($ = await o.fs.read(F(c.dir, m))) == null ? void 0 : $.text) ?? ""
1944
1984
  };
1945
1985
  })
1946
- ).then((u) => ({ location: p.dir, group: p.dir.split("/")[0], files: u })), k.set(g, h);
1986
+ ).then((m) => ({ location: c.dir, group: c.dir.split("/")[0], files: m })), j.set(y, g);
1947
1987
  }
1948
- return h;
1988
+ return g;
1949
1989
  }
1950
- async function $(a) {
1951
- var p;
1952
- return r || await ((p = O.listTemplates) == null ? void 0 : p.call(O)), r == null ? void 0 : r.get(a.toLowerCase());
1990
+ async function w(o) {
1991
+ var c;
1992
+ return r || await ((c = E.listTemplates) == null ? void 0 : c.call(E)), r == null ? void 0 : r.get(o.toLowerCase());
1953
1993
  }
1954
- const O = {
1994
+ const E = {
1955
1995
  invalidate() {
1956
- n.clear(), k.clear(), r = null;
1996
+ n.clear(), j.clear(), r = null;
1957
1997
  },
1958
1998
  async listWorkspaces() {
1959
- return i.map((a) => ({
1960
- id: a.id,
1961
- label: a.label,
1962
- ...a.description ? { description: a.description } : {},
1963
- ...a.icon ? { icon: a.icon } : {},
1964
- ...a.readOnly ? { readOnly: !0 } : {}
1999
+ return i.map((o) => ({
2000
+ id: o.id,
2001
+ label: o.label,
2002
+ ...o.description ? { description: o.description } : {},
2003
+ ...o.icon ? { icon: o.icon } : {},
2004
+ ...o.readOnly ? { readOnly: !0 } : {}
1965
2005
  }));
1966
2006
  },
1967
- async listModules(a) {
1968
- const p = i.findIndex((u) => u.id === a), g = l(a);
1969
- j(g);
1970
- const h = await T(g), N = await Promise.all(
1971
- i.slice(0, p).map(async (u) => ({ r: u, modules: await T(u) }))
2007
+ async listModules(o) {
2008
+ const c = i.findIndex((m) => m.id === o), y = l(o);
2009
+ S(y);
2010
+ const g = await T(y), x = await Promise.all(
2011
+ i.slice(0, c).map(async (m) => ({ r: m, modules: await T(m) }))
1972
2012
  );
1973
- return [...h.values()].map(({ ref: u }) => {
1974
- const w = N.find((L) => L.modules.has(u.id.toLowerCase()));
1975
- return w ? { ...u, shadowedBy: w.r.id } : u;
1976
- }).sort((u, w) => u.id.localeCompare(w.id));
2013
+ return [...g.values()].map(({ ref: m }) => {
2014
+ const $ = x.find((L) => L.modules.has(m.id.toLowerCase()));
2015
+ return $ ? { ...m, shadowedBy: $.r.id } : m;
2016
+ }).sort((m, $) => m.id.localeCompare($.id));
1977
2017
  },
1978
- async readModule(a) {
1979
- const { root: p, module: g } = await I(a), h = await c(p.fs, g.dir), N = [];
1980
- for (const u of h) {
1981
- const w = await p.fs.read(F(g.dir, u));
1982
- w && N.push({
1983
- path: u,
1984
- text: w.text,
1985
- version: w.version,
1986
- ...p.readOnly ? { readOnly: !0 } : {}
2018
+ async readModule(o) {
2019
+ const { root: c, module: y } = await I(o), g = await b(c.fs, y.dir), x = [];
2020
+ for (const m of g) {
2021
+ const $ = await c.fs.read(F(y.dir, m));
2022
+ $ && x.push({
2023
+ path: m,
2024
+ text: $.text,
2025
+ version: $.version,
2026
+ ...c.readOnly ? { readOnly: !0 } : {}
1987
2027
  });
1988
2028
  }
1989
- return N;
2029
+ return x;
1990
2030
  },
1991
- async writeModule(a, p) {
1992
- const { module: g } = await I(a), h = y(a.workspaceId), N = /* @__PURE__ */ new Map(), u = [];
1993
- for (const M of p) {
1994
- if (M.path.split("/").some((Z) => Z === ".." || Z === "" || Z.startsWith(".")))
1995
- throw new Error(`Refusing to write outside the module: ${M.path}`);
1996
- const R = await h.fs.read(F(g.dir, M.path));
1997
- N.set(M.path, R);
1998
- const B = M.baseVersion;
1999
- (B === void 0 ? R !== null && M.type === "write" : (R == null ? void 0 : R.version) !== B) && u.push({ path: M.path, ...R ? { currentVersion: R.version } : {} });
2031
+ async writeModule(o, c) {
2032
+ const { module: y } = await I(o), g = h(o.workspaceId), x = /* @__PURE__ */ new Map(), m = [];
2033
+ for (const K of c) {
2034
+ if (K.path.split("/").some((Y) => Y === ".." || Y === "" || Y.startsWith(".")))
2035
+ throw new Error(`Refusing to write outside the module: ${K.path}`);
2036
+ const R = await g.fs.read(F(y.dir, K.path));
2037
+ x.set(K.path, R);
2038
+ const z = K.baseVersion;
2039
+ (z === void 0 ? R !== null && K.type === "write" : (R == null ? void 0 : R.version) !== z) && m.push({ path: K.path, ...R ? { currentVersion: R.version } : {} });
2000
2040
  }
2001
- if (u.length)
2002
- return { ok: !1, conflicts: u };
2003
- const w = fe(o()), L = {};
2004
- for (const M of p) {
2005
- const R = F(g.dir, M.path), B = N.get(M.path);
2006
- B && await v(h.fs, R, B.text, w), M.type === "write" ? L[M.path] = await h.fs.write(R, M.text) : await h.fs.remove(R);
2041
+ if (m.length)
2042
+ return { ok: !1, conflicts: m };
2043
+ const $ = fe(a()), L = {};
2044
+ for (const K of c) {
2045
+ const R = F(y.dir, K.path), z = x.get(K.path);
2046
+ z && await D(g.fs, R, z.text, $), K.type === "write" ? L[K.path] = await g.fs.write(R, K.text) : await g.fs.remove(R);
2007
2047
  }
2008
- return j(h), { ok: !0, versions: L, revision: w };
2048
+ return S(g), { ok: !0, versions: L, revision: $ };
2009
2049
  },
2010
- async createModule(a) {
2011
- var u;
2012
- const p = y(a.workspaceId), g = a.id.startsWith(W) ? a.id.slice(W.length) : a.id.split(".").pop() ?? a.id, h = ((u = e.moduleFolder) == null ? void 0 : u.call(e, a)) ?? F(
2013
- P(a.packageId ?? "") || "Custom",
2014
- P(g) || "Module"
2050
+ async createModule(o) {
2051
+ var m;
2052
+ const c = h(o.workspaceId), y = o.id.startsWith(W) ? o.id.slice(W.length) : o.id.split(".").pop() ?? o.id, g = ((m = e.moduleFolder) == null ? void 0 : m.call(e, o)) ?? F(
2053
+ P(o.packageId ?? "") || "Custom",
2054
+ P(y) || "Module"
2015
2055
  );
2016
- if ((await p.fs.list(h)).length > 0)
2017
- throw new Error(`The folder ${h} is not empty`);
2018
- if ((await T(p)).has(a.id.toLowerCase()))
2019
- throw new Error(`"${a.id}" already exists in ${p.label}`);
2020
- for (const w of a.files)
2021
- await p.fs.write(F(h, w.path), w.text);
2022
- j(p);
2023
- const N = (await T(p)).get(a.id.toLowerCase());
2024
- if (!N)
2025
- throw new Error(`The new module ${a.id} has no manifest naming it`);
2026
- return N.ref;
2056
+ if ((await c.fs.list(g)).length > 0)
2057
+ throw new Error(`The folder ${g} is not empty`);
2058
+ if ((await T(c)).has(o.id.toLowerCase()))
2059
+ throw new Error(`"${o.id}" already exists in ${c.label}`);
2060
+ for (const $ of o.files)
2061
+ await c.fs.write(F(g, $.path), $.text);
2062
+ S(c);
2063
+ const x = (await T(c)).get(o.id.toLowerCase());
2064
+ if (!x)
2065
+ throw new Error(`The new module ${o.id} has no manifest naming it`);
2066
+ return x.ref;
2027
2067
  },
2028
- async deleteModule(a) {
2029
- const { module: p } = await I(a), g = y(a.workspaceId);
2030
- await g.fs.removeDir(p.dir), s.delete(`${g.id}:${a.id.toLowerCase()}`), j(g);
2068
+ async deleteModule(o) {
2069
+ const { module: c } = await I(o), y = h(o.workspaceId);
2070
+ await y.fs.removeDir(c.dir), s.delete(`${y.id}:${o.id.toLowerCase()}`), S(y);
2031
2071
  },
2032
2072
  async listTemplates() {
2033
- const a = /* @__PURE__ */ new Map(), p = [];
2034
- for (const g of i)
2035
- for (const h of await E(g)) {
2036
- let N;
2073
+ const o = /* @__PURE__ */ new Map(), c = [];
2074
+ for (const y of i)
2075
+ for (const g of await v(y)) {
2076
+ let x;
2037
2077
  try {
2038
- N = (await A(g, h)).entries;
2078
+ x = (await f(y, g)).entries;
2039
2079
  } catch {
2040
2080
  continue;
2041
2081
  }
2042
- for (const u of N) {
2043
- const w = Vt(u, g.readOnly);
2044
- w.id && !a.has(w.id.toLowerCase()) && (a.set(w.id.toLowerCase(), { rootId: g.id, path: h }), p.push(w));
2082
+ for (const m of x) {
2083
+ const $ = Gt(m, y.readOnly);
2084
+ $.id && !o.has($.id.toLowerCase()) && (o.set($.id.toLowerCase(), { rootId: y.id, path: g }), c.push($));
2045
2085
  }
2046
2086
  }
2047
- return r = a, p;
2087
+ return r = o, c;
2048
2088
  },
2049
- async saveTemplate(a, p) {
2050
- const g = (p == null ? void 0 : p.previousId) ?? a.id, h = await $(g);
2051
- if (h) {
2052
- const N = y(h.rootId), { text: u, entries: w } = await A(N, h.path), L = w.findIndex(
2053
- (R) => me(R) && String(R.slug ?? "").toLowerCase() === g.toLowerCase()
2054
- ), M = [...w];
2055
- M[L < 0 ? M.length : L] = xe(
2056
- a,
2057
- L < 0 ? void 0 : w[L]
2058
- ), await D(N, h.path, u, M);
2089
+ async saveTemplate(o, c) {
2090
+ const y = (c == null ? void 0 : c.previousId) ?? o.id, g = await w(y);
2091
+ if (g) {
2092
+ const x = h(g.rootId), { text: m, entries: $ } = await f(x, g.path), L = $.findIndex(
2093
+ (R) => me(R) && String(R.slug ?? "").toLowerCase() === y.toLowerCase()
2094
+ ), K = [...$];
2095
+ K[L < 0 ? K.length : L] = xe(
2096
+ o,
2097
+ L < 0 ? void 0 : $[L]
2098
+ ), await C(x, g.path, m, K);
2059
2099
  } else {
2060
- const N = i.find((M) => !M.readOnly && C(M));
2061
- if (!N)
2100
+ const x = i.find((K) => !K.readOnly && A(K));
2101
+ if (!x)
2062
2102
  throw new Error("No writable folder holds templates");
2063
- const u = F(
2064
- C(N),
2065
- `wizard-templates-${Zt(a.category ?? "custom")}.seed.json`
2066
- ), { text: w, entries: L } = await A(N, u);
2067
- await D(N, u, w, [...L, xe(a)]);
2103
+ const m = F(
2104
+ A(x),
2105
+ `wizard-templates-${Qt(o.category ?? "custom")}.seed.json`
2106
+ ), { text: $, entries: L } = await f(x, m);
2107
+ await C(x, m, $, [...L, xe(o)]);
2068
2108
  }
2069
- return r = null, { ...a, extra: a.extra };
2109
+ return r = null, { ...o, extra: o.extra };
2070
2110
  },
2071
- async deleteTemplate(a) {
2072
- const p = await $(a);
2073
- if (!p)
2111
+ async deleteTemplate(o) {
2112
+ const c = await w(o);
2113
+ if (!c)
2074
2114
  return;
2075
- const g = y(p.rootId), { text: h, entries: N } = await A(g, p.path);
2076
- await D(
2115
+ const y = h(c.rootId), { text: g, entries: x } = await f(y, c.path);
2116
+ await C(
2117
+ y,
2118
+ c.path,
2077
2119
  g,
2078
- p.path,
2079
- h,
2080
- N.filter(
2081
- (u) => !(me(u) && String(u.slug ?? "").toLowerCase() === a.toLowerCase())
2120
+ x.filter(
2121
+ (m) => !(me(m) && String(m.slug ?? "").toLowerCase() === o.toLowerCase())
2082
2122
  )
2083
2123
  ), r = null;
2084
2124
  },
2085
- async validate(a, p) {
2086
- const g = l(a.workspaceId), h = [...(await T(g)).values()], N = await Promise.all(
2087
- h.filter((L) => L.ref.id.toLowerCase() !== a.id.toLowerCase()).map((L) => S(g, L))
2088
- ), u = h.find((L) => L.ref.id.toLowerCase() === a.id.toLowerCase()), w = (u == null ? void 0 : u.dir) ?? a.id;
2089
- return Rt(
2090
- [...N, { location: w, group: w.split("/")[0], files: p }],
2125
+ async validate(o, c) {
2126
+ const y = l(o.workspaceId), g = [...(await T(y)).values()], x = await Promise.all(
2127
+ g.filter((L) => L.ref.id.toLowerCase() !== o.id.toLowerCase()).map((L) => O(y, L))
2128
+ ), m = g.find((L) => L.ref.id.toLowerCase() === o.id.toLowerCase()), $ = (m == null ? void 0 : m.dir) ?? o.id;
2129
+ return Ut(
2130
+ [...x, { location: $, group: $.split("/")[0], files: c }],
2091
2131
  {
2092
2132
  knownDuplicates: e.knownDuplicates
2093
2133
  }
2094
- ).filter((L) => L.message.split(/[ ,]+/).includes(w));
2134
+ ).filter((L) => L.message.split(/[ ,]+/).includes($));
2095
2135
  },
2096
- async listRevisions(a, p) {
2097
- const { root: g, module: h } = await I(a), N = (await f(g.fs, h.dir)).filter(
2098
- (w) => !p || w.path === p
2099
- ), u = /* @__PURE__ */ new Map();
2100
- for (const w of N)
2101
- u.set(w.stamp, [...u.get(w.stamp) ?? [], w.path]);
2102
- return [...u].map(([w, L]) => ({
2103
- id: w,
2104
- timestamp: Jt(w) ?? 0,
2136
+ async listRevisions(o, c) {
2137
+ const { root: y, module: g } = await I(o), x = (await u(y.fs, g.dir)).filter(
2138
+ ($) => !c || $.path === c
2139
+ ), m = /* @__PURE__ */ new Map();
2140
+ for (const $ of x)
2141
+ m.set($.stamp, [...m.get($.stamp) ?? [], $.path]);
2142
+ return [...m].map(([$, L]) => ({
2143
+ id: $,
2144
+ timestamp: Yt($) ?? 0,
2105
2145
  summary: L.sort().join(", "),
2106
- ...p ? { path: p } : {}
2107
- })).sort((w, L) => L.timestamp - w.timestamp);
2146
+ ...c ? { path: c } : {}
2147
+ })).sort(($, L) => L.timestamp - $.timestamp);
2108
2148
  },
2109
- async readRevision(a, p, g) {
2149
+ async readRevision(o, c, y) {
2110
2150
  var L;
2111
- const { root: h, module: N } = await I(a), u = (await f(h.fs, N.dir)).filter(
2112
- (M) => M.stamp === p && (!g || M.path === g)
2151
+ const { root: g, module: x } = await I(o), m = (await u(g.fs, x.dir)).filter(
2152
+ (K) => K.stamp === c && (!y || K.path === y)
2113
2153
  );
2114
- if (u.length === 0)
2115
- throw new Error(`Unknown revision "${p}"`);
2116
- const w = {};
2117
- for (const M of u)
2118
- w[M.path] = ((L = await h.fs.read(F(N.dir, M.at))) == null ? void 0 : L.text) ?? "";
2119
- return g ? w[g] : JSON.stringify(w, null, 2);
2154
+ if (m.length === 0)
2155
+ throw new Error(`Unknown revision "${c}"`);
2156
+ const $ = {};
2157
+ for (const K of m)
2158
+ $[K.path] = ((L = await g.fs.read(F(x.dir, K.at))) == null ? void 0 : L.text) ?? "";
2159
+ return y ? $[y] : JSON.stringify($, null, 2);
2120
2160
  },
2121
- async rollback(a, p, g) {
2161
+ async rollback(o, c, y) {
2122
2162
  var L;
2123
- const { module: h } = await I(a), N = y(a.workspaceId), u = (await f(N.fs, h.dir)).filter(
2124
- (M) => M.stamp === p && (!g || M.path === g)
2163
+ const { module: g } = await I(o), x = h(o.workspaceId), m = (await u(x.fs, g.dir)).filter(
2164
+ (K) => K.stamp === c && (!y || K.path === y)
2125
2165
  );
2126
- if (u.length === 0)
2127
- throw new Error(`Unknown revision "${p}"`);
2128
- const w = fe(o());
2129
- for (const M of u) {
2130
- const R = F(h.dir, M.path), B = ((L = await N.fs.read(F(h.dir, M.at))) == null ? void 0 : L.text) ?? "", Z = await N.fs.read(R);
2131
- Z && await v(N.fs, R, Z.text, w), await N.fs.write(R, B);
2166
+ if (m.length === 0)
2167
+ throw new Error(`Unknown revision "${c}"`);
2168
+ const $ = fe(a());
2169
+ for (const K of m) {
2170
+ const R = F(g.dir, K.path), z = ((L = await x.fs.read(F(g.dir, K.at))) == null ? void 0 : L.text) ?? "", Y = await x.fs.read(R);
2171
+ Y && await D(x.fs, R, Y.text, $), await x.fs.write(R, z);
2132
2172
  }
2133
- j(N);
2173
+ S(x);
2134
2174
  }
2135
2175
  };
2136
- return O;
2176
+ return E;
2137
2177
  }
2138
2178
  class ye extends Error {
2139
- constructor(i, t, o) {
2140
- super(i), this.status = t, this.body = o, this.name = "OmniVerkRestError";
2179
+ constructor(i, t, a) {
2180
+ super(i), this.status = t, this.body = a, this.name = "OmniVerkRestError";
2141
2181
  }
2142
2182
  }
2143
- const Yt = new TextDecoder("utf-8", { ignoreBOM: !0 });
2144
- function Xt(e) {
2183
+ const ei = new TextDecoder("utf-8", { ignoreBOM: !0 });
2184
+ function ti(e) {
2145
2185
  const i = atob(e), t = new Uint8Array(i.length);
2146
- for (let o = 0; o < i.length; o++)
2147
- t[o] = i.charCodeAt(o);
2148
- return Yt.decode(t);
2186
+ for (let a = 0; a < i.length; a++)
2187
+ t[a] = i.charCodeAt(a);
2188
+ return ei.decode(t);
2149
2189
  }
2150
2190
  function Ce(e) {
2151
2191
  const i = new TextEncoder().encode(e);
2152
2192
  let t = "";
2153
- for (let o = 0; o < i.length; o += 32768)
2154
- t += String.fromCharCode(...i.subarray(o, o + 32768));
2193
+ for (let a = 0; a < i.length; a += 32768)
2194
+ t += String.fromCharCode(...i.subarray(a, a + 32768));
2155
2195
  return btoa(t);
2156
2196
  }
2157
- function Qt(e) {
2197
+ function ii(e) {
2158
2198
  let i = 2166136261;
2159
2199
  for (let t = 0; t < e.length; t++)
2160
2200
  i = Math.imul(i ^ e.charCodeAt(t), 16777619);
2161
2201
  return `${e.length}:${(i >>> 0).toString(16)}`;
2162
2202
  }
2163
- function si(e = {}) {
2164
- const i = (e.baseUrl ?? "/api").replace(/\/+$/, ""), t = e.fetch ?? ((d, m) => globalThis.fetch(d, m)), o = e.language ?? "en", n = encodeURIComponent;
2165
- async function s(d, m, b, C = "json") {
2166
- const j = typeof e.headers == "function" ? await e.headers() : e.headers ?? {}, T = await t(`${i}${m}`, {
2203
+ function ri(e = {}) {
2204
+ const i = (e.baseUrl ?? "/api").replace(/\/+$/, ""), t = e.fetch ?? ((d, p) => globalThis.fetch(d, p)), a = e.language ?? "en", n = encodeURIComponent;
2205
+ async function s(d, p, k, A = "json") {
2206
+ const S = typeof e.headers == "function" ? await e.headers() : e.headers ?? {}, T = await t(`${i}${p}`, {
2167
2207
  method: d,
2168
2208
  credentials: e.credentials ?? "same-origin",
2169
2209
  headers: {
2170
- Accept: C === "json" ? "application/json" : "text/plain, application/json",
2171
- ...b === void 0 ? {} : { "Content-Type": "application/json" },
2172
- ...j
2210
+ Accept: A === "json" ? "application/json" : "text/plain, application/json",
2211
+ ...k === void 0 ? {} : { "Content-Type": "application/json" },
2212
+ ...S
2173
2213
  },
2174
- ...b === void 0 ? {} : { body: JSON.stringify(b) }
2214
+ ...k === void 0 ? {} : { body: JSON.stringify(k) }
2175
2215
  }), I = await T.text();
2176
- let c = I;
2177
- if (C === "json" || !T.ok)
2216
+ let b = I;
2217
+ if (A === "json" || !T.ok)
2178
2218
  try {
2179
- c = I ? JSON.parse(I) : void 0;
2219
+ b = I ? JSON.parse(I) : void 0;
2180
2220
  } catch {
2181
- c = I;
2221
+ b = I;
2182
2222
  }
2183
2223
  if (!T.ok)
2184
2224
  throw new ye(
2185
- `${d} ${m}: ${T.status} ${T.statusText}`,
2225
+ `${d} ${p}: ${T.status} ${T.statusText}`,
2186
2226
  T.status,
2187
- c
2227
+ b
2188
2228
  );
2189
- return c;
2229
+ return b;
2190
2230
  }
2191
2231
  const r = e.templates === !1 ? {} : {
2192
2232
  async listTemplates() {
2193
2233
  const d = await s(
2194
2234
  "GET",
2195
- `/module-templates?lang=${n(o)}&hidden=true`
2235
+ `/module-templates?lang=${n(a)}&hidden=true`
2196
2236
  );
2197
2237
  return (await Promise.all(
2198
2238
  (d ?? []).map(
2199
- (b) => s(
2239
+ (k) => s(
2200
2240
  "GET",
2201
- `/module-templates/${n(b.slug)}?lang=${n(o)}`
2241
+ `/module-templates/${n(k.slug)}?lang=${n(a)}`
2202
2242
  )
2203
2243
  )
2204
- )).map((b) => Ie(b, o));
2244
+ )).map((k) => Ie(k, a));
2205
2245
  },
2206
- async saveTemplate(d, m) {
2207
- const b = (m == null ? void 0 : m.previousId) ?? d.id, C = Ut(d);
2208
- let j;
2209
- if ((m == null ? void 0 : m.previousId) === void 0)
2210
- j = await s(
2246
+ async saveTemplate(d, p) {
2247
+ const k = (p == null ? void 0 : p.previousId) ?? d.id, A = _t(d);
2248
+ let S;
2249
+ if ((p == null ? void 0 : p.previousId) === void 0)
2250
+ S = await s(
2211
2251
  "GET",
2212
- `/module-templates/${n(d.id)}?lang=${n(o)}`
2252
+ `/module-templates/${n(d.id)}?lang=${n(a)}`
2213
2253
  ).then(
2214
2254
  () => !0,
2215
2255
  (I) => I instanceof ye && I.status === 404 ? !1 : Promise.reject(I)
2216
2256
  ) ? await s(
2217
2257
  "PUT",
2218
- `/module-templates/${n(d.id)}?lang=${n(o)}`,
2219
- C
2220
- ) : await s("POST", `/module-templates?lang=${n(o)}`, C);
2258
+ `/module-templates/${n(d.id)}?lang=${n(a)}`,
2259
+ A
2260
+ ) : await s("POST", `/module-templates?lang=${n(a)}`, A);
2221
2261
  else {
2222
- if (b !== d.id)
2262
+ if (k !== d.id)
2223
2263
  throw new Error(
2224
2264
  "The OmniVerk API keeps a template's slug: save it as a new template instead."
2225
2265
  );
2226
- j = await s(
2266
+ S = await s(
2227
2267
  "PUT",
2228
- `/module-templates/${n(b)}?lang=${n(o)}`,
2229
- C
2268
+ `/module-templates/${n(k)}?lang=${n(a)}`,
2269
+ A
2230
2270
  );
2231
2271
  }
2232
- return Ie(j, o);
2272
+ return Ie(S, a);
2233
2273
  },
2234
2274
  async deleteTemplate(d) {
2235
2275
  await s("DELETE", `/module-templates/${n(d)}`);
2236
2276
  }
2237
2277
  };
2238
2278
  if ((e.mode ?? "manifest-only") === "manifest-only") {
2239
- const d = "seed", m = /* @__PURE__ */ new Map(), b = (j) => {
2279
+ const d = "seed", p = /* @__PURE__ */ new Map(), k = (S) => {
2240
2280
  var T, I;
2241
- return ((T = m.get(j)) == null ? void 0 : T.manifestFile) ?? `${(I = j.split(".").pop()) == null ? void 0 : I.toLowerCase()}.manifest.json`;
2242
- }, C = async (j) => {
2243
- const T = await s("GET", `/module-manifests/${n(j)}`), I = de(T, { finalNewline: !1 });
2244
- return { path: b(j), text: I, version: Qt(I) };
2281
+ return ((T = p.get(S)) == null ? void 0 : T.manifestFile) ?? `${(I = S.split(".").pop()) == null ? void 0 : I.toLowerCase()}.manifest.json`;
2282
+ }, A = async (S) => {
2283
+ const T = await s("GET", `/module-manifests/${n(S)}`), I = ae(T, { finalNewline: !1 });
2284
+ return { path: k(S), text: I, version: ii(I) };
2245
2285
  };
2246
2286
  return {
2247
2287
  async listWorkspaces() {
2248
2288
  return [{ id: d, label: e.workspaceLabel ?? "Seed/Modules" }];
2249
2289
  },
2250
2290
  async listModules() {
2251
- const j = await s("GET", "/module-manifests");
2252
- return m.clear(), (j ?? []).map((T) => (m.set(T.packageName, T), {
2291
+ const S = await s("GET", "/module-manifests");
2292
+ return p.clear(), (S ?? []).map((T) => (p.set(T.packageName, T), {
2253
2293
  workspaceId: d,
2254
2294
  id: T.packageName,
2255
2295
  // the package is the manifest's category, as in the `files` mode and OmniVerk's own
@@ -2263,63 +2303,63 @@ function si(e = {}) {
2263
2303
  contents: "manifest"
2264
2304
  }));
2265
2305
  },
2266
- async readModule(j) {
2267
- return [await C(j.id)];
2306
+ async readModule(S) {
2307
+ return [await A(S.id)];
2268
2308
  },
2269
- async writeModule(j, T) {
2270
- const I = b(j.id), c = T.find((x) => x.path !== I || x.type !== "write");
2271
- if (c)
2309
+ async writeModule(S, T) {
2310
+ const I = k(S.id), b = T.find((N) => N.path !== I || N.type !== "write");
2311
+ if (b)
2272
2312
  throw new Error(
2273
- `This OmniVerk API stores only the manifest; "${c.path}" was not saved.`
2313
+ `This OmniVerk API stores only the manifest; "${b.path}" was not saved.`
2274
2314
  );
2275
- const v = T[0];
2276
- if (!v || v.type !== "write")
2315
+ const D = T[0];
2316
+ if (!D || D.type !== "write")
2277
2317
  return { ok: !0, versions: {} };
2278
- const f = await C(j.id);
2279
- if (v.baseVersion !== void 0 && v.baseVersion !== f.version)
2280
- return { ok: !1, conflicts: [{ path: I, currentVersion: f.version }] };
2281
- const E = await s(
2318
+ const u = await A(S.id);
2319
+ if (D.baseVersion !== void 0 && D.baseVersion !== u.version)
2320
+ return { ok: !1, conflicts: [{ path: I, currentVersion: u.version }] };
2321
+ const v = await s(
2282
2322
  "PUT",
2283
- `/module-manifests/${n(j.id)}`,
2323
+ `/module-manifests/${n(S.id)}`,
2284
2324
  {
2285
- manifest: _(v.text).value
2325
+ manifest: _(D.text).value
2286
2326
  }
2287
- ), A = await C(j.id);
2327
+ ), f = await A(S.id);
2288
2328
  return {
2289
2329
  ok: !0,
2290
- versions: { [I]: A.version },
2291
- ...E != null && E.revision ? { revision: E.revision } : {}
2330
+ versions: { [I]: f.version },
2331
+ ...v != null && v.revision ? { revision: v.revision } : {}
2292
2332
  };
2293
2333
  },
2294
- async listRevisions(j) {
2334
+ async listRevisions(S) {
2295
2335
  return (await s(
2296
2336
  "GET",
2297
- `/module-manifests/${n(j.id)}/revisions`
2337
+ `/module-manifests/${n(S.id)}/revisions`
2298
2338
  ) ?? []).map((I) => ({
2299
2339
  id: I.id,
2300
2340
  timestamp: Date.parse(I.at) || 0,
2301
- path: b(j.id),
2341
+ path: k(S.id),
2302
2342
  ...I.sizeBytes !== void 0 ? { summary: `${I.sizeBytes} B` } : {}
2303
2343
  }));
2304
2344
  },
2305
- async readRevision(j, T) {
2345
+ async readRevision(S, T) {
2306
2346
  return s(
2307
2347
  "GET",
2308
- `/module-manifests/${n(j.id)}/revisions/${n(T)}`,
2348
+ `/module-manifests/${n(S.id)}/revisions/${n(T)}`,
2309
2349
  void 0,
2310
2350
  "text"
2311
2351
  );
2312
2352
  },
2313
- async rollback(j, T) {
2353
+ async rollback(S, T) {
2314
2354
  await s(
2315
2355
  "POST",
2316
- `/module-manifests/${n(j.id)}/revisions/${n(T)}/rollback`
2356
+ `/module-manifests/${n(S.id)}/revisions/${n(T)}/rollback`
2317
2357
  );
2318
2358
  },
2319
2359
  ...r
2320
2360
  };
2321
2361
  }
2322
- const l = (d) => `/module-files/${n(d.workspaceId)}/modules/${n(d.id)}`, y = (d) => d.map((m) => ({ path: m.path, content: Ce(m.text) }));
2362
+ const l = (d) => `/module-files/${n(d.workspaceId)}/modules/${n(d.id)}`, h = (d) => d.map((p) => ({ path: p.path, content: Ce(p.text) }));
2323
2363
  return {
2324
2364
  async listWorkspaces() {
2325
2365
  return s("GET", "/module-files/workspaces");
@@ -2328,43 +2368,43 @@ function si(e = {}) {
2328
2368
  return (await s(
2329
2369
  "GET",
2330
2370
  `/module-files/${n(d)}/modules`
2331
- ) ?? []).map((b) => ({ ...b, workspaceId: d }));
2371
+ ) ?? []).map((k) => ({ ...k, workspaceId: d }));
2332
2372
  },
2333
2373
  async readModule(d) {
2334
- const m = await s("GET", l(d));
2335
- return ((m == null ? void 0 : m.files) ?? []).map((b) => ({
2336
- path: b.path,
2337
- text: Xt(b.content),
2338
- ...b.version ? { version: b.version } : {},
2339
- ...b.readOnly ? { readOnly: !0 } : {}
2374
+ const p = await s("GET", l(d));
2375
+ return ((p == null ? void 0 : p.files) ?? []).map((k) => ({
2376
+ path: k.path,
2377
+ text: ti(k.content),
2378
+ ...k.version ? { version: k.version } : {},
2379
+ ...k.readOnly ? { readOnly: !0 } : {}
2340
2380
  }));
2341
2381
  },
2342
- async writeModule(d, m) {
2343
- var b;
2382
+ async writeModule(d, p) {
2383
+ var k;
2344
2384
  try {
2345
- const C = await s(
2385
+ const A = await s(
2346
2386
  "PUT",
2347
2387
  l(d),
2348
2388
  {
2349
- changes: m.map(
2350
- (j) => j.type === "write" ? {
2389
+ changes: p.map(
2390
+ (S) => S.type === "write" ? {
2351
2391
  type: "write",
2352
- path: j.path,
2353
- content: Ce(j.text),
2354
- baseVersion: j.baseVersion
2355
- } : { type: "delete", path: j.path, baseVersion: j.baseVersion }
2392
+ path: S.path,
2393
+ content: Ce(S.text),
2394
+ baseVersion: S.baseVersion
2395
+ } : { type: "delete", path: S.path, baseVersion: S.baseVersion }
2356
2396
  )
2357
2397
  }
2358
2398
  );
2359
2399
  return {
2360
2400
  ok: !0,
2361
- versions: C == null ? void 0 : C.versions,
2362
- ...C != null && C.revision ? { revision: C.revision } : {}
2401
+ versions: A == null ? void 0 : A.versions,
2402
+ ...A != null && A.revision ? { revision: A.revision } : {}
2363
2403
  };
2364
- } catch (C) {
2365
- if (C instanceof ye && C.status === 409)
2366
- return { ok: !1, conflicts: ((b = C.body) == null ? void 0 : b.conflicts) ?? m.map((T) => ({ path: T.path })) };
2367
- throw C;
2404
+ } catch (A) {
2405
+ if (A instanceof ye && A.status === 409)
2406
+ return { ok: !1, conflicts: ((k = A.body) == null ? void 0 : k.conflicts) ?? p.map((T) => ({ path: T.path })) };
2407
+ throw A;
2368
2408
  }
2369
2409
  },
2370
2410
  async createModule(d) {
@@ -2374,44 +2414,44 @@ function si(e = {}) {
2374
2414
  {
2375
2415
  packageId: d.packageId,
2376
2416
  id: d.id,
2377
- files: y(d.files)
2417
+ files: h(d.files)
2378
2418
  }
2379
2419
  ), workspaceId: d.workspaceId };
2380
2420
  },
2381
2421
  async deleteModule(d) {
2382
2422
  await s("DELETE", l(d));
2383
2423
  },
2384
- async listRevisions(d, m) {
2424
+ async listRevisions(d, p) {
2385
2425
  return s(
2386
2426
  "GET",
2387
- `${l(d)}/revisions${m ? `?path=${n(m)}` : ""}`
2427
+ `${l(d)}/revisions${p ? `?path=${n(p)}` : ""}`
2388
2428
  );
2389
2429
  },
2390
- async readRevision(d, m, b) {
2430
+ async readRevision(d, p, k) {
2391
2431
  return s(
2392
2432
  "GET",
2393
- `${l(d)}/revisions/${n(m)}${b ? `?path=${n(b)}` : ""}`,
2433
+ `${l(d)}/revisions/${n(p)}${k ? `?path=${n(k)}` : ""}`,
2394
2434
  void 0,
2395
2435
  "text"
2396
2436
  );
2397
2437
  },
2398
- async rollback(d, m, b) {
2438
+ async rollback(d, p, k) {
2399
2439
  await s(
2400
2440
  "POST",
2401
- `${l(d)}/revisions/${n(m)}/rollback${b ? `?path=${n(b)}` : ""}`
2441
+ `${l(d)}/revisions/${n(p)}/rollback${k ? `?path=${n(k)}` : ""}`
2402
2442
  );
2403
2443
  },
2404
2444
  ...e.serverValidation ? {
2405
- async validate(d, m) {
2445
+ async validate(d, p) {
2406
2446
  return s("POST", `${l(d)}/validate`, {
2407
- files: y(m)
2447
+ files: h(p)
2408
2448
  });
2409
2449
  }
2410
2450
  } : {},
2411
2451
  ...r
2412
2452
  };
2413
2453
  }
2414
- const ei = [
2454
+ const ni = [
2415
2455
  "en",
2416
2456
  "pl",
2417
2457
  "de",
@@ -2440,12 +2480,12 @@ const ei = [
2440
2480
  } catch {
2441
2481
  return { path: i.path, value: {} };
2442
2482
  }
2443
- }, ti = (e) => {
2483
+ }, si = (e) => {
2444
2484
  var i;
2445
2485
  return ((i = be(e)) == null ? void 0 : i.path.replace(/\.manifest\.json$/i, "")) ?? "module";
2446
2486
  };
2447
- function oi(e = {}) {
2448
- const i = e.t ?? ((s, r) => r), t = (s, r) => i(`devStudio.omniverk.${s}`, r), o = {
2487
+ function li(e = {}) {
2488
+ const i = e.t ?? ((s, r) => r), t = (s, r) => i(`devStudio.omniverk.${s}`, r), a = {
2449
2489
  type: "object",
2450
2490
  properties: {
2451
2491
  name: { type: "string", title: t("field.name", "Name") },
@@ -2453,7 +2493,7 @@ function oi(e = {}) {
2453
2493
  dataType: {
2454
2494
  type: "string",
2455
2495
  title: t("field.dataType", "Data type"),
2456
- enum: [...vt]
2496
+ enum: [...kt]
2457
2497
  },
2458
2498
  maxLength: { type: "integer", title: t("field.maxLength", "Max length") },
2459
2499
  isRequired: { type: "boolean", title: t("field.isRequired", "Required") },
@@ -2484,21 +2524,21 @@ function oi(e = {}) {
2484
2524
  };
2485
2525
  return {
2486
2526
  id: "omniverk",
2487
- kinds: yt,
2488
- manifestSections: ht(i, { scripting: e.scripting }),
2489
- entities: { entityMetaSchema: n, fieldSchema: o },
2490
- locales: e.locales ?? ei,
2527
+ kinds: wt,
2528
+ manifestSections: $t(i, { scripting: e.scripting }),
2529
+ entities: { entityMetaSchema: n, fieldSchema: a },
2530
+ locales: e.locales ?? ni,
2491
2531
  requiredLocales: ["en", "pl"],
2492
2532
  moduleId: (s) => {
2493
2533
  var l;
2494
2534
  const r = (l = be(s)) == null ? void 0 : l.value.packageName;
2495
2535
  return typeof r == "string" && r ? r : void 0;
2496
2536
  },
2497
- validateModule: (s) => Pt(s),
2537
+ validateModule: (s) => Vt(s),
2498
2538
  generateModule: async (s, { existingIds: r }) => {
2499
- const l = await xt(
2539
+ const l = await Ot(
2500
2540
  {
2501
- ...It(s),
2541
+ ...At(s),
2502
2542
  iconConfig: e.iconConfig,
2503
2543
  ownerTenantId: e.ownerTenantId
2504
2544
  },
@@ -2513,10 +2553,34 @@ function oi(e = {}) {
2513
2553
  files: l.package.files
2514
2554
  };
2515
2555
  },
2516
- duplicateModule: (s, r) => Ot(s, r),
2556
+ duplicateModule: (s, r) => Kt(s, r),
2557
+ scripts: {
2558
+ categories: [
2559
+ "calculation",
2560
+ "formatting",
2561
+ "integration",
2562
+ "maintenance",
2563
+ "reporting",
2564
+ "utility",
2565
+ "validation"
2566
+ ],
2567
+ phases: ["preInstall", "postInstall", "preUninstall", "postUninstall", "migrations"]
2568
+ },
2517
2569
  newFile: (s, { files: r }) => {
2518
- var C;
2519
- const l = ti(r), y = ((C = be(r)) == null ? void 0 : C.value) ?? {}, d = `${String(y.packageName ?? l)}.Core`, b = {
2570
+ var A;
2571
+ const l = si(r), h = ((A = be(r)) == null ? void 0 : A.value) ?? {};
2572
+ if (s === "scripts") {
2573
+ let S = `${l}.scripts.json`;
2574
+ for (let I = 2; r.some((b) => b.path === S); I++)
2575
+ S = `${l}.${I}.scripts.json`;
2576
+ const T = {
2577
+ moduleName: String(h.packageName ?? l),
2578
+ version: "1.0.0",
2579
+ scripts: []
2580
+ };
2581
+ return { path: S, text: ae(T) };
2582
+ }
2583
+ const d = `${String(h.packageName ?? l)}.Core`, k = {
2520
2584
  entities: ["entities.json", { moduleName: d, version: "1.0.0", entities: [] }],
2521
2585
  views: ["views.json", { moduleName: d, version: "1.0.0", views: [] }],
2522
2586
  workflows: ["workflows.json", { moduleName: d, version: "1.0.0", workflows: [] }],
@@ -2524,9 +2588,13 @@ function oi(e = {}) {
2524
2588
  "permissions.json",
2525
2589
  { moduleName: d, version: "1.0.0", permissions: [], permissionGroups: [] }
2526
2590
  ],
2527
- seeds: ["seeds.json", { moduleName: d, version: "1.0.0", seeds: {} }]
2591
+ seeds: ["seeds.json", { moduleName: d, version: "1.0.0", seeds: {} }],
2592
+ dataSources: [
2593
+ "datasources.json",
2594
+ { moduleName: String(h.packageName ?? l), version: "1.0.0", dataSources: [] }
2595
+ ]
2528
2596
  }[s];
2529
- return b ? { path: `${l}.${b[0]}`, text: de(b[1]) } : void 0;
2597
+ return k ? { path: `${l}.${k[0]}`, text: ae(k[1]) } : void 0;
2530
2598
  },
2531
2599
  templateSchema: {
2532
2600
  type: "object",
@@ -2550,22 +2618,22 @@ function oi(e = {}) {
2550
2618
  }
2551
2619
  };
2552
2620
  }
2553
- function ai(e = {}) {
2621
+ function ci(e = {}) {
2554
2622
  let i = 0;
2555
2623
  const t = /* @__PURE__ */ new Map();
2556
2624
  for (const [n, s] of Object.entries(e))
2557
2625
  t.set(n, { text: s, version: String(++i) });
2558
- const o = (n) => n ? `${n}/` : "";
2626
+ const a = (n) => n ? `${n}/` : "";
2559
2627
  return {
2560
2628
  async list(n) {
2561
- const s = o(n), r = /* @__PURE__ */ new Map();
2629
+ const s = a(n), r = /* @__PURE__ */ new Map();
2562
2630
  for (const l of t.keys()) {
2563
2631
  if (!l.startsWith(s))
2564
2632
  continue;
2565
- const y = l.slice(s.length), d = y.indexOf("/");
2566
- r.set(d < 0 ? y : y.slice(0, d), d < 0 ? "file" : "directory");
2633
+ const h = l.slice(s.length), d = h.indexOf("/");
2634
+ r.set(d < 0 ? h : h.slice(0, d), d < 0 ? "file" : "directory");
2567
2635
  }
2568
- return [...r].map(([l, y]) => ({ name: l, kind: y }));
2636
+ return [...r].map(([l, h]) => ({ name: l, kind: h }));
2569
2637
  },
2570
2638
  async read(n) {
2571
2639
  const s = t.get(n);
@@ -2579,7 +2647,7 @@ function ai(e = {}) {
2579
2647
  t.delete(n);
2580
2648
  },
2581
2649
  async removeDir(n) {
2582
- const s = o(n);
2650
+ const s = a(n);
2583
2651
  for (const r of [...t.keys()])
2584
2652
  r.startsWith(s) && t.delete(r);
2585
2653
  },
@@ -2588,12 +2656,12 @@ function ai(e = {}) {
2588
2656
  }
2589
2657
  };
2590
2658
  }
2591
- const Ge = () => typeof window > "u" ? void 0 : window.showDirectoryPicker;
2592
- function ri() {
2593
- return typeof Ge() == "function";
2659
+ const _e = () => typeof window > "u" ? void 0 : window.showDirectoryPicker;
2660
+ function di() {
2661
+ return typeof _e() == "function";
2594
2662
  }
2595
- async function li(e = {}) {
2596
- const i = Ge();
2663
+ async function pi(e = {}) {
2664
+ const i = _e();
2597
2665
  if (!i)
2598
2666
  throw new Error("This browser cannot open folders (File System Access API).");
2599
2667
  return i({
@@ -2601,119 +2669,121 @@ async function li(e = {}) {
2601
2669
  ...e.id ? { id: e.id } : {}
2602
2670
  });
2603
2671
  }
2604
- const re = (e) => typeof e == "object" && e !== null && (e.name === "NotFoundError" || e.name === "TypeMismatchError");
2605
- function ci(e) {
2672
+ const le = (e) => typeof e == "object" && e !== null && (e.name === "NotFoundError" || e.name === "TypeMismatchError");
2673
+ function mi(e) {
2606
2674
  const i = new TextDecoder("utf-8", { ignoreBOM: !0 });
2607
2675
  async function t(r, l = !1) {
2608
- let y = e;
2676
+ let h = e;
2609
2677
  for (const d of r.split("/").filter(Boolean))
2610
2678
  try {
2611
- y = await y.getDirectoryHandle(d, { create: l });
2612
- } catch (m) {
2613
- if (re(m))
2679
+ h = await h.getDirectoryHandle(d, { create: l });
2680
+ } catch (p) {
2681
+ if (le(p))
2614
2682
  return null;
2615
- throw m;
2683
+ throw p;
2616
2684
  }
2617
- return y;
2685
+ return h;
2618
2686
  }
2619
- const o = (r) => {
2687
+ const a = (r) => {
2620
2688
  const l = r.lastIndexOf("/");
2621
2689
  return l < 0 ? ["", r] : [r.slice(0, l), r.slice(l + 1)];
2622
2690
  };
2623
2691
  async function n(r, l = !1) {
2624
- const [y, d] = o(r), m = await t(y, l);
2625
- if (!m)
2692
+ const [h, d] = a(r), p = await t(h, l);
2693
+ if (!p)
2626
2694
  return null;
2627
2695
  try {
2628
- return await m.getFileHandle(d, { create: l });
2629
- } catch (b) {
2630
- if (re(b))
2696
+ return await p.getFileHandle(d, { create: l });
2697
+ } catch (k) {
2698
+ if (le(k))
2631
2699
  return null;
2632
- throw b;
2700
+ throw k;
2633
2701
  }
2634
2702
  }
2635
2703
  const s = (r) => `${r.lastModified}:${r.size}`;
2636
2704
  return {
2637
2705
  async list(r) {
2638
- const l = await t(r), y = [];
2706
+ const l = await t(r), h = [];
2639
2707
  if (l)
2640
2708
  for await (const d of l.values())
2641
- y.push({ name: d.name, kind: d.kind });
2642
- return y;
2709
+ h.push({ name: d.name, kind: d.kind });
2710
+ return h;
2643
2711
  },
2644
2712
  async read(r) {
2645
2713
  const l = await n(r);
2646
2714
  if (!l)
2647
2715
  return null;
2648
- const y = await l.getFile();
2649
- return { text: i.decode(await y.arrayBuffer()), version: s(y) };
2716
+ const h = await l.getFile();
2717
+ return { text: i.decode(await h.arrayBuffer()), version: s(h) };
2650
2718
  },
2651
2719
  async write(r, l) {
2652
- const y = await n(r, !0);
2653
- if (!y)
2720
+ const h = await n(r, !0);
2721
+ if (!h)
2654
2722
  throw new Error(`Cannot write ${r}`);
2655
- const d = await y.createWritable();
2656
- return await d.write(l), await d.close(), s(await y.getFile());
2723
+ const d = await h.createWritable();
2724
+ return await d.write(l), await d.close(), s(await h.getFile());
2657
2725
  },
2658
2726
  async remove(r) {
2659
- const [l, y] = o(r), d = await t(l);
2727
+ const [l, h] = a(r), d = await t(l);
2660
2728
  try {
2661
- await (d == null ? void 0 : d.removeEntry(y));
2662
- } catch (m) {
2663
- if (!re(m))
2664
- throw m;
2729
+ await (d == null ? void 0 : d.removeEntry(h));
2730
+ } catch (p) {
2731
+ if (!le(p))
2732
+ throw p;
2665
2733
  }
2666
2734
  },
2667
2735
  async removeDir(r) {
2668
- const [l, y] = o(r), d = await t(l);
2736
+ const [l, h] = a(r), d = await t(l);
2669
2737
  try {
2670
- await (d == null ? void 0 : d.removeEntry(y, { recursive: !0 }));
2671
- } catch (m) {
2672
- if (!re(m))
2673
- throw m;
2738
+ await (d == null ? void 0 : d.removeEntry(h, { recursive: !0 }));
2739
+ } catch (p) {
2740
+ if (!le(p))
2741
+ throw p;
2674
2742
  }
2675
2743
  }
2676
2744
  };
2677
2745
  }
2678
2746
  export {
2679
2747
  W as OMNIVERK_CUSTOM_PREFIX,
2680
- vt as OMNIVERK_DATA_TYPES,
2681
- Ft as OMNIVERK_LEGACY_LIST_VIEW_FILES,
2682
- ei as OMNIVERK_LOCALES,
2748
+ kt as OMNIVERK_DATA_TYPES,
2749
+ qt as OMNIVERK_LEGACY_LIST_VIEW_FILES,
2750
+ ni as OMNIVERK_LOCALES,
2683
2751
  ye as OmniVerkRestError,
2684
- xt as buildOmniVerkModule,
2685
- ci as createDirectoryHandleFileSystem,
2686
- ai as createMemorySeedFileSystem,
2687
- si as createOmniVerkRestProvider,
2688
- oi as createOmniVerkStudioPreset,
2689
- ni as createSeedFolderProvider,
2690
- Ot as duplicateOmniVerkModule,
2691
- ri as isSeedFolderPickerSupported,
2692
- Xe as omniverkEntitiesKind,
2693
- yt as omniverkFileKinds,
2694
- kt as omniverkFilePrefix,
2695
- Qe as omniverkI18nKind,
2696
- He as omniverkManifestKind,
2697
- ht as omniverkManifestSections,
2752
+ Ot as buildOmniVerkModule,
2753
+ mi as createDirectoryHandleFileSystem,
2754
+ ci as createMemorySeedFileSystem,
2755
+ ri as createOmniVerkRestProvider,
2756
+ li as createOmniVerkStudioPreset,
2757
+ ai as createSeedFolderProvider,
2758
+ Kt as duplicateOmniVerkModule,
2759
+ di as isSeedFolderPickerSupported,
2760
+ ht as omniverkDataSourcesKind,
2761
+ Qe as omniverkEntitiesKind,
2762
+ wt as omniverkFileKinds,
2763
+ jt as omniverkFilePrefix,
2764
+ et as omniverkI18nKind,
2765
+ Ze as omniverkManifestKind,
2766
+ $t as omniverkManifestSections,
2698
2767
  P as omniverkPascalIdentifier,
2699
- mt as omniverkPermissionsKind,
2768
+ ut as omniverkPermissionsKind,
2700
2769
  fe as omniverkRevisionStamp,
2701
- ft as omniverkScriptKind,
2702
- ut as omniverkSeedsKind,
2703
- It as omniverkSpecFromStudio,
2704
- qe as omniverkStableId,
2705
- Ve as omniverkTableName,
2770
+ yt as omniverkScriptKind,
2771
+ gt as omniverkScriptsKind,
2772
+ ft as omniverkSeedsKind,
2773
+ At as omniverkSpecFromStudio,
2774
+ Ve as omniverkStableId,
2775
+ Ue as omniverkTableName,
2706
2776
  Ie as omniverkTemplateFromDto,
2707
- Vt as omniverkTemplateFromEntry,
2777
+ Gt as omniverkTemplateFromEntry,
2708
2778
  xe as omniverkTemplateToEntry,
2709
- Ut as omniverkTemplateToInput,
2710
- st as omniverkViewFromItem,
2711
- nt as omniverkViewItem,
2712
- ot as omniverkViewsKind,
2713
- lt as omniverkWorkflowFromItem,
2714
- rt as omniverkWorkflowItem,
2715
- ct as omniverkWorkflowsKind,
2716
- li as pickSeedDirectory,
2717
- Pt as validateOmniVerkModule,
2718
- Rt as validateOmniVerkWorkspace
2779
+ _t as omniverkTemplateToInput,
2780
+ ot as omniverkViewFromItem,
2781
+ st as omniverkViewItem,
2782
+ at as omniverkViewsKind,
2783
+ ct as omniverkWorkflowFromItem,
2784
+ lt as omniverkWorkflowItem,
2785
+ dt as omniverkWorkflowsKind,
2786
+ pi as pickSeedDirectory,
2787
+ Vt as validateOmniVerkModule,
2788
+ Ut as validateOmniVerkWorkspace
2719
2789
  };