@knkcs/importhub-ui 0.4.0 → 0.5.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,37 +1,38 @@
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) {
1
+ import { createHostMembers as he } from "@knkcs/anker/host";
2
+ import { S as k, R as Y, C as ce, N as be } from "./importhub-client-fCWgKH03.js";
3
+ const _ = "user_stub_ada", ee = "user_stub_grace", te = "ws_stub_main", Me = "ws_stub_other";
4
+ function ke(r = te) {
5
5
  return {
6
- userId: S,
7
- workspaceId: i,
8
- members: ne([
9
- { userId: S, displayName: "Ada Importer", email: "ada@example.com" }
6
+ userId: _,
7
+ workspaceId: r,
8
+ members: he([
9
+ { userId: _, displayName: "Ada Importer", email: "ada@example.com" },
10
+ { userId: ee, displayName: "Grace Hopper", email: "grace@example.com" }
10
11
  ])
11
12
  };
12
13
  }
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")
14
+ const b = (r, c, l, u = []) => ({
15
+ accessor: r.split(".").pop() ?? r,
16
+ path: r,
17
+ fieldType: c,
18
+ label: l,
19
+ children: u
20
+ }), K = (r) => r.flatMap((c) => [c.path, ...K(c.children)]), le = (r) => [
21
+ b("titel", "text", "Titel"),
22
+ b("abkuerzung", "text", "Abkürzung"),
23
+ ...r ? [b("fussnote", "rich_text", "Fußnote")] : [],
24
+ b("stand", "fieldset", "Stand", [
25
+ b("stand.datum", "date", "Datum"),
26
+ b("stand.art", "select", "Art")
26
27
  ])
27
- ], X = () => [
28
- h("fundstelle", "text", "Fundstelle"),
29
- h("ausgabedatum", "date", "Ausgabedatum")
28
+ ], pe = () => [
29
+ b("fundstelle", "text", "Fundstelle"),
30
+ b("ausgabedatum", "date", "Ausgabedatum")
30
31
  ];
31
- function ee() {
32
- const i = Z(!1), o = Z(!0), a = [
33
- h("aktenzeichen", "text", "Aktenzeichen"),
34
- h("datum", "date", "Datum")
32
+ function ue() {
33
+ const r = le(!1), c = le(!0), l = [
34
+ b("aktenzeichen", "text", "Aktenzeichen"),
35
+ b("datum", "date", "Datum")
35
36
  ];
36
37
  return [
37
38
  {
@@ -39,30 +40,30 @@ function ee() {
39
40
  blueprintId: "bp_stub_gesetz",
40
41
  blueprintName: "Gesetz",
41
42
  label: "Release 2",
42
- fieldPaths: F(i),
43
- fields: i,
44
- releaseSpecFields: X()
43
+ fieldPaths: K(r),
44
+ fields: r,
45
+ releaseSpecFields: pe()
45
46
  },
46
47
  {
47
48
  id: "br_stub_gesetz_1",
48
49
  blueprintId: "bp_stub_gesetz",
49
50
  blueprintName: "Gesetz",
50
51
  label: "Release 1",
51
- fieldPaths: F(o),
52
- fields: o,
53
- releaseSpecFields: X()
52
+ fieldPaths: K(c),
53
+ fields: c,
54
+ releaseSpecFields: pe()
54
55
  },
55
56
  {
56
57
  id: "br_stub_entscheidung_1",
57
58
  blueprintId: "bp_stub_entscheidung",
58
59
  blueprintName: "Entscheidung",
59
60
  label: "Release 1",
60
- fieldPaths: F(a),
61
- fields: a
61
+ fieldPaths: K(l),
62
+ fields: l
62
63
  }
63
64
  ];
64
65
  }
65
- function re() {
66
+ function _e() {
66
67
  return [
67
68
  {
68
69
  id: "mp_stub_norm",
@@ -94,7 +95,7 @@ function re() {
94
95
  }
95
96
  ];
96
97
  }
97
- function oe() {
98
+ function Ie() {
98
99
  return [
99
100
  {
100
101
  id: "es_stub_latin1",
@@ -107,7 +108,7 @@ function oe() {
107
108
  }
108
109
  ];
109
110
  }
110
- function ae() {
111
+ function ye() {
111
112
  return [
112
113
  {
113
114
  id: "ip_stub_gesetz",
@@ -138,12 +139,12 @@ function ae() {
138
139
  }
139
140
  ];
140
141
  }
141
- const D = (i, o, a, d = "") => ({
142
+ const Q = (r, c, l, u = "") => ({
142
143
  field_type: "text",
143
- config: { name: o, api_accessor: i, required: a, instructions: d },
144
+ config: { name: c, api_accessor: r, required: l, instructions: u },
144
145
  system: !1
145
146
  });
146
- function le() {
147
+ function Se() {
147
148
  return [
148
149
  {
149
150
  name: "citation-links",
@@ -165,8 +166,8 @@ function le() {
165
166
  target: "source_file",
166
167
  description: "Renames every element of one name to another.",
167
168
  settingsSpec: [
168
- D("from", "Element", !0, "The element's name now."),
169
- D("to", "New name", !0)
169
+ Q("from", "Element", !0, "The element's name now."),
170
+ Q("to", "New name", !0)
170
171
  ]
171
172
  },
172
173
  {
@@ -174,11 +175,153 @@ function le() {
174
175
  kind: "preprocessor",
175
176
  target: "source_file",
176
177
  description: "Wraps each sentence of an element in its own element.",
177
- settingsSpec: [D("element", "Element", !1)]
178
+ settingsSpec: [Q("element", "Element", !1)]
178
179
  }
179
180
  ];
180
181
  }
181
- const pe = [
182
+ const $ = (r = {}) => ({
183
+ matched: 0,
184
+ created: 0,
185
+ problems: 0,
186
+ planned: 0,
187
+ corrected: 0,
188
+ kept: 0,
189
+ unchanged: 0,
190
+ ...r
191
+ }), P = (r) => ({
192
+ importProfile: {
193
+ configurationId: "ip_stub_gesetz",
194
+ name: "Boorberg gesetz",
195
+ releaseId: `ip_stub_gesetz_rel${r}`,
196
+ number: r
197
+ },
198
+ mappings: [
199
+ {
200
+ configurationId: "mp_stub_norm",
201
+ name: "Gesetz norms",
202
+ releaseId: "mp_stub_norm_rel1",
203
+ number: 1
204
+ }
205
+ ],
206
+ entitySet: {
207
+ configurationId: "es_stub_latin1",
208
+ name: "ISO Latin 1",
209
+ releaseId: "es_stub_latin1_rel1",
210
+ number: 1
211
+ }
212
+ }), T = (r) => ({
213
+ importProfileId: "ip_stub_gesetz",
214
+ importProfileName: "Boorberg gesetz",
215
+ sourceFileId: `sf_${r.id}`,
216
+ startedBy: _,
217
+ phase: "ended",
218
+ failureReason: "",
219
+ progress: { done: 0, total: 0 },
220
+ counts: $(),
221
+ changeSetId: "",
222
+ releases: P(2),
223
+ createTime: "2026-11-03T09:00:00.000Z",
224
+ startTime: "",
225
+ endTime: "",
226
+ cancelledBy: "",
227
+ effectiveDate: "",
228
+ ...r
229
+ }), B = (r, c, l, u, h) => ({
230
+ id: `prob_stub_${r}`,
231
+ mappingId: c === "norm" ? "mp_stub_norm" : "mp_stub_title",
232
+ mappingName: c === "norm" ? "Gesetz norms" : "Gesetz titles",
233
+ sourceKey: l,
234
+ field: u,
235
+ reason: h
236
+ });
237
+ function Pe() {
238
+ return [
239
+ T({
240
+ id: "im_stub_running",
241
+ phase: "writing",
242
+ progress: { done: 48, total: 120 },
243
+ counts: $({ matched: 120, created: 40, planned: 8 }),
244
+ changeSetId: "cs_stub_running",
245
+ createTime: "2026-11-04T10:00:00.000Z",
246
+ startTime: "2026-11-04T10:00:05.000Z"
247
+ }),
248
+ T({
249
+ id: "im_stub_queued",
250
+ phase: "queued",
251
+ startedBy: ee,
252
+ releases: P(2),
253
+ createTime: "2026-11-04T10:05:00.000Z"
254
+ }),
255
+ T({
256
+ id: "im_stub_problems",
257
+ outcome: "succeeded_with_problems",
258
+ counts: $({
259
+ matched: 212,
260
+ created: 180,
261
+ planned: 20,
262
+ corrected: 6,
263
+ kept: 1,
264
+ problems: 5
265
+ }),
266
+ changeSetId: "cs_stub_problems",
267
+ releases: {
268
+ ...P(2),
269
+ mappings: [
270
+ ...P(2).mappings,
271
+ {
272
+ configurationId: "mp_stub_title",
273
+ name: "Gesetz titles",
274
+ releaseId: "mp_stub_title_rel3",
275
+ number: 3
276
+ }
277
+ ]
278
+ },
279
+ createTime: "2026-11-03T09:00:00.000Z",
280
+ startTime: "2026-11-03T09:00:02.000Z",
281
+ endTime: "2026-11-03T09:12:40.000Z",
282
+ effectiveDate: "2026-10-01",
283
+ source: { date: "2026-09-20", reference: "BGBl. 2026 I Nr. 270" },
284
+ itemProblems: [
285
+ B(1, "norm", "BJNR000010001", "stand/datum", "“31.02.2026” is not a date."),
286
+ B(2, "norm", "BJNR000010002", "", "The Version Match found two Releases."),
287
+ B(3, "title", "BJNR000020001", "", "No Title has the Ausgabe code BY-7."),
288
+ B(4, "norm", "BJNR000030001", "titel", "The field is required."),
289
+ B(5, "title", "BJNR000030002", "", "No Title has the Ausgabe code BY-9.")
290
+ ]
291
+ }),
292
+ T({
293
+ id: "im_stub_succeeded",
294
+ outcome: "succeeded",
295
+ counts: $({ matched: 64, created: 64 }),
296
+ changeSetId: "cs_stub_succeeded",
297
+ releases: P(1),
298
+ createTime: "2026-11-02T14:00:00.000Z",
299
+ startTime: "2026-11-02T14:00:01.000Z",
300
+ endTime: "2026-11-02T14:03:10.000Z"
301
+ }),
302
+ T({
303
+ id: "im_stub_failed",
304
+ outcome: "failed",
305
+ failureReason: "The worker crashed three times running this Import.",
306
+ counts: $({ matched: 30 }),
307
+ releases: P(1),
308
+ createTime: "2026-11-02T11:00:00.000Z",
309
+ startTime: "2026-11-02T11:00:01.000Z",
310
+ endTime: "2026-11-02T11:20:00.000Z"
311
+ }),
312
+ T({
313
+ id: "im_stub_cancelled",
314
+ outcome: "cancelled",
315
+ cancelledBy: ee,
316
+ counts: $({ matched: 12, created: 3 }),
317
+ releases: P(1),
318
+ createTime: "2026-11-01T16:00:00.000Z",
319
+ startTime: "2026-11-01T16:00:01.000Z",
320
+ endTime: "2026-11-01T16:01:00.000Z"
321
+ })
322
+ ];
323
+ }
324
+ const we = [
182
325
  "listImportProfiles",
183
326
  "getImportProfile",
184
327
  "createImportProfile",
@@ -200,82 +343,90 @@ const pe = [
200
343
  "cutRelease",
201
344
  "listHistory",
202
345
  "compareRevisions",
203
- "restoreRevision"
346
+ "restoreRevision",
347
+ "uploadSourceFile",
348
+ "startImport",
349
+ "listImports",
350
+ "getImport",
351
+ "cancelImport",
352
+ "listItemProblems"
204
353
  ];
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(),
354
+ let de = Date.parse("2026-11-02T08:00:00Z");
355
+ const w = () => (de += 36e5, new Date(de).toISOString()), X = (r = []) => r.map((c) => {
356
+ const l = Math.max(c.releaseNumber ?? 0, 1), u = Array.from({ length: l }, (I, p) => ({
357
+ id: `${c.id}_r${p + 1}`,
358
+ content: structuredClone(c.content),
359
+ savedBy: _,
360
+ savedAt: w(),
212
361
  restoredFromRevisionId: ""
213
- })), b = Array.from({ length: o.releaseNumber ?? 0 }, (I, p) => ({
214
- id: `${o.id}_rel${p + 1}`,
362
+ })), h = Array.from({ length: c.releaseNumber ?? 0 }, (I, p) => ({
363
+ id: `${c.id}_rel${p + 1}`,
215
364
  number: p + 1,
216
- revisionId: `${o.id}_r${p + 1}`,
217
- releasedBy: S,
218
- releasedAt: R()
365
+ revisionId: `${c.id}_r${p + 1}`,
366
+ releasedBy: _,
367
+ releasedAt: w()
219
368
  }));
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);
369
+ return { id: c.id, content: structuredClone(c.content), revisions: u, releases: h };
370
+ }), N = (r) => r.revisions[r.revisions.length - 1], fe = (r) => r.releases[r.releases.length - 1], D = (r) => {
371
+ const c = fe(r), l = r.revisions.find((u) => u.id === c?.revisionId);
223
372
  return {
224
- draftRevisionId: E(i).id,
373
+ draftRevisionId: N(r).id,
225
374
  // By content, as importhub compares: a draft that restored the
226
375
  // released content does not differ.
227
- draftDiffersFromRelease: !a || JSON.stringify(a.content) !== JSON.stringify(E(i).content),
228
- ...o ? { latestRelease: { id: o.id, number: o.number } } : {}
376
+ draftDiffersFromRelease: !l || JSON.stringify(l.content) !== JSON.stringify(N(r).content),
377
+ ...c ? { latestRelease: { id: c.id, number: c.number } } : {}
229
378
  };
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(
379
+ }, ve = (r) => r.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`), me = (r) => Object.fromEntries(
380
+ Object.entries(r).map(([c, l]) => [ve(c), l])
381
+ ), R = (r) => ({
382
+ valid: r.length === 0,
383
+ reasons: r
384
+ }), j = (r) => [...r].sort((c, l) => c.content.name.localeCompare(l.content.name));
385
+ let Te = 0;
386
+ function Be(r = {}) {
387
+ const c = Object.fromEntries(
239
388
  Object.entries(
240
- i.workspaces ?? {
241
- [U]: {
242
- importProfiles: ae(),
243
- mappings: re(),
244
- entitySets: oe()
389
+ r.workspaces ?? {
390
+ [te]: {
391
+ importProfiles: ye(),
392
+ mappings: _e(),
393
+ entitySets: Ie(),
394
+ imports: Pe()
245
395
  }
246
396
  }
247
397
  ).map(([e, t]) => [
248
398
  e,
249
399
  {
250
- importProfiles: H(t.importProfiles),
251
- mappings: H(t.mappings),
252
- entitySets: H(t.entitySets)
400
+ importProfiles: X(t.importProfiles),
401
+ mappings: X(t.mappings),
402
+ entitySets: X(t.entitySets),
403
+ imports: structuredClone(t.imports ?? [])
253
404
  }
254
405
  ])
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;
406
+ ), l = r.processors ?? Se(), u = r.blueprintReleases ?? ue();
407
+ let h = r.activeWorkspaceId ?? te;
408
+ const I = Object.fromEntries(we.map((e) => [e, 0])), p = () => (c[h] ??= { importProfiles: [], mappings: [], entitySets: [], imports: [] }, c[h]), f = async (e, t) => {
409
+ if (I[e]++, r.fail) throw r.fail;
259
410
  return structuredClone(t());
260
411
  }, g = (e, t, s) => {
261
- const n = e.find((c) => c.id === t);
412
+ const n = e.find((a) => a.id === t);
262
413
  if (!n) throw new Error(`${s} ${t} not found`);
263
414
  return n;
264
415
  }, v = (e, t, s) => {
265
416
  if (!t.trim()) throw new Error("a name is required");
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))
417
+ if (e.some((n) => n.id !== s && n.content.name === t)) throw new be();
418
+ }, ne = (e, t) => t !== "" && t !== N(e).id, O = (e, t, s, n = "") => {
419
+ if (ne(e, s))
269
420
  throw new Error("the draft moved: somebody saved in between");
270
421
  e.content = structuredClone(t), e.revisions.push({
271
422
  id: `${e.id}_r${e.revisions.length + 1}`,
272
423
  content: structuredClone(t),
273
- savedBy: S,
274
- savedAt: R(),
424
+ savedBy: _,
425
+ savedAt: w(),
275
426
  restoredFromRevisionId: n
276
427
  });
277
- }, z = (e, t) => {
278
- const s = te(e);
428
+ }, q = (e, t) => {
429
+ const s = H(e);
279
430
  return {
280
431
  id: s,
281
432
  content: structuredClone(t),
@@ -283,16 +434,16 @@ function _e(i = {}) {
283
434
  {
284
435
  id: `${s}_r1`,
285
436
  content: structuredClone(t),
286
- savedBy: S,
287
- savedAt: R(),
437
+ savedBy: _,
438
+ savedAt: w(),
288
439
  restoredFromRevisionId: ""
289
440
  }
290
441
  ],
291
442
  releases: []
292
443
  };
293
444
  };
294
- function N(e) {
295
- const t = [], s = d.find((r) => r.id === e.blueprintReleaseId);
445
+ function G(e) {
446
+ const t = [], s = u.find((o) => o.id === e.blueprintReleaseId);
296
447
  e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
297
448
  path: "/blueprintReleaseId",
298
449
  code: "release_of_other_blueprint",
@@ -310,85 +461,85 @@ function _e(i = {}) {
310
461
  code: "no_element_selector",
311
462
  message: "It has no element selector."
312
463
  }), !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.` });
464
+ const n = (o, i) => {
465
+ typeof i == "string" && i !== "" && !Re(i) && t.push({ path: o, code: "invalid_xpath", message: `"${i}" is not an XPath.` });
315
466
  };
316
467
  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,
468
+ const a = [];
469
+ return (e.fields ?? []).forEach((o, i) => {
470
+ const m = `/fields/${i}`;
471
+ for (const { path: d, rel: M, mapping: S } of se(o, "", m))
472
+ a.push(d), n(`${M}/selector`, S.selector), s && !s.fieldPaths.includes(d) && t.push({
473
+ path: m,
323
474
  code: "unknown_field_path",
324
- message: `The pinned Release has no field ${m}.`
325
- }), y.type === "select" && !y.selectOptions && t.push({
326
- path: f,
475
+ message: `The pinned Release has no field ${d}.`
476
+ }), S.type === "select" && !S.selectOptions && t.push({
477
+ path: m,
327
478
  code: "xmlmapper_schema",
328
- message: `The select field ${m} has no select options.`
479
+ message: `The select field ${d} has no select options.`
329
480
  });
330
- }), (e.versionMatch?.contentFields ?? []).forEach((r, l) => {
331
- c.includes(r) || t.push({
332
- path: `/version_match/content_fields/${l}`,
481
+ }), (e.versionMatch?.contentFields ?? []).forEach((o, i) => {
482
+ a.includes(o) || t.push({
483
+ path: `/version_match/content_fields/${i}`,
333
484
  code: "unknown_version_match_field",
334
- message: `The Version Match compares ${r}, which the Mapping does not map.`
485
+ message: `The Version Match compares ${o}, which the Mapping does not map.`
335
486
  });
336
- }), (e.titleContributions ?? []).forEach((r, l) => {
337
- (!r.selector || !r.ausgabeCodeSelector) && t.push({
338
- path: `/title_contributions/${l}`,
487
+ }), (e.titleContributions ?? []).forEach((o, i) => {
488
+ (!o.selector || !o.ausgabeCodeSelector) && t.push({
489
+ path: `/title_contributions/${i}`,
339
490
  code: "incomplete_title_contribution",
340
491
  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}`,
492
+ }), n(`/title_contributions/${i}/selector`, o.selector);
493
+ }), (e.placeholderAssets ?? []).forEach((o, i) => {
494
+ (!o.selector || !o.assetType || !o.keyParts?.length || !o.nameSelector) && t.push({
495
+ path: `/placeholder_assets/${i}`,
345
496
  code: "incomplete_placeholder_assets",
346
497
  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);
498
+ }), n(`/placeholder_assets/${i}/selector`, o.selector), (o.keyParts ?? []).forEach((m, d) => {
499
+ n(`/placeholder_assets/${i}/key_parts/${d}`, m);
349
500
  });
350
501
  }), t;
351
502
  }
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" ? [
503
+ function re(e, t, s) {
504
+ return e.flatMap((n, a) => {
505
+ const o = `/${t}/${a}`, i = l.find((d) => d.name === n.processor);
506
+ return i ? i.target !== "source_file" ? [
356
507
  {
357
- path: r,
508
+ path: o,
358
509
  code: "rich_text_processor",
359
- message: `${l.name} is configured on a rich-text field, not on a Profile.`
510
+ message: `${i.name} is configured on a rich-text field, not on a Profile.`
360
511
  }
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}`,
512
+ ] : i.kind !== s ? [{ path: o, code: "wrong_processor_kind", message: `${i.name} does not run here.` }] : i.settingsSpec.filter(
513
+ (d) => d.config.required && (n.settings[d.config.api_accessor] ?? "") === ""
514
+ ).map((d) => ({
515
+ path: `${o}/settings/${d.config.api_accessor}`,
365
516
  code: "invalid_processor_settings",
366
- message: `${l.name}: ${m.config.api_accessor} is required.`
517
+ message: `${i.name}: ${d.config.api_accessor} is required.`
367
518
  })) : [
368
- { path: r, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
519
+ { path: o, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
369
520
  ];
370
521
  });
371
522
  }
372
- function q(e) {
523
+ function J(e) {
373
524
  const t = p(), s = [
374
- ...J(e.preprocessors, "preprocessors", "preprocessor"),
375
- ...J(e.postProcessors, "postProcessors", "post_processor")
525
+ ...re(e.preprocessors, "preprocessors", "preprocessor"),
526
+ ...re(e.postProcessors, "postProcessors", "post_processor")
376
527
  ];
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) {
528
+ return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, a) => {
529
+ const o = t.mappings.find((m) => m.id === n);
530
+ if (!o) {
380
531
  s.push({
381
- path: `/mappingIds/${c}`,
532
+ path: `/mappingIds/${a}`,
382
533
  code: "mapping_missing",
383
534
  message: "It includes a Mapping that does not exist."
384
535
  });
385
536
  return;
386
537
  }
387
- const l = N(r.content);
388
- l.length > 0 && s.push({
389
- path: `/mappingIds/${c}`,
538
+ const i = G(o.content);
539
+ i.length > 0 && s.push({
540
+ path: `/mappingIds/${a}`,
390
541
  code: "mapping_invalid",
391
- message: `The Mapping ${r.content.name} is invalid: ${l.map((f) => f.message).join(" ")}`
542
+ message: `The Mapping ${o.content.name} is invalid: ${i.map((m) => m.message).join(" ")}`
392
543
  });
393
544
  }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
394
545
  path: "/entitySetId",
@@ -396,241 +547,368 @@ function _e(i = {}) {
396
547
  message: "It names an Entity Set that does not exist."
397
548
  }), s;
398
549
  }
399
- const G = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], k = (e) => ({
550
+ const oe = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], F = (e) => ({
400
551
  id: e.id,
401
552
  content: e.content,
402
- validity: P(q(e.content)),
403
- state: x(e)
404
- }), O = (e) => ({
553
+ validity: R(J(e.content)),
554
+ state: D(e)
555
+ }), z = (e) => ({
405
556
  id: e.id,
406
557
  content: e.content,
407
- validity: P(N(e.content)),
408
- state: x(e)
409
- }), B = (e) => ({
558
+ validity: R(G(e.content)),
559
+ state: D(e)
560
+ }), C = (e) => ({
410
561
  id: e.id,
411
562
  content: e.content,
412
- validity: P(G(e.content)),
413
- state: x(e)
414
- }), A = (e) => C(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
563
+ validity: R(oe(e.content)),
564
+ state: D(e)
565
+ }), A = (e) => j(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
415
566
  id: t.id,
416
567
  name: t.content.name
417
- })), te = (e) => `${e}_stub_new_${++me}`, w = (e) => {
568
+ })), H = (e) => `${e}_stub_new_${++Te}`, E = (e) => {
418
569
  const t = p();
419
570
  switch (e) {
420
571
  case "importProfile":
421
572
  return {
422
573
  items: t.importProfiles,
423
574
  name: "Import Profile",
424
- reasons: (s) => q(s)
575
+ reasons: (s) => J(s)
425
576
  };
426
577
  case "mapping":
427
578
  return {
428
579
  items: t.mappings,
429
580
  name: "Mapping",
430
- reasons: (s) => N(s)
581
+ reasons: (s) => G(s)
431
582
  };
432
583
  case "entitySet":
433
584
  return {
434
585
  items: t.entitySets,
435
586
  name: "Entity Set",
436
- reasons: (s) => G(s)
587
+ reasons: (s) => oe(s)
437
588
  };
438
589
  }
439
- }, _ = (e, t) => {
440
- E(t).validity = P(w(e).reasons(t.content));
441
- }, T = (e, t) => {
590
+ }, y = (e, t) => {
591
+ N(t).validity = R(E(e).reasons(t.content));
592
+ }, L = (e, t) => {
442
593
  const s = e.revisions.find((n) => n.id === t);
443
594
  if (!s) throw new Error(`Revision ${t} not found`);
444
595
  return s;
596
+ }, ie = /* @__PURE__ */ new Set(), ae = r.contenthubRights ?? ["editor", "publisher"], x = (e) => {
597
+ const t = p().imports.find((s) => s.id === e);
598
+ if (!t) throw new Error(`Import ${e} not found`);
599
+ return t;
600
+ }, U = (e) => {
601
+ e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = w());
602
+ }, Z = ({ itemProblems: e, ...t }) => t, W = (e, t) => {
603
+ const s = fe(e);
604
+ if (!s)
605
+ throw new k(`the ${t} ${e.content.name} has no Release yet`);
606
+ const n = e.revisions.find((a) => a.id === s.revisionId)?.content ?? e.content;
607
+ return {
608
+ content: n,
609
+ ref: {
610
+ configurationId: e.id,
611
+ name: n.name,
612
+ releaseId: s.id,
613
+ number: s.number
614
+ }
615
+ };
445
616
  };
446
617
  return {
447
618
  calls: I,
448
619
  switchWorkspace(e) {
449
- b = e;
620
+ h = e;
621
+ },
622
+ updateImport(e, t) {
623
+ Object.assign(x(e), structuredClone(t));
450
624
  },
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", () => {
625
+ listImportProfiles: () => f("listImportProfiles", () => j(p().importProfiles).map(F)),
626
+ getImportProfile: (e) => f("getImportProfile", () => F(g(p().importProfiles, e, "Import Profile"))),
627
+ createImportProfile: (e) => f("createImportProfile", () => {
454
628
  v(p().importProfiles, e.name);
455
- const t = z("ip", e);
456
- return _("importProfile", t), p().importProfiles.push(t), k(t);
629
+ const t = q("ip", e);
630
+ return y("importProfile", t), p().importProfiles.push(t), F(t);
457
631
  }),
458
- updateImportProfile: (e, t, s) => u("updateImportProfile", () => {
632
+ updateImportProfile: (e, t, s) => f("updateImportProfile", () => {
459
633
  const n = g(p().importProfiles, e, "Import Profile");
460
- return v(p().importProfiles, t.name, e), M(n, t, s), _("importProfile", n), k(n);
634
+ return v(p().importProfiles, t.name, e), O(n, t, s), y("importProfile", n), F(n);
461
635
  }),
462
- deleteImportProfile: (e) => u("deleteImportProfile", () => {
636
+ deleteImportProfile: (e) => f("deleteImportProfile", () => {
463
637
  g(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
464
638
  }),
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", () => {
639
+ listProcessors: () => f("listProcessors", () => [...l].sort((e, t) => e.name.localeCompare(t.name))),
640
+ listMappings: () => f("listMappings", () => j(p().mappings).map(z)),
641
+ getMapping: (e) => f("getMapping", () => z(g(p().mappings, e, "Mapping"))),
642
+ createMapping: (e) => f("createMapping", () => {
469
643
  v(p().mappings, e.name);
470
- const t = z("mp", e);
471
- return _("mapping", t), p().mappings.push(t), O(t);
644
+ const t = q("mp", e);
645
+ return y("mapping", t), p().mappings.push(t), z(t);
472
646
  }),
473
- updateMapping: (e, t, s) => u("updateMapping", () => {
647
+ updateMapping: (e, t, s) => f("updateMapping", () => {
474
648
  const n = g(p().mappings, e, "Mapping");
475
- return v(p().mappings, t.name, e), M(n, t, s), _("mapping", n), O(n);
649
+ return v(p().mappings, t.name, e), O(n, t, s), y("mapping", n), z(n);
476
650
  }),
477
- deleteMapping: (e) => u("deleteMapping", () => {
651
+ deleteMapping: (e) => f("deleteMapping", () => {
478
652
  g(p().mappings, e, "Mapping");
479
653
  const t = A((s) => s.mappingIds.includes(e));
480
654
  if (t.length > 0)
481
- throw new V(
655
+ throw new ce(
482
656
  t,
483
657
  `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
484
658
  );
485
659
  p().mappings = p().mappings.filter((s) => s.id !== e);
486
660
  }),
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);
661
+ listMappingImportProfiles: (e) => f("listMappingImportProfiles", () => (g(p().mappings, e, "Mapping"), A((t) => t.mappingIds.includes(e)))),
662
+ checkMappingBlueprintRelease: (e, t) => f("checkMappingBlueprintRelease", () => {
663
+ const s = g(p().mappings, e, "Mapping"), n = u.find((a) => a.id === t);
490
664
  if (!n) throw new Error(`Blueprint Release ${t} not found`);
491
665
  if (n.blueprintId !== s.content.blueprintId)
492
666
  throw new Error("the Release is of another Blueprint");
493
667
  return {
494
668
  blueprintId: n.blueprintId,
495
- missingFieldPaths: (s.content.fields ?? []).flatMap((c, r) => L(c, "", `/fields/${r}`).map((l) => l.path)).filter((c) => !n.fieldPaths.includes(c)),
669
+ missingFieldPaths: (s.content.fields ?? []).flatMap((a, o) => se(a, "", `/fields/${o}`).map((i) => i.path)).filter((a) => !n.fieldPaths.includes(a)),
496
670
  missingReleaseSpecFields: [
497
- ...(s.content.releaseSpec ?? []).map((c) => c.field ?? ""),
671
+ ...(s.content.releaseSpec ?? []).map((a) => a.field ?? ""),
498
672
  ...s.content.versionMatch?.releaseSpecFields ?? []
499
673
  ].filter(
500
- (c, r, l) => c !== "" && l.indexOf(c) === r && !(n.releaseSpecFields ?? []).some((f) => f.path === c)
674
+ (a, o, i) => a !== "" && i.indexOf(a) === o && !(n.releaseSpecFields ?? []).some((m) => m.path === a)
501
675
  )
502
676
  };
503
677
  }),
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", () => {
678
+ listEntitySets: () => f("listEntitySets", () => j(p().entitySets).map(C)),
679
+ getEntitySet: (e) => f("getEntitySet", () => C(g(p().entitySets, e, "Entity Set"))),
680
+ createEntitySet: (e) => f("createEntitySet", () => {
507
681
  v(p().entitySets, e.name);
508
- const t = z("es", e);
509
- return _("entitySet", t), p().entitySets.push(t), B(t);
682
+ const t = q("es", e);
683
+ return y("entitySet", t), p().entitySets.push(t), C(t);
510
684
  }),
511
- updateEntitySet: (e, t, s) => u("updateEntitySet", () => {
685
+ updateEntitySet: (e, t, s) => f("updateEntitySet", () => {
512
686
  const n = g(p().entitySets, e, "Entity Set");
513
- return v(p().entitySets, t.name, e), M(n, t, s), _("entitySet", n), B(n);
687
+ return v(p().entitySets, t.name, e), O(n, t, s), y("entitySet", n), C(n);
514
688
  }),
515
- deleteEntitySet: (e) => u("deleteEntitySet", () => {
689
+ deleteEntitySet: (e) => f("deleteEntitySet", () => {
516
690
  g(p().entitySets, e, "Entity Set");
517
691
  const t = A((s) => s.entitySetId === e);
518
692
  if (t.length > 0)
519
- throw new V(
693
+ throw new ce(
520
694
  t,
521
695
  `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
522
696
  );
523
697
  p().entitySets = p().entitySets.filter((s) => s.id !== e);
524
698
  }),
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(
699
+ cutRelease: (e, t, s) => f("cutRelease", () => {
700
+ const n = E(e), a = g(n.items, t, n.name);
701
+ if (ne(a, s))
702
+ throw new Y("the draft moved: somebody saved in between");
703
+ const o = R(n.reasons(a.content));
704
+ if (!o.valid) throw new Y("the draft is invalid", o);
705
+ if (!D(a).draftDiffersFromRelease)
706
+ throw new Y(
533
707
  "the draft does not differ from the latest Release: there is nothing to release"
534
708
  );
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()
709
+ const i = a.releases.length + 1, m = {
710
+ id: `${a.id}_rel${i}`,
711
+ number: i,
712
+ revisionId: N(a).id,
713
+ releasedBy: _,
714
+ releasedAt: w()
541
715
  };
542
- return c.releases.push(f), {
543
- release: f,
544
- importProfiles: e === "mapping" ? A((m) => m.mappingIds.includes(t)) : []
716
+ return a.releases.push(m), {
717
+ release: m,
718
+ importProfiles: e === "mapping" ? A((d) => d.mappingIds.includes(t)) : []
545
719
  };
546
720
  }),
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");
721
+ listHistory: (e, t, s) => f("listHistory", () => {
722
+ const n = E(e), a = g(n.items, t, n.name), o = [...a.revisions].reverse(), i = Number(s || "0");
549
723
  return {
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
724
+ revisions: o.slice(i, i + 10).map((d) => ({
725
+ id: d.id,
726
+ savedBy: d.savedBy,
727
+ savedAt: d.savedAt,
728
+ validity: d.validity ?? R(n.reasons(d.content)),
729
+ restoredFromRevisionId: d.restoredFromRevisionId
556
730
  })),
557
- releases: [...c.releases].reverse(),
558
- nextPageToken: l + 10 < r.length ? String(l + 10) : ""
731
+ releases: [...a.releases].reverse(),
732
+ nextPageToken: i + 10 < o.length ? String(i + 10) : ""
559
733
  };
560
734
  }),
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 };
735
+ compareRevisions: (e, t, s, n) => f("compareRevisions", () => {
736
+ const a = E(e), o = g(a.items, t, a.name), i = me(L(o, s).content), m = me(L(o, n).content), d = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(m)])].map((M) => {
737
+ const S = i[M], V = m[M], ge = S === void 0 && V !== void 0 ? "added" : S !== void 0 && V === void 0 ? "removed" : JSON.stringify(S) === JSON.stringify(V) ? "unchanged" : "changed";
738
+ return { field: M, status: ge };
565
739
  });
566
740
  return {
567
- from: { revisionId: s, content: l },
568
- to: { revisionId: n, content: f },
569
- fields: m
741
+ from: { revisionId: s, content: i },
742
+ to: { revisionId: n, content: m },
743
+ fields: d
744
+ };
745
+ }),
746
+ restoreRevision: (e, t, s, n) => f("restoreRevision", () => {
747
+ const a = E(e), o = g(a.items, t, a.name);
748
+ O(o, L(o, s).content, n, s), y(e, o);
749
+ }),
750
+ async uploadSourceFile(e, t) {
751
+ if (I.uploadSourceFile++, r.fail) throw r.fail;
752
+ for (const n of [0.25, 0.5, 0.75])
753
+ await new Promise((a) => setTimeout(a, 20)), t(n);
754
+ if (r.uploadFails) throw r.uploadFails;
755
+ t(1);
756
+ const s = H("sf");
757
+ return ie.add(s), { id: s, fileName: e.name };
758
+ },
759
+ startImport: (e) => f("startImport", () => {
760
+ const t = p(), s = g(t.importProfiles, e.importProfileId, "Import Profile");
761
+ if (!ie.has(e.sourceFileId))
762
+ throw new k("nothing was uploaded to the Source File");
763
+ if (!ae.includes("editor"))
764
+ throw new k(
765
+ "starting an Import needs contenthub editor in the workspace"
766
+ );
767
+ const n = W(s, "Import Profile");
768
+ if (n.content.autoPublish && !ae.includes("publisher"))
769
+ throw new k(
770
+ "the Import Profile has Auto-publish, which needs contenthub publisher"
771
+ );
772
+ const a = J(n.content);
773
+ if (a.length > 0)
774
+ throw new k(
775
+ `the Import Profile ${n.ref.name} is invalid: ${a.map((d) => d.message).join(" ")}`
776
+ );
777
+ const o = n.content.mappingIds.map(
778
+ (d) => W(g(t.mappings, d, "Mapping"), "Mapping").ref
779
+ ), i = n.content.entitySetId ? W(g(t.entitySets, n.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, m = {
780
+ id: H("im"),
781
+ importProfileId: s.id,
782
+ importProfileName: n.ref.name,
783
+ sourceFileId: e.sourceFileId,
784
+ startedBy: _,
785
+ phase: "queued",
786
+ failureReason: "",
787
+ progress: { done: 0, total: 0 },
788
+ counts: {
789
+ matched: 0,
790
+ created: 0,
791
+ problems: 0,
792
+ planned: 0,
793
+ corrected: 0,
794
+ kept: 0,
795
+ unchanged: 0
796
+ },
797
+ changeSetId: "",
798
+ releases: {
799
+ importProfile: n.ref,
800
+ mappings: o,
801
+ ...i ? { entitySet: i } : {}
802
+ },
803
+ createTime: w(),
804
+ startTime: "",
805
+ endTime: "",
806
+ cancelledBy: "",
807
+ effectiveDate: e.effectiveDate ?? "",
808
+ ...e.source ? { source: e.source } : {},
809
+ itemProblems: []
810
+ };
811
+ return t.imports.unshift(m), Z(m);
812
+ }),
813
+ listImports: (e) => f("listImports", () => {
814
+ const t = p().imports;
815
+ t.forEach(U);
816
+ const s = Number(e || "0");
817
+ return {
818
+ imports: t.slice(s, s + 50).map(Z),
819
+ nextPageToken: s + 50 < t.length ? String(s + 50) : ""
570
820
  };
571
821
  }),
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);
822
+ getImport: (e) => f("getImport", () => {
823
+ const t = x(e);
824
+ return U(t), Z(t);
825
+ }),
826
+ cancelImport: (e) => f("cancelImport", () => {
827
+ const t = x(e);
828
+ if (t.phase === "ended") throw new Error("the Import has ended");
829
+ return t.cancelledBy ||= _, t.phase === "queued" && U(t), Z(t);
830
+ }),
831
+ listItemProblems: (e, t) => f("listItemProblems", () => {
832
+ const s = x(e).itemProblems ?? [], n = t.sourceKeyQuery.toLowerCase(), a = s.filter(
833
+ (m) => (!t.mappingId || m.mappingId === t.mappingId) && m.sourceKey.toLowerCase().includes(n)
834
+ ), o = /* @__PURE__ */ new Map();
835
+ for (const m of s) {
836
+ const d = o.get(m.mappingId) ?? {
837
+ mappingId: m.mappingId,
838
+ mappingName: m.mappingName,
839
+ count: 0
840
+ };
841
+ d.count++, o.set(m.mappingId, d);
842
+ }
843
+ const i = Number(t.pageToken || "0");
844
+ return {
845
+ itemProblems: a.slice(i, i + 50),
846
+ totalCount: s.length,
847
+ matchingCount: a.length,
848
+ mappings: [...o.values()].sort((m, d) => m.mappingName.localeCompare(d.mappingName)),
849
+ nextPageToken: i + 50 < a.length ? String(i + 50) : ""
850
+ };
575
851
  })
576
852
  };
577
853
  }
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;
854
+ function Re(r) {
855
+ const c = [], l = { "]": "[", ")": "(" };
856
+ for (const u of r)
857
+ if (u === "[" || u === "(") c.push(u);
858
+ else if (u in l && c.pop() !== l[u]) return !1;
859
+ return c.length === 0;
584
860
  }
585
- function L(i, o, a) {
586
- const d = `${o}${String(i.name ?? "")}`;
861
+ function se(r, c, l) {
862
+ const u = `${c}${String(r.name ?? "")}`;
587
863
  return [
588
- { path: d, rel: a, mapping: i },
864
+ { path: u, rel: l, mapping: r },
589
865
  ...["fields", "virtualTableFields"].flatMap(
590
- (b) => (Array.isArray(i[b]) ? i[b] : []).flatMap(
591
- (I, p) => L(I, `${d}.`, `${a}/${b}/${p}`)
866
+ (h) => (Array.isArray(r[h]) ? r[h] : []).flatMap(
867
+ (I, p) => se(I, `${u}.`, `${l}/${h}/${p}`)
592
868
  )
593
869
  )
594
870
  ];
595
871
  }
596
- function ye(i = ee()) {
872
+ function Ne(r = ue()) {
597
873
  return {
598
874
  async listBlueprints() {
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));
875
+ return [...new Map(r.map((l) => [l.blueprintId, l.blueprintName]))].map(([l, u]) => ({ id: l, name: u })).sort((l, u) => l.name.localeCompare(u.name));
600
876
  },
601
- async listReleases(o) {
602
- return i.filter((a) => a.blueprintId === o).map((a) => ({ id: a.id, label: a.label }));
877
+ async listReleases(c) {
878
+ return r.filter((l) => l.blueprintId === c).map((l) => ({ id: l.id, label: l.label }));
603
879
  },
604
- async getRelease(o) {
605
- const a = i.find((d) => d.id === o);
606
- if (!a) throw new Error(`Blueprint Release ${o} not found`);
880
+ async getRelease(c) {
881
+ const l = r.find((u) => u.id === c);
882
+ if (!l) throw new Error(`Blueprint Release ${c} not found`);
607
883
  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,
884
+ id: l.id,
885
+ blueprintId: l.blueprintId,
886
+ name: l.label,
887
+ fields: l.fields ?? l.fieldPaths.map((u) => ({
888
+ accessor: u,
889
+ path: u,
614
890
  fieldType: "text",
615
891
  label: "",
616
892
  children: []
617
893
  })),
618
- releaseSpecFields: a.releaseSpecFields ?? []
894
+ releaseSpecFields: l.releaseSpecFields ?? []
619
895
  };
620
896
  }
621
897
  };
622
898
  }
623
899
  export {
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
900
+ ee as STUB_OTHER_USER_ID,
901
+ Me as STUB_OTHER_WORKSPACE_ID,
902
+ _ as STUB_USER_ID,
903
+ te as STUB_WORKSPACE_ID,
904
+ Ne as createStubBlueprints,
905
+ Be as createStubImporthubClient,
906
+ ue as stubBlueprintReleases,
907
+ Ie as stubEntitySets,
908
+ ke as stubIdentity,
909
+ ye as stubImportProfiles,
910
+ Pe as stubImports,
911
+ _e as stubMappings,
912
+ Se as stubProcessors
635
913
  };
636
914
  //# sourceMappingURL=testing.js.map