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