@_linked/core 2.36.1 → 2.36.3
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 +24 -0
- package/README.md +19 -0
- package/lib/esm/collections/CoreSet.js +2 -0
- package/lib/esm/collections/CoreSet.js.map +1 -1
- package/lib/esm/collections/ShapeSet.js +2 -0
- package/lib/esm/collections/ShapeSet.js.map +1 -1
- package/lib/esm/expressions/Expr.js +3 -2
- package/lib/esm/expressions/Expr.js.map +1 -1
- package/lib/esm/expressions/ExpressionNode.js +10 -7
- package/lib/esm/expressions/ExpressionNode.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/queries/AskBuilder.js +5 -3
- package/lib/esm/queries/AskBuilder.js.map +1 -1
- package/lib/esm/queries/CountBuilder.js +4 -2
- package/lib/esm/queries/CountBuilder.js.map +1 -1
- package/lib/esm/queries/CreateBuilder.js +2 -0
- package/lib/esm/queries/CreateBuilder.js.map +1 -1
- package/lib/esm/queries/DeleteBuilder.js +3 -1
- package/lib/esm/queries/DeleteBuilder.js.map +1 -1
- package/lib/esm/queries/DslJsonExpression.js +7 -6
- package/lib/esm/queries/DslJsonExpression.js.map +1 -1
- package/lib/esm/queries/FieldSet.js +10 -8
- package/lib/esm/queries/FieldSet.js.map +1 -1
- package/lib/esm/queries/IRLower.js +2 -1
- package/lib/esm/queries/IRLower.js.map +1 -1
- package/lib/esm/queries/MutationSerialization.js +2 -1
- package/lib/esm/queries/MutationSerialization.js.map +1 -1
- package/lib/esm/queries/PropertyPath.js +2 -0
- package/lib/esm/queries/PropertyPath.js.map +1 -1
- package/lib/esm/queries/ProxiedPathBuilder.js +2 -1
- package/lib/esm/queries/ProxiedPathBuilder.js.map +1 -1
- package/lib/esm/queries/QueryBuilder.js +5 -4
- package/lib/esm/queries/QueryBuilder.js.map +1 -1
- package/lib/esm/queries/QueryContext.js +17 -6
- package/lib/esm/queries/QueryContext.js.map +1 -1
- package/lib/esm/queries/SelectQuery.js +18 -12
- package/lib/esm/queries/SelectQuery.js.map +1 -1
- package/lib/esm/queries/UpdateBuilder.js +3 -1
- package/lib/esm/queries/UpdateBuilder.js.map +1 -1
- package/lib/esm/queries/lower.js +5 -4
- package/lib/esm/queries/lower.js.map +1 -1
- package/lib/esm/shapes/SHACL.js +6 -3
- package/lib/esm/shapes/SHACL.js.map +1 -1
- package/lib/esm/shapes/Shape.d.ts +3 -1
- package/lib/esm/shapes/Shape.js +20 -2
- package/lib/esm/shapes/Shape.js.map +1 -1
- package/lib/esm/utils/LinkedErrorLogging.d.ts +2 -1
- package/lib/esm/utils/LinkedErrorLogging.js +11 -0
- package/lib/esm/utils/LinkedErrorLogging.js.map +1 -1
- package/lib/esm/utils/LinkedFileStorage.d.ts +6 -4
- package/lib/esm/utils/LinkedFileStorage.js +34 -4
- package/lib/esm/utils/LinkedFileStorage.js.map +1 -1
- package/lib/esm/utils/Package.d.ts +6 -0
- package/lib/esm/utils/Package.js +35 -7
- package/lib/esm/utils/Package.js.map +1 -1
- package/lib/esm/utils/Prefix.d.ts +4 -2
- package/lib/esm/utils/Prefix.js +18 -2
- package/lib/esm/utils/Prefix.js.map +1 -1
- package/lib/esm/utils/ShapeClass.js +11 -6
- package/lib/esm/utils/ShapeClass.js.map +1 -1
- package/lib/esm/utils/cached.js +2 -1
- package/lib/esm/utils/cached.js.map +1 -1
- package/lib/esm/utils/linkedError.d.ts +32 -0
- package/lib/esm/utils/linkedError.js +63 -0
- package/lib/esm/utils/linkedError.js.map +1 -1
- package/lib/esm/utils/unresolvedShape.d.ts +3 -1
- package/lib/esm/utils/unresolvedShape.js +5 -1
- package/lib/esm/utils/unresolvedShape.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,12 +24,14 @@ export interface FileStorePurposeListing {
|
|
|
24
24
|
configured: boolean;
|
|
25
25
|
}
|
|
26
26
|
export declare abstract class LinkedFileStorage {
|
|
27
|
-
private static defaultStore;
|
|
28
|
-
private static
|
|
27
|
+
private static get defaultStore();
|
|
28
|
+
private static set defaultStore(value);
|
|
29
|
+
private static get url();
|
|
30
|
+
private static set url(value);
|
|
29
31
|
/** Purpose → the store configured for it. */
|
|
30
|
-
private static stores;
|
|
32
|
+
private static get stores();
|
|
31
33
|
/** Every declared purpose, configured or not. */
|
|
32
|
-
private static purposes;
|
|
34
|
+
private static get purposes();
|
|
33
35
|
/** Purposes already reported as falling back, so the log fires once each. */
|
|
34
36
|
private static loggedFallbacks;
|
|
35
37
|
static get accessURL(): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sharedState } from './sharedState.js';
|
|
1
2
|
/**
|
|
2
3
|
* Well-known file store purposes shipped with core.
|
|
3
4
|
*
|
|
@@ -12,7 +13,40 @@ export const FileStorePurposes = {
|
|
|
12
13
|
/** Built app bundles published by `linked build-app`. */
|
|
13
14
|
appAssets: 'appAssets',
|
|
14
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The configured stores, shared by every copy of core in the runtime: the server configures
|
|
18
|
+
* them through one copy and an upload may reach them through another.
|
|
19
|
+
*/
|
|
20
|
+
const storageState = sharedState('@_linked/core', 'LinkedFileStorage', () => ({
|
|
21
|
+
defaultStore: undefined,
|
|
22
|
+
/** The default accessURL, used while no default store is set. */
|
|
23
|
+
url: undefined,
|
|
24
|
+
/** Purpose → the store configured for it. */
|
|
25
|
+
stores: new Map(),
|
|
26
|
+
/** Every declared purpose, configured or not. */
|
|
27
|
+
purposes: new Map(),
|
|
28
|
+
}));
|
|
15
29
|
export class LinkedFileStorage {
|
|
30
|
+
static get defaultStore() {
|
|
31
|
+
return storageState.defaultStore;
|
|
32
|
+
}
|
|
33
|
+
static set defaultStore(store) {
|
|
34
|
+
storageState.defaultStore = store;
|
|
35
|
+
}
|
|
36
|
+
static get url() {
|
|
37
|
+
return storageState.url;
|
|
38
|
+
}
|
|
39
|
+
static set url(accessURL) {
|
|
40
|
+
storageState.url = accessURL;
|
|
41
|
+
}
|
|
42
|
+
/** Purpose → the store configured for it. */
|
|
43
|
+
static get stores() {
|
|
44
|
+
return storageState.stores;
|
|
45
|
+
}
|
|
46
|
+
/** Every declared purpose, configured or not. */
|
|
47
|
+
static get purposes() {
|
|
48
|
+
return storageState.purposes;
|
|
49
|
+
}
|
|
16
50
|
static get accessURL() {
|
|
17
51
|
// check if default store is not set, return default accessURL
|
|
18
52
|
if (!this.defaultStore) {
|
|
@@ -170,10 +204,6 @@ export class LinkedFileStorage {
|
|
|
170
204
|
registerWellKnownPurposes();
|
|
171
205
|
}
|
|
172
206
|
}
|
|
173
|
-
/** Purpose → the store configured for it. */
|
|
174
|
-
LinkedFileStorage.stores = new Map();
|
|
175
|
-
/** Every declared purpose, configured or not. */
|
|
176
|
-
LinkedFileStorage.purposes = new Map();
|
|
177
207
|
/** Purposes already reported as falling back, so the log fires once each. */
|
|
178
208
|
LinkedFileStorage.loggedFallbacks = new Set();
|
|
179
209
|
/** The purposes core ships with are declared at module load. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkedFileStorage.js","sourceRoot":"","sources":["../../../src/utils/LinkedFileStorage.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,4EAA4E;IAC5E,OAAO,EAAE,SAAS;IAClB,yDAAyD;IACzD,SAAS,EAAE,WAAW;CACd,CAAC;AAeX,MAAM,OAAgB,iBAAiB;IAWrC,MAAM,KAAK,SAAS;QAClB,8DAA8D;QAC9D,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,GAAG,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,SAAiB;QAC1C,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAChC,C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QAC1C,yBAAyB,EAAE,CAAC;IAC9B,CAAC;;AA1MD,6CAA6C;AAC9B,wBAAM,GAA4B,IAAI,GAAG,EAAE,CAAC;AAC3D,iDAAiD;AAClC,0BAAQ,GAAsC,IAAI,GAAG,EAAE,CAAC;AACvE,6EAA6E;AAC9D,iCAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;AAwM1D,gEAAgE;AAChE,SAAS,yBAAyB;IAChC,iBAAiB,CAAC,eAAe,CAAC,iBAAiB,CAAC,OAAO,EAAE;QAC3D,WAAW,EAAE,wDAAwD;KACtE,CAAC,CAAC;IACH,iBAAiB,CAAC,eAAe,CAAC,iBAAiB,CAAC,SAAS,EAAE;QAC7D,WAAW,EAAE,oDAAoD;KAClE,CAAC,CAAC;AACL,CAAC;AAED,yBAAyB,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,YAAoB,SAAS;IAC/D,2EAA2E;IAC3E,sEAAsE;IACtE,wEAAwE;IACxE,0EAA0E;IAC1E,6CAA6C;IAC7C,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC9C,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9C,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type {IFileStore, SaveFileOptions} from '../interfaces/IFileStore.js';\nimport type {Readable} from 'stream';\n\n/**\n * Well-known file store purposes shipped with core.\n *\n * Core itself never writes to `appAssets`; it lives here as the documented\n * convention (plan 011 D4) so the CLI and apps agree on the same key without a\n * shared runtime dependency. Any *new* purpose's constant belongs in the\n * runtime package that owns the concept, not here and not in the CLI.\n */\nexport const FileStorePurposes = {\n /** User-generated files. Resolves to the default store unless split out. */\n uploads: 'uploads',\n /** Built app bundles published by `linked build-app`. */\n appAssets: 'appAssets',\n} as const;\n\nexport type FileStorePurpose =\n (typeof FileStorePurposes)[keyof typeof FileStorePurposes];\n\nexport interface FileStorePurposeInfo {\n description?: string;\n}\n\nexport interface FileStorePurposeListing {\n purpose: string;\n description?: string;\n configured: boolean;\n}\n\nexport abstract class LinkedFileStorage {\n private static defaultStore: IFileStore;\n private static url: string; // default accessURL\n\n /** Purpose → the store configured for it. */\n private static stores: Map<string, IFileStore> = new Map();\n /** Every declared purpose, configured or not. */\n private static purposes: Map<string, FileStorePurposeInfo> = new Map();\n /** Purposes already reported as falling back, so the log fires once each. */\n private static loggedFallbacks: Set<string> = new Set();\n\n static get accessURL(): string {\n // check if default store is not set, return default accessURL\n if (!this.defaultStore) {\n return this.url;\n }\n\n return this.defaultStore.accessURL;\n }\n\n static setDefaultAccessURL(accessURL: string): string {\n return (this.url = accessURL);\n }\n\n static getDefaultStore(): IFileStore {\n return this.defaultStore;\n }\n\n /**\n * Configure the default store: the fallback for *every* purpose, `uploads`\n * included.\n *\n * It deliberately writes no entry into the purpose → store map, so `uploads`\n * behaves exactly like `appAssets`: an explicit `setStore('uploads', other)`\n * wins whenever it is called, before or after this, and `hasStore('uploads')`\n * stays false until such a call is made.\n */\n static setDefaultStore(store: IFileStore) {\n this.defaultStore = store;\n\n if (this.defaultStore.init) {\n this.defaultStore.init();\n }\n }\n\n /** @deprecated use {@link LinkedFileStorage.getDefaultStore} */\n static getDefaultDataset(): IFileStore {\n return this.getDefaultStore();\n }\n\n /** @deprecated use {@link LinkedFileStorage.setDefaultStore} */\n static setDefaultDataset(dataset: IFileStore) {\n this.setDefaultStore(dataset);\n }\n\n /**\n * Declare a purpose without configuring a store for it.\n *\n * A package that *reads* a purpose the app may leave unconfigured registers\n * it in the same module that exports its constant, so importing the constant\n * is the registration and ordering resolves itself.\n */\n static registerPurpose(purpose: string, info: FileStorePurposeInfo = {}) {\n const existing = this.purposes.get(purpose);\n // Keep an existing description rather than blanking it on a re-register.\n this.purposes.set(purpose, {\n description: info.description ?? existing?.description,\n });\n }\n\n /** Configure the store for a purpose. Also registers the purpose. */\n static setStore(purpose: string, store: IFileStore) {\n this.registerPurpose(purpose);\n this.stores.set(purpose, store);\n\n if (store.init) {\n store.init();\n }\n }\n\n /**\n * Resolve the store for a purpose (plan 011 D2):\n * - configured → that store;\n * - registered, not configured → the default store, logged once;\n * - not registered → throws.\n *\n * Unregistered throws on purpose: only a registry can tell \"the app did not\n * split this purpose out\" apart from a typo. Without it, `'appAsset'` would\n * silently write release bundles into the uploads store.\n *\n * The returned store is a **live reference**, resolved once at call time. A\n * caller that holds on to a store returned through the default-store fallback\n * keeps that object even after a later `setStore(purpose, other)`; call\n * `getStore` again per operation if the configuration can change at runtime.\n */\n static getStore(purpose: string): IFileStore {\n const configured = this.stores.get(purpose);\n if (configured) {\n return configured;\n }\n\n if (!this.purposes.has(purpose)) {\n throw new Error(\n `Unknown file store purpose '${purpose}'. Register it with LinkedFileStorage.setStore(), ` +\n `or import the package that defines it. Known purposes: ${\n this.listPurposes()\n .map((entry) => entry.purpose)\n .join(', ') || '(none)'\n }`,\n );\n }\n\n if (!this.defaultStore) {\n throw new Error(\n `No file store is configured for purpose '${purpose}', and no default store is configured. ` +\n `Call LinkedFileStorage.setStore('${purpose}', store) or LinkedFileStorage.setDefaultStore(store).`,\n );\n }\n\n if (!this.loggedFallbacks.has(purpose)) {\n this.loggedFallbacks.add(purpose);\n // `debug`, not `info`: falling back is the normal configuration for an\n // app that runs one store, so this must not read as a problem or show up\n // in default-level logs. It stays available when diagnosing which store a\n // purpose actually resolved to.\n console.debug(\n `[LinkedFileStorage] Purpose '${purpose}' has no dedicated store; using the default store.`,\n );\n }\n\n return this.defaultStore;\n }\n\n /**\n * Whether a store was *explicitly configured* for this purpose.\n *\n * The default-store fallback is deliberately ignored: `hasStore(p)` is false\n * while `getStore(p)` still returns a usable store via the default. Use this\n * to ask \"did the app split this purpose out?\", never as a guard before\n * `getStore` — that would skip a perfectly working fallback.\n */\n static hasStore(purpose: string): boolean {\n return this.stores.has(purpose);\n }\n\n /** Every declared purpose, with whether it has its own store. */\n static listPurposes(): FileStorePurposeListing[] {\n return Array.from(this.purposes.entries()).map(([purpose, info]) => ({\n purpose,\n description: info.description,\n configured: this.stores.has(purpose),\n }));\n }\n\n /** The access URL of the store resolved for this purpose. */\n static accessURLFor(purpose: string): string {\n return this.getStore(purpose).accessURL;\n }\n\n static deleteFile(filePath: string): Promise<void> {\n return this.defaultStore.deleteFile(filePath);\n }\n\n static fileExists(filePath: string): Promise<boolean> {\n return this.defaultStore.fileExists(filePath);\n }\n\n static getFile(filePath: string): Promise<Buffer> {\n return this.defaultStore.getFile(filePath);\n }\n\n static listFiles(prefix?: string): Promise<string[]> {\n return this.defaultStore.listFiles(prefix);\n }\n\n static saveFile(\n filePath: string,\n fileContent: string | Uint8Array | Buffer | Readable,\n options?: SaveFileOptions | string,\n /**\n * Forwarded exactly as given. No default here on purpose: \"unspecified\"\n * must reach the store so it can apply its own default.\n */\n preventDuplicates?: boolean,\n ): Promise<string> {\n return this.defaultStore.saveFile(\n filePath,\n fileContent,\n options,\n preventDuplicates,\n );\n }\n\n /**\n * Clears the module-global registry and default store.\n * For tests only — the registry is process-wide state.\n *\n * @internal\n */\n static resetForTests() {\n this.stores.clear();\n this.purposes.clear();\n this.loggedFallbacks.clear();\n this.defaultStore = undefined as unknown as IFileStore;\n this.url = undefined as unknown as string;\n registerWellKnownPurposes();\n }\n}\n\n/** The purposes core ships with are declared at module load. */\nfunction registerWellKnownPurposes() {\n LinkedFileStorage.registerPurpose(FileStorePurposes.uploads, {\n description: 'User-generated files. Falls back to the default store.',\n });\n LinkedFileStorage.registerPurpose(FileStorePurposes.appAssets, {\n description: 'Built app bundles published by `linked build-app`.',\n });\n}\n\nregisterWellKnownPurposes();\n\n/**\n * Get the full path of an asset based on the way LinkedFileStorage is configured\n * Returns accessURL + directory (/public by default) + path\n * @param path asset path\n * @param directory asset directory (optional, default is /public)\n * @returns asset url. e.g. https://cdn.example.com/public/image.png\n */\nexport function asset(path: string, directory: string = '/public'): string {\n // Some callers pass a raw app-relative path like `/images/foo.webp`, while\n // others may already have a fully qualified asset URL from an earlier\n // `asset(...)` call or backend response normalization. Keep this helper\n // idempotent so shared card/image components can safely call `asset(...)`\n // without duplicating the access URL prefix.\n if (/^(?:[a-z]+:)?\\/\\//i.test(path) || path.startsWith('data:') || path.startsWith('blob:')) {\n return path;\n }\n\n const accessURL = LinkedFileStorage.accessURL;\n const assetUrl = accessURL + directory + path;\n return assetUrl;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LinkedFileStorage.js","sourceRoot":"","sources":["../../../src/utils/LinkedFileStorage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,4EAA4E;IAC5E,OAAO,EAAE,SAAS;IAClB,yDAAyD;IACzD,SAAS,EAAE,WAAW;CACd,CAAC;AAeX;;;GAGG;AACH,MAAM,YAAY,GAAG,WAAW,CAAC,eAAe,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5E,YAAY,EAAE,SAAmC;IACjD,iEAAiE;IACjE,GAAG,EAAE,SAA+B;IACpC,6CAA6C;IAC7C,MAAM,EAAE,IAAI,GAAG,EAAsB;IACrC,iDAAiD;IACjD,QAAQ,EAAE,IAAI,GAAG,EAAgC;CAClD,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAgB,iBAAiB;IAC7B,MAAM,KAAK,YAAY;QAC7B,OAAO,YAAY,CAAC,YAA0B,CAAC;IACjD,CAAC;IACO,MAAM,KAAK,YAAY,CAAC,KAAiB;QAC/C,YAAY,CAAC,YAAY,GAAG,KAAK,CAAC;IACpC,CAAC;IACO,MAAM,KAAK,GAAG;QACp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O,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC9C,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9C,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type {IFileStore, SaveFileOptions} from '../interfaces/IFileStore.js';\nimport type {Readable} from 'stream';\nimport {sharedState} from './sharedState.js';\n\n/**\n * Well-known file store purposes shipped with core.\n *\n * Core itself never writes to `appAssets`; it lives here as the documented\n * convention (plan 011 D4) so the CLI and apps agree on the same key without a\n * shared runtime dependency. Any *new* purpose's constant belongs in the\n * runtime package that owns the concept, not here and not in the CLI.\n */\nexport const FileStorePurposes = {\n /** User-generated files. Resolves to the default store unless split out. */\n uploads: 'uploads',\n /** Built app bundles published by `linked build-app`. */\n appAssets: 'appAssets',\n} as const;\n\nexport type FileStorePurpose =\n (typeof FileStorePurposes)[keyof typeof FileStorePurposes];\n\nexport interface FileStorePurposeInfo {\n description?: string;\n}\n\nexport interface FileStorePurposeListing {\n purpose: string;\n description?: string;\n configured: boolean;\n}\n\n/**\n * The configured stores, shared by every copy of core in the runtime: the server configures\n * them through one copy and an upload may reach them through another.\n */\nconst storageState = sharedState('@_linked/core', 'LinkedFileStorage', () => ({\n defaultStore: undefined as IFileStore | undefined,\n /** The default accessURL, used while no default store is set. */\n url: undefined as string | undefined,\n /** Purpose → the store configured for it. */\n stores: new Map<string, IFileStore>(),\n /** Every declared purpose, configured or not. */\n purposes: new Map<string, FileStorePurposeInfo>(),\n}));\n\nexport abstract class LinkedFileStorage {\n private static get defaultStore(): IFileStore {\n return storageState.defaultStore as IFileStore;\n }\n private static set defaultStore(store: IFileStore) {\n storageState.defaultStore = store;\n }\n private static get url(): string {\n return storageState.url as string;\n }\n private static set url(accessURL: string) {\n storageState.url = accessURL;\n }\n\n /** Purpose → the store configured for it. */\n private static get stores(): Map<string, IFileStore> {\n return storageState.stores;\n }\n /** Every declared purpose, configured or not. */\n private static get purposes(): Map<string, FileStorePurposeInfo> {\n return storageState.purposes;\n }\n /** Purposes already reported as falling back, so the log fires once each. */\n private static loggedFallbacks: Set<string> = new Set();\n\n static get accessURL(): string {\n // check if default store is not set, return default accessURL\n if (!this.defaultStore) {\n return this.url;\n }\n\n return this.defaultStore.accessURL;\n }\n\n static setDefaultAccessURL(accessURL: string): string {\n return (this.url = accessURL);\n }\n\n static getDefaultStore(): IFileStore {\n return this.defaultStore;\n }\n\n /**\n * Configure the default store: the fallback for *every* purpose, `uploads`\n * included.\n *\n * It deliberately writes no entry into the purpose → store map, so `uploads`\n * behaves exactly like `appAssets`: an explicit `setStore('uploads', other)`\n * wins whenever it is called, before or after this, and `hasStore('uploads')`\n * stays false until such a call is made.\n */\n static setDefaultStore(store: IFileStore) {\n this.defaultStore = store;\n\n if (this.defaultStore.init) {\n this.defaultStore.init();\n }\n }\n\n /** @deprecated use {@link LinkedFileStorage.getDefaultStore} */\n static getDefaultDataset(): IFileStore {\n return this.getDefaultStore();\n }\n\n /** @deprecated use {@link LinkedFileStorage.setDefaultStore} */\n static setDefaultDataset(dataset: IFileStore) {\n this.setDefaultStore(dataset);\n }\n\n /**\n * Declare a purpose without configuring a store for it.\n *\n * A package that *reads* a purpose the app may leave unconfigured registers\n * it in the same module that exports its constant, so importing the constant\n * is the registration and ordering resolves itself.\n */\n static registerPurpose(purpose: string, info: FileStorePurposeInfo = {}) {\n const existing = this.purposes.get(purpose);\n // Keep an existing description rather than blanking it on a re-register.\n this.purposes.set(purpose, {\n description: info.description ?? existing?.description,\n });\n }\n\n /** Configure the store for a purpose. Also registers the purpose. */\n static setStore(purpose: string, store: IFileStore) {\n this.registerPurpose(purpose);\n this.stores.set(purpose, store);\n\n if (store.init) {\n store.init();\n }\n }\n\n /**\n * Resolve the store for a purpose (plan 011 D2):\n * - configured → that store;\n * - registered, not configured → the default store, logged once;\n * - not registered → throws.\n *\n * Unregistered throws on purpose: only a registry can tell \"the app did not\n * split this purpose out\" apart from a typo. Without it, `'appAsset'` would\n * silently write release bundles into the uploads store.\n *\n * The returned store is a **live reference**, resolved once at call time. A\n * caller that holds on to a store returned through the default-store fallback\n * keeps that object even after a later `setStore(purpose, other)`; call\n * `getStore` again per operation if the configuration can change at runtime.\n */\n static getStore(purpose: string): IFileStore {\n const configured = this.stores.get(purpose);\n if (configured) {\n return configured;\n }\n\n if (!this.purposes.has(purpose)) {\n throw new Error(\n `Unknown file store purpose '${purpose}'. Register it with LinkedFileStorage.setStore(), ` +\n `or import the package that defines it. Known purposes: ${\n this.listPurposes()\n .map((entry) => entry.purpose)\n .join(', ') || '(none)'\n }`,\n );\n }\n\n if (!this.defaultStore) {\n throw new Error(\n `No file store is configured for purpose '${purpose}', and no default store is configured. ` +\n `Call LinkedFileStorage.setStore('${purpose}', store) or LinkedFileStorage.setDefaultStore(store).`,\n );\n }\n\n if (!this.loggedFallbacks.has(purpose)) {\n this.loggedFallbacks.add(purpose);\n // `debug`, not `info`: falling back is the normal configuration for an\n // app that runs one store, so this must not read as a problem or show up\n // in default-level logs. It stays available when diagnosing which store a\n // purpose actually resolved to.\n console.debug(\n `[LinkedFileStorage] Purpose '${purpose}' has no dedicated store; using the default store.`,\n );\n }\n\n return this.defaultStore;\n }\n\n /**\n * Whether a store was *explicitly configured* for this purpose.\n *\n * The default-store fallback is deliberately ignored: `hasStore(p)` is false\n * while `getStore(p)` still returns a usable store via the default. Use this\n * to ask \"did the app split this purpose out?\", never as a guard before\n * `getStore` — that would skip a perfectly working fallback.\n */\n static hasStore(purpose: string): boolean {\n return this.stores.has(purpose);\n }\n\n /** Every declared purpose, with whether it has its own store. */\n static listPurposes(): FileStorePurposeListing[] {\n return Array.from(this.purposes.entries()).map(([purpose, info]) => ({\n purpose,\n description: info.description,\n configured: this.stores.has(purpose),\n }));\n }\n\n /** The access URL of the store resolved for this purpose. */\n static accessURLFor(purpose: string): string {\n return this.getStore(purpose).accessURL;\n }\n\n static deleteFile(filePath: string): Promise<void> {\n return this.defaultStore.deleteFile(filePath);\n }\n\n static fileExists(filePath: string): Promise<boolean> {\n return this.defaultStore.fileExists(filePath);\n }\n\n static getFile(filePath: string): Promise<Buffer> {\n return this.defaultStore.getFile(filePath);\n }\n\n static listFiles(prefix?: string): Promise<string[]> {\n return this.defaultStore.listFiles(prefix);\n }\n\n static saveFile(\n filePath: string,\n fileContent: string | Uint8Array | Buffer | Readable,\n options?: SaveFileOptions | string,\n /**\n * Forwarded exactly as given. No default here on purpose: \"unspecified\"\n * must reach the store so it can apply its own default.\n */\n preventDuplicates?: boolean,\n ): Promise<string> {\n return this.defaultStore.saveFile(\n filePath,\n fileContent,\n options,\n preventDuplicates,\n );\n }\n\n /**\n * Clears the module-global registry and default store.\n * For tests only — the registry is process-wide state.\n *\n * @internal\n */\n static resetForTests() {\n this.stores.clear();\n this.purposes.clear();\n this.loggedFallbacks.clear();\n this.defaultStore = undefined as unknown as IFileStore;\n this.url = undefined as unknown as string;\n registerWellKnownPurposes();\n }\n}\n\n/** The purposes core ships with are declared at module load. */\nfunction registerWellKnownPurposes() {\n LinkedFileStorage.registerPurpose(FileStorePurposes.uploads, {\n description: 'User-generated files. Falls back to the default store.',\n });\n LinkedFileStorage.registerPurpose(FileStorePurposes.appAssets, {\n description: 'Built app bundles published by `linked build-app`.',\n });\n}\n\nregisterWellKnownPurposes();\n\n/**\n * Get the full path of an asset based on the way LinkedFileStorage is configured\n * Returns accessURL + directory (/public by default) + path\n * @param path asset path\n * @param directory asset directory (optional, default is /public)\n * @returns asset url. e.g. https://cdn.example.com/public/image.png\n */\nexport function asset(path: string, directory: string = '/public'): string {\n // Some callers pass a raw app-relative path like `/images/foo.webp`, while\n // others may already have a fully qualified asset URL from an earlier\n // `asset(...)` call or backend response normalization. Keep this helper\n // idempotent so shared card/image components can safely call `asset(...)`\n // without duplicating the access URL prefix.\n if (/^(?:[a-z]+:)?\\/\\//i.test(path) || path.startsWith('data:') || path.startsWith('blob:')) {\n return path;\n }\n\n const accessURL = LinkedFileStorage.accessURL;\n const assetUrl = accessURL + directory + path;\n return assetUrl;\n}\n"]}
|
|
@@ -158,8 +158,14 @@ export interface LinkedPackageObject {
|
|
|
158
158
|
*/
|
|
159
159
|
registerPackageModule(_module: any): void;
|
|
160
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* The default page size. A live binding that follows `setDefaultPageLimit` calls made through
|
|
163
|
+
* any copy of core; {@link getDefaultPageLimit} reads the same value.
|
|
164
|
+
*/
|
|
161
165
|
export declare var DEFAULT_LIMIT: number;
|
|
162
166
|
export declare function setDefaultPageLimit(limit: number): void;
|
|
167
|
+
/** The default page size set with {@link setDefaultPageLimit} (12 unless set). */
|
|
168
|
+
export declare function getDefaultPageLimit(): number;
|
|
163
169
|
export declare function autoLoadOntologyData(value: boolean): void;
|
|
164
170
|
export declare function linkedPackage(packageName: string, options?: {
|
|
165
171
|
baseUri?: string;
|
package/lib/esm/utils/Package.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a, _b;
|
|
1
2
|
/*
|
|
2
3
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
@@ -8,6 +9,7 @@ import { createNodeShapeData } from '../shapes/nodeShapeData.js';
|
|
|
8
9
|
import { Shape } from '../shapes/Shape.js';
|
|
9
10
|
import { List } from '../shapes/List.class.js';
|
|
10
11
|
import { Prefix } from './Prefix.js';
|
|
12
|
+
import { sharedState } from './sharedState.js';
|
|
11
13
|
import { coreOntology } from '../ontologies/linked-core.js';
|
|
12
14
|
import { rdf } from '../ontologies/rdf.js';
|
|
13
15
|
import { addNodeShapeToShapeClass, getShapeClass } from './ShapeClass.js';
|
|
@@ -16,16 +18,42 @@ import { rdfs } from '../ontologies/rdfs.js';
|
|
|
16
18
|
import { xsd } from '../ontologies/xsd.js';
|
|
17
19
|
// var packageParsePromises: Map<string,Promise<any>> = new Map();
|
|
18
20
|
// var loadedPackages: Set<NamedNode> = new Set();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Ontology registrations and package settings, shared by every copy of core in the runtime:
|
|
23
|
+
* `autoLoadOntologyData(true)` through one copy loads ontologies another copy registered, and
|
|
24
|
+
* `setDefaultPageLimit` through either sets the limit both read.
|
|
25
|
+
*/
|
|
26
|
+
const packageState = sharedState('@_linked/core', 'Package', () => ({
|
|
27
|
+
ontologies: new Set(),
|
|
28
|
+
autoLoadOntologyData: false,
|
|
29
|
+
defaultLimit: 12,
|
|
30
|
+
/** One setter per copy of this module, keeping that copy's `DEFAULT_LIMIT` binding in step. */
|
|
31
|
+
limitBindings: new Set(),
|
|
32
|
+
}));
|
|
33
|
+
// A container an older copy of core created lacks the fields added since.
|
|
34
|
+
(_a = packageState.defaultLimit) !== null && _a !== void 0 ? _a : (packageState.defaultLimit = 12);
|
|
35
|
+
(_b = packageState.limitBindings) !== null && _b !== void 0 ? _b : (packageState.limitBindings = new Set());
|
|
36
|
+
const ontologies = packageState.ontologies;
|
|
37
|
+
/**
|
|
38
|
+
* The default page size. A live binding that follows `setDefaultPageLimit` calls made through
|
|
39
|
+
* any copy of core; {@link getDefaultPageLimit} reads the same value.
|
|
40
|
+
*/
|
|
41
|
+
export var DEFAULT_LIMIT = packageState.defaultLimit;
|
|
42
|
+
packageState.limitBindings.add((limit) => {
|
|
23
43
|
DEFAULT_LIMIT = limit;
|
|
44
|
+
});
|
|
45
|
+
export function setDefaultPageLimit(limit) {
|
|
46
|
+
packageState.defaultLimit = limit;
|
|
47
|
+
packageState.limitBindings.forEach((bind) => bind(limit));
|
|
48
|
+
}
|
|
49
|
+
/** The default page size set with {@link setDefaultPageLimit} (12 unless set). */
|
|
50
|
+
export function getDefaultPageLimit() {
|
|
51
|
+
return packageState.defaultLimit;
|
|
24
52
|
}
|
|
25
53
|
export function autoLoadOntologyData(value) {
|
|
26
|
-
|
|
54
|
+
packageState.autoLoadOntologyData = value;
|
|
27
55
|
//this may be set to true after some ontologies have already indexed,
|
|
28
|
-
if (
|
|
56
|
+
if (value) {
|
|
29
57
|
// so in that case we load all data of ontologies that are already indexed
|
|
30
58
|
ontologies.forEach((ontologyExport) => {
|
|
31
59
|
//see linkedOntology() where we store the data loading method under the _load key
|
|
@@ -203,7 +231,7 @@ export function linkedPackage(packageName, options) {
|
|
|
203
231
|
//register all the exports under the prefix. NOTE: this means the file name HAS to match the prefix
|
|
204
232
|
registerInPackageTree(prefixAndFileName, exportsCopy);
|
|
205
233
|
// });
|
|
206
|
-
if (
|
|
234
|
+
if (packageState.autoLoadOntologyData) {
|
|
207
235
|
loadData().catch((err) => {
|
|
208
236
|
console.warn('Could not load ontology data. Do you need to rebuild the module of the ' +
|
|
209
237
|
prefixAndFileName +
|
|
@@ -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,EAA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H;AACxH,mBAAmB,CACjB,EAAC,IAAI,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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E;AAC5E,mBAAmB,CACjB,EAAC,IAAI,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAC,EACjE,WAAW,EACX,KAAK,CAAC,OAAO,EACb,SAAS,CACV,CAAC;AAEF,mFAAmF;AACnF,2EAA2E;AAC3E,+FAA+F;AAC/F,8FAA8F;AAC9F,iGAAiG;AACjG,wHAAwH;AACxH,mBAAmB,CACjB,EAAC,IAAI,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 {sharedState} from './sharedState.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();\n/**\n * Ontology registrations and package settings, shared by every copy of core in the runtime:\n * `autoLoadOntologyData(true)` through one copy loads ontologies another copy registered, and\n * `setDefaultPageLimit` through either sets the limit both read.\n */\nconst packageState = sharedState('@_linked/core', 'Package', () => ({\n ontologies: new Set<any>(),\n autoLoadOntologyData: false,\n defaultLimit: 12,\n /** One setter per copy of this module, keeping that copy's `DEFAULT_LIMIT` binding in step. */\n limitBindings: new Set<(limit: number) => void>(),\n}));\n// A container an older copy of core created lacks the fields added since.\npackageState.defaultLimit ??= 12;\npackageState.limitBindings ??= new Set();\nconst ontologies = packageState.ontologies;\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\n/**\n * The default page size. A live binding that follows `setDefaultPageLimit` calls made through\n * any copy of core; {@link getDefaultPageLimit} reads the same value.\n */\nexport var DEFAULT_LIMIT = packageState.defaultLimit;\npackageState.limitBindings.add((limit) => {\n DEFAULT_LIMIT = limit;\n});\n\nexport function setDefaultPageLimit(limit: number)\n{\n packageState.defaultLimit = limit;\n packageState.limitBindings.forEach((bind) => bind(limit));\n}\n\n/** The default page size set with {@link setDefaultPageLimit} (12 unless set). */\nexport function getDefaultPageLimit(): number\n{\n return packageState.defaultLimit;\n}\n\nexport function autoLoadOntologyData(value: boolean)\n{\n packageState.autoLoadOntologyData = value;\n //this may be set to true after some ontologies have already indexed,\n if (value)\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 (packageState.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"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare class Prefix {
|
|
2
|
-
static uriToPrefix: Map<string, string>;
|
|
3
|
-
static
|
|
2
|
+
static get uriToPrefix(): Map<string, string>;
|
|
3
|
+
static set uriToPrefix(map: Map<string, string>);
|
|
4
|
+
static get prefixToUri(): Map<string, string>;
|
|
5
|
+
static set prefixToUri(map: Map<string, string>);
|
|
4
6
|
static getUriToPrefixMap(): Map<string, string>;
|
|
5
7
|
static getPrefixToUriMap(): Map<string, string>;
|
|
6
8
|
static add(prefix: string, fullURI: string): void;
|
package/lib/esm/utils/Prefix.js
CHANGED
|
@@ -3,7 +3,25 @@
|
|
|
3
3
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
4
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
+
import { sharedState } from './sharedState.js';
|
|
7
|
+
/** The prefix maps, shared so a prefix registered through one copy of core serialises in all. */
|
|
8
|
+
const prefixState = sharedState('@_linked/core', 'Prefix', () => ({
|
|
9
|
+
uriToPrefix: new Map(),
|
|
10
|
+
prefixToUri: new Map(),
|
|
11
|
+
}));
|
|
6
12
|
export class Prefix {
|
|
13
|
+
static get uriToPrefix() {
|
|
14
|
+
return prefixState.uriToPrefix;
|
|
15
|
+
}
|
|
16
|
+
static set uriToPrefix(map) {
|
|
17
|
+
prefixState.uriToPrefix = map;
|
|
18
|
+
}
|
|
19
|
+
static get prefixToUri() {
|
|
20
|
+
return prefixState.prefixToUri;
|
|
21
|
+
}
|
|
22
|
+
static set prefixToUri(map) {
|
|
23
|
+
prefixState.prefixToUri = map;
|
|
24
|
+
}
|
|
7
25
|
static getUriToPrefixMap() {
|
|
8
26
|
return this.uriToPrefix;
|
|
9
27
|
}
|
|
@@ -123,6 +141,4 @@ export class Prefix {
|
|
|
123
141
|
}
|
|
124
142
|
}
|
|
125
143
|
}
|
|
126
|
-
Prefix.uriToPrefix = new Map();
|
|
127
|
-
Prefix.prefixToUri = new Map();
|
|
128
144
|
//# sourceMappingURL=Prefix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prefix.js","sourceRoot":"","sources":["../../../src/utils/Prefix.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,MAAM;
|
|
1
|
+
{"version":3,"file":"Prefix.js","sourceRoot":"","sources":["../../../src/utils/Prefix.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AA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C,GAAG;QACxB,0EAA0E;QAC1E,0DAA0D;QAC1D,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QACnC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAClC,IAAI,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;CACF","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 {sharedState} from './sharedState.js';\n\n/** The prefix maps, shared so a prefix registered through one copy of core serialises in all. */\nconst prefixState = sharedState('@_linked/core', 'Prefix', () => ({\n uriToPrefix: new Map<string, string>(),\n prefixToUri: new Map<string, string>(),\n}));\n\nexport class Prefix {\n static get uriToPrefix(): Map<string, string> {\n return prefixState.uriToPrefix;\n }\n static set uriToPrefix(map: Map<string, string>) {\n prefixState.uriToPrefix = map;\n }\n static get prefixToUri(): Map<string, string> {\n return prefixState.prefixToUri;\n }\n static set prefixToUri(map: Map<string, string>) {\n prefixState.prefixToUri = map;\n }\n\n static getUriToPrefixMap() {\n return this.uriToPrefix;\n }\n\n static getPrefixToUriMap() {\n return this.prefixToUri;\n }\n\n static add(prefix: string, fullURI: string) {\n this.uriToPrefix.set(fullURI, prefix);\n this.prefixToUri.set(prefix, fullURI);\n }\n\n static delete(prefix: string) {\n if (this.prefixToUri.has(prefix)) {\n let fullURI = this.getFullURI(prefix);\n this.uriToPrefix.delete(fullURI);\n this.prefixToUri.delete(prefix);\n }\n }\n\n static clear() {\n this.uriToPrefix = new Map<string, string>();\n this.prefixToUri = new Map<string, string>();\n }\n\n static getPrefix(fullURI: string): string {\n if (this.uriToPrefix.has(fullURI)) {\n return this.uriToPrefix.get(fullURI);\n }\n let match = this.findMatch(fullURI);\n if (match.length > 0) return match[1];\n }\n\n static getFullURI(prefix: string): string {\n return this.prefixToUri.get(prefix);\n }\n\n\n static findMatch(fullURI: string): [string, string, string] | [] {\n for (let [ontologyURI, prefix] of this.uriToPrefix.entries()) {\n if (fullURI.substring(0, ontologyURI.length) == ontologyURI) {\n return [ontologyURI, prefix, fullURI.substring(ontologyURI.length)];\n }\n }\n return [];\n }\n\n /**\n * Compact a full IRI to `prefix:local`, but ONLY when `local` is a legal\n * SPARQL 1.1 `PN_LOCAL`. Otherwise undefined, so callers emit `<full-iri>`.\n *\n * Returning an invalid prefixed name is not a cosmetic problem: `#` is not in\n * `PN_LOCAL`, so a namespace that merely string-prefixes another one turns\n * `https://data.create.now/access#PolicyRegistry` into\n * `create-now:access#PolicyRegistry`, where the tokenizer ends the name at\n * `create-now:access` and reads `#PolicyRegistry .` as a COMMENT — eating the\n * triple terminator and producing a query the store rejects with a parse\n * error that points at the *next* line. See docs/plans/041.\n *\n * The check is an allowlist on purpose. A blocklist (this used to exclude\n * only `/`) is wrong again the moment another illegal character shows up;\n * over-rejecting only costs a longer full IRI, never correctness.\n */\n static toPrefixed(fullURI: string) {\n let match = this.findMatch(fullURI);\n if (match.length > 0) {\n const postFix = fullURI.substring(match[0].length);\n if (Prefix.isValidLocalName(postFix)) {\n return match[1] + ':' + postFix;\n }\n }\n }\n\n /**\n * Is this a local part we can safely emit after `prefix:`?\n *\n * A conservative ASCII subset of `PN_LOCAL`: no leading/trailing `.`, no `%`\n * escapes, and none of the characters (`#`, `/`, `?`, `@`, ...) that would\n * end the token early. Empty is allowed — `prefix:` is a valid PNAME_LN.\n */\n static isValidLocalName(local: string): boolean {\n if (local === '') return true;\n return /^[A-Za-z0-9_:](?:[A-Za-z0-9_:.-]*[A-Za-z0-9_:-])?$/.test(local);\n }\n\n static toPrefixedIfPossible(fullURI: string) {\n return this.toPrefixed(fullURI) || fullURI;\n }\n\n static toFullIfPossible(fullURI: string): string {\n let res = this._toFull(fullURI);\n if(res) {\n return res;\n }\n return fullURI;\n }\n\n /**\n * Converts a prefixed URI back to its full URI\n * Will return the prefixed URI if no prefix was found\n * @param uri\n */\n static toFull(uri) {\n let res = this._toFull(uri);\n if(res) {\n return res;\n }\n const colon = uri.indexOf(':');\n const prefix = colon === -1 ? uri : uri.slice(0, colon);\n throw new Error(\n 'Unknown prefix ' +\n prefix +\n '. Could not convert ' +\n uri +\n ' to a full URI',\n );\n }\n private static _toFull(uri) {\n // Split on the FIRST colon only: the local name may itself contain colons\n // (e.g. `ex:foo:bar`), which `split(':')` would truncate.\n const colon = uri.indexOf(':');\n if (colon === -1) return undefined;\n const prefix = uri.slice(0, colon);\n const rest = uri.slice(colon + 1);\n let ontologyURI = this.getFullURI(prefix);\n if (ontologyURI) {\n return ontologyURI + rest;\n }\n }\n}\n"]}
|