@knkcs/importhub-ui 0.1.0 → 0.2.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.d.ts CHANGED
@@ -1,31 +1,199 @@
1
1
  import { HostIdentity } from '@knkcs/anker/host';
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
+ /** A Configuration Release, as a list names it: "Release 3". */
14
+ declare interface ConfigurationRelease {
15
+ id: string;
16
+ number: number;
17
+ }
18
+
19
+ /** Where a configuration stands: its draft and its latest Release. */
20
+ declare interface ConfigurationState {
21
+ draftRevisionId: string;
22
+ /** Unset while the configuration has none. */
23
+ latestRelease?: ConfigurationRelease;
24
+ /** True when the draft differs from the latest Release, and while there is none. */
25
+ draftDiffersFromRelease: boolean;
26
+ }
27
+
28
+ /** One configuration of a kind, at its draft. */
29
+ declare interface Configured<C> {
30
+ id: string;
31
+ /** The draft's content. */
32
+ content: C;
33
+ /**
34
+ * Whether it is valid now: for Profiles and Mappings the service's
35
+ * `current_validity`, which counts what changed since the save (an
36
+ * included Mapping turned invalid, a Blueprint gone); for Entity Sets the
37
+ * validity as saved, the only one they have.
38
+ */
39
+ validity: Validity;
40
+ state: ConfigurationState;
41
+ }
42
+
43
+ /**
44
+ * An `ImporthubBlueprints` over the stub's Blueprint Releases, for a host's
45
+ * `ImporthubHost.blueprints` in tests.
46
+ */
47
+ export declare function createStubBlueprints(blueprintReleases?: StubBlueprintRelease[]): ImporthubBlueprints;
2
48
 
3
49
  export declare function createStubImporthubClient(options?: StubImporthubClientOptions): StubImporthubClient;
4
50
 
5
- /** An Entity Set, as a list names it: its draft's name. */
6
- declare interface EntitySetSummary {
51
+ declare type EntitySet = Configured<EntitySetContent>;
52
+
53
+ /** What an admin edits of an Entity Set. */
54
+ declare interface EntitySetContent {
55
+ name: string;
56
+ description: string;
57
+ /** Entity names without `&` and `;`, to the text each stands for. */
58
+ entities: Record<string, string>;
59
+ }
60
+
61
+ /** A Blueprint, as a Mapping's target is picked and named. */
62
+ declare interface ImporthubBlueprint {
7
63
  id: string;
8
64
  name: string;
9
65
  }
10
66
 
67
+ /** A Blueprint Release, as a Mapping pins it: `label` names it, such as "Release 3". */
68
+ declare interface ImporthubBlueprintRelease {
69
+ id: string;
70
+ label: string;
71
+ }
72
+
73
+ /**
74
+ * Where the screens find Blueprints and their Releases, which live in
75
+ * blueprinthub, not importhub: importhub stores only their ids. A host that
76
+ * reaches blueprinthub (core does) answers from it; one that does not leaves
77
+ * `ImporthubHost.blueprints` out, and the Mapping screens then take and show
78
+ * the two as labelled ids, the technical detail anker's id rule allows.
79
+ */
80
+ declare interface ImporthubBlueprints {
81
+ /** The workspace's Blueprints a Mapping may target, by name. */
82
+ listBlueprints(): Promise<ImporthubBlueprint[]>;
83
+ /** A Blueprint's Releases, newest first. */
84
+ listReleases(blueprintId: string): Promise<ImporthubBlueprintRelease[]>;
85
+ }
86
+
11
87
  /**
12
88
  * What the screens ask of importhub. Every call acts on the caller's
13
89
  * workspace, which importhub takes from the token's active workspace and
14
90
  * never from an argument: a host switches workspace by switching the token.
91
+ * An update names the draft it was made on, and is refused when somebody
92
+ * saved in between.
15
93
  */
16
94
  declare interface ImporthubClient {
17
95
  /** Every Import Profile of the workspace, by name. */
18
- listImportProfiles(): Promise<ImportProfileSummary[]>;
96
+ listImportProfiles(): Promise<ImportProfile[]>;
97
+ getImportProfile(id: string): Promise<ImportProfile>;
98
+ createImportProfile(content: ImportProfileContent): Promise<ImportProfile>;
99
+ updateImportProfile(id: string, content: ImportProfileContent, draftRevisionId: string): Promise<ImportProfile>;
100
+ deleteImportProfile(id: string): Promise<void>;
101
+ /** The Processor catalogue, by name; the same in every workspace. */
102
+ listProcessors(): Promise<Processor[]>;
103
+ /** Every Mapping of the workspace, by name. */
104
+ listMappings(): Promise<Mapping[]>;
105
+ getMapping(id: string): Promise<Mapping>;
106
+ createMapping(content: MappingContent): Promise<Mapping>;
107
+ updateMapping(id: string, content: MappingContent, draftRevisionId: string): Promise<Mapping>;
108
+ /** Throws ConfigurationInUseError while a Profile includes it. */
109
+ deleteMapping(id: string): Promise<void>;
110
+ /** The Import Profiles whose draft or latest Release includes it. */
111
+ listMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;
112
+ /** Checks moving the draft to another Blueprint Release, saving nothing. */
113
+ checkMappingBlueprintRelease(id: string, blueprintReleaseId: string): Promise<BlueprintReleaseCheck>;
19
114
  /** Every Entity Set of the workspace, by name. */
20
- listEntitySets(): Promise<EntitySetSummary[]>;
115
+ listEntitySets(): Promise<EntitySet[]>;
116
+ getEntitySet(id: string): Promise<EntitySet>;
117
+ createEntitySet(content: EntitySetContent): Promise<EntitySet>;
118
+ updateEntitySet(id: string, content: EntitySetContent, draftRevisionId: string): Promise<EntitySet>;
119
+ /** Throws ConfigurationInUseError while a Profile names it. */
120
+ deleteEntitySet(id: string): Promise<void>;
121
+ }
122
+
123
+ declare type ImportProfile = Configured<ImportProfileContent>;
124
+
125
+ /** What an admin edits of an Import Profile. */
126
+ declare interface ImportProfileContent {
127
+ name: string;
128
+ description: string;
129
+ /** The Entity Set the Source File is read with; "" for none. */
130
+ entitySetId: string;
131
+ /** In the order they run. */
132
+ preprocessors: ProcessorStep[];
133
+ /** The Mappings it includes, by id, in the order they run. */
134
+ mappingIds: string[];
135
+ /** In the order they run. */
136
+ postProcessors: ProcessorStep[];
137
+ autoPublish: boolean;
138
+ deleteSourceFileOnSuccess: boolean;
21
139
  }
22
140
 
23
- /** An Import Profile, as a list names it. */
24
- declare interface ImportProfileSummary {
141
+ /** An Import Profile, named where another configuration is used. */
142
+ declare interface ImportProfileRef {
25
143
  id: string;
26
144
  name: string;
27
145
  }
28
146
 
147
+ declare type Mapping = Configured<MappingContent>;
148
+
149
+ /**
150
+ * What an admin edits of a Mapping, in the JSON shape of importhub.v1's
151
+ * MappingContent (its camelCase keys). The screens here edit only the
152
+ * fields they name; every other setting (field mappings, Version Match,
153
+ * Title Contributions, …) is the structured editor's (F4), and travels
154
+ * through as given, so a save here never drops it.
155
+ */
156
+ declare interface MappingContent {
157
+ name: string;
158
+ description?: string;
159
+ blueprintId: string;
160
+ blueprintReleaseId: string;
161
+ elementSelector?: string;
162
+ sourceKey?: {
163
+ selector?: string;
164
+ template?: string;
165
+ [key: string]: unknown;
166
+ };
167
+ /** Each an xmlmapper FieldMapping; `name` is the field path. */
168
+ fields?: Array<Record<string, unknown>>;
169
+ [key: string]: unknown;
170
+ }
171
+
172
+ /** One entry of the Processor catalogue. */
173
+ declare interface Processor {
174
+ /** How a Profile names it, such as `entity-element`. */
175
+ name: string;
176
+ kind: ProcessorKind;
177
+ /** What it works on: a Profile lists only `source_file` ones. */
178
+ target: ProcessorTarget;
179
+ /** In English, from the service. */
180
+ description: string;
181
+ /** Its settings as fieldkit Fields, in form order; empty for none. */
182
+ settingsSpec: Schema;
183
+ }
184
+
185
+ declare type ProcessorKind = "preprocessor" | "post_processor";
186
+
187
+ /** One Processor in a Profile's pipeline, with its settings. */
188
+ declare interface ProcessorStep {
189
+ /** The Processor, by its name in the catalogue. */
190
+ processor: string;
191
+ /** One value per setting of its settings spec, by `api_accessor`. */
192
+ settings: Record<string, unknown>;
193
+ }
194
+
195
+ declare type ProcessorTarget = "source_file" | "rich_text_field";
196
+
29
197
  /** A second workspace, for tests that switch to it. */
30
198
  export declare const STUB_OTHER_WORKSPACE_ID = "ws_stub_other";
31
199
 
@@ -35,8 +203,31 @@ export declare const STUB_USER_ID = "user_stub_ada";
35
203
  /** The stub workspace's id. */
36
204
  export declare const STUB_WORKSPACE_ID = "ws_stub_main";
37
205
 
206
+ /** A Blueprint Release the stub knows, with the field paths it has. */
207
+ export declare interface StubBlueprintRelease {
208
+ id: string;
209
+ blueprintId: string;
210
+ blueprintName: string;
211
+ label: string;
212
+ fieldPaths: string[];
213
+ }
214
+
215
+ /**
216
+ * Two Releases of the "Gesetz" Blueprint, the newer of which dropped
217
+ * `fussnote`, and one of "Entscheidung".
218
+ */
219
+ export declare function stubBlueprintReleases(): StubBlueprintRelease[];
220
+
221
+ /** A stub configuration as the stub client is seeded with it: an id and its content. */
222
+ export declare interface StubConfiguration<C> {
223
+ id: string;
224
+ content: C;
225
+ /** The number of its latest Release; none when unset. */
226
+ releaseNumber?: number;
227
+ }
228
+
38
229
  /** The stub workspace's Entity Sets: one. */
39
- export declare function stubEntitySets(): EntitySetSummary[];
230
+ export declare function stubEntitySets(): StubConfiguration<EntitySetContent>[];
40
231
 
41
232
  /**
42
233
  * A `HostIdentity` for anker's `TestHost` or `HostProvider`: Ada, in the stub
@@ -47,29 +238,59 @@ export declare function stubIdentity(workspaceId?: string): HostIdentity;
47
238
  export declare interface StubImporthubClient extends ImporthubClient {
48
239
  /** Answer for another workspace from now on, as a host's new token would. */
49
240
  switchWorkspace(workspaceId: string): void;
50
- /** How many reads each method has answered, for tests that count reloads. */
241
+ /** How many calls each method has answered, for tests that count reloads. */
51
242
  readonly calls: Readonly<Record<keyof ImporthubClient, number>>;
52
243
  }
53
244
 
54
245
  export declare interface StubImporthubClientOptions {
55
246
  /**
56
247
  * The workspaces by id. Without it, the stub workspace holds the
57
- * fixtures' Import Profiles and Entity Sets.
248
+ * fixtures' Import Profiles, Mappings and Entity Sets.
58
249
  */
59
250
  workspaces?: Record<string, StubWorkspace>;
60
251
  /** The workspace answered for first; the stub workspace by default. */
61
252
  activeWorkspaceId?: string;
62
- /** Fail every read with this error, as an unreachable importhub would. */
253
+ /** The Processor catalogue; the fixtures' by default. */
254
+ processors?: Processor[];
255
+ /** The Blueprint Releases blueprinthub knows; the fixtures' by default. */
256
+ blueprintReleases?: StubBlueprintRelease[];
257
+ /** Fail every call with this error, as an unreachable importhub would. */
63
258
  fail?: Error;
64
259
  }
65
260
 
66
- /** The stub workspace's Import Profiles: two, one per kind of Source File. */
67
- export declare function stubImportProfiles(): ImportProfileSummary[];
261
+ /**
262
+ * The stub workspace's Import Profiles: one per kind of Source File. The
263
+ * VRPML one includes the invalid Mapping, so it is invalid too.
264
+ */
265
+ export declare function stubImportProfiles(): StubConfiguration<ImportProfileContent>[];
266
+
267
+ /** The stub workspace's Mappings: one valid and released, one invalid. */
268
+ export declare function stubMappings(): StubConfiguration<MappingContent>[];
269
+
270
+ /** The catalogue, a few Processors of each kind and target. */
271
+ export declare function stubProcessors(): Processor[];
68
272
 
69
273
  /** What one stub workspace holds. */
70
274
  export declare interface StubWorkspace {
71
- importProfiles?: ImportProfileSummary[];
72
- entitySets?: EntitySetSummary[];
275
+ importProfiles?: StubConfiguration<ImportProfileContent>[];
276
+ mappings?: StubConfiguration<MappingContent>[];
277
+ entitySets?: StubConfiguration<EntitySetContent>[];
278
+ }
279
+
280
+ /** Whether a configuration may be released, and if not, why. */
281
+ declare interface Validity {
282
+ valid: boolean;
283
+ reasons: ValidityReason[];
284
+ }
285
+
286
+ /** One thing that makes a configuration invalid (importhub.v1.ValidityReason). */
287
+ declare interface ValidityReason {
288
+ /** Where, as a JSON Pointer into the content; empty for the whole. */
289
+ path: string;
290
+ /** A stable code, such as `no_mappings`; the type's service lists them. */
291
+ code: string;
292
+ /** What is wrong, in English, for a person. */
293
+ message: string;
73
294
  }
74
295
 
75
296
  export { }