solid-logic 1.3.17-8a332867 → 1.3.17-a27c1702

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 (122) hide show
  1. package/jest.config.js +1 -1
  2. package/lib/acl/aclLogic.d.ts +12 -30
  3. package/lib/acl/aclLogic.d.ts.map +1 -1
  4. package/lib/acl/aclLogic.js +152 -119
  5. package/lib/acl/aclLogic.js.map +1 -1
  6. package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
  7. package/lib/authn/SolidAuthnLogic.js +2 -2
  8. package/lib/authn/SolidAuthnLogic.js.map +1 -1
  9. package/lib/chat/chatLogic.d.ts +16 -0
  10. package/lib/chat/chatLogic.d.ts.map +1 -0
  11. package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -87
  12. package/lib/chat/chatLogic.js.map +1 -0
  13. package/lib/inbox/inboxLogic.d.ts +7 -0
  14. package/lib/inbox/inboxLogic.d.ts.map +1 -0
  15. package/lib/inbox/{InboxLogic.js → inboxLogic.js} +58 -64
  16. package/lib/inbox/inboxLogic.js.map +1 -0
  17. package/lib/index.d.ts +18 -9
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +86 -34
  20. package/lib/index.js.map +1 -1
  21. package/lib/logic/CustomError.d.ts +4 -0
  22. package/lib/logic/CustomError.d.ts.map +1 -1
  23. package/lib/logic/CustomError.js +17 -1
  24. package/lib/logic/CustomError.js.map +1 -1
  25. package/lib/logic/SolidLogic.d.ts +8 -34
  26. package/lib/logic/SolidLogic.d.ts.map +1 -1
  27. package/lib/logic/SolidLogic.js +16 -250
  28. package/lib/logic/SolidLogic.js.map +1 -1
  29. package/lib/logic/solidLogicSingleton.js +1 -1
  30. package/lib/logic/solidLogicSingleton.js.map +1 -1
  31. package/lib/logic/solidLogicSingletonNew.d.ts +80 -0
  32. package/lib/logic/solidLogicSingletonNew.d.ts.map +1 -0
  33. package/lib/logic/solidLogicSingletonNew.js +238 -0
  34. package/lib/logic/solidLogicSingletonNew.js.map +1 -0
  35. package/lib/profile/profileLogic.d.ts +13 -0
  36. package/lib/profile/profileLogic.d.ts.map +1 -0
  37. package/lib/profile/profileLogic.js +268 -0
  38. package/lib/profile/profileLogic.js.map +1 -0
  39. package/lib/typeIndex/typeIndexLogic.d.ts +31 -21
  40. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  41. package/lib/typeIndex/typeIndexLogic.js +650 -295
  42. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  43. package/lib/types.d.ts +17 -0
  44. package/lib/types.d.ts.map +1 -1
  45. package/lib/util/containerLogic.d.ts +11 -0
  46. package/lib/util/containerLogic.d.ts.map +1 -0
  47. package/lib/{profile/ProfileLogic.js → util/containerLogic.js} +53 -44
  48. package/lib/util/containerLogic.js.map +1 -0
  49. package/lib/util/ns.d.ts +2 -0
  50. package/lib/util/ns.d.ts.map +1 -0
  51. package/lib/util/ns.js +34 -0
  52. package/lib/util/ns.js.map +1 -0
  53. package/lib/util/utilityLogic.d.ts +15 -0
  54. package/lib/util/utilityLogic.d.ts.map +1 -0
  55. package/lib/util/utilityLogic.js +272 -0
  56. package/lib/util/utilityLogic.js.map +1 -0
  57. package/lib/util/utils.d.ts +8 -0
  58. package/lib/util/utils.d.ts.map +1 -0
  59. package/lib/util/utils.js +48 -0
  60. package/lib/util/utils.js.map +1 -0
  61. package/package.json +3 -1
  62. package/src/acl/aclLogic.ts +136 -118
  63. package/src/authn/SolidAuthnLogic.ts +3 -2
  64. package/src/chat/chatLogic.ts +225 -0
  65. package/src/inbox/inboxLogic.ts +57 -0
  66. package/src/index.ts +139 -27
  67. package/src/logic/CustomError.ts +5 -1
  68. package/src/logic/SolidLogic.ts +30 -211
  69. package/src/logic/solidLogicSingleton.ts +1 -1
  70. package/src/logic/solidLogicSingletonNew.ts +239 -0
  71. package/src/profile/profileLogic.ts +134 -0
  72. package/src/typeIndex/typeIndexLogic.ts +417 -153
  73. package/src/types.ts +7 -3
  74. package/src/util/containerLogic.ts +54 -0
  75. package/src/util/ns.ts +5 -0
  76. package/src/util/utilityLogic.ts +155 -0
  77. package/src/util/utils.ts +52 -0
  78. package/test/aclLogic.test.ts +13 -4
  79. package/test/chatLogic.test.ts +70 -71
  80. package/test/container.test.ts +56 -0
  81. package/test/helpers/dataSetup.ts +134 -0
  82. package/test/helpers/setup.ts +1 -0
  83. package/test/inboxLogic.test.ts +39 -38
  84. package/test/logic.test.ts +10 -9
  85. package/test/profileLogic.test.ts +246 -0
  86. package/test/typeIndexLogic.test.ts +49 -22
  87. package/test/typeIndexLogicPart2.test.ts +485 -0
  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/profile/ProfileLogic.d.ts +0 -13
  105. package/lib/profile/ProfileLogic.d.ts.map +0 -1
  106. package/lib/profile/ProfileLogic.js.map +0 -1
  107. package/lib/util/UtilityLogic.d.ts +0 -33
  108. package/lib/util/UtilityLogic.d.ts.map +0 -1
  109. package/lib/util/UtilityLogic.js +0 -240
  110. package/lib/util/UtilityLogic.js.map +0 -1
  111. package/lib/util/uri.d.ts +0 -3
  112. package/lib/util/uri.d.ts.map +0 -1
  113. package/lib/util/uri.js +0 -9
  114. package/lib/util/uri.js.map +0 -1
  115. package/src/chat/ChatLogic.ts +0 -244
  116. package/src/chat/determineChatContainer.ts +0 -14
  117. package/src/discovery/discoveryLogic.ts +0 -310
  118. package/src/inbox/InboxLogic.ts +0 -66
  119. package/src/profile/ProfileLogic.ts +0 -44
  120. package/src/util/UtilityLogic.ts +0 -161
  121. package/src/util/uri.ts +0 -5
  122. package/test/discoveryLogic.test.ts +0 -740
@@ -1,42 +1,69 @@
1
- import { sym } from 'rdflib'
2
- import { AuthenticationContext } from '../src/types'
3
- import * as typeIndexLogic from '../src/typeIndex/typeIndexLogic'
1
+ import { Fetcher, Store, sym, UpdateManager } from "rdflib";
2
+ import { createAclLogic } from "../src/acl/aclLogic";
3
+ import { createProfileLogic } from "../src/profile/profileLogic";
4
+ import { createTypeIndexLogic } from "../src/typeIndex/typeIndexLogic";
5
+ import { AuthenticationContext } from "../src/types";
6
+ import { createContainerLogic } from "../src/util/containerLogic";
7
+ import { createUtilityLogic } from "../src/util/utilityLogic";
8
+ import { alice } from "./helpers/dataSetup";
4
9
 
5
- it('loadIndex', async () => {
6
- const context = {
10
+ let store;
11
+ let options;
12
+ let typeIndexLogic
13
+ const authn = {
14
+ currentUser: () => {
15
+ return alice;
16
+ },
17
+ };
18
+ describe('typeIndexLogic', () => {
19
+ beforeEach(() => {
20
+ options = { fetch: fetch };
21
+ store = new Store()
22
+ store.fetcher = new Fetcher(store, options);
23
+ store.updater = new UpdateManager(store);
24
+ const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
25
+ typeIndexLogic = createTypeIndexLogic(store, authn, createProfileLogic(store, authn, util), util)
26
+
27
+ })
28
+ describe('loadIndex', () => {
29
+ it('loadIndex', async () => {
30
+ const context = {
7
31
  index: {}
8
- }
32
+ }
9
33
 
10
- const result = await typeIndexLogic.loadIndex(context, true)
11
- expect(result).toEqual({
34
+ const result = await typeIndexLogic.loadIndex(context, true)
35
+ expect(result).toEqual({
12
36
  index: {
13
- private: [],
14
- public: []
37
+ private: [],
38
+ public: []
15
39
  },
40
+ })
16
41
  })
17
- })
42
+ })
18
43
 
19
- describe('loadTypeIndexes', () => {
44
+ describe('loadTypeIndexes', () => {
20
45
  it('exists', () => {
21
- expect(typeIndexLogic.loadTypeIndexes).toBeInstanceOf(Function)
46
+ expect(typeIndexLogic.loadTypeIndexes).toBeInstanceOf(Function)
22
47
  })
23
- it.skip('runs', async () => {
24
- const result = await typeIndexLogic.loadTypeIndexes({})
25
- expect(result).toBeInstanceOf(Object)
48
+ it('runs', async () => {
49
+ const result = await typeIndexLogic.loadTypeIndexes({})
50
+ expect(result).toBeInstanceOf(Object)
26
51
  })
27
- })
52
+ })
28
53
 
29
- describe('registerInTypeIndex', () => {
54
+ describe('registerInTypeIndex', () => {
30
55
  it('exists', () => {
31
- expect(typeIndexLogic.registerInTypeIndex).toBeInstanceOf(Function)
56
+ expect(typeIndexLogic.registerInTypeIndex).toBeInstanceOf(Function)
32
57
  })
33
58
  it('throws error', async () => {
34
- expect(typeIndexLogic.registerInTypeIndex(
59
+ expect(typeIndexLogic.registerInTypeIndex(
35
60
  {} as AuthenticationContext,
36
61
  sym('https://test.test#'),
37
62
  sym('https://test.test#'),
38
63
  false
39
- )).rejects
64
+ )).rejects
40
65
  .toThrow('@@ ensureLoadedPreferences: no user specified')
41
66
  })
42
- })
67
+ })
68
+
69
+ })
@@ -0,0 +1,485 @@
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
+ })