@knkcs/importhub-ui 0.7.0 → 0.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","sources":["../src/testing/fixtures.ts","../src/testing/stub-client.ts"],"sourcesContent":["import { createHostMembers, type HostIdentity } from \"@knkcs/anker/host\";\nimport type {\n\tApiKey,\n\tEntitySetContent,\n\tImport,\n\tImportCounts,\n\tImportProfileContent,\n\tItemProblem,\n\tMappingContent,\n\tProcessor,\n} from \"../client/importhub-client\";\nimport type { ImporthubBlueprintField } from \"../common/host\";\n\n/** The stub viewer's id. */\nexport const STUB_USER_ID = \"user_stub_ada\";\n/** A second member of the stub workspace, who starts and cancels Imports too. */\nexport const STUB_OTHER_USER_ID = \"user_stub_grace\";\n/** The stub workspace's id. */\nexport const STUB_WORKSPACE_ID = \"ws_stub_main\";\n/** A second workspace, for tests that switch to it. */\nexport const STUB_OTHER_WORKSPACE_ID = \"ws_stub_other\";\n\n/**\n * A `HostIdentity` for anker's `TestHost` or `HostProvider`: Ada, in the stub\n * workspace unless another is named.\n */\nexport function stubIdentity(workspaceId: string = STUB_WORKSPACE_ID): HostIdentity {\n\treturn {\n\t\tuserId: STUB_USER_ID,\n\t\tworkspaceId,\n\t\tmembers: createHostMembers([\n\t\t\t{ userId: STUB_USER_ID, displayName: \"Ada Importer\", email: \"ada@example.com\" },\n\t\t\t{ userId: STUB_OTHER_USER_ID, displayName: \"Grace Hopper\", email: \"grace@example.com\" },\n\t\t]),\n\t};\n}\n\n/** A stub configuration as the stub client is seeded with it: an id and its content. */\nexport interface StubConfiguration<C> {\n\tid: string;\n\tcontent: C;\n\t/** The number of its latest Release; none when unset. */\n\treleaseNumber?: number;\n}\n\n/** A Blueprint Release the stub knows, with the field paths it has. */\nexport interface StubBlueprintRelease {\n\tid: string;\n\tblueprintId: string;\n\tblueprintName: string;\n\tlabel: string;\n\t/** Every field path, nested ones included (`stand.datum`). */\n\tfieldPaths: string[];\n\t/** Its field tree, for the Mapping editor; the paths as text fields when unset. */\n\tfields?: ImporthubBlueprintField[];\n\t/** Its Release Spec fields; none when unset. */\n\treleaseSpecFields?: ImporthubBlueprintField[];\n}\n\nconst field = (\n\tpath: string,\n\tfieldType: string,\n\tlabel: string,\n\tchildren: ImporthubBlueprintField[] = [],\n): ImporthubBlueprintField => ({\n\taccessor: path.split(\".\").pop() ?? path,\n\tpath,\n\tfieldType,\n\tlabel,\n\tchildren,\n});\n\n/** Every path of a field tree, parents before their children. */\nconst pathsOf = (tree: ImporthubBlueprintField[]): string[] =>\n\ttree.flatMap((f) => [f.path, ...pathsOf(f.children)]);\n\nconst gesetzFields = (withFootnote: boolean) => [\n\tfield(\"titel\", \"text\", \"Titel\"),\n\tfield(\"abkuerzung\", \"text\", \"Abkürzung\"),\n\t...(withFootnote ? [field(\"fussnote\", \"rich_text\", \"Fußnote\")] : []),\n\tfield(\"stand\", \"fieldset\", \"Stand\", [\n\t\tfield(\"stand.datum\", \"date\", \"Datum\"),\n\t\tfield(\"stand.art\", \"select\", \"Art\"),\n\t]),\n];\n\nconst gesetzReleaseSpec = () => [\n\tfield(\"fundstelle\", \"text\", \"Fundstelle\"),\n\tfield(\"ausgabedatum\", \"date\", \"Ausgabedatum\"),\n];\n\n/**\n * Two Releases of the \"Gesetz\" Blueprint, with a fieldset `stand` and two\n * Release Spec fields, the newer of which dropped `fussnote`, and one of\n * \"Entscheidung\".\n */\nexport function stubBlueprintReleases(): StubBlueprintRelease[] {\n\tconst gesetz2 = gesetzFields(false);\n\tconst gesetz1 = gesetzFields(true);\n\tconst entscheidung = [\n\t\tfield(\"aktenzeichen\", \"text\", \"Aktenzeichen\"),\n\t\tfield(\"datum\", \"date\", \"Datum\"),\n\t];\n\treturn [\n\t\t{\n\t\t\tid: \"br_stub_gesetz_2\",\n\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\tblueprintName: \"Gesetz\",\n\t\t\tlabel: \"Release 2\",\n\t\t\tfieldPaths: pathsOf(gesetz2),\n\t\t\tfields: gesetz2,\n\t\t\treleaseSpecFields: gesetzReleaseSpec(),\n\t\t},\n\t\t{\n\t\t\tid: \"br_stub_gesetz_1\",\n\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\tblueprintName: \"Gesetz\",\n\t\t\tlabel: \"Release 1\",\n\t\t\tfieldPaths: pathsOf(gesetz1),\n\t\t\tfields: gesetz1,\n\t\t\treleaseSpecFields: gesetzReleaseSpec(),\n\t\t},\n\t\t{\n\t\t\tid: \"br_stub_entscheidung_1\",\n\t\t\tblueprintId: \"bp_stub_entscheidung\",\n\t\t\tblueprintName: \"Entscheidung\",\n\t\t\tlabel: \"Release 1\",\n\t\t\tfieldPaths: pathsOf(entscheidung),\n\t\t\tfields: entscheidung,\n\t\t},\n\t];\n}\n\n/** The stub workspace's Mappings: one valid and released, one invalid. */\nexport function stubMappings(): StubConfiguration<MappingContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"mp_stub_norm\",\n\t\t\treleaseNumber: 1,\n\t\t\tcontent: {\n\t\t\t\tname: \"Gesetz norms\",\n\t\t\t\tdescription: \"One Content per norm\",\n\t\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\t\tblueprintReleaseId: \"br_stub_gesetz_1\",\n\t\t\t\telementSelector: \"//norm\",\n\t\t\t\tsourceKey: { selector: \"@id\" },\n\t\t\t\tfields: [\n\t\t\t\t\t{ name: \"titel\", selector: \"titel\", type: \"text\" },\n\t\t\t\t\t{ name: \"fussnote\", selector: \"fn\", type: \"text\" },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: \"mp_stub_decision\",\n\t\t\tcontent: {\n\t\t\t\tname: \"Court decisions\",\n\t\t\t\tdescription: \"\",\n\t\t\t\tblueprintId: \"bp_stub_entscheidung\",\n\t\t\t\tblueprintReleaseId: \"br_stub_entscheidung_1\",\n\t\t\t\telementSelector: \"\",\n\t\t\t\tsourceKey: {},\n\t\t\t\tfields: [],\n\t\t\t},\n\t\t},\n\t];\n}\n\n/** The stub workspace's Entity Sets: one. */\nexport function stubEntitySets(): StubConfiguration<EntitySetContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"es_stub_latin1\",\n\t\t\treleaseNumber: 1,\n\t\t\tcontent: {\n\t\t\t\tname: \"ISO Latin 1\",\n\t\t\t\tdescription: \"The Latin-1 entities Boorberg's files use\",\n\t\t\t\tentities: { auml: \"ä\", nbsp: \" \" },\n\t\t\t},\n\t\t},\n\t];\n}\n\n/**\n * The stub workspace's Import Profiles: one per kind of Source File. The\n * VRPML one includes the invalid Mapping, so it is invalid too.\n */\nexport function stubImportProfiles(): StubConfiguration<ImportProfileContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"ip_stub_gesetz\",\n\t\t\treleaseNumber: 2,\n\t\t\tcontent: {\n\t\t\t\tname: \"Boorberg gesetz\",\n\t\t\t\tdescription: \"Boorberg's law files\",\n\t\t\t\tentitySetId: \"es_stub_latin1\",\n\t\t\t\tpreprocessors: [{ processor: \"rename-element\", settings: { from: \"para\", to: \"absatz\" } }],\n\t\t\t\tmappingIds: [\"mp_stub_norm\"],\n\t\t\t\tpostProcessors: [],\n\t\t\t\tautoPublish: false,\n\t\t\t\tdeleteSourceFileOnSuccess: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: \"ip_stub_vrpml\",\n\t\t\tcontent: {\n\t\t\t\tname: \"VRPML court decisions\",\n\t\t\t\tdescription: \"\",\n\t\t\t\tentitySetId: \"\",\n\t\t\t\tpreprocessors: [],\n\t\t\t\tmappingIds: [\"mp_stub_decision\"],\n\t\t\t\tpostProcessors: [],\n\t\t\t\tautoPublish: false,\n\t\t\t\tdeleteSourceFileOnSuccess: false,\n\t\t\t},\n\t\t},\n\t];\n}\n\nconst text = (accessor: string, name: string, required: boolean, instructions = \"\") => ({\n\tfield_type: \"text\",\n\tconfig: { name, api_accessor: accessor, required, instructions },\n\tsystem: false,\n});\n\n/** The catalogue, a few Processors of each kind and target. */\nexport function stubProcessors(): Processor[] {\n\treturn [\n\t\t{\n\t\t\tname: \"citation-links\",\n\t\t\tkind: \"post_processor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription:\n\t\t\t\t\"Links citations in rich text to the Content they name, through legalcitationhub.\",\n\t\t\tsettingsSpec: [],\n\t\t},\n\t\t{\n\t\t\tname: \"norm-cite\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"rich_text_field\",\n\t\t\tdescription: \"Marks legal norm citations in one rich-text field.\",\n\t\t\tsettingsSpec: [],\n\t\t},\n\t\t{\n\t\t\tname: \"rename-element\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription: \"Renames every element of one name to another.\",\n\t\t\tsettingsSpec: [\n\t\t\t\ttext(\"from\", \"Element\", true, \"The element's name now.\"),\n\t\t\t\ttext(\"to\", \"New name\", true),\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: \"sentence-detect\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription: \"Wraps each sentence of an element in its own element.\",\n\t\t\tsettingsSpec: [text(\"element\", \"Element\", false)],\n\t\t},\n\t];\n}\n\n/** A stub Import as the stub client is seeded with it, with its Item Problems. */\nexport interface StubImport extends Import {\n\titemProblems?: ItemProblem[];\n}\n\nconst counts = (c: Partial<ImportCounts> = {}): ImportCounts => ({\n\tmatched: 0,\n\tcreated: 0,\n\tproblems: 0,\n\tplanned: 0,\n\tcorrected: 0,\n\tkept: 0,\n\tunchanged: 0,\n\t...c,\n});\n\n/** The Releases the fixtures' Imports of the gesetz Profile ran with. */\nconst gesetzReleases = (profileRelease: number): Import[\"releases\"] => ({\n\timportProfile: {\n\t\tconfigurationId: \"ip_stub_gesetz\",\n\t\tname: \"Boorberg gesetz\",\n\t\treleaseId: `ip_stub_gesetz_rel${profileRelease}`,\n\t\tnumber: profileRelease,\n\t},\n\tmappings: [\n\t\t{\n\t\t\tconfigurationId: \"mp_stub_norm\",\n\t\t\tname: \"Gesetz norms\",\n\t\t\treleaseId: \"mp_stub_norm_rel1\",\n\t\t\tnumber: 1,\n\t\t},\n\t],\n\tentitySet: {\n\t\tconfigurationId: \"es_stub_latin1\",\n\t\tname: \"ISO Latin 1\",\n\t\treleaseId: \"es_stub_latin1_rel1\",\n\t\tnumber: 1,\n\t},\n});\n\nconst stubImport = (i: Partial<StubImport> & Pick<Import, \"id\">): StubImport => ({\n\timportProfileId: \"ip_stub_gesetz\",\n\timportProfileName: \"Boorberg gesetz\",\n\tsourceFileId: `sf_${i.id}`,\n\tstartedBy: STUB_USER_ID,\n\tphase: \"ended\",\n\tfailureReason: \"\",\n\tprogress: { done: 0, total: 0 },\n\tcounts: counts(),\n\tchangeSetId: \"\",\n\treleases: gesetzReleases(2),\n\tcreateTime: \"2026-11-03T09:00:00.000Z\",\n\tstartTime: \"\",\n\tendTime: \"\",\n\tcancelledBy: \"\",\n\teffectiveDate: \"\",\n\t...i,\n});\n\nconst problem = (\n\tn: number,\n\tmapping: \"norm\" | \"title\",\n\tsourceKey: string,\n\tfield: string,\n\treason: string,\n): ItemProblem => ({\n\tid: `prob_stub_${n}`,\n\tmappingId: mapping === \"norm\" ? \"mp_stub_norm\" : \"mp_stub_title\",\n\tmappingName: mapping === \"norm\" ? \"Gesetz norms\" : \"Gesetz titles\",\n\tsourceKey,\n\tfield,\n\treason,\n});\n\n/**\n * The stub workspace's Imports, newest first: one running, one queued\n * behind it, and one of each Import Outcome.\n */\nexport function stubImports(): StubImport[] {\n\treturn [\n\t\tstubImport({\n\t\t\tid: \"im_stub_running\",\n\t\t\tphase: \"writing\",\n\t\t\tprogress: { done: 48, total: 120 },\n\t\t\tcounts: counts({ matched: 120, created: 40, planned: 8 }),\n\t\t\tchangeSetId: \"cs_stub_running\",\n\t\t\tcreateTime: \"2026-11-04T10:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-04T10:00:05.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_queued\",\n\t\t\tphase: \"queued\",\n\t\t\tstartedBy: STUB_OTHER_USER_ID,\n\t\t\treleases: gesetzReleases(2),\n\t\t\tcreateTime: \"2026-11-04T10:05:00.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_problems\",\n\t\t\toutcome: \"succeeded_with_problems\",\n\t\t\tcounts: counts({\n\t\t\t\tmatched: 212,\n\t\t\t\tcreated: 180,\n\t\t\t\tplanned: 20,\n\t\t\t\tcorrected: 6,\n\t\t\t\tkept: 1,\n\t\t\t\tproblems: 5,\n\t\t\t}),\n\t\t\tchangeSetId: \"cs_stub_problems\",\n\t\t\treleases: {\n\t\t\t\t...gesetzReleases(2),\n\t\t\t\tmappings: [\n\t\t\t\t\t...gesetzReleases(2).mappings,\n\t\t\t\t\t{\n\t\t\t\t\t\tconfigurationId: \"mp_stub_title\",\n\t\t\t\t\t\tname: \"Gesetz titles\",\n\t\t\t\t\t\treleaseId: \"mp_stub_title_rel3\",\n\t\t\t\t\t\tnumber: 3,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tcreateTime: \"2026-11-03T09:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-03T09:00:02.000Z\",\n\t\t\tendTime: \"2026-11-03T09:12:40.000Z\",\n\t\t\teffectiveDate: \"2026-10-01\",\n\t\t\tsource: { date: \"2026-09-20\", reference: \"BGBl. 2026 I Nr. 270\" },\n\t\t\titemProblems: [\n\t\t\t\tproblem(1, \"norm\", \"BJNR000010001\", \"stand/datum\", \"“31.02.2026” is not a date.\"),\n\t\t\t\tproblem(2, \"norm\", \"BJNR000010002\", \"\", \"The Version Match found two Releases.\"),\n\t\t\t\tproblem(3, \"title\", \"BJNR000020001\", \"\", \"No Title has the Ausgabe code BY-7.\"),\n\t\t\t\tproblem(4, \"norm\", \"BJNR000030001\", \"titel\", \"The field is required.\"),\n\t\t\t\tproblem(5, \"title\", \"BJNR000030002\", \"\", \"No Title has the Ausgabe code BY-9.\"),\n\t\t\t],\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_succeeded\",\n\t\t\toutcome: \"succeeded\",\n\t\t\tcounts: counts({ matched: 64, created: 64 }),\n\t\t\tchangeSetId: \"cs_stub_succeeded\",\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-02T14:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-02T14:00:01.000Z\",\n\t\t\tendTime: \"2026-11-02T14:03:10.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_failed\",\n\t\t\toutcome: \"failed\",\n\t\t\tfailureReason: \"The worker crashed three times running this Import.\",\n\t\t\tcounts: counts({ matched: 30 }),\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-02T11:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-02T11:00:01.000Z\",\n\t\t\tendTime: \"2026-11-02T11:20:00.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_cancelled\",\n\t\t\toutcome: \"cancelled\",\n\t\t\tcancelledBy: STUB_OTHER_USER_ID,\n\t\t\tcounts: counts({ matched: 12, created: 3 }),\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-01T16:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-01T16:00:01.000Z\",\n\t\t\tendTime: \"2026-11-01T16:01:00.000Z\",\n\t\t}),\n\t];\n}\n\n/**\n * The stub workspace's API keys, newest first: Grace's nightly feed, which\n * never expires, and Ada's pipeline key, which does.\n */\nexport function stubApiKeys(): ApiKey[] {\n\treturn [\n\t\t{\n\t\t\tid: \"key_stub_nightly\",\n\t\t\tname: \"Nightly gesetz feed\",\n\t\t\tkeyPrefix: \"ihk_7Qx2\",\n\t\t\towner: STUB_OTHER_USER_ID,\n\t\t\texpireTime: \"\",\n\t\t\tcreateTime: \"2026-11-20T07:30:00.000Z\",\n\t\t},\n\t\t{\n\t\t\tid: \"key_stub_pipeline\",\n\t\t\tname: \"VRPML pipeline\",\n\t\t\tkeyPrefix: \"ihk_b91F\",\n\t\t\towner: STUB_USER_ID,\n\t\t\texpireTime: \"2027-06-30T21:59:59.000Z\",\n\t\t\tcreateTime: \"2026-11-03T12:00:00.000Z\",\n\t\t},\n\t];\n}\n","// An `ImporthubClient` over in-memory workspaces seeded from the fixtures.\n//\n// importhub takes the workspace from the caller's token, never from an\n// argument, so a real client answers for whichever workspace the host's\n// session is in. The stub does the same: it answers for its active\n// workspace, and a test switches it (`switchWorkspace`) where a host would\n// switch the token, which is how a host's test shows that switching reloads\n// the new workspace's data.\n//\n// It keeps importhub's rules a screen shows (internal/server's handlers):\n// validity reasons with their codes, a delete refused while Import Profiles\n// use the configuration, names unique per kind, a save on a draft that moved\n// refused, and the Blueprint Release check. Its messages are its own, not\n// importhub's.\n//\n// Typed as the whole interface, so a method added to `ImporthubClient`\n// without an answer here fails this package's typecheck, not a host's test.\nimport type {\n\tApiKey,\n\tConfigurationComparison,\n\tConfigurationKind,\n\tConfigurationReleaseRecord,\n\tConfigurationState,\n\tEntitySet,\n\tEntitySetContent,\n\tImport,\n\tImporthubClient,\n\tImportProfile,\n\tImportProfileContent,\n\tMapping,\n\tMappingContent,\n\tProcessor,\n\tProcessorStep,\n\tValidity,\n\tValidityReason,\n} from \"../client/importhub-client\";\nimport {\n\tAPI_KEY_NAME_MAX,\n\tConfigurationInUseError,\n\tNameTakenError,\n\tReleaseRefusedError,\n\tStartRefusedError,\n} from \"../client/importhub-client\";\nimport type { ImporthubBlueprints } from \"../common/host\";\nimport {\n\tSTUB_USER_ID,\n\tSTUB_WORKSPACE_ID,\n\ttype StubBlueprintRelease,\n\ttype StubConfiguration,\n\ttype StubImport,\n\tstubApiKeys,\n\tstubBlueprintReleases,\n\tstubEntitySets,\n\tstubImportProfiles,\n\tstubImports,\n\tstubMappings,\n\tstubProcessors,\n} from \"./fixtures\";\n\n/** What one stub workspace holds. */\nexport interface StubWorkspace {\n\timportProfiles?: StubConfiguration<ImportProfileContent>[];\n\tmappings?: StubConfiguration<MappingContent>[];\n\tentitySets?: StubConfiguration<EntitySetContent>[];\n\t/** Its Imports, newest first, each with its Item Problems. */\n\timports?: StubImport[];\n\t/** Its importhub API keys, newest first. */\n\tapiKeys?: ApiKey[];\n}\n\n/** A contenthub right the stub viewer holds, which Start checks. */\nexport type StubContenthubRight = \"editor\" | \"publisher\";\n\nexport interface StubImporthubClientOptions {\n\t/**\n\t * The workspaces by id. Without it, the stub workspace holds the\n\t * fixtures' Import Profiles, Mappings and Entity Sets.\n\t */\n\tworkspaces?: Record<string, StubWorkspace>;\n\t/** The workspace answered for first; the stub workspace by default. */\n\tactiveWorkspaceId?: string;\n\t/** The Processor catalogue; the fixtures' by default. */\n\tprocessors?: Processor[];\n\t/** The Blueprint Releases blueprinthub knows; the fixtures' by default. */\n\tblueprintReleases?: StubBlueprintRelease[];\n\t/**\n\t * The contenthub rights the viewer holds, which Start checks\n\t * (start-an-import:AC4); both by default.\n\t */\n\tcontenthubRights?: StubContenthubRight[];\n\t/** Fail every upload with this error, as an unreachable blob store would. */\n\tuploadFails?: Error;\n\t/** Fail every call with this error, as an unreachable importhub would. */\n\tfail?: Error;\n}\n\nexport interface StubImporthubClient extends ImporthubClient {\n\t/** Answer for another workspace from now on, as a host's new token would. */\n\tswitchWorkspace(workspaceId: string): void;\n\t/**\n\t * Moves an Import on as importhub's worker would: a phase, progress,\n\t * counts, an Outcome. For tests that follow an Import while it runs.\n\t */\n\tupdateImport(id: string, patch: Partial<StubImport>): void;\n\t/** How many calls each method has answered, for tests that count reloads. */\n\treadonly calls: Readonly<Record<keyof ImporthubClient, number>>;\n}\n\n/** One saved Revision of a stored configuration. */\ninterface StoredRevision<C> {\n\tid: string;\n\tcontent: C;\n\tsavedBy: string;\n\tsavedAt: string;\n\t/** As decided at the save; a fixture's is decided when it is read. */\n\tvalidity?: Validity;\n\trestoredFromRevisionId: string;\n}\n\n/**\n * One stored configuration: every Revision, newest last (the draft), and\n * every Release, oldest first, as versionkit's linear mode keeps them.\n */\ninterface Stored<C> {\n\tid: string;\n\t/** The draft's content, which the screens' reads answer with. */\n\tcontent: C;\n\trevisions: StoredRevision<C>[];\n\treleases: ConfigurationReleaseRecord[];\n}\n\ninterface Workspace {\n\timportProfiles: Stored<ImportProfileContent>[];\n\tmappings: Stored<MappingContent>[];\n\tentitySets: Stored<EntitySetContent>[];\n\timports: StubImport[];\n\tapiKeys: ApiKey[];\n}\n\nconst METHODS: (keyof ImporthubClient)[] = [\n\t\"listImportProfiles\",\n\t\"getImportProfile\",\n\t\"createImportProfile\",\n\t\"updateImportProfile\",\n\t\"deleteImportProfile\",\n\t\"listProcessors\",\n\t\"listMappings\",\n\t\"getMapping\",\n\t\"createMapping\",\n\t\"updateMapping\",\n\t\"deleteMapping\",\n\t\"listMappingImportProfiles\",\n\t\"checkMappingBlueprintRelease\",\n\t\"listEntitySets\",\n\t\"getEntitySet\",\n\t\"createEntitySet\",\n\t\"updateEntitySet\",\n\t\"deleteEntitySet\",\n\t\"cutRelease\",\n\t\"listHistory\",\n\t\"compareRevisions\",\n\t\"restoreRevision\",\n\t\"uploadSourceFile\",\n\t\"startImport\",\n\t\"listImports\",\n\t\"getImport\",\n\t\"cancelImport\",\n\t\"listItemProblems\",\n\t\"listApiKeys\",\n\t\"createApiKey\",\n\t\"revokeApiKey\",\n];\n\n// A stub clock: each save and cut is an hour after the last, from the\n// fixtures' first save, so a history reads in order and tests stay stable.\nlet clock = Date.parse(\"2026-11-02T08:00:00Z\");\nconst tick = () => {\n\tclock += 3_600_000;\n\treturn new Date(clock).toISOString();\n};\n\n/**\n * A fixture as stored: released `releaseNumber` times, each Release cut\n * from a Revision of its own, the last of which is the draft; or one\n * unreleased Revision.\n */\nconst seed = <C>(items: StubConfiguration<C>[] = []): Stored<C>[] =>\n\titems.map((i) => {\n\t\tconst count = Math.max(i.releaseNumber ?? 0, 1);\n\t\tconst revisions = Array.from({ length: count }, (_, n) => ({\n\t\t\tid: `${i.id}_r${n + 1}`,\n\t\t\tcontent: structuredClone(i.content),\n\t\t\tsavedBy: STUB_USER_ID,\n\t\t\tsavedAt: tick(),\n\t\t\trestoredFromRevisionId: \"\",\n\t\t}));\n\t\tconst releases = Array.from({ length: i.releaseNumber ?? 0 }, (_, n) => ({\n\t\t\tid: `${i.id}_rel${n + 1}`,\n\t\t\tnumber: n + 1,\n\t\t\trevisionId: `${i.id}_r${n + 1}`,\n\t\t\treleasedBy: STUB_USER_ID,\n\t\t\treleasedAt: tick(),\n\t\t}));\n\t\treturn { id: i.id, content: structuredClone(i.content), revisions, releases };\n\t});\n\nconst draftOf = <C>(s: Stored<C>) => s.revisions[s.revisions.length - 1] as StoredRevision<C>;\nconst latestReleaseOf = <C>(s: Stored<C>) => s.releases[s.releases.length - 1];\n\nconst stateOf = <C>(s: Stored<C>): ConfigurationState => {\n\tconst latest = latestReleaseOf(s);\n\tconst released = s.revisions.find((r) => r.id === latest?.revisionId);\n\treturn {\n\t\tdraftRevisionId: draftOf(s).id,\n\t\t// By content, as importhub compares: a draft that restored the\n\t\t// released content does not differ.\n\t\tdraftDiffersFromRelease:\n\t\t\t!released || JSON.stringify(released.content) !== JSON.stringify(draftOf(s).content),\n\t\t...(latest ? { latestRelease: { id: latest.id, number: latest.number } } : {}),\n\t};\n};\n\n/** A content's top-level keys as importhub's comparison names them. */\nconst snake = (key: string) => key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);\nconst protoKeyed = (content: unknown): Record<string, unknown> =>\n\tObject.fromEntries(\n\t\tObject.entries(content as Record<string, unknown>).map(([k, v]) => [snake(k), v]),\n\t);\n\nconst validity = (reasons: ValidityReason[]): Validity => ({\n\tvalid: reasons.length === 0,\n\treasons,\n});\n\nconst byName = <T extends { content: { name: string } }>(items: T[]) =>\n\t[...items].sort((a, b) => a.content.name.localeCompare(b.content.name));\n\nlet created = 0;\n\nexport function createStubImporthubClient(\n\toptions: StubImporthubClientOptions = {},\n): StubImporthubClient {\n\tconst workspaces: Record<string, Workspace> = Object.fromEntries(\n\t\tObject.entries(\n\t\t\toptions.workspaces ?? {\n\t\t\t\t[STUB_WORKSPACE_ID]: {\n\t\t\t\t\timportProfiles: stubImportProfiles(),\n\t\t\t\t\tmappings: stubMappings(),\n\t\t\t\t\tentitySets: stubEntitySets(),\n\t\t\t\t\timports: stubImports(),\n\t\t\t\t\tapiKeys: stubApiKeys(),\n\t\t\t\t},\n\t\t\t},\n\t\t).map(([id, w]) => [\n\t\t\tid,\n\t\t\t{\n\t\t\t\timportProfiles: seed(w.importProfiles),\n\t\t\t\tmappings: seed(w.mappings),\n\t\t\t\tentitySets: seed(w.entitySets),\n\t\t\t\timports: structuredClone(w.imports ?? []),\n\t\t\t\tapiKeys: structuredClone(w.apiKeys ?? []),\n\t\t\t},\n\t\t]),\n\t);\n\tconst processors = options.processors ?? stubProcessors();\n\tconst releases = options.blueprintReleases ?? stubBlueprintReleases();\n\tlet active = options.activeWorkspaceId ?? STUB_WORKSPACE_ID;\n\tconst calls = Object.fromEntries(METHODS.map((m) => [m, 0])) as Record<\n\t\tkeyof ImporthubClient,\n\t\tnumber\n\t>;\n\tconst ws = (): Workspace => {\n\t\tworkspaces[active] ??= {\n\t\t\timportProfiles: [],\n\t\t\tmappings: [],\n\t\t\tentitySets: [],\n\t\t\timports: [],\n\t\t\tapiKeys: [],\n\t\t};\n\t\treturn workspaces[active];\n\t};\n\tconst answer = async <T>(method: keyof ImporthubClient, run: () => T): Promise<T> => {\n\t\tcalls[method]++;\n\t\tif (options.fail) throw options.fail;\n\t\treturn structuredClone(run());\n\t};\n\tconst find = <C>(items: Stored<C>[], id: string, kind: string): Stored<C> => {\n\t\tconst item = items.find((i) => i.id === id);\n\t\tif (!item) throw new Error(`${kind} ${id} not found`);\n\t\treturn item;\n\t};\n\tconst nameFree = <C extends { name: string }>(items: Stored<C>[], name: string, id?: string) => {\n\t\tif (!name.trim()) throw new Error(\"a name is required\");\n\t\tif (items.some((i) => i.id !== id && i.content.name === name)) throw new NameTakenError();\n\t};\n\tconst moved = <C>(item: Stored<C>, draftRevisionId: string) =>\n\t\tdraftRevisionId !== \"\" && draftRevisionId !== draftOf(item).id;\n\t/** Saves content as the item's new draft Revision. */\n\tconst save = <C>(\n\t\titem: Stored<C>,\n\t\tcontent: C,\n\t\tdraftRevisionId: string,\n\t\trestoredFromRevisionId = \"\",\n\t) => {\n\t\tif (moved(item, draftRevisionId)) {\n\t\t\tthrow new Error(\"the draft moved: somebody saved in between\");\n\t\t}\n\t\titem.content = structuredClone(content);\n\t\titem.revisions.push({\n\t\t\tid: `${item.id}_r${item.revisions.length + 1}`,\n\t\t\tcontent: structuredClone(content),\n\t\t\tsavedBy: STUB_USER_ID,\n\t\t\tsavedAt: tick(),\n\t\t\trestoredFromRevisionId,\n\t\t});\n\t};\n\t/** A new configuration, its content the first draft. */\n\tconst stored = <C>(prefix: string, content: C): Stored<C> => {\n\t\tconst id = newId(prefix);\n\t\treturn {\n\t\t\tid,\n\t\t\tcontent: structuredClone(content),\n\t\t\trevisions: [\n\t\t\t\t{\n\t\t\t\t\tid: `${id}_r1`,\n\t\t\t\t\tcontent: structuredClone(content),\n\t\t\t\t\tsavedBy: STUB_USER_ID,\n\t\t\t\t\tsavedAt: tick(),\n\t\t\t\t\trestoredFromRevisionId: \"\",\n\t\t\t\t},\n\t\t\t],\n\t\t\treleases: [],\n\t\t};\n\t};\n\n\tfunction mappingReasons(c: MappingContent): ValidityReason[] {\n\t\tconst out: ValidityReason[] = [];\n\t\tconst release = releases.find((r) => r.id === c.blueprintReleaseId);\n\t\tif (!c.blueprintReleaseId) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"no_blueprint_release\",\n\t\t\t\tmessage: \"It pins no Blueprint Release.\",\n\t\t\t});\n\t\t} else if (!release) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"blueprint_gone\",\n\t\t\t\tmessage: \"blueprinthub does not know the Blueprint Release it pins.\",\n\t\t\t});\n\t\t} else if (release.blueprintId !== c.blueprintId) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"release_of_other_blueprint\",\n\t\t\t\tmessage: \"The pinned Release is of another Blueprint.\",\n\t\t\t});\n\t\t}\n\t\tif (!c.elementSelector) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/elementSelector\",\n\t\t\t\tcode: \"no_element_selector\",\n\t\t\t\tmessage: \"It has no element selector.\",\n\t\t\t});\n\t\t}\n\t\tif (!c.sourceKey?.selector && !c.sourceKey?.template) {\n\t\t\tout.push({ path: \"/sourceKey\", code: \"no_source_key\", message: \"It has no Source Key.\" });\n\t\t}\n\t\tconst xpath = (path: string, expr: unknown) => {\n\t\t\tif (typeof expr === \"string\" && expr !== \"\" && !balanced(expr)) {\n\t\t\t\tout.push({ path, code: \"invalid_xpath\", message: `\"${expr}\" is not an XPath.` });\n\t\t\t}\n\t\t};\n\t\txpath(\"/element_selector\", c.elementSelector);\n\t\txpath(\"/source_key/selector\", c.sourceKey?.selector);\n\t\tconst mapped: string[] = [];\n\t\t(c.fields ?? []).forEach((f, i) => {\n\t\t\tconst at = `/fields/${i}`;\n\t\t\tfor (const { path, rel, mapping } of walk(f, \"\", at)) {\n\t\t\t\tmapped.push(path);\n\t\t\t\txpath(`${rel}/selector`, mapping.selector);\n\t\t\t\tif (release && !release.fieldPaths.includes(path)) {\n\t\t\t\t\tout.push({\n\t\t\t\t\t\tpath: at,\n\t\t\t\t\t\tcode: \"unknown_field_path\",\n\t\t\t\t\t\tmessage: `The pinned Release has no field ${path}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (mapping.type === \"select\" && !mapping.selectOptions) {\n\t\t\t\t\tout.push({\n\t\t\t\t\t\tpath: at,\n\t\t\t\t\t\tcode: \"xmlmapper_schema\",\n\t\t\t\t\t\tmessage: `The select field ${path} has no select options.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t(c.versionMatch?.contentFields ?? []).forEach((f, i) => {\n\t\t\tif (!mapped.includes(f)) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/version_match/content_fields/${i}`,\n\t\t\t\t\tcode: \"unknown_version_match_field\",\n\t\t\t\t\tmessage: `The Version Match compares ${f}, which the Mapping does not map.`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t(c.titleContributions ?? []).forEach((tc, i) => {\n\t\t\tif (!tc.selector || !tc.ausgabeCodeSelector) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/title_contributions/${i}`,\n\t\t\t\t\tcode: \"incomplete_title_contribution\",\n\t\t\t\t\tmessage: \"A Title Contribution needs a selector and an Ausgabe code selector.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\txpath(`/title_contributions/${i}/selector`, tc.selector);\n\t\t});\n\t\t(c.placeholderAssets ?? []).forEach((pa, i) => {\n\t\t\tif (!pa.selector || !pa.assetType || !pa.keyParts?.length || !pa.nameSelector) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/placeholder_assets/${i}`,\n\t\t\t\t\tcode: \"incomplete_placeholder_assets\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Placeholder Assets need a selector, an asset type, the key's parts and a name selector.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\txpath(`/placeholder_assets/${i}/selector`, pa.selector);\n\t\t\t(pa.keyParts ?? []).forEach((k, j) => {\n\t\t\t\txpath(`/placeholder_assets/${i}/key_parts/${j}`, k);\n\t\t\t});\n\t\t});\n\t\treturn out;\n\t}\n\n\tfunction stepReasons(\n\t\tsteps: ProcessorStep[],\n\t\tlist: string,\n\t\tkind: Processor[\"kind\"],\n\t): ValidityReason[] {\n\t\treturn steps.flatMap((s, i): ValidityReason[] => {\n\t\t\tconst path = `/${list}/${i}`;\n\t\t\tconst p = processors.find((x) => x.name === s.processor);\n\t\t\tif (!p)\n\t\t\t\treturn [\n\t\t\t\t\t{ path, code: \"unknown_processor\", message: `No Processor is called ${s.processor}.` },\n\t\t\t\t];\n\t\t\tif (p.target !== \"source_file\") {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tcode: \"rich_text_processor\",\n\t\t\t\t\t\tmessage: `${p.name} is configured on a rich-text field, not on a Profile.`,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (p.kind !== kind)\n\t\t\t\treturn [{ path, code: \"wrong_processor_kind\", message: `${p.name} does not run here.` }];\n\t\t\tconst missing = p.settingsSpec.filter(\n\t\t\t\t(f) => f.config.required && (s.settings[f.config.api_accessor] ?? \"\") === \"\",\n\t\t\t);\n\t\t\treturn missing.map((f) => ({\n\t\t\t\tpath: `${path}/settings/${f.config.api_accessor}`,\n\t\t\t\tcode: \"invalid_processor_settings\",\n\t\t\t\tmessage: `${p.name}: ${f.config.api_accessor} is required.`,\n\t\t\t}));\n\t\t});\n\t}\n\n\tfunction profileReasons(c: ImportProfileContent): ValidityReason[] {\n\t\tconst w = ws();\n\t\tconst out = [\n\t\t\t...stepReasons(c.preprocessors, \"preprocessors\", \"preprocessor\"),\n\t\t\t...stepReasons(c.postProcessors, \"postProcessors\", \"post_processor\"),\n\t\t];\n\t\tif (c.mappingIds.length === 0) {\n\t\t\tout.push({ path: \"/mappingIds\", code: \"no_mappings\", message: \"It includes no Mapping.\" });\n\t\t}\n\t\tc.mappingIds.forEach((id, i) => {\n\t\t\tconst m = w.mappings.find((x) => x.id === id);\n\t\t\tif (!m) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/mappingIds/${i}`,\n\t\t\t\t\tcode: \"mapping_missing\",\n\t\t\t\t\tmessage: \"It includes a Mapping that does not exist.\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst reasons = mappingReasons(m.content);\n\t\t\tif (reasons.length > 0) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/mappingIds/${i}`,\n\t\t\t\t\tcode: \"mapping_invalid\",\n\t\t\t\t\tmessage: `The Mapping ${m.content.name} is invalid: ${reasons.map((r) => r.message).join(\" \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tif (c.entitySetId && !w.entitySets.some((e) => e.id === c.entitySetId)) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/entitySetId\",\n\t\t\t\tcode: \"entity_set_missing\",\n\t\t\t\tmessage: \"It names an Entity Set that does not exist.\",\n\t\t\t});\n\t\t}\n\t\treturn out;\n\t}\n\n\tconst entitySetReasons = (c: EntitySetContent): ValidityReason[] =>\n\t\tObject.keys(c.entities).length === 0\n\t\t\t? [{ path: \"/entities\", code: \"no_entities\", message: \"It defines no entity.\" }]\n\t\t\t: [];\n\n\tconst profileOf = (s: Stored<ImportProfileContent>): ImportProfile => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(profileReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst mappingOf = (s: Stored<MappingContent>): Mapping => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(mappingReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst entitySetOf = (s: Stored<EntitySetContent>): EntitySet => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(entitySetReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst profilesUsing = (uses: (c: ImportProfileContent) => boolean) =>\n\t\tbyName(ws().importProfiles.filter((p) => uses(p.content))).map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.content.name,\n\t\t}));\n\tconst newId = (prefix: string) => `${prefix}_stub_new_${++created}`;\n\n\t// Each kind's items and rules, for the calls every kind shares.\n\tconst ofKind = (kind: ConfigurationKind) => {\n\t\tconst w = ws();\n\t\tswitch (kind) {\n\t\t\tcase \"importProfile\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.importProfiles as Stored<unknown>[],\n\t\t\t\t\tname: \"Import Profile\",\n\t\t\t\t\treasons: (c: unknown) => profileReasons(c as ImportProfileContent),\n\t\t\t\t};\n\t\t\tcase \"mapping\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.mappings as Stored<unknown>[],\n\t\t\t\t\tname: \"Mapping\",\n\t\t\t\t\treasons: (c: unknown) => mappingReasons(c as MappingContent),\n\t\t\t\t};\n\t\t\tcase \"entitySet\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.entitySets as Stored<unknown>[],\n\t\t\t\t\tname: \"Entity Set\",\n\t\t\t\t\treasons: (c: unknown) => entitySetReasons(c as EntitySetContent),\n\t\t\t\t};\n\t\t}\n\t};\n\t/** The draft's validity, decided as a save decides it. */\n\tconst decide = (kind: ConfigurationKind, item: Stored<unknown>) => {\n\t\tdraftOf(item).validity = validity(ofKind(kind).reasons(item.content));\n\t};\n\tconst revisionIn = (item: Stored<unknown>, revisionId: string) => {\n\t\tconst r = item.revisions.find((x) => x.id === revisionId);\n\t\tif (!r) throw new Error(`Revision ${revisionId} not found`);\n\t\treturn r;\n\t};\n\n\t// The Source Files uploaded, by id: Start reads only those.\n\tconst sourceFiles = new Set<string>();\n\tconst rights = options.contenthubRights ?? [\"editor\", \"publisher\"];\n\tconst findImport = (id: string): StubImport => {\n\t\tconst im = ws().imports.find((i) => i.id === id);\n\t\tif (!im) throw new Error(`Import ${id} not found`);\n\t\treturn im;\n\t};\n\t/**\n\t * What the worker does to an Import somebody asked to cancel: it stops at\n\t * its next item, which in the stub is the next read.\n\t */\n\tconst settle = (im: StubImport) => {\n\t\tif (im.cancelledBy && im.phase !== \"ended\") {\n\t\t\tim.phase = \"ended\";\n\t\t\tim.outcome = \"cancelled\";\n\t\t\tim.endTime = tick();\n\t\t}\n\t};\n\tconst importOf = ({ itemProblems: _, ...im }: StubImport): Import => im;\n\t/** The latest Release of a configuration, as Start pins it; refused when there is none. */\n\tconst pinned = <C extends { name: string }>(item: Stored<C>, kind: string) => {\n\t\tconst latest = latestReleaseOf(item);\n\t\tif (!latest) {\n\t\t\tthrow new StartRefusedError(`the ${kind} ${item.content.name} has no Release yet`);\n\t\t}\n\t\tconst content = item.revisions.find((r) => r.id === latest.revisionId)?.content ?? item.content;\n\t\treturn {\n\t\t\tcontent,\n\t\t\tref: {\n\t\t\t\tconfigurationId: item.id,\n\t\t\t\tname: content.name,\n\t\t\t\treleaseId: latest.id,\n\t\t\t\tnumber: latest.number,\n\t\t\t},\n\t\t};\n\t};\n\n\treturn {\n\t\tcalls,\n\t\tswitchWorkspace(workspaceId) {\n\t\t\tactive = workspaceId;\n\t\t},\n\t\tupdateImport(id, patch) {\n\t\t\tObject.assign(findImport(id), structuredClone(patch));\n\t\t},\n\n\t\tlistImportProfiles: () =>\n\t\t\tanswer(\"listImportProfiles\", () => byName(ws().importProfiles).map(profileOf)),\n\t\tgetImportProfile: (id) =>\n\t\t\tanswer(\"getImportProfile\", () => profileOf(find(ws().importProfiles, id, \"Import Profile\"))),\n\t\tcreateImportProfile: (content) =>\n\t\t\tanswer(\"createImportProfile\", () => {\n\t\t\t\tnameFree(ws().importProfiles, content.name);\n\t\t\t\tconst s = stored(\"ip\", content);\n\t\t\t\tdecide(\"importProfile\", s);\n\t\t\t\tws().importProfiles.push(s);\n\t\t\t\treturn profileOf(s);\n\t\t\t}),\n\t\tupdateImportProfile: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateImportProfile\", () => {\n\t\t\t\tconst s = find(ws().importProfiles, id, \"Import Profile\");\n\t\t\t\tnameFree(ws().importProfiles, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"importProfile\", s);\n\t\t\t\treturn profileOf(s);\n\t\t\t}),\n\t\tdeleteImportProfile: (id) =>\n\t\t\tanswer(\"deleteImportProfile\", () => {\n\t\t\t\tfind(ws().importProfiles, id, \"Import Profile\");\n\t\t\t\tws().importProfiles = ws().importProfiles.filter((p) => p.id !== id);\n\t\t\t}),\n\n\t\tlistProcessors: () =>\n\t\t\tanswer(\"listProcessors\", () => [...processors].sort((a, b) => a.name.localeCompare(b.name))),\n\n\t\tlistMappings: () => answer(\"listMappings\", () => byName(ws().mappings).map(mappingOf)),\n\t\tgetMapping: (id) => answer(\"getMapping\", () => mappingOf(find(ws().mappings, id, \"Mapping\"))),\n\t\tcreateMapping: (content) =>\n\t\t\tanswer(\"createMapping\", () => {\n\t\t\t\tnameFree(ws().mappings, content.name);\n\t\t\t\tconst s = stored(\"mp\", content);\n\t\t\t\tdecide(\"mapping\", s);\n\t\t\t\tws().mappings.push(s);\n\t\t\t\treturn mappingOf(s);\n\t\t\t}),\n\t\tupdateMapping: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateMapping\", () => {\n\t\t\t\tconst s = find(ws().mappings, id, \"Mapping\");\n\t\t\t\tnameFree(ws().mappings, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"mapping\", s);\n\t\t\t\treturn mappingOf(s);\n\t\t\t}),\n\t\tdeleteMapping: (id) =>\n\t\t\tanswer(\"deleteMapping\", () => {\n\t\t\t\tfind(ws().mappings, id, \"Mapping\");\n\t\t\t\tconst using = profilesUsing((c) => c.mappingIds.includes(id));\n\t\t\t\tif (using.length > 0) {\n\t\t\t\t\tthrow new ConfigurationInUseError(\n\t\t\t\t\t\tusing,\n\t\t\t\t\t\t`the Mapping is included by ${using.map((p) => p.name).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tws().mappings = ws().mappings.filter((m) => m.id !== id);\n\t\t\t}),\n\t\tlistMappingImportProfiles: (id) =>\n\t\t\tanswer(\"listMappingImportProfiles\", () => {\n\t\t\t\tfind(ws().mappings, id, \"Mapping\");\n\t\t\t\treturn profilesUsing((c) => c.mappingIds.includes(id));\n\t\t\t}),\n\t\tcheckMappingBlueprintRelease: (id, blueprintReleaseId) =>\n\t\t\tanswer(\"checkMappingBlueprintRelease\", () => {\n\t\t\t\tconst m = find(ws().mappings, id, \"Mapping\");\n\t\t\t\tconst release = releases.find((r) => r.id === blueprintReleaseId);\n\t\t\t\tif (!release) throw new Error(`Blueprint Release ${blueprintReleaseId} not found`);\n\t\t\t\tif (release.blueprintId !== m.content.blueprintId) {\n\t\t\t\t\tthrow new Error(\"the Release is of another Blueprint\");\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tblueprintId: release.blueprintId,\n\t\t\t\t\tmissingFieldPaths: (m.content.fields ?? [])\n\t\t\t\t\t\t.flatMap((f, i) => walk(f, \"\", `/fields/${i}`).map((w) => w.path))\n\t\t\t\t\t\t.filter((path) => !release.fieldPaths.includes(path)),\n\t\t\t\t\tmissingReleaseSpecFields: [\n\t\t\t\t\t\t...(m.content.releaseSpec ?? []).map((r) => r.field ?? \"\"),\n\t\t\t\t\t\t...(m.content.versionMatch?.releaseSpecFields ?? []),\n\t\t\t\t\t].filter(\n\t\t\t\t\t\t(f, i, all) =>\n\t\t\t\t\t\t\tf !== \"\" &&\n\t\t\t\t\t\t\tall.indexOf(f) === i &&\n\t\t\t\t\t\t\t!(release.releaseSpecFields ?? []).some((r) => r.path === f),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}),\n\n\t\tlistEntitySets: () => answer(\"listEntitySets\", () => byName(ws().entitySets).map(entitySetOf)),\n\t\tgetEntitySet: (id) =>\n\t\t\tanswer(\"getEntitySet\", () => entitySetOf(find(ws().entitySets, id, \"Entity Set\"))),\n\t\tcreateEntitySet: (content) =>\n\t\t\tanswer(\"createEntitySet\", () => {\n\t\t\t\tnameFree(ws().entitySets, content.name);\n\t\t\t\tconst s = stored(\"es\", content);\n\t\t\t\tdecide(\"entitySet\", s);\n\t\t\t\tws().entitySets.push(s);\n\t\t\t\treturn entitySetOf(s);\n\t\t\t}),\n\t\tupdateEntitySet: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateEntitySet\", () => {\n\t\t\t\tconst s = find(ws().entitySets, id, \"Entity Set\");\n\t\t\t\tnameFree(ws().entitySets, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"entitySet\", s);\n\t\t\t\treturn entitySetOf(s);\n\t\t\t}),\n\t\tdeleteEntitySet: (id) =>\n\t\t\tanswer(\"deleteEntitySet\", () => {\n\t\t\t\tfind(ws().entitySets, id, \"Entity Set\");\n\t\t\t\tconst using = profilesUsing((c) => c.entitySetId === id);\n\t\t\t\tif (using.length > 0) {\n\t\t\t\t\tthrow new ConfigurationInUseError(\n\t\t\t\t\t\tusing,\n\t\t\t\t\t\t`the Entity Set is named by ${using.map((p) => p.name).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tws().entitySets = ws().entitySets.filter((e) => e.id !== id);\n\t\t\t}),\n\n\t\tcutRelease: (kind, id, draftRevisionId) =>\n\t\t\tanswer(\"cutRelease\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tif (moved(item, draftRevisionId)) {\n\t\t\t\t\tthrow new ReleaseRefusedError(\"the draft moved: somebody saved in between\");\n\t\t\t\t}\n\t\t\t\t// Valid now, as importhub decides it again at the cut.\n\t\t\t\tconst now = validity(k.reasons(item.content));\n\t\t\t\tif (!now.valid) throw new ReleaseRefusedError(\"the draft is invalid\", now);\n\t\t\t\tif (!stateOf(item).draftDiffersFromRelease) {\n\t\t\t\t\tthrow new ReleaseRefusedError(\n\t\t\t\t\t\t\"the draft does not differ from the latest Release: there is nothing to release\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst number = item.releases.length + 1;\n\t\t\t\tconst release: ConfigurationReleaseRecord = {\n\t\t\t\t\tid: `${item.id}_rel${number}`,\n\t\t\t\t\tnumber,\n\t\t\t\t\trevisionId: draftOf(item).id,\n\t\t\t\t\treleasedBy: STUB_USER_ID,\n\t\t\t\t\treleasedAt: tick(),\n\t\t\t\t};\n\t\t\t\titem.releases.push(release);\n\t\t\t\treturn {\n\t\t\t\t\trelease,\n\t\t\t\t\timportProfiles: kind === \"mapping\" ? profilesUsing((c) => c.mappingIds.includes(id)) : [],\n\t\t\t\t};\n\t\t\t}),\n\t\tlistHistory: (kind, id, pageToken) =>\n\t\t\tanswer(\"listHistory\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\t// Pages of ten, newest first; the token is the next page's offset.\n\t\t\t\tconst newest = [...item.revisions].reverse();\n\t\t\t\tconst from = Number(pageToken || \"0\");\n\t\t\t\tconst page = newest.slice(from, from + 10);\n\t\t\t\treturn {\n\t\t\t\t\trevisions: page.map((r) => ({\n\t\t\t\t\t\tid: r.id,\n\t\t\t\t\t\tsavedBy: r.savedBy,\n\t\t\t\t\t\tsavedAt: r.savedAt,\n\t\t\t\t\t\tvalidity: r.validity ?? validity(k.reasons(r.content)),\n\t\t\t\t\t\trestoredFromRevisionId: r.restoredFromRevisionId,\n\t\t\t\t\t})),\n\t\t\t\t\treleases: [...item.releases].reverse(),\n\t\t\t\t\tnextPageToken: from + 10 < newest.length ? String(from + 10) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\t\tcompareRevisions: (kind, id, fromRevisionId, toRevisionId) =>\n\t\t\tanswer(\"compareRevisions\", (): ConfigurationComparison => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tconst from = protoKeyed(revisionIn(item, fromRevisionId).content);\n\t\t\t\tconst to = protoKeyed(revisionIn(item, toRevisionId).content);\n\t\t\t\tconst fields = [...new Set([...Object.keys(from), ...Object.keys(to)])].map((field) => {\n\t\t\t\t\tconst a = from[field];\n\t\t\t\t\tconst b = to[field];\n\t\t\t\t\tconst status =\n\t\t\t\t\t\ta === undefined && b !== undefined\n\t\t\t\t\t\t\t? (\"added\" as const)\n\t\t\t\t\t\t\t: a !== undefined && b === undefined\n\t\t\t\t\t\t\t\t? (\"removed\" as const)\n\t\t\t\t\t\t\t\t: JSON.stringify(a) === JSON.stringify(b)\n\t\t\t\t\t\t\t\t\t? (\"unchanged\" as const)\n\t\t\t\t\t\t\t\t\t: (\"changed\" as const);\n\t\t\t\t\treturn { field, status };\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tfrom: { revisionId: fromRevisionId, content: from },\n\t\t\t\t\tto: { revisionId: toRevisionId, content: to },\n\t\t\t\t\tfields,\n\t\t\t\t};\n\t\t\t}),\n\t\trestoreRevision: (kind, id, revisionId, draftRevisionId) =>\n\t\t\tanswer(\"restoreRevision\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tsave(item, revisionIn(item, revisionId).content, draftRevisionId, revisionId);\n\t\t\t\tdecide(kind, item);\n\t\t\t}),\n\n\t\tasync uploadSourceFile(file, onProgress) {\n\t\t\tcalls.uploadSourceFile++;\n\t\t\tif (options.fail) throw options.fail;\n\t\t\t// A few steps apart, so a screen shows the bar move.\n\t\t\tfor (const f of [0.25, 0.5, 0.75]) {\n\t\t\t\tawait new Promise((r) => setTimeout(r, 20));\n\t\t\t\tonProgress(f);\n\t\t\t}\n\t\t\tif (options.uploadFails) throw options.uploadFails;\n\t\t\tonProgress(1);\n\t\t\tconst id = newId(\"sf\");\n\t\t\tsourceFiles.add(id);\n\t\t\treturn { id, fileName: file.name };\n\t\t},\n\t\tstartImport: (input) =>\n\t\t\tanswer(\"startImport\", () => {\n\t\t\t\tconst w = ws();\n\t\t\t\tconst profile = find(w.importProfiles, input.importProfileId, \"Import Profile\");\n\t\t\t\tif (!sourceFiles.has(input.sourceFileId)) {\n\t\t\t\t\tthrow new StartRefusedError(\"nothing was uploaded to the Source File\");\n\t\t\t\t}\n\t\t\t\t// importhub's order: the rights first, then what would run.\n\t\t\t\tif (!rights.includes(\"editor\")) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t\"starting an Import needs contenthub editor in the workspace\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst p = pinned(profile, \"Import Profile\");\n\t\t\t\tif (p.content.autoPublish && !rights.includes(\"publisher\")) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t\"the Import Profile has Auto-publish, which needs contenthub publisher\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst reasons = profileReasons(p.content);\n\t\t\t\tif (reasons.length > 0) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t`the Import Profile ${p.ref.name} is invalid: ${reasons.map((r) => r.message).join(\" \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst mappings = p.content.mappingIds.map(\n\t\t\t\t\t(id) => pinned(find(w.mappings, id, \"Mapping\"), \"Mapping\").ref,\n\t\t\t\t);\n\t\t\t\tconst entitySet = p.content.entitySetId\n\t\t\t\t\t? pinned(find(w.entitySets, p.content.entitySetId, \"Entity Set\"), \"Entity Set\").ref\n\t\t\t\t\t: undefined;\n\t\t\t\tconst im: StubImport = {\n\t\t\t\t\tid: newId(\"im\"),\n\t\t\t\t\timportProfileId: profile.id,\n\t\t\t\t\timportProfileName: p.ref.name,\n\t\t\t\t\tsourceFileId: input.sourceFileId,\n\t\t\t\t\tstartedBy: STUB_USER_ID,\n\t\t\t\t\tphase: \"queued\",\n\t\t\t\t\tfailureReason: \"\",\n\t\t\t\t\tprogress: { done: 0, total: 0 },\n\t\t\t\t\tcounts: {\n\t\t\t\t\t\tmatched: 0,\n\t\t\t\t\t\tcreated: 0,\n\t\t\t\t\t\tproblems: 0,\n\t\t\t\t\t\tplanned: 0,\n\t\t\t\t\t\tcorrected: 0,\n\t\t\t\t\t\tkept: 0,\n\t\t\t\t\t\tunchanged: 0,\n\t\t\t\t\t},\n\t\t\t\t\tchangeSetId: \"\",\n\t\t\t\t\treleases: {\n\t\t\t\t\t\timportProfile: p.ref,\n\t\t\t\t\t\tmappings,\n\t\t\t\t\t\t...(entitySet ? { entitySet } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tcreateTime: tick(),\n\t\t\t\t\tstartTime: \"\",\n\t\t\t\t\tendTime: \"\",\n\t\t\t\t\tcancelledBy: \"\",\n\t\t\t\t\teffectiveDate: input.effectiveDate ?? \"\",\n\t\t\t\t\t...(input.source ? { source: input.source } : {}),\n\t\t\t\t\titemProblems: [],\n\t\t\t\t};\n\t\t\t\tw.imports.unshift(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tlistImports: (pageToken) =>\n\t\t\tanswer(\"listImports\", () => {\n\t\t\t\t// Pages of fifty, newest first; the token is the next page's offset.\n\t\t\t\tconst all = ws().imports;\n\t\t\t\tall.forEach(settle);\n\t\t\t\tconst from = Number(pageToken || \"0\");\n\t\t\t\treturn {\n\t\t\t\t\timports: all.slice(from, from + 50).map(importOf),\n\t\t\t\t\tnextPageToken: from + 50 < all.length ? String(from + 50) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\t\tgetImport: (id) =>\n\t\t\tanswer(\"getImport\", () => {\n\t\t\t\tconst im = findImport(id);\n\t\t\t\tsettle(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tcancelImport: (id) =>\n\t\t\tanswer(\"cancelImport\", () => {\n\t\t\t\tconst im = findImport(id);\n\t\t\t\tif (im.phase === \"ended\") throw new Error(\"the Import has ended\");\n\t\t\t\tim.cancelledBy ||= STUB_USER_ID;\n\t\t\t\t// A queued Import ends at once; a running one at its next item.\n\t\t\t\tif (im.phase === \"queued\") settle(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tlistItemProblems: (importId, filter) =>\n\t\t\tanswer(\"listItemProblems\", () => {\n\t\t\t\tconst all = findImport(importId).itemProblems ?? [];\n\t\t\t\tconst query = filter.sourceKeyQuery.toLowerCase();\n\t\t\t\tconst matching = all.filter(\n\t\t\t\t\t(p) =>\n\t\t\t\t\t\t(!filter.mappingId || p.mappingId === filter.mappingId) &&\n\t\t\t\t\t\tp.sourceKey.toLowerCase().includes(query),\n\t\t\t\t);\n\t\t\t\tconst counts = new Map<string, { mappingId: string; mappingName: string; count: number }>();\n\t\t\t\tfor (const p of all) {\n\t\t\t\t\tconst c = counts.get(p.mappingId) ?? {\n\t\t\t\t\t\tmappingId: p.mappingId,\n\t\t\t\t\t\tmappingName: p.mappingName,\n\t\t\t\t\t\tcount: 0,\n\t\t\t\t\t};\n\t\t\t\t\tc.count++;\n\t\t\t\t\tcounts.set(p.mappingId, c);\n\t\t\t\t}\n\t\t\t\tconst from = Number(filter.pageToken || \"0\");\n\t\t\t\treturn {\n\t\t\t\t\titemProblems: matching.slice(from, from + 50),\n\t\t\t\t\ttotalCount: all.length,\n\t\t\t\t\tmatchingCount: matching.length,\n\t\t\t\t\tmappings: [...counts.values()].sort((a, b) => a.mappingName.localeCompare(b.mappingName)),\n\t\t\t\t\tnextPageToken: from + 50 < matching.length ? String(from + 50) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\n\t\tlistApiKeys: () => answer(\"listApiKeys\", () => ws().apiKeys),\n\t\tcreateApiKey: (input) =>\n\t\t\tanswer(\"createApiKey\", () => {\n\t\t\t\t// CreateAPIKey's rules: a name, not too long, and an expiry ahead.\n\t\t\t\tconst name = input.name.trim();\n\t\t\t\tif (!name) throw new Error(\"a name is required\");\n\t\t\t\tif (name.length > API_KEY_NAME_MAX) {\n\t\t\t\t\tthrow new Error(`the name is longer than ${API_KEY_NAME_MAX} characters`);\n\t\t\t\t}\n\t\t\t\tconst expireTime = input.expireTime ? new Date(input.expireTime).toISOString() : \"\";\n\t\t\t\tif (expireTime && Date.parse(expireTime) <= Date.now()) {\n\t\t\t\t\tthrow new Error(\"the expiry must lie in the future\");\n\t\t\t\t}\n\t\t\t\tconst n = ++created;\n\t\t\t\tconst apiKey: ApiKey = {\n\t\t\t\t\tid: `key_stub_new_${n}`,\n\t\t\t\t\tname,\n\t\t\t\t\tkeyPrefix: `ihk_n${String(n).padStart(3, \"0\")}`,\n\t\t\t\t\towner: STUB_USER_ID,\n\t\t\t\t\texpireTime,\n\t\t\t\t\tcreateTime: new Date().toISOString(),\n\t\t\t\t};\n\t\t\t\tws().apiKeys.unshift(apiKey);\n\t\t\t\t// The secret is returned here and kept nowhere, as importhub keeps it.\n\t\t\t\treturn { apiKey, secret: `${apiKey.keyPrefix}_stub_secret_${n}` };\n\t\t\t}),\n\t\trevokeApiKey: (id) =>\n\t\t\tanswer(\"revokeApiKey\", () => {\n\t\t\t\tconst w = ws();\n\t\t\t\tif (!w.apiKeys.some((k) => k.id === id)) throw new Error(`API key ${id} not found`);\n\t\t\t\tw.apiKeys = w.apiKeys.filter((k) => k.id !== id);\n\t\t\t}),\n\t};\n}\n\n/**\n * Whether an XPath's brackets and parentheses pair up: the stub's stand-in\n * for importhub's XPath check, enough to show a reason at its field.\n */\nfunction balanced(expr: string): boolean {\n\tconst open: string[] = [];\n\tconst pairs: Record<string, string> = { \"]\": \"[\", \")\": \"(\" };\n\tfor (const ch of expr) {\n\t\tif (ch === \"[\" || ch === \"(\") open.push(ch);\n\t\telse if (ch in pairs && open.pop() !== pairs[ch]) return false;\n\t}\n\treturn open.length === 0;\n}\n\n/** A field mapping and its children, each with its field path and pointer. */\nfunction walk(\n\tmapping: Record<string, unknown>,\n\tprefix: string,\n\tat: string,\n): { path: string; rel: string; mapping: Record<string, unknown> }[] {\n\tconst path = `${prefix}${String(mapping.name ?? \"\")}`;\n\treturn [\n\t\t{ path, rel: at, mapping },\n\t\t...([\"fields\", \"virtualTableFields\"] as const).flatMap((key) =>\n\t\t\t(Array.isArray(mapping[key]) ? (mapping[key] as Record<string, unknown>[]) : []).flatMap(\n\t\t\t\t(child, j) => walk(child, `${path}.`, `${at}/${key}/${j}`),\n\t\t\t),\n\t\t),\n\t];\n}\n\n/**\n * An `ImporthubBlueprints` over the stub's Blueprint Releases, for a host's\n * `ImporthubHost.blueprints` in tests.\n */\nexport function createStubBlueprints(\n\tblueprintReleases: StubBlueprintRelease[] = stubBlueprintReleases(),\n): ImporthubBlueprints {\n\treturn {\n\t\tasync listBlueprints() {\n\t\t\tconst byId = new Map(blueprintReleases.map((r) => [r.blueprintId, r.blueprintName]));\n\t\t\treturn [...byId]\n\t\t\t\t.map(([id, name]) => ({ id, name }))\n\t\t\t\t.sort((a, b) => a.name.localeCompare(b.name));\n\t\t},\n\t\tasync listReleases(blueprintId) {\n\t\t\treturn blueprintReleases\n\t\t\t\t.filter((r) => r.blueprintId === blueprintId)\n\t\t\t\t.map((r) => ({ id: r.id, label: r.label }));\n\t\t},\n\t\tasync getRelease(releaseId) {\n\t\t\tconst r = blueprintReleases.find((x) => x.id === releaseId);\n\t\t\tif (!r) throw new Error(`Blueprint Release ${releaseId} not found`);\n\t\t\treturn {\n\t\t\t\tid: r.id,\n\t\t\t\tblueprintId: r.blueprintId,\n\t\t\t\tname: r.label,\n\t\t\t\tfields:\n\t\t\t\t\tr.fields ??\n\t\t\t\t\tr.fieldPaths.map((path) => ({\n\t\t\t\t\t\taccessor: path,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tfieldType: \"text\",\n\t\t\t\t\t\tlabel: \"\",\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t})),\n\t\t\t\treleaseSpecFields: r.releaseSpecFields ?? [],\n\t\t\t};\n\t\t},\n\t};\n}\n"],"names":["STUB_USER_ID","STUB_OTHER_USER_ID","STUB_WORKSPACE_ID","STUB_OTHER_WORKSPACE_ID","stubIdentity","workspaceId","createHostMembers","field","path","fieldType","label","children","pathsOf","tree","f","gesetzFields","withFootnote","gesetzReleaseSpec","stubBlueprintReleases","gesetz2","gesetz1","entscheidung","stubMappings","stubEntitySets","stubImportProfiles","text","accessor","name","required","instructions","stubProcessors","counts","c","gesetzReleases","profileRelease","stubImport","i","problem","n","mapping","sourceKey","reason","stubImports","stubApiKeys","METHODS","clock","tick","seed","items","count","revisions","_","releases","draftOf","s","latestReleaseOf","stateOf","latest","released","r","snake","key","protoKeyed","content","k","v","validity","reasons","byName","a","b","created","createStubImporthubClient","options","workspaces","id","w","processors","active","calls","m","ws","answer","method","run","find","kind","item","nameFree","NameTakenError","moved","draftRevisionId","save","restoredFromRevisionId","stored","prefix","newId","mappingReasons","out","release","xpath","expr","balanced","mapped","at","rel","walk","tc","pa","j","stepReasons","steps","list","p","x","profileReasons","e","entitySetReasons","profileOf","mappingOf","entitySetOf","profilesUsing","uses","ofKind","decide","revisionIn","revisionId","sourceFiles","rights","findImport","im","settle","importOf","pinned","StartRefusedError","patch","using","ConfigurationInUseError","blueprintReleaseId","all","ReleaseRefusedError","now","number","pageToken","newest","from","fromRevisionId","toRevisionId","to","fields","status","file","onProgress","input","profile","mappings","entitySet","importId","filter","query","matching","API_KEY_NAME_MAX","expireTime","apiKey","open","pairs","ch","child","createStubBlueprints","blueprintReleases","blueprintId","releaseId"],"mappings":";;AAcO,MAAMA,IAAe,iBAEfC,IAAqB,mBAErBC,KAAoB,gBAEpBC,KAA0B;AAMhC,SAASC,GAAaC,IAAsBH,IAAiC;AACnF,SAAO;AAAA,IACN,QAAQF;AAAA,IACR,aAAAK;AAAA,IACA,SAASC,GAAkB;AAAA,MAC1B,EAAE,QAAQN,GAAc,aAAa,gBAAgB,OAAO,kBAAA;AAAA,MAC5D,EAAE,QAAQC,GAAoB,aAAa,gBAAgB,OAAO,oBAAA;AAAA,IAAoB,CACtF;AAAA,EAAA;AAEH;AAwBA,MAAMM,IAAQ,CACbC,GACAC,GACAC,GACAC,IAAsC,CAAA,OACR;AAAA,EAC9B,UAAUH,EAAK,MAAM,GAAG,EAAE,SAASA;AAAA,EACnC,MAAAA;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AACD,IAGMC,IAAU,CAACC,MAChBA,EAAK,QAAQ,CAACC,MAAM,CAACA,EAAE,MAAM,GAAGF,EAAQE,EAAE,QAAQ,CAAC,CAAC,GAE/CC,KAAe,CAACC,MAA0B;AAAA,EAC/CT,EAAM,SAAS,QAAQ,OAAO;AAAA,EA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AmBmD,EAAE,qBAAqB,CAAA;AAAA,MAAC;AAAA,IAE7C;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"testing.js","sources":["../src/testing/fixtures.ts","../src/testing/mapping-test.ts","../src/testing/stub-client.ts"],"sourcesContent":["import { createHostMembers, type HostIdentity } from \"@knkcs/anker/host\";\nimport type {\n\tApiKey,\n\tEntitySetContent,\n\tImport,\n\tImportCounts,\n\tImportProfileContent,\n\tItemProblem,\n\tMappingContent,\n\tProcessor,\n} from \"../client/importhub-client\";\nimport type { ImporthubBlueprintField } from \"../common/host\";\n\n/** The stub viewer's id. */\nexport const STUB_USER_ID = \"user_stub_ada\";\n/** A second member of the stub workspace, who starts and cancels Imports too. */\nexport const STUB_OTHER_USER_ID = \"user_stub_grace\";\n/** The stub workspace's id. */\nexport const STUB_WORKSPACE_ID = \"ws_stub_main\";\n/** A second workspace, for tests that switch to it. */\nexport const STUB_OTHER_WORKSPACE_ID = \"ws_stub_other\";\n\n/**\n * A `HostIdentity` for anker's `TestHost` or `HostProvider`: Ada, in the stub\n * workspace unless another is named.\n */\nexport function stubIdentity(workspaceId: string = STUB_WORKSPACE_ID): HostIdentity {\n\treturn {\n\t\tuserId: STUB_USER_ID,\n\t\tworkspaceId,\n\t\tmembers: createHostMembers([\n\t\t\t{ userId: STUB_USER_ID, displayName: \"Ada Importer\", email: \"ada@example.com\" },\n\t\t\t{ userId: STUB_OTHER_USER_ID, displayName: \"Grace Hopper\", email: \"grace@example.com\" },\n\t\t]),\n\t};\n}\n\n/** A stub configuration as the stub client is seeded with it: an id and its content. */\nexport interface StubConfiguration<C> {\n\tid: string;\n\tcontent: C;\n\t/** The number of its latest Release; none when unset. */\n\treleaseNumber?: number;\n}\n\n/** A Blueprint Release the stub knows, with the field paths it has. */\nexport interface StubBlueprintRelease {\n\tid: string;\n\tblueprintId: string;\n\tblueprintName: string;\n\tlabel: string;\n\t/** Every field path, nested ones included (`stand.datum`). */\n\tfieldPaths: string[];\n\t/** Its field tree, for the Mapping editor; the paths as text fields when unset. */\n\tfields?: ImporthubBlueprintField[];\n\t/** Its Release Spec fields; none when unset. */\n\treleaseSpecFields?: ImporthubBlueprintField[];\n}\n\nconst field = (\n\tpath: string,\n\tfieldType: string,\n\tlabel: string,\n\tchildren: ImporthubBlueprintField[] = [],\n): ImporthubBlueprintField => ({\n\taccessor: path.split(\".\").pop() ?? path,\n\tpath,\n\tfieldType,\n\tlabel,\n\tchildren,\n});\n\n/** Every path of a field tree, parents before their children. */\nconst pathsOf = (tree: ImporthubBlueprintField[]): string[] =>\n\ttree.flatMap((f) => [f.path, ...pathsOf(f.children)]);\n\nconst gesetzFields = (withFootnote: boolean) => [\n\tfield(\"titel\", \"text\", \"Titel\"),\n\tfield(\"abkuerzung\", \"text\", \"Abkürzung\"),\n\tfield(\"anzeigename\", \"textarea\", \"Anzeigename\"),\n\t...(withFootnote ? [field(\"fussnote\", \"rich_text\", \"Fußnote\")] : []),\n\tfield(\"stand\", \"fieldset\", \"Stand\", [\n\t\tfield(\"stand.datum\", \"date\", \"Datum\"),\n\t\tfield(\"stand.art\", \"select\", \"Art\"),\n\t]),\n];\n\nconst gesetzReleaseSpec = () => [\n\tfield(\"fundstelle\", \"text\", \"Fundstelle\"),\n\tfield(\"ausgabedatum\", \"date\", \"Ausgabedatum\"),\n];\n\n/**\n * Two Releases of the \"Gesetz\" Blueprint, with a fieldset `stand` and two\n * Release Spec fields, the newer of which dropped `fussnote`, and one of\n * \"Entscheidung\".\n */\nexport function stubBlueprintReleases(): StubBlueprintRelease[] {\n\tconst gesetz2 = gesetzFields(false);\n\tconst gesetz1 = gesetzFields(true);\n\tconst entscheidung = [\n\t\tfield(\"aktenzeichen\", \"text\", \"Aktenzeichen\"),\n\t\tfield(\"datum\", \"date\", \"Datum\"),\n\t];\n\treturn [\n\t\t{\n\t\t\tid: \"br_stub_gesetz_2\",\n\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\tblueprintName: \"Gesetz\",\n\t\t\tlabel: \"Release 2\",\n\t\t\tfieldPaths: pathsOf(gesetz2),\n\t\t\tfields: gesetz2,\n\t\t\treleaseSpecFields: gesetzReleaseSpec(),\n\t\t},\n\t\t{\n\t\t\tid: \"br_stub_gesetz_1\",\n\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\tblueprintName: \"Gesetz\",\n\t\t\tlabel: \"Release 1\",\n\t\t\tfieldPaths: pathsOf(gesetz1),\n\t\t\tfields: gesetz1,\n\t\t\treleaseSpecFields: gesetzReleaseSpec(),\n\t\t},\n\t\t{\n\t\t\tid: \"br_stub_entscheidung_1\",\n\t\t\tblueprintId: \"bp_stub_entscheidung\",\n\t\t\tblueprintName: \"Entscheidung\",\n\t\t\tlabel: \"Release 1\",\n\t\t\tfieldPaths: pathsOf(entscheidung),\n\t\t\tfields: entscheidung,\n\t\t},\n\t];\n}\n\n/** The stub workspace's Mappings: one valid and released, one invalid. */\nexport function stubMappings(): StubConfiguration<MappingContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"mp_stub_norm\",\n\t\t\treleaseNumber: 1,\n\t\t\tcontent: {\n\t\t\t\tname: \"Gesetz norms\",\n\t\t\t\tdescription: \"One Content per norm\",\n\t\t\t\tblueprintId: \"bp_stub_gesetz\",\n\t\t\t\tblueprintReleaseId: \"br_stub_gesetz_1\",\n\t\t\t\telementSelector: \"//norm\",\n\t\t\t\tsourceKey: { selector: \"@id\" },\n\t\t\t\tfields: [\n\t\t\t\t\t{ name: \"titel\", selector: \"titel\", type: \"text\" },\n\t\t\t\t\t{ name: \"fussnote\", selector: \"fn\", type: \"text\" },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: \"mp_stub_decision\",\n\t\t\tcontent: {\n\t\t\t\tname: \"Court decisions\",\n\t\t\t\tdescription: \"\",\n\t\t\t\tblueprintId: \"bp_stub_entscheidung\",\n\t\t\t\tblueprintReleaseId: \"br_stub_entscheidung_1\",\n\t\t\t\telementSelector: \"\",\n\t\t\t\tsourceKey: {},\n\t\t\t\tfields: [],\n\t\t\t},\n\t\t},\n\t];\n}\n\n/**\n * A sample file for the \"Gesetz norms\" Mapping's Mapping Test: two norms,\n * the second without a footnote.\n */\nexport const stubMappingTestSample = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gesetz>\n\t<norm id=\"n1\"><titel>§ 1 Geltungsbereich</titel><fn>Gilt ab 2026.</fn></norm>\n\t<norm id=\"n2\"><titel>§ 2 Begriffsbestimmungen</titel></norm>\n</gesetz>\n`;\n\n/** The stub workspace's Entity Sets: one. */\nexport function stubEntitySets(): StubConfiguration<EntitySetContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"es_stub_latin1\",\n\t\t\treleaseNumber: 1,\n\t\t\tcontent: {\n\t\t\t\tname: \"ISO Latin 1\",\n\t\t\t\tdescription: \"The Latin-1 entities Boorberg's files use\",\n\t\t\t\tentities: { auml: \"ä\", nbsp: \" \" },\n\t\t\t},\n\t\t},\n\t];\n}\n\n/**\n * The stub workspace's Import Profiles: one per kind of Source File. The\n * VRPML one includes the invalid Mapping, so it is invalid too.\n */\nexport function stubImportProfiles(): StubConfiguration<ImportProfileContent>[] {\n\treturn [\n\t\t{\n\t\t\tid: \"ip_stub_gesetz\",\n\t\t\treleaseNumber: 2,\n\t\t\tcontent: {\n\t\t\t\tname: \"Boorberg gesetz\",\n\t\t\t\tdescription: \"Boorberg's law files\",\n\t\t\t\tentitySetId: \"es_stub_latin1\",\n\t\t\t\tpreprocessors: [{ processor: \"rename-element\", settings: { from: \"para\", to: \"absatz\" } }],\n\t\t\t\tmappingIds: [\"mp_stub_norm\"],\n\t\t\t\tpostProcessors: [],\n\t\t\t\tautoPublish: false,\n\t\t\t\tdeleteSourceFileOnSuccess: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: \"ip_stub_vrpml\",\n\t\t\tcontent: {\n\t\t\t\tname: \"VRPML court decisions\",\n\t\t\t\tdescription: \"\",\n\t\t\t\tentitySetId: \"\",\n\t\t\t\tpreprocessors: [],\n\t\t\t\tmappingIds: [\"mp_stub_decision\"],\n\t\t\t\tpostProcessors: [],\n\t\t\t\tautoPublish: false,\n\t\t\t\tdeleteSourceFileOnSuccess: false,\n\t\t\t},\n\t\t},\n\t];\n}\n\nconst text = (accessor: string, name: string, required: boolean, instructions = \"\") => ({\n\tfield_type: \"text\",\n\tconfig: { name, api_accessor: accessor, required, instructions },\n\tsystem: false,\n});\n\n/** The catalogue, a few Processors of each kind and target. */\nexport function stubProcessors(): Processor[] {\n\treturn [\n\t\t{\n\t\t\tname: \"citation-links\",\n\t\t\tkind: \"post_processor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription:\n\t\t\t\t\"Links citations in rich text to the Content they name, through legalcitationhub.\",\n\t\t\tsettingsSpec: [],\n\t\t},\n\t\t{\n\t\t\tname: \"norm-cite\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"rich_text_field\",\n\t\t\tdescription: \"Marks legal norm citations in one rich-text field.\",\n\t\t\tsettingsSpec: [],\n\t\t},\n\t\t{\n\t\t\tname: \"rename-element\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription: \"Renames every element of one name to another.\",\n\t\t\tsettingsSpec: [\n\t\t\t\ttext(\"from\", \"Element\", true, \"The element's name now.\"),\n\t\t\t\ttext(\"to\", \"New name\", true),\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: \"sentence-detect\",\n\t\t\tkind: \"preprocessor\",\n\t\t\ttarget: \"source_file\",\n\t\t\tdescription: \"Wraps each sentence of an element in its own element.\",\n\t\t\tsettingsSpec: [text(\"element\", \"Element\", false)],\n\t\t},\n\t];\n}\n\n/** A stub Import as the stub client is seeded with it, with its Item Problems. */\nexport interface StubImport extends Import {\n\titemProblems?: ItemProblem[];\n}\n\nconst counts = (c: Partial<ImportCounts> = {}): ImportCounts => ({\n\tmatched: 0,\n\tcreated: 0,\n\tproblems: 0,\n\tplanned: 0,\n\tcorrected: 0,\n\tkept: 0,\n\tunchanged: 0,\n\t...c,\n});\n\n/** The Releases the fixtures' Imports of the gesetz Profile ran with. */\nconst gesetzReleases = (profileRelease: number): Import[\"releases\"] => ({\n\timportProfile: {\n\t\tconfigurationId: \"ip_stub_gesetz\",\n\t\tname: \"Boorberg gesetz\",\n\t\treleaseId: `ip_stub_gesetz_rel${profileRelease}`,\n\t\tnumber: profileRelease,\n\t},\n\tmappings: [\n\t\t{\n\t\t\tconfigurationId: \"mp_stub_norm\",\n\t\t\tname: \"Gesetz norms\",\n\t\t\treleaseId: \"mp_stub_norm_rel1\",\n\t\t\tnumber: 1,\n\t\t},\n\t],\n\tentitySet: {\n\t\tconfigurationId: \"es_stub_latin1\",\n\t\tname: \"ISO Latin 1\",\n\t\treleaseId: \"es_stub_latin1_rel1\",\n\t\tnumber: 1,\n\t},\n});\n\nconst stubImport = (i: Partial<StubImport> & Pick<Import, \"id\">): StubImport => ({\n\timportProfileId: \"ip_stub_gesetz\",\n\timportProfileName: \"Boorberg gesetz\",\n\tsourceFileId: `sf_${i.id}`,\n\tstartedBy: STUB_USER_ID,\n\tphase: \"ended\",\n\tfailureReason: \"\",\n\tprogress: { done: 0, total: 0 },\n\tcounts: counts(),\n\tchangeSetId: \"\",\n\treleases: gesetzReleases(2),\n\tcreateTime: \"2026-11-03T09:00:00.000Z\",\n\tstartTime: \"\",\n\tendTime: \"\",\n\tcancelledBy: \"\",\n\teffectiveDate: \"\",\n\t...i,\n});\n\nconst problem = (\n\tn: number,\n\tmapping: \"norm\" | \"title\",\n\tsourceKey: string,\n\tfield: string,\n\treason: string,\n): ItemProblem => ({\n\tid: `prob_stub_${n}`,\n\tmappingId: mapping === \"norm\" ? \"mp_stub_norm\" : \"mp_stub_title\",\n\tmappingName: mapping === \"norm\" ? \"Gesetz norms\" : \"Gesetz titles\",\n\tsourceKey,\n\tfield,\n\treason,\n});\n\n/**\n * The stub workspace's Imports, newest first: one running, one queued\n * behind it, and one of each Import Outcome.\n */\nexport function stubImports(): StubImport[] {\n\treturn [\n\t\tstubImport({\n\t\t\tid: \"im_stub_running\",\n\t\t\tphase: \"writing\",\n\t\t\tprogress: { done: 48, total: 120 },\n\t\t\tcounts: counts({ matched: 120, created: 40, planned: 8 }),\n\t\t\tchangeSetId: \"cs_stub_running\",\n\t\t\tcreateTime: \"2026-11-04T10:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-04T10:00:05.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_queued\",\n\t\t\tphase: \"queued\",\n\t\t\tstartedBy: STUB_OTHER_USER_ID,\n\t\t\treleases: gesetzReleases(2),\n\t\t\tcreateTime: \"2026-11-04T10:05:00.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_problems\",\n\t\t\toutcome: \"succeeded_with_problems\",\n\t\t\tcounts: counts({\n\t\t\t\tmatched: 212,\n\t\t\t\tcreated: 180,\n\t\t\t\tplanned: 20,\n\t\t\t\tcorrected: 6,\n\t\t\t\tkept: 1,\n\t\t\t\tproblems: 5,\n\t\t\t}),\n\t\t\tchangeSetId: \"cs_stub_problems\",\n\t\t\treleases: {\n\t\t\t\t...gesetzReleases(2),\n\t\t\t\tmappings: [\n\t\t\t\t\t...gesetzReleases(2).mappings,\n\t\t\t\t\t{\n\t\t\t\t\t\tconfigurationId: \"mp_stub_title\",\n\t\t\t\t\t\tname: \"Gesetz titles\",\n\t\t\t\t\t\treleaseId: \"mp_stub_title_rel3\",\n\t\t\t\t\t\tnumber: 3,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tcreateTime: \"2026-11-03T09:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-03T09:00:02.000Z\",\n\t\t\tendTime: \"2026-11-03T09:12:40.000Z\",\n\t\t\teffectiveDate: \"2026-10-01\",\n\t\t\tsource: { date: \"2026-09-20\", reference: \"BGBl. 2026 I Nr. 270\" },\n\t\t\titemProblems: [\n\t\t\t\tproblem(1, \"norm\", \"BJNR000010001\", \"stand/datum\", \"“31.02.2026” is not a date.\"),\n\t\t\t\tproblem(2, \"norm\", \"BJNR000010002\", \"\", \"The Version Match found two Releases.\"),\n\t\t\t\tproblem(3, \"title\", \"BJNR000020001\", \"\", \"No Title has the Ausgabe code BY-7.\"),\n\t\t\t\tproblem(4, \"norm\", \"BJNR000030001\", \"titel\", \"The field is required.\"),\n\t\t\t\tproblem(5, \"title\", \"BJNR000030002\", \"\", \"No Title has the Ausgabe code BY-9.\"),\n\t\t\t],\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_succeeded\",\n\t\t\toutcome: \"succeeded\",\n\t\t\tcounts: counts({ matched: 64, created: 64 }),\n\t\t\tchangeSetId: \"cs_stub_succeeded\",\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-02T14:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-02T14:00:01.000Z\",\n\t\t\tendTime: \"2026-11-02T14:03:10.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_failed\",\n\t\t\toutcome: \"failed\",\n\t\t\tfailureReason: \"The worker crashed three times running this Import.\",\n\t\t\tcounts: counts({ matched: 30 }),\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-02T11:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-02T11:00:01.000Z\",\n\t\t\tendTime: \"2026-11-02T11:20:00.000Z\",\n\t\t}),\n\t\tstubImport({\n\t\t\tid: \"im_stub_cancelled\",\n\t\t\toutcome: \"cancelled\",\n\t\t\tcancelledBy: STUB_OTHER_USER_ID,\n\t\t\tcounts: counts({ matched: 12, created: 3 }),\n\t\t\treleases: gesetzReleases(1),\n\t\t\tcreateTime: \"2026-11-01T16:00:00.000Z\",\n\t\t\tstartTime: \"2026-11-01T16:00:01.000Z\",\n\t\t\tendTime: \"2026-11-01T16:01:00.000Z\",\n\t\t}),\n\t];\n}\n\n/**\n * The stub workspace's API keys, newest first: Grace's nightly feed, which\n * never expires, and Ada's pipeline key, which does.\n */\nexport function stubApiKeys(): ApiKey[] {\n\treturn [\n\t\t{\n\t\t\tid: \"key_stub_nightly\",\n\t\t\tname: \"Nightly gesetz feed\",\n\t\t\tkeyPrefix: \"ihk_7Qx2\",\n\t\t\towner: STUB_OTHER_USER_ID,\n\t\t\texpireTime: \"\",\n\t\t\tcreateTime: \"2026-11-20T07:30:00.000Z\",\n\t\t},\n\t\t{\n\t\t\tid: \"key_stub_pipeline\",\n\t\t\tname: \"VRPML pipeline\",\n\t\t\tkeyPrefix: \"ihk_b91F\",\n\t\t\towner: STUB_USER_ID,\n\t\t\texpireTime: \"2027-06-30T21:59:59.000Z\",\n\t\t\tcreateTime: \"2026-11-03T12:00:00.000Z\",\n\t\t},\n\t];\n}\n","// The stub's Mapping Test: a small reading of a sample with the DOM's own\n// XPath, enough for a host's test to see a Mapping Test answer what the\n// Mapping as edited selects, not a canned answer. It is not xmlmapper: it\n// reads each field's XPath as a string (fieldsets nested), says a field\n// without a value cannot be mapped unless it is optional, and leaves out\n// everything an Import derives besides (Validity Periods, Release Spec,\n// display names, collection routing). Its messages are its own, not\n// importhub's.\n//\n// It needs a DOM (DOMParser and document.evaluate): a browser, or jsdom,\n// where a host's screen tests run anyway.\nimport {\n\ttype MappingContent,\n\ttype MappingTestElement,\n\ttype MappingTestProblem,\n\tMappingTestRefusedError,\n\ttype MappingTestResult,\n} from \"../client/importhub-client\";\n\n/** The entities XML itself defines, which an Entity Set never replaces. */\nconst XML_ENTITIES = new Set([\"amp\", \"lt\", \"gt\", \"quot\", \"apos\"]);\n\n/** The sample with an Entity Set's entities replaced, as an Import reads it. */\nexport function withEntities(sample: string, entities: Record<string, string>): string {\n\treturn sample.replace(/&([A-Za-z_][\\w.-]*);/g, (whole, name: string) =>\n\t\t!XML_ENTITIES.has(name) && name in entities ? (entities[name] ?? whole) : whole,\n\t);\n}\n\nexport function runStubMappingTest(content: MappingContent, sample: string): MappingTestResult {\n\tif (typeof DOMParser === \"undefined\") {\n\t\tthrow new Error(\"the stub's Mapping Test reads the sample with the DOM: run it in a browser\");\n\t}\n\tconst doc = new DOMParser().parseFromString(sample, \"application/xml\");\n\tconst parseError = doc.getElementsByTagName(\"parsererror\")[0];\n\tif (parseError) {\n\t\tthrow new MappingTestRefusedError(\n\t\t\t`the sample is not XML: ${(parseError.textContent ?? \"\").split(\"\\n\")[0]}`,\n\t\t);\n\t}\n\tconst selector = content.elementSelector?.trim() ?? \"\";\n\tif (!selector) throw new MappingTestRefusedError(\"the Mapping has no element selector\");\n\n\tconst nodes = (() => {\n\t\ttry {\n\t\t\tconst r = doc.evaluate(selector, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\n\t\t\treturn Array.from({ length: r.snapshotLength }, (_, i) => r.snapshotItem(i) as Node);\n\t\t} catch {\n\t\t\tthrow new MappingTestRefusedError(`the element selector ${selector} cannot be evaluated`);\n\t\t}\n\t})();\n\tconst keySelector = content.sourceKey?.selector?.trim() ?? \"\";\n\n\treturn {\n\t\telements: nodes.map((node, i): MappingTestElement => {\n\t\t\tconst problems: MappingTestProblem[] = [];\n\t\t\tlet sourceKey = \"\";\n\t\t\tif (keySelector) {\n\t\t\t\ttry {\n\t\t\t\t\tsourceKey = stringAt(doc, keySelector, node).trim();\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new MappingTestRefusedError(`the Source Key ${keySelector} cannot be evaluated`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!sourceKey) problems.push({ field: \"\", reason: \"the element has no Source Key\" });\n\t\t\tconst values = mapFields(doc, content.fields ?? [], node, \"\", problems);\n\t\t\treturn {\n\t\t\t\tposition: i + 1,\n\t\t\t\tsourceKey,\n\t\t\t\tvalues,\n\t\t\t\tfirstDay: \"\",\n\t\t\t\tlastDay: \"\",\n\t\t\t\treleaseSpec: {},\n\t\t\t\tdisplayName: \"\",\n\t\t\t\tcollections: [...(content.collections ?? [])],\n\t\t\t\tproblems,\n\t\t\t};\n\t\t}),\n\t};\n}\n\nfunction stringAt(doc: Document, xpath: string, context: Node): string {\n\treturn doc.evaluate(`string(${xpath})`, context, null, XPathResult.STRING_TYPE, null).stringValue;\n}\n\nfunction mapFields(\n\tdoc: Document,\n\tfields: ReadonlyArray<Record<string, unknown>>,\n\tcontext: Node,\n\tprefix: string,\n\tproblems: MappingTestProblem[],\n): Record<string, unknown> {\n\tconst out: Record<string, unknown> = {};\n\tfor (const f of fields) {\n\t\tconst name = typeof f.name === \"string\" ? f.name : \"\";\n\t\tif (!name) continue;\n\t\tconst path = prefix ? `${prefix}.${name}` : name;\n\t\tconst selector = typeof f.selector === \"string\" ? f.selector.trim() : \"\";\n\t\tif (f.type === \"fieldset\") {\n\t\t\tlet inner: Node | null = context;\n\t\t\tif (selector && selector !== \".\") {\n\t\t\t\ttry {\n\t\t\t\t\tinner = doc.evaluate(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tXPathResult.FIRST_ORDERED_NODE_TYPE,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t).singleNodeValue;\n\t\t\t\t} catch {\n\t\t\t\t\tinner = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!inner) {\n\t\t\t\tif (!f.optional) problems.push({ field: path, reason: `nothing at ${selector}` });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst children = Array.isArray(f.fields) ? (f.fields as Record<string, unknown>[]) : [];\n\t\t\tout[name] = mapFields(doc, children, inner, path, problems);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!selector) {\n\t\t\tproblems.push({ field: path, reason: \"the field has no XPath\" });\n\t\t\tcontinue;\n\t\t}\n\t\tlet value: string;\n\t\ttry {\n\t\t\tvalue = stringAt(doc, selector, context).trim();\n\t\t} catch {\n\t\t\tproblems.push({ field: path, reason: `the XPath ${selector} cannot be evaluated` });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!value) {\n\t\t\tif (!f.optional) problems.push({ field: path, reason: `nothing at ${selector}` });\n\t\t\tcontinue;\n\t\t}\n\t\tout[name] = value;\n\t}\n\treturn out;\n}\n","// An `ImporthubClient` over in-memory workspaces seeded from the fixtures.\n//\n// importhub takes the workspace from the caller's token, never from an\n// argument, so a real client answers for whichever workspace the host's\n// session is in. The stub does the same: it answers for its active\n// workspace, and a test switches it (`switchWorkspace`) where a host would\n// switch the token, which is how a host's test shows that switching reloads\n// the new workspace's data.\n//\n// It keeps importhub's rules a screen shows (internal/server's handlers):\n// validity reasons with their codes, a delete refused while Import Profiles\n// use the configuration, names unique per kind, a save on a draft that moved\n// refused, and the Blueprint Release check. Its messages are its own, not\n// importhub's.\n//\n// Typed as the whole interface, so a method added to `ImporthubClient`\n// without an answer here fails this package's typecheck, not a host's test.\nimport type {\n\tApiKey,\n\tConfigurationComparison,\n\tConfigurationKind,\n\tConfigurationReleaseRecord,\n\tConfigurationState,\n\tEntitySet,\n\tEntitySetContent,\n\tImport,\n\tImporthubClient,\n\tImportProfile,\n\tImportProfileContent,\n\tMapping,\n\tMappingContent,\n\tProcessor,\n\tProcessorStep,\n\tValidity,\n\tValidityReason,\n} from \"../client/importhub-client\";\nimport {\n\tAPI_KEY_NAME_MAX,\n\tConfigurationInUseError,\n\tMappingTestRefusedError,\n\tNameTakenError,\n\tReleaseRefusedError,\n\tStartRefusedError,\n} from \"../client/importhub-client\";\nimport type { ImporthubBlueprintField, ImporthubBlueprints } from \"../common/host\";\nimport { plainTextFields } from \"../screens/mapping-editor/field-tree\";\nimport {\n\tSTUB_USER_ID,\n\tSTUB_WORKSPACE_ID,\n\ttype StubBlueprintRelease,\n\ttype StubConfiguration,\n\ttype StubImport,\n\tstubApiKeys,\n\tstubBlueprintReleases,\n\tstubEntitySets,\n\tstubImportProfiles,\n\tstubImports,\n\tstubMappings,\n\tstubProcessors,\n} from \"./fixtures\";\nimport { runStubMappingTest, withEntities } from \"./mapping-test\";\n\n/** What one stub workspace holds. */\nexport interface StubWorkspace {\n\timportProfiles?: StubConfiguration<ImportProfileContent>[];\n\tmappings?: StubConfiguration<MappingContent>[];\n\tentitySets?: StubConfiguration<EntitySetContent>[];\n\t/** Its Imports, newest first, each with its Item Problems. */\n\timports?: StubImport[];\n\t/** Its importhub API keys, newest first. */\n\tapiKeys?: ApiKey[];\n}\n\n/** A contenthub right the stub viewer holds, which Start checks. */\nexport type StubContenthubRight = \"editor\" | \"publisher\";\n\nexport interface StubImporthubClientOptions {\n\t/**\n\t * The workspaces by id. Without it, the stub workspace holds the\n\t * fixtures' Import Profiles, Mappings and Entity Sets.\n\t */\n\tworkspaces?: Record<string, StubWorkspace>;\n\t/** The workspace answered for first; the stub workspace by default. */\n\tactiveWorkspaceId?: string;\n\t/** The Processor catalogue; the fixtures' by default. */\n\tprocessors?: Processor[];\n\t/** The Blueprint Releases blueprinthub knows; the fixtures' by default. */\n\tblueprintReleases?: StubBlueprintRelease[];\n\t/**\n\t * The contenthub rights the viewer holds, which Start checks\n\t * (start-an-import:AC4); both by default.\n\t */\n\tcontenthubRights?: StubContenthubRight[];\n\t/** Fail every upload with this error, as an unreachable blob store would. */\n\tuploadFails?: Error;\n\t/** Fail every call with this error, as an unreachable importhub would. */\n\tfail?: Error;\n}\n\nexport interface StubImporthubClient extends ImporthubClient {\n\t/** Answer for another workspace from now on, as a host's new token would. */\n\tswitchWorkspace(workspaceId: string): void;\n\t/**\n\t * Moves an Import on as importhub's worker would: a phase, progress,\n\t * counts, an Outcome. For tests that follow an Import while it runs.\n\t */\n\tupdateImport(id: string, patch: Partial<StubImport>): void;\n\t/** How many calls each method has answered, for tests that count reloads. */\n\treadonly calls: Readonly<Record<keyof ImporthubClient, number>>;\n}\n\n/** One saved Revision of a stored configuration. */\ninterface StoredRevision<C> {\n\tid: string;\n\tcontent: C;\n\tsavedBy: string;\n\tsavedAt: string;\n\t/** As decided at the save; a fixture's is decided when it is read. */\n\tvalidity?: Validity;\n\trestoredFromRevisionId: string;\n}\n\n/**\n * One stored configuration: every Revision, newest last (the draft), and\n * every Release, oldest first, as versionkit's linear mode keeps them.\n */\ninterface Stored<C> {\n\tid: string;\n\t/** The draft's content, which the screens' reads answer with. */\n\tcontent: C;\n\trevisions: StoredRevision<C>[];\n\treleases: ConfigurationReleaseRecord[];\n}\n\ninterface Workspace {\n\timportProfiles: Stored<ImportProfileContent>[];\n\tmappings: Stored<MappingContent>[];\n\tentitySets: Stored<EntitySetContent>[];\n\timports: StubImport[];\n\tapiKeys: ApiKey[];\n}\n\nconst METHODS: (keyof ImporthubClient)[] = [\n\t\"listImportProfiles\",\n\t\"getImportProfile\",\n\t\"createImportProfile\",\n\t\"updateImportProfile\",\n\t\"deleteImportProfile\",\n\t\"listProcessors\",\n\t\"listMappings\",\n\t\"getMapping\",\n\t\"createMapping\",\n\t\"updateMapping\",\n\t\"deleteMapping\",\n\t\"listMappingImportProfiles\",\n\t\"checkMappingBlueprintRelease\",\n\t\"runMappingTest\",\n\t\"listEntitySets\",\n\t\"getEntitySet\",\n\t\"createEntitySet\",\n\t\"updateEntitySet\",\n\t\"deleteEntitySet\",\n\t\"cutRelease\",\n\t\"listHistory\",\n\t\"compareRevisions\",\n\t\"restoreRevision\",\n\t\"uploadSourceFile\",\n\t\"startImport\",\n\t\"listImports\",\n\t\"getImport\",\n\t\"cancelImport\",\n\t\"listItemProblems\",\n\t\"listApiKeys\",\n\t\"createApiKey\",\n\t\"revokeApiKey\",\n];\n\n// A stub clock: each save and cut is an hour after the last, from the\n// fixtures' first save, so a history reads in order and tests stay stable.\nlet clock = Date.parse(\"2026-11-02T08:00:00Z\");\nconst tick = () => {\n\tclock += 3_600_000;\n\treturn new Date(clock).toISOString();\n};\n\n/**\n * A fixture as stored: released `releaseNumber` times, each Release cut\n * from a Revision of its own, the last of which is the draft; or one\n * unreleased Revision.\n */\nconst seed = <C>(items: StubConfiguration<C>[] = []): Stored<C>[] =>\n\titems.map((i) => {\n\t\tconst count = Math.max(i.releaseNumber ?? 0, 1);\n\t\tconst revisions = Array.from({ length: count }, (_, n) => ({\n\t\t\tid: `${i.id}_r${n + 1}`,\n\t\t\tcontent: structuredClone(i.content),\n\t\t\tsavedBy: STUB_USER_ID,\n\t\t\tsavedAt: tick(),\n\t\t\trestoredFromRevisionId: \"\",\n\t\t}));\n\t\tconst releases = Array.from({ length: i.releaseNumber ?? 0 }, (_, n) => ({\n\t\t\tid: `${i.id}_rel${n + 1}`,\n\t\t\tnumber: n + 1,\n\t\t\trevisionId: `${i.id}_r${n + 1}`,\n\t\t\treleasedBy: STUB_USER_ID,\n\t\t\treleasedAt: tick(),\n\t\t}));\n\t\treturn { id: i.id, content: structuredClone(i.content), revisions, releases };\n\t});\n\nconst draftOf = <C>(s: Stored<C>) => s.revisions[s.revisions.length - 1] as StoredRevision<C>;\nconst latestReleaseOf = <C>(s: Stored<C>) => s.releases[s.releases.length - 1];\n\nconst stateOf = <C>(s: Stored<C>): ConfigurationState => {\n\tconst latest = latestReleaseOf(s);\n\tconst released = s.revisions.find((r) => r.id === latest?.revisionId);\n\treturn {\n\t\tdraftRevisionId: draftOf(s).id,\n\t\t// By content, as importhub compares: a draft that restored the\n\t\t// released content does not differ.\n\t\tdraftDiffersFromRelease:\n\t\t\t!released || JSON.stringify(released.content) !== JSON.stringify(draftOf(s).content),\n\t\t...(latest ? { latestRelease: { id: latest.id, number: latest.number } } : {}),\n\t};\n};\n\n/** A content's top-level keys as importhub's comparison names them. */\nconst snake = (key: string) => key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);\nconst protoKeyed = (content: unknown): Record<string, unknown> =>\n\tObject.fromEntries(\n\t\tObject.entries(content as Record<string, unknown>).map(([k, v]) => [snake(k), v]),\n\t);\n\nconst validity = (reasons: ValidityReason[]): Validity => ({\n\tvalid: reasons.length === 0,\n\treasons,\n});\n\nconst byName = <T extends { content: { name: string } }>(items: T[]) =>\n\t[...items].sort((a, b) => a.content.name.localeCompare(b.content.name));\n\nlet created = 0;\n\nexport function createStubImporthubClient(\n\toptions: StubImporthubClientOptions = {},\n): StubImporthubClient {\n\tconst workspaces: Record<string, Workspace> = Object.fromEntries(\n\t\tObject.entries(\n\t\t\toptions.workspaces ?? {\n\t\t\t\t[STUB_WORKSPACE_ID]: {\n\t\t\t\t\timportProfiles: stubImportProfiles(),\n\t\t\t\t\tmappings: stubMappings(),\n\t\t\t\t\tentitySets: stubEntitySets(),\n\t\t\t\t\timports: stubImports(),\n\t\t\t\t\tapiKeys: stubApiKeys(),\n\t\t\t\t},\n\t\t\t},\n\t\t).map(([id, w]) => [\n\t\t\tid,\n\t\t\t{\n\t\t\t\timportProfiles: seed(w.importProfiles),\n\t\t\t\tmappings: seed(w.mappings),\n\t\t\t\tentitySets: seed(w.entitySets),\n\t\t\t\timports: structuredClone(w.imports ?? []),\n\t\t\t\tapiKeys: structuredClone(w.apiKeys ?? []),\n\t\t\t},\n\t\t]),\n\t);\n\tconst processors = options.processors ?? stubProcessors();\n\tconst releases = options.blueprintReleases ?? stubBlueprintReleases();\n\tlet active = options.activeWorkspaceId ?? STUB_WORKSPACE_ID;\n\tconst calls = Object.fromEntries(METHODS.map((m) => [m, 0])) as Record<\n\t\tkeyof ImporthubClient,\n\t\tnumber\n\t>;\n\tconst ws = (): Workspace => {\n\t\tworkspaces[active] ??= {\n\t\t\timportProfiles: [],\n\t\t\tmappings: [],\n\t\t\tentitySets: [],\n\t\t\timports: [],\n\t\t\tapiKeys: [],\n\t\t};\n\t\treturn workspaces[active];\n\t};\n\tconst answer = async <T>(method: keyof ImporthubClient, run: () => T): Promise<T> => {\n\t\tcalls[method]++;\n\t\tif (options.fail) throw options.fail;\n\t\treturn structuredClone(run());\n\t};\n\tconst find = <C>(items: Stored<C>[], id: string, kind: string): Stored<C> => {\n\t\tconst item = items.find((i) => i.id === id);\n\t\tif (!item) throw new Error(`${kind} ${id} not found`);\n\t\treturn item;\n\t};\n\tconst nameFree = <C extends { name: string }>(items: Stored<C>[], name: string, id?: string) => {\n\t\tif (!name.trim()) throw new Error(\"a name is required\");\n\t\tif (items.some((i) => i.id !== id && i.content.name === name)) throw new NameTakenError();\n\t};\n\tconst moved = <C>(item: Stored<C>, draftRevisionId: string) =>\n\t\tdraftRevisionId !== \"\" && draftRevisionId !== draftOf(item).id;\n\t/** Saves content as the item's new draft Revision. */\n\tconst save = <C>(\n\t\titem: Stored<C>,\n\t\tcontent: C,\n\t\tdraftRevisionId: string,\n\t\trestoredFromRevisionId = \"\",\n\t) => {\n\t\tif (moved(item, draftRevisionId)) {\n\t\t\tthrow new Error(\"the draft moved: somebody saved in between\");\n\t\t}\n\t\titem.content = structuredClone(content);\n\t\titem.revisions.push({\n\t\t\tid: `${item.id}_r${item.revisions.length + 1}`,\n\t\t\tcontent: structuredClone(content),\n\t\t\tsavedBy: STUB_USER_ID,\n\t\t\tsavedAt: tick(),\n\t\t\trestoredFromRevisionId,\n\t\t});\n\t};\n\t/** A new configuration, its content the first draft. */\n\tconst stored = <C>(prefix: string, content: C): Stored<C> => {\n\t\tconst id = newId(prefix);\n\t\treturn {\n\t\t\tid,\n\t\t\tcontent: structuredClone(content),\n\t\t\trevisions: [\n\t\t\t\t{\n\t\t\t\t\tid: `${id}_r1`,\n\t\t\t\t\tcontent: structuredClone(content),\n\t\t\t\t\tsavedBy: STUB_USER_ID,\n\t\t\t\t\tsavedAt: tick(),\n\t\t\t\t\trestoredFromRevisionId: \"\",\n\t\t\t\t},\n\t\t\t],\n\t\t\treleases: [],\n\t\t};\n\t};\n\n\tfunction mappingReasons(c: MappingContent): ValidityReason[] {\n\t\tconst out: ValidityReason[] = [];\n\t\tconst release = releases.find((r) => r.id === c.blueprintReleaseId);\n\t\tif (!c.blueprintReleaseId) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"no_blueprint_release\",\n\t\t\t\tmessage: \"It pins no Blueprint Release.\",\n\t\t\t});\n\t\t} else if (!release) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"blueprint_gone\",\n\t\t\t\tmessage: \"blueprinthub does not know the Blueprint Release it pins.\",\n\t\t\t});\n\t\t} else if (release.blueprintId !== c.blueprintId) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/blueprintReleaseId\",\n\t\t\t\tcode: \"release_of_other_blueprint\",\n\t\t\t\tmessage: \"The pinned Release is of another Blueprint.\",\n\t\t\t});\n\t\t}\n\t\tif (!c.elementSelector) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/elementSelector\",\n\t\t\t\tcode: \"no_element_selector\",\n\t\t\t\tmessage: \"It has no element selector.\",\n\t\t\t});\n\t\t}\n\t\tif (!c.sourceKey?.selector && !c.sourceKey?.template) {\n\t\t\tout.push({ path: \"/sourceKey\", code: \"no_source_key\", message: \"It has no Source Key.\" });\n\t\t}\n\t\tconst xpath = (path: string, expr: unknown) => {\n\t\t\tif (typeof expr === \"string\" && expr !== \"\" && !balanced(expr)) {\n\t\t\t\tout.push({ path, code: \"invalid_xpath\", message: `\"${expr}\" is not an XPath.` });\n\t\t\t}\n\t\t};\n\t\txpath(\"/element_selector\", c.elementSelector);\n\t\txpath(\"/source_key/selector\", c.sourceKey?.selector);\n\t\tconst mapped: string[] = [];\n\t\t(c.fields ?? []).forEach((f, i) => {\n\t\t\tconst at = `/fields/${i}`;\n\t\t\tfor (const { path, rel, mapping } of walk(f, \"\", at)) {\n\t\t\t\tmapped.push(path);\n\t\t\t\txpath(`${rel}/selector`, mapping.selector);\n\t\t\t\tif (release && !release.fieldPaths.includes(path)) {\n\t\t\t\t\tout.push({\n\t\t\t\t\t\tpath: at,\n\t\t\t\t\t\tcode: \"unknown_field_path\",\n\t\t\t\t\t\tmessage: `The pinned Release has no field ${path}.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (mapping.type === \"select\" && !mapping.selectOptions) {\n\t\t\t\t\tout.push({\n\t\t\t\t\t\tpath: at,\n\t\t\t\t\t\tcode: \"xmlmapper_schema\",\n\t\t\t\t\t\tmessage: `The select field ${path} has no select options.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t(c.versionMatch?.contentFields ?? []).forEach((f, i) => {\n\t\t\tif (!mapped.includes(f)) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/version_match/content_fields/${i}`,\n\t\t\t\t\tcode: \"unknown_version_match_field\",\n\t\t\t\t\tmessage: `The Version Match compares ${f}, which the Mapping does not map.`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t(c.titleContributions ?? []).forEach((tc, i) => {\n\t\t\tif (!tc.selector || !tc.ausgabeCodeSelector) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/title_contributions/${i}`,\n\t\t\t\t\tcode: \"incomplete_title_contribution\",\n\t\t\t\t\tmessage: \"A Title Contribution needs a selector and an Ausgabe code selector.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\txpath(`/title_contributions/${i}/selector`, tc.selector);\n\t\t});\n\t\t(c.placeholderAssets ?? []).forEach((pa, i) => {\n\t\t\tif (!pa.selector || !pa.assetType || !pa.keyParts?.length || !pa.nameSelector) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/placeholder_assets/${i}`,\n\t\t\t\t\tcode: \"incomplete_placeholder_assets\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Placeholder Assets need a selector, an asset type, the key's parts and a name selector.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\txpath(`/placeholder_assets/${i}/selector`, pa.selector);\n\t\t\t(pa.keyParts ?? []).forEach((k, j) => {\n\t\t\t\txpath(`/placeholder_assets/${i}/key_parts/${j}`, k);\n\t\t\t});\n\t\t});\n\t\tout.push(...displayNameReasons(c, release?.fields, mapped));\n\t\treturn out;\n\t}\n\n\tfunction stepReasons(\n\t\tsteps: ProcessorStep[],\n\t\tlist: string,\n\t\tkind: Processor[\"kind\"],\n\t): ValidityReason[] {\n\t\treturn steps.flatMap((s, i): ValidityReason[] => {\n\t\t\tconst path = `/${list}/${i}`;\n\t\t\tconst p = processors.find((x) => x.name === s.processor);\n\t\t\tif (!p)\n\t\t\t\treturn [\n\t\t\t\t\t{ path, code: \"unknown_processor\", message: `No Processor is called ${s.processor}.` },\n\t\t\t\t];\n\t\t\tif (p.target !== \"source_file\") {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tcode: \"rich_text_processor\",\n\t\t\t\t\t\tmessage: `${p.name} is configured on a rich-text field, not on a Profile.`,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (p.kind !== kind)\n\t\t\t\treturn [{ path, code: \"wrong_processor_kind\", message: `${p.name} does not run here.` }];\n\t\t\tconst missing = p.settingsSpec.filter(\n\t\t\t\t(f) => f.config.required && (s.settings[f.config.api_accessor] ?? \"\") === \"\",\n\t\t\t);\n\t\t\treturn missing.map((f) => ({\n\t\t\t\tpath: `${path}/settings/${f.config.api_accessor}`,\n\t\t\t\tcode: \"invalid_processor_settings\",\n\t\t\t\tmessage: `${p.name}: ${f.config.api_accessor} is required.`,\n\t\t\t}));\n\t\t});\n\t}\n\n\tfunction profileReasons(c: ImportProfileContent): ValidityReason[] {\n\t\tconst w = ws();\n\t\tconst out = [\n\t\t\t...stepReasons(c.preprocessors, \"preprocessors\", \"preprocessor\"),\n\t\t\t...stepReasons(c.postProcessors, \"postProcessors\", \"post_processor\"),\n\t\t];\n\t\tif (c.mappingIds.length === 0) {\n\t\t\tout.push({ path: \"/mappingIds\", code: \"no_mappings\", message: \"It includes no Mapping.\" });\n\t\t}\n\t\tc.mappingIds.forEach((id, i) => {\n\t\t\tconst m = w.mappings.find((x) => x.id === id);\n\t\t\tif (!m) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/mappingIds/${i}`,\n\t\t\t\t\tcode: \"mapping_missing\",\n\t\t\t\t\tmessage: \"It includes a Mapping that does not exist.\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst reasons = mappingReasons(m.content);\n\t\t\tif (reasons.length > 0) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/mappingIds/${i}`,\n\t\t\t\t\tcode: \"mapping_invalid\",\n\t\t\t\t\tmessage: `The Mapping ${m.content.name} is invalid: ${reasons.map((r) => r.message).join(\" \")}`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tif (c.entitySetId && !w.entitySets.some((e) => e.id === c.entitySetId)) {\n\t\t\tout.push({\n\t\t\t\tpath: \"/entitySetId\",\n\t\t\t\tcode: \"entity_set_missing\",\n\t\t\t\tmessage: \"It names an Entity Set that does not exist.\",\n\t\t\t});\n\t\t}\n\t\treturn out;\n\t}\n\n\tconst entitySetReasons = (c: EntitySetContent): ValidityReason[] =>\n\t\tObject.keys(c.entities).length === 0\n\t\t\t? [{ path: \"/entities\", code: \"no_entities\", message: \"It defines no entity.\" }]\n\t\t\t: [];\n\n\tconst profileOf = (s: Stored<ImportProfileContent>): ImportProfile => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(profileReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst mappingOf = (s: Stored<MappingContent>): Mapping => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(mappingReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst entitySetOf = (s: Stored<EntitySetContent>): EntitySet => ({\n\t\tid: s.id,\n\t\tcontent: s.content,\n\t\tvalidity: validity(entitySetReasons(s.content)),\n\t\tstate: stateOf(s),\n\t});\n\tconst profilesUsing = (uses: (c: ImportProfileContent) => boolean) =>\n\t\tbyName(ws().importProfiles.filter((p) => uses(p.content))).map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.content.name,\n\t\t}));\n\tconst newId = (prefix: string) => `${prefix}_stub_new_${++created}`;\n\n\t// Each kind's items and rules, for the calls every kind shares.\n\tconst ofKind = (kind: ConfigurationKind) => {\n\t\tconst w = ws();\n\t\tswitch (kind) {\n\t\t\tcase \"importProfile\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.importProfiles as Stored<unknown>[],\n\t\t\t\t\tname: \"Import Profile\",\n\t\t\t\t\treasons: (c: unknown) => profileReasons(c as ImportProfileContent),\n\t\t\t\t};\n\t\t\tcase \"mapping\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.mappings as Stored<unknown>[],\n\t\t\t\t\tname: \"Mapping\",\n\t\t\t\t\treasons: (c: unknown) => mappingReasons(c as MappingContent),\n\t\t\t\t};\n\t\t\tcase \"entitySet\":\n\t\t\t\treturn {\n\t\t\t\t\titems: w.entitySets as Stored<unknown>[],\n\t\t\t\t\tname: \"Entity Set\",\n\t\t\t\t\treasons: (c: unknown) => entitySetReasons(c as EntitySetContent),\n\t\t\t\t};\n\t\t}\n\t};\n\t/** The draft's validity, decided as a save decides it. */\n\tconst decide = (kind: ConfigurationKind, item: Stored<unknown>) => {\n\t\tdraftOf(item).validity = validity(ofKind(kind).reasons(item.content));\n\t};\n\tconst revisionIn = (item: Stored<unknown>, revisionId: string) => {\n\t\tconst r = item.revisions.find((x) => x.id === revisionId);\n\t\tif (!r) throw new Error(`Revision ${revisionId} not found`);\n\t\treturn r;\n\t};\n\n\t// The Source Files uploaded, by id: Start reads only those.\n\tconst sourceFiles = new Set<string>();\n\tconst rights = options.contenthubRights ?? [\"editor\", \"publisher\"];\n\tconst findImport = (id: string): StubImport => {\n\t\tconst im = ws().imports.find((i) => i.id === id);\n\t\tif (!im) throw new Error(`Import ${id} not found`);\n\t\treturn im;\n\t};\n\t/**\n\t * What the worker does to an Import somebody asked to cancel: it stops at\n\t * its next item, which in the stub is the next read.\n\t */\n\tconst settle = (im: StubImport) => {\n\t\tif (im.cancelledBy && im.phase !== \"ended\") {\n\t\t\tim.phase = \"ended\";\n\t\t\tim.outcome = \"cancelled\";\n\t\t\tim.endTime = tick();\n\t\t}\n\t};\n\tconst importOf = ({ itemProblems: _, ...im }: StubImport): Import => im;\n\t/** The latest Release of a configuration, as Start pins it; refused when there is none. */\n\tconst pinned = <C extends { name: string }>(item: Stored<C>, kind: string) => {\n\t\tconst latest = latestReleaseOf(item);\n\t\tif (!latest) {\n\t\t\tthrow new StartRefusedError(`the ${kind} ${item.content.name} has no Release yet`);\n\t\t}\n\t\tconst content = item.revisions.find((r) => r.id === latest.revisionId)?.content ?? item.content;\n\t\treturn {\n\t\t\tcontent,\n\t\t\tref: {\n\t\t\t\tconfigurationId: item.id,\n\t\t\t\tname: content.name,\n\t\t\t\treleaseId: latest.id,\n\t\t\t\tnumber: latest.number,\n\t\t\t},\n\t\t};\n\t};\n\n\treturn {\n\t\tcalls,\n\t\tswitchWorkspace(workspaceId) {\n\t\t\tactive = workspaceId;\n\t\t},\n\t\tupdateImport(id, patch) {\n\t\t\tObject.assign(findImport(id), structuredClone(patch));\n\t\t},\n\n\t\tlistImportProfiles: () =>\n\t\t\tanswer(\"listImportProfiles\", () => byName(ws().importProfiles).map(profileOf)),\n\t\tgetImportProfile: (id) =>\n\t\t\tanswer(\"getImportProfile\", () => profileOf(find(ws().importProfiles, id, \"Import Profile\"))),\n\t\tcreateImportProfile: (content) =>\n\t\t\tanswer(\"createImportProfile\", () => {\n\t\t\t\tnameFree(ws().importProfiles, content.name);\n\t\t\t\tconst s = stored(\"ip\", content);\n\t\t\t\tdecide(\"importProfile\", s);\n\t\t\t\tws().importProfiles.push(s);\n\t\t\t\treturn profileOf(s);\n\t\t\t}),\n\t\tupdateImportProfile: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateImportProfile\", () => {\n\t\t\t\tconst s = find(ws().importProfiles, id, \"Import Profile\");\n\t\t\t\tnameFree(ws().importProfiles, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"importProfile\", s);\n\t\t\t\treturn profileOf(s);\n\t\t\t}),\n\t\tdeleteImportProfile: (id) =>\n\t\t\tanswer(\"deleteImportProfile\", () => {\n\t\t\t\tfind(ws().importProfiles, id, \"Import Profile\");\n\t\t\t\tws().importProfiles = ws().importProfiles.filter((p) => p.id !== id);\n\t\t\t}),\n\n\t\tlistProcessors: () =>\n\t\t\tanswer(\"listProcessors\", () => [...processors].sort((a, b) => a.name.localeCompare(b.name))),\n\n\t\tlistMappings: () => answer(\"listMappings\", () => byName(ws().mappings).map(mappingOf)),\n\t\tgetMapping: (id) => answer(\"getMapping\", () => mappingOf(find(ws().mappings, id, \"Mapping\"))),\n\t\tcreateMapping: (content) =>\n\t\t\tanswer(\"createMapping\", () => {\n\t\t\t\tnameFree(ws().mappings, content.name);\n\t\t\t\tconst s = stored(\"mp\", content);\n\t\t\t\tdecide(\"mapping\", s);\n\t\t\t\tws().mappings.push(s);\n\t\t\t\treturn mappingOf(s);\n\t\t\t}),\n\t\tupdateMapping: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateMapping\", () => {\n\t\t\t\tconst s = find(ws().mappings, id, \"Mapping\");\n\t\t\t\tnameFree(ws().mappings, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"mapping\", s);\n\t\t\t\treturn mappingOf(s);\n\t\t\t}),\n\t\tdeleteMapping: (id) =>\n\t\t\tanswer(\"deleteMapping\", () => {\n\t\t\t\tfind(ws().mappings, id, \"Mapping\");\n\t\t\t\tconst using = profilesUsing((c) => c.mappingIds.includes(id));\n\t\t\t\tif (using.length > 0) {\n\t\t\t\t\tthrow new ConfigurationInUseError(\n\t\t\t\t\t\tusing,\n\t\t\t\t\t\t`the Mapping is included by ${using.map((p) => p.name).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tws().mappings = ws().mappings.filter((m) => m.id !== id);\n\t\t\t}),\n\t\tlistMappingImportProfiles: (id) =>\n\t\t\tanswer(\"listMappingImportProfiles\", () => {\n\t\t\t\tfind(ws().mappings, id, \"Mapping\");\n\t\t\t\treturn profilesUsing((c) => c.mappingIds.includes(id));\n\t\t\t}),\n\t\tcheckMappingBlueprintRelease: (id, blueprintReleaseId) =>\n\t\t\tanswer(\"checkMappingBlueprintRelease\", () => {\n\t\t\t\tconst m = find(ws().mappings, id, \"Mapping\");\n\t\t\t\tconst release = releases.find((r) => r.id === blueprintReleaseId);\n\t\t\t\tif (!release) throw new Error(`Blueprint Release ${blueprintReleaseId} not found`);\n\t\t\t\tif (release.blueprintId !== m.content.blueprintId) {\n\t\t\t\t\tthrow new Error(\"the Release is of another Blueprint\");\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tblueprintId: release.blueprintId,\n\t\t\t\t\tmissingFieldPaths: (m.content.fields ?? [])\n\t\t\t\t\t\t.flatMap((f, i) => walk(f, \"\", `/fields/${i}`).map((w) => w.path))\n\t\t\t\t\t\t.filter((path) => !release.fieldPaths.includes(path)),\n\t\t\t\t\tmissingReleaseSpecFields: [\n\t\t\t\t\t\t...(m.content.releaseSpec ?? []).map((r) => r.field ?? \"\"),\n\t\t\t\t\t\t...(m.content.versionMatch?.releaseSpecFields ?? []),\n\t\t\t\t\t].filter(\n\t\t\t\t\t\t(f, i, all) =>\n\t\t\t\t\t\t\tf !== \"\" &&\n\t\t\t\t\t\t\tall.indexOf(f) === i &&\n\t\t\t\t\t\t\t!(release.releaseSpecFields ?? []).some((r) => r.path === f),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}),\n\n\t\trunMappingTest: ({ content, sample, entitySetId }) =>\n\t\t\tanswer(\"runMappingTest\", () => {\n\t\t\t\tlet text = new TextDecoder().decode(sample);\n\t\t\t\tif (entitySetId) {\n\t\t\t\t\t// The Entity Set's draft, as importhub reads it for a test.\n\t\t\t\t\tconst es = ws().entitySets.find((e) => e.id === entitySetId);\n\t\t\t\t\tif (!es) throw new MappingTestRefusedError(`Entity Set ${entitySetId} not found`);\n\t\t\t\t\ttext = withEntities(text, es.content.entities);\n\t\t\t\t}\n\t\t\t\treturn runStubMappingTest(content, text);\n\t\t\t}),\n\n\t\tlistEntitySets: () => answer(\"listEntitySets\", () => byName(ws().entitySets).map(entitySetOf)),\n\t\tgetEntitySet: (id) =>\n\t\t\tanswer(\"getEntitySet\", () => entitySetOf(find(ws().entitySets, id, \"Entity Set\"))),\n\t\tcreateEntitySet: (content) =>\n\t\t\tanswer(\"createEntitySet\", () => {\n\t\t\t\tnameFree(ws().entitySets, content.name);\n\t\t\t\tconst s = stored(\"es\", content);\n\t\t\t\tdecide(\"entitySet\", s);\n\t\t\t\tws().entitySets.push(s);\n\t\t\t\treturn entitySetOf(s);\n\t\t\t}),\n\t\tupdateEntitySet: (id, content, draftRevisionId) =>\n\t\t\tanswer(\"updateEntitySet\", () => {\n\t\t\t\tconst s = find(ws().entitySets, id, \"Entity Set\");\n\t\t\t\tnameFree(ws().entitySets, content.name, id);\n\t\t\t\tsave(s, content, draftRevisionId);\n\t\t\t\tdecide(\"entitySet\", s);\n\t\t\t\treturn entitySetOf(s);\n\t\t\t}),\n\t\tdeleteEntitySet: (id) =>\n\t\t\tanswer(\"deleteEntitySet\", () => {\n\t\t\t\tfind(ws().entitySets, id, \"Entity Set\");\n\t\t\t\tconst using = profilesUsing((c) => c.entitySetId === id);\n\t\t\t\tif (using.length > 0) {\n\t\t\t\t\tthrow new ConfigurationInUseError(\n\t\t\t\t\t\tusing,\n\t\t\t\t\t\t`the Entity Set is named by ${using.map((p) => p.name).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tws().entitySets = ws().entitySets.filter((e) => e.id !== id);\n\t\t\t}),\n\n\t\tcutRelease: (kind, id, draftRevisionId) =>\n\t\t\tanswer(\"cutRelease\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tif (moved(item, draftRevisionId)) {\n\t\t\t\t\tthrow new ReleaseRefusedError(\"the draft moved: somebody saved in between\");\n\t\t\t\t}\n\t\t\t\t// Valid now, as importhub decides it again at the cut.\n\t\t\t\tconst now = validity(k.reasons(item.content));\n\t\t\t\tif (!now.valid) throw new ReleaseRefusedError(\"the draft is invalid\", now);\n\t\t\t\tif (!stateOf(item).draftDiffersFromRelease) {\n\t\t\t\t\tthrow new ReleaseRefusedError(\n\t\t\t\t\t\t\"the draft does not differ from the latest Release: there is nothing to release\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst number = item.releases.length + 1;\n\t\t\t\tconst release: ConfigurationReleaseRecord = {\n\t\t\t\t\tid: `${item.id}_rel${number}`,\n\t\t\t\t\tnumber,\n\t\t\t\t\trevisionId: draftOf(item).id,\n\t\t\t\t\treleasedBy: STUB_USER_ID,\n\t\t\t\t\treleasedAt: tick(),\n\t\t\t\t};\n\t\t\t\titem.releases.push(release);\n\t\t\t\treturn {\n\t\t\t\t\trelease,\n\t\t\t\t\timportProfiles: kind === \"mapping\" ? profilesUsing((c) => c.mappingIds.includes(id)) : [],\n\t\t\t\t};\n\t\t\t}),\n\t\tlistHistory: (kind, id, pageToken) =>\n\t\t\tanswer(\"listHistory\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\t// Pages of ten, newest first; the token is the next page's offset.\n\t\t\t\tconst newest = [...item.revisions].reverse();\n\t\t\t\tconst from = Number(pageToken || \"0\");\n\t\t\t\tconst page = newest.slice(from, from + 10);\n\t\t\t\treturn {\n\t\t\t\t\trevisions: page.map((r) => ({\n\t\t\t\t\t\tid: r.id,\n\t\t\t\t\t\tsavedBy: r.savedBy,\n\t\t\t\t\t\tsavedAt: r.savedAt,\n\t\t\t\t\t\tvalidity: r.validity ?? validity(k.reasons(r.content)),\n\t\t\t\t\t\trestoredFromRevisionId: r.restoredFromRevisionId,\n\t\t\t\t\t})),\n\t\t\t\t\treleases: [...item.releases].reverse(),\n\t\t\t\t\tnextPageToken: from + 10 < newest.length ? String(from + 10) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\t\tcompareRevisions: (kind, id, fromRevisionId, toRevisionId) =>\n\t\t\tanswer(\"compareRevisions\", (): ConfigurationComparison => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tconst from = protoKeyed(revisionIn(item, fromRevisionId).content);\n\t\t\t\tconst to = protoKeyed(revisionIn(item, toRevisionId).content);\n\t\t\t\tconst fields = [...new Set([...Object.keys(from), ...Object.keys(to)])].map((field) => {\n\t\t\t\t\tconst a = from[field];\n\t\t\t\t\tconst b = to[field];\n\t\t\t\t\tconst status =\n\t\t\t\t\t\ta === undefined && b !== undefined\n\t\t\t\t\t\t\t? (\"added\" as const)\n\t\t\t\t\t\t\t: a !== undefined && b === undefined\n\t\t\t\t\t\t\t\t? (\"removed\" as const)\n\t\t\t\t\t\t\t\t: JSON.stringify(a) === JSON.stringify(b)\n\t\t\t\t\t\t\t\t\t? (\"unchanged\" as const)\n\t\t\t\t\t\t\t\t\t: (\"changed\" as const);\n\t\t\t\t\treturn { field, status };\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tfrom: { revisionId: fromRevisionId, content: from },\n\t\t\t\t\tto: { revisionId: toRevisionId, content: to },\n\t\t\t\t\tfields,\n\t\t\t\t};\n\t\t\t}),\n\t\trestoreRevision: (kind, id, revisionId, draftRevisionId) =>\n\t\t\tanswer(\"restoreRevision\", () => {\n\t\t\t\tconst k = ofKind(kind);\n\t\t\t\tconst item = find(k.items, id, k.name);\n\t\t\t\tsave(item, revisionIn(item, revisionId).content, draftRevisionId, revisionId);\n\t\t\t\tdecide(kind, item);\n\t\t\t}),\n\n\t\tasync uploadSourceFile(file, onProgress) {\n\t\t\tcalls.uploadSourceFile++;\n\t\t\tif (options.fail) throw options.fail;\n\t\t\t// A few steps apart, so a screen shows the bar move.\n\t\t\tfor (const f of [0.25, 0.5, 0.75]) {\n\t\t\t\tawait new Promise((r) => setTimeout(r, 20));\n\t\t\t\tonProgress(f);\n\t\t\t}\n\t\t\tif (options.uploadFails) throw options.uploadFails;\n\t\t\tonProgress(1);\n\t\t\tconst id = newId(\"sf\");\n\t\t\tsourceFiles.add(id);\n\t\t\treturn { id, fileName: file.name };\n\t\t},\n\t\tstartImport: (input) =>\n\t\t\tanswer(\"startImport\", () => {\n\t\t\t\tconst w = ws();\n\t\t\t\tconst profile = find(w.importProfiles, input.importProfileId, \"Import Profile\");\n\t\t\t\tif (!sourceFiles.has(input.sourceFileId)) {\n\t\t\t\t\tthrow new StartRefusedError(\"nothing was uploaded to the Source File\");\n\t\t\t\t}\n\t\t\t\t// importhub's order: the rights first, then what would run.\n\t\t\t\tif (!rights.includes(\"editor\")) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t\"starting an Import needs contenthub editor in the workspace\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst p = pinned(profile, \"Import Profile\");\n\t\t\t\tif (p.content.autoPublish && !rights.includes(\"publisher\")) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t\"the Import Profile has Auto-publish, which needs contenthub publisher\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst reasons = profileReasons(p.content);\n\t\t\t\tif (reasons.length > 0) {\n\t\t\t\t\tthrow new StartRefusedError(\n\t\t\t\t\t\t`the Import Profile ${p.ref.name} is invalid: ${reasons.map((r) => r.message).join(\" \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst mappings = p.content.mappingIds.map(\n\t\t\t\t\t(id) => pinned(find(w.mappings, id, \"Mapping\"), \"Mapping\").ref,\n\t\t\t\t);\n\t\t\t\tconst entitySet = p.content.entitySetId\n\t\t\t\t\t? pinned(find(w.entitySets, p.content.entitySetId, \"Entity Set\"), \"Entity Set\").ref\n\t\t\t\t\t: undefined;\n\t\t\t\tconst im: StubImport = {\n\t\t\t\t\tid: newId(\"im\"),\n\t\t\t\t\timportProfileId: profile.id,\n\t\t\t\t\timportProfileName: p.ref.name,\n\t\t\t\t\tsourceFileId: input.sourceFileId,\n\t\t\t\t\tstartedBy: STUB_USER_ID,\n\t\t\t\t\tphase: \"queued\",\n\t\t\t\t\tfailureReason: \"\",\n\t\t\t\t\tprogress: { done: 0, total: 0 },\n\t\t\t\t\tcounts: {\n\t\t\t\t\t\tmatched: 0,\n\t\t\t\t\t\tcreated: 0,\n\t\t\t\t\t\tproblems: 0,\n\t\t\t\t\t\tplanned: 0,\n\t\t\t\t\t\tcorrected: 0,\n\t\t\t\t\t\tkept: 0,\n\t\t\t\t\t\tunchanged: 0,\n\t\t\t\t\t},\n\t\t\t\t\tchangeSetId: \"\",\n\t\t\t\t\treleases: {\n\t\t\t\t\t\timportProfile: p.ref,\n\t\t\t\t\t\tmappings,\n\t\t\t\t\t\t...(entitySet ? { entitySet } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tcreateTime: tick(),\n\t\t\t\t\tstartTime: \"\",\n\t\t\t\t\tendTime: \"\",\n\t\t\t\t\tcancelledBy: \"\",\n\t\t\t\t\teffectiveDate: input.effectiveDate ?? \"\",\n\t\t\t\t\t...(input.source ? { source: input.source } : {}),\n\t\t\t\t\titemProblems: [],\n\t\t\t\t};\n\t\t\t\tw.imports.unshift(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tlistImports: (pageToken) =>\n\t\t\tanswer(\"listImports\", () => {\n\t\t\t\t// Pages of fifty, newest first; the token is the next page's offset.\n\t\t\t\tconst all = ws().imports;\n\t\t\t\tall.forEach(settle);\n\t\t\t\tconst from = Number(pageToken || \"0\");\n\t\t\t\treturn {\n\t\t\t\t\timports: all.slice(from, from + 50).map(importOf),\n\t\t\t\t\tnextPageToken: from + 50 < all.length ? String(from + 50) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\t\tgetImport: (id) =>\n\t\t\tanswer(\"getImport\", () => {\n\t\t\t\tconst im = findImport(id);\n\t\t\t\tsettle(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tcancelImport: (id) =>\n\t\t\tanswer(\"cancelImport\", () => {\n\t\t\t\tconst im = findImport(id);\n\t\t\t\tif (im.phase === \"ended\") throw new Error(\"the Import has ended\");\n\t\t\t\tim.cancelledBy ||= STUB_USER_ID;\n\t\t\t\t// A queued Import ends at once; a running one at its next item.\n\t\t\t\tif (im.phase === \"queued\") settle(im);\n\t\t\t\treturn importOf(im);\n\t\t\t}),\n\t\tlistItemProblems: (importId, filter) =>\n\t\t\tanswer(\"listItemProblems\", () => {\n\t\t\t\tconst all = findImport(importId).itemProblems ?? [];\n\t\t\t\tconst query = filter.sourceKeyQuery.toLowerCase();\n\t\t\t\tconst matching = all.filter(\n\t\t\t\t\t(p) =>\n\t\t\t\t\t\t(!filter.mappingId || p.mappingId === filter.mappingId) &&\n\t\t\t\t\t\tp.sourceKey.toLowerCase().includes(query),\n\t\t\t\t);\n\t\t\t\tconst counts = new Map<string, { mappingId: string; mappingName: string; count: number }>();\n\t\t\t\tfor (const p of all) {\n\t\t\t\t\tconst c = counts.get(p.mappingId) ?? {\n\t\t\t\t\t\tmappingId: p.mappingId,\n\t\t\t\t\t\tmappingName: p.mappingName,\n\t\t\t\t\t\tcount: 0,\n\t\t\t\t\t};\n\t\t\t\t\tc.count++;\n\t\t\t\t\tcounts.set(p.mappingId, c);\n\t\t\t\t}\n\t\t\t\tconst from = Number(filter.pageToken || \"0\");\n\t\t\t\treturn {\n\t\t\t\t\titemProblems: matching.slice(from, from + 50),\n\t\t\t\t\ttotalCount: all.length,\n\t\t\t\t\tmatchingCount: matching.length,\n\t\t\t\t\tmappings: [...counts.values()].sort((a, b) => a.mappingName.localeCompare(b.mappingName)),\n\t\t\t\t\tnextPageToken: from + 50 < matching.length ? String(from + 50) : \"\",\n\t\t\t\t};\n\t\t\t}),\n\n\t\tlistApiKeys: () => answer(\"listApiKeys\", () => ws().apiKeys),\n\t\tcreateApiKey: (input) =>\n\t\t\tanswer(\"createApiKey\", () => {\n\t\t\t\t// CreateAPIKey's rules: a name, not too long, and an expiry ahead.\n\t\t\t\tconst name = input.name.trim();\n\t\t\t\tif (!name) throw new Error(\"a name is required\");\n\t\t\t\tif (name.length > API_KEY_NAME_MAX) {\n\t\t\t\t\tthrow new Error(`the name is longer than ${API_KEY_NAME_MAX} characters`);\n\t\t\t\t}\n\t\t\t\tconst expireTime = input.expireTime ? new Date(input.expireTime).toISOString() : \"\";\n\t\t\t\tif (expireTime && Date.parse(expireTime) <= Date.now()) {\n\t\t\t\t\tthrow new Error(\"the expiry must lie in the future\");\n\t\t\t\t}\n\t\t\t\tconst n = ++created;\n\t\t\t\tconst apiKey: ApiKey = {\n\t\t\t\t\tid: `key_stub_new_${n}`,\n\t\t\t\t\tname,\n\t\t\t\t\tkeyPrefix: `ihk_n${String(n).padStart(3, \"0\")}`,\n\t\t\t\t\towner: STUB_USER_ID,\n\t\t\t\t\texpireTime,\n\t\t\t\t\tcreateTime: new Date().toISOString(),\n\t\t\t\t};\n\t\t\t\tws().apiKeys.unshift(apiKey);\n\t\t\t\t// The secret is returned here and kept nowhere, as importhub keeps it.\n\t\t\t\treturn { apiKey, secret: `${apiKey.keyPrefix}_stub_secret_${n}` };\n\t\t\t}),\n\t\trevokeApiKey: (id) =>\n\t\t\tanswer(\"revokeApiKey\", () => {\n\t\t\t\tconst w = ws();\n\t\t\t\tif (!w.apiKeys.some((k) => k.id === id)) throw new Error(`API key ${id} not found`);\n\t\t\t\tw.apiKeys = w.apiKeys.filter((k) => k.id !== id);\n\t\t\t}),\n\t};\n}\n\n/**\n * Whether an XPath's brackets and parentheses pair up: the stub's stand-in\n * for importhub's XPath check, enough to show a reason at its field.\n */\nfunction balanced(expr: string): boolean {\n\tconst open: string[] = [];\n\tconst pairs: Record<string, string> = { \"]\": \"[\", \")\": \"(\" };\n\tfor (const ch of expr) {\n\t\tif (ch === \"[\" || ch === \"(\") open.push(ch);\n\t\telse if (ch in pairs && open.pop() !== pairs[ch]) return false;\n\t}\n\treturn open.length === 0;\n}\n\n/** A field mapping and its children, each with its field path and pointer. */\nfunction walk(\n\tmapping: Record<string, unknown>,\n\tprefix: string,\n\tat: string,\n): { path: string; rel: string; mapping: Record<string, unknown> }[] {\n\tconst path = `${prefix}${String(mapping.name ?? \"\")}`;\n\treturn [\n\t\t{ path, rel: at, mapping },\n\t\t...([\"fields\", \"virtualTableFields\"] as const).flatMap((key) =>\n\t\t\t(Array.isArray(mapping[key]) ? (mapping[key] as Record<string, unknown>[]) : []).flatMap(\n\t\t\t\t(child, j) => walk(child, `${path}.`, `${at}/${key}/${j}`),\n\t\t\t),\n\t\t),\n\t];\n}\n\n/**\n * An `ImporthubBlueprints` over the stub's Blueprint Releases, for a host's\n * `ImporthubHost.blueprints` in tests.\n */\nexport function createStubBlueprints(\n\tblueprintReleases: StubBlueprintRelease[] = stubBlueprintReleases(),\n): ImporthubBlueprints {\n\treturn {\n\t\tasync listBlueprints() {\n\t\t\tconst byId = new Map(blueprintReleases.map((r) => [r.blueprintId, r.blueprintName]));\n\t\t\treturn [...byId]\n\t\t\t\t.map(([id, name]) => ({ id, name }))\n\t\t\t\t.sort((a, b) => a.name.localeCompare(b.name));\n\t\t},\n\t\tasync listReleases(blueprintId) {\n\t\t\treturn blueprintReleases\n\t\t\t\t.filter((r) => r.blueprintId === blueprintId)\n\t\t\t\t.map((r) => ({ id: r.id, label: r.label }));\n\t\t},\n\t\tasync getRelease(releaseId) {\n\t\t\tconst r = blueprintReleases.find((x) => x.id === releaseId);\n\t\t\tif (!r) throw new Error(`Blueprint Release ${releaseId} not found`);\n\t\t\treturn {\n\t\t\t\tid: r.id,\n\t\t\t\tblueprintId: r.blueprintId,\n\t\t\t\tname: r.label,\n\t\t\t\tfields:\n\t\t\t\t\tr.fields ??\n\t\t\t\t\tr.fieldPaths.map((path) => ({\n\t\t\t\t\t\taccessor: path,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tfieldType: \"text\",\n\t\t\t\t\t\tlabel: \"\",\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t})),\n\t\t\t\treleaseSpecFields: r.releaseSpecFields ?? [],\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * The display name's reasons, as importhub's checkDisplayName gives them\n * (internal/configstore/mapping.go): template and field set together, the\n * field a plain-text one of the pinned Release that no field mapping writes.\n */\nfunction displayNameReasons(\n\tc: MappingContent,\n\ttree: ImporthubBlueprintField[] | undefined,\n\tmapped: string[],\n): ValidityReason[] {\n\tconst template = (c.displayNameTemplate ?? \"\").trim();\n\tconst field = (c.displayNameField ?? \"\").trim();\n\tconst reason = (path: string, code: string, message: string): ValidityReason[] => [\n\t\t{ path, code, message },\n\t];\n\tif (!template && !field) return [];\n\tif (!field) {\n\t\treturn reason(\n\t\t\t\"/display_name_field\",\n\t\t\t\"incomplete_display_name\",\n\t\t\t\"the display-name template names no field to write the display name into\",\n\t\t);\n\t}\n\tif (!template) {\n\t\treturn reason(\n\t\t\t\"/display_name_template\",\n\t\t\t\"incomplete_display_name\",\n\t\t\t`the display-name field \"${field}\" has no display-name template to fill it`,\n\t\t);\n\t}\n\tif (!tree) return [];\n\tconst paths = (fs: ImporthubBlueprintField[]): string[] =>\n\t\tfs.flatMap((f) => [f.path, ...paths(f.children)]);\n\tif (!paths(tree).includes(field)) {\n\t\treturn reason(\n\t\t\t\"/display_name_field\",\n\t\t\t\"unknown_display_name_field\",\n\t\t\t`the Blueprint Release has no field \"${field}\" to write the display name into`,\n\t\t);\n\t}\n\tif (!plainTextFields(tree).some((f) => f.path === field)) {\n\t\treturn reason(\n\t\t\t\"/display_name_field\",\n\t\t\t\"display_name_field_not_plain_text\",\n\t\t\t`the display-name field \"${field}\" is not a plain-text one (text or textarea)`,\n\t\t);\n\t}\n\tif (mapped.includes(field)) {\n\t\treturn reason(\n\t\t\t\"/display_name_field\",\n\t\t\t\"display_name_field_mapped\",\n\t\t\t`the field \"${field}\" is mapped too: it takes the display name or a mapped value, not both`,\n\t\t);\n\t}\n\treturn [];\n}\n"],"names":["STUB_USER_ID","STUB_OTHER_USER_ID","STUB_WORKSPACE_ID","STUB_OTHER_WORKSPACE_ID","stubIdentity","workspaceId","createHostMembers","field","path","fieldType","label","children","pathsOf","tree","f","gesetzFields","withFootnote","gesetzReleaseSpec","stubBlueprintReleases","gesetz2","gesetz1","entscheidung","stubMappings","stubMappingTestSample","stubEntitySets","stubImportProfiles","text","accessor","name","required","instructions","stubProcessors","counts","c","gesetzReleases","profileRelease","stubImport","i","problem","mapping","sourceKey","reason","stubImports","stubApiKeys","XML_ENTITIES","withEntities","sample","entities","whole","runStubMappingTest","content","doc","parseError","MappingTestRefusedError","selector","nodes","r","_","keySelector","node","problems","stringAt","values","mapFields","xpath","context","fields","prefix","out","inner","value","METHODS","clock","tick","seed","items","count","revisions","n","releases","draftOf","s","latestReleaseOf","stateOf","latest","released","snake","key","protoKeyed","k","v","validity","reasons","byName","b","created","createStubImporthubClient","options","workspaces","id","w","processors","active","calls","m","ws","answer","method","run","find","kind","item","nameFree","NameTakenError","moved","draftRevisionId","save","restoredFromRevisionId","stored","newId","mappingReasons","release","expr","balanced","mapped","at","rel","walk","tc","pa","j","displayNameReasons","stepReasons","steps","list","p","x","profileReasons","e","entitySetReasons","profileOf","mappingOf","entitySetOf","profilesUsing","uses","ofKind","decide","revisionIn","revisionId","sourceFiles","rights","findImport","im","settle","importOf","pinned","StartRefusedError","patch","a","using","ConfigurationInUseError","blueprintReleaseId","all","entitySetId","es","ReleaseRefusedError","now","number","pageToken","newest","from","fromRevisionId","toRevisionId","to","status","file","onProgress","input","profile","mappings","entitySet","importId","filter","query","matching","API_KEY_NAME_MAX","expireTime","apiKey","open","pairs","ch","child","createStubBlueprints","blueprintReleases","blueprintId","releaseId","template","code","message","paths","fs","plainTextFields"],"mappings":";;;AAcO,MAAMA,IAAe,iBAEfC,IAAqB,mBAErBC,KAAoB,gBAEpBC,KAA0B;AAMhC,SAASC,GAAaC,IAAsBH,IAAiC;AACnF,SAAO;AAAA,IACN,QAAQF;AAAA,IACR,aAAAK;AAAA,IACA,SAASC,GAAkB;AAAA,MAC1B,EAAE,QAAQN,GAAc,aAAa,gBAAgB,OAAO,kBAAA;AAAA,MAC5D,EAAE,QAAQC,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lC,CAAK;AAAA,IAAA;AAGlC,MAAI,CAACM,EAAM,QAAO,CAAA;AAClB,QAAM0L,IAAQ,CAACC,MACdA,EAAG,QAAQ,CAAC1L,MAAM,CAACA,EAAE,MAAM,GAAGyL,EAAMzL,EAAE,QAAQ,CAAC,CAAC;AACjD,SAAKyL,EAAM1L,CAAI,EAAE,SAASN,CAAK,IAO1BkM,GAAgB5L,CAAI,EAAE,KAAK,CAACC,MAAMA,EAAE,SAASP,CAAK,IAOnDqH,EAAO,SAASrH,CAAK,IACjBkC;AAAA,IACN;AAAA,IACA;AAAA,IACA,cAAclC,CAAK;AAAA,EAAA,IAGd,CAAA,IAbCkC;AAAA,IACN;AAAA,IACA;AAAA,IACA,2BAA2BlC,CAAK;AAAA,EAAA,IAV1BkC;AAAA,IACN;AAAA,IACA;AAAA,IACA,uCAAuClC,CAAK;AAAA,EAAA;AAkB/C;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knkcs/importhub-ui",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "importhub's screens for knk hosts: Imports, Import Profiles, Mappings and Entity Sets",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- {"version":3,"file":"importhub-client-BS6F4DW2.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// release and history (F3, release-a-configuration) cut Releases, list,\n// compare and restore Revisions, alike for every kind of configuration.\n// Imports (F6, start-an-import, follow-an-import) upload a Source File,\n// start, list, read and cancel Imports, and list their Item Problems. API\n// keys (F9, import-with-an-api-key) are created, listed and revoked.\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, enums by their names\n * (`CHANGED_VERSION_HANDLING_KEEP`), unset settings left out. The settings are\n * typed as the structured editor (F4) edits them; every key travels through\n * as given, typed or not, so a save never drops one a screen does not show.\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\textractPattern?: string;\n\t\t/** `-` when unset; \"\" joins the groups with nothing. */\n\t\textractSeparator?: string;\n\t\tnormalize?: boolean;\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\tversionMatch?: {\n\t\tvalidityPeriod?: boolean;\n\t\treleaseSpecFields?: string[];\n\t\tcontentFields?: string[];\n\t};\n\tvalidityPeriod?: {\n\t\tvalidFromSelector?: string;\n\t\tvalidToSelector?: string;\n\t\tdateFormats?: string[];\n\t};\n\treleaseSpec?: Array<{ field?: string; selector?: string }>;\n\t/** Unset: Correct. */\n\tchangedVersion?: ChangedVersionHandling;\n\tstub?: boolean;\n\ttitleContributions?: Array<{\n\t\tselector?: string;\n\t\tausgabeCodeSelector?: string;\n\t\treferenceSpecValues?: Array<{ field?: string; selector?: string }>;\n\t\treferenceFilterSelector?: string;\n\t\tintent?: TitleIntent;\n\t\tintentTextSelector?: string;\n\t}>;\n\tcollectionRouting?: {\n\t\tselector?: string;\n\t\tcollectionMap?: Record<string, string>;\n\t\tidPattern?: string;\n\t\tcollectionTemplate?: string;\n\t\tsuffix?: string;\n\t\tfallback?: string;\n\t};\n\tcollections?: string[];\n\tdisplayNameTemplate?: string;\n\tplaceholderAssets?: Array<{\n\t\tselector?: string;\n\t\tassetType?: string;\n\t\tkeyParts?: string[];\n\t\tnameSelector?: string;\n\t\tdescriptionSelector?: string;\n\t\tmetadata?: Record<string, string>;\n\t\tfolderRoot?: string;\n\t\tfolderPathSelector?: string;\n\t}>;\n\t[key: string]: unknown;\n}\n\n/** What happens to a Changed Version (importhub.v1.ChangedVersionHandling). */\nexport type ChangedVersionHandling =\n\t| \"CHANGED_VERSION_HANDLING_UNSPECIFIED\"\n\t| \"CHANGED_VERSION_HANDLING_CORRECT\"\n\t| \"CHANGED_VERSION_HANDLING_KEEP\"\n\t| \"CHANGED_VERSION_HANDLING_FAIL\";\n\n/** The intent a Title Contribution writes (importhub.v1.TitleIntent). */\nexport type TitleIntent =\n\t| \"TITLE_INTENT_UNSPECIFIED\"\n\t| \"TITLE_INTENT_EXCLUDE\"\n\t| \"TITLE_INTENT_REPLACE\"\n\t| \"TITLE_INTENT_ANNOTATE\";\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/**\n * A cut importhub refused (release-a-configuration:AC3): the draft is\n * invalid now, it does not differ from the latest Release, or somebody saved\n * in between. Carries the draft's validity when that was the reason, so the\n * screen lists why.\n */\nexport class ReleaseRefusedError extends Error {\n\treadonly validity?: Validity;\n\tconstructor(message: string, validity?: Validity) {\n\t\tsuper(message);\n\t\tthis.name = \"ReleaseRefusedError\";\n\t\tthis.validity = validity;\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/** The kinds of versioned configuration (ADR 0016). */\nexport type ConfigurationKind = \"importProfile\" | \"mapping\" | \"entitySet\";\n\n/** One saved Revision of a configuration, as its history lists it. */\nexport interface ConfigurationRevision {\n\tid: string;\n\t/** The odon user id of who saved it; the host's members name them. */\n\tsavedBy: string;\n\t/** When it was saved, as an ISO 8601 timestamp. */\n\tsavedAt: string;\n\t/** Whether it could be released, as decided when it was saved. */\n\tvalidity: Validity;\n\t/** The Revision it restored; \"\" for an ordinary save. */\n\trestoredFromRevisionId: string;\n}\n\n/** A Configuration Release as the history lists it: who cut it, when, from what. */\nexport interface ConfigurationReleaseRecord extends ConfigurationRelease {\n\t/** The Revision it pins. */\n\trevisionId: string;\n\t/** The odon user id of the admin who cut it. */\n\treleasedBy: string;\n\t/** When it was cut, as an ISO 8601 timestamp. */\n\treleasedAt: string;\n}\n\n/** One page of a configuration's history. */\nexport interface ConfigurationHistoryPage {\n\t/** This page's Revisions, newest first. */\n\trevisions: ConfigurationRevision[];\n\t/** Every Release, newest first, on every page. */\n\treleases: ConfigurationReleaseRecord[];\n\t/** The token of the next page; \"\" on the last. */\n\tnextPageToken: string;\n}\n\n/**\n * One side of a comparison: a Revision's content, keyed as importhub keys\n * the compared fields (the proto's field names, such as `mapping_ids`).\n */\nexport interface ConfigurationVersion {\n\trevisionId: string;\n\tcontent: Record<string, unknown>;\n}\n\nexport type FieldComparisonStatus = \"unchanged\" | \"added\" | \"removed\" | \"changed\";\n\n/** Two Revisions of one configuration, and how each top-level field differs. */\nexport interface ConfigurationComparison {\n\tfrom: ConfigurationVersion;\n\tto: ConfigurationVersion;\n\tfields: { field: string; status: FieldComparisonStatus }[];\n}\n\n/** A Release cut, and for a Mapping the Import Profiles that take it. */\nexport interface CutReleaseResult {\n\trelease: ConfigurationReleaseRecord;\n\t/** The Profiles that include the Mapping; empty for other kinds. */\n\timportProfiles: ImportProfileRef[];\n}\n\n/** Where an Import is (importhub.v1.ImportPhase). */\nexport type ImportPhase = \"queued\" | \"reading\" | \"writing\" | \"ended\";\n\n/** How an Import ended (importhub.v1.ImportOutcome, CONTEXT.md \"Import Outcome\"). */\nexport type ImportOutcome = \"succeeded\" | \"succeeded_with_problems\" | \"failed\" | \"cancelled\";\n\n/** The publication that triggered an Import: such as 2026-09-20, \"BGBl. 2026 I Nr. 270\". */\nexport interface ImportSource {\n\t/** The day it was published, as YYYY-MM-DD. */\n\tdate: string;\n\t/** How it is cited. */\n\treference: string;\n}\n\n/** One Configuration Release an Import runs with, named as it was then. */\nexport interface ImportReleaseRef {\n\tconfigurationId: string;\n\t/** The configuration's name in that Release. */\n\tname: string;\n\treleaseId: string;\n\t/** \"Release 3\". */\n\tnumber: number;\n}\n\n/** What an Import has done (importhub.v1.ImportCounts). */\nexport interface ImportCounts {\n\t/** Source Versions its Mappings matched. */\n\tmatched: number;\n\t/** Content it created. */\n\tcreated: number;\n\t/** Item Problems: Source Versions it skipped. */\n\tproblems: number;\n\t/** New Planned Releases of Content that exists. */\n\tplanned: number;\n\t/** Changed Versions planned as corrections. */\n\tcorrected: number;\n\t/** Changed Versions kept. */\n\tkept: number;\n\t/** Source Versions already in contenthub. */\n\tunchanged: number;\n}\n\n/** One run of an Import Profile's Release over one Source File. */\nexport interface Import {\n\tid: string;\n\timportProfileId: string;\n\t/** The Profile's name when the Import started. */\n\timportProfileName: string;\n\tsourceFileId: string;\n\t/** The odon user id of who started it; the host's members name them. */\n\tstartedBy: string;\n\tphase: ImportPhase;\n\t/** Unset until it has ended. */\n\toutcome?: ImportOutcome;\n\t/** Why it Failed, as importhub words it; \"\" otherwise. */\n\tfailureReason: string;\n\t/** How far the current phase is: done of total, both 0 while unknown. */\n\tprogress: { done: number; total: number };\n\tcounts: ImportCounts;\n\t/** The contenthub Change Set it fills; \"\" until it opened one. */\n\tchangeSetId: string;\n\t/** The exact Releases it runs with, pinned at Start (release-a-configuration:AC8). */\n\treleases: {\n\t\timportProfile?: ImportReleaseRef;\n\t\t/** In the Profile's order. */\n\t\tmappings: ImportReleaseRef[];\n\t\t/** Unset when the Profile names no Entity Set. */\n\t\tentitySet?: ImportReleaseRef;\n\t};\n\t/** ISO 8601 timestamps; start and end \"\" until they happen. */\n\tcreateTime: string;\n\tstartTime: string;\n\tendTime: string;\n\t/** The odon user id of who cancelled it, as soon as they asked; \"\" for nobody. */\n\tcancelledBy: string;\n\t/** YYYY-MM-DD, or \"\" for none. */\n\teffectiveDate: string;\n\tsource?: ImportSource;\n}\n\n/** One page of the workspace's Imports, newest first. */\nexport interface ImportsPage {\n\timports: Import[];\n\t/** \"\" on the last page. */\n\tnextPageToken: string;\n}\n\n/** A Source File uploaded and ready to be imported. */\nexport interface SourceFile {\n\tid: string;\n\tfileName: string;\n}\n\n/** What starting an Import takes. */\nexport interface StartImportInput {\n\timportProfileId: string;\n\tsourceFileId: string;\n\t/** YYYY-MM-DD; \"\" or unset for none. */\n\teffectiveDate?: string;\n\t/** Both or neither. */\n\tsource?: ImportSource;\n}\n\n/** One Source Version an Import could not save and skipped (CONTEXT.md \"Item Problem\"). */\nexport interface ItemProblem {\n\tid: string;\n\tmappingId: string;\n\t/** The Mapping's name in the Release the Import ran. */\n\tmappingName: string;\n\t/** \"\" when the element has none. */\n\tsourceKey: string;\n\t/** A /-separated path in the Content's data; \"\" for the Source Version as a whole. */\n\tfield: string;\n\t/** Why, as importhub words it. */\n\treason: string;\n}\n\n/** How an Import's Item Problems are filtered: by Mapping, and by Source Key. */\nexport interface ItemProblemsFilter {\n\t/** \"\" for every Mapping. */\n\tmappingId: string;\n\t/** Matches Source Keys that contain it, ignoring case; \"\" for all. */\n\tsourceKeyQuery: string;\n\t/** \"\" for the first page. */\n\tpageToken: string;\n}\n\n/** One page of an Import's Item Problems, with their counts. */\nexport interface ItemProblemsPage {\n\titemProblems: ItemProblem[];\n\t/** Every Item Problem of the Import, whatever the filter. */\n\ttotalCount: number;\n\t/** The Item Problems the filter matches, on every page. */\n\tmatchingCount: number;\n\t/** Every Mapping with Item Problems and how many, whatever the filter. */\n\tmappings: { mappingId: string; mappingName: string; count: number }[];\n\t/** \"\" on the last page. */\n\tnextPageToken: string;\n}\n\n/**\n * A Start importhub refused (start-an-import:AC4, release-a-configuration:AC5):\n * the starter lacks contenthub `editor`, or `publisher` for an Auto-publish\n * Profile, or what the Import would run has no Release or is invalid now. Its\n * message is importhub's, which names what stands in the way.\n */\nexport class StartRefusedError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"StartRefusedError\";\n\t}\n}\n\n/**\n * An importhub API key of the workspace (importhub.v1.APIKey): an odon API\n * key with scope `importhub:workspace:<W>`, which importhub created with a\n * standing Delegation Grant that ends with it (ADR 0006, amended). Never its\n * secret.\n */\nexport interface ApiKey {\n\tid: string;\n\t/** What it is for, as people read it: \"Nightly gesetz feed\". */\n\tname: string;\n\t/** The secret's first characters, for telling keys apart. */\n\tkeyPrefix: string;\n\t/** The odon user id of who created it, as whom it acts; the host's members name them. */\n\towner: string;\n\t/** When it stops working, as an ISO 8601 timestamp; \"\" for never. */\n\texpireTime: string;\n\t/** When it was created, as an ISO 8601 timestamp. */\n\tcreateTime: string;\n}\n\n/** The longest name CreateAPIKey takes. */\nexport const API_KEY_NAME_MAX = 100;\n\n/** What creating an API key takes. */\nexport interface CreateApiKeyInput {\n\t/** Not blank, at most API_KEY_NAME_MAX characters. */\n\tname: string;\n\t/** When it stops working, as an ISO 8601 timestamp in the future; \"\" or unset for never. */\n\texpireTime?: string;\n}\n\n/** A key just created, with its secret: the one time importhub returns it. */\nexport interface CreatedApiKey {\n\tapiKey: ApiKey;\n\t/** To send as `Authorization: Bearer <secret>`; no later call returns it. */\n\tsecret: string;\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\t/**\n\t * Cuts a Configuration Release from the draft named. Throws\n\t * ReleaseRefusedError, with the reasons when the draft is invalid.\n\t */\n\tcutRelease(\n\t\tkind: ConfigurationKind,\n\t\tid: string,\n\t\tdraftRevisionId: string,\n\t): Promise<CutReleaseResult>;\n\t/** One page of the history; pageToken \"\" for the first. */\n\tlistHistory(\n\t\tkind: ConfigurationKind,\n\t\tid: string,\n\t\tpageToken: string,\n\t): Promise<ConfigurationHistoryPage>;\n\tcompareRevisions(\n\t\tkind: ConfigurationKind,\n\t\tid: string,\n\t\tfromRevisionId: string,\n\t\ttoRevisionId: string,\n\t): Promise<ConfigurationComparison>;\n\t/** Saves an older Revision's content as a new draft, on the draft named. */\n\trestoreRevision(\n\t\tkind: ConfigurationKind,\n\t\tid: string,\n\t\trevisionId: string,\n\t\tdraftRevisionId: string,\n\t): Promise<void>;\n\n\t/**\n\t * Uploads one file as a Source File: importhub hands out a direct upload\n\t * URL into its blob store, and the file goes there, not through importhub\n\t * (start-an-import:AC1). `onProgress` hears the share sent, 0 to 1.\n\t */\n\tuploadSourceFile(file: File, onProgress: (fraction: number) => void): Promise<SourceFile>;\n\t/** Queues an Import. Throws StartRefusedError, with importhub's reason. */\n\tstartImport(input: StartImportInput): Promise<Import>;\n\t/** One page of the workspace's Imports, newest first; pageToken \"\" for the first. */\n\tlistImports(pageToken: string): Promise<ImportsPage>;\n\tgetImport(id: string): Promise<Import>;\n\t/** Asks a queued or running Import to stop; returns it as it is now. */\n\tcancelImport(id: string): Promise<Import>;\n\tlistItemProblems(importId: string, filter: ItemProblemsFilter): Promise<ItemProblemsPage>;\n\n\t/**\n\t * Every API key of the workspace, every importer's, newest first, without\n\t * their secrets. Needs importhub's `importer`, as all three key calls do.\n\t */\n\tlistApiKeys(): Promise<ApiKey[]>;\n\t/**\n\t * Creates an API key acting as the caller, with its Delegation Grant, and\n\t * returns its secret this once (import-with-an-api-key:AC5).\n\t */\n\tcreateApiKey(input: CreateApiKeyInput): Promise<CreatedApiKey>;\n\t/**\n\t * Revokes an API key in odon and releases its Grant: it stops working at\n\t * once (import-with-an-api-key:AC7).\n\t */\n\trevokeApiKey(id: string): Promise<void>;\n}\n"],"names":["ConfigurationInUseError","importProfiles","message","ReleaseRefusedError","validity","NameTakenError","StartRefusedError","API_KEY_NAME_MAX"],"mappings":"AA2NO,MAAMA,UAAgC,MAAM;AAAA,EACzC;AAAA,EACT,YAAYC,GAAoCC,IAAU,6BAA6B;AACtF,UAAMA,CAAO,GACb,KAAK,OAAO,2BACZ,KAAK,iBAAiBD;AAAA,EACvB;AACD;AAQO,MAAME,UAA4B,MAAM;AAAA,EACrC;AAAA,EACT,YAAYD,GAAiBE,GAAqB;AACjD,UAAMF,CAAO,GACb,KAAK,OAAO,uBACZ,KAAK,WAAWE;AAAA,EACjB;AACD;AAGO,MAAMC,UAAuB,MAAM;AAAA,EACzC,YAAYH,IAAU,qBAAqB;AAC1C,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACb;AACD;AAiNO,MAAMI,UAA0B,MAAM;AAAA,EAC5C,YAAYJ,GAAiB;AAC5B,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACb;AACD;AAuBO,MAAMK,IAAmB;"}