@ldo/solid-type-index 1.0.0-alpha.33 → 1.0.0-alpha.36

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 (175) hide show
  1. package/dist/.ldo/profile.context.cjs +22 -0
  2. package/dist/.ldo/profile.context.js +22 -0
  3. package/dist/.ldo/profile.context.js.map +1 -0
  4. package/dist/.ldo/profile.schema.cjs +52 -0
  5. package/dist/.ldo/profile.schema.js +52 -0
  6. package/dist/.ldo/profile.schema.js.map +1 -0
  7. package/dist/.ldo/profile.shapeTypes.cjs +20 -0
  8. package/dist/.ldo/profile.shapeTypes.js +21 -0
  9. package/dist/.ldo/profile.shapeTypes.js.map +1 -0
  10. package/dist/.ldo/profile.typings.d.cts +32 -0
  11. package/dist/.ldo/profile.typings.d.cts.map +1 -0
  12. package/dist/.ldo/profile.typings.d.ts +32 -0
  13. package/dist/.ldo/profile.typings.d.ts.map +1 -0
  14. package/dist/.ldo/typeIndex.context.cjs +55 -0
  15. package/dist/.ldo/typeIndex.context.js +55 -0
  16. package/dist/.ldo/typeIndex.context.js.map +1 -0
  17. package/dist/.ldo/typeIndex.schema.cjs +117 -0
  18. package/dist/.ldo/typeIndex.schema.js +117 -0
  19. package/dist/.ldo/typeIndex.schema.js.map +1 -0
  20. package/dist/.ldo/typeIndex.shapeTypes.cjs +29 -0
  21. package/dist/.ldo/typeIndex.shapeTypes.js +29 -0
  22. package/dist/.ldo/typeIndex.shapeTypes.js.map +1 -0
  23. package/dist/.ldo/typeIndex.typings.d.cts +39 -0
  24. package/dist/.ldo/typeIndex.typings.d.cts.map +1 -0
  25. package/dist/.ldo/typeIndex.typings.d.ts +39 -0
  26. package/dist/.ldo/typeIndex.typings.d.ts.map +1 -0
  27. package/dist/_virtual/rolldown_runtime.cjs +30 -0
  28. package/dist/constants.cjs +10 -0
  29. package/dist/constants.js +8 -0
  30. package/dist/constants.js.map +1 -0
  31. package/dist/getTypeIndex.cjs +57 -0
  32. package/dist/getTypeIndex.d.cts +16 -0
  33. package/dist/getTypeIndex.d.cts.map +1 -0
  34. package/dist/getTypeIndex.d.ts +16 -0
  35. package/dist/getTypeIndex.d.ts.map +1 -0
  36. package/dist/getTypeIndex.js +55 -0
  37. package/dist/getTypeIndex.js.map +1 -0
  38. package/dist/index.cjs +16 -0
  39. package/dist/index.d.cts +5 -0
  40. package/dist/index.d.ts +5 -0
  41. package/dist/index.js +6 -0
  42. package/dist/react/useInstanceUris.cjs +31 -0
  43. package/dist/react/useInstanceUris.d.cts +15 -0
  44. package/dist/react/useInstanceUris.d.cts.map +1 -0
  45. package/dist/react/useInstanceUris.d.ts +15 -0
  46. package/dist/react/useInstanceUris.d.ts.map +1 -0
  47. package/dist/react/useInstanceUris.js +31 -0
  48. package/dist/react/useInstanceUris.js.map +1 -0
  49. package/dist/react/useTypeIndexProfile.cjs +14 -0
  50. package/dist/react/useTypeIndexProfile.d.cts +9 -0
  51. package/dist/react/useTypeIndexProfile.d.cts.map +1 -0
  52. package/dist/react/useTypeIndexProfile.d.ts +9 -0
  53. package/dist/react/useTypeIndexProfile.d.ts.map +1 -0
  54. package/dist/react/useTypeIndexProfile.js +14 -0
  55. package/dist/react/useTypeIndexProfile.js.map +1 -0
  56. package/dist/react/util/useSubscribeToUris.cjs +28 -0
  57. package/dist/react/util/useSubscribeToUris.js +28 -0
  58. package/dist/react/util/useSubscribeToUris.js.map +1 -0
  59. package/dist/setTypeIndex.cjs +129 -0
  60. package/dist/{types/setTypeIndex.d.ts → setTypeIndex.d.cts} +17 -13
  61. package/dist/setTypeIndex.d.cts.map +1 -0
  62. package/dist/setTypeIndex.d.ts +57 -0
  63. package/dist/setTypeIndex.d.ts.map +1 -0
  64. package/dist/setTypeIndex.js +125 -0
  65. package/dist/setTypeIndex.js.map +1 -0
  66. package/dist/util/Options.cjs +16 -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.ts +11 -0
  70. package/dist/util/Options.d.ts.map +1 -0
  71. package/dist/util/Options.js +16 -0
  72. package/dist/util/Options.js.map +1 -0
  73. package/package.json +22 -18
  74. package/src/.ldo/profile.shapeTypes.ts +3 -3
  75. package/src/.ldo/typeIndex.shapeTypes.ts +3 -3
  76. package/src/getTypeIndex.ts +7 -7
  77. package/src/index.ts +4 -4
  78. package/src/react/useInstanceUris.ts +5 -5
  79. package/src/react/useTypeIndexProfile.ts +2 -2
  80. package/src/setTypeIndex.ts +6 -6
  81. package/dist/cjs/.ldo/profile.context.cjs +0 -21
  82. package/dist/cjs/.ldo/profile.context.js.map +0 -1
  83. package/dist/cjs/.ldo/profile.schema.cjs +0 -64
  84. package/dist/cjs/.ldo/profile.schema.js.map +0 -1
  85. package/dist/cjs/.ldo/profile.shapeTypes.cjs +0 -19
  86. package/dist/cjs/.ldo/profile.shapeTypes.js.map +0 -1
  87. package/dist/cjs/.ldo/profile.typings.cjs +0 -3
  88. package/dist/cjs/.ldo/profile.typings.js.map +0 -1
  89. package/dist/cjs/.ldo/typeIndex.context.cjs +0 -66
  90. package/dist/cjs/.ldo/typeIndex.context.js.map +0 -1
  91. package/dist/cjs/.ldo/typeIndex.schema.cjs +0 -146
  92. package/dist/cjs/.ldo/typeIndex.schema.js.map +0 -1
  93. package/dist/cjs/.ldo/typeIndex.shapeTypes.cjs +0 -27
  94. package/dist/cjs/.ldo/typeIndex.shapeTypes.js.map +0 -1
  95. package/dist/cjs/.ldo/typeIndex.typings.cjs +0 -3
  96. package/dist/cjs/.ldo/typeIndex.typings.js.map +0 -1
  97. package/dist/cjs/constants.cjs +0 -9
  98. package/dist/cjs/constants.js.map +0 -1
  99. package/dist/cjs/getTypeIndex.cjs +0 -67
  100. package/dist/cjs/getTypeIndex.js.map +0 -1
  101. package/dist/cjs/index.cjs +0 -21
  102. package/dist/cjs/index.js.map +0 -1
  103. package/dist/cjs/react/useInstanceUris.cjs +0 -33
  104. package/dist/cjs/react/useInstanceUris.js.map +0 -1
  105. package/dist/cjs/react/useTypeIndexProfile.cjs +0 -12
  106. package/dist/cjs/react/useTypeIndexProfile.js.map +0 -1
  107. package/dist/cjs/react/util/useSubscribeToUris.cjs +0 -33
  108. package/dist/cjs/react/util/useSubscribeToUris.js.map +0 -1
  109. package/dist/cjs/setTypeIndex.cjs +0 -163
  110. package/dist/cjs/setTypeIndex.js.map +0 -1
  111. package/dist/cjs/util/Options.cjs +0 -12
  112. package/dist/cjs/util/Options.js.map +0 -1
  113. package/dist/esm/.ldo/profile.context.js +0 -18
  114. package/dist/esm/.ldo/profile.context.js.map +0 -1
  115. package/dist/esm/.ldo/profile.schema.js +0 -61
  116. package/dist/esm/.ldo/profile.schema.js.map +0 -1
  117. package/dist/esm/.ldo/profile.shapeTypes.js +0 -16
  118. package/dist/esm/.ldo/profile.shapeTypes.js.map +0 -1
  119. package/dist/esm/.ldo/profile.typings.js +0 -2
  120. package/dist/esm/.ldo/profile.typings.js.map +0 -1
  121. package/dist/esm/.ldo/typeIndex.context.js +0 -63
  122. package/dist/esm/.ldo/typeIndex.context.js.map +0 -1
  123. package/dist/esm/.ldo/typeIndex.schema.js +0 -143
  124. package/dist/esm/.ldo/typeIndex.schema.js.map +0 -1
  125. package/dist/esm/.ldo/typeIndex.shapeTypes.js +0 -24
  126. package/dist/esm/.ldo/typeIndex.shapeTypes.js.map +0 -1
  127. package/dist/esm/.ldo/typeIndex.typings.js +0 -2
  128. package/dist/esm/.ldo/typeIndex.typings.js.map +0 -1
  129. package/dist/esm/constants.js +0 -6
  130. package/dist/esm/constants.js.map +0 -1
  131. package/dist/esm/getTypeIndex.js +0 -61
  132. package/dist/esm/getTypeIndex.js.map +0 -1
  133. package/dist/esm/index.js +0 -5
  134. package/dist/esm/index.js.map +0 -1
  135. package/dist/esm/react/useInstanceUris.js +0 -30
  136. package/dist/esm/react/useInstanceUris.js.map +0 -1
  137. package/dist/esm/react/useTypeIndexProfile.js +0 -9
  138. package/dist/esm/react/useTypeIndexProfile.js.map +0 -1
  139. package/dist/esm/react/util/useSubscribeToUris.js +0 -30
  140. package/dist/esm/react/util/useSubscribeToUris.js.map +0 -1
  141. package/dist/esm/setTypeIndex.js +0 -156
  142. package/dist/esm/setTypeIndex.js.map +0 -1
  143. package/dist/esm/util/Options.js +0 -9
  144. package/dist/esm/util/Options.js.map +0 -1
  145. package/dist/types/.ldo/profile.context.d.ts +0 -8
  146. package/dist/types/.ldo/profile.context.d.ts.map +0 -1
  147. package/dist/types/.ldo/profile.schema.d.ts +0 -8
  148. package/dist/types/.ldo/profile.schema.d.ts.map +0 -1
  149. package/dist/types/.ldo/profile.shapeTypes.d.ts +0 -12
  150. package/dist/types/.ldo/profile.shapeTypes.d.ts.map +0 -1
  151. package/dist/types/.ldo/profile.typings.d.ts +0 -26
  152. package/dist/types/.ldo/profile.typings.d.ts.map +0 -1
  153. package/dist/types/.ldo/typeIndex.context.d.ts +0 -8
  154. package/dist/types/.ldo/typeIndex.context.d.ts.map +0 -1
  155. package/dist/types/.ldo/typeIndex.schema.d.ts +0 -8
  156. package/dist/types/.ldo/typeIndex.schema.d.ts.map +0 -1
  157. package/dist/types/.ldo/typeIndex.shapeTypes.d.ts +0 -16
  158. package/dist/types/.ldo/typeIndex.shapeTypes.d.ts.map +0 -1
  159. package/dist/types/.ldo/typeIndex.typings.d.ts +0 -53
  160. package/dist/types/.ldo/typeIndex.typings.d.ts.map +0 -1
  161. package/dist/types/constants.d.ts +0 -6
  162. package/dist/types/constants.d.ts.map +0 -1
  163. package/dist/types/getTypeIndex.d.ts +0 -10
  164. package/dist/types/getTypeIndex.d.ts.map +0 -1
  165. package/dist/types/index.d.ts +0 -5
  166. package/dist/types/index.d.ts.map +0 -1
  167. package/dist/types/react/useInstanceUris.d.ts +0 -9
  168. package/dist/types/react/useInstanceUris.d.ts.map +0 -1
  169. package/dist/types/react/useTypeIndexProfile.d.ts +0 -3
  170. package/dist/types/react/useTypeIndexProfile.d.ts.map +0 -1
  171. package/dist/types/react/util/useSubscribeToUris.d.ts +0 -2
  172. package/dist/types/react/util/useSubscribeToUris.d.ts.map +0 -1
  173. package/dist/types/setTypeIndex.d.ts.map +0 -1
  174. package/dist/types/util/Options.d.ts +0 -11
  175. package/dist/types/util/Options.d.ts.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { useLdo } from "@ldo/solid-react";
2
+ import { useEffect, useRef } from "react";
3
+
4
+ //#region src/react/util/useSubscribeToUris.ts
5
+ function useSubscribeToUris(uris) {
6
+ const { dataset } = useLdo();
7
+ const currentlySubscribed = useRef({});
8
+ useEffect(() => {
9
+ const resources = uris.map((uri) => dataset.getResource(uri));
10
+ const previousSubscriptions = { ...currentlySubscribed.current };
11
+ Promise.all(resources.map(async (resource) => {
12
+ if (!previousSubscriptions[resource.uri]) {
13
+ await resource.readIfUnfetched();
14
+ currentlySubscribed.current[resource.uri] = await resource.subscribeToNotifications();
15
+ } else delete previousSubscriptions[resource.uri];
16
+ })).then(async () => {
17
+ await Promise.all(Object.entries(previousSubscriptions).map(async ([resourceUri, subscriptionId]) => {
18
+ delete currentlySubscribed.current[resourceUri];
19
+ const resource = dataset.getResource(resourceUri);
20
+ await resource.unsubscribeFromNotifications(subscriptionId);
21
+ }));
22
+ });
23
+ }, [uris]);
24
+ }
25
+
26
+ //#endregion
27
+ export { useSubscribeToUris };
28
+ //# sourceMappingURL=useSubscribeToUris.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubscribeToUris.js","names":["uris: string[]"],"sources":["../../../src/react/util/useSubscribeToUris.ts"],"sourcesContent":["import { useLdo } from \"@ldo/solid-react\";\nimport { useEffect, useRef } from \"react\";\n\nexport function useSubscribeToUris(uris: string[]) {\n const { dataset } = useLdo();\n const currentlySubscribed = useRef<Record<string, string>>({});\n useEffect(() => {\n const resources = uris.map((uri) => dataset.getResource(uri));\n const previousSubscriptions = { ...currentlySubscribed.current };\n Promise.all<void>(\n resources.map(async (resource) => {\n if (!previousSubscriptions[resource.uri]) {\n // Read and subscribe\n await resource.readIfUnfetched();\n currentlySubscribed.current[resource.uri] =\n await resource.subscribeToNotifications();\n } else {\n delete previousSubscriptions[resource.uri];\n }\n }),\n ).then(async () => {\n // Unsubscribe from all remaining previous subscriptions\n await Promise.all(\n Object.entries(previousSubscriptions).map(\n async ([resourceUri, subscriptionId]) => {\n // Unsubscribe\n delete currentlySubscribed.current[resourceUri];\n const resource = dataset.getResource(resourceUri);\n await resource.unsubscribeFromNotifications(subscriptionId);\n },\n ),\n );\n });\n }, [uris]);\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmBA,MAAgB;CACjD,MAAM,EAAE,SAAS,GAAG,QAAQ;CAC5B,MAAM,sBAAsB,OAA+B,CAAE,EAAC;AAC9D,WAAU,MAAM;EACd,MAAM,YAAY,KAAK,IAAI,CAAC,QAAQ,QAAQ,YAAY,IAAI,CAAC;EAC7D,MAAM,wBAAwB,EAAE,GAAG,oBAAoB,QAAS;AAChE,UAAQ,IACN,UAAU,IAAI,OAAO,aAAa;AAChC,QAAK,sBAAsB,SAAS,MAAM;AAExC,UAAM,SAAS,iBAAiB;AAChC,wBAAoB,QAAQ,SAAS,OACnC,MAAM,SAAS,0BAA0B;GAC5C,MACC,QAAO,sBAAsB,SAAS;EAEzC,EAAC,CACH,CAAC,KAAK,YAAY;AAEjB,SAAM,QAAQ,IACZ,OAAO,QAAQ,sBAAsB,CAAC,IACpC,OAAO,CAAC,aAAa,eAAe,KAAK;AAEvC,WAAO,oBAAoB,QAAQ;IACnC,MAAM,WAAW,QAAQ,YAAY,YAAY;AACjD,UAAM,SAAS,6BAA6B,eAAe;GAC5D,EACF,CACF;EACF,EAAC;CACH,GAAE,CAAC,IAAK,EAAC;AACX"}
@@ -0,0 +1,129 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_profile_shapeTypes = require('.ldo/profile.shapeTypes.cjs');
3
+ const require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_typeIndex_shapeTypes = require('.ldo/typeIndex.shapeTypes.cjs');
4
+ const require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_constants = require('./constants.cjs');
5
+ const require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_util_Options = require('./util/Options.cjs');
6
+ const require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_getTypeIndex = require('./getTypeIndex.cjs');
7
+ const uuid = require_rolldown_runtime.__toESM(require("uuid"));
8
+ const __ldo_rdf_utils = require_rolldown_runtime.__toESM(require("@ldo/rdf-utils"));
9
+ const __ldo_ldo = require_rolldown_runtime.__toESM(require("@ldo/ldo"));
10
+
11
+ //#region src/setTypeIndex.ts
12
+ /**
13
+ * =============================================================================
14
+ * INITIALIZERS
15
+ * =============================================================================
16
+ */
17
+ async function initTypeIndex(webId, options) {
18
+ const { dataset } = require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_util_Options.guaranteeOptions(options);
19
+ const profile = await require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_getTypeIndex.getProfile(webId, options);
20
+ if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
21
+ const profileFolder = await dataset.getResource(webId).getParentContainer();
22
+ if (profileFolder?.isError) throw profileFolder;
23
+ if (!profileFolder) throw new Error("No folder to save the type indexes to.");
24
+ if (!profile.privateTypeIndex?.size) await createIndex(webId, profileFolder, dataset, true);
25
+ if (!profile.publicTypeIndex?.size) await createIndex(webId, profileFolder, dataset, false);
26
+ }
27
+ }
28
+ /**
29
+ * @internal
30
+ * @param webId
31
+ * @param profileFolder
32
+ * @param dataset
33
+ */
34
+ async function createIndex(webId, profileFolder, dataset, isPrivate) {
35
+ const createResult = await profileFolder.createChildAndOverwrite(`${isPrivate ? "private" : "public"}_index_${(0, uuid.v4)()}`);
36
+ if (createResult.isError) throw createResult;
37
+ const indexResource = createResult.resource;
38
+ const wacResult = await indexResource.setWac({
39
+ agent: { [webId]: {
40
+ read: true,
41
+ write: true,
42
+ append: true,
43
+ control: true
44
+ } },
45
+ public: {
46
+ read: isPrivate ? false : true,
47
+ write: true,
48
+ append: true,
49
+ control: true
50
+ },
51
+ authenticated: {
52
+ read: isPrivate ? false : true,
53
+ write: true,
54
+ append: true,
55
+ control: true
56
+ }
57
+ });
58
+ if (wacResult.isError) throw wacResult;
59
+ const transaction = dataset.startTransaction();
60
+ const cProfile = transaction.usingType(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_profile_shapeTypes.TypeIndexProfileShapeType).write(dataset.getResource(webId).uri).fromSubject(webId);
61
+ if (isPrivate) cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
62
+ else cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
63
+ const cTypeIndex = transaction.usingType(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_typeIndex_shapeTypes.TypeIndexDocumentShapeType).write(indexResource.uri).fromSubject(indexResource.uri);
64
+ cTypeIndex.type = (0, __ldo_ldo.set)({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
65
+ const commitResult = await transaction.commitToRemote();
66
+ if (commitResult.isError) throw commitResult;
67
+ }
68
+ /**
69
+ * Adds an instance to a TypeRegistration
70
+ * @param indexUri The URI of the TypeIndex
71
+ * @param classUri The URI for the class the instance should be added to
72
+ * @param instances Objects representing the instances to add
73
+ * @param options Options
74
+ */
75
+ function addRegistration(indexUri, classUri, instances, options) {
76
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
77
+ instances.instance?.forEach((instance) => {
78
+ typeRegistration.instance?.add({ "@id": instance });
79
+ });
80
+ instances.instanceContainer?.forEach((instanceContainer) => {
81
+ typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
82
+ });
83
+ }
84
+ /**
85
+ * Removes instances from a TypeRegistration
86
+ * @param indexUri The URI of the TypeIndex
87
+ * @param classUri The URI for the class the instance should be removed from
88
+ * @param instances Objects representing the instances to remove
89
+ * @param options Options
90
+ */
91
+ async function removeRegistration(indexUri, classUri, instances, options) {
92
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
93
+ instances.instance?.forEach((instanceUri) => {
94
+ typeRegistration.instance?.delete({ "@id": instanceUri });
95
+ });
96
+ instances.instanceContainer?.forEach((instanceContainerUri) => {
97
+ typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
98
+ });
99
+ }
100
+ /**
101
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
102
+ * creates one.
103
+ * @param indexUri The URI of the typeIndex
104
+ * @param classUri The URI of the class in question for the TypeRegistration
105
+ * @param options
106
+ * @returns The Type Index
107
+ */
108
+ function findAppropriateTypeRegistration(indexUri, classUri, options) {
109
+ const { dataset } = require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_util_Options.guaranteeOptions(options);
110
+ const existingRegistrationsUris = dataset.match(null, (0, __ldo_rdf_utils.namedNode)(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_constants.RDF_TYPE), (0, __ldo_rdf_utils.namedNode)(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_constants.TYPE_REGISTRATION), (0, __ldo_rdf_utils.namedNode)(indexUri)).toArray().map((quad$1) => quad$1.subject);
111
+ const existingRegistrationForClassUri = existingRegistrationsUris.find((registrationUri) => {
112
+ return dataset.has((0, __ldo_rdf_utils.quad)(registrationUri, (0, __ldo_rdf_utils.namedNode)(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_constants.FOR_CLASS), (0, __ldo_rdf_utils.namedNode)(classUri), (0, __ldo_rdf_utils.namedNode)(indexUri)));
113
+ })?.value;
114
+ let typeRegistration;
115
+ if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(existingRegistrationForClassUri);
116
+ else {
117
+ typeRegistration = dataset.usingType(require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src__ldo_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(`${indexUri}#${(0, uuid.v4)()}`);
118
+ typeRegistration.type = { "@id": "TypeRegistration" };
119
+ typeRegistration.forClass = { "@id": classUri };
120
+ }
121
+ return typeRegistration;
122
+ }
123
+
124
+ //#endregion
125
+ exports.addRegistration = addRegistration;
126
+ exports.createIndex = createIndex;
127
+ exports.findAppropriateTypeRegistration = findAppropriateTypeRegistration;
128
+ exports.initTypeIndex = initTypeIndex;
129
+ exports.removeRegistration = removeRegistration;
@@ -1,28 +1,31 @@
1
- import { type Options } from "./util/Options.js";
2
- import type { TypeRegistration } from "./.ldo/typeIndex.typings.js";
3
- import type { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
4
- import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
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
+
5
8
  /**
6
9
  * =============================================================================
7
10
  * INITIALIZERS
8
11
  * =============================================================================
9
12
  */
10
- export declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
13
+ declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
11
14
  /**
12
15
  * @internal
13
16
  * @param webId
14
17
  * @param profileFolder
15
18
  * @param dataset
16
19
  */
17
- export declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
20
+ declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
18
21
  /**
19
22
  * =============================================================================
20
23
  * DATASET MODIFIERS
21
24
  * =============================================================================
22
25
  */
23
26
  interface Instances {
24
- instance?: string[];
25
- instanceContainer?: string[];
27
+ instance?: string[];
28
+ instanceContainer?: string[];
26
29
  }
27
30
  /**
28
31
  * Adds an instance to a TypeRegistration
@@ -31,7 +34,7 @@ interface Instances {
31
34
  * @param instances Objects representing the instances to add
32
35
  * @param options Options
33
36
  */
34
- export declare function addRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): void;
37
+ declare function addRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): void;
35
38
  /**
36
39
  * Removes instances from a TypeRegistration
37
40
  * @param indexUri The URI of the TypeIndex
@@ -39,7 +42,7 @@ export declare function addRegistration(indexUri: string, classUri: string, inst
39
42
  * @param instances Objects representing the instances to remove
40
43
  * @param options Options
41
44
  */
42
- export declare function removeRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): Promise<void>;
45
+ declare function removeRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): Promise<void>;
43
46
  /**
44
47
  * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
45
48
  * creates one.
@@ -48,6 +51,7 @@ export declare function removeRegistration(indexUri: string, classUri: string, i
48
51
  * @param options
49
52
  * @returns The Type Index
50
53
  */
51
- export declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
52
- export {};
53
- //# sourceMappingURL=setTypeIndex.d.ts.map
54
+ declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
55
+ //#endregion
56
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
57
+ //# sourceMappingURL=setTypeIndex.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.d.cts","names":[],"sources":["../../src/setTypeIndex.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA2BA;;;AAGG,iBAHmB,aAAA,CAGnB,KAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EADS,OACT,CAAA,EAAA,OAAA,CAAA,IAAA,CAAA;AAAO;AAyBV;;;;;AAGW,iBAHW,WAAA,CAGX,KAAA,EAAA,GAAA,EAAA,aAAA,EADM,cACN,EAAA,OAAA,EAAA,mBAAA,CAAA,CACN,oBADM,GACiB,eADjB,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,OAAA,CAAA,EAGS,OAHT,CAAA,IAAA,CAAA;;AAGS;AA4CnB;AAmBD;;UAZU,SAAA,CAeG;EAAS,QACV,CAAA,EAAA,MAAA,EAAA;EAAO,iBAAA,CAAA,EAAA,MAAA,EAAA;AAyBnB;;;;;AAImB;AA0BnB;;AAGY,iBA9DI,eAAA,CA8DJ,QAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EA3DC,SA2DD,EAAA,OAAA,CAAA,EA1DA,OA0DA,CAAA,EAAA,IAAA;;AACO;;;;;;iBAlCG,kBAAA,gDAGT,qBACD,UAAO;;;;;;;;;iBA0BH,+BAAA,+CAGJ,UACT"}
@@ -0,0 +1,57 @@
1
+ import { TypeRegistration } from ".ldo/typeIndex.typings.js";
2
+ import { Options } from "./util/Options.js";
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
+ * =============================================================================
10
+ * INITIALIZERS
11
+ * =============================================================================
12
+ */
13
+ declare function initTypeIndex(webId: string, options?: Options): Promise<void>;
14
+ /**
15
+ * @internal
16
+ * @param webId
17
+ * @param profileFolder
18
+ * @param dataset
19
+ */
20
+ declare function createIndex(webId: any, profileFolder: SolidContainer, dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]>, isPrivate: boolean): Promise<void>;
21
+ /**
22
+ * =============================================================================
23
+ * DATASET MODIFIERS
24
+ * =============================================================================
25
+ */
26
+ interface Instances {
27
+ instance?: string[];
28
+ instanceContainer?: string[];
29
+ }
30
+ /**
31
+ * Adds an instance to a TypeRegistration
32
+ * @param indexUri The URI of the TypeIndex
33
+ * @param classUri The URI for the class the instance should be added to
34
+ * @param instances Objects representing the instances to add
35
+ * @param options Options
36
+ */
37
+ declare function addRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): void;
38
+ /**
39
+ * Removes instances from a TypeRegistration
40
+ * @param indexUri The URI of the TypeIndex
41
+ * @param classUri The URI for the class the instance should be removed from
42
+ * @param instances Objects representing the instances to remove
43
+ * @param options Options
44
+ */
45
+ declare function removeRegistration(indexUri: string, classUri: string, instances: Instances, options?: Options): Promise<void>;
46
+ /**
47
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
48
+ * creates one.
49
+ * @param indexUri The URI of the typeIndex
50
+ * @param classUri The URI of the class in question for the TypeRegistration
51
+ * @param options
52
+ * @returns The Type Index
53
+ */
54
+ declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
55
+ //#endregion
56
+ export { addRegistration as addRegistration$1, createIndex as createIndex$1, findAppropriateTypeRegistration as findAppropriateTypeRegistration$1, initTypeIndex as initTypeIndex$1, removeRegistration as removeRegistration$1 };
57
+ //# sourceMappingURL=setTypeIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.d.ts","names":[],"sources":["../../src/setTypeIndex.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AA2BA;;;AAGG,iBAHmB,aAAA,CAGnB,KAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EADS,OACT,CAAA,EAAA,OAAA,CAAA,IAAA,CAAA;AAAO;AAyBV;;;;;AAGW,iBAHW,WAAA,CAGX,KAAA,EAAA,GAAA,EAAA,aAAA,EADM,cACN,EAAA,OAAA,EAAA,mBAAA,CAAA,CACN,oBADM,GACiB,eADjB,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,OAAA,CAAA,EAGS,OAHT,CAAA,IAAA,CAAA;;AAGS;AA4CnB;AAmBD;;UAZU,SAAA,CAeG;EAAS,QACV,CAAA,EAAA,MAAA,EAAA;EAAO,iBAAA,CAAA,EAAA,MAAA,EAAA;AAyBnB;;;;;AAImB;AA0BnB;;AAGY,iBA9DI,eAAA,CA8DJ,QAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EA3DC,SA2DD,EAAA,OAAA,CAAA,EA1DA,OA0DA,CAAA,EAAA,IAAA;;AACO;;;;;;iBAlCG,kBAAA,gDAGT,qBACD,UAAO;;;;;;;;;iBA0BH,+BAAA,+CAGJ,UACT"}
@@ -0,0 +1,125 @@
1
+ import { TypeIndexProfileShapeType } from ".ldo/profile.shapeTypes.js";
2
+ import { TypeIndexDocumentShapeType, TypeRegistrationShapeType } from ".ldo/typeIndex.shapeTypes.js";
3
+ import { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from "./constants.js";
4
+ import { guaranteeOptions } from "./util/Options.js";
5
+ import { getProfile } from "./getTypeIndex.js";
6
+ import { v4 } from "uuid";
7
+ import { namedNode, quad } from "@ldo/rdf-utils";
8
+ import { set } from "@ldo/ldo";
9
+
10
+ //#region src/setTypeIndex.ts
11
+ /**
12
+ * =============================================================================
13
+ * INITIALIZERS
14
+ * =============================================================================
15
+ */
16
+ async function initTypeIndex(webId, options) {
17
+ const { dataset } = guaranteeOptions(options);
18
+ const profile = await getProfile(webId, options);
19
+ if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
20
+ const profileFolder = await dataset.getResource(webId).getParentContainer();
21
+ if (profileFolder?.isError) throw profileFolder;
22
+ if (!profileFolder) throw new Error("No folder to save the type indexes to.");
23
+ if (!profile.privateTypeIndex?.size) await createIndex(webId, profileFolder, dataset, true);
24
+ if (!profile.publicTypeIndex?.size) await createIndex(webId, profileFolder, dataset, false);
25
+ }
26
+ }
27
+ /**
28
+ * @internal
29
+ * @param webId
30
+ * @param profileFolder
31
+ * @param dataset
32
+ */
33
+ async function createIndex(webId, profileFolder, dataset, isPrivate) {
34
+ const createResult = await profileFolder.createChildAndOverwrite(`${isPrivate ? "private" : "public"}_index_${v4()}`);
35
+ if (createResult.isError) throw createResult;
36
+ const indexResource = createResult.resource;
37
+ const wacResult = await indexResource.setWac({
38
+ agent: { [webId]: {
39
+ read: true,
40
+ write: true,
41
+ append: true,
42
+ control: true
43
+ } },
44
+ public: {
45
+ read: isPrivate ? false : true,
46
+ write: true,
47
+ append: true,
48
+ control: true
49
+ },
50
+ authenticated: {
51
+ read: isPrivate ? false : true,
52
+ write: true,
53
+ append: true,
54
+ control: true
55
+ }
56
+ });
57
+ if (wacResult.isError) throw wacResult;
58
+ const transaction = dataset.startTransaction();
59
+ const cProfile = transaction.usingType(TypeIndexProfileShapeType).write(dataset.getResource(webId).uri).fromSubject(webId);
60
+ if (isPrivate) cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
61
+ else cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
62
+ const cTypeIndex = transaction.usingType(TypeIndexDocumentShapeType).write(indexResource.uri).fromSubject(indexResource.uri);
63
+ cTypeIndex.type = set({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
64
+ const commitResult = await transaction.commitToRemote();
65
+ if (commitResult.isError) throw commitResult;
66
+ }
67
+ /**
68
+ * Adds an instance to a TypeRegistration
69
+ * @param indexUri The URI of the TypeIndex
70
+ * @param classUri The URI for the class the instance should be added to
71
+ * @param instances Objects representing the instances to add
72
+ * @param options Options
73
+ */
74
+ function addRegistration(indexUri, classUri, instances, options) {
75
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
76
+ instances.instance?.forEach((instance) => {
77
+ typeRegistration.instance?.add({ "@id": instance });
78
+ });
79
+ instances.instanceContainer?.forEach((instanceContainer) => {
80
+ typeRegistration.instanceContainer?.add({ "@id": instanceContainer });
81
+ });
82
+ }
83
+ /**
84
+ * Removes instances from a TypeRegistration
85
+ * @param indexUri The URI of the TypeIndex
86
+ * @param classUri The URI for the class the instance should be removed from
87
+ * @param instances Objects representing the instances to remove
88
+ * @param options Options
89
+ */
90
+ async function removeRegistration(indexUri, classUri, instances, options) {
91
+ const typeRegistration = findAppropriateTypeRegistration(indexUri, classUri, options);
92
+ instances.instance?.forEach((instanceUri) => {
93
+ typeRegistration.instance?.delete({ "@id": instanceUri });
94
+ });
95
+ instances.instanceContainer?.forEach((instanceContainerUri) => {
96
+ typeRegistration.instanceContainer?.delete({ "@id": instanceContainerUri });
97
+ });
98
+ }
99
+ /**
100
+ * Finds a TypeRegistration inside of a type index. If it doesn't exist, it
101
+ * creates one.
102
+ * @param indexUri The URI of the typeIndex
103
+ * @param classUri The URI of the class in question for the TypeRegistration
104
+ * @param options
105
+ * @returns The Type Index
106
+ */
107
+ function findAppropriateTypeRegistration(indexUri, classUri, options) {
108
+ const { dataset } = guaranteeOptions(options);
109
+ const existingRegistrationsUris = dataset.match(null, namedNode(RDF_TYPE), namedNode(TYPE_REGISTRATION), namedNode(indexUri)).toArray().map((quad$1) => quad$1.subject);
110
+ const existingRegistrationForClassUri = existingRegistrationsUris.find((registrationUri) => {
111
+ return dataset.has(quad(registrationUri, namedNode(FOR_CLASS), namedNode(classUri), namedNode(indexUri)));
112
+ })?.value;
113
+ let typeRegistration;
114
+ if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(TypeRegistrationShapeType).write(indexUri).fromSubject(existingRegistrationForClassUri);
115
+ else {
116
+ typeRegistration = dataset.usingType(TypeRegistrationShapeType).write(indexUri).fromSubject(`${indexUri}#${v4()}`);
117
+ typeRegistration.type = { "@id": "TypeRegistration" };
118
+ typeRegistration.forClass = { "@id": classUri };
119
+ }
120
+ return typeRegistration;
121
+ }
122
+
123
+ //#endregion
124
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
125
+ //# sourceMappingURL=setTypeIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTypeIndex.js","names":["webId: string","options?: Options","profileFolder: SolidContainer","dataset: ConnectedLdoDataset<\n (SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]\n >","isPrivate: boolean","indexUri: string","classUri: string","instances: Instances","existingRegistrationsUris: NamedNode[]","quad","typeRegistration: TypeRegistration"],"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,16 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const __ldo_connected_solid = require_rolldown_runtime.__toESM(require("@ldo/connected-solid"));
3
+
4
+ //#region src/util/Options.ts
5
+ function guaranteeOptions(options) {
6
+ const fetch = (0, __ldo_connected_solid.guaranteeFetch)(options?.fetch);
7
+ const dataset = options?.solidLdoDataset ?? (0, __ldo_connected_solid.createSolidLdoDataset)();
8
+ dataset.setContext("solid", { fetch });
9
+ return {
10
+ fetch,
11
+ dataset
12
+ };
13
+ }
14
+
15
+ //#endregion
16
+ 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"],"sourcesContent":[],"mappings":";;;;UAKiB,OAAA;oBACG,qBAAqB;EADxB,KAAA,CAAA,EAAA,OAEA,KAFO"}
@@ -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.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.d.ts","names":[],"sources":["../../../src/util/Options.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,OAAA;oBACG,qBAAqB;EADxB,KAAA,CAAA,EAAA,OAEA,KAFO"}
@@ -0,0 +1,16 @@
1
+ import { createSolidLdoDataset, guaranteeFetch } from "@ldo/connected-solid";
2
+
3
+ //#region src/util/Options.ts
4
+ function guaranteeOptions(options) {
5
+ const fetch = guaranteeFetch(options?.fetch);
6
+ const dataset = options?.solidLdoDataset ?? createSolidLdoDataset();
7
+ dataset.setContext("solid", { fetch });
8
+ return {
9
+ fetch,
10
+ dataset
11
+ };
12
+ }
13
+
14
+ //#endregion
15
+ export { guaranteeOptions };
16
+ //# sourceMappingURL=Options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Options.js","names":["options?: Options"],"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,iBAAiBA,SAAmB;CAClD,MAAM,QAAQ,eAAe,SAAS,MAAM;CAC5C,MAAM,UAAW,SAAS,mBACxB,uBAAuB;AACzB,SAAQ,WAAW,SAAS,EAAE,MAAO,EAAC;AACtC,QAAO;EAAE;EAAO;CAAS;AAC1B"}
package/package.json CHANGED
@@ -1,25 +1,28 @@
1
1
  {
2
2
  "name": "@ldo/solid-type-index",
3
- "version": "1.0.0-alpha.33",
3
+ "version": "1.0.0-alpha.36",
4
4
  "description": "Solid Type Index support for LDO",
5
5
  "type": "module",
6
- "main": "./dist/cjs/index.cjs",
7
- "module": "./dist/esm/index.js",
8
- "types": "./dist/types/index.d.ts",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/types/index.d.ts",
12
- "import": "./dist/esm/index.js",
13
- "require": "./dist/cjs/index.cjs"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
14
19
  },
15
20
  "./package.json": "./package.json"
16
21
  },
17
22
  "scripts": {
18
- "build": "rimraf dist && npm run build:cjs && npm run build:esm",
19
- "build:cjs": "tsc --project tsconfig.cjs.json && node ../../scripts/rename-to-cjs.js",
20
- "build:esm": "tsc --project tsconfig.esm.json",
23
+ "build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 tsdown",
21
24
  "test": "vitest run --coverage",
22
- "prepublishOnly": " npm run build",
25
+ "prepublishOnly": "npm run build",
23
26
  "build:ldo": "ldo build --input src/.shapes --output src/.ldo",
24
27
  "lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
25
28
  "remove-dist": "rimraf dist/"
@@ -35,17 +38,18 @@
35
38
  },
36
39
  "homepage": "https://github.com/o-development/ldo/tree/main/packages/solid-react#readme",
37
40
  "devDependencies": {
38
- "@ldo/rdf-utils": "^1.0.0-alpha.30",
39
- "@ldo/test-solid-server": "^1.0.0-alpha.28",
40
- "@rdfjs/types": "^1.0.1",
41
+ "@ldo/test-solid-server": "^1.0.0-alpha.36",
41
42
  "@testing-library/react": "^14.1.2",
42
- "jest-environment-jsdom": "^29.7.0",
43
43
  "start-server-and-test": "^2.0.3",
44
44
  "ts-node": "^10.9.2"
45
45
  },
46
46
  "dependencies": {
47
- "@ldo/connected-solid": "^1.0.0-alpha.32",
48
- "@ldo/solid-react": "^1.0.0-alpha.33"
47
+ "@ldo/connected": "^1.0.0-alpha.36",
48
+ "@ldo/connected-solid": "^1.0.0-alpha.36",
49
+ "@ldo/ldo": "^1.0.0-alpha.36",
50
+ "@ldo/rdf-utils": "^1.0.0-alpha.36",
51
+ "@ldo/solid-react": "^1.0.0-alpha.36",
52
+ "@rdfjs/types": "^1.0.1"
49
53
  },
50
54
  "files": [
51
55
  "dist",
@@ -54,5 +58,5 @@
54
58
  "publishConfig": {
55
59
  "access": "public"
56
60
  },
57
- "gitHead": "1b1e729a510e7e791cf2e4d24debe2b30db6c7ec"
61
+ "gitHead": "e97a0f8b5fa7f609e5070e472b1b63ff8a9502a8"
58
62
  }
@@ -1,7 +1,7 @@
1
1
  import { ShapeType } from "@ldo/ldo";
2
- import { profileSchema } from "./profile.schema.js";
3
- import { profileContext } from "./profile.context.js";
4
- import { TypeIndexProfile } from "./profile.typings.js";
2
+ import { profileSchema } from "./profile.schema";
3
+ import { profileContext } from "./profile.context";
4
+ import { TypeIndexProfile } from "./profile.typings";
5
5
 
6
6
  /**
7
7
  * =============================================================================
@@ -1,7 +1,7 @@
1
1
  import { ShapeType } from "@ldo/ldo";
2
- import { typeIndexSchema } from "./typeIndex.schema.js";
3
- import { typeIndexContext } from "./typeIndex.context.js";
4
- import { TypeIndexDocument, TypeRegistration } from "./typeIndex.typings.js";
2
+ import { typeIndexSchema } from "./typeIndex.schema";
3
+ import { typeIndexContext } from "./typeIndex.context";
4
+ import { TypeIndexDocument, TypeRegistration } from "./typeIndex.typings";
5
5
 
6
6
  /**
7
7
  * =============================================================================
@@ -1,10 +1,10 @@
1
- import type { TypeRegistration } from "./.ldo/typeIndex.typings.js";
2
- import type { TypeIndexProfile } from "./.ldo/profile.typings.js";
3
- import { TypeIndexProfileShapeType } from "./.ldo/profile.shapeTypes.js";
4
- import { TypeRegistrationShapeType } from "./.ldo/typeIndex.shapeTypes.js";
5
- import { RDF_TYPE, TYPE_REGISTRATION } from "./constants.js";
6
- import type { Options } from "./util/Options.js";
7
- import { guaranteeOptions } from "./util/Options.js";
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
+ import { RDF_TYPE, TYPE_REGISTRATION } from "./constants";
6
+ import type { Options } from "./util/Options";
7
+ import { guaranteeOptions } from "./util/Options";
8
8
  import type { LdSet } from "@ldo/ldo";
9
9
  import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid";
10
10