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