@_linked/core 2.34.0 → 2.36.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 +22 -0
- package/README.md +54 -0
- package/lib/esm/index.d.ts +5 -1
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/live/LiveQueryStore.d.ts +22 -0
- package/lib/esm/live/LiveQueryStore.js +88 -20
- package/lib/esm/live/LiveQueryStore.js.map +1 -1
- package/lib/esm/live/changes.d.ts +9 -1
- package/lib/esm/live/changes.js +7 -2
- package/lib/esm/live/changes.js.map +1 -1
- package/lib/esm/live/keys.d.ts +6 -0
- package/lib/esm/live/keys.js +10 -1
- package/lib/esm/live/keys.js.map +1 -1
- package/lib/esm/live/matcher.d.ts +4 -1
- package/lib/esm/live/matcher.js +10 -5
- package/lib/esm/live/matcher.js.map +1 -1
- package/lib/esm/queries/AskBuilder.d.ts +6 -0
- package/lib/esm/queries/AskBuilder.js +14 -0
- package/lib/esm/queries/AskBuilder.js.map +1 -1
- package/lib/esm/queries/CountBuilder.d.ts +6 -0
- package/lib/esm/queries/CountBuilder.js +14 -0
- package/lib/esm/queries/CountBuilder.js.map +1 -1
- package/lib/esm/queries/CreateBuilder.d.ts +4 -0
- package/lib/esm/queries/CreateBuilder.js +15 -1
- package/lib/esm/queries/CreateBuilder.js.map +1 -1
- package/lib/esm/queries/DeleteBuilder.d.ts +4 -0
- package/lib/esm/queries/DeleteBuilder.js +15 -1
- package/lib/esm/queries/DeleteBuilder.js.map +1 -1
- package/lib/esm/queries/FieldSet.d.ts +17 -0
- package/lib/esm/queries/FieldSet.js +110 -22
- package/lib/esm/queries/FieldSet.js.map +1 -1
- package/lib/esm/queries/IRLower.js +3 -2
- package/lib/esm/queries/IRLower.js.map +1 -1
- package/lib/esm/queries/IRMutation.js +15 -14
- package/lib/esm/queries/IRMutation.js.map +1 -1
- package/lib/esm/queries/MutationQuery.js +3 -2
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/queries/MutationSerialization.js +2 -2
- package/lib/esm/queries/MutationSerialization.js.map +1 -1
- package/lib/esm/queries/PropertyPath.js +4 -3
- package/lib/esm/queries/PropertyPath.js.map +1 -1
- package/lib/esm/queries/QueryBuilder.d.ts +7 -0
- package/lib/esm/queries/QueryBuilder.js +42 -4
- package/lib/esm/queries/QueryBuilder.js.map +1 -1
- package/lib/esm/queries/QueryContext.js +2 -0
- package/lib/esm/queries/QueryContext.js.map +1 -1
- package/lib/esm/queries/SelectQuery.js +8 -3
- package/lib/esm/queries/SelectQuery.js.map +1 -1
- package/lib/esm/queries/UpdateBuilder.d.ts +4 -0
- package/lib/esm/queries/UpdateBuilder.js +15 -1
- package/lib/esm/queries/UpdateBuilder.js.map +1 -1
- package/lib/esm/queries/fromJSON.d.ts +12 -1
- package/lib/esm/queries/fromJSON.js +5 -1
- package/lib/esm/queries/fromJSON.js.map +1 -1
- package/lib/esm/queries/lower.js +12 -5
- package/lib/esm/queries/lower.js.map +1 -1
- package/lib/esm/queries/queryDependencies.js +14 -10
- package/lib/esm/queries/queryDependencies.js.map +1 -1
- package/lib/esm/queries/resolveShape.js +16 -3
- package/lib/esm/queries/resolveShape.js.map +1 -1
- package/lib/esm/shapes/Shape.js +2 -1
- package/lib/esm/shapes/Shape.js.map +1 -1
- package/lib/esm/shapes/nodeShapeData.js +7 -10
- package/lib/esm/shapes/nodeShapeData.js.map +1 -1
- package/lib/esm/shapes/registerRuntimeShape.js +3 -1
- package/lib/esm/shapes/registerRuntimeShape.js.map +1 -1
- package/lib/esm/shapes/syncShapes.d.ts +6 -2
- package/lib/esm/shapes/syncShapes.js +16 -9
- package/lib/esm/shapes/syncShapes.js.map +1 -1
- package/lib/esm/shapes/validation.js +10 -6
- package/lib/esm/shapes/validation.js.map +1 -1
- package/lib/esm/sparql/irToAlgebra.js +117 -52
- package/lib/esm/sparql/irToAlgebra.js.map +1 -1
- package/lib/esm/sparql/ownedLinkCheck.js +6 -1
- package/lib/esm/sparql/ownedLinkCheck.js.map +1 -1
- package/lib/esm/utils/LinkedStorage.d.ts +7 -0
- package/lib/esm/utils/LinkedStorage.js +39 -12
- package/lib/esm/utils/LinkedStorage.js.map +1 -1
- package/lib/esm/utils/ShapeCatalog.d.ts +57 -0
- package/lib/esm/utils/ShapeCatalog.js +86 -0
- package/lib/esm/utils/ShapeCatalog.js.map +1 -0
- package/lib/esm/utils/ShapeClass.d.ts +73 -8
- package/lib/esm/utils/ShapeClass.js +245 -66
- package/lib/esm/utils/ShapeClass.js.map +1 -1
- package/lib/esm/utils/linkedError.d.ts +35 -0
- package/lib/esm/utils/linkedError.js +52 -0
- package/lib/esm/utils/linkedError.js.map +1 -0
- package/lib/esm/utils/registryCache.d.ts +15 -0
- package/lib/esm/utils/registryCache.js +50 -0
- package/lib/esm/utils/registryCache.js.map +1 -0
- package/lib/esm/utils/sharedState.d.ts +25 -0
- package/lib/esm/utils/sharedState.js +34 -0
- package/lib/esm/utils/sharedState.js.map +1 -0
- package/lib/esm/utils/unresolvedShape.d.ts +42 -0
- package/lib/esm/utils/unresolvedShape.js +68 -0
- package/lib/esm/utils/unresolvedShape.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getActiveShapeCatalog } from './ShapeClass.js';
|
|
2
|
+
/**
|
|
3
|
+
* The error core throws when a shape IRI does not resolve, carrying the IRIs as fields so a
|
|
4
|
+
* host can map it without parsing the message. It stays a plain `Error` (`name` is
|
|
5
|
+
* `'Error'`): only the message and the fields are added.
|
|
6
|
+
*/
|
|
7
|
+
export class UnresolvedShapeError extends Error {
|
|
8
|
+
constructor(message, details) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.shapeIri = details.shapeIri;
|
|
11
|
+
if (details.property !== undefined)
|
|
12
|
+
this.property = details.property;
|
|
13
|
+
if (details.propertyIri !== undefined)
|
|
14
|
+
this.propertyIri = details.propertyIri;
|
|
15
|
+
if (details.ownerShapeIri !== undefined)
|
|
16
|
+
this.ownerShapeIri = details.ownerShapeIri;
|
|
17
|
+
if (details.catalog !== undefined)
|
|
18
|
+
this.catalog = details.catalog;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The details for a property whose value shape does not resolve. The owner is the property's
|
|
23
|
+
* `parentNodeShape`, or `owner` when the caller knows it better (a path walk).
|
|
24
|
+
*/
|
|
25
|
+
export function unresolvedValueShapeDetails(ps, owner) {
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
27
|
+
const ownerShapeIri = (_a = owner === null || owner === void 0 ? void 0 : owner.id) !== null && _a !== void 0 ? _a : (_b = ps.parentNodeShape) === null || _b === void 0 ? void 0 : _b.id;
|
|
28
|
+
const catalog = (_c = getActiveShapeCatalog()) === null || _c === void 0 ? void 0 : _c.name;
|
|
29
|
+
return Object.assign(Object.assign(Object.assign({ shapeIri: (_e = (_d = ps.valueShape) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : '', property: ps.label }, (ps.path && typeof ps.path === 'object' && 'id' in ps.path && typeof ps.path.id === 'string'
|
|
30
|
+
? { propertyIri: ps.path.id }
|
|
31
|
+
: {})), (ownerShapeIri ? { ownerShapeIri } : {})), (catalog !== undefined ? { catalog } : {}));
|
|
32
|
+
}
|
|
33
|
+
/** The details for a shape named directly (a query's or mutation's own shape). */
|
|
34
|
+
export function topLevelDetails(shapeIri) {
|
|
35
|
+
var _a;
|
|
36
|
+
const catalog = (_a = getActiveShapeCatalog()) === null || _a === void 0 ? void 0 : _a.name;
|
|
37
|
+
return Object.assign({ shapeIri }, (catalog !== undefined ? { catalog } : {}));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Why the shape is missing, in words: `property 'home' of '<owner>' points at it; catalog
|
|
41
|
+
* 'p1#main' does not hold it`. Each error keeps its own leading sentence and appends this.
|
|
42
|
+
*/
|
|
43
|
+
export function describeUnresolved(details) {
|
|
44
|
+
const parts = [];
|
|
45
|
+
if (details.property !== undefined) {
|
|
46
|
+
parts.push(details.ownerShapeIri
|
|
47
|
+
? `property '${details.property}' of '${details.ownerShapeIri}' points at it`
|
|
48
|
+
: `property '${details.property}' points at it`);
|
|
49
|
+
}
|
|
50
|
+
if (getActiveShapeCatalog() !== undefined) {
|
|
51
|
+
parts.push(details.catalog !== undefined
|
|
52
|
+
? `catalog '${details.catalog}' does not hold it`
|
|
53
|
+
: 'the active catalog does not hold it');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
parts.push('it is not registered');
|
|
57
|
+
}
|
|
58
|
+
return parts.join('; ');
|
|
59
|
+
}
|
|
60
|
+
/** `<prefix> (<why>)` as an {@link UnresolvedShapeError}. */
|
|
61
|
+
export function unresolvedShapeError(prefix, details) {
|
|
62
|
+
return new UnresolvedShapeError(`${prefix} (${describeUnresolved(details)})`, details);
|
|
63
|
+
}
|
|
64
|
+
/** The error for a property whose `valueShape` does not resolve. */
|
|
65
|
+
export function unresolvedValueShapeError(prefix, ps, owner) {
|
|
66
|
+
return unresolvedShapeError(prefix, unresolvedValueShapeDetails(ps, owner));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=unresolvedShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unresolvedShape.js","sourceRoot":"","sources":["../../../src/utils/unresolvedShape.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAetD;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAO7C,YAAY,OAAe,EAAE,OAA+B;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACrE,IAAI,OAAO,CAAC,WAAW,K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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 type {NodeShapeData, PropertyShapeData} from '../shapes/nodeShapeData.js';\nimport {getActiveShapeCatalog} from './ShapeClass.js';\n\n/**\n * Where an unresolved shape was met: the shape IRI that could not be resolved and, when a\n * property pointed at it, that property and the shape that declares it. `catalog` is the\n * active catalog's `name`, absent in the global registry or for an unnamed catalog.\n */\nexport interface UnresolvedShapeDetails {\n shapeIri: string;\n property?: string;\n propertyIri?: string;\n ownerShapeIri?: string;\n catalog?: string;\n}\n\n/**\n * The error core throws when a shape IRI does not resolve, carrying the IRIs as fields so a\n * host can map it without parsing the message. It stays a plain `Error` (`name` is\n * `'Error'`): only the message and the fields are added.\n */\nexport class UnresolvedShapeError extends Error implements UnresolvedShapeDetails {\n readonly shapeIri: string;\n readonly property?: string;\n readonly propertyIri?: string;\n readonly ownerShapeIri?: string;\n readonly catalog?: string;\n\n constructor(message: string, details: UnresolvedShapeDetails) {\n super(message);\n this.shapeIri = details.shapeIri;\n if (details.property !== undefined) this.property = details.property;\n if (details.propertyIri !== undefined) this.propertyIri = details.propertyIri;\n if (details.ownerShapeIri !== undefined) this.ownerShapeIri = details.ownerShapeIri;\n if (details.catalog !== undefined) this.catalog = details.catalog;\n }\n}\n\n/**\n * The details for a property whose value shape does not resolve. The owner is the property's\n * `parentNodeShape`, or `owner` when the caller knows it better (a path walk).\n */\nexport function unresolvedValueShapeDetails(\n ps: PropertyShapeData,\n owner?: NodeShapeData,\n): UnresolvedShapeDetails {\n const ownerShapeIri = owner?.id ?? ps.parentNodeShape?.id;\n const catalog = getActiveShapeCatalog()?.name;\n return {\n shapeIri: ps.valueShape?.id ?? '',\n property: ps.label,\n ...(ps.path && typeof ps.path === 'object' && 'id' in ps.path && typeof ps.path.id === 'string'\n ? {propertyIri: ps.path.id}\n : {}),\n ...(ownerShapeIri ? {ownerShapeIri} : {}),\n ...(catalog !== undefined ? {catalog} : {}),\n };\n}\n\n/** The details for a shape named directly (a query's or mutation's own shape). */\nexport function topLevelDetails(shapeIri: string): UnresolvedShapeDetails {\n const catalog = getActiveShapeCatalog()?.name;\n return {shapeIri, ...(catalog !== undefined ? {catalog} : {})};\n}\n\n/**\n * Why the shape is missing, in words: `property 'home' of '<owner>' points at it; catalog\n * 'p1#main' does not hold it`. Each error keeps its own leading sentence and appends this.\n */\nexport function describeUnresolved(details: UnresolvedShapeDetails): string {\n const parts: string[] = [];\n if (details.property !== undefined) {\n parts.push(\n details.ownerShapeIri\n ? `property '${details.property}' of '${details.ownerShapeIri}' points at it`\n : `property '${details.property}' points at it`,\n );\n }\n if (getActiveShapeCatalog() !== undefined) {\n parts.push(\n details.catalog !== undefined\n ? `catalog '${details.catalog}' does not hold it`\n : 'the active catalog does not hold it',\n );\n } else {\n parts.push('it is not registered');\n }\n return parts.join('; ');\n}\n\n/** `<prefix> (<why>)` as an {@link UnresolvedShapeError}. */\nexport function unresolvedShapeError(\n prefix: string,\n details: UnresolvedShapeDetails,\n): UnresolvedShapeError {\n return new UnresolvedShapeError(`${prefix} (${describeUnresolved(details)})`, details);\n}\n\n/** The error for a property whose `valueShape` does not resolve. */\nexport function unresolvedValueShapeError(\n prefix: string,\n ps: PropertyShapeData,\n owner?: NodeShapeData,\n): UnresolvedShapeError {\n return unresolvedShapeError(prefix, unresolvedValueShapeDetails(ps, owner));\n}\n"]}
|