solid-logic 1.3.17-80b4d030 → 1.3.17-81536f11

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 (56) hide show
  1. package/lib/acl/aclLogic.d.ts +2 -11
  2. package/lib/acl/aclLogic.d.ts.map +1 -1
  3. package/lib/acl/aclLogic.js.map +1 -1
  4. package/lib/chat/chatLogic.d.ts +2 -15
  5. package/lib/chat/chatLogic.d.ts.map +1 -1
  6. package/lib/chat/chatLogic.js +8 -7
  7. package/lib/chat/chatLogic.js.map +1 -1
  8. package/lib/inbox/inboxLogic.d.ts +2 -6
  9. package/lib/inbox/inboxLogic.d.ts.map +1 -1
  10. package/lib/inbox/inboxLogic.js.map +1 -1
  11. package/lib/index.d.ts +4 -18
  12. package/lib/index.d.ts.map +1 -1
  13. package/lib/index.js +2 -86
  14. package/lib/index.js.map +1 -1
  15. package/lib/issuer/issuerLogic.js +1 -1
  16. package/lib/issuer/issuerLogic.js.map +1 -1
  17. package/lib/logic/solidLogic.d.ts +6 -0
  18. package/lib/logic/solidLogic.d.ts.map +1 -0
  19. package/lib/logic/{SolidLogic.js → solidLogic.js} +38 -33
  20. package/lib/logic/solidLogic.js.map +1 -0
  21. package/lib/logic/solidLogicSingleton.d.ts +1 -2
  22. package/lib/logic/solidLogicSingleton.d.ts.map +1 -1
  23. package/lib/logic/solidLogicSingleton.js +2 -2
  24. package/lib/logic/solidLogicSingleton.js.map +1 -1
  25. package/lib/profile/profileLogic.d.ts +2 -12
  26. package/lib/profile/profileLogic.d.ts.map +1 -1
  27. package/lib/profile/profileLogic.js +1 -23
  28. package/lib/profile/profileLogic.js.map +1 -1
  29. package/lib/typeIndex/typeIndexLogic.d.ts +2 -31
  30. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  31. package/lib/typeIndex/typeIndexLogic.js +12 -359
  32. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  33. package/lib/types.d.ts +65 -1
  34. package/lib/types.d.ts.map +1 -1
  35. package/package.json +14 -14
  36. package/src/acl/aclLogic.ts +5 -4
  37. package/src/chat/chatLogic.ts +7 -7
  38. package/src/inbox/inboxLogic.ts +2 -1
  39. package/src/index.ts +5 -147
  40. package/src/issuer/issuerLogic.ts +1 -1
  41. package/src/logic/solidLogic.ts +75 -0
  42. package/src/logic/solidLogicSingleton.ts +2 -2
  43. package/src/profile/profileLogic.ts +4 -12
  44. package/src/typeIndex/typeIndexLogic.ts +6 -277
  45. package/src/types.ts +76 -1
  46. package/test/typeIndexLogic.test.ts +484 -54
  47. package/lib/logic/SolidLogic.d.ts +0 -22
  48. package/lib/logic/SolidLogic.d.ts.map +0 -1
  49. package/lib/logic/SolidLogic.js.map +0 -1
  50. package/lib/logic/solidLogicSingletonNew.d.ts +0 -80
  51. package/lib/logic/solidLogicSingletonNew.d.ts.map +0 -1
  52. package/lib/logic/solidLogicSingletonNew.js +0 -238
  53. package/lib/logic/solidLogicSingletonNew.js.map +0 -1
  54. package/src/logic/SolidLogic.ts +0 -81
  55. package/src/logic/solidLogicSingletonNew.ts +0 -239
  56. package/test/typeIndexLogicPart2.test.ts +0 -485
@@ -1,485 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- *
4
- */
5
- import { Fetcher, Store, UpdateManager } from "rdflib";
6
- import { createAclLogic } from "../src/acl/aclLogic";
7
- import { createProfileLogic } from "../src/profile/profileLogic";
8
- import { createTypeIndexLogic} from "../src/typeIndex/typeIndexLogic";
9
- import { createContainerLogic } from "../src/util/containerLogic";
10
- import { ns } from "../src/util/ns";
11
- import { createUtilityLogic } from "../src/util/utilityLogic";
12
- import { uniqueNodes } from "../src/util/utils";
13
- import { alice, AlicePhotoFolder, AlicePhotos, AlicePreferences, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AlicePublicTypeIndex, AlicePublicTypes, bob, BobProfile, club, ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes } from "./helpers/dataSetup";
14
-
15
- const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
16
- window.$SolidTestEnvironment = { username: alice.uri }
17
-
18
- const Tracker = ns.wf('Tracker')
19
- const Image = ns.schema('Image')
20
-
21
- //let web = {}
22
- //web = loadWebObject()
23
- const user = alice
24
- const profile = user.doc()
25
- const web = {}
26
- web[profile.uri] = AliceProfile
27
- web[AlicePreferencesFile.uri] = AlicePreferences
28
- web[AlicePrivateTypeIndex.uri] = AlicePrivateTypes
29
- web[AlicePublicTypeIndex.uri] = AlicePublicTypes
30
- web[AlicePhotoFolder.uri] = AlicePhotos
31
- web[bob.doc().uri] = BobProfile
32
-
33
- web[club.doc().uri] = ClubProfile
34
- web[ClubPreferencesFile.uri] = ClubPreferences
35
- web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
36
- web[ClubPublicTypeIndex.uri] = ClubPublicTypes
37
- let requests = []
38
- let statustoBeReturned = 200
39
- let typeIndexLogic
40
-
41
- describe("TypeIndex logic NEW", () => {
42
- let store;
43
- let options;
44
- const authn = {
45
- currentUser: () => {
46
- return alice;
47
- },
48
- };
49
-
50
- beforeEach(() => {
51
- fetchMock.resetMocks();
52
- requests = []
53
- statustoBeReturned = 200
54
- const init = { headers: { "Content-Type": "text/turtle" } } // Fetch options tend to be called this
55
-
56
- fetchMock.mockIf(/^https?.*$/, async req => {
57
-
58
- if (req.method !== 'GET') {
59
- requests.push(req)
60
- if (req.method === 'PUT') {
61
- const contents = await req.text()
62
- web[req.url] = contents // Update our dummy web
63
- console.log(`Tetst: Updated ${req.url} on PUT to <<<${web[req.url]}>>>`)
64
- }
65
- return { status: statustoBeReturned }
66
- }
67
- const contents = web[req.url]
68
- if (contents !== undefined) { //
69
- return {
70
- body: prefixes + contents, // Add namespaces to anything
71
- status: 200,
72
- headers: {
73
- "Content-Type": "text/turtle",
74
- "WAC-Allow": 'user="write", public="read"',
75
- "Accept-Patch": "application/sparql-update"
76
- }
77
- }
78
- } // if contents
79
- return {
80
- status: 404,
81
- body: 'Not Found'
82
- }
83
- })
84
-
85
- store = new Store()
86
- store.fetcher = new Fetcher(store, { fetch: fetch });
87
- store.updater = new UpdateManager(store);
88
- const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
89
- typeIndexLogic = createTypeIndexLogic(store, authn, createProfileLogic(store, authn, util), util)
90
- });
91
-
92
- describe('loadAllTypeIndexes', () => {
93
- it('exists', () => {
94
- expect(typeIndexLogic.loadAllTypeIndexes).toBeInstanceOf(Function)
95
- })
96
- })
97
-
98
- const AliceScopes = [{
99
- "agent": {
100
- "classOrder": 5,
101
- "termType": "NamedNode",
102
- "value": "https://alice.example.com/profile/card.ttl#me",
103
- },
104
- "index": {
105
- "classOrder": 5,
106
- "termType": "NamedNode",
107
- "value": "https://alice.example.com/profile/public-type-index.ttl",
108
- },
109
- "label": "public",
110
- },
111
- {
112
- "agent": {
113
- "classOrder": 5,
114
- "termType": "NamedNode",
115
- "value": "https://alice.example.com/profile/card.ttl#me",
116
- },
117
- "index": {
118
- "classOrder": 5,
119
- "termType": "NamedNode",
120
- "value": "https://alice.example.com/settings/private-type-index.ttl",
121
- },
122
- "label": "private",
123
- }
124
- ];
125
-
126
- describe('loadTypeIndexesFor', () => {
127
- it('exists', () => {
128
- expect(typeIndexLogic.loadTypeIndexesFor).toBeInstanceOf(Function)
129
- })
130
- it('loads data', async () => {
131
- const result = await typeIndexLogic.loadTypeIndexesFor(alice)
132
- expect(result).toEqual(AliceScopes)
133
- expect(store.statementsMatching(null, null, null, AlicePrivateTypeIndex).length).toEqual(8)
134
- expect(store.statementsMatching(null, null, null, AlicePublicTypeIndex).length).toEqual(8)
135
- })
136
- })
137
-
138
- const ClubScopes =
139
- [
140
- {
141
- "agent": {
142
- "classOrder": 5,
143
- "termType": "NamedNode",
144
- "value": "https://club.example.com/profile/card.ttl#it",
145
- },
146
- "index": {
147
- "classOrder": 5,
148
- "termType": "NamedNode",
149
- "value": "https://club.example.com/profile/public-type-index.ttl",
150
- },
151
- "label": "public",
152
- },
153
- {
154
- "agent": {
155
- "classOrder": 5,
156
- "termType": "NamedNode",
157
- "value": "https://club.example.com/profile/card.ttl#it",
158
- },
159
- "index": {
160
- "classOrder": 5,
161
- "termType": "NamedNode",
162
- "value": "https://club.example.com/settings/private-type-index.ttl",
163
- },
164
- "label": "private",
165
- }
166
- ]
167
- describe('loadCommunityTypeIndexes', () => {
168
- it('exists', () => {
169
- expect(typeIndexLogic.loadCommunityTypeIndexes).toBeInstanceOf(Function)
170
- })
171
- it('loads data', async () => {
172
- const result = await typeIndexLogic.loadCommunityTypeIndexes(alice)
173
- expect(result).toEqual(ClubScopes)
174
- })
175
- })
176
-
177
- const AliceAndClubScopes =
178
- [
179
- {
180
- "instance": {
181
- "classOrder": 5,
182
- "termType": "NamedNode",
183
- "value": "https://alice.example.com/publicStuff/actionItems.ttl#this",
184
- },
185
- "scope": {
186
- "agent": {
187
- "classOrder": 5,
188
- "termType": "NamedNode",
189
- "value": "https://alice.example.com/profile/card.ttl#me",
190
- },
191
- "index": {
192
- "classOrder": 5,
193
- "termType": "NamedNode",
194
- "value": "https://alice.example.com/profile/public-type-index.ttl",
195
- },
196
- "label": "public",
197
- },
198
- },
199
- {
200
- "instance": {
201
- "classOrder": 5,
202
- "termType": "NamedNode",
203
- "value": "https://alice.example.com/project4/issues.ttl#this",
204
- },
205
- "scope": {
206
- "agent": {
207
- "classOrder": 5,
208
- "termType": "NamedNode",
209
- "value": "https://alice.example.com/profile/card.ttl#me",
210
- },
211
- "index": {
212
- "classOrder": 5,
213
- "termType": "NamedNode",
214
- "value": "https://alice.example.com/profile/public-type-index.ttl",
215
- },
216
- "label": "public",
217
- },
218
- },
219
- {
220
- "instance": {
221
- "classOrder": 5,
222
- "termType": "NamedNode",
223
- "value": "https://alice.example.com/privateStuff/ToDo.ttl#this",
224
- },
225
- "scope": {
226
- "agent": {
227
- "classOrder": 5,
228
- "termType": "NamedNode",
229
- "value": "https://alice.example.com/profile/card.ttl#me",
230
- },
231
- "index": {
232
- "classOrder": 5,
233
- "termType": "NamedNode",
234
- "value": "https://alice.example.com/settings/private-type-index.ttl",
235
- },
236
- "label": "private",
237
- },
238
- },
239
- {
240
- "instance": {
241
- "classOrder": 5,
242
- "termType": "NamedNode",
243
- "value": "https://alice.example.com/privateStuff/Goals.ttl#this",
244
- },
245
- "scope": {
246
- "agent": {
247
- "classOrder": 5,
248
- "termType": "NamedNode",
249
- "value": "https://alice.example.com/profile/card.ttl#me",
250
- },
251
- "index": {
252
- "classOrder": 5,
253
- "termType": "NamedNode",
254
- "value": "https://alice.example.com/settings/private-type-index.ttl",
255
- },
256
- "label": "private",
257
- },
258
- },
259
- {
260
- "instance": {
261
- "classOrder": 5,
262
- "termType": "NamedNode",
263
- "value": "https://alice.example.com/privateStuff/workingOn.ttl#this",
264
- },
265
- "scope": {
266
- "agent": {
267
- "classOrder": 5,
268
- "termType": "NamedNode",
269
- "value": "https://alice.example.com/profile/card.ttl#me",
270
- },
271
- "index": {
272
- "classOrder": 5,
273
- "termType": "NamedNode",
274
- "value": "https://alice.example.com/settings/private-type-index.ttl",
275
- },
276
- "label": "private",
277
- },
278
- },
279
- {
280
- "instance": {
281
- "classOrder": 5,
282
- "termType": "NamedNode",
283
- "value": "https://club.example.com/publicStuff/actionItems.ttl#this",
284
- },
285
- "scope": {
286
- "agent": {
287
- "classOrder": 5,
288
- "termType": "NamedNode",
289
- "value": "https://club.example.com/profile/card.ttl#it",
290
- },
291
- "index": {
292
- "classOrder": 5,
293
- "termType": "NamedNode",
294
- "value": "https://club.example.com/profile/public-type-index.ttl",
295
- },
296
- "label": "public",
297
- },
298
- },
299
- {
300
- "instance": {
301
- "classOrder": 5,
302
- "termType": "NamedNode",
303
- "value": "https://club.example.com/project4/clubIssues.ttl#this",
304
- },
305
- "scope": {
306
- "agent": {
307
- "classOrder": 5,
308
- "termType": "NamedNode",
309
- "value": "https://club.example.com/profile/card.ttl#it",
310
- },
311
- "index": {
312
- "classOrder": 5,
313
- "termType": "NamedNode",
314
- "value": "https://club.example.com/profile/public-type-index.ttl",
315
- },
316
- "label": "public",
317
- },
318
- },
319
- {
320
- "instance": {
321
- "classOrder": 5,
322
- "termType": "NamedNode",
323
- "value": "https://club.example.com/privateStuff/ToDo.ttl#this",
324
- },
325
- "scope": {
326
- "agent": {
327
- "classOrder": 5,
328
- "termType": "NamedNode",
329
- "value": "https://club.example.com/profile/card.ttl#it",
330
- },
331
- "index": {
332
- "classOrder": 5,
333
- "termType": "NamedNode",
334
- "value": "https://club.example.com/settings/private-type-index.ttl",
335
- },
336
- "label": "private",
337
- },
338
- },
339
- {
340
- "instance": {
341
- "classOrder": 5,
342
- "termType": "NamedNode",
343
- "value": "https://club.example.com/privateStuff/Goals.ttl#this",
344
- },
345
- "scope": {
346
- "agent": {
347
- "classOrder": 5,
348
- "termType": "NamedNode",
349
- "value": "https://club.example.com/profile/card.ttl#it",
350
- },
351
- "index": {
352
- "classOrder": 5,
353
- "termType": "NamedNode",
354
- "value": "https://club.example.com/settings/private-type-index.ttl",
355
- },
356
- "label": "private",
357
- },
358
- },
359
- {
360
- "instance": {
361
- "classOrder": 5,
362
- "termType": "NamedNode",
363
- "value": "https://club.example.com/privateStuff/tasks.ttl#this",
364
- },
365
- "scope": {
366
- "agent": {
367
- "classOrder": 5,
368
- "termType": "NamedNode",
369
- "value": "https://club.example.com/profile/card.ttl#it",
370
- },
371
- "index": {
372
- "classOrder": 5,
373
- "termType": "NamedNode",
374
- "value": "https://club.example.com/settings/private-type-index.ttl",
375
- },
376
- "label": "private",
377
- },
378
- },
379
- ]
380
-
381
- describe('getScopedAppInstances', () => {
382
- it('exists', () => {
383
- expect(typeIndexLogic.getScopedAppInstances).toBeInstanceOf(Function)
384
- })
385
- it('pulls in users scopes and also community ones', async () => {
386
- const result = await typeIndexLogic.getScopedAppInstances(Tracker, alice)
387
- expect(result).toEqual(AliceAndClubScopes)
388
- })
389
- it('creates new preferenceFile and typeIndex files where they dont exist', async () => {
390
- const result = await typeIndexLogic.getScopedAppInstances(Tracker, bob)
391
-
392
- expect(requests[0].method).toEqual('PATCH') // Add preferrencesFile link to profile
393
- expect(requests[0].url).toEqual('https://bob.example.com/profile/card.ttl')
394
-
395
- expect(requests[1].method).toEqual('PUT') // create publiTypeIndex
396
- expect(requests[1].url).toEqual('https://bob.example.com/profile/publicTypeIndex.ttl')
397
-
398
- expect(requests[2].method).toEqual('PATCH') // Add link of publiTypeIndex to profile
399
- expect(requests[2].url).toEqual('https://bob.example.com/profile/card.ttl')
400
-
401
- expect(requests[3].method).toEqual('PUT') // create preferenceFile
402
- expect(requests[3].url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
403
-
404
- expect(requests[4].method).toEqual('PATCH') // Add privateTypeIndex link preference file
405
- expect(requests[4].url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
406
-
407
- expect(requests[5].method).toEqual('PUT') //create privatTypeIndex
408
- expect(requests[5].url).toEqual('https://bob.example.com/Settings/privateTypeIndex.ttl')
409
-
410
- expect(requests.length).toEqual(6)
411
-
412
- })
413
- })
414
-
415
- const TRACKERS =
416
- [
417
- {
418
- "classOrder": 5,
419
- "termType": "NamedNode",
420
- "value": "https://alice.example.com/publicStuff/actionItems.ttl#this",
421
- },
422
- {
423
- "classOrder": 5,
424
- "termType": "NamedNode",
425
- "value": "https://alice.example.com/project4/issues.ttl#this",
426
- },
427
- {
428
- "classOrder": 5,
429
- "termType": "NamedNode",
430
- "value": "https://alice.example.com/privateStuff/ToDo.ttl#this",
431
- },
432
- {
433
- "classOrder": 5,
434
- "termType": "NamedNode",
435
- "value": "https://alice.example.com/privateStuff/Goals.ttl#this",
436
- },
437
- {
438
- "classOrder": 5,
439
- "termType": "NamedNode",
440
- "value": "https://alice.example.com/privateStuff/workingOn.ttl#this",
441
- },
442
- {
443
- "classOrder": 5,
444
- "termType": "NamedNode",
445
- "value": "https://club.example.com/publicStuff/actionItems.ttl#this",
446
- },
447
- {
448
- "classOrder": 5,
449
- "termType": "NamedNode",
450
- "value": "https://club.example.com/project4/clubIssues.ttl#this",
451
- },
452
- {
453
- "classOrder": 5,
454
- "termType": "NamedNode",
455
- "value": "https://club.example.com/privateStuff/ToDo.ttl#this",
456
- },
457
- {
458
- "classOrder": 5,
459
- "termType": "NamedNode",
460
- "value": "https://club.example.com/privateStuff/Goals.ttl#this",
461
- },
462
- {
463
- "classOrder": 5,
464
- "termType": "NamedNode",
465
- "value": "https://club.example.com/privateStuff/tasks.ttl#this",
466
- },
467
- ]
468
-
469
- describe('getAppInstances', () => {
470
- it('exists', () => {
471
- expect(typeIndexLogic.getAppInstances).toBeInstanceOf(Function)
472
- })
473
- it('finds trackers', async () => {
474
- const result = await typeIndexLogic.getAppInstances(Tracker)
475
- expect(result).toEqual(TRACKERS)
476
- expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
477
- })
478
- it('finds images in containers', async () => {
479
- const result = await typeIndexLogic.getAppInstances(Image)
480
- expect(result.length).toEqual(3)
481
- expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
482
- expect(result.map(x => x.uri).join()).toEqual("https://alice.example.com/profile/Photos/photo1.png,https://alice.example.com/profile/Photos/photo2.png,https://alice.example.com/profile/Photos/photo3.png")
483
- })
484
- })
485
- })