@knkcs/importhub-ui 0.4.0 → 0.6.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 _e } from "@knkcs/anker/host";
2
+ import { A as ce, S as M, R as Q, C as le, N as ye } from "./importhub-client-BS6F4DW2.js";
3
+ const h = "user_stub_ada", q = "user_stub_grace", te = "ws_stub_main", Be = "ws_stub_other";
4
+ function Ae(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: h,
7
+ workspaceId: r,
8
+ members: _e([
9
+ { userId: h, displayName: "Ada Importer", email: "ada@example.com" },
10
+ { userId: q, 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 _ = (r, c, l, u = []) => ({
15
+ accessor: r.split(".").pop() ?? r,
16
+ path: r,
17
+ fieldType: c,
18
+ label: l,
19
+ children: u
20
+ }), j = (r) => r.flatMap((c) => [c.path, ...j(c.children)]), pe = (r) => [
21
+ _("titel", "text", "Titel"),
22
+ _("abkuerzung", "text", "Abkürzung"),
23
+ ...r ? [_("fussnote", "rich_text", "Fußnote")] : [],
24
+ _("stand", "fieldset", "Stand", [
25
+ _("stand.datum", "date", "Datum"),
26
+ _("stand.art", "select", "Art")
26
27
  ])
27
- ], X = () => [
28
- h("fundstelle", "text", "Fundstelle"),
29
- h("ausgabedatum", "date", "Ausgabedatum")
28
+ ], de = () => [
29
+ _("fundstelle", "text", "Fundstelle"),
30
+ _("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 ge() {
33
+ const r = pe(!1), c = pe(!0), l = [
34
+ _("aktenzeichen", "text", "Aktenzeichen"),
35
+ _("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: j(r),
44
+ fields: r,
45
+ releaseSpecFields: de()
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: j(c),
53
+ fields: c,
54
+ releaseSpecFields: de()
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: j(l),
62
+ fields: l
62
63
  }
63
64
  ];
64
65
  }
65
- function re() {
66
+ function Ie() {
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 Se() {
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 we() {
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 X = (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 Pe() {
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
+ X("from", "Element", !0, "The element's name now."),
170
+ X("to", "New name", !0)
170
171
  ]
171
172
  },
172
173
  {
@@ -174,11 +175,173 @@ 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: [X("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
+ }), w = (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: h,
217
+ phase: "ended",
218
+ failureReason: "",
219
+ progress: { done: 0, total: 0 },
220
+ counts: $(),
221
+ changeSetId: "",
222
+ releases: w(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, b) => ({
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: b
236
+ });
237
+ function ve() {
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: q,
252
+ releases: w(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
+ ...w(2),
269
+ mappings: [
270
+ ...w(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: w(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: w(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: q,
316
+ counts: $({ matched: 12, created: 3 }),
317
+ releases: w(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
+ function Te() {
325
+ return [
326
+ {
327
+ id: "key_stub_nightly",
328
+ name: "Nightly gesetz feed",
329
+ keyPrefix: "ihk_7Qx2",
330
+ owner: q,
331
+ expireTime: "",
332
+ createTime: "2026-11-20T07:30:00.000Z"
333
+ },
334
+ {
335
+ id: "key_stub_pipeline",
336
+ name: "VRPML pipeline",
337
+ keyPrefix: "ihk_b91F",
338
+ owner: h,
339
+ expireTime: "2027-06-30T21:59:59.000Z",
340
+ createTime: "2026-11-03T12:00:00.000Z"
341
+ }
342
+ ];
343
+ }
344
+ const Re = [
182
345
  "listImportProfiles",
183
346
  "getImportProfile",
184
347
  "createImportProfile",
@@ -200,82 +363,101 @@ const pe = [
200
363
  "cutRelease",
201
364
  "listHistory",
202
365
  "compareRevisions",
203
- "restoreRevision"
366
+ "restoreRevision",
367
+ "uploadSourceFile",
368
+ "startImport",
369
+ "listImports",
370
+ "getImport",
371
+ "cancelImport",
372
+ "listItemProblems",
373
+ "listApiKeys",
374
+ "createApiKey",
375
+ "revokeApiKey"
204
376
  ];
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(),
377
+ let me = Date.parse("2026-11-02T08:00:00Z");
378
+ const P = () => (me += 36e5, new Date(me).toISOString()), ee = (r = []) => r.map((c) => {
379
+ const l = Math.max(c.releaseNumber ?? 0, 1), u = Array.from({ length: l }, (y, p) => ({
380
+ id: `${c.id}_r${p + 1}`,
381
+ content: structuredClone(c.content),
382
+ savedBy: h,
383
+ savedAt: P(),
212
384
  restoredFromRevisionId: ""
213
- })), b = Array.from({ length: o.releaseNumber ?? 0 }, (I, p) => ({
214
- id: `${o.id}_rel${p + 1}`,
385
+ })), b = Array.from({ length: c.releaseNumber ?? 0 }, (y, p) => ({
386
+ id: `${c.id}_rel${p + 1}`,
215
387
  number: p + 1,
216
- revisionId: `${o.id}_r${p + 1}`,
217
- releasedBy: S,
218
- releasedAt: R()
388
+ revisionId: `${c.id}_r${p + 1}`,
389
+ releasedBy: h,
390
+ releasedAt: P()
219
391
  }));
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);
392
+ return { id: c.id, content: structuredClone(c.content), revisions: u, releases: b };
393
+ }), A = (r) => r.revisions[r.revisions.length - 1], he = (r) => r.releases[r.releases.length - 1], Z = (r) => {
394
+ const c = he(r), l = r.revisions.find((u) => u.id === c?.revisionId);
223
395
  return {
224
- draftRevisionId: E(i).id,
396
+ draftRevisionId: A(r).id,
225
397
  // By content, as importhub compares: a draft that restored the
226
398
  // 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 } } : {}
399
+ draftDiffersFromRelease: !l || JSON.stringify(l.content) !== JSON.stringify(A(r).content),
400
+ ...c ? { latestRelease: { id: c.id, number: c.number } } : {}
229
401
  };
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(
402
+ }, $e = (r) => r.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`), ue = (r) => Object.fromEntries(
403
+ Object.entries(r).map(([c, l]) => [$e(c), l])
404
+ ), R = (r) => ({
405
+ valid: r.length === 0,
406
+ reasons: r
407
+ }), D = (r) => [...r].sort((c, l) => c.content.name.localeCompare(l.content.name));
408
+ let fe = 0;
409
+ function Ne(r = {}) {
410
+ const c = Object.fromEntries(
239
411
  Object.entries(
240
- i.workspaces ?? {
241
- [U]: {
242
- importProfiles: ae(),
243
- mappings: re(),
244
- entitySets: oe()
412
+ r.workspaces ?? {
413
+ [te]: {
414
+ importProfiles: we(),
415
+ mappings: Ie(),
416
+ entitySets: Se(),
417
+ imports: ve(),
418
+ apiKeys: Te()
245
419
  }
246
420
  }
247
421
  ).map(([e, t]) => [
248
422
  e,
249
423
  {
250
- importProfiles: H(t.importProfiles),
251
- mappings: H(t.mappings),
252
- entitySets: H(t.entitySets)
424
+ importProfiles: ee(t.importProfiles),
425
+ mappings: ee(t.mappings),
426
+ entitySets: ee(t.entitySets),
427
+ imports: structuredClone(t.imports ?? []),
428
+ apiKeys: structuredClone(t.apiKeys ?? [])
253
429
  }
254
430
  ])
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;
431
+ ), l = r.processors ?? Pe(), u = r.blueprintReleases ?? ge();
432
+ let b = r.activeWorkspaceId ?? te;
433
+ const y = Object.fromEntries(Re.map((e) => [e, 0])), p = () => (c[b] ??= {
434
+ importProfiles: [],
435
+ mappings: [],
436
+ entitySets: [],
437
+ imports: [],
438
+ apiKeys: []
439
+ }, c[b]), f = async (e, t) => {
440
+ if (y[e]++, r.fail) throw r.fail;
259
441
  return structuredClone(t());
260
442
  }, g = (e, t, s) => {
261
- const n = e.find((c) => c.id === t);
443
+ const n = e.find((i) => i.id === t);
262
444
  if (!n) throw new Error(`${s} ${t} not found`);
263
445
  return n;
264
446
  }, v = (e, t, s) => {
265
447
  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))
448
+ if (e.some((n) => n.id !== s && n.content.name === t)) throw new ye();
449
+ }, ne = (e, t) => t !== "" && t !== A(e).id, N = (e, t, s, n = "") => {
450
+ if (ne(e, s))
269
451
  throw new Error("the draft moved: somebody saved in between");
270
452
  e.content = structuredClone(t), e.revisions.push({
271
453
  id: `${e.id}_r${e.revisions.length + 1}`,
272
454
  content: structuredClone(t),
273
- savedBy: S,
274
- savedAt: R(),
455
+ savedBy: h,
456
+ savedAt: P(),
275
457
  restoredFromRevisionId: n
276
458
  });
277
- }, z = (e, t) => {
278
- const s = te(e);
459
+ }, G = (e, t) => {
460
+ const s = H(e);
279
461
  return {
280
462
  id: s,
281
463
  content: structuredClone(t),
@@ -283,16 +465,16 @@ function _e(i = {}) {
283
465
  {
284
466
  id: `${s}_r1`,
285
467
  content: structuredClone(t),
286
- savedBy: S,
287
- savedAt: R(),
468
+ savedBy: h,
469
+ savedAt: P(),
288
470
  restoredFromRevisionId: ""
289
471
  }
290
472
  ],
291
473
  releases: []
292
474
  };
293
475
  };
294
- function N(e) {
295
- const t = [], s = d.find((r) => r.id === e.blueprintReleaseId);
476
+ function J(e) {
477
+ const t = [], s = u.find((o) => o.id === e.blueprintReleaseId);
296
478
  e.blueprintReleaseId ? s ? s.blueprintId !== e.blueprintId && t.push({
297
479
  path: "/blueprintReleaseId",
298
480
  code: "release_of_other_blueprint",
@@ -310,85 +492,85 @@ function _e(i = {}) {
310
492
  code: "no_element_selector",
311
493
  message: "It has no element selector."
312
494
  }), !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.` });
495
+ const n = (o, a) => {
496
+ typeof a == "string" && a !== "" && !Ee(a) && t.push({ path: o, code: "invalid_xpath", message: `"${a}" is not an XPath.` });
315
497
  };
316
498
  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,
499
+ const i = [];
500
+ return (e.fields ?? []).forEach((o, a) => {
501
+ const m = `/fields/${a}`;
502
+ for (const { path: d, rel: k, mapping: S } of se(o, "", m))
503
+ i.push(d), n(`${k}/selector`, S.selector), s && !s.fieldPaths.includes(d) && t.push({
504
+ path: m,
323
505
  code: "unknown_field_path",
324
- message: `The pinned Release has no field ${m}.`
325
- }), y.type === "select" && !y.selectOptions && t.push({
326
- path: f,
506
+ message: `The pinned Release has no field ${d}.`
507
+ }), S.type === "select" && !S.selectOptions && t.push({
508
+ path: m,
327
509
  code: "xmlmapper_schema",
328
- message: `The select field ${m} has no select options.`
510
+ message: `The select field ${d} has no select options.`
329
511
  });
330
- }), (e.versionMatch?.contentFields ?? []).forEach((r, l) => {
331
- c.includes(r) || t.push({
332
- path: `/version_match/content_fields/${l}`,
512
+ }), (e.versionMatch?.contentFields ?? []).forEach((o, a) => {
513
+ i.includes(o) || t.push({
514
+ path: `/version_match/content_fields/${a}`,
333
515
  code: "unknown_version_match_field",
334
- message: `The Version Match compares ${r}, which the Mapping does not map.`
516
+ message: `The Version Match compares ${o}, which the Mapping does not map.`
335
517
  });
336
- }), (e.titleContributions ?? []).forEach((r, l) => {
337
- (!r.selector || !r.ausgabeCodeSelector) && t.push({
338
- path: `/title_contributions/${l}`,
518
+ }), (e.titleContributions ?? []).forEach((o, a) => {
519
+ (!o.selector || !o.ausgabeCodeSelector) && t.push({
520
+ path: `/title_contributions/${a}`,
339
521
  code: "incomplete_title_contribution",
340
522
  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}`,
523
+ }), n(`/title_contributions/${a}/selector`, o.selector);
524
+ }), (e.placeholderAssets ?? []).forEach((o, a) => {
525
+ (!o.selector || !o.assetType || !o.keyParts?.length || !o.nameSelector) && t.push({
526
+ path: `/placeholder_assets/${a}`,
345
527
  code: "incomplete_placeholder_assets",
346
528
  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);
529
+ }), n(`/placeholder_assets/${a}/selector`, o.selector), (o.keyParts ?? []).forEach((m, d) => {
530
+ n(`/placeholder_assets/${a}/key_parts/${d}`, m);
349
531
  });
350
532
  }), t;
351
533
  }
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" ? [
534
+ function re(e, t, s) {
535
+ return e.flatMap((n, i) => {
536
+ const o = `/${t}/${i}`, a = l.find((d) => d.name === n.processor);
537
+ return a ? a.target !== "source_file" ? [
356
538
  {
357
- path: r,
539
+ path: o,
358
540
  code: "rich_text_processor",
359
- message: `${l.name} is configured on a rich-text field, not on a Profile.`
541
+ message: `${a.name} is configured on a rich-text field, not on a Profile.`
360
542
  }
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}`,
543
+ ] : a.kind !== s ? [{ path: o, code: "wrong_processor_kind", message: `${a.name} does not run here.` }] : a.settingsSpec.filter(
544
+ (d) => d.config.required && (n.settings[d.config.api_accessor] ?? "") === ""
545
+ ).map((d) => ({
546
+ path: `${o}/settings/${d.config.api_accessor}`,
365
547
  code: "invalid_processor_settings",
366
- message: `${l.name}: ${m.config.api_accessor} is required.`
548
+ message: `${a.name}: ${d.config.api_accessor} is required.`
367
549
  })) : [
368
- { path: r, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
550
+ { path: o, code: "unknown_processor", message: `No Processor is called ${n.processor}.` }
369
551
  ];
370
552
  });
371
553
  }
372
- function q(e) {
554
+ function L(e) {
373
555
  const t = p(), s = [
374
- ...J(e.preprocessors, "preprocessors", "preprocessor"),
375
- ...J(e.postProcessors, "postProcessors", "post_processor")
556
+ ...re(e.preprocessors, "preprocessors", "preprocessor"),
557
+ ...re(e.postProcessors, "postProcessors", "post_processor")
376
558
  ];
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) {
559
+ return e.mappingIds.length === 0 && s.push({ path: "/mappingIds", code: "no_mappings", message: "It includes no Mapping." }), e.mappingIds.forEach((n, i) => {
560
+ const o = t.mappings.find((m) => m.id === n);
561
+ if (!o) {
380
562
  s.push({
381
- path: `/mappingIds/${c}`,
563
+ path: `/mappingIds/${i}`,
382
564
  code: "mapping_missing",
383
565
  message: "It includes a Mapping that does not exist."
384
566
  });
385
567
  return;
386
568
  }
387
- const l = N(r.content);
388
- l.length > 0 && s.push({
389
- path: `/mappingIds/${c}`,
569
+ const a = J(o.content);
570
+ a.length > 0 && s.push({
571
+ path: `/mappingIds/${i}`,
390
572
  code: "mapping_invalid",
391
- message: `The Mapping ${r.content.name} is invalid: ${l.map((f) => f.message).join(" ")}`
573
+ message: `The Mapping ${o.content.name} is invalid: ${a.map((m) => m.message).join(" ")}`
392
574
  });
393
575
  }), e.entitySetId && !t.entitySets.some((n) => n.id === e.entitySetId) && s.push({
394
576
  path: "/entitySetId",
@@ -396,241 +578,393 @@ function _e(i = {}) {
396
578
  message: "It names an Entity Set that does not exist."
397
579
  }), s;
398
580
  }
399
- const G = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], k = (e) => ({
581
+ const ie = (e) => Object.keys(e.entities).length === 0 ? [{ path: "/entities", code: "no_entities", message: "It defines no entity." }] : [], x = (e) => ({
400
582
  id: e.id,
401
583
  content: e.content,
402
- validity: P(q(e.content)),
403
- state: x(e)
584
+ validity: R(L(e.content)),
585
+ state: Z(e)
404
586
  }), O = (e) => ({
405
587
  id: e.id,
406
588
  content: e.content,
407
- validity: P(N(e.content)),
408
- state: x(e)
409
- }), B = (e) => ({
589
+ validity: R(J(e.content)),
590
+ state: Z(e)
591
+ }), F = (e) => ({
410
592
  id: e.id,
411
593
  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) => ({
594
+ validity: R(ie(e.content)),
595
+ state: Z(e)
596
+ }), K = (e) => D(p().importProfiles.filter((t) => e(t.content))).map((t) => ({
415
597
  id: t.id,
416
598
  name: t.content.name
417
- })), te = (e) => `${e}_stub_new_${++me}`, w = (e) => {
599
+ })), H = (e) => `${e}_stub_new_${++fe}`, E = (e) => {
418
600
  const t = p();
419
601
  switch (e) {
420
602
  case "importProfile":
421
603
  return {
422
604
  items: t.importProfiles,
423
605
  name: "Import Profile",
424
- reasons: (s) => q(s)
606
+ reasons: (s) => L(s)
425
607
  };
426
608
  case "mapping":
427
609
  return {
428
610
  items: t.mappings,
429
611
  name: "Mapping",
430
- reasons: (s) => N(s)
612
+ reasons: (s) => J(s)
431
613
  };
432
614
  case "entitySet":
433
615
  return {
434
616
  items: t.entitySets,
435
617
  name: "Entity Set",
436
- reasons: (s) => G(s)
618
+ reasons: (s) => ie(s)
437
619
  };
438
620
  }
439
- }, _ = (e, t) => {
440
- E(t).validity = P(w(e).reasons(t.content));
441
- }, T = (e, t) => {
621
+ }, I = (e, t) => {
622
+ A(t).validity = R(E(e).reasons(t.content));
623
+ }, U = (e, t) => {
442
624
  const s = e.revisions.find((n) => n.id === t);
443
625
  if (!s) throw new Error(`Revision ${t} not found`);
444
626
  return s;
627
+ }, oe = /* @__PURE__ */ new Set(), ae = r.contenthubRights ?? ["editor", "publisher"], z = (e) => {
628
+ const t = p().imports.find((s) => s.id === e);
629
+ if (!t) throw new Error(`Import ${e} not found`);
630
+ return t;
631
+ }, W = (e) => {
632
+ e.cancelledBy && e.phase !== "ended" && (e.phase = "ended", e.outcome = "cancelled", e.endTime = P());
633
+ }, C = ({ itemProblems: e, ...t }) => t, V = (e, t) => {
634
+ const s = he(e);
635
+ if (!s)
636
+ throw new M(`the ${t} ${e.content.name} has no Release yet`);
637
+ const n = e.revisions.find((i) => i.id === s.revisionId)?.content ?? e.content;
638
+ return {
639
+ content: n,
640
+ ref: {
641
+ configurationId: e.id,
642
+ name: n.name,
643
+ releaseId: s.id,
644
+ number: s.number
645
+ }
646
+ };
445
647
  };
446
648
  return {
447
- calls: I,
649
+ calls: y,
448
650
  switchWorkspace(e) {
449
651
  b = e;
450
652
  },
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", () => {
653
+ updateImport(e, t) {
654
+ Object.assign(z(e), structuredClone(t));
655
+ },
656
+ listImportProfiles: () => f("listImportProfiles", () => D(p().importProfiles).map(x)),
657
+ getImportProfile: (e) => f("getImportProfile", () => x(g(p().importProfiles, e, "Import Profile"))),
658
+ createImportProfile: (e) => f("createImportProfile", () => {
454
659
  v(p().importProfiles, e.name);
455
- const t = z("ip", e);
456
- return _("importProfile", t), p().importProfiles.push(t), k(t);
660
+ const t = G("ip", e);
661
+ return I("importProfile", t), p().importProfiles.push(t), x(t);
457
662
  }),
458
- updateImportProfile: (e, t, s) => u("updateImportProfile", () => {
663
+ updateImportProfile: (e, t, s) => f("updateImportProfile", () => {
459
664
  const n = g(p().importProfiles, e, "Import Profile");
460
- return v(p().importProfiles, t.name, e), M(n, t, s), _("importProfile", n), k(n);
665
+ return v(p().importProfiles, t.name, e), N(n, t, s), I("importProfile", n), x(n);
461
666
  }),
462
- deleteImportProfile: (e) => u("deleteImportProfile", () => {
667
+ deleteImportProfile: (e) => f("deleteImportProfile", () => {
463
668
  g(p().importProfiles, e, "Import Profile"), p().importProfiles = p().importProfiles.filter((t) => t.id !== e);
464
669
  }),
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", () => {
670
+ listProcessors: () => f("listProcessors", () => [...l].sort((e, t) => e.name.localeCompare(t.name))),
671
+ listMappings: () => f("listMappings", () => D(p().mappings).map(O)),
672
+ getMapping: (e) => f("getMapping", () => O(g(p().mappings, e, "Mapping"))),
673
+ createMapping: (e) => f("createMapping", () => {
469
674
  v(p().mappings, e.name);
470
- const t = z("mp", e);
471
- return _("mapping", t), p().mappings.push(t), O(t);
675
+ const t = G("mp", e);
676
+ return I("mapping", t), p().mappings.push(t), O(t);
472
677
  }),
473
- updateMapping: (e, t, s) => u("updateMapping", () => {
678
+ updateMapping: (e, t, s) => f("updateMapping", () => {
474
679
  const n = g(p().mappings, e, "Mapping");
475
- return v(p().mappings, t.name, e), M(n, t, s), _("mapping", n), O(n);
680
+ return v(p().mappings, t.name, e), N(n, t, s), I("mapping", n), O(n);
476
681
  }),
477
- deleteMapping: (e) => u("deleteMapping", () => {
682
+ deleteMapping: (e) => f("deleteMapping", () => {
478
683
  g(p().mappings, e, "Mapping");
479
- const t = A((s) => s.mappingIds.includes(e));
684
+ const t = K((s) => s.mappingIds.includes(e));
480
685
  if (t.length > 0)
481
- throw new V(
686
+ throw new le(
482
687
  t,
483
688
  `the Mapping is included by ${t.map((s) => s.name).join(", ")}`
484
689
  );
485
690
  p().mappings = p().mappings.filter((s) => s.id !== e);
486
691
  }),
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);
692
+ listMappingImportProfiles: (e) => f("listMappingImportProfiles", () => (g(p().mappings, e, "Mapping"), K((t) => t.mappingIds.includes(e)))),
693
+ checkMappingBlueprintRelease: (e, t) => f("checkMappingBlueprintRelease", () => {
694
+ const s = g(p().mappings, e, "Mapping"), n = u.find((i) => i.id === t);
490
695
  if (!n) throw new Error(`Blueprint Release ${t} not found`);
491
696
  if (n.blueprintId !== s.content.blueprintId)
492
697
  throw new Error("the Release is of another Blueprint");
493
698
  return {
494
699
  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)),
700
+ missingFieldPaths: (s.content.fields ?? []).flatMap((i, o) => se(i, "", `/fields/${o}`).map((a) => a.path)).filter((i) => !n.fieldPaths.includes(i)),
496
701
  missingReleaseSpecFields: [
497
- ...(s.content.releaseSpec ?? []).map((c) => c.field ?? ""),
702
+ ...(s.content.releaseSpec ?? []).map((i) => i.field ?? ""),
498
703
  ...s.content.versionMatch?.releaseSpecFields ?? []
499
704
  ].filter(
500
- (c, r, l) => c !== "" && l.indexOf(c) === r && !(n.releaseSpecFields ?? []).some((f) => f.path === c)
705
+ (i, o, a) => i !== "" && a.indexOf(i) === o && !(n.releaseSpecFields ?? []).some((m) => m.path === i)
501
706
  )
502
707
  };
503
708
  }),
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", () => {
709
+ listEntitySets: () => f("listEntitySets", () => D(p().entitySets).map(F)),
710
+ getEntitySet: (e) => f("getEntitySet", () => F(g(p().entitySets, e, "Entity Set"))),
711
+ createEntitySet: (e) => f("createEntitySet", () => {
507
712
  v(p().entitySets, e.name);
508
- const t = z("es", e);
509
- return _("entitySet", t), p().entitySets.push(t), B(t);
713
+ const t = G("es", e);
714
+ return I("entitySet", t), p().entitySets.push(t), F(t);
510
715
  }),
511
- updateEntitySet: (e, t, s) => u("updateEntitySet", () => {
716
+ updateEntitySet: (e, t, s) => f("updateEntitySet", () => {
512
717
  const n = g(p().entitySets, e, "Entity Set");
513
- return v(p().entitySets, t.name, e), M(n, t, s), _("entitySet", n), B(n);
718
+ return v(p().entitySets, t.name, e), N(n, t, s), I("entitySet", n), F(n);
514
719
  }),
515
- deleteEntitySet: (e) => u("deleteEntitySet", () => {
720
+ deleteEntitySet: (e) => f("deleteEntitySet", () => {
516
721
  g(p().entitySets, e, "Entity Set");
517
- const t = A((s) => s.entitySetId === e);
722
+ const t = K((s) => s.entitySetId === e);
518
723
  if (t.length > 0)
519
- throw new V(
724
+ throw new le(
520
725
  t,
521
726
  `the Entity Set is named by ${t.map((s) => s.name).join(", ")}`
522
727
  );
523
728
  p().entitySets = p().entitySets.filter((s) => s.id !== e);
524
729
  }),
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(
730
+ cutRelease: (e, t, s) => f("cutRelease", () => {
731
+ const n = E(e), i = g(n.items, t, n.name);
732
+ if (ne(i, s))
733
+ throw new Q("the draft moved: somebody saved in between");
734
+ const o = R(n.reasons(i.content));
735
+ if (!o.valid) throw new Q("the draft is invalid", o);
736
+ if (!Z(i).draftDiffersFromRelease)
737
+ throw new Q(
533
738
  "the draft does not differ from the latest Release: there is nothing to release"
534
739
  );
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()
740
+ const a = i.releases.length + 1, m = {
741
+ id: `${i.id}_rel${a}`,
742
+ number: a,
743
+ revisionId: A(i).id,
744
+ releasedBy: h,
745
+ releasedAt: P()
541
746
  };
542
- return c.releases.push(f), {
543
- release: f,
544
- importProfiles: e === "mapping" ? A((m) => m.mappingIds.includes(t)) : []
747
+ return i.releases.push(m), {
748
+ release: m,
749
+ importProfiles: e === "mapping" ? K((d) => d.mappingIds.includes(t)) : []
545
750
  };
546
751
  }),
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");
752
+ listHistory: (e, t, s) => f("listHistory", () => {
753
+ const n = E(e), i = g(n.items, t, n.name), o = [...i.revisions].reverse(), a = Number(s || "0");
549
754
  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
755
+ revisions: o.slice(a, a + 10).map((d) => ({
756
+ id: d.id,
757
+ savedBy: d.savedBy,
758
+ savedAt: d.savedAt,
759
+ validity: d.validity ?? R(n.reasons(d.content)),
760
+ restoredFromRevisionId: d.restoredFromRevisionId
556
761
  })),
557
- releases: [...c.releases].reverse(),
558
- nextPageToken: l + 10 < r.length ? String(l + 10) : ""
762
+ releases: [...i.releases].reverse(),
763
+ nextPageToken: a + 10 < o.length ? String(a + 10) : ""
559
764
  };
560
765
  }),
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 };
766
+ compareRevisions: (e, t, s, n) => f("compareRevisions", () => {
767
+ const i = E(e), o = g(i.items, t, i.name), a = ue(U(o, s).content), m = ue(U(o, n).content), d = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(m)])].map((k) => {
768
+ const S = a[k], Y = m[k], be = S === void 0 && Y !== void 0 ? "added" : S !== void 0 && Y === void 0 ? "removed" : JSON.stringify(S) === JSON.stringify(Y) ? "unchanged" : "changed";
769
+ return { field: k, status: be };
565
770
  });
566
771
  return {
567
- from: { revisionId: s, content: l },
568
- to: { revisionId: n, content: f },
569
- fields: m
772
+ from: { revisionId: s, content: a },
773
+ to: { revisionId: n, content: m },
774
+ fields: d
775
+ };
776
+ }),
777
+ restoreRevision: (e, t, s, n) => f("restoreRevision", () => {
778
+ const i = E(e), o = g(i.items, t, i.name);
779
+ N(o, U(o, s).content, n, s), I(e, o);
780
+ }),
781
+ async uploadSourceFile(e, t) {
782
+ if (y.uploadSourceFile++, r.fail) throw r.fail;
783
+ for (const n of [0.25, 0.5, 0.75])
784
+ await new Promise((i) => setTimeout(i, 20)), t(n);
785
+ if (r.uploadFails) throw r.uploadFails;
786
+ t(1);
787
+ const s = H("sf");
788
+ return oe.add(s), { id: s, fileName: e.name };
789
+ },
790
+ startImport: (e) => f("startImport", () => {
791
+ const t = p(), s = g(t.importProfiles, e.importProfileId, "Import Profile");
792
+ if (!oe.has(e.sourceFileId))
793
+ throw new M("nothing was uploaded to the Source File");
794
+ if (!ae.includes("editor"))
795
+ throw new M(
796
+ "starting an Import needs contenthub editor in the workspace"
797
+ );
798
+ const n = V(s, "Import Profile");
799
+ if (n.content.autoPublish && !ae.includes("publisher"))
800
+ throw new M(
801
+ "the Import Profile has Auto-publish, which needs contenthub publisher"
802
+ );
803
+ const i = L(n.content);
804
+ if (i.length > 0)
805
+ throw new M(
806
+ `the Import Profile ${n.ref.name} is invalid: ${i.map((d) => d.message).join(" ")}`
807
+ );
808
+ const o = n.content.mappingIds.map(
809
+ (d) => V(g(t.mappings, d, "Mapping"), "Mapping").ref
810
+ ), a = n.content.entitySetId ? V(g(t.entitySets, n.content.entitySetId, "Entity Set"), "Entity Set").ref : void 0, m = {
811
+ id: H("im"),
812
+ importProfileId: s.id,
813
+ importProfileName: n.ref.name,
814
+ sourceFileId: e.sourceFileId,
815
+ startedBy: h,
816
+ phase: "queued",
817
+ failureReason: "",
818
+ progress: { done: 0, total: 0 },
819
+ counts: {
820
+ matched: 0,
821
+ created: 0,
822
+ problems: 0,
823
+ planned: 0,
824
+ corrected: 0,
825
+ kept: 0,
826
+ unchanged: 0
827
+ },
828
+ changeSetId: "",
829
+ releases: {
830
+ importProfile: n.ref,
831
+ mappings: o,
832
+ ...a ? { entitySet: a } : {}
833
+ },
834
+ createTime: P(),
835
+ startTime: "",
836
+ endTime: "",
837
+ cancelledBy: "",
838
+ effectiveDate: e.effectiveDate ?? "",
839
+ ...e.source ? { source: e.source } : {},
840
+ itemProblems: []
841
+ };
842
+ return t.imports.unshift(m), C(m);
843
+ }),
844
+ listImports: (e) => f("listImports", () => {
845
+ const t = p().imports;
846
+ t.forEach(W);
847
+ const s = Number(e || "0");
848
+ return {
849
+ imports: t.slice(s, s + 50).map(C),
850
+ nextPageToken: s + 50 < t.length ? String(s + 50) : ""
851
+ };
852
+ }),
853
+ getImport: (e) => f("getImport", () => {
854
+ const t = z(e);
855
+ return W(t), C(t);
856
+ }),
857
+ cancelImport: (e) => f("cancelImport", () => {
858
+ const t = z(e);
859
+ if (t.phase === "ended") throw new Error("the Import has ended");
860
+ return t.cancelledBy ||= h, t.phase === "queued" && W(t), C(t);
861
+ }),
862
+ listItemProblems: (e, t) => f("listItemProblems", () => {
863
+ const s = z(e).itemProblems ?? [], n = t.sourceKeyQuery.toLowerCase(), i = s.filter(
864
+ (m) => (!t.mappingId || m.mappingId === t.mappingId) && m.sourceKey.toLowerCase().includes(n)
865
+ ), o = /* @__PURE__ */ new Map();
866
+ for (const m of s) {
867
+ const d = o.get(m.mappingId) ?? {
868
+ mappingId: m.mappingId,
869
+ mappingName: m.mappingName,
870
+ count: 0
871
+ };
872
+ d.count++, o.set(m.mappingId, d);
873
+ }
874
+ const a = Number(t.pageToken || "0");
875
+ return {
876
+ itemProblems: i.slice(a, a + 50),
877
+ totalCount: s.length,
878
+ matchingCount: i.length,
879
+ mappings: [...o.values()].sort((m, d) => m.mappingName.localeCompare(d.mappingName)),
880
+ nextPageToken: a + 50 < i.length ? String(a + 50) : ""
881
+ };
882
+ }),
883
+ listApiKeys: () => f("listApiKeys", () => p().apiKeys),
884
+ createApiKey: (e) => f("createApiKey", () => {
885
+ const t = e.name.trim();
886
+ if (!t) throw new Error("a name is required");
887
+ if (t.length > ce)
888
+ throw new Error(`the name is longer than ${ce} characters`);
889
+ const s = e.expireTime ? new Date(e.expireTime).toISOString() : "";
890
+ if (s && Date.parse(s) <= Date.now())
891
+ throw new Error("the expiry must lie in the future");
892
+ const n = ++fe, i = {
893
+ id: `key_stub_new_${n}`,
894
+ name: t,
895
+ keyPrefix: `ihk_n${String(n).padStart(3, "0")}`,
896
+ owner: h,
897
+ expireTime: s,
898
+ createTime: (/* @__PURE__ */ new Date()).toISOString()
570
899
  };
900
+ return p().apiKeys.unshift(i), { apiKey: i, secret: `${i.keyPrefix}_stub_secret_${n}` };
571
901
  }),
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);
902
+ revokeApiKey: (e) => f("revokeApiKey", () => {
903
+ const t = p();
904
+ if (!t.apiKeys.some((s) => s.id === e)) throw new Error(`API key ${e} not found`);
905
+ t.apiKeys = t.apiKeys.filter((s) => s.id !== e);
575
906
  })
576
907
  };
577
908
  }
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;
909
+ function Ee(r) {
910
+ const c = [], l = { "]": "[", ")": "(" };
911
+ for (const u of r)
912
+ if (u === "[" || u === "(") c.push(u);
913
+ else if (u in l && c.pop() !== l[u]) return !1;
914
+ return c.length === 0;
584
915
  }
585
- function L(i, o, a) {
586
- const d = `${o}${String(i.name ?? "")}`;
916
+ function se(r, c, l) {
917
+ const u = `${c}${String(r.name ?? "")}`;
587
918
  return [
588
- { path: d, rel: a, mapping: i },
919
+ { path: u, rel: l, mapping: r },
589
920
  ...["fields", "virtualTableFields"].flatMap(
590
- (b) => (Array.isArray(i[b]) ? i[b] : []).flatMap(
591
- (I, p) => L(I, `${d}.`, `${a}/${b}/${p}`)
921
+ (b) => (Array.isArray(r[b]) ? r[b] : []).flatMap(
922
+ (y, p) => se(y, `${u}.`, `${l}/${b}/${p}`)
592
923
  )
593
924
  )
594
925
  ];
595
926
  }
596
- function ye(i = ee()) {
927
+ function xe(r = ge()) {
597
928
  return {
598
929
  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));
930
+ 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
931
  },
601
- async listReleases(o) {
602
- return i.filter((a) => a.blueprintId === o).map((a) => ({ id: a.id, label: a.label }));
932
+ async listReleases(c) {
933
+ return r.filter((l) => l.blueprintId === c).map((l) => ({ id: l.id, label: l.label }));
603
934
  },
604
- async getRelease(o) {
605
- const a = i.find((d) => d.id === o);
606
- if (!a) throw new Error(`Blueprint Release ${o} not found`);
935
+ async getRelease(c) {
936
+ const l = r.find((u) => u.id === c);
937
+ if (!l) throw new Error(`Blueprint Release ${c} not found`);
607
938
  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,
939
+ id: l.id,
940
+ blueprintId: l.blueprintId,
941
+ name: l.label,
942
+ fields: l.fields ?? l.fieldPaths.map((u) => ({
943
+ accessor: u,
944
+ path: u,
614
945
  fieldType: "text",
615
946
  label: "",
616
947
  children: []
617
948
  })),
618
- releaseSpecFields: a.releaseSpecFields ?? []
949
+ releaseSpecFields: l.releaseSpecFields ?? []
619
950
  };
620
951
  }
621
952
  };
622
953
  }
623
954
  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
955
+ q as STUB_OTHER_USER_ID,
956
+ Be as STUB_OTHER_WORKSPACE_ID,
957
+ h as STUB_USER_ID,
958
+ te as STUB_WORKSPACE_ID,
959
+ xe as createStubBlueprints,
960
+ Ne as createStubImporthubClient,
961
+ Te as stubApiKeys,
962
+ ge as stubBlueprintReleases,
963
+ Se as stubEntitySets,
964
+ Ae as stubIdentity,
965
+ we as stubImportProfiles,
966
+ ve as stubImports,
967
+ Ie as stubMappings,
968
+ Pe as stubProcessors
635
969
  };
636
970
  //# sourceMappingURL=testing.js.map