solid-logic 3.0.9-f327aa58 → 3.0.9-f51524a8
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/babel.config.js +6 -0
- package/eslint.config.js +23 -24
- package/jest.config.js +15 -8
- package/lib/acl/aclLogic.d.ts +2 -2
- package/lib/acl/aclLogic.d.ts.map +1 -1
- package/lib/authSession/authSession.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.d.ts +3 -3
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/authUtil.d.ts +1 -1
- package/lib/chat/chatLogic.d.ts +1 -1
- package/lib/inbox/inboxLogic.d.ts +1 -1
- package/lib/inbox/inboxLogic.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/solidLogic.d.ts +2 -2
- package/lib/logic/solidLogic.d.ts.map +1 -1
- package/lib/profile/profileLogic.d.ts +1 -1
- package/lib/solid-logic.js +107 -0
- package/lib/solid-logic.js.map +1 -0
- package/lib/types.d.ts +2 -2
- package/lib/util/containerLogic.d.ts +1 -1
- package/lib/util/containerLogic.d.ts.map +1 -1
- package/lib/util/debug.d.ts.map +1 -1
- package/lib/util/utilityLogic.d.ts +1 -1
- package/lib/util/utilityLogic.d.ts.map +1 -1
- package/lib/util/utils.d.ts +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/package.json +39 -16
- package/rollup.config.js +29 -0
- package/src/acl/aclLogic.ts +8 -8
- package/src/authSession/authSession.ts +7 -1
- package/src/authn/SolidAuthnLogic.ts +7 -8
- 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 +1 -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 +4 -8
- package/src/util/utilityLogic.ts +18 -18
- package/src/util/utils.ts +12 -12
- package/src/versionInfo.ts +32 -0
- package/test/aclLogic.test.ts +5 -5
- package/test/authUtil.test.ts +1 -1
- package/test/chatLogic.test.ts +160 -154
- package/test/container.test.ts +23 -23
- package/test/helpers/dataSetup.ts +2 -1
- package/test/helpers/setup.ts +8 -3
- package/test/inboxLogic.test.ts +101 -110
- package/test/logic.test.ts +2 -2
- package/test/profileLogic.test.ts +35 -33
- package/test/solidAuthLogic.test.ts +1 -1
- package/test/typeIndexLogic.test.ts +71 -71
- package/test/utilityLogic.test.ts +46 -45
- package/test/utils.test.ts +11 -11
- package/timestamp.sh +13 -0
- package/tsconfig.json +5 -3
- package/tsconfig.test.json +8 -0
- package/lib/acl/aclLogic.js +0 -168
- package/lib/acl/aclLogic.js.map +0 -1
- package/lib/authSession/authSession.js +0 -6
- package/lib/authSession/authSession.js.map +0 -1
- package/lib/authn/SolidAuthnLogic.js +0 -193
- package/lib/authn/SolidAuthnLogic.js.map +0 -1
- package/lib/authn/authUtil.js +0 -105
- package/lib/authn/authUtil.js.map +0 -1
- package/lib/chat/chatLogic.js +0 -272
- package/lib/chat/chatLogic.js.map +0 -1
- package/lib/inbox/inboxLogic.js +0 -139
- package/lib/inbox/inboxLogic.js.map +0 -1
- package/lib/index.js +0 -29
- package/lib/index.js.map +0 -1
- package/lib/issuer/issuerLogic.js +0 -52
- package/lib/issuer/issuerLogic.js.map +0 -1
- package/lib/logic/CustomError.js +0 -89
- package/lib/logic/CustomError.js.map +0 -1
- package/lib/logic/solidLogic.js +0 -102
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.js +0 -94
- package/lib/logic/solidLogicSingleton.js.map +0 -1
- package/lib/profile/profileLogic.js +0 -259
- package/lib/profile/profileLogic.js.map +0 -1
- package/lib/typeIndex/typeIndexLogic.js +0 -399
- package/lib/typeIndex/typeIndexLogic.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.js +0 -40
- package/lib/util/debug.js.map +0 -1
- package/lib/util/ns.js +0 -44
- package/lib/util/ns.js.map +0 -1
- package/lib/util/utilityLogic.js +0 -284
- package/lib/util/utilityLogic.js.map +0 -1
- package/lib/util/utils.js +0 -47
- package/lib/util/utils.js.map +0 -1
|
@@ -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,23 +34,22 @@ 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: Request[] = []
|
|
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
|
|
54
53
|
|
|
55
54
|
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
56
55
|
|
|
@@ -69,9 +68,9 @@ describe("TypeIndex logic NEW", () => {
|
|
|
69
68
|
body: prefixes + contents, // Add namespaces to anything
|
|
70
69
|
status: 200,
|
|
71
70
|
headers: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
'Content-Type': 'text/turtle',
|
|
72
|
+
'WAC-Allow': 'user="write", public="read"',
|
|
73
|
+
'Accept-Patch': 'application/sparql-update'
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
} // if contents
|
|
@@ -82,11 +81,11 @@ describe("TypeIndex logic NEW", () => {
|
|
|
82
81
|
})
|
|
83
82
|
|
|
84
83
|
store = new Store()
|
|
85
|
-
store.fetcher = new Fetcher(store, { fetch: fetch })
|
|
86
|
-
store.updater = new UpdateManager(store)
|
|
84
|
+
store.fetcher = new Fetcher(store, { fetch: fetch })
|
|
85
|
+
store.updater = new UpdateManager(store)
|
|
87
86
|
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
88
87
|
typeIndexLogic = createTypeIndexLogic(store, authn, createProfileLogic(store, authn, util), util)
|
|
89
|
-
})
|
|
88
|
+
})
|
|
90
89
|
|
|
91
90
|
describe('loadAllTypeIndexes', () => {
|
|
92
91
|
it('exists', () => {
|
|
@@ -95,32 +94,32 @@ describe("TypeIndex logic NEW", () => {
|
|
|
95
94
|
})
|
|
96
95
|
|
|
97
96
|
const AliceScopes = [{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
'agent': {
|
|
98
|
+
'classOrder': 5,
|
|
99
|
+
'termType': 'NamedNode',
|
|
100
|
+
'value': 'https://alice.example.com/profile/card.ttl#me',
|
|
102
101
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
'index': {
|
|
103
|
+
'classOrder': 5,
|
|
104
|
+
'termType': 'NamedNode',
|
|
105
|
+
'value': 'https://alice.example.com/profile/public-type-index.ttl',
|
|
107
106
|
},
|
|
108
|
-
|
|
107
|
+
'label': 'public',
|
|
109
108
|
},
|
|
110
109
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
'agent': {
|
|
111
|
+
'classOrder': 5,
|
|
112
|
+
'termType': 'NamedNode',
|
|
113
|
+
'value': 'https://alice.example.com/profile/card.ttl#me',
|
|
115
114
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
'index': {
|
|
116
|
+
'classOrder': 5,
|
|
117
|
+
'termType': 'NamedNode',
|
|
118
|
+
'value': 'https://alice.example.com/settings/private-type-index.ttl',
|
|
120
119
|
},
|
|
121
|
-
|
|
120
|
+
'label': 'private',
|
|
122
121
|
}
|
|
123
|
-
]
|
|
122
|
+
]
|
|
124
123
|
|
|
125
124
|
describe('loadTypeIndexesFor', () => {
|
|
126
125
|
it('exists', () => {
|
|
@@ -137,30 +136,30 @@ describe("TypeIndex logic NEW", () => {
|
|
|
137
136
|
const ClubScopes =
|
|
138
137
|
[
|
|
139
138
|
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
'agent': {
|
|
140
|
+
'classOrder': 5,
|
|
141
|
+
'termType': 'NamedNode',
|
|
142
|
+
'value': 'https://club.example.com/profile/card.ttl#it',
|
|
144
143
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
'index': {
|
|
145
|
+
'classOrder': 5,
|
|
146
|
+
'termType': 'NamedNode',
|
|
147
|
+
'value': 'https://club.example.com/profile/public-type-index.ttl',
|
|
149
148
|
},
|
|
150
|
-
|
|
149
|
+
'label': 'public',
|
|
151
150
|
},
|
|
152
151
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
'agent': {
|
|
153
|
+
'classOrder': 5,
|
|
154
|
+
'termType': 'NamedNode',
|
|
155
|
+
'value': 'https://club.example.com/profile/card.ttl#it',
|
|
157
156
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
'index': {
|
|
158
|
+
'classOrder': 5,
|
|
159
|
+
'termType': 'NamedNode',
|
|
160
|
+
'value': 'https://club.example.com/settings/private-type-index.ttl',
|
|
162
161
|
},
|
|
163
|
-
|
|
162
|
+
'label': 'private',
|
|
164
163
|
}
|
|
165
164
|
]
|
|
166
165
|
describe('loadCommunityTypeIndexes', () => {
|
|
@@ -173,7 +172,7 @@ describe("TypeIndex logic NEW", () => {
|
|
|
173
172
|
})
|
|
174
173
|
})
|
|
175
174
|
|
|
176
|
-
const AliceAndClubScopes = [{
|
|
175
|
+
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'}}]
|
|
177
176
|
|
|
178
177
|
describe('getScopedAppInstances', () => {
|
|
179
178
|
it('exists', () => {
|
|
@@ -184,6 +183,7 @@ describe("TypeIndex logic NEW", () => {
|
|
|
184
183
|
expect(result).toEqual(AliceAndClubScopes) // @@ AliceAndClubScopes
|
|
185
184
|
})
|
|
186
185
|
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,33 +2,32 @@
|
|
|
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: Request[] = []
|
|
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
|
|
32
31
|
|
|
33
32
|
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
34
33
|
|
|
@@ -47,9 +46,9 @@ describe("utilityLogic", () => {
|
|
|
47
46
|
body: prefixes + contents, // Add namespaces to anything
|
|
48
47
|
status: 200,
|
|
49
48
|
headers: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
'Content-Type': 'text/turtle',
|
|
50
|
+
'WAC-Allow': 'user="write", public="read"',
|
|
51
|
+
'Accept-Patch': 'application/sparql-update'
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
} // if contents
|
|
@@ -71,25 +70,27 @@ describe("utilityLogic", () => {
|
|
|
71
70
|
web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
|
|
72
71
|
web[ClubPublicTypeIndex.uri] = ClubPublicTypes
|
|
73
72
|
|
|
74
|
-
options = { fetch: fetch }
|
|
73
|
+
options = { fetch: fetch }
|
|
75
74
|
store = new Store()
|
|
76
|
-
store.fetcher = new Fetcher(store, options)
|
|
77
|
-
store.updater = new UpdateManager(store)
|
|
75
|
+
store.fetcher = new Fetcher(store, options)
|
|
76
|
+
store.updater = new UpdateManager(store)
|
|
78
77
|
requests = []
|
|
79
78
|
utilityLogic = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
80
|
-
})
|
|
79
|
+
})
|
|
81
80
|
|
|
82
81
|
describe('loadOrCreateIfNotExists', () => {
|
|
83
82
|
it('exists', () => {
|
|
84
83
|
expect(utilityLogic.loadOrCreateIfNotExists).toBeInstanceOf(Function)
|
|
85
84
|
})
|
|
86
85
|
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
|
|
93
94
|
const result = await utilityLogic.loadOrCreateIfNotExists(sym(suggestion))
|
|
94
95
|
expect(requests[0].method).toEqual('PUT')
|
|
95
96
|
expect(requests[0].url).toEqual(suggestion)
|
|
@@ -126,32 +127,32 @@ describe("utilityLogic", () => {
|
|
|
126
127
|
})
|
|
127
128
|
|
|
128
129
|
})
|
|
129
|
-
describe(
|
|
130
|
+
describe('setSinglePeerAccess', () => {
|
|
130
131
|
beforeEach(() => {
|
|
131
132
|
fetchMock.mockOnceIf(
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
'https://owner.com/some/resource',
|
|
134
|
+
'hello', {
|
|
134
135
|
headers: {
|
|
135
136
|
Link: '<https://owner.com/some/acl>; rel="acl"'
|
|
136
137
|
}
|
|
137
|
-
})
|
|
138
|
+
})
|
|
138
139
|
fetchMock.mockOnceIf(
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
'https://owner.com/some/acl',
|
|
141
|
+
'Created', {
|
|
141
142
|
status: 201
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
it(
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
it('Creates the right ACL doc', async () => {
|
|
145
146
|
await utilityLogic.setSinglePeerAccess({
|
|
146
|
-
ownerWebId:
|
|
147
|
-
peerWebId:
|
|
148
|
-
accessToModes:
|
|
149
|
-
defaultModes:
|
|
150
|
-
target:
|
|
151
|
-
})
|
|
147
|
+
ownerWebId: 'https://owner.com/#me',
|
|
148
|
+
peerWebId: 'https://peer.com/#me',
|
|
149
|
+
accessToModes: 'acl:Read, acl:Control',
|
|
150
|
+
defaultModes: 'acl:Write',
|
|
151
|
+
target: 'https://owner.com/some/resource'
|
|
152
|
+
})
|
|
152
153
|
expect(fetchMock.mock.calls).toEqual([
|
|
153
|
-
[
|
|
154
|
-
[
|
|
154
|
+
[ 'https://owner.com/some/resource', fetchMock.mock.calls[0][1] ],
|
|
155
|
+
[ 'https://owner.com/some/acl', {
|
|
155
156
|
body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
|
|
156
157
|
'\n' +
|
|
157
158
|
'<#alice> a acl:Authorization;\n' +
|
|
@@ -168,12 +169,12 @@ describe("setSinglePeerAccess", () => {
|
|
|
168
169
|
' acl:default <https://owner.com/some/resource>;\n' +
|
|
169
170
|
' acl:mode acl:Write.\n',
|
|
170
171
|
headers: [
|
|
171
|
-
[
|
|
172
|
+
['Content-Type', 'text/turtle']
|
|
172
173
|
],
|
|
173
|
-
method:
|
|
174
|
+
method: 'PUT'
|
|
174
175
|
}]
|
|
175
|
-
])
|
|
176
|
-
})
|
|
177
|
-
})
|
|
176
|
+
])
|
|
177
|
+
})
|
|
178
|
+
})
|
|
178
179
|
|
|
179
180
|
})
|
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/timestamp.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
echo "export default {"
|
|
4
|
+
date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",'
|
|
5
|
+
git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/'
|
|
6
|
+
echo " npmInfo: {"
|
|
7
|
+
npm version | sed 's/\x1b\[[0-9;:]*[mG]//g' | grep -v '^{' | while read line; do
|
|
8
|
+
key=$(echo "$line" | cut -d ':' -f 1 | tr -d ' ')
|
|
9
|
+
value=$(echo "$line" | cut -d ':' -f 2- | tr -d ' ')
|
|
10
|
+
echo " \"${key}\": \"${value}\","
|
|
11
|
+
done
|
|
12
|
+
echo " }"
|
|
13
|
+
echo "};"
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Basic Options */
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
"target": "ES2020", /* Allow top-level await and modern JS features. */
|
|
5
|
+
"module": "ESNext", /* Use ESNext modules for Webpack/Babel compatibility. */
|
|
6
|
+
"moduleResolution": "node", /* Use Node.js-style module resolution for Webpack compatibility. */
|
|
6
7
|
"lib": [
|
|
7
8
|
"dom",
|
|
8
9
|
"es2015",
|
|
@@ -71,5 +72,6 @@
|
|
|
71
72
|
},
|
|
72
73
|
"include": [
|
|
73
74
|
"src/**/*"
|
|
74
|
-
]
|
|
75
|
+
],
|
|
76
|
+
"exclude": ["node_modules"]
|
|
75
77
|
}
|