@ldo/solid-type-index 1.0.0-alpha.5 → 1.0.0-alpha.50

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.
Files changed (136) hide show
  1. package/README.md +6 -6
  2. package/dist/_ldo/profile.context.cjs +20 -0
  3. package/dist/_ldo/profile.context.mjs +22 -0
  4. package/dist/_ldo/profile.context.mjs.map +1 -0
  5. package/dist/_ldo/profile.schema.cjs +50 -0
  6. package/dist/_ldo/profile.schema.mjs +52 -0
  7. package/dist/_ldo/profile.schema.mjs.map +1 -0
  8. package/dist/_ldo/profile.shapeTypes.cjs +18 -0
  9. package/dist/_ldo/profile.shapeTypes.mjs +20 -0
  10. package/dist/_ldo/profile.shapeTypes.mjs.map +1 -0
  11. package/dist/_ldo/profile.typings.d.cts +30 -0
  12. package/dist/_ldo/profile.typings.d.cts.map +1 -0
  13. package/dist/_ldo/profile.typings.d.mts +30 -0
  14. package/dist/_ldo/profile.typings.d.mts.map +1 -0
  15. package/dist/_ldo/typeIndex.context.cjs +53 -0
  16. package/dist/_ldo/typeIndex.context.mjs +55 -0
  17. package/dist/_ldo/typeIndex.context.mjs.map +1 -0
  18. package/dist/_ldo/typeIndex.schema.cjs +115 -0
  19. package/dist/_ldo/typeIndex.schema.mjs +117 -0
  20. package/dist/_ldo/typeIndex.schema.mjs.map +1 -0
  21. package/dist/_ldo/typeIndex.shapeTypes.cjs +27 -0
  22. package/dist/_ldo/typeIndex.shapeTypes.mjs +28 -0
  23. package/dist/_ldo/typeIndex.shapeTypes.mjs.map +1 -0
  24. package/dist/_ldo/typeIndex.typings.d.cts +37 -0
  25. package/dist/_ldo/typeIndex.typings.d.cts.map +1 -0
  26. package/dist/_ldo/typeIndex.typings.d.mts +37 -0
  27. package/dist/_ldo/typeIndex.typings.d.mts.map +1 -0
  28. package/dist/constants.cjs +8 -0
  29. package/dist/constants.mjs +8 -0
  30. package/dist/constants.mjs.map +1 -0
  31. package/dist/getTypeIndex.cjs +52 -0
  32. package/dist/getTypeIndex.d.cts +14 -0
  33. package/dist/getTypeIndex.d.cts.map +1 -0
  34. package/dist/getTypeIndex.d.mts +14 -0
  35. package/dist/getTypeIndex.d.mts.map +1 -0
  36. package/dist/getTypeIndex.mjs +51 -0
  37. package/dist/getTypeIndex.mjs.map +1 -0
  38. package/dist/index.cjs +16 -0
  39. package/dist/index.d.cts +5 -0
  40. package/dist/index.d.mts +5 -0
  41. package/dist/index.mjs +5 -0
  42. package/dist/react/useInstanceUris.cjs +27 -0
  43. package/dist/react/useInstanceUris.d.cts +13 -0
  44. package/dist/react/useInstanceUris.d.cts.map +1 -0
  45. package/dist/react/useInstanceUris.d.mts +13 -0
  46. package/dist/react/useInstanceUris.d.mts.map +1 -0
  47. package/dist/react/useInstanceUris.mjs +29 -0
  48. package/dist/react/useInstanceUris.mjs.map +1 -0
  49. package/dist/react/useTypeIndexProfile.cjs +10 -0
  50. package/dist/react/useTypeIndexProfile.d.cts +7 -0
  51. package/dist/react/useTypeIndexProfile.d.cts.map +1 -0
  52. package/dist/react/useTypeIndexProfile.d.mts +7 -0
  53. package/dist/react/useTypeIndexProfile.d.mts.map +1 -0
  54. package/dist/react/useTypeIndexProfile.mjs +12 -0
  55. package/dist/react/useTypeIndexProfile.mjs.map +1 -0
  56. package/dist/react/util/useSubscribeToUris.cjs +24 -0
  57. package/dist/react/util/useSubscribeToUris.mjs +26 -0
  58. package/dist/react/util/useSubscribeToUris.mjs.map +1 -0
  59. package/dist/setTypeIndex.cjs +125 -0
  60. package/dist/setTypeIndex.d.cts +56 -0
  61. package/dist/setTypeIndex.d.cts.map +1 -0
  62. package/dist/setTypeIndex.d.mts +56 -0
  63. package/dist/setTypeIndex.d.mts.map +1 -0
  64. package/dist/setTypeIndex.mjs +123 -0
  65. package/dist/setTypeIndex.mjs.map +1 -0
  66. package/dist/util/Options.cjs +13 -0
  67. package/dist/util/Options.d.cts +11 -0
  68. package/dist/util/Options.d.cts.map +1 -0
  69. package/dist/util/Options.d.mts +11 -0
  70. package/dist/util/Options.d.mts.map +1 -0
  71. package/dist/util/Options.mjs +15 -0
  72. package/dist/util/Options.mjs.map +1 -0
  73. package/package.json +36 -21
  74. package/src/{.ldo → _ldo}/profile.context.ts +1 -1
  75. package/src/{.ldo → _ldo}/profile.schema.ts +1 -1
  76. package/src/{.ldo → _ldo}/profile.shapeTypes.ts +2 -2
  77. package/src/{.ldo → _ldo}/profile.typings.ts +1 -1
  78. package/src/{.ldo → _ldo}/typeIndex.context.ts +1 -1
  79. package/src/{.ldo → _ldo}/typeIndex.schema.ts +1 -1
  80. package/src/{.ldo → _ldo}/typeIndex.shapeTypes.ts +2 -2
  81. package/src/{.ldo → _ldo}/typeIndex.typings.ts +1 -1
  82. package/src/getTypeIndex.ts +4 -4
  83. package/src/react/useInstanceUris.ts +3 -1
  84. package/src/react/useTypeIndexProfile.ts +2 -2
  85. package/src/setTypeIndex.ts +7 -7
  86. package/src/util/Options.ts +0 -2
  87. package/dist/.ldo/profile.context.d.ts +0 -2
  88. package/dist/.ldo/profile.context.js +0 -16
  89. package/dist/.ldo/profile.context.js.map +0 -1
  90. package/dist/.ldo/profile.schema.d.ts +0 -2
  91. package/dist/.ldo/profile.schema.js +0 -59
  92. package/dist/.ldo/profile.schema.js.map +0 -1
  93. package/dist/.ldo/profile.shapeTypes.d.ts +0 -3
  94. package/dist/.ldo/profile.shapeTypes.js +0 -11
  95. package/dist/.ldo/profile.shapeTypes.js.map +0 -1
  96. package/dist/.ldo/profile.typings.d.ts +0 -11
  97. package/dist/.ldo/profile.typings.js +0 -3
  98. package/dist/.ldo/profile.typings.js.map +0 -1
  99. package/dist/.ldo/typeIndex.context.d.ts +0 -2
  100. package/dist/.ldo/typeIndex.context.js +0 -61
  101. package/dist/.ldo/typeIndex.context.js.map +0 -1
  102. package/dist/.ldo/typeIndex.schema.d.ts +0 -2
  103. package/dist/.ldo/typeIndex.schema.js +0 -141
  104. package/dist/.ldo/typeIndex.schema.js.map +0 -1
  105. package/dist/.ldo/typeIndex.shapeTypes.d.ts +0 -4
  106. package/dist/.ldo/typeIndex.shapeTypes.js +0 -16
  107. package/dist/.ldo/typeIndex.shapeTypes.js.map +0 -1
  108. package/dist/.ldo/typeIndex.typings.d.ts +0 -26
  109. package/dist/.ldo/typeIndex.typings.js +0 -3
  110. package/dist/.ldo/typeIndex.typings.js.map +0 -1
  111. package/dist/constants.d.ts +0 -5
  112. package/dist/constants.js +0 -9
  113. package/dist/constants.js.map +0 -1
  114. package/dist/getTypeIndex.d.ts +0 -9
  115. package/dist/getTypeIndex.js +0 -62
  116. package/dist/getTypeIndex.js.map +0 -1
  117. package/dist/index.d.ts +0 -4
  118. package/dist/index.js +0 -21
  119. package/dist/index.js.map +0 -1
  120. package/dist/react/useInstanceUris.d.ts +0 -2
  121. package/dist/react/useInstanceUris.js +0 -26
  122. package/dist/react/useInstanceUris.js.map +0 -1
  123. package/dist/react/useTypeIndexProfile.d.ts +0 -2
  124. package/dist/react/useTypeIndexProfile.js +0 -13
  125. package/dist/react/useTypeIndexProfile.js.map +0 -1
  126. package/dist/react/util/useSubscribeToUris.d.ts +0 -1
  127. package/dist/react/util/useSubscribeToUris.js +0 -31
  128. package/dist/react/util/useSubscribeToUris.js.map +0 -1
  129. package/dist/setTypeIndex.d.ts +0 -14
  130. package/dist/setTypeIndex.js +0 -124
  131. package/dist/setTypeIndex.js.map +0 -1
  132. package/dist/util/Options.d.ts +0 -10
  133. package/dist/util/Options.js +0 -13
  134. package/dist/util/Options.js.map +0 -1
  135. /package/src/{.shapes → _shapes}/profile.shex +0 -0
  136. /package/src/{.shapes → _shapes}/typeIndex.shex +0 -0
@@ -0,0 +1,125 @@
1
+ const require_profile_shapeTypes = require("./_ldo/profile.shapeTypes.cjs");
2
+ const require_typeIndex_shapeTypes = require("./_ldo/typeIndex.shapeTypes.cjs");
3
+ const require_constants = require("./constants.cjs");
4
+ const require_Options = require("./util/Options.cjs");
5
+ const require_getTypeIndex = require("./getTypeIndex.cjs");
6
+ let uuid = require("uuid");
7
+ let _ldo_rdf_utils = require("@ldo/rdf-utils");
8
+ let _ldo_ldo = require("@ldo/ldo");
9
+ //#region src/setTypeIndex.ts
10
+ /**
11
+ * =============================================================================
12
+ * INITIALIZERS
13
+ * =============================================================================
14
+ */
15
+ async function initTypeIndex(webId, options) {
16
+ const { dataset } = require_Options.guaranteeOptions(options);
17
+ const profile = await require_getTypeIndex.getProfile(webId, options);
18
+ if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
19
+ const profileFolder = await dataset.getResource(webId).getParentContainer();
20
+ if (profileFolder?.isError) throw profileFolder;
21
+ if (!profileFolder) throw new Error("No folder to save the type indexes to.");
22
+ if (!profile.privateTypeIndex?.size) await createIndex(webId, profileFolder, dataset, true);
23
+ if (!profile.publicTypeIndex?.size) await createIndex(webId, profileFolder, dataset, false);
24
+ }
25
+ }
26
+ /**
27
+ * @internal
28
+ * @param webId
29
+ * @param profileFolder
30
+ * @param dataset
31
+ */
32
+ async function createIndex(webId, profileFolder, dataset, isPrivate) {
33
+ const createResult = await profileFolder.createChildAndOverwrite(`${isPrivate ? "private" : "public"}_index_${(0, uuid.v4)()}`);
34
+ if (createResult.isError) throw createResult;
35
+ const indexResource = createResult.resource;
36
+ const wacResult = await indexResource.setWac({
37
+ agent: { [webId]: {
38
+ read: true,
39
+ write: true,
40
+ append: true,
41
+ control: true
42
+ } },
43
+ public: {
44
+ read: isPrivate ? false : true,
45
+ write: true,
46
+ append: true,
47
+ control: true
48
+ },
49
+ authenticated: {
50
+ read: isPrivate ? false : true,
51
+ write: true,
52
+ append: true,
53
+ control: true
54
+ }
55
+ });
56
+ if (wacResult.isError) throw wacResult;
57
+ const transaction = dataset.startTransaction();
58
+ const cProfile = transaction.usingType(require_profile_shapeTypes.TypeIndexProfileShapeType).write(dataset.getResource(webId).uri).fromSubject(webId);
59
+ if (isPrivate) cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
60
+ else cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
61
+ const cTypeIndex = transaction.usingType(require_typeIndex_shapeTypes.TypeIndexDocumentShapeType).write(indexResource.uri).fromSubject(indexResource.uri);
62
+ cTypeIndex.type = (0, _ldo_ldo.set)({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
63
+ const commitResult = await transaction.commitToRemote();
64
+ if (commitResult.isError) throw commitResult;
65
+ }
66
+ /**
67
+ * Adds an instance to a TypeRegistration
68
+ * @param indexUri The URI of the TypeIndex
69
+ * @param classUri The URI for the class the instance should be added to
70
+ * @param instances Objects representing the instances to add
71
+ * @param options Options
72
+ */
73
+ function addRegistration(indexUri, classUri, instances, options) {
74
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
75
+ instances.instance?.forEach((instance) => {
76
+ typeRegistration.instance?.add({ "@id": instance });
77
+ });
78
+ instances.instanceContainer?.forEach((instanceContainer) => {
79
+ typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
80
+ });
81
+ }
82
+ /**
83
+ * Removes instances from a TypeRegistration
84
+ * @param indexUri The URI of the TypeIndex
85
+ * @param classUri The URI for the class the instance should be removed from
86
+ * @param instances Objects representing the instances to remove
87
+ * @param options Options
88
+ */
89
+ async function removeRegistration(indexUri, classUri, instances, options) {
90
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
91
+ instances.instance?.forEach((instanceUri) => {
92
+ typeRegistration.instance?.delete({ "@id": instanceUri });
93
+ });
94
+ instances.instanceContainer?.forEach((instanceContainerUri) => {
95
+ typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
96
+ });
97
+ }
98
+ /**
99
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
100
+ * creates one.
101
+ * @param indexUri The URI of the typeIndex
102
+ * @param classUri The URI of the class in question for the TypeRegistration
103
+ * @param options
104
+ * @returns The Type Index
105
+ */
106
+ function findAppropriateTypeRegistration(indexUri, classUri, options) {
107
+ const { dataset } = require_Options.guaranteeOptions(options);
108
+ const existingRegistrationForClassUri = dataset.match(null, (0, _ldo_rdf_utils.namedNode)(require_constants.RDF_TYPE), (0, _ldo_rdf_utils.namedNode)(require_constants.TYPE_REGISTRATION), (0, _ldo_rdf_utils.namedNode)(indexUri)).toArray().map((quad) => quad.subject).find((registrationUri) => {
109
+ return dataset.has((0, _ldo_rdf_utils.quad)(registrationUri, (0, _ldo_rdf_utils.namedNode)(require_constants.FOR_CLASS), (0, _ldo_rdf_utils.namedNode)(classUri), (0, _ldo_rdf_utils.namedNode)(indexUri)));
110
+ })?.value;
111
+ let typeRegistration;
112
+ if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(require_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(existingRegistrationForClassUri);
113
+ else {
114
+ typeRegistration = dataset.usingType(require_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(`${indexUri}#${(0, uuid.v4)()}`);
115
+ typeRegistration.type = { "@id": "TypeRegistration" };
116
+ typeRegistration.forClass = { "@id": classUri };
117
+ }
118
+ return typeRegistration;
119
+ }
120
+ //#endregion
121
+ exports.addRegistration = addRegistration;
122
+ exports.createIndex = createIndex;
123
+ exports.findAppropriateTypeRegistration = findAppropriateTypeRegistration;
124
+ exports.initTypeIndex = initTypeIndex;
125
+ exports.removeRegistration = removeRegistration;
@@ -0,0 +1,56 @@
1
+ import { TypeRegistration } from "./_ldo/typeIndex.typings.cjs";
2
+ import { Options } from "./util/Options.cjs";
3
+ import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
4
+ import { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
5
+
6
+ //#region src/setTypeIndex.d.ts
7
+ /**
8
+ * =============================================================================
9
+ * INITIALIZERS
10
+ * =============================================================================
11
+ */
12
+ declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
13
+ /**
14
+ * @internal
15
+ * @param webId
16
+ * @param profileFolder
17
+ * @param dataset
18
+ */
19
+ declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
20
+ /**
21
+ * =============================================================================
22
+ * DATASET MODIFIERS
23
+ * =============================================================================
24
+ */
25
+ interface Instances {
26
+ instance?: string[];
27
+ instanceContainer?: string[];
28
+ }
29
+ /**
30
+ * Adds an instance to a TypeRegistration
31
+ * @param indexUri The URI of the TypeIndex
32
+ * @param classUri The URI for the class the instance should be added to
33
+ * @param instances Objects representing the instances to add
34
+ * @param options Options
35
+ */
36
+ declare function addRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): void;
37
+ /**
38
+ * Removes instances from a TypeRegistration
39
+ * @param indexUri The URI of the TypeIndex
40
+ * @param classUri The URI for the class the instance should be removed from
41
+ * @param instances Objects representing the instances to remove
42
+ * @param options Options
43
+ */
44
+ declare function removeRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): Promise<void>;
45
+ /**
46
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
47
+ * creates one.
48
+ * @param indexUri The URI of the typeIndex
49
+ * @param classUri The URI of the class in question for the TypeRegistration
50
+ * @param options
51
+ * @returns The Type Index
52
+ */
53
+ declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
54
+ //#endregion
55
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
56
+ //# sourceMappingURL=setTypeIndex.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.d.cts","names":[],"sources":["../src/setTypeIndex.ts"],"mappings":";;;;;;;;AA2BA;;;iBAAsB,aAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA;;;;;;;iBAyBmB,WAAA,CACpB,KAAA,OACA,aAAA,EAAe,cAAA,EACf,OAAA,EAAS,mBAAA,EACN,oBAAA,GAAuB,eAAA,0BAE1B,SAAA,YAAkB,OAAA;;;;;;UAmDV,SAAA;EACR,QAAA;EACA,iBAAA;AAAA;;;;;;;;iBAUc,eAAA,CACd,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA;;;;AAvBX;;;;iBAgDqB,kBAAA,CACpB,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA,GAAO,OAAA;AAjCnB;;;;;;;;AAAA,iBA2DgB,+BAAA,CACd,QAAA,UACA,QAAA,UACA,OAAA,GAAU,OAAA,GACT,gBAAA"}
@@ -0,0 +1,56 @@
1
+ import { TypeRegistration } from "./_ldo/typeIndex.typings.mjs";
2
+ import { Options } from "./util/Options.mjs";
3
+ import { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
4
+ import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
5
+
6
+ //#region src/setTypeIndex.d.ts
7
+ /**
8
+ * =============================================================================
9
+ * INITIALIZERS
10
+ * =============================================================================
11
+ */
12
+ declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
13
+ /**
14
+ * @internal
15
+ * @param webId
16
+ * @param profileFolder
17
+ * @param dataset
18
+ */
19
+ declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
20
+ /**
21
+ * =============================================================================
22
+ * DATASET MODIFIERS
23
+ * =============================================================================
24
+ */
25
+ interface Instances {
26
+ instance?: string[];
27
+ instanceContainer?: string[];
28
+ }
29
+ /**
30
+ * Adds an instance to a TypeRegistration
31
+ * @param indexUri The URI of the TypeIndex
32
+ * @param classUri The URI for the class the instance should be added to
33
+ * @param instances Objects representing the instances to add
34
+ * @param options Options
35
+ */
36
+ declare function addRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): void;
37
+ /**
38
+ * Removes instances from a TypeRegistration
39
+ * @param indexUri The URI of the TypeIndex
40
+ * @param classUri The URI for the class the instance should be removed from
41
+ * @param instances Objects representing the instances to remove
42
+ * @param options Options
43
+ */
44
+ declare function removeRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): Promise<void>;
45
+ /**
46
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
47
+ * creates one.
48
+ * @param indexUri The URI of the typeIndex
49
+ * @param classUri The URI of the class in question for the TypeRegistration
50
+ * @param options
51
+ * @returns The Type Index
52
+ */
53
+ declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
54
+ //#endregion
55
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
56
+ //# sourceMappingURL=setTypeIndex.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.d.mts","names":[],"sources":["../src/setTypeIndex.ts"],"mappings":";;;;;;;;AA2BA;;;iBAAsB,aAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA;;;;;;;iBAyBmB,WAAA,CACpB,KAAA,OACA,aAAA,EAAe,cAAA,EACf,OAAA,EAAS,mBAAA,EACN,oBAAA,GAAuB,eAAA,0BAE1B,SAAA,YAAkB,OAAA;;;;;;UAmDV,SAAA;EACR,QAAA;EACA,iBAAA;AAAA;;;;;;;;iBAUc,eAAA,CACd,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA;;;;AAvBX;;;;iBAgDqB,kBAAA,CACpB,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA,GAAO,OAAA;AAjCnB;;;;;;;;AAAA,iBA2DgB,+BAAA,CACd,QAAA,UACA,QAAA,UACA,OAAA,GAAU,OAAA,GACT,gBAAA"}
@@ -0,0 +1,123 @@
1
+ import { TypeIndexProfileShapeType } from "./_ldo/profile.shapeTypes.mjs";
2
+ import { TypeIndexDocumentShapeType, TypeRegistrationShapeType } from "./_ldo/typeIndex.shapeTypes.mjs";
3
+ import { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from "./constants.mjs";
4
+ import { guaranteeOptions } from "./util/Options.mjs";
5
+ import { getProfile } from "./getTypeIndex.mjs";
6
+ import { v4 } from "uuid";
7
+ import { namedNode, quad } from "@ldo/rdf-utils";
8
+ import { set } from "@ldo/ldo";
9
+ //#region src/setTypeIndex.ts
10
+ /**
11
+ * =============================================================================
12
+ * INITIALIZERS
13
+ * =============================================================================
14
+ */
15
+ async function initTypeIndex(webId, options) {
16
+ const { dataset } = guaranteeOptions(options);
17
+ const profile = await getProfile(webId, options);
18
+ if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
19
+ const profileFolder = await dataset.getResource(webId).getParentContainer();
20
+ if (profileFolder?.isError) throw profileFolder;
21
+ if (!profileFolder) throw new Error("No folder to save the type indexes to.");
22
+ if (!profile.privateTypeIndex?.size) await createIndex(webId, profileFolder, dataset, true);
23
+ if (!profile.publicTypeIndex?.size) await createIndex(webId, profileFolder, dataset, false);
24
+ }
25
+ }
26
+ /**
27
+ * @internal
28
+ * @param webId
29
+ * @param profileFolder
30
+ * @param dataset
31
+ */
32
+ async function createIndex(webId, profileFolder, dataset, isPrivate) {
33
+ const createResult = await profileFolder.createChildAndOverwrite(`${isPrivate ? "private" : "public"}_index_${v4()}`);
34
+ if (createResult.isError) throw createResult;
35
+ const indexResource = createResult.resource;
36
+ const wacResult = await indexResource.setWac({
37
+ agent: { [webId]: {
38
+ read: true,
39
+ write: true,
40
+ append: true,
41
+ control: true
42
+ } },
43
+ public: {
44
+ read: isPrivate ? false : true,
45
+ write: true,
46
+ append: true,
47
+ control: true
48
+ },
49
+ authenticated: {
50
+ read: isPrivate ? false : true,
51
+ write: true,
52
+ append: true,
53
+ control: true
54
+ }
55
+ });
56
+ if (wacResult.isError) throw wacResult;
57
+ const transaction = dataset.startTransaction();
58
+ const cProfile = transaction.usingType(TypeIndexProfileShapeType).write(dataset.getResource(webId).uri).fromSubject(webId);
59
+ if (isPrivate) cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
60
+ else cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
61
+ const cTypeIndex = transaction.usingType(TypeIndexDocumentShapeType).write(indexResource.uri).fromSubject(indexResource.uri);
62
+ cTypeIndex.type = set({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
63
+ const commitResult = await transaction.commitToRemote();
64
+ if (commitResult.isError) throw commitResult;
65
+ }
66
+ /**
67
+ * Adds an instance to a TypeRegistration
68
+ * @param indexUri The URI of the TypeIndex
69
+ * @param classUri The URI for the class the instance should be added to
70
+ * @param instances Objects representing the instances to add
71
+ * @param options Options
72
+ */
73
+ function addRegistration(indexUri, classUri, instances, options) {
74
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
75
+ instances.instance?.forEach((instance) => {
76
+ typeRegistration.instance?.add({ "@id": instance });
77
+ });
78
+ instances.instanceContainer?.forEach((instanceContainer) => {
79
+ typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
80
+ });
81
+ }
82
+ /**
83
+ * Removes instances from a TypeRegistration
84
+ * @param indexUri The URI of the TypeIndex
85
+ * @param classUri The URI for the class the instance should be removed from
86
+ * @param instances Objects representing the instances to remove
87
+ * @param options Options
88
+ */
89
+ async function removeRegistration(indexUri, classUri, instances, options) {
90
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
91
+ instances.instance?.forEach((instanceUri) => {
92
+ typeRegistration.instance?.delete({ "@id": instanceUri });
93
+ });
94
+ instances.instanceContainer?.forEach((instanceContainerUri) => {
95
+ typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
96
+ });
97
+ }
98
+ /**
99
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
100
+ * creates one.
101
+ * @param indexUri The URI of the typeIndex
102
+ * @param classUri The URI of the class in question for the TypeRegistration
103
+ * @param options
104
+ * @returns The Type Index
105
+ */
106
+ function findAppropriateTypeRegistration(indexUri, classUri, options) {
107
+ const { dataset } = guaranteeOptions(options);
108
+ const existingRegistrationForClassUri = dataset.match(null, namedNode(RDF_TYPE), namedNode(TYPE_REGISTRATION), namedNode(indexUri)).toArray().map((quad) => quad.subject).find((registrationUri) => {
109
+ return dataset.has(quad(registrationUri, namedNode(FOR_CLASS), namedNode(classUri), namedNode(indexUri)));
110
+ })?.value;
111
+ let typeRegistration;
112
+ if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(TypeRegistrationShapeType).write(indexUri).fromSubject(existingRegistrationForClassUri);
113
+ else {
114
+ typeRegistration = dataset.usingType(TypeRegistrationShapeType).write(indexUri).fromSubject(`${indexUri}#${v4()}`);
115
+ typeRegistration.type = { "@id": "TypeRegistration" };
116
+ typeRegistration.forClass = { "@id": classUri };
117
+ }
118
+ return typeRegistration;
119
+ }
120
+ //#endregion
121
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
122
+
123
+ //# sourceMappingURL=setTypeIndex.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.mjs","names":[],"sources":["../src/setTypeIndex.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { v4 } from \"uuid\";\nimport { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from \"./constants\";\nimport { guaranteeOptions, type Options } from \"./util/Options\";\nimport { namedNode, quad } from \"@ldo/rdf-utils\";\nimport type { TypeRegistration } from \"./_ldo/typeIndex.typings\";\nimport { getProfile } from \"./getTypeIndex\";\nimport { TypeIndexProfileShapeType } from \"./_ldo/profile.shapeTypes\";\nimport type { NamedNode } from \"@rdfjs/types\";\nimport { set } from \"@ldo/ldo\";\nimport type {\n SolidConnectedPlugin,\n SolidContainer,\n SolidContainerUri,\n SolidLeafUri,\n} from \"@ldo/connected-solid\";\nimport type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\nimport {\n TypeIndexDocumentShapeType,\n TypeRegistrationShapeType,\n} from \"./_ldo/typeIndex.shapeTypes\";\n\n/**\n * =============================================================================\n * INITIALIZERS\n * =============================================================================\n */\nexport async function initTypeIndex(\n webId: string,\n options?: Options,\n): Promise<void> {\n const { dataset } = guaranteeOptions(options);\n const profile = await getProfile(webId, options);\n if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {\n const profileFolder = await dataset\n .getResource(webId as SolidLeafUri | SolidContainerUri)\n .getParentContainer();\n if (profileFolder?.isError) throw profileFolder;\n if (!profileFolder)\n throw new Error(\"No folder to save the type indexes to.\");\n if (!profile.privateTypeIndex?.size) {\n await createIndex(webId, profileFolder, dataset, true);\n }\n if (!profile.publicTypeIndex?.size) {\n await createIndex(webId, profileFolder, dataset, false);\n }\n }\n}\n\n/**\n * @internal\n * @param webId\n * @param profileFolder\n * @param dataset\n */\nexport async function createIndex(\n webId,\n profileFolder: SolidContainer,\n dataset: ConnectedLdoDataset<\n (SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]\n >,\n isPrivate: boolean,\n) {\n // Create a private type index\n const createResult = await profileFolder.createChildAndOverwrite(\n `${isPrivate ? \"private\" : \"public\"}_index_${v4()}`,\n );\n if (createResult.isError) throw createResult;\n const indexResource = createResult.resource;\n const wacResult = await indexResource.setWac({\n agent: {\n [webId]: { read: true, write: true, append: true, control: true },\n },\n public: {\n read: isPrivate ? false : true,\n write: true,\n append: true,\n control: true,\n },\n authenticated: {\n read: isPrivate ? false : true,\n write: true,\n append: true,\n control: true,\n },\n });\n if (wacResult.isError) throw wacResult;\n const transaction = dataset.startTransaction();\n const cProfile = transaction\n .usingType(TypeIndexProfileShapeType)\n .write(dataset.getResource(webId).uri)\n .fromSubject(webId);\n if (isPrivate) {\n cProfile.privateTypeIndex?.add({ \"@id\": indexResource.uri });\n } else {\n cProfile.publicTypeIndex?.add({ \"@id\": indexResource.uri });\n }\n const cTypeIndex = transaction\n .usingType(TypeIndexDocumentShapeType)\n .write(indexResource.uri)\n .fromSubject(indexResource.uri);\n\n cTypeIndex.type = set({ \"@id\": \"ListedDocument\" }, { \"@id\": \"TypeIndex\" });\n const commitResult = await transaction.commitToRemote();\n if (commitResult.isError) throw commitResult;\n}\n\n/**\n * =============================================================================\n * DATASET MODIFIERS\n * =============================================================================\n */\ninterface Instances {\n instance?: string[];\n instanceContainer?: string[];\n}\n\n/**\n * Adds an instance to a TypeRegistration\n * @param indexUri The URI of the TypeIndex\n * @param classUri The URI for the class the instance should be added to\n * @param instances Objects representing the instances to add\n * @param options Options\n */\nexport function addRegistration(\n indexUri: string,\n classUri: string,\n instances: Instances,\n options?: Options,\n): void {\n // Check to see if its already in the index\n const typeRegistration = findAppropriateTypeRegistration(\n indexUri,\n classUri,\n options,\n );\n\n // Add instances to type registration\n instances.instance?.forEach((instance) => {\n typeRegistration.instance?.add({ \"@id\": instance });\n });\n instances.instanceContainer?.forEach((instanceContainer) => {\n typeRegistration.instanceContainer?.add({ \"@id\": instanceContainer });\n });\n}\n\n/**\n * Removes instances from a TypeRegistration\n * @param indexUri The URI of the TypeIndex\n * @param classUri The URI for the class the instance should be removed from\n * @param instances Objects representing the instances to remove\n * @param options Options\n */\nexport async function removeRegistration(\n indexUri: string,\n classUri: string,\n instances: Instances,\n options?: Options,\n) {\n // Check to see if its already in the index\n const typeRegistration = findAppropriateTypeRegistration(\n indexUri,\n classUri,\n options,\n );\n\n // Add instances to type registration\n instances.instance?.forEach((instanceUri) => {\n typeRegistration.instance?.delete({ \"@id\": instanceUri });\n });\n instances.instanceContainer?.forEach((instanceContainerUri) => {\n typeRegistration.instanceContainer?.delete({ \"@id\": instanceContainerUri });\n });\n}\n\n/**\n * Finds a TypeRegistration inside of a type index. If it doesn't exist, it\n * creates one.\n * @param indexUri The URI of the typeIndex\n * @param classUri The URI of the class in question for the TypeRegistration\n * @param options\n * @returns The Type Index\n */\nexport function findAppropriateTypeRegistration(\n indexUri: string,\n classUri: string,\n options?: Options,\n): TypeRegistration {\n const { dataset } = guaranteeOptions(options);\n // Check to see if its already in the index\n const existingRegistrationsUris: NamedNode[] = dataset\n .match(\n null,\n namedNode(RDF_TYPE),\n namedNode(TYPE_REGISTRATION),\n namedNode(indexUri),\n )\n .toArray()\n .map((quad) => quad.subject) as NamedNode[];\n\n const existingRegistrationForClassUri = existingRegistrationsUris.find(\n (registrationUri) => {\n return dataset.has(\n quad(\n registrationUri,\n namedNode(FOR_CLASS),\n namedNode(classUri),\n namedNode(indexUri),\n ),\n );\n },\n )?.value;\n\n let typeRegistration: TypeRegistration;\n if (existingRegistrationForClassUri) {\n typeRegistration = dataset\n .usingType(TypeRegistrationShapeType)\n .write(indexUri)\n .fromSubject(existingRegistrationForClassUri);\n } else {\n typeRegistration = dataset\n .usingType(TypeRegistrationShapeType)\n .write(indexUri)\n .fromSubject(`${indexUri}#${v4()}`);\n typeRegistration.type = { \"@id\": \"TypeRegistration\" };\n typeRegistration.forClass = { \"@id\": classUri };\n }\n return typeRegistration;\n}\n"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ let _ldo_connected_solid = require("@ldo/connected-solid");
2
+ //#region src/util/Options.ts
3
+ function guaranteeOptions(options) {
4
+ const fetch = (0, _ldo_connected_solid.guaranteeFetch)(options?.fetch);
5
+ const dataset = options?.solidLdoDataset ?? (0, _ldo_connected_solid.createSolidLdoDataset)();
6
+ dataset.setContext("solid", { fetch });
7
+ return {
8
+ fetch,
9
+ dataset
10
+ };
11
+ }
12
+ //#endregion
13
+ exports.guaranteeOptions = guaranteeOptions;
@@ -0,0 +1,11 @@
1
+ import { ConnectedLdoDataset, IConnectedLdoDataset } from "@ldo/connected";
2
+ import { SolidConnectedPlugin } from "@ldo/connected-solid";
3
+
4
+ //#region src/util/Options.d.ts
5
+ interface Options {
6
+ solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;
7
+ fetch?: typeof fetch;
8
+ }
9
+ //#endregion
10
+ export { Options };
11
+ //# sourceMappingURL=Options.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.d.cts","names":[],"sources":["../../src/util/Options.ts"],"mappings":";;;;UAKiB,OAAA;EACf,eAAA,GAAkB,oBAAA,CAAqB,oBAAA;EACvC,KAAA,UAAe,KAAA;AAAA"}
@@ -0,0 +1,11 @@
1
+ import { SolidConnectedPlugin } from "@ldo/connected-solid";
2
+ import { ConnectedLdoDataset, IConnectedLdoDataset } from "@ldo/connected";
3
+
4
+ //#region src/util/Options.d.ts
5
+ interface Options {
6
+ solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;
7
+ fetch?: typeof fetch;
8
+ }
9
+ //#endregion
10
+ export { Options };
11
+ //# sourceMappingURL=Options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.d.mts","names":[],"sources":["../../src/util/Options.ts"],"mappings":";;;;UAKiB,OAAA;EACf,eAAA,GAAkB,oBAAA,CAAqB,oBAAA;EACvC,KAAA,UAAe,KAAA;AAAA"}
@@ -0,0 +1,15 @@
1
+ import { createSolidLdoDataset, guaranteeFetch } from "@ldo/connected-solid";
2
+ //#region src/util/Options.ts
3
+ function guaranteeOptions(options) {
4
+ const fetch = guaranteeFetch(options?.fetch);
5
+ const dataset = options?.solidLdoDataset ?? createSolidLdoDataset();
6
+ dataset.setContext("solid", { fetch });
7
+ return {
8
+ fetch,
9
+ dataset
10
+ };
11
+ }
12
+ //#endregion
13
+ export { guaranteeOptions };
14
+
15
+ //# sourceMappingURL=Options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.mjs","names":[],"sources":["../../src/util/Options.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ConnectedLdoDataset, IConnectedLdoDataset } from \"@ldo/connected\";\nimport type { SolidConnectedPlugin } from \"@ldo/connected-solid\";\nimport { createSolidLdoDataset, guaranteeFetch } from \"@ldo/connected-solid\";\n\nexport interface Options {\n solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;\n fetch?: typeof fetch;\n}\n\nexport function guaranteeOptions(options?: Options) {\n const fetch = guaranteeFetch(options?.fetch);\n const dataset = (options?.solidLdoDataset ??\n createSolidLdoDataset()) as ConnectedLdoDataset<SolidConnectedPlugin[]>;\n dataset.setContext(\"solid\", { fetch });\n return { fetch, dataset };\n}\n"],"mappings":";;AAUA,SAAgB,iBAAiB,SAAmB;CAClD,MAAM,QAAQ,eAAe,SAAS,MAAM;CAC5C,MAAM,UAAW,SAAS,mBACxB,uBAAuB;AACzB,SAAQ,WAAW,SAAS,EAAE,OAAO,CAAC;AACtC,QAAO;EAAE;EAAO;EAAS"}
package/package.json CHANGED
@@ -1,41 +1,56 @@
1
1
  {
2
2
  "name": "@ldo/solid-type-index",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.50",
4
4
  "description": "Solid Type Index support for LDO",
5
- "main": "dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
6
22
  "scripts": {
7
- "build": "tsc --project tsconfig.build.json",
8
- "watch": "tsc --watch",
9
- "test": "npm run test:integration",
10
- "test:watch": "jest --watch",
11
- "prepublishOnly": "npm run test && npm run build",
12
- "build:ldo": "ldo build --input src/.shapes --output src/.ldo",
13
- "lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
14
- "test:integration": "start-server-and-test start-test-server http://localhost:3003 start-integration-test",
15
- "start-test-server": "ts-node ./test/test-server/runServer.ts",
16
- "start-integration-test": "jest --coverage"
23
+ "build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 tsdown",
24
+ "test": "vitest run --coverage",
25
+ "prepublishOnly": "npm run build",
26
+ "build:ldo": "ldo build --input src/_shapes --output src/_ldo",
27
+ "lint:check": "eslint src/** --no-error-on-unmatched-pattern",
28
+ "lint": "npm run lint:check -- --fix",
29
+ "remove-dist": "rimraf dist/"
17
30
  },
18
31
  "repository": {
19
32
  "type": "git",
20
- "url": "git+https://github.com/o-development/ldobjects.git"
33
+ "url": "git+https://github.com/o-development/ldo.git"
21
34
  },
22
35
  "author": "Jackson Morgan",
23
36
  "license": "MIT",
24
37
  "bugs": {
25
- "url": "https://github.com/o-development/ldobjects/issues"
38
+ "url": "https://github.com/o-development/ldo/issues"
26
39
  },
27
- "homepage": "https://github.com/o-development/ldobjects/tree/main/packages/solid-react#readme",
40
+ "homepage": "https://github.com/o-development/ldo/tree/main/packages/solid-react#readme",
28
41
  "devDependencies": {
29
- "@ldo/rdf-utils": "^1.0.0-alpha.3",
30
- "@rdfjs/types": "^1.0.1",
42
+ "@ldo/test-solid-server": "^1.0.0-alpha.50",
31
43
  "@testing-library/react": "^14.1.2",
32
- "jest-environment-jsdom": "^29.7.0",
33
44
  "start-server-and-test": "^2.0.3",
34
45
  "ts-node": "^10.9.2"
35
46
  },
36
47
  "dependencies": {
37
- "@ldo/connected-solid": "^1.0.0-alpha.3",
38
- "@ldo/solid-react": "^1.0.0-alpha.5"
48
+ "@ldo/connected": "^1.0.0-alpha.50",
49
+ "@ldo/connected-solid": "^1.0.0-alpha.50",
50
+ "@ldo/ldo": "^1.0.0-alpha.50",
51
+ "@ldo/rdf-utils": "^1.0.0-alpha.50",
52
+ "@ldo/solid-react": "^1.0.0-alpha.50",
53
+ "@rdfjs/types": "^1.0.1"
39
54
  },
40
55
  "files": [
41
56
  "dist",
@@ -44,5 +59,5 @@
44
59
  "publishConfig": {
45
60
  "access": "public"
46
61
  },
47
- "gitHead": "3d4927ea60db0670bfe8b7d3dcff13d0b13697c0"
62
+ "gitHead": "7277a6694f01cdb776495a3028a625d8386c4887"
48
63
  }
@@ -1,4 +1,4 @@
1
- import { LdoJsonldContext } from "@ldo/ldo";
1
+ import type { LdoJsonldContext } from "@ldo/ldo";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,4 +1,4 @@
1
- import { Schema } from "shexj";
1
+ import type { Schema } from "shexj";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,7 +1,7 @@
1
- import { ShapeType } from "@ldo/ldo";
1
+ import type { ShapeType } from "@ldo/ldo";
2
2
  import { profileSchema } from "./profile.schema";
3
3
  import { profileContext } from "./profile.context";
4
- import { TypeIndexProfile } from "./profile.typings";
4
+ import type { TypeIndexProfile } from "./profile.typings";
5
5
 
6
6
  /**
7
7
  * =============================================================================
@@ -1,4 +1,4 @@
1
- import { LdoJsonldContext, LdSet } from "@ldo/ldo";
1
+ import type { LdoJsonldContext, LdSet } from "@ldo/ldo";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,4 +1,4 @@
1
- import { LdoJsonldContext } from "@ldo/ldo";
1
+ import type { LdoJsonldContext } from "@ldo/ldo";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,4 +1,4 @@
1
- import { Schema } from "shexj";
1
+ import type { Schema } from "shexj";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,7 +1,7 @@
1
- import { ShapeType } from "@ldo/ldo";
1
+ import type { ShapeType } from "@ldo/ldo";
2
2
  import { typeIndexSchema } from "./typeIndex.schema";
3
3
  import { typeIndexContext } from "./typeIndex.context";
4
- import { TypeIndexDocument, TypeRegistration } from "./typeIndex.typings";
4
+ import type { TypeIndexDocument, TypeRegistration } from "./typeIndex.typings";
5
5
 
6
6
  /**
7
7
  * =============================================================================
@@ -1,4 +1,4 @@
1
- import { LdoJsonldContext, LdSet } from "@ldo/ldo";
1
+ import type { LdoJsonldContext, LdSet } from "@ldo/ldo";
2
2
 
3
3
  /**
4
4
  * =============================================================================
@@ -1,7 +1,7 @@
1
- import type { TypeRegistration } from "./.ldo/typeIndex.typings";
2
- import type { TypeIndexProfile } from "./.ldo/profile.typings";
3
- import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes";
4
- import { TypeRegistrationShapeType } from "./.ldo/typeIndex.shapeTypes";
1
+ import type { TypeRegistration } from "./_ldo/typeIndex.typings";
2
+ import type { TypeIndexProfile } from "./_ldo/profile.typings";
3
+ import { TypeIndexProfileShapeType } from "./_ldo/profile.shapeTypes";
4
+ import { TypeRegistrationShapeType } from "./_ldo/typeIndex.shapeTypes";
5
5
  import { RDF_TYPE, TYPE_REGISTRATION } from "./constants";
6
6
  import type { Options } from "./util/Options";
7
7
  import { guaranteeOptions } from "./util/Options";
@@ -2,7 +2,7 @@ import { useTypeIndexProfile } from "./useTypeIndexProfile";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { useSubscribeToUris } from "./util/useSubscribeToUris";
4
4
  import { useLdo, useMatchSubject } from "@ldo/solid-react";
5
- import { TypeRegistrationShapeType } from "../.ldo/typeIndex.shapeTypes";
5
+ import { TypeRegistrationShapeType } from "../_ldo/typeIndex.shapeTypes";
6
6
  import { RDF_TYPE, TYPE_REGISTRATION } from "../constants";
7
7
  import {
8
8
  getInstanceUris,
@@ -37,6 +37,8 @@ export function useInstanceUris(classUri: string): SolidLeafUri[] {
37
37
 
38
38
  useEffect(() => {
39
39
  getInstanceUris(classUri, typeRegistrations.toArray(), {
40
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
+ // @ts-ignore TODO: come back and see if we can fix this
40
42
  solidLdoDataset: dataset,
41
43
  }).then(setLeafUris);
42
44
  }, [typeRegistrations]);