@ldo/solid-type-index 0.0.1-alpha.32 → 1.0.0-alpha.1
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 +2 -1
- package/dist/getTypeIndex.js.map +1 -1
- package/dist/react/useInstanceUris.js +1 -1
- package/dist/react/useInstanceUris.js.map +1 -1
- package/dist/setTypeIndex.js +13 -14
- package/dist/setTypeIndex.js.map +1 -1
- package/package.json +5 -5
- 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 +2 -1
- package/src/react/useInstanceUris.ts +1 -1
- package/src/setTypeIndex.ts +36 -24
|
@@ -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
|
@@ -2,7 +2,8 @@ import type { LeafUri } from "@ldo/solid";
|
|
|
2
2
|
import type { TypeRegistration } from "./.ldo/typeIndex.typings";
|
|
3
3
|
import type { TypeIndexProfile } from "./.ldo/profile.typings";
|
|
4
4
|
import type { Options } from "./util/Options";
|
|
5
|
-
|
|
5
|
+
import type { LdSet } from "@ldo/ldo";
|
|
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
8
|
export declare function getTypeIndexesUrisFromProfile(profile: TypeIndexProfile): LeafUri[];
|
|
8
9
|
export declare function getInstanceUris(classUri: string, typeRegistrations: TypeRegistration[], options?: Options): Promise<LeafUri[]>;
|
package/dist/getTypeIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTypeIndex.js","sourceRoot":"","sources":["../src/getTypeIndex.ts"],"names":[],"mappings":";;;AAGA,kEAAsE;AACtE,sEAAwE;AACxE,2CAA0D;AAE1D,4CAAkD;
|
|
1
|
+
{"version":3,"file":"getTypeIndex.js","sourceRoot":"","sources":["../src/getTypeIndex.ts"],"names":[],"mappings":";;;AAGA,kEAAsE;AACtE,sEAAwE;AACxE,2CAA0D;AAE1D,4CAAkD;AAG3C,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,MA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,0BAAgB,EAAC,OAAO,CAAC,CAAC;IAE9C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAW,CAAC;IACpC,MAAM,OAAO,CAAC,GAAG,CACf,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;QAC3C,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE;YAE7C,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1C,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAY,CAAC,CACzC,CAAC;YAEF,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE;gBAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAC3C,iBAAiB,CAAC,KAAK,CAAiB,CACzC,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,MAAM;wBAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,IAAI,EAAE,CACT,CAAC;SACH;IACH,CAAC,CAAC,CACH,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AA/BD,0CA+BC"}
|
|
@@ -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":";;;AACA,+DAA4D;AAC5D,iCAAqD;AACrD,kEAA+D;AAC/D,kDAA2D;AAC3D,uEAAyE;AACzE,4CAA2D;AAC3D,kDAGyB;AAQzB,SAAgB,eAAe,CAAC,QAAgB;IAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,oBAAM,GAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAA,yCAAmB,GAAE,CAAC;IAEtC,MAAM,aAAa,GAAa,IAAA,eAAO,EACrC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,4CAA6B,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7D,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,IAAA,uCAAkB,EAAC,aAAa,CAAC,CAAC;IAElC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAY,EAAE,CAAC,CAAC;IAExD,MAAM,iBAAiB,GAAG,IAAA,6BAAe,EACvC,gDAAyB,EACzB,oBAAQ,EACR,6BAAiB,CAClB,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAA,8BAAe,EAAC,QAAQ,EAAE,iBAAiB,EAAE;
|
|
1
|
+
{"version":3,"file":"useInstanceUris.js","sourceRoot":"","sources":["../../src/react/useInstanceUris.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAC5D,iCAAqD;AACrD,kEAA+D;AAC/D,kDAA2D;AAC3D,uEAAyE;AACzE,4CAA2D;AAC3D,kDAGyB;AAQzB,SAAgB,eAAe,CAAC,QAAgB;IAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,oBAAM,GAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAA,yCAAmB,GAAE,CAAC;IAEtC,MAAM,aAAa,GAAa,IAAA,eAAO,EACrC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,4CAA6B,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7D,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,IAAA,uCAAkB,EAAC,aAAa,CAAC,CAAC;IAElC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAY,EAAE,CAAC,CAAC;IAExD,MAAM,iBAAiB,GAAG,IAAA,6BAAe,EACvC,gDAAyB,EACzB,oBAAQ,EACR,6BAAiB,CAClB,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAA,8BAAe,EAAC,QAAQ,EAAE,iBAAiB,CAAC,OAAO,EAAE,EAAE;YACrD,eAAe,EAAE,OAAO;SACzB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO,QAAQ,CAAC;AAClB,CAAC;AA1BD,0CA0BC"}
|
package/dist/setTypeIndex.js
CHANGED
|
@@ -8,19 +8,20 @@ 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
|
+
if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
|
|
15
16
|
const profileFolder = await dataset.getResource(webId).getParentContainer();
|
|
16
17
|
if (profileFolder?.isError)
|
|
17
18
|
throw profileFolder;
|
|
18
19
|
if (!profileFolder)
|
|
19
20
|
throw new Error("No folder to save the type indexes to.");
|
|
20
|
-
if (!profile.privateTypeIndex?.
|
|
21
|
+
if (!profile.privateTypeIndex?.size) {
|
|
21
22
|
await createIndex(webId, profileFolder, dataset, true);
|
|
22
23
|
}
|
|
23
|
-
if (!profile.publicTypeIndex?.
|
|
24
|
+
if (!profile.publicTypeIndex?.size) {
|
|
24
25
|
await createIndex(webId, profileFolder, dataset, false);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -56,16 +57,16 @@ async function createIndex(webId, profileFolder, dataset, isPrivate) {
|
|
|
56
57
|
.write(dataset.getResource(webId).uri)
|
|
57
58
|
.fromSubject(webId);
|
|
58
59
|
if (isPrivate) {
|
|
59
|
-
cProfile.privateTypeIndex?.
|
|
60
|
+
cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
|
-
cProfile.publicTypeIndex?.
|
|
63
|
+
cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
|
|
63
64
|
}
|
|
64
65
|
const cTypeIndex = transaction
|
|
65
66
|
.usingType(typeIndex_shapeTypes_1.TypeIndexDocumentShapeType)
|
|
66
67
|
.write(indexResource.uri)
|
|
67
68
|
.fromSubject(indexResource.uri);
|
|
68
|
-
cTypeIndex.type =
|
|
69
|
+
cTypeIndex.type = (0, ldo_1.set)({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
|
|
69
70
|
const commitResult = await transaction.commitToPod();
|
|
70
71
|
if (commitResult.isError)
|
|
71
72
|
throw commitResult;
|
|
@@ -74,22 +75,20 @@ exports.createIndex = createIndex;
|
|
|
74
75
|
function addRegistration(indexUri, classUri, instances, options) {
|
|
75
76
|
const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
|
|
76
77
|
instances.instance?.forEach((instance) => {
|
|
77
|
-
typeRegistration.instance?.
|
|
78
|
+
typeRegistration.instance?.add({ "@id": instance });
|
|
78
79
|
});
|
|
79
80
|
instances.instanceContainer?.forEach((instanceContainer) => {
|
|
80
|
-
typeRegistration.instanceContainer?.
|
|
81
|
+
typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
exports.addRegistration = addRegistration;
|
|
84
85
|
async function removeRegistration(indexUri, classUri, instances, options) {
|
|
85
86
|
const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
typeRegistration.instance?.splice(typeRegistration.instance.findIndex((val) => val["@id"] === instance), 1);
|
|
87
|
+
instances.instance?.forEach((instanceUri) => {
|
|
88
|
+
typeRegistration.instance?.delete({ "@id": instanceUri });
|
|
89
89
|
});
|
|
90
|
-
instances.instanceContainer?.forEach((
|
|
91
|
-
|
|
92
|
-
typeRegistration.instanceContainer?.splice(typeRegistration.instanceContainer.findIndex((val) => val["@id"] === instanceContainer), 1);
|
|
90
|
+
instances.instanceContainer?.forEach((instanceContainerUri) => {
|
|
91
|
+
typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
|
|
93
92
|
});
|
|
94
93
|
}
|
|
95
94
|
exports.removeRegistration = removeRegistration;
|
package/dist/setTypeIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTypeIndex.js","sourceRoot":"","sources":["../src/setTypeIndex.ts"],"names":[],"mappings":";;;AAAA,+BAA0B;AAC1B,sEAGqC;AACrC,2CAAqE;AACrE,4CAAgE;AAChE,kDAAoD;AAEpD,iDAA4C;AAC5C,kEAAsE;
|
|
1
|
+
{"version":3,"file":"setTypeInd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,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;KACjD;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA7CD,0EA6CC"}
|
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.1",
|
|
4
4
|
"description": "Solid Type Index support for LDO",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
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.1",
|
|
30
30
|
"@rdfjs/types": "^1.0.1",
|
|
31
31
|
"@testing-library/react": "^14.1.2",
|
|
32
32
|
"@types/jest": "^27.0.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"ts-node": "^10.9.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ldo/solid": "^0.0
|
|
40
|
-
"@ldo/solid-react": "^0.0
|
|
39
|
+
"@ldo/solid": "^1.0.0-alpha.1",
|
|
40
|
+
"@ldo/solid-react": "^1.0.0-alpha.1"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d9e4f2c416d20d16e84ce93744f0dbc79a39349a"
|
|
50
50
|
}
|
|
@@ -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
|
@@ -6,11 +6,12 @@ import { TypeRegistrationShapeType } from "./.ldo/typeIndex.shapeTypes";
|
|
|
6
6
|
import { RDF_TYPE, TYPE_REGISTRATION } from "./constants";
|
|
7
7
|
import type { Options } from "./util/Options";
|
|
8
8
|
import { guaranteeOptions } from "./util/Options";
|
|
9
|
+
import type { LdSet } from "@ldo/ldo";
|
|
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
|
|
@@ -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
|
@@ -12,6 +12,7 @@ import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes";
|
|
|
12
12
|
import type { Container } from "@ldo/solid";
|
|
13
13
|
import type { ISolidLdoDataset } from "@ldo/solid";
|
|
14
14
|
import type { NamedNode } from "@rdfjs/types";
|
|
15
|
+
import { set } from "@ldo/ldo";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* =============================================================================
|
|
@@ -24,15 +25,15 @@ export async function initTypeIndex(
|
|
|
24
25
|
): Promise<void> {
|
|
25
26
|
const { dataset } = guaranteeOptions(options);
|
|
26
27
|
const profile = await getProfile(webId, options);
|
|
27
|
-
if (!profile.privateTypeIndex?.
|
|
28
|
+
if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
|
|
28
29
|
const profileFolder = await dataset.getResource(webId).getParentContainer();
|
|
29
30
|
if (profileFolder?.isError) throw profileFolder;
|
|
30
31
|
if (!profileFolder)
|
|
31
32
|
throw new Error("No folder to save the type indexes to.");
|
|
32
|
-
if (!profile.privateTypeIndex?.
|
|
33
|
+
if (!profile.privateTypeIndex?.size) {
|
|
33
34
|
await createIndex(webId, profileFolder, dataset, true);
|
|
34
35
|
}
|
|
35
|
-
if (!profile.publicTypeIndex?.
|
|
36
|
+
if (!profile.publicTypeIndex?.size) {
|
|
36
37
|
await createIndex(webId, profileFolder, dataset, false);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -80,16 +81,16 @@ export async function createIndex(
|
|
|
80
81
|
.write(dataset.getResource(webId).uri)
|
|
81
82
|
.fromSubject(webId);
|
|
82
83
|
if (isPrivate) {
|
|
83
|
-
cProfile.privateTypeIndex?.
|
|
84
|
+
cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
|
|
84
85
|
} else {
|
|
85
|
-
cProfile.publicTypeIndex?.
|
|
86
|
+
cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
|
|
86
87
|
}
|
|
87
88
|
const cTypeIndex = transaction
|
|
88
89
|
.usingType(TypeIndexDocumentShapeType)
|
|
89
90
|
.write(indexResource.uri)
|
|
90
91
|
.fromSubject(indexResource.uri);
|
|
91
92
|
|
|
92
|
-
cTypeIndex.type =
|
|
93
|
+
cTypeIndex.type = set({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
|
|
93
94
|
const commitResult = await transaction.commitToPod();
|
|
94
95
|
if (commitResult.isError) throw commitResult;
|
|
95
96
|
}
|
|
@@ -104,6 +105,13 @@ interface Instances {
|
|
|
104
105
|
instanceContainer?: string[];
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Adds an instance to a TypeRegistration
|
|
110
|
+
* @param indexUri The URI of the TypeIndex
|
|
111
|
+
* @param classUri The URI for the class the instance should be added to
|
|
112
|
+
* @param instances Objects representing the instances to add
|
|
113
|
+
* @param options Options
|
|
114
|
+
*/
|
|
107
115
|
export function addRegistration(
|
|
108
116
|
indexUri: string,
|
|
109
117
|
classUri: string,
|
|
@@ -119,13 +127,20 @@ export function addRegistration(
|
|
|
119
127
|
|
|
120
128
|
// Add instances to type registration
|
|
121
129
|
instances.instance?.forEach((instance) => {
|
|
122
|
-
typeRegistration.instance?.
|
|
130
|
+
typeRegistration.instance?.add({ "@id": instance });
|
|
123
131
|
});
|
|
124
132
|
instances.instanceContainer?.forEach((instanceContainer) => {
|
|
125
|
-
typeRegistration.instanceContainer?.
|
|
133
|
+
typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
|
|
126
134
|
});
|
|
127
135
|
}
|
|
128
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Removes instances from a TypeRegistration
|
|
139
|
+
* @param indexUri The URI of the TypeIndex
|
|
140
|
+
* @param classUri The URI for the class the instance should be removed from
|
|
141
|
+
* @param instances Objects representing the instances to remove
|
|
142
|
+
* @param options Options
|
|
143
|
+
*/
|
|
129
144
|
export async function removeRegistration(
|
|
130
145
|
indexUri: string,
|
|
131
146
|
classUri: string,
|
|
@@ -139,31 +154,28 @@ export async function removeRegistration(
|
|
|
139
154
|
options,
|
|
140
155
|
);
|
|
141
156
|
|
|
142
|
-
console.log(typeRegistration["@id"]);
|
|
143
|
-
|
|
144
157
|
// Add instances to type registration
|
|
145
|
-
instances.instance?.forEach((
|
|
146
|
-
typeRegistration.instance?.
|
|
147
|
-
typeRegistration.instance.findIndex((val) => val["@id"] === instance),
|
|
148
|
-
1,
|
|
149
|
-
);
|
|
158
|
+
instances.instance?.forEach((instanceUri) => {
|
|
159
|
+
typeRegistration.instance?.delete({ "@id": instanceUri });
|
|
150
160
|
});
|
|
151
|
-
instances.instanceContainer?.forEach((
|
|
152
|
-
|
|
153
|
-
typeRegistration.instanceContainer?.splice(
|
|
154
|
-
typeRegistration.instanceContainer.findIndex(
|
|
155
|
-
(val) => val["@id"] === instanceContainer,
|
|
156
|
-
),
|
|
157
|
-
1,
|
|
158
|
-
);
|
|
161
|
+
instances.instanceContainer?.forEach((instanceContainerUri) => {
|
|
162
|
+
typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
|
|
159
163
|
});
|
|
160
164
|
}
|
|
161
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Finds a TypeRegistration inside of a type index. If it doesn't exist, it
|
|
168
|
+
* creates one.
|
|
169
|
+
* @param indexUri The URI of the typeIndex
|
|
170
|
+
* @param classUri The URI of the class in question for the TypeRegistration
|
|
171
|
+
* @param options
|
|
172
|
+
* @returns The Type Index
|
|
173
|
+
*/
|
|
162
174
|
export function findAppropriateTypeRegistration(
|
|
163
175
|
indexUri: string,
|
|
164
176
|
classUri: string,
|
|
165
177
|
options?: Options,
|
|
166
|
-
) {
|
|
178
|
+
): TypeRegistration {
|
|
167
179
|
const { dataset } = guaranteeOptions(options);
|
|
168
180
|
// Check to see if its already in the index
|
|
169
181
|
const existingRegistrationsUris: NamedNode[] = dataset
|