@_linked/core 2.32.0 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.33.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#340](https://github.com/linked-fw/core/pull/340) [`666e74c`](https://github.com/linked-fw/core/commit/666e74c8fc0b92d76c1cbcd4941738cd0c82ab5c) Thanks [@flyon](https://github.com/flyon)! - Shape sync skips unchanged shapes. Each synced NodeShape now stores `core:shapeHash`, a SHA-256 of the canonical data the sync writes for it (property shapes, `sh:in` lists, paths and generated single-owner shapes included). `syncShapes()` reads the stored hashes of all code shapes in one select and returns a delete→create thunk only for shapes whose hash is missing or differs, so syncing an unchanged app writes nothing and the plan length is the number of shapes actually written (plus pruned orphans). `syncShape()` does the same check inside its thunk. Shapes stored by earlier versions have no hash and are rewritten once. New option `force: true` (on `syncShapes` options and as a third `syncShape` argument) rewrites regardless — use it to repair a shape whose stored subtree was changed outside shape sync, which the hash does not detect.
8
+
3
9
  ## 2.32.0
4
10
 
5
11
  ### Minor Changes
@@ -1,6 +1,7 @@
1
1
  import './shapes/index.js';
2
2
  import './live.js';
3
3
  export { syncShapes, syncShape } from './shapes/syncShapes.js';
4
+ export type { SyncShapesOptions, SyncShapeOptions } from './shapes/syncShapes.js';
4
5
  export { singleOwnerShapeIri, singleOwnerProperties, buildSingleOwnerConstraints, } from './shapes/singleOwnerConstraint.js';
5
6
  export { rdfList } from './shapes/List.js';
6
7
  export { serializePathToNodeData } from './shapes/serializePathToNodeData.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,0DAA0D;AAC1D,OAAO,mBAAmB,CAAC;AAC3B,8EAA8E;AAC9E,OAAO,WAAW,CAAC;AACnB,OAAO,EAAC,UAAU,EAAE,SA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AAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAGzD,8CAA8C;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAe3C,sEAAsE;AACtE,OAAO,EACL,cAAc,EACd,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAWxC,0FAA0F;AAC1F,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,0BAA0B,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// Registers every shape core defines (side effects only).\nimport './shapes/index.js';\n// Registers the live-query store so `query.live()` works (side effects only).\nimport './live.js';\nexport {syncShapes, syncShape} from './shapes/syncShapes.js';\nexport {\n singleOwnerShapeIri,\n singleOwnerProperties,\n buildSingleOwnerConstraints,\n} from './shapes/singleOwnerConstraint.js';\nexport {rdfList} from './shapes/List.js';\nexport {serializePathToNodeData} from './shapes/serializePathToNodeData.js';\n// Core public API surface (documented as root imports in the README).\nexport {Shape} from './shapes/Shape.js';\n// SHACL-aligned validation of plain data objects against a shape.\nexport {validate, assertValid, ShapeValidationError} from './shapes/validation.js';\nexport type {\n ValidationReport,\n ValidationResult,\n ValidationMode,\n ValidateOptions,\n ValidatableShape,\n} from './shapes/validation.js';\nexport {LinkedStorage} from './utils/LinkedStorage.js';\n// New dynamic query building API (Phase 2)\nexport {SelectBuilder, QueryBuilder} from './queries/QueryBuilder.js';\nexport {lower} from './queries/lower.js';\nexport type {LowerableQuery} from './queries/lower.js';\nexport {fromJSON} from './queries/fromJSON.js';\nexport type {QueryJSON} from './queries/fromJSON.js';\nexport {\n getQueryContext,\n setQueryContext,\n subscribeQueryContext,\n PendingQueryContext,\n UnresolvedContextError,\n} from './queries/QueryContext.js';\nexport {subscribeQueryDispatch} from './queries/queryDispatch.js';\nexport type {QueryDispatchEvent, QueryDispatchListener} from './queries/queryDispatch.js';\nexport {\n CONTEXT_REF_KEY,\n encodeContextRef,\n isContextRefJSON,\n resolveContextId,\n} from './queries/ContextRef.js';\nexport type {ContextRefJSON} from './queries/ContextRef.js';\nexport {PropertyPath, walkPropertyPath} from './queries/PropertyPath.js';\n\n// Phase 3a — FieldSet\nexport {FieldSet} from './queries/FieldSet.js';\nexport type {FieldSetEntry, FieldSetInput, FieldSetJSON, FieldSetFieldJSON} from './queries/FieldSet.js';\n\n// Phase 4 — Serialization types\nexport type {QueryBuilderJSON} from './queries/QueryBuilder.js';\n\n// Phase 3b — Mutation builders\nexport {AskBuilder, isAskQuery} from './queries/AskBuilder.js';\nexport type {AskSpec} from './queries/AskBuilder.js';\nexport type {AskQuery, AskQueryJSON, RawAskInput} from './queries/AskQuery.js';\nexport {CountBuilder, isCountQuery} from './queries/CountBuilder.js';\nexport type {CountSpec} from './queries/CountBuilder.js';\nexport type {CountQuery, CountQueryJSON, RawCountInput} from './queries/CountQuery.js';\nexport {CreateBuilder} from './queries/CreateBuilder.js';\nexport {UpdateBuilder} from './queries/UpdateBuilder.js';\nexport {DeleteBuilder} from './queries/DeleteBuilder.js';\nexport type {DeleteId} from './queries/DeleteBuilder.js';\n\n// Expressions — computed fields and functions\nexport {ExpressionNode} from './expressions/ExpressionNode.js';\nexport type {ExpressionInput, PropertyRefMap} from './expressions/ExpressionNode.js';\nexport {Expr} from './expressions/Expr.js';\nexport type {\n ExpressionUpdateProxy,\n ExpressionUpdateResult,\n BaseExpressionMethods,\n NumericExpressionMethods,\n StringExpressionMethods,\n DateExpressionMethods,\n BooleanExpressionMethods,\n} from './expressions/ExpressionMethods.js';\n\n// Phase 5 — Component query integration\nexport type {LinkedComponentInterface, QueryComponentLike} from './queries/SelectQuery.js';\n\n\n// Mutation DSL-JSON serialization (create/update/delete to/from JSON)\nexport {\n encodeNodeData,\n encodeValue,\n} from './queries/MutationSerialization.js';\nexport {\n decodeNodeData,\n lowerMutationJSON,\n} from './queries/lowerMutationJSON.js';\nexport type {\n MutationJSON,\n CreateMutationJSON,\n UpdateMutationJSON,\n DeleteMutationJSON,\n MutationValueJSON,\n MutationNodeDataJSON,\n} from './queries/MutationSerialization.js';\n\n\n// Live-query dependency helpers — what a query reads and a mutation writes, as predicates\nexport {queryDependencies, mutationEffects} from './queries/queryDependencies.js';\nexport type {QueryDependencies, MutationEffects} from './queries/queryDependencies.js';\nexport {findPropertyShapeById} from './shapes/nodeShapeData.js';\n\n// Live queries — see documentation/live-queries.md\nexport {LiveQueryStore, getLiveQueryStore, resetLiveQueryStore, publishChange, invalidate} from './live/LiveQueryStore.js';\nexport type {ChangeEvent} from './live/changes.js';\nexport type {\n LiveQuery,\n LiveState,\n LiveStatus,\n LiveListener,\n LiveQueryOptions,\n LiveQueryStoreOptions,\n} from './live/LiveQueryStore.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,0DAA0D;AAC1D,OAAO,mBAAmB,CAAC;AAC3B,8EAA8E;AAC9E,OAAO,WAAW,CAAC;AACnB,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,sEAAsE;AACtE,OA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C,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAWxC,0FAA0F;AAC1F,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,0BAA0B,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// Registers every shape core defines (side effects only).\nimport './shapes/index.js';\n// Registers the live-query store so `query.live()` works (side effects only).\nimport './live.js';\nexport {syncShapes, syncShape} from './shapes/syncShapes.js';\nexport type {SyncShapesOptions, SyncShapeOptions} from './shapes/syncShapes.js';\nexport {\n singleOwnerShapeIri,\n singleOwnerProperties,\n buildSingleOwnerConstraints,\n} from './shapes/singleOwnerConstraint.js';\nexport {rdfList} from './shapes/List.js';\nexport {serializePathToNodeData} from './shapes/serializePathToNodeData.js';\n// Core public API surface (documented as root imports in the README).\nexport {Shape} from './shapes/Shape.js';\n// SHACL-aligned validation of plain data objects against a shape.\nexport {validate, assertValid, ShapeValidationError} from './shapes/validation.js';\nexport type {\n ValidationReport,\n ValidationResult,\n ValidationMode,\n ValidateOptions,\n ValidatableShape,\n} from './shapes/validation.js';\nexport {LinkedStorage} from './utils/LinkedStorage.js';\n// New dynamic query building API (Phase 2)\nexport {SelectBuilder, QueryBuilder} from './queries/QueryBuilder.js';\nexport {lower} from './queries/lower.js';\nexport type {LowerableQuery} from './queries/lower.js';\nexport {fromJSON} from './queries/fromJSON.js';\nexport type {QueryJSON} from './queries/fromJSON.js';\nexport {\n getQueryContext,\n setQueryContext,\n subscribeQueryContext,\n PendingQueryContext,\n UnresolvedContextError,\n} from './queries/QueryContext.js';\nexport {subscribeQueryDispatch} from './queries/queryDispatch.js';\nexport type {QueryDispatchEvent, QueryDispatchListener} from './queries/queryDispatch.js';\nexport {\n CONTEXT_REF_KEY,\n encodeContextRef,\n isContextRefJSON,\n resolveContextId,\n} from './queries/ContextRef.js';\nexport type {ContextRefJSON} from './queries/ContextRef.js';\nexport {PropertyPath, walkPropertyPath} from './queries/PropertyPath.js';\n\n// Phase 3a — FieldSet\nexport {FieldSet} from './queries/FieldSet.js';\nexport type {FieldSetEntry, FieldSetInput, FieldSetJSON, FieldSetFieldJSON} from './queries/FieldSet.js';\n\n// Phase 4 — Serialization types\nexport type {QueryBuilderJSON} from './queries/QueryBuilder.js';\n\n// Phase 3b — Mutation builders\nexport {AskBuilder, isAskQuery} from './queries/AskBuilder.js';\nexport type {AskSpec} from './queries/AskBuilder.js';\nexport type {AskQuery, AskQueryJSON, RawAskInput} from './queries/AskQuery.js';\nexport {CountBuilder, isCountQuery} from './queries/CountBuilder.js';\nexport type {CountSpec} from './queries/CountBuilder.js';\nexport type {CountQuery, CountQueryJSON, RawCountInput} from './queries/CountQuery.js';\nexport {CreateBuilder} from './queries/CreateBuilder.js';\nexport {UpdateBuilder} from './queries/UpdateBuilder.js';\nexport {DeleteBuilder} from './queries/DeleteBuilder.js';\nexport type {DeleteId} from './queries/DeleteBuilder.js';\n\n// Expressions — computed fields and functions\nexport {ExpressionNode} from './expressions/ExpressionNode.js';\nexport type {ExpressionInput, PropertyRefMap} from './expressions/ExpressionNode.js';\nexport {Expr} from './expressions/Expr.js';\nexport type {\n ExpressionUpdateProxy,\n ExpressionUpdateResult,\n BaseExpressionMethods,\n NumericExpressionMethods,\n StringExpressionMethods,\n DateExpressionMethods,\n BooleanExpressionMethods,\n} from './expressions/ExpressionMethods.js';\n\n// Phase 5 — Component query integration\nexport type {LinkedComponentInterface, QueryComponentLike} from './queries/SelectQuery.js';\n\n\n// Mutation DSL-JSON serialization (create/update/delete to/from JSON)\nexport {\n encodeNodeData,\n encodeValue,\n} from './queries/MutationSerialization.js';\nexport {\n decodeNodeData,\n lowerMutationJSON,\n} from './queries/lowerMutationJSON.js';\nexport type {\n MutationJSON,\n CreateMutationJSON,\n UpdateMutationJSON,\n DeleteMutationJSON,\n MutationValueJSON,\n MutationNodeDataJSON,\n} from './queries/MutationSerialization.js';\n\n\n// Live-query dependency helpers — what a query reads and a mutation writes, as predicates\nexport {queryDependencies, mutationEffects} from './queries/queryDependencies.js';\nexport type {QueryDependencies, MutationEffects} from './queries/queryDependencies.js';\nexport {findPropertyShapeById} from './shapes/nodeShapeData.js';\n\n// Live queries — see documentation/live-queries.md\nexport {LiveQueryStore, getLiveQueryStore, resetLiveQueryStore, publishChange, invalidate} from './live/LiveQueryStore.js';\nexport type {ChangeEvent} from './live/changes.js';\nexport type {\n LiveQuery,\n LiveState,\n LiveStatus,\n LiveListener,\n LiveQueryOptions,\n LiveQueryStoreOptions,\n} from './live/LiveQueryStore.js';\n"]}
@@ -16,4 +16,5 @@ export declare const coreOntology: {
16
16
  displayHidden: NodeReferenceValue;
17
17
  generated: NodeReferenceValue;
18
18
  generatedShape: NodeReferenceValue;
19
+ shapeHash: NodeReferenceValue;
19
20
  };
@@ -48,6 +48,10 @@ const generated = ns('generated');
48
48
  // single-owner constraint of each `contains` property). It is `contains`, so deleting the
49
49
  // shape deletes them, and sync writes them nested in the shape's own create.
50
50
  const generatedShape = ns('generatedShape');
51
+ // Content hash of everything shape sync writes for a NodeShape (the shape, its property shapes,
52
+ // lists, paths and generated shapes), stored on the NodeShape. A sync skips a shape whose stored
53
+ // hash equals the hash of what it would write.
54
+ const shapeHash = ns('shapeHash');
51
55
  export const coreOntology = {
52
56
  Package,
53
57
  ShapeClass,
@@ -63,5 +67,6 @@ export const coreOntology = {
63
67
  displayHidden,
64
68
  generated,
65
69
  generatedShape,
70
+ shapeHash,
66
71
  };
67
72
  //# sourceMappingURL=linked-core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"linked-core.js","sour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AmF;AACnF,oFAAoF;AACpF,mFAAmF;AACnF,0EAA0E;AAC1E,EAAE;AACF,mFAAmF;AACnF,kFAAkF;AAClF,qFAAqF;AACrF,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,aAAa,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAE1C,uFAAuF;AACvF,kGAAkG;AAClG,8EAA8E;AAC9E,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAElC,yFAAyF;AACzF,0FAA0F;AAC1F,6EAA6E;AAC7E,MAAM,cAAc,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO;IACP,UAAU;IACV,YAAY;IACZ,MAAM,EAAE,cAAc;IACtB,cAAc;IACd,UAAU;IACV,WAAW;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,aAAa;IACb,SAAS;IACT,cAAc;CACf,CAAC","sourcesContent":["import type {NodeReferenceValue} from '../utils/NodeReference.js';\nimport {createNameSpace} from '../utils/NameSpace.js';\nimport {Prefix} from '../utils/Prefix.js';\n\n// The @_linked/core framework vocabulary. First-party ontology IRIs follow Create Now\n// arch-02 §\"Public ontology namespace\":\n// https://linked.cm/ont/{ontologySlug}/{localName}\n// where ontologySlug defaults to the owning package's publicSlug (`@_linked/core` -> `core`)\n// and the prefix label equals the ontologySlug. Previously `https://linked.cm/ont/linked-core/`\n// (prefix `linked_core`), a leftover of a reverted slug derivation.\nexport const ns = createNameSpace('https://linked.cm/ont/core/');\nexport const _self: NodeReferenceValue = ns('');\n// @deprecated prefix alias: keeps `linked_core:` prefixed names resolving (to the NEW IRIs).\n// It does not make the old full IRIs match. Registered BEFORE `core` because the last add\n// wins for IRI -> prefix compaction, so output always uses `core:`.\nPrefix.add('linked_core', _self.id);\nPrefix.add('core', _self.id);\n\nconst Package = ns('Package');\nconst ShapeClass = ns('ShapeClass');\nconst definesShape = ns('definesShape');\nconst moduleProperty = ns('module');\nconst usesShapeClass = ns('usesShapeClass');\nconst editInline = ns('editInline');\nconst isExtending = ns('isExtending');\n\n// Containment / lifecycle vocabulary.\n// contains — property characteristic: the subject owns the value through this property\n// (composition); the owned walk follows it.\n// dependent — shape characteristic, deprecated: no effect (persisted for older shapes).\n// PathNode — class for SHACL property-path operator nodes (sh:inversePath/alternativePath/…).\nconst contains = ns('contains');\nconst dependent = ns('dependent');\nconst PathNode = ns('PathNode');\n\n// Display vocabulary. SHACL has `sh:order` and `sh:group`, which say how properties\n// are arranged; it has no way to say how *important* a property is, which is what a\n// renderer needs when it can only show one, three or six of them. `displayRank` is\n// that: a single linear rank per property, lower = more important, from which every\n// truncated context (\"show the top 3\") derives. `displayHidden` removes a property\n// from generic rendering without changing its cardinality or its meaning.\n//\n// Placement is deliberate (backlog-029): this is an ecosystem SHACL extension that\n// materializes onto the pure `sh:NodeShape` and therefore travels with an ejected\n// app — NOT the CN-proprietary `code:` vocab, which describes source-code structure.\nconst displayRank = ns('displayRank');\nconst displayHidden = ns('displayHidden');\n\n// Provenance marker: a NodeShape core generates at sync time from another shape's code\n// (today the `<propertyShape>.singleOwner` constraint derived from `contains`), rather than one a\n// developer declared. Catalog readers skip shapes with `core:generated true`.\nconst generated = ns('generated');\n\n// Ownership edge from a NodeShape to the shapes core generated from it at sync time (the\n// single-owner constraint of each `contains` property). It is `contains`, so deleting the\n// shape deletes them, and sync writes them nested in the shape's own create.\nconst generatedShape = ns('generatedShape');\n\nexport const coreOntology = {\n Package,\n ShapeClass,\n definesShape,\n module: moduleProperty,\n usesShapeClass,\n editInline,\n isExtending,\n contains,\n dependent,\n PathNode,\n displayRank,\n displayHidden,\n generated,\n generatedShape,\n};\n"]}
1
+ {"version":3,"file":"linked-core.js","sourceRoot":"","sources":["../../../src/ontologies/linked-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAA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,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,aAAa,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAE1C,uFAAuF;AACvF,kGAAkG;AAClG,8EAA8E;AAC9E,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAElC,yFAAyF;AACzF,0FAA0F;AAC1F,6EAA6E;AAC7E,MAAM,cAAc,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;AAE5C,gGAAgG;AAChG,iGAAiG;AACjG,+CAA+C;AAC/C,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO;IACP,UAAU;IACV,YAAY;IACZ,MAAM,EAAE,cAAc;IACtB,cAAc;IACd,UAAU;IACV,WAAW;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,aAAa;IACb,SAAS;IACT,cAAc;IACd,SAAS;CACV,CAAC","sourcesContent":["import type {NodeReferenceValue} from '../utils/NodeReference.js';\nimport {createNameSpace} from '../utils/NameSpace.js';\nimport {Prefix} from '../utils/Prefix.js';\n\n// The @_linked/core framework vocabulary. First-party ontology IRIs follow Create Now\n// arch-02 §\"Public ontology namespace\":\n// https://linked.cm/ont/{ontologySlug}/{localName}\n// where ontologySlug defaults to the owning package's publicSlug (`@_linked/core` -> `core`)\n// and the prefix label equals the ontologySlug. Previously `https://linked.cm/ont/linked-core/`\n// (prefix `linked_core`), a leftover of a reverted slug derivation.\nexport const ns = createNameSpace('https://linked.cm/ont/core/');\nexport const _self: NodeReferenceValue = ns('');\n// @deprecated prefix alias: keeps `linked_core:` prefixed names resolving (to the NEW IRIs).\n// It does not make the old full IRIs match. Registered BEFORE `core` because the last add\n// wins for IRI -> prefix compaction, so output always uses `core:`.\nPrefix.add('linked_core', _self.id);\nPrefix.add('core', _self.id);\n\nconst Package = ns('Package');\nconst ShapeClass = ns('ShapeClass');\nconst definesShape = ns('definesShape');\nconst moduleProperty = ns('module');\nconst usesShapeClass = ns('usesShapeClass');\nconst editInline = ns('editInline');\nconst isExtending = ns('isExtending');\n\n// Containment / lifecycle vocabulary.\n// contains — property characteristic: the subject owns the value through this property\n// (composition); the owned walk follows it.\n// dependent — shape characteristic, deprecated: no effect (persisted for older shapes).\n// PathNode — class for SHACL property-path operator nodes (sh:inversePath/alternativePath/…).\nconst contains = ns('contains');\nconst dependent = ns('dependent');\nconst PathNode = ns('PathNode');\n\n// Display vocabulary. SHACL has `sh:order` and `sh:group`, which say how properties\n// are arranged; it has no way to say how *important* a property is, which is what a\n// renderer needs when it can only show one, three or six of them. `displayRank` is\n// that: a single linear rank per property, lower = more important, from which every\n// truncated context (\"show the top 3\") derives. `displayHidden` removes a property\n// from generic rendering without changing its cardinality or its meaning.\n//\n// Placement is deliberate (backlog-029): this is an ecosystem SHACL extension that\n// materializes onto the pure `sh:NodeShape` and therefore travels with an ejected\n// app — NOT the CN-proprietary `code:` vocab, which describes source-code structure.\nconst displayRank = ns('displayRank');\nconst displayHidden = ns('displayHidden');\n\n// Provenance marker: a NodeShape core generates at sync time from another shape's code\n// (today the `<propertyShape>.singleOwner` constraint derived from `contains`), rather than one a\n// developer declared. Catalog readers skip shapes with `core:generated true`.\nconst generated = ns('generated');\n\n// Ownership edge from a NodeShape to the shapes core generated from it at sync time (the\n// single-owner constraint of each `contains` property). It is `contains`, so deleting the\n// shape deletes them, and sync writes them nested in the shape's own create.\nconst generatedShape = ns('generatedShape');\n\n// Content hash of everything shape sync writes for a NodeShape (the shape, its property shapes,\n// lists, paths and generated shapes), stored on the NodeShape. A sync skips a shape whose stored\n// hash equals the hash of what it would write.\nconst shapeHash = ns('shapeHash');\n\nexport const coreOntology = {\n Package,\n ShapeClass,\n definesShape,\n module: moduleProperty,\n usesShapeClass,\n editInline,\n isExtending,\n contains,\n dependent,\n PathNode,\n displayRank,\n displayHidden,\n generated,\n generatedShape,\n shapeHash,\n};\n"]}
@@ -7,6 +7,33 @@ import type { IDataset } from '../interfaces/IDataset.js';
7
7
  * @internal Exported for tests only — not part of the public API.
8
8
  */
9
9
  export declare function buildPropertyShapeData(ps: PropertyShapeData, shapeIri: string): Record<string, unknown>;
10
+ /**
11
+ * Version of the {@link shapeSyncHash} input. Bump it whenever core changes the SHACL it writes
12
+ * for a shape (a serialization change that the create data itself does not show), so every stored
13
+ * shape is rewritten once by the next sync. Without a bump, stores keep the old triples: their
14
+ * stored hashes still match, so the sync skips them.
15
+ *
16
+ * Enforced by `shape-sync-output-equivalence.test.ts`: its golden SHACL output is recorded in
17
+ * `SHAPE_HASH_LEDGER` with the version it was generated for, and regenerating the golden without
18
+ * bumping this constant fails that test. To change the output: bump this by one, update the
19
+ * golden, and append `{version, goldenDigest}` to the ledger (never edit an existing entry).
20
+ *
21
+ * @internal Exported for tests only — not part of the public API.
22
+ */
23
+ export declare const SHAPE_HASH_VERSION = 1;
24
+ /**
25
+ * The content hash shape sync stores on a NodeShape as `core:shapeHash`: SHA-256 (hex) of the
26
+ * canonical form of the shape IRI and the exact create data the sync writes for it — the
27
+ * NodeShape, its flattened own + inherited property shapes, their `sh:in` lists and paths, and
28
+ * the generated single-owner shapes it owns (whose owner classes come from the registered
29
+ * sub-shapes, so registering a new sub-shape changes the hash of the declaring shape).
30
+ *
31
+ * Deterministic across processes, runtimes and Node versions: no blank-node labels, no object key
32
+ * order, no array order (see {@link canonicalize}).
33
+ *
34
+ * @internal Exported for tests only — not part of the public API.
35
+ */
36
+ export declare function shapeSyncHash(data: Record<string, unknown>, shapeIri: string): string;
10
37
  /** Options controlling how {@link syncShapes} treats store shapes that are not in code. */
11
38
  export interface SyncShapesOptions {
12
39
  /**
@@ -27,6 +54,18 @@ export interface SyncShapesOptions {
27
54
  * `'all'` and `'ownedNamespaces'` are destructive and must be requested explicitly.
28
55
  */
29
56
  orphanScope?: 'all' | 'ownedNamespaces' | 'none';
57
+ /**
58
+ * Rewrite every code shape, even one whose stored `core:shapeHash` matches. Default `false`:
59
+ * a shape is rewritten only when its hash differs or is missing. Use it to repair a shape
60
+ * whose stored subtree was edited or partly deleted outside shape sync (the hash describes
61
+ * what sync last wrote, not what is in the store now).
62
+ */
63
+ force?: boolean;
64
+ }
65
+ /** Options for {@link syncShape}. */
66
+ export interface SyncShapeOptions {
67
+ /** Rewrite the shape even when its stored `core:shapeHash` matches. See {@link SyncShapesOptions.force}. */
68
+ force?: boolean;
30
69
  }
31
70
  /**
32
71
  * Plan an idempotent sync of all code-registered (non-framework) NodeShapes into the store as
@@ -39,6 +78,15 @@ export interface SyncShapesOptions {
39
78
  * Each in-code shape's thunk runs `delete → create` in order (the delete cascade-cleans the old
40
79
  * property shapes / list / path subtrees via the containment cascade, the create rebuilds them).
41
80
  *
81
+ * **Unchanged shapes are skipped.** The create stores a content hash of everything it writes for
82
+ * the shape on the NodeShape (`core:shapeHash`, see {@link shapeSyncHash}). The plan reads the
83
+ * stored hashes of all code shapes in one select and builds a thunk only for a shape whose hash
84
+ * is missing (never synced, or synced before hashes existed) or differs. Syncing an unchanged
85
+ * app therefore returns no write thunks, and the length of the plan is the number of shapes
86
+ * actually written plus the pruned orphans. The hash records what sync last wrote, not what the
87
+ * store holds now: a subtree edited or partly deleted by another writer while the NodeShape and
88
+ * its hash survive is not detected. `options.force` rewrites every code shape.
89
+ *
42
90
  * **Shapes in the store but not registered in this process are left alone by default**
43
91
  * (`orphanScope: 'none'`). The registry only holds what this process happened to import, and
44
92
  * that is routinely a subset of what the dataset holds: shapes are deep-importable one file at a
@@ -55,8 +103,8 @@ export interface SyncShapesOptions {
55
103
  * with `'none'` no read is made.
56
104
  *
57
105
  * `ds` (optional) targets an explicit dataset instead of the global router. It is a **plan-time**
58
- * parameter: it feeds both the orphan-detection read (so orphans are computed against the same
59
- * store they'll be pruned from) and every delete/create thunk. Omitted → the global router;
106
+ * parameter: it feeds the stored-hash read and the orphan-detection read (so both are computed
107
+ * against the same store they'll be written to) and every delete/create thunk. Omitted → the global router;
60
108
  * the returned thunks stay nullary either way.
61
109
  */
62
110
  export declare function syncShapes(ds?: IDataset, options?: SyncShapesOptions): Promise<Array<() => Promise<void>>>;
@@ -71,9 +119,12 @@ export declare function syncShapes(ds?: IDataset, options?: SyncShapesOptions):
71
119
  * its registered class via `getShapeClass`; the shape must be code-registered.
72
120
  * @param ds optional explicit dataset to materialize into (a store or a router) — both the delete
73
121
  * and the create run against it instead of the global router. Omitted → global behavior.
122
+ * @param options `force: true` rewrites the shape even when its stored hash matches.
74
123
  * @returns a single unexecuted thunk (consistent with {@link syncShapes}), so callers can batch
75
124
  * several together — e.g. a shape plus its referenced object-property shapes:
76
125
  * `await Promise.all([syncShape(Person), syncShape(Address)].map((run) => run()))`.
126
+ * Unless `force` is set, the thunk first reads the shape's stored `core:shapeHash` and writes
127
+ * nothing when it equals the hash of what it would write (see {@link syncShapes}).
77
128
  * @throws if `target` is a framework/meta shape, is not registered, or has no `.shape`.
78
129
  */
79
- export declare function syncShape(target: typeof Shape | string, ds?: IDataset): () => Promise<void>;
130
+ export declare function syncShape(target: typeof Shape | string, ds?: IDataset, options?: SyncShapeOptions): () => Promise<void>;
@@ -19,6 +19,8 @@ import { DeleteBuilder } from '../queries/DeleteBuilder.js';
19
19
  import { rdfList } from './List.js';
20
20
  import { serializePathToNodeData } from './serializePathToNodeData.js';
21
21
  import { buildSingleOwnerConstraints } from './singleOwnerConstraint.js';
22
+ import { QueryBuilder } from '../queries/QueryBuilder.js';
23
+ import { sha256Hex } from '../utils/sha256.js';
22
24
  /**
23
25
  * The npm scope of framework shapes (NodeShape/PropertyShape/List/PathNode/Shape) that
24
26
  * describe the meta-model itself and must never be synced as user data.
@@ -129,10 +131,106 @@ function buildNodeShapeData(nodeShape, shapeIri) {
129
131
  }
130
132
  return d;
131
133
  }
134
+ /**
135
+ * Version of the {@link shapeSyncHash} input. Bump it whenever core changes the SHACL it writes
136
+ * for a shape (a serialization change that the create data itself does not show), so every stored
137
+ * shape is rewritten once by the next sync. Without a bump, stores keep the old triples: their
138
+ * stored hashes still match, so the sync skips them.
139
+ *
140
+ * Enforced by `shape-sync-output-equivalence.test.ts`: its golden SHACL output is recorded in
141
+ * `SHAPE_HASH_LEDGER` with the version it was generated for, and regenerating the golden without
142
+ * bumping this constant fails that test. To change the output: bump this by one, update the
143
+ * golden, and append `{version, goldenDigest}` to the ledger (never edit an existing entry).
144
+ *
145
+ * @internal Exported for tests only — not part of the public API.
146
+ */
147
+ export const SHAPE_HASH_VERSION = 1;
148
+ /**
149
+ * A canonical string for create-pipeline data: equal for equal data, independent of object key
150
+ * order and of the order of array values.
151
+ *
152
+ * Arrays are sorted because in create data an array is always a multi-valued property (a set of
153
+ * RDF values: `properties`, `generatedShapes`, `targetObjectsOf`, …). Ordered `rdf:List`s
154
+ * (`sh:in`, sequence and alternative paths, `sh:or`) are nested `first`/`rest` objects, so their
155
+ * order is kept by the structure. A shape class value (`shape: List`) is written as its NodeShape
156
+ * IRI. Values without ids (blank nodes once written) are compared by structure, so no blank-node
157
+ * label is ever part of the input.
158
+ */
159
+ function canonicalize(value) {
160
+ var _a, _b;
161
+ if (value === null || value === undefined)
162
+ return 'null';
163
+ switch (typeof value) {
164
+ case 'string':
165
+ return JSON.stringify(value);
166
+ case 'number':
167
+ return `n:${Object.is(value, -0) ? '0' : String(value)}`;
168
+ case 'boolean':
169
+ return `b:${value}`;
170
+ case 'bigint':
171
+ return `i:${value.toString()}`;
172
+ case 'function': {
173
+ const shapeId = (_a = value.shape) === null || _a === void 0 ? void 0 : _a.id;
174
+ return `c:${JSON.stringify((_b = shapeId !== null && shapeId !== void 0 ? shapeId : value.name) !== null && _b !== void 0 ? _b : '')}`;
175
+ }
176
+ }
177
+ if (Array.isArray(value)) {
178
+ return `[${value.map(canonicalize).sort().join(',')}]`;
179
+ }
180
+ if (value instanceof Date)
181
+ return `d:${value.toISOString()}`;
182
+ if (value instanceof RegExp)
183
+ return `r:${JSON.stringify(value.source)}/${value.flags}`;
184
+ const record = value;
185
+ const keys = Object.keys(record)
186
+ .filter((k) => record[k] !== undefined)
187
+ .sort();
188
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(record[k])}`).join(',')}}`;
189
+ }
190
+ /**
191
+ * The content hash shape sync stores on a NodeShape as `core:shapeHash`: SHA-256 (hex) of the
192
+ * canonical form of the shape IRI and the exact create data the sync writes for it — the
193
+ * NodeShape, its flattened own + inherited property shapes, their `sh:in` lists and paths, and
194
+ * the generated single-owner shapes it owns (whose owner classes come from the registered
195
+ * sub-shapes, so registering a new sub-shape changes the hash of the declaring shape).
196
+ *
197
+ * Deterministic across processes, runtimes and Node versions: no blank-node labels, no object key
198
+ * order, no array order (see {@link canonicalize}).
199
+ *
200
+ * @internal Exported for tests only — not part of the public API.
201
+ */
202
+ export function shapeSyncHash(data, shapeIri) {
203
+ return sha256Hex(`linked-shape-sync/${SHAPE_HASH_VERSION}\n${canonicalize({ iri: shapeIri, data })}`);
204
+ }
205
+ /** The create data and its content hash for one shape, as the sync writes it. */
206
+ function buildSyncData(nodeShape, iri) {
207
+ const data = buildNodeShapeData(nodeShape, iri);
208
+ return { data, hash: shapeSyncHash(data, iri) };
209
+ }
210
+ /**
211
+ * The stored `core:shapeHash` of each of `iris` that exists as a NodeShape, in one select. A shape
212
+ * that is absent, or stored without a hash (written before hashes existed), is missing from the
213
+ * map. `ds` targets an explicit dataset, as for the writes.
214
+ */
215
+ function readStoredHashes(iris, ds) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ var _a;
218
+ const stored = new Map();
219
+ if (iris.length === 0)
220
+ return stored;
221
+ const rows = (_a = (yield QueryBuilder.from(NodeShape).select(['shapeHash']).forAll(iris).exec(ds))) !== null && _a !== void 0 ? _a : [];
222
+ for (const row of rows) {
223
+ if (row && typeof row.shapeHash === 'string')
224
+ stored.set(row.id, row.shapeHash);
225
+ }
226
+ return stored;
227
+ });
228
+ }
132
229
  /**
133
230
  * The per-shape `delete → create` thunk shared by `syncShapes()` and `syncShape()`: exactly two
134
231
  * requests. The delete cascade-cleans the shape's old property-shape / list / path subtrees; the
135
- * create rebuilds them.
232
+ * create rebuilds them, and stores the content hash (`core:shapeHash`) of what it wrote on the
233
+ * NodeShape so a later sync can skip the shape while it is unchanged.
136
234
  *
137
235
  * The single-owner constraints generated from the shape's own `contains` properties
138
236
  * (`${iri}/${label}.singleOwner`, see `singleOwnerConstraint.ts`) are owned by the shape through
@@ -146,12 +244,16 @@ function buildNodeShapeData(nodeShape, shapeIri) {
146
244
  * global router. Omitted → today's global behavior.
147
245
  */
148
246
  function buildSyncThunk(nodeShape, iri, ds) {
149
- return () => __awaiter(this, void 0, void 0, function* () {
150
- // Build the data fresh on each invocation, so every run writes from the current
151
- // shape metadata.
152
- const data = buildNodeShapeData(nodeShape, iri);
247
+ // `writeShape` builds the data fresh on each invocation, so every run writes from the current
248
+ // shape metadata, and the hash stored with it always describes what was written.
249
+ return () => writeShape(nodeShape, iri, ds);
250
+ }
251
+ /** Delete (cascade) then create one shape, storing the hash of the written data. */
252
+ function writeShape(nodeShape, iri, ds) {
253
+ return __awaiter(this, void 0, void 0, function* () {
254
+ const { data, hash } = buildSyncData(nodeShape, iri);
153
255
  yield DeleteBuilder.from(NodeShape, { id: iri }).exec(ds);
154
- yield NodeShape.create(data).withId(iri).exec(ds);
256
+ yield NodeShape.create(Object.assign(Object.assign({}, data), { shapeHash: hash })).withId(iri).exec(ds);
155
257
  });
156
258
  }
157
259
  /** The generated single-owner shape IRIs a code shape writes. */
@@ -182,6 +284,15 @@ function shapeNamespace(iri) {
182
284
  * Each in-code shape's thunk runs `delete → create` in order (the delete cascade-cleans the old
183
285
  * property shapes / list / path subtrees via the containment cascade, the create rebuilds them).
184
286
  *
287
+ * **Unchanged shapes are skipped.** The create stores a content hash of everything it writes for
288
+ * the shape on the NodeShape (`core:shapeHash`, see {@link shapeSyncHash}). The plan reads the
289
+ * stored hashes of all code shapes in one select and builds a thunk only for a shape whose hash
290
+ * is missing (never synced, or synced before hashes existed) or differs. Syncing an unchanged
291
+ * app therefore returns no write thunks, and the length of the plan is the number of shapes
292
+ * actually written plus the pruned orphans. The hash records what sync last wrote, not what the
293
+ * store holds now: a subtree edited or partly deleted by another writer while the NodeShape and
294
+ * its hash survive is not detected. `options.force` rewrites every code shape.
295
+ *
185
296
  * **Shapes in the store but not registered in this process are left alone by default**
186
297
  * (`orphanScope: 'none'`). The registry only holds what this process happened to import, and
187
298
  * that is routinely a subset of what the dataset holds: shapes are deep-importable one file at a
@@ -198,8 +309,8 @@ function shapeNamespace(iri) {
198
309
  * with `'none'` no read is made.
199
310
  *
200
311
  * `ds` (optional) targets an explicit dataset instead of the global router. It is a **plan-time**
201
- * parameter: it feeds both the orphan-detection read (so orphans are computed against the same
202
- * store they'll be pruned from) and every delete/create thunk. Omitted → the global router;
312
+ * parameter: it feeds the stored-hash read and the orphan-detection read (so both are computed
313
+ * against the same store they'll be written to) and every delete/create thunk. Omitted → the global router;
203
314
  * the returned thunks stay nullary either way.
204
315
  */
205
316
  export function syncShapes(ds, options) {
@@ -233,8 +344,15 @@ export function syncShapes(ds, options) {
233
344
  // Namespaces this process actually writes — the ownership scope for `'ownedNamespaces'` pruning.
234
345
  const ownedNamespaces = new Set(userShapes.map((s) => shapeNamespace(s.iri)));
235
346
  const thunks = [];
236
- // 2. Per in-code shape: delete (cascade) then recreate.
347
+ // 2. Per in-code shape whose stored content hash is missing or differs: delete (cascade) then
348
+ // recreate. An unchanged shape gets no thunk, so syncing an unchanged app writes nothing.
349
+ // The stored hashes are read in one select, against the same `ds` the thunks target.
350
+ const storedHashes = (options === null || options === void 0 ? void 0 : options.force)
351
+ ? new Map()
352
+ : yield readStoredHashes(userShapes.map((s) => s.iri), ds);
237
353
  for (const { iri, nodeShape } of userShapes) {
354
+ if (!(options === null || options === void 0 ? void 0 : options.force) && storedHashes.get(iri) === buildSyncData(nodeShape, iri).hash)
355
+ continue;
238
356
  thunks.push(buildSyncThunk(nodeShape, iri, ds));
239
357
  }
240
358
  // 3. Orphan sweep (unless disabled). Identity-read existing NodeShape IRIs (ids only). Must hit
@@ -267,12 +385,15 @@ export function syncShapes(ds, options) {
267
385
  * its registered class via `getShapeClass`; the shape must be code-registered.
268
386
  * @param ds optional explicit dataset to materialize into (a store or a router) — both the delete
269
387
  * and the create run against it instead of the global router. Omitted → global behavior.
388
+ * @param options `force: true` rewrites the shape even when its stored hash matches.
270
389
  * @returns a single unexecuted thunk (consistent with {@link syncShapes}), so callers can batch
271
390
  * several together — e.g. a shape plus its referenced object-property shapes:
272
391
  * `await Promise.all([syncShape(Person), syncShape(Address)].map((run) => run()))`.
392
+ * Unless `force` is set, the thunk first reads the shape's stored `core:shapeHash` and writes
393
+ * nothing when it equals the hash of what it would write (see {@link syncShapes}).
273
394
  * @throws if `target` is a framework/meta shape, is not registered, or has no `.shape`.
274
395
  */
275
- export function syncShape(target, ds) {
396
+ export function syncShape(target, ds, options) {
276
397
  // Normalize target → its registered shape class.
277
398
  const cls = typeof target === 'string' ? getShapeClass(target) : target;
278
399
  if (typeof target === 'string' && !cls) {
@@ -292,6 +413,13 @@ export function syncShape(target, ds) {
292
413
  throw new Error(`syncShape: refusing to sync framework/meta shape ${iri}`);
293
414
  }
294
415
  assertNoGeneratedIriCollision(nodeShape, iri, (id) => !!getShapeClass(id));
295
- return buildSyncThunk(nodeShape, iri, ds);
416
+ if (options === null || options === void 0 ? void 0 : options.force)
417
+ return buildSyncThunk(nodeShape, iri, ds);
418
+ return () => __awaiter(this, void 0, void 0, function* () {
419
+ const stored = yield readStoredHashes([iri], ds);
420
+ if (stored.get(iri) === buildSyncData(nodeShape, iri).hash)
421
+ return;
422
+ yield writeShape(nodeShape, iri, ds);
423
+ });
296
424
  }
297
425
  //# sourceMappingURL=syncShapes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"syncShapes.js","sourceRoot":"","sources":["../../../src/shapes/syncShapes.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAC,kBAAkB,EAAE,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K,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAAC;IAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,OAAO,MAAM,KAAK,QAAQ;YACxB,CAAC,CAAC,0CAA0C,MAAM,EAAE;YACpD,CAAC,CAAC,6CAA6C,CAClD,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,CAAC;IAEzB,+FAA+F;IAC/F,uDAAuD;IACvD,MAAM,GAAG,GAAI,GAA8B,CAAC,WAAW,CAAC;IACxD,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,iBAAiB,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,oDAAoD,GAAG,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,6BAA6B,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,OAAO,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5C,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 */\nimport {getAllShapeClasses, getShapeClass} from '../utils/ShapeClass.js';\nimport {NodeShape} from './SHACL.js';\nimport {\n getUniquePropertyShapes,\n type NodeShapeData,\n type PropertyShapeData,\n} from './nodeShapeData.js';\nimport {Shape} from './Shape.js';\nimport {DeleteBuilder} from '../queries/DeleteBuilder.js';\nimport type {IDataset} from '../interfaces/IDataset.js';\nimport {rdfList} from './List.js';\nimport {serializePathToNodeData} from './serializePathToNodeData.js';\nimport {buildSingleOwnerConstraints} from './singleOwnerConstraint.js';\n\n/**\n * The npm scope of framework shapes (NodeShape/PropertyShape/List/PathNode/Shape) that\n * describe the meta-model itself and must never be synced as user data.\n */\nconst FRAMEWORK_PACKAGE = '@_linked/core';\n\n/**\n * Build the create-pipeline data object for a single PropertyShape (flattened under shapeIri).\n *\n * @internal Exported for tests only — not part of the public API.\n */\nexport function buildPropertyShapeData(ps: PropertyShapeData, shapeIri: string): Record<string, unknown> {\n const psIri = `${shapeIri}/${ps.label}`;\n const d: Record<string, unknown> = {\n __id: psIri,\n path: serializePathToNodeData(ps.path),\n };\n // `rdfs:label` — the DSL label, i.e. the accessor name the property is reached\n // by in code (`person.memberships`). It is NOT `sh:name`, written below, which\n // is a human-readable display string.\n //\n // Without this the label is only ever implied by `psIri`, and a reader has to\n // re-derive one from the path's local part. That works right up until the two\n // differ — `@_linked/org` declares `memberships` on the path `org:hasMembership`\n // — at which point the catalog reports `hasMembership`, the query proxy indexes\n // the shape with it, and the class (which only knows `memberships`) throws.\n // Readers already prefer a stored label and fall back to the path, so writing it\n // is the whole fix; old catalogs keep working via that fallback.\n if (ps.label) d.label = ps.label;\n if (ps.nodeKind) d.nodeKind = ps.nodeKind;\n if (ps.datatype) d.datatype = ps.datatype;\n if (typeof ps.minCount === 'number') d.minCount = ps.minCount;\n if (typeof ps.maxCount === 'number') d.maxCount = ps.maxCount;\n if (ps.name) d.name = ps.name;\n if (ps.description) d.description = ps.description;\n if (typeof ps.order === 'number') d.order = ps.order;\n if (ps.group) d.group = ps.group;\n if (typeof ps.displayRank === 'number') d.displayRank = ps.displayRank;\n if (ps.displayHidden !== undefined) d.displayHidden = ps.displayHidden;\n if (ps.class) d.class = ps.class;\n if (ps.in) d.in = rdfList(ps.in, {base: `${psIri}/in`});\n if (ps.equalsConstraint) d.equalsConstraint = ps.equalsConstraint;\n if (ps.disjoint) d.disjoint = ps.disjoint;\n if (ps.lessThan) d.lessThan = ps.lessThan;\n if (ps.lessThanOrEquals) d.lessThanOrEquals = ps.lessThanOrEquals;\n if (ps.minInclusive !== undefined) d.minInclusive = ps.minInclusive;\n if (ps.maxInclusive !== undefined) d.maxInclusive = ps.maxInclusive;\n if (ps.minExclusive !== undefined) d.minExclusive = ps.minExclusive;\n if (ps.maxExclusive !== undefined) d.maxExclusive = ps.maxExclusive;\n if (typeof ps.minLength === 'number') d.minLength = ps.minLength;\n if (typeof ps.maxLength === 'number') d.maxLength = ps.maxLength;\n // sh:pattern is serialized as its regex source string.\n if (ps.pattern) d.pattern = ps.pattern.source;\n if (ps.hasValueConstraint !== undefined) d.hasValue = ps.hasValueConstraint;\n if (ps.valueShape) d.valueShape = ps.valueShape;\n if (ps.contains) d.contains = true;\n return d;\n}\n\n/** Build the create-pipeline data object for a NodeShape and its (flattened) property shapes. */\nfunction buildNodeShapeData(nodeShape: NodeShapeData, shapeIri: string): Record<string, unknown> {\n const d: Record<string, unknown> = {};\n if (nodeShape.targetClass) d.targetClass = nodeShape.targetClass;\n if (nodeShape.description) d.description = nodeShape.description;\n if (nodeShape.extends) d.extends = nodeShape.extends;\n if (nodeShape.dependent) d.dependent = true;\n if (nodeShape.closed !== undefined) d.closed = nodeShape.closed;\n if (nodeShape.ignoredProperties && nodeShape.ignoredProperties.length) {\n d.ignoredProperties = nodeShape.ignoredProperties;\n }\n // Flatten: emit own + inherited property shapes (deduped by label) under this shape.\n d.properties = getUniquePropertyShapes(nodeShape).map((ps) =>\n buildPropertyShapeData(ps, shapeIri),\n );\n // The single-owner constraints of the shape's own `contains` properties, owned through\n // `core:generatedShape` and written nested in the same create with their fixed IRIs.\n const generated = buildSingleOwnerConstraints(nodeShape, shapeIri);\n if (generated.length > 0) {\n d.generatedShapes = generated.map(({iri, data}) => ({__id: iri, ...data}));\n }\n return d;\n}\n\n/**\n * The per-shape `delete → create` thunk shared by `syncShapes()` and `syncShape()`: exactly two\n * requests. The delete cascade-cleans the shape's old property-shape / list / path subtrees; the\n * create rebuilds them.\n *\n * The single-owner constraints generated from the shape's own `contains` properties\n * (`${iri}/${label}.singleOwner`, see `singleOwnerConstraint.ts`) are owned by the shape through\n * `core:generatedShape` (a `contains` property with value shape NodeShape). The delete removes\n * them and their property shapes through the owned walk, and their blank path and qualified-shape\n * nodes through the blank-node cascade; the create writes the current ones nested, in the same request\n * as the shape. A removed or renamed accessor therefore loses its constraint on the next sync,\n * and a NodeShape the shape does not own is never touched.\n *\n * `ds` (optional) targets an explicit dataset — both requests run against it instead of the\n * global router. Omitted → today's global behavior.\n */\nfunction buildSyncThunk(nodeShape: NodeShapeData, iri: string, ds?: IDataset): () => Promise<void> {\n return async () => {\n // Build the data fresh on each invocation, so every run writes from the current\n // shape metadata.\n const data = buildNodeShapeData(nodeShape, iri);\n await DeleteBuilder.from(NodeShape, {id: iri}).exec(ds);\n await (NodeShape.create(data as never).withId(iri) as unknown as {\n exec: (target?: IDataset) => Promise<unknown>;\n }).exec(ds);\n };\n}\n\n/** The generated single-owner shape IRIs a code shape writes. */\nfunction generatedIrisOf(nodeShape: NodeShapeData, iri: string): string[] {\n return buildSingleOwnerConstraints(nodeShape, iri).map((c) => c.iri);\n}\n\n/** Throw when a registered shape IRI equals one of a shape's generated single-owner IRIs. */\nfunction assertNoGeneratedIriCollision(\n nodeShape: NodeShapeData,\n iri: string,\n isRegistered: (iri: string) => boolean,\n): void {\n for (const generated of generatedIrisOf(nodeShape, iri)) {\n if (isRegistered(generated)) {\n throw new Error(`Shape IRI ${generated} collides with a generated single-owner shape`);\n }\n }\n}\n\n/** Options controlling how {@link syncShapes} treats store shapes that are not in code. */\nexport interface SyncShapesOptions {\n /**\n * How to treat NodeShapes present in the store but not in the current process's code:\n * - `'none'` (default) — never prune; purely additive (delete→recreate the code shapes, touch\n * nothing else). The only mode that is safe when the process has loaded a *subset* of the\n * shapes in the dataset, or when the dataset has more than one writer.\n * - `'all'` — prune every store-only shape as an orphan. Only correct when this process has\n * loaded **every** shape the dataset should hold and is its **only** writer; \"not registered\n * here\" is then taken to mean \"deleted from code\".\n * - `'ownedNamespaces'` — prune a store-only shape ONLY if its IRI falls within a namespace\n * this process actually writes (the package-namespace of one of its code-registered shapes,\n * i.e. the IRI prefix up to the last `/` or `#`). Protects other writers' packages (arch-04:\n * one app-data dataset, several writers), but NOT the rest of a package the process only\n * partially loaded — the namespace is the whole package, so a deep import of one shape file\n * still claims all of it.\n *\n * `'all'` and `'ownedNamespaces'` are destructive and must be requested explicitly.\n */\n orphanScope?: 'all' | 'ownedNamespaces' | 'none';\n}\n\n/** The owning namespace of a shape IRI — everything up to and including the last `/` or `#`. */\nfunction shapeNamespace(iri: string): string {\n const cut = Math.max(iri.lastIndexOf('/'), iri.lastIndexOf('#'));\n return cut >= 0 ? iri.slice(0, cut + 1) : iri;\n}\n\n/**\n * Plan an idempotent sync of all code-registered (non-framework) NodeShapes into the store as\n * SHACL data — the forward (code → graph) materialization of arch-05 \"code is canonical\".\n *\n * Returns built-but-unexecuted thunks; the caller controls execution and batching:\n * ```ts\n * await Promise.all((await syncShapes()).map((run) => run()));\n * ```\n * Each in-code shape's thunk runs `delete → create` in order (the delete cascade-cleans the old\n * property shapes / list / path subtrees via the containment cascade, the create rebuilds them).\n *\n * **Shapes in the store but not registered in this process are left alone by default**\n * (`orphanScope: 'none'`). The registry only holds what this process happened to import, and\n * that is routinely a subset of what the dataset holds: shapes are deep-importable one file at a\n * time, and an app-data dataset also holds shapes other writers materialized (CN's\n * `bindShape` / `enableCapability`). \"Not registered here\" therefore does not mean \"deleted from\n * code\". Measured against a dataset holding the 36 `@_linked/schema` shapes: a process that\n * imported only `@_linked/schema/shapes/Thing` (11 shapes registered) deleted the other 25 under\n * both `'all'` and `'ownedNamespaces'`, and a process that imported no shapes deleted all 36.\n *\n * Pruning is opt-in via `options.orphanScope` (see {@link SyncShapesOptions}): pass `'all'` only\n * from a process that has loaded every shape the dataset should hold and is its sole writer, and\n * `'ownedNamespaces'` only when it has loaded every shape of each package it registers. Pruned\n * orphans are deleted with their owned subtree. Pruning reads the existing shape IRIs first;\n * with `'none'` no read is made.\n *\n * `ds` (optional) targets an explicit dataset instead of the global router. It is a **plan-time**\n * parameter: it feeds both the orphan-detection read (so orphans are computed against the same\n * store they'll be pruned from) and every delete/create thunk. Omitted → the global router;\n * the returned thunks stay nullary either way.\n */\nexport async function syncShapes(\n ds?: IDataset,\n options?: SyncShapesOptions,\n): Promise<Array<() => Promise<void>>> {\n const orphanScope = options?.orphanScope ?? 'none';\n // 1. Enumerate code-registered user shapes (exclude framework/meta shapes).\n const userShapes: Array<{iri: string; nodeShape: NodeShapeData}> = [];\n for (const [iri, shapeClass] of getAllShapeClasses()) {\n if (!shapeClass?.shape) continue;\n const pkg = (shapeClass as {packageName?: string}).packageName;\n // Skip framework/meta shapes: the core package, and the base `Shape` which is registered\n // directly (no applyLinkedShape) and therefore carries no packageName.\n if (!pkg || pkg === FRAMEWORK_PACKAGE) continue;\n userShapes.push({iri, nodeShape: shapeClass.shape});\n }\n const localShapeIris = new Set(userShapes.map((s) => s.iri));\n for (const {iri, nodeShape} of userShapes) {\n assertNoGeneratedIriCollision(nodeShape, iri, (id) => localShapeIris.has(id));\n }\n // The generated single-owner shapes of in-code shapes are written by the same thunks, so they\n // are never orphans. Derived in memory from the same function that builds them; a stale\n // generated shape (removed accessor or shape) is not protected and goes with its owner's\n // delete, through the `core:generatedShape` cascade.\n for (const {iri, nodeShape} of userShapes) {\n for (const generated of generatedIrisOf(nodeShape, iri)) localShapeIris.add(generated);\n }\n // Namespaces this process actually writes — the ownership scope for `'ownedNamespaces'` pruning.\n const ownedNamespaces = new Set(userShapes.map((s) => shapeNamespace(s.iri)));\n\n const thunks: Array<() => Promise<void>> = [];\n\n // 2. Per in-code shape: delete (cascade) then recreate.\n for (const {iri, nodeShape} of userShapes) {\n thunks.push(buildSyncThunk(nodeShape, iri, ds));\n }\n\n // 3. Orphan sweep (unless disabled). Identity-read existing NodeShape IRIs (ids only). Must hit\n // the same `ds` the thunks target, or orphans get computed against the wrong store.\n if (orphanScope !== 'none') {\n const existingRows = (await (NodeShape as unknown as {\n select: () => {exec: (target?: IDataset) => Promise<Array<{id: string}>>};\n }).select().exec(ds)) as Array<{id: string}>;\n\n // Orphan shapes (in store, not in code) → delete (cascade cleans their owned subtree). In\n // `'ownedNamespaces'` mode, only shapes within a namespace this process writes are eligible —\n // other writers' shapes (different package namespace) are left untouched.\n for (const {id: iri} of existingRows) {\n if (localShapeIris.has(iri)) continue;\n if (orphanScope === 'ownedNamespaces' && !ownedNamespaces.has(shapeNamespace(iri))) {\n continue;\n }\n thunks.push(() =>\n (DeleteBuilder.from(NodeShape, {id: iri}).exec(ds) as Promise<unknown>).then(\n () => undefined,\n ),\n );\n }\n }\n\n return thunks;\n}\n\n/**\n * Plan an idempotent sync of ONE code-registered NodeShape into the store as SHACL data.\n *\n * Scoped counterpart to {@link syncShapes}: materializes a single shape (delete → recreate, so the\n * delete cascade-cleans the old property-shape / list / path subtrees and the create rebuilds them)\n * and does NOT run the store-wide orphan sweep — other shapes in the store are untouched.\n *\n * @param target a shape class (e.g. `Person`) or its NodeShape IRI string. An IRI is resolved to\n * its registered class via `getShapeClass`; the shape must be code-registered.\n * @param ds optional explicit dataset to materialize into (a store or a router) — both the delete\n * and the create run against it instead of the global router. Omitted → global behavior.\n * @returns a single unexecuted thunk (consistent with {@link syncShapes}), so callers can batch\n * several together — e.g. a shape plus its referenced object-property shapes:\n * `await Promise.all([syncShape(Person), syncShape(Address)].map((run) => run()))`.\n * @throws if `target` is a framework/meta shape, is not registered, or has no `.shape`.\n */\nexport function syncShape(target: typeof Shape | string, ds?: IDataset): () => Promise<void> {\n // Normalize target → its registered shape class.\n const cls =\n typeof target === 'string' ? getShapeClass(target) : (target as typeof Shape);\n if (typeof target === 'string' && !cls) {\n throw new Error(`syncShape: no registered shape for IRI ${target}`);\n }\n const nodeShape = cls?.shape;\n if (!nodeShape) {\n throw new Error(\n typeof target === 'string'\n ? `syncShape: no registered shape for IRI ${target}`\n : `syncShape: shape class has no static .shape`,\n );\n }\n const iri = nodeShape.id;\n\n // Never materialize a framework/meta shape as user data — same invariant syncShapes() enforces\n // by skipping (the base Shape carries no packageName).\n const pkg = (cls as {packageName?: string}).packageName;\n if (!pkg || pkg === FRAMEWORK_PACKAGE) {\n throw new Error(`syncShape: refusing to sync framework/meta shape ${iri}`);\n }\n\n assertNoGeneratedIriCollision(nodeShape, iri, (id) => !!getShapeClass(id));\n return buildSyncThunk(nodeShape, iri, ds);\n}\n"]}
1
+ {"version":3,"file":"syncShapes.js","sourceRoot":"","sources":["../../../src/shapes/syncShapes.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAE7C;;;GAGG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAqB,EAAE,QAAgB;IAC5E,MAAM,KAAK,GAAG,GAAG,QAAQ,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IACxC,MAAM,CAAC,GAA4B;QACjC,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,uBAAuB,CAAC,EAAE,CAAC,IAAI,CAAC;KACvC,CAAC;IACF,+EAA+E;IAC/E,+EAA+E;IAC/E,sCAAsC;IACtC,EA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,MAAM,gBAAgB,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI;YAAE,OAAO;QACnE,MAAM,UAAU,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC,CAAA,CAAC;AACJ,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 */\nimport {getAllShapeClasses, getShapeClass} from '../utils/ShapeClass.js';\nimport {NodeShape} from './SHACL.js';\nimport {\n getUniquePropertyShapes,\n type NodeShapeData,\n type PropertyShapeData,\n} from './nodeShapeData.js';\nimport {Shape} from './Shape.js';\nimport {DeleteBuilder} from '../queries/DeleteBuilder.js';\nimport type {IDataset} from '../interfaces/IDataset.js';\nimport {rdfList} from './List.js';\nimport {serializePathToNodeData} from './serializePathToNodeData.js';\nimport {buildSingleOwnerConstraints} from './singleOwnerConstraint.js';\nimport {QueryBuilder} from '../queries/QueryBuilder.js';\nimport {sha256Hex} from '../utils/sha256.js';\n\n/**\n * The npm scope of framework shapes (NodeShape/PropertyShape/List/PathNode/Shape) that\n * describe the meta-model itself and must never be synced as user data.\n */\nconst FRAMEWORK_PACKAGE = '@_linked/core';\n\n/**\n * Build the create-pipeline data object for a single PropertyShape (flattened under shapeIri).\n *\n * @internal Exported for tests only — not part of the public API.\n */\nexport function buildPropertyShapeData(ps: PropertyShapeData, shapeIri: string): Record<string, unknown> {\n const psIri = `${shapeIri}/${ps.label}`;\n const d: Record<string, unknown> = {\n __id: psIri,\n path: serializePathToNodeData(ps.path),\n };\n // `rdfs:label` — the DSL label, i.e. the accessor name the property is reached\n // by in code (`person.memberships`). It is NOT `sh:name`, written below, which\n // is a human-readable display string.\n //\n // Without this the label is only ever implied by `psIri`, and a reader has to\n // re-derive one from the path's local part. That works right up until the two\n // differ — `@_linked/org` declares `memberships` on the path `org:hasMembership`\n // — at which point the catalog reports `hasMembership`, the query proxy indexes\n // the shape with it, and the class (which only knows `memberships`) throws.\n // Readers already prefer a stored label and fall back to the path, so writing it\n // is the whole fix; old catalogs keep working via that fallback.\n if (ps.label) d.label = ps.label;\n if (ps.nodeKind) d.nodeKind = ps.nodeKind;\n if (ps.datatype) d.datatype = ps.datatype;\n if (typeof ps.minCount === 'number') d.minCount = ps.minCount;\n if (typeof ps.maxCount === 'number') d.maxCount = ps.maxCount;\n if (ps.name) d.name = ps.name;\n if (ps.description) d.description = ps.description;\n if (typeof ps.order === 'number') d.order = ps.order;\n if (ps.group) d.group = ps.group;\n if (typeof ps.displayRank === 'number') d.displayRank = ps.displayRank;\n if (ps.displayHidden !== undefined) d.displayHidden = ps.displayHidden;\n if (ps.class) d.class = ps.class;\n if (ps.in) d.in = rdfList(ps.in, {base: `${psIri}/in`});\n if (ps.equalsConstraint) d.equalsConstraint = ps.equalsConstraint;\n if (ps.disjoint) d.disjoint = ps.disjoint;\n if (ps.lessThan) d.lessThan = ps.lessThan;\n if (ps.lessThanOrEquals) d.lessThanOrEquals = ps.lessThanOrEquals;\n if (ps.minInclusive !== undefined) d.minInclusive = ps.minInclusive;\n if (ps.maxInclusive !== undefined) d.maxInclusive = ps.maxInclusive;\n if (ps.minExclusive !== undefined) d.minExclusive = ps.minExclusive;\n if (ps.maxExclusive !== undefined) d.maxExclusive = ps.maxExclusive;\n if (typeof ps.minLength === 'number') d.minLength = ps.minLength;\n if (typeof ps.maxLength === 'number') d.maxLength = ps.maxLength;\n // sh:pattern is serialized as its regex source string.\n if (ps.pattern) d.pattern = ps.pattern.source;\n if (ps.hasValueConstraint !== undefined) d.hasValue = ps.hasValueConstraint;\n if (ps.valueShape) d.valueShape = ps.valueShape;\n if (ps.contains) d.contains = true;\n return d;\n}\n\n/** Build the create-pipeline data object for a NodeShape and its (flattened) property shapes. */\nfunction buildNodeShapeData(nodeShape: NodeShapeData, shapeIri: string): Record<string, unknown> {\n const d: Record<string, unknown> = {};\n if (nodeShape.targetClass) d.targetClass = nodeShape.targetClass;\n if (nodeShape.description) d.description = nodeShape.description;\n if (nodeShape.extends) d.extends = nodeShape.extends;\n if (nodeShape.dependent) d.dependent = true;\n if (nodeShape.closed !== undefined) d.closed = nodeShape.closed;\n if (nodeShape.ignoredProperties && nodeShape.ignoredProperties.length) {\n d.ignoredProperties = nodeShape.ignoredProperties;\n }\n // Flatten: emit own + inherited property shapes (deduped by label) under this shape.\n d.properties = getUniquePropertyShapes(nodeShape).map((ps) =>\n buildPropertyShapeData(ps, shapeIri),\n );\n // The single-owner constraints of the shape's own `contains` properties, owned through\n // `core:generatedShape` and written nested in the same create with their fixed IRIs.\n const generated = buildSingleOwnerConstraints(nodeShape, shapeIri);\n if (generated.length > 0) {\n d.generatedShapes = generated.map(({iri, data}) => ({__id: iri, ...data}));\n }\n return d;\n}\n\n/**\n * Version of the {@link shapeSyncHash} input. Bump it whenever core changes the SHACL it writes\n * for a shape (a serialization change that the create data itself does not show), so every stored\n * shape is rewritten once by the next sync. Without a bump, stores keep the old triples: their\n * stored hashes still match, so the sync skips them.\n *\n * Enforced by `shape-sync-output-equivalence.test.ts`: its golden SHACL output is recorded in\n * `SHAPE_HASH_LEDGER` with the version it was generated for, and regenerating the golden without\n * bumping this constant fails that test. To change the output: bump this by one, update the\n * golden, and append `{version, goldenDigest}` to the ledger (never edit an existing entry).\n *\n * @internal Exported for tests only — not part of the public API.\n */\nexport const SHAPE_HASH_VERSION = 1;\n\n/**\n * A canonical string for create-pipeline data: equal for equal data, independent of object key\n * order and of the order of array values.\n *\n * Arrays are sorted because in create data an array is always a multi-valued property (a set of\n * RDF values: `properties`, `generatedShapes`, `targetObjectsOf`, …). Ordered `rdf:List`s\n * (`sh:in`, sequence and alternative paths, `sh:or`) are nested `first`/`rest` objects, so their\n * order is kept by the structure. A shape class value (`shape: List`) is written as its NodeShape\n * IRI. Values without ids (blank nodes once written) are compared by structure, so no blank-node\n * label is ever part of the input.\n */\nfunction canonicalize(value: unknown): string {\n if (value === null || value === undefined) return 'null';\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'number':\n return `n:${Object.is(value, -0) ? '0' : String(value)}`;\n case 'boolean':\n return `b:${value}`;\n case 'bigint':\n return `i:${value.toString()}`;\n case 'function': {\n const shapeId = (value as {shape?: {id?: string}}).shape?.id;\n return `c:${JSON.stringify(shapeId ?? (value as {name?: string}).name ?? '')}`;\n }\n }\n if (Array.isArray(value)) {\n return `[${value.map(canonicalize).sort().join(',')}]`;\n }\n if (value instanceof Date) return `d:${value.toISOString()}`;\n if (value instanceof RegExp) return `r:${JSON.stringify(value.source)}/${value.flags}`;\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record)\n .filter((k) => record[k] !== undefined)\n .sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(record[k])}`).join(',')}}`;\n}\n\n/**\n * The content hash shape sync stores on a NodeShape as `core:shapeHash`: SHA-256 (hex) of the\n * canonical form of the shape IRI and the exact create data the sync writes for it — the\n * NodeShape, its flattened own + inherited property shapes, their `sh:in` lists and paths, and\n * the generated single-owner shapes it owns (whose owner classes come from the registered\n * sub-shapes, so registering a new sub-shape changes the hash of the declaring shape).\n *\n * Deterministic across processes, runtimes and Node versions: no blank-node labels, no object key\n * order, no array order (see {@link canonicalize}).\n *\n * @internal Exported for tests only — not part of the public API.\n */\nexport function shapeSyncHash(data: Record<string, unknown>, shapeIri: string): string {\n return sha256Hex(`linked-shape-sync/${SHAPE_HASH_VERSION}\\n${canonicalize({iri: shapeIri, data})}`);\n}\n\n/** The create data and its content hash for one shape, as the sync writes it. */\nfunction buildSyncData(\n nodeShape: NodeShapeData,\n iri: string,\n): {data: Record<string, unknown>; hash: string} {\n const data = buildNodeShapeData(nodeShape, iri);\n return {data, hash: shapeSyncHash(data, iri)};\n}\n\n/**\n * The stored `core:shapeHash` of each of `iris` that exists as a NodeShape, in one select. A shape\n * that is absent, or stored without a hash (written before hashes existed), is missing from the\n * map. `ds` targets an explicit dataset, as for the writes.\n */\nasync function readStoredHashes(iris: string[], ds?: IDataset): Promise<Map<string, string>> {\n const stored = new Map<string, string>();\n if (iris.length === 0) return stored;\n const rows = (await (QueryBuilder.from(NodeShape).select(['shapeHash']).forAll(iris) as unknown as {\n exec: (target?: IDataset) => Promise<Array<{id: string; shapeHash?: unknown}> | null>;\n }).exec(ds)) ?? [];\n for (const row of rows) {\n if (row && typeof row.shapeHash === 'string') stored.set(row.id, row.shapeHash);\n }\n return stored;\n}\n\n/**\n * The per-shape `delete → create` thunk shared by `syncShapes()` and `syncShape()`: exactly two\n * requests. The delete cascade-cleans the shape's old property-shape / list / path subtrees; the\n * create rebuilds them, and stores the content hash (`core:shapeHash`) of what it wrote on the\n * NodeShape so a later sync can skip the shape while it is unchanged.\n *\n * The single-owner constraints generated from the shape's own `contains` properties\n * (`${iri}/${label}.singleOwner`, see `singleOwnerConstraint.ts`) are owned by the shape through\n * `core:generatedShape` (a `contains` property with value shape NodeShape). The delete removes\n * them and their property shapes through the owned walk, and their blank path and qualified-shape\n * nodes through the blank-node cascade; the create writes the current ones nested, in the same request\n * as the shape. A removed or renamed accessor therefore loses its constraint on the next sync,\n * and a NodeShape the shape does not own is never touched.\n *\n * `ds` (optional) targets an explicit dataset — both requests run against it instead of the\n * global router. Omitted → today's global behavior.\n */\nfunction buildSyncThunk(nodeShape: NodeShapeData, iri: string, ds?: IDataset): () => Promise<void> {\n // `writeShape` builds the data fresh on each invocation, so every run writes from the current\n // shape metadata, and the hash stored with it always describes what was written.\n return () => writeShape(nodeShape, iri, ds);\n}\n\n/** Delete (cascade) then create one shape, storing the hash of the written data. */\nasync function writeShape(nodeShape: NodeShapeData, iri: string, ds?: IDataset): Promise<void> {\n const {data, hash} = buildSyncData(nodeShape, iri);\n await DeleteBuilder.from(NodeShape, {id: iri}).exec(ds);\n await (NodeShape.create({...data, shapeHash: hash} as never).withId(iri) as unknown as {\n exec: (target?: IDataset) => Promise<unknown>;\n }).exec(ds);\n}\n\n/** The generated single-owner shape IRIs a code shape writes. */\nfunction generatedIrisOf(nodeShape: NodeShapeData, iri: string): string[] {\n return buildSingleOwnerConstraints(nodeShape, iri).map((c) => c.iri);\n}\n\n/** Throw when a registered shape IRI equals one of a shape's generated single-owner IRIs. */\nfunction assertNoGeneratedIriCollision(\n nodeShape: NodeShapeData,\n iri: string,\n isRegistered: (iri: string) => boolean,\n): void {\n for (const generated of generatedIrisOf(nodeShape, iri)) {\n if (isRegistered(generated)) {\n throw new Error(`Shape IRI ${generated} collides with a generated single-owner shape`);\n }\n }\n}\n\n/** Options controlling how {@link syncShapes} treats store shapes that are not in code. */\nexport interface SyncShapesOptions {\n /**\n * How to treat NodeShapes present in the store but not in the current process's code:\n * - `'none'` (default) — never prune; purely additive (delete→recreate the code shapes, touch\n * nothing else). The only mode that is safe when the process has loaded a *subset* of the\n * shapes in the dataset, or when the dataset has more than one writer.\n * - `'all'` — prune every store-only shape as an orphan. Only correct when this process has\n * loaded **every** shape the dataset should hold and is its **only** writer; \"not registered\n * here\" is then taken to mean \"deleted from code\".\n * - `'ownedNamespaces'` — prune a store-only shape ONLY if its IRI falls within a namespace\n * this process actually writes (the package-namespace of one of its code-registered shapes,\n * i.e. the IRI prefix up to the last `/` or `#`). Protects other writers' packages (arch-04:\n * one app-data dataset, several writers), but NOT the rest of a package the process only\n * partially loaded — the namespace is the whole package, so a deep import of one shape file\n * still claims all of it.\n *\n * `'all'` and `'ownedNamespaces'` are destructive and must be requested explicitly.\n */\n orphanScope?: 'all' | 'ownedNamespaces' | 'none';\n /**\n * Rewrite every code shape, even one whose stored `core:shapeHash` matches. Default `false`:\n * a shape is rewritten only when its hash differs or is missing. Use it to repair a shape\n * whose stored subtree was edited or partly deleted outside shape sync (the hash describes\n * what sync last wrote, not what is in the store now).\n */\n force?: boolean;\n}\n\n/** Options for {@link syncShape}. */\nexport interface SyncShapeOptions {\n /** Rewrite the shape even when its stored `core:shapeHash` matches. See {@link SyncShapesOptions.force}. */\n force?: boolean;\n}\n\n/** The owning namespace of a shape IRI — everything up to and including the last `/` or `#`. */\nfunction shapeNamespace(iri: string): string {\n const cut = Math.max(iri.lastIndexOf('/'), iri.lastIndexOf('#'));\n return cut >= 0 ? iri.slice(0, cut + 1) : iri;\n}\n\n/**\n * Plan an idempotent sync of all code-registered (non-framework) NodeShapes into the store as\n * SHACL data — the forward (code → graph) materialization of arch-05 \"code is canonical\".\n *\n * Returns built-but-unexecuted thunks; the caller controls execution and batching:\n * ```ts\n * await Promise.all((await syncShapes()).map((run) => run()));\n * ```\n * Each in-code shape's thunk runs `delete → create` in order (the delete cascade-cleans the old\n * property shapes / list / path subtrees via the containment cascade, the create rebuilds them).\n *\n * **Unchanged shapes are skipped.** The create stores a content hash of everything it writes for\n * the shape on the NodeShape (`core:shapeHash`, see {@link shapeSyncHash}). The plan reads the\n * stored hashes of all code shapes in one select and builds a thunk only for a shape whose hash\n * is missing (never synced, or synced before hashes existed) or differs. Syncing an unchanged\n * app therefore returns no write thunks, and the length of the plan is the number of shapes\n * actually written plus the pruned orphans. The hash records what sync last wrote, not what the\n * store holds now: a subtree edited or partly deleted by another writer while the NodeShape and\n * its hash survive is not detected. `options.force` rewrites every code shape.\n *\n * **Shapes in the store but not registered in this process are left alone by default**\n * (`orphanScope: 'none'`). The registry only holds what this process happened to import, and\n * that is routinely a subset of what the dataset holds: shapes are deep-importable one file at a\n * time, and an app-data dataset also holds shapes other writers materialized (CN's\n * `bindShape` / `enableCapability`). \"Not registered here\" therefore does not mean \"deleted from\n * code\". Measured against a dataset holding the 36 `@_linked/schema` shapes: a process that\n * imported only `@_linked/schema/shapes/Thing` (11 shapes registered) deleted the other 25 under\n * both `'all'` and `'ownedNamespaces'`, and a process that imported no shapes deleted all 36.\n *\n * Pruning is opt-in via `options.orphanScope` (see {@link SyncShapesOptions}): pass `'all'` only\n * from a process that has loaded every shape the dataset should hold and is its sole writer, and\n * `'ownedNamespaces'` only when it has loaded every shape of each package it registers. Pruned\n * orphans are deleted with their owned subtree. Pruning reads the existing shape IRIs first;\n * with `'none'` no read is made.\n *\n * `ds` (optional) targets an explicit dataset instead of the global router. It is a **plan-time**\n * parameter: it feeds the stored-hash read and the orphan-detection read (so both are computed\n * against the same store they'll be written to) and every delete/create thunk. Omitted → the global router;\n * the returned thunks stay nullary either way.\n */\nexport async function syncShapes(\n ds?: IDataset,\n options?: SyncShapesOptions,\n): Promise<Array<() => Promise<void>>> {\n const orphanScope = options?.orphanScope ?? 'none';\n // 1. Enumerate code-registered user shapes (exclude framework/meta shapes).\n const userShapes: Array<{iri: string; nodeShape: NodeShapeData}> = [];\n for (const [iri, shapeClass] of getAllShapeClasses()) {\n if (!shapeClass?.shape) continue;\n const pkg = (shapeClass as {packageName?: string}).packageName;\n // Skip framework/meta shapes: the core package, and the base `Shape` which is registered\n // directly (no applyLinkedShape) and therefore carries no packageName.\n if (!pkg || pkg === FRAMEWORK_PACKAGE) continue;\n userShapes.push({iri, nodeShape: shapeClass.shape});\n }\n const localShapeIris = new Set(userShapes.map((s) => s.iri));\n for (const {iri, nodeShape} of userShapes) {\n assertNoGeneratedIriCollision(nodeShape, iri, (id) => localShapeIris.has(id));\n }\n // The generated single-owner shapes of in-code shapes are written by the same thunks, so they\n // are never orphans. Derived in memory from the same function that builds them; a stale\n // generated shape (removed accessor or shape) is not protected and goes with its owner's\n // delete, through the `core:generatedShape` cascade.\n for (const {iri, nodeShape} of userShapes) {\n for (const generated of generatedIrisOf(nodeShape, iri)) localShapeIris.add(generated);\n }\n // Namespaces this process actually writes — the ownership scope for `'ownedNamespaces'` pruning.\n const ownedNamespaces = new Set(userShapes.map((s) => shapeNamespace(s.iri)));\n\n const thunks: Array<() => Promise<void>> = [];\n\n // 2. Per in-code shape whose stored content hash is missing or differs: delete (cascade) then\n // recreate. An unchanged shape gets no thunk, so syncing an unchanged app writes nothing.\n // The stored hashes are read in one select, against the same `ds` the thunks target.\n const storedHashes = options?.force\n ? new Map<string, string>()\n : await readStoredHashes(userShapes.map((s) => s.iri), ds);\n for (const {iri, nodeShape} of userShapes) {\n if (!options?.force && storedHashes.get(iri) === buildSyncData(nodeShape, iri).hash) continue;\n thunks.push(buildSyncThunk(nodeShape, iri, ds));\n }\n\n // 3. Orphan sweep (unless disabled). Identity-read existing NodeShape IRIs (ids only). Must hit\n // the same `ds` the thunks target, or orphans get computed against the wrong store.\n if (orphanScope !== 'none') {\n const existingRows = (await (NodeShape as unknown as {\n select: () => {exec: (target?: IDataset) => Promise<Array<{id: string}>>};\n }).select().exec(ds)) as Array<{id: string}>;\n\n // Orphan shapes (in store, not in code) → delete (cascade cleans their owned subtree). In\n // `'ownedNamespaces'` mode, only shapes within a namespace this process writes are eligible —\n // other writers' shapes (different package namespace) are left untouched.\n for (const {id: iri} of existingRows) {\n if (localShapeIris.has(iri)) continue;\n if (orphanScope === 'ownedNamespaces' && !ownedNamespaces.has(shapeNamespace(iri))) {\n continue;\n }\n thunks.push(() =>\n (DeleteBuilder.from(NodeShape, {id: iri}).exec(ds) as Promise<unknown>).then(\n () => undefined,\n ),\n );\n }\n }\n\n return thunks;\n}\n\n/**\n * Plan an idempotent sync of ONE code-registered NodeShape into the store as SHACL data.\n *\n * Scoped counterpart to {@link syncShapes}: materializes a single shape (delete → recreate, so the\n * delete cascade-cleans the old property-shape / list / path subtrees and the create rebuilds them)\n * and does NOT run the store-wide orphan sweep — other shapes in the store are untouched.\n *\n * @param target a shape class (e.g. `Person`) or its NodeShape IRI string. An IRI is resolved to\n * its registered class via `getShapeClass`; the shape must be code-registered.\n * @param ds optional explicit dataset to materialize into (a store or a router) — both the delete\n * and the create run against it instead of the global router. Omitted → global behavior.\n * @param options `force: true` rewrites the shape even when its stored hash matches.\n * @returns a single unexecuted thunk (consistent with {@link syncShapes}), so callers can batch\n * several together — e.g. a shape plus its referenced object-property shapes:\n * `await Promise.all([syncShape(Person), syncShape(Address)].map((run) => run()))`.\n * Unless `force` is set, the thunk first reads the shape's stored `core:shapeHash` and writes\n * nothing when it equals the hash of what it would write (see {@link syncShapes}).\n * @throws if `target` is a framework/meta shape, is not registered, or has no `.shape`.\n */\nexport function syncShape(\n target: typeof Shape | string,\n ds?: IDataset,\n options?: SyncShapeOptions,\n): () => Promise<void> {\n // Normalize target → its registered shape class.\n const cls =\n typeof target === 'string' ? getShapeClass(target) : (target as typeof Shape);\n if (typeof target === 'string' && !cls) {\n throw new Error(`syncShape: no registered shape for IRI ${target}`);\n }\n const nodeShape = cls?.shape;\n if (!nodeShape) {\n throw new Error(\n typeof target === 'string'\n ? `syncShape: no registered shape for IRI ${target}`\n : `syncShape: shape class has no static .shape`,\n );\n }\n const iri = nodeShape.id;\n\n // Never materialize a framework/meta shape as user data — same invariant syncShapes() enforces\n // by skipping (the base Shape carries no packageName).\n const pkg = (cls as {packageName?: string}).packageName;\n if (!pkg || pkg === FRAMEWORK_PACKAGE) {\n throw new Error(`syncShape: refusing to sync framework/meta shape ${iri}`);\n }\n\n assertNoGeneratedIriCollision(nodeShape, iri, (id) => !!getShapeClass(id));\n if (options?.force) return buildSyncThunk(nodeShape, iri, ds);\n return async () => {\n const stored = await readStoredHashes([iri], ds);\n if (stored.get(iri) === buildSyncData(nodeShape, iri).hash) return;\n await writeShape(nodeShape, iri, ds);\n };\n}\n"]}
@@ -459,6 +459,9 @@ createPropertyShape({ path: coreOntology.dependent, datatype: xsd.boolean, maxCo
459
459
  createPropertyShape({ path: shacl.targetObjectsOf, shape: Shape }, 'targetObjectsOf', shacl.IRI, NodeShape);
460
460
  createPropertyShape({ path: coreOntology.generated, datatype: xsd.boolean, maxCount: 1 }, 'generated', shacl.Literal, NodeShape);
461
461
  createPropertyShape({ path: coreOntology.generatedShape, shape: NodeShape, contains: true }, 'generatedShapes', shacl.IRI, NodeShape);
462
+ // NodeShape.shapeHash (core:shapeHash — the content hash shape sync stores on each shape it
463
+ // writes, so the next sync can skip an unchanged shape; see syncShapes.ts).
464
+ createPropertyShape({ path: coreOntology.shapeHash, datatype: xsd.string, maxCount: 1 }, 'shapeHash', shacl.Literal, NodeShape);
462
465
  // The terms of the generated single-owner constraint (`singleOwnerConstraint.ts`):
463
466
  // `sh:qualifiedValueShape [ sh:or ( [ sh:class A ] [ sh:class B ] ) ]` and
464
467
  // `sh:qualifiedMaxCount`. The qualified shape and the `sh:or` list are written without ids, so
@@ -1 +1 @@
1
- {"version":3,"file":"Package.js","sourceRoot":"","sources":["../../../src/utils/Package.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,SAAS,EACT,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,mBAAmB,EAAqB,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAC,KAAK,EAAwB,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAC,wBAAwB,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AASzC,kEAAkE;AAClE,kDAAkD;AAClD,IAAI,UAAU,GAAa,IAAI,GAAG,EAAE,CAAC;AACrC,IAAI,qBAAqB,GAAG,KAAK,CAAC;AA+KlC,MAAM,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC;AAE9B,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAE/C,aAAa,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,OAAO,EACP,KAAK,CAAC,GAAG,EACT,SAAS,CACV,CAAC;AACF,mBAAmB,CACjB,EAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAC;AAC7D,2EAA2E;AAC3E,UAAU,EACV,KAAK,CAAC,cAAc,EACpB,SAAS,CACV,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 */\nimport {\n createPropertyShape,\n getAndClearCallbacks,\n getNodeShapeUri,\n getPackageUri,\n setPackagePublishConfig,\n NodeShape,\n PropertyShape,\n} from '../shapes/SHACL.js';\nimport {createNodeShapeData, type NodeShapeData} from '../shapes/nodeShapeData.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {List} from '../shapes/List.class.js';\nimport {Prefix} from './Prefix.js';\nimport {coreOntology} from '../ontologies/linked-core.js';\nimport {rdf} from '../ontologies/rdf.js';\nimport {addNodeShapeToShapeClass,getShapeClass} from './ShapeClass.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {rdfs} from '../ontologies/rdfs.js';\nimport {xsd} from '../ontologies/xsd.js';\nimport type {NodeReferenceValue} from './NodeReference.js';\n\n//global tree\ndeclare var _linked: any;\ndeclare var window;\ndeclare var global;\n\n\n// var packageParsePromises: Map<string,Promise<any>> = new Map();\n// var loadedPackages: Set<NamedNode> = new Set();\nlet ontologies: Set<any> = new Set();\nlet _autoLoadOntologyData = false;\n/**\n * a map of requested property shapes for specific nodes\n * The value is a promise if it's still loading, or true if it is fully loaded\n */\n// type ClassDecorator = <T extends {new (...args: any[]): {}}>(\n// constructor: T,\n// ) => T;\n\nexport type ShapeConfig = {\n /**\n * The name this shape is identified by, overriding the class name.\n *\n * A shape's IRI is `<baseUri>shape/<package>/<name>`, and `Server.call`\n * routes on it — so the name is persisted data, not a label. Taking it from\n * `constructor.name` couples that data to how the code was compiled: a\n * minifier renames the class, and so does a plain name collision, because a\n * shape and the ontology term it targets deliberately share a name. Either\n * one silently changes what the shape *is*.\n *\n * Optional, and defaults to `constructor.name`, so existing shapes are\n * unaffected. Set it where the identity has to outlive the build.\n */\n name?: string;\n /**\n * A short description of the shape, what it represents and what it is used for.\n * will be stored as rdfs:comment on the shape node\n */\n description?: string;\n /**\n * @deprecated No effect on deletes. Ownership is per property: every node a `contains`\n * property reaches is deleted with its owner, whether or not its shape is\n * `dependent`. Still accepted and persisted (`core:dependent`) by shape sync.\n */\n dependent?: boolean;\n /**\n * Close the shape (sh:closed): target nodes with properties outside this shape are invalid.\n */\n closed?: boolean;\n /**\n * Properties permitted in addition to the declared ones when the shape is closed\n * (sh:ignoredProperties).\n */\n ignoredProperties?: NodeReferenceValue[];\n};\n\nexport type PackageMetadata = {\n id: string;\n packageName: string;\n type: NodeReferenceValue;\n};\n\n/**\n * This object, returned by [linkedPackage()](/docs/lincd.js/modules/utils_Module#linkedPackage),\n * contains the decorators to link different parts of a LINCD module.\n */\nexport interface LinkedPackageObject\n{\n /**\n * Links a typescript class to a SHACL shape.\n * This decorator creates a SHACL shape and looks at the static property [targetClass](/docs/lincd.js/classes/shapes_Shape.Shape#targetclass)\n * The rest of the shape is typically 'shaped' by methods that use [property decorators](/docs/lincd.js/modules/utils_ShapeDecorators).\n *\n * @example\n * Example of a typescript class using the \\@linkedShape decorator:\n * ```tsx\n * @linkedShape\n * export class Person extends Shape { ... }\n * ```\n * Or with options:\n * ```tsx\n * @linkedShape({ description: \"...\" })\n * export class Person extends Shape { ... }\n * ```\n */\n linkedShape: {\n <T extends typeof Shape>(constructor: T): void;\n <T extends typeof Shape>(config?: ShapeConfig): (constructor: T) => void;\n };\n /**\n * Use this decorator to make any other classes or functions available on demand to other LINCD modules.\n * It does not change the object it is applied on.\n * This is specifically required for their use in an open-ended LINCD application.\n *\n * @example\n * An example helper utility using the \\@linkedUtil decorator:\n * ```tsx\n * @linkedUtil\n * export class Sort {\n * static byName(persons:Person[]) {\n * return persons.sort((p1,p2) => p1.name < p2.name ? -1 : 1)\n * }\n * ```\n */\n linkedUtil: (constructor: any) => any;\n /**\n * Used to notify LINCD.js of an ontology.\n * See also the [Ontology guides](/docs/guides/linked-code/ontologies).\n *\n * @param allFileExports - all the objects that are exported by the ontology file (use `import * as _this from \"./path-to-this-file\")`)\n * @param nameSpace - the result of [createNameSpace](/docs/lincd.js/modules/utils_NameSpace#createnamespace). This allows consumers to generate NamedNodes that may not be listed in this ontology if needed\n * @param prefixAndFileName - a suggested prefix chosen by you. Make sure the suggestedPrefix matches the file name and the name of the exported object that groups all entities together\n * @param loadDataFunction - a method that loads _and parses_ the raw ontology data. This means the ontology will be loaded into the local graph. The returned result is mostly a JSONLDParsePromise (from lincd-jsonld/JSONLD, not bundled in LINCD.js)\n * @param dataSource - the relative path to the raw data of the ontology\n * @example\n * Example of an Ontology File that used linkedOntology()\n * ```tsx\n * import {NamedNode} from 'lincd/models';\n * import {JSONLD} from 'lincd-jsonld/JSONLD';\n * import {createNameSpace} from 'lincd/utils/NameSpace';\n * import {linkedOntology} from '../package.js';\n * import * as _this from './my.js-ontology';\n *\n * let dataFile = '../data/my.js-ontology.json';\n * export var loadData = () => JSONLD.parsePromise(import(dataFile));\n *\n * export var ns = createNameSpace('http://www.my-ontology.com/');\n *\n * export var _self: NamedNode = ns('');\n *\n * // Classes\n * export var ExampleClass: NamedNode = ns('ExampleClass');\n *\n * // Properties\n * export var exampleProperty: NamedNode = ns('exampleProperty');\n *\n * export const myOntology = {\n * ExampleClass,\n * exampleProperty,\n * };\n *\n * linkedOntology(_this, ns, 'myOntology', loadData, dataFile);\n * ```\n */\n linkedOntology: (\n allFileExports,\n nameSpace: (term: string) => NodeReferenceValue,\n suggestedPrefixAndFileName: string,\n loadDataFunction?: () => Promise<any>,\n dataSource?: string | string[],\n ) => void;\n /**\n * Low level method used by other decorators to write to the modules' object in the LINCD tree.\n * You should typically not need this.\n * @param exportFileName - the file name that this exported object is available under. Needs to be unique across the module.\n * @param exportedObject - the exported object (the class, constant, function, etc)\n */\n registerPackageExport: (exportedObject: any) => void;\n\n /**\n * Get a Shape subclass registered in this package by name.\n * Returns undefined if the shape is not registered or bundled.\n *\n * Useful for avoiding circular dependencies between shapes.\n * E.g. `getOneAs(..., getPackageShape('ImageObject'))` in Thing.ts\n * avoids importing ImageObject (which extends Thing).\n */\n getPackageShape: (name: string) => ShapeConstructor | undefined;\n /**\n * A reference to the modules' object in the LINCD tree.\n * Contains all linked components of the module.\n */\n packageExports: any;\n packageName: string;\n packageMetadata: PackageMetadata;\n\n /**\n * Register a file (a javascript module) and all its exported objects.\n * Specifically helpful for registering multiple functional components if you declare them without a function name\n * @param _this\n * @param _module\n */\n registerPackageModule(_module): void;\n}\n\nexport var DEFAULT_LIMIT = 12;\n\nexport function setDefaultPageLimit(limit: number)\n{\n DEFAULT_LIMIT = limit;\n}\n\nexport function autoLoadOntologyData(value: boolean)\n{\n _autoLoadOntologyData = value;\n //this may be set to true after some ontologies have already indexed,\n if (_autoLoadOntologyData)\n {\n // so in that case we load all data of ontologies that are already indexed\n ontologies.forEach((ontologyExport) => {\n //see linkedOntology() where we store the data loading method under the _load key\n if (ontologyExport['_load'])\n {\n ontologyExport['_load']();\n }\n });\n }\n}\n\n\nexport function linkedPackage(\n packageName: string,\n options?: {baseUri?: string},\n): LinkedPackageObject\n{\n // Declare the package's publish root before any shape/metadata IRI is built.\n // The slug is derived from `packageName`; only `baseUri` is configurable — CN\n // injects a workspace-scoped root for private packages, first-party packages\n // default to linked.cm.\n setPackagePublishConfig(packageName, options);\n let packageMetadata = registerPackageMetadata(packageName);\n let packageTreeObject = registerPackageInTree(packageName);\n\n //#Create declarators for this module\n let registerPackageExport = function(object) {\n // Plan-011 §I2 interim — \"Key X was already defined\" warning silenced\n // until the duplicate-instance root cause is investigated. With Vite\n // SSR resolving workspace packages from src/, package.ts evaluates\n // twice and every export key trips this warning. The overwrite is\n // safe because the second registration is the same class.\n packageTreeObject[object.name] = object;\n };\n\n let registerInPackageTree = function(exportName,exportedObject) {\n packageTreeObject[exportName] = exportedObject;\n };\n\n function registerPackageModule(_module): void\n {\n for (var key in _module.exports)\n {\n //if the exported object itself is not named or its name is _wrappedComponent\n //then we give it the same name as it's export name.\n if (\n !_module.exports[key].name ||\n _module.exports[key].name === '_wrappedComponent'\n )\n {\n Object.defineProperty(_module.exports[key],'name',{value: key});\n //manual 'hack' to set the name of the original function\n if (\n _module.exports[key]['original'] &&\n !_module.exports[key]['original']['name']\n )\n {\n Object.defineProperty(_module.exports[key]['original'],'name',{\n value: key + '_implementation',\n });\n }\n }\n registerInPackageTree(key,_module.exports[key]);\n }\n }\n\n //create a declarator function which Components of this module can use register themselves and add themselves to the global tree\n let linkedUtil = function(constructor) {\n //add the component class of this module to the global tree\n registerPackageExport(constructor);\n\n //return the original class without modifications\n return constructor;\n };\n\n // helper that contains the previous body; applies the decorator work to a given constructor\n function applyLinkedShape<T extends typeof Shape>(\n constructor: T,\n options?: ShapeConfig,\n ): void\n {\n if(!constructor) {\n throw new Error('Constructor is undefined, skipping registration: '+constructor?.toString().substring(0,100)+' '+JSON.stringify(options));\n return;\n }\n // add the component class of this module to the global tree\n registerPackageExport(constructor);\n\n // register the component and its shape\n Shape.registerByType(constructor);\n\n // Track the un-sanitized package name on the constructor so consumers\n // (e.g. LincdServerProxy) can route backend calls using the real module\n // specifier (e.g. '@_linked/server'), not the lossy URI-sanitized form\n // ('-_linked-server' — non-recoverable via decodeURIComponent).\n if (!Object.getOwnPropertyNames(constructor).includes('packageName')) {\n (constructor as any).packageName = packageName;\n }\n\n // if no shape object has been attached to the constructor\n if (!Object.getOwnPropertyNames(constructor).includes('shape'))\n {\n // The shape's identity. An explicit name wins; otherwise the class name,\n // which is what every existing shape relies on.\n const shapeName = options?.name ?? constructor.name;\n\n // A class name ending in a digit, with no explicit name given, is almost\n // always a bundler disambiguating a collision — `BackendAPIStore2` when\n // the ontology term of the same name took the binding first. The shape\n // then registers under an IRI the rest of the system will never ask for,\n // and the only symptom is a 501 several layers away. Say so here, where\n // it is cheap and early.\n if (!options?.name && /\\d$/.test(constructor.name)) {\n console.warn(\n `[linked] Shape '${constructor.name}' in '${packageName}' has a name ending in a digit, ` +\n `which usually means a bundler renamed it to avoid a collision — often with the ` +\n `ontology term it targets. Its IRI will not match what consumers ask for. ` +\n `Pass an explicit name: @linkedShape({name: '...'}).`,\n );\n }\n\n // create a new node shape (plain metadata object) for this shapeClass\n const nodeShape: NodeShapeData = createNodeShapeData(\n getNodeShapeUri(packageName, shapeName),\n );\n // connect the typescript class to its NodeShape\n constructor.shape = nodeShape;\n // set the name\n nodeShape.label = shapeName;\n\n if (options)\n {\n if (options.description)\n {\n nodeShape.description = options.description;\n }\n if (options.dependent)\n {\n nodeShape.dependent = true;\n }\n if (options.closed !== undefined)\n {\n nodeShape.closed = options.closed;\n }\n if (options.ignoredProperties)\n {\n nodeShape.ignoredProperties = options.ignoredProperties;\n }\n }\n\n // also keep track of the reverse: nodeShape to typescript class\n addNodeShapeToShapeClass(nodeShape,constructor);\n\n //track what extends what (nodeShape level)\n const extendingShapeClass = Object.getPrototypeOf(\n constructor,\n ) as typeof Shape;\n const extendingShape = extendingShapeClass.shape;\n //if this shape class is extending something other then Shape\n if (extendingShape && !(extendingShapeClass === Shape)) {\n //store which nodeShape this nodeShape extends\n nodeShape.extends = {id: extendingShape.id};\n }\n \n\n // run deferred callbacks from property decorators\n if (constructor['shapeCallbacks'])\n {\n constructor['shapeCallbacks'].forEach((callback) => {\n callback(nodeShape);\n });\n const nodeCallbacks = getAndClearCallbacks(nodeShape.id);\n if(nodeCallbacks) {\n nodeCallbacks.forEach((callback) => {\n callback(nodeShape);\n });\n }\n delete constructor['shapeCallbacks'];\n }\n }\n else\n {\n console.warn('This ShapeClass already has a shape: ',constructor.shape);\n }\n\n if (constructor.targetClass)\n {\n (constructor.shape as NodeShapeData).targetClass = constructor.targetClass;\n }\n\n // return the original class without modifications\n // return constructor;\n }\n\n // Overloaded signatures to support both usages\n function linkedShape<T extends typeof Shape>(constructor: T): void;\n function linkedShape<T extends typeof Shape>(\n options?: ShapeConfig,\n ): (constructor: T) => void;\n function linkedShape(arg?: any): void | ((constructor: any) => void)\n {\n // usage as @linkedShape\n if (typeof arg === 'function')\n {\n applyLinkedShape(arg);\n return;\n }\n // usage as @linkedShape({...}) or @linkedShape()\n const options: ShapeConfig | undefined = arg;\n return function <T extends typeof Shape>(constructor: T): void {\n applyLinkedShape(constructor,options);\n };\n }\n\n /**\n *\n * @param exports all exports of the file, simply provide \"this\" as value!\n * @param dataSource the path leading to the ontology's data file\n * @param nameSpace the base URI of the ontology\n * @param prefixAndFileName the file name MUST match the prefix for this ontology\n */\n let linkedOntology = function(\n exports,\n nameSpace: (term: string) => NodeReferenceValue,\n prefixAndFileName: string,\n loadData?,\n dataSource?: string | string[],\n ) {\n let exportsCopy = {...exports};\n //store specifics in exports. And make sure we can detect this as an ontology later\n exportsCopy['_ns'] = nameSpace;\n exportsCopy['_prefix'] = prefixAndFileName;\n exportsCopy['_load'] = loadData;\n exportsCopy['_data'] = dataSource;\n\n //register the prefix here (so just calling linkedOntology with a prefix will automatically register that prefix)\n if (prefixAndFileName)\n {\n //run the namespace without any term name, this will give back a named node with just the namespace as URI, then get that URI to provide it as full URI\n Prefix.add(prefixAndFileName,nameSpace('').id);\n }\n\n ontologies.add(exportsCopy);\n //register all the exports under the prefix. NOTE: this means the file name HAS to match the prefix\n registerInPackageTree(prefixAndFileName,exportsCopy);\n // });\n\n if (_autoLoadOntologyData)\n {\n loadData().catch((err) => {\n console.warn(\n 'Could not load ontology data. Do you need to rebuild the module of the ' +\n prefixAndFileName +\n ' ontology?',\n err,\n );\n });\n }\n };\n\n /**\n * This method is used to get a shape class in this package by its name.\n * This can be used to avoid circular dependencies between shapes.\n * @param name\n */\n let getPackageShape = (name: string): ShapeConstructor | undefined => {\n //get the named node of the node shape first,\n //then get the shape class that defines this node shape\n return getShapeClass(\n getNodeShapeUri(packageName, name),\n );\n };\n\n //return the declarators so the module can use them\n return {\n linkedShape,\n linkedUtil,\n linkedOntology,\n registerPackageExport,\n registerPackageModule,\n getPackageShape,\n packageExports: packageTreeObject,\n packageName: packageName,\n packageMetadata,\n } as LinkedPackageObject;\n}\n\nfunction registerPackageInTree(packageName,packageExports?)\n{\n //if something with this name already registered in the global tree\n if (packageName in _linked._modules)\n {\n // Plan-011 §I2 interim — silenced until the duplicate-Linked-instance\n // root cause is investigated. Vite SSR resolving workspace packages\n // from src/ for HMR causes each package.ts to evaluate twice, so this\n // warning fired ~80x per boot. Same package, same exports — the\n // Object.assign below preserves the registry correctly.\n Object.assign(_linked._modules[packageName],packageExports);\n }\n else\n {\n //initiate an empty object for this module in the global tree\n _linked._modules[packageName] = packageExports || {};\n }\n return _linked._modules[packageName];\n}\n\nfunction registerPackageMetadata(packageName: string): PackageMetadata\n{\n if (!_linked._packages)\n {\n _linked._packages = {};\n }\n if (packageName in _linked._packages)\n {\n return _linked._packages[packageName];\n }\n const packageMetadata: PackageMetadata = {\n id: getPackageUri(packageName),\n packageName,\n type: coreOntology.Package,\n };\n _linked._packages[packageName] = packageMetadata;\n return packageMetadata;\n}\n\n\nexport function initTree()\n{\n let globalObject =\n typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : undefined;\n // Idempotent: if the global tree is already set up (by another copy of\n // this Package.ts in the same Node process — structural under Vite SSR,\n // which evaluates the file once for its own SSR transform AND once via\n // Node's resolver when a non-Vite import path reaches @_linked/core),\n // attach to it instead of throwing. Both instances write the same\n // _modules / _packages registry shape.\n //\n // Legacy `lincd` package's Package.ts (separate file) still throws on\n // dup — that throw signals a REAL problem (legacy `lincd` should never\n // load in a clean post-eradication state).\n if (!('_linked' in globalObject))\n {\n globalObject['_linked'] = {_modules: {}, _packages: {}};\n }\n}\n\n//when this file is used, make sure the tree is initialized\ninitTree();\n\n//now that this file is set up, we can link linked shapes in the core module itself\nexport const corePackage = linkedPackage('@_linked/core');\n// NodeShape, PropertyShape and List share their names with ontology terms (shacl.NodeShape,\n// shacl.PropertyShape, rdf.List), so a bundler may rename the classes. Explicit names keep\n// their IRIs independent of that.\ncorePackage.linkedShape({\n name: 'NodeShape',\n description:\n 'Represents a SHACL NodeShape; defines constraints for a class of RDF nodes. Links to multiple PropertyShapes. (schema, constraint, class validation)',\n})(NodeShape);\ncorePackage.linkedShape({\n name: 'PropertyShape',\n description:\n 'Represents a SHACL PropertyShape; specifies rules for one property of a NodeShape (path, datatype, cardinality). (validation rule, property constraint)',\n // Owned by its NodeShape through the `contains` sh:property edge: deleting the NodeShape\n // deletes it.\n})(PropertyShape);\n// List is registered here, by value, because PropertyShape.in below uses it as its value\n// shape. Naming it by string instead would leave it unregistered for anyone who loads the\n// SHACL metamodel without importing shapes/List (backlog 045).\ncorePackage.linkedShape({\n name: 'List',\n})(List);\n// ValidationReport / ValidationResult removed in core metadata rewrite\n\n//ALL the following is to support Shape having get/set methods with property shapes\n//and Shape itself having a nodeShape\n//if we dont need Shape to have get/set methods (like label and type) then this can be removed\n// Base Shape IRI follows the same scheme as every other core shape:\n// https://linked.cm/shape/core/Shape (corePackage above declared slug 'core').\nShape.shape = createNodeShapeData(\n getNodeShapeUri('@_linked/core', 'Shape'),\n);\naddNodeShapeToShapeClass(Shape.shape,Shape);\n\n//Here we can register the properties of the Shape class itself\n//We can't do that inside of Shape because it would cause circular dependencies\ncreatePropertyShape({\n path: rdfs.label,\n //TODO: multiple labels should be possible\n maxCount: 1,//currently get label is implemented to return a single value\n },\n 'label',\n shacl.Literal,\n Shape,\n);\ncreatePropertyShape(\n {\n path: rdf.type,\n shape: Shape,\n },\n 'type',\n shacl.IRI,\n Shape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.property,\n shape: PropertyShape,\n contains: true, // a NodeShape owns its property shapes (cascade on delete)\n },\n 'properties',\n shacl.IRI,\n NodeShape,\n);\n\ncreatePropertyShape({\n path: rdfs.comment,\n maxCount: 1,\n },'description',shacl.Literal, NodeShape);\n\ncreatePropertyShape({\n path: rdf.type,\n maxCount: 1,\n shape: Shape,\n},'type',shacl.IRI, NodeShape);\n\ncreatePropertyShape(\n {\n path: shacl.targetClass,\n shape: Shape, //should be rdfs Class, but that's currently not available in LINCD. So queries currently cannot continue after accessing targetClass\n maxCount: 1,\n },\n 'targetClass',\n shacl.IRI,\n NodeShape,\n);\n\ncreatePropertyShape({\n path: shacl.targetNode,\n shape: Shape,//actually returns a NamedNode... is this correct then? Should we define or use a rdfs Class that matches the potential values?\n},'targetNode',shacl.IRI, NodeShape);\n\ncreatePropertyShape({\n path: coreOntology.isExtending,\n shape: NodeShape,\n},'extends',shacl.IRI, NodeShape);\n\n//currently path accepts multiple values, so its a multi-value property\n//these values will be consequent properties that follow each other. Other property paths are not supported yet.\ncreatePropertyShape(\n {\n // No fixed valueShape: sh:path is polymorphic (a predicate IRI, a PathList for a\n // sequence, or a PathNode for inverse/alt/cardinality). Omitting valueShape lets the\n // create pipeline use each value's own shape. Simple paths are passed as\n // {id} node references, complex paths as PathList/PathNode node-data.\n path: shacl.path,\n // Not `contains`: a predicate path is a shared IRI. A complex path's operator node or\n // sequence list is written without an id, so it becomes a blank node, as SHACL requires,\n // and the blank-node cascade deletes it with the property shape.\n nodeKind: shacl.BlankNodeOrIRI,\n },\n 'path',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.node,\n shape: NodeShape,\n maxCount: 1,\n },\n 'valueShape',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n maxCount: 1,\n path: shacl.nodeKind,\n shape: Shape, //actually returns a NamedNode. Queries currently cannot continue after accessing nodeKind\n },\n 'nodeKind',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.datatype,\n shape: Shape,\n maxCount: 1,\n },\n 'datatype',\n shacl.IRI,\n PropertyShape,\n);\n\n//PropertyShape.maxCount\ncreatePropertyShape(\n {\n path: shacl.maxCount,\n datatype: xsd.integer,\n maxCount: 1,\n },\n 'maxCount',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.minCount\ncreatePropertyShape(\n {\n path: shacl.minCount,\n datatype: xsd.integer,\n maxCount: 1,\n },\n 'minCount',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.name\ncreatePropertyShape(\n {\n path: shacl.name,\n maxCount: 1,\n },\n 'name',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.description\ncreatePropertyShape(\n {\n path: shacl.description,\n maxCount: 1,\n },\n 'description',\n shacl.Literal,\n PropertyShape,\n);\n\n// ---------------------------------------------------------------------------\n// Remaining SHACL meta-model accessors for shape serialization.\n// Labels match the PropertyShapeData / NodeShapeData fields so syncShapes() can\n// build the create-pipeline data directly. `sh:in` is owned (contains, valueShape List).\n// ---------------------------------------------------------------------------\n\n// PropertyShape.class\ncreatePropertyShape(\n {path: shacl.class, shape: Shape, maxCount: 1},\n 'class',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape.in → an rdf:List (owned)\ncreatePropertyShape(\n {path: shacl.in, shape: List, maxCount: 1, contains: true},\n 'in',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape pair constraints (values are property IRIs)\n// Labelled `equalsConstraint`, not `equals`: `equals` is a query-builder method, so a\n// property under that label is unreachable through the DSL (backlog 041). The name also\n// matches the `PropertyShapeData` field. The predicate stays sh:equals.\ncreatePropertyShape({path: shacl.equals, shape: Shape, maxCount: 1}, 'equalsConstraint', shacl.IRI, PropertyShape);\ncreatePropertyShape({path: shacl.disjoint, shape: Shape, maxCount: 1}, 'disjoint', shacl.IRI, PropertyShape);\ncreatePropertyShape({path: shacl.lessThan, shape: Shape, maxCount: 1}, 'lessThan', shacl.IRI, PropertyShape);\ncreatePropertyShape(\n {path: shacl.lessThanOrEquals, shape: Shape, maxCount: 1},\n 'lessThanOrEquals',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape.hasValue (literal or IRI — generic)\ncreatePropertyShape({path: shacl.hasValue, maxCount: 1}, 'hasValue', null, PropertyShape);\n\n// PropertyShape.defaultValue (literal or IRI — generic, mirrors hasValue).\n// getResult() already emits `defaultValue`, but without this registration the\n// property is not queryable and a query referencing it throws before executing.\ncreatePropertyShape({path: shacl.defaultValue, maxCount: 1}, 'defaultValue', null, PropertyShape);\n\n// PropertyShape value-range / string-length / pattern constraints (report 021 §3, G5).\n// The range constraints carry no fixed datatype — the literal is typed from the JS value\n// (integer/double), mirroring the constrained property's own datatype. Length is an integer;\n// pattern is the regex source string.\ncreatePropertyShape({path: shacl.minInclusive, maxCount: 1}, 'minInclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.maxInclusive, maxCount: 1}, 'maxInclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.minExclusive, maxCount: 1}, 'minExclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.maxExclusive, maxCount: 1}, 'maxExclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape(\n {path: shacl.minLength, datatype: xsd.integer, maxCount: 1},\n 'minLength',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.maxLength, datatype: xsd.integer, maxCount: 1},\n 'maxLength',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.pattern, datatype: xsd.string, maxCount: 1},\n 'pattern',\n shacl.Literal,\n PropertyShape,\n);\n\n// PropertyShape.order / group\ncreatePropertyShape(\n {path: shacl.order, datatype: xsd.integer, maxCount: 1},\n 'order',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape({path: shacl.group, maxCount: 1}, 'group', shacl.Literal, PropertyShape);\n\n// PropertyShape.displayRank / displayHidden (core: display vocabulary).\n// These materialize onto the pure sh:NodeShape and so travel with an ejected app.\ncreatePropertyShape(\n {path: coreOntology.displayRank, datatype: xsd.integer, maxCount: 1},\n 'displayRank',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: coreOntology.displayHidden, datatype: xsd.boolean, maxCount: 1},\n 'displayHidden',\n shacl.Literal,\n PropertyShape,\n);\n\n// PropertyShape.contains (core:contains — persists the composition flag)\ncreatePropertyShape(\n {path: coreOntology.contains, datatype: xsd.boolean, maxCount: 1},\n 'contains',\n shacl.Literal,\n PropertyShape,\n);\n\n// NodeShape.closed / ignoredProperties / dependent (deprecated, persisted only)\ncreatePropertyShape(\n {path: shacl.closed, datatype: xsd.boolean, maxCount: 1},\n 'closed',\n shacl.Literal,\n NodeShape,\n);\ncreatePropertyShape(\n {path: shacl.ignoredProperties, shape: Shape},\n 'ignoredProperties',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.dependent, datatype: xsd.boolean, maxCount: 1},\n 'dependent',\n shacl.Literal,\n NodeShape,\n);\n\n// NodeShape.targetObjectsOf (sh:targetObjectsOf — values are predicate IRIs),\n// NodeShape.generated (core:generated — marks a shape core generates at sync time,\n// e.g. the `<propertyShape>.singleOwner` constraint, so catalog readers can skip it) and\n// NodeShape.generatedShapes (core:generatedShape — the shape owns the shapes generated from\n// it: `contains`, so deleting the shape deletes them).\ncreatePropertyShape(\n {path: shacl.targetObjectsOf, shape: Shape},\n 'targetObjectsOf',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.generated, datatype: xsd.boolean, maxCount: 1},\n 'generated',\n shacl.Literal,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.generatedShape, shape: NodeShape, contains: true},\n 'generatedShapes',\n shacl.IRI,\n NodeShape,\n);\n\n// The terms of the generated single-owner constraint (`singleOwnerConstraint.ts`):\n// `sh:qualifiedValueShape [ sh:or ( [ sh:class A ] [ sh:class B ] ) ]` and\n// `sh:qualifiedMaxCount`. The qualified shape and the `sh:or` list are written without ids, so\n// they are blank nodes, deleted with their property shape by the blank-node cascade. The list\n// cells are `PathList`s (blank-capable `rdf:List` cells); like `sh:path`, `orShapes` declares no\n// value shape (`PathList.ts` imports `package.js`, which loads this module), so the create uses each value's own shape.\ncreatePropertyShape(\n {path: shacl.qualifiedValueShape, shape: NodeShape, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI},\n 'qualifiedValueShape',\n shacl.BlankNodeOrIRI,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.qualifiedMaxCount, datatype: xsd.integer, maxCount: 1},\n 'qualifiedMaxCount',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.class, shape: Shape, maxCount: 1},\n 'class',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: shacl.or, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI},\n // `or` is reserved (a DSL-JSON combinator), so the accessor is `orShapes`.\n 'orShapes',\n shacl.BlankNodeOrIRI,\n NodeShape,\n);\n"]}
1
+ {"version":3,"file":"Package.js","sourceRoot":"","sources":["../../../src/utils/Package.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,SAAS,EACT,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,mBAAmB,EAAqB,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAC,KAAK,EAAwB,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAC,wBAAwB,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CA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AI,EAAE,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAC,EAChG,qBAAqB,EACrB,KAAK,CAAC,cAAc,EACpB,aAAa,CACd,CAAC;AACF,mBAAmB,CACjB,EAAC,IAAI,EAAE,KAAK,CAAC,iBAAiB,EAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAC,EACnE,mBAAmB,EACnB,KAAK,CAAC,OAAO,EACb,aAAa,CACd,CAAC;AACF,mBAAmB,CACjB,EAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAC,EAC9C,OAAO,EACP,KAAK,CAAC,GAAG,EACT,SAAS,CACV,CAAC;AACF,mBAAmB,CACjB,EAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAC;AAC7D,2EAA2E;AAC3E,UAAU,EACV,KAAK,CAAC,cAAc,EACpB,SAAS,CACV,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 */\nimport {\n createPropertyShape,\n getAndClearCallbacks,\n getNodeShapeUri,\n getPackageUri,\n setPackagePublishConfig,\n NodeShape,\n PropertyShape,\n} from '../shapes/SHACL.js';\nimport {createNodeShapeData, type NodeShapeData} from '../shapes/nodeShapeData.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {List} from '../shapes/List.class.js';\nimport {Prefix} from './Prefix.js';\nimport {coreOntology} from '../ontologies/linked-core.js';\nimport {rdf} from '../ontologies/rdf.js';\nimport {addNodeShapeToShapeClass,getShapeClass} from './ShapeClass.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {rdfs} from '../ontologies/rdfs.js';\nimport {xsd} from '../ontologies/xsd.js';\nimport type {NodeReferenceValue} from './NodeReference.js';\n\n//global tree\ndeclare var _linked: any;\ndeclare var window;\ndeclare var global;\n\n\n// var packageParsePromises: Map<string,Promise<any>> = new Map();\n// var loadedPackages: Set<NamedNode> = new Set();\nlet ontologies: Set<any> = new Set();\nlet _autoLoadOntologyData = false;\n/**\n * a map of requested property shapes for specific nodes\n * The value is a promise if it's still loading, or true if it is fully loaded\n */\n// type ClassDecorator = <T extends {new (...args: any[]): {}}>(\n// constructor: T,\n// ) => T;\n\nexport type ShapeConfig = {\n /**\n * The name this shape is identified by, overriding the class name.\n *\n * A shape's IRI is `<baseUri>shape/<package>/<name>`, and `Server.call`\n * routes on it — so the name is persisted data, not a label. Taking it from\n * `constructor.name` couples that data to how the code was compiled: a\n * minifier renames the class, and so does a plain name collision, because a\n * shape and the ontology term it targets deliberately share a name. Either\n * one silently changes what the shape *is*.\n *\n * Optional, and defaults to `constructor.name`, so existing shapes are\n * unaffected. Set it where the identity has to outlive the build.\n */\n name?: string;\n /**\n * A short description of the shape, what it represents and what it is used for.\n * will be stored as rdfs:comment on the shape node\n */\n description?: string;\n /**\n * @deprecated No effect on deletes. Ownership is per property: every node a `contains`\n * property reaches is deleted with its owner, whether or not its shape is\n * `dependent`. Still accepted and persisted (`core:dependent`) by shape sync.\n */\n dependent?: boolean;\n /**\n * Close the shape (sh:closed): target nodes with properties outside this shape are invalid.\n */\n closed?: boolean;\n /**\n * Properties permitted in addition to the declared ones when the shape is closed\n * (sh:ignoredProperties).\n */\n ignoredProperties?: NodeReferenceValue[];\n};\n\nexport type PackageMetadata = {\n id: string;\n packageName: string;\n type: NodeReferenceValue;\n};\n\n/**\n * This object, returned by [linkedPackage()](/docs/lincd.js/modules/utils_Module#linkedPackage),\n * contains the decorators to link different parts of a LINCD module.\n */\nexport interface LinkedPackageObject\n{\n /**\n * Links a typescript class to a SHACL shape.\n * This decorator creates a SHACL shape and looks at the static property [targetClass](/docs/lincd.js/classes/shapes_Shape.Shape#targetclass)\n * The rest of the shape is typically 'shaped' by methods that use [property decorators](/docs/lincd.js/modules/utils_ShapeDecorators).\n *\n * @example\n * Example of a typescript class using the \\@linkedShape decorator:\n * ```tsx\n * @linkedShape\n * export class Person extends Shape { ... }\n * ```\n * Or with options:\n * ```tsx\n * @linkedShape({ description: \"...\" })\n * export class Person extends Shape { ... }\n * ```\n */\n linkedShape: {\n <T extends typeof Shape>(constructor: T): void;\n <T extends typeof Shape>(config?: ShapeConfig): (constructor: T) => void;\n };\n /**\n * Use this decorator to make any other classes or functions available on demand to other LINCD modules.\n * It does not change the object it is applied on.\n * This is specifically required for their use in an open-ended LINCD application.\n *\n * @example\n * An example helper utility using the \\@linkedUtil decorator:\n * ```tsx\n * @linkedUtil\n * export class Sort {\n * static byName(persons:Person[]) {\n * return persons.sort((p1,p2) => p1.name < p2.name ? -1 : 1)\n * }\n * ```\n */\n linkedUtil: (constructor: any) => any;\n /**\n * Used to notify LINCD.js of an ontology.\n * See also the [Ontology guides](/docs/guides/linked-code/ontologies).\n *\n * @param allFileExports - all the objects that are exported by the ontology file (use `import * as _this from \"./path-to-this-file\")`)\n * @param nameSpace - the result of [createNameSpace](/docs/lincd.js/modules/utils_NameSpace#createnamespace). This allows consumers to generate NamedNodes that may not be listed in this ontology if needed\n * @param prefixAndFileName - a suggested prefix chosen by you. Make sure the suggestedPrefix matches the file name and the name of the exported object that groups all entities together\n * @param loadDataFunction - a method that loads _and parses_ the raw ontology data. This means the ontology will be loaded into the local graph. The returned result is mostly a JSONLDParsePromise (from lincd-jsonld/JSONLD, not bundled in LINCD.js)\n * @param dataSource - the relative path to the raw data of the ontology\n * @example\n * Example of an Ontology File that used linkedOntology()\n * ```tsx\n * import {NamedNode} from 'lincd/models';\n * import {JSONLD} from 'lincd-jsonld/JSONLD';\n * import {createNameSpace} from 'lincd/utils/NameSpace';\n * import {linkedOntology} from '../package.js';\n * import * as _this from './my.js-ontology';\n *\n * let dataFile = '../data/my.js-ontology.json';\n * export var loadData = () => JSONLD.parsePromise(import(dataFile));\n *\n * export var ns = createNameSpace('http://www.my-ontology.com/');\n *\n * export var _self: NamedNode = ns('');\n *\n * // Classes\n * export var ExampleClass: NamedNode = ns('ExampleClass');\n *\n * // Properties\n * export var exampleProperty: NamedNode = ns('exampleProperty');\n *\n * export const myOntology = {\n * ExampleClass,\n * exampleProperty,\n * };\n *\n * linkedOntology(_this, ns, 'myOntology', loadData, dataFile);\n * ```\n */\n linkedOntology: (\n allFileExports,\n nameSpace: (term: string) => NodeReferenceValue,\n suggestedPrefixAndFileName: string,\n loadDataFunction?: () => Promise<any>,\n dataSource?: string | string[],\n ) => void;\n /**\n * Low level method used by other decorators to write to the modules' object in the LINCD tree.\n * You should typically not need this.\n * @param exportFileName - the file name that this exported object is available under. Needs to be unique across the module.\n * @param exportedObject - the exported object (the class, constant, function, etc)\n */\n registerPackageExport: (exportedObject: any) => void;\n\n /**\n * Get a Shape subclass registered in this package by name.\n * Returns undefined if the shape is not registered or bundled.\n *\n * Useful for avoiding circular dependencies between shapes.\n * E.g. `getOneAs(..., getPackageShape('ImageObject'))` in Thing.ts\n * avoids importing ImageObject (which extends Thing).\n */\n getPackageShape: (name: string) => ShapeConstructor | undefined;\n /**\n * A reference to the modules' object in the LINCD tree.\n * Contains all linked components of the module.\n */\n packageExports: any;\n packageName: string;\n packageMetadata: PackageMetadata;\n\n /**\n * Register a file (a javascript module) and all its exported objects.\n * Specifically helpful for registering multiple functional components if you declare them without a function name\n * @param _this\n * @param _module\n */\n registerPackageModule(_module): void;\n}\n\nexport var DEFAULT_LIMIT = 12;\n\nexport function setDefaultPageLimit(limit: number)\n{\n DEFAULT_LIMIT = limit;\n}\n\nexport function autoLoadOntologyData(value: boolean)\n{\n _autoLoadOntologyData = value;\n //this may be set to true after some ontologies have already indexed,\n if (_autoLoadOntologyData)\n {\n // so in that case we load all data of ontologies that are already indexed\n ontologies.forEach((ontologyExport) => {\n //see linkedOntology() where we store the data loading method under the _load key\n if (ontologyExport['_load'])\n {\n ontologyExport['_load']();\n }\n });\n }\n}\n\n\nexport function linkedPackage(\n packageName: string,\n options?: {baseUri?: string},\n): LinkedPackageObject\n{\n // Declare the package's publish root before any shape/metadata IRI is built.\n // The slug is derived from `packageName`; only `baseUri` is configurable — CN\n // injects a workspace-scoped root for private packages, first-party packages\n // default to linked.cm.\n setPackagePublishConfig(packageName, options);\n let packageMetadata = registerPackageMetadata(packageName);\n let packageTreeObject = registerPackageInTree(packageName);\n\n //#Create declarators for this module\n let registerPackageExport = function(object) {\n // Plan-011 §I2 interim — \"Key X was already defined\" warning silenced\n // until the duplicate-instance root cause is investigated. With Vite\n // SSR resolving workspace packages from src/, package.ts evaluates\n // twice and every export key trips this warning. The overwrite is\n // safe because the second registration is the same class.\n packageTreeObject[object.name] = object;\n };\n\n let registerInPackageTree = function(exportName,exportedObject) {\n packageTreeObject[exportName] = exportedObject;\n };\n\n function registerPackageModule(_module): void\n {\n for (var key in _module.exports)\n {\n //if the exported object itself is not named or its name is _wrappedComponent\n //then we give it the same name as it's export name.\n if (\n !_module.exports[key].name ||\n _module.exports[key].name === '_wrappedComponent'\n )\n {\n Object.defineProperty(_module.exports[key],'name',{value: key});\n //manual 'hack' to set the name of the original function\n if (\n _module.exports[key]['original'] &&\n !_module.exports[key]['original']['name']\n )\n {\n Object.defineProperty(_module.exports[key]['original'],'name',{\n value: key + '_implementation',\n });\n }\n }\n registerInPackageTree(key,_module.exports[key]);\n }\n }\n\n //create a declarator function which Components of this module can use register themselves and add themselves to the global tree\n let linkedUtil = function(constructor) {\n //add the component class of this module to the global tree\n registerPackageExport(constructor);\n\n //return the original class without modifications\n return constructor;\n };\n\n // helper that contains the previous body; applies the decorator work to a given constructor\n function applyLinkedShape<T extends typeof Shape>(\n constructor: T,\n options?: ShapeConfig,\n ): void\n {\n if(!constructor) {\n throw new Error('Constructor is undefined, skipping registration: '+constructor?.toString().substring(0,100)+' '+JSON.stringify(options));\n return;\n }\n // add the component class of this module to the global tree\n registerPackageExport(constructor);\n\n // register the component and its shape\n Shape.registerByType(constructor);\n\n // Track the un-sanitized package name on the constructor so consumers\n // (e.g. LincdServerProxy) can route backend calls using the real module\n // specifier (e.g. '@_linked/server'), not the lossy URI-sanitized form\n // ('-_linked-server' — non-recoverable via decodeURIComponent).\n if (!Object.getOwnPropertyNames(constructor).includes('packageName')) {\n (constructor as any).packageName = packageName;\n }\n\n // if no shape object has been attached to the constructor\n if (!Object.getOwnPropertyNames(constructor).includes('shape'))\n {\n // The shape's identity. An explicit name wins; otherwise the class name,\n // which is what every existing shape relies on.\n const shapeName = options?.name ?? constructor.name;\n\n // A class name ending in a digit, with no explicit name given, is almost\n // always a bundler disambiguating a collision — `BackendAPIStore2` when\n // the ontology term of the same name took the binding first. The shape\n // then registers under an IRI the rest of the system will never ask for,\n // and the only symptom is a 501 several layers away. Say so here, where\n // it is cheap and early.\n if (!options?.name && /\\d$/.test(constructor.name)) {\n console.warn(\n `[linked] Shape '${constructor.name}' in '${packageName}' has a name ending in a digit, ` +\n `which usually means a bundler renamed it to avoid a collision — often with the ` +\n `ontology term it targets. Its IRI will not match what consumers ask for. ` +\n `Pass an explicit name: @linkedShape({name: '...'}).`,\n );\n }\n\n // create a new node shape (plain metadata object) for this shapeClass\n const nodeShape: NodeShapeData = createNodeShapeData(\n getNodeShapeUri(packageName, shapeName),\n );\n // connect the typescript class to its NodeShape\n constructor.shape = nodeShape;\n // set the name\n nodeShape.label = shapeName;\n\n if (options)\n {\n if (options.description)\n {\n nodeShape.description = options.description;\n }\n if (options.dependent)\n {\n nodeShape.dependent = true;\n }\n if (options.closed !== undefined)\n {\n nodeShape.closed = options.closed;\n }\n if (options.ignoredProperties)\n {\n nodeShape.ignoredProperties = options.ignoredProperties;\n }\n }\n\n // also keep track of the reverse: nodeShape to typescript class\n addNodeShapeToShapeClass(nodeShape,constructor);\n\n //track what extends what (nodeShape level)\n const extendingShapeClass = Object.getPrototypeOf(\n constructor,\n ) as typeof Shape;\n const extendingShape = extendingShapeClass.shape;\n //if this shape class is extending something other then Shape\n if (extendingShape && !(extendingShapeClass === Shape)) {\n //store which nodeShape this nodeShape extends\n nodeShape.extends = {id: extendingShape.id};\n }\n \n\n // run deferred callbacks from property decorators\n if (constructor['shapeCallbacks'])\n {\n constructor['shapeCallbacks'].forEach((callback) => {\n callback(nodeShape);\n });\n const nodeCallbacks = getAndClearCallbacks(nodeShape.id);\n if(nodeCallbacks) {\n nodeCallbacks.forEach((callback) => {\n callback(nodeShape);\n });\n }\n delete constructor['shapeCallbacks'];\n }\n }\n else\n {\n console.warn('This ShapeClass already has a shape: ',constructor.shape);\n }\n\n if (constructor.targetClass)\n {\n (constructor.shape as NodeShapeData).targetClass = constructor.targetClass;\n }\n\n // return the original class without modifications\n // return constructor;\n }\n\n // Overloaded signatures to support both usages\n function linkedShape<T extends typeof Shape>(constructor: T): void;\n function linkedShape<T extends typeof Shape>(\n options?: ShapeConfig,\n ): (constructor: T) => void;\n function linkedShape(arg?: any): void | ((constructor: any) => void)\n {\n // usage as @linkedShape\n if (typeof arg === 'function')\n {\n applyLinkedShape(arg);\n return;\n }\n // usage as @linkedShape({...}) or @linkedShape()\n const options: ShapeConfig | undefined = arg;\n return function <T extends typeof Shape>(constructor: T): void {\n applyLinkedShape(constructor,options);\n };\n }\n\n /**\n *\n * @param exports all exports of the file, simply provide \"this\" as value!\n * @param dataSource the path leading to the ontology's data file\n * @param nameSpace the base URI of the ontology\n * @param prefixAndFileName the file name MUST match the prefix for this ontology\n */\n let linkedOntology = function(\n exports,\n nameSpace: (term: string) => NodeReferenceValue,\n prefixAndFileName: string,\n loadData?,\n dataSource?: string | string[],\n ) {\n let exportsCopy = {...exports};\n //store specifics in exports. And make sure we can detect this as an ontology later\n exportsCopy['_ns'] = nameSpace;\n exportsCopy['_prefix'] = prefixAndFileName;\n exportsCopy['_load'] = loadData;\n exportsCopy['_data'] = dataSource;\n\n //register the prefix here (so just calling linkedOntology with a prefix will automatically register that prefix)\n if (prefixAndFileName)\n {\n //run the namespace without any term name, this will give back a named node with just the namespace as URI, then get that URI to provide it as full URI\n Prefix.add(prefixAndFileName,nameSpace('').id);\n }\n\n ontologies.add(exportsCopy);\n //register all the exports under the prefix. NOTE: this means the file name HAS to match the prefix\n registerInPackageTree(prefixAndFileName,exportsCopy);\n // });\n\n if (_autoLoadOntologyData)\n {\n loadData().catch((err) => {\n console.warn(\n 'Could not load ontology data. Do you need to rebuild the module of the ' +\n prefixAndFileName +\n ' ontology?',\n err,\n );\n });\n }\n };\n\n /**\n * This method is used to get a shape class in this package by its name.\n * This can be used to avoid circular dependencies between shapes.\n * @param name\n */\n let getPackageShape = (name: string): ShapeConstructor | undefined => {\n //get the named node of the node shape first,\n //then get the shape class that defines this node shape\n return getShapeClass(\n getNodeShapeUri(packageName, name),\n );\n };\n\n //return the declarators so the module can use them\n return {\n linkedShape,\n linkedUtil,\n linkedOntology,\n registerPackageExport,\n registerPackageModule,\n getPackageShape,\n packageExports: packageTreeObject,\n packageName: packageName,\n packageMetadata,\n } as LinkedPackageObject;\n}\n\nfunction registerPackageInTree(packageName,packageExports?)\n{\n //if something with this name already registered in the global tree\n if (packageName in _linked._modules)\n {\n // Plan-011 §I2 interim — silenced until the duplicate-Linked-instance\n // root cause is investigated. Vite SSR resolving workspace packages\n // from src/ for HMR causes each package.ts to evaluate twice, so this\n // warning fired ~80x per boot. Same package, same exports — the\n // Object.assign below preserves the registry correctly.\n Object.assign(_linked._modules[packageName],packageExports);\n }\n else\n {\n //initiate an empty object for this module in the global tree\n _linked._modules[packageName] = packageExports || {};\n }\n return _linked._modules[packageName];\n}\n\nfunction registerPackageMetadata(packageName: string): PackageMetadata\n{\n if (!_linked._packages)\n {\n _linked._packages = {};\n }\n if (packageName in _linked._packages)\n {\n return _linked._packages[packageName];\n }\n const packageMetadata: PackageMetadata = {\n id: getPackageUri(packageName),\n packageName,\n type: coreOntology.Package,\n };\n _linked._packages[packageName] = packageMetadata;\n return packageMetadata;\n}\n\n\nexport function initTree()\n{\n let globalObject =\n typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : undefined;\n // Idempotent: if the global tree is already set up (by another copy of\n // this Package.ts in the same Node process — structural under Vite SSR,\n // which evaluates the file once for its own SSR transform AND once via\n // Node's resolver when a non-Vite import path reaches @_linked/core),\n // attach to it instead of throwing. Both instances write the same\n // _modules / _packages registry shape.\n //\n // Legacy `lincd` package's Package.ts (separate file) still throws on\n // dup — that throw signals a REAL problem (legacy `lincd` should never\n // load in a clean post-eradication state).\n if (!('_linked' in globalObject))\n {\n globalObject['_linked'] = {_modules: {}, _packages: {}};\n }\n}\n\n//when this file is used, make sure the tree is initialized\ninitTree();\n\n//now that this file is set up, we can link linked shapes in the core module itself\nexport const corePackage = linkedPackage('@_linked/core');\n// NodeShape, PropertyShape and List share their names with ontology terms (shacl.NodeShape,\n// shacl.PropertyShape, rdf.List), so a bundler may rename the classes. Explicit names keep\n// their IRIs independent of that.\ncorePackage.linkedShape({\n name: 'NodeShape',\n description:\n 'Represents a SHACL NodeShape; defines constraints for a class of RDF nodes. Links to multiple PropertyShapes. (schema, constraint, class validation)',\n})(NodeShape);\ncorePackage.linkedShape({\n name: 'PropertyShape',\n description:\n 'Represents a SHACL PropertyShape; specifies rules for one property of a NodeShape (path, datatype, cardinality). (validation rule, property constraint)',\n // Owned by its NodeShape through the `contains` sh:property edge: deleting the NodeShape\n // deletes it.\n})(PropertyShape);\n// List is registered here, by value, because PropertyShape.in below uses it as its value\n// shape. Naming it by string instead would leave it unregistered for anyone who loads the\n// SHACL metamodel without importing shapes/List (backlog 045).\ncorePackage.linkedShape({\n name: 'List',\n})(List);\n// ValidationReport / ValidationResult removed in core metadata rewrite\n\n//ALL the following is to support Shape having get/set methods with property shapes\n//and Shape itself having a nodeShape\n//if we dont need Shape to have get/set methods (like label and type) then this can be removed\n// Base Shape IRI follows the same scheme as every other core shape:\n// https://linked.cm/shape/core/Shape (corePackage above declared slug 'core').\nShape.shape = createNodeShapeData(\n getNodeShapeUri('@_linked/core', 'Shape'),\n);\naddNodeShapeToShapeClass(Shape.shape,Shape);\n\n//Here we can register the properties of the Shape class itself\n//We can't do that inside of Shape because it would cause circular dependencies\ncreatePropertyShape({\n path: rdfs.label,\n //TODO: multiple labels should be possible\n maxCount: 1,//currently get label is implemented to return a single value\n },\n 'label',\n shacl.Literal,\n Shape,\n);\ncreatePropertyShape(\n {\n path: rdf.type,\n shape: Shape,\n },\n 'type',\n shacl.IRI,\n Shape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.property,\n shape: PropertyShape,\n contains: true, // a NodeShape owns its property shapes (cascade on delete)\n },\n 'properties',\n shacl.IRI,\n NodeShape,\n);\n\ncreatePropertyShape({\n path: rdfs.comment,\n maxCount: 1,\n },'description',shacl.Literal, NodeShape);\n\ncreatePropertyShape({\n path: rdf.type,\n maxCount: 1,\n shape: Shape,\n},'type',shacl.IRI, NodeShape);\n\ncreatePropertyShape(\n {\n path: shacl.targetClass,\n shape: Shape, //should be rdfs Class, but that's currently not available in LINCD. So queries currently cannot continue after accessing targetClass\n maxCount: 1,\n },\n 'targetClass',\n shacl.IRI,\n NodeShape,\n);\n\ncreatePropertyShape({\n path: shacl.targetNode,\n shape: Shape,//actually returns a NamedNode... is this correct then? Should we define or use a rdfs Class that matches the potential values?\n},'targetNode',shacl.IRI, NodeShape);\n\ncreatePropertyShape({\n path: coreOntology.isExtending,\n shape: NodeShape,\n},'extends',shacl.IRI, NodeShape);\n\n//currently path accepts multiple values, so its a multi-value property\n//these values will be consequent properties that follow each other. Other property paths are not supported yet.\ncreatePropertyShape(\n {\n // No fixed valueShape: sh:path is polymorphic (a predicate IRI, a PathList for a\n // sequence, or a PathNode for inverse/alt/cardinality). Omitting valueShape lets the\n // create pipeline use each value's own shape. Simple paths are passed as\n // {id} node references, complex paths as PathList/PathNode node-data.\n path: shacl.path,\n // Not `contains`: a predicate path is a shared IRI. A complex path's operator node or\n // sequence list is written without an id, so it becomes a blank node, as SHACL requires,\n // and the blank-node cascade deletes it with the property shape.\n nodeKind: shacl.BlankNodeOrIRI,\n },\n 'path',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.node,\n shape: NodeShape,\n maxCount: 1,\n },\n 'valueShape',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n maxCount: 1,\n path: shacl.nodeKind,\n shape: Shape, //actually returns a NamedNode. Queries currently cannot continue after accessing nodeKind\n },\n 'nodeKind',\n shacl.IRI,\n PropertyShape,\n);\n\ncreatePropertyShape(\n {\n path: shacl.datatype,\n shape: Shape,\n maxCount: 1,\n },\n 'datatype',\n shacl.IRI,\n PropertyShape,\n);\n\n//PropertyShape.maxCount\ncreatePropertyShape(\n {\n path: shacl.maxCount,\n datatype: xsd.integer,\n maxCount: 1,\n },\n 'maxCount',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.minCount\ncreatePropertyShape(\n {\n path: shacl.minCount,\n datatype: xsd.integer,\n maxCount: 1,\n },\n 'minCount',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.name\ncreatePropertyShape(\n {\n path: shacl.name,\n maxCount: 1,\n },\n 'name',\n shacl.Literal,\n PropertyShape,\n);\n\n//PropertyShape.description\ncreatePropertyShape(\n {\n path: shacl.description,\n maxCount: 1,\n },\n 'description',\n shacl.Literal,\n PropertyShape,\n);\n\n// ---------------------------------------------------------------------------\n// Remaining SHACL meta-model accessors for shape serialization.\n// Labels match the PropertyShapeData / NodeShapeData fields so syncShapes() can\n// build the create-pipeline data directly. `sh:in` is owned (contains, valueShape List).\n// ---------------------------------------------------------------------------\n\n// PropertyShape.class\ncreatePropertyShape(\n {path: shacl.class, shape: Shape, maxCount: 1},\n 'class',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape.in → an rdf:List (owned)\ncreatePropertyShape(\n {path: shacl.in, shape: List, maxCount: 1, contains: true},\n 'in',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape pair constraints (values are property IRIs)\n// Labelled `equalsConstraint`, not `equals`: `equals` is a query-builder method, so a\n// property under that label is unreachable through the DSL (backlog 041). The name also\n// matches the `PropertyShapeData` field. The predicate stays sh:equals.\ncreatePropertyShape({path: shacl.equals, shape: Shape, maxCount: 1}, 'equalsConstraint', shacl.IRI, PropertyShape);\ncreatePropertyShape({path: shacl.disjoint, shape: Shape, maxCount: 1}, 'disjoint', shacl.IRI, PropertyShape);\ncreatePropertyShape({path: shacl.lessThan, shape: Shape, maxCount: 1}, 'lessThan', shacl.IRI, PropertyShape);\ncreatePropertyShape(\n {path: shacl.lessThanOrEquals, shape: Shape, maxCount: 1},\n 'lessThanOrEquals',\n shacl.IRI,\n PropertyShape,\n);\n\n// PropertyShape.hasValue (literal or IRI — generic)\ncreatePropertyShape({path: shacl.hasValue, maxCount: 1}, 'hasValue', null, PropertyShape);\n\n// PropertyShape.defaultValue (literal or IRI — generic, mirrors hasValue).\n// getResult() already emits `defaultValue`, but without this registration the\n// property is not queryable and a query referencing it throws before executing.\ncreatePropertyShape({path: shacl.defaultValue, maxCount: 1}, 'defaultValue', null, PropertyShape);\n\n// PropertyShape value-range / string-length / pattern constraints (report 021 §3, G5).\n// The range constraints carry no fixed datatype — the literal is typed from the JS value\n// (integer/double), mirroring the constrained property's own datatype. Length is an integer;\n// pattern is the regex source string.\ncreatePropertyShape({path: shacl.minInclusive, maxCount: 1}, 'minInclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.maxInclusive, maxCount: 1}, 'maxInclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.minExclusive, maxCount: 1}, 'minExclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape({path: shacl.maxExclusive, maxCount: 1}, 'maxExclusive', shacl.Literal, PropertyShape);\ncreatePropertyShape(\n {path: shacl.minLength, datatype: xsd.integer, maxCount: 1},\n 'minLength',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.maxLength, datatype: xsd.integer, maxCount: 1},\n 'maxLength',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.pattern, datatype: xsd.string, maxCount: 1},\n 'pattern',\n shacl.Literal,\n PropertyShape,\n);\n\n// PropertyShape.order / group\ncreatePropertyShape(\n {path: shacl.order, datatype: xsd.integer, maxCount: 1},\n 'order',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape({path: shacl.group, maxCount: 1}, 'group', shacl.Literal, PropertyShape);\n\n// PropertyShape.displayRank / displayHidden (core: display vocabulary).\n// These materialize onto the pure sh:NodeShape and so travel with an ejected app.\ncreatePropertyShape(\n {path: coreOntology.displayRank, datatype: xsd.integer, maxCount: 1},\n 'displayRank',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: coreOntology.displayHidden, datatype: xsd.boolean, maxCount: 1},\n 'displayHidden',\n shacl.Literal,\n PropertyShape,\n);\n\n// PropertyShape.contains (core:contains — persists the composition flag)\ncreatePropertyShape(\n {path: coreOntology.contains, datatype: xsd.boolean, maxCount: 1},\n 'contains',\n shacl.Literal,\n PropertyShape,\n);\n\n// NodeShape.closed / ignoredProperties / dependent (deprecated, persisted only)\ncreatePropertyShape(\n {path: shacl.closed, datatype: xsd.boolean, maxCount: 1},\n 'closed',\n shacl.Literal,\n NodeShape,\n);\ncreatePropertyShape(\n {path: shacl.ignoredProperties, shape: Shape},\n 'ignoredProperties',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.dependent, datatype: xsd.boolean, maxCount: 1},\n 'dependent',\n shacl.Literal,\n NodeShape,\n);\n\n// NodeShape.targetObjectsOf (sh:targetObjectsOf — values are predicate IRIs),\n// NodeShape.generated (core:generated — marks a shape core generates at sync time,\n// e.g. the `<propertyShape>.singleOwner` constraint, so catalog readers can skip it) and\n// NodeShape.generatedShapes (core:generatedShape — the shape owns the shapes generated from\n// it: `contains`, so deleting the shape deletes them).\ncreatePropertyShape(\n {path: shacl.targetObjectsOf, shape: Shape},\n 'targetObjectsOf',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.generated, datatype: xsd.boolean, maxCount: 1},\n 'generated',\n shacl.Literal,\n NodeShape,\n);\ncreatePropertyShape(\n {path: coreOntology.generatedShape, shape: NodeShape, contains: true},\n 'generatedShapes',\n shacl.IRI,\n NodeShape,\n);\n\n// NodeShape.shapeHash (core:shapeHash — the content hash shape sync stores on each shape it\n// writes, so the next sync can skip an unchanged shape; see syncShapes.ts).\ncreatePropertyShape(\n {path: coreOntology.shapeHash, datatype: xsd.string, maxCount: 1},\n 'shapeHash',\n shacl.Literal,\n NodeShape,\n);\n\n// The terms of the generated single-owner constraint (`singleOwnerConstraint.ts`):\n// `sh:qualifiedValueShape [ sh:or ( [ sh:class A ] [ sh:class B ] ) ]` and\n// `sh:qualifiedMaxCount`. The qualified shape and the `sh:or` list are written without ids, so\n// they are blank nodes, deleted with their property shape by the blank-node cascade. The list\n// cells are `PathList`s (blank-capable `rdf:List` cells); like `sh:path`, `orShapes` declares no\n// value shape (`PathList.ts` imports `package.js`, which loads this module), so the create uses each value's own shape.\ncreatePropertyShape(\n {path: shacl.qualifiedValueShape, shape: NodeShape, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI},\n 'qualifiedValueShape',\n shacl.BlankNodeOrIRI,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.qualifiedMaxCount, datatype: xsd.integer, maxCount: 1},\n 'qualifiedMaxCount',\n shacl.Literal,\n PropertyShape,\n);\ncreatePropertyShape(\n {path: shacl.class, shape: Shape, maxCount: 1},\n 'class',\n shacl.IRI,\n NodeShape,\n);\ncreatePropertyShape(\n {path: shacl.or, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI},\n // `or` is reserved (a DSL-JSON combinator), so the accessor is `orShapes`.\n 'orShapes',\n shacl.BlankNodeOrIRI,\n NodeShape,\n);\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * SHA-256 (FIPS 180-4) of a string's UTF-8 bytes, as lowercase hex.
3
+ *
4
+ * Pure JS and synchronous, so it gives the same digest in Node and in the browser without
5
+ * `node:crypto` or the async `SubtleCrypto`. Meant for small inputs such as content hashes of
6
+ * generated data, not for bulk hashing.
7
+ */
8
+ export declare function sha256Hex(input: string): string;
@@ -0,0 +1,80 @@
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ /**
7
+ * SHA-256 (FIPS 180-4) of a string's UTF-8 bytes, as lowercase hex.
8
+ *
9
+ * Pure JS and synchronous, so it gives the same digest in Node and in the browser without
10
+ * `node:crypto` or the async `SubtleCrypto`. Meant for small inputs such as content hashes of
11
+ * generated data, not for bulk hashing.
12
+ */
13
+ export function sha256Hex(input) {
14
+ const bytes = new TextEncoder().encode(input);
15
+ const bitLength = bytes.length * 8;
16
+ // Message + 0x80 + zero padding + 64-bit big-endian length, rounded up to 64-byte blocks.
17
+ const paddedLength = Math.ceil((bytes.length + 9) / 64) * 64;
18
+ const padded = new Uint8Array(paddedLength);
19
+ padded.set(bytes);
20
+ padded[bytes.length] = 0x80;
21
+ const view = new DataView(padded.buffer);
22
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000));
23
+ view.setUint32(paddedLength - 4, bitLength >>> 0);
24
+ const h = new Uint32Array([
25
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
26
+ ]);
27
+ const w = new Uint32Array(64);
28
+ for (let offset = 0; offset < paddedLength; offset += 64) {
29
+ for (let i = 0; i < 16; i++)
30
+ w[i] = view.getUint32(offset + i * 4);
31
+ for (let i = 16; i < 64; i++) {
32
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
33
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
34
+ w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
35
+ }
36
+ let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], k = h[7];
37
+ for (let i = 0; i < 64; i++) {
38
+ const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
39
+ const ch = (e & f) ^ (~e & g);
40
+ const t1 = (k + S1 + ch + K[i] + w[i]) >>> 0;
41
+ const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
42
+ const maj = (a & b) ^ (a & c) ^ (b & c);
43
+ const t2 = (S0 + maj) >>> 0;
44
+ k = g;
45
+ g = f;
46
+ f = e;
47
+ e = (d + t1) >>> 0;
48
+ d = c;
49
+ c = b;
50
+ b = a;
51
+ a = (t1 + t2) >>> 0;
52
+ }
53
+ h[0] += a;
54
+ h[1] += b;
55
+ h[2] += c;
56
+ h[3] += d;
57
+ h[4] += e;
58
+ h[5] += f;
59
+ h[6] += g;
60
+ h[7] += k;
61
+ }
62
+ let hex = '';
63
+ for (let i = 0; i < 8; i++)
64
+ hex += h[i].toString(16).padStart(8, '0');
65
+ return hex;
66
+ }
67
+ function rotr(x, n) {
68
+ return (x >>> n) | (x << (32 - n));
69
+ }
70
+ const K = new Uint32Array([
71
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
72
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
73
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
74
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
75
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
76
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
77
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
78
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
79
+ ]);
80
+ //# sourceMappingURL=sha256.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/utils/sha256.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACnC,0FAA0F;IAC1F,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,WAAW,CA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AAW,CAAC;IACxB,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;CAC/F,CAAC,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/**\n * SHA-256 (FIPS 180-4) of a string's UTF-8 bytes, as lowercase hex.\n *\n * Pure JS and synchronous, so it gives the same digest in Node and in the browser without\n * `node:crypto` or the async `SubtleCrypto`. Meant for small inputs such as content hashes of\n * generated data, not for bulk hashing.\n */\nexport function sha256Hex(input: string): string {\n const bytes = new TextEncoder().encode(input);\n const bitLength = bytes.length * 8;\n // Message + 0x80 + zero padding + 64-bit big-endian length, rounded up to 64-byte blocks.\n const paddedLength = Math.ceil((bytes.length + 9) / 64) * 64;\n const padded = new Uint8Array(paddedLength);\n padded.set(bytes);\n padded[bytes.length] = 0x80;\n const view = new DataView(padded.buffer);\n view.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000));\n view.setUint32(paddedLength - 4, bitLength >>> 0);\n\n const h = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ]);\n const w = new Uint32Array(64);\n for (let offset = 0; offset < paddedLength; offset += 64) {\n for (let i = 0; i < 16; i++) w[i] = view.getUint32(offset + i * 4);\n for (let i = 16; i < 64; i++) {\n const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);\n const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);\n w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;\n }\n let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], k = h[7];\n for (let i = 0; i < 64; i++) {\n const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (k + S1 + ch + K[i] + w[i]) >>> 0;\n const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (S0 + maj) >>> 0;\n k = g;\n g = f;\n f = e;\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) >>> 0;\n }\n h[0] += a;\n h[1] += b;\n h[2] += c;\n h[3] += d;\n h[4] += e;\n h[5] += f;\n h[6] += g;\n h[7] += k;\n }\n let hex = '';\n for (let i = 0; i < 8; i++) hex += h[i].toString(16).padStart(8, '0');\n return hex;\n}\n\nfunction rotr(x: number, n: number): number {\n return (x >>> n) | (x << (32 - n));\n}\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_linked/core",
3
- "version": "2.32.0",
3
+ "version": "2.33.0",
4
4
  "packageManager": "npm@12.2.0",
5
5
  "license": "MIT",
6
6
  "linkedPackage": true,