solid-logic 1.3.17-615b75c1 → 1.3.17-6e0634d8

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 (127) hide show
  1. package/README.md +2 -2
  2. package/jest.config.js +1 -1
  3. package/lib/acl/aclLogic.d.ts +3 -30
  4. package/lib/acl/aclLogic.d.ts.map +1 -1
  5. package/lib/acl/aclLogic.js +150 -119
  6. package/lib/acl/aclLogic.js.map +1 -1
  7. package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
  8. package/lib/authn/SolidAuthnLogic.js +2 -2
  9. package/lib/authn/SolidAuthnLogic.js.map +1 -1
  10. package/lib/chat/chatLogic.d.ts +3 -0
  11. package/lib/chat/chatLogic.d.ts.map +1 -0
  12. package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -86
  13. package/lib/chat/chatLogic.js.map +1 -0
  14. package/lib/inbox/inboxLogic.d.ts +3 -0
  15. package/lib/inbox/inboxLogic.d.ts.map +1 -0
  16. package/lib/inbox/{InboxLogic.js → inboxLogic.js} +59 -64
  17. package/lib/inbox/inboxLogic.js.map +1 -0
  18. package/lib/index.d.ts +6 -11
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +5 -25
  21. package/lib/index.js.map +1 -1
  22. package/lib/issuer/issuerLogic.js +1 -1
  23. package/lib/issuer/issuerLogic.js.map +1 -1
  24. package/lib/logic/CustomError.d.ts +4 -0
  25. package/lib/logic/CustomError.d.ts.map +1 -1
  26. package/lib/logic/CustomError.js +17 -1
  27. package/lib/logic/CustomError.js.map +1 -1
  28. package/lib/logic/solidLogic.d.ts +6 -0
  29. package/lib/logic/solidLogic.d.ts.map +1 -0
  30. package/lib/logic/solidLogic.js +92 -0
  31. package/lib/logic/solidLogic.js.map +1 -0
  32. package/lib/logic/solidLogicSingleton.d.ts +1 -2
  33. package/lib/logic/solidLogicSingleton.d.ts.map +1 -1
  34. package/lib/logic/solidLogicSingleton.js +3 -3
  35. package/lib/logic/solidLogicSingleton.js.map +1 -1
  36. package/lib/profile/profileLogic.d.ts +3 -0
  37. package/lib/profile/profileLogic.d.ts.map +1 -0
  38. package/lib/profile/profileLogic.js +246 -0
  39. package/lib/profile/profileLogic.js.map +1 -0
  40. package/lib/typeIndex/typeIndexLogic.d.ts +2 -21
  41. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  42. package/lib/typeIndex/typeIndexLogic.js +304 -296
  43. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  44. package/lib/types.d.ts +82 -1
  45. package/lib/types.d.ts.map +1 -1
  46. package/lib/util/containerLogic.d.ts +11 -0
  47. package/lib/util/containerLogic.d.ts.map +1 -0
  48. package/lib/{profile/ProfileLogic.js → util/containerLogic.js} +51 -44
  49. package/lib/util/containerLogic.js.map +1 -0
  50. package/lib/util/ns.d.ts +2 -0
  51. package/lib/util/ns.d.ts.map +1 -0
  52. package/lib/util/ns.js +34 -0
  53. package/lib/util/ns.js.map +1 -0
  54. package/lib/util/utilityLogic.d.ts +15 -0
  55. package/lib/util/utilityLogic.d.ts.map +1 -0
  56. package/lib/util/utilityLogic.js +274 -0
  57. package/lib/util/utilityLogic.js.map +1 -0
  58. package/lib/util/utils.d.ts +8 -0
  59. package/lib/util/utils.d.ts.map +1 -0
  60. package/lib/util/utils.js +48 -0
  61. package/lib/util/utils.js.map +1 -0
  62. package/package.json +5 -1
  63. package/src/acl/aclLogic.ts +136 -118
  64. package/src/authn/SolidAuthnLogic.ts +3 -2
  65. package/src/chat/chatLogic.ts +225 -0
  66. package/src/inbox/inboxLogic.ts +58 -0
  67. package/src/index.ts +11 -29
  68. package/src/issuer/issuerLogic.ts +1 -1
  69. package/src/logic/CustomError.ts +5 -1
  70. package/src/logic/solidLogic.ts +75 -0
  71. package/src/logic/solidLogicSingleton.ts +3 -3
  72. package/src/profile/profileLogic.ts +126 -0
  73. package/src/typeIndex/typeIndexLogic.ts +175 -182
  74. package/src/types.ts +83 -4
  75. package/src/util/containerLogic.ts +53 -0
  76. package/src/util/ns.ts +5 -0
  77. package/src/util/utilityLogic.ts +156 -0
  78. package/src/util/utils.ts +52 -0
  79. package/test/aclLogic.test.ts +13 -4
  80. package/test/chatLogic.test.ts +70 -71
  81. package/test/container.test.ts +57 -0
  82. package/test/helpers/dataSetup.ts +134 -0
  83. package/test/helpers/setup.ts +1 -0
  84. package/test/inboxLogic.test.ts +40 -38
  85. package/test/logic.test.ts +10 -9
  86. package/test/profileLogic.test.ts +246 -0
  87. package/test/typeIndexLogic.test.ts +487 -30
  88. package/test/utilityLogic.test.ts +172 -126
  89. package/test/utils.test.ts +32 -0
  90. package/lib/chat/ChatLogic.d.ts +0 -26
  91. package/lib/chat/ChatLogic.d.ts.map +0 -1
  92. package/lib/chat/ChatLogic.js.map +0 -1
  93. package/lib/chat/determineChatContainer.d.ts +0 -3
  94. package/lib/chat/determineChatContainer.d.ts.map +0 -1
  95. package/lib/chat/determineChatContainer.js +0 -12
  96. package/lib/chat/determineChatContainer.js.map +0 -1
  97. package/lib/discovery/discoveryLogic.d.ts +0 -40
  98. package/lib/discovery/discoveryLogic.d.ts.map +0 -1
  99. package/lib/discovery/discoveryLogic.js +0 -494
  100. package/lib/discovery/discoveryLogic.js.map +0 -1
  101. package/lib/inbox/InboxLogic.d.ts +0 -18
  102. package/lib/inbox/InboxLogic.d.ts.map +0 -1
  103. package/lib/inbox/InboxLogic.js.map +0 -1
  104. package/lib/logic/SolidLogic.d.ts +0 -48
  105. package/lib/logic/SolidLogic.d.ts.map +0 -1
  106. package/lib/logic/SolidLogic.js +0 -321
  107. package/lib/logic/SolidLogic.js.map +0 -1
  108. package/lib/profile/ProfileLogic.d.ts +0 -13
  109. package/lib/profile/ProfileLogic.d.ts.map +0 -1
  110. package/lib/profile/ProfileLogic.js.map +0 -1
  111. package/lib/util/UtilityLogic.d.ts +0 -33
  112. package/lib/util/UtilityLogic.d.ts.map +0 -1
  113. package/lib/util/UtilityLogic.js +0 -240
  114. package/lib/util/UtilityLogic.js.map +0 -1
  115. package/lib/util/uri.d.ts +0 -3
  116. package/lib/util/uri.d.ts.map +0 -1
  117. package/lib/util/uri.js +0 -9
  118. package/lib/util/uri.js.map +0 -1
  119. package/src/chat/ChatLogic.ts +0 -244
  120. package/src/chat/determineChatContainer.ts +0 -14
  121. package/src/discovery/discoveryLogic.ts +0 -311
  122. package/src/inbox/InboxLogic.ts +0 -66
  123. package/src/logic/SolidLogic.ts +0 -262
  124. package/src/profile/ProfileLogic.ts +0 -44
  125. package/src/util/UtilityLogic.ts +0 -161
  126. package/src/util/uri.ts +0 -5
  127. package/test/discoveryLogic.test.ts +0 -740
@@ -1,262 +0,0 @@
1
- import { Session } from "@inrupt/solid-client-authn-browser";
2
- import * as rdf from "rdflib";
3
- import { NamedNode, Statement, LiveStore } from "rdflib";
4
- import solidNamespace from "solid-namespace";
5
- import { SolidAuthnLogic } from "../authn/SolidAuthnLogic";
6
- import { ChatLogic } from "../chat/ChatLogic";
7
- import { ProfileLogic } from "../profile/ProfileLogic";
8
- import { AuthnLogic, SolidNamespace } from "../types";
9
- import * as debug from "../util/debug";
10
- import { UtilityLogic } from "../util/UtilityLogic";
11
- import { CrossOriginForbiddenError, FetchError, NotFoundError, SameOriginForbiddenError, UnauthorizedError } from "./CustomError";
12
- /*
13
- ** It is important to distinquish `fetch`, a function provided by the browser
14
- ** and `Fetcher`, a helper object for the rdflib Store which turns it
15
- ** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
16
- ** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
17
- */
18
-
19
- const ns: SolidNamespace = solidNamespace(rdf);
20
-
21
- export class SolidLogic {
22
- cache: {
23
- profileDocument: {
24
- [WebID: string]: NamedNode;
25
- };
26
- preferencesFile: {
27
- [WebID: string]: NamedNode;
28
- };
29
- };
30
-
31
- store: LiveStore;
32
- me: string | undefined;
33
- underlyingFetch: { fetch: (url: string, options?: any) => any };
34
-
35
- chat: ChatLogic;
36
- profile: ProfileLogic;
37
- authn: AuthnLogic;
38
- util: UtilityLogic;
39
-
40
- constructor(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: Session) {
41
- // would xpect to be able to do it this way: but get TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation status: 999
42
- // this.store = new rdf.LiveStore({})
43
- // this.store.fetcher._fetch = fetch
44
- console.log("SolidLogic: Unique instance created. There should only be one of these.")
45
- this.store = rdf.graph() as LiveStore; // Make a Quad store
46
- rdf.fetcher(this.store, { fetch: specialFetch.fetch}); // Attach a web I/O module, store.fetcher
47
- this.store.updater = new rdf.UpdateManager(this.store); // Add real-time live updates store.updater
48
-
49
- this.store.features = [] // disable automatic node merging on store load
50
- this.cache = {
51
- profileDocument: {},
52
- preferencesFile: {},
53
- };
54
- this.underlyingFetch = { fetch: fetch }; // Note global one not the one passed
55
- this.authn = new SolidAuthnLogic(session);
56
- debug.log('SolidAuthnLogic initialized')
57
- this.profile = new ProfileLogic(this.store, ns, this.authn);
58
- this.chat = new ChatLogic(this.store, ns, this.profile);
59
- this.util = new UtilityLogic(this.store, ns, this.underlyingFetch);
60
- }
61
-
62
- findAclDocUrl(url: string) {
63
- return this.util.findAclDocUrl(url);
64
- }
65
-
66
- async loadProfile(me: NamedNode): Promise<NamedNode> {
67
- /*
68
- // console.log('loadProfile cache ', this.cache)
69
- if (this.cache.profileDocument[me.value]) {
70
- return this.cache.profileDocument[me.value];
71
- } @@ just use the cache in the store
72
- */
73
- console.log('loadProfile me ', me)
74
- const profileDocument = me.doc()
75
- try {
76
- await this.store.fetcher.load(profileDocument);
77
- return profileDocument;
78
- } catch (err) {
79
- const message = `Cannot load profile ${profileDocument} : ${err}`;
80
- throw new Error(message);
81
- }
82
- }
83
-
84
- async loadPreferences(me: NamedNode): Promise<NamedNode> {
85
- console.log('loadPreferences cache ', this.cache)
86
- if (this.cache.preferencesFile[me.value]) {
87
- return this.cache.preferencesFile[me.value];
88
- }
89
- await this.loadProfile(me) // Load pointer to pref file
90
- const preferencesFile = this.store.any(me, ns.space('preferencesFile'), null, me.doc());
91
-
92
- // console.log('this.store.any()', this.store.any())
93
- /**
94
- * Are we working cross-origin?
95
- * Returns True if we are in a webapp at an origin, and the file origin is different
96
- */
97
- function differentOrigin(): boolean {
98
- if (!preferencesFile) {
99
- return true;
100
- }
101
- return (
102
- `${window.location.origin}/` !== new URL(preferencesFile.value).origin
103
- );
104
- }
105
-
106
- if (!preferencesFile) {
107
- throw new Error(
108
- `Can't find a preference file pointer in profile ${me.doc()}`
109
- );
110
- }
111
-
112
- // //// Load preference file
113
- try {
114
- await this.store.fetcher.load(preferencesFile as NamedNode, {
115
- withCredentials: true,
116
- });
117
- } catch (err) {
118
- // Really important to look at why
119
- const status = err.status;
120
- debug.log(`HTTP status ${status} for preference file ${preferencesFile}`);
121
- if (status === 401) {
122
- throw new UnauthorizedError();
123
- }
124
- if (status === 403) {
125
- if (differentOrigin()) {
126
- throw new CrossOriginForbiddenError();
127
- }
128
- throw new SameOriginForbiddenError();
129
- }
130
- if (status === 404) {
131
- throw new NotFoundError(preferencesFile.value);
132
- }
133
- throw new FetchError(err.status, err.message);
134
- }
135
- return preferencesFile as NamedNode;
136
- }
137
-
138
- getTypeIndex(
139
- me: NamedNode | string,
140
- preferencesFile: NamedNode | string,
141
- isPublic: boolean
142
- ): NamedNode[] {
143
- // console.log('getTypeIndex', this.store.each(me, undefined, undefined, preferencesFile), isPublic, preferencesFile)
144
- return this.store.each(
145
- me as NamedNode,
146
- isPublic ? ns.solid("publicTypeIndex") : ns.solid("privateTypeIndex"),
147
- undefined,
148
- preferencesFile as NamedNode
149
- ) as NamedNode[];
150
- }
151
-
152
- getRegistrations(instance, theClass) {
153
- return this.store
154
- .each(undefined, ns.solid("instance"), instance)
155
- .filter((r) => {
156
- return this.store.holds(r, ns.solid("forClass"), theClass);
157
- });
158
- }
159
-
160
- load(doc: NamedNode | NamedNode[] | string) {
161
- return this.store.fetcher.load(doc);
162
- }
163
-
164
- async loadIndexes(
165
- me: NamedNode | string,
166
- publicProfile: NamedNode | string | null,
167
- preferencesFile: NamedNode | string | null,
168
- onWarning = async (_err: Error) => {
169
- return undefined;
170
- }
171
- ): Promise<{
172
- private: any;
173
- public: any;
174
- }> {
175
- let privateIndexes: any[] = [];
176
- let publicIndexes: any[] = [];
177
- if (publicProfile) {
178
- publicIndexes = this.getTypeIndex(me, publicProfile, true);
179
- try {
180
- await this.load(publicIndexes as NamedNode[]);
181
- } catch (err) {
182
- onWarning(new Error(`loadIndex: loading public type index(es) ${err}`));
183
- }
184
- }
185
- if (preferencesFile) {
186
- privateIndexes = this.getTypeIndex(me, preferencesFile, false);
187
- // console.log({ privateIndexes })
188
- if (privateIndexes.length === 0) {
189
- await onWarning(
190
- new Error(
191
- `Your preference file ${preferencesFile} does not point to a private type index.`
192
- )
193
- );
194
- } else {
195
- try {
196
- await this.load(privateIndexes);
197
- } catch (err) {
198
- onWarning(
199
- new Error(`loadIndex: loading private type index(es) ${err}`)
200
- );
201
- }
202
- }
203
- // } else {
204
- // debug.log(
205
- // 'We know your preference file is not available, so we are not bothering with private type indexes.'
206
- // )
207
- }
208
-
209
- return {
210
- private: privateIndexes,
211
- public: publicIndexes,
212
- };
213
- }
214
-
215
- async createEmptyRdfDoc(doc: NamedNode, comment: string) {
216
- await this.store.fetcher.webOperation("PUT", doc.uri, {
217
- data: `# ${new Date()} ${comment}
218
- `,
219
- contentType: "text/turtle",
220
- });
221
- }
222
-
223
- // @@@@ use the one in rdflib.js when it is available and delete this
224
- updatePromise(
225
- del: Array<Statement>,
226
- ins: Array<Statement> = []
227
- ): Promise<void> {
228
- return new Promise((resolve, reject) => {
229
- this.store.updater.update(del, ins, function (_uri, ok, errorBody) {
230
- if (!ok) {
231
- reject(new Error(errorBody));
232
- } else {
233
- resolve();
234
- }
235
- }); // callback
236
- }); // promise
237
- }
238
-
239
- isContainer(url: string) {
240
- return this.util.isContainer(url);
241
- }
242
-
243
- getContainerElements(containerNode: NamedNode): NamedNode[] {
244
- return this.util.getContainerElements(containerNode);
245
- }
246
-
247
- getContainerMembers(containerUrl: string): Promise<string[]> {
248
- return this.util.getContainerMembers(containerUrl);
249
- }
250
-
251
- async recursiveDelete(url: string) {
252
- return this.util.recursiveDelete(url);
253
- }
254
-
255
- clearStore() {
256
- return this.util.clearStore();
257
- }
258
-
259
- async fetch(url: string, options?: any) {
260
- return this.underlyingFetch.fetch(url, options);
261
- }
262
- }
@@ -1,44 +0,0 @@
1
- import { NamedNode, LiveStore } from "rdflib";
2
- import { AuthnLogic, SolidNamespace } from "../types";
3
-
4
- export class ProfileLogic {
5
- store: LiveStore;
6
- ns: SolidNamespace;
7
- authn: AuthnLogic;
8
-
9
- constructor(store: LiveStore, ns: SolidNamespace, authn: AuthnLogic) {
10
- this.store = store;
11
- this.ns = ns;
12
- this.authn = authn;
13
- }
14
-
15
- async loadMe(): Promise<NamedNode> {
16
- const me = this.authn.currentUser();
17
- if (me === null) {
18
- throw new Error("Current user not found! Not logged in?");
19
- }
20
- await this.store.fetcher?.load(me.doc());
21
- return me;
22
- }
23
-
24
- getPodRoot(user: NamedNode): NamedNode {
25
- const podRoot = this.findStorage(user);
26
- if (!podRoot) {
27
- throw new Error("User pod root not found!");
28
- }
29
- return podRoot as NamedNode;
30
- }
31
-
32
- async getMainInbox(user: NamedNode): Promise<NamedNode> {
33
- await this.store.fetcher?.load(user);
34
- const mainInbox = this.store.any(user, this.ns.ldp("inbox"), undefined, user.doc());
35
- if (!mainInbox) {
36
- throw new Error("User main inbox not found!");
37
- }
38
- return mainInbox as NamedNode;
39
- }
40
-
41
- private findStorage(me: NamedNode) {
42
- return this.store.any(me, this.ns.space("storage"), undefined, me.doc());
43
- }
44
- }
@@ -1,161 +0,0 @@
1
- import { NamedNode, Statement, sym, LiveStore } from "rdflib";
2
- import { SolidNamespace } from "../types";
3
-
4
- export const ACL_LINK = sym(
5
- "http://www.iana.org/assignments/link-relations/acl"
6
- );
7
-
8
- /**
9
- * Utility-related logic
10
- */
11
- export class UtilityLogic {
12
- store: LiveStore;
13
- ns: SolidNamespace;
14
- underlyingFetch: { fetch: (url: string, options?: any) => any };
15
-
16
- constructor(store: LiveStore, ns: SolidNamespace, underlyingFetch: { fetch: (url: string, options?: any) => any }) {
17
- this.store = store;
18
- this.ns = ns;
19
- this.underlyingFetch = underlyingFetch;
20
- }
21
-
22
- async findAclDocUrl(url: string) {
23
- const doc = this.store.sym(url);
24
- await this.store.fetcher?.load(doc);
25
- const docNode = this.store.any(doc, ACL_LINK);
26
- if (!docNode) {
27
- throw new Error(`No ACL link discovered for ${url}`);
28
- }
29
- return docNode.value;
30
- }
31
-
32
- // Copied from https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5
33
- async setSinglePeerAccess(options: {
34
- ownerWebId: string,
35
- peerWebId: string,
36
- accessToModes?: string,
37
- defaultModes?: string,
38
- target: string
39
- }) {
40
- let str = [
41
- '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',
42
- '',
43
- `<#alice> a acl:Authorization;\n acl:agent <${options.ownerWebId}>;`,
44
- ` acl:accessTo <${options.target}>;`,
45
- ` acl:default <${options.target}>;`,
46
- ' acl:mode acl:Read, acl:Write, acl:Control.',
47
- ''
48
- ].join('\n')
49
- if (options.accessToModes) {
50
- str += [
51
- '<#bobAccessTo> a acl:Authorization;',
52
- ` acl:agent <${options.peerWebId}>;`,
53
- ` acl:accessTo <${options.target}>;`,
54
- ` acl:mode ${options.accessToModes}.`,
55
- ''
56
- ].join('\n')
57
- }
58
- if (options.defaultModes) {
59
- str += [
60
- '<#bobDefault> a acl:Authorization;',
61
- ` acl:agent <${options.peerWebId}>;`,
62
- ` acl:default <${options.target}>;`,
63
- ` acl:mode ${options.defaultModes}.`,
64
- ''
65
- ].join('\n')
66
- }
67
- const aclDocUrl = await this.findAclDocUrl(options.target);
68
- return this.underlyingFetch.fetch(aclDocUrl, {
69
- method: 'PUT',
70
- body: str,
71
- headers: [
72
- [ 'Content-Type', 'text/turtle' ]
73
- ]
74
- });
75
- }
76
-
77
- async loadDoc(doc: NamedNode): Promise<void> {
78
- // Load a document into the knowledge base (fetcher.store)
79
- // withCredentials: Web arch should let us just load by turning off creds helps CORS
80
- // reload: Gets around a specific old Chrome bug caching/origin/cors
81
- // console.log('loading', profileDocument)
82
- if (!this.store.fetcher) {
83
- throw new Error("Cannot load doc, have no fetcher");
84
- }
85
- await this.store.fetcher.load(doc, {
86
- withCredentials: false, // @@ BUT this won't work when logged in an accessing private stuff!
87
- cache: "reload",
88
- });
89
- // console.log('loaded', profileDocument, this.store)
90
- }
91
-
92
- isContainer(url: string) {
93
- return url.substr(-1) === "/";
94
- }
95
-
96
- async createContainer(url: string) {
97
- if (!this.isContainer(url)) {
98
- throw new Error(`Not a container URL ${url}`);
99
- }
100
- // Copied from https://github.com/solidos/solid-crud-tests/blob/v3.1.0/test/surface/create-container.test.ts#L56-L64
101
- const result = await this.underlyingFetch.fetch(url, {
102
- method: "PUT",
103
- headers: {
104
- "Content-Type": "text/turtle",
105
- "If-None-Match": "*",
106
- Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/solidos/node-solid-server/issues/1465
107
- },
108
- body: " ", // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
109
- });
110
- if (result.status.toString()[0] !== '2') {
111
- throw new Error(`Not OK: got ${result.status} response while creating container at ${url}`);
112
- }
113
- }
114
-
115
- getContainerElements(containerNode: NamedNode): NamedNode[] {
116
- return this.store
117
- .statementsMatching(
118
- containerNode,
119
- this.store.sym("http://www.w3.org/ns/ldp#contains"),
120
- undefined,
121
- containerNode.doc()
122
- )
123
- .map((st: Statement) => st.object as NamedNode);
124
- }
125
-
126
- async getContainerMembers(containerUrl: string): Promise<string[]> {
127
- const containerNode = this.store.sym(containerUrl);
128
- await this.store.fetcher?.load(containerNode);
129
- const nodes = this.getContainerElements(containerNode);
130
- return nodes.map(node => node.value);
131
- }
132
-
133
- async recursiveDelete(url: string) {
134
- try {
135
- if (this.isContainer(url)) {
136
- const aclDocUrl = await this.findAclDocUrl(url);
137
- await this.underlyingFetch.fetch(aclDocUrl, { method: "DELETE" });
138
- const containerMembers = await this.getContainerMembers(url);
139
- await Promise.all(
140
- containerMembers.map((url) => this.recursiveDelete(url))
141
- );
142
- }
143
- return this.underlyingFetch.fetch(url, { method: "DELETE" });
144
- } catch (e) {
145
- // console.log(`Please manually remove ${url} from your system under test.`, e);
146
- }
147
- }
148
-
149
- clearStore() {
150
- this.store.statements.slice().forEach(this.store.remove.bind(this.store));
151
- }
152
-
153
- getArchiveUrl(baseUrl: string, date: Date) {
154
- const year = date.getUTCFullYear();
155
- const month = ('0' + (date.getUTCMonth()+1)).slice(-2);
156
- const day = ('0' + (date.getUTCDate())).slice(-2);
157
- const parts = baseUrl.split('/');
158
- const filename = parts[parts.length -1 ];
159
- return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString();
160
- }
161
- }
package/src/util/uri.ts DELETED
@@ -1,5 +0,0 @@
1
- import { NamedNode, sym } from "rdflib";
2
-
3
- export function newThing(doc: NamedNode): NamedNode {
4
- return sym(doc.uri + "#" + "id" + ("" + Date.now()));
5
- }