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