@knkcs/importhub-ui 0.9.0 → 0.11.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,38 +1,38 @@
1
- import { createHostMembers as Se } from "@knkcs/anker/host";
2
- import { M as O, A as pe, S as B, R as ee, C as ce, N as we } from "./importhub-client-Wrb4s3lw.js";
3
- import { p as Pe } from "./field-tree-CghMgGKm.js";
4
- const b = "user_stub_ada", H = "user_stub_grace", ne = "ws_stub_main", De = "ws_stub_other";
5
- function Ze(n = ne) {
1
+ import { createHostMembers as Re } from "@knkcs/anker/host";
2
+ import { M as z, A as de, S as D, R as se, C as me, N as Te } from "./importhub-client-BzOVIXA4.js";
3
+ import { p as ve } from "./field-tree-CghMgGKm.js";
4
+ const y = "user_stub_ada", U = "user_stub_grace", oe = "ws_stub_main", Ge = "ws_stub_other";
5
+ function Le(s = oe) {
6
6
  return {
7
- userId: b,
8
- workspaceId: n,
9
- members: Se([
10
- { userId: b, displayName: "Ada Importer", email: "ada@example.com" },
11
- { userId: H, displayName: "Grace Hopper", email: "grace@example.com" }
7
+ userId: y,
8
+ workspaceId: s,
9
+ members: Re([
10
+ { userId: y, displayName: "Ada Importer", email: "ada@example.com" },
11
+ { userId: U, displayName: "Grace Hopper", email: "grace@example.com" }
12
12
  ])
13
13
  };
14
14
  }
15
- const S = (n, a, o, m = []) => ({
16
- accessor: n.split(".").pop() ?? n,
17
- path: n,
15
+ const S = (s, a, i, m = []) => ({
16
+ accessor: s.split(".").pop() ?? s,
17
+ path: s,
18
18
  fieldType: a,
19
- label: o,
19
+ label: i,
20
20
  children: m
21
- }), q = (n) => n.flatMap((a) => [a.path, ...q(a.children)]), de = (n) => [
21
+ }), H = (s) => s.flatMap((a) => [a.path, ...H(a.children)]), ue = (s) => [
22
22
  S("titel", "text", "Titel"),
23
23
  S("abkuerzung", "text", "Abkürzung"),
24
24
  S("anzeigename", "textarea", "Anzeigename"),
25
- ...n ? [S("fussnote", "rich_text", "Fußnote")] : [],
25
+ ...s ? [S("fussnote", "rich_text", "Fußnote")] : [],
26
26
  S("stand", "fieldset", "Stand", [
27
27
  S("stand.datum", "date", "Datum"),
28
28
  S("stand.art", "select", "Art")
29
29
  ])
30
- ], me = () => [
30
+ ], fe = () => [
31
31
  S("fundstelle", "text", "Fundstelle"),
32
32
  S("ausgabedatum", "date", "Ausgabedatum")
33
33
  ];
34
- function ge() {
35
- const n = de(!1), a = de(!0), o = [
34
+ function be() {
35
+ const s = ue(!1), a = ue(!0), i = [
36
36
  S("aktenzeichen", "text", "Aktenzeichen"),
37
37
  S("datum", "date", "Datum")
38
38
  ];
@@ -42,30 +42,30 @@ function ge() {
42
42
  blueprintId: "bp_stub_gesetz",
43
43
  blueprintName: "Gesetz",
44
44
  label: "Release 2",
45
- fieldPaths: q(n),
46
- fields: n,
47
- releaseSpecFields: me()
45
+ fieldPaths: H(s),
46
+ fields: s,
47
+ releaseSpecFields: fe()
48
48
  },
49
49
  {
50
50
  id: "br_stub_gesetz_1",
51
51
  blueprintId: "bp_stub_gesetz",
52
52
  blueprintName: "Gesetz",
53
53
  label: "Release 1",
54
- fieldPaths: q(a),
54
+ fieldPaths: H(a),
55
55
  fields: a,
56
- releaseSpecFields: me()
56
+ releaseSpecFields: fe()
57
57
  },
58
58
  {
59
59
  id: "br_stub_entscheidung_1",
60
60
  blueprintId: "bp_stub_entscheidung",
61
61
  blueprintName: "Entscheidung",
62
62
  label: "Release 1",
63
- fieldPaths: q(o),
64
- fields: o
63
+ fieldPaths: H(i),
64
+ fields: i
65
65
  }
66
66
  ];
67
67
  }
68
- function Te() {
68
+ function $e() {
69
69
  return [
70
70
  {
71
71
  id: "mp_stub_norm",
@@ -103,7 +103,7 @@ const je = `<?xml version="1.0" encoding="UTF-8"?>
103
103
  <norm id="n2"><titel>§ 2 Begriffsbestimmungen</titel></norm>
104
104
  </gesetz>
105
105
  `;
106
- function ve() {
106
+ function Ee() {
107
107
  return [
108
108
  {
109
109
  id: "es_stub_latin1",
@@ -116,7 +116,7 @@ function ve() {
116
116
  }
117
117
  ];
118
118
  }
119
- function $e() {
119
+ function Me() {
120
120
  return [
121
121
  {
122
122
  id: "ip_stub_gesetz",
@@ -147,12 +147,12 @@ function $e() {
147
147
  }
148
148
  ];
149
149
  }
150
- const te = (n, a, o, m = "") => ({
150
+ const re = (s, a, i, m = "") => ({
151
151
  field_type: "text",
152
- config: { name: a, api_accessor: n, required: o, instructions: m },
152
+ config: { name: a, api_accessor: s, required: i, instructions: m },
153
153
  system: !1
154
154
  });
155
- function Ee() {
155
+ function ke() {
156
156
  return [
157
157
  {
158
158
  name: "citation-links",
@@ -174,8 +174,8 @@ function Ee() {
174
174
  target: "source_file",
175
175
  description: "Renames every element of one name to another.",
176
176
  settingsSpec: [
177
- te("from", "Element", !0, "The element's name now."),
178
- te("to", "New name", !0)
177
+ re("from", "Element", !0, "The element's name now."),
178
+ re("to", "New name", !0)
179
179
  ]
180
180
  },
181
181
  {
@@ -183,11 +183,11 @@ function Ee() {
183
183
  kind: "preprocessor",
184
184
  target: "source_file",
185
185
  description: "Wraps each sentence of an element in its own element.",
186
- settingsSpec: [te("element", "Element", !1)]
186
+ settingsSpec: [re("element", "Element", !1)]
187
187
  }
188
188
  ];
189
189
  }
190
- const M = (n = {}) => ({
190
+ const k = (s = {}) => ({
191
191
  matched: 0,
192
192
  created: 0,
193
193
  problems: 0,
@@ -195,13 +195,15 @@ const M = (n = {}) => ({
195
195
  corrected: 0,
196
196
  kept: 0,
197
197
  unchanged: 0,
198
- ...n
199
- }), v = (n) => ({
198
+ stubbed: 0,
199
+ pendingReferences: 0,
200
+ ...s
201
+ }), T = (s) => ({
200
202
  importProfile: {
201
203
  configurationId: "ip_stub_gesetz",
202
204
  name: "Boorberg gesetz",
203
- releaseId: `ip_stub_gesetz_rel${n}`,
204
- number: n
205
+ releaseId: `ip_stub_gesetz_rel${s}`,
206
+ number: s
205
207
  },
206
208
  mappings: [
207
209
  {
@@ -217,65 +219,138 @@ const M = (n = {}) => ({
217
219
  releaseId: "es_stub_latin1_rel1",
218
220
  number: 1
219
221
  }
220
- }), E = (n) => ({
222
+ }), M = (s) => ({
221
223
  importProfileId: "ip_stub_gesetz",
222
224
  importProfileName: "Boorberg gesetz",
223
- sourceFileId: `sf_${n.id}`,
224
- startedBy: b,
225
+ sourceFileId: `sf_${s.id}`,
226
+ startedBy: y,
225
227
  phase: "ended",
226
228
  failureReason: "",
227
229
  progress: { done: 0, total: 0 },
228
- counts: M(),
230
+ counts: k(),
229
231
  changeSetId: "",
230
- releases: v(2),
232
+ releases: T(2),
231
233
  createTime: "2026-11-03T09:00:00.000Z",
232
234
  startTime: "",
233
235
  endTime: "",
234
236
  cancelledBy: "",
235
237
  effectiveDate: "",
236
- ...n
237
- }), x = (n, a, o, m, g) => ({
238
- id: `prob_stub_${n}`,
238
+ dryRun: !1,
239
+ draft: !1,
240
+ assetMoves: [],
241
+ sourceFileDeleteTime: "",
242
+ sourceFileDeletionReason: "",
243
+ ...s
244
+ }), $ = (s, a, i, m, f, b = "") => ({
245
+ id: `prob_stub_${s}`,
239
246
  mappingId: a === "norm" ? "mp_stub_norm" : "mp_stub_title",
240
247
  mappingName: a === "norm" ? "Gesetz norms" : "Gesetz titles",
241
- sourceKey: o,
248
+ sourceKey: i,
242
249
  field: m,
243
- reason: g
250
+ reason: f,
251
+ displayName: b
252
+ }), A = (s, a, i, m, f = "") => ({
253
+ mappingId: s === "norm" ? "mp_stub_norm" : "mp_stub_title",
254
+ mappingName: s === "norm" ? "Gesetz norms" : "Gesetz titles",
255
+ sourceKey: a,
256
+ displayName: i,
257
+ action: m,
258
+ // Content it would create or stub has none yet.
259
+ contentId: m === "created" || m === "stubbed" ? "" : `ct_${a}`,
260
+ firstDay: f,
261
+ lastDay: ""
244
262
  });
245
- function Re() {
263
+ function Ne() {
246
264
  return [
247
- E({
265
+ M({
248
266
  id: "im_stub_running",
249
267
  phase: "writing",
250
268
  progress: { done: 48, total: 120 },
251
- counts: M({ matched: 120, created: 40, planned: 8 }),
269
+ counts: k({ matched: 120, created: 40, planned: 8 }),
252
270
  changeSetId: "cs_stub_running",
253
271
  createTime: "2026-11-04T10:00:00.000Z",
254
272
  startTime: "2026-11-04T10:00:05.000Z"
255
273
  }),
256
- E({
274
+ M({
257
275
  id: "im_stub_queued",
258
276
  phase: "queued",
259
- startedBy: H,
260
- releases: v(2),
277
+ startedBy: U,
278
+ releases: T(2),
261
279
  createTime: "2026-11-04T10:05:00.000Z"
262
280
  }),
263
- E({
281
+ M({
282
+ id: "im_stub_dry_run",
283
+ dryRun: !0,
284
+ outcome: "succeeded_with_problems",
285
+ counts: k({
286
+ matched: 8,
287
+ created: 1,
288
+ planned: 1,
289
+ corrected: 1,
290
+ kept: 1,
291
+ stubbed: 1,
292
+ unchanged: 1,
293
+ problems: 2,
294
+ pendingReferences: 1
295
+ }),
296
+ releases: {
297
+ ...T(2),
298
+ mappings: [
299
+ ...T(2).mappings,
300
+ {
301
+ configurationId: "mp_stub_title",
302
+ name: "Gesetz titles",
303
+ releaseId: "mp_stub_title_rel3",
304
+ number: 3
305
+ }
306
+ ]
307
+ },
308
+ createTime: "2026-11-03T15:00:00.000Z",
309
+ startTime: "2026-11-03T15:00:01.000Z",
310
+ endTime: "2026-11-03T15:01:30.000Z",
311
+ dryRunContents: [
312
+ A("norm", "BJNR000040001", "§ 1 Geltungsbereich", "created", "2026-10-01"),
313
+ A("norm", "BJNR000040002", "§ 2 Begriffe", "planned", "2026-10-01"),
314
+ A("norm", "BJNR000040003", "§ 3 Zuständigkeit", "corrected", "2025-01-01"),
315
+ A("norm", "BJNR000040004", "§ 4 Verfahren", "kept", "2025-01-01"),
316
+ A("title", "BY-4", "Bayern, Ausgabe 4", "stubbed"),
317
+ A("norm", "BJNR000040005", "§ 5 Inkrafttreten", "unchanged", "2024-01-01")
318
+ ],
319
+ itemProblems: [
320
+ $(6, "norm", "BJNR000040006", "stand/datum", "“30.02.2026” is not a date."),
321
+ {
322
+ ...$(
323
+ 7,
324
+ "norm",
325
+ "BJNR000040007",
326
+ "verweise/0",
327
+ "No Content has the Source Key BJNR000099001."
328
+ ),
329
+ pendingReference: {
330
+ targetMappingId: "mp_stub_norm",
331
+ targetBlueprintId: "bp_stub_gesetz",
332
+ targetSourceKey: "BJNR000099001"
333
+ }
334
+ }
335
+ ]
336
+ }),
337
+ M({
264
338
  id: "im_stub_problems",
265
339
  outcome: "succeeded_with_problems",
266
- counts: M({
340
+ counts: k({
267
341
  matched: 212,
268
342
  created: 180,
269
343
  planned: 20,
270
344
  corrected: 6,
271
345
  kept: 1,
272
- problems: 5
346
+ problems: 6,
347
+ pendingReferences: 1
273
348
  }),
274
349
  changeSetId: "cs_stub_problems",
275
350
  releases: {
276
- ...v(2),
351
+ ...T(2),
277
352
  mappings: [
278
- ...v(2).mappings,
353
+ ...T(2).mappings,
279
354
  {
280
355
  configurationId: "mp_stub_title",
281
356
  name: "Gesetz titles",
@@ -290,52 +365,77 @@ function Re() {
290
365
  effectiveDate: "2026-10-01",
291
366
  source: { date: "2026-09-20", reference: "BGBl. 2026 I Nr. 270" },
292
367
  itemProblems: [
293
- x(1, "norm", "BJNR000010001", "stand/datum", "“31.02.2026” is not a date."),
294
- x(2, "norm", "BJNR000010002", "", "The Version Match found two Releases."),
295
- x(3, "title", "BJNR000020001", "", "No Title has the Ausgabe code BY-7."),
296
- x(4, "norm", "BJNR000030001", "titel", "The field is required."),
297
- x(5, "title", "BJNR000030002", "", "No Title has the Ausgabe code BY-9.")
368
+ $(1, "norm", "BJNR000010001", "stand/datum", "“31.02.2026” is not a date."),
369
+ $(2, "norm", "BJNR000010002", "", "The Version Match found two Releases."),
370
+ $(3, "title", "BJNR000020001", "", "No Title has the Ausgabe code BY-7."),
371
+ $(4, "norm", "BJNR000030001", "titel", "The field is required."),
372
+ $(5, "title", "BJNR000030002", "", "No Title has the Ausgabe code BY-9."),
373
+ {
374
+ ...$(
375
+ 8,
376
+ "norm",
377
+ "BJNR000050003",
378
+ "verweise/1",
379
+ "No Content has the Source Key BJNR000099002.",
380
+ "§ 3 Anwendungsbereich"
381
+ ),
382
+ pendingReference: {
383
+ targetMappingId: "mp_stub_norm",
384
+ targetBlueprintId: "bp_stub_gesetz",
385
+ targetSourceKey: "BJNR000099002"
386
+ }
387
+ }
388
+ ],
389
+ // Two Placeholder Assets found outside the folder mirroring their
390
+ // path (link-placeholder-assets-in-mediahub:AC7).
391
+ assetMoves: [
392
+ { key: "grafik/bgbl-2026-270-abb1.png", from: "(no folder)", to: "Grafiken / BGBl / 2026" },
393
+ { key: "formel/f12.mml", from: "Import / alt", to: "Formeln / 2026" }
298
394
  ]
299
395
  }),
300
- E({
396
+ M({
301
397
  id: "im_stub_succeeded",
302
398
  outcome: "succeeded",
303
- counts: M({ matched: 64, created: 64 }),
399
+ counts: k({ matched: 64, created: 64 }),
304
400
  changeSetId: "cs_stub_succeeded",
305
- releases: v(1),
401
+ releases: T(1),
306
402
  createTime: "2026-11-02T14:00:00.000Z",
307
403
  startTime: "2026-11-02T14:00:01.000Z",
308
- endTime: "2026-11-02T14:03:10.000Z"
404
+ endTime: "2026-11-02T14:03:10.000Z",
405
+ // Its Profile deletes the Source File once an Import Succeeds without
406
+ // Item Problems (re-run-a-source-file:AC2), so it offers no Re-run.
407
+ sourceFileDeleteTime: "2026-11-02T14:03:11.000Z",
408
+ sourceFileDeletionReason: "Deleted when the Import succeeded without Item Problems, as its Import Profile says."
309
409
  }),
310
- E({
410
+ M({
311
411
  id: "im_stub_failed",
312
412
  outcome: "failed",
313
413
  failureReason: "The worker crashed three times running this Import.",
314
- counts: M({ matched: 30 }),
315
- releases: v(1),
414
+ counts: k({ matched: 30 }),
415
+ releases: T(1),
316
416
  createTime: "2026-11-02T11:00:00.000Z",
317
417
  startTime: "2026-11-02T11:00:01.000Z",
318
418
  endTime: "2026-11-02T11:20:00.000Z"
319
419
  }),
320
- E({
420
+ M({
321
421
  id: "im_stub_cancelled",
322
422
  outcome: "cancelled",
323
- cancelledBy: H,
324
- counts: M({ matched: 12, created: 3 }),
325
- releases: v(1),
423
+ cancelledBy: U,
424
+ counts: k({ matched: 12, created: 3 }),
425
+ releases: T(1),
326
426
  createTime: "2026-11-01T16:00:00.000Z",
327
427
  startTime: "2026-11-01T16:00:01.000Z",
328
428
  endTime: "2026-11-01T16:01:00.000Z"
329
429
  })
330
430
  ];
331
431
  }
332
- function Me() {
432
+ function Be() {
333
433
  return [
334
434
  {
335
435
  id: "key_stub_nightly",
336
436
  name: "Nightly gesetz feed",
337
437
  keyPrefix: "ihk_7Qx2",
338
- owner: H,
438
+ owner: U,
339
439
  expireTime: "",
340
440
  createTime: "2026-11-20T07:30:00.000Z"
341
441
  },
@@ -343,80 +443,80 @@ function Me() {
343
443
  id: "key_stub_pipeline",
344
444
  name: "VRPML pipeline",
345
445
  keyPrefix: "ihk_b91F",
346
- owner: b,
446
+ owner: y,
347
447
  expireTime: "2027-06-30T21:59:59.000Z",
348
448
  createTime: "2026-11-03T12:00:00.000Z"
349
449
  }
350
450
  ];
351
451
  }
352
- const ke = /* @__PURE__ */ new Set(["amp", "lt", "gt", "quot", "apos"]);
353
- function Ne(n, a) {
354
- return n.replace(
452
+ const Fe = /* @__PURE__ */ new Set(["amp", "lt", "gt", "quot", "apos"]);
453
+ function De(s, a) {
454
+ return s.replace(
355
455
  /&([A-Za-z_][\w.-]*);/g,
356
- (o, m) => !ke.has(m) && m in a ? a[m] ?? o : o
456
+ (i, m) => !Fe.has(m) && m in a ? a[m] ?? i : i
357
457
  );
358
458
  }
359
- function Ae(n, a) {
459
+ function Ae(s, a) {
360
460
  if (typeof DOMParser > "u")
361
461
  throw new Error("the stub's Mapping Test reads the sample with the DOM: run it in a browser");
362
- const o = new DOMParser().parseFromString(a, "application/xml"), m = o.getElementsByTagName("parsererror")[0];
462
+ const i = new DOMParser().parseFromString(a, "application/xml"), m = i.getElementsByTagName("parsererror")[0];
363
463
  if (m)
364
- throw new O(
464
+ throw new z(
365
465
  `the sample is not XML: ${(m.textContent ?? "").split(`
366
466
  `)[0]}`
367
467
  );
368
- const g = n.elementSelector?.trim() ?? "";
369
- if (!g) throw new O("the Mapping has no element selector");
370
- const y = (() => {
468
+ const f = s.elementSelector?.trim() ?? "";
469
+ if (!f) throw new z("the Mapping has no element selector");
470
+ const b = (() => {
371
471
  try {
372
- const d = o.evaluate(g, o, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
373
- return Array.from({ length: d.snapshotLength }, (h, _) => d.snapshotItem(_));
472
+ const d = i.evaluate(f, i, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
473
+ return Array.from({ length: d.snapshotLength }, (g, _) => d.snapshotItem(_));
374
474
  } catch {
375
- throw new O(`the element selector ${g} cannot be evaluated`);
475
+ throw new z(`the element selector ${f} cannot be evaluated`);
376
476
  }
377
- })(), r = n.sourceKey?.selector?.trim() ?? "";
477
+ })(), o = s.sourceKey?.selector?.trim() ?? "";
378
478
  return {
379
- elements: y.map((d, h) => {
479
+ elements: b.map((d, g) => {
380
480
  const _ = [];
381
481
  let w = "";
382
- if (r)
482
+ if (o)
383
483
  try {
384
- w = _e(o, r, d).trim();
484
+ w = ye(i, o, d).trim();
385
485
  } catch {
386
- throw new O(`the Source Key ${r} cannot be evaluated`);
486
+ throw new z(`the Source Key ${o} cannot be evaluated`);
387
487
  }
388
488
  w || _.push({ field: "", reason: "the element has no Source Key" });
389
- const I = ye(o, n.fields ?? [], d, "", _);
489
+ const I = Ie(i, s.fields ?? [], d, "", _);
390
490
  return {
391
- position: h + 1,
491
+ position: g + 1,
392
492
  sourceKey: w,
393
493
  values: I,
394
494
  firstDay: "",
395
495
  lastDay: "",
396
496
  releaseSpec: {},
397
497
  displayName: "",
398
- collections: [...n.collections ?? []],
498
+ collections: [...s.collections ?? []],
399
499
  problems: _
400
500
  };
401
501
  })
402
502
  };
403
503
  }
404
- function _e(n, a, o) {
405
- return n.evaluate(`string(${a})`, o, null, XPathResult.STRING_TYPE, null).stringValue;
504
+ function ye(s, a, i) {
505
+ return s.evaluate(`string(${a})`, i, null, XPathResult.STRING_TYPE, null).stringValue;
406
506
  }
407
- function ye(n, a, o, m, g) {
408
- const y = {};
409
- for (const r of a) {
410
- const d = typeof r.name == "string" ? r.name : "";
507
+ function Ie(s, a, i, m, f) {
508
+ const b = {};
509
+ for (const o of a) {
510
+ const d = typeof o.name == "string" ? o.name : "";
411
511
  if (!d) continue;
412
- const h = m ? `${m}.${d}` : d, _ = typeof r.selector == "string" ? r.selector.trim() : "";
413
- if (r.type === "fieldset") {
414
- let I = o;
512
+ const g = m ? `${m}.${d}` : d, _ = typeof o.selector == "string" ? o.selector.trim() : "";
513
+ if (o.type === "fieldset") {
514
+ let I = i;
415
515
  if (_ && _ !== ".")
416
516
  try {
417
- I = n.evaluate(
517
+ I = s.evaluate(
418
518
  _,
419
- o,
519
+ i,
420
520
  null,
421
521
  XPathResult.FIRST_ORDERED_NODE_TYPE,
422
522
  null
@@ -425,33 +525,33 @@ function ye(n, a, o, m, g) {
425
525
  I = null;
426
526
  }
427
527
  if (!I) {
428
- r.optional || g.push({ field: h, reason: `nothing at ${_}` });
528
+ o.optional || f.push({ field: g, reason: `nothing at ${_}` });
429
529
  continue;
430
530
  }
431
- const k = Array.isArray(r.fields) ? r.fields : [];
432
- y[d] = ye(n, k, I, h, g);
531
+ const O = Array.isArray(o.fields) ? o.fields : [];
532
+ b[d] = Ie(s, O, I, g, f);
433
533
  continue;
434
534
  }
435
535
  if (!_) {
436
- g.push({ field: h, reason: "the field has no XPath" });
536
+ f.push({ field: g, reason: "the field has no XPath" });
437
537
  continue;
438
538
  }
439
539
  let w;
440
540
  try {
441
- w = _e(n, _, o).trim();
541
+ w = ye(s, _, i).trim();
442
542
  } catch {
443
- g.push({ field: h, reason: `the XPath ${_} cannot be evaluated` });
543
+ f.push({ field: g, reason: `the XPath ${_} cannot be evaluated` });
444
544
  continue;
445
545
  }
446
546
  if (!w) {
447
- r.optional || g.push({ field: h, reason: `nothing at ${_}` });
547
+ o.optional || f.push({ field: g, reason: `nothing at ${_}` });
448
548
  continue;
449
549
  }
450
- y[d] = w;
550
+ b[d] = w;
451
551
  }
452
- return y;
552
+ return b;
453
553
  }
454
- const Be = [
554
+ const xe = [
455
555
  "listImportProfiles",
456
556
  "getImportProfile",
457
557
  "createImportProfile",
@@ -480,113 +580,116 @@ const Be = [
480
580
  "listImports",
481
581
  "getImport",
482
582
  "cancelImport",
583
+ "rerunImport",
483
584
  "listItemProblems",
585
+ "startDryRun",
586
+ "listDryRunContents",
484
587
  "listApiKeys",
485
588
  "createApiKey",
486
589
  "revokeApiKey"
487
590
  ];
488
- let ue = Date.parse("2026-11-02T08:00:00Z");
489
- const $ = () => (ue += 36e5, new Date(ue).toISOString()), se = (n = []) => n.map((a) => {
490
- const o = Math.max(a.releaseNumber ?? 0, 1), m = Array.from({ length: o }, (y, r) => ({
491
- id: `${a.id}_r${r + 1}`,
591
+ let ge = Date.parse("2026-11-02T08:00:00Z");
592
+ const N = () => (ge += 36e5, new Date(ge).toISOString()), ie = (s = []) => s.map((a) => {
593
+ const i = Math.max(a.releaseNumber ?? 0, 1), m = Array.from({ length: i }, (b, o) => ({
594
+ id: `${a.id}_r${o + 1}`,
492
595
  content: structuredClone(a.content),
493
- savedBy: b,
494
- savedAt: $(),
596
+ savedBy: y,
597
+ savedAt: N(),
495
598
  restoredFromRevisionId: ""
496
- })), g = Array.from({ length: a.releaseNumber ?? 0 }, (y, r) => ({
497
- id: `${a.id}_rel${r + 1}`,
498
- number: r + 1,
499
- revisionId: `${a.id}_r${r + 1}`,
500
- releasedBy: b,
501
- releasedAt: $()
599
+ })), f = Array.from({ length: a.releaseNumber ?? 0 }, (b, o) => ({
600
+ id: `${a.id}_rel${o + 1}`,
601
+ number: o + 1,
602
+ revisionId: `${a.id}_r${o + 1}`,
603
+ releasedBy: y,
604
+ releasedAt: N()
502
605
  }));
503
- return { id: a.id, content: structuredClone(a.content), revisions: m, releases: g };
504
- }), F = (n) => n.revisions[n.revisions.length - 1], be = (n) => n.releases[n.releases.length - 1], G = (n) => {
505
- const a = be(n), o = n.revisions.find((m) => m.id === a?.revisionId);
606
+ return { id: a.id, content: structuredClone(a.content), revisions: m, releases: f };
607
+ }), C = (s) => s.revisions[s.revisions.length - 1], Se = (s) => s.releases[s.releases.length - 1], j = (s) => {
608
+ const a = Se(s), i = s.revisions.find((m) => m.id === a?.revisionId);
506
609
  return {
507
- draftRevisionId: F(n).id,
610
+ draftRevisionId: C(s).id,
508
611
  // By content, as importhub compares: a draft that restored the
509
612
  // released content does not differ.
510
- draftDiffersFromRelease: !o || JSON.stringify(o.content) !== JSON.stringify(F(n).content),
613
+ draftDiffersFromRelease: !i || JSON.stringify(i.content) !== JSON.stringify(C(s).content),
511
614
  ...a ? { latestRelease: { id: a.id, number: a.number } } : {}
512
615
  };
513
- }, xe = (n) => n.replace(/[A-Z]/g, (a) => `_${a.toLowerCase()}`), fe = (n) => Object.fromEntries(
514
- Object.entries(n).map(([a, o]) => [xe(a), o])
515
- ), R = (n) => ({
516
- valid: n.length === 0,
517
- reasons: n
518
- }), L = (n) => [...n].sort((a, o) => a.content.name.localeCompare(o.content.name));
519
- let he = 0;
520
- function Ge(n = {}) {
616
+ }, Ce = (s) => s.replace(/[A-Z]/g, (a) => `_${a.toLowerCase()}`), he = (s) => Object.fromEntries(
617
+ Object.entries(s).map(([a, i]) => [Ce(a), i])
618
+ ), x = (s) => ({
619
+ valid: s.length === 0,
620
+ reasons: s
621
+ }), q = (s) => [...s].sort((a, i) => a.content.name.localeCompare(i.content.name));
622
+ let _e = 0;
623
+ function qe(s = {}) {
521
624
  const a = Object.fromEntries(
522
625
  Object.entries(
523
- n.workspaces ?? {
524
- [ne]: {
525
- importProfiles: $e(),
526
- mappings: Te(),
527
- entitySets: ve(),
528
- imports: Re(),
529
- apiKeys: Me()
626
+ s.workspaces ?? {
627
+ [oe]: {
628
+ importProfiles: Me(),
629
+ mappings: $e(),
630
+ entitySets: Ee(),
631
+ imports: Ne(),
632
+ apiKeys: Be()
530
633
  }
531
634
  }
532
635
  ).map(([e, t]) => [
533
636
  e,
534
637
  {
535
- importProfiles: se(t.importProfiles),
536
- mappings: se(t.mappings),
537
- entitySets: se(t.entitySets),
638
+ importProfiles: ie(t.importProfiles),
639
+ mappings: ie(t.mappings),
640
+ entitySets: ie(t.entitySets),
538
641
  imports: structuredClone(t.imports ?? []),
539
642
  apiKeys: structuredClone(t.apiKeys ?? [])
540
643
  }
541
644
  ])
542
- ), o = n.processors ?? Ee(), m = n.blueprintReleases ?? ge();
543
- let g = n.activeWorkspaceId ?? ne;
544
- const y = Object.fromEntries(Be.map((e) => [e, 0])), r = () => (a[g] ??= {
645
+ ), i = s.processors ?? ke(), m = s.blueprintReleases ?? be();
646
+ let f = s.activeWorkspaceId ?? oe;
647
+ const b = Object.fromEntries(xe.map((e) => [e, 0])), o = () => (a[f] ??= {
545
648
  importProfiles: [],
546
649
  mappings: [],
547
650
  entitySets: [],
548
651
  imports: [],
549
652
  apiKeys: []
550
- }, a[g]), d = async (e, t) => {
551
- if (y[e]++, n.fail) throw n.fail;
653
+ }, a[f]), d = async (e, t) => {
654
+ if (b[e]++, s.fail) throw s.fail;
552
655
  return structuredClone(t());
553
- }, h = (e, t, s) => {
554
- const i = e.find((l) => l.id === t);
555
- if (!i) throw new Error(`${s} ${t} not found`);
556
- return i;
557
- }, _ = (e, t, s) => {
656
+ }, g = (e, t, n) => {
657
+ const r = e.find((c) => c.id === t);
658
+ if (!r) throw new Error(`${n} ${t} not found`);
659
+ return r;
660
+ }, _ = (e, t, n) => {
558
661
  if (!t.trim()) throw new Error("a name is required");
559
- if (e.some((i) => i.id !== s && i.content.name === t)) throw new we();
560
- }, w = (e, t) => t !== "" && t !== F(e).id, I = (e, t, s, i = "") => {
561
- if (w(e, s))
662
+ if (e.some((r) => r.id !== n && r.content.name === t)) throw new Te();
663
+ }, w = (e, t) => t !== "" && t !== C(e).id, I = (e, t, n, r = "") => {
664
+ if (w(e, n))
562
665
  throw new Error("the draft moved: somebody saved in between");
563
666
  e.content = structuredClone(t), e.revisions.push({
564
667
  id: `${e.id}_r${e.revisions.length + 1}`,
565
668
  content: structuredClone(t),
566
- savedBy: b,
567
- savedAt: $(),
568
- restoredFromRevisionId: i
669
+ savedBy: y,
670
+ savedAt: N(),
671
+ restoredFromRevisionId: r
569
672
  });
570
- }, k = (e, t) => {
571
- const s = X(e);
673
+ }, O = (e, t) => {
674
+ const n = Y(e);
572
675
  return {
573
- id: s,
676
+ id: n,
574
677
  content: structuredClone(t),
575
678
  revisions: [
576
679
  {
577
- id: `${s}_r1`,
680
+ id: `${n}_r1`,
578
681
  content: structuredClone(t),
579
- savedBy: b,
580
- savedAt: $(),
682
+ savedBy: y,
683
+ savedAt: N(),
581
684
  restoredFromRevisionId: ""
582
685
  }
583
686
  ],
584
687
  releases: []
585
688
  };
586
689
  };
587
- function J(e) {
588
- const t = [], s = m.find((p) => p.id === e.blueprintReleaseId);
589
- e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
690
+ function X(e) {
691
+ const t = [], n = m.find((p) => p.id === e.blueprintReleaseId);
692
+ e.blueprintReleaseId ? n ? n.blueprintId !== e.blueprintId && t.push({
590
693
  path: "/blueprintReleaseId",
591
694
  code: "release_of_other_blueprint",
592
695
  message: "The pinned Release is of another Blueprint."
@@ -603,522 +706,573 @@ function Ge(n = {}) {
603
706
  code: "no_element_selector",
604
707
  message: "It has no element selector."
605
708
  }), !e.sourceKey?.selector && !e.sourceKey?.template && t.push({ path: "/sourceKey", code: "no_source_key", message: "It has no Source Key." });
606
- const i = (p, c) => {
607
- typeof c == "string" && c !== "" && !Oe(c) && t.push({ path: p, code: "invalid_xpath", message: `"${c}" is not an XPath.` });
709
+ const r = (p, l) => {
710
+ typeof l == "string" && l !== "" && !Oe(l) && t.push({ path: p, code: "invalid_xpath", message: `"${l}" is not an XPath.` });
608
711
  };
609
- i("/element_selector", e.elementSelector), i("/source_key/selector", e.sourceKey?.selector);
610
- const l = [];
611
- return (e.fields ?? []).forEach((p, c) => {
612
- const f = `/fields/${c}`;
613
- for (const { path: u, rel: A, mapping: T } of ie(p, "", f))
614
- l.push(u), i(`${A}/selector`, T.selector), s && !s.fieldPaths.includes(u) && t.push({
615
- path: f,
712
+ r("/element_selector", e.elementSelector), r("/source_key/selector", e.sourceKey?.selector);
713
+ const c = [];
714
+ return (e.fields ?? []).forEach((p, l) => {
715
+ const u = `/fields/${l}`;
716
+ for (const { path: h, rel: v, mapping: P } of ae(p, "", u))
717
+ c.push(h), r(`${v}/selector`, P.selector), n && !n.fieldPaths.includes(h) && t.push({
718
+ path: u,
616
719
  code: "unknown_field_path",
617
- message: `The pinned Release has no field ${u}.`
618
- }), T.type === "select" && !T.selectOptions && t.push({
619
- path: f,
720
+ message: `The pinned Release has no field ${h}.`
721
+ }), P.type === "select" && !P.selectOptions && t.push({
722
+ path: u,
620
723
  code: "xmlmapper_schema",
621
- message: `The select field ${u} has no select options.`
724
+ message: `The select field ${h} has no select options.`
622
725
  });
623
- }), (e.versionMatch?.contentFields ?? []).forEach((p, c) => {
624
- l.includes(p) || t.push({
625
- path: `/version_match/content_fields/${c}`,
726
+ }), (e.versionMatch?.contentFields ?? []).forEach((p, l) => {
727
+ c.includes(p) || t.push({
728
+ path: `/version_match/content_fields/${l}`,
626
729
  code: "unknown_version_match_field",
627
730
  message: `The Version Match compares ${p}, which the Mapping does not map.`
628
731
  });
629
- }), (e.titleContributions ?? []).forEach((p, c) => {
732
+ }), (e.titleContributions ?? []).forEach((p, l) => {
630
733
  (!p.selector || !p.ausgabeCodeSelector) && t.push({
631
- path: `/title_contributions/${c}`,
734
+ path: `/title_contributions/${l}`,
632
735
  code: "incomplete_title_contribution",
633
736
  message: "A Title Contribution needs a selector and an Ausgabe code selector."
634
- }), i(`/title_contributions/${c}/selector`, p.selector);
635
- }), (e.placeholderAssets ?? []).forEach((p, c) => {
737
+ }), r(`/title_contributions/${l}/selector`, p.selector);
738
+ }), (e.placeholderAssets ?? []).forEach((p, l) => {
636
739
  (!p.selector || !p.assetType || !p.keyParts?.length || !p.nameSelector) && t.push({
637
- path: `/placeholder_assets/${c}`,
740
+ path: `/placeholder_assets/${l}`,
638
741
  code: "incomplete_placeholder_assets",
639
742
  message: "Placeholder Assets need a selector, an asset type, the key's parts and a name selector."
640
- }), i(`/placeholder_assets/${c}/selector`, p.selector), (p.keyParts ?? []).forEach((f, u) => {
641
- i(`/placeholder_assets/${c}/key_parts/${u}`, f);
743
+ }), r(`/placeholder_assets/${l}/selector`, p.selector), (p.keyParts ?? []).forEach((u, h) => {
744
+ r(`/placeholder_assets/${l}/key_parts/${h}`, u);
642
745
  });
643
- }), t.push(...Fe(e, s?.fields, l)), t;
746
+ }), t.push(...Ke(e, n?.fields, c)), t;
644
747
  }
645
- function re(e, t, s) {
646
- return e.flatMap((i, l) => {
647
- const p = `/${t}/${l}`, c = o.find((u) => u.name === i.processor);
648
- return c ? c.target !== "source_file" ? [
748
+ function le(e, t, n) {
749
+ return e.flatMap((r, c) => {
750
+ const p = `/${t}/${c}`, l = i.find((h) => h.name === r.processor);
751
+ return l ? l.target !== "source_file" ? [
649
752
  {
650
753
  path: p,
651
754
  code: "rich_text_processor",
652
- message: `${c.name} is configured on a rich-text field, not on a Profile.`
755
+ message: `${l.name} is configured on a rich-text field, not on a Profile.`
653
756
  }
654
- ] : c.kind !== s ? [{ path: p, code: "wrong_processor_kind", message: `${c.name} does not run here.` }] : c.settingsSpec.filter(
655
- (u) => u.config.required && (i.settings[u.config.api_accessor] ?? "") === ""
656
- ).map((u) => ({
657
- path: `${p}/settings/${u.config.api_accessor}`,
757
+ ] : l.kind !== n ? [{ path: p, code: "wrong_processor_kind", message: `${l.name} does not run here.` }] : l.settingsSpec.filter(
758
+ (h) => h.config.required && (r.settings[h.config.api_accessor] ?? "") === ""
759
+ ).map((h) => ({
760
+ path: `${p}/settings/${h.config.api_accessor}`,
658
761
  code: "invalid_processor_settings",
659
- message: `${c.name}: ${u.config.api_accessor} is required.`
762
+ message: `${l.name}: ${h.config.api_accessor} is required.`
660
763
  })) : [
661
- { path: p, code: "unknown_processor", message: `No Processor is called ${i.processor}.` }
764
+ { path: p, code: "unknown_processor", message: `No Processor is called ${r.processor}.` }
662
765
  ];
663
766
  });
664
767
  }
665
- function U(e) {
666
- const t = r(), s = [
667
- ...re(e.preprocessors, "preprocessors", "preprocessor"),
668
- ...re(e.postProcessors, "postProcessors", "post_processor")
768
+ function V(e) {
769
+ const t = o(), n = [
770
+ ...le(e.preprocessors, "preprocessors", "preprocessor"),
771
+ ...le(e.postProcessors, "postProcessors", "post_processor")
669
772
  ];
670
- return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((i, l) => {
671
- const p = t.mappings.find((f) => f.id === i);
773
+ return e.mappingIds.length === 0 && n.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((r, c) => {
774
+ const p = t.mappings.find((u) => u.id === r);
672
775
  if (!p) {
673
- s.push({
674
- path: `/mappingIds/${l}`,
776
+ n.push({
777
+ path: `/mappingIds/${c}`,
675
778
  code: "mapping_missing",
676
779
  message: "It includes a Mapping that does not exist."
677
780
  });
678
781
  return;
679
782
  }
680
- const c = J(p.content);
681
- c.length > 0 && s.push({
682
- path: `/mappingIds/${l}`,
783
+ const l = X(p.content);
784
+ l.length > 0 && n.push({
785
+ path: `/mappingIds/${c}`,
683
786
  code: "mapping_invalid",
684
- message: `The Mapping ${p.content.name} is invalid: ${c.map((f) => f.message).join(" ")}`
787
+ message: `The Mapping ${p.content.name} is invalid: ${l.map((u) => u.message).join(" ")}`
685
788
  });
686
- }), e.entitySetId && !t.entitySets.some((i) => i.id === e.entitySetId) && s.push({
789
+ }), e.entitySetId && !t.entitySets.some((r) => r.id === e.entitySetId) && n.push({
687
790
  path: "/entitySetId",
688
791
  code: "entity_set_missing",
689
792
  message: "It names an Entity Set that does not exist."
690
- }), s;
793
+ }), n;
691
794
  }
692
- const oe = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], K = (e) => ({
795
+ const ce = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], Z = (e) => ({
693
796
  id: e.id,
694
797
  content: e.content,
695
- validity: R(U(e.content)),
696
- state: G(e)
697
- }), z = (e) => ({
798
+ validity: x(V(e.content)),
799
+ state: j(e)
800
+ }), J = (e) => ({
698
801
  id: e.id,
699
802
  content: e.content,
700
- validity: R(J(e.content)),
701
- state: G(e)
702
- }), C = (e) => ({
803
+ validity: x(X(e.content)),
804
+ state: j(e)
805
+ }), G = (e) => ({
703
806
  id: e.id,
704
807
  content: e.content,
705
- validity: R(oe(e.content)),
706
- state: G(e)
707
- }), D = (e) => L(r().importProfiles.filter((t) => e(t.content))).map((t) => ({
808
+ validity: x(ce(e.content)),
809
+ state: j(e)
810
+ }), L = (e) => q(o().importProfiles.filter((t) => e(t.content))).map((t) => ({
708
811
  id: t.id,
709
812
  name: t.content.name
710
- })), X = (e) => `${e}_stub_new_${++he}`, N = (e) => {
711
- const t = r();
813
+ })), Y = (e) => `${e}_stub_new_${++_e}`, K = (e) => {
814
+ const t = o();
712
815
  switch (e) {
713
816
  case "importProfile":
714
817
  return {
715
818
  items: t.importProfiles,
716
819
  name: "Import Profile",
717
- reasons: (s) => U(s)
820
+ reasons: (n) => V(n)
718
821
  };
719
822
  case "mapping":
720
823
  return {
721
824
  items: t.mappings,
722
825
  name: "Mapping",
723
- reasons: (s) => J(s)
826
+ reasons: (n) => X(n)
724
827
  };
725
828
  case "entitySet":
726
829
  return {
727
830
  items: t.entitySets,
728
831
  name: "Entity Set",
729
- reasons: (s) => oe(s)
832
+ reasons: (n) => ce(n)
730
833
  };
731
834
  }
732
- }, P = (e, t) => {
733
- F(t).validity = R(N(e).reasons(t.content));
734
- }, V = (e, t) => {
735
- const s = e.revisions.find((i) => i.id === t);
736
- if (!s) throw new Error(`Revision ${t} not found`);
737
- return s;
738
- }, ae = /* @__PURE__ */ new Set(), le = n.contenthubRights ?? ["editor", "publisher"], Z = (e) => {
739
- const t = r().imports.find((s) => s.id === e);
835
+ }, E = (e, t) => {
836
+ C(t).validity = x(K(e).reasons(t.content));
837
+ }, W = (e, t) => {
838
+ const n = e.revisions.find((r) => r.id === t);
839
+ if (!n) throw new Error(`Revision ${t} not found`);
840
+ return n;
841
+ }, Q = /* @__PURE__ */ new Set(), pe = s.contenthubRights ?? ["editor", "publisher"], B = (e) => {
842
+ const t = o().imports.find((n) => n.id === e);
740
843
  if (!t) throw new Error(`Import ${e} not found`);
741
844
  return t;
742
- }, Y = (e) => {
743
- e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = $());
744
- }, j = ({ itemProblems: e, ...t }) => t, W = (e, t) => {
745
- const s = be(e);
746
- if (!s)
747
- throw new B(`the ${t} ${e.content.name} has no Release yet`);
748
- const i = e.revisions.find((l) => l.id === s.revisionId)?.content ?? e.content;
845
+ }, ee = (e) => {
846
+ e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = N());
847
+ }, F = ({ itemProblems: e, dryRunContents: t, ...n }) => n, we = (e, t) => {
848
+ const n = Se(e);
849
+ if (!n)
850
+ throw new D(`the ${t} ${e.content.name} has no Release yet`);
851
+ const r = e.revisions.find((c) => c.id === n.revisionId)?.content ?? e.content;
749
852
  return {
750
- content: i,
853
+ content: r,
751
854
  ref: {
752
855
  configurationId: e.id,
753
- name: i.name,
754
- releaseId: s.id,
755
- number: s.number
856
+ name: r.name,
857
+ releaseId: n.id,
858
+ number: n.number
756
859
  }
757
860
  };
861
+ }, Pe = (e) => ({
862
+ content: e.content,
863
+ ref: {
864
+ configurationId: e.id,
865
+ name: e.content.name,
866
+ releaseId: "",
867
+ number: 0,
868
+ revisionId: C(e).id
869
+ }
870
+ }), te = (e, t) => {
871
+ const n = o(), r = t && (e.draft ?? !1), c = g(n.importProfiles, e.importProfileId, "Import Profile");
872
+ if (!Q.has(e.sourceFileId))
873
+ throw new D("nothing was uploaded to the Source File");
874
+ if (!t && !pe.includes("editor"))
875
+ throw new D("starting an Import needs contenthub editor in the workspace");
876
+ const p = (R, ne) => r ? Pe(R) : we(R, ne), l = p(c, "Import Profile");
877
+ if (!t && l.content.autoPublish && !pe.includes("publisher"))
878
+ throw new D(
879
+ "the Import Profile has Auto-publish, which needs contenthub publisher"
880
+ );
881
+ const u = V(l.content);
882
+ if (u.length > 0)
883
+ throw new D(
884
+ `the ${r ? "draft of the " : ""}Import Profile ${l.ref.name} is invalid: ${u.map((R) => R.message).join(" ")}`
885
+ );
886
+ const h = l.content.mappingIds.map(
887
+ (R) => p(g(n.mappings, R, "Mapping"), "Mapping").ref
888
+ ), v = l.content.entitySetId ? p(g(n.entitySets, l.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, P = {
889
+ id: Y("im"),
890
+ importProfileId: c.id,
891
+ importProfileName: l.ref.name,
892
+ sourceFileId: e.sourceFileId,
893
+ startedBy: y,
894
+ phase: "queued",
895
+ failureReason: "",
896
+ progress: { done: 0, total: 0 },
897
+ counts: {
898
+ matched: 0,
899
+ created: 0,
900
+ problems: 0,
901
+ planned: 0,
902
+ corrected: 0,
903
+ kept: 0,
904
+ unchanged: 0,
905
+ stubbed: 0,
906
+ pendingReferences: 0
907
+ },
908
+ changeSetId: "",
909
+ releases: {
910
+ importProfile: l.ref,
911
+ mappings: h,
912
+ ...v ? { entitySet: v } : {}
913
+ },
914
+ createTime: N(),
915
+ startTime: "",
916
+ endTime: "",
917
+ cancelledBy: "",
918
+ effectiveDate: e.effectiveDate ?? "",
919
+ ...e.source ? { source: e.source } : {},
920
+ dryRun: t,
921
+ draft: r,
922
+ assetMoves: [],
923
+ sourceFileDeleteTime: "",
924
+ sourceFileDeletionReason: "",
925
+ itemProblems: [],
926
+ ...t ? { dryRunContents: [] } : {}
927
+ };
928
+ return n.imports.unshift(P), P;
758
929
  };
759
930
  return {
760
- calls: y,
931
+ calls: b,
761
932
  switchWorkspace(e) {
762
- g = e;
933
+ f = e;
763
934
  },
764
935
  updateImport(e, t) {
765
- Object.assign(Z(e), structuredClone(t));
936
+ Object.assign(B(e), structuredClone(t));
766
937
  },
767
- listImportProfiles: () => d("listImportProfiles", () => L(r().importProfiles).map(K)),
768
- getImportProfile: (e) => d("getImportProfile", () => K(h(r().importProfiles, e, "Import Profile"))),
938
+ listImportProfiles: () => d("listImportProfiles", () => q(o().importProfiles).map(Z)),
939
+ getImportProfile: (e) => d("getImportProfile", () => Z(g(o().importProfiles, e, "Import Profile"))),
769
940
  createImportProfile: (e) => d("createImportProfile", () => {
770
- _(r().importProfiles, e.name);
771
- const t = k("ip", e);
772
- return P("importProfile", t), r().importProfiles.push(t), K(t);
941
+ _(o().importProfiles, e.name);
942
+ const t = O("ip", e);
943
+ return E("importProfile", t), o().importProfiles.push(t), Z(t);
773
944
  }),
774
- updateImportProfile: (e, t, s) => d("updateImportProfile", () => {
775
- const i = h(r().importProfiles, e, "Import Profile");
776
- return _(r().importProfiles, t.name, e), I(i, t, s), P("importProfile", i), K(i);
945
+ updateImportProfile: (e, t, n) => d("updateImportProfile", () => {
946
+ const r = g(o().importProfiles, e, "Import Profile");
947
+ return _(o().importProfiles, t.name, e), I(r, t, n), E("importProfile", r), Z(r);
777
948
  }),
778
949
  deleteImportProfile: (e) => d("deleteImportProfile", () => {
779
- h(r().importProfiles, e, "Import Profile"), r().importProfiles = r().importProfiles.filter((t) => t.id !== e);
950
+ g(o().importProfiles, e, "Import Profile"), o().importProfiles = o().importProfiles.filter((t) => t.id !== e);
780
951
  }),
781
- listProcessors: () => d("listProcessors", () => [...o].sort((e, t) => e.name.localeCompare(t.name))),
782
- listMappings: () => d("listMappings", () => L(r().mappings).map(z)),
783
- getMapping: (e) => d("getMapping", () => z(h(r().mappings, e, "Mapping"))),
952
+ listProcessors: () => d("listProcessors", () => [...i].sort((e, t) => e.name.localeCompare(t.name))),
953
+ listMappings: () => d("listMappings", () => q(o().mappings).map(J)),
954
+ getMapping: (e) => d("getMapping", () => J(g(o().mappings, e, "Mapping"))),
784
955
  createMapping: (e) => d("createMapping", () => {
785
- _(r().mappings, e.name);
786
- const t = k("mp", e);
787
- return P("mapping", t), r().mappings.push(t), z(t);
956
+ _(o().mappings, e.name);
957
+ const t = O("mp", e);
958
+ return E("mapping", t), o().mappings.push(t), J(t);
788
959
  }),
789
- updateMapping: (e, t, s) => d("updateMapping", () => {
790
- const i = h(r().mappings, e, "Mapping");
791
- return _(r().mappings, t.name, e), I(i, t, s), P("mapping", i), z(i);
960
+ updateMapping: (e, t, n) => d("updateMapping", () => {
961
+ const r = g(o().mappings, e, "Mapping");
962
+ return _(o().mappings, t.name, e), I(r, t, n), E("mapping", r), J(r);
792
963
  }),
793
964
  deleteMapping: (e) => d("deleteMapping", () => {
794
- h(r().mappings, e, "Mapping");
795
- const t = D((s) => s.mappingIds.includes(e));
965
+ g(o().mappings, e, "Mapping");
966
+ const t = L((n) => n.mappingIds.includes(e));
796
967
  if (t.length > 0)
797
- throw new ce(
968
+ throw new me(
798
969
  t,
799
- `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
970
+ `the Mapping is included by ${t.map((n) => n.name).join(", ")}`
800
971
  );
801
- r().mappings = r().mappings.filter((s) => s.id !== e);
972
+ o().mappings = o().mappings.filter((n) => n.id !== e);
802
973
  }),
803
- listMappingImportProfiles: (e) => d("listMappingImportProfiles", () => (h(r().mappings, e, "Mapping"), D((t) => t.mappingIds.includes(e)))),
974
+ listMappingImportProfiles: (e) => d("listMappingImportProfiles", () => (g(o().mappings, e, "Mapping"), L((t) => t.mappingIds.includes(e)))),
804
975
  checkMappingBlueprintRelease: (e, t) => d("checkMappingBlueprintRelease", () => {
805
- const s = h(r().mappings, e, "Mapping"), i = m.find((l) => l.id === t);
806
- if (!i) throw new Error(`Blueprint Release ${t} not found`);
807
- if (i.blueprintId !== s.content.blueprintId)
976
+ const n = g(o().mappings, e, "Mapping"), r = m.find((c) => c.id === t);
977
+ if (!r) throw new Error(`Blueprint Release ${t} not found`);
978
+ if (r.blueprintId !== n.content.blueprintId)
808
979
  throw new Error("the Release is of another Blueprint");
809
980
  return {
810
- blueprintId: i.blueprintId,
811
- missingFieldPaths: (s.content.fields ?? []).flatMap((l, p) => ie(l, "", `/fields/${p}`).map((c) => c.path)).filter((l) => !i.fieldPaths.includes(l)),
981
+ blueprintId: r.blueprintId,
982
+ missingFieldPaths: (n.content.fields ?? []).flatMap((c, p) => ae(c, "", `/fields/${p}`).map((l) => l.path)).filter((c) => !r.fieldPaths.includes(c)),
812
983
  missingReleaseSpecFields: [
813
- ...(s.content.releaseSpec ?? []).map((l) => l.field ?? ""),
814
- ...s.content.versionMatch?.releaseSpecFields ?? []
984
+ ...(n.content.releaseSpec ?? []).map((c) => c.field ?? ""),
985
+ ...n.content.versionMatch?.releaseSpecFields ?? []
815
986
  ].filter(
816
- (l, p, c) => l !== "" && c.indexOf(l) === p && !(i.releaseSpecFields ?? []).some((f) => f.path === l)
987
+ (c, p, l) => c !== "" && l.indexOf(c) === p && !(r.releaseSpecFields ?? []).some((u) => u.path === c)
817
988
  )
818
989
  };
819
990
  }),
820
- runMappingTest: ({ content: e, sample: t, entitySetId: s }) => d("runMappingTest", () => {
821
- let i = new TextDecoder().decode(t);
822
- if (s) {
823
- const l = r().entitySets.find((p) => p.id === s);
824
- if (!l) throw new O(`Entity Set ${s} not found`);
825
- i = Ne(i, l.content.entities);
991
+ runMappingTest: ({ content: e, sample: t, entitySetId: n }) => d("runMappingTest", () => {
992
+ let r = new TextDecoder().decode(t);
993
+ if (n) {
994
+ const c = o().entitySets.find((p) => p.id === n);
995
+ if (!c) throw new z(`Entity Set ${n} not found`);
996
+ r = De(r, c.content.entities);
826
997
  }
827
- return Ae(e, i);
998
+ return Ae(e, r);
828
999
  }),
829
- listEntitySets: () => d("listEntitySets", () => L(r().entitySets).map(C)),
830
- getEntitySet: (e) => d("getEntitySet", () => C(h(r().entitySets, e, "Entity Set"))),
1000
+ listEntitySets: () => d("listEntitySets", () => q(o().entitySets).map(G)),
1001
+ getEntitySet: (e) => d("getEntitySet", () => G(g(o().entitySets, e, "Entity Set"))),
831
1002
  createEntitySet: (e) => d("createEntitySet", () => {
832
- _(r().entitySets, e.name);
833
- const t = k("es", e);
834
- return P("entitySet", t), r().entitySets.push(t), C(t);
1003
+ _(o().entitySets, e.name);
1004
+ const t = O("es", e);
1005
+ return E("entitySet", t), o().entitySets.push(t), G(t);
835
1006
  }),
836
- updateEntitySet: (e, t, s) => d("updateEntitySet", () => {
837
- const i = h(r().entitySets, e, "Entity Set");
838
- return _(r().entitySets, t.name, e), I(i, t, s), P("entitySet", i), C(i);
1007
+ updateEntitySet: (e, t, n) => d("updateEntitySet", () => {
1008
+ const r = g(o().entitySets, e, "Entity Set");
1009
+ return _(o().entitySets, t.name, e), I(r, t, n), E("entitySet", r), G(r);
839
1010
  }),
840
1011
  deleteEntitySet: (e) => d("deleteEntitySet", () => {
841
- h(r().entitySets, e, "Entity Set");
842
- const t = D((s) => s.entitySetId === e);
1012
+ g(o().entitySets, e, "Entity Set");
1013
+ const t = L((n) => n.entitySetId === e);
843
1014
  if (t.length > 0)
844
- throw new ce(
1015
+ throw new me(
845
1016
  t,
846
- `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
1017
+ `the Entity Set is named by ${t.map((n) => n.name).join(", ")}`
847
1018
  );
848
- r().entitySets = r().entitySets.filter((s) => s.id !== e);
1019
+ o().entitySets = o().entitySets.filter((n) => n.id !== e);
849
1020
  }),
850
- cutRelease: (e, t, s) => d("cutRelease", () => {
851
- const i = N(e), l = h(i.items, t, i.name);
852
- if (w(l, s))
853
- throw new ee("the draft moved: somebody saved in between");
854
- const p = R(i.reasons(l.content));
855
- if (!p.valid) throw new ee("the draft is invalid", p);
856
- if (!G(l).draftDiffersFromRelease)
857
- throw new ee(
1021
+ cutRelease: (e, t, n) => d("cutRelease", () => {
1022
+ const r = K(e), c = g(r.items, t, r.name);
1023
+ if (w(c, n))
1024
+ throw new se("the draft moved: somebody saved in between");
1025
+ const p = x(r.reasons(c.content));
1026
+ if (!p.valid) throw new se("the draft is invalid", p);
1027
+ if (!j(c).draftDiffersFromRelease)
1028
+ throw new se(
858
1029
  "the draft does not differ from the latest Release: there is nothing to release"
859
1030
  );
860
- const c = l.releases.length + 1, f = {
861
- id: `${l.id}_rel${c}`,
862
- number: c,
863
- revisionId: F(l).id,
864
- releasedBy: b,
865
- releasedAt: $()
1031
+ const l = c.releases.length + 1, u = {
1032
+ id: `${c.id}_rel${l}`,
1033
+ number: l,
1034
+ revisionId: C(c).id,
1035
+ releasedBy: y,
1036
+ releasedAt: N()
866
1037
  };
867
- return l.releases.push(f), {
868
- release: f,
869
- importProfiles: e === "mapping" ? D((u) => u.mappingIds.includes(t)) : []
1038
+ return c.releases.push(u), {
1039
+ release: u,
1040
+ importProfiles: e === "mapping" ? L((h) => h.mappingIds.includes(t)) : []
870
1041
  };
871
1042
  }),
872
- listHistory: (e, t, s) => d("listHistory", () => {
873
- const i = N(e), l = h(i.items, t, i.name), p = [...l.revisions].reverse(), c = Number(s || "0");
1043
+ listHistory: (e, t, n) => d("listHistory", () => {
1044
+ const r = K(e), c = g(r.items, t, r.name), p = [...c.revisions].reverse(), l = Number(n || "0");
874
1045
  return {
875
- revisions: p.slice(c, c + 10).map((u) => ({
876
- id: u.id,
877
- savedBy: u.savedBy,
878
- savedAt: u.savedAt,
879
- validity: u.validity ?? R(i.reasons(u.content)),
880
- restoredFromRevisionId: u.restoredFromRevisionId
1046
+ revisions: p.slice(l, l + 10).map((h) => ({
1047
+ id: h.id,
1048
+ savedBy: h.savedBy,
1049
+ savedAt: h.savedAt,
1050
+ validity: h.validity ?? x(r.reasons(h.content)),
1051
+ restoredFromRevisionId: h.restoredFromRevisionId
881
1052
  })),
882
- releases: [...l.releases].reverse(),
883
- nextPageToken: c + 10 < p.length ? String(c + 10) : ""
1053
+ releases: [...c.releases].reverse(),
1054
+ nextPageToken: l + 10 < p.length ? String(l + 10) : ""
884
1055
  };
885
1056
  }),
886
- compareRevisions: (e, t, s, i) => d("compareRevisions", () => {
887
- const l = N(e), p = h(l.items, t, l.name), c = fe(V(p, s).content), f = fe(V(p, i).content), u = [.../* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(f)])].map((A) => {
888
- const T = c[A], Q = f[A], Ie = T === void 0 && Q !== void 0 ? "added" : T !== void 0 && Q === void 0 ? "removed" : JSON.stringify(T) === JSON.stringify(Q) ? "unchanged" : "changed";
889
- return { field: A, status: Ie };
1057
+ compareRevisions: (e, t, n, r) => d("compareRevisions", () => {
1058
+ const c = K(e), p = g(c.items, t, c.name), l = he(W(p, n).content), u = he(W(p, r).content), h = [.../* @__PURE__ */ new Set([...Object.keys(l), ...Object.keys(u)])].map((v) => {
1059
+ const P = l[v], R = u[v], ne = P === void 0 && R !== void 0 ? "added" : P !== void 0 && R === void 0 ? "removed" : JSON.stringify(P) === JSON.stringify(R) ? "unchanged" : "changed";
1060
+ return { field: v, status: ne };
890
1061
  });
891
1062
  return {
892
- from: { revisionId: s, content: c },
893
- to: { revisionId: i, content: f },
894
- fields: u
1063
+ from: { revisionId: n, content: l },
1064
+ to: { revisionId: r, content: u },
1065
+ fields: h
895
1066
  };
896
1067
  }),
897
- restoreRevision: (e, t, s, i) => d("restoreRevision", () => {
898
- const l = N(e), p = h(l.items, t, l.name);
899
- I(p, V(p, s).content, i, s), P(e, p);
1068
+ restoreRevision: (e, t, n, r) => d("restoreRevision", () => {
1069
+ const c = K(e), p = g(c.items, t, c.name);
1070
+ I(p, W(p, n).content, r, n), E(e, p);
900
1071
  }),
901
1072
  async uploadSourceFile(e, t) {
902
- if (y.uploadSourceFile++, n.fail) throw n.fail;
903
- for (const i of [0.25, 0.5, 0.75])
904
- await new Promise((l) => setTimeout(l, 20)), t(i);
905
- if (n.uploadFails) throw n.uploadFails;
1073
+ if (b.uploadSourceFile++, s.fail) throw s.fail;
1074
+ for (const r of [0.25, 0.5, 0.75])
1075
+ await new Promise((c) => setTimeout(c, 20)), t(r);
1076
+ if (s.uploadFails) throw s.uploadFails;
906
1077
  t(1);
907
- const s = X("sf");
908
- return ae.add(s), { id: s, fileName: e.name };
1078
+ const n = Y("sf");
1079
+ return Q.add(n), { id: n, fileName: e.name };
909
1080
  },
910
- startImport: (e) => d("startImport", () => {
911
- const t = r(), s = h(t.importProfiles, e.importProfileId, "Import Profile");
912
- if (!ae.has(e.sourceFileId))
913
- throw new B("nothing was uploaded to the Source File");
914
- if (!le.includes("editor"))
915
- throw new B(
916
- "starting an Import needs contenthub editor in the workspace"
917
- );
918
- const i = W(s, "Import Profile");
919
- if (i.content.autoPublish && !le.includes("publisher"))
920
- throw new B(
921
- "the Import Profile has Auto-publish, which needs contenthub publisher"
922
- );
923
- const l = U(i.content);
924
- if (l.length > 0)
925
- throw new B(
926
- `the Import Profile ${i.ref.name} is invalid: ${l.map((u) => u.message).join(" ")}`
927
- );
928
- const p = i.content.mappingIds.map(
929
- (u) => W(h(t.mappings, u, "Mapping"), "Mapping").ref
930
- ), c = i.content.entitySetId ? W(h(t.entitySets, i.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, f = {
931
- id: X("im"),
932
- importProfileId: s.id,
933
- importProfileName: i.ref.name,
934
- sourceFileId: e.sourceFileId,
935
- startedBy: b,
936
- phase: "queued",
937
- failureReason: "",
938
- progress: { done: 0, total: 0 },
939
- counts: {
940
- matched: 0,
941
- created: 0,
942
- problems: 0,
943
- planned: 0,
944
- corrected: 0,
945
- kept: 0,
946
- unchanged: 0
947
- },
948
- changeSetId: "",
949
- releases: {
950
- importProfile: i.ref,
951
- mappings: p,
952
- ...c ? { entitySet: c } : {}
953
- },
954
- createTime: $(),
955
- startTime: "",
956
- endTime: "",
957
- cancelledBy: "",
958
- effectiveDate: e.effectiveDate ?? "",
959
- ...e.source ? { source: e.source } : {},
960
- itemProblems: []
961
- };
962
- return t.imports.unshift(f), j(f);
963
- }),
1081
+ startImport: (e) => d("startImport", () => F(te(e, !1))),
964
1082
  listImports: (e) => d("listImports", () => {
965
- const t = r().imports;
966
- t.forEach(Y);
967
- const s = Number(e || "0");
1083
+ const t = o().imports;
1084
+ t.forEach(ee);
1085
+ const n = Number(e || "0");
968
1086
  return {
969
- imports: t.slice(s, s + 50).map(j),
970
- nextPageToken: s + 50 < t.length ? String(s + 50) : ""
1087
+ // As importhub's ListImports, without the asset moves, which
1088
+ // grow with the Source File; getImport reads them.
1089
+ imports: t.slice(n, n + 50).map((r) => ({ ...F(r), assetMoves: [] })),
1090
+ nextPageToken: n + 50 < t.length ? String(n + 50) : ""
971
1091
  };
972
1092
  }),
973
1093
  getImport: (e) => d("getImport", () => {
974
- const t = Z(e);
975
- return Y(t), j(t);
1094
+ const t = B(e);
1095
+ return ee(t), F(t);
976
1096
  }),
977
1097
  cancelImport: (e) => d("cancelImport", () => {
978
- const t = Z(e);
1098
+ const t = B(e);
979
1099
  if (t.phase === "ended") throw new Error("the Import has ended");
980
- return t.cancelledBy ||= b, t.phase === "queued" && Y(t), j(t);
1100
+ return t.cancelledBy ||= y, t.phase === "queued" && ee(t), F(t);
1101
+ }),
1102
+ rerunImport: (e) => d("rerunImport", () => {
1103
+ const t = B(e);
1104
+ if (t.sourceFileDeleteTime)
1105
+ throw new D(
1106
+ `the Source File was deleted at ${t.sourceFileDeleteTime}: ${t.sourceFileDeletionReason}`
1107
+ );
1108
+ return Q.add(t.sourceFileId), F(
1109
+ te(
1110
+ {
1111
+ importProfileId: t.importProfileId,
1112
+ sourceFileId: t.sourceFileId,
1113
+ effectiveDate: t.effectiveDate,
1114
+ ...t.source ? { source: t.source } : {},
1115
+ draft: t.draft
1116
+ },
1117
+ t.dryRun
1118
+ )
1119
+ );
981
1120
  }),
982
1121
  listItemProblems: (e, t) => d("listItemProblems", () => {
983
- const s = Z(e).itemProblems ?? [], i = t.sourceKeyQuery.toLowerCase(), l = s.filter(
984
- (f) => (!t.mappingId || f.mappingId === t.mappingId) && f.sourceKey.toLowerCase().includes(i)
1122
+ const n = B(e).itemProblems ?? [], r = t.sourceKeyQuery.toLowerCase(), c = n.filter(
1123
+ (u) => (!t.mappingId || u.mappingId === t.mappingId) && u.sourceKey.toLowerCase().includes(r)
985
1124
  ), p = /* @__PURE__ */ new Map();
986
- for (const f of s) {
987
- const u = p.get(f.mappingId) ?? {
988
- mappingId: f.mappingId,
989
- mappingName: f.mappingName,
1125
+ for (const u of n) {
1126
+ const h = p.get(u.mappingId) ?? {
1127
+ mappingId: u.mappingId,
1128
+ mappingName: u.mappingName,
990
1129
  count: 0
991
1130
  };
992
- u.count++, p.set(f.mappingId, u);
1131
+ h.count++, p.set(u.mappingId, h);
993
1132
  }
994
- const c = Number(t.pageToken || "0");
1133
+ const l = Number(t.pageToken || "0");
1134
+ return {
1135
+ itemProblems: c.slice(l, l + 50),
1136
+ totalCount: n.length,
1137
+ matchingCount: c.length,
1138
+ mappings: [...p.values()].sort((u, h) => u.mappingName.localeCompare(h.mappingName)),
1139
+ pendingReferenceCount: n.filter((u) => u.pendingReference).length,
1140
+ nextPageToken: l + 50 < c.length ? String(l + 50) : ""
1141
+ };
1142
+ }),
1143
+ startDryRun: (e) => d("startDryRun", () => F(te(e, !0))),
1144
+ listDryRunContents: (e, t) => d("listDryRunContents", () => {
1145
+ const n = B(e);
1146
+ if (!n.dryRun) throw new Error("the Import is no Dry Run");
1147
+ const r = n.dryRunContents ?? [], c = t.sourceKeyQuery.toLowerCase(), p = r.filter(
1148
+ (u) => (!t.action || u.action === t.action) && (!t.mappingId || u.mappingId === t.mappingId) && u.sourceKey.toLowerCase().includes(c)
1149
+ ), l = Number(t.pageToken || "0");
995
1150
  return {
996
- itemProblems: l.slice(c, c + 50),
997
- totalCount: s.length,
998
- matchingCount: l.length,
999
- mappings: [...p.values()].sort((f, u) => f.mappingName.localeCompare(u.mappingName)),
1000
- nextPageToken: c + 50 < l.length ? String(c + 50) : ""
1151
+ contents: p.slice(l, l + 50),
1152
+ totalCount: r.length,
1153
+ matchingCount: p.length,
1154
+ nextPageToken: l + 50 < p.length ? String(l + 50) : ""
1001
1155
  };
1002
1156
  }),
1003
- listApiKeys: () => d("listApiKeys", () => r().apiKeys),
1157
+ listApiKeys: () => d("listApiKeys", () => o().apiKeys),
1004
1158
  createApiKey: (e) => d("createApiKey", () => {
1005
1159
  const t = e.name.trim();
1006
1160
  if (!t) throw new Error("a name is required");
1007
- if (t.length > pe)
1008
- throw new Error(`the name is longer than ${pe} characters`);
1009
- const s = e.expireTime ? new Date(e.expireTime).toISOString() : "";
1010
- if (s && Date.parse(s) <= Date.now())
1161
+ if (t.length > de)
1162
+ throw new Error(`the name is longer than ${de} characters`);
1163
+ const n = e.expireTime ? new Date(e.expireTime).toISOString() : "";
1164
+ if (n && Date.parse(n) <= Date.now())
1011
1165
  throw new Error("the expiry must lie in the future");
1012
- const i = ++he, l = {
1013
- id: `key_stub_new_${i}`,
1166
+ const r = ++_e, c = {
1167
+ id: `key_stub_new_${r}`,
1014
1168
  name: t,
1015
- keyPrefix: `ihk_n${String(i).padStart(3, "0")}`,
1016
- owner: b,
1017
- expireTime: s,
1169
+ keyPrefix: `ihk_n${String(r).padStart(3, "0")}`,
1170
+ owner: y,
1171
+ expireTime: n,
1018
1172
  createTime: (/* @__PURE__ */ new Date()).toISOString()
1019
1173
  };
1020
- return r().apiKeys.unshift(l), { apiKey: l, secret: `${l.keyPrefix}_stub_secret_${i}` };
1174
+ return o().apiKeys.unshift(c), { apiKey: c, secret: `${c.keyPrefix}_stub_secret_${r}` };
1021
1175
  }),
1022
1176
  revokeApiKey: (e) => d("revokeApiKey", () => {
1023
- const t = r();
1024
- if (!t.apiKeys.some((s) => s.id === e)) throw new Error(`API key ${e} not found`);
1025
- t.apiKeys = t.apiKeys.filter((s) => s.id !== e);
1177
+ const t = o();
1178
+ if (!t.apiKeys.some((n) => n.id === e)) throw new Error(`API key ${e} not found`);
1179
+ t.apiKeys = t.apiKeys.filter((n) => n.id !== e);
1026
1180
  })
1027
1181
  };
1028
1182
  }
1029
- function Oe(n) {
1030
- const a = [], o = { "]": "[", ")": "(" };
1031
- for (const m of n)
1183
+ function Oe(s) {
1184
+ const a = [], i = { "]": "[", ")": "(" };
1185
+ for (const m of s)
1032
1186
  if (m === "[" || m === "(") a.push(m);
1033
- else if (m in o && a.pop() !== o[m]) return !1;
1187
+ else if (m in i && a.pop() !== i[m]) return !1;
1034
1188
  return a.length === 0;
1035
1189
  }
1036
- function ie(n, a, o) {
1037
- const m = `${a}${String(n.name ?? "")}`;
1190
+ function ae(s, a, i) {
1191
+ const m = `${a}${String(s.name ?? "")}`;
1038
1192
  return [
1039
- { path: m, rel: o, mapping: n },
1193
+ { path: m, rel: i, mapping: s },
1040
1194
  ...["fields", "virtualTableFields"].flatMap(
1041
- (g) => (Array.isArray(n[g]) ? n[g] : []).flatMap(
1042
- (y, r) => ie(y, `${m}.`, `${o}/${g}/${r}`)
1195
+ (f) => (Array.isArray(s[f]) ? s[f] : []).flatMap(
1196
+ (b, o) => ae(b, `${m}.`, `${i}/${f}/${o}`)
1043
1197
  )
1044
1198
  )
1045
1199
  ];
1046
1200
  }
1047
- function Le(n = ge()) {
1201
+ function He(s = be()) {
1048
1202
  return {
1049
1203
  async listBlueprints() {
1050
- return [...new Map(n.map((o) => [o.blueprintId, o.blueprintName]))].map(([o, m]) => ({ id: o, name: m })).sort((o, m) => o.name.localeCompare(m.name));
1204
+ return [...new Map(s.map((i) => [i.blueprintId, i.blueprintName]))].map(([i, m]) => ({ id: i, name: m })).sort((i, m) => i.name.localeCompare(m.name));
1051
1205
  },
1052
1206
  async listReleases(a) {
1053
- return n.filter((o) => o.blueprintId === a).map((o) => ({ id: o.id, label: o.label }));
1207
+ return s.filter((i) => i.blueprintId === a).map((i) => ({ id: i.id, label: i.label }));
1054
1208
  },
1055
1209
  async getRelease(a) {
1056
- const o = n.find((m) => m.id === a);
1057
- if (!o) throw new Error(`Blueprint Release ${a} not found`);
1210
+ const i = s.find((m) => m.id === a);
1211
+ if (!i) throw new Error(`Blueprint Release ${a} not found`);
1058
1212
  return {
1059
- id: o.id,
1060
- blueprintId: o.blueprintId,
1061
- name: o.label,
1062
- fields: o.fields ?? o.fieldPaths.map((m) => ({
1213
+ id: i.id,
1214
+ blueprintId: i.blueprintId,
1215
+ name: i.label,
1216
+ fields: i.fields ?? i.fieldPaths.map((m) => ({
1063
1217
  accessor: m,
1064
1218
  path: m,
1065
1219
  fieldType: "text",
1066
1220
  label: "",
1067
1221
  children: []
1068
1222
  })),
1069
- releaseSpecFields: o.releaseSpecFields ?? []
1223
+ releaseSpecFields: i.releaseSpecFields ?? []
1070
1224
  };
1071
1225
  }
1072
1226
  };
1073
1227
  }
1074
- function Fe(n, a, o) {
1075
- const m = (n.displayNameTemplate ?? "").trim(), g = (n.displayNameField ?? "").trim(), y = (d, h, _) => [
1076
- { path: d, code: h, message: _ }
1228
+ function Ke(s, a, i) {
1229
+ const m = (s.displayNameTemplate ?? "").trim(), f = (s.displayNameField ?? "").trim(), b = (d, g, _) => [
1230
+ { path: d, code: g, message: _ }
1077
1231
  ];
1078
- if (!m && !g) return [];
1079
- if (!g)
1080
- return y(
1232
+ if (!m && !f) return [];
1233
+ if (!f)
1234
+ return b(
1081
1235
  "/display_name_field",
1082
1236
  "incomplete_display_name",
1083
1237
  "the display-name template names no field to write the display name into"
1084
1238
  );
1085
1239
  if (!m)
1086
- return y(
1240
+ return b(
1087
1241
  "/display_name_template",
1088
1242
  "incomplete_display_name",
1089
- `the display-name field "${g}" has no display-name template to fill it`
1243
+ `the display-name field "${f}" has no display-name template to fill it`
1090
1244
  );
1091
1245
  if (!a) return [];
1092
- const r = (d) => d.flatMap((h) => [h.path, ...r(h.children)]);
1093
- return r(a).includes(g) ? Pe(a).some((d) => d.path === g) ? o.includes(g) ? y(
1246
+ const o = (d) => d.flatMap((g) => [g.path, ...o(g.children)]);
1247
+ return o(a).includes(f) ? ve(a).some((d) => d.path === f) ? i.includes(f) ? b(
1094
1248
  "/display_name_field",
1095
1249
  "display_name_field_mapped",
1096
- `the field "${g}" is mapped too: it takes the display name or a mapped value, not both`
1097
- ) : [] : y(
1250
+ `the field "${f}" is mapped too: it takes the display name or a mapped value, not both`
1251
+ ) : [] : b(
1098
1252
  "/display_name_field",
1099
1253
  "display_name_field_not_plain_text",
1100
- `the display-name field "${g}" is not a plain-text one (text or textarea)`
1101
- ) : y(
1254
+ `the display-name field "${f}" is not a plain-text one (text or textarea)`
1255
+ ) : b(
1102
1256
  "/display_name_field",
1103
1257
  "unknown_display_name_field",
1104
- `the Blueprint Release has no field "${g}" to write the display name into`
1258
+ `the Blueprint Release has no field "${f}" to write the display name into`
1105
1259
  );
1106
1260
  }
1107
1261
  export {
1108
- H as STUB_OTHER_USER_ID,
1109
- De as STUB_OTHER_WORKSPACE_ID,
1110
- b as STUB_USER_ID,
1111
- ne as STUB_WORKSPACE_ID,
1112
- Le as createStubBlueprints,
1113
- Ge as createStubImporthubClient,
1114
- Me as stubApiKeys,
1115
- ge as stubBlueprintReleases,
1116
- ve as stubEntitySets,
1117
- Ze as stubIdentity,
1118
- $e as stubImportProfiles,
1119
- Re as stubImports,
1262
+ U as STUB_OTHER_USER_ID,
1263
+ Ge as STUB_OTHER_WORKSPACE_ID,
1264
+ y as STUB_USER_ID,
1265
+ oe as STUB_WORKSPACE_ID,
1266
+ He as createStubBlueprints,
1267
+ qe as createStubImporthubClient,
1268
+ Be as stubApiKeys,
1269
+ be as stubBlueprintReleases,
1270
+ Ee as stubEntitySets,
1271
+ Le as stubIdentity,
1272
+ Me as stubImportProfiles,
1273
+ Ne as stubImports,
1120
1274
  je as stubMappingTestSample,
1121
- Te as stubMappings,
1122
- Ee as stubProcessors
1275
+ $e as stubMappings,
1276
+ ke as stubProcessors
1123
1277
  };
1124
1278
  //# sourceMappingURL=testing.js.map