{"version":3,"sources":["../src/graph-extension/define-graph-extension.ts"],"names":["unwrap","validateGraphExtension"],"mappings":";;;;;AAyDO,SAAS,qBACd,KAAA,EACoB;AACpB,EAAA,OAAOA,yBAAOC,wCAAA,CAAuB,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAA;AAE/D","file":"chunk-LWYUB45D.cjs","sourcesContent":["/**\n * Public entry for declaring a graph extension.\n *\n * Pure value: validates the input, deeply freezes the result, and returns\n * a `GraphExtension`. Invalid documents throw\n * `GraphExtensionValidationError` carrying every issue with a\n * JSON-pointer `path` to the offending field.\n */\nimport { unwrap } from \"../utils/result\";\nimport { type GraphExtension } from \"./extension-types\";\nimport { validateGraphExtension } from \"./validation\";\n\n/**\n * Validates and freezes a graph-extension document.\n *\n * Authoring entry point — runs validation in **strict** mode: unknown\n * top-level keys (e.g. `node` instead of `nodes`) and unsupported\n * string formats (e.g. `\"date-time\"` with a hyphen instead of\n * `\"datetime\"`) fail loudly with `UNKNOWN_DOCUMENT_KEY` /\n * `UNSUPPORTED_STRING_FORMAT`. The persistence-load path leaves both\n * checks off so a document committed by a future v1.x writer with\n * additive fields still parses on an older v1 reader. Callers\n * accepting raw JSON from an untyped source (e.g. an LLM proposal)\n * should validate first via `validateGraphExtension` and surface\n * the structured issues, then pass the validated document here.\n *\n * @param input - Document describing additional node kinds, edge\n *   kinds, and ontology relations. Must satisfy the v1 property-type\n *   subset documented in `ExtensionPropertyType`.\n *\n * @returns The same document, deeply frozen and shape-checked.\n *\n * @throws {GraphExtensionValidationError} when the document violates\n *   the v1 property-type subset, references undeclared kinds, contains\n *   ontology cycles, etc. The thrown error's `details.issues` array\n *   carries every failure with a JSON-pointer path.\n * @throws {GraphExtensionVersionUnsupportedError} when the document\n *   declares a future major version this library cannot safely decode.\n *\n * @example\n * ```typescript\n * const extension = defineGraphExtension({\n *   nodes: {\n *     Paper: {\n *       properties: {\n *         doi:   { type: \"string\" },\n *         title: { type: \"string\", searchable: { language: \"english\" } },\n *       },\n *       unique: [{ name: \"paper_doi\", fields: [\"doi\"] }],\n *     },\n *   },\n * });\n *\n * const evolved = await store.evolve(extension);\n * const papers = evolved.getNodeCollectionOrThrow(\"Paper\");\n * ```\n */\nexport function defineGraphExtension<const T extends GraphExtension>(\n  input: T,\n): T & GraphExtension {\n  return unwrap(validateGraphExtension(input, { strict: true })) as T &\n    GraphExtension;\n}\n"]}