@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 @@
1
+ {"version":3,"file":"typeIndex.schema.mjs","names":[],"sources":["../../src/_ldo/typeIndex.schema.ts"],"sourcesContent":["import type { Schema } from \"shexj\";\n\n/**\n * =============================================================================\n * typeIndexSchema: ShexJ Schema for typeIndex\n * =============================================================================\n */\nexport const typeIndexSchema: Schema = {\n type: \"Schema\",\n shapes: [\n {\n id: \"https://shaperepo.com/schemas/solidProfile#TypeIndexDocument\",\n type: \"ShapeDecl\",\n shapeExpr: {\n type: \"Shape\",\n expression: {\n type: \"EachOf\",\n expressions: [\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n valueExpr: {\n type: \"NodeConstraint\",\n values: [\"http://www.w3.org/ns/solid/terms#TypeIndex\"],\n },\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"Defines the node as a TypeIndex\",\n },\n },\n ],\n },\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n valueExpr: {\n type: \"NodeConstraint\",\n values: [\"http://www.w3.org/ns/solid/terms#ListedDocument\"],\n },\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"Defines the node as a Listed Document\",\n },\n },\n ],\n },\n ],\n },\n extra: [\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\"],\n },\n },\n {\n id: \"https://shaperepo.com/schemas/solidProfile#TypeRegistration\",\n type: \"ShapeDecl\",\n shapeExpr: {\n type: \"Shape\",\n expression: {\n type: \"EachOf\",\n expressions: [\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n valueExpr: {\n type: \"NodeConstraint\",\n values: [\"http://www.w3.org/ns/solid/terms#TypeRegistration\"],\n },\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"Defines this node as a Type Registration\",\n },\n },\n ],\n },\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/ns/solid/terms#forClass\",\n valueExpr: {\n type: \"NodeConstraint\",\n nodeKind: \"iri\",\n },\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"The class of object at this type.\",\n },\n },\n ],\n },\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/ns/solid/terms#instance\",\n valueExpr: {\n type: \"NodeConstraint\",\n nodeKind: \"iri\",\n },\n min: 0,\n max: -1,\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"A specific resource that contains the class.\",\n },\n },\n ],\n },\n {\n type: \"TripleConstraint\",\n predicate: \"http://www.w3.org/ns/solid/terms#instanceContainer\",\n valueExpr: {\n type: \"NodeConstraint\",\n nodeKind: \"iri\",\n },\n min: 0,\n max: -1,\n annotations: [\n {\n type: \"Annotation\",\n predicate: \"http://www.w3.org/2000/01/rdf-schema#comment\",\n object: {\n value: \"Containers that contain resources with the class.\",\n },\n },\n ],\n },\n ],\n },\n extra: [\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\"],\n },\n },\n ],\n};\n"],"mappings":";;;;;;AAOA,MAAa,kBAA0B;CACrC,MAAM;CACN,QAAQ,CACN;EACE,IAAI;EACJ,MAAM;EACN,WAAW;GACT,MAAM;GACN,YAAY;IACV,MAAM;IACN,aAAa,CACX;KACE,MAAM;KACN,WAAW;KACX,WAAW;MACT,MAAM;MACN,QAAQ,CAAC,6CAA6C;MACvD;KACD,aAAa,CACX;MACE,MAAM;MACN,WAAW;MACX,QAAQ,EACN,OAAO,mCACR;MACF,CACF;KACF,EACD;KACE,MAAM;KACN,WAAW;KACX,WAAW;MACT,MAAM;MACN,QAAQ,CAAC,kDAAkD;MAC5D;KACD,aAAa,CACX;MACE,MAAM;MACN,WAAW;MACX,QAAQ,EACN,OAAO,yCACR;MACF,CACF;KACF,CACF;IACF;GACD,OAAO,CAAC,kDAAkD;GAC3D;EACF,EACD;EACE,IAAI;EACJ,MAAM;EACN,WAAW;GACT,MAAM;GACN,YAAY;IACV,MAAM;IACN,aAAa;KACX;MACE,MAAM;MACN,WAAW;MACX,WAAW;OACT,MAAM;OACN,QAAQ,CAAC,oDAAoD;OAC9D;MACD,aAAa,CACX;OACE,MAAM;OACN,WAAW;OACX,QAAQ,EACN,OAAO,4CACR;OACF,CACF;MACF;KACD;MACE,MAAM;MACN,WAAW;MACX,WAAW;OACT,MAAM;OACN,UAAU;OACX;MACD,aAAa,CACX;OACE,MAAM;OACN,WAAW;OACX,QAAQ,EACN,OAAO,qCACR;OACF,CACF;MACF;KACD;MACE,MAAM;MACN,WAAW;MACX,WAAW;OACT,MAAM;OACN,UAAU;OACX;MACD,KAAK;MACL,KAAK;MACL,aAAa,CACX;OACE,MAAM;OACN,WAAW;OACX,QAAQ,EACN,OAAO,gDACR;OACF,CACF;MACF;KACD;MACE,MAAM;MACN,WAAW;MACX,WAAW;OACT,MAAM;OACN,UAAU;OACX;MACD,KAAK;MACL,KAAK;MACL,aAAa,CACX;OACE,MAAM;OACN,WAAW;OACX,QAAQ,EACN,OAAO,qDACR;OACF,CACF;MACF;KACF;IACF;GACD,OAAO,CAAC,kDAAkD;GAC3D;EACF,CACF;CACF"}
@@ -0,0 +1,27 @@
1
+ const require_typeIndex_schema = require("./typeIndex.schema.cjs");
2
+ const require_typeIndex_context = require("./typeIndex.context.cjs");
3
+ //#region src/_ldo/typeIndex.shapeTypes.ts
4
+ /**
5
+ * =============================================================================
6
+ * LDO ShapeTypes typeIndex
7
+ * =============================================================================
8
+ */
9
+ /**
10
+ * TypeIndexDocument ShapeType
11
+ */
12
+ const TypeIndexDocumentShapeType = {
13
+ schema: require_typeIndex_schema.typeIndexSchema,
14
+ shape: "https://shaperepo.com/schemas/solidProfile#TypeIndexDocument",
15
+ context: require_typeIndex_context.typeIndexContext
16
+ };
17
+ /**
18
+ * TypeRegistration ShapeType
19
+ */
20
+ const TypeRegistrationShapeType = {
21
+ schema: require_typeIndex_schema.typeIndexSchema,
22
+ shape: "https://shaperepo.com/schemas/solidProfile#TypeRegistration",
23
+ context: require_typeIndex_context.typeIndexContext
24
+ };
25
+ //#endregion
26
+ exports.TypeIndexDocumentShapeType = TypeIndexDocumentShapeType;
27
+ exports.TypeRegistrationShapeType = TypeRegistrationShapeType;
@@ -0,0 +1,28 @@
1
+ import { typeIndexSchema } from "./typeIndex.schema.mjs";
2
+ import { typeIndexContext } from "./typeIndex.context.mjs";
3
+ //#region src/_ldo/typeIndex.shapeTypes.ts
4
+ /**
5
+ * =============================================================================
6
+ * LDO ShapeTypes typeIndex
7
+ * =============================================================================
8
+ */
9
+ /**
10
+ * TypeIndexDocument ShapeType
11
+ */
12
+ const TypeIndexDocumentShapeType = {
13
+ schema: typeIndexSchema,
14
+ shape: "https://shaperepo.com/schemas/solidProfile#TypeIndexDocument",
15
+ context: typeIndexContext
16
+ };
17
+ /**
18
+ * TypeRegistration ShapeType
19
+ */
20
+ const TypeRegistrationShapeType = {
21
+ schema: typeIndexSchema,
22
+ shape: "https://shaperepo.com/schemas/solidProfile#TypeRegistration",
23
+ context: typeIndexContext
24
+ };
25
+ //#endregion
26
+ export { TypeIndexDocumentShapeType, TypeRegistrationShapeType };
27
+
28
+ //# sourceMappingURL=typeIndex.shapeTypes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndex.shapeTypes.mjs","names":[],"sources":["../../src/_ldo/typeIndex.shapeTypes.ts"],"sourcesContent":["import type { ShapeType } from \"@ldo/ldo\";\nimport { typeIndexSchema } from \"./typeIndex.schema\";\nimport { typeIndexContext } from \"./typeIndex.context\";\nimport type { TypeIndexDocument, TypeRegistration } from \"./typeIndex.typings\";\n\n/**\n * =============================================================================\n * LDO ShapeTypes typeIndex\n * =============================================================================\n */\n\n/**\n * TypeIndexDocument ShapeType\n */\nexport const TypeIndexDocumentShapeType: ShapeType<TypeIndexDocument> = {\n schema: typeIndexSchema,\n shape: \"https://shaperepo.com/schemas/solidProfile#TypeIndexDocument\",\n context: typeIndexContext,\n};\n\n/**\n * TypeRegistration ShapeType\n */\nexport const TypeRegistrationShapeType: ShapeType<TypeRegistration> = {\n schema: typeIndexSchema,\n shape: \"https://shaperepo.com/schemas/solidProfile#TypeRegistration\",\n context: typeIndexContext,\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,6BAA2D;CACtE,QAAQ;CACR,OAAO;CACP,SAAS;CACV;;;;AAKD,MAAa,4BAAyD;CACpE,QAAQ;CACR,OAAO;CACP,SAAS;CACV"}
@@ -0,0 +1,37 @@
1
+ import { LdSet, LdoJsonldContext } from "@ldo/ldo";
2
+
3
+ //#region src/_ldo/typeIndex.typings.d.ts
4
+ /**
5
+ * TypeRegistration Type
6
+ */
7
+ interface TypeRegistration {
8
+ "@id"?: string;
9
+ "@context"?: LdoJsonldContext;
10
+ /**
11
+ * Defines this node as a Type Registration
12
+ */
13
+ type: {
14
+ "@id": "TypeRegistration";
15
+ };
16
+ /**
17
+ * The class of object at this type.
18
+ */
19
+ forClass: {
20
+ "@id": string;
21
+ };
22
+ /**
23
+ * A specific resource that contains the class.
24
+ */
25
+ instance?: LdSet<{
26
+ "@id": string;
27
+ }>;
28
+ /**
29
+ * Containers that contain resources with the class.
30
+ */
31
+ instanceContainer?: LdSet<{
32
+ "@id": string;
33
+ }>;
34
+ }
35
+ //#endregion
36
+ export { TypeRegistration };
37
+ //# sourceMappingURL=typeIndex.typings.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndex.typings.d.cts","names":[],"sources":["../../src/_ldo/typeIndex.typings.ts"],"mappings":";;;;;;UA8BiB,gBAAA;EACf,KAAA;EACA,UAAA,GAAa,gBAAA;;;;EAIb,IAAA;IACE,KAAA;EAAA;;;;EAKF,QAAA;IACE,KAAA;EAAA;;;;EAKF,QAAA,GAAW,KAAA;IACT,KAAA;EAAA;;;;EAKF,iBAAA,GAAoB,KAAA;IAClB,KAAA;EAAA;AAAA"}
@@ -0,0 +1,37 @@
1
+ import { LdSet, LdoJsonldContext } from "@ldo/ldo";
2
+
3
+ //#region src/_ldo/typeIndex.typings.d.ts
4
+ /**
5
+ * TypeRegistration Type
6
+ */
7
+ interface TypeRegistration {
8
+ "@id"?: string;
9
+ "@context"?: LdoJsonldContext;
10
+ /**
11
+ * Defines this node as a Type Registration
12
+ */
13
+ type: {
14
+ "@id": "TypeRegistration";
15
+ };
16
+ /**
17
+ * The class of object at this type.
18
+ */
19
+ forClass: {
20
+ "@id": string;
21
+ };
22
+ /**
23
+ * A specific resource that contains the class.
24
+ */
25
+ instance?: LdSet<{
26
+ "@id": string;
27
+ }>;
28
+ /**
29
+ * Containers that contain resources with the class.
30
+ */
31
+ instanceContainer?: LdSet<{
32
+ "@id": string;
33
+ }>;
34
+ }
35
+ //#endregion
36
+ export { TypeRegistration };
37
+ //# sourceMappingURL=typeIndex.typings.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndex.typings.d.mts","names":[],"sources":["../../src/_ldo/typeIndex.typings.ts"],"mappings":";;;;;;UA8BiB,gBAAA;EACf,KAAA;EACA,UAAA,GAAa,gBAAA;;;;EAIb,IAAA;IACE,KAAA;EAAA;;;;EAKF,QAAA;IACE,KAAA;EAAA;;;;EAKF,QAAA,GAAW,KAAA;IACT,KAAA;EAAA;;;;EAKF,iBAAA,GAAoB,KAAA;IAClB,KAAA;EAAA;AAAA"}
@@ -0,0 +1,8 @@
1
+ //#region src/constants.ts
2
+ const RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
3
+ const TYPE_REGISTRATION = "http://www.w3.org/ns/solid/terms#TypeRegistration";
4
+ const FOR_CLASS = "http://www.w3.org/ns/solid/terms#forClass";
5
+ //#endregion
6
+ exports.FOR_CLASS = FOR_CLASS;
7
+ exports.RDF_TYPE = RDF_TYPE;
8
+ exports.TYPE_REGISTRATION = TYPE_REGISTRATION;
@@ -0,0 +1,8 @@
1
+ //#region src/constants.ts
2
+ const RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
3
+ const TYPE_REGISTRATION = "http://www.w3.org/ns/solid/terms#TypeRegistration";
4
+ const FOR_CLASS = "http://www.w3.org/ns/solid/terms#forClass";
5
+ //#endregion
6
+ export { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION };
7
+
8
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const RDF_TYPE = \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\";\nexport const TYPE_REGISTRATION =\n \"http://www.w3.org/ns/solid/terms#TypeRegistration\";\nexport const FOR_CLASS = \"http://www.w3.org/ns/solid/terms#forClass\";\nexport const INSTANCE = \"http://www.w3.org/ns/solid/terms#instance\";\nexport const INSTANCE_CONTAINER =\n \"http://www.w3.org/ns/solid/terms#instanceContainer\";\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,oBACX;AACF,MAAa,YAAY"}
@@ -0,0 +1,52 @@
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
+ //#region src/getTypeIndex.ts
6
+ async function getTypeRegistrations(webId, options) {
7
+ const { dataset } = require_Options.guaranteeOptions(options);
8
+ const typeIndexUris = getTypeIndexesUrisFromProfile(await getProfile(webId, options));
9
+ await Promise.all(typeIndexUris.map(async (typeIndexUri) => {
10
+ const readResult = await dataset.getResource(typeIndexUri).readIfUnfetched();
11
+ if (readResult.isError) throw readResult;
12
+ }));
13
+ return dataset.usingType(require_typeIndex_shapeTypes.TypeRegistrationShapeType).matchSubject(require_constants.RDF_TYPE, require_constants.TYPE_REGISTRATION);
14
+ }
15
+ async function getProfile(webId, options) {
16
+ const { dataset } = require_Options.guaranteeOptions(options);
17
+ const readResult = await dataset.getResource(webId).readIfUnfetched();
18
+ if (readResult.isError) throw readResult;
19
+ return dataset.usingType(require_profile_shapeTypes.TypeIndexProfileShapeType).fromSubject(webId);
20
+ }
21
+ function getTypeIndexesUrisFromProfile(profile) {
22
+ const uris = [];
23
+ profile.privateTypeIndex?.forEach((indexNode) => {
24
+ uris.push(indexNode["@id"]);
25
+ });
26
+ profile.publicTypeIndex?.forEach((indexNode) => {
27
+ uris.push(indexNode["@id"]);
28
+ });
29
+ return uris;
30
+ }
31
+ async function getInstanceUris(classUri, typeRegistrations, options) {
32
+ const { dataset } = require_Options.guaranteeOptions(options);
33
+ const leafUris = /* @__PURE__ */ new Set();
34
+ await Promise.all(typeRegistrations.map(async (registration) => {
35
+ if (registration.forClass["@id"] === classUri) {
36
+ registration.instance?.forEach((instance) => leafUris.add(instance["@id"]));
37
+ await Promise.all(registration.instanceContainer?.map(async (instanceContainer) => {
38
+ const containerResource = dataset.getResource(instanceContainer["@id"]);
39
+ await containerResource.readIfUnfetched();
40
+ containerResource.children().forEach((child) => {
41
+ if (child.type === "SolidLeaf") leafUris.add(child.uri);
42
+ });
43
+ }) ?? []);
44
+ }
45
+ }));
46
+ return Array.from(leafUris);
47
+ }
48
+ //#endregion
49
+ exports.getInstanceUris = getInstanceUris;
50
+ exports.getProfile = getProfile;
51
+ exports.getTypeIndexesUrisFromProfile = getTypeIndexesUrisFromProfile;
52
+ exports.getTypeRegistrations = getTypeRegistrations;
@@ -0,0 +1,14 @@
1
+ import { TypeRegistration } from "./_ldo/typeIndex.typings.cjs";
2
+ import { TypeIndexProfile } from "./_ldo/profile.typings.cjs";
3
+ import { Options } from "./util/Options.cjs";
4
+ import { LdSet } from "@ldo/ldo";
5
+ import { SolidLeafUri } from "@ldo/connected-solid";
6
+
7
+ //#region src/getTypeIndex.d.ts
8
+ declare function getTypeRegistrations(webId: string, options?: Options): Promise<LdSet<TypeRegistration>>;
9
+ declare function getProfile(webId: string, options?: Options): Promise<TypeIndexProfile>;
10
+ declare function getTypeIndexesUrisFromProfile(profile: TypeIndexProfile): SolidLeafUri[];
11
+ declare function getInstanceUris(classUri: string, typeRegistrations: TypeRegistration[], options?: Options): Promise<SolidLeafUri[]>;
12
+ //#endregion
13
+ export { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations };
14
+ //# sourceMappingURL=getTypeIndex.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTypeIndex.d.cts","names":[],"sources":["../src/getTypeIndex.ts"],"mappings":";;;;;;;iBAUsB,oBAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,KAAA,CAAM,gBAAA;AAAA,iBAwBK,UAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,gBAAA;AAAA,iBAQK,6BAAA,CACd,OAAA,EAAS,gBAAA,GACR,YAAA;AAAA,iBAWmB,eAAA,CACpB,QAAA,UACA,iBAAA,EAAmB,gBAAA,IACnB,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,YAAA"}
@@ -0,0 +1,14 @@
1
+ import { TypeRegistration } from "./_ldo/typeIndex.typings.mjs";
2
+ import { TypeIndexProfile } from "./_ldo/profile.typings.mjs";
3
+ import { Options } from "./util/Options.mjs";
4
+ import { SolidLeafUri } from "@ldo/connected-solid";
5
+ import { LdSet } from "@ldo/ldo";
6
+
7
+ //#region src/getTypeIndex.d.ts
8
+ declare function getTypeRegistrations(webId: string, options?: Options): Promise<LdSet<TypeRegistration>>;
9
+ declare function getProfile(webId: string, options?: Options): Promise<TypeIndexProfile>;
10
+ declare function getTypeIndexesUrisFromProfile(profile: TypeIndexProfile): SolidLeafUri[];
11
+ declare function getInstanceUris(classUri: string, typeRegistrations: TypeRegistration[], options?: Options): Promise<SolidLeafUri[]>;
12
+ //#endregion
13
+ export { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations };
14
+ //# sourceMappingURL=getTypeIndex.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTypeIndex.d.mts","names":[],"sources":["../src/getTypeIndex.ts"],"mappings":";;;;;;;iBAUsB,oBAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,KAAA,CAAM,gBAAA;AAAA,iBAwBK,UAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,gBAAA;AAAA,iBAQK,6BAAA,CACd,OAAA,EAAS,gBAAA,GACR,YAAA;AAAA,iBAWmB,eAAA,CACpB,QAAA,UACA,iBAAA,EAAmB,gBAAA,IACnB,OAAA,GAAU,OAAA,GACT,OAAA,CAAQ,YAAA"}
@@ -0,0 +1,51 @@
1
+ import { TypeIndexProfileShapeType } from "./_ldo/profile.shapeTypes.mjs";
2
+ import { TypeRegistrationShapeType } from "./_ldo/typeIndex.shapeTypes.mjs";
3
+ import { RDF_TYPE, TYPE_REGISTRATION } from "./constants.mjs";
4
+ import { guaranteeOptions } from "./util/Options.mjs";
5
+ //#region src/getTypeIndex.ts
6
+ async function getTypeRegistrations(webId, options) {
7
+ const { dataset } = guaranteeOptions(options);
8
+ const typeIndexUris = getTypeIndexesUrisFromProfile(await getProfile(webId, options));
9
+ await Promise.all(typeIndexUris.map(async (typeIndexUri) => {
10
+ const readResult = await dataset.getResource(typeIndexUri).readIfUnfetched();
11
+ if (readResult.isError) throw readResult;
12
+ }));
13
+ return dataset.usingType(TypeRegistrationShapeType).matchSubject(RDF_TYPE, TYPE_REGISTRATION);
14
+ }
15
+ async function getProfile(webId, options) {
16
+ const { dataset } = guaranteeOptions(options);
17
+ const readResult = await dataset.getResource(webId).readIfUnfetched();
18
+ if (readResult.isError) throw readResult;
19
+ return dataset.usingType(TypeIndexProfileShapeType).fromSubject(webId);
20
+ }
21
+ function getTypeIndexesUrisFromProfile(profile) {
22
+ const uris = [];
23
+ profile.privateTypeIndex?.forEach((indexNode) => {
24
+ uris.push(indexNode["@id"]);
25
+ });
26
+ profile.publicTypeIndex?.forEach((indexNode) => {
27
+ uris.push(indexNode["@id"]);
28
+ });
29
+ return uris;
30
+ }
31
+ async function getInstanceUris(classUri, typeRegistrations, options) {
32
+ const { dataset } = guaranteeOptions(options);
33
+ const leafUris = /* @__PURE__ */ new Set();
34
+ await Promise.all(typeRegistrations.map(async (registration) => {
35
+ if (registration.forClass["@id"] === classUri) {
36
+ registration.instance?.forEach((instance) => leafUris.add(instance["@id"]));
37
+ await Promise.all(registration.instanceContainer?.map(async (instanceContainer) => {
38
+ const containerResource = dataset.getResource(instanceContainer["@id"]);
39
+ await containerResource.readIfUnfetched();
40
+ containerResource.children().forEach((child) => {
41
+ if (child.type === "SolidLeaf") leafUris.add(child.uri);
42
+ });
43
+ }) ?? []);
44
+ }
45
+ }));
46
+ return Array.from(leafUris);
47
+ }
48
+ //#endregion
49
+ export { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations };
50
+
51
+ //# sourceMappingURL=getTypeIndex.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTypeIndex.mjs","names":[],"sources":["../src/getTypeIndex.ts"],"sourcesContent":["import type { TypeRegistration } from \"./_ldo/typeIndex.typings\";\nimport type { TypeIndexProfile } from \"./_ldo/profile.typings\";\nimport { TypeIndexProfileShapeType } from \"./_ldo/profile.shapeTypes\";\nimport { TypeRegistrationShapeType } from \"./_ldo/typeIndex.shapeTypes\";\nimport { RDF_TYPE, TYPE_REGISTRATION } from \"./constants\";\nimport type { Options } from \"./util/Options\";\nimport { guaranteeOptions } from \"./util/Options\";\nimport type { LdSet } from \"@ldo/ldo\";\nimport type { SolidContainerUri, SolidLeafUri } from \"@ldo/connected-solid\";\n\nexport async function getTypeRegistrations(\n webId: string,\n options?: Options,\n): Promise<LdSet<TypeRegistration>> {\n const { dataset } = guaranteeOptions(options);\n\n // Get Profile\n const profile = await getProfile(webId, options);\n\n // Get Type Indexes\n const typeIndexUris = getTypeIndexesUrisFromProfile(profile);\n\n // Fetch the type Indexes\n await Promise.all(\n typeIndexUris.map(async (typeIndexUri) => {\n const typeIndexResource = dataset.getResource(typeIndexUri);\n const readResult = await typeIndexResource.readIfUnfetched();\n if (readResult.isError) throw readResult;\n }),\n );\n\n // Get Type Registrations\n return dataset\n .usingType(TypeRegistrationShapeType)\n .matchSubject(RDF_TYPE, TYPE_REGISTRATION);\n}\n\nexport async function getProfile(\n webId: string,\n options?: Options,\n): Promise<TypeIndexProfile> {\n const { dataset } = guaranteeOptions(options);\n const profileResource = dataset.getResource(webId);\n const readResult = await profileResource.readIfUnfetched();\n if (readResult.isError) throw readResult;\n return dataset.usingType(TypeIndexProfileShapeType).fromSubject(webId);\n}\n\nexport function getTypeIndexesUrisFromProfile(\n profile: TypeIndexProfile,\n): SolidLeafUri[] {\n const uris: SolidLeafUri[] = [];\n profile.privateTypeIndex?.forEach((indexNode) => {\n uris.push(indexNode[\"@id\"] as SolidLeafUri);\n });\n profile.publicTypeIndex?.forEach((indexNode) => {\n uris.push(indexNode[\"@id\"] as SolidLeafUri);\n });\n return uris;\n}\n\nexport async function getInstanceUris(\n classUri: string,\n typeRegistrations: TypeRegistration[],\n options?: Options,\n): Promise<SolidLeafUri[]> {\n const { dataset } = guaranteeOptions(options);\n\n const leafUris = new Set<SolidLeafUri>();\n await Promise.all(\n typeRegistrations.map(async (registration) => {\n if (registration.forClass[\"@id\"] === classUri) {\n // Individual registrations\n registration.instance?.forEach((instance) =>\n leafUris.add(instance[\"@id\"] as SolidLeafUri),\n );\n // Container registrations\n await Promise.all(\n registration.instanceContainer?.map(async (instanceContainer) => {\n const containerResource = dataset.getResource(\n instanceContainer[\"@id\"] as SolidContainerUri,\n );\n await containerResource.readIfUnfetched();\n containerResource.children().forEach((child) => {\n if (child.type === \"SolidLeaf\") leafUris.add(child.uri);\n });\n }) ?? [],\n );\n }\n }),\n );\n return Array.from(leafUris);\n}\n"],"mappings":";;;;;AAUA,eAAsB,qBACpB,OACA,SACkC;CAClC,MAAM,EAAE,YAAY,iBAAiB,QAAQ;CAM7C,MAAM,gBAAgB,8BAA8B,MAH9B,WAAW,OAAO,QAAQ,CAGY;AAG5D,OAAM,QAAQ,IACZ,cAAc,IAAI,OAAO,iBAAiB;EAExC,MAAM,aAAa,MADO,QAAQ,YAAY,aACJ,CAAC,iBAAiB;AAC5D,MAAI,WAAW,QAAS,OAAM;GAC9B,CACH;AAGD,QAAO,QACJ,UAAU,0BAA0B,CACpC,aAAa,UAAU,kBAAkB;;AAG9C,eAAsB,WACpB,OACA,SAC2B;CAC3B,MAAM,EAAE,YAAY,iBAAiB,QAAQ;CAE7C,MAAM,aAAa,MADK,QAAQ,YAAY,MACJ,CAAC,iBAAiB;AAC1D,KAAI,WAAW,QAAS,OAAM;AAC9B,QAAO,QAAQ,UAAU,0BAA0B,CAAC,YAAY,MAAM;;AAGxE,SAAgB,8BACd,SACgB;CAChB,MAAM,OAAuB,EAAE;AAC/B,SAAQ,kBAAkB,SAAS,cAAc;AAC/C,OAAK,KAAK,UAAU,OAAuB;GAC3C;AACF,SAAQ,iBAAiB,SAAS,cAAc;AAC9C,OAAK,KAAK,UAAU,OAAuB;GAC3C;AACF,QAAO;;AAGT,eAAsB,gBACpB,UACA,mBACA,SACyB;CACzB,MAAM,EAAE,YAAY,iBAAiB,QAAQ;CAE7C,MAAM,2BAAW,IAAI,KAAmB;AACxC,OAAM,QAAQ,IACZ,kBAAkB,IAAI,OAAO,iBAAiB;AAC5C,MAAI,aAAa,SAAS,WAAW,UAAU;AAE7C,gBAAa,UAAU,SAAS,aAC9B,SAAS,IAAI,SAAS,OAAuB,CAC9C;AAED,SAAM,QAAQ,IACZ,aAAa,mBAAmB,IAAI,OAAO,sBAAsB;IAC/D,MAAM,oBAAoB,QAAQ,YAChC,kBAAkB,OACnB;AACD,UAAM,kBAAkB,iBAAiB;AACzC,sBAAkB,UAAU,CAAC,SAAS,UAAU;AAC9C,SAAI,MAAM,SAAS,YAAa,UAAS,IAAI,MAAM,IAAI;MACvD;KACF,IAAI,EAAE,CACT;;GAEH,CACH;AACD,QAAO,MAAM,KAAK,SAAS"}
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_getTypeIndex = require("./getTypeIndex.cjs");
3
+ const require_setTypeIndex = require("./setTypeIndex.cjs");
4
+ const require_useTypeIndexProfile = require("./react/useTypeIndexProfile.cjs");
5
+ const require_useInstanceUris = require("./react/useInstanceUris.cjs");
6
+ exports.addRegistration = require_setTypeIndex.addRegistration;
7
+ exports.createIndex = require_setTypeIndex.createIndex;
8
+ exports.findAppropriateTypeRegistration = require_setTypeIndex.findAppropriateTypeRegistration;
9
+ exports.getInstanceUris = require_getTypeIndex.getInstanceUris;
10
+ exports.getProfile = require_getTypeIndex.getProfile;
11
+ exports.getTypeIndexesUrisFromProfile = require_getTypeIndex.getTypeIndexesUrisFromProfile;
12
+ exports.getTypeRegistrations = require_getTypeIndex.getTypeRegistrations;
13
+ exports.initTypeIndex = require_setTypeIndex.initTypeIndex;
14
+ exports.removeRegistration = require_setTypeIndex.removeRegistration;
15
+ exports.useInstanceUris = require_useInstanceUris.useInstanceUris;
16
+ exports.useTypeIndexProfile = require_useTypeIndexProfile.useTypeIndexProfile;
@@ -0,0 +1,5 @@
1
+ import { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations } from "./getTypeIndex.cjs";
2
+ import { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration } from "./setTypeIndex.cjs";
3
+ import { useInstanceUris } from "./react/useInstanceUris.cjs";
4
+ import { useTypeIndexProfile } from "./react/useTypeIndexProfile.cjs";
5
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations, initTypeIndex, removeRegistration, useInstanceUris, useTypeIndexProfile };
@@ -0,0 +1,5 @@
1
+ import { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations } from "./getTypeIndex.mjs";
2
+ import { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration } from "./setTypeIndex.mjs";
3
+ import { useInstanceUris } from "./react/useInstanceUris.mjs";
4
+ import { useTypeIndexProfile } from "./react/useTypeIndexProfile.mjs";
5
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations, initTypeIndex, removeRegistration, useInstanceUris, useTypeIndexProfile };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations } from "./getTypeIndex.mjs";
2
+ import { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration } from "./setTypeIndex.mjs";
3
+ import { useTypeIndexProfile } from "./react/useTypeIndexProfile.mjs";
4
+ import { useInstanceUris } from "./react/useInstanceUris.mjs";
5
+ export { addRegistration, createIndex, findAppropriateTypeRegistration, getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations, initTypeIndex, removeRegistration, useInstanceUris, useTypeIndexProfile };
@@ -0,0 +1,27 @@
1
+ const require_typeIndex_shapeTypes = require("../_ldo/typeIndex.shapeTypes.cjs");
2
+ const require_constants = require("../constants.cjs");
3
+ const require_getTypeIndex = require("../getTypeIndex.cjs");
4
+ const require_useTypeIndexProfile = require("./useTypeIndexProfile.cjs");
5
+ const require_useSubscribeToUris = require("./util/useSubscribeToUris.cjs");
6
+ let _ldo_solid_react = require("@ldo/solid-react");
7
+ let react = require("react");
8
+ //#region src/react/useInstanceUris.ts
9
+ /**
10
+ * Provides the LeafUris of everything in a type node for a specific class uri
11
+ *
12
+ * @param classUri - the class uri
13
+ * @returns - URIs of all resources registered with this node
14
+ */
15
+ function useInstanceUris(classUri) {
16
+ const { dataset } = (0, _ldo_solid_react.useLdo)();
17
+ const profile = require_useTypeIndexProfile.useTypeIndexProfile();
18
+ require_useSubscribeToUris.useSubscribeToUris((0, react.useMemo)(() => profile ? require_getTypeIndex.getTypeIndexesUrisFromProfile(profile) : [], [profile]));
19
+ const [leafUris, setLeafUris] = (0, react.useState)([]);
20
+ const typeRegistrations = (0, _ldo_solid_react.useMatchSubject)(require_typeIndex_shapeTypes.TypeRegistrationShapeType, require_constants.RDF_TYPE, require_constants.TYPE_REGISTRATION);
21
+ (0, react.useEffect)(() => {
22
+ require_getTypeIndex.getInstanceUris(classUri, typeRegistrations.toArray(), { solidLdoDataset: dataset }).then(setLeafUris);
23
+ }, [typeRegistrations]);
24
+ return leafUris;
25
+ }
26
+ //#endregion
27
+ exports.useInstanceUris = useInstanceUris;
@@ -0,0 +1,13 @@
1
+ import { SolidLeafUri } from "@ldo/connected-solid";
2
+
3
+ //#region src/react/useInstanceUris.d.ts
4
+ /**
5
+ * Provides the LeafUris of everything in a type node for a specific class uri
6
+ *
7
+ * @param classUri - the class uri
8
+ * @returns - URIs of all resources registered with this node
9
+ */
10
+ declare function useInstanceUris(classUri: string): SolidLeafUri[];
11
+ //#endregion
12
+ export { useInstanceUris };
13
+ //# sourceMappingURL=useInstanceUris.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInstanceUris.d.cts","names":[],"sources":["../../src/react/useInstanceUris.ts"],"mappings":";;;;;AAkBA;;;;iBAAgB,eAAA,CAAgB,QAAA,WAAmB,YAAA"}
@@ -0,0 +1,13 @@
1
+ import { SolidLeafUri } from "@ldo/connected-solid";
2
+
3
+ //#region src/react/useInstanceUris.d.ts
4
+ /**
5
+ * Provides the LeafUris of everything in a type node for a specific class uri
6
+ *
7
+ * @param classUri - the class uri
8
+ * @returns - URIs of all resources registered with this node
9
+ */
10
+ declare function useInstanceUris(classUri: string): SolidLeafUri[];
11
+ //#endregion
12
+ export { useInstanceUris };
13
+ //# sourceMappingURL=useInstanceUris.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInstanceUris.d.mts","names":[],"sources":["../../src/react/useInstanceUris.ts"],"mappings":";;;;;AAkBA;;;;iBAAgB,eAAA,CAAgB,QAAA,WAAmB,YAAA"}
@@ -0,0 +1,29 @@
1
+ import { TypeRegistrationShapeType } from "../_ldo/typeIndex.shapeTypes.mjs";
2
+ import { RDF_TYPE, TYPE_REGISTRATION } from "../constants.mjs";
3
+ import { getInstanceUris, getTypeIndexesUrisFromProfile } from "../getTypeIndex.mjs";
4
+ import { useTypeIndexProfile } from "./useTypeIndexProfile.mjs";
5
+ import { useSubscribeToUris } from "./util/useSubscribeToUris.mjs";
6
+ import { useLdo, useMatchSubject } from "@ldo/solid-react";
7
+ import { useEffect, useMemo, useState } from "react";
8
+ //#region src/react/useInstanceUris.ts
9
+ /**
10
+ * Provides the LeafUris of everything in a type node for a specific class uri
11
+ *
12
+ * @param classUri - the class uri
13
+ * @returns - URIs of all resources registered with this node
14
+ */
15
+ function useInstanceUris(classUri) {
16
+ const { dataset } = useLdo();
17
+ const profile = useTypeIndexProfile();
18
+ useSubscribeToUris(useMemo(() => profile ? getTypeIndexesUrisFromProfile(profile) : [], [profile]));
19
+ const [leafUris, setLeafUris] = useState([]);
20
+ const typeRegistrations = useMatchSubject(TypeRegistrationShapeType, RDF_TYPE, TYPE_REGISTRATION);
21
+ useEffect(() => {
22
+ getInstanceUris(classUri, typeRegistrations.toArray(), { solidLdoDataset: dataset }).then(setLeafUris);
23
+ }, [typeRegistrations]);
24
+ return leafUris;
25
+ }
26
+ //#endregion
27
+ export { useInstanceUris };
28
+
29
+ //# sourceMappingURL=useInstanceUris.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInstanceUris.mjs","names":[],"sources":["../../src/react/useInstanceUris.ts"],"sourcesContent":["import { useTypeIndexProfile } from \"./useTypeIndexProfile\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useSubscribeToUris } from \"./util/useSubscribeToUris\";\nimport { useLdo, useMatchSubject } from \"@ldo/solid-react\";\nimport { TypeRegistrationShapeType } from \"../_ldo/typeIndex.shapeTypes\";\nimport { RDF_TYPE, TYPE_REGISTRATION } from \"../constants\";\nimport {\n getInstanceUris,\n getTypeIndexesUrisFromProfile,\n} from \"../getTypeIndex\";\nimport type { SolidLeafUri } from \"@ldo/connected-solid\";\n\n/**\n * Provides the LeafUris of everything in a type node for a specific class uri\n *\n * @param classUri - the class uri\n * @returns - URIs of all resources registered with this node\n */\nexport function useInstanceUris(classUri: string): SolidLeafUri[] {\n const { dataset } = useLdo();\n const profile = useTypeIndexProfile();\n\n const typeIndexUris: string[] = useMemo(\n () => (profile ? getTypeIndexesUrisFromProfile(profile) : []),\n [profile],\n );\n\n useSubscribeToUris(typeIndexUris);\n\n const [leafUris, setLeafUris] = useState<SolidLeafUri[]>([]);\n\n const typeRegistrations = useMatchSubject(\n TypeRegistrationShapeType,\n RDF_TYPE,\n TYPE_REGISTRATION,\n );\n\n useEffect(() => {\n getInstanceUris(classUri, typeRegistrations.toArray(), {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore TODO: come back and see if we can fix this\n solidLdoDataset: dataset,\n }).then(setLeafUris);\n }, [typeRegistrations]);\n\n return leafUris;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,gBAAgB,UAAkC;CAChE,MAAM,EAAE,YAAY,QAAQ;CAC5B,MAAM,UAAU,qBAAqB;AAOrC,oBALgC,cACvB,UAAU,8BAA8B,QAAQ,GAAG,EAAE,EAC5D,CAAC,QAAQ,CAGqB,CAAC;CAEjC,MAAM,CAAC,UAAU,eAAe,SAAyB,EAAE,CAAC;CAE5D,MAAM,oBAAoB,gBACxB,2BACA,UACA,kBACD;AAED,iBAAgB;AACd,kBAAgB,UAAU,kBAAkB,SAAS,EAAE,EAGrD,iBAAiB,SAClB,CAAC,CAAC,KAAK,YAAY;IACnB,CAAC,kBAAkB,CAAC;AAEvB,QAAO"}
@@ -0,0 +1,10 @@
1
+ const require_profile_shapeTypes = require("../_ldo/profile.shapeTypes.cjs");
2
+ let _ldo_solid_react = require("@ldo/solid-react");
3
+ //#region src/react/useTypeIndexProfile.ts
4
+ function useTypeIndexProfile() {
5
+ const { session } = (0, _ldo_solid_react.useSolidAuth)();
6
+ (0, _ldo_solid_react.useResource)(session.webId, { subscribe: true });
7
+ return (0, _ldo_solid_react.useSubject)(require_profile_shapeTypes.TypeIndexProfileShapeType, session.webId);
8
+ }
9
+ //#endregion
10
+ exports.useTypeIndexProfile = useTypeIndexProfile;
@@ -0,0 +1,7 @@
1
+ import { TypeIndexProfile } from "../_ldo/profile.typings.cjs";
2
+
3
+ //#region src/react/useTypeIndexProfile.d.ts
4
+ declare function useTypeIndexProfile(): TypeIndexProfile | undefined;
5
+ //#endregion
6
+ export { useTypeIndexProfile };
7
+ //# sourceMappingURL=useTypeIndexProfile.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTypeIndexProfile.d.cts","names":[],"sources":["../../src/react/useTypeIndexProfile.ts"],"mappings":";;;iBAIgB,mBAAA,CAAA,GAAuB,gBAAA"}
@@ -0,0 +1,7 @@
1
+ import { TypeIndexProfile } from "../_ldo/profile.typings.mjs";
2
+
3
+ //#region src/react/useTypeIndexProfile.d.ts
4
+ declare function useTypeIndexProfile(): TypeIndexProfile | undefined;
5
+ //#endregion
6
+ export { useTypeIndexProfile };
7
+ //# sourceMappingURL=useTypeIndexProfile.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTypeIndexProfile.d.mts","names":[],"sources":["../../src/react/useTypeIndexProfile.ts"],"mappings":";;;iBAIgB,mBAAA,CAAA,GAAuB,gBAAA"}
@@ -0,0 +1,12 @@
1
+ import { TypeIndexProfileShapeType } from "../_ldo/profile.shapeTypes.mjs";
2
+ import { useResource, useSolidAuth, useSubject } from "@ldo/solid-react";
3
+ //#region src/react/useTypeIndexProfile.ts
4
+ function useTypeIndexProfile() {
5
+ const { session } = useSolidAuth();
6
+ useResource(session.webId, { subscribe: true });
7
+ return useSubject(TypeIndexProfileShapeType, session.webId);
8
+ }
9
+ //#endregion
10
+ export { useTypeIndexProfile };
11
+
12
+ //# sourceMappingURL=useTypeIndexProfile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTypeIndexProfile.mjs","names":[],"sources":["../../src/react/useTypeIndexProfile.ts"],"sourcesContent":["import { useResource, useSolidAuth, useSubject } from \"@ldo/solid-react\";\nimport type { TypeIndexProfile } from \"../_ldo/profile.typings\";\nimport { TypeIndexProfileShapeType } from \"../_ldo/profile.shapeTypes\";\n\nexport function useTypeIndexProfile(): TypeIndexProfile | undefined {\n const { session } = useSolidAuth();\n useResource(session.webId, { subscribe: true });\n const profile = useSubject(TypeIndexProfileShapeType, session.webId);\n return profile;\n}\n"],"mappings":";;;AAIA,SAAgB,sBAAoD;CAClE,MAAM,EAAE,YAAY,cAAc;AAClC,aAAY,QAAQ,OAAO,EAAE,WAAW,MAAM,CAAC;AAE/C,QADgB,WAAW,2BAA2B,QAAQ,MAChD"}
@@ -0,0 +1,24 @@
1
+ let _ldo_solid_react = require("@ldo/solid-react");
2
+ let react = require("react");
3
+ //#region src/react/util/useSubscribeToUris.ts
4
+ function useSubscribeToUris(uris) {
5
+ const { dataset } = (0, _ldo_solid_react.useLdo)();
6
+ const currentlySubscribed = (0, react.useRef)({});
7
+ (0, react.useEffect)(() => {
8
+ const resources = uris.map((uri) => dataset.getResource(uri));
9
+ const previousSubscriptions = { ...currentlySubscribed.current };
10
+ Promise.all(resources.map(async (resource) => {
11
+ if (!previousSubscriptions[resource.uri]) {
12
+ await resource.readIfUnfetched();
13
+ currentlySubscribed.current[resource.uri] = await resource.subscribeToNotifications();
14
+ } else delete previousSubscriptions[resource.uri];
15
+ })).then(async () => {
16
+ await Promise.all(Object.entries(previousSubscriptions).map(async ([resourceUri, subscriptionId]) => {
17
+ delete currentlySubscribed.current[resourceUri];
18
+ await dataset.getResource(resourceUri).unsubscribeFromNotifications(subscriptionId);
19
+ }));
20
+ });
21
+ }, [uris]);
22
+ }
23
+ //#endregion
24
+ exports.useSubscribeToUris = useSubscribeToUris;
@@ -0,0 +1,26 @@
1
+ import { useLdo } from "@ldo/solid-react";
2
+ import { useEffect, useRef } from "react";
3
+ //#region src/react/util/useSubscribeToUris.ts
4
+ function useSubscribeToUris(uris) {
5
+ const { dataset } = useLdo();
6
+ const currentlySubscribed = useRef({});
7
+ useEffect(() => {
8
+ const resources = uris.map((uri) => dataset.getResource(uri));
9
+ const previousSubscriptions = { ...currentlySubscribed.current };
10
+ Promise.all(resources.map(async (resource) => {
11
+ if (!previousSubscriptions[resource.uri]) {
12
+ await resource.readIfUnfetched();
13
+ currentlySubscribed.current[resource.uri] = await resource.subscribeToNotifications();
14
+ } else delete previousSubscriptions[resource.uri];
15
+ })).then(async () => {
16
+ await Promise.all(Object.entries(previousSubscriptions).map(async ([resourceUri, subscriptionId]) => {
17
+ delete currentlySubscribed.current[resourceUri];
18
+ await dataset.getResource(resourceUri).unsubscribeFromNotifications(subscriptionId);
19
+ }));
20
+ });
21
+ }, [uris]);
22
+ }
23
+ //#endregion
24
+ export { useSubscribeToUris };
25
+
26
+ //# sourceMappingURL=useSubscribeToUris.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubscribeToUris.mjs","names":[],"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,mBAAmB,MAAgB;CACjD,MAAM,EAAE,YAAY,QAAQ;CAC5B,MAAM,sBAAsB,OAA+B,EAAE,CAAC;AAC9D,iBAAgB;EACd,MAAM,YAAY,KAAK,KAAK,QAAQ,QAAQ,YAAY,IAAI,CAAC;EAC7D,MAAM,wBAAwB,EAAE,GAAG,oBAAoB,SAAS;AAChE,UAAQ,IACN,UAAU,IAAI,OAAO,aAAa;AAChC,OAAI,CAAC,sBAAsB,SAAS,MAAM;AAExC,UAAM,SAAS,iBAAiB;AAChC,wBAAoB,QAAQ,SAAS,OACnC,MAAM,SAAS,0BAA0B;SAE3C,QAAO,sBAAsB,SAAS;IAExC,CACH,CAAC,KAAK,YAAY;AAEjB,SAAM,QAAQ,IACZ,OAAO,QAAQ,sBAAsB,CAAC,IACpC,OAAO,CAAC,aAAa,oBAAoB;AAEvC,WAAO,oBAAoB,QAAQ;AAEnC,UADiB,QAAQ,YAAY,YACvB,CAAC,6BAA6B,eAAe;KAE9D,CACF;IACD;IACD,CAAC,KAAK,CAAC"}