@_linked/core 2.30.1 → 2.32.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +107 -60
  3. package/lib/esm/ontologies/linked-core.js +3 -2
  4. package/lib/esm/ontologies/linked-core.js.map +1 -1
  5. package/lib/esm/ontologies/shacl.d.ts +3 -0
  6. package/lib/esm/ontologies/shacl.js +6 -0
  7. package/lib/esm/ontologies/shacl.js.map +1 -1
  8. package/lib/esm/queries/IRMutation.js +1 -1
  9. package/lib/esm/queries/IRMutation.js.map +1 -1
  10. package/lib/esm/queries/IntermediateRepresentation.d.ts +0 -5
  11. package/lib/esm/queries/IntermediateRepresentation.js.map +1 -1
  12. package/lib/esm/queries/MutationQuery.js +0 -15
  13. package/lib/esm/queries/MutationQuery.js.map +1 -1
  14. package/lib/esm/queries/MutationSerialization.d.ts +6 -5
  15. package/lib/esm/queries/MutationSerialization.js +1 -9
  16. package/lib/esm/queries/MutationSerialization.js.map +1 -1
  17. package/lib/esm/queries/QueryFactory.d.ts +0 -6
  18. package/lib/esm/queries/QueryFactory.js.map +1 -1
  19. package/lib/esm/queries/lowerMutationJSON.js +1 -6
  20. package/lib/esm/queries/lowerMutationJSON.js.map +1 -1
  21. package/lib/esm/shapes/List.class.d.ts +3 -3
  22. package/lib/esm/shapes/List.class.js +3 -3
  23. package/lib/esm/shapes/List.class.js.map +1 -1
  24. package/lib/esm/shapes/List.d.ts +0 -1
  25. package/lib/esm/shapes/List.js.map +1 -1
  26. package/lib/esm/shapes/PathList.d.ts +24 -0
  27. package/lib/esm/shapes/PathList.js +60 -0
  28. package/lib/esm/shapes/PathList.js.map +1 -0
  29. package/lib/esm/shapes/PathNode.d.ts +8 -9
  30. package/lib/esm/shapes/PathNode.js +20 -14
  31. package/lib/esm/shapes/PathNode.js.map +1 -1
  32. package/lib/esm/shapes/SHACL.d.ts +15 -13
  33. package/lib/esm/shapes/SHACL.js +8 -0
  34. package/lib/esm/shapes/SHACL.js.map +1 -1
  35. package/lib/esm/shapes/index.d.ts +1 -0
  36. package/lib/esm/shapes/index.js +1 -0
  37. package/lib/esm/shapes/index.js.map +1 -1
  38. package/lib/esm/shapes/nodeShapeData.d.ts +4 -1
  39. package/lib/esm/shapes/nodeShapeData.js.map +1 -1
  40. package/lib/esm/shapes/serializePathToNodeData.d.ts +12 -11
  41. package/lib/esm/shapes/serializePathToNodeData.js +12 -11
  42. package/lib/esm/shapes/serializePathToNodeData.js.map +1 -1
  43. package/lib/esm/shapes/singleOwnerConstraint.d.ts +5 -7
  44. package/lib/esm/shapes/singleOwnerConstraint.js +65 -21
  45. package/lib/esm/shapes/singleOwnerConstraint.js.map +1 -1
  46. package/lib/esm/shapes/syncShapes.js +2 -2
  47. package/lib/esm/shapes/syncShapes.js.map +1 -1
  48. package/lib/esm/shapes/validation.js +2 -2
  49. package/lib/esm/shapes/validation.js.map +1 -1
  50. package/lib/esm/sparql/irToAlgebra.d.ts +15 -33
  51. package/lib/esm/sparql/irToAlgebra.js +680 -431
  52. package/lib/esm/sparql/irToAlgebra.js.map +1 -1
  53. package/lib/esm/sparql/ownedLinkCheck.d.ts +6 -10
  54. package/lib/esm/sparql/ownedLinkCheck.js +10 -11
  55. package/lib/esm/sparql/ownedLinkCheck.js.map +1 -1
  56. package/lib/esm/utils/Package.d.ts +3 -2
  57. package/lib/esm/utils/Package.js +21 -8
  58. package/lib/esm/utils/Package.js.map +1 -1
  59. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/shapes/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,GAAG,EAA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C/D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,IAAI,CAAC,MAAc,EAAE,KAAa;IACzC,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n/**\n * SHACL-aligned validation of plain data objects against a node shape.\n *\n * One entry point — {@link validate} — used by the create and update pipelines\n * (via `MutationQueryFactory.describe()`) and directly by callers that want to\n * know how well an object fits a shape without building a mutation.\n *\n * **Shape of the output.** This library has no triple/Turtle layer and this\n * module does not add one: a {@link ValidationReport} is plain JavaScript. It is\n * however 1-1 with the SHACL vocabulary — one key per SHACL property, named\n * after it, holding a value the mutation pipeline accepts (a literal, or a\n * `{id}` node reference for IRI-valued properties). So a report can be\n * materialized by an ordinary create query as soon as shape classes for\n * `sh:ValidationReport` / `sh:ValidationResult` exist, with no transform step:\n *\n * ```ts\n * const report = validate(Slide, data);\n * await ValidationReport.create(report); // once those shape classes exist\n * ```\n *\n * Two deliberate departures, both documented on the types: `results` is plural\n * where SHACL's repeated property is `sh:result`, and `propertyPath` is a\n * non-SHACL locator. Both map cleanly — a shape class chooses its own labels for\n * SHACL paths, and an extension property is legal on a SHACL report.\n *\n * **Coverage.** Cardinality (`sh:minCount` / `sh:maxCount`), node kind (literal\n * vs relation), undeclared properties (as `sh:closed`), `sh:datatype`, the four\n * `sh:min/maxInclusive/Exclusive` bounds, `sh:min/maxLength`, `sh:pattern` and\n * `sh:in`. Each is one entry in {@link CARDINALITY_CONSTRAINTS} or\n * {@link VALUE_CONSTRAINTS}, so adding another is one function and one test.\n *\n * Not covered: `sh:languageIn` / `sh:uniqueLang` (skipped at serialization time\n * too, so there is no metadata to check against) and `sh:hasValue`.\n */\nimport {getShapeRegistryInstanceCount} from '../utils/ShapeClass.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {xsd} from '../ontologies/xsd.js';\nimport {isNodeReferenceValue, type NodeReferenceValue} from '../utils/NodeReference.js';\nimport {getUniquePropertyShapes} from './nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from './nodeShapeData.js';\nimport {getNodeShape, getShapeClass, isSubShapeOf} from '../utils/ShapeClass.js';\nimport {isExpressionNode} from '../expressions/ExpressionNode.js';\nimport {asContextRef} from '../queries/QueryContext.js';\n\n/**\n * Which constraints apply to the data being validated.\n *\n * - `complete` — the object describes a whole node (a create, or a standalone\n * object being checked for fit). Properties absent from the data are genuinely\n * absent, so `sh:minCount` presence is checkable.\n * - `partial` — the object describes a change to an existing node (an update).\n * The store holds whatever the payload does not mention, so presence is\n * unknowable; only the values actually provided are checked.\n */\nexport type ValidationMode = 'complete' | 'partial';\n\n/**\n * A single constraint violation — an `sh:ValidationResult`.\n *\n * Every key is the local name of the SHACL property it carries, and every value\n * is in a form the create pipeline accepts (a literal, or a `{id}` node\n * reference for IRI-valued properties). A shape class declaring these\n * properties therefore materializes a result with no transform step:\n * `ValidationResult.create(result)`. The one non-SHACL key is `propertyPath`;\n * see {@link ValidationReport}.\n */\nexport interface ValidationResult {\n /** `sh:focusNode` — the node the violation is about, when its id is known. */\n focusNode?: NodeReferenceValue;\n /** `sh:resultPath` — the IRI of the property the violation is about. */\n resultPath?: NodeReferenceValue;\n /**\n * `sh:value` — the offending value, present only when it is an RDF term (a\n * literal or a node reference). Cardinality violations are about the property\n * rather than any one value, so they carry none.\n */\n value?: LiteralTerm | NodeReferenceValue;\n /** `sh:sourceShape` — the node or property shape carrying the constraint. */\n sourceShape?: NodeReferenceValue;\n /** `sh:sourceConstraintComponent` — which SHACL constraint failed. */\n sourceConstraintComponent: NodeReferenceValue;\n /** `sh:resultSeverity` — `sh:Violation`, `sh:Warning` or `sh:Info`. */\n resultSeverity: NodeReferenceValue;\n /** `sh:resultMessage` — human-readable explanation. */\n resultMessage: string;\n /**\n * **Not SHACL.** The property's label, dot-joined through nested shapes\n * (`author.fullName`) — the locator a caller needs to point at a field in the\n * object they passed in, which `sh:resultPath` alone cannot give (it names the\n * property, not where the nesting reached it). Materializes like any other\n * property once a shape class declares it; drop it for a pure-SHACL result.\n */\n propertyPath?: string;\n}\n\n/**\n * The outcome of a validation run — an `sh:ValidationReport`.\n *\n * Plain objects, 1-1 with the SHACL vocabulary, so a report can later be\n * materialized through an ordinary create query against shape classes for\n * `sh:ValidationReport` / `sh:ValidationResult` — whether or not this library\n * ever ships those classes. `results` is the sole plural rename (SHACL's\n * property is `sh:result`, repeated); a shape class maps it with\n * `@objectProperty({path: shacl.result, …}) get results()`.\n */\nexport interface ValidationReport {\n /** `sh:conforms` — true when there are no `sh:Violation`-severity results. */\n conforms: boolean;\n /** `sh:result` — every violation found, in deterministic order. */\n results: ValidationResult[];\n}\n\n/** The literal types the mutation pipeline accepts as a value. */\ntype LiteralTerm = string | number | boolean | Date;\n\nexport interface ValidateOptions {\n /** Defaults to `complete`. */\n mode?: ValidationMode;\n /** How deep to descend into nested node descriptions. Defaults to 10. */\n maxDepth?: number;\n}\n\n/** Thrown by {@link assertValid} — carries the full report, not just the first violation. */\nexport class ShapeValidationError extends Error {\n readonly report: ValidationReport;\n constructor(report: ValidationReport) {\n super(report.results.map((r) => r.resultMessage).join('\\n'));\n this.name = 'ShapeValidationError';\n this.report = report;\n }\n}\n\n/**\n * Keys that carry metadata about the node rather than a property value: `id` /\n * `__id` name it, `__blank` asks for an anonymous node, and `shape` names the shape of a nested value when the\n * property shape itself doesn't declare one (see `convertUpdateValue`).\n */\nconst RESERVED_KEYS = new Set(['id', '__id', '__blank', 'shape']);\n\n/**\n * The message for an undeclared property key. Shared with the normalization path\n * in `MutationQuery`, which needs the same guard to build a field at all.\n */\nexport function undeclaredPropertyMessage(key: string, shape: NodeShapeData): string {\n const shapeName = shape.label || shape.id?.split('/').pop();\n const base =\n `Invalid property key: ${key}. The shape ${shapeName} does not have a registered ` +\n `property with this name. Make sure the get/set method exists, and that it uses a ` +\n `@objectProperty or @literalProperty decorator.`;\n\n // If more than one copy of the shape registry module has evaluated, this message is\n // very probably lying: the property IS declared, on a copy this code cannot see.\n // Saying so here is the whole point — the previous version of this error accused\n // correct application code, and finding the real cause took a day of eliminating\n // innocent suspects. See docs/reports/043-module-identity-in-the-backend.md.\n const copies = getShapeRegistryInstanceCount();\n if (copies > 1) {\n return (\n `${base}\\n\\n` +\n `NOTE: ${copies} copies of the shape registry have loaded in this process. If this ` +\n `property is declared, it almost certainly registered on a different copy than the ` +\n `one validating here, and the declaration is not the problem. This happens when part ` +\n `of the app resolves a framework package to its source and part to its built output.`\n );\n }\n return base;\n}\n\n// ---------------------------------------------------------------------------\n// Constraint components\n// ---------------------------------------------------------------------------\n\n/** What a constraint check needs to know about the property it is checking. */\ninterface PropertyContext {\n shape: NodeShapeData;\n propertyShape: PropertyShapeData;\n /** Dot-joined label path from the root of the validated object. */\n property: string;\n focusNode?: string;\n mode: ValidationMode;\n}\n\n/**\n * A constraint check. Receives the property's values already normalized to an\n * array (a single value becomes a one-element array) and returns any violations.\n */\ntype ConstraintCheck = (values: unknown[], ctx: PropertyContext) => ValidationResult[];\n\n/**\n * `sh:value` must be an RDF term. A literal or a node reference is one; a plain\n * object, array or function is not, so it is left off rather than emitted as\n * something no store could materialize — the message still names it.\n */\nfunction asTerm(value: unknown): LiteralTerm | NodeReferenceValue | undefined {\n if (isScalarValue(value)) return value as LiteralTerm;\n if (isNodeReference(value)) return {id: (value as NodeReferenceValue).id};\n return undefined;\n}\n\n/**\n * A violation about the node itself rather than one of its property shapes —\n * `sh:sourceShape` is the node shape, and there is no `sh:resultPath` (an\n * undeclared key has no property IRI to point at).\n */\nfunction nodeViolation(\n shape: NodeShapeData,\n ctx: {focusNode?: string},\n component: NodeReferenceValue,\n message: string,\n propertyPath?: string,\n value?: unknown,\n): ValidationResult {\n const result: ValidationResult = {\n sourceConstraintComponent: component,\n resultSeverity: shacl.Violation,\n resultMessage: message,\n };\n if (ctx.focusNode) result.focusNode = {id: ctx.focusNode};\n if (propertyPath) result.propertyPath = propertyPath;\n const term = asTerm(value);\n if (term !== undefined) result.value = term;\n if (shape.id) result.sourceShape = {id: shape.id};\n return result;\n}\n\n/**\n * Build a result, omitting absent keys entirely — an `undefined` value is not a\n * property the create pipeline should see.\n */\nfunction violation(\n ctx: PropertyContext,\n component: NodeReferenceValue,\n message: string,\n value?: unknown,\n): ValidationResult {\n const result: ValidationResult = {\n sourceConstraintComponent: component,\n resultSeverity: shacl.Violation,\n resultMessage: message,\n };\n if (ctx.focusNode) result.focusNode = {id: ctx.focusNode};\n const path = ctx.propertyShape.path as NodeReferenceValue | undefined;\n if (path?.id) result.resultPath = {id: path.id};\n if (ctx.property) result.propertyPath = ctx.property;\n const term = asTerm(value);\n if (term !== undefined) result.value = term;\n const sourceShape = ctx.propertyShape.id || ctx.shape.id;\n if (sourceShape) result.sourceShape = {id: sourceShape};\n return result;\n}\n\n/** The label used in messages — the property's own label, not its nested path. */\nfunction labelOf(ps: PropertyShapeData): string {\n return ps.label || ps.id;\n}\n\n/** `sh:maxCount` — no more values than the shape allows. */\nconst maxCountCheck: ConstraintCheck = (values, ctx) => {\n const {maxCount} = ctx.propertyShape;\n if (typeof maxCount !== 'number' || values.length <= maxCount) return [];\n return [\n violation(\n ctx,\n shacl.MaxCountConstraintComponent,\n `Property '${labelOf(ctx.propertyShape)}' allows at most ${maxCount} value(s), but ${values.length} were provided.`,\n ),\n ];\n};\n\n/** `sh:minCount` — at least as many values as the shape requires. */\nconst minCountCheck: ConstraintCheck = (values, ctx) => {\n const {minCount} = ctx.propertyShape;\n if (typeof minCount !== 'number' || minCount <= 0 || values.length >= minCount) return [];\n return [\n violation(\n ctx,\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ctx.propertyShape)}' requires at least ${minCount} value(s), but ${values.length} were provided.`,\n ),\n ];\n};\n\n/** True when the property clearly accepts only literal values. */\nfunction expectsLiteral(ps: PropertyShapeData): boolean {\n if (ps.nodeKind) return ps.nodeKind.id === shacl.Literal.id;\n return !!ps.datatype && !ps.valueShape && !ps.class;\n}\n\n/**\n * True when the property clearly accepts only nodes (IRIs/blank nodes). `sh:class` counts\n * as much as `sh:node`: a value that is an instance of a class is a node, whether or not\n * the property names a shape for it.\n */\nfunction expectsNode(ps: PropertyShapeData): boolean {\n if (ps.nodeKind) {\n return (\n ps.nodeKind.id === shacl.IRI.id ||\n ps.nodeKind.id === shacl.BlankNode.id ||\n ps.nodeKind.id === shacl.BlankNodeOrIRI.id\n );\n }\n return !!(ps.valueShape || ps.class);\n}\n\nfunction isScalarValue(value: unknown): boolean {\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n );\n}\n\n/**\n * `sh:nodeKind` — literal properties reject nodes/objects, relation properties\n * reject bare scalars. Ambiguous kinds (`sh:IRIOrLiteral`, or no `nodeKind` and\n * no `datatype`/`valueShape`/`class` to infer from) are not enforced.\n */\nconst nodeKindCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n const literalExpected = expectsLiteral(ps);\n const nodeExpected = expectsNode(ps);\n if (!literalExpected && !nodeExpected) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el)) continue;\n const scalar = isScalarValue(el);\n if (literalExpected && !scalar) {\n results.push(\n violation(\n ctx,\n shacl.NodeKindConstraintComponent,\n `Property '${labelOf(ps)}' is a literal property but was given a ${typeof el === 'object' ? 'node/object' : typeof el} value.`,\n el,\n ),\n );\n } else if (nodeExpected && scalar) {\n results.push(\n violation(\n ctx,\n shacl.NodeKindConstraintComponent,\n `Property '${labelOf(ps)}' is a relation (object) property but was given a literal (${typeof el}). Provide a {id} reference or a nested object.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/**\n * An element worth checking: a concrete value rather than something whose final\n * form is decided elsewhere (an expression, a context ref, an absent value).\n */\nfunction isCheckableElement(el: unknown): boolean {\n return el !== null && el !== undefined && !isExpressionNode(el) && !asContextRef(el);\n}\n\nconst XSD_BASE = xsd.string.id.slice(0, -'string'.length);\n\n/** `xsd:integer` rather than the full IRI, when the datatype is an XSD one. */\nfunction datatypeLabel(datatype: NodeReferenceValue): string {\n return datatype.id.startsWith(XSD_BASE)\n ? `xsd:${datatype.id.slice(XSD_BASE.length)}`\n : datatype.id;\n}\n\n/** How a value reads in a message — its JS kind, which is what went wrong. */\nfunction describeValue(value: unknown): string {\n if (value instanceof Date) return 'a Date';\n if (Array.isArray(value)) return 'an array';\n if (typeof value === 'number') return Number.isInteger(value) ? 'a whole number' : 'a decimal number';\n if (typeof value === 'object') return 'a node/object';\n return `a ${typeof value}`;\n}\n\nconst isFiniteNumber = (v: unknown) => typeof v === 'number' && Number.isFinite(v);\n\n/**\n * What each XSD datatype accepts as a JavaScript value.\n *\n * This matters more than a normal type check: mutation literals are typed from\n * the *JavaScript* type when they reach SPARQL (`irToAlgebra`), not from the\n * declared datatype — a number becomes `xsd:integer`/`xsd:double`, a boolean\n * `xsd:boolean`, a `Date` `xsd:dateTime`, and a string an untyped literal. So a\n * string handed to an `xsd:integer` property does not merely skip a check, it\n * writes the wrong RDF term. Rejecting it is a correctness fix.\n *\n * `xsd:date` and `xsd:dateTime` take a `Date` and nothing else — one representation for a point\n * in time, rather than a JS object and a hand-written lexical string that behave differently.\n * The serializer derives the right lexical form from the declared datatype\n * (`irToAlgebra.dateToTerm`), so an `xsd:date` property gets `\"2020-06-15\"^^xsd:date` from the\n * same `Date` an `xsd:dateTime` property gets a full timestamp from.\n *\n * `xsd:time` is the exception, and takes a STRING. A `Date` cannot express a time of day without\n * inventing a date to carry it: the date half is meaningless, has to be discarded on\n * serialization, and makes two identical clock times on different days compare unequal. JS has\n * no time-only type — `Temporal.PlainTime` is the right answer and is not available yet — so the\n * lexical form is the honest representation. It is pattern-checked here, and `irToAlgebra` types\n * it from the declared datatype so it is written `\"10:30:00\"^^xsd:time` rather than as a plain\n * literal.\n *\n * Datatypes with no obvious JS counterpart (`xsd:duration`, `xsd:gYear`,\n * `xsd:Bytes`) are not checked.\n */\n/**\n * `HH:MM:SS` with optional milliseconds and optional timezone.\n *\n * Ranges are enforced by the pattern rather than parsed: hours 00-23, minutes and seconds 00-59,\n * so \"25:00:00\" is rejected where a looser `\\d{2}` would let it through and write a malformed\n * literal. The optional `Z`/offset is included because it is valid `xsd:time` — rejecting\n * \"14:30:00Z\" would make this stricter than the datatype it validates.\n */\nconst XSD_TIME_PATTERN = /^([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.\\d{1,3})?(Z|[+-]([01]\\d|2[0-3]):[0-5]\\d)?$/;\n\nconst DATATYPE_RULES: Record<string, {accepts: (v: unknown) => boolean; expected: string}> = {\n [xsd.string.id]: {accepts: (v) => typeof v === 'string', expected: 'a string'},\n [xsd.boolean.id]: {accepts: (v) => typeof v === 'boolean', expected: 'a boolean'},\n [xsd.integer.id]: {accepts: (v) => isFiniteNumber(v) && Number.isInteger(v), expected: 'a whole number'},\n [xsd.long.id]: {accepts: (v) => isFiniteNumber(v) && Number.isInteger(v), expected: 'a whole number'},\n [xsd.decimal.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.float.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.double.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.date.id]: {accepts: (v) => v instanceof Date, expected: 'a Date'},\n [xsd.dateTime.id]: {accepts: (v) => v instanceof Date, expected: 'a Date'},\n [xsd.time.id]: {\n accepts: (v) => typeof v === 'string' && XSD_TIME_PATTERN.test(v),\n expected: 'a time string like \"14:30:00\", \"14:30:00.250\" or \"14:30:00Z\"',\n },\n};\n\n/** `sh:datatype` — the value's JavaScript type must match the declared datatype. */\nconst datatypeCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.datatype) return [];\n const rule = DATATYPE_RULES[ps.datatype.id];\n if (!rule) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n // A node reference is a node-kind problem, not a datatype one — one\n // violation per mistake, reported by the check that owns it.\n if (!isCheckableElement(el) || isNodeReference(el) || rule.accepts(el)) continue;\n results.push(\n violation(\n ctx,\n shacl.DatatypeConstraintComponent,\n `Property '${labelOf(ps)}' expects ${datatypeLabel(ps.datatype)} (${rule.expected}), but was given ${describeValue(el)}.`,\n el,\n ),\n );\n }\n return results;\n};\n\n/** The four `sh:min/maxInclusive/Exclusive` range constraints, on numbers. */\nconst rangeCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n const bounds: {\n limit: unknown;\n component: NodeReferenceValue;\n ok: (v: number, limit: number) => boolean;\n phrase: string;\n }[] = [\n {limit: ps.minInclusive, component: shacl.MinInclusiveConstraintComponent, ok: (v, l) => v >= l, phrase: 'at least'},\n {limit: ps.maxInclusive, component: shacl.MaxInclusiveConstraintComponent, ok: (v, l) => v <= l, phrase: 'at most'},\n {limit: ps.minExclusive, component: shacl.MinExclusiveConstraintComponent, ok: (v, l) => v > l, phrase: 'greater than'},\n {limit: ps.maxExclusive, component: shacl.MaxExclusiveConstraintComponent, ok: (v, l) => v < l, phrase: 'less than'},\n ];\n const active = bounds.filter((b) => typeof b.limit === 'number');\n if (!active.length) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n // Non-numbers are the datatype check's business.\n if (!isCheckableElement(el) || typeof el !== 'number') continue;\n for (const bound of active) {\n if (bound.ok(el, bound.limit as number)) continue;\n results.push(\n violation(\n ctx,\n bound.component,\n `Property '${labelOf(ps)}' must be ${bound.phrase} ${bound.limit}, but was given ${el}.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/** `sh:minLength` / `sh:maxLength`, on strings. */\nconst lengthCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (typeof ps.minLength !== 'number' && typeof ps.maxLength !== 'number') return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || typeof el !== 'string') continue;\n if (typeof ps.minLength === 'number' && el.length < ps.minLength) {\n results.push(\n violation(\n ctx,\n shacl.MinLengthConstraintComponent,\n `Property '${labelOf(ps)}' must be at least ${ps.minLength} character(s), but was given ${el.length}.`,\n el,\n ),\n );\n }\n if (typeof ps.maxLength === 'number' && el.length > ps.maxLength) {\n results.push(\n violation(\n ctx,\n shacl.MaxLengthConstraintComponent,\n `Property '${labelOf(ps)}' must be at most ${ps.maxLength} character(s), but was given ${el.length}.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/** `sh:pattern` — the string form of the value must match the shape's regex. */\nconst patternCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.pattern) return [];\n // Rebuild without `g`/`y`: those carry `lastIndex` between calls, so a shared\n // shape regex would match every other value.\n const regex = new RegExp(ps.pattern.source, ps.pattern.flags.replace(/[gy]/g, ''));\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || typeof el !== 'string') continue;\n if (regex.test(el)) continue;\n results.push(\n violation(\n ctx,\n shacl.PatternConstraintComponent,\n `Property '${labelOf(ps)}' must match ${String(ps.pattern)}, but was given \"${el}\".`,\n el,\n ),\n );\n }\n return results;\n};\n\n/** `sh:in` — the value must be one of the shape's allowed values. */\nconst inCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.in?.length) return [];\n const allowed = ps.in;\n const matches = (el: unknown) =>\n allowed.some((a) =>\n isNodeReferenceValue(a)\n ? isNodeReference(el) && (el as NodeReferenceValue).id === a.id\n : a === el,\n );\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || matches(el)) continue;\n const rendered = allowed\n .map((a) => (isNodeReferenceValue(a) ? a.id : JSON.stringify(a)))\n .join(', ');\n results.push(\n violation(\n ctx,\n shacl.InConstraintComponent,\n `Property '${labelOf(ps)}' must be one of [${rendered}].`,\n el,\n ),\n );\n }\n return results;\n};\n\n/**\n * The registry. Every property-level constraint the library enforces lives here;\n * adding another SHACL component is one more entry plus its test.\n *\n * Split by what each kind of check needs to see. **Cardinality** needs the\n * property's whole value set, so it cannot run against a set modification —\n * `{add: […]}` changes a count that lives in the store. **Value** checks need\n * only the value in hand, so they run everywhere a concrete value appears,\n * including inside `add`.\n *\n * Cardinality runs first when it runs at all: a count problem explains itself\n * better than the per-value violations that would follow it.\n */\nconst CARDINALITY_CONSTRAINTS: ConstraintCheck[] = [maxCountCheck, minCountCheck];\n\nconst VALUE_CONSTRAINTS: ConstraintCheck[] = [\n nodeKindCheck,\n datatypeCheck,\n rangeCheck,\n lengthCheck,\n patternCheck,\n inCheck,\n];\n\nconst PROPERTY_CONSTRAINTS: ConstraintCheck[] = [\n ...CARDINALITY_CONSTRAINTS,\n ...VALUE_CONSTRAINTS,\n];\n\n// ---------------------------------------------------------------------------\n// Value classification\n// ---------------------------------------------------------------------------\n\n/**\n * A `{add, remove}` set modification. The resulting value count depends on the\n * node's current state, so cardinality and kind are unknowable here.\n */\nfunction isSetModification(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n const expected = (obj.add ? 1 : 0) + (obj.remove ? 1 : 0);\n return expected > 0 && Object.getOwnPropertyNames(obj).length === expected;\n}\n\n/** An object carrying only an `id` — a reference to an existing node, not a description. */\nfunction isNodeReference(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'id' in value &&\n Object.keys(value).length === 1\n );\n}\n\n/**\n * A value that stands for something resolved later — an expression, a query\n * context reference, a callback, or nothing at all.\n *\n * Must be ruled out *before* anything reads properties off the value: a resolved\n * context ref is a query proxy that throws on any undecorated key, so probing it\n * for `.add` is not a safe way to ask what it is.\n */\nfunction isDeferredValue(value: unknown): boolean {\n return (\n value === undefined ||\n typeof value === 'function' ||\n isExpressionNode(value) ||\n !!asContextRef(value)\n );\n}\n\n/** Values whose final shape isn't knowable without the store or a lowering pass. */\nfunction isOpaqueValue(value: unknown): boolean {\n return isDeferredValue(value) || isSetModification(value);\n}\n\n/** A nested node description — an object to descend into, rather than a leaf value. */\nfunction isNodeDescription(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !isNodeReference(value) &&\n !isOpaqueValue(value)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Entry points\n// ---------------------------------------------------------------------------\n\n/**\n * What can be validated against: a shape class (`Person`) or the plain\n * `NodeShapeData` the decorators generate (`Person.shape`, or the same object\n * obtained anywhere else). The two are interchangeable — the class is unwrapped\n * to its `shape` and nothing else about it is read.\n */\nexport type ValidatableShape = NodeShapeData | {shape: NodeShapeData};\n\nfunction resolveShapeData(shape: ValidatableShape): NodeShapeData {\n const resolved = 'propertyShapes' in shape ? shape : (shape as {shape: NodeShapeData}).shape;\n if (!resolved) {\n throw new Error(\n 'validate() requires a node shape or a shape class with a static `shape`. ' +\n 'Did you pass an unregistered class (missing @linkedShape)?',\n );\n }\n return resolved as NodeShapeData;\n}\n\n/**\n * Validate a plain data object against a node shape.\n *\n * Never throws for invalid *data* — a violation is a result, not an exception.\n * (It does throw when the *shape* argument itself is unusable.)\n *\n * ```ts\n * const report = validate(Person, {name: ['a', 'b']});\n * report.conforms; // false\n * report.results[0].sourceConstraintComponent.id; // …shacl#MaxCountConstraintComponent\n * ```\n *\n * **A shape class is optional.** The plain `NodeShapeData` the decorators\n * generate validates identically, so a caller that only ever holds shape\n * objects needs no class reference:\n *\n * ```ts\n * validate(Person, data); // ≡\n * validate(Person.shape, data); // same report\n * ```\n *\n * That holds even though a shape object carries neither its inherited property\n * shapes (a subclass's `propertyShapes` holds only its own) nor its nested\n * shapes (`valueShape` is a bare `{id}`): both are resolved through the shape\n * registry by id. A shape whose id is not registered therefore cannot be fully\n * checked, and says so — see {@link unresolvedValueShapeMessage} and the\n * inherited-properties check in `validateNode` — rather than reporting a node\n * as conforming on the strength of a branch it could not look at.\n */\nexport function validate(\n shape: ValidatableShape,\n data: unknown,\n options: ValidateOptions = {},\n): ValidationReport {\n const {mode = 'complete', maxDepth = 10} = options;\n const results = validateNode(resolveShapeData(shape), data, {\n mode,\n maxDepth,\n depth: 0,\n prefix: '',\n });\n return {\n conforms: !results.some((r) => r.resultSeverity.id === shacl.Violation.id),\n results,\n };\n}\n\n/** {@link validate}, but throws a {@link ShapeValidationError} when the data doesn't conform. */\nexport function assertValid(\n shape: ValidatableShape,\n data: unknown,\n options: ValidateOptions = {},\n): void {\n const report = validate(shape, data, options);\n if (!report.conforms) throw new ShapeValidationError(report);\n}\n\n// ---------------------------------------------------------------------------\n// Walk\n// ---------------------------------------------------------------------------\n\ninterface WalkContext {\n mode: ValidationMode;\n maxDepth: number;\n depth: number;\n /** Dot-joined label path of the node being validated (`''` at the root). */\n prefix: string;\n focusNode?: string;\n}\n\nfunction validateNode(\n shape: NodeShapeData,\n data: unknown,\n ctx: WalkContext,\n): ValidationResult[] {\n if (typeof data !== 'object' || data === null || Array.isArray(data)) {\n return [\n nodeViolation(\n shape,\n ctx,\n shacl.NodeConstraintComponent,\n `Expected an object describing '${shape.label || shape.id}', but got ${data === null ? 'null' : typeof data}.`,\n ctx.prefix,\n data,\n ),\n ];\n }\n\n const obj = data as Record<string, unknown>;\n const propertyShapes = getUniquePropertyShapes(shape);\n const byLabel = new Map(propertyShapes.map((ps) => [ps.label, ps]));\n const focusNode =\n typeof obj.__id === 'string'\n ? obj.__id\n : typeof obj.id === 'string'\n ? obj.id\n : ctx.focusNode;\n const results: ValidationResult[] = [];\n\n // A shape declaring a superclass carries only its *own* property shapes; the\n // inherited ones are resolved through the registry by id. If this shape's id\n // is not registered, that resolution quietly yields half a shape — required\n // inherited properties go unchecked, and any that *are* supplied look\n // undeclared. Report it rather than let a partial shape pass as a clean bill.\n //\n // \"Registered\" means present in EITHER registry. Checking only for a class rejected\n // exactly the shapes the metamodel work exists to support: a data-only child is\n // registered, its parent resolves, and its inherited properties are checked — it simply\n // has no class, which is not a defect.\n if (shape.extends?.id && !getShapeClass(shape.id) && !getNodeShape(shape.id)) {\n results.push(\n nodeViolation(\n shape,\n {focusNode},\n shacl.NodeConstraintComponent,\n `Cannot resolve the properties '${shape.label || shape.id}' inherits from '${shape.extends.id}': shape '${shape.id}' is not registered, so only its own properties could be checked.`,\n ctx.prefix,\n ),\n );\n }\n\n // Presence of required properties — only decidable for a complete description.\n if (ctx.mode === 'complete') {\n for (const ps of propertyShapes) {\n if (typeof ps.minCount !== 'number' || ps.minCount <= 0) continue;\n if (ps.label in obj) continue;\n results.push(\n violation(\n {shape, propertyShape: ps, property: join(ctx.prefix, ps.label), focusNode, mode: ctx.mode},\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ps)}' requires at least ${ps.minCount} value(s), but none were provided.`,\n ),\n );\n }\n }\n\n // The values actually provided.\n for (const [key, value] of Object.entries(obj)) {\n if (RESERVED_KEYS.has(key)) continue;\n const propertyShape = byLabel.get(key);\n if (!propertyShape) {\n results.push(\n nodeViolation(\n shape,\n {...ctx, focusNode},\n shacl.ClosedConstraintComponent,\n undeclaredPropertyMessage(key, shape),\n join(ctx.prefix, key),\n value,\n ),\n );\n continue;\n }\n results.push(\n ...validateProperty(value, {\n shape,\n propertyShape,\n property: join(ctx.prefix, key),\n focusNode,\n mode: ctx.mode,\n }, ctx),\n );\n }\n\n return results;\n}\n\nfunction validateProperty(\n value: unknown,\n propCtx: PropertyContext,\n walk: WalkContext,\n): ValidationResult[] {\n const ps = propCtx.propertyShape;\n\n // `null` clears the property — the same as providing zero values, so clearing\n // a required one is a cardinality violation (both spellings behave alike).\n if (value === null) {\n if (typeof ps.minCount === 'number' && ps.minCount > 0) {\n return [\n violation(\n propCtx,\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ps)}' requires at least ${ps.minCount} value(s) and cannot be cleared.`,\n ),\n ];\n }\n return [];\n }\n\n // Ruled out first: reading `.add` off a resolved context proxy would throw.\n if (isDeferredValue(value)) return [];\n\n // A set modification adds to and removes from what the store already holds,\n // so the resulting *count* is unknowable here — but each added value is as\n // checkable as any other, and skipping them let mistyped literals through the\n // one door the rest of this module closes. `remove` takes `{id}` references\n // only, which normalization enforces on its own.\n if (isSetModification(value)) {\n const {add} = value as {add?: unknown};\n if (add === undefined) return [];\n return runChecks(VALUE_CONSTRAINTS, toValues(add), propCtx, walk);\n }\n\n return runChecks(PROPERTY_CONSTRAINTS, toValues(value), propCtx, walk);\n}\n\n/** A property's value(s) as an array — a single value becomes a one-element one. */\nfunction toValues(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Run a set of constraint checks over a property's values, then descend into any\n * nested node descriptions among them (`sh:node`-style recursion). A bare `{id}`\n * is a reference to an existing node and has nothing to validate; an object with\n * an id *and* data is a nested create with a predefined id.\n */\nfunction runChecks(\n checks: ConstraintCheck[],\n values: unknown[],\n propCtx: PropertyContext,\n walk: WalkContext,\n): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const check of checks) {\n results.push(...check(values, propCtx));\n }\n\n if (walk.depth < walk.maxDepth) {\n for (const el of values) {\n if (!isNodeDescription(el)) continue;\n const nestedShape = resolveValueShape(propCtx.propertyShape, el);\n if (!nestedShape) {\n // The value is a node description we have no shape for, so nothing about\n // it can be checked. Silently skipping would report the whole node as\n // conforming on the strength of a branch never looked at.\n results.push(\n violation(\n propCtx,\n shacl.NodeConstraintComponent,\n unresolvedValueShapeMessage(propCtx.propertyShape),\n ),\n );\n continue;\n }\n results.push(\n ...validateNode(nestedShape, el, {\n ...walk,\n depth: walk.depth + 1,\n prefix: propCtx.property,\n focusNode: undefined,\n }),\n );\n }\n }\n\n return results;\n}\n\n/**\n * Why a nested value could not be resolved to a shape — the property named one\n * that is not registered, or named none and the value did not carry one either.\n * Both are actionable, and they are fixed differently.\n */\nfunction unresolvedValueShapeMessage(ps: PropertyShapeData): string {\n const label = labelOf(ps);\n return ps.valueShape\n ? `Cannot validate the value of '${label}': its shape '${ps.valueShape.id}' is not registered.`\n : `Cannot validate the value of '${label}': the property declares no shape for its values. ` +\n `Add a 'shape' to its @objectProperty decorator, or give the value a 'shape' key.`;\n}\n\n/**\n * The shape a nested value should be validated against: the shape class carried\n * in the value's reserved `shape` key when the property declares no `valueShape`\n * or the key names a subclass of it, otherwise the declared `valueShape`. Mirrors\n * `convertUpdateValue`; returns undefined when neither is available.\n */\nfunction resolveValueShape(\n ps: PropertyShapeData,\n value: unknown,\n): NodeShapeData | undefined {\n const own = (value as {shape?: {shape?: NodeShapeData}}).shape?.shape;\n if (!ps.valueShape) return own;\n const declared = getShapeClass(ps.valueShape)?.shape;\n // A value naming a subclass of the declared shape is validated as that subclass.\n if (own && declared && isSubShapeOf(own, declared)) return own;\n return declared;\n}\n\nfunction join(prefix: string, label: string): string {\n return prefix ? `${prefix}.${label}` : label;\n}\n"]}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/shapes/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAgFxD,6FAA6F;AAC7F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE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,SAAS,IACpB,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,EAAqB;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,UAAU;QAClB,CAAC,CAAC,iCAAiC,KAAK,iBAAiB,EAAE,CAAC,UAAU,CAAC,EAAE,sBAAsB;QAC/F,CAAC,CAAC,iCAAiC,KAAK,oDAAoD;YACxF,kFAAkF,CAAC;AAC3F,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,EAAqB,EACrB,KAAc;;IAEd,MAAM,GAAG,GAAG,MAAC,KAA2C,CAAC,KAAK,0CAAE,KAAK,CAAC;IACtE,IAAI,CAAC,EAAE,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAA,aAAa,CAAC,EAAE,CAAC,UAAU,CAAC,0CAAE,KAAK,CAAC;IACrD,iFAAiF;IACjF,IAAI,GAAG,IAAI,QAAQ,IAAI,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;QAAE,OAAO,GAAG,CAAC;IAC/D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,IAAI,CAAC,MAAc,EAAE,KAAa;IACzC,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n/**\n * SHACL-aligned validation of plain data objects against a node shape.\n *\n * One entry point — {@link validate} — used by the create and update pipelines\n * (via `MutationQueryFactory.describe()`) and directly by callers that want to\n * know how well an object fits a shape without building a mutation.\n *\n * **Shape of the output.** This library has no triple/Turtle layer and this\n * module does not add one: a {@link ValidationReport} is plain JavaScript. It is\n * however 1-1 with the SHACL vocabulary — one key per SHACL property, named\n * after it, holding a value the mutation pipeline accepts (a literal, or a\n * `{id}` node reference for IRI-valued properties). So a report can be\n * materialized by an ordinary create query as soon as shape classes for\n * `sh:ValidationReport` / `sh:ValidationResult` exist, with no transform step:\n *\n * ```ts\n * const report = validate(Slide, data);\n * await ValidationReport.create(report); // once those shape classes exist\n * ```\n *\n * Two deliberate departures, both documented on the types: `results` is plural\n * where SHACL's repeated property is `sh:result`, and `propertyPath` is a\n * non-SHACL locator. Both map cleanly — a shape class chooses its own labels for\n * SHACL paths, and an extension property is legal on a SHACL report.\n *\n * **Coverage.** Cardinality (`sh:minCount` / `sh:maxCount`), node kind (literal\n * vs relation), undeclared properties (as `sh:closed`), `sh:datatype`, the four\n * `sh:min/maxInclusive/Exclusive` bounds, `sh:min/maxLength`, `sh:pattern` and\n * `sh:in`. Each is one entry in {@link CARDINALITY_CONSTRAINTS} or\n * {@link VALUE_CONSTRAINTS}, so adding another is one function and one test.\n *\n * Not covered: `sh:languageIn` / `sh:uniqueLang` (skipped at serialization time\n * too, so there is no metadata to check against) and `sh:hasValue`.\n */\nimport {getShapeRegistryInstanceCount} from '../utils/ShapeClass.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {xsd} from '../ontologies/xsd.js';\nimport {isNodeReferenceValue, type NodeReferenceValue} from '../utils/NodeReference.js';\nimport {getUniquePropertyShapes} from './nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from './nodeShapeData.js';\nimport {getNodeShape, getShapeClass, isSubShapeOf} from '../utils/ShapeClass.js';\nimport {isExpressionNode} from '../expressions/ExpressionNode.js';\nimport {asContextRef} from '../queries/QueryContext.js';\n\n/**\n * Which constraints apply to the data being validated.\n *\n * - `complete` — the object describes a whole node (a create, or a standalone\n * object being checked for fit). Properties absent from the data are genuinely\n * absent, so `sh:minCount` presence is checkable.\n * - `partial` — the object describes a change to an existing node (an update).\n * The store holds whatever the payload does not mention, so presence is\n * unknowable; only the values actually provided are checked.\n */\nexport type ValidationMode = 'complete' | 'partial';\n\n/**\n * A single constraint violation — an `sh:ValidationResult`.\n *\n * Every key is the local name of the SHACL property it carries, and every value\n * is in a form the create pipeline accepts (a literal, or a `{id}` node\n * reference for IRI-valued properties). A shape class declaring these\n * properties therefore materializes a result with no transform step:\n * `ValidationResult.create(result)`. The one non-SHACL key is `propertyPath`;\n * see {@link ValidationReport}.\n */\nexport interface ValidationResult {\n /** `sh:focusNode` — the node the violation is about, when its id is known. */\n focusNode?: NodeReferenceValue;\n /** `sh:resultPath` — the IRI of the property the violation is about. */\n resultPath?: NodeReferenceValue;\n /**\n * `sh:value` — the offending value, present only when it is an RDF term (a\n * literal or a node reference). Cardinality violations are about the property\n * rather than any one value, so they carry none.\n */\n value?: LiteralTerm | NodeReferenceValue;\n /** `sh:sourceShape` — the node or property shape carrying the constraint. */\n sourceShape?: NodeReferenceValue;\n /** `sh:sourceConstraintComponent` — which SHACL constraint failed. */\n sourceConstraintComponent: NodeReferenceValue;\n /** `sh:resultSeverity` — `sh:Violation`, `sh:Warning` or `sh:Info`. */\n resultSeverity: NodeReferenceValue;\n /** `sh:resultMessage` — human-readable explanation. */\n resultMessage: string;\n /**\n * **Not SHACL.** The property's label, dot-joined through nested shapes\n * (`author.fullName`) — the locator a caller needs to point at a field in the\n * object they passed in, which `sh:resultPath` alone cannot give (it names the\n * property, not where the nesting reached it). Materializes like any other\n * property once a shape class declares it; drop it for a pure-SHACL result.\n */\n propertyPath?: string;\n}\n\n/**\n * The outcome of a validation run — an `sh:ValidationReport`.\n *\n * Plain objects, 1-1 with the SHACL vocabulary, so a report can later be\n * materialized through an ordinary create query against shape classes for\n * `sh:ValidationReport` / `sh:ValidationResult` — whether or not this library\n * ever ships those classes. `results` is the sole plural rename (SHACL's\n * property is `sh:result`, repeated); a shape class maps it with\n * `@objectProperty({path: shacl.result, …}) get results()`.\n */\nexport interface ValidationReport {\n /** `sh:conforms` — true when there are no `sh:Violation`-severity results. */\n conforms: boolean;\n /** `sh:result` — every violation found, in deterministic order. */\n results: ValidationResult[];\n}\n\n/** The literal types the mutation pipeline accepts as a value. */\ntype LiteralTerm = string | number | boolean | Date;\n\nexport interface ValidateOptions {\n /** Defaults to `complete`. */\n mode?: ValidationMode;\n /** How deep to descend into nested node descriptions. Defaults to 10. */\n maxDepth?: number;\n}\n\n/** Thrown by {@link assertValid} — carries the full report, not just the first violation. */\nexport class ShapeValidationError extends Error {\n readonly report: ValidationReport;\n constructor(report: ValidationReport) {\n super(report.results.map((r) => r.resultMessage).join('\\n'));\n this.name = 'ShapeValidationError';\n this.report = report;\n }\n}\n\n/**\n * Keys that carry metadata about the node rather than a property value: `id` /\n * `__id` name it, and `shape` names the shape of a nested value when the\n * property shape itself doesn't declare one (see `convertUpdateValue`).\n */\nconst RESERVED_KEYS = new Set(['id', '__id', 'shape']);\n\n/**\n * The message for an undeclared property key. Shared with the normalization path\n * in `MutationQuery`, which needs the same guard to build a field at all.\n */\nexport function undeclaredPropertyMessage(key: string, shape: NodeShapeData): string {\n const shapeName = shape.label || shape.id?.split('/').pop();\n const base =\n `Invalid property key: ${key}. The shape ${shapeName} does not have a registered ` +\n `property with this name. Make sure the get/set method exists, and that it uses a ` +\n `@objectProperty or @literalProperty decorator.`;\n\n // If more than one copy of the shape registry module has evaluated, this message is\n // very probably lying: the property IS declared, on a copy this code cannot see.\n // Saying so here is the whole point — the previous version of this error accused\n // correct application code, and finding the real cause took a day of eliminating\n // innocent suspects. See docs/reports/043-module-identity-in-the-backend.md.\n const copies = getShapeRegistryInstanceCount();\n if (copies > 1) {\n return (\n `${base}\\n\\n` +\n `NOTE: ${copies} copies of the shape registry have loaded in this process. If this ` +\n `property is declared, it almost certainly registered on a different copy than the ` +\n `one validating here, and the declaration is not the problem. This happens when part ` +\n `of the app resolves a framework package to its source and part to its built output.`\n );\n }\n return base;\n}\n\n// ---------------------------------------------------------------------------\n// Constraint components\n// ---------------------------------------------------------------------------\n\n/** What a constraint check needs to know about the property it is checking. */\ninterface PropertyContext {\n shape: NodeShapeData;\n propertyShape: PropertyShapeData;\n /** Dot-joined label path from the root of the validated object. */\n property: string;\n focusNode?: string;\n mode: ValidationMode;\n}\n\n/**\n * A constraint check. Receives the property's values already normalized to an\n * array (a single value becomes a one-element array) and returns any violations.\n */\ntype ConstraintCheck = (values: unknown[], ctx: PropertyContext) => ValidationResult[];\n\n/**\n * `sh:value` must be an RDF term. A literal or a node reference is one; a plain\n * object, array or function is not, so it is left off rather than emitted as\n * something no store could materialize — the message still names it.\n */\nfunction asTerm(value: unknown): LiteralTerm | NodeReferenceValue | undefined {\n if (isScalarValue(value)) return value as LiteralTerm;\n if (isNodeReference(value)) return {id: (value as NodeReferenceValue).id};\n return undefined;\n}\n\n/**\n * A violation about the node itself rather than one of its property shapes —\n * `sh:sourceShape` is the node shape, and there is no `sh:resultPath` (an\n * undeclared key has no property IRI to point at).\n */\nfunction nodeViolation(\n shape: NodeShapeData,\n ctx: {focusNode?: string},\n component: NodeReferenceValue,\n message: string,\n propertyPath?: string,\n value?: unknown,\n): ValidationResult {\n const result: ValidationResult = {\n sourceConstraintComponent: component,\n resultSeverity: shacl.Violation,\n resultMessage: message,\n };\n if (ctx.focusNode) result.focusNode = {id: ctx.focusNode};\n if (propertyPath) result.propertyPath = propertyPath;\n const term = asTerm(value);\n if (term !== undefined) result.value = term;\n if (shape.id) result.sourceShape = {id: shape.id};\n return result;\n}\n\n/**\n * Build a result, omitting absent keys entirely — an `undefined` value is not a\n * property the create pipeline should see.\n */\nfunction violation(\n ctx: PropertyContext,\n component: NodeReferenceValue,\n message: string,\n value?: unknown,\n): ValidationResult {\n const result: ValidationResult = {\n sourceConstraintComponent: component,\n resultSeverity: shacl.Violation,\n resultMessage: message,\n };\n if (ctx.focusNode) result.focusNode = {id: ctx.focusNode};\n const path = ctx.propertyShape.path as NodeReferenceValue | undefined;\n if (path?.id) result.resultPath = {id: path.id};\n if (ctx.property) result.propertyPath = ctx.property;\n const term = asTerm(value);\n if (term !== undefined) result.value = term;\n const sourceShape = ctx.propertyShape.id || ctx.shape.id;\n if (sourceShape) result.sourceShape = {id: sourceShape};\n return result;\n}\n\n/** The label used in messages — the property's own label, not its nested path. */\nfunction labelOf(ps: PropertyShapeData): string {\n return ps.label || ps.id;\n}\n\n/** `sh:maxCount` — no more values than the shape allows. */\nconst maxCountCheck: ConstraintCheck = (values, ctx) => {\n const {maxCount} = ctx.propertyShape;\n if (typeof maxCount !== 'number' || values.length <= maxCount) return [];\n return [\n violation(\n ctx,\n shacl.MaxCountConstraintComponent,\n `Property '${labelOf(ctx.propertyShape)}' allows at most ${maxCount} value(s), but ${values.length} were provided.`,\n ),\n ];\n};\n\n/** `sh:minCount` — at least as many values as the shape requires. */\nconst minCountCheck: ConstraintCheck = (values, ctx) => {\n const {minCount} = ctx.propertyShape;\n if (typeof minCount !== 'number' || minCount <= 0 || values.length >= minCount) return [];\n return [\n violation(\n ctx,\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ctx.propertyShape)}' requires at least ${minCount} value(s), but ${values.length} were provided.`,\n ),\n ];\n};\n\n/** True when the property clearly accepts only literal values. */\nfunction expectsLiteral(ps: PropertyShapeData): boolean {\n if (ps.nodeKind) return ps.nodeKind.id === shacl.Literal.id;\n return !!ps.datatype && !ps.valueShape && !ps.class;\n}\n\n/**\n * True when the property clearly accepts only nodes (IRIs/blank nodes). `sh:class` counts\n * as much as `sh:node`: a value that is an instance of a class is a node, whether or not\n * the property names a shape for it.\n */\nfunction expectsNode(ps: PropertyShapeData): boolean {\n if (ps.nodeKind) {\n return (\n ps.nodeKind.id === shacl.IRI.id ||\n ps.nodeKind.id === shacl.BlankNode.id ||\n ps.nodeKind.id === shacl.BlankNodeOrIRI.id\n );\n }\n return !!(ps.valueShape || ps.class);\n}\n\nfunction isScalarValue(value: unknown): boolean {\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n );\n}\n\n/**\n * `sh:nodeKind` — literal properties reject nodes/objects, relation properties\n * reject bare scalars. Ambiguous kinds (`sh:IRIOrLiteral`, or no `nodeKind` and\n * no `datatype`/`valueShape`/`class` to infer from) are not enforced.\n */\nconst nodeKindCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n const literalExpected = expectsLiteral(ps);\n const nodeExpected = expectsNode(ps);\n if (!literalExpected && !nodeExpected) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el)) continue;\n const scalar = isScalarValue(el);\n if (literalExpected && !scalar) {\n results.push(\n violation(\n ctx,\n shacl.NodeKindConstraintComponent,\n `Property '${labelOf(ps)}' is a literal property but was given a ${typeof el === 'object' ? 'node/object' : typeof el} value.`,\n el,\n ),\n );\n } else if (nodeExpected && scalar) {\n results.push(\n violation(\n ctx,\n shacl.NodeKindConstraintComponent,\n `Property '${labelOf(ps)}' is a relation (object) property but was given a literal (${typeof el}). Provide a {id} reference or a nested object.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/**\n * An element worth checking: a concrete value rather than something whose final\n * form is decided elsewhere (an expression, a context ref, an absent value).\n */\nfunction isCheckableElement(el: unknown): boolean {\n return el !== null && el !== undefined && !isExpressionNode(el) && !asContextRef(el);\n}\n\nconst XSD_BASE = xsd.string.id.slice(0, -'string'.length);\n\n/** `xsd:integer` rather than the full IRI, when the datatype is an XSD one. */\nfunction datatypeLabel(datatype: NodeReferenceValue): string {\n return datatype.id.startsWith(XSD_BASE)\n ? `xsd:${datatype.id.slice(XSD_BASE.length)}`\n : datatype.id;\n}\n\n/** How a value reads in a message — its JS kind, which is what went wrong. */\nfunction describeValue(value: unknown): string {\n if (value instanceof Date) return 'a Date';\n if (Array.isArray(value)) return 'an array';\n if (typeof value === 'number') return Number.isInteger(value) ? 'a whole number' : 'a decimal number';\n if (typeof value === 'object') return 'a node/object';\n return `a ${typeof value}`;\n}\n\nconst isFiniteNumber = (v: unknown) => typeof v === 'number' && Number.isFinite(v);\n\n/**\n * What each XSD datatype accepts as a JavaScript value.\n *\n * This matters more than a normal type check: mutation literals are typed from\n * the *JavaScript* type when they reach SPARQL (`irToAlgebra`), not from the\n * declared datatype — a number becomes `xsd:integer`/`xsd:double`, a boolean\n * `xsd:boolean`, a `Date` `xsd:dateTime`, and a string an untyped literal. So a\n * string handed to an `xsd:integer` property does not merely skip a check, it\n * writes the wrong RDF term. Rejecting it is a correctness fix.\n *\n * `xsd:date` and `xsd:dateTime` take a `Date` and nothing else — one representation for a point\n * in time, rather than a JS object and a hand-written lexical string that behave differently.\n * The serializer derives the right lexical form from the declared datatype\n * (`irToAlgebra.dateToTerm`), so an `xsd:date` property gets `\"2020-06-15\"^^xsd:date` from the\n * same `Date` an `xsd:dateTime` property gets a full timestamp from.\n *\n * `xsd:time` is the exception, and takes a STRING. A `Date` cannot express a time of day without\n * inventing a date to carry it: the date half is meaningless, has to be discarded on\n * serialization, and makes two identical clock times on different days compare unequal. JS has\n * no time-only type — `Temporal.PlainTime` is the right answer and is not available yet — so the\n * lexical form is the honest representation. It is pattern-checked here, and `irToAlgebra` types\n * it from the declared datatype so it is written `\"10:30:00\"^^xsd:time` rather than as a plain\n * literal.\n *\n * Datatypes with no obvious JS counterpart (`xsd:duration`, `xsd:gYear`,\n * `xsd:Bytes`) are not checked.\n */\n/**\n * `HH:MM:SS` with optional milliseconds and optional timezone.\n *\n * Ranges are enforced by the pattern rather than parsed: hours 00-23, minutes and seconds 00-59,\n * so \"25:00:00\" is rejected where a looser `\\d{2}` would let it through and write a malformed\n * literal. The optional `Z`/offset is included because it is valid `xsd:time` — rejecting\n * \"14:30:00Z\" would make this stricter than the datatype it validates.\n */\nconst XSD_TIME_PATTERN = /^([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.\\d{1,3})?(Z|[+-]([01]\\d|2[0-3]):[0-5]\\d)?$/;\n\nconst DATATYPE_RULES: Record<string, {accepts: (v: unknown) => boolean; expected: string}> = {\n [xsd.string.id]: {accepts: (v) => typeof v === 'string', expected: 'a string'},\n [xsd.boolean.id]: {accepts: (v) => typeof v === 'boolean', expected: 'a boolean'},\n [xsd.integer.id]: {accepts: (v) => isFiniteNumber(v) && Number.isInteger(v), expected: 'a whole number'},\n [xsd.long.id]: {accepts: (v) => isFiniteNumber(v) && Number.isInteger(v), expected: 'a whole number'},\n [xsd.decimal.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.float.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.double.id]: {accepts: isFiniteNumber, expected: 'a number'},\n [xsd.date.id]: {accepts: (v) => v instanceof Date, expected: 'a Date'},\n [xsd.dateTime.id]: {accepts: (v) => v instanceof Date, expected: 'a Date'},\n [xsd.time.id]: {\n accepts: (v) => typeof v === 'string' && XSD_TIME_PATTERN.test(v),\n expected: 'a time string like \"14:30:00\", \"14:30:00.250\" or \"14:30:00Z\"',\n },\n};\n\n/** `sh:datatype` — the value's JavaScript type must match the declared datatype. */\nconst datatypeCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.datatype) return [];\n const rule = DATATYPE_RULES[ps.datatype.id];\n if (!rule) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n // A node reference is a node-kind problem, not a datatype one — one\n // violation per mistake, reported by the check that owns it.\n if (!isCheckableElement(el) || isNodeReference(el) || rule.accepts(el)) continue;\n results.push(\n violation(\n ctx,\n shacl.DatatypeConstraintComponent,\n `Property '${labelOf(ps)}' expects ${datatypeLabel(ps.datatype)} (${rule.expected}), but was given ${describeValue(el)}.`,\n el,\n ),\n );\n }\n return results;\n};\n\n/** The four `sh:min/maxInclusive/Exclusive` range constraints, on numbers. */\nconst rangeCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n const bounds: {\n limit: unknown;\n component: NodeReferenceValue;\n ok: (v: number, limit: number) => boolean;\n phrase: string;\n }[] = [\n {limit: ps.minInclusive, component: shacl.MinInclusiveConstraintComponent, ok: (v, l) => v >= l, phrase: 'at least'},\n {limit: ps.maxInclusive, component: shacl.MaxInclusiveConstraintComponent, ok: (v, l) => v <= l, phrase: 'at most'},\n {limit: ps.minExclusive, component: shacl.MinExclusiveConstraintComponent, ok: (v, l) => v > l, phrase: 'greater than'},\n {limit: ps.maxExclusive, component: shacl.MaxExclusiveConstraintComponent, ok: (v, l) => v < l, phrase: 'less than'},\n ];\n const active = bounds.filter((b) => typeof b.limit === 'number');\n if (!active.length) return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n // Non-numbers are the datatype check's business.\n if (!isCheckableElement(el) || typeof el !== 'number') continue;\n for (const bound of active) {\n if (bound.ok(el, bound.limit as number)) continue;\n results.push(\n violation(\n ctx,\n bound.component,\n `Property '${labelOf(ps)}' must be ${bound.phrase} ${bound.limit}, but was given ${el}.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/** `sh:minLength` / `sh:maxLength`, on strings. */\nconst lengthCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (typeof ps.minLength !== 'number' && typeof ps.maxLength !== 'number') return [];\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || typeof el !== 'string') continue;\n if (typeof ps.minLength === 'number' && el.length < ps.minLength) {\n results.push(\n violation(\n ctx,\n shacl.MinLengthConstraintComponent,\n `Property '${labelOf(ps)}' must be at least ${ps.minLength} character(s), but was given ${el.length}.`,\n el,\n ),\n );\n }\n if (typeof ps.maxLength === 'number' && el.length > ps.maxLength) {\n results.push(\n violation(\n ctx,\n shacl.MaxLengthConstraintComponent,\n `Property '${labelOf(ps)}' must be at most ${ps.maxLength} character(s), but was given ${el.length}.`,\n el,\n ),\n );\n }\n }\n return results;\n};\n\n/** `sh:pattern` — the string form of the value must match the shape's regex. */\nconst patternCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.pattern) return [];\n // Rebuild without `g`/`y`: those carry `lastIndex` between calls, so a shared\n // shape regex would match every other value.\n const regex = new RegExp(ps.pattern.source, ps.pattern.flags.replace(/[gy]/g, ''));\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || typeof el !== 'string') continue;\n if (regex.test(el)) continue;\n results.push(\n violation(\n ctx,\n shacl.PatternConstraintComponent,\n `Property '${labelOf(ps)}' must match ${String(ps.pattern)}, but was given \"${el}\".`,\n el,\n ),\n );\n }\n return results;\n};\n\n/** `sh:in` — the value must be one of the shape's allowed values. */\nconst inCheck: ConstraintCheck = (values, ctx) => {\n const ps = ctx.propertyShape;\n if (!ps.in?.length) return [];\n const allowed = ps.in;\n const matches = (el: unknown) =>\n allowed.some((a) =>\n isNodeReferenceValue(a)\n ? isNodeReference(el) && (el as NodeReferenceValue).id === a.id\n : a === el,\n );\n\n const results: ValidationResult[] = [];\n for (const el of values) {\n if (!isCheckableElement(el) || matches(el)) continue;\n const rendered = allowed\n .map((a) => (isNodeReferenceValue(a) ? a.id : JSON.stringify(a)))\n .join(', ');\n results.push(\n violation(\n ctx,\n shacl.InConstraintComponent,\n `Property '${labelOf(ps)}' must be one of [${rendered}].`,\n el,\n ),\n );\n }\n return results;\n};\n\n/**\n * The registry. Every property-level constraint the library enforces lives here;\n * adding another SHACL component is one more entry plus its test.\n *\n * Split by what each kind of check needs to see. **Cardinality** needs the\n * property's whole value set, so it cannot run against a set modification —\n * `{add: […]}` changes a count that lives in the store. **Value** checks need\n * only the value in hand, so they run everywhere a concrete value appears,\n * including inside `add`.\n *\n * Cardinality runs first when it runs at all: a count problem explains itself\n * better than the per-value violations that would follow it.\n */\nconst CARDINALITY_CONSTRAINTS: ConstraintCheck[] = [maxCountCheck, minCountCheck];\n\nconst VALUE_CONSTRAINTS: ConstraintCheck[] = [\n nodeKindCheck,\n datatypeCheck,\n rangeCheck,\n lengthCheck,\n patternCheck,\n inCheck,\n];\n\nconst PROPERTY_CONSTRAINTS: ConstraintCheck[] = [\n ...CARDINALITY_CONSTRAINTS,\n ...VALUE_CONSTRAINTS,\n];\n\n// ---------------------------------------------------------------------------\n// Value classification\n// ---------------------------------------------------------------------------\n\n/**\n * A `{add, remove}` set modification. The resulting value count depends on the\n * node's current state, so cardinality and kind are unknowable here.\n */\nfunction isSetModification(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false;\n const obj = value as Record<string, unknown>;\n const expected = (obj.add ? 1 : 0) + (obj.remove ? 1 : 0);\n return expected > 0 && Object.getOwnPropertyNames(obj).length === expected;\n}\n\n/** An object carrying only an `id` — a reference to an existing node, not a description. */\nfunction isNodeReference(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'id' in value &&\n Object.keys(value).length === 1\n );\n}\n\n/**\n * A value that stands for something resolved later — an expression, a query\n * context reference, a callback, or nothing at all.\n *\n * Must be ruled out *before* anything reads properties off the value: a resolved\n * context ref is a query proxy that throws on any undecorated key, so probing it\n * for `.add` is not a safe way to ask what it is.\n */\nfunction isDeferredValue(value: unknown): boolean {\n return (\n value === undefined ||\n typeof value === 'function' ||\n isExpressionNode(value) ||\n !!asContextRef(value)\n );\n}\n\n/** Values whose final shape isn't knowable without the store or a lowering pass. */\nfunction isOpaqueValue(value: unknown): boolean {\n return isDeferredValue(value) || isSetModification(value);\n}\n\n/** A nested node description — an object to descend into, rather than a leaf value. */\nfunction isNodeDescription(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !(value instanceof Date) &&\n !isNodeReference(value) &&\n !isOpaqueValue(value)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Entry points\n// ---------------------------------------------------------------------------\n\n/**\n * What can be validated against: a shape class (`Person`) or the plain\n * `NodeShapeData` the decorators generate (`Person.shape`, or the same object\n * obtained anywhere else). The two are interchangeable — the class is unwrapped\n * to its `shape` and nothing else about it is read.\n */\nexport type ValidatableShape = NodeShapeData | {shape: NodeShapeData};\n\nfunction resolveShapeData(shape: ValidatableShape): NodeShapeData {\n const resolved = 'propertyShapes' in shape ? shape : (shape as {shape: NodeShapeData}).shape;\n if (!resolved) {\n throw new Error(\n 'validate() requires a node shape or a shape class with a static `shape`. ' +\n 'Did you pass an unregistered class (missing @linkedShape)?',\n );\n }\n return resolved as NodeShapeData;\n}\n\n/**\n * Validate a plain data object against a node shape.\n *\n * Never throws for invalid *data* — a violation is a result, not an exception.\n * (It does throw when the *shape* argument itself is unusable.)\n *\n * ```ts\n * const report = validate(Person, {name: ['a', 'b']});\n * report.conforms; // false\n * report.results[0].sourceConstraintComponent.id; // …shacl#MaxCountConstraintComponent\n * ```\n *\n * **A shape class is optional.** The plain `NodeShapeData` the decorators\n * generate validates identically, so a caller that only ever holds shape\n * objects needs no class reference:\n *\n * ```ts\n * validate(Person, data); // ≡\n * validate(Person.shape, data); // same report\n * ```\n *\n * That holds even though a shape object carries neither its inherited property\n * shapes (a subclass's `propertyShapes` holds only its own) nor its nested\n * shapes (`valueShape` is a bare `{id}`): both are resolved through the shape\n * registry by id. A shape whose id is not registered therefore cannot be fully\n * checked, and says so — see {@link unresolvedValueShapeMessage} and the\n * inherited-properties check in `validateNode` — rather than reporting a node\n * as conforming on the strength of a branch it could not look at.\n */\nexport function validate(\n shape: ValidatableShape,\n data: unknown,\n options: ValidateOptions = {},\n): ValidationReport {\n const {mode = 'complete', maxDepth = 10} = options;\n const results = validateNode(resolveShapeData(shape), data, {\n mode,\n maxDepth,\n depth: 0,\n prefix: '',\n });\n return {\n conforms: !results.some((r) => r.resultSeverity.id === shacl.Violation.id),\n results,\n };\n}\n\n/** {@link validate}, but throws a {@link ShapeValidationError} when the data doesn't conform. */\nexport function assertValid(\n shape: ValidatableShape,\n data: unknown,\n options: ValidateOptions = {},\n): void {\n const report = validate(shape, data, options);\n if (!report.conforms) throw new ShapeValidationError(report);\n}\n\n// ---------------------------------------------------------------------------\n// Walk\n// ---------------------------------------------------------------------------\n\ninterface WalkContext {\n mode: ValidationMode;\n maxDepth: number;\n depth: number;\n /** Dot-joined label path of the node being validated (`''` at the root). */\n prefix: string;\n focusNode?: string;\n}\n\nfunction validateNode(\n shape: NodeShapeData,\n data: unknown,\n ctx: WalkContext,\n): ValidationResult[] {\n if (typeof data !== 'object' || data === null || Array.isArray(data)) {\n return [\n nodeViolation(\n shape,\n ctx,\n shacl.NodeConstraintComponent,\n `Expected an object describing '${shape.label || shape.id}', but got ${data === null ? 'null' : typeof data}.`,\n ctx.prefix,\n data,\n ),\n ];\n }\n\n const obj = data as Record<string, unknown>;\n const propertyShapes = getUniquePropertyShapes(shape);\n const byLabel = new Map(propertyShapes.map((ps) => [ps.label, ps]));\n const focusNode =\n typeof obj.__id === 'string'\n ? obj.__id\n : typeof obj.id === 'string'\n ? obj.id\n : ctx.focusNode;\n const results: ValidationResult[] = [];\n\n // A shape declaring a superclass carries only its *own* property shapes; the\n // inherited ones are resolved through the registry by id. If this shape's id\n // is not registered, that resolution quietly yields half a shape — required\n // inherited properties go unchecked, and any that *are* supplied look\n // undeclared. Report it rather than let a partial shape pass as a clean bill.\n //\n // \"Registered\" means present in EITHER registry. Checking only for a class rejected\n // exactly the shapes the metamodel work exists to support: a data-only child is\n // registered, its parent resolves, and its inherited properties are checked — it simply\n // has no class, which is not a defect.\n if (shape.extends?.id && !getShapeClass(shape.id) && !getNodeShape(shape.id)) {\n results.push(\n nodeViolation(\n shape,\n {focusNode},\n shacl.NodeConstraintComponent,\n `Cannot resolve the properties '${shape.label || shape.id}' inherits from '${shape.extends.id}': shape '${shape.id}' is not registered, so only its own properties could be checked.`,\n ctx.prefix,\n ),\n );\n }\n\n // Presence of required properties — only decidable for a complete description.\n if (ctx.mode === 'complete') {\n for (const ps of propertyShapes) {\n if (typeof ps.minCount !== 'number' || ps.minCount <= 0) continue;\n if (ps.label in obj) continue;\n results.push(\n violation(\n {shape, propertyShape: ps, property: join(ctx.prefix, ps.label), focusNode, mode: ctx.mode},\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ps)}' requires at least ${ps.minCount} value(s), but none were provided.`,\n ),\n );\n }\n }\n\n // The values actually provided.\n for (const [key, value] of Object.entries(obj)) {\n if (RESERVED_KEYS.has(key)) continue;\n const propertyShape = byLabel.get(key);\n if (!propertyShape) {\n results.push(\n nodeViolation(\n shape,\n {...ctx, focusNode},\n shacl.ClosedConstraintComponent,\n undeclaredPropertyMessage(key, shape),\n join(ctx.prefix, key),\n value,\n ),\n );\n continue;\n }\n results.push(\n ...validateProperty(value, {\n shape,\n propertyShape,\n property: join(ctx.prefix, key),\n focusNode,\n mode: ctx.mode,\n }, ctx),\n );\n }\n\n return results;\n}\n\nfunction validateProperty(\n value: unknown,\n propCtx: PropertyContext,\n walk: WalkContext,\n): ValidationResult[] {\n const ps = propCtx.propertyShape;\n\n // `null` clears the property — the same as providing zero values, so clearing\n // a required one is a cardinality violation (both spellings behave alike).\n if (value === null) {\n if (typeof ps.minCount === 'number' && ps.minCount > 0) {\n return [\n violation(\n propCtx,\n shacl.MinCountConstraintComponent,\n `Property '${labelOf(ps)}' requires at least ${ps.minCount} value(s) and cannot be cleared.`,\n ),\n ];\n }\n return [];\n }\n\n // Ruled out first: reading `.add` off a resolved context proxy would throw.\n if (isDeferredValue(value)) return [];\n\n // A set modification adds to and removes from what the store already holds,\n // so the resulting *count* is unknowable here — but each added value is as\n // checkable as any other, and skipping them let mistyped literals through the\n // one door the rest of this module closes. `remove` takes `{id}` references\n // only, which normalization enforces on its own.\n if (isSetModification(value)) {\n const {add} = value as {add?: unknown};\n if (add === undefined) return [];\n return runChecks(VALUE_CONSTRAINTS, toValues(add), propCtx, walk);\n }\n\n return runChecks(PROPERTY_CONSTRAINTS, toValues(value), propCtx, walk);\n}\n\n/** A property's value(s) as an array — a single value becomes a one-element one. */\nfunction toValues(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Run a set of constraint checks over a property's values, then descend into any\n * nested node descriptions among them (`sh:node`-style recursion). A bare `{id}`\n * is a reference to an existing node and has nothing to validate; an object with\n * an id *and* data is a nested create with a predefined id.\n */\nfunction runChecks(\n checks: ConstraintCheck[],\n values: unknown[],\n propCtx: PropertyContext,\n walk: WalkContext,\n): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const check of checks) {\n results.push(...check(values, propCtx));\n }\n\n if (walk.depth < walk.maxDepth) {\n for (const el of values) {\n if (!isNodeDescription(el)) continue;\n const nestedShape = resolveValueShape(propCtx.propertyShape, el);\n if (!nestedShape) {\n // The value is a node description we have no shape for, so nothing about\n // it can be checked. Silently skipping would report the whole node as\n // conforming on the strength of a branch never looked at.\n results.push(\n violation(\n propCtx,\n shacl.NodeConstraintComponent,\n unresolvedValueShapeMessage(propCtx.propertyShape),\n ),\n );\n continue;\n }\n results.push(\n ...validateNode(nestedShape, el, {\n ...walk,\n depth: walk.depth + 1,\n prefix: propCtx.property,\n focusNode: undefined,\n }),\n );\n }\n }\n\n return results;\n}\n\n/**\n * Why a nested value could not be resolved to a shape — the property named one\n * that is not registered, or named none and the value did not carry one either.\n * Both are actionable, and they are fixed differently.\n */\nfunction unresolvedValueShapeMessage(ps: PropertyShapeData): string {\n const label = labelOf(ps);\n return ps.valueShape\n ? `Cannot validate the value of '${label}': its shape '${ps.valueShape.id}' is not registered.`\n : `Cannot validate the value of '${label}': the property declares no shape for its values. ` +\n `Add a 'shape' to its @objectProperty decorator, or give the value a 'shape' key.`;\n}\n\n/**\n * The shape a nested value should be validated against: the shape class carried\n * in the value's reserved `shape` key when the property declares no `valueShape`\n * or the key names a subclass of it, otherwise the declared `valueShape`. Mirrors\n * `convertUpdateValue`; returns undefined when neither is available.\n */\nfunction resolveValueShape(\n ps: PropertyShapeData,\n value: unknown,\n): NodeShapeData | undefined {\n const own = (value as {shape?: {shape?: NodeShapeData}}).shape?.shape;\n if (!ps.valueShape) return own;\n const declared = getShapeClass(ps.valueShape)?.shape;\n // A value naming a subclass of the declared shape is validated as that subclass.\n if (own && declared && isSubShapeOf(own, declared)) return own;\n return declared;\n}\n\nfunction join(prefix: string, label: string): string {\n return prefix ? `${prefix}.${label}` : label;\n}\n"]}
@@ -26,36 +26,19 @@ export declare function updateToAlgebra(query: IRUpdateMutation, options?: Sparq
26
26
  * needs no guard.
27
27
  */
28
28
  export declare function upsertToAlgebra(query: IRUpsertMutation, options?: SparqlOptions): SparqlDeleteInsertPlan;
29
- /** Gather contains-predicate IRIs and dependent targetClass IRIs from the registry. */
30
- export declare function collectContainment(): {
31
- containsPreds: string[];
32
- dependentTypes: string[];
33
- };
34
29
  /**
35
- * Build DELETE patterns + WHERE OPTIONAL blocks that cascade-delete the owned subtree
36
- * reachable from `rootTerm` via `contains` edges. `varPrefix` keeps generated variables
37
- * unique across multiple roots in one query. Returns empty when nothing is owned.
38
- *
39
- * `anchor`, when given, leads every block: the triple that binds a variable root, so
40
- * each block stays correct on its own (as a UNION branch) when no such root exists.
41
- * `onlyTypes`, when given, restricts the blocks to those dependent types (a subject delete
42
- * passes the types its shape can reach); by default every registered dependent type gets one.
30
+ * How many times one walk path may re-enter a shape it already passed through (a cycle through
31
+ * several shapes, or a sub-shape's edge back into its own kind). Values below are not deleted.
43
32
  */
44
- export declare function buildOwnedCascade(rootTerm: SparqlTerm, varPrefix: string, anchor?: SparqlTriple, keep?: SparqlTerm[], onlyTypes?: string[]): {
45
- deletePatterns: SparqlTriple[];
46
- whereOptionals: SparqlAlgebraNode[];
47
- };
33
+ export declare const MAX_OWNED_RECURSION = 4;
34
+ /** Above this many branches for one root shape, lowering warns once (see backlog 055). */
35
+ export declare const OWNED_BRANCH_WARNING = 64;
48
36
  /**
49
37
  * Build DELETE + WHERE OPTIONAL that removes the *old node's own* one-hop triples when a
50
38
  * `contains` edge is replaced, unset, or set-removed. A `contains` edge asserts exclusive
51
39
  * ownership, so overwriting it must delete the previously owned child fully — not merely
52
- * unlink it — or the child orphans (backlog 032). This is `contains`-driven and deliberately
53
- * does NOT require the child shape to be `dependent`: ownership via the edge is sufficient.
54
- * Owned descendants *below* the old node are cascaded separately by `buildOwnedCascade`.
55
- *
56
- * Callers use it only for a property that declares a value shape. A shape-less `contains`
57
- * slot (like `sh:path`) may hold a shared IRI, so its old value is left to
58
- * `buildOwnedCascade`, which deletes it only when it is dependent-typed.
40
+ * unlink it — or the child orphans (backlog 032). Ownership via the edge is sufficient.
41
+ * Owned descendants *below* the old node are deleted separately (`ownedSubtreeBlocks`).
59
42
  *
60
43
  * The owning edge `<subject> <prop> ?old` is re-asserted INSIDE the WHERE group so `?old`
61
44
  * is bound there: when no old value exists the group matches nothing and the DELETE is a
@@ -75,19 +58,18 @@ export declare function buildOwnedSelfDelete(subjectTerm: SparqlTerm, propertyTe
75
58
  * Converts an IRDeleteMutation to a SparqlDeleteInsertPlan (DELETE + WHERE).
76
59
  *
77
60
  * The WHERE is the type guard of every id, joined with ONE UNION of independent
78
- * blocks: per id its own triples, its incoming references and, for a shape that
79
- * owns something, one block per immediately-owned child (`<s> <p> ?dN . ?dN ?dN_p ?dN_o`,
80
- * for each of the shape's own and inherited `contains` properties with a value shape and
81
- * a simple path) and one block per dependent type its owned subtree can reach
82
- * (`reachableDependentTypes`; none for a shape that owns only non-dependent values). The
61
+ * blocks: per id its own triples, its incoming references, its blank values and one branch
62
+ * per owned path, plus that node's blank values (`ownedSubtreeBlocks`: the shape's own and
63
+ * inherited `contains` properties, their value shapes' in turn, and the extra ones of
64
+ * registered sub-shapes behind a type guard; none for a shape that owns nothing). The
83
65
  * bulk deletes (`deleteAllToAlgebra`, `deleteWhereToAlgebra`) add the same owned blocks,
84
66
  * rooted at the subject variable (see `bulkDeleteUnion`).
85
67
  *
86
68
  * The blocks must not be chained as OPTIONALs. A chain of OPTIONALs is a join, so
87
69
  * the solutions multiply: own triples x incoming references x owned triples of each
88
- * dependent type. Deleting one shape description with the shape sync's cascade
70
+ * owned path. Deleting one shape description with the shape sync's cascade
89
71
  * produced ~27,000 solutions for ~130 triples and took over 30 seconds on Fuseki,
90
- * which re-evaluates the cascade property path for every left-hand row. A UNION
72
+ * which re-evaluated the former registry-wide cascade path for every left-hand row. A UNION
91
73
  * yields each block's matches once, so the solutions add up instead, and it deletes
92
74
  * exactly the same triples: a DELETE template triple whose variables a solution
93
75
  * leaves unbound is skipped, as it was for an OPTIONAL that did not match.
@@ -101,7 +83,7 @@ export declare function deleteToAlgebra(query: IRDeleteMutation, _options?: Spar
101
83
  *
102
84
  * Generates DELETE { ?a0 ?p ?o . [blank-node and owned-cleanup wildcards] }
103
85
  * WHERE { ?a0 a <Shape> . { ?a0 ?p ?o } UNION [one block per blank node,
104
- * owned child and dependent type] }
86
+ * owned group] }
105
87
  * (see `bulkDeleteUnion`). Unlike a delete by id, incoming references are not deleted.
106
88
  */
107
89
  export declare function deleteAllToAlgebra(query: IRDeleteAllMutation, _options?: SparqlOptions): SparqlDeleteInsertPlan;
@@ -109,7 +91,7 @@ export declare function deleteAllToAlgebra(query: IRDeleteAllMutation, _options?
109
91
  * Converts an IRDeleteWhereMutation to a SparqlDeleteInsertPlan.
110
92
  *
111
93
  * Like deleteAllToAlgebra but adds filter conditions from the where clause. The cleanup
112
- * UNION (blank nodes, owned children, dependent cascade) is joined with the filtered match,
94
+ * UNION (blank nodes, owned subtree) is joined with the filtered match,
113
95
  * so only the matched subjects' children are deleted.
114
96
  */
115
97
  export declare function deleteWhereToAlgebra(query: IRDeleteWhereMutation, _options?: SparqlOptions): SparqlDeleteInsertPlan;