solid-logic 3.0.9-f51524a8 → 3.0.9-fa4d7e8
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/eslint.config.js +24 -23
- package/jest.config.js +8 -15
- package/lib/acl/aclLogic.d.ts +2 -2
- package/lib/acl/aclLogic.d.ts.map +1 -1
- package/lib/acl/aclLogic.js +168 -0
- package/lib/acl/aclLogic.js.map +1 -0
- package/lib/authSession/authSession.js +8 -0
- package/lib/authSession/authSession.js.map +1 -0
- package/lib/authn/SolidAuthnLogic.d.ts +3 -3
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +191 -0
- package/lib/authn/SolidAuthnLogic.js.map +1 -0
- package/lib/authn/authUtil.d.ts +1 -1
- package/lib/authn/authUtil.js +105 -0
- package/lib/authn/authUtil.js.map +1 -0
- package/lib/chat/chatLogic.d.ts +1 -1
- package/lib/chat/chatLogic.js +272 -0
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/inbox/inboxLogic.d.ts +1 -1
- package/lib/inbox/inboxLogic.d.ts.map +1 -1
- package/lib/inbox/inboxLogic.js +139 -0
- package/lib/inbox/inboxLogic.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +31 -0
- package/lib/index.js.map +1 -0
- package/lib/issuer/issuerLogic.js +52 -0
- package/lib/issuer/issuerLogic.js.map +1 -0
- package/lib/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/CustomError.js +89 -0
- package/lib/logic/CustomError.js.map +1 -0
- package/lib/logic/solidLogic.d.ts +2 -2
- package/lib/logic/solidLogic.d.ts.map +1 -1
- package/lib/logic/solidLogic.js +102 -0
- package/lib/logic/solidLogic.js.map +1 -0
- package/lib/logic/solidLogicSingleton.js +94 -0
- package/lib/logic/solidLogicSingleton.js.map +1 -0
- package/lib/profile/profileLogic.d.ts +1 -1
- package/lib/profile/profileLogic.js +259 -0
- package/lib/profile/profileLogic.js.map +1 -0
- package/lib/typeIndex/typeIndexLogic.js +399 -0
- package/lib/typeIndex/typeIndexLogic.js.map +1 -0
- package/lib/types.d.ts +2 -2
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/util/containerLogic.d.ts +1 -1
- package/lib/util/containerLogic.d.ts.map +1 -1
- package/lib/util/containerLogic.js +102 -0
- package/lib/util/containerLogic.js.map +1 -0
- package/lib/util/debug.d.ts.map +1 -1
- package/lib/util/debug.js +40 -0
- package/lib/util/debug.js.map +1 -0
- package/lib/util/ns.js +44 -0
- package/lib/util/ns.js.map +1 -0
- package/lib/util/utilityLogic.d.ts +1 -1
- package/lib/util/utilityLogic.d.ts.map +1 -1
- package/lib/util/utilityLogic.js +284 -0
- package/lib/util/utilityLogic.js.map +1 -0
- package/lib/util/utils.d.ts +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +47 -0
- package/lib/util/utils.js.map +1 -0
- package/package.json +15 -38
- package/src/acl/aclLogic.ts +8 -8
- package/src/authn/SolidAuthnLogic.ts +6 -6
- package/src/authn/authUtil.ts +1 -1
- package/src/chat/chatLogic.ts +75 -75
- package/src/inbox/inboxLogic.ts +19 -19
- package/src/index.ts +2 -1
- package/src/logic/CustomError.ts +6 -6
- package/src/logic/solidLogic.ts +22 -22
- package/src/logic/solidLogicSingleton.ts +3 -3
- package/src/profile/profileLogic.ts +22 -22
- package/src/typeIndex/typeIndexLogic.ts +7 -7
- package/src/types.ts +2 -2
- package/src/util/containerLogic.ts +15 -15
- package/src/util/debug.ts +8 -4
- package/src/util/utilityLogic.ts +18 -18
- package/src/util/utils.ts +12 -12
- package/test/aclLogic.test.ts +5 -5
- package/test/authUtil.test.ts +1 -1
- package/test/chatLogic.test.ts +154 -160
- package/test/container.test.ts +23 -23
- package/test/helpers/dataSetup.ts +1 -2
- package/test/helpers/setup.ts +3 -8
- package/test/inboxLogic.test.ts +110 -101
- package/test/logic.test.ts +2 -2
- package/test/profileLogic.test.ts +33 -35
- package/test/solidAuthLogic.test.ts +1 -1
- package/test/typeIndexLogic.test.ts +71 -71
- package/test/utilityLogic.test.ts +45 -46
- package/test/utils.test.ts +11 -11
- package/tsconfig.json +3 -5
- package/babel.config.js +0 -6
- package/lib/solid-logic.js +0 -107
- package/lib/solid-logic.js.map +0 -1
- package/rollup.config.js +0 -29
- package/src/versionInfo.ts +0 -32
- package/timestamp.sh +0 -13
- package/tsconfig.test.json +0 -8
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
import { Fetcher, Store, sym, UpdateManager } from
|
|
6
|
-
import { createAclLogic } from
|
|
7
|
-
import { createProfileLogic } from
|
|
8
|
-
import { createTypeIndexLogic} from
|
|
9
|
-
import { createContainerLogic } from
|
|
10
|
-
import { ns } from
|
|
11
|
-
import { createUtilityLogic } from
|
|
12
|
-
import { uniqueNodes } from
|
|
13
|
-
import { alice, AlicePhotoFolder, AlicePhotos, AlicePreferences, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AlicePublicTypeIndex, AlicePublicTypes, bob, BobProfile, club, ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes } from
|
|
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";
|
|
14
14
|
|
|
15
15
|
const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
|
|
16
16
|
window.$SolidTestEnvironment = { username: alice.uri }
|
|
@@ -34,22 +34,23 @@ web[club.doc().uri] = ClubProfile
|
|
|
34
34
|
web[ClubPreferencesFile.uri] = ClubPreferences
|
|
35
35
|
web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
|
|
36
36
|
web[ClubPublicTypeIndex.uri] = ClubPublicTypes
|
|
37
|
-
let requests
|
|
37
|
+
let requests = []
|
|
38
38
|
let statustoBeReturned = 200
|
|
39
39
|
let typeIndexLogic
|
|
40
40
|
|
|
41
|
-
describe(
|
|
42
|
-
let store
|
|
41
|
+
describe("TypeIndex logic NEW", () => {
|
|
42
|
+
let store;
|
|
43
43
|
const authn = {
|
|
44
44
|
currentUser: () => {
|
|
45
|
-
return alice
|
|
45
|
+
return alice;
|
|
46
46
|
},
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
beforeEach(() => {
|
|
50
|
-
fetchMock.resetMocks()
|
|
50
|
+
fetchMock.resetMocks();
|
|
51
51
|
requests = []
|
|
52
52
|
statustoBeReturned = 200
|
|
53
|
+
const init = { headers: { "Content-Type": "text/turtle" } } // Fetch options tend to be called this
|
|
53
54
|
|
|
54
55
|
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
55
56
|
|
|
@@ -68,9 +69,9 @@ describe('TypeIndex logic NEW', () => {
|
|
|
68
69
|
body: prefixes + contents, // Add namespaces to anything
|
|
69
70
|
status: 200,
|
|
70
71
|
headers: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
"Content-Type": "text/turtle",
|
|
73
|
+
"WAC-Allow": 'user="write", public="read"',
|
|
74
|
+
"Accept-Patch": "application/sparql-update"
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
} // if contents
|
|
@@ -81,11 +82,11 @@ describe('TypeIndex logic NEW', () => {
|
|
|
81
82
|
})
|
|
82
83
|
|
|
83
84
|
store = new Store()
|
|
84
|
-
store.fetcher = new Fetcher(store, { fetch: fetch })
|
|
85
|
-
store.updater = new UpdateManager(store)
|
|
85
|
+
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
86
|
+
store.updater = new UpdateManager(store);
|
|
86
87
|
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
87
88
|
typeIndexLogic = createTypeIndexLogic(store, authn, createProfileLogic(store, authn, util), util)
|
|
88
|
-
})
|
|
89
|
+
});
|
|
89
90
|
|
|
90
91
|
describe('loadAllTypeIndexes', () => {
|
|
91
92
|
it('exists', () => {
|
|
@@ -94,32 +95,32 @@ describe('TypeIndex logic NEW', () => {
|
|
|
94
95
|
})
|
|
95
96
|
|
|
96
97
|
const AliceScopes = [{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
"agent": {
|
|
99
|
+
"classOrder": 5,
|
|
100
|
+
"termType": "NamedNode",
|
|
101
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
101
102
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
"index": {
|
|
104
|
+
"classOrder": 5,
|
|
105
|
+
"termType": "NamedNode",
|
|
106
|
+
"value": "https://alice.example.com/profile/public-type-index.ttl",
|
|
106
107
|
},
|
|
107
|
-
|
|
108
|
+
"label": "public",
|
|
108
109
|
},
|
|
109
110
|
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
"agent": {
|
|
112
|
+
"classOrder": 5,
|
|
113
|
+
"termType": "NamedNode",
|
|
114
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
114
115
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
"index": {
|
|
117
|
+
"classOrder": 5,
|
|
118
|
+
"termType": "NamedNode",
|
|
119
|
+
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
119
120
|
},
|
|
120
|
-
|
|
121
|
+
"label": "private",
|
|
121
122
|
}
|
|
122
|
-
]
|
|
123
|
+
];
|
|
123
124
|
|
|
124
125
|
describe('loadTypeIndexesFor', () => {
|
|
125
126
|
it('exists', () => {
|
|
@@ -136,30 +137,30 @@ describe('TypeIndex logic NEW', () => {
|
|
|
136
137
|
const ClubScopes =
|
|
137
138
|
[
|
|
138
139
|
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
"agent": {
|
|
141
|
+
"classOrder": 5,
|
|
142
|
+
"termType": "NamedNode",
|
|
143
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
143
144
|
},
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
"index": {
|
|
146
|
+
"classOrder": 5,
|
|
147
|
+
"termType": "NamedNode",
|
|
148
|
+
"value": "https://club.example.com/profile/public-type-index.ttl",
|
|
148
149
|
},
|
|
149
|
-
|
|
150
|
+
"label": "public",
|
|
150
151
|
},
|
|
151
152
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
"agent": {
|
|
154
|
+
"classOrder": 5,
|
|
155
|
+
"termType": "NamedNode",
|
|
156
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
156
157
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
"index": {
|
|
159
|
+
"classOrder": 5,
|
|
160
|
+
"termType": "NamedNode",
|
|
161
|
+
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
161
162
|
},
|
|
162
|
-
|
|
163
|
+
"label": "private",
|
|
163
164
|
}
|
|
164
165
|
]
|
|
165
166
|
describe('loadCommunityTypeIndexes', () => {
|
|
@@ -172,7 +173,7 @@ describe('TypeIndex logic NEW', () => {
|
|
|
172
173
|
})
|
|
173
174
|
})
|
|
174
175
|
|
|
175
|
-
const AliceAndClubScopes = [{
|
|
176
|
+
const AliceAndClubScopes = [{"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/publicStuff/actionItems.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/card.ttl#me"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/public-type-index.ttl"}, "label": "public"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/project4/issues.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/card.ttl#me"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/public-type-index.ttl"}, "label": "public"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/ToDo.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/card.ttl#me"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/Goals.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/card.ttl#me"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/workingOn.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/profile/card.ttl#me"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/publicStuff/actionItems.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/card.ttl#it"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/public-type-index.ttl"}, "label": "public"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/project4/clubIssues.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/card.ttl#it"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/public-type-index.ttl"}, "label": "public"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/ToDo.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/card.ttl#it"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/Goals.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/card.ttl#it"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}, {"instance": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/tasks.ttl#this"}, "scope": {"agent": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/profile/card.ttl#it"}, "index": {"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/settings/private-type-index.ttl"}, "label": "private"}, "type": {"classOrder": 5, "termType": "NamedNode", "value": "http://www.w3.org/2005/01/wf/flow#Tracker"}}]
|
|
176
177
|
|
|
177
178
|
describe('getScopedAppInstances', () => {
|
|
178
179
|
it('exists', () => {
|
|
@@ -183,7 +184,6 @@ describe('TypeIndex logic NEW', () => {
|
|
|
183
184
|
expect(result).toEqual(AliceAndClubScopes) // @@ AliceAndClubScopes
|
|
184
185
|
})
|
|
185
186
|
it('creates new preferenceFile and typeIndex files where they dont exist', async () => {
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
187
187
|
const result = await typeIndexLogic.getScopedAppInstances(Tracker, bob)
|
|
188
188
|
|
|
189
189
|
expect(requests[0].method).toEqual('PATCH') // Add preferrencesFile link to profile
|
|
@@ -210,16 +210,16 @@ describe('TypeIndex logic NEW', () => {
|
|
|
210
210
|
})
|
|
211
211
|
|
|
212
212
|
const TRACKERS =
|
|
213
|
-
[{
|
|
214
|
-
{
|
|
215
|
-
{
|
|
216
|
-
{
|
|
217
|
-
{
|
|
218
|
-
{
|
|
219
|
-
{
|
|
220
|
-
{
|
|
221
|
-
{
|
|
222
|
-
{
|
|
213
|
+
[{"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/publicStuff/actionItems.ttl#this"},
|
|
214
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/project4/issues.ttl#this"},
|
|
215
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/ToDo.ttl#this"},
|
|
216
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/Goals.ttl#this"},
|
|
217
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://alice.example.com/privateStuff/workingOn.ttl#this"},
|
|
218
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/publicStuff/actionItems.ttl#this"},
|
|
219
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/project4/clubIssues.ttl#this"},
|
|
220
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/ToDo.ttl#this"},
|
|
221
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/Goals.ttl#this"},
|
|
222
|
+
{"classOrder": 5, "termType": "NamedNode", "value": "https://club.example.com/privateStuff/tasks.ttl#this"} ]
|
|
223
223
|
|
|
224
224
|
describe('getAppInstances', () => {
|
|
225
225
|
it('exists', () => {
|
|
@@ -234,7 +234,7 @@ describe('TypeIndex logic NEW', () => {
|
|
|
234
234
|
const result = await typeIndexLogic.getAppInstances(Image)
|
|
235
235
|
expect(result.length).toEqual(1)
|
|
236
236
|
expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
|
|
237
|
-
expect(result.map(x => x.uri).join()).toEqual(
|
|
237
|
+
expect(result.map(x => x.uri).join()).toEqual("https://alice.example.com/profile/Photos/")
|
|
238
238
|
})
|
|
239
239
|
})
|
|
240
240
|
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
import fetchMock from
|
|
6
|
-
import { UpdateManager, sym, Fetcher, Store } from
|
|
7
|
-
import { createAclLogic } from
|
|
8
|
-
import { WebOperationError } from
|
|
9
|
-
import { createContainerLogic } from
|
|
10
|
-
import { ns } from
|
|
11
|
-
import { createUtilityLogic } from
|
|
12
|
-
import { alice, AlicePhotoFolder, AlicePhotos, AlicePreferences, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AlicePublicTypeIndex, AlicePublicTypes, bob, BobProfile, club, ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes } from
|
|
5
|
+
import fetchMock from "jest-fetch-mock";
|
|
6
|
+
import { UpdateManager, sym, Fetcher, Store } from "rdflib";
|
|
7
|
+
import { createAclLogic } from "../src/acl/aclLogic";
|
|
8
|
+
import { WebOperationError } from "../src/logic/CustomError";
|
|
9
|
+
import { createContainerLogic } from "../src/util/containerLogic";
|
|
10
|
+
import { ns } from "../src/util/ns";
|
|
11
|
+
import { createUtilityLogic } from "../src/util/utilityLogic";
|
|
12
|
+
import { alice, AlicePhotoFolder, AlicePhotos, AlicePreferences, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AlicePublicTypeIndex, AlicePublicTypes, bob, BobProfile, club, ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes } from "./helpers/dataSetup";
|
|
13
13
|
|
|
14
14
|
window.$SolidTestEnvironment = { username: alice.uri }
|
|
15
15
|
const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
|
|
16
16
|
|
|
17
|
-
describe(
|
|
18
|
-
let store
|
|
19
|
-
let options
|
|
17
|
+
describe("utilityLogic", () => {
|
|
18
|
+
let store;
|
|
19
|
+
let options;
|
|
20
20
|
let web = {}
|
|
21
|
-
let requests
|
|
21
|
+
let requests = []
|
|
22
22
|
let statustoBeReturned = 200
|
|
23
23
|
let utilityLogic
|
|
24
24
|
beforeEach(() => {
|
|
25
|
-
fetchMock.resetMocks()
|
|
26
|
-
fetchMock.mockResponse(
|
|
25
|
+
fetchMock.resetMocks();
|
|
26
|
+
fetchMock.mockResponse("Not Found", {
|
|
27
27
|
status: 404,
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
requests = []
|
|
30
30
|
statustoBeReturned = 200
|
|
31
|
+
const init = { headers: { "Content-Type": "text/turtle" } } // Fetch options tend to be called this
|
|
31
32
|
|
|
32
33
|
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
33
34
|
|
|
@@ -46,9 +47,9 @@ describe('utilityLogic', () => {
|
|
|
46
47
|
body: prefixes + contents, // Add namespaces to anything
|
|
47
48
|
status: 200,
|
|
48
49
|
headers: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
"Content-Type": "text/turtle",
|
|
51
|
+
"WAC-Allow": 'user="write", public="read"',
|
|
52
|
+
"Accept-Patch": "application/sparql-update"
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
} // if contents
|
|
@@ -70,27 +71,25 @@ describe('utilityLogic', () => {
|
|
|
70
71
|
web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
|
|
71
72
|
web[ClubPublicTypeIndex.uri] = ClubPublicTypes
|
|
72
73
|
|
|
73
|
-
options = { fetch: fetch }
|
|
74
|
+
options = { fetch: fetch };
|
|
74
75
|
store = new Store()
|
|
75
|
-
store.fetcher = new Fetcher(store, options)
|
|
76
|
-
store.updater = new UpdateManager(store)
|
|
76
|
+
store.fetcher = new Fetcher(store, options);
|
|
77
|
+
store.updater = new UpdateManager(store);
|
|
77
78
|
requests = []
|
|
78
79
|
utilityLogic = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
79
|
-
})
|
|
80
|
+
});
|
|
80
81
|
|
|
81
82
|
describe('loadOrCreateIfNotExists', () => {
|
|
82
83
|
it('exists', () => {
|
|
83
84
|
expect(utilityLogic.loadOrCreateIfNotExists).toBeInstanceOf(Function)
|
|
84
85
|
})
|
|
85
86
|
it('does nothing if existing file', async () => {
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
87
|
const result = await utilityLogic.loadOrCreateIfNotExists(alice.doc())
|
|
88
88
|
expect(requests).toEqual([])
|
|
89
89
|
|
|
90
90
|
})
|
|
91
91
|
it('creates empty file if did not exist', async () => {
|
|
92
92
|
const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
93
|
const result = await utilityLogic.loadOrCreateIfNotExists(sym(suggestion))
|
|
95
94
|
expect(requests[0].method).toEqual('PUT')
|
|
96
95
|
expect(requests[0].url).toEqual(suggestion)
|
|
@@ -127,32 +126,32 @@ describe('utilityLogic', () => {
|
|
|
127
126
|
})
|
|
128
127
|
|
|
129
128
|
})
|
|
130
|
-
describe(
|
|
129
|
+
describe("setSinglePeerAccess", () => {
|
|
131
130
|
beforeEach(() => {
|
|
132
131
|
fetchMock.mockOnceIf(
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
"https://owner.com/some/resource",
|
|
133
|
+
"hello", {
|
|
135
134
|
headers: {
|
|
136
135
|
Link: '<https://owner.com/some/acl>; rel="acl"'
|
|
137
136
|
}
|
|
138
|
-
})
|
|
137
|
+
});
|
|
139
138
|
fetchMock.mockOnceIf(
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
"https://owner.com/some/acl",
|
|
140
|
+
"Created", {
|
|
142
141
|
status: 201
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
it(
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
it("Creates the right ACL doc", async () => {
|
|
146
145
|
await utilityLogic.setSinglePeerAccess({
|
|
147
|
-
ownerWebId:
|
|
148
|
-
peerWebId:
|
|
149
|
-
accessToModes:
|
|
150
|
-
defaultModes:
|
|
151
|
-
target:
|
|
152
|
-
})
|
|
146
|
+
ownerWebId: "https://owner.com/#me",
|
|
147
|
+
peerWebId: "https://peer.com/#me",
|
|
148
|
+
accessToModes: "acl:Read, acl:Control",
|
|
149
|
+
defaultModes: "acl:Write",
|
|
150
|
+
target: "https://owner.com/some/resource"
|
|
151
|
+
});
|
|
153
152
|
expect(fetchMock.mock.calls).toEqual([
|
|
154
|
-
[
|
|
155
|
-
[
|
|
153
|
+
[ "https://owner.com/some/resource", fetchMock.mock.calls[0][1] ],
|
|
154
|
+
[ "https://owner.com/some/acl", {
|
|
156
155
|
body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
|
|
157
156
|
'\n' +
|
|
158
157
|
'<#alice> a acl:Authorization;\n' +
|
|
@@ -169,12 +168,12 @@ describe('setSinglePeerAccess', () => {
|
|
|
169
168
|
' acl:default <https://owner.com/some/resource>;\n' +
|
|
170
169
|
' acl:mode acl:Write.\n',
|
|
171
170
|
headers: [
|
|
172
|
-
[
|
|
171
|
+
["Content-Type", "text/turtle"]
|
|
173
172
|
],
|
|
174
|
-
method:
|
|
173
|
+
method: "PUT"
|
|
175
174
|
}]
|
|
176
|
-
])
|
|
177
|
-
})
|
|
178
|
-
})
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
179
178
|
|
|
180
179
|
})
|
package/test/utils.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as rdf from
|
|
2
|
-
import { getArchiveUrl, uniqueNodes } from '../src/util/utils'
|
|
1
|
+
import * as rdf from "rdflib";
|
|
2
|
+
import { getArchiveUrl, uniqueNodes } from '../src/util/utils';
|
|
3
3
|
|
|
4
4
|
describe('utils', () => {
|
|
5
5
|
describe('uniqueNodes', () => {
|
|
@@ -19,14 +19,14 @@ describe('utils', () => {
|
|
|
19
19
|
})
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
describe(
|
|
23
|
-
it(
|
|
24
|
-
const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('7 Feb 2062 UTC'))
|
|
25
|
-
expect(url).toEqual('https://example.com/inbox/archive/2062/02/07/asdf-qwer-asdf-qwer')
|
|
26
|
-
})
|
|
27
|
-
it(
|
|
28
|
-
const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('12 Nov 2012 UTC'))
|
|
29
|
-
expect(url).toEqual('https://example.com/inbox/archive/2012/11/12/asdf-qwer-asdf-qwer')
|
|
30
|
-
})
|
|
22
|
+
describe("getArchiveUrl", () => {
|
|
23
|
+
it("produces the right URL in February", () => {
|
|
24
|
+
const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('7 Feb 2062 UTC'));
|
|
25
|
+
expect(url).toEqual('https://example.com/inbox/archive/2062/02/07/asdf-qwer-asdf-qwer');
|
|
26
|
+
});
|
|
27
|
+
it("produces the right URL in November", () => {
|
|
28
|
+
const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('12 Nov 2012 UTC'));
|
|
29
|
+
expect(url).toEqual('https://example.com/inbox/archive/2012/11/12/asdf-qwer-asdf-qwer');
|
|
30
|
+
});
|
|
31
31
|
})
|
|
32
32
|
})
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Basic Options */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"moduleResolution": "node", /* Use Node.js-style module resolution for Webpack compatibility. */
|
|
4
|
+
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
|
5
|
+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
|
7
6
|
"lib": [
|
|
8
7
|
"dom",
|
|
9
8
|
"es2015",
|
|
@@ -72,6 +71,5 @@
|
|
|
72
71
|
},
|
|
73
72
|
"include": [
|
|
74
73
|
"src/**/*"
|
|
75
|
-
]
|
|
76
|
-
"exclude": ["node_modules"]
|
|
74
|
+
]
|
|
77
75
|
}
|