@knkcs/importhub-ui 0.0.0-stage → 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/CHANGELOG.md +15 -0
- package/LICENSE +30 -0
- package/README.md +113 -2
- package/dist/importhub-client-CYqd7Eeq.js +16 -0
- package/dist/importhub-client-CYqd7Eeq.js.map +1 -0
- package/dist/index.d.ts +824 -0
- package/dist/index.js +1755 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +296 -0
- package/dist/testing.js +427 -0
- package/dist/testing.js.map +1 -0
- package/package.json +100 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0](https://github.com/knkCS/importhub/compare/importhub-ui-v0.1.0...importhub-ui-v0.2.0) (2026-12-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **ui:** configuration screens for Import Profiles, Processors, Mappings and Entity Sets (F2) ([#88](https://github.com/knkCS/importhub/issues/88)) ([7b879f9](https://github.com/knkCS/importhub/commit/7b879f9a6886440b22fef845706f6e3ba2928b06))
|
|
9
|
+
|
|
10
|
+
## 0.1.0 (2026-12-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **ui:** @knkcs/importhub-ui package and the Standalone App (F1) ([#82](https://github.com/knkCS/importhub/issues/82)) ([c44def1](https://github.com/knkCS/importhub/commit/c44def1e8e1e65b2514624160d276110fc335154))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Copyright (c) 2026 knk Gruppe (https://knk.de/)
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary property of knk Gruppe and its subsidiaries.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted to employees and contractors of knk Gruppe and
|
|
9
|
+
its subsidiary companies to use, copy, modify, and distribute the Software
|
|
10
|
+
solely for internal business purposes within the knk group of companies.
|
|
11
|
+
|
|
12
|
+
The following restrictions apply:
|
|
13
|
+
|
|
14
|
+
1. The Software may not be used, copied, modified, merged, published,
|
|
15
|
+
distributed, sublicensed, or sold by any person or entity outside of
|
|
16
|
+
the knk group of companies without prior written consent from knk Gruppe.
|
|
17
|
+
|
|
18
|
+
2. The Software may not be incorporated into products or services offered
|
|
19
|
+
to third parties outside of the knk group of companies.
|
|
20
|
+
|
|
21
|
+
3. This license notice shall be included in all copies or substantial
|
|
22
|
+
portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @knkcs/importhub-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
importhub's screens for knk hosts, built on [anker](https://github.com/knkCS/anker). They talk to [importhub](https://github.com/knkCS/importhub)'s Connect API. importhub's own Standalone App (`web/` in the repository) is built on this package, and another solution embeds it the same way (ADR 0005, amended).
|
|
4
|
+
|
|
5
|
+
The package exports **screens, not routes**. The host draws the page frame (anker's host contract, knkcms/core ADR 0003): a screen reports its title, breadcrumbs and header actions, reads the viewer and the active workspace from `@knkcs/anker/host`, and asks the host for everything only the host knows through `ImporthubHostProvider`. The package never navigates on its own.
|
|
6
|
+
|
|
7
|
+
So far it holds the configuration screens (Import Profiles, Mappings, Entity Sets and the Processor catalogue) and a start page for Imports. The screens for Imports, the start flow, the Dry Run report, the Mapping editor and Mapping Test, and configuration history follow.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @knkcs/importhub-ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies: `react` and `react-dom` 19, `@knkcs/anker` ^5.20, `@tanstack/react-query` 5, `i18next` 26, `react-i18next` 17, `@bufbuild/protobuf` 2, `@connectrpc/connect` 2, `@connectrpc/connect-web` 2, `@knkcs/fieldkit` 0.18 (the Processor settings forms), `react-hook-form` 7, `@hookform/resolvers` 3, `zod` 3, `@tanstack/react-table` 8, `react-router` 7 and `lucide-react`. `package.json` has the exact ranges. anker brings its own peers (Chakra UI 3, react-router, react-hook-form, …).
|
|
16
|
+
|
|
17
|
+
## Host contract
|
|
18
|
+
|
|
19
|
+
A host mounts the screens inside anker's `Provider` (or its own Chakra system) and `HostProvider`, a `QueryClientProvider`, an i18next instance that has the package's translations, and a router.
|
|
20
|
+
|
|
21
|
+
### Client
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { createConnectImporthubClient } from "@knkcs/importhub-ui";
|
|
25
|
+
|
|
26
|
+
// "" when importhub serves the page itself; the mount prefix when a host proxies it.
|
|
27
|
+
const client = createConnectImporthubClient({
|
|
28
|
+
baseUrl: "/api/importhub",
|
|
29
|
+
fetch: (input, init) => fetch(input, { ...init, credentials: "include" }),
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`createConnectImporthubClient({ baseUrl, fetch?, transport? })` returns an `ImporthubClient`. The screens depend on this interface, not on the generated Connect client, so they read domain types and a test can pass the stub from `./testing` instead.
|
|
34
|
+
|
|
35
|
+
### Workspace and identity
|
|
36
|
+
|
|
37
|
+
importhub takes the workspace from the caller's token, never from a request. The screens read the active workspace from anker's `useHostIdentity()` and key every query by it (`importhubKeys`), so a host that switches workspace (a new token and a new identity) shows the new workspace's data, never the old one's cache.
|
|
38
|
+
|
|
39
|
+
### Paths and the Change Set link
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { ImporthubHostProvider, STANDALONE_IMPORTHUB_PATHS } from "@knkcs/importhub-ui";
|
|
43
|
+
|
|
44
|
+
<ImporthubHostProvider
|
|
45
|
+
host={{
|
|
46
|
+
// Where the host mounts each section's index: imports, profiles, mappings, entitySets,
|
|
47
|
+
// processors. An item of a section lives at `<index>/<id>` (`itemPath`).
|
|
48
|
+
paths: STANDALONE_IMPORTHUB_PATHS,
|
|
49
|
+
// Where a Change Set lives in contenthub, or null when the host has no contenthub to link to.
|
|
50
|
+
changeSetHref: (changeSetId) => `/change-sets/${changeSetId}`,
|
|
51
|
+
// Whether the viewer may change configuration (importhub's `admin`). Unset: read-only.
|
|
52
|
+
canConfigure: true,
|
|
53
|
+
// Optional: where Blueprints and their Releases are found, to name a Mapping's target.
|
|
54
|
+
// Without it, the Mapping screens take and show their ids, labelled as such.
|
|
55
|
+
blueprints: { listBlueprints, listReleases },
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{routes}
|
|
59
|
+
</ImporthubHostProvider>;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
An Import fills one contenthub Change Set, and its page links out to it (`ChangeSetLink`) where `changeSetHref` says. Without a provider the screens use the Standalone App's paths and show no Change Set link.
|
|
63
|
+
|
|
64
|
+
### Screens
|
|
65
|
+
|
|
66
|
+
- `ImportProfilesIndex({ client, onOpen })` and `ImportProfileDetail({ client, id, onDeleted })`: the Import Profiles, each with its Entity Set, its Preprocessors, Mappings and Post-processors in order (each Processor configured in a form fieldkit generates from its settings spec), Auto-publish and delete-on-success.
|
|
67
|
+
- `MappingsIndex({ client, onOpen })` and `MappingDetail({ client, id, onDeleted })`: the Mappings with their target Blueprint and pinned Release, the Profiles that include each, and the move to another Release, which lists the field paths it would lose first.
|
|
68
|
+
- `EntitySetsIndex({ client, onOpen })` and `EntitySetDetail({ client, id, onDeleted })`: the Entity Sets and their tables of entities.
|
|
69
|
+
- `ProcessorCatalogue({ client })`: every Processor with its kind, description and settings.
|
|
70
|
+
- `ImporthubStartPage({ client, section })`: a section's start page, for a section with no screen yet (Imports).
|
|
71
|
+
|
|
72
|
+
Every configuration screen shows why a configuration is invalid, saves with the header's one Save and deletes from the rail (anker ADR 0004), and is read-only unless the host says `canConfigure`. `onOpen` runs after a create too; `onDeleted` once the item is gone.
|
|
73
|
+
|
|
74
|
+
### Translations
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { IMPORTHUB_UI_NS, i18nResources } from "@knkcs/importhub-ui";
|
|
78
|
+
|
|
79
|
+
i18n.init({
|
|
80
|
+
resources: { en: { [IMPORTHUB_UI_NS]: i18nResources.en[IMPORTHUB_UI_NS] }, de: { … } },
|
|
81
|
+
ns: [IMPORTHUB_UI_NS, …],
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Every string is under `IMPORTHUB_UI_NS`, in English and German (knkcms/core ADR 0005). List the constant, never the literal, so a rename fails the host's compile rather than rendering raw keys.
|
|
86
|
+
|
|
87
|
+
## Testing a host
|
|
88
|
+
|
|
89
|
+
`@knkcs/importhub-ui/testing` exports `createStubImporthubClient`, an `ImporthubClient` over in-memory workspaces seeded from its fixtures, and `stubIdentity()` for anker's `TestHost`:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { TestHost } from "@knkcs/anker/host";
|
|
93
|
+
import { ImporthubStartPage } from "@knkcs/importhub-ui";
|
|
94
|
+
import { createStubImporthubClient, stubIdentity } from "@knkcs/importhub-ui/testing";
|
|
95
|
+
|
|
96
|
+
<TestHost identity={stubIdentity()}>
|
|
97
|
+
<ImporthubStartPage client={createStubImporthubClient()} section="imports" />
|
|
98
|
+
</TestHost>;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`switchWorkspace(id)` makes the stub answer for another workspace, as a host's new token would.
|
|
102
|
+
|
|
103
|
+
## Develop
|
|
104
|
+
|
|
105
|
+
From the repository root, after `npm ci`:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
npm run typecheck:ui
|
|
109
|
+
npm run lint:ui
|
|
110
|
+
npm run test:ui # node tests, and the screens in Chromium (vitest browser mode, Playwright)
|
|
111
|
+
npm run build:ui
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The screens' tests (`*.test.tsx`) run in a real Chromium; the checks that read files or need no DOM (`*.test.ts`: anker's rules, the translations, the clients) run in Node. `pretest` installs Playwright's Chromium when it is missing, as in anker and taskhub-ui.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class o extends Error {
|
|
2
|
+
importProfiles;
|
|
3
|
+
constructor(r, s = "in use by Import Profiles") {
|
|
4
|
+
super(s), this.name = "ConfigurationInUseError", this.importProfiles = r;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
class n extends Error {
|
|
8
|
+
constructor(r = "the name is taken") {
|
|
9
|
+
super(r), this.name = "NameTakenError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
o as C,
|
|
14
|
+
n as N
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=importhub-client-CYqd7Eeq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importhub-client-CYqd7Eeq.js","sources":["../src/client/importhub-client.ts"],"sourcesContent":["// The client the screens are handed: a small, hand-written interface over\n// importhub's Connect API, as every hub package has (blueprinthub-ui,\n// contenthub-ui). Proto types never leave it, so a host or a test can supply\n// any implementation (`createConnectImporthubClient`, or the stub in\n// `@knkcs/importhub-ui/testing`), and a screen never learns the wire.\n//\n// It grows with the screens: the configuration screens (F2) read and write\n// Import Profiles, Mappings and Entity Sets and read the Processor catalogue.\n// Releases, history and comparison are later screens' (release-a-configuration).\n\nimport type { Schema } from \"@knkcs/fieldkit/schema\";\n\n/** One thing that makes a configuration invalid (importhub.v1.ValidityReason). */\nexport interface ValidityReason {\n\t/** Where, as a JSON Pointer into the content; empty for the whole. */\n\tpath: string;\n\t/** A stable code, such as `no_mappings`; the type's service lists them. */\n\tcode: string;\n\t/** What is wrong, in English, for a person. */\n\tmessage: string;\n}\n\n/** Whether a configuration may be released, and if not, why. */\nexport interface Validity {\n\tvalid: boolean;\n\treasons: ValidityReason[];\n}\n\n/** A Configuration Release, as a list names it: \"Release 3\". */\nexport interface ConfigurationRelease {\n\tid: string;\n\tnumber: number;\n}\n\n/** Where a configuration stands: its draft and its latest Release. */\nexport interface ConfigurationState {\n\tdraftRevisionId: string;\n\t/** Unset while the configuration has none. */\n\tlatestRelease?: ConfigurationRelease;\n\t/** True when the draft differs from the latest Release, and while there is none. */\n\tdraftDiffersFromRelease: boolean;\n}\n\n/** One configuration of a kind, at its draft. */\ninterface Configured<C> {\n\tid: string;\n\t/** The draft's content. */\n\tcontent: C;\n\t/**\n\t * Whether it is valid now: for Profiles and Mappings the service's\n\t * `current_validity`, which counts what changed since the save (an\n\t * included Mapping turned invalid, a Blueprint gone); for Entity Sets the\n\t * validity as saved, the only one they have.\n\t */\n\tvalidity: Validity;\n\tstate: ConfigurationState;\n}\n\n/** One Processor in a Profile's pipeline, with its settings. */\nexport interface ProcessorStep {\n\t/** The Processor, by its name in the catalogue. */\n\tprocessor: string;\n\t/** One value per setting of its settings spec, by `api_accessor`. */\n\tsettings: Record<string, unknown>;\n}\n\n/** What an admin edits of an Import Profile. */\nexport interface ImportProfileContent {\n\tname: string;\n\tdescription: string;\n\t/** The Entity Set the Source File is read with; \"\" for none. */\n\tentitySetId: string;\n\t/** In the order they run. */\n\tpreprocessors: ProcessorStep[];\n\t/** The Mappings it includes, by id, in the order they run. */\n\tmappingIds: string[];\n\t/** In the order they run. */\n\tpostProcessors: ProcessorStep[];\n\tautoPublish: boolean;\n\tdeleteSourceFileOnSuccess: boolean;\n}\n\nexport type ImportProfile = Configured<ImportProfileContent>;\n\n/**\n * What an admin edits of a Mapping, in the JSON shape of importhub.v1's\n * MappingContent (its camelCase keys). The screens here edit only the\n * fields they name; every other setting (field mappings, Version Match,\n * Title Contributions, …) is the structured editor's (F4), and travels\n * through as given, so a save here never drops it.\n */\nexport interface MappingContent {\n\tname: string;\n\tdescription?: string;\n\tblueprintId: string;\n\tblueprintReleaseId: string;\n\telementSelector?: string;\n\tsourceKey?: {\n\t\tselector?: string;\n\t\ttemplate?: string;\n\t\t[key: string]: unknown;\n\t};\n\t/** Each an xmlmapper FieldMapping; `name` is the field path. */\n\tfields?: Array<Record<string, unknown>>;\n\t[key: string]: unknown;\n}\n\nexport type Mapping = Configured<MappingContent>;\n\n/** What an admin edits of an Entity Set. */\nexport interface EntitySetContent {\n\tname: string;\n\tdescription: string;\n\t/** Entity names without `&` and `;`, to the text each stands for. */\n\tentities: Record<string, string>;\n}\n\nexport type EntitySet = Configured<EntitySetContent>;\n\n/** An Import Profile, named where another configuration is used. */\nexport interface ImportProfileRef {\n\tid: string;\n\tname: string;\n}\n\nexport type ProcessorKind = \"preprocessor\" | \"post_processor\";\nexport type ProcessorTarget = \"source_file\" | \"rich_text_field\";\n\n/** One entry of the Processor catalogue. */\nexport interface Processor {\n\t/** How a Profile names it, such as `entity-element`. */\n\tname: string;\n\tkind: ProcessorKind;\n\t/** What it works on: a Profile lists only `source_file` ones. */\n\ttarget: ProcessorTarget;\n\t/** In English, from the service. */\n\tdescription: string;\n\t/** Its settings as fieldkit Fields, in form order; empty for none. */\n\tsettingsSpec: Schema;\n}\n\n/** What moving a Mapping's draft to another Blueprint Release would lose. */\nexport interface BlueprintReleaseCheck {\n\tblueprintId: string;\n\t/** Every mapped field path the Release does not have. */\n\tmissingFieldPaths: string[];\n\t/** Every Release Spec field read or matched on that it does not have. */\n\tmissingReleaseSpecFields: string[];\n}\n\n/**\n * A delete importhub refused because Import Profiles still include the\n * Mapping, or name the Entity Set (manage-mappings:AC4,\n * manage-entity-sets:AC3). Carries the Profiles, so the screen names them.\n */\nexport class ConfigurationInUseError extends Error {\n\treadonly importProfiles: ImportProfileRef[];\n\tconstructor(importProfiles: ImportProfileRef[], message = \"in use by Import Profiles\") {\n\t\tsuper(message);\n\t\tthis.name = \"ConfigurationInUseError\";\n\t\tthis.importProfiles = importProfiles;\n\t}\n}\n\n/** A create or rename refused: another configuration of the kind has the name. */\nexport class NameTakenError extends Error {\n\tconstructor(message = \"the name is taken\") {\n\t\tsuper(message);\n\t\tthis.name = \"NameTakenError\";\n\t}\n}\n\n/**\n * What the screens ask of importhub. Every call acts on the caller's\n * workspace, which importhub takes from the token's active workspace and\n * never from an argument: a host switches workspace by switching the token.\n * An update names the draft it was made on, and is refused when somebody\n * saved in between.\n */\nexport interface ImporthubClient {\n\t/** Every Import Profile of the workspace, by name. */\n\tlistImportProfiles(): Promise<ImportProfile[]>;\n\tgetImportProfile(id: string): Promise<ImportProfile>;\n\tcreateImportProfile(content: ImportProfileContent): Promise<ImportProfile>;\n\tupdateImportProfile(\n\t\tid: string,\n\t\tcontent: ImportProfileContent,\n\t\tdraftRevisionId: string,\n\t): Promise<ImportProfile>;\n\tdeleteImportProfile(id: string): Promise<void>;\n\n\t/** The Processor catalogue, by name; the same in every workspace. */\n\tlistProcessors(): Promise<Processor[]>;\n\n\t/** Every Mapping of the workspace, by name. */\n\tlistMappings(): Promise<Mapping[]>;\n\tgetMapping(id: string): Promise<Mapping>;\n\tcreateMapping(content: MappingContent): Promise<Mapping>;\n\tupdateMapping(id: string, content: MappingContent, draftRevisionId: string): Promise<Mapping>;\n\t/** Throws ConfigurationInUseError while a Profile includes it. */\n\tdeleteMapping(id: string): Promise<void>;\n\t/** The Import Profiles whose draft or latest Release includes it. */\n\tlistMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;\n\t/** Checks moving the draft to another Blueprint Release, saving nothing. */\n\tcheckMappingBlueprintRelease(\n\t\tid: string,\n\t\tblueprintReleaseId: string,\n\t): Promise<BlueprintReleaseCheck>;\n\n\t/** Every Entity Set of the workspace, by name. */\n\tlistEntitySets(): Promise<EntitySet[]>;\n\tgetEntitySet(id: string): Promise<EntitySet>;\n\tcreateEntitySet(content: EntitySetContent): Promise<EntitySet>;\n\tupdateEntitySet(\n\t\tid: string,\n\t\tcontent: EntitySetContent,\n\t\tdraftRevisionId: string,\n\t): Promise<EntitySet>;\n\t/** Throws ConfigurationInUseError while a Profile names it. */\n\tdeleteEntitySet(id: string): Promise<void>;\n}\n"],"names":["ConfigurationInUseError","importProfiles","message","NameTakenError"],"mappings":"AA2JO,MAAMA,UAAgC,MAAM;AAAA,EACzC;AAAA,EACT,YAAYC,GAAoCC,IAAU,6BAA6B;AACtF,UAAMA,CAAO,GACb,KAAK,OAAO,2BACZ,KAAK,iBAAiBD;AAAA,EACvB;AACD;AAGO,MAAME,UAAuB,MAAM;AAAA,EACzC,YAAYD,IAAU,qBAAqB;AAC1C,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACb;AACD;"}
|