@knkcs/importhub-ui 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.js CHANGED
@@ -1,41 +1,68 @@
1
- import { createHostMembers as X } from "@knkcs/anker/host";
2
- import { R as j, C as J, N as Y } from "./importhub-client-CrS-3Zuu.js";
3
- const b = "user_stub_ada", D = "ws_stub_main", ce = "ws_stub_other";
4
- function me(r = D) {
1
+ import { createHostMembers as ne } from "@knkcs/anker/host";
2
+ import { R as K, C as V, N as ie } from "./importhub-client-CrS-3Zuu.js";
3
+ const S = "user_stub_ada", U = "ws_stub_main", he = "ws_stub_other";
4
+ function be(i = U) {
5
5
  return {
6
- userId: b,
7
- workspaceId: r,
8
- members: X([
9
- { userId: b, displayName: "Ada Importer", email: "ada@example.com" }
6
+ userId: S,
7
+ workspaceId: i,
8
+ members: ne([
9
+ { userId: S, displayName: "Ada Importer", email: "ada@example.com" }
10
10
  ])
11
11
  };
12
12
  }
13
- function Z() {
13
+ const h = (i, o, a, d = []) => ({
14
+ accessor: i.split(".").pop() ?? i,
15
+ path: i,
16
+ fieldType: o,
17
+ label: a,
18
+ children: d
19
+ }), F = (i) => i.flatMap((o) => [o.path, ...F(o.children)]), Z = (i) => [
20
+ h("titel", "text", "Titel"),
21
+ h("abkuerzung", "text", "Abkürzung"),
22
+ ...i ? [h("fussnote", "rich_text", "Fußnote")] : [],
23
+ h("stand", "fieldset", "Stand", [
24
+ h("stand.datum", "date", "Datum"),
25
+ h("stand.art", "select", "Art")
26
+ ])
27
+ ], X = () => [
28
+ h("fundstelle", "text", "Fundstelle"),
29
+ h("ausgabedatum", "date", "Ausgabedatum")
30
+ ];
31
+ function ee() {
32
+ const i = Z(!1), o = Z(!0), a = [
33
+ h("aktenzeichen", "text", "Aktenzeichen"),
34
+ h("datum", "date", "Datum")
35
+ ];
14
36
  return [
15
37
  {
16
38
  id: "br_stub_gesetz_2",
17
39
  blueprintId: "bp_stub_gesetz",
18
40
  blueprintName: "Gesetz",
19
41
  label: "Release 2",
20
- fieldPaths: ["titel", "abkuerzung"]
42
+ fieldPaths: F(i),
43
+ fields: i,
44
+ releaseSpecFields: X()
21
45
  },
22
46
  {
23
47
  id: "br_stub_gesetz_1",
24
48
  blueprintId: "bp_stub_gesetz",
25
49
  blueprintName: "Gesetz",
26
50
  label: "Release 1",
27
- fieldPaths: ["titel", "abkuerzung", "fussnote"]
51
+ fieldPaths: F(o),
52
+ fields: o,
53
+ releaseSpecFields: X()
28
54
  },
29
55
  {
30
56
  id: "br_stub_entscheidung_1",
31
57
  blueprintId: "bp_stub_entscheidung",
32
58
  blueprintName: "Entscheidung",
33
59
  label: "Release 1",
34
- fieldPaths: ["aktenzeichen", "datum"]
60
+ fieldPaths: F(a),
61
+ fields: a
35
62
  }
36
63
  ];
37
64
  }
38
- function ee() {
65
+ function re() {
39
66
  return [
40
67
  {
41
68
  id: "mp_stub_norm",
@@ -67,7 +94,7 @@ function ee() {
67
94
  }
68
95
  ];
69
96
  }
70
- function te() {
97
+ function oe() {
71
98
  return [
72
99
  {
73
100
  id: "es_stub_latin1",
@@ -80,7 +107,7 @@ function te() {
80
107
  }
81
108
  ];
82
109
  }
83
- function se() {
110
+ function ae() {
84
111
  return [
85
112
  {
86
113
  id: "ip_stub_gesetz",
@@ -111,12 +138,12 @@ function se() {
111
138
  }
112
139
  ];
113
140
  }
114
- const F = (r, a, p, f = "") => ({
141
+ const D = (i, o, a, d = "") => ({
115
142
  field_type: "text",
116
- config: { name: a, api_accessor: r, required: p, instructions: f },
143
+ config: { name: o, api_accessor: i, required: a, instructions: d },
117
144
  system: !1
118
145
  });
119
- function ne() {
146
+ function le() {
120
147
  return [
121
148
  {
122
149
  name: "citation-links",
@@ -138,8 +165,8 @@ function ne() {
138
165
  target: "source_file",
139
166
  description: "Renames every element of one name to another.",
140
167
  settingsSpec: [
141
- F("from", "Element", !0, "The element's name now."),
142
- F("to", "New name", !0)
168
+ D("from", "Element", !0, "The element's name now."),
169
+ D("to", "New name", !0)
143
170
  ]
144
171
  },
145
172
  {
@@ -147,11 +174,11 @@ function ne() {
147
174
  kind: "preprocessor",
148
175
  target: "source_file",
149
176
  description: "Wraps each sentence of an element in its own element.",
150
- settingsSpec: [F("element", "Element", !1)]
177
+ settingsSpec: [D("element", "Element", !1)]
151
178
  }
152
179
  ];
153
180
  }
154
- const ie = [
181
+ const pe = [
155
182
  "listImportProfiles",
156
183
  "getImportProfile",
157
184
  "createImportProfile",
@@ -175,80 +202,80 @@ const ie = [
175
202
  "compareRevisions",
176
203
  "restoreRevision"
177
204
  ];
178
- let q = Date.parse("2026-11-02T08:00:00Z");
179
- const P = () => (q += 36e5, new Date(q).toISOString()), K = (r = []) => r.map((a) => {
180
- const p = Math.max(a.releaseNumber ?? 0, 1), f = Array.from({ length: p }, (w, i) => ({
181
- id: `${a.id}_r${i + 1}`,
182
- content: structuredClone(a.content),
183
- savedBy: b,
184
- savedAt: P(),
205
+ let Q = Date.parse("2026-11-02T08:00:00Z");
206
+ const R = () => (Q += 36e5, new Date(Q).toISOString()), H = (i = []) => i.map((o) => {
207
+ const a = Math.max(o.releaseNumber ?? 0, 1), d = Array.from({ length: a }, (I, p) => ({
208
+ id: `${o.id}_r${p + 1}`,
209
+ content: structuredClone(o.content),
210
+ savedBy: S,
211
+ savedAt: R(),
185
212
  restoredFromRevisionId: ""
186
- })), I = Array.from({ length: a.releaseNumber ?? 0 }, (w, i) => ({
187
- id: `${a.id}_rel${i + 1}`,
188
- number: i + 1,
189
- revisionId: `${a.id}_r${i + 1}`,
190
- releasedBy: b,
191
- releasedAt: P()
213
+ })), b = Array.from({ length: o.releaseNumber ?? 0 }, (I, p) => ({
214
+ id: `${o.id}_rel${p + 1}`,
215
+ number: p + 1,
216
+ revisionId: `${o.id}_r${p + 1}`,
217
+ releasedBy: S,
218
+ releasedAt: R()
192
219
  }));
193
- return { id: a.id, content: structuredClone(a.content), revisions: f, releases: I };
194
- }), v = (r) => r.revisions[r.revisions.length - 1], re = (r) => r.releases[r.releases.length - 1], O = (r) => {
195
- const a = re(r), p = r.revisions.find((f) => f.id === a?.revisionId);
220
+ return { id: o.id, content: structuredClone(o.content), revisions: d, releases: b };
221
+ }), E = (i) => i.revisions[i.revisions.length - 1], ce = (i) => i.releases[i.releases.length - 1], x = (i) => {
222
+ const o = ce(i), a = i.revisions.find((d) => d.id === o?.revisionId);
196
223
  return {
197
- draftRevisionId: v(r).id,
224
+ draftRevisionId: E(i).id,
198
225
  // By content, as importhub compares: a draft that restored the
199
226
  // released content does not differ.
200
- draftDiffersFromRelease: !p || JSON.stringify(p.content) !== JSON.stringify(v(r).content),
201
- ...a ? { latestRelease: { id: a.id, number: a.number } } : {}
227
+ draftDiffersFromRelease: !a || JSON.stringify(a.content) !== JSON.stringify(E(i).content),
228
+ ...o ? { latestRelease: { id: o.id, number: o.number } } : {}
202
229
  };
203
- }, oe = (r) => r.replace(/[A-Z]/g, (a) => `_${a.toLowerCase()}`), G = (r) => Object.fromEntries(
204
- Object.entries(r).map(([a, p]) => [oe(a), p])
205
- ), y = (r) => ({
206
- valid: r.length === 0,
207
- reasons: r
208
- }), B = (r) => [...r].sort((a, p) => a.content.name.localeCompare(p.content.name));
209
- let ae = 0;
210
- function de(r = {}) {
211
- const a = Object.fromEntries(
230
+ }, de = (i) => i.replace(/[A-Z]/g, (o) => `_${o.toLowerCase()}`), Y = (i) => Object.fromEntries(
231
+ Object.entries(i).map(([o, a]) => [de(o), a])
232
+ ), P = (i) => ({
233
+ valid: i.length === 0,
234
+ reasons: i
235
+ }), C = (i) => [...i].sort((o, a) => o.content.name.localeCompare(a.content.name));
236
+ let me = 0;
237
+ function _e(i = {}) {
238
+ const o = Object.fromEntries(
212
239
  Object.entries(
213
- r.workspaces ?? {
214
- [D]: {
215
- importProfiles: se(),
216
- mappings: ee(),
217
- entitySets: te()
240
+ i.workspaces ?? {
241
+ [U]: {
242
+ importProfiles: ae(),
243
+ mappings: re(),
244
+ entitySets: oe()
218
245
  }
219
246
  }
220
247
  ).map(([e, t]) => [
221
248
  e,
222
249
  {
223
- importProfiles: K(t.importProfiles),
224
- mappings: K(t.mappings),
225
- entitySets: K(t.entitySets)
250
+ importProfiles: H(t.importProfiles),
251
+ mappings: H(t.mappings),
252
+ entitySets: H(t.entitySets)
226
253
  }
227
254
  ])
228
- ), p = r.processors ?? ne(), f = r.blueprintReleases ?? Z();
229
- let I = r.activeWorkspaceId ?? D;
230
- const w = Object.fromEntries(ie.map((e) => [e, 0])), i = () => (a[I] ??= { importProfiles: [], mappings: [], entitySets: [] }, a[I]), c = async (e, t) => {
231
- if (w[e]++, r.fail) throw r.fail;
255
+ ), a = i.processors ?? le(), d = i.blueprintReleases ?? ee();
256
+ let b = i.activeWorkspaceId ?? U;
257
+ const I = Object.fromEntries(pe.map((e) => [e, 0])), p = () => (o[b] ??= { importProfiles: [], mappings: [], entitySets: [] }, o[b]), u = async (e, t) => {
258
+ if (I[e]++, i.fail) throw i.fail;
232
259
  return structuredClone(t());
233
- }, u = (e, t, s) => {
234
- const n = e.find((o) => o.id === t);
260
+ }, g = (e, t, s) => {
261
+ const n = e.find((c) => c.id === t);
235
262
  if (!n) throw new Error(`${s} ${t} not found`);
236
263
  return n;
237
- }, _ = (e, t, s) => {
264
+ }, v = (e, t, s) => {
238
265
  if (!t.trim()) throw new Error("a name is required");
239
- if (e.some((n) => n.id !== s && n.content.name === t)) throw new Y();
240
- }, H = (e, t) => t !== "" && t !== v(e).id, R = (e, t, s, n = "") => {
241
- if (H(e, s))
266
+ if (e.some((n) => n.id !== s && n.content.name === t)) throw new ie();
267
+ }, W = (e, t) => t !== "" && t !== E(e).id, M = (e, t, s, n = "") => {
268
+ if (W(e, s))
242
269
  throw new Error("the draft moved: somebody saved in between");
243
270
  e.content = structuredClone(t), e.revisions.push({
244
271
  id: `${e.id}_r${e.revisions.length + 1}`,
245
272
  content: structuredClone(t),
246
- savedBy: b,
247
- savedAt: P(),
273
+ savedBy: S,
274
+ savedAt: R(),
248
275
  restoredFromRevisionId: n
249
276
  });
250
- }, N = (e, t) => {
251
- const s = V(e);
277
+ }, z = (e, t) => {
278
+ const s = te(e);
252
279
  return {
253
280
  id: s,
254
281
  content: structuredClone(t),
@@ -256,17 +283,17 @@ function de(r = {}) {
256
283
  {
257
284
  id: `${s}_r1`,
258
285
  content: structuredClone(t),
259
- savedBy: b,
260
- savedAt: P(),
286
+ savedBy: S,
287
+ savedAt: R(),
261
288
  restoredFromRevisionId: ""
262
289
  }
263
290
  ],
264
291
  releases: []
265
292
  };
266
293
  };
267
- function C(e) {
268
- const t = [], s = f.find((n) => n.id === e.blueprintReleaseId);
269
- return e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
294
+ function N(e) {
295
+ const t = [], s = d.find((r) => r.id === e.blueprintReleaseId);
296
+ e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
270
297
  path: "/blueprintReleaseId",
271
298
  code: "release_of_other_blueprint",
272
299
  message: "The pinned Release is of another Blueprint."
@@ -282,55 +309,86 @@ function de(r = {}) {
282
309
  path: "/elementSelector",
283
310
  code: "no_element_selector",
284
311
  message: "It has no element selector."
285
- }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." }), (e.fields ?? []).forEach((n, o) => {
286
- const l = String(n.name ?? "");
287
- s && !s.fieldPaths.includes(l) && t.push({
288
- path: `/fields/${o}`,
289
- code: "unknown_field_path",
290
- message: `The pinned Release has no field ${l}.`
312
+ }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." });
313
+ const n = (r, l) => {
314
+ typeof l == "string" && l !== "" && !ue(l) && t.push({ path: r, code: "invalid_xpath", message: `"${l}" is not an XPath.` });
315
+ };
316
+ n("/element_selector", e.elementSelector), n("/source_key/selector", e.sourceKey?.selector);
317
+ const c = [];
318
+ return (e.fields ?? []).forEach((r, l) => {
319
+ const f = `/fields/${l}`;
320
+ for (const { path: m, rel: $, mapping: y } of L(r, "", f))
321
+ c.push(m), n(`${$}/selector`, y.selector), s && !s.fieldPaths.includes(m) && t.push({
322
+ path: f,
323
+ code: "unknown_field_path",
324
+ message: `The pinned Release has no field ${m}.`
325
+ }), y.type === "select" && !y.selectOptions && t.push({
326
+ path: f,
327
+ code: "xmlmapper_schema",
328
+ message: `The select field ${m} has no select options.`
329
+ });
330
+ }), (e.versionMatch?.contentFields ?? []).forEach((r, l) => {
331
+ c.includes(r) || t.push({
332
+ path: `/version_match/content_fields/${l}`,
333
+ code: "unknown_version_match_field",
334
+ message: `The Version Match compares ${r}, which the Mapping does not map.`
335
+ });
336
+ }), (e.titleContributions ?? []).forEach((r, l) => {
337
+ (!r.selector || !r.ausgabeCodeSelector) && t.push({
338
+ path: `/title_contributions/${l}`,
339
+ code: "incomplete_title_contribution",
340
+ message: "A Title Contribution needs a selector and an Ausgabe code selector."
341
+ }), n(`/title_contributions/${l}/selector`, r.selector);
342
+ }), (e.placeholderAssets ?? []).forEach((r, l) => {
343
+ (!r.selector || !r.assetType || !r.keyParts?.length || !r.nameSelector) && t.push({
344
+ path: `/placeholder_assets/${l}`,
345
+ code: "incomplete_placeholder_assets",
346
+ message: "Placeholder Assets need a selector, an asset type, the key's parts and a name selector."
347
+ }), n(`/placeholder_assets/${l}/selector`, r.selector), (r.keyParts ?? []).forEach((f, m) => {
348
+ n(`/placeholder_assets/${l}/key_parts/${m}`, f);
291
349
  });
292
350
  }), t;
293
351
  }
294
- function U(e, t, s) {
295
- return e.flatMap((n, o) => {
296
- const l = `/${t}/${o}`, m = p.find((d) => d.name === n.processor);
297
- return m ? m.target !== "source_file" ? [
352
+ function J(e, t, s) {
353
+ return e.flatMap((n, c) => {
354
+ const r = `/${t}/${c}`, l = a.find((m) => m.name === n.processor);
355
+ return l ? l.target !== "source_file" ? [
298
356
  {
299
- path: l,
357
+ path: r,
300
358
  code: "rich_text_processor",
301
- message: `${m.name} is configured on a rich-text field, not on a Profile.`
359
+ message: `${l.name} is configured on a rich-text field, not on a Profile.`
302
360
  }
303
- ] : m.kind !== s ? [{ path: l, code: "wrong_processor_kind", message: `${m.name} does not run here.` }] : m.settingsSpec.filter(
304
- (d) => d.config.required && (n.settings[d.config.api_accessor] ?? "") === ""
305
- ).map((d) => ({
306
- path: `${l}/settings/${d.config.api_accessor}`,
361
+ ] : l.kind !== s ? [{ path: r, code: "wrong_processor_kind", message: `${l.name} does not run here.` }] : l.settingsSpec.filter(
362
+ (m) => m.config.required && (n.settings[m.config.api_accessor] ?? "") === ""
363
+ ).map((m) => ({
364
+ path: `${r}/settings/${m.config.api_accessor}`,
307
365
  code: "invalid_processor_settings",
308
- message: `${m.name}: ${d.config.api_accessor} is required.`
366
+ message: `${l.name}: ${m.config.api_accessor} is required.`
309
367
  })) : [
310
- { path: l, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
368
+ { path: r, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
311
369
  ];
312
370
  });
313
371
  }
314
- function L(e) {
315
- const t = i(), s = [
316
- ...U(e.preprocessors, "preprocessors", "preprocessor"),
317
- ...U(e.postProcessors, "postProcessors", "post_processor")
372
+ function q(e) {
373
+ const t = p(), s = [
374
+ ...J(e.preprocessors, "preprocessors", "preprocessor"),
375
+ ...J(e.postProcessors, "postProcessors", "post_processor")
318
376
  ];
319
- return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, o) => {
320
- const l = t.mappings.find((g) => g.id === n);
321
- if (!l) {
377
+ return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, c) => {
378
+ const r = t.mappings.find((f) => f.id === n);
379
+ if (!r) {
322
380
  s.push({
323
- path: `/mappingIds/${o}`,
381
+ path: `/mappingIds/${c}`,
324
382
  code: "mapping_missing",
325
383
  message: "It includes a Mapping that does not exist."
326
384
  });
327
385
  return;
328
386
  }
329
- const m = C(l.content);
330
- m.length > 0 && s.push({
331
- path: `/mappingIds/${o}`,
387
+ const l = N(r.content);
388
+ l.length > 0 && s.push({
389
+ path: `/mappingIds/${c}`,
332
390
  code: "mapping_invalid",
333
- message: `The Mapping ${l.content.name} is invalid: ${m.map((g) => g.message).join(" ")}`
391
+ message: `The Mapping ${r.content.name} is invalid: ${l.map((f) => f.message).join(" ")}`
334
392
  });
335
393
  }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
336
394
  path: "/entitySetId",
@@ -338,201 +396,241 @@ function de(r = {}) {
338
396
  message: "It names an Entity Set that does not exist."
339
397
  }), s;
340
398
  }
341
- const W = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], E = (e) => ({
399
+ const G = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], k = (e) => ({
342
400
  id: e.id,
343
401
  content: e.content,
344
- validity: y(L(e.content)),
345
- state: O(e)
346
- }), M = (e) => ({
402
+ validity: P(q(e.content)),
403
+ state: x(e)
404
+ }), O = (e) => ({
347
405
  id: e.id,
348
406
  content: e.content,
349
- validity: y(C(e.content)),
350
- state: O(e)
351
- }), $ = (e) => ({
407
+ validity: P(N(e.content)),
408
+ state: x(e)
409
+ }), B = (e) => ({
352
410
  id: e.id,
353
411
  content: e.content,
354
- validity: y(W(e.content)),
355
- state: O(e)
356
- }), k = (e) => B(i().importProfiles.filter((t) => e(t.content))).map((t) => ({
412
+ validity: P(G(e.content)),
413
+ state: x(e)
414
+ }), A = (e) => C(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
357
415
  id: t.id,
358
416
  name: t.content.name
359
- })), V = (e) => `${e}_stub_new_${++ae}`, S = (e) => {
360
- const t = i();
417
+ })), te = (e) => `${e}_stub_new_${++me}`, w = (e) => {
418
+ const t = p();
361
419
  switch (e) {
362
420
  case "importProfile":
363
421
  return {
364
422
  items: t.importProfiles,
365
423
  name: "Import Profile",
366
- reasons: (s) => L(s)
424
+ reasons: (s) => q(s)
367
425
  };
368
426
  case "mapping":
369
427
  return {
370
428
  items: t.mappings,
371
429
  name: "Mapping",
372
- reasons: (s) => C(s)
430
+ reasons: (s) => N(s)
373
431
  };
374
432
  case "entitySet":
375
433
  return {
376
434
  items: t.entitySets,
377
435
  name: "Entity Set",
378
- reasons: (s) => W(s)
436
+ reasons: (s) => G(s)
379
437
  };
380
438
  }
381
- }, h = (e, t) => {
382
- v(t).validity = y(S(e).reasons(t.content));
383
- }, x = (e, t) => {
439
+ }, _ = (e, t) => {
440
+ E(t).validity = P(w(e).reasons(t.content));
441
+ }, T = (e, t) => {
384
442
  const s = e.revisions.find((n) => n.id === t);
385
443
  if (!s) throw new Error(`Revision ${t} not found`);
386
444
  return s;
387
445
  };
388
446
  return {
389
- calls: w,
447
+ calls: I,
390
448
  switchWorkspace(e) {
391
- I = e;
449
+ b = e;
392
450
  },
393
- listImportProfiles: () => c("listImportProfiles", () => B(i().importProfiles).map(E)),
394
- getImportProfile: (e) => c("getImportProfile", () => E(u(i().importProfiles, e, "Import Profile"))),
395
- createImportProfile: (e) => c("createImportProfile", () => {
396
- _(i().importProfiles, e.name);
397
- const t = N("ip", e);
398
- return h("importProfile", t), i().importProfiles.push(t), E(t);
451
+ listImportProfiles: () => u("listImportProfiles", () => C(p().importProfiles).map(k)),
452
+ getImportProfile: (e) => u("getImportProfile", () => k(g(p().importProfiles, e, "Import Profile"))),
453
+ createImportProfile: (e) => u("createImportProfile", () => {
454
+ v(p().importProfiles, e.name);
455
+ const t = z("ip", e);
456
+ return _("importProfile", t), p().importProfiles.push(t), k(t);
399
457
  }),
400
- updateImportProfile: (e, t, s) => c("updateImportProfile", () => {
401
- const n = u(i().importProfiles, e, "Import Profile");
402
- return _(i().importProfiles, t.name, e), R(n, t, s), h("importProfile", n), E(n);
458
+ updateImportProfile: (e, t, s) => u("updateImportProfile", () => {
459
+ const n = g(p().importProfiles, e, "Import Profile");
460
+ return v(p().importProfiles, t.name, e), M(n, t, s), _("importProfile", n), k(n);
403
461
  }),
404
- deleteImportProfile: (e) => c("deleteImportProfile", () => {
405
- u(i().importProfiles, e, "Import Profile"), i().importProfiles = i().importProfiles.filter((t) => t.id !== e);
462
+ deleteImportProfile: (e) => u("deleteImportProfile", () => {
463
+ g(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
406
464
  }),
407
- listProcessors: () => c("listProcessors", () => [...p].sort((e, t) => e.name.localeCompare(t.name))),
408
- listMappings: () => c("listMappings", () => B(i().mappings).map(M)),
409
- getMapping: (e) => c("getMapping", () => M(u(i().mappings, e, "Mapping"))),
410
- createMapping: (e) => c("createMapping", () => {
411
- _(i().mappings, e.name);
412
- const t = N("mp", e);
413
- return h("mapping", t), i().mappings.push(t), M(t);
465
+ listProcessors: () => u("listProcessors", () => [...a].sort((e, t) => e.name.localeCompare(t.name))),
466
+ listMappings: () => u("listMappings", () => C(p().mappings).map(O)),
467
+ getMapping: (e) => u("getMapping", () => O(g(p().mappings, e, "Mapping"))),
468
+ createMapping: (e) => u("createMapping", () => {
469
+ v(p().mappings, e.name);
470
+ const t = z("mp", e);
471
+ return _("mapping", t), p().mappings.push(t), O(t);
414
472
  }),
415
- updateMapping: (e, t, s) => c("updateMapping", () => {
416
- const n = u(i().mappings, e, "Mapping");
417
- return _(i().mappings, t.name, e), R(n, t, s), h("mapping", n), M(n);
473
+ updateMapping: (e, t, s) => u("updateMapping", () => {
474
+ const n = g(p().mappings, e, "Mapping");
475
+ return v(p().mappings, t.name, e), M(n, t, s), _("mapping", n), O(n);
418
476
  }),
419
- deleteMapping: (e) => c("deleteMapping", () => {
420
- u(i().mappings, e, "Mapping");
421
- const t = k((s) => s.mappingIds.includes(e));
477
+ deleteMapping: (e) => u("deleteMapping", () => {
478
+ g(p().mappings, e, "Mapping");
479
+ const t = A((s) => s.mappingIds.includes(e));
422
480
  if (t.length > 0)
423
- throw new J(
481
+ throw new V(
424
482
  t,
425
483
  `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
426
484
  );
427
- i().mappings = i().mappings.filter((s) => s.id !== e);
485
+ p().mappings = p().mappings.filter((s) => s.id !== e);
428
486
  }),
429
- listMappingImportProfiles: (e) => c("listMappingImportProfiles", () => (u(i().mappings, e, "Mapping"), k((t) => t.mappingIds.includes(e)))),
430
- checkMappingBlueprintRelease: (e, t) => c("checkMappingBlueprintRelease", () => {
431
- const s = u(i().mappings, e, "Mapping"), n = f.find((o) => o.id === t);
487
+ listMappingImportProfiles: (e) => u("listMappingImportProfiles", () => (g(p().mappings, e, "Mapping"), A((t) => t.mappingIds.includes(e)))),
488
+ checkMappingBlueprintRelease: (e, t) => u("checkMappingBlueprintRelease", () => {
489
+ const s = g(p().mappings, e, "Mapping"), n = d.find((c) => c.id === t);
432
490
  if (!n) throw new Error(`Blueprint Release ${t} not found`);
433
491
  if (n.blueprintId !== s.content.blueprintId)
434
492
  throw new Error("the Release is of another Blueprint");
435
493
  return {
436
494
  blueprintId: n.blueprintId,
437
- missingFieldPaths: (s.content.fields ?? []).map((o) => String(o.name ?? "")).filter((o) => !n.fieldPaths.includes(o)),
438
- missingReleaseSpecFields: []
495
+ missingFieldPaths: (s.content.fields ?? []).flatMap((c, r) => L(c, "", `/fields/${r}`).map((l) => l.path)).filter((c) => !n.fieldPaths.includes(c)),
496
+ missingReleaseSpecFields: [
497
+ ...(s.content.releaseSpec ?? []).map((c) => c.field ?? ""),
498
+ ...s.content.versionMatch?.releaseSpecFields ?? []
499
+ ].filter(
500
+ (c, r, l) => c !== "" && l.indexOf(c) === r && !(n.releaseSpecFields ?? []).some((f) => f.path === c)
501
+ )
439
502
  };
440
503
  }),
441
- listEntitySets: () => c("listEntitySets", () => B(i().entitySets).map($)),
442
- getEntitySet: (e) => c("getEntitySet", () => $(u(i().entitySets, e, "Entity Set"))),
443
- createEntitySet: (e) => c("createEntitySet", () => {
444
- _(i().entitySets, e.name);
445
- const t = N("es", e);
446
- return h("entitySet", t), i().entitySets.push(t), $(t);
504
+ listEntitySets: () => u("listEntitySets", () => C(p().entitySets).map(B)),
505
+ getEntitySet: (e) => u("getEntitySet", () => B(g(p().entitySets, e, "Entity Set"))),
506
+ createEntitySet: (e) => u("createEntitySet", () => {
507
+ v(p().entitySets, e.name);
508
+ const t = z("es", e);
509
+ return _("entitySet", t), p().entitySets.push(t), B(t);
447
510
  }),
448
- updateEntitySet: (e, t, s) => c("updateEntitySet", () => {
449
- const n = u(i().entitySets, e, "Entity Set");
450
- return _(i().entitySets, t.name, e), R(n, t, s), h("entitySet", n), $(n);
511
+ updateEntitySet: (e, t, s) => u("updateEntitySet", () => {
512
+ const n = g(p().entitySets, e, "Entity Set");
513
+ return v(p().entitySets, t.name, e), M(n, t, s), _("entitySet", n), B(n);
451
514
  }),
452
- deleteEntitySet: (e) => c("deleteEntitySet", () => {
453
- u(i().entitySets, e, "Entity Set");
454
- const t = k((s) => s.entitySetId === e);
515
+ deleteEntitySet: (e) => u("deleteEntitySet", () => {
516
+ g(p().entitySets, e, "Entity Set");
517
+ const t = A((s) => s.entitySetId === e);
455
518
  if (t.length > 0)
456
- throw new J(
519
+ throw new V(
457
520
  t,
458
521
  `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
459
522
  );
460
- i().entitySets = i().entitySets.filter((s) => s.id !== e);
523
+ p().entitySets = p().entitySets.filter((s) => s.id !== e);
461
524
  }),
462
- cutRelease: (e, t, s) => c("cutRelease", () => {
463
- const n = S(e), o = u(n.items, t, n.name);
464
- if (H(o, s))
465
- throw new j("the draft moved: somebody saved in between");
466
- const l = y(n.reasons(o.content));
467
- if (!l.valid) throw new j("the draft is invalid", l);
468
- if (!O(o).draftDiffersFromRelease)
469
- throw new j(
525
+ cutRelease: (e, t, s) => u("cutRelease", () => {
526
+ const n = w(e), c = g(n.items, t, n.name);
527
+ if (W(c, s))
528
+ throw new K("the draft moved: somebody saved in between");
529
+ const r = P(n.reasons(c.content));
530
+ if (!r.valid) throw new K("the draft is invalid", r);
531
+ if (!x(c).draftDiffersFromRelease)
532
+ throw new K(
470
533
  "the draft does not differ from the latest Release: there is nothing to release"
471
534
  );
472
- const m = o.releases.length + 1, g = {
473
- id: `${o.id}_rel${m}`,
474
- number: m,
475
- revisionId: v(o).id,
476
- releasedBy: b,
477
- releasedAt: P()
535
+ const l = c.releases.length + 1, f = {
536
+ id: `${c.id}_rel${l}`,
537
+ number: l,
538
+ revisionId: E(c).id,
539
+ releasedBy: S,
540
+ releasedAt: R()
478
541
  };
479
- return o.releases.push(g), {
480
- release: g,
481
- importProfiles: e === "mapping" ? k((d) => d.mappingIds.includes(t)) : []
542
+ return c.releases.push(f), {
543
+ release: f,
544
+ importProfiles: e === "mapping" ? A((m) => m.mappingIds.includes(t)) : []
482
545
  };
483
546
  }),
484
- listHistory: (e, t, s) => c("listHistory", () => {
485
- const n = S(e), o = u(n.items, t, n.name), l = [...o.revisions].reverse(), m = Number(s || "0");
547
+ listHistory: (e, t, s) => u("listHistory", () => {
548
+ const n = w(e), c = g(n.items, t, n.name), r = [...c.revisions].reverse(), l = Number(s || "0");
486
549
  return {
487
- revisions: l.slice(m, m + 10).map((d) => ({
488
- id: d.id,
489
- savedBy: d.savedBy,
490
- savedAt: d.savedAt,
491
- validity: d.validity ?? y(n.reasons(d.content)),
492
- restoredFromRevisionId: d.restoredFromRevisionId
550
+ revisions: r.slice(l, l + 10).map((m) => ({
551
+ id: m.id,
552
+ savedBy: m.savedBy,
553
+ savedAt: m.savedAt,
554
+ validity: m.validity ?? P(n.reasons(m.content)),
555
+ restoredFromRevisionId: m.restoredFromRevisionId
493
556
  })),
494
- releases: [...o.releases].reverse(),
495
- nextPageToken: m + 10 < l.length ? String(m + 10) : ""
557
+ releases: [...c.releases].reverse(),
558
+ nextPageToken: l + 10 < r.length ? String(l + 10) : ""
496
559
  };
497
560
  }),
498
- compareRevisions: (e, t, s, n) => c("compareRevisions", () => {
499
- const o = S(e), l = u(o.items, t, o.name), m = G(x(l, s).content), g = G(x(l, n).content), d = [.../* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(g)])].map((z) => {
500
- const A = m[z], T = g[z], Q = A === void 0 && T !== void 0 ? "added" : A !== void 0 && T === void 0 ? "removed" : JSON.stringify(A) === JSON.stringify(T) ? "unchanged" : "changed";
501
- return { field: z, status: Q };
561
+ compareRevisions: (e, t, s, n) => u("compareRevisions", () => {
562
+ const c = w(e), r = g(c.items, t, c.name), l = Y(T(r, s).content), f = Y(T(r, n).content), m = [.../* @__PURE__ */ new Set([...Object.keys(l), ...Object.keys(f)])].map(($) => {
563
+ const y = l[$], j = f[$], se = y === void 0 && j !== void 0 ? "added" : y !== void 0 && j === void 0 ? "removed" : JSON.stringify(y) === JSON.stringify(j) ? "unchanged" : "changed";
564
+ return { field: $, status: se };
502
565
  });
503
566
  return {
504
- from: { revisionId: s, content: m },
505
- to: { revisionId: n, content: g },
506
- fields: d
567
+ from: { revisionId: s, content: l },
568
+ to: { revisionId: n, content: f },
569
+ fields: m
507
570
  };
508
571
  }),
509
- restoreRevision: (e, t, s, n) => c("restoreRevision", () => {
510
- const o = S(e), l = u(o.items, t, o.name);
511
- R(l, x(l, s).content, n, s), h(e, l);
572
+ restoreRevision: (e, t, s, n) => u("restoreRevision", () => {
573
+ const c = w(e), r = g(c.items, t, c.name);
574
+ M(r, T(r, s).content, n, s), _(e, r);
512
575
  })
513
576
  };
514
577
  }
515
- function ue(r = Z()) {
578
+ function ue(i) {
579
+ const o = [], a = { "]": "[", ")": "(" };
580
+ for (const d of i)
581
+ if (d === "[" || d === "(") o.push(d);
582
+ else if (d in a && o.pop() !== a[d]) return !1;
583
+ return o.length === 0;
584
+ }
585
+ function L(i, o, a) {
586
+ const d = `${o}${String(i.name ?? "")}`;
587
+ return [
588
+ { path: d, rel: a, mapping: i },
589
+ ...["fields", "virtualTableFields"].flatMap(
590
+ (b) => (Array.isArray(i[b]) ? i[b] : []).flatMap(
591
+ (I, p) => L(I, `${d}.`, `${a}/${b}/${p}`)
592
+ )
593
+ )
594
+ ];
595
+ }
596
+ function ye(i = ee()) {
516
597
  return {
517
598
  async listBlueprints() {
518
- return [...new Map(r.map((p) => [p.blueprintId, p.blueprintName]))].map(([p, f]) => ({ id: p, name: f })).sort((p, f) => p.name.localeCompare(f.name));
599
+ return [...new Map(i.map((a) => [a.blueprintId, a.blueprintName]))].map(([a, d]) => ({ id: a, name: d })).sort((a, d) => a.name.localeCompare(d.name));
600
+ },
601
+ async listReleases(o) {
602
+ return i.filter((a) => a.blueprintId === o).map((a) => ({ id: a.id, label: a.label }));
519
603
  },
520
- async listReleases(a) {
521
- return r.filter((p) => p.blueprintId === a).map((p) => ({ id: p.id, label: p.label }));
604
+ async getRelease(o) {
605
+ const a = i.find((d) => d.id === o);
606
+ if (!a) throw new Error(`Blueprint Release ${o} not found`);
607
+ return {
608
+ id: a.id,
609
+ blueprintId: a.blueprintId,
610
+ name: a.label,
611
+ fields: a.fields ?? a.fieldPaths.map((d) => ({
612
+ accessor: d,
613
+ path: d,
614
+ fieldType: "text",
615
+ label: "",
616
+ children: []
617
+ })),
618
+ releaseSpecFields: a.releaseSpecFields ?? []
619
+ };
522
620
  }
523
621
  };
524
622
  }
525
623
  export {
526
- ce as STUB_OTHER_WORKSPACE_ID,
527
- b as STUB_USER_ID,
528
- D as STUB_WORKSPACE_ID,
529
- ue as createStubBlueprints,
530
- de as createStubImporthubClient,
531
- Z as stubBlueprintReleases,
532
- te as stubEntitySets,
533
- me as stubIdentity,
534
- se as stubImportProfiles,
535
- ee as stubMappings,
536
- ne as stubProcessors
624
+ he as STUB_OTHER_WORKSPACE_ID,
625
+ S as STUB_USER_ID,
626
+ U as STUB_WORKSPACE_ID,
627
+ ye as createStubBlueprints,
628
+ _e as createStubImporthubClient,
629
+ ee as stubBlueprintReleases,
630
+ oe as stubEntitySets,
631
+ be as stubIdentity,
632
+ ae as stubImportProfiles,
633
+ re as stubMappings,
634
+ le as stubProcessors
537
635
  };
538
636
  //# sourceMappingURL=testing.js.map