@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
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { Schema } from '@knkcs/fieldkit/schema';
|
|
3
|
+
|
|
4
|
+
/** What moving a Mapping's draft to another Blueprint Release would lose. */
|
|
5
|
+
declare interface BlueprintReleaseCheck {
|
|
6
|
+
blueprintId: string;
|
|
7
|
+
/** Every mapped field path the Release does not have. */
|
|
8
|
+
missingFieldPaths: string[];
|
|
9
|
+
/** Every Release Spec field read or matched on that it does not have. */
|
|
10
|
+
missingReleaseSpecFields: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** What happens to a Changed Version (importhub.v1.ChangedVersionHandling). */
|
|
14
|
+
declare type ChangedVersionHandling = "CHANGED_VERSION_HANDLING_UNSPECIFIED" | "CHANGED_VERSION_HANDLING_CORRECT" | "CHANGED_VERSION_HANDLING_KEEP" | "CHANGED_VERSION_HANDLING_FAIL";
|
|
15
|
+
|
|
16
|
+
/** Two Revisions of one configuration, and how each top-level field differs. */
|
|
17
|
+
declare interface ConfigurationComparison {
|
|
18
|
+
from: ConfigurationVersion;
|
|
19
|
+
to: ConfigurationVersion;
|
|
20
|
+
fields: {
|
|
21
|
+
field: string;
|
|
22
|
+
status: FieldComparisonStatus;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** One page of a configuration's history. */
|
|
27
|
+
declare interface ConfigurationHistoryPage {
|
|
28
|
+
/** This page's Revisions, newest first. */
|
|
29
|
+
revisions: ConfigurationRevision[];
|
|
30
|
+
/** Every Release, newest first, on every page. */
|
|
31
|
+
releases: ConfigurationReleaseRecord[];
|
|
32
|
+
/** The token of the next page; "" on the last. */
|
|
33
|
+
nextPageToken: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The kinds of versioned configuration (ADR 0016). */
|
|
37
|
+
declare type ConfigurationKind = "importProfile" | "mapping" | "entitySet";
|
|
38
|
+
|
|
39
|
+
/** A Configuration Release, as a list names it: "Release 3". */
|
|
40
|
+
declare interface ConfigurationRelease {
|
|
41
|
+
id: string;
|
|
42
|
+
number: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A Configuration Release as the history lists it: who cut it, when, from what. */
|
|
46
|
+
declare interface ConfigurationReleaseRecord extends ConfigurationRelease {
|
|
47
|
+
/** The Revision it pins. */
|
|
48
|
+
revisionId: string;
|
|
49
|
+
/** The odon user id of the admin who cut it. */
|
|
50
|
+
releasedBy: string;
|
|
51
|
+
/** When it was cut, as an ISO 8601 timestamp. */
|
|
52
|
+
releasedAt: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** One saved Revision of a configuration, as its history lists it. */
|
|
56
|
+
declare interface ConfigurationRevision {
|
|
57
|
+
id: string;
|
|
58
|
+
/** The odon user id of who saved it; the host's members name them. */
|
|
59
|
+
savedBy: string;
|
|
60
|
+
/** When it was saved, as an ISO 8601 timestamp. */
|
|
61
|
+
savedAt: string;
|
|
62
|
+
/** Whether it could be released, as decided when it was saved. */
|
|
63
|
+
validity: Validity;
|
|
64
|
+
/** The Revision it restored; "" for an ordinary save. */
|
|
65
|
+
restoredFromRevisionId: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Where a configuration stands: its draft and its latest Release. */
|
|
69
|
+
declare interface ConfigurationState {
|
|
70
|
+
draftRevisionId: string;
|
|
71
|
+
/** Unset while the configuration has none. */
|
|
72
|
+
latestRelease?: ConfigurationRelease;
|
|
73
|
+
/** True when the draft differs from the latest Release, and while there is none. */
|
|
74
|
+
draftDiffersFromRelease: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* One side of a comparison: a Revision's content, keyed as importhub keys
|
|
79
|
+
* the compared fields (the proto's field names, such as `mapping_ids`).
|
|
80
|
+
*/
|
|
81
|
+
declare interface ConfigurationVersion {
|
|
82
|
+
revisionId: string;
|
|
83
|
+
content: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** One configuration of a kind, at its draft. */
|
|
87
|
+
declare interface Configured<C> {
|
|
88
|
+
id: string;
|
|
89
|
+
/** The draft's content. */
|
|
90
|
+
content: C;
|
|
91
|
+
/**
|
|
92
|
+
* Whether it is valid now: for Profiles and Mappings the service's
|
|
93
|
+
* `current_validity`, which counts what changed since the save (an
|
|
94
|
+
* included Mapping turned invalid, a Blueprint gone); for Entity Sets the
|
|
95
|
+
* validity as saved, the only one they have.
|
|
96
|
+
*/
|
|
97
|
+
validity: Validity;
|
|
98
|
+
state: ConfigurationState;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A Release cut, and for a Mapping the Import Profiles that take it. */
|
|
102
|
+
declare interface CutReleaseResult {
|
|
103
|
+
release: ConfigurationReleaseRecord;
|
|
104
|
+
/** The Profiles that include the Mapping; empty for other kinds. */
|
|
105
|
+
importProfiles: ImportProfileRef[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare type EntitySet = Configured<EntitySetContent>;
|
|
109
|
+
|
|
110
|
+
/** What an admin edits of an Entity Set. */
|
|
111
|
+
declare interface EntitySetContent {
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
/** Entity names without `&` and `;`, to the text each stands for. */
|
|
115
|
+
entities: Record<string, string>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare type FieldComparisonStatus = "unchanged" | "added" | "removed" | "changed";
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* What the screens ask of importhub. Every call acts on the caller's
|
|
122
|
+
* workspace, which importhub takes from the token's active workspace and
|
|
123
|
+
* never from an argument: a host switches workspace by switching the token.
|
|
124
|
+
* An update names the draft it was made on, and is refused when somebody
|
|
125
|
+
* saved in between.
|
|
126
|
+
*/
|
|
127
|
+
declare interface ImporthubClient {
|
|
128
|
+
/** Every Import Profile of the workspace, by name. */
|
|
129
|
+
listImportProfiles(): Promise<ImportProfile[]>;
|
|
130
|
+
getImportProfile(id: string): Promise<ImportProfile>;
|
|
131
|
+
createImportProfile(content: ImportProfileContent): Promise<ImportProfile>;
|
|
132
|
+
updateImportProfile(id: string, content: ImportProfileContent, draftRevisionId: string): Promise<ImportProfile>;
|
|
133
|
+
deleteImportProfile(id: string): Promise<void>;
|
|
134
|
+
/** The Processor catalogue, by name; the same in every workspace. */
|
|
135
|
+
listProcessors(): Promise<Processor[]>;
|
|
136
|
+
/** Every Mapping of the workspace, by name. */
|
|
137
|
+
listMappings(): Promise<Mapping[]>;
|
|
138
|
+
getMapping(id: string): Promise<Mapping>;
|
|
139
|
+
createMapping(content: MappingContent): Promise<Mapping>;
|
|
140
|
+
updateMapping(id: string, content: MappingContent, draftRevisionId: string): Promise<Mapping>;
|
|
141
|
+
/** Throws ConfigurationInUseError while a Profile includes it. */
|
|
142
|
+
deleteMapping(id: string): Promise<void>;
|
|
143
|
+
/** The Import Profiles whose draft or latest Release includes it. */
|
|
144
|
+
listMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;
|
|
145
|
+
/** Checks moving the draft to another Blueprint Release, saving nothing. */
|
|
146
|
+
checkMappingBlueprintRelease(id: string, blueprintReleaseId: string): Promise<BlueprintReleaseCheck>;
|
|
147
|
+
/** Every Entity Set of the workspace, by name. */
|
|
148
|
+
listEntitySets(): Promise<EntitySet[]>;
|
|
149
|
+
getEntitySet(id: string): Promise<EntitySet>;
|
|
150
|
+
createEntitySet(content: EntitySetContent): Promise<EntitySet>;
|
|
151
|
+
updateEntitySet(id: string, content: EntitySetContent, draftRevisionId: string): Promise<EntitySet>;
|
|
152
|
+
/** Throws ConfigurationInUseError while a Profile names it. */
|
|
153
|
+
deleteEntitySet(id: string): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Cuts a Configuration Release from the draft named. Throws
|
|
156
|
+
* ReleaseRefusedError, with the reasons when the draft is invalid.
|
|
157
|
+
*/
|
|
158
|
+
cutRelease(kind: ConfigurationKind, id: string, draftRevisionId: string): Promise<CutReleaseResult>;
|
|
159
|
+
/** One page of the history; pageToken "" for the first. */
|
|
160
|
+
listHistory(kind: ConfigurationKind, id: string, pageToken: string): Promise<ConfigurationHistoryPage>;
|
|
161
|
+
compareRevisions(kind: ConfigurationKind, id: string, fromRevisionId: string, toRevisionId: string): Promise<ConfigurationComparison>;
|
|
162
|
+
/** Saves an older Revision's content as a new draft, on the draft named. */
|
|
163
|
+
restoreRevision(kind: ConfigurationKind, id: string, revisionId: string, draftRevisionId: string): Promise<void>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare type ImportProfile = Configured<ImportProfileContent>;
|
|
167
|
+
|
|
168
|
+
/** What an admin edits of an Import Profile. */
|
|
169
|
+
declare interface ImportProfileContent {
|
|
170
|
+
name: string;
|
|
171
|
+
description: string;
|
|
172
|
+
/** The Entity Set the Source File is read with; "" for none. */
|
|
173
|
+
entitySetId: string;
|
|
174
|
+
/** In the order they run. */
|
|
175
|
+
preprocessors: ProcessorStep[];
|
|
176
|
+
/** The Mappings it includes, by id, in the order they run. */
|
|
177
|
+
mappingIds: string[];
|
|
178
|
+
/** In the order they run. */
|
|
179
|
+
postProcessors: ProcessorStep[];
|
|
180
|
+
autoPublish: boolean;
|
|
181
|
+
deleteSourceFileOnSuccess: boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** An Import Profile, named where another configuration is used. */
|
|
185
|
+
declare interface ImportProfileRef {
|
|
186
|
+
id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare type Mapping = Configured<MappingContent>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* What an admin edits of a Mapping, in the JSON shape of importhub.v1's
|
|
194
|
+
* MappingContent: its camelCase keys, enums by their names
|
|
195
|
+
* (`CHANGED_VERSION_HANDLING_KEEP`), unset settings left out. The settings are
|
|
196
|
+
* typed as the structured editor (F4) edits them; every key travels through
|
|
197
|
+
* as given, typed or not, so a save never drops one a screen does not show.
|
|
198
|
+
*/
|
|
199
|
+
declare interface MappingContent {
|
|
200
|
+
name: string;
|
|
201
|
+
description?: string;
|
|
202
|
+
blueprintId: string;
|
|
203
|
+
blueprintReleaseId: string;
|
|
204
|
+
elementSelector?: string;
|
|
205
|
+
sourceKey?: {
|
|
206
|
+
selector?: string;
|
|
207
|
+
template?: string;
|
|
208
|
+
extractPattern?: string;
|
|
209
|
+
/** `-` when unset; "" joins the groups with nothing. */
|
|
210
|
+
extractSeparator?: string;
|
|
211
|
+
normalize?: boolean;
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
};
|
|
214
|
+
/** Each an xmlmapper FieldMapping; `name` is the field path. */
|
|
215
|
+
fields?: Array<Record<string, unknown>>;
|
|
216
|
+
versionMatch?: {
|
|
217
|
+
validityPeriod?: boolean;
|
|
218
|
+
releaseSpecFields?: string[];
|
|
219
|
+
contentFields?: string[];
|
|
220
|
+
};
|
|
221
|
+
validityPeriod?: {
|
|
222
|
+
validFromSelector?: string;
|
|
223
|
+
validToSelector?: string;
|
|
224
|
+
dateFormats?: string[];
|
|
225
|
+
};
|
|
226
|
+
releaseSpec?: Array<{
|
|
227
|
+
field?: string;
|
|
228
|
+
selector?: string;
|
|
229
|
+
}>;
|
|
230
|
+
/** Unset: Correct. */
|
|
231
|
+
changedVersion?: ChangedVersionHandling;
|
|
232
|
+
stub?: boolean;
|
|
233
|
+
titleContributions?: Array<{
|
|
234
|
+
selector?: string;
|
|
235
|
+
ausgabeCodeSelector?: string;
|
|
236
|
+
referenceSpecValues?: Array<{
|
|
237
|
+
field?: string;
|
|
238
|
+
selector?: string;
|
|
239
|
+
}>;
|
|
240
|
+
referenceFilterSelector?: string;
|
|
241
|
+
intent?: TitleIntent;
|
|
242
|
+
intentTextSelector?: string;
|
|
243
|
+
}>;
|
|
244
|
+
collectionRouting?: {
|
|
245
|
+
selector?: string;
|
|
246
|
+
collectionMap?: Record<string, string>;
|
|
247
|
+
idPattern?: string;
|
|
248
|
+
collectionTemplate?: string;
|
|
249
|
+
suffix?: string;
|
|
250
|
+
fallback?: string;
|
|
251
|
+
};
|
|
252
|
+
collections?: string[];
|
|
253
|
+
displayNameTemplate?: string;
|
|
254
|
+
placeholderAssets?: Array<{
|
|
255
|
+
selector?: string;
|
|
256
|
+
assetType?: string;
|
|
257
|
+
keyParts?: string[];
|
|
258
|
+
nameSelector?: string;
|
|
259
|
+
descriptionSelector?: string;
|
|
260
|
+
metadata?: Record<string, string>;
|
|
261
|
+
folderRoot?: string;
|
|
262
|
+
folderPathSelector?: string;
|
|
263
|
+
}>;
|
|
264
|
+
[key: string]: unknown;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The structured Mapping editor (edit-a-mapping-in-the-structured-editor):
|
|
269
|
+
* a Mapping's page, as `MappingDetail` shows it, with the editor's tabs
|
|
270
|
+
* between Settings and History. Fields shows the pinned Release's field tree
|
|
271
|
+
* and the selected field's form with its Advanced (JSON); Source Key &
|
|
272
|
+
* Source Versions and Output hold the Mapping-level settings. Every tab edits one
|
|
273
|
+
* form over the whole content and saves with the header's one Save, and the
|
|
274
|
+
* reasons importhub gives for an invalid draft show at the fields they
|
|
275
|
+
* concern. The field tree comes from the host's
|
|
276
|
+
* `ImporthubBlueprints.getRelease`.
|
|
277
|
+
*
|
|
278
|
+
* From `@knkcs/importhub-ui/mapping-editor`, which a host loads lazily, so a
|
|
279
|
+
* host that never opens a Mapping never loads the editor (knkcms/core
|
|
280
|
+
* ADR 0003).
|
|
281
|
+
*/
|
|
282
|
+
export declare function MappingEditor({ client, id, onDeleted }: MappingEditorProps): JSX.Element;
|
|
283
|
+
|
|
284
|
+
export declare interface MappingEditorProps {
|
|
285
|
+
client: ImporthubClient;
|
|
286
|
+
/** The Mapping's id. */
|
|
287
|
+
id: string;
|
|
288
|
+
/** It was deleted: the host leaves its page. */
|
|
289
|
+
onDeleted: () => void;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** One entry of the Processor catalogue. */
|
|
293
|
+
declare interface Processor {
|
|
294
|
+
/** How a Profile names it, such as `entity-element`. */
|
|
295
|
+
name: string;
|
|
296
|
+
kind: ProcessorKind;
|
|
297
|
+
/** What it works on: a Profile lists only `source_file` ones. */
|
|
298
|
+
target: ProcessorTarget;
|
|
299
|
+
/** In English, from the service. */
|
|
300
|
+
description: string;
|
|
301
|
+
/** Its settings as fieldkit Fields, in form order; empty for none. */
|
|
302
|
+
settingsSpec: Schema;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare type ProcessorKind = "preprocessor" | "post_processor";
|
|
306
|
+
|
|
307
|
+
/** One Processor in a Profile's pipeline, with its settings. */
|
|
308
|
+
declare interface ProcessorStep {
|
|
309
|
+
/** The Processor, by its name in the catalogue. */
|
|
310
|
+
processor: string;
|
|
311
|
+
/** One value per setting of its settings spec, by `api_accessor`. */
|
|
312
|
+
settings: Record<string, unknown>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare type ProcessorTarget = "source_file" | "rich_text_field";
|
|
316
|
+
|
|
317
|
+
/** The intent a Title Contribution writes (importhub.v1.TitleIntent). */
|
|
318
|
+
declare type TitleIntent = "TITLE_INTENT_UNSPECIFIED" | "TITLE_INTENT_EXCLUDE" | "TITLE_INTENT_REPLACE" | "TITLE_INTENT_ANNOTATE";
|
|
319
|
+
|
|
320
|
+
/** Whether a configuration may be released, and if not, why. */
|
|
321
|
+
declare interface Validity {
|
|
322
|
+
valid: boolean;
|
|
323
|
+
reasons: ValidityReason[];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** One thing that makes a configuration invalid (importhub.v1.ValidityReason). */
|
|
327
|
+
declare interface ValidityReason {
|
|
328
|
+
/** Where, as a JSON Pointer into the content; empty for the whole. */
|
|
329
|
+
path: string;
|
|
330
|
+
/** A stable code, such as `no_mappings`; the type's service lists them. */
|
|
331
|
+
code: string;
|
|
332
|
+
/** What is wrong, in English, for a person. */
|
|
333
|
+
message: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export { }
|