@ldo/solid-react 0.0.1-alpha.14

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 (190) hide show
  1. package/README.md +13 -0
  2. package/dist/BrowserSolidLdoProvider.d.ts +2 -0
  3. package/dist/BrowserSolidLdoProvider.js +58 -0
  4. package/dist/BrowserSolidLdoProvider.js.map +1 -0
  5. package/dist/LdoContext.d.ts +9 -0
  6. package/dist/LdoContext.js +9 -0
  7. package/dist/LdoContext.js.map +1 -0
  8. package/dist/LdoProvider.d.ts +9 -0
  9. package/dist/LdoProvider.js +45 -0
  10. package/dist/LdoProvider.js.map +1 -0
  11. package/dist/SolidAuthContext.d.ts +14 -0
  12. package/dist/SolidAuthContext.js +10 -0
  13. package/dist/SolidAuthContext.js.map +1 -0
  14. package/dist/SolidAuthProvider.d.ts +17 -0
  15. package/dist/SolidAuthProvider.js +56 -0
  16. package/dist/SolidAuthProvider.js.map +1 -0
  17. package/dist/SolidLdoProvider.d.ts +8 -0
  18. package/dist/SolidLdoProvider.js +31 -0
  19. package/dist/SolidLdoProvider.js.map +1 -0
  20. package/dist/document/DocumentStore.d.ts +11 -0
  21. package/dist/document/DocumentStore.js +24 -0
  22. package/dist/document/DocumentStore.js.map +1 -0
  23. package/dist/document/FetchableDocument.d.ts +28 -0
  24. package/dist/document/FetchableDocument.js +75 -0
  25. package/dist/document/FetchableDocument.js.map +1 -0
  26. package/dist/document/accessRules/AccessRules.d.ts +19 -0
  27. package/dist/document/accessRules/AccessRules.js +53 -0
  28. package/dist/document/accessRules/AccessRules.js.map +1 -0
  29. package/dist/document/accessRules/AccessRulesStore.d.ts +10 -0
  30. package/dist/document/accessRules/AccessRulesStore.js +12 -0
  31. package/dist/document/accessRules/AccessRulesStore.js.map +1 -0
  32. package/dist/document/errors/DocumentError.d.ts +5 -0
  33. package/dist/document/errors/DocumentError.js +11 -0
  34. package/dist/document/errors/DocumentError.js.map +1 -0
  35. package/dist/document/errors/DocumentFetchError.d.ts +6 -0
  36. package/dist/document/errors/DocumentFetchError.js +12 -0
  37. package/dist/document/errors/DocumentFetchError.js.map +1 -0
  38. package/dist/document/resource/Resource.d.ts +23 -0
  39. package/dist/document/resource/Resource.js +48 -0
  40. package/dist/document/resource/Resource.js.map +1 -0
  41. package/dist/document/resource/binaryResource/BinaryResource.d.ts +7 -0
  42. package/dist/document/resource/binaryResource/BinaryResource.js +11 -0
  43. package/dist/document/resource/binaryResource/BinaryResource.js.map +1 -0
  44. package/dist/document/resource/binaryResource/BinaryResourceStore.d.ts +10 -0
  45. package/dist/document/resource/binaryResource/BinaryResourceStore.js +15 -0
  46. package/dist/document/resource/binaryResource/BinaryResourceStore.js.map +1 -0
  47. package/dist/document/resource/dataResource/DataResource.d.ts +20 -0
  48. package/dist/document/resource/dataResource/DataResource.js +81 -0
  49. package/dist/document/resource/dataResource/DataResource.js.map +1 -0
  50. package/dist/document/resource/dataResource/DataResourceStore.d.ts +10 -0
  51. package/dist/document/resource/dataResource/DataResourceStore.js +15 -0
  52. package/dist/document/resource/dataResource/DataResourceStore.js.map +1 -0
  53. package/dist/document/resource/dataResource/containerResource/ContainerResource.d.ts +20 -0
  54. package/dist/document/resource/dataResource/containerResource/ContainerResource.js +74 -0
  55. package/dist/document/resource/dataResource/containerResource/ContainerResource.js.map +1 -0
  56. package/dist/document/resource/dataResource/containerResource/ContainerResourceStore.d.ts +13 -0
  57. package/dist/document/resource/dataResource/containerResource/ContainerResourceStore.js +33 -0
  58. package/dist/document/resource/dataResource/containerResource/ContainerResourceStore.js.map +1 -0
  59. package/dist/documentHooks/useAccessRules.d.ts +3 -0
  60. package/dist/documentHooks/useAccessRules.js +16 -0
  61. package/dist/documentHooks/useAccessRules.js.map +1 -0
  62. package/dist/documentHooks/useBinaryResource.d.ts +2 -0
  63. package/dist/documentHooks/useBinaryResource.js +16 -0
  64. package/dist/documentHooks/useBinaryResource.js.map +1 -0
  65. package/dist/documentHooks/useContainerResource.d.ts +2 -0
  66. package/dist/documentHooks/useContainerResource.js +16 -0
  67. package/dist/documentHooks/useContainerResource.js.map +1 -0
  68. package/dist/documentHooks/useDataResource.d.ts +2 -0
  69. package/dist/documentHooks/useDataResource.js +16 -0
  70. package/dist/documentHooks/useDataResource.js.map +1 -0
  71. package/dist/documentHooks/useDocument.d.ts +5 -0
  72. package/dist/documentHooks/useDocument.js +20 -0
  73. package/dist/documentHooks/useDocument.js.map +1 -0
  74. package/dist/index.d.ts +6 -0
  75. package/dist/index.js +25 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/ldo/solid.context.d.ts +2 -0
  78. package/dist/ldo/solid.context.js +33 -0
  79. package/dist/ldo/solid.context.js.map +1 -0
  80. package/dist/ldo/solid.schema.d.ts +2 -0
  81. package/dist/ldo/solid.schema.js +211 -0
  82. package/dist/ldo/solid.schema.js.map +1 -0
  83. package/dist/ldo/solid.shapeTypes.d.ts +4 -0
  84. package/dist/ldo/solid.shapeTypes.js +16 -0
  85. package/dist/ldo/solid.shapeTypes.js.map +1 -0
  86. package/dist/ldo/solid.typings.d.ts +26 -0
  87. package/dist/ldo/solid.typings.js +3 -0
  88. package/dist/ldo/solid.typings.js.map +1 -0
  89. package/dist/ldoHooks/helpers/TrackingProxyContext.d.ts +10 -0
  90. package/dist/ldoHooks/helpers/TrackingProxyContext.js +68 -0
  91. package/dist/ldoHooks/helpers/TrackingProxyContext.js.map +1 -0
  92. package/dist/ldoHooks/helpers/UpdateManager.d.ts +12 -0
  93. package/dist/ldoHooks/helpers/UpdateManager.js +64 -0
  94. package/dist/ldoHooks/helpers/UpdateManager.js.map +1 -0
  95. package/dist/ldoHooks/useMatchingObjects.d.ts +0 -0
  96. package/dist/ldoHooks/useMatchingObjects.js +2 -0
  97. package/dist/ldoHooks/useMatchingObjects.js.map +1 -0
  98. package/dist/ldoHooks/useMatchingSubjects.d.ts +0 -0
  99. package/dist/ldoHooks/useMatchingSubjects.js +2 -0
  100. package/dist/ldoHooks/useMatchingSubjects.js.map +1 -0
  101. package/dist/ldoHooks/useSubject.d.ts +3 -0
  102. package/dist/ldoHooks/useSubject.js +38 -0
  103. package/dist/ldoHooks/useSubject.js.map +1 -0
  104. package/dist/old/LdoContext.d.ts +9 -0
  105. package/dist/old/LdoContext.js +9 -0
  106. package/dist/old/LdoContext.js.map +1 -0
  107. package/dist/old/LdoProvider.d.ts +9 -0
  108. package/dist/old/LdoProvider.js +41 -0
  109. package/dist/old/LdoProvider.js.map +1 -0
  110. package/dist/old/SolidAuthProvider.d.ts +3 -0
  111. package/dist/old/SolidAuthProvider.js +56 -0
  112. package/dist/old/SolidAuthProvider.js.map +1 -0
  113. package/dist/old/documentHooks/useAccessRules.d.ts +3 -0
  114. package/dist/old/documentHooks/useAccessRules.js +17 -0
  115. package/dist/old/documentHooks/useAccessRules.js.map +1 -0
  116. package/dist/old/documentHooks/useBinaryResource.d.ts +2 -0
  117. package/dist/old/documentHooks/useBinaryResource.js +11 -0
  118. package/dist/old/documentHooks/useBinaryResource.js.map +1 -0
  119. package/dist/old/documentHooks/useContainerResource.d.ts +2 -0
  120. package/dist/old/documentHooks/useContainerResource.js +11 -0
  121. package/dist/old/documentHooks/useContainerResource.js.map +1 -0
  122. package/dist/old/documentHooks/useDataResource.d.ts +2 -0
  123. package/dist/old/documentHooks/useDataResource.js +11 -0
  124. package/dist/old/documentHooks/useDataResource.js.map +1 -0
  125. package/dist/old/documentHooks/useDocument.d.ts +6 -0
  126. package/dist/old/documentHooks/useDocument.js +24 -0
  127. package/dist/old/documentHooks/useDocument.js.map +1 -0
  128. package/dist/old/ldoHooks/helpers/TrackingProxyContext.d.ts +10 -0
  129. package/dist/old/ldoHooks/helpers/TrackingProxyContext.js +68 -0
  130. package/dist/old/ldoHooks/helpers/TrackingProxyContext.js.map +1 -0
  131. package/dist/old/ldoHooks/helpers/UpdateManager.d.ts +9 -0
  132. package/dist/old/ldoHooks/helpers/UpdateManager.js +61 -0
  133. package/dist/old/ldoHooks/helpers/UpdateManager.js.map +1 -0
  134. package/dist/old/ldoHooks/useMatchingObjects.d.ts +0 -0
  135. package/dist/old/ldoHooks/useMatchingObjects.js +2 -0
  136. package/dist/old/ldoHooks/useMatchingObjects.js.map +1 -0
  137. package/dist/old/ldoHooks/useMatchingSubjects.d.ts +0 -0
  138. package/dist/old/ldoHooks/useMatchingSubjects.js +2 -0
  139. package/dist/old/ldoHooks/useMatchingSubjects.js.map +1 -0
  140. package/dist/old/ldoHooks/useSubject.d.ts +3 -0
  141. package/dist/old/ldoHooks/useSubject.js +38 -0
  142. package/dist/old/ldoHooks/useSubject.js.map +1 -0
  143. package/dist/old/useLdo.d.ts +18 -0
  144. package/dist/old/useLdo.js +46 -0
  145. package/dist/old/useLdo.js.map +1 -0
  146. package/dist/useLdo.d.ts +18 -0
  147. package/dist/useLdo.js +46 -0
  148. package/dist/useLdo.js.map +1 -0
  149. package/dist/useLdoMethods.d.ts +12 -0
  150. package/dist/useLdoMethods.js +34 -0
  151. package/dist/useLdoMethods.js.map +1 -0
  152. package/dist/useResource.d.ts +11 -0
  153. package/dist/useResource.js +48 -0
  154. package/dist/useResource.js.map +1 -0
  155. package/dist/useRootContainer.d.ts +2 -0
  156. package/dist/useRootContainer.js +23 -0
  157. package/dist/useRootContainer.js.map +1 -0
  158. package/dist/useSubject.d.ts +5 -0
  159. package/dist/useSubject.js +36 -0
  160. package/dist/useSubject.js.map +1 -0
  161. package/dist/util/TrackingProxyContext.d.ts +15 -0
  162. package/dist/util/TrackingProxyContext.js +74 -0
  163. package/dist/util/TrackingProxyContext.js.map +1 -0
  164. package/dist/util/changesToSparqlUpdate.d.ts +3 -0
  165. package/dist/util/changesToSparqlUpdate.js +26 -0
  166. package/dist/util/changesToSparqlUpdate.js.map +1 -0
  167. package/dist/util/createGlobalHook.d.ts +6 -0
  168. package/dist/util/createGlobalHook.js +18 -0
  169. package/dist/util/createGlobalHook.js.map +1 -0
  170. package/dist/util/createWrapperProxy.d.ts +2 -0
  171. package/dist/util/createWrapperProxy.js +8 -0
  172. package/dist/util/createWrapperProxy.js.map +1 -0
  173. package/dist/util/splitChangesByGraph.d.ts +6 -0
  174. package/dist/util/splitChangesByGraph.js +45 -0
  175. package/dist/util/splitChangesByGraph.js.map +1 -0
  176. package/dist/util/useForceReload.d.ts +1 -0
  177. package/dist/util/useForceReload.js +10 -0
  178. package/dist/util/useForceReload.js.map +1 -0
  179. package/package.json +51 -0
  180. package/src/BrowserSolidLdoProvider.tsx +91 -0
  181. package/src/SolidAuthContext.ts +26 -0
  182. package/src/SolidLdoProvider.tsx +55 -0
  183. package/src/index.ts +9 -0
  184. package/src/useLdoMethods.ts +92 -0
  185. package/src/useResource.ts +97 -0
  186. package/src/useRootContainer.ts +24 -0
  187. package/src/useSubject.ts +67 -0
  188. package/src/util/TrackingProxyContext.ts +99 -0
  189. package/src/util/createWrapperProxy.ts +7 -0
  190. package/src/util/useForceReload.ts +6 -0
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Solid-Dataset
2
+
3
+ Pre-alpha
4
+
5
+ ## Notes:
6
+ - Any quads in the default graph will not be synced to Solid Pods, but will be added to the dataset without any syncing
7
+
8
+
9
+ ## TODO:
10
+ - Create an event for each thing that happens. Like "Loaded"
11
+ - You should be able to initialize classes with loading = true so that there isn't a flash on initial load
12
+ - Access rule stuff just doesn't work. I might need to program a custom implementation for that
13
+ - There should probably be separate libraries for React native and Web React
@@ -0,0 +1,2 @@
1
+ import type { FunctionComponent, PropsWithChildren } from "react";
2
+ export declare const BrowserSolidLdoProvider: FunctionComponent<PropsWithChildren>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrowserSolidLdoProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const SolidAuthContext_1 = require("./SolidAuthContext");
7
+ const solid_client_authn_browser_1 = require("@inrupt/solid-client-authn-browser");
8
+ const SolidLdoProvider_1 = require("./SolidLdoProvider");
9
+ const PRE_REDIRECT_URI = "PRE_REDIRECT_URI";
10
+ const BrowserSolidLdoProvider = ({ children, }) => {
11
+ const [session, setSession] = (0, react_1.useState)((0, solid_client_authn_browser_1.getDefaultSession)().info);
12
+ const [ranInitialAuthCheck, setRanInitialAuthCheck] = (0, react_1.useState)(false);
13
+ const runInitialAuthCheck = (0, react_1.useCallback)(async () => {
14
+ if (!window.localStorage.getItem(PRE_REDIRECT_URI)) {
15
+ window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
16
+ }
17
+ await (0, solid_client_authn_browser_1.handleIncomingRedirect)({
18
+ restorePreviousSession: true,
19
+ });
20
+ setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
21
+ window.history.replaceState({}, "", window.localStorage.getItem(PRE_REDIRECT_URI));
22
+ window.localStorage.removeItem(PRE_REDIRECT_URI);
23
+ setRanInitialAuthCheck(true);
24
+ }, []);
25
+ const login = (0, react_1.useCallback)(async (issuer, options) => {
26
+ const fullOptions = {
27
+ redirectUrl: window.location.href,
28
+ clientName: "Solid App",
29
+ oidcIssuer: issuer,
30
+ ...options,
31
+ };
32
+ window.localStorage.setItem(PRE_REDIRECT_URI, fullOptions.redirectUrl);
33
+ await (0, solid_client_authn_browser_1.login)(fullOptions);
34
+ setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
35
+ }, []);
36
+ const logout = (0, react_1.useCallback)(async () => {
37
+ await (0, solid_client_authn_browser_1.logout)();
38
+ setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
39
+ }, []);
40
+ const signUp = (0, react_1.useCallback)(async (issuer, options) => {
41
+ return login(issuer, { ...options, prompt: "create" });
42
+ }, [login]);
43
+ (0, react_1.useEffect)(() => {
44
+ runInitialAuthCheck();
45
+ }, []);
46
+ const solidAuthFunctions = (0, react_1.useMemo)(() => ({
47
+ runInitialAuthCheck,
48
+ login,
49
+ logout,
50
+ signUp,
51
+ session,
52
+ ranInitialAuthCheck,
53
+ fetch: solid_client_authn_browser_1.fetch,
54
+ }), [login, logout, ranInitialAuthCheck, runInitialAuthCheck, session, signUp]);
55
+ return ((0, jsx_runtime_1.jsx)(SolidAuthContext_1.SolidAuthContext.Provider, { value: solidAuthFunctions, children: (0, jsx_runtime_1.jsx)(SolidLdoProvider_1.SolidLdoProvider, { children: children }) }));
56
+ };
57
+ exports.BrowserSolidLdoProvider = BrowserSolidLdoProvider;
58
+ //# sourceMappingURL=BrowserSolidLdoProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserSolidLdoProvider.js","sourceRoot":"","sources":["../src/BrowserSolidLdoProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyE;AAGzE,yDAAsD;AACtD,mFAM4C;AAC5C,yDAAsD;AAEtD,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAErC,MAAM,uBAAuB,GAAyC,CAAC,EAC5E,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAc,IAAA,8CAAiB,GAAE,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,mBAAmB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACjD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;YAClD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACrE;QAED,MAAM,IAAA,mDAAsB,EAAC;YAC3B,sBAAsB,EAAE,IAAI;SAC7B,CAAC,CAAC;QACH,UAAU,CAAC,EAAE,GAAG,IAAA,8CAAiB,GAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,YAAY,CACzB,EAAE,EACF,E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AE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,IAAA,eAAO,EAChC,GAAG,EAAE,CAAC,CAAC;QACL,mBAAmB;QACnB,KAAK;QACL,MAAM;QACN,MAAM;QACN,OAAO;QACP,mBAAmB;QACnB,KAAK,EAAE,kCAAY;KACpB,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAC3E,CAAC;IAEF,OAAO,CACL,uBAAC,mCAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,kBAAkB,YAClD,uBAAC,mCAAgB,cAAE,QAAQ,GAAoB,GACrB,CAC7B,CAAC;AACJ,CAAC,CAAC;AA3EW,QAAA,uBAAuB,2BA2ElC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import type { BinaryResourceStoreDependencies } from "./document/resource/binaryResource/BinaryResourceStore";
3
+ import type { DataResourceStoreDependencies } from "./document/resource/dataResource/DataResourceStore";
4
+ import type { AccessRulesStoreDependencies } from "./document/accessRules/AccessRulesStore";
5
+ import type { ContainerResourceStoreDependencies } from "./document/resource/dataResource/containerResource/ContainerResourceStore";
6
+ export interface LdoContextData extends BinaryResourceStoreDependencies, DataResourceStoreDependencies, AccessRulesStoreDependencies, ContainerResourceStoreDependencies {
7
+ }
8
+ export declare const LdoContextProvider: import("react").Provider<LdoContextData>;
9
+ export declare const useLdoContext: () => LdoContextData;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLdoContext = exports.LdoContextProvider = void 0;
4
+ const react_1 = require("react");
5
+ const LdoContext = (0, react_1.createContext)({});
6
+ exports.LdoContextProvider = LdoContext.Provider;
7
+ const useLdoContext = () => (0, react_1.useContext)(LdoContext);
8
+ exports.useLdoContext = useLdoContext;
9
+ //# sourceMappingURL=LdoContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LdoContext.js","sourceRoot":"","sources":["../src/LdoContext.ts"],"names":[],"mappings":";;;AAAA,iCAAkD;AAelD,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAiB,EAAE,CAAC,CAAC;AAExC,QAAA,kBAAkB,GAAG,UAAU,CAAC,QAAQ,CAAC;AAC/C,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;AAA7C,QAAA,aAAa,iBAAgC"}
@@ -0,0 +1,9 @@
1
+ import type { FunctionComponent, PropsWithChildren } from "react";
2
+ import type { LdoContextData } from "./LdoContext";
3
+ import type { Dataset } from "@rdfjs/types";
4
+ export interface LdoProviderProps extends PropsWithChildren {
5
+ fetch?: typeof fetch;
6
+ dataset?: Dataset;
7
+ onDocumentError?: LdoContextData["onDocumentError"];
8
+ }
9
+ export declare const LdoProvider: FunctionComponent<PropsWithChildren<LdoProviderProps>>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LdoProvider = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
10
+ const ldo_1 = require("@ldo/ldo");
11
+ const LdoContext_1 = require("./LdoContext");
12
+ const UpdateManager_1 = require("./ldoHooks/helpers/UpdateManager");
13
+ const BinaryResourceStore_1 = require("./document/resource/binaryResource/BinaryResourceStore");
14
+ const DataResourceStore_1 = require("./document/resource/dataResource/DataResourceStore");
15
+ const ContainerResourceStore_1 = require("./document/resource/dataResource/containerResource/ContainerResourceStore");
16
+ const AccessRulesStore_1 = require("./document/accessRules/AccessRulesStore");
17
+ const LdoProvider = ({ dataset, fetch, onDocumentError, children }) => {
18
+ const finalFetch = (0, react_1.useMemo)(() => fetch || cross_fetch_1.default, [fetch]);
19
+ const ldoDataset = (0, react_1.useMemo)(() => (0, ldo_1.createLdoDataset)(dataset), [dataset]);
20
+ const storeDependencies = (0, react_1.useMemo)(() => {
21
+ const dependencies = {
22
+ onDocumentError,
23
+ fetch: finalFetch,
24
+ dataset: ldoDataset,
25
+ updateManager: new UpdateManager_1.UpdateManager(),
26
+ };
27
+ const binaryResourceStore = new BinaryResourceStore_1.BinaryResourceStore(dependencies);
28
+ const dataResourceStore = new DataResourceStore_1.DataResourceStore(dependencies);
29
+ const containerResourceStore = new ContainerResourceStore_1.ContainerResourceStore(dependencies);
30
+ const accessRulesStore = new AccessRulesStore_1.AccessRulesStore(dependencies);
31
+ dependencies.binaryResourceStore = binaryResourceStore;
32
+ dependencies.dataResourceStore = dataResourceStore;
33
+ dependencies.containerResourceStore = containerResourceStore;
34
+ dependencies.accessRulesStore = accessRulesStore;
35
+ return dependencies;
36
+ }, []);
37
+ (0, react_1.useEffect)(() => {
38
+ storeDependencies.fetch = finalFetch;
39
+ storeDependencies.dataset = ldoDataset;
40
+ storeDependencies.onDocumentError = onDocumentError;
41
+ }, [finalFetch, ldoDataset, onDocumentError]);
42
+ return ((0, jsx_runtime_1.jsx)(LdoContext_1.LdoContextProvider, { value: storeDependencies, children: children }));
43
+ };
44
+ exports.LdoProvider = LdoProvider;
45
+ //# sourceMappingURL=LdoProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LdoProvider.js","sourceRoot":"","sources":["../src/LdoProvider.tsx"],"names":[],"mappings":";;;;;;;AACA,iCAAkD;AAClD,8DAAqC;AACrC,kCAA4C;AAE5C,6CAAkD;AAClD,oEAAiE;AACjE,gGAA6F;AAC7F,0FAAuF;AACvF,sHAAmH;AACnH,8EAA2E;AAYpE,MAAM,WAAW,GAEpB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,EAAE,EAAE;IACpD,MAAM,UAAU,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,KAAK,IAAI,qBAAU,EAAE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,eAwCtB"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { ISessionInfo, ILoginInputOptions } from "@inrupt/solid-client-authn-core";
3
+ export type SessionInfo = ISessionInfo;
4
+ export type LoginOptions = ILoginInputOptions;
5
+ export interface SolidAuthFunctions {
6
+ login: (issuer: string, loginOptions?: LoginOptions) => Promise<void>;
7
+ logout: () => Promise<void>;
8
+ signUp: (issuer: string, loginOptions?: LoginOptions) => Promise<void>;
9
+ fetch: typeof fetch;
10
+ session: SessionInfo;
11
+ ranInitialAuthCheck: boolean;
12
+ }
13
+ export declare const SolidAuthContext: import("react").Context<SolidAuthFunctions>;
14
+ export declare function useSolidAuth(): SolidAuthFunctions;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSolidAuth = exports.SolidAuthContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.SolidAuthContext = (0, react_1.createContext)(undefined);
6
+ function useSolidAuth() {
7
+ return (0, react_1.useContext)(exports.SolidAuthContext);
8
+ }
9
+ exports.useSolidAuth = useSolidAuth;
10
+ //# sourceMappingURL=SolidAuthContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolidAuthContext.js","sourceRoot":"","sources":["../src/SolidAuthContext.ts"],"names":[],"mappings":";;;AAIA,iCAAkD;AAiBrC,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAqB,SAAS,CAAC,CAAC;AAE7E,SAAgB,YAAY;IAC1B,OAAO,IAAA,kBAAU,EAAC,wBAAgB,CAAC,CAAC;AACtC,CAAC;AAFD,oCAEC"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import type { ISessionInfo } from "solid-authn-react-native";
3
+ interface AuthGlobalHookReturn {
4
+ runInitialAuthCheck: () => Promise<void>;
5
+ login: (issuer: string) => Promise<void>;
6
+ logout: () => Promise<void>;
7
+ signUp: (issuer: string) => Promise<void>;
8
+ fetch: typeof fetch;
9
+ session: ISessionInfo;
10
+ ranInitialAuthCheck: boolean;
11
+ }
12
+ export declare const SolidAuthContext: import("react").Context<AuthGlobalHookReturn>;
13
+ export declare const SolidAuthProvider: import("react").FunctionComponent<{
14
+ children?: import("react").ReactNode;
15
+ }>;
16
+ export declare const useSolidAuth: () => AuthGlobalHookReturn;
17
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSolidAuth = exports.SolidAuthProvider = exports.SolidAuthContext = void 0;
4
+ const react_1 = require("react");
5
+ const solid_authn_react_native_1 = require("solid-authn-react-native");
6
+ const createGlobalHook_1 = require("./util/createGlobalHook");
7
+ const PRE_REDIRECT_URI = "PRE_REDIRECT_URI";
8
+ function useAuthGlobalHookFunc() {
9
+ const [session, setSession] = (0, react_1.useState)((0, solid_authn_react_native_1.getDefaultSession)().info);
10
+ const [ranInitialAuthCheck, setRanInitialAuthCheck] = (0, react_1.useState)(false);
11
+ const runInitialAuthCheck = (0, react_1.useCallback)(async () => {
12
+ if (!window.localStorage.getItem(PRE_REDIRECT_URI)) {
13
+ window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
14
+ }
15
+ await (0, solid_authn_react_native_1.handleIncomingRedirect)({
16
+ restorePreviousSession: true,
17
+ });
18
+ setSession({ ...(0, solid_authn_react_native_1.getDefaultSession)().info });
19
+ window.history.replaceState({}, "", window.localStorage.getItem(PRE_REDIRECT_URI));
20
+ window.localStorage.removeItem(PRE_REDIRECT_URI);
21
+ setRanInitialAuthCheck(true);
22
+ }, []);
23
+ const login = (0, react_1.useCallback)(async (issuer, clientName = "Solid App") => {
24
+ window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
25
+ await (0, solid_authn_react_native_1.login)({
26
+ oidcIssuer: issuer,
27
+ redirectUrl: window.location.href,
28
+ clientName,
29
+ });
30
+ setSession({ ...(0, solid_authn_react_native_1.getDefaultSession)().info });
31
+ }, []);
32
+ const logout = (0, react_1.useCallback)(async () => {
33
+ await (0, solid_authn_react_native_1.logout)();
34
+ setSession({ ...(0, solid_authn_react_native_1.getDefaultSession)().info });
35
+ }, []);
36
+ const signUp = (0, react_1.useCallback)(async (issuer) => {
37
+ console.log(`Signup Pressed with issuer ${issuer}`);
38
+ }, []);
39
+ (0, react_1.useEffect)(() => {
40
+ runInitialAuthCheck();
41
+ }, []);
42
+ return (0, react_1.useMemo)(() => ({
43
+ runInitialAuthCheck,
44
+ login,
45
+ logout,
46
+ signUp,
47
+ session,
48
+ ranInitialAuthCheck,
49
+ fetch: solid_authn_react_native_1.fetch,
50
+ }), [login, logout, ranInitialAuthCheck, runInitialAuthCheck, session, signUp]);
51
+ }
52
+ const authGlobalHook = (0, createGlobalHook_1.createGlobalHook)(useAuthGlobalHookFunc);
53
+ exports.SolidAuthContext = authGlobalHook.Context;
54
+ exports.SolidAuthProvider = authGlobalHook.Provider;
55
+ exports.useSolidAuth = authGlobalHook.useGlobal;
56
+ //# sourceMappingURL=SolidAuthProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolidAuthProvider.js","sourceRoot":"","sources":["../src/SolidAuthProvider.ts"],"names":[],"mappings":";;;AAAA,iCAAkE;AAElE,uEAMkC;AAElC,8DAA2D;AAE3D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAY5C,SAAS,qBAAqB;IAC5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EACpC,IAAA,4CAAiB,GAAE,CAAC,IAAI,CACzB,CAAC;IACF,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,mBAAmB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAEjD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;YAClD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE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G,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,mBAAmB,EAAE,CAAC;IACxB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,CAAC;QACL,mBAAmB;QACnB,KAAK;QACL,MAAM;QACN,MAAM;QACN,OAAO;QACP,mBAAmB;QACnB,KAAK,EAAE,gCAAY;KACpB,CAAC,EACF,CAAC,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,IAAA,mCAAgB,EAAC,qBAAqB,CAAC,CAAC;AAElD,QAAA,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC;AAC1C,QAAA,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC;AAC5C,QAAA,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { type FunctionComponent, type PropsWithChildren } from "react";
3
+ import type { UseLdoMethods } from "./useLdoMethods";
4
+ export declare const SolidLdoReactContext: React.Context<UseLdoMethods>;
5
+ export declare function useLdo(): UseLdoMethods;
6
+ export interface SolidLdoProviderProps extends PropsWithChildren {
7
+ }
8
+ export declare const SolidLdoProvider: FunctionComponent<SolidLdoProviderProps>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolidLdoProvider = exports.useLdo = exports.SolidLdoReactContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_2 = require("react");
7
+ const SolidAuthContext_1 = require("./SolidAuthContext");
8
+ const solid_1 = require("@ldo/solid");
9
+ const useLdoMethods_1 = require("./useLdoMethods");
10
+ exports.SolidLdoReactContext = (0, react_1.createContext)(undefined);
11
+ function useLdo() {
12
+ return (0, react_1.useContext)(exports.SolidLdoReactContext);
13
+ }
14
+ exports.useLdo = useLdo;
15
+ const SolidLdoProvider = ({ children, }) => {
16
+ const { fetch } = (0, SolidAuthContext_1.useSolidAuth)();
17
+ const solidLdoDataset = (0, react_2.useMemo)(() => {
18
+ const ldoDataset = (0, solid_1.createSolidLdoDataset)({
19
+ fetch,
20
+ });
21
+ ldoDataset.setMaxListeners(1000);
22
+ return ldoDataset;
23
+ }, []);
24
+ (0, react_2.useEffect)(() => {
25
+ solidLdoDataset.context.fetch = fetch;
26
+ }, [fetch]);
27
+ const value = (0, react_2.useMemo)(() => (0, useLdoMethods_1.createUseLdoMethods)(solidLdoDataset), [solidLdoDataset]);
28
+ return ((0, jsx_runtime_1.jsx)(exports.SolidLdoReactContext.Provider, { value: value, children: children }));
29
+ };
30
+ exports.SolidLdoProvider = SolidLdoProvider;
31
+ //# sourceMappingURL=SolidLdoProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolidLdoProvider.js","sourceRoot":"","sources":["../src/SolidLdoProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyD;AACzD,iCAKe;AACf,yDAAkD;AAElD,sCAAmD;AAEnD,mDAAsD;AAEzC,QAAA,oBAAoB,GAI/B,IAAA,qBAAa,EAAgB,SAAS,CAAC,CAAC;AAE1C,SAAgB,MAAM;IACpB,OAAO,IAAA,kBAAU,EAAC,4BAAoB,CAAC,CAAC;AAC1C,CAAC;AAFD,wBAEC;AAIM,MAAM,gBAAgB,GAA6C,CAAC,EACzE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,+BAAY,GAAE,CAAC;IAGjC,MAAM,eAAe,GAAoB,IAAA,eAAO,EAAC,GAAG,EAAE;QACpD,MAAM,UAAU,GAAG,IAAA,6BAAqB,EAAC;YACvC,KAAK;SACN,CAAC,CAAC;QACH,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACxC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,KAAK,GAAkB,IAAA,eAAO,EAClC,GAAG,EAAE,CAAC,IAAA,mCAAmB,EAAC,eAAe,CAAC,EAC1C,CAAC,eAAe,CAAC,CAClB,CAAC;IAEF,OAAO,CACL,uBAAC,4BAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACxC,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B"}
@@ -0,0 +1,11 @@
1
+ import type { FetchableDocument } from "./FetchableDocument";
2
+ export interface DocumentStoreDependencies {
3
+ }
4
+ export declare abstract class DocumentStore<DocumentType extends FetchableDocument, Initializer, Dependencies extends DocumentStoreDependencies> {
5
+ protected documentMap: Map<Initializer, DocumentType>;
6
+ protected dependencies: Dependencies;
7
+ constructor(dependencies: Dependencies);
8
+ get(initializerInput: Initializer): DocumentType;
9
+ protected abstract create(initializer: Initializer): DocumentType;
10
+ protected normalizeInitializer(initializer: Initializer): Initializer;
11
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentStore = void 0;
4
+ class DocumentStore {
5
+ constructor(dependencies) {
6
+ this.documentMap = new Map();
7
+ this.dependencies = dependencies;
8
+ }
9
+ get(initializerInput) {
10
+ const initializer = this.normalizeInitializer(initializerInput);
11
+ const document = this.documentMap.get(initializer);
12
+ if (document) {
13
+ return document;
14
+ }
15
+ const newDocument = this.create(initializer);
16
+ this.documentMap.set(initializer, newDocument);
17
+ return newDocument;
18
+ }
19
+ normalizeInitializer(initializer) {
20
+ return initializer;
21
+ }
22
+ }
23
+ exports.DocumentStore = DocumentStore;
24
+ //# sourceMappingURL=DocumentStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentStore.js","sourceRoot":"","sources":["../../src/document/DocumentStore.ts"],"names":[],"mappings":";;;AAMA,MAAsB,aAAa;IAQjC,YAAY,YAA0B;QACpC,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,gBAA6B;QAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACnD,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC/C,OAAO,WAAW,CAAC;IACrB,CAAC;IAIS,oBAAoB,CAAC,WAAwB;QACrD,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA7BD,sCA6BC"}
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from "events";
3
+ import type { DocumentError } from "./errors/DocumentError";
4
+ export interface FetchableDocumentDependencies {
5
+ onDocumentError?: (error: DocumentError) => void;
6
+ }
7
+ export declare abstract class FetchableDocument extends EventEmitter {
8
+ protected _isLoading: boolean;
9
+ protected _isWriting: boolean;
10
+ protected _didInitialFetch: boolean;
11
+ protected _error?: DocumentError;
12
+ private dependencies;
13
+ constructor(dependencies: FetchableDocumentDependencies);
14
+ get isLoading(): boolean;
15
+ get didInitialFetch(): boolean;
16
+ get error(): DocumentError | undefined;
17
+ get isWriting(): boolean;
18
+ protected get onDocumentError(): any;
19
+ read(): Promise<void>;
20
+ reload(): Promise<void>;
21
+ protected abstract fetchDocument(): Promise<DocumentError | undefined>;
22
+ protected beginWrite(): void;
23
+ protected endWrite(error?: DocumentError): void;
24
+ setError(error: DocumentError): void;
25
+ protected emitStateUpdate(): void;
26
+ onStateUpdate(callback: () => void): void;
27
+ offStateUpdate(callback: () => void): void;
28
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FetchableDocument = void 0;
7
+ const events_1 = __importDefault(require("events"));
8
+ const STATE_UPDATE = "stateUpdate";
9
+ class FetchableDocument extends events_1.default {
10
+ constructor(dependencies) {
11
+ super();
12
+ this._isLoading = false;
13
+ this._isWriting = false;
14
+ this._didInitialFetch = false;
15
+ this.dependencies = dependencies;
16
+ }
17
+ get isLoading() {
18
+ return this._isLoading;
19
+ }
20
+ get didInitialFetch() {
21
+ return this._didInitialFetch;
22
+ }
23
+ get error() {
24
+ return this._error;
25
+ }
26
+ get isWriting() {
27
+ return this._isWriting;
28
+ }
29
+ get onDocumentError() {
30
+ return this.dependencies.onDocumentError;
31
+ }
32
+ async read() {
33
+ this._isLoading = true;
34
+ this.emitStateUpdate();
35
+ const documentError = await this.fetchDocument();
36
+ this._isLoading = false;
37
+ this._didInitialFetch = true;
38
+ if (documentError) {
39
+ this.setError(documentError);
40
+ }
41
+ this.emitStateUpdate();
42
+ }
43
+ async reload() {
44
+ return this.read();
45
+ }
46
+ beginWrite() {
47
+ this._isWriting = true;
48
+ this.emitStateUpdate();
49
+ }
50
+ endWrite(error) {
51
+ if (error) {
52
+ this.setError(error);
53
+ }
54
+ this._isWriting = false;
55
+ this.emitStateUpdate();
56
+ }
57
+ setError(error) {
58
+ this._error = error;
59
+ this.emitStateUpdate();
60
+ if (this.onDocumentError) {
61
+ this.onDocumentError(error);
62
+ }
63
+ }
64
+ emitStateUpdate() {
65
+ this.emit(STATE_UPDATE);
66
+ }
67
+ onStateUpdate(callback) {
68
+ this.on(STATE_UPDATE, callback);
69
+ }
70
+ offStateUpdate(callback) {
71
+ this.off(STATE_UPDATE, callback);
72
+ }
73
+ }
74
+ exports.FetchableDocument = FetchableDocument;
75
+ //# sourceMappingURL=FetchableDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchableDocument.js","sourceRoot":"","sources":["../../src/document/FetchableDocument.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAkC;AAOlC,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC,MAAsB,iBAAkB,SAAQ,gBAAY;IAO1D,YAAY,YAA2C;QACrD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAMD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAc,eAAe;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC;IAC3C,CAAC;IAOD,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SAC9B;QACD,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAIS,UAAU;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAES,QAAQ,CAAC,KAAqB;QACtC,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACtB;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,QAAQ,CAAC,KAAoB;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;SAC7B;IACH,CAAC;IAKS,eAAe;QACvB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,QAAoB;QAChC,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,cAAc,CAAC,QAAoB;QACjC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAjGD,8CAiGC"}
@@ -0,0 +1,19 @@
1
+ import type { AccessModes as IAccessModes } from "@inrupt/solid-client";
2
+ import type { FetchableDocumentDependencies } from "../FetchableDocument";
3
+ import { FetchableDocument } from "../FetchableDocument";
4
+ import type { Resource } from "../resource/Resource";
5
+ export type AccessModes = IAccessModes;
6
+ export interface AccessRulesDependencies extends FetchableDocumentDependencies {
7
+ fetch: typeof fetch;
8
+ }
9
+ export declare class AccessRules extends FetchableDocument {
10
+ readonly resource: Resource;
11
+ private _publicAccess;
12
+ private _agentAccess;
13
+ private dependencies0;
14
+ constructor(resource: Resource, dependencies: AccessRulesDependencies);
15
+ get publicAccess(): IAccessModes | null;
16
+ get agentAccess(): Record<string, IAccessModes> | null;
17
+ protected get fetch(): any;
18
+ protected fetchDocument(): Promise<undefined>;
19
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessRules = void 0;
4
+ const solid_client_1 = require("@inrupt/solid-client");
5
+ const FetchableDocument_1 = require("../FetchableDocument");
6
+ const DocumentError_1 = require("../errors/DocumentError");
7
+ class AccessRules extends FetchableDocument_1.FetchableDocument {
8
+ constructor(resource, dependencies) {
9
+ super(dependencies);
10
+ this._publicAccess = null;
11
+ this._agentAccess = null;
12
+ this.dependencies0 = dependencies;
13
+ this.resource = resource;
14
+ }
15
+ get publicAccess() {
16
+ return this._publicAccess;
17
+ }
18
+ get agentAccess() {
19
+ return this._agentAccess;
20
+ }
21
+ get fetch() {
22
+ return this.dependencies0.fetch;
23
+ }
24
+ async fetchDocument() {
25
+ try {
26
+ const [publicAccess, agentAccess] = await Promise.all([
27
+ solid_client_1.universalAccess.getPublicAccess(this.resource.uri, {
28
+ fetch: this.fetch,
29
+ }),
30
+ solid_client_1.universalAccess.getAgentAccessAll(this.resource.uri, {
31
+ fetch: this.fetch,
32
+ }),
33
+ ]);
34
+ this._publicAccess = publicAccess || {
35
+ read: false,
36
+ write: false,
37
+ append: false,
38
+ controlRead: false,
39
+ controlWrite: false,
40
+ };
41
+ this._agentAccess = agentAccess || {};
42
+ return undefined;
43
+ }
44
+ catch (err) {
45
+ if (typeof err === "object" && err.message) {
46
+ this.setError(new DocumentError_1.DocumentError(this, err.message));
47
+ }
48
+ this.setError(new DocumentError_1.DocumentError(this, "Error Fetching Access Rules"));
49
+ }
50
+ }
51
+ }
52
+ exports.AccessRules = AccessRules;
53
+ //# sourceMappingURL=AccessRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessRules.js","sourceRoot":"","sources":["../../../src/document/accessRules/AccessRules.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AAEvD,4DAAyD;AAEzD,2DAAwD;AAQxD,MAAa,WAAY,SAAQ,qCAAiB;IAMhD,YAAY,QAAkB,EAAE,YAAqC;QACnE,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAOD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IAClC,CAAC;IAOS,KAAK,CAAC,aAAa;QAC3B,IAAI;YACF,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACpD,8BAAe,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;oBACjD,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC;gBACF,8BAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;oBACnD,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC;aACH,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,GAAG,YAAY,IAAI;gBACnC,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,KAAK;gBACb,WAAW,EAAE,KAAK;gBAClB,YAAY,EAAE,KAAK;aACpB,CAAC;YACF,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC;SAClB;QAAC,OAAO,GAAY,EAAE;YACrB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAK,GAAa,CAAC,OAAO,EAAE;gBACrD,IAAI,CAAC,QAAQ,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC,CAAC;aAChE;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC,CAAC;SACvE;IACH,CAAC;CACF;AA9DD,kCA8DC"}
@@ -0,0 +1,10 @@
1
+ import type { DocumentStoreDependencies } from "../DocumentStore";
2
+ import { DocumentStore } from "../DocumentStore";
3
+ import type { Resource } from "../resource/Resource";
4
+ import type { AccessRulesDependencies } from "./AccessRules";
5
+ import { AccessRules } from "./AccessRules";
6
+ export interface AccessRulesStoreDependencies extends DocumentStoreDependencies, AccessRulesDependencies {
7
+ }
8
+ export declare class AccessRulesStore extends DocumentStore<AccessRules, Resource, AccessRulesStoreDependencies> {
9
+ create(initializer: Resource): AccessRules;
10
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessRulesStore = void 0;
4
+ const DocumentStore_1 = require("../DocumentStore");
5
+ const AccessRules_1 = require("./AccessRules");
6
+ class AccessRulesStore extends DocumentStore_1.DocumentStore {
7
+ create(initializer) {
8
+ return new AccessRules_1.AccessRules(initializer, this.dependencies);
9
+ }
10
+ }
11
+ exports.AccessRulesStore = AccessRulesStore;
12
+ //# sourceMappingURL=AccessRulesStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessRulesStore.js","sourceRoot":"","sources":["../../../src/document/accessRules/AccessRulesStore.ts"],"names":[],"mappings":";;;AACA,oDAAiD;AAGjD,+CAA4C;AAM5C,MAAa,gBAAiB,SAAQ,6BAIrC;IACC,MAAM,CAAC,WAAqB;QAC1B,OAAO,IAAI,yBAAW,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;CACF;AARD,4CAQC"}
@@ -0,0 +1,5 @@
1
+ import type { FetchableDocument } from "../FetchableDocument";
2
+ export declare class DocumentError extends Error {
3
+ readonly document: FetchableDocument;
4
+ constructor(document: FetchableDocument, message: string);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentError = void 0;
4
+ class DocumentError extends Error {
5
+ constructor(document, message) {
6
+ super(message);
7
+ this.document = document;
8
+ }
9
+ }
10
+ exports.DocumentError = DocumentError;
11
+ //# sourceMappingURL=DocumentError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentError.js","sourceRoot":"","sources":["../../../src/document/errors/DocumentError.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAGtC,YAAY,QAA2B,EAAE,OAAe;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAPD,sCAOC"}
@@ -0,0 +1,6 @@
1
+ import type { FetchableDocument } from "../FetchableDocument";
2
+ import { DocumentError } from "./DocumentError";
3
+ export declare class DocumentFetchError extends DocumentError {
4
+ readonly status: number;
5
+ constructor(document: FetchableDocument, status: number, message: string);
6
+ }