@ldo/solid-type-index 1.0.0-alpha.38 → 1.0.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/_ldo/profile.context.cjs +1 -3
- package/dist/_ldo/{profile.context.js → profile.context.mjs} +2 -2
- package/dist/_ldo/profile.context.mjs.map +1 -0
- package/dist/_ldo/profile.schema.cjs +1 -3
- package/dist/_ldo/{profile.schema.js → profile.schema.mjs} +2 -2
- package/dist/_ldo/profile.schema.mjs.map +1 -0
- package/dist/_ldo/profile.shapeTypes.cjs +5 -7
- package/dist/_ldo/{profile.shapeTypes.js → profile.shapeTypes.mjs} +4 -5
- package/dist/_ldo/profile.shapeTypes.mjs.map +1 -0
- package/dist/_ldo/profile.typings.d.cts +0 -2
- package/dist/_ldo/profile.typings.d.cts.map +1 -1
- package/dist/_ldo/{profile.typings.d.ts → profile.typings.d.mts} +1 -3
- package/dist/_ldo/profile.typings.d.mts.map +1 -0
- package/dist/_ldo/typeIndex.context.cjs +1 -3
- package/dist/_ldo/{typeIndex.context.js → typeIndex.context.mjs} +2 -2
- package/dist/_ldo/typeIndex.context.mjs.map +1 -0
- package/dist/_ldo/typeIndex.schema.cjs +1 -3
- package/dist/_ldo/{typeIndex.schema.js → typeIndex.schema.mjs} +2 -2
- package/dist/_ldo/typeIndex.schema.mjs.map +1 -0
- package/dist/_ldo/typeIndex.shapeTypes.cjs +7 -9
- package/dist/_ldo/{typeIndex.shapeTypes.js → typeIndex.shapeTypes.mjs} +4 -5
- package/dist/_ldo/typeIndex.shapeTypes.mjs.map +1 -0
- package/dist/_ldo/typeIndex.typings.d.cts +0 -2
- package/dist/_ldo/typeIndex.typings.d.cts.map +1 -1
- package/dist/_ldo/{typeIndex.typings.d.ts → typeIndex.typings.d.mts} +1 -3
- package/dist/_ldo/typeIndex.typings.d.mts.map +1 -0
- package/dist/constants.cjs +1 -3
- package/dist/{constants.js → constants.mjs} +2 -2
- package/dist/constants.mjs.map +1 -0
- package/dist/getTypeIndex.cjs +14 -19
- package/dist/getTypeIndex.d.cts +0 -2
- package/dist/getTypeIndex.d.cts.map +1 -1
- package/dist/{getTypeIndex.d.ts → getTypeIndex.d.mts} +5 -7
- package/dist/getTypeIndex.d.mts.map +1 -0
- package/dist/{getTypeIndex.js → getTypeIndex.mjs} +10 -14
- package/dist/getTypeIndex.mjs.map +1 -0
- package/dist/index.cjs +16 -16
- package/dist/{index.js → index.d.mts} +4 -5
- package/dist/index.mjs +5 -0
- package/dist/react/useInstanceUris.cjs +13 -17
- package/dist/react/useInstanceUris.d.cts +0 -2
- package/dist/react/useInstanceUris.d.cts.map +1 -1
- package/dist/react/{useInstanceUris.d.ts → useInstanceUris.d.mts} +2 -4
- package/dist/react/useInstanceUris.d.mts.map +1 -0
- package/dist/react/{useInstanceUris.js → useInstanceUris.mjs} +8 -10
- package/dist/react/useInstanceUris.mjs.map +1 -0
- package/dist/react/useTypeIndexProfile.cjs +6 -10
- package/dist/react/useTypeIndexProfile.d.cts +0 -2
- package/dist/react/useTypeIndexProfile.d.cts.map +1 -1
- package/dist/react/useTypeIndexProfile.d.mts +7 -0
- package/dist/react/useTypeIndexProfile.d.mts.map +1 -0
- package/dist/react/{useTypeIndexProfile.js → useTypeIndexProfile.mjs} +4 -6
- package/dist/react/useTypeIndexProfile.mjs.map +1 -0
- package/dist/react/util/useSubscribeToUris.cjs +5 -9
- package/dist/react/util/{useSubscribeToUris.js → useSubscribeToUris.mjs} +3 -5
- package/dist/react/util/useSubscribeToUris.mjs.map +1 -0
- package/dist/setTypeIndex.cjs +19 -23
- package/dist/setTypeIndex.d.cts +0 -1
- package/dist/setTypeIndex.d.cts.map +1 -1
- package/dist/{setTypeIndex.d.ts → setTypeIndex.d.mts} +4 -5
- package/dist/setTypeIndex.d.mts.map +1 -0
- package/dist/{setTypeIndex.js → setTypeIndex.mjs} +8 -10
- package/dist/setTypeIndex.mjs.map +1 -0
- package/dist/util/Options.cjs +4 -7
- package/dist/util/Options.d.cts.map +1 -1
- package/dist/util/{Options.d.ts → Options.d.mts} +1 -1
- package/dist/util/Options.d.mts.map +1 -0
- package/dist/util/{Options.js → Options.mjs} +2 -3
- package/dist/util/Options.mjs.map +1 -0
- package/package.json +14 -13
- package/src/_ldo/profile.context.ts +1 -1
- package/src/_ldo/profile.schema.ts +1 -1
- package/src/_ldo/profile.shapeTypes.ts +2 -2
- package/src/_ldo/profile.typings.ts +1 -1
- package/src/_ldo/typeIndex.context.ts +1 -1
- package/src/_ldo/typeIndex.schema.ts +1 -1
- package/src/_ldo/typeIndex.shapeTypes.ts +2 -2
- package/src/_ldo/typeIndex.typings.ts +1 -1
- package/dist/_ldo/profile.context.js.map +0 -1
- package/dist/_ldo/profile.schema.js.map +0 -1
- package/dist/_ldo/profile.shapeTypes.js.map +0 -1
- package/dist/_ldo/profile.typings.d.ts.map +0 -1
- package/dist/_ldo/typeIndex.context.js.map +0 -1
- package/dist/_ldo/typeIndex.schema.js.map +0 -1
- package/dist/_ldo/typeIndex.shapeTypes.js.map +0 -1
- package/dist/_ldo/typeIndex.typings.d.ts.map +0 -1
- package/dist/_virtual/rolldown_runtime.cjs +0 -30
- package/dist/constants.js.map +0 -1
- package/dist/getTypeIndex.d.ts.map +0 -1
- package/dist/getTypeIndex.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/react/useInstanceUris.d.ts.map +0 -1
- package/dist/react/useInstanceUris.js.map +0 -1
- package/dist/react/useTypeIndexProfile.d.ts +0 -9
- package/dist/react/useTypeIndexProfile.d.ts.map +0 -1
- package/dist/react/useTypeIndexProfile.js.map +0 -1
- package/dist/react/util/useSubscribeToUris.js.map +0 -1
- package/dist/setTypeIndex.d.ts.map +0 -1
- package/dist/setTypeIndex.js.map +0 -1
- package/dist/util/Options.d.ts.map +0 -1
- package/dist/util/Options.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { getInstanceUris, getProfile, getTypeIndexesUrisFromProfile, getTypeRegistrations } from "./getTypeIndex.
|
|
2
|
-
import { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration } from "./setTypeIndex.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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";
|
|
6
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 };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
9
|
-
|
|
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");
|
|
10
8
|
//#region src/react/useInstanceUris.ts
|
|
11
9
|
/**
|
|
12
10
|
* Provides the LeafUris of everything in a type node for a specific class uri
|
|
@@ -15,17 +13,15 @@ const react = require_rolldown_runtime.__toESM(require("react"));
|
|
|
15
13
|
* @returns - URIs of all resources registered with this node
|
|
16
14
|
*/
|
|
17
15
|
function useInstanceUris(classUri) {
|
|
18
|
-
const { dataset } = (0,
|
|
19
|
-
const profile =
|
|
20
|
-
|
|
21
|
-
require__Users_jacksonmorgan_O_ldo_packages_solid_type_index_src_react_util_useSubscribeToUris.useSubscribeToUris(typeIndexUris);
|
|
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]));
|
|
22
19
|
const [leafUris, setLeafUris] = (0, react.useState)([]);
|
|
23
|
-
const typeRegistrations = (0,
|
|
20
|
+
const typeRegistrations = (0, _ldo_solid_react.useMatchSubject)(require_typeIndex_shapeTypes.TypeRegistrationShapeType, require_constants.RDF_TYPE, require_constants.TYPE_REGISTRATION);
|
|
24
21
|
(0, react.useEffect)(() => {
|
|
25
|
-
|
|
22
|
+
require_getTypeIndex.getInstanceUris(classUri, typeRegistrations.toArray(), { solidLdoDataset: dataset }).then(setLeafUris);
|
|
26
23
|
}, [typeRegistrations]);
|
|
27
24
|
return leafUris;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
//#endregion
|
|
31
|
-
exports.useInstanceUris = useInstanceUris;
|
|
27
|
+
exports.useInstanceUris = useInstanceUris;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SolidLeafUri } from "@ldo/connected-solid";
|
|
2
2
|
|
|
3
3
|
//#region src/react/useInstanceUris.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Provides the LeafUris of everything in a type node for a specific class uri
|
|
7
6
|
*
|
|
@@ -9,7 +8,6 @@ import { SolidLeafUri } from "@ldo/connected-solid";
|
|
|
9
8
|
* @returns - URIs of all resources registered with this node
|
|
10
9
|
*/
|
|
11
10
|
declare function useInstanceUris(classUri: string): SolidLeafUri[];
|
|
12
|
-
//# sourceMappingURL=useInstanceUris.d.ts.map
|
|
13
11
|
//#endregion
|
|
14
12
|
export { useInstanceUris };
|
|
15
13
|
//# sourceMappingURL=useInstanceUris.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInstanceUris.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"useInstanceUris.d.cts","names":[],"sources":["../../src/react/useInstanceUris.ts"],"mappings":";;;;;AAkBA;;;;iBAAgB,eAAA,CAAgB,QAAA,WAAmB,YAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SolidLeafUri } from "@ldo/connected-solid";
|
|
2
2
|
|
|
3
3
|
//#region src/react/useInstanceUris.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Provides the LeafUris of everything in a type node for a specific class uri
|
|
7
6
|
*
|
|
@@ -9,7 +8,6 @@ import { SolidLeafUri } from "@ldo/connected-solid";
|
|
|
9
8
|
* @returns - URIs of all resources registered with this node
|
|
10
9
|
*/
|
|
11
10
|
declare function useInstanceUris(classUri: string): SolidLeafUri[];
|
|
12
|
-
//# sourceMappingURL=useInstanceUris.d.ts.map
|
|
13
11
|
//#endregion
|
|
14
|
-
export { useInstanceUris
|
|
15
|
-
//# sourceMappingURL=useInstanceUris.d.
|
|
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"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { TypeRegistrationShapeType } from "../_ldo/typeIndex.shapeTypes.
|
|
2
|
-
import { RDF_TYPE, TYPE_REGISTRATION } from "../constants.
|
|
3
|
-
import { getInstanceUris, getTypeIndexesUrisFromProfile } from "../getTypeIndex.
|
|
4
|
-
import { useTypeIndexProfile } from "./useTypeIndexProfile.
|
|
5
|
-
import { useSubscribeToUris } from "./util/useSubscribeToUris.
|
|
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
6
|
import { useLdo, useMatchSubject } from "@ldo/solid-react";
|
|
7
7
|
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
|
|
9
8
|
//#region src/react/useInstanceUris.ts
|
|
10
9
|
/**
|
|
11
10
|
* Provides the LeafUris of everything in a type node for a specific class uri
|
|
@@ -16,8 +15,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
16
15
|
function useInstanceUris(classUri) {
|
|
17
16
|
const { dataset } = useLdo();
|
|
18
17
|
const profile = useTypeIndexProfile();
|
|
19
|
-
|
|
20
|
-
useSubscribeToUris(typeIndexUris);
|
|
18
|
+
useSubscribeToUris(useMemo(() => profile ? getTypeIndexesUrisFromProfile(profile) : [], [profile]));
|
|
21
19
|
const [leafUris, setLeafUris] = useState([]);
|
|
22
20
|
const typeRegistrations = useMatchSubject(TypeRegistrationShapeType, RDF_TYPE, TYPE_REGISTRATION);
|
|
23
21
|
useEffect(() => {
|
|
@@ -25,7 +23,7 @@ function useInstanceUris(classUri) {
|
|
|
25
23
|
}, [typeRegistrations]);
|
|
26
24
|
return leafUris;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
//#endregion
|
|
30
27
|
export { useInstanceUris };
|
|
31
|
-
|
|
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,CACV,CAEgC;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"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const __ldo_solid_react = require_rolldown_runtime.__toESM(require("@ldo/solid-react"));
|
|
4
|
-
|
|
1
|
+
const require_profile_shapeTypes = require("../_ldo/profile.shapeTypes.cjs");
|
|
2
|
+
let _ldo_solid_react = require("@ldo/solid-react");
|
|
5
3
|
//#region src/react/useTypeIndexProfile.ts
|
|
6
4
|
function useTypeIndexProfile() {
|
|
7
|
-
const { session } = (0,
|
|
8
|
-
(0,
|
|
9
|
-
|
|
10
|
-
return profile;
|
|
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);
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
//#endregion
|
|
14
|
-
exports.useTypeIndexProfile = useTypeIndexProfile;
|
|
10
|
+
exports.useTypeIndexProfile = useTypeIndexProfile;
|
|
@@ -2,8 +2,6 @@ import { TypeIndexProfile } from "../_ldo/profile.typings.cjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/react/useTypeIndexProfile.d.ts
|
|
4
4
|
declare function useTypeIndexProfile(): TypeIndexProfile | undefined;
|
|
5
|
-
//# sourceMappingURL=useTypeIndexProfile.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
6
|
export { useTypeIndexProfile };
|
|
9
7
|
//# sourceMappingURL=useTypeIndexProfile.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeIndexProfile.d.cts","names":[],"sources":["
|
|
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"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { TypeIndexProfileShapeType } from "../_ldo/profile.shapeTypes.
|
|
1
|
+
import { TypeIndexProfileShapeType } from "../_ldo/profile.shapeTypes.mjs";
|
|
2
2
|
import { useResource, useSolidAuth, useSubject } from "@ldo/solid-react";
|
|
3
|
-
|
|
4
3
|
//#region src/react/useTypeIndexProfile.ts
|
|
5
4
|
function useTypeIndexProfile() {
|
|
6
5
|
const { session } = useSolidAuth();
|
|
7
6
|
useResource(session.webId, { subscribe: true });
|
|
8
|
-
|
|
9
|
-
return profile;
|
|
7
|
+
return useSubject(TypeIndexProfileShapeType, session.webId);
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
//#endregion
|
|
13
10
|
export { useTypeIndexProfile };
|
|
14
|
-
|
|
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,MAAM"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
4
|
-
|
|
1
|
+
let _ldo_solid_react = require("@ldo/solid-react");
|
|
2
|
+
let react = require("react");
|
|
5
3
|
//#region src/react/util/useSubscribeToUris.ts
|
|
6
4
|
function useSubscribeToUris(uris) {
|
|
7
|
-
const { dataset } = (0,
|
|
5
|
+
const { dataset } = (0, _ldo_solid_react.useLdo)();
|
|
8
6
|
const currentlySubscribed = (0, react.useRef)({});
|
|
9
7
|
(0, react.useEffect)(() => {
|
|
10
8
|
const resources = uris.map((uri) => dataset.getResource(uri));
|
|
@@ -17,12 +15,10 @@ function useSubscribeToUris(uris) {
|
|
|
17
15
|
})).then(async () => {
|
|
18
16
|
await Promise.all(Object.entries(previousSubscriptions).map(async ([resourceUri, subscriptionId]) => {
|
|
19
17
|
delete currentlySubscribed.current[resourceUri];
|
|
20
|
-
|
|
21
|
-
await resource.unsubscribeFromNotifications(subscriptionId);
|
|
18
|
+
await dataset.getResource(resourceUri).unsubscribeFromNotifications(subscriptionId);
|
|
22
19
|
}));
|
|
23
20
|
});
|
|
24
21
|
}, [uris]);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
//#endregion
|
|
28
|
-
exports.useSubscribeToUris = useSubscribeToUris;
|
|
24
|
+
exports.useSubscribeToUris = useSubscribeToUris;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useLdo } from "@ldo/solid-react";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
|
|
4
3
|
//#region src/react/util/useSubscribeToUris.ts
|
|
5
4
|
function useSubscribeToUris(uris) {
|
|
6
5
|
const { dataset } = useLdo();
|
|
@@ -16,13 +15,12 @@ function useSubscribeToUris(uris) {
|
|
|
16
15
|
})).then(async () => {
|
|
17
16
|
await Promise.all(Object.entries(previousSubscriptions).map(async ([resourceUri, subscriptionId]) => {
|
|
18
17
|
delete currentlySubscribed.current[resourceUri];
|
|
19
|
-
|
|
20
|
-
await resource.unsubscribeFromNotifications(subscriptionId);
|
|
18
|
+
await dataset.getResource(resourceUri).unsubscribeFromNotifications(subscriptionId);
|
|
21
19
|
}));
|
|
22
20
|
});
|
|
23
21
|
}, [uris]);
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
//#endregion
|
|
27
24
|
export { useSubscribeToUris };
|
|
28
|
-
|
|
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,YAAY,CAClC,6BAA6B,eAAe;KAE9D,CACF;IACD;IACD,CAAC,KAAK,CAAC"}
|
package/dist/setTypeIndex.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const __ldo_ldo = require_rolldown_runtime.__toESM(require("@ldo/ldo"));
|
|
10
|
-
|
|
1
|
+
const require_profile_shapeTypes = require("./_ldo/profile.shapeTypes.cjs");
|
|
2
|
+
const require_typeIndex_shapeTypes = require("./_ldo/typeIndex.shapeTypes.cjs");
|
|
3
|
+
const require_constants = require("./constants.cjs");
|
|
4
|
+
const require_Options = require("./util/Options.cjs");
|
|
5
|
+
const require_getTypeIndex = require("./getTypeIndex.cjs");
|
|
6
|
+
let uuid = require("uuid");
|
|
7
|
+
let _ldo_rdf_utils = require("@ldo/rdf-utils");
|
|
8
|
+
let _ldo_ldo = require("@ldo/ldo");
|
|
11
9
|
//#region src/setTypeIndex.ts
|
|
12
10
|
/**
|
|
13
11
|
* =============================================================================
|
|
@@ -15,8 +13,8 @@ const __ldo_ldo = require_rolldown_runtime.__toESM(require("@ldo/ldo"));
|
|
|
15
13
|
* =============================================================================
|
|
16
14
|
*/
|
|
17
15
|
async function initTypeIndex(webId, options) {
|
|
18
|
-
const { dataset } =
|
|
19
|
-
const profile = await
|
|
16
|
+
const { dataset } = require_Options.guaranteeOptions(options);
|
|
17
|
+
const profile = await require_getTypeIndex.getProfile(webId, options);
|
|
20
18
|
if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {
|
|
21
19
|
const profileFolder = await dataset.getResource(webId).getParentContainer();
|
|
22
20
|
if (profileFolder?.isError) throw profileFolder;
|
|
@@ -57,11 +55,11 @@ async function createIndex(webId, profileFolder, dataset, isPrivate) {
|
|
|
57
55
|
});
|
|
58
56
|
if (wacResult.isError) throw wacResult;
|
|
59
57
|
const transaction = dataset.startTransaction();
|
|
60
|
-
const cProfile = transaction.usingType(
|
|
58
|
+
const cProfile = transaction.usingType(require_profile_shapeTypes.TypeIndexProfileShapeType).write(dataset.getResource(webId).uri).fromSubject(webId);
|
|
61
59
|
if (isPrivate) cProfile.privateTypeIndex?.add({ "@id": indexResource.uri });
|
|
62
60
|
else cProfile.publicTypeIndex?.add({ "@id": indexResource.uri });
|
|
63
|
-
const cTypeIndex = transaction.usingType(
|
|
64
|
-
cTypeIndex.type = (0,
|
|
61
|
+
const cTypeIndex = transaction.usingType(require_typeIndex_shapeTypes.TypeIndexDocumentShapeType).write(indexResource.uri).fromSubject(indexResource.uri);
|
|
62
|
+
cTypeIndex.type = (0, _ldo_ldo.set)({ "@id": "ListedDocument" }, { "@id": "TypeIndex" });
|
|
65
63
|
const commitResult = await transaction.commitToRemote();
|
|
66
64
|
if (commitResult.isError) throw commitResult;
|
|
67
65
|
}
|
|
@@ -106,24 +104,22 @@ async function removeRegistration(indexUri, classUri, instances, options) {
|
|
|
106
104
|
* @returns The Type Index
|
|
107
105
|
*/
|
|
108
106
|
function findAppropriateTypeRegistration(indexUri, classUri, options) {
|
|
109
|
-
const { dataset } =
|
|
110
|
-
const
|
|
111
|
-
|
|
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)));
|
|
107
|
+
const { dataset } = require_Options.guaranteeOptions(options);
|
|
108
|
+
const existingRegistrationForClassUri = dataset.match(null, (0, _ldo_rdf_utils.namedNode)(require_constants.RDF_TYPE), (0, _ldo_rdf_utils.namedNode)(require_constants.TYPE_REGISTRATION), (0, _ldo_rdf_utils.namedNode)(indexUri)).toArray().map((quad) => quad.subject).find((registrationUri) => {
|
|
109
|
+
return dataset.has((0, _ldo_rdf_utils.quad)(registrationUri, (0, _ldo_rdf_utils.namedNode)(require_constants.FOR_CLASS), (0, _ldo_rdf_utils.namedNode)(classUri), (0, _ldo_rdf_utils.namedNode)(indexUri)));
|
|
113
110
|
})?.value;
|
|
114
111
|
let typeRegistration;
|
|
115
|
-
if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(
|
|
112
|
+
if (existingRegistrationForClassUri) typeRegistration = dataset.usingType(require_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(existingRegistrationForClassUri);
|
|
116
113
|
else {
|
|
117
|
-
typeRegistration = dataset.usingType(
|
|
114
|
+
typeRegistration = dataset.usingType(require_typeIndex_shapeTypes.TypeRegistrationShapeType).write(indexUri).fromSubject(`${indexUri}#${(0, uuid.v4)()}`);
|
|
118
115
|
typeRegistration.type = { "@id": "TypeRegistration" };
|
|
119
116
|
typeRegistration.forClass = { "@id": classUri };
|
|
120
117
|
}
|
|
121
118
|
return typeRegistration;
|
|
122
119
|
}
|
|
123
|
-
|
|
124
120
|
//#endregion
|
|
125
121
|
exports.addRegistration = addRegistration;
|
|
126
122
|
exports.createIndex = createIndex;
|
|
127
123
|
exports.findAppropriateTypeRegistration = findAppropriateTypeRegistration;
|
|
128
124
|
exports.initTypeIndex = initTypeIndex;
|
|
129
|
-
exports.removeRegistration = removeRegistration;
|
|
125
|
+
exports.removeRegistration = removeRegistration;
|
package/dist/setTypeIndex.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
|
4
4
|
import { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
|
|
5
5
|
|
|
6
6
|
//#region src/setTypeIndex.d.ts
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* =============================================================================
|
|
10
9
|
* INITIALIZERS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTypeIndex.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"setTypeIndex.d.cts","names":[],"sources":["../src/setTypeIndex.ts"],"mappings":";;;;;;;;AA2BA;;;iBAAsB,aAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA;;;;;;;iBAyBmB,WAAA,CACpB,KAAA,OACA,aAAA,EAAe,cAAA,EACf,OAAA,EAAS,mBAAA,EACN,oBAAA,GAAuB,eAAA,0BAE1B,SAAA,YAAkB,OAAA;;;;;;UAmDV,SAAA;EACR,QAAA;EACA,iBAAA;AAAA;;;;;;;;iBAUc,eAAA,CACd,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA;;;;AAvBX;;;;iBAgDqB,kBAAA,CACpB,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA,GAAO,OAAA;AAjCnB;;;;;;;;AAAA,iBA2DgB,+BAAA,CACd,QAAA,UACA,QAAA,UACA,OAAA,GAAU,OAAA,GACT,gBAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { TypeRegistration } from "./_ldo/typeIndex.typings.
|
|
2
|
-
import { Options } from "./util/Options.
|
|
1
|
+
import { TypeRegistration } from "./_ldo/typeIndex.typings.mjs";
|
|
2
|
+
import { Options } from "./util/Options.mjs";
|
|
3
3
|
import { SolidConnectedPlugin, SolidContainer } from "@ldo/connected-solid";
|
|
4
4
|
import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
5
5
|
|
|
6
6
|
//#region src/setTypeIndex.d.ts
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* =============================================================================
|
|
10
9
|
* INITIALIZERS
|
|
@@ -53,5 +52,5 @@ declare function removeRegistration(indexUri: string, classUri: string, instance
|
|
|
53
52
|
*/
|
|
54
53
|
declare function findAppropriateTypeRegistration(indexUri: string, classUri: string, options?: Options): TypeRegistration;
|
|
55
54
|
//#endregion
|
|
56
|
-
export { addRegistration
|
|
57
|
-
//# sourceMappingURL=setTypeIndex.d.
|
|
55
|
+
export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
|
|
56
|
+
//# sourceMappingURL=setTypeIndex.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setTypeIndex.d.mts","names":[],"sources":["../src/setTypeIndex.ts"],"mappings":";;;;;;;;AA2BA;;;iBAAsB,aAAA,CACpB,KAAA,UACA,OAAA,GAAU,OAAA,GACT,OAAA;;;;;;;iBAyBmB,WAAA,CACpB,KAAA,OACA,aAAA,EAAe,cAAA,EACf,OAAA,EAAS,mBAAA,EACN,oBAAA,GAAuB,eAAA,0BAE1B,SAAA,YAAkB,OAAA;;;;;;UAmDV,SAAA;EACR,QAAA;EACA,iBAAA;AAAA;;;;;;;;iBAUc,eAAA,CACd,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA;;;;AAvBX;;;;iBAgDqB,kBAAA,CACpB,QAAA,UACA,QAAA,UACA,SAAA,EAAW,SAAA,EACX,OAAA,GAAU,OAAA,GAAO,OAAA;AAjCnB;;;;;;;;AAAA,iBA2DgB,+BAAA,CACd,QAAA,UACA,QAAA,UACA,OAAA,GAAU,OAAA,GACT,gBAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { TypeIndexProfileShapeType } from "./_ldo/profile.shapeTypes.
|
|
2
|
-
import { TypeIndexDocumentShapeType, TypeRegistrationShapeType } from "./_ldo/typeIndex.shapeTypes.
|
|
3
|
-
import { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from "./constants.
|
|
4
|
-
import { guaranteeOptions } from "./util/Options.
|
|
5
|
-
import { getProfile } from "./getTypeIndex.
|
|
1
|
+
import { TypeIndexProfileShapeType } from "./_ldo/profile.shapeTypes.mjs";
|
|
2
|
+
import { TypeIndexDocumentShapeType, TypeRegistrationShapeType } from "./_ldo/typeIndex.shapeTypes.mjs";
|
|
3
|
+
import { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from "./constants.mjs";
|
|
4
|
+
import { guaranteeOptions } from "./util/Options.mjs";
|
|
5
|
+
import { getProfile } from "./getTypeIndex.mjs";
|
|
6
6
|
import { v4 } from "uuid";
|
|
7
7
|
import { namedNode, quad } from "@ldo/rdf-utils";
|
|
8
8
|
import { set } from "@ldo/ldo";
|
|
9
|
-
|
|
10
9
|
//#region src/setTypeIndex.ts
|
|
11
10
|
/**
|
|
12
11
|
* =============================================================================
|
|
@@ -106,8 +105,7 @@ async function removeRegistration(indexUri, classUri, instances, options) {
|
|
|
106
105
|
*/
|
|
107
106
|
function findAppropriateTypeRegistration(indexUri, classUri, options) {
|
|
108
107
|
const { dataset } = guaranteeOptions(options);
|
|
109
|
-
const
|
|
110
|
-
const existingRegistrationForClassUri = existingRegistrationsUris.find((registrationUri) => {
|
|
108
|
+
const existingRegistrationForClassUri = dataset.match(null, namedNode(RDF_TYPE), namedNode(TYPE_REGISTRATION), namedNode(indexUri)).toArray().map((quad) => quad.subject).find((registrationUri) => {
|
|
111
109
|
return dataset.has(quad(registrationUri, namedNode(FOR_CLASS), namedNode(classUri), namedNode(indexUri)));
|
|
112
110
|
})?.value;
|
|
113
111
|
let typeRegistration;
|
|
@@ -119,7 +117,7 @@ function findAppropriateTypeRegistration(indexUri, classUri, options) {
|
|
|
119
117
|
}
|
|
120
118
|
return typeRegistration;
|
|
121
119
|
}
|
|
122
|
-
|
|
123
120
|
//#endregion
|
|
124
121
|
export { addRegistration, createIndex, findAppropriateTypeRegistration, initTypeIndex, removeRegistration };
|
|
125
|
-
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=setTypeIndex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setTypeIndex.mjs","names":[],"sources":["../src/setTypeIndex.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { v4 } from \"uuid\";\nimport { FOR_CLASS, RDF_TYPE, TYPE_REGISTRATION } from \"./constants\";\nimport { guaranteeOptions, type Options } from \"./util/Options\";\nimport { namedNode, quad } from \"@ldo/rdf-utils\";\nimport type { TypeRegistration } from \"./_ldo/typeIndex.typings\";\nimport { getProfile } from \"./getTypeIndex\";\nimport { TypeIndexProfileShapeType } from \"./_ldo/profile.shapeTypes\";\nimport type { NamedNode } from \"@rdfjs/types\";\nimport { set } from \"@ldo/ldo\";\nimport type {\n SolidConnectedPlugin,\n SolidContainer,\n SolidContainerUri,\n SolidLeafUri,\n} from \"@ldo/connected-solid\";\nimport type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\nimport {\n TypeIndexDocumentShapeType,\n TypeRegistrationShapeType,\n} from \"./_ldo/typeIndex.shapeTypes\";\n\n/**\n * =============================================================================\n * INITIALIZERS\n * =============================================================================\n */\nexport async function initTypeIndex(\n webId: string,\n options?: Options,\n): Promise<void> {\n const { dataset } = guaranteeOptions(options);\n const profile = await getProfile(webId, options);\n if (!profile.privateTypeIndex?.size || !profile.publicTypeIndex?.size) {\n const profileFolder = await dataset\n .getResource(webId as SolidLeafUri | SolidContainerUri)\n .getParentContainer();\n if (profileFolder?.isError) throw profileFolder;\n if (!profileFolder)\n throw new Error(\"No folder to save the type indexes to.\");\n if (!profile.privateTypeIndex?.size) {\n await createIndex(webId, profileFolder, dataset, true);\n }\n if (!profile.publicTypeIndex?.size) {\n await createIndex(webId, profileFolder, dataset, false);\n }\n }\n}\n\n/**\n * @internal\n * @param webId\n * @param profileFolder\n * @param dataset\n */\nexport async function createIndex(\n webId,\n profileFolder: SolidContainer,\n dataset: ConnectedLdoDataset<\n (SolidConnectedPlugin | ConnectedPlugin<any, any, any, any>)[]\n >,\n isPrivate: boolean,\n) {\n // Create a private type index\n const createResult = await profileFolder.createChildAndOverwrite(\n `${isPrivate ? \"private\" : \"public\"}_index_${v4()}`,\n );\n if (createResult.isError) throw createResult;\n const indexResource = createResult.resource;\n const wacResult = await indexResource.setWac({\n agent: {\n [webId]: { read: true, write: true, append: true, control: true },\n },\n public: {\n read: isPrivate ? false : true,\n write: true,\n append: true,\n control: true,\n },\n authenticated: {\n read: isPrivate ? false : true,\n write: true,\n append: true,\n control: true,\n },\n });\n if (wacResult.isError) throw wacResult;\n const transaction = dataset.startTransaction();\n const cProfile = transaction\n .usingType(TypeIndexProfileShapeType)\n .write(dataset.getResource(webId).uri)\n .fromSubject(webId);\n if (isPrivate) {\n cProfile.privateTypeIndex?.add({ \"@id\": indexResource.uri });\n } else {\n cProfile.publicTypeIndex?.add({ \"@id\": indexResource.uri });\n }\n const cTypeIndex = transaction\n .usingType(TypeIndexDocumentShapeType)\n .write(indexResource.uri)\n .fromSubject(indexResource.uri);\n\n cTypeIndex.type = set({ \"@id\": \"ListedDocument\" }, { \"@id\": \"TypeIndex\" });\n const commitResult = await transaction.commitToRemote();\n if (commitResult.isError) throw commitResult;\n}\n\n/**\n * =============================================================================\n * DATASET MODIFIERS\n * =============================================================================\n */\ninterface Instances {\n instance?: string[];\n instanceContainer?: string[];\n}\n\n/**\n * Adds an instance to a TypeRegistration\n * @param indexUri The URI of the TypeIndex\n * @param classUri The URI for the class the instance should be added to\n * @param instances Objects representing the instances to add\n * @param options Options\n */\nexport function addRegistration(\n indexUri: string,\n classUri: string,\n instances: Instances,\n options?: Options,\n): void {\n // Check to see if its already in the index\n const typeRegistration = findAppropriateTypeRegistration(\n indexUri,\n classUri,\n options,\n );\n\n // Add instances to type registration\n instances.instance?.forEach((instance) => {\n typeRegistration.instance?.add({ \"@id\": instance });\n });\n instances.instanceContainer?.forEach((instanceContainer) => {\n typeRegistration.instanceContainer?.add({ \"@id\": instanceContainer });\n });\n}\n\n/**\n * Removes instances from a TypeRegistration\n * @param indexUri The URI of the TypeIndex\n * @param classUri The URI for the class the instance should be removed from\n * @param instances Objects representing the instances to remove\n * @param options Options\n */\nexport async function removeRegistration(\n indexUri: string,\n classUri: string,\n instances: Instances,\n options?: Options,\n) {\n // Check to see if its already in the index\n const typeRegistration = findAppropriateTypeRegistration(\n indexUri,\n classUri,\n options,\n );\n\n // Add instances to type registration\n instances.instance?.forEach((instanceUri) => {\n typeRegistration.instance?.delete({ \"@id\": instanceUri });\n });\n instances.instanceContainer?.forEach((instanceContainerUri) => {\n typeRegistration.instanceContainer?.delete({ \"@id\": instanceContainerUri });\n });\n}\n\n/**\n * Finds a TypeRegistration inside of a type index. If it doesn't exist, it\n * creates one.\n * @param indexUri The URI of the typeIndex\n * @param classUri The URI of the class in question for the TypeRegistration\n * @param options\n * @returns The Type Index\n */\nexport function findAppropriateTypeRegistration(\n indexUri: string,\n classUri: string,\n options?: Options,\n): TypeRegistration {\n const { dataset } = guaranteeOptions(options);\n // Check to see if its already in the index\n const existingRegistrationsUris: NamedNode[] = dataset\n .match(\n null,\n namedNode(RDF_TYPE),\n namedNode(TYPE_REGISTRATION),\n namedNode(indexUri),\n )\n .toArray()\n .map((quad) => quad.subject) as NamedNode[];\n\n const existingRegistrationForClassUri = existingRegistrationsUris.find(\n (registrationUri) => {\n return dataset.has(\n quad(\n registrationUri,\n namedNode(FOR_CLASS),\n namedNode(classUri),\n namedNode(indexUri),\n ),\n );\n },\n )?.value;\n\n let typeRegistration: TypeRegistration;\n if (existingRegistrationForClassUri) {\n typeRegistration = dataset\n .usingType(TypeRegistrationShapeType)\n .write(indexUri)\n .fromSubject(existingRegistrationForClassUri);\n } else {\n typeRegistration = dataset\n .usingType(TypeRegistrationShapeType)\n .write(indexUri)\n .fromSubject(`${indexUri}#${v4()}`);\n typeRegistration.type = { \"@id\": \"TypeRegistration\" };\n typeRegistration.forClass = { \"@id\": classUri };\n }\n return typeRegistration;\n}\n"],"mappings":"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"}
|
package/dist/util/Options.cjs
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
const __ldo_connected_solid = require_rolldown_runtime.__toESM(require("@ldo/connected-solid"));
|
|
3
|
-
|
|
1
|
+
let _ldo_connected_solid = require("@ldo/connected-solid");
|
|
4
2
|
//#region src/util/Options.ts
|
|
5
3
|
function guaranteeOptions(options) {
|
|
6
|
-
const fetch = (0,
|
|
7
|
-
const dataset = options?.solidLdoDataset ?? (0,
|
|
4
|
+
const fetch = (0, _ldo_connected_solid.guaranteeFetch)(options?.fetch);
|
|
5
|
+
const dataset = options?.solidLdoDataset ?? (0, _ldo_connected_solid.createSolidLdoDataset)();
|
|
8
6
|
dataset.setContext("solid", { fetch });
|
|
9
7
|
return {
|
|
10
8
|
fetch,
|
|
11
9
|
dataset
|
|
12
10
|
};
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
//#endregion
|
|
16
|
-
exports.guaranteeOptions = guaranteeOptions;
|
|
13
|
+
exports.guaranteeOptions = guaranteeOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Options.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"Options.d.cts","names":[],"sources":["../../src/util/Options.ts"],"mappings":";;;;UAKiB,OAAA;EACf,eAAA,GAAkB,oBAAA,CAAqB,oBAAA;EACvC,KAAA,UAAe,KAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Options.d.mts","names":[],"sources":["../../src/util/Options.ts"],"mappings":";;;;UAKiB,OAAA;EACf,eAAA,GAAkB,oBAAA,CAAqB,oBAAA;EACvC,KAAA,UAAe,KAAA;AAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createSolidLdoDataset, guaranteeFetch } from "@ldo/connected-solid";
|
|
2
|
-
|
|
3
2
|
//#region src/util/Options.ts
|
|
4
3
|
function guaranteeOptions(options) {
|
|
5
4
|
const fetch = guaranteeFetch(options?.fetch);
|
|
@@ -10,7 +9,7 @@ function guaranteeOptions(options) {
|
|
|
10
9
|
dataset
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
export { guaranteeOptions };
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=Options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Options.mjs","names":[],"sources":["../../src/util/Options.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ConnectedLdoDataset, IConnectedLdoDataset } from \"@ldo/connected\";\nimport type { SolidConnectedPlugin } from \"@ldo/connected-solid\";\nimport { createSolidLdoDataset, guaranteeFetch } from \"@ldo/connected-solid\";\n\nexport interface Options {\n solidLdoDataset?: IConnectedLdoDataset<SolidConnectedPlugin[]>;\n fetch?: typeof fetch;\n}\n\nexport function guaranteeOptions(options?: Options) {\n const fetch = guaranteeFetch(options?.fetch);\n const dataset = (options?.solidLdoDataset ??\n createSolidLdoDataset()) as ConnectedLdoDataset<SolidConnectedPlugin[]>;\n dataset.setContext(\"solid\", { fetch });\n return { fetch, dataset };\n}\n"],"mappings":";;AAUA,SAAgB,iBAAiB,SAAmB;CAClD,MAAM,QAAQ,eAAe,SAAS,MAAM;CAC5C,MAAM,UAAW,SAAS,mBACxB,uBAAuB;AACzB,SAAQ,WAAW,SAAS,EAAE,OAAO,CAAC;AACtC,QAAO;EAAE;EAAO;EAAS"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/solid-type-index",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.43",
|
|
4
4
|
"description": "Solid Type Index support for LDO",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.
|
|
8
|
-
"types": "./dist/index.d.
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": {
|
|
12
|
-
"types": "./dist/index.d.
|
|
13
|
-
"default": "./dist/index.
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
14
|
},
|
|
15
15
|
"require": {
|
|
16
16
|
"types": "./dist/index.d.cts",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"test": "vitest run --coverage",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
26
|
"build:ldo": "ldo build --input src/_shapes --output src/_ldo",
|
|
27
|
-
"lint": "eslint src/** --
|
|
27
|
+
"lint:check": "eslint src/** --no-error-on-unmatched-pattern",
|
|
28
|
+
"lint": "npm run lint:check -- --fix",
|
|
28
29
|
"remove-dist": "rimraf dist/"
|
|
29
30
|
},
|
|
30
31
|
"repository": {
|
|
@@ -38,17 +39,17 @@
|
|
|
38
39
|
},
|
|
39
40
|
"homepage": "https://github.com/o-development/ldo/tree/main/packages/solid-react#readme",
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@ldo/test-solid-server": "^1.0.0-alpha.
|
|
42
|
+
"@ldo/test-solid-server": "^1.0.0-alpha.43",
|
|
42
43
|
"@testing-library/react": "^14.1.2",
|
|
43
44
|
"start-server-and-test": "^2.0.3",
|
|
44
45
|
"ts-node": "^10.9.2"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@ldo/connected": "^1.0.0-alpha.
|
|
48
|
-
"@ldo/connected-solid": "^1.0.0-alpha.
|
|
49
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
50
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
51
|
-
"@ldo/solid-react": "^1.0.0-alpha.
|
|
48
|
+
"@ldo/connected": "^1.0.0-alpha.43",
|
|
49
|
+
"@ldo/connected-solid": "^1.0.0-alpha.43",
|
|
50
|
+
"@ldo/ldo": "^1.0.0-alpha.43",
|
|
51
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.43",
|
|
52
|
+
"@ldo/solid-react": "^1.0.0-alpha.43",
|
|
52
53
|
"@rdfjs/types": "^1.0.1"
|
|
53
54
|
},
|
|
54
55
|
"files": [
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"publishConfig": {
|
|
59
60
|
"access": "public"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "474cff455e7e3993747d8ecdd40d12e9b20b74f5"
|
|
62
63
|
}
|