Skip to content

Commit cf3122e

Browse files
authored
Merge pull request #26 from solid/move-logic
take solidLogic from rdflib
2 parents 233102d + d6c2ce6 commit cf3122e

File tree

7 files changed

+35
-34
lines changed

7 files changed

+35
-34
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-logic",
3-
"version": "1.3.12",
3+
"version": "1.3.12-bbf45639",
44
"description": "Core business logic of Solid OS",
55
"main": "lib/index.js",
66
"scripts": {
@@ -41,7 +41,7 @@
4141
"typescript": "4.5.4"
4242
},
4343
"dependencies": {
44-
"rdflib": "^2.2.15",
44+
"rdflib": "^2.2.15-bbf45639",
4545
"solid-namespace": "^0.5.2"
4646
}
4747
}

src/chat/ChatLogic.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { NamedNode, Node, st, term } from "rdflib";
2-
import { LiveStore, SolidNamespace } from "../index";
1+
import { LiveStore, NamedNode, Node, st, term } from "rdflib";
2+
import { SolidNamespace } from "../index";
33
import { ProfileLogic } from "../profile/ProfileLogic";
44
import { newThing } from "../uri";
55
import { determineChatContainer } from "./determineChatContainer";
@@ -38,7 +38,7 @@ export class ChatLogic {
3838
// Some servers don't present a Link http response header
3939
// if the container doesn't exist yet, so refetch the container
4040
// now that it has been created:
41-
await this.store.fetcher.load(chatContainer);
41+
await this.store.fetcher?.load(chatContainer);
4242

4343
// FIXME: check the Why value on this quad:
4444
const chatAclDoc = this.store.any(
@@ -66,7 +66,7 @@ export class ChatLogic {
6666
acl:mode
6767
acl:Read, acl:Append.
6868
`;
69-
await this.store.fetcher.webOperation("PUT", chatAclDoc.value, {
69+
await this.store.fetcher?.webOperation("PUT", chatAclDoc.value, {
7070
data: aclBody,
7171
contentType: "text/turtle",
7272
});
@@ -81,7 +81,7 @@ export class ChatLogic {
8181
if (!privateTypeIndex) {
8282
throw new Error("Private type index not found!");
8383
}
84-
await this.store.fetcher.load(privateTypeIndex);
84+
await this.store.fetcher?.load(privateTypeIndex);
8585
const reg = newThing(privateTypeIndex);
8686
const ins = [
8787
st(
@@ -99,7 +99,7 @@ export class ChatLogic {
9999
st(reg, this.ns.solid("instance"), chatThing, privateTypeIndex.doc()),
100100
];
101101
await new Promise((resolve, reject) => {
102-
this.store.updater.update([], ins, function (_uri, ok, errm) {
102+
this.store.updater?.update([], ins, function (_uri, ok, errm) {
103103
if (!ok) {
104104
reject(new Error(errm));
105105
} else {
@@ -115,7 +115,7 @@ export class ChatLogic {
115115
const chatContainer = determineChatContainer(invitee, podRoot);
116116
let exists = true;
117117
try {
118-
await this.store.fetcher.load(
118+
await this.store.fetcher?.load(
119119
new NamedNode(chatContainer.value + "index.ttl#this")
120120
);
121121
} catch (e) {
@@ -165,7 +165,7 @@ export class ChatLogic {
165165
}
166166

167167
return new Promise(function (resolve, reject) {
168-
updater.put(
168+
updater?.put(
169169
newChatDoc,
170170
kb.statementsMatching(undefined, undefined, undefined, newChatDoc),
171171
"text/turtle",
@@ -213,7 +213,7 @@ export class ChatLogic {
213213
}
214214

215215
private async sendInvite(invitee: NamedNode, chatThing: NamedNode) {
216-
await this.store.fetcher.load(invitee.doc());
216+
await this.store.fetcher?.load(invitee.doc());
217217
const inviteeInbox = this.store.any(
218218
invitee,
219219
this.ns.ldp("inbox"),
@@ -228,17 +228,17 @@ export class ChatLogic {
228228
${this.ns.rdf("seeAlso")} <${chatThing.value}> .
229229
`;
230230

231-
const inviteResponse = await this.store.fetcher.webOperation(
231+
const inviteResponse = await this.store.fetcher?.webOperation(
232232
"POST",
233233
inviteeInbox.value,
234234
{
235235
data: inviteBody,
236236
contentType: "text/turtle",
237237
}
238238
);
239-
const locationStr = inviteResponse.headers.get("location");
239+
const locationStr = inviteResponse?.headers.get("location");
240240
if (!locationStr) {
241-
throw new Error(`Invite sending returned a ${inviteResponse.status}`);
241+
throw new Error(`Invite sending returned a ${inviteResponse?.status}`);
242242
}
243243
}
244244
}

src/inbox/InboxLogic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// import { v4 as uuid } from "uuid";
2-
import { NamedNode, Node, st, term } from "rdflib";
3-
import { LiveStore, SolidNamespace } from "../index";
2+
import { LiveStore, NamedNode, Node, st, term } from "rdflib";
3+
import { SolidNamespace } from "../index";
44
import { ProfileLogic } from "../profile/ProfileLogic";
55
import { UtilityLogic } from "../util/UtilityLogic";
66
// import { newThing } from "../uri";
@@ -70,7 +70,7 @@ export class InboxLogic {
7070
};
7171
const uploaded = await this.util.fetcher.fetch(archiveUrl, options);
7272
if (uploaded.status.toString()[0] === '2') {
73-
await this.store.fetcher._fetch(url, {
73+
await this.store.fetcher?._fetch(url, {
7474
method: 'DELETE'
7575
});
7676
}

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ import { ChatLogic } from "./chat/ChatLogic";
1010
import * as debug from "./debug";
1111
import { ProfileLogic } from "./profile/ProfileLogic";
1212
import { UtilityLogic } from "./util/UtilityLogic";
13+
import { ConnectedStore, LiveStore } from 'rdflib'
1314

1415
export { ACL_LINK } from './util/UtilityLogic';
1516

1617
const ns: SolidNamespace = solidNamespace(rdf);
1718

18-
interface ConnectedStore extends Store {
19+
/* interface ConnectedStore extends Store {
1920
fetcher: Fetcher;
2021
}
2122
2223
export interface LiveStore extends ConnectedStore {
2324
updater: UpdateManager;
24-
}
25+
} */
2526

2627
export interface SolidNamespace {
2728
[key: string]: (term: string) => NamedNode;

src/profile/ProfileLogic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { NamedNode } from "rdflib";
1+
import { LiveStore, NamedNode } from "rdflib";
22
import { AuthnLogic } from "../authn";
3-
import { LiveStore, SolidNamespace } from "../index";
3+
import { SolidNamespace } from "../index";
44

55
export class ProfileLogic {
66
store: LiveStore;
@@ -18,7 +18,7 @@ export class ProfileLogic {
1818
if (me === null) {
1919
throw new Error("Current user not found! Not logged in?");
2020
}
21-
await this.store.fetcher.load(me.doc());
21+
await this.store.fetcher?.load(me.doc());
2222
return me;
2323
}
2424

@@ -31,7 +31,7 @@ export class ProfileLogic {
3131
}
3232

3333
async getMainInbox(user: NamedNode): Promise<NamedNode> {
34-
await this.store.fetcher.load(user);
34+
await this.store.fetcher?.load(user);
3535
const mainInbox = this.store.any(user, this.ns.ldp("inbox"), undefined, user.doc());
3636
if (!mainInbox) {
3737
throw new Error("User main inbox not found!");

src/util/UtilityLogic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { NamedNode, Node, st, term, sym, Statement } from "rdflib";
2-
import { LiveStore, SolidNamespace } from "../index";
1+
import { LiveStore, NamedNode, Node, st, term, sym, Statement } from "rdflib";
2+
import { SolidNamespace } from "../index";
33
import { ProfileLogic } from "../profile/ProfileLogic";
44
import { newThing } from "../uri";
55

@@ -33,7 +33,7 @@ export class UtilityLogic {
3333

3434
async findAclDocUrl(url: string) {
3535
const doc = this.store.sym(url);
36-
await this.store.fetcher.load(doc);
36+
await this.store.fetcher?.load(doc);
3737
const docNode = this.store.any(doc, ACL_LINK);
3838
if (!docNode) {
3939
throw new Error(`No ACL link discovered for ${url}`);
@@ -137,7 +137,7 @@ export class UtilityLogic {
137137

138138
async getContainerMembers(containerUrl: string): Promise<string[]> {
139139
const containerNode = this.store.sym(containerUrl);
140-
await this.store.fetcher.load(containerNode);
140+
await this.store.fetcher?.load(containerNode);
141141
const nodes = this.getContainerElements(containerNode);
142142
return nodes.map(node => node.value);
143143
}

0 commit comments

Comments
 (0)