solid-logic 1.3.14-fd51b121 → 1.3.15-599d981c

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.
Files changed (39) hide show
  1. package/.github/workflows/ci.yml +0 -1
  2. package/.nvmrc +1 -0
  3. package/jest.config.js +1 -1
  4. package/lib/authn/SolidAuthnLogic.js +1 -1
  5. package/lib/authn/SolidAuthnLogic.js.map +1 -1
  6. package/lib/discovery/discoveryLogic.d.ts +40 -0
  7. package/lib/discovery/discoveryLogic.d.ts.map +1 -0
  8. package/lib/discovery/discoveryLogic.js +494 -0
  9. package/lib/discovery/discoveryLogic.js.map +1 -0
  10. package/lib/inbox/InboxLogic.js +2 -2
  11. package/lib/inbox/InboxLogic.js.map +1 -1
  12. package/lib/index.d.ts +1 -0
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +7 -1
  15. package/lib/index.js.map +1 -1
  16. package/lib/logic/SolidLogic.d.ts +2 -3
  17. package/lib/logic/SolidLogic.d.ts.map +1 -1
  18. package/lib/logic/SolidLogic.js +42 -41
  19. package/lib/logic/SolidLogic.js.map +1 -1
  20. package/lib/typeIndex/typeIndexLogic.d.ts +4 -4
  21. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  22. package/lib/typeIndex/typeIndexLogic.js +93 -31
  23. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  24. package/lib/util/UtilityLogic.d.ts +2 -2
  25. package/lib/util/UtilityLogic.d.ts.map +1 -1
  26. package/lib/util/UtilityLogic.js +6 -6
  27. package/lib/util/UtilityLogic.js.map +1 -1
  28. package/package.json +13 -13
  29. package/src/authn/SolidAuthnLogic.ts +5 -5
  30. package/src/discovery/discoveryLogic.ts +311 -0
  31. package/src/inbox/InboxLogic.ts +2 -2
  32. package/src/index.ts +10 -0
  33. package/src/logic/SolidLogic.ts +31 -32
  34. package/src/typeIndex/typeIndexLogic.ts +92 -61
  35. package/src/util/UtilityLogic.ts +8 -8
  36. package/test/chatLogic.test.ts +1 -1
  37. package/test/discoveryLogic.test.ts +740 -0
  38. package/test/helpers/setup.ts +3 -0
  39. package/test/typeIndexLogic.test.ts +9 -7
@@ -43,10 +43,10 @@ exports.ACL_LINK = (0, rdflib_1.sym)("http://www.iana.org/assignments/link-relat
43
43
  * Utility-related logic
44
44
  */
45
45
  var UtilityLogic = /** @class */ (function () {
46
- function UtilityLogic(store, ns, fetcher) {
46
+ function UtilityLogic(store, ns, underlyingFetch) {
47
47
  this.store = store;
48
48
  this.ns = ns;
49
- this.fetcher = fetcher;
49
+ this.underlyingFetch = underlyingFetch;
50
50
  }
51
51
  UtilityLogic.prototype.findAclDocUrl = function (url) {
52
52
  var _a;
@@ -105,7 +105,7 @@ var UtilityLogic = /** @class */ (function () {
105
105
  return [4 /*yield*/, this.findAclDocUrl(options.target)];
106
106
  case 1:
107
107
  aclDocUrl = _a.sent();
108
- return [2 /*return*/, this.fetcher.fetch(aclDocUrl, {
108
+ return [2 /*return*/, this.underlyingFetch.fetch(aclDocUrl, {
109
109
  method: 'PUT',
110
110
  body: str,
111
111
  headers: [
@@ -151,7 +151,7 @@ var UtilityLogic = /** @class */ (function () {
151
151
  if (!this.isContainer(url)) {
152
152
  throw new Error("Not a container URL ".concat(url));
153
153
  }
154
- return [4 /*yield*/, this.fetcher.fetch(url, {
154
+ return [4 /*yield*/, this.underlyingFetch.fetch(url, {
155
155
  method: "PUT",
156
156
  headers: {
157
157
  "Content-Type": "text/turtle",
@@ -204,7 +204,7 @@ var UtilityLogic = /** @class */ (function () {
204
204
  return [4 /*yield*/, this.findAclDocUrl(url)];
205
205
  case 1:
206
206
  aclDocUrl = _a.sent();
207
- return [4 /*yield*/, this.fetcher.fetch(aclDocUrl, { method: "DELETE" })];
207
+ return [4 /*yield*/, this.underlyingFetch.fetch(aclDocUrl, { method: "DELETE" })];
208
208
  case 2:
209
209
  _a.sent();
210
210
  return [4 /*yield*/, this.getContainerMembers(url)];
@@ -214,7 +214,7 @@ var UtilityLogic = /** @class */ (function () {
214
214
  case 4:
215
215
  _a.sent();
216
216
  _a.label = 5;
217
- case 5: return [2 /*return*/, this.fetcher.fetch(url, { method: "DELETE" })];
217
+ case 5: return [2 /*return*/, this.underlyingFetch.fetch(url, { method: "DELETE" })];
218
218
  case 6:
219
219
  e_1 = _a.sent();
220
220
  return [3 /*break*/, 7];
@@ -1 +1 @@
1
- {"version":3,"file":"UtilityLogic.js","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8D;AAGjD,QAAA,QAAQ,GAAG,IAAA,YAAG,EACzB,oDAAoD,CACrD,CAAC;AAEF;;GAEG;AACH;IAKE,sBAAY,KAAgB,EAAE,EAAkB,EAAE,OAAuD;QACvG,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEK,oCAAa,GAAnB,UAAoB,GAAW;;;;;;;wBACvB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;wBAChC,qBAAM,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,0CAAE,IAAI,CAAC,GAAG,CAAC,CAAA,EAAA;;wBAAnC,SAAmC,CAAC;wBAC9B,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAQ,CAAC,CAAC;wBAC9C,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,KAAK,CAAC,qCAA8B,GAAG,CAAE,CAAC,CAAC;yBACtD;wBACD,sBAAO,OAAO,CAAC,KAAK,EAAC;;;;KACtB;IAED,2GAA2G;IACrG,0CAAmB,GAAzB,UAA0B,OAMzB;;;;;;wBACK,GAAG,GAAG;4BACR,gDAAgD;4BAChD,EAAE;4BACF,sDA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D,CAAC,AAtJD,IAsJC;AAtJY,oCAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-logic",
3
- "version": "1.3.14-fd51b121",
3
+ "version": "1.3.15-599d981c",
4
4
  "description": "Core business logic of Solid OS",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -24,23 +24,23 @@
24
24
  },
25
25
  "homepage": "https://github.com/solid/solid-logic#readme",
26
26
  "devDependencies": {
27
- "@babel/plugin-proposal-class-properties": "~7.16.5",
28
- "@babel/plugin-proposal-optional-chaining": "~7.16.5",
29
- "@babel/plugin-transform-async-to-generator": "~7.16.5",
27
+ "@babel/plugin-proposal-class-properties": "~7.16.7",
28
+ "@babel/plugin-proposal-optional-chaining": "~7.16.7",
29
+ "@babel/plugin-transform-async-to-generator": "~7.16.8",
30
30
  "@babel/plugin-transform-runtime": "^7.17.0",
31
- "@babel/preset-env": "~7.16.5",
32
- "@babel/preset-typescript": "~7.16.5",
33
- "@types/jest": "^27.0.3",
34
- "@typescript-eslint/eslint-plugin": "^5.8.0",
35
- "@typescript-eslint/parser": "^5.8.0",
36
- "eslint": "^8.11.0",
31
+ "@babel/preset-env": "~7.16.11",
32
+ "@babel/preset-typescript": "~7.16.7",
33
+ "@types/jest": "^27.4.1",
34
+ "@typescript-eslint/eslint-plugin": "^5.16.0",
35
+ "@typescript-eslint/parser": "^5.16.0",
36
+ "eslint": "^8.12.0",
37
37
  "jest": "^27.5.1",
38
38
  "jest-fetch-mock": "^3.0.3",
39
- "typescript": "^4.6.2"
39
+ "typescript": "^4.6.3"
40
40
  },
41
41
  "dependencies": {
42
- "@inrupt/solid-client-authn-browser": "^1.11.6",
43
- "rdflib": "^2.2.18",
42
+ "@inrupt/solid-client-authn-browser": "^1.11.7",
43
+ "rdflib": "^2.2.19",
44
44
  "solid-namespace": "^0.5.2"
45
45
  }
46
46
  }
@@ -4,21 +4,21 @@ import * as debug from '../util/debug'
4
4
  import { Session } from "@inrupt/solid-client-authn-browser";
5
5
  import { AuthenticationContext, AuthnLogic } from "../types";
6
6
  export class SolidAuthnLogic implements AuthnLogic {
7
- private session: Session;
7
+ private session: Session;
8
8
 
9
9
  constructor(solidAuthSession: Session) {
10
10
  this.session = solidAuthSession;
11
11
  }
12
-
12
+
13
13
  // we created authSession getter because we want to access it as authn.authSession externally
14
- get authSession():Session { return this.session }
14
+ get authSession():Session { return this.session }
15
15
 
16
16
  currentUser(): NamedNode | null {
17
17
  const app = appContext()
18
18
  if (app.viewingNoAuthPage) {
19
19
  return sym(app.webId)
20
20
  }
21
- if (this.session.info.webId && this.session.info.isLoggedIn) {
21
+ if (this && this.session && this.session.info && this.session.info.webId && this.session.info.isLoggedIn) {
22
22
  return sym(this.session.info.webId)
23
23
  }
24
24
  return offlineTestID() // null unless testing
@@ -120,4 +120,4 @@ export class SolidAuthnLogic implements AuthnLogic {
120
120
  return webId
121
121
  }
122
122
 
123
- }
123
+ }
@@ -0,0 +1,311 @@
1
+ import { NamedNode, Namespace, LiveStore, sym, st } from "rdflib";
2
+ // import * as debug from '../util/debug'
3
+ // import { getContainerMembers } from '../util/UtilityLogic'
4
+ import { solidLogicSingleton } from "../logic/solidLogicSingleton"
5
+ import { newThing } from "../util/uri"
6
+
7
+ const { authn } = solidLogicSingleton
8
+ const { currentUser } = authn
9
+
10
+ type TypeIndexScope = { label: string, index: NamedNode, agent: NamedNode } ;
11
+ type ScopedApp = { instance: NamedNode, scope: TypeIndexScope }
12
+
13
+ const ns = {
14
+ dct: Namespace('http://purl.org/dc/terms/'),
15
+ ldp: Namespace('http://www.w3.org/ns/ldp#'),
16
+ meeting: Namespace('http://www.w3.org/ns/pim/meeting#'),
17
+ rdf: Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
18
+ schema: Namespace('http://schema.org/'),
19
+ solid: Namespace('http://www.w3.org/ns/solid/terms#'),
20
+ space: Namespace('http://www.w3.org/ns/pim/space#'),
21
+ stat: Namespace('http://www.w3.org/ns/posix/stat#'),
22
+ vcard: Namespace('http://www.w3.org/2006/vcard/ns#'),
23
+ wf: Namespace('http://www.w3.org/2005/01/wf/flow#'),
24
+ xsd: Namespace('http://www.w3.org/2001/XMLSchema#')
25
+
26
+ }
27
+
28
+ /** Create a resource if it really does not exist
29
+ * Be absolutely sure something does not exist before creating a new empty file
30
+ * as otherwise existing could be deleted.
31
+ * @param doc {NamedNode} - The resource
32
+ */
33
+ export async function loadOrCreateIfNotExists (store: LiveStore, doc: NamedNode) {
34
+ let response
35
+ // console.log('@@ loadOrCreateIfNotExists doc ', doc)
36
+ try {
37
+ response = await store.fetcher.load(doc)
38
+ } catch (err) {
39
+ if (err.response.status === 404) {
40
+ // console.log('createIfNotExists doc does NOT exist, will create: ' + doc)
41
+ try {
42
+ store.fetcher.webOperation('PUT', doc, {data: '', contentType: 'text/turtle'})
43
+ } catch (err) {
44
+ const msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err
45
+ // console.log(msg)
46
+ throw new Error(msg)
47
+ }
48
+ delete store.fetcher.requested[doc.uri] // delete cached 404 error
49
+ // console.log('createIfNotExists doc created ok ' + doc)
50
+ } else {
51
+ const msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
52
+ // console.log(msg)
53
+ throw new Error(msg) // @@ add nested errors
54
+ }
55
+ }
56
+ // console.log('createIfNotExists doc exists, all good ' + doc)
57
+ return response
58
+ }
59
+
60
+ export function suggestPreferencesFile (me:NamedNode) {
61
+ const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')
62
+ // const stripped = me.uri.replace(\/[p|P]rofile/\g, '/').replace(\/[p|P]ublic/\g, '/')
63
+ const folderURI = stripped.split('/').slice(0,-1).join('/') + '/Settings/'
64
+ const fileURI = folderURI + 'Preferences.ttl'
65
+ return sym(fileURI)
66
+ }
67
+
68
+ export function suggestPublicTypeIndex (me:NamedNode) {
69
+ return sym(me.doc().dir()?.uri + 'publicTypeIndex.ttl')
70
+ }
71
+ // Note this one is based off the pref file not the profile
72
+
73
+ export function suggestPrivateTypeIndex (preferencesFile:NamedNode) {
74
+ return sym(preferencesFile.doc().dir()?.uri + 'privateTypeIndex.ttl')
75
+ }
76
+ /* Follow link from this doc to another thing, or else make a new link
77
+ **
78
+ ** return: null no ld one and failed to make a new one
79
+ */
80
+ export async function followOrCreateLink(store: LiveStore, subject: NamedNode, predicate: NamedNode,
81
+ object: NamedNode, doc:NamedNode):Promise<NamedNode | null> {
82
+ await store.fetcher.load(doc)
83
+ const result = store.any(subject, predicate, null, doc)
84
+ // console.log('@@ followOrCreateLink result ', result)
85
+
86
+ if (result) return result as NamedNode
87
+ if (!store.updater.editable(doc)) {
88
+ // console.log(`followOrCreateLink: Can't modify ${doc} so can't make new link to ${object}.`)
89
+ // console.log('followOrCreateLink @@ connectedStatements', store.connectedStatements(subject))
90
+ return null
91
+ }
92
+ try {
93
+ await store.updater.update([], [ st(subject, predicate, object, doc)])
94
+ } catch (err) {
95
+ console.warn(`followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`)
96
+ return null
97
+ }
98
+
99
+ // console.log(`Success making link in ${doc} to ${object}` )
100
+
101
+ try {
102
+ await loadOrCreateIfNotExists(store, object)
103
+ // store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
104
+ } catch (err) {
105
+ console.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)
106
+ }
107
+ // console.log(`followOrCreateLink: Success loading or saving new linked document: ${object}.`)
108
+ return object
109
+ }
110
+
111
+ export async function loadProfile(store: LiveStore, user: NamedNode) {
112
+ // console.log(' @@ loadProfile: user', user)
113
+ if (!user) {
114
+ throw new Error(`loadProfile: no user given.`)
115
+ }
116
+ // try {
117
+ await store.fetcher.load(user.doc())
118
+ // } catch (err) {
119
+ // throw new Error(`Unable to load profile of user ${user}: ${err}`)
120
+ //}
121
+ return user.doc()
122
+ }
123
+
124
+ export async function loadPreferences(store: LiveStore, user: NamedNode): Promise <NamedNode | undefined > {
125
+ // console.log('loadPreferences @@ user', user)
126
+ await loadProfile(store as LiveStore, user)
127
+
128
+ const possiblePreferencesFile = suggestPreferencesFile(user)
129
+
130
+ const preferencesFile = await followOrCreateLink(store, user, ns.space('preferencesFile') as NamedNode, possiblePreferencesFile, user.doc())
131
+ // const preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile)
132
+
133
+ // console.log('loadPreferences @@ pref file', preferencesFile)
134
+ if (!preferencesFile) {
135
+ const message = `User ${user} has no pointer in profile to preferences file.`
136
+ console.warn(message)
137
+ // throw new Error()
138
+ return undefined
139
+ }
140
+ try {
141
+ await store.fetcher.load(preferencesFile as NamedNode)
142
+ } catch (err) { // Mabeb a permission propblem or origin problem
143
+ return undefined
144
+ // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
145
+ }
146
+ return preferencesFile as NamedNode
147
+ }
148
+
149
+ export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<TypeIndexScope>> {
150
+ // console.log('@@ loadTypeIndexesFor user', user)
151
+ if (!user) throw new Error(`loadTypeIndexesFor: No user given`)
152
+ const profile = await loadProfile(store, user)
153
+
154
+ const suggestion = suggestPublicTypeIndex(user)
155
+
156
+ const publicTypeIndex = await followOrCreateLink(store, user, ns.solid('publicTypeIndex') as NamedNode, suggestion, profile)
157
+
158
+ // const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
159
+ // console.log('@@ loadTypeIndexesFor publicTypeIndex', publicTypeIndex)
160
+
161
+ const publicScopes = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
162
+
163
+ let preferencesFile
164
+ try {
165
+ preferencesFile = await loadPreferences(store, user)
166
+ } catch (err) {
167
+ preferencesFile = null
168
+ }
169
+
170
+ let privateScopes
171
+ if (preferencesFile) { // watch out - can be in either as spec was not clear. Legacy is profile.
172
+ // If there is a legacy one linked from the profile, use that.
173
+ // Otherwiae use or make one linked from Preferences
174
+ const suggestedPrivateTypeIndex = suggestPrivateTypeIndex(preferencesFile)
175
+
176
+ const privateTypeIndex = store.any(user, ns.solid('privateTypeIndex'), undefined, profile) ||
177
+
178
+ await followOrCreateLink(store, user, ns.solid('privateTypeIndex') as NamedNode, suggestedPrivateTypeIndex, preferencesFile);
179
+
180
+ privateScopes = privateTypeIndex ? [ { label: 'private', index: privateTypeIndex as NamedNode, agent: user } ] : []
181
+ } else {
182
+ privateScopes = []
183
+ }
184
+ const scopes = publicScopes.concat(privateScopes)
185
+ if (scopes.length === 0) return scopes
186
+ const files = scopes.map(scope => scope.index)
187
+ // console.log('@@ loadTypeIndexesFor files ', files)
188
+ try {
189
+ await store.fetcher.load(files)
190
+ } catch (err) {
191
+ console.warn('Problems loading type index: ', err)
192
+ }
193
+ return scopes
194
+ }
195
+
196
+ export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<TypeIndexScope[][]> {
197
+ const preferencesFile = await loadPreferences(store, user)
198
+ if (preferencesFile) { // For now, pick up communities as simple links from the preferences file.
199
+ const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode)
200
+ // console.log('loadCommunityTypeIndexes communities: ',communities)
201
+ let result = []
202
+ for (const org of communities) {
203
+ result = result.concat(await loadTypeIndexesFor(store, org as NamedNode) as any)
204
+ }
205
+ // const communityTypeIndexesPromises = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
206
+ // const result1 = Promise.all(communityTypeIndexesPromises)
207
+ return result
208
+ }
209
+ return [] // No communities
210
+ }
211
+
212
+ export async function loadAllTypeIndexes (store:LiveStore, user:NamedNode) {
213
+ return (await loadTypeIndexesFor(store, user)).concat((await loadCommunityTypeIndexes(store, user)).flat())
214
+ }
215
+
216
+ // Utility: remove duplicates from Array of NamedNodes
217
+
218
+ export function uniqueNodes (arr: NamedNode[]): NamedNode[] {
219
+ const uris = arr.map(x => x.uri)
220
+ const set = new Set(uris)
221
+ const uris2 = Array.from(set)
222
+ const arr2 = uris2.map(u => new NamedNode(u))
223
+ return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
224
+ }
225
+
226
+ export async function getScopedAppsfromIndex (store, scope, theClass: NamedNode) {
227
+ // console.log(`getScopedAppsfromIndex agent ${scope.agent} index: ${scope.index}` )
228
+ const index = scope.index
229
+ const registrations = store.each(undefined, ns.solid('forClass'), theClass, index)
230
+ // console.log(' registrations', registrations )
231
+
232
+ const directInstances = registrations.map(reg => store.each(reg as NamedNode, ns.solid('instance'), null, index)).flat()
233
+ // console.log(' directInstances', directInstances )
234
+ let instances = uniqueNodes(directInstances)
235
+
236
+ /*
237
+ let instanceContainers = []
238
+ for (const reg of registrations) {
239
+ const cont = store.any(reg as NamedNode, ns.solid('instanceContainer'), null, index)
240
+ if (cont) {
241
+ // console.log(' @@ getScopedAppsfromIndex got one: ', cont)
242
+ instanceContainers.push(cont)
243
+ }
244
+ }
245
+ */
246
+ const instanceContainers = registrations.map(
247
+ reg => store.each(reg as NamedNode, ns.solid('instanceContainer'), null, index)).flat()
248
+
249
+ // instanceContainers may be deprocatable if no one has used them
250
+
251
+ const containers = uniqueNodes(instanceContainers)
252
+ for (let i = 0; i < containers.length; i++) {
253
+ const cont = containers[i]
254
+ await store.fetcher.load(cont)
255
+ const contents = store.each(cont, ns.ldp('contains'), null, cont)
256
+ // if (contents.length) console.log('getScopedAppsfromIndex @@ instanceContainer contents:', contents)
257
+ instances = instances.concat(contents)
258
+ }
259
+ return instances.map(instance => { return {instance, scope}})
260
+ }
261
+
262
+
263
+ export async function getScopedAppInstances (store:LiveStore, klass: NamedNode, user: NamedNode):Promise<ScopedApp[]> {
264
+ // console.log('getScopedAppInstances @@ ' + user)
265
+ const scopes = await loadAllTypeIndexes(store, user)
266
+ let scopedApps = []
267
+ for (const scope of scopes) {
268
+ const scopedApps0 = await getScopedAppsfromIndex(store, scope, klass) as any
269
+ scopedApps = scopedApps.concat(scopedApps0)
270
+ }
271
+ return scopedApps
272
+ }
273
+ // This is the function signature which used to be in solid-ui/logic
274
+ // Recommended to use getScopedAppInstances instead as it provides more information.
275
+ //
276
+ export async function getAppInstances (store:LiveStore, klass: NamedNode): Promise<NamedNode[]> {
277
+ const user = currentUser()
278
+ if (!user) throw new Error('getAppInstances: Must be logged in to find apps.')
279
+ const scopedAppInstances = await getScopedAppInstances(store, klass, user)
280
+ return scopedAppInstances.map(scoped => scoped.instance)
281
+ }
282
+ /**
283
+ * Register a new app in a type index
284
+ * used in chat in bookmark.js (solid-ui)
285
+ * Returns the registration object if successful else null
286
+ */
287
+ export async function registerInstanceInTypeIndex (
288
+ store:LiveStore,
289
+ instance: NamedNode,
290
+ index: NamedNode,
291
+ theClass: NamedNode,
292
+ // agent: NamedNode
293
+ ): Promise<NamedNode | null> {
294
+ const registration = newThing(index)
295
+ const ins = [
296
+ // See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
297
+ st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
298
+ st(registration, ns.solid('forClass'), theClass, index),
299
+ st(registration, ns.solid('instance'), instance, index)
300
+ ]
301
+ try {
302
+ console.log('patching index', ins)
303
+ await store.updater.update([], ins)
304
+ } catch (err) {
305
+ const msg = `Unable to register ${instance} in index ${index}: ${err}`
306
+ console.warn(msg)
307
+ return null
308
+ }
309
+ return registration
310
+ }
311
+ // ENDS
@@ -44,7 +44,7 @@ export class InboxLogic {
44
44
  return ourInbox;
45
45
  }
46
46
  async markAsRead(url: string, date: Date) {
47
- const downloaded = await this.util.fetcher.fetch(url);
47
+ const downloaded = await this.util.underlyingFetch.fetch(url);
48
48
  if (downloaded.status !== 200) {
49
49
  throw new Error(`Not OK! ${url}`);
50
50
  }
@@ -56,7 +56,7 @@ export class InboxLogic {
56
56
  [ 'Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream' ]
57
57
  ]
58
58
  };
59
- const uploaded = await this.util.fetcher.fetch(archiveUrl, options);
59
+ const uploaded = await this.util.underlyingFetch.fetch(archiveUrl, options);
60
60
  if (uploaded.status.toString()[0] === '2') {
61
61
  await this.store.fetcher?._fetch(url, {
62
62
  method: 'DELETE'
package/src/index.ts CHANGED
@@ -12,12 +12,22 @@ export {
12
12
  setACLUserPublic,
13
13
  genACLText
14
14
  } from './acl/aclLogic'
15
+
15
16
  export {
16
17
  ensureTypeIndexes,
17
18
  loadTypeIndexes,
18
19
  registerInTypeIndex,
19
20
  loadIndex
20
21
  } from './typeIndex/typeIndexLogic'
22
+
23
+ export {
24
+ loadProfile,
25
+ loadPreferences,
26
+ loadTypeIndexesFor,
27
+ loadCommunityTypeIndexes,
28
+ loadAllTypeIndexes
29
+ } from './discovery/discoveryLogic'
30
+
21
31
  export { SolidLogic } from './logic/SolidLogic'
22
32
  export { offlineTestID, appContext } from './authn/authUtil'
23
33
  export { ACL_LINK } from './util/UtilityLogic'
@@ -10,6 +10,13 @@ import * as debug from "../util/debug";
10
10
  import { UtilityLogic } from "../util/UtilityLogic";
11
11
  import { CrossOriginForbiddenError, FetchError, NotFoundError, SameOriginForbiddenError, UnauthorizedError } from "./CustomError";
12
12
 
13
+ import { solidLogicSingleton } from "../logic/solidLogicSingleton"
14
+ /*
15
+ ** It is important to distinquish `fetch`, a function provided by the browser
16
+ ** and `Fetcher`, a helper object for the rdflib Store which turns it
17
+ ** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
18
+ ** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
19
+ */
13
20
 
14
21
  const ns: SolidNamespace = solidNamespace(rdf);
15
22
 
@@ -25,60 +32,64 @@ export class SolidLogic {
25
32
 
26
33
  store: LiveStore;
27
34
  me: string | undefined;
28
- fetcher: { fetch: (url: string, options?: any) => any };
35
+ underlyingFetch: { fetch: (url: string, options?: any) => any };
29
36
 
30
37
  chat: ChatLogic;
31
38
  profile: ProfileLogic;
32
39
  authn: AuthnLogic;
33
40
  util: UtilityLogic;
34
41
 
35
- constructor(fetcher: { fetch: (url: any, requestInit: any) => any }, session: Session) {
42
+ constructor(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: Session) {
43
+ // would xpect to be able to do it this way: but get TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation status: 999
44
+ // this.store = new rdf.LiveStore({})
45
+ // this.store.fetcher._fetch = fetch
46
+ console.log("SolidLogic: Unique instance created. There should only be one of these.")
36
47
  this.store = rdf.graph() as LiveStore; // Make a Quad store
37
- rdf.fetcher(this.store, fetcher); // Attach a web I/O module, store.fetcher
48
+ rdf.fetcher(this.store, { fetch: specialFetch.fetch}); // Attach a web I/O module, store.fetcher
38
49
  this.store.updater = new rdf.UpdateManager(this.store); // Add real-time live updates store.updater
50
+
39
51
  this.store.features = [] // disable automatic node merging on store load
40
52
  this.cache = {
41
53
  profileDocument: {},
42
54
  preferencesFile: {},
43
55
  };
44
- this.fetcher = fetcher;
56
+ this.underlyingFetch = { fetch: fetch }; // Note global one not the one passed
45
57
  this.authn = new SolidAuthnLogic(session);
46
58
  debug.log('SolidAuthnLogic initialized')
47
59
  this.profile = new ProfileLogic(this.store, ns, this.authn);
48
60
  this.chat = new ChatLogic(this.store, ns, this.profile);
49
- this.util = new UtilityLogic(this.store, ns, this.fetcher);
61
+ this.util = new UtilityLogic(this.store, ns, this.underlyingFetch);
50
62
  }
51
63
 
52
64
  findAclDocUrl(url: string) {
53
65
  return this.util.findAclDocUrl(url);
54
66
  }
55
67
 
56
- loadDoc(doc: NamedNode): Promise<void> {
57
- return this.util.loadDoc(doc);
58
- }
59
-
60
68
  async loadProfile(me: NamedNode): Promise<NamedNode> {
61
- // console.log('loadProfile', me)
69
+ /*
70
+ // console.log('loadProfile cache ', this.cache)
62
71
  if (this.cache.profileDocument[me.value]) {
63
72
  return this.cache.profileDocument[me.value];
64
- }
65
- let profileDocument;
73
+ } @@ just use the cache in the store
74
+ */
75
+ console.log('loadProfile me ', me)
76
+ const profileDocument = me.doc()
66
77
  try {
67
- profileDocument = me.doc();
68
- await this.loadDoc(profileDocument);
69
- return profileDocument;
78
+ await this.store.fetcher.load(profileDocument);
79
+ return profileDocument;
70
80
  } catch (err) {
71
- const message = `Logged in but cannot load profile ${profileDocument} : ${err}`;
81
+ const message = `Cannot load profile ${profileDocument} : ${err}`;
72
82
  throw new Error(message);
73
83
  }
74
84
  }
75
85
 
76
86
  async loadPreferences(me: NamedNode): Promise<NamedNode> {
77
- // console.log('loadPreferences', me)
87
+ console.log('loadPreferences cache ', this.cache)
78
88
  if (this.cache.preferencesFile[me.value]) {
79
89
  return this.cache.preferencesFile[me.value];
80
90
  }
81
- const preferencesFile = this.store.any(me, ns.space("preferencesFile"));
91
+ await this.loadProfile(me) // Load pointer to pref file
92
+ const preferencesFile = this.store.any(me, ns.space('preferencesFile'), null, me.doc());
82
93
 
83
94
  // console.log('this.store.any()', this.store.any())
84
95
  /**
@@ -100,12 +111,9 @@ export class SolidLogic {
100
111
  );
101
112
  }
102
113
 
103
- if (!this.store.fetcher) {
104
- throw new Error("Cannot load doc, have no fetcher");
105
- }
106
114
  // //// Load preference file
107
115
  try {
108
- await this.store.fetcher.load(preferencesFile as NamedNode, {
116
+ await solidLogicSingleton.store.fetcher.load(preferencesFile as NamedNode, { // @@ was this.store.
109
117
  withCredentials: true,
110
118
  });
111
119
  } catch (err) {
@@ -152,9 +160,6 @@ export class SolidLogic {
152
160
  }
153
161
 
154
162
  load(doc: NamedNode | NamedNode[] | string) {
155
- if (!this.store.fetcher) {
156
- throw new Error("Cannot load doc(s), have no fetcher");
157
- }
158
163
  return this.store.fetcher.load(doc);
159
164
  }
160
165
 
@@ -210,9 +215,6 @@ export class SolidLogic {
210
215
  }
211
216
 
212
217
  async createEmptyRdfDoc(doc: NamedNode, comment: string) {
213
- if (!this.store.fetcher) {
214
- throw new Error("Cannot create empty rdf doc, have no fetcher");
215
- }
216
218
  await this.store.fetcher.webOperation("PUT", doc.uri, {
217
219
  data: `# ${new Date()} ${comment}
218
220
  `,
@@ -226,9 +228,6 @@ export class SolidLogic {
226
228
  ins: Array<Statement> = []
227
229
  ): Promise<void> {
228
230
  return new Promise((resolve, reject) => {
229
- if (!this.store.updater) {
230
- throw new Error("Cannot updatePromise, have no updater");
231
- }
232
231
  this.store.updater.update(del, ins, function (_uri, ok, errorBody) {
233
232
  if (!ok) {
234
233
  reject(new Error(errorBody));
@@ -260,6 +259,6 @@ export class SolidLogic {
260
259
  }
261
260
 
262
261
  async fetch(url: string, options?: any) {
263
- return this.fetcher.fetch(url, options);
262
+ return this.underlyingFetch.fetch(url, options);
264
263
  }
265
264
  }