@ldo/solid-type-index 0.0.1-alpha.32 → 1.0.0-alpha.2
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/dist/.ldo/profile.context.d.ts +1 -1
- package/dist/.ldo/profile.typings.d.ts +6 -6
- package/dist/.ldo/typeIndex.context.d.ts +1 -1
- package/dist/.ldo/typeIndex.context.js +15 -1
- package/dist/.ldo/typeIndex.context.js.map +1 -1
- package/dist/.ldo/typeIndex.typings.d.ts +9 -9
- package/dist/getTypeIndex.d.ts +5 -4
- package/dist/getTypeIndex.js +1 -1
- package/dist/getTypeIndex.js.map +1 -1
- package/dist/react/useInstanceUris.d.ts +2 -2
- package/dist/react/useInstanceUris.js +1 -1
- package/dist/react/useInstanceUris.js.map +1 -1
- package/dist/react/util/useSubscribeToUris.js.map +1 -1
- package/dist/setTypeIndex.d.ts +3 -3
- package/dist/setTypeIndex.js +17 -16
- package/dist/setTypeIndex.js.map +1 -1
- package/dist/util/Options.d.ts +4 -3
- package/dist/util/Options.js +5 -4
- package/dist/util/Options.js.map +1 -1
- package/package.json +6 -8
- package/src/.ldo/profile.context.ts +1 -1
- package/src/.ldo/profile.typings.ts +6 -6
- package/src/.ldo/typeIndex.context.ts +16 -2
- package/src/.ldo/typeIndex.typings.ts +9 -9
- package/src/getTypeIndex.ts +12 -11
- package/src/react/useInstanceUris.ts +4 -4
- package/src/setTypeIndex.ts +52 -30
- package/src/util/Options.ts +10 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LdoJsonldContext } from "@ldo/
|
|
1
|
+
import { LdoJsonldContext } from "@ldo/ldo";
|
|
2
2
|
export declare const profileContext: LdoJsonldContext;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LdoJsonldContext, LdSet } from "@ldo/ldo";
|
|
2
2
|
export interface TypeIndexProfile {
|
|
3
3
|
"@id"?: string;
|
|
4
|
-
"@context"?:
|
|
5
|
-
privateTypeIndex?: {
|
|
4
|
+
"@context"?: LdoJsonldContext;
|
|
5
|
+
privateTypeIndex?: LdSet<{
|
|
6
6
|
"@id": string;
|
|
7
|
-
}
|
|
8
|
-
publicTypeIndex?: {
|
|
7
|
+
}>;
|
|
8
|
+
publicTypeIndex?: LdSet<{
|
|
9
9
|
"@id": string;
|
|
10
|
-
}
|
|
10
|
+
}>;
|
|
11
11
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LdoJsonldContext } from "@ldo/
|
|
1
|
+
import { LdoJsonldContext } from "@ldo/ldo";
|
|
2
2
|
export declare const typeIndexContext: LdoJsonldContext;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.typeIndexContext = void 0;
|
|
4
4
|
exports.typeIndexContext = {
|
|
5
5
|
type: {
|
|
6
|
-
"@id": "@type"
|
|
6
|
+
"@id": "@type",
|
|
7
7
|
},
|
|
8
8
|
TypeIndex: {
|
|
9
9
|
"@id": "http://www.w3.org/ns/solid/terms#TypeIndex",
|
|
@@ -43,5 +43,19 @@ exports.typeIndexContext = {
|
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
|
+
forClass: {
|
|
47
|
+
"@id": "http://www.w3.org/ns/solid/terms#forClass",
|
|
48
|
+
"@type": "@id",
|
|
49
|
+
},
|
|
50
|
+
instance: {
|
|
51
|
+
"@id": "http://www.w3.org/ns/solid/terms#instance",
|
|
52
|
+
"@type": "@id",
|
|
53
|
+
"@isCollection": true,
|
|
54
|
+
},
|
|
55
|
+
instanceContainer: {
|
|
56
|
+
"@id": "http://www.w3.org/ns/solid/terms#instanceContainer",
|
|
57
|
+
"@type": "@id",
|
|
58
|
+
"@isCollection": true,
|
|
59
|
+
},
|
|
46
60
|
};
|
|
47
61
|
//# sourceMappingURL=typeIndex.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeIndex.context.js","sourceRoot":"","sources":["../../src/.ldo/typeIndex.context.ts"],"names":[],"mappings":";;;AAOa,QAAA,gBAAgB,GAAqB;IAChD,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;KACf;IACD,SAAS,EAAE;QACT,KAAK,EAAE,4CAA4C;QACnD,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD,cAAc,EAAE;QACd,KAAK,EAAE,iDAAiD;QACxD,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,mDAAmD;QAC1D,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,2CAA2C;gBAClD,OAAO,EAAE,KAAK;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,2CAA2C;gBAClD,OAAO,EAAE,KAAK;gBACd,eAAe,EAAE,IAAI;aACtB;YACD,iBAAiB,EAAE;gBACjB,KAAK,EAAE,oDAAoD;gBAC3D,OAAO,EAAE,KAAK;gBACd,eAAe,EAAE,IAAI;aACtB;SACF;KACF;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"typeIndex.context.js","sourceRoot":"","sources":["../../src/.ldo/typeIndex.context.ts"],"names":[],"mappings":";;;AAOa,QAAA,gBAAgB,GAAqB;IAChD,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;KACf;IACD,SAAS,EAAE;QACT,KAAK,EAAE,4CAA4C;QACnD,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD,cAAc,EAAE;QACd,KAAK,EAAE,iDAAiD;QACxD,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,mDAAmD;QAC1D,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,KAAK,EAAE,OAAO;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,2CAA2C;gBAClD,OAAO,EAAE,KAAK;aACf;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,2CAA2C;gBAClD,OAAO,EAAE,KAAK;gBACd,eAAe,EAAE,IAAI;aACtB;YACD,iBAAiB,EAAE;gBACjB,KAAK,EAAE,oDAAoD;gBAC3D,OAAO,EAAE,KAAK;gBACd,eAAe,EAAE,IAAI;aACtB;SACF;KACF;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,2CAA2C;QAClD,OAAO,EAAE,KAAK;KACf;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,2CAA2C;QAClD,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,IAAI;KACtB;IACD,iBAAiB,EAAE;QACjB,KAAK,EAAE,oDAAoD;QAC3D,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,IAAI;KACtB;CACF,CAAC"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LdoJsonldContext, LdSet } from "@ldo/ldo";
|
|
2
2
|
export interface TypeIndexDocument {
|
|
3
3
|
"@id"?: string;
|
|
4
|
-
"@context"?:
|
|
5
|
-
type:
|
|
4
|
+
"@context"?: LdoJsonldContext;
|
|
5
|
+
type: LdSet<{
|
|
6
6
|
"@id": "TypeIndex";
|
|
7
7
|
} | {
|
|
8
8
|
"@id": "ListedDocument";
|
|
9
|
-
}
|
|
9
|
+
}>;
|
|
10
10
|
}
|
|
11
11
|
export interface TypeRegistration {
|
|
12
12
|
"@id"?: string;
|
|
13
|
-
"@context"?:
|
|
13
|
+
"@context"?: LdoJsonldContext;
|
|
14
14
|
type: {
|
|
15
15
|
"@id": "TypeRegistration";
|
|
16
16
|
};
|
|
17
17
|
forClass: {
|
|
18
18
|
"@id": string;
|
|
19
19
|
};
|
|
20
|
-
instance?: {
|
|
20
|
+
instance?: LdSet<{
|
|
21
21
|
"@id": string;
|
|
22
|
-
}
|
|
23
|
-
instanceContainer?: {
|
|
22
|
+
}>;
|
|
23
|
+
instanceContainer?: LdSet<{
|
|
24
24
|
"@id": string;
|
|
25
|
-
}
|
|
25
|
+
}>;
|
|
26
26
|
}
|
package/dist/getTypeIndex.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { LeafUri } from "@ldo/solid";
|
|
2
1
|
import type { TypeRegistration } from "./.ldo/typeIndex.typings";
|
|
3
2
|
import type { TypeIndexProfile } from "./.ldo/profile.typings";
|
|
4
3
|
import type { Options } from "./util/Options";
|
|
5
|
-
|
|
4
|
+
import type { LdSet } from "@ldo/ldo";
|
|
5
|
+
import type { SolidLeafUri } from "@ldo/connected-solid";
|
|
6
|
+
export declare function getTypeRegistrations(webId: string, options?: Options): Promise<LdSet<TypeRegistration>>;
|
|
6
7
|
export declare function getProfile(webId: string, options?: Options): Promise<TypeIndexProfile>;
|
|
7
|
-
export declare function getTypeIndexesUrisFromProfile(profile: TypeIndexProfile):
|
|
8
|
-
export declare function getInstanceUris(classUri: string, typeRegistrations: TypeRegistration[], options?: Options): Promise<
|
|
8
|
+
export declare function getTypeIndexesUrisFromProfile(profile: TypeIndexProfile): SolidLeafUri[];
|
|
9
|
+
export declare function getInstanceUris(classUri: string, typeRegistrations: TypeRegistration[], options?: Options): Promise<SolidLeafUri[]>;
|
package/dist/getTypeIndex.js
CHANGED
|
@@ -50,7 +50,7 @@ async function getInstanceUris(classUri, typeRegistrations, options) {
|
|
|
50
50
|
const containerResource = dataset.getResource(instanceContainer["@id"]);
|
|
51
51
|
await containerResource.readIfUnfetched();
|
|
52
52
|
containerResource.children().forEach((child) => {
|
|
53
|
-
if (child.type === "
|
|
53
|
+
if (child.type === "SolidLeaf")
|
|
54
54
|
leafUris.add(child.uri);
|
|
55
55
|
});
|
|
56
56
|
}) ?? []);
|
package/dist/getTypeIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTypeIndex.js","sourceRoot":"","sources":["../src/getTypeIndex.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getTypeIndex.js","sourceRoot":"","sources":["../src/getTypeIndex.ts"],"names":[],"mappings":";;;AAEA,kEAAsE;AACtE,sEAAwE;AACxE,2CAA0D;AAE1D,4CAAkD;AAI3C,KAAK,UAAU,oBAAoB,CACxC,KAAa,EACb,OAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC;IAG9C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAGjD,MAAM,aAAa,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAG7D,MAAM,OAAO,CAAC,GAAG,CACf,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;QACvC,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,eAAe,EAAE,CAAC;QAC7D,IAAI,UAAU,CAAC,OAAO;YAAE,MAAM,UAAU,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;IAGF,OAAO,OAAO;SACX,SAAS,CAAC,gDAAyB,CAAC;SACpC,YAAY,CAAC,oBAAQ,EAAE,6BAAiB,CAAC,CAAC;AAC/C,CAAC;AAzBD,oDAyBC;AAEM,KAAK,UAAU,UAAU,CAC9B,KAAa,EACb,OAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,eAAe,EAAE,CAAC;IAC3D,IAAI,UAAU,CAAC,OAAO;QAAE,MAAM,UAAU,CAAC;IACzC,OA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AAsB,CAC9C,CAAC;gBACF,MAAM,iBAAiB,CAAC,eAAe,EAAE,CAAC;gBAC1C,iBAAiB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;wBAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,IAAI,EAAE,CACT,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AA/BD,0CA+BC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function useInstanceUris(classUri: string):
|
|
1
|
+
import type { SolidLeafUri } from "@ldo/connected-solid";
|
|
2
|
+
export declare function useInstanceUris(classUri: string): SolidLeafUri[];
|
|
@@ -16,7 +16,7 @@ function useInstanceUris(classUri) {
|
|
|
16
16
|
const [leafUris, setLeafUris] = (0, react_1.useState)([]);
|
|
17
17
|
const typeRegistrations = (0, solid_react_1.useMatchSubject)(typeIndex_shapeTypes_1.TypeRegistrationShapeType, constants_1.RDF_TYPE, constants_1.TYPE_REGISTRATION);
|
|
18
18
|
(0, react_1.useEffect)(() => {
|
|
19
|
-
(0, getTypeIndex_1.getInstanceUris)(classUri, typeRegistrations, {
|
|
19
|
+
(0, getTypeIndex_1.getInstanceUris)(classUri, typeRegistrations.toArray(), {
|
|
20
20
|
solidLdoDataset: dataset,
|
|
21
21
|
}).then(setLeafUris);
|
|
22
22
|
}, [typeRegistrations]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInstanceUris.js","sourceRoot":"","sources":["../../src/react/useInstanceUris.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"useInstanceUris.js","sourceRoot":"","sources":["../../src/react/useInstanceUris.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vC,MAAM,QAAQ,CAAC,wBAAwB,EAAE,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,OAAO,qBAAqB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAEhB,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,CACvC,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,EAAE;gBAEtC,OAAO,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBAClD,MAAM,QAAQ,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;YAC9D,CAAC,CACF,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACb,CAAC;AA/BD,gDA+BC"}
|
package/dist/setTypeIndex.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Options } from "./util/Options";
|
|
2
2
|
import type { TypeRegistration } from "./.ldo/typeIndex.typings";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
|
|
4
|
+
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
5
5
|
export declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
|
|
6
|
-
export declare function createIndex(webId: any, profileFolder:
|
|
6
|
+
export declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
|
|
7
7
|
interface Instances {
|
|
8
8
|
instance?: string[];
|
|
9
9
|
instanceContainer?: string[];
|
package/dist/setTypeIndex.js
CHANGED
|
@@ -8,19 +8,22 @@ const Options_1 = require("./util/Options");
|
|
|
8
8
|
const data_model_1 = require("@rdfjs/data-model");
|
|
9
9
|
const getTypeIndex_1 = require("./getTypeIndex");
|
|
10
10
|
const profile_shapeTypes_1 = require("./.ldo/profile.shapeTypes");
|
|
11
|
+
const ldo_1 = require("@ldo/ldo");
|
|
11
12
|
async function initTypeIndex(webId, options) {
|
|
12
13
|
const { dataset } = (0, Options_1.guaranteeOptions)(options);
|
|
13
14
|
const profile = await (0, getTypeIndex_1.getProfile)(webId, options);
|
|
14
|
-
if (!profile.privateTypeIndex?.
|
|
15
|
-
const profileFolder = await dataset
|
|
15
|
+
if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
|
|
16
|
+
const profileFolder = await dataset
|
|
17
|
+
.getResource(webId)
|
|
18
|
+
.getParentContainer();
|
|
16
19
|
if (profileFolder?.isError)
|
|
17
20
|
throw profileFolder;
|
|
18
21
|
if (!profileFolder)
|
|
19
22
|
throw new Error("No folder to save the type indexes to.");
|
|
20
|
-
if (!profile.privateTypeIndex?.
|
|
23
|
+
if (!profile.privateTypeIndex?.size) {
|
|
21
24
|
await createIndex(webId, profileFolder, dataset, true);
|
|
22
25
|
}
|
|
23
|
-
if (!profile.publicTypeIndex?.
|
|
26
|
+
if (!profile.publicTypeIndex?.size) {
|
|
24
27
|
await createIndex(webId, profileFolder, dataset, false);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -56,17 +59,17 @@ async function createIndex(webId, profileFolder, dataset, isPrivate) {
|
|
|
56
59
|
.write(dataset.getResource(webId).uri)
|
|
57
60
|
.fromSubject(webId);
|
|
58
61
|
if (isPrivate) {
|
|
59
|
-
cProfile.privateTypeIndex?.
|
|
62
|
+
cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
62
|
-
cProfile.publicTypeIndex?.
|
|
65
|
+
cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
|
|
63
66
|
}
|
|
64
67
|
const cTypeIndex = transaction
|
|
65
68
|
.usingType(typeIndex_shapeTypes_1.TypeIndexDocumentShapeType)
|
|
66
69
|
.write(indexResource.uri)
|
|
67
70
|
.fromSubject(indexResource.uri);
|
|
68
|
-
cTypeIndex.type =
|
|
69
|
-
const commitResult = await transaction.
|
|
71
|
+
cTypeIndex.type = (0, ldo_1.set)({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
|
|
72
|
+
const commitResult = await transaction.commitToRemote();
|
|
70
73
|
if (commitResult.isError)
|
|
71
74
|
throw commitResult;
|
|
72
75
|
}
|
|
@@ -74,22 +77,20 @@ exports.createIndex = createIndex;
|
|
|
74
77
|
function addRegistration(indexUri, classUri, instances, options) {
|
|
75
78
|
const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
|
|
76
79
|
instances.instance?.forEach((instance) => {
|
|
77
|
-
typeRegistration.instance?.
|
|
80
|
+
typeRegistration.instance?.add({ "@id": instance });
|
|
78
81
|
});
|
|
79
82
|
instances.instanceContainer?.forEach((instanceContainer) => {
|
|
80
|
-
typeRegistration.instanceContainer?.
|
|
83
|
+
typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
exports.addRegistration = addRegistration;
|
|
84
87
|
async function removeRegistration(indexUri, classUri, instances, options) {
|
|
85
88
|
const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
typeRegistration.instance?.splice(typeRegistration.instance.findIndex((val) => val["@id"] === instance), 1);
|
|
89
|
+
instances.instance?.forEach((instanceUri) => {
|
|
90
|
+
typeRegistration.instance?.delete({ "@id": instanceUri });
|
|
89
91
|
});
|
|
90
|
-
instances.instanceContainer?.forEach((
|
|
91
|
-
|
|
92
|
-
typeRegistration.instanceContainer?.splice(typeRegistration.instanceContainer.findIndex((val) => val["@id"] === instanceContainer), 1);
|
|
92
|
+
instances.instanceContainer?.forEach((instanceContainerUri) => {
|
|
93
|
+
typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
exports.removeRegistration = removeRegistration;
|
package/dist/setTypeIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTypeIndex.js","sourceRoot":"","sources":["../src/setTypeIndex.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"setTypeIndex.js","sourceRoot":"","sources":["../src/setTypeIndex.ts"],"names":[],"mappings":";;;AACA,+BAA0B;AAC1B,sEAGqC;AACrC,2CAAqE;AACrE,4CAAgE;AAChE,kDAAoD;AAEpD,iDAA4C;AAC5C,kEAAsE;AAEtE,kCAA+B;AAcxB,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,OAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAU,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;QACtE,MAAM,aAAa,GAAG,MAAM,OAAO;aAChC,WAAW,CAAC,KAAyC,CAAC;aACtD,kBAAkB,EAAE,CAAC;QACxB,IAAI,aAAa,EAAE,OAAO;YAAE,MAAM,aAAa,CAAC;QAChD,IAAI,CAAC,aAAa;YAChB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;YACpC,MAAM,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,C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CAAC,EACpB,IAAA,sBAAS,EAAC,QAAQ,CAAC,EACnB,IAAA,sBAAS,EAAC,QAAQ,CAAC,CACpB,CACF,CAAC;IACJ,CAAC,CACF,EAAE,KAAK,CAAC;IAET,IAAI,gBAAkC,CAAC;IACvC,IAAI,+BAA+B,EAAE,CAAC;QACpC,gBAAgB,GAAG,OAAO;aACvB,SAAS,CAAC,gDAAyB,CAAC;aACpC,KAAK,CAAC,QAAQ,CAAC;aACf,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,gBAAgB,GAAG,OAAO;aACvB,SAAS,CAAC,gDAAyB,CAAC;aACpC,KAAK,CAAC,QAAQ,CAAC;aACf,WAAW,CAAC,GAAG,QAAQ,IAAI,IAAA,SAAE,GAAE,EAAE,CAAC,CAAC;QACtC,gBAAgB,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QACtD,gBAAgB,CAAC,QAAQ,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClD,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA7CD,0EA6CC"}
|
package/dist/util/Options.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConnectedLdoDataset, IConnectedLdoDataset } from "@ldo/connected";
|
|
2
|
+
import type { SolidConnectedPlugin } from "@ldo/connected-solid";
|
|
2
3
|
export interface Options {
|
|
3
|
-
solidLdoDataset?:
|
|
4
|
+
solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;
|
|
4
5
|
fetch?: typeof fetch;
|
|
5
6
|
}
|
|
6
7
|
export declare function guaranteeOptions(options?: Options): {
|
|
7
8
|
fetch: typeof globalThis.fetch;
|
|
8
|
-
dataset:
|
|
9
|
+
dataset: ConnectedLdoDataset<SolidConnectedPlugin[]>;
|
|
9
10
|
};
|
package/dist/util/Options.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.guaranteeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
const guaranteeFetch_1 = require("@ldo/solid/dist/util/guaranteeFetch");
|
|
4
|
+
const connected_solid_1 = require("@ldo/connected-solid");
|
|
6
5
|
function guaranteeOptions(options) {
|
|
7
|
-
const fetch = (0,
|
|
8
|
-
const dataset = options?.solidLdoDataset ??
|
|
6
|
+
const fetch = (0, connected_solid_1.guaranteeFetch)(options?.fetch);
|
|
7
|
+
const dataset = (options?.solidLdoDataset ??
|
|
8
|
+
(0, connected_solid_1.createSolidLdoDataset)());
|
|
9
|
+
dataset.setContext("solid", { fetch });
|
|
9
10
|
return { fetch, dataset };
|
|
10
11
|
}
|
|
11
12
|
exports.guaranteeOptions = guaranteeOptions;
|
package/dist/util/Options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Options.js","sourceRoot":"","sources":["../../src/util/Options.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Options.js","sourceRoot":"","sources":["../../src/util/Options.ts"],"names":[],"mappings":";;;AAGA,0DAA6E;AAS7E,SAAgB,gBAAgB,CAAC,OAAiB;IAChD,MAAM,KAAK,GAAG,IAAA,gCAAc,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,eAAe;QACvC,IAAA,uCAAqB,GAAE,CAAgD,CAAC;IAC1E,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAND,4CAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/solid-type-index",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "Solid Type Index support for LDO",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,18 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/o-development/ldobjects/tree/main/packages/solid-react#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@ldo/rdf-utils": "^0.0
|
|
29
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.2",
|
|
30
30
|
"@rdfjs/types": "^1.0.1",
|
|
31
31
|
"@testing-library/react": "^14.1.2",
|
|
32
|
-
"
|
|
33
|
-
"jest-environment-jsdom": "^27.0.0",
|
|
32
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
34
33
|
"start-server-and-test": "^2.0.3",
|
|
35
|
-
"ts-jest": "^27.1.2",
|
|
36
34
|
"ts-node": "^10.9.2"
|
|
37
35
|
},
|
|
38
36
|
"dependencies": {
|
|
39
|
-
"@ldo/solid": "^0.0
|
|
40
|
-
"@ldo/solid-react": "^0.0
|
|
37
|
+
"@ldo/connected-solid": "^1.0.0-alpha.2",
|
|
38
|
+
"@ldo/solid-react": "^1.0.0-alpha.2"
|
|
41
39
|
},
|
|
42
40
|
"files": [
|
|
43
41
|
"dist",
|
|
@@ -46,5 +44,5 @@
|
|
|
46
44
|
"publishConfig": {
|
|
47
45
|
"access": "public"
|
|
48
46
|
},
|
|
49
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ba5cbcfa79af530258cad3b7ae1478a6673befea"
|
|
50
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LdoJsonldContext, LdSet } from "@ldo/ldo";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* =============================================================================
|
|
@@ -11,17 +11,17 @@ import { ContextDefinition } from "jsonld";
|
|
|
11
11
|
*/
|
|
12
12
|
export interface TypeIndexProfile {
|
|
13
13
|
"@id"?: string;
|
|
14
|
-
"@context"?:
|
|
14
|
+
"@context"?: LdoJsonldContext;
|
|
15
15
|
/**
|
|
16
16
|
* A registry of all types used on the user's Pod (for private access only)
|
|
17
17
|
*/
|
|
18
|
-
privateTypeIndex?: {
|
|
18
|
+
privateTypeIndex?: LdSet<{
|
|
19
19
|
"@id": string;
|
|
20
|
-
}
|
|
20
|
+
}>;
|
|
21
21
|
/**
|
|
22
22
|
* A registry of all types used on the user's Pod (for public access)
|
|
23
23
|
*/
|
|
24
|
-
publicTypeIndex?: {
|
|
24
|
+
publicTypeIndex?: LdSet<{
|
|
25
25
|
"@id": string;
|
|
26
|
-
}
|
|
26
|
+
}>;
|
|
27
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LdoJsonldContext } from "@ldo/
|
|
1
|
+
import { LdoJsonldContext } from "@ldo/ldo";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* =============================================================================
|
|
@@ -7,7 +7,7 @@ import { LdoJsonldContext } from "@ldo/jsonld-dataset-proxy";
|
|
|
7
7
|
*/
|
|
8
8
|
export const typeIndexContext: LdoJsonldContext = {
|
|
9
9
|
type: {
|
|
10
|
-
"@id": "@type"
|
|
10
|
+
"@id": "@type",
|
|
11
11
|
},
|
|
12
12
|
TypeIndex: {
|
|
13
13
|
"@id": "http://www.w3.org/ns/solid/terms#TypeIndex",
|
|
@@ -47,4 +47,18 @@ export const typeIndexContext: LdoJsonldContext = {
|
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
|
+
forClass: {
|
|
51
|
+
"@id": "http://www.w3.org/ns/solid/terms#forClass",
|
|
52
|
+
"@type": "@id",
|
|
53
|
+
},
|
|
54
|
+
instance: {
|
|
55
|
+
"@id": "http://www.w3.org/ns/solid/terms#instance",
|
|
56
|
+
"@type": "@id",
|
|
57
|
+
"@isCollection": true,
|
|
58
|
+
},
|
|
59
|
+
instanceContainer: {
|
|
60
|
+
"@id": "http://www.w3.org/ns/solid/terms#instanceContainer",
|
|
61
|
+
"@type": "@id",
|
|
62
|
+
"@isCollection": true,
|
|
63
|
+
},
|
|
50
64
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LdoJsonldContext, LdSet } from "@ldo/ldo";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* =============================================================================
|
|
@@ -11,18 +11,18 @@ import { ContextDefinition } from "jsonld";
|
|
|
11
11
|
*/
|
|
12
12
|
export interface TypeIndexDocument {
|
|
13
13
|
"@id"?: string;
|
|
14
|
-
"@context"?:
|
|
14
|
+
"@context"?: LdoJsonldContext;
|
|
15
15
|
/**
|
|
16
16
|
* Defines the node as a TypeIndex | Defines the node as a Listed Document
|
|
17
17
|
*/
|
|
18
|
-
type:
|
|
18
|
+
type: LdSet<
|
|
19
19
|
| {
|
|
20
20
|
"@id": "TypeIndex";
|
|
21
21
|
}
|
|
22
22
|
| {
|
|
23
23
|
"@id": "ListedDocument";
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -30,7 +30,7 @@ export interface TypeIndexDocument {
|
|
|
30
30
|
*/
|
|
31
31
|
export interface TypeRegistration {
|
|
32
32
|
"@id"?: string;
|
|
33
|
-
"@context"?:
|
|
33
|
+
"@context"?: LdoJsonldContext;
|
|
34
34
|
/**
|
|
35
35
|
* Defines this node as a Type Registration
|
|
36
36
|
*/
|
|
@@ -46,13 +46,13 @@ export interface TypeRegistration {
|
|
|
46
46
|
/**
|
|
47
47
|
* A specific resource that contains the class.
|
|
48
48
|
*/
|
|
49
|
-
instance?: {
|
|
49
|
+
instance?: LdSet<{
|
|
50
50
|
"@id": string;
|
|
51
|
-
}
|
|
51
|
+
}>;
|
|
52
52
|
/**
|
|
53
53
|
* Containers that contain resources with the class.
|
|
54
54
|
*/
|
|
55
|
-
instanceContainer?: {
|
|
55
|
+
instanceContainer?: LdSet<{
|
|
56
56
|
"@id": string;
|
|
57
|
-
}
|
|
57
|
+
}>;
|
|
58
58
|
}
|
package/src/getTypeIndex.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ContainerUri, LeafUri } from "@ldo/solid";
|
|
2
1
|
import type { TypeRegistration } from "./.ldo/typeIndex.typings";
|
|
3
2
|
import type { TypeIndexProfile } from "./.ldo/profile.typings";
|
|
4
3
|
import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes";
|
|
@@ -6,11 +5,13 @@ import { TypeRegistrationShapeType } from "./.ldo/typeIndex.shapeTypes";
|
|
|
6
5
|
import { RDF_TYPE, TYPE_REGISTRATION } from "./constants";
|
|
7
6
|
import type { Options } from "./util/Options";
|
|
8
7
|
import { guaranteeOptions } from "./util/Options";
|
|
8
|
+
import type { LdSet } from "@ldo/ldo";
|
|
9
|
+
import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid";
|
|
9
10
|
|
|
10
11
|
export async function getTypeRegistrations(
|
|
11
12
|
webId: string,
|
|
12
13
|
options?: Options,
|
|
13
|
-
): Promise<TypeRegistration
|
|
14
|
+
): Promise<LdSet<TypeRegistration>> {
|
|
14
15
|
const { dataset } = guaranteeOptions(options);
|
|
15
16
|
|
|
16
17
|
// Get Profile
|
|
@@ -47,13 +48,13 @@ export async function getProfile(
|
|
|
47
48
|
|
|
48
49
|
export function getTypeIndexesUrisFromProfile(
|
|
49
50
|
profile: TypeIndexProfile,
|
|
50
|
-
):
|
|
51
|
-
const uris:
|
|
51
|
+
): SolidLeafUri[] {
|
|
52
|
+
const uris: SolidLeafUri[] = [];
|
|
52
53
|
profile.privateTypeIndex?.forEach((indexNode) => {
|
|
53
|
-
uris.push(indexNode["@id"] as
|
|
54
|
+
uris.push(indexNode["@id"] as SolidLeafUri);
|
|
54
55
|
});
|
|
55
56
|
profile.publicTypeIndex?.forEach((indexNode) => {
|
|
56
|
-
uris.push(indexNode["@id"] as
|
|
57
|
+
uris.push(indexNode["@id"] as SolidLeafUri);
|
|
57
58
|
});
|
|
58
59
|
return uris;
|
|
59
60
|
}
|
|
@@ -62,26 +63,26 @@ export async function getInstanceUris(
|
|
|
62
63
|
classUri: string,
|
|
63
64
|
typeRegistrations: TypeRegistration[],
|
|
64
65
|
options?: Options,
|
|
65
|
-
): Promise<
|
|
66
|
+
): Promise<SolidLeafUri[]> {
|
|
66
67
|
const { dataset } = guaranteeOptions(options);
|
|
67
68
|
|
|
68
|
-
const leafUris = new Set<
|
|
69
|
+
const leafUris = new Set<SolidLeafUri>();
|
|
69
70
|
await Promise.all(
|
|
70
71
|
typeRegistrations.map(async (registration) => {
|
|
71
72
|
if (registration.forClass["@id"] === classUri) {
|
|
72
73
|
// Individual registrations
|
|
73
74
|
registration.instance?.forEach((instance) =>
|
|
74
|
-
leafUris.add(instance["@id"] as
|
|
75
|
+
leafUris.add(instance["@id"] as SolidLeafUri),
|
|
75
76
|
);
|
|
76
77
|
// Container registrations
|
|
77
78
|
await Promise.all(
|
|
78
79
|
registration.instanceContainer?.map(async (instanceContainer) => {
|
|
79
80
|
const containerResource = dataset.getResource(
|
|
80
|
-
instanceContainer["@id"] as
|
|
81
|
+
instanceContainer["@id"] as SolidContainerUri,
|
|
81
82
|
);
|
|
82
83
|
await containerResource.readIfUnfetched();
|
|
83
84
|
containerResource.children().forEach((child) => {
|
|
84
|
-
if (child.type === "
|
|
85
|
+
if (child.type === "SolidLeaf") leafUris.add(child.uri);
|
|
85
86
|
});
|
|
86
87
|
}) ?? [],
|
|
87
88
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LeafUri } from "@ldo/solid";
|
|
2
1
|
import { useTypeIndexProfile } from "./useTypeIndexProfile";
|
|
3
2
|
import { useEffect, useMemo, useState } from "react";
|
|
4
3
|
import { useSubscribeToUris } from "./util/useSubscribeToUris";
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
getInstanceUris,
|
|
10
9
|
getTypeIndexesUrisFromProfile,
|
|
11
10
|
} from "../getTypeIndex";
|
|
11
|
+
import type { SolidLeafUri } from "@ldo/connected-solid";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Provides the LeafUris of everything in a type node for a specific class uri
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
* @param classUri - the class uri
|
|
17
17
|
* @returns - URIs of all resources registered with this node
|
|
18
18
|
*/
|
|
19
|
-
export function useInstanceUris(classUri: string):
|
|
19
|
+
export function useInstanceUris(classUri: string): SolidLeafUri[] {
|
|
20
20
|
const { dataset } = useLdo();
|
|
21
21
|
const profile = useTypeIndexProfile();
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ export function useInstanceUris(classUri: string): LeafUri[] {
|
|
|
27
27
|
|
|
28
28
|
useSubscribeToUris(typeIndexUris);
|
|
29
29
|
|
|
30
|
-
const [leafUris, setLeafUris] = useState<
|
|
30
|
+
const [leafUris, setLeafUris] = useState<SolidLeafUri[]>([]);
|
|
31
31
|
|
|
32
32
|
const typeRegistrations = useMatchSubject(
|
|
33
33
|
TypeRegistrationShapeType,
|
|
@@ -36,7 +36,7 @@ export function useInstanceUris(classUri: string): LeafUri[] {
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
39
|
-
getInstanceUris(classUri, typeRegistrations, {
|
|
39
|
+
getInstanceUris(classUri, typeRegistrations.toArray(), {
|
|
40
40
|
solidLdoDataset: dataset,
|
|
41
41
|
}).then(setLeafUris);
|
|
42
42
|
}, [typeRegistrations]);
|
package/src/setTypeIndex.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import { v4 } from "uuid";
|
|
2
3
|
import {
|
|
3
4
|
TypeIndexDocumentShapeType,
|
|
@@ -9,9 +10,15 @@ import { namedNode, quad } from "@rdfjs/data-model";
|
|
|
9
10
|
import type { TypeRegistration } from "./.ldo/typeIndex.typings";
|
|
10
11
|
import { getProfile } from "./getTypeIndex";
|
|
11
12
|
import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes";
|
|
12
|
-
import type { Container } from "@ldo/solid";
|
|
13
|
-
import type { ISolidLdoDataset } from "@ldo/solid";
|
|
14
13
|
import type { NamedNode } from "@rdfjs/types";
|
|
14
|
+
import { set } from "@ldo/ldo";
|
|
15
|
+
import type {
|
|
16
|
+
SolidConnectedPlugin,
|
|
17
|
+
SolidContainer,
|
|
18
|
+
SolidContainerUri,
|
|
19
|
+
SolidLeafUri,
|
|
20
|
+
} from "@ldo/connected-solid";
|
|
21
|
+
import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
24
|
* =============================================================================
|
|
@@ -24,15 +31,17 @@ export async function initTypeIndex(
|
|
|
24
31
|
): Promise<void> {
|
|
25
32
|
const { dataset } = guaranteeOptions(options);
|
|
26
33
|
const profile = await getProfile(webId, options);
|
|
27
|
-
if (!profile.privateTypeIndex?.
|
|
28
|
-
const profileFolder = await dataset
|
|
34
|
+
if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
|
|
35
|
+
const profileFolder = await dataset
|
|
36
|
+
.getResource(webId as SolidLeafUri | SolidContainerUri)
|
|
37
|
+
.getParentContainer();
|
|
29
38
|
if (profileFolder?.isError) throw profileFolder;
|
|
30
39
|
if (!profileFolder)
|
|
31
40
|
throw new Error("No folder to save the type indexes to.");
|
|
32
|
-
if (!profile.privateTypeIndex?.
|
|
41
|
+
if (!profile.privateTypeIndex?.size) {
|
|
33
42
|
await createIndex(webId, profileFolder, dataset, true);
|
|
34
43
|
}
|
|
35
|
-
if (!profile.publicTypeIndex?.
|
|
44
|
+
if (!profile.publicTypeIndex?.size) {
|
|
36
45
|
await createIndex(webId, profileFolder, dataset, false);
|
|
37
46
|
}
|
|
38
47
|
}
|
|
@@ -46,8 +55,10 @@ export async function initTypeIndex(
|
|
|
46
55
|
*/
|
|
47
56
|
export async function createIndex(
|
|
48
57
|
webId,
|
|
49
|
-
profileFolder:
|
|
50
|
-
dataset:
|
|
58
|
+
profileFolder: SolidContainer,
|
|
59
|
+
dataset: ConnectedLdoDataset<
|
|
60
|
+
(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]
|
|
61
|
+
>,
|
|
51
62
|
isPrivate: boolean,
|
|
52
63
|
) {
|
|
53
64
|
// Create a private type index
|
|
@@ -80,17 +91,17 @@ export async function createIndex(
|
|
|
80
91
|
.write(dataset.getResource(webId).uri)
|
|
81
92
|
.fromSubject(webId);
|
|
82
93
|
if (isPrivate) {
|
|
83
|
-
cProfile.privateTypeIndex?.
|
|
94
|
+
cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
|
|
84
95
|
} else {
|
|
85
|
-
cProfile.publicTypeIndex?.
|
|
96
|
+
cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
|
|
86
97
|
}
|
|
87
98
|
const cTypeIndex = transaction
|
|
88
99
|
.usingType(TypeIndexDocumentShapeType)
|
|
89
100
|
.write(indexResource.uri)
|
|
90
101
|
.fromSubject(indexResource.uri);
|
|
91
102
|
|
|
92
|
-
cTypeIndex.type =
|
|
93
|
-
const commitResult = await transaction.
|
|
103
|
+
cTypeIndex.type = set({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
|
|
104
|
+
const commitResult = await transaction.commitToRemote();
|
|
94
105
|
if (commitResult.isError) throw commitResult;
|
|
95
106
|
}
|
|
96
107
|
|
|
@@ -104,6 +115,13 @@ interface Instances {
|
|
|
104
115
|
instanceContainer?: string[];
|
|
105
116
|
}
|
|
106
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Adds an instance to a TypeRegistration
|
|
120
|
+
* @param indexUri The URI of the TypeIndex
|
|
121
|
+
* @param classUri The URI for the class the instance should be added to
|
|
122
|
+
* @param instances Objects representing the instances to add
|
|
123
|
+
* @param options Options
|
|
124
|
+
*/
|
|
107
125
|
export function addRegistration(
|
|
108
126
|
indexUri: string,
|
|
109
127
|
classUri: string,
|
|
@@ -119,13 +137,20 @@ export function addRegistration(
|
|
|
119
137
|
|
|
120
138
|
// Add instances to type registration
|
|
121
139
|
instances.instance?.forEach((instance) => {
|
|
122
|
-
typeRegistration.instance?.
|
|
140
|
+
typeRegistration.instance?.add({ "@id": instance });
|
|
123
141
|
});
|
|
124
142
|
instances.instanceContainer?.forEach((instanceContainer) => {
|
|
125
|
-
typeRegistration.instanceContainer?.
|
|
143
|
+
typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
|
|
126
144
|
});
|
|
127
145
|
}
|
|
128
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Removes instances from a TypeRegistration
|
|
149
|
+
* @param indexUri The URI of the TypeIndex
|
|
150
|
+
* @param classUri The URI for the class the instance should be removed from
|
|
151
|
+
* @param instances Objects representing the instances to remove
|
|
152
|
+
* @param options Options
|
|
153
|
+
*/
|
|
129
154
|
export async function removeRegistration(
|
|
130
155
|
indexUri: string,
|
|
131
156
|
classUri: string,
|
|
@@ -139,31 +164,28 @@ export async function removeRegistration(
|
|
|
139
164
|
options,
|
|
140
165
|
);
|
|
141
166
|
|
|
142
|
-
console.log(typeRegistration["@id"]);
|
|
143
|
-
|
|
144
167
|
// Add instances to type registration
|
|
145
|
-
instances.instance?.forEach((
|
|
146
|
-
typeRegistration.instance?.
|
|
147
|
-
typeRegistration.instance.findIndex((val) => val["@id"] === instance),
|
|
148
|
-
1,
|
|
149
|
-
);
|
|
168
|
+
instances.instance?.forEach((instanceUri) => {
|
|
169
|
+
typeRegistration.instance?.delete({ "@id": instanceUri });
|
|
150
170
|
});
|
|
151
|
-
instances.instanceContainer?.forEach((
|
|
152
|
-
|
|
153
|
-
typeRegistration.instanceContainer?.splice(
|
|
154
|
-
typeRegistration.instanceContainer.findIndex(
|
|
155
|
-
(val) => val["@id"] === instanceContainer,
|
|
156
|
-
),
|
|
157
|
-
1,
|
|
158
|
-
);
|
|
171
|
+
instances.instanceContainer?.forEach((instanceContainerUri) => {
|
|
172
|
+
typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
|
|
159
173
|
});
|
|
160
174
|
}
|
|
161
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Finds a TypeRegistration inside of a type index. If it doesn't exist, it
|
|
178
|
+
* creates one.
|
|
179
|
+
* @param indexUri The URI of the typeIndex
|
|
180
|
+
* @param classUri The URI of the class in question for the TypeRegistration
|
|
181
|
+
* @param options
|
|
182
|
+
* @returns The Type Index
|
|
183
|
+
*/
|
|
162
184
|
export function findAppropriateTypeRegistration(
|
|
163
185
|
indexUri: string,
|
|
164
186
|
classUri: string,
|
|
165
187
|
options?: Options,
|
|
166
|
-
) {
|
|
188
|
+
): TypeRegistration {
|
|
167
189
|
const { dataset } = guaranteeOptions(options);
|
|
168
190
|
// Check to see if its already in the index
|
|
169
191
|
const existingRegistrationsUris: NamedNode[] = dataset
|
package/src/util/Options.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type { ConnectedLdoDataset, IConnectedLdoDataset } from "@ldo/connected";
|
|
3
|
+
import type { SolidConnectedPlugin } from "@ldo/connected-solid";
|
|
4
|
+
import { createSolidLdoDataset, guaranteeFetch } from "@ldo/connected-solid";
|
|
4
5
|
|
|
5
6
|
export interface Options {
|
|
6
|
-
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore I'm honestly just tired of dealing with this at this point
|
|
9
|
+
solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;
|
|
7
10
|
fetch?: typeof fetch;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export function guaranteeOptions(options?: Options) {
|
|
11
14
|
const fetch = guaranteeFetch(options?.fetch);
|
|
12
|
-
const dataset = options?.solidLdoDataset ??
|
|
15
|
+
const dataset = (options?.solidLdoDataset ??
|
|
16
|
+
createSolidLdoDataset()) as ConnectedLdoDataset<SolidConnectedPlugin[]>;
|
|
17
|
+
dataset.setContext("solid", { fetch });
|
|
13
18
|
return { fetch, dataset };
|
|
14
19
|
}
|