Skip to content

Commit ab00e7b

Browse files
committed
Merge branch 'main' into stringUrl
2 parents 6e0634d + f20ef74 commit ab00e7b

8 files changed

Lines changed: 2111 additions & 2535 deletions

File tree

package-lock.json

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

package.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-logic",
3-
"version": "1.3.17",
3+
"version": "2.1.2",
44
"description": "Core business logic of Solid OS",
55
"main": "lib/index.js",
66
"scripts": {
@@ -25,26 +25,24 @@
2525
},
2626
"homepage": "https://github.com/solidos/solid-logic#readme",
2727
"devDependencies": {
28-
"@babel/core": "^7.17.10",
29-
"@babel/plugin-proposal-class-properties": "~7.16.7",
30-
"@babel/plugin-proposal-optional-chaining": "~7.16.7",
31-
"@babel/plugin-transform-async-to-generator": "~7.16.8",
32-
"@babel/plugin-transform-runtime": "^7.17.0",
33-
"@babel/preset-env": "~7.16.11",
34-
"@babel/preset-typescript": "~7.16.7",
35-
"@types/jest": "^27.4.1",
36-
"@typescript-eslint/eslint-plugin": "^5.19.0",
37-
"@typescript-eslint/parser": "^5.19.0",
38-
"babel-jest": "^28.0.3",
39-
"eslint": "^8.13.0",
28+
"@babel/plugin-proposal-class-properties": "~7.18.6",
29+
"@babel/plugin-proposal-optional-chaining": "~7.20.7",
30+
"@babel/plugin-transform-async-to-generator": "~7.20.7",
31+
"@babel/plugin-transform-runtime": "^7.19.6",
32+
"@babel/preset-env": "~7.20.2",
33+
"@babel/preset-typescript": "~7.18.6",
34+
"@types/jest": "^27.5.2",
35+
"@typescript-eslint/eslint-plugin": "^5.50.0",
36+
"@typescript-eslint/parser": "^5.50.0",
37+
"eslint": "^8.33.0",
4038
"jest": "^27.5.1",
4139
"jest-environment-node-debug": "^2.0.0",
4240
"jest-fetch-mock": "^3.0.3",
43-
"typescript": "^4.6.3"
41+
"typescript": "^4.9.5"
4442
},
4543
"dependencies": {
46-
"@inrupt/solid-client-authn-browser": "^1.11.7",
47-
"rdflib": "^2.2.19",
44+
"@inrupt/solid-client-authn-browser": "^1.13.0",
45+
"rdflib": "^2.2.25",
4846
"solid-namespace": "^0.5.2"
4947
}
5048
}

src/inbox/inboxLogic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { InboxLogic } from "../types";
33
import { getArchiveUrl } from "../util/utils";
44

55
export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {
6-
6+
77
async function createInboxFor(peerWebId: string, nick: string) {
88
const myWebId: NamedNode = await profileLogic.loadMe();
99
const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId);
1010
const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`;
1111
await containerLogic.createContainer(ourInbox);
12-
const aclDocUrl = await aclLogic.findAclDocUrl(sym(ourInbox))
12+
// const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);
1313
await utilityLogic.setSinglePeerAccess({
1414
ownerWebId: myWebId.value,
1515
peerWebId,
@@ -55,4 +55,4 @@ export function createInboxLogic(store, profileLogic, utilityLogic, containerLog
5555
getNewMessages,
5656
markAsRead
5757
}
58-
}
58+
}

src/profile/profileLogic.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function createProfileLogic(store, authn, utilityLogic): ProfileLogic {
1111
/**
1212
* loads the preference without throwing errors - if it can create it it does so.
1313
* remark: it still throws error if it cannot load profile.
14-
* @param user
14+
* @param user
1515
* @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
1616
*/
1717
async function silencedLoadPreferences(user: NamedNode): Promise <NamedNode | undefined> {
@@ -25,7 +25,7 @@ export function createProfileLogic(store, authn, utilityLogic): ProfileLogic {
2525
/**
2626
* loads the preference without returning different errors if it cannot create or load it.
2727
* remark: it also throws error if it cannot load profile.
28-
* @param user
28+
* @param user
2929
* @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
3030
*/
3131
async function loadPreferences (user: NamedNode): Promise <NamedNode> {
@@ -48,9 +48,8 @@ export function createProfileLogic(store, authn, utilityLogic): ProfileLogic {
4848
throw err
4949
}
5050

51-
let response
5251
try {
53-
response = await store.fetcher.load(preferencesFile as NamedNode)
52+
await store.fetcher.load(preferencesFile as NamedNode)
5453
} catch (err) { // Maybe a permission problem or origin problem
5554
const msg = `Unable to load preference of user ${user}: ${err}`
5655
debug.warn(msg)
@@ -123,4 +122,3 @@ export function createProfileLogic(store, authn, utilityLogic): ProfileLogic {
123122
silencedLoadPreferences
124123
}
125124
}
126-

src/typeIndex/typeIndexLogic.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NamedNode, st, sym } from 'rdflib'
22
import { ScopedApp, TypeIndexLogic, TypeIndexScope } from '../types'
33
import * as debug from "../util/debug"
44
import { ns as namespace } from '../util/ns'
5-
import { newThing, uniqueNodes } from "../util/utils"
5+
import { newThing } from "../util/utils"
66

77
export function createTypeIndexLogic(store, authn, profileLogic, utilityLogic): TypeIndexLogic {
88
const ns = namespace
@@ -155,29 +155,27 @@ export function createTypeIndexLogic(store, authn, profileLogic, utilityLogic):
155155

156156
async function getScopedAppsFromIndex(scope: TypeIndexScope, theClass: NamedNode | null): Promise<ScopedApp[]> {
157157
const index = scope.index
158+
const results: ScopedApp[] = []
158159
const registrations = store.statementsMatching(null, ns.solid('instance'), null, index)
159160
.concat(store.statementsMatching(null, ns.solid('instanceContainer'), null, index))
160161
.map(st => st.subject)
161-
const relevant = theClass ? registrations.filter(reg => store.any(reg, ns.solid('forClass'), null, index)?.sameTerm(theClass))
162-
: registrations
163-
const directInstances = relevant.map(reg => store.each(reg, ns.solid('instance'), null, index).map(one => sym(one.value))).flat()
164-
let instances = uniqueNodes(directInstances)
165-
166-
const instanceContainers = relevant.map(
167-
reg => store.each(reg, ns.solid('instanceContainer'), null, index).map(one => sym(one.value))).flat()
168-
169-
// instanceContainers may be deprocatable if no one has used them
170-
const containers = uniqueNodes(instanceContainers)
171-
if (containers.length > 0) { console.log('@@ getScopedAppsFromIndex containers ', containers) }
172-
for (let i = 0; i < containers.length; i++) {
173-
const cont = containers[i]
174-
await store.fetcher.load(cont)
175-
const contents = store.each(cont, ns.ldp('contains'), null, cont).map(one => sym(one.value))
176-
instances = instances.concat(contents)
162+
for (const reg of registrations) {
163+
const klass = store.any(reg, ns.solid('forClass'), null, index)
164+
if (!theClass || klass.sameTerm(theClass)) {
165+
const instances = store.each(reg, ns.solid('instance'), null, index)
166+
for (const instance of instances) {
167+
results.push({ instance, type: klass, scope })
168+
}
169+
const containers = store.each(reg, ns.solid('instanceContainer'), null, index)
170+
for (const instance of containers) {
171+
await store.fetcher.load(instance)
172+
results.push({ instance: sym(instance.value), type: klass, scope })
173+
}
174+
}
177175
}
178-
return instances.map(instance => { return { instance, scope } })
176+
return results
179177
}
180-
178+
181179
return {
182180
registerInTypeIndex,
183181
getRegistrations,

src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface SolidNamespace {
3333
}
3434

3535
export type TypeIndexScope = { label: string, index: NamedNode, agent: NamedNode }
36-
export type ScopedApp = { instance: NamedNode, scope: TypeIndexScope }
36+
export type ScopedApp = { instance: NamedNode, type: NamedNode, scope: TypeIndexScope }
3737

3838
export interface NewPaneOptions {
3939
me?: NamedNode;
@@ -119,4 +119,3 @@ export interface SolidLogic {
119119
updatePromise: (del: Array<Statement>, ins: Array<Statement>) => Promise<void>,
120120
clearStore: () => void
121121
}
122-

test/container.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ describe("Container", () => {
2828
'https://container.com/bar/'
2929
].sort());
3030
});
31-
it("getContainerMembers- When container is empty - Resolves to an empty array", async () => {
31+
it.skip("getContainerMembers- When container is empty - Resolves to an empty array", async () => {
32+
jest.setTimeout(2000)
3233
containerIsEmpty();
3334
const result = await containerLogic.getContainerMembers(sym('https://container.com/'));
3435
expect(result).toEqual([]);
@@ -37,7 +38,7 @@ describe("Container", () => {
3738
function containerIsEmpty() {
3839
fetchMock.mockOnceIf(
3940
"https://com/",
40-
" ", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
41+
"", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
4142
{
4243
headers: { "Content-Type": "text/turtle" },
4344
}

0 commit comments

Comments
 (0)