@knkcs/importhub-ui 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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\tEntitySetContent,\n\tImportProfileContent,\n\tMappingContent,\n\tProcessor,\n} from \"../client/importhub-client\";\n\n/** The stub viewer's id. */\nexport const STUB_USER_ID = \"user_stub_ada\";\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]),\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\tfieldPaths: string[];\n}\n\n/**\n * Two Releases of the \"Gesetz\" Blueprint, the newer of which dropped\n * `fussnote`, and one of \"Entscheidung\".\n */\nexport function stubBlueprintReleases(): StubBlueprintRelease[] {\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: [\"titel\", \"abkuerzung\"],\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: [\"titel\", \"abkuerzung\", \"fussnote\"],\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: [\"aktenzeichen\", \"datum\"],\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","// 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\tConfigurationState,\n\tEntitySet,\n\tEntitySetContent,\n\tImporthubClient,\n\tImportProfile,\n\tImportProfileContent,\n\tMapping,\n\tMappingContent,\n\tProcessor,\n\tProcessorStep,\n\tValidity,\n\tValidityReason,\n} from \"../client/importhub-client\";\nimport { ConfigurationInUseError, NameTakenError } from \"../client/importhub-client\";\nimport type { ImporthubBlueprints } from \"../common/host\";\nimport {\n\tSTUB_WORKSPACE_ID,\n\ttype StubBlueprintRelease,\n\ttype StubConfiguration,\n\tstubBlueprintReleases,\n\tstubEntitySets,\n\tstubImportProfiles,\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}\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/** 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/** How many calls each method has answered, for tests that count reloads. */\n\treadonly calls: Readonly<Record<keyof ImporthubClient, number>>;\n}\n\n/** One stored configuration: its draft, and how many saves it has had. */\ninterface Stored<C> {\n\tid: string;\n\tcontent: C;\n\trevision: number;\n\treleaseNumber?: number;\n\t/** The revision the latest Release was cut from. */\n\treleasedRevision?: number;\n}\n\ninterface Workspace {\n\timportProfiles: Stored<ImportProfileContent>[];\n\tmappings: Stored<MappingContent>[];\n\tentitySets: Stored<EntitySetContent>[];\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];\n\nconst seed = <C>(items: StubConfiguration<C>[] = []): Stored<C>[] =>\n\titems.map((i) => ({\n\t\tid: i.id,\n\t\tcontent: structuredClone(i.content),\n\t\trevision: 1,\n\t\treleaseNumber: i.releaseNumber,\n\t\treleasedRevision: i.releaseNumber ? 1 : undefined,\n\t}));\n\nconst stateOf = <C>(s: Stored<C>): ConfigurationState => ({\n\tdraftRevisionId: `${s.id}_r${s.revision}`,\n\tdraftDiffersFromRelease: s.releasedRevision !== s.revision,\n\t...(s.releaseNumber\n\t\t? { latestRelease: { id: `${s.id}_rel${s.releaseNumber}`, number: s.releaseNumber } }\n\t\t: {}),\n});\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},\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},\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] ??= { importProfiles: [], mappings: [], entitySets: [] };\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 save = <C>(item: Stored<C>, content: C, draftRevisionId: string) => {\n\t\tif (draftRevisionId && draftRevisionId !== stateOf(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.revision++;\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\t(c.fields ?? []).forEach((f, i) => {\n\t\t\tconst path = String(f.name ?? \"\");\n\t\t\tif (release && !release.fieldPaths.includes(path)) {\n\t\t\t\tout.push({\n\t\t\t\t\tpath: `/fields/${i}`,\n\t\t\t\t\tcode: \"unknown_field_path\",\n\t\t\t\t\tmessage: `The pinned Release has no field ${path}.`,\n\t\t\t\t});\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\treturn {\n\t\tcalls,\n\t\tswitchWorkspace(workspaceId) {\n\t\t\tactive = workspaceId;\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<ImportProfileContent> = {\n\t\t\t\t\tid: newId(\"ip\"),\n\t\t\t\t\tcontent: structuredClone(content),\n\t\t\t\t\trevision: 1,\n\t\t\t\t};\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\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<MappingContent> = {\n\t\t\t\t\tid: newId(\"mp\"),\n\t\t\t\t\tcontent: structuredClone(content),\n\t\t\t\t\trevision: 1,\n\t\t\t\t};\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\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.map((f) => String(f.name ?? \"\"))\n\t\t\t\t\t\t.filter((path) => !release.fieldPaths.includes(path)),\n\t\t\t\t\tmissingReleaseSpecFields: [],\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<EntitySetContent> = {\n\t\t\t\t\tid: newId(\"es\"),\n\t\t\t\t\tcontent: structuredClone(content),\n\t\t\t\t\trevision: 1,\n\t\t\t\t};\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\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\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};\n}\n"],"names":["STUB_USER_ID","STUB_WORKSPACE_ID","STUB_OTHER_WORKSPACE_ID","stubIdentity","workspaceId","createHostMembers","stubBlueprintReleases","stubMappings","stubEntitySets","stubImportProfiles","text","accessor","name","required","instructions","stubProcessors","METHODS","seed","items","i","stateOf","s","validity","reasons","byName","a","b","created","createStubImporthubClient","options","workspaces","id","w","processors","releases","active","calls","m","ws","answer","method","run","find","kind","item","nameFree","NameTakenError","save","content","draftRevisionId","mappingReasons","c","out","release","r","f","path","stepReasons","steps","list","p","x","profileReasons","e","entitySetReasons","profileOf","mappingOf","entitySetOf","profilesUsing","uses","newId","prefix","using","ConfigurationInUseError","blueprintReleaseId","createStubBlueprints","blueprintReleases","blueprintId"],"mappings":";;AASO,MAAMA,IAAe,iBAEfC,IAAoB,gBAEpBC,IAA0B;AAMhC,SAASC,EAAaC,IAAsBH,GAAiC;AACnF,SAAO;AAAA,IACN,QAAQD;AAAA,IACR,aAAAI;AAAA,IACA,SAASC,EAAkB;AAAA,MAC1B,EAAE,QAAQL,GAAc,aAAa,gBAAgB,OAAO,kBAAA;AAAA,IAAkB,CAC9E;AAAA,EAAA;AAEH;AAuBO,SAASM,IAAgD;AAC/D,SAAO;AAAA,IACN;AAAA,MACC,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,eAAe;AAAA,MACf,OAAO;AAAA,MACP,YAAY,CAAC,SAAS,YAAY;AAAA,IAAA;AAAA,IAEnC;AAAA,MACC,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,eAAe;AAAA,MACf,OAAO;AAAA,MACP,YAAY,CAAC,SAAS,cAAc,UAAU;AAAA,IAAA;AAAA,IAE/C;AAAA,MACC,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,eAAe;AAAA,MACf,OAAO;AAAA,MACP,YAAY,CAAC,gBAAgB,OAAO;AAAA,IAAA;AAAA,EACrC;AAEF;AAGO,SAASC,IAAoD;AACnE,SAAO;AAAA,IACN;AAAA,MACC,IAAI;AAAA,MACJ,eAAe;A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IAC5C;AAAA,EAAA;AAEF;"}
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\tEntitySetContent,\n\tImportProfileContent,\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/** 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]),\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","// 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\tConfigurationComparison,\n\tConfigurationKind,\n\tConfigurationReleaseRecord,\n\tConfigurationState,\n\tEntitySet,\n\tEntitySetContent,\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\tConfigurationInUseError,\n\tNameTakenError,\n\tReleaseRefusedError,\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\tstubBlueprintReleases,\n\tstubEntitySets,\n\tstubImportProfiles,\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}\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/** 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/** 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}\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];\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},\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},\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] ??= { importProfiles: [], mappings: [], entitySets: [] };\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\treturn {\n\t\tcalls,\n\t\tswitchWorkspace(workspaceId) {\n\t\t\tactive = workspaceId;\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\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_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","METHODS","clock","tick","seed","items","i","count","revisions","_","n","releases","draftOf","s","latestReleaseOf","stateOf","latest","released","r","snake","key","c","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","mapping","walk","tc","pa","j","stepReasons","steps","list","p","x","profileReasons","e","entitySetReasons","profileOf","mappingOf","entitySetOf","profilesUsing","uses","ofKind","decide","revisionIn","revisionId","using","ConfigurationInUseError","blueprintReleaseId","all","ReleaseRefusedError","now","number","pageToken","newest","from","fromRevisionId","toRevisionId","to","fields","status","open","pairs","ch","child","createStubBlueprints","blueprintReleases","blueprintId","releaseId"],"mappings":";;AAUO,MAAMA,IAAe,iBAEfC,IAAoB,gBAEpBC,KAA0B;AAMhC,SAASC,GAAaC,IAAsBH,GAAiC;AACnF,SAAO;AAAA,IACN,QAAQD;AAAA,IACR,aAAAI;AAAA,IACA,SAASC,GAAkB;AAAA,MAC1B,EAAE,QAAQL,GAAc,aAAa,gBAAgB,OAAO,kBAAA;AAAA,IAAkB,CAC9E;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,IAAe,CAACC,MAA0B;AAAA,EAC/CT,EAAM,SAAS,QAAQ,OAAO;AAAA,EAC9BA,EAAM,cAAc,QAAQ,WAAW;AAAA,EACvC,GAAIS,IAAe,CAACT,EAAM,YAAY,aAAa,SAAS,CAAC,IAAI,CAAA;AAAA,EACjEA,EAAM,SAAS,YAAY,SAAS;AAAA,IACnCA,EAAM,eAAe,QAAQ,OAAO;AAAA,IACpCA,EAAM,aAAa,UAAU,KAAK;AAAA,EAAA,CAClC;AACF,GAEMU,IAAoB,MAAM;AAAA,EAC/BV,EAAM,cAAc,QAAQ,YAAY;AAAA,EACxCA,EAAM,gBAAgB,QAAQ,cAAc;AAC7C;AAOO,SAASW,KAAgD;AAC/D,QAAMC,IAAUJ,EAAa,EAAK,GAC5BK,IAAUL,EAAa,EAAI,GAC3BM,IAAe;AAAA,IACpBd,EAAM,gBAAgB,QAAQ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AO,EAAE,IAAAsC,GAAI,MAAAtC,IAAO,EAClC,KAAK,CAAC,GAAGiC,MAAM,EAAE,KAAK,cAAcA,EAAE,IAAI,CAAC;AAAA,IAC9C;AAAA,IACA,MAAM,aAAa+E,GAAa;AAC/B,aAAOD,EACL,OAAO,CAAC1F,MAAMA,EAAE,gBAAgB2F,CAAW,EAC3C,IAAI,CAAC3F,OAAO,EAAE,IAAIA,EAAE,IAAI,OAAOA,EAAE,QAAQ;AAAA,IAC5C;AAAA,IACA,MAAM,WAAW4F,GAAW;AAC3B,YAAM5F,IAAI0F,EAAkB,KAAK,CAACjC,MAAMA,EAAE,OAAOmC,CAAS;AAC1D,UAAI,CAAC5F,EAAG,OAAM,IAAI,MAAM,qBAAqB4F,CAAS,YAAY;AAClE,aAAO;AAAA,QACN,IAAI5F,EAAE;AAAA,QACN,aAAaA,EAAE;AAAA,QACf,MAAMA,EAAE;AAAA,QACR,QACCA,EAAE,UACFA,EAAE,WAAW,IAAI,CAACxC,OAAU;AAAA,UAC3B,UAAUA;AAAA,UACV,MAAAA;AAAA,UACA,WAAW;AAAA,UACX,OAAO;AAAA,UACP,UAAU,CAAA;AAAA,QAAC,EACV;AAAA,QACH,mBAAmBwC,EAAE,qBAAqB,CAAA;AAAA,MAAC;AAAA,IAE7C;AAAA,EAAA;AAEF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knkcs/importhub-ui",
3
- "version": "0.2.0",
3
+ "version": "0.4.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",
@@ -15,6 +15,10 @@
15
15
  "./testing": {
16
16
  "types": "./dist/testing.d.ts",
17
17
  "import": "./dist/testing.js"
18
+ },
19
+ "./mapping-editor": {
20
+ "types": "./dist/mapping-editor.d.ts",
21
+ "import": "./dist/mapping-editor.js"
18
22
  }
19
23
  },
20
24
  "files": [
@@ -1,16 +0,0 @@
1
- class o extends Error {
2
- importProfiles;
3
- constructor(r, s = "in use by Import Profiles") {
4
- super(s), this.name = "ConfigurationInUseError", this.importProfiles = r;
5
- }
6
- }
7
- class n extends Error {
8
- constructor(r = "the name is taken") {
9
- super(r), this.name = "NameTakenError";
10
- }
11
- }
12
- export {
13
- o as C,
14
- n as N
15
- };
16
- //# sourceMappingURL=importhub-client-CYqd7Eeq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importhub-client-CYqd7Eeq.js","sources":["../src/client/importhub-client.ts"],"sourcesContent":["// The client the screens are handed: a small, hand-written interface over\n// importhub's Connect API, as every hub package has (blueprinthub-ui,\n// contenthub-ui). Proto types never leave it, so a host or a test can supply\n// any implementation (`createConnectImporthubClient`, or the stub in\n// `@knkcs/importhub-ui/testing`), and a screen never learns the wire.\n//\n// It grows with the screens: the configuration screens (F2) read and write\n// Import Profiles, Mappings and Entity Sets and read the Processor catalogue.\n// Releases, history and comparison are later screens' (release-a-configuration).\n\nimport type { Schema } from \"@knkcs/fieldkit/schema\";\n\n/** One thing that makes a configuration invalid (importhub.v1.ValidityReason). */\nexport interface ValidityReason {\n\t/** Where, as a JSON Pointer into the content; empty for the whole. */\n\tpath: string;\n\t/** A stable code, such as `no_mappings`; the type's service lists them. */\n\tcode: string;\n\t/** What is wrong, in English, for a person. */\n\tmessage: string;\n}\n\n/** Whether a configuration may be released, and if not, why. */\nexport interface Validity {\n\tvalid: boolean;\n\treasons: ValidityReason[];\n}\n\n/** A Configuration Release, as a list names it: \"Release 3\". */\nexport interface ConfigurationRelease {\n\tid: string;\n\tnumber: number;\n}\n\n/** Where a configuration stands: its draft and its latest Release. */\nexport interface ConfigurationState {\n\tdraftRevisionId: string;\n\t/** Unset while the configuration has none. */\n\tlatestRelease?: ConfigurationRelease;\n\t/** True when the draft differs from the latest Release, and while there is none. */\n\tdraftDiffersFromRelease: boolean;\n}\n\n/** One configuration of a kind, at its draft. */\ninterface Configured<C> {\n\tid: string;\n\t/** The draft's content. */\n\tcontent: C;\n\t/**\n\t * Whether it is valid now: for Profiles and Mappings the service's\n\t * `current_validity`, which counts what changed since the save (an\n\t * included Mapping turned invalid, a Blueprint gone); for Entity Sets the\n\t * validity as saved, the only one they have.\n\t */\n\tvalidity: Validity;\n\tstate: ConfigurationState;\n}\n\n/** One Processor in a Profile's pipeline, with its settings. */\nexport interface ProcessorStep {\n\t/** The Processor, by its name in the catalogue. */\n\tprocessor: string;\n\t/** One value per setting of its settings spec, by `api_accessor`. */\n\tsettings: Record<string, unknown>;\n}\n\n/** What an admin edits of an Import Profile. */\nexport interface ImportProfileContent {\n\tname: string;\n\tdescription: string;\n\t/** The Entity Set the Source File is read with; \"\" for none. */\n\tentitySetId: string;\n\t/** In the order they run. */\n\tpreprocessors: ProcessorStep[];\n\t/** The Mappings it includes, by id, in the order they run. */\n\tmappingIds: string[];\n\t/** In the order they run. */\n\tpostProcessors: ProcessorStep[];\n\tautoPublish: boolean;\n\tdeleteSourceFileOnSuccess: boolean;\n}\n\nexport type ImportProfile = Configured<ImportProfileContent>;\n\n/**\n * What an admin edits of a Mapping, in the JSON shape of importhub.v1's\n * MappingContent (its camelCase keys). The screens here edit only the\n * fields they name; every other setting (field mappings, Version Match,\n * Title Contributions, …) is the structured editor's (F4), and travels\n * through as given, so a save here never drops it.\n */\nexport interface MappingContent {\n\tname: string;\n\tdescription?: string;\n\tblueprintId: string;\n\tblueprintReleaseId: string;\n\telementSelector?: string;\n\tsourceKey?: {\n\t\tselector?: string;\n\t\ttemplate?: string;\n\t\t[key: string]: unknown;\n\t};\n\t/** Each an xmlmapper FieldMapping; `name` is the field path. */\n\tfields?: Array<Record<string, unknown>>;\n\t[key: string]: unknown;\n}\n\nexport type Mapping = Configured<MappingContent>;\n\n/** What an admin edits of an Entity Set. */\nexport interface EntitySetContent {\n\tname: string;\n\tdescription: string;\n\t/** Entity names without `&` and `;`, to the text each stands for. */\n\tentities: Record<string, string>;\n}\n\nexport type EntitySet = Configured<EntitySetContent>;\n\n/** An Import Profile, named where another configuration is used. */\nexport interface ImportProfileRef {\n\tid: string;\n\tname: string;\n}\n\nexport type ProcessorKind = \"preprocessor\" | \"post_processor\";\nexport type ProcessorTarget = \"source_file\" | \"rich_text_field\";\n\n/** One entry of the Processor catalogue. */\nexport interface Processor {\n\t/** How a Profile names it, such as `entity-element`. */\n\tname: string;\n\tkind: ProcessorKind;\n\t/** What it works on: a Profile lists only `source_file` ones. */\n\ttarget: ProcessorTarget;\n\t/** In English, from the service. */\n\tdescription: string;\n\t/** Its settings as fieldkit Fields, in form order; empty for none. */\n\tsettingsSpec: Schema;\n}\n\n/** What moving a Mapping's draft to another Blueprint Release would lose. */\nexport interface BlueprintReleaseCheck {\n\tblueprintId: string;\n\t/** Every mapped field path the Release does not have. */\n\tmissingFieldPaths: string[];\n\t/** Every Release Spec field read or matched on that it does not have. */\n\tmissingReleaseSpecFields: string[];\n}\n\n/**\n * A delete importhub refused because Import Profiles still include the\n * Mapping, or name the Entity Set (manage-mappings:AC4,\n * manage-entity-sets:AC3). Carries the Profiles, so the screen names them.\n */\nexport class ConfigurationInUseError extends Error {\n\treadonly importProfiles: ImportProfileRef[];\n\tconstructor(importProfiles: ImportProfileRef[], message = \"in use by Import Profiles\") {\n\t\tsuper(message);\n\t\tthis.name = \"ConfigurationInUseError\";\n\t\tthis.importProfiles = importProfiles;\n\t}\n}\n\n/** A create or rename refused: another configuration of the kind has the name. */\nexport class NameTakenError extends Error {\n\tconstructor(message = \"the name is taken\") {\n\t\tsuper(message);\n\t\tthis.name = \"NameTakenError\";\n\t}\n}\n\n/**\n * What the screens ask of importhub. Every call acts on the caller's\n * workspace, which importhub takes from the token's active workspace and\n * never from an argument: a host switches workspace by switching the token.\n * An update names the draft it was made on, and is refused when somebody\n * saved in between.\n */\nexport interface ImporthubClient {\n\t/** Every Import Profile of the workspace, by name. */\n\tlistImportProfiles(): Promise<ImportProfile[]>;\n\tgetImportProfile(id: string): Promise<ImportProfile>;\n\tcreateImportProfile(content: ImportProfileContent): Promise<ImportProfile>;\n\tupdateImportProfile(\n\t\tid: string,\n\t\tcontent: ImportProfileContent,\n\t\tdraftRevisionId: string,\n\t): Promise<ImportProfile>;\n\tdeleteImportProfile(id: string): Promise<void>;\n\n\t/** The Processor catalogue, by name; the same in every workspace. */\n\tlistProcessors(): Promise<Processor[]>;\n\n\t/** Every Mapping of the workspace, by name. */\n\tlistMappings(): Promise<Mapping[]>;\n\tgetMapping(id: string): Promise<Mapping>;\n\tcreateMapping(content: MappingContent): Promise<Mapping>;\n\tupdateMapping(id: string, content: MappingContent, draftRevisionId: string): Promise<Mapping>;\n\t/** Throws ConfigurationInUseError while a Profile includes it. */\n\tdeleteMapping(id: string): Promise<void>;\n\t/** The Import Profiles whose draft or latest Release includes it. */\n\tlistMappingImportProfiles(id: string): Promise<ImportProfileRef[]>;\n\t/** Checks moving the draft to another Blueprint Release, saving nothing. */\n\tcheckMappingBlueprintRelease(\n\t\tid: string,\n\t\tblueprintReleaseId: string,\n\t): Promise<BlueprintReleaseCheck>;\n\n\t/** Every Entity Set of the workspace, by name. */\n\tlistEntitySets(): Promise<EntitySet[]>;\n\tgetEntitySet(id: string): Promise<EntitySet>;\n\tcreateEntitySet(content: EntitySetContent): Promise<EntitySet>;\n\tupdateEntitySet(\n\t\tid: string,\n\t\tcontent: EntitySetContent,\n\t\tdraftRevisionId: string,\n\t): Promise<EntitySet>;\n\t/** Throws ConfigurationInUseError while a Profile names it. */\n\tdeleteEntitySet(id: string): Promise<void>;\n}\n"],"names":["ConfigurationInUseError","importProfiles","message","NameTakenError"],"mappings":"AA2JO,MAAMA,UAAgC,MAAM;AAAA,EACzC;AAAA,EACT,YAAYC,GAAoCC,IAAU,6BAA6B;AACtF,UAAMA,CAAO,GACb,KAAK,OAAO,2BACZ,KAAK,iBAAiBD;AAAA,EACvB;AACD;AAGO,MAAME,UAAuB,MAAM;AAAA,EACzC,YAAYD,IAAU,qBAAqB;AAC1C,UAAMA,CAAO,GACb,KAAK,OAAO;AAAA,EACb;AACD;"}