solid-logic 3.1.1-fafcec1 → 4.0.0-3e8294e
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/README.md +129 -2
- package/dist/acl/aclLogic.d.ts +5 -0
- package/{lib → dist}/acl/aclLogic.d.ts.map +1 -1
- package/dist/acl/aclLogic.js +117 -0
- package/dist/acl/aclLogic.js.map +1 -0
- package/dist/authSession/authSession.js +3 -0
- package/dist/authSession/authSession.js.map +1 -0
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/dist/authn/SolidAuthnLogic.js +109 -0
- package/dist/authn/SolidAuthnLogic.js.map +1 -0
- package/{lib → dist}/authn/authUtil.d.ts +1 -1
- package/dist/authn/authUtil.d.ts.map +1 -0
- package/dist/authn/authUtil.js +64 -0
- package/dist/authn/authUtil.js.map +1 -0
- package/{lib → dist}/chat/chatLogic.d.ts +1 -1
- package/{lib → dist}/chat/chatLogic.d.ts.map +1 -1
- package/dist/chat/chatLogic.js +157 -0
- package/dist/chat/chatLogic.js.map +1 -0
- package/{lib → dist}/inbox/inboxLogic.d.ts +1 -1
- package/{lib → dist}/inbox/inboxLogic.d.ts.map +1 -1
- package/dist/inbox/inboxLogic.js +51 -0
- package/dist/inbox/inboxLogic.js.map +1 -0
- package/{lib → dist}/index.d.ts +1 -1
- package/{lib → dist}/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/issuer/issuerLogic.js +37 -0
- package/dist/issuer/issuerLogic.js.map +1 -0
- package/{lib → dist}/logic/CustomError.d.ts.map +1 -1
- package/dist/logic/CustomError.js +27 -0
- package/dist/logic/CustomError.js.map +1 -0
- package/dist/logic/solidLogic.d.ts +6 -0
- package/{lib → dist}/logic/solidLogic.d.ts.map +1 -1
- package/dist/logic/solidLogic.js +64 -0
- package/dist/logic/solidLogic.js.map +1 -0
- package/dist/logic/solidLogicSingleton.d.ts +4 -0
- package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +1 -1
- package/dist/logic/solidLogicSingleton.js +31 -0
- package/dist/logic/solidLogicSingleton.js.map +1 -0
- package/{lib → dist}/profile/profileLogic.d.ts +1 -1
- package/{lib → dist}/profile/profileLogic.d.ts.map +1 -1
- package/dist/profile/profileLogic.js +128 -0
- package/dist/profile/profileLogic.js.map +1 -0
- package/dist/solid-logic.esm.js +7356 -0
- package/dist/solid-logic.esm.js.map +1 -0
- package/dist/solid-logic.esm.min.js +32 -0
- package/dist/solid-logic.esm.min.js.map +1 -0
- package/dist/solid-logic.js +7415 -0
- package/dist/solid-logic.js.map +1 -0
- package/dist/solid-logic.min.js +32 -0
- package/dist/solid-logic.min.js.map +1 -0
- package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/dist/typeIndex/typeIndexLogic.js +182 -0
- package/dist/typeIndex/typeIndexLogic.js.map +1 -0
- package/{lib → dist}/types.d.ts +2 -2
- package/{lib → dist}/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/{lib → dist}/util/containerLogic.d.ts +1 -1
- package/{lib → dist}/util/containerLogic.d.ts.map +1 -1
- package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +15 -23
- package/dist/util/containerLogic.js.map +1 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/debug.js +13 -0
- package/dist/util/debug.js.map +1 -0
- package/dist/util/ns.js +5 -0
- package/dist/util/ns.js.map +1 -0
- package/{lib → dist}/util/utilityLogic.d.ts +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts.map +1 -1
- package/dist/util/utilityLogic.js +144 -0
- package/dist/util/utilityLogic.js.map +1 -0
- package/{lib → dist}/util/utils.d.ts +1 -1
- package/{lib → dist}/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +39 -0
- package/dist/util/utils.js.map +1 -0
- package/dist/versionInfo.js +30 -0
- package/dist/versionInfo.js.map +1 -0
- package/package.json +51 -23
- package/eslint.config.js +0 -29
- package/jest.config.js +0 -10
- package/lib/acl/aclLogic.d.ts +0 -5
- 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.d.ts.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 -31
- 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.d.ts +0 -6
- package/lib/logic/solidLogic.js +0 -102
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.d.ts +0 -3
- 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/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.d.ts.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
- package/src/acl/aclLogic.ts +0 -156
- package/src/authSession/authSession.ts +0 -7
- package/src/authn/SolidAuthnLogic.ts +0 -127
- package/src/authn/authUtil.ts +0 -70
- package/src/chat/chatLogic.ts +0 -226
- package/src/inbox/inboxLogic.ts +0 -59
- package/src/index.ts +0 -22
- package/src/issuer/issuerLogic.ts +0 -40
- package/src/logic/CustomError.ts +0 -29
- package/src/logic/solidLogic.ts +0 -76
- package/src/logic/solidLogicSingleton.ts +0 -20
- package/src/profile/profileLogic.ts +0 -125
- package/src/typeIndex/typeIndexLogic.ts +0 -198
- package/src/types.ts +0 -122
- package/src/util/debug.ts +0 -20
- package/src/util/ns.ts +0 -5
- package/src/util/utilityLogic.ts +0 -156
- package/src/util/utils.ts +0 -52
- package/test/aclLogic.test.ts +0 -24
- package/test/authUtil.test.ts +0 -23
- package/test/chatLogic.test.ts +0 -316
- package/test/container.test.ts +0 -58
- package/test/helpers/dataSetup.ts +0 -134
- package/test/helpers/setup.ts +0 -17
- package/test/inboxLogic.test.ts +0 -218
- package/test/logic.test.ts +0 -29
- package/test/profileLogic.test.ts +0 -246
- package/test/solidAuthLogic.test.ts +0 -49
- package/test/typeIndexLogic.test.ts +0 -255
- package/test/utilityLogic.test.ts +0 -179
- package/test/utils.test.ts +0 -32
- package/tsconfig.json +0 -75
- /package/{lib → dist}/authSession/authSession.d.ts +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{lib → dist}/types.js.map +0 -0
- /package/{lib → dist}/util/debug.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts.map +0 -0
package/test/chatLogic.test.ts
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher } from "rdflib";
|
|
6
|
-
import { createAclLogic } from "../src/acl/aclLogic";
|
|
7
|
-
import { createChatLogic } from '../src/chat/chatLogic';
|
|
8
|
-
import { createProfileLogic } from "../src/profile/profileLogic";
|
|
9
|
-
import { createContainerLogic } from "../src/util/containerLogic";
|
|
10
|
-
import { createUtilityLogic } from "../src/util/utilityLogic";
|
|
11
|
-
import { alice, bob } from "./helpers/dataSetup";
|
|
12
|
-
|
|
13
|
-
window.$SolidTestEnvironment = { username: alice.uri }
|
|
14
|
-
|
|
15
|
-
describe("Chat logic", () => {
|
|
16
|
-
let chatLogic;
|
|
17
|
-
let store;
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
fetchMock.resetMocks();
|
|
20
|
-
fetchMock.mockResponse("Not Found", {
|
|
21
|
-
status: 404,
|
|
22
|
-
});
|
|
23
|
-
store = new Store()
|
|
24
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
25
|
-
store.updater = new UpdateManager(store);
|
|
26
|
-
const authn = {
|
|
27
|
-
currentUser: () => {
|
|
28
|
-
return alice;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
32
|
-
chatLogic = createChatLogic(store, createProfileLogic(store, authn, util))
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("get chat, without creating", () => {
|
|
36
|
-
describe("when no chat exists yet", () => {
|
|
37
|
-
let result;
|
|
38
|
-
beforeEach(async () => {
|
|
39
|
-
aliceHasValidProfile();
|
|
40
|
-
noChatWithBobExists();
|
|
41
|
-
result = await chatLogic.getChat(bob, false);
|
|
42
|
-
});
|
|
43
|
-
it("does not return a chat", async () => {
|
|
44
|
-
expect(result).toBeNull();
|
|
45
|
-
});
|
|
46
|
-
it("loaded the current user profile", () => {
|
|
47
|
-
expect(fetchMock.mock.calls[0][0]).toBe(
|
|
48
|
-
"https://alice.example.com/profile/card.ttl"
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
it("tried to load the chat document", () => {
|
|
52
|
-
expect(fetchMock.mock.calls[1][0]).toBe(
|
|
53
|
-
"https://alice.example.com/IndividualChats/bob.example.com/index.ttl"
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
it("has no additional fetch requests", () => {
|
|
57
|
-
expect(fetchMock.mock.calls.length).toBe(2);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("get chat, create if missing", () => {
|
|
63
|
-
describe("when no chat exists yet", () => {
|
|
64
|
-
let result;
|
|
65
|
-
beforeEach(async () => {
|
|
66
|
-
Date.now = jest.fn(() =>
|
|
67
|
-
new Date(Date.UTC(2021, 1, 6, 10, 11, 12)).valueOf()
|
|
68
|
-
);
|
|
69
|
-
aliceHasValidProfile();
|
|
70
|
-
noChatWithBobExists();
|
|
71
|
-
chatWithBobCanBeCreated();
|
|
72
|
-
bobHasAnInbox();
|
|
73
|
-
invitationCanBeSent();
|
|
74
|
-
chatContainerIsFound();
|
|
75
|
-
chatContainerAclCanBeSet();
|
|
76
|
-
editablePrivateTypeIndexIsFound();
|
|
77
|
-
privateTypeIndexIsUpdated();
|
|
78
|
-
result = await chatLogic.getChat(bob, true);
|
|
79
|
-
});
|
|
80
|
-
it("returns the chat URI based on the invitee's WebID", () => {
|
|
81
|
-
expect(result.uri).toBe(
|
|
82
|
-
"https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this"
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
it("created a chat document", () => {
|
|
86
|
-
const request = getRequestTo(
|
|
87
|
-
"PUT",
|
|
88
|
-
"https://alice.example.com/IndividualChats/bob.example.com/index.ttl"
|
|
89
|
-
);
|
|
90
|
-
expect(request.body).toBe(`@prefix : <#>.
|
|
91
|
-
@prefix dc: <http://purl.org/dc/elements/1.1/>.
|
|
92
|
-
@prefix meeting: <http://www.w3.org/ns/pim/meeting#>.
|
|
93
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
94
|
-
@prefix c: </profile/card.ttl#>.
|
|
95
|
-
|
|
96
|
-
:this
|
|
97
|
-
a meeting:LongChat;
|
|
98
|
-
dc:author c:me;
|
|
99
|
-
dc:created "2021-02-06T10:11:12Z"^^xsd:dateTime;
|
|
100
|
-
dc:title "Chat channel".
|
|
101
|
-
`);
|
|
102
|
-
});
|
|
103
|
-
it("allowed Bob to participate in the chat by adding an ACL", () => {
|
|
104
|
-
const request = getRequestTo(
|
|
105
|
-
"PUT",
|
|
106
|
-
"https://alice.example.com/IndividualChats/bob.example.com/.acl"
|
|
107
|
-
);
|
|
108
|
-
expect(request.body).toBe(`
|
|
109
|
-
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
|
|
110
|
-
<#owner>
|
|
111
|
-
a acl:Authorization;
|
|
112
|
-
acl:agent <https://alice.example.com/profile/card.ttl#me>;
|
|
113
|
-
acl:accessTo <.>;
|
|
114
|
-
acl:default <.>;
|
|
115
|
-
acl:mode
|
|
116
|
-
acl:Read, acl:Write, acl:Control.
|
|
117
|
-
<#invitee>
|
|
118
|
-
a acl:Authorization;
|
|
119
|
-
acl:agent <https://bob.example.com/profile/card.ttl#me>;
|
|
120
|
-
acl:accessTo <.>;
|
|
121
|
-
acl:default <.>;
|
|
122
|
-
acl:mode
|
|
123
|
-
acl:Read, acl:Append.
|
|
124
|
-
`);
|
|
125
|
-
});
|
|
126
|
-
it("sent an invitation to invitee inbox", () => {
|
|
127
|
-
const request = getRequestTo("POST", "https://bob.example.com/inbox");
|
|
128
|
-
expect(request.body).toContain(`
|
|
129
|
-
<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
|
|
130
|
-
<http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso> <https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this> .
|
|
131
|
-
`);
|
|
132
|
-
});
|
|
133
|
-
it("added the new chat to private type index", () => {
|
|
134
|
-
const request = getRequestTo(
|
|
135
|
-
"PATCH",
|
|
136
|
-
"https://alice.example.com/settings/privateTypeIndex.ttl"
|
|
137
|
-
);
|
|
138
|
-
expect(request.body)
|
|
139
|
-
.toBe(`INSERT DATA { <https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/solid/terms#TypeRegistration> .
|
|
140
|
-
<https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/ns/solid/terms#forClass> <http://www.w3.org/ns/pim/meeting#LongChat> .
|
|
141
|
-
<https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/ns/solid/terms#instance> <https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this> .
|
|
142
|
-
}
|
|
143
|
-
`);
|
|
144
|
-
});
|
|
145
|
-
it("has no additional fetch requests", () => {
|
|
146
|
-
expect(fetchMock.mock.calls.length).toBe(9);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe("possible errors", () => {
|
|
152
|
-
it("profile does not link to storage", async () => {
|
|
153
|
-
fetchMock.mockOnceIf("https://alice.example.com/profile/card.ttl", "<><><>.", {
|
|
154
|
-
headers: {
|
|
155
|
-
"Content-Type": "text/turtle",
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
const expectedError = new Error("User pod root not found!");
|
|
159
|
-
await expect(chatLogic.getChat(bob, false)).rejects.toEqual(expectedError);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("invitee inbox not found", async () => {
|
|
163
|
-
aliceHasValidProfile();
|
|
164
|
-
noChatWithBobExists();
|
|
165
|
-
chatWithBobCanBeCreated();
|
|
166
|
-
bobDoesNotHaveAnInbox();
|
|
167
|
-
const expectedError = new Error(
|
|
168
|
-
"Invitee inbox not found! https://bob.example.com/profile/card.ttl#me"
|
|
169
|
-
);
|
|
170
|
-
await expect(chatLogic.getChat(bob, true)).rejects.toEqual(expectedError);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
function aliceHasValidProfile() {
|
|
175
|
-
fetchMock.mockOnceIf(
|
|
176
|
-
"https://alice.example.com/profile/card.ttl",
|
|
177
|
-
`
|
|
178
|
-
<https://alice.example.com/profile/card.ttl#me>
|
|
179
|
-
<http://www.w3.org/ns/pim/space#storage> <https://alice.example.com/> ;
|
|
180
|
-
<http://www.w3.org/ns/solid/terms#privateTypeIndex> <https://alice.example.com/settings/privateTypeIndex.ttl> ;
|
|
181
|
-
.`,
|
|
182
|
-
{
|
|
183
|
-
headers: {
|
|
184
|
-
"Content-Type": "text/turtle",
|
|
185
|
-
},
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function noChatWithBobExists() {
|
|
191
|
-
return fetchMock.mockOnceIf(
|
|
192
|
-
({ url, method }) =>
|
|
193
|
-
url === "https://alice.example.com/IndividualChats/bob.example.com/index.ttl" &&
|
|
194
|
-
method === "GET",
|
|
195
|
-
"Not found",
|
|
196
|
-
{
|
|
197
|
-
status: 404,
|
|
198
|
-
}
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function chatWithBobCanBeCreated() {
|
|
203
|
-
return fetchMock.mockOnceIf(
|
|
204
|
-
({ url, method }) =>
|
|
205
|
-
url === "https://alice.example.com/IndividualChats/bob.example.com/index.ttl" &&
|
|
206
|
-
method === "PUT",
|
|
207
|
-
"Created",
|
|
208
|
-
{
|
|
209
|
-
status: 201,
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function bobHasAnInbox() {
|
|
215
|
-
fetchMock.mockOnceIf(
|
|
216
|
-
"https://bob.example.com/profile/card.ttl",
|
|
217
|
-
"<https://bob.example.com/profile/card.ttl#me><http://www.w3.org/ns/ldp#inbox><https://bob.example.com/inbox>.",
|
|
218
|
-
{
|
|
219
|
-
headers: { "Content-Type": "text/turtle" },
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function bobDoesNotHaveAnInbox() {
|
|
225
|
-
fetchMock.mockOnceIf("https://bob.example.com/profile/card.ttl", "<><><>.", {
|
|
226
|
-
headers: {
|
|
227
|
-
"Content-Type": "text/turtle",
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function invitationCanBeSent() {
|
|
233
|
-
return fetchMock.mockOnceIf(
|
|
234
|
-
({ url, method }) =>
|
|
235
|
-
url === "https://bob.example.com/inbox" && method === "POST",
|
|
236
|
-
"Created",
|
|
237
|
-
{
|
|
238
|
-
status: 201,
|
|
239
|
-
headers: {
|
|
240
|
-
location:
|
|
241
|
-
"https://bob.example.com/inbox/22373339-6cc0-49fc-b69e-0402edda6e4e.ttl",
|
|
242
|
-
},
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function chatContainerIsFound() {
|
|
248
|
-
return fetchMock.mockOnceIf(
|
|
249
|
-
({ url, method }) =>
|
|
250
|
-
url === "https://alice.example.com/IndividualChats/bob.example.com/" &&
|
|
251
|
-
method === "GET",
|
|
252
|
-
"<><><>.",
|
|
253
|
-
{
|
|
254
|
-
status: 200,
|
|
255
|
-
headers: {
|
|
256
|
-
"Content-Type": "text/turtle",
|
|
257
|
-
Link: '<.acl>; rel="acl"',
|
|
258
|
-
},
|
|
259
|
-
}
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function chatContainerAclCanBeSet() {
|
|
264
|
-
return fetchMock.mockOnceIf(
|
|
265
|
-
({ url, method }) =>
|
|
266
|
-
url === "https://alice.example.com/IndividualChats/bob.example.com/.acl" &&
|
|
267
|
-
method === "PUT",
|
|
268
|
-
"Created",
|
|
269
|
-
{
|
|
270
|
-
status: 201,
|
|
271
|
-
}
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function editablePrivateTypeIndexIsFound() {
|
|
276
|
-
return fetchMock.mockOnceIf(
|
|
277
|
-
({ url, method }) =>
|
|
278
|
-
url === "https://alice.example.com/settings/privateTypeIndex.ttl" &&
|
|
279
|
-
method === "GET",
|
|
280
|
-
"<><><>.",
|
|
281
|
-
{
|
|
282
|
-
status: 200,
|
|
283
|
-
headers: {
|
|
284
|
-
"Content-Type": "text/turtle",
|
|
285
|
-
"wac-allow": 'user="read write append control",public=""',
|
|
286
|
-
"ms-author-via": "SPARQL",
|
|
287
|
-
},
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function privateTypeIndexIsUpdated() {
|
|
293
|
-
return fetchMock.mockOnceIf(
|
|
294
|
-
({ url, method }) =>
|
|
295
|
-
url === "https://alice.example.com/settings/privateTypeIndex.ttl" &&
|
|
296
|
-
method === "PATCH",
|
|
297
|
-
"OK",
|
|
298
|
-
{
|
|
299
|
-
status: 200,
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function getRequestTo(
|
|
305
|
-
method: "GET" | "PUT" | "POST" | "DELETE" | "PATCH",
|
|
306
|
-
url: string
|
|
307
|
-
): RequestInit {
|
|
308
|
-
const call = fetchMock.mock.calls.find(
|
|
309
|
-
(it) => it[0] === url && method === it[1]?.method
|
|
310
|
-
);
|
|
311
|
-
expect(call).not.toBeNull();
|
|
312
|
-
const request = call?.[1];
|
|
313
|
-
expect(request).not.toBeNull();
|
|
314
|
-
return request!;
|
|
315
|
-
}
|
|
316
|
-
});
|
package/test/container.test.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher, sym } from "rdflib";
|
|
6
|
-
import { createContainerLogic } from "../src/util/containerLogic";
|
|
7
|
-
import { alice } from "./helpers/dataSetup";
|
|
8
|
-
|
|
9
|
-
window.$SolidTestEnvironment = { username: alice.uri }
|
|
10
|
-
|
|
11
|
-
describe("Container", () => {
|
|
12
|
-
let store
|
|
13
|
-
let containerLogic
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
fetchMock.resetMocks()
|
|
16
|
-
store = new Store()
|
|
17
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
18
|
-
store.updater = new UpdateManager(store);
|
|
19
|
-
containerLogic = createContainerLogic(store)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it("getContainerMembers - When container has some containment triples", async () => {
|
|
23
|
-
containerHasSomeContainmentTriples()
|
|
24
|
-
const containerMembers = await containerLogic.getContainerMembers(sym('https://container.com/'));
|
|
25
|
-
const result = containerMembers.map(oneResult => oneResult.value)
|
|
26
|
-
expect(result.sort()).toEqual([
|
|
27
|
-
'https://container.com/foo.txt',
|
|
28
|
-
'https://container.com/bar/'
|
|
29
|
-
].sort());
|
|
30
|
-
});
|
|
31
|
-
it.skip("getContainerMembers- When container is empty - Resolves to an empty array", async () => {
|
|
32
|
-
jest.setTimeout(2000)
|
|
33
|
-
containerIsEmpty();
|
|
34
|
-
const result = await containerLogic.getContainerMembers(sym('https://container.com/'));
|
|
35
|
-
expect(result).toEqual([]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
function containerIsEmpty() {
|
|
39
|
-
fetchMock.mockOnceIf(
|
|
40
|
-
"https://com/",
|
|
41
|
-
"", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
|
|
42
|
-
{
|
|
43
|
-
headers: { "Content-Type": "text/turtle" },
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function containerHasSomeContainmentTriples() {
|
|
49
|
-
fetchMock.mockOnceIf(
|
|
50
|
-
"https://container.com/",
|
|
51
|
-
"<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .",
|
|
52
|
-
{
|
|
53
|
-
headers: { "Content-Type": "text/turtle" },
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
})
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { sym } from 'rdflib'
|
|
2
|
-
import * as rdf from "rdflib";
|
|
3
|
-
import solidNamespace from "solid-namespace";
|
|
4
|
-
import { SolidNamespace } from '../../src/types';
|
|
5
|
-
const ns: SolidNamespace = solidNamespace(rdf);
|
|
6
|
-
|
|
7
|
-
//------ Club -------------------------------------------------------
|
|
8
|
-
const club = sym('https://club.example.com/profile/card.ttl#it')
|
|
9
|
-
const ClubPreferencesFile = sym('https://club.example.com/settings/prefs.ttl')
|
|
10
|
-
const ClubPublicTypeIndex = sym('https://club.example.com/profile/public-type-index.ttl')
|
|
11
|
-
const ClubPrivateTypeIndex = sym('https://club.example.com/settings/private-type-index.ttl')
|
|
12
|
-
|
|
13
|
-
const ClubProfile = `
|
|
14
|
-
|
|
15
|
-
<#it> a vcard:Organization;
|
|
16
|
-
space:preferencesFile ${ClubPreferencesFile};
|
|
17
|
-
solid:publicTypeIndex ${ClubPublicTypeIndex};
|
|
18
|
-
vcard:fn "Card Club" .
|
|
19
|
-
`
|
|
20
|
-
const ClubPreferences = `
|
|
21
|
-
${club} solid:privateTypeIndex ${ClubPrivateTypeIndex} .
|
|
22
|
-
`
|
|
23
|
-
const ClubPublicTypes = `
|
|
24
|
-
|
|
25
|
-
:chat1 solid:forClass meeting:LongChat; solid:instance <../publicStuff/ourChat.ttl#this> .
|
|
26
|
-
|
|
27
|
-
:todo solid:forClass wf:Tracker; solid:instance <../publicStuff/actionItems.ttl#this>.
|
|
28
|
-
|
|
29
|
-
:issues solid:forClass wf:Tracker; solid:instance <../project4/clubIssues.ttl#this>.
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const ClubPrivateTypes = `
|
|
33
|
-
:id1592319218311 solid:forClass wf:Tracker; solid:instance <../privateStuff/ToDo.ttl#this>.
|
|
34
|
-
|
|
35
|
-
:id1592319391415 solid:forClass wf:Tracker; solid:instance <../privateStuff/Goals.ttl#this>.
|
|
36
|
-
|
|
37
|
-
:id1595595377864 solid:forClass wf:Tracker; solid:instance <../privateStuff/tasks.ttl#this>.
|
|
38
|
-
|
|
39
|
-
:id1596123375929 solid:forClass meeting:Meeting; solid:instance <../project4/clubMeeting.ttl#this>.
|
|
40
|
-
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
//------ Alice -------------------------------------------------------
|
|
44
|
-
const alice = sym("https://alice.example.com/profile/card.ttl#me")
|
|
45
|
-
const AliceProfileFile = alice.doc()
|
|
46
|
-
const AlicePreferencesFile = sym('https://alice.example.com/settings/prefs.ttl')
|
|
47
|
-
const AlicePublicTypeIndex = sym('https://alice.example.com/profile/public-type-index.ttl')
|
|
48
|
-
const AlicePrivateTypeIndex = sym('https://alice.example.com/settings/private-type-index.ttl')
|
|
49
|
-
const AlicePhotoFolder = sym(alice.dir().uri + "Photos/")
|
|
50
|
-
const AliceProfile = `
|
|
51
|
-
<#me> a vcard:Individual;
|
|
52
|
-
space:preferencesFile ${AlicePreferencesFile};
|
|
53
|
-
solid:publicTypeIndex ${AlicePublicTypeIndex};
|
|
54
|
-
vcard:fn "Alice" .
|
|
55
|
-
`
|
|
56
|
-
const AlicePreferences = `
|
|
57
|
-
${alice} solid:privateTypeIndex ${AlicePrivateTypeIndex};
|
|
58
|
-
solid:community ${club} .
|
|
59
|
-
`
|
|
60
|
-
const AlicePublicTypes = `
|
|
61
|
-
|
|
62
|
-
:chat1 solid:forClass meeting:LongChat; solid:instance <../publicStuff/myChat.ttl#this> .
|
|
63
|
-
|
|
64
|
-
:todo solid:forClass wf:Tracker; solid:instance <../publicStuff/actionItems.ttl#this>.
|
|
65
|
-
|
|
66
|
-
:issues solid:forClass wf:Tracker; solid:instance <../project4/issues.ttl#this>.
|
|
67
|
-
|
|
68
|
-
:photos solid:forClass schema:Image; solid:instanceContainer ${AlicePhotoFolder} .
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
const AlicePrivateTypes = `
|
|
72
|
-
:id1592319218311 solid:forClass wf:Tracker; solid:instance <../privateStuff/ToDo.ttl#this>.
|
|
73
|
-
|
|
74
|
-
:id1592319391415 solid:forClass wf:Tracker; solid:instance <../privateStuff/Goals.ttl#this>.
|
|
75
|
-
|
|
76
|
-
:id1595595377864 solid:forClass wf:Tracker; solid:instance <../privateStuff/workingOn.ttl#this>.
|
|
77
|
-
|
|
78
|
-
:id1596123375929 solid:forClass meeting:Meeting; solid:instance <../project4/meeting1.ttl#this>.
|
|
79
|
-
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
const AlicePhotos = `
|
|
83
|
-
<>
|
|
84
|
-
a ldp:BasicContainer, ldp:Container;
|
|
85
|
-
dct:modified "2021-04-26T05:34:16Z"^^xsd:dateTime;
|
|
86
|
-
ldp:contains
|
|
87
|
-
<photo1.png>, <photo2.png>, <photo3.png> ;
|
|
88
|
-
stat:mtime 1619415256.541;
|
|
89
|
-
stat:size 4096 .
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
//------ Bob -------------------------------------------------------
|
|
93
|
-
const bob = sym('https://bob.example.com/profile/card.ttl#me')
|
|
94
|
-
|
|
95
|
-
const BobProfile = `
|
|
96
|
-
<#me> a vcard:Individual;
|
|
97
|
-
vcard:fn "Bob" .
|
|
98
|
-
`
|
|
99
|
-
|
|
100
|
-
//------ Boby -------------------------------------------------------
|
|
101
|
-
const boby = sym('https://boby.example.com/profile/card.ttl#me')
|
|
102
|
-
|
|
103
|
-
const BobyProfile = `
|
|
104
|
-
<#me> a vcard:Individual;
|
|
105
|
-
vcard:fn "Boby" .
|
|
106
|
-
`
|
|
107
|
-
export function loadWebObject() {
|
|
108
|
-
const web = {}
|
|
109
|
-
web[alice.doc().uri] = AliceProfile
|
|
110
|
-
web[AlicePreferencesFile.uri] = AlicePreferences
|
|
111
|
-
web[AlicePrivateTypeIndex.uri] = AlicePrivateTypes
|
|
112
|
-
web[AlicePublicTypeIndex.uri] = AlicePublicTypes
|
|
113
|
-
web[AlicePhotoFolder.uri] = AlicePhotos
|
|
114
|
-
web[bob.doc().uri] = BobProfile
|
|
115
|
-
web[boby.doc().uri] = BobyProfile
|
|
116
|
-
|
|
117
|
-
web[club.doc().uri] = ClubProfile
|
|
118
|
-
web[ClubPreferencesFile.uri] = ClubPreferences
|
|
119
|
-
web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
|
|
120
|
-
web[ClubPublicTypeIndex.uri] = ClubPublicTypes
|
|
121
|
-
return web
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function clearLocalStore(store) {
|
|
125
|
-
store.statements.slice().forEach(store.remove.bind(store))
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export {
|
|
129
|
-
alice, bob, boby, club,
|
|
130
|
-
AlicePhotoFolder, AlicePreferences, AlicePhotos, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AliceProfileFile, AlicePublicTypeIndex, AlicePublicTypes,
|
|
131
|
-
BobProfile,
|
|
132
|
-
ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes,
|
|
133
|
-
clearLocalStore
|
|
134
|
-
}
|
package/test/helpers/setup.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { error, log, trace, warn } from '../../src/util/debug'
|
|
2
|
-
import fetchMock from "jest-fetch-mock";
|
|
3
|
-
import { TextEncoder, TextDecoder } from 'util'
|
|
4
|
-
global.TextEncoder = TextEncoder
|
|
5
|
-
global.TextDecoder = TextDecoder
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
fetchMock.enableMocks();
|
|
9
|
-
// We don't want to output debug messages to console as part of the tests
|
|
10
|
-
jest.mock('../../src/util/debug')
|
|
11
|
-
|
|
12
|
-
export function silenceDebugMessages () {
|
|
13
|
-
(log as any).mockImplementation(() => null)
|
|
14
|
-
;(warn as any).mockImplementation(() => null)
|
|
15
|
-
;(error as any).mockImplementation(() => null)
|
|
16
|
-
;(trace as any).mockImplementation(() => null)
|
|
17
|
-
}
|