solid-logic 1.3.17-f5eebe26 → 1.3.17-f7a7b156

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.
@@ -1,5 +1,4 @@
1
- import * as $rdf from 'rdflib';
2
- import { LiveStore, NamedNode } from 'rdflib';
1
+ import { NamedNode, LiveStore } from 'rdflib';
3
2
  declare type TypeIndexScope = {
4
3
  label: string;
5
4
  index: NamedNode;
@@ -16,22 +15,23 @@ declare type ScopedApp = {
16
15
  * @param doc {NamedNode} - The resource
17
16
  */
18
17
  export declare function loadOrCreateIfNotExists(store: LiveStore, doc: NamedNode): Promise<any>;
19
- export declare function suggestPreferencesFile(me: NamedNode): $rdf.NamedNode;
20
- export declare function suggestPublicTypeIndex(me: NamedNode): $rdf.NamedNode;
21
- export declare function suggestPrivateTypeIndex(preferencesFile: NamedNode): $rdf.NamedNode;
18
+ export declare function suggestPreferencesFile(me: NamedNode): NamedNode;
19
+ export declare function suggestPublicTypeIndex(me: NamedNode): NamedNode;
20
+ export declare function suggestPrivateTypeIndex(preferencesFile: NamedNode): NamedNode;
22
21
  export declare function followOrCreateLink(store: LiveStore, subject: NamedNode, predicate: NamedNode, object: NamedNode, doc: NamedNode): Promise<NamedNode | null>;
23
- export declare function loadProfile(store: LiveStore, user: NamedNode): Promise<$rdf.NamedNode>;
22
+ export declare function loadProfile(store: LiveStore, user: NamedNode): Promise<NamedNode>;
24
23
  export declare function loadPreferences(store: LiveStore, user: NamedNode): Promise<NamedNode | undefined>;
25
24
  export declare function loadTypeIndexesFor(store: LiveStore, user: NamedNode): Promise<Array<TypeIndexScope>>;
26
25
  export declare function loadCommunityTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndexScope[][]>;
27
26
  export declare function loadAllTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndexScope[]>;
28
27
  export declare function uniqueNodes(arr: NamedNode[]): NamedNode[];
29
- export declare function getScopedAppsfromIndex(store: any, scope: any, theClass: NamedNode): Promise<{
30
- instance: $rdf.NamedNode;
28
+ export declare function getScopedAppsFromIndex(store: any, scope: any, theClass: NamedNode | null): Promise<{
29
+ instance: NamedNode;
31
30
  scope: any;
32
31
  }[]>;
33
32
  export declare function getScopedAppInstances(store: LiveStore, klass: NamedNode, user: NamedNode): Promise<ScopedApp[]>;
34
33
  export declare function getAppInstances(store: LiveStore, klass: NamedNode): Promise<NamedNode[]>;
35
34
  export declare function registerInstanceInTypeIndex(store: LiveStore, instance: NamedNode, index: NamedNode, theClass: NamedNode): Promise<NamedNode | null>;
35
+ export declare function deleteTypeIndexRegistration(store: LiveStore, item: any): Promise<void>;
36
36
  export {};
37
37
  //# sourceMappingURL=discoveryLogic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discoveryLogic.d.ts","sourceRoot":"","sources":["../../src/discovery/discoveryLogic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAW,MAAM,QAAQ,CAAA;AAStD,aAAK,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAC3E,aAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAA;AAE/D;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,gBAyB9E;AAED,wBAAgB,sBAAsB,CAAE,EAAE,EAAC,SAAS,kBAMnD;AAED,wBAAgB,sBAAsB,CAAE,EAAE,EAAC,SAAS,kBAEnD;AAGD,wBAAgB,uBAAuB,CAAE,eAAe,EAAC,SAAS,kBAEjE;AAMD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAA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C,CAa5G;AAED,wBAAsB,kBAAkB,CAAE,KAAK,EAAC,SAAS,EAAE,IAAI,EAAC,SAAS,6BAExE;AAGD,wBAAgB,WAAW,CAAE,GAAG,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAM1D;AAED,wBAAsB,sBAAsB,CAAE,KAAK,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI;;;KAuBrF;AAED,wBAAsB,qBAAqB,CAAE,KAAK,EAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAQpH;AAKD,wBAAsB,eAAe,CAAE,KAAK,EAAC,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAK9F;AAOD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAC,SAAS,EACf,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,SAAS,GAElB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAgB3B;AAED,wBAAsB,2BAA2B,CAAE,KAAK,EAAE,SAAS,EAAE,IAAI,KAAA,iBAKxE"}
@@ -62,12 +62,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
62
62
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
63
  };
64
64
  Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.registerInstanceInTypeIndex = exports.getAppInstances = exports.getScopedAppInstances = exports.getScopedAppsfromIndex = exports.uniqueNodes = exports.loadAllTypeIndexes = exports.loadCommunityTypeIndexes = exports.loadTypeIndexesFor = exports.loadPreferences = exports.loadProfile = exports.followOrCreateLink = exports.suggestPrivateTypeIndex = exports.suggestPublicTypeIndex = exports.suggestPreferencesFile = exports.loadOrCreateIfNotExists = void 0;
66
- var $rdf = __importStar(require("rdflib"));
65
+ exports.deleteTypeIndexRegistration = exports.registerInstanceInTypeIndex = exports.getAppInstances = exports.getScopedAppInstances = exports.getScopedAppsFromIndex = exports.uniqueNodes = exports.loadAllTypeIndexes = exports.loadCommunityTypeIndexes = exports.loadTypeIndexesFor = exports.loadPreferences = exports.loadProfile = exports.followOrCreateLink = exports.suggestPrivateTypeIndex = exports.suggestPublicTypeIndex = exports.suggestPreferencesFile = exports.loadOrCreateIfNotExists = void 0;
67
66
  var rdflib_1 = require("rdflib");
68
- var solid_namespace_1 = __importDefault(require("solid-namespace"));
67
+ var $rdf = __importStar(require("rdflib"));
69
68
  var solidLogicSingleton_1 = require("../logic/solidLogicSingleton");
70
69
  var uri_1 = require("../util/uri");
70
+ var solid_namespace_1 = __importDefault(require("solid-namespace"));
71
71
  var authn = solidLogicSingleton_1.solidLogicSingleton.authn;
72
72
  var currentUser = authn.currentUser;
73
73
  var ns = (0, solid_namespace_1.default)($rdf);
@@ -91,27 +91,21 @@ function loadOrCreateIfNotExists(store, doc) {
91
91
  case 2:
92
92
  err_1 = _a.sent();
93
93
  if (err_1.response.status === 404) {
94
- // console.log('createIfNotExists doc does NOT exist, will create: ' + doc)
95
94
  try {
96
95
  store.fetcher.webOperation('PUT', doc, { data: '', contentType: 'text/turtle' });
97
96
  }
98
97
  catch (err) {
99
98
  msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err;
100
- // console.log(msg)
101
99
  throw new Error(msg);
102
100
  }
103
101
  delete store.fetcher.requested[doc.uri]; // delete cached 404 error
104
- // console.log('createIfNotExists doc created ok ' + doc)
105
102
  }
106
103
  else {
107
104
  msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err_1;
108
- // console.log(msg)
109
105
  throw new Error(msg); // @@ add nested errors
110
106
  }
111
107
  return [3 /*break*/, 3];
112
- case 3:
113
- // console.log('createIfNotExists doc exists, all good ' + doc)
114
- return [2 /*return*/, response];
108
+ case 3: return [2 /*return*/, response];
115
109
  }
116
110
  });
117
111
  });
@@ -149,12 +143,9 @@ function followOrCreateLink(store, subject, predicate, object, doc) {
149
143
  case 1:
150
144
  _a.sent();
151
145
  result = store.any(subject, predicate, null, doc);
152
- // console.log('@@ followOrCreateLink result ', result)
153
146
  if (result)
154
147
  return [2 /*return*/, result];
155
148
  if (!store.updater.editable(doc)) {
156
- // console.log(`followOrCreateLink: Can't modify ${doc} so can't make new link to ${object}.`)
157
- // console.log('followOrCreateLink @@ connectedStatements', store.connectedStatements(subject))
158
149
  return [2 /*return*/, null];
159
150
  }
160
151
  _a.label = 2;
@@ -180,9 +171,7 @@ function followOrCreateLink(store, subject, predicate, object, doc) {
180
171
  err_3 = _a.sent();
181
172
  console.warn("followOrCreateLink: Error loading or saving new linked document: ".concat(object, ": ").concat(err_3));
182
173
  return [3 /*break*/, 8];
183
- case 8:
184
- // console.log(`followOrCreateLink: Success loading or saving new linked document: ${object}.`)
185
- return [2 /*return*/, object];
174
+ case 8: return [2 /*return*/, object];
186
175
  }
187
176
  });
188
177
  });
@@ -190,26 +179,24 @@ function followOrCreateLink(store, subject, predicate, object, doc) {
190
179
  exports.followOrCreateLink = followOrCreateLink;
191
180
  function loadProfile(store, user) {
192
181
  return __awaiter(this, void 0, void 0, function () {
182
+ var err_4;
193
183
  return __generator(this, function (_a) {
194
184
  switch (_a.label) {
195
185
  case 0:
196
- // console.log(' @@ loadProfile: user', user)
197
186
  if (!user) {
198
187
  throw new Error("loadProfile: no user given.");
199
188
  }
200
- // try {
201
- return [4 /*yield*/, store.fetcher.load(user.doc())
202
- // } catch (err) {
203
- // throw new Error(`Unable to load profile of user ${user}: ${err}`)
204
- //}
205
- ];
189
+ _a.label = 1;
206
190
  case 1:
207
- // try {
191
+ _a.trys.push([1, 3, , 4]);
192
+ return [4 /*yield*/, store.fetcher.load(user.doc())];
193
+ case 2:
208
194
  _a.sent();
209
- // } catch (err) {
210
- // throw new Error(`Unable to load profile of user ${user}: ${err}`)
211
- //}
212
- return [2 /*return*/, user.doc()];
195
+ return [3 /*break*/, 4];
196
+ case 3:
197
+ err_4 = _a.sent();
198
+ throw new Error("Unable to load profile of user ".concat(user, ": ").concat(err_4));
199
+ case 4: return [2 /*return*/, user.doc()];
213
200
  }
214
201
  });
215
202
  });
@@ -217,26 +204,19 @@ function loadProfile(store, user) {
217
204
  exports.loadProfile = loadProfile;
218
205
  function loadPreferences(store, user) {
219
206
  return __awaiter(this, void 0, void 0, function () {
220
- var possiblePreferencesFile, preferencesFile, message, err_4;
207
+ var possiblePreferencesFile, preferencesFile, message, err_5;
221
208
  return __generator(this, function (_a) {
222
209
  switch (_a.label) {
223
- case 0:
224
- // console.log('loadPreferences @@ user', user)
225
- return [4 /*yield*/, loadProfile(store, user)];
210
+ case 0: return [4 /*yield*/, loadProfile(store, user)];
226
211
  case 1:
227
- // console.log('loadPreferences @@ user', user)
228
212
  _a.sent();
229
213
  possiblePreferencesFile = suggestPreferencesFile(user);
230
- return [4 /*yield*/, followOrCreateLink(store, user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc())
231
- // console.log('loadPreferences @@ pref file', preferencesFile)
232
- ];
214
+ return [4 /*yield*/, followOrCreateLink(store, user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc())];
233
215
  case 2:
234
216
  preferencesFile = _a.sent();
235
- // console.log('loadPreferences @@ pref file', preferencesFile)
236
217
  if (!preferencesFile) {
237
218
  message = "User ".concat(user, " has no pointer in profile to preferences file.");
238
219
  console.warn(message);
239
- // throw new Error()
240
220
  return [2 /*return*/, undefined];
241
221
  }
242
222
  _a.label = 3;
@@ -247,10 +227,8 @@ function loadPreferences(store, user) {
247
227
  _a.sent();
248
228
  return [3 /*break*/, 6];
249
229
  case 5:
250
- err_4 = _a.sent();
251
- return [2 /*return*/, undefined
252
- // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
253
- ];
230
+ err_5 = _a.sent();
231
+ return [2 /*return*/, undefined];
254
232
  case 6: return [2 /*return*/, preferencesFile];
255
233
  }
256
234
  });
@@ -259,21 +237,17 @@ function loadPreferences(store, user) {
259
237
  exports.loadPreferences = loadPreferences;
260
238
  function loadTypeIndexesFor(store, user) {
261
239
  return __awaiter(this, void 0, void 0, function () {
262
- var profile, suggestion, publicTypeIndex, publicScopes, preferencesFile, err_5, privateScopes, suggestedPrivateTypeIndex, privateTypeIndex, _a, scopes, files, err_6;
240
+ var profile, suggestion, publicTypeIndex, publicScopes, preferencesFile, err_6, privateScopes, suggestedPrivateTypeIndex, privateTypeIndex, _a, scopes, files, err_7;
263
241
  return __generator(this, function (_b) {
264
242
  switch (_b.label) {
265
243
  case 0:
266
- // console.log('@@ loadTypeIndexesFor user', user)
267
244
  if (!user)
268
245
  throw new Error("loadTypeIndexesFor: No user given");
269
246
  return [4 /*yield*/, loadProfile(store, user)];
270
247
  case 1:
271
248
  profile = _b.sent();
272
249
  suggestion = suggestPublicTypeIndex(user);
273
- return [4 /*yield*/, followOrCreateLink(store, user, ns.solid('publicTypeIndex'), suggestion, profile)
274
- // const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
275
- // console.log('@@ loadTypeIndexesFor publicTypeIndex', publicTypeIndex)
276
- ];
250
+ return [4 /*yield*/, followOrCreateLink(store, user, ns.solid('publicTypeIndex'), suggestion, profile)];
277
251
  case 2:
278
252
  publicTypeIndex = _b.sent();
279
253
  publicScopes = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex, agent: user }] : [];
@@ -285,7 +259,7 @@ function loadTypeIndexesFor(store, user) {
285
259
  preferencesFile = _b.sent();
286
260
  return [3 /*break*/, 6];
287
261
  case 5:
288
- err_5 = _b.sent();
262
+ err_6 = _b.sent();
289
263
  preferencesFile = null;
290
264
  return [3 /*break*/, 6];
291
265
  case 6:
@@ -317,8 +291,8 @@ function loadTypeIndexesFor(store, user) {
317
291
  _b.sent();
318
292
  return [3 /*break*/, 14];
319
293
  case 13:
320
- err_6 = _b.sent();
321
- console.warn('Problems loading type index: ', err_6);
294
+ err_7 = _b.sent();
295
+ console.warn('Problems loading type index: ', err_7);
322
296
  return [3 /*break*/, 14];
323
297
  case 14: return [2 /*return*/, scopes];
324
298
  }
@@ -335,7 +309,7 @@ function loadCommunityTypeIndexes(store, user) {
335
309
  case 1:
336
310
  preferencesFile = _c.sent();
337
311
  if (!preferencesFile) return [3 /*break*/, 6];
338
- communities = store.each(user, ns.solid('community'), undefined, preferencesFile);
312
+ communities = store.each(user, ns.solid('community'), undefined, preferencesFile).concat(store.each(user, ns.solid('community'), undefined, user.doc()));
339
313
  result = [];
340
314
  _i = 0, communities_1 = communities;
341
315
  _c.label = 2;
@@ -350,10 +324,7 @@ function loadCommunityTypeIndexes(store, user) {
350
324
  case 4:
351
325
  _i++;
352
326
  return [3 /*break*/, 2];
353
- case 5:
354
- // const communityTypeIndexesPromises = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
355
- // const result1 = Promise.all(communityTypeIndexesPromises)
356
- return [2 /*return*/, result];
327
+ case 5: return [2 /*return*/, result];
357
328
  case 6: return [2 /*return*/, []]; // No communities
358
329
  }
359
330
  });
@@ -384,18 +355,25 @@ function uniqueNodes(arr) {
384
355
  return arr2; // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
385
356
  }
386
357
  exports.uniqueNodes = uniqueNodes;
387
- function getScopedAppsfromIndex(store, scope, theClass) {
358
+ function getScopedAppsFromIndex(store, scope, theClass) {
388
359
  return __awaiter(this, void 0, void 0, function () {
389
- var index, registrations, directInstances, instances, instanceContainers, containers, i, cont, contents;
360
+ var index, registrations, relevant, directInstances, instances, instanceContainers, containers, i, cont, contents;
390
361
  return __generator(this, function (_a) {
391
362
  switch (_a.label) {
392
363
  case 0:
393
364
  index = scope.index;
394
- registrations = store.each(undefined, ns.solid('forClass'), theClass, index);
395
- directInstances = registrations.map(function (reg) { return store.each(reg, ns.solid('instance'), null, index); }).flat();
365
+ registrations = store.statementsMatching(null, ns.solid('instance'), null, index)
366
+ .concat(store.statementsMatching(null, ns.solid('instanceContainer'), null, index))
367
+ .map(function (st) { return st.subject; });
368
+ relevant = theClass ? registrations.filter(function (reg) { return store.any(reg, ns.solid('forClass'), null, index).sameTerm(theClass); })
369
+ : registrations;
370
+ directInstances = relevant.map(function (reg) { return store.each(reg, ns.solid('instance'), null, index); }).flat();
396
371
  instances = uniqueNodes(directInstances);
397
- instanceContainers = registrations.map(function (reg) { return store.each(reg, ns.solid('instanceContainer'), null, index); }).flat();
372
+ instanceContainers = relevant.map(function (reg) { return store.each(reg, ns.solid('instanceContainer'), null, index); }).flat();
398
373
  containers = uniqueNodes(instanceContainers);
374
+ if (containers.length > 0) {
375
+ console.log('@@ getScopedAppsFromIndex containers ', containers);
376
+ }
399
377
  i = 0;
400
378
  _a.label = 1;
401
379
  case 1:
@@ -405,7 +383,6 @@ function getScopedAppsfromIndex(store, scope, theClass) {
405
383
  case 2:
406
384
  _a.sent();
407
385
  contents = store.each(cont, ns.ldp('contains'), null, cont);
408
- // if (contents.length) console.log('getScopedAppsfromIndex @@ instanceContainer contents:', contents)
409
386
  instances = instances.concat(contents);
410
387
  _a.label = 3;
411
388
  case 3:
@@ -416,7 +393,7 @@ function getScopedAppsfromIndex(store, scope, theClass) {
416
393
  });
417
394
  });
418
395
  }
419
- exports.getScopedAppsfromIndex = getScopedAppsfromIndex;
396
+ exports.getScopedAppsFromIndex = getScopedAppsFromIndex;
420
397
  function getScopedAppInstances(store, klass, user) {
421
398
  return __awaiter(this, void 0, void 0, function () {
422
399
  var scopes, scopedApps, _i, scopes_1, scope, scopedApps0;
@@ -431,7 +408,7 @@ function getScopedAppInstances(store, klass, user) {
431
408
  case 2:
432
409
  if (!(_i < scopes_1.length)) return [3 /*break*/, 5];
433
410
  scope = scopes_1[_i];
434
- return [4 /*yield*/, getScopedAppsfromIndex(store, scope, klass)];
411
+ return [4 /*yield*/, getScopedAppsFromIndex(store, scope, klass)];
435
412
  case 3:
436
413
  scopedApps0 = _a.sent();
437
414
  scopedApps = scopedApps.concat(scopedApps0);
@@ -473,7 +450,7 @@ exports.getAppInstances = getAppInstances;
473
450
  */
474
451
  function registerInstanceInTypeIndex(store, instance, index, theClass) {
475
452
  return __awaiter(this, void 0, void 0, function () {
476
- var registration, ins, err_7, msg;
453
+ var registration, ins, err_8, msg;
477
454
  return __generator(this, function (_a) {
478
455
  switch (_a.label) {
479
456
  case 0:
@@ -487,14 +464,13 @@ function registerInstanceInTypeIndex(store, instance, index, theClass) {
487
464
  _a.label = 1;
488
465
  case 1:
489
466
  _a.trys.push([1, 3, , 4]);
490
- console.log('patching index', ins);
491
467
  return [4 /*yield*/, store.updater.update([], ins)];
492
468
  case 2:
493
469
  _a.sent();
494
470
  return [3 /*break*/, 4];
495
471
  case 3:
496
- err_7 = _a.sent();
497
- msg = "Unable to register ".concat(instance, " in index ").concat(index, ": ").concat(err_7);
472
+ err_8 = _a.sent();
473
+ msg = "Unable to register ".concat(instance, " in index ").concat(index, ": ").concat(err_8);
498
474
  console.warn(msg);
499
475
  return [2 /*return*/, null];
500
476
  case 4: return [2 /*return*/, registration];
@@ -503,5 +479,24 @@ function registerInstanceInTypeIndex(store, instance, index, theClass) {
503
479
  });
504
480
  }
505
481
  exports.registerInstanceInTypeIndex = registerInstanceInTypeIndex;
482
+ function deleteTypeIndexRegistration(store, item) {
483
+ return __awaiter(this, void 0, void 0, function () {
484
+ var reg, statements;
485
+ return __generator(this, function (_a) {
486
+ switch (_a.label) {
487
+ case 0:
488
+ reg = store.the(null, ns.solid('instance'), item.instance, item.scope.index);
489
+ if (!reg)
490
+ throw new Error("deleteTypeIndexRegistration: No registration found for ".concat(item.instance));
491
+ statements = store.statementsMatching(reg, null, null, item.scope.index);
492
+ return [4 /*yield*/, store.updater.update(statements, [])];
493
+ case 1:
494
+ _a.sent();
495
+ return [2 /*return*/];
496
+ }
497
+ });
498
+ });
499
+ }
500
+ exports.deleteTypeIndexRegistration = deleteTypeIndexRegistration;
506
501
  // ENDS
507
502
  //# sourceMappingURL=discoveryLogic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"discoveryLogic.js","sourceRoot":"","sources":["../../src/discovery/discove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E7B,GAAG,GAAG,6BAAsB,QAAQ,uBAAa,KAAK,eAAK,KAAG,CAAE,CAAA;oBACtE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBACjB,sBAAO,IAAI,EAAA;wBAEf,sBAAO,YAAY,EAAA;;;;CACtB;AAtBD,kEAsBC;AAED,SAAsB,2BAA2B,CAAE,KAAgB,EAAE,IAAI;;;;;;oBACjE,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAc,CAAA;oBAC/F,IAAI,CAAC,GAAG;wBAAE,MAAM,IAAI,KAAK,CAAC,iEAA0D,IAAI,CAAC,QAAQ,CAAE,CAAC,CAAA;oBAC9F,UAAU,GAAG,KAAK,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;oBAC9E,qBAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,EAAA;;oBAA1C,SAA0C,CAAA;;;;;CAC3C;AALD,kEAKC;AACD,OAAO"}
package/lib/index.d.ts CHANGED
@@ -5,7 +5,7 @@ declare const chat: import("./chat/ChatLogic").ChatLogic;
5
5
  declare const profile: import("./profile/ProfileLogic").ProfileLogic;
6
6
  export { setACLUserPublic, genACLText } from './acl/aclLogic';
7
7
  export { ensureTypeIndexes, loadTypeIndexes, registerInTypeIndex, loadIndex } from './typeIndex/typeIndexLogic';
8
- export { loadProfile, loadPreferences, loadTypeIndexesFor, loadCommunityTypeIndexes, loadAllTypeIndexes } from './discovery/discoveryLogic';
8
+ export { deleteTypeIndexRegistration, followOrCreateLink, getAppInstances, getScopedAppInstances, getScopedAppsFromIndex, loadAllTypeIndexes, loadCommunityTypeIndexes, loadOrCreateIfNotExists, loadPreferences, loadProfile, loadTypeIndexesFor, registerInstanceInTypeIndex, suggestPreferencesFile, suggestPrivateTypeIndex, suggestPublicTypeIndex, uniqueNodes } from './discovery/discoveryLogic';
9
9
  export { SolidLogic } from './logic/SolidLogic';
10
10
  export { offlineTestID, appContext } from './authn/authUtil';
11
11
  export { ACL_LINK } from './util/UtilityLogic';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,KAAK,8BAA4B,CAAA;AACvC,QAAA,MAAM,WAAW,sDAAwC,CAAA;AACzD,QAAA,MAAM,KAAK,4BAA4B,CAAA;AAEvC,QAAA,MAAM,IAAI,sCAA2B,CAAA;AACrC,QAAA,MAAM,OAAO,+CAA8B,CAAA;AAE3C,OAAO,EACL,gBAAgB,EAChB,UAAU,EACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,SAAS,EACV,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACvI,OAAO,EAAE,KAAK,EAAE,WAAW,EAA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I,EAAE,OAAO,EAAE,CAAA"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.profile = exports.chat = exports.store = exports.authSession = exports.authn = exports.FetchError = exports.NotFoundError = exports.SameOriginForbiddenError = exports.CrossOriginForbiddenError = exports.UnauthorizedError = exports.solidLogicSingleton = exports.getSuggestedIssuers = exports.ACL_LINK = exports.appContext = exports.offlineTestID = exports.SolidLogic = exports.loadAllTypeIndexes = exports.loadCommunityTypeIndexes = exports.loadTypeIndexesFor = exports.loadPreferences = exports.loadProfile = exports.loadIndex = exports.registerInTypeIndex = exports.loadTypeIndexes = exports.ensureTypeIndexes = exports.genACLText = exports.setACLUserPublic = void 0;
3
+ exports.profile = exports.chat = exports.store = exports.authSession = exports.authn = exports.FetchError = exports.NotFoundError = exports.SameOriginForbiddenError = exports.CrossOriginForbiddenError = exports.UnauthorizedError = exports.solidLogicSingleton = exports.getSuggestedIssuers = exports.ACL_LINK = exports.appContext = exports.offlineTestID = exports.SolidLogic = exports.uniqueNodes = exports.suggestPublicTypeIndex = exports.suggestPrivateTypeIndex = exports.suggestPreferencesFile = exports.registerInstanceInTypeIndex = exports.loadTypeIndexesFor = exports.loadProfile = exports.loadPreferences = exports.loadOrCreateIfNotExists = exports.loadCommunityTypeIndexes = exports.loadAllTypeIndexes = exports.getScopedAppsFromIndex = exports.getScopedAppInstances = exports.getAppInstances = exports.followOrCreateLink = exports.deleteTypeIndexRegistration = exports.loadIndex = exports.registerInTypeIndex = exports.loadTypeIndexes = exports.ensureTypeIndexes = exports.genACLText = exports.setACLUserPublic = void 0;
4
4
  // Make these variables directly accessible as it is what you need most of the time
5
5
  // This also makes these variable globaly accesible in mashlib
6
6
  var solidLogicSingleton_1 = require("./logic/solidLogicSingleton");
@@ -22,12 +22,25 @@ Object.defineProperty(exports, "ensureTypeIndexes", { enumerable: true, get: fun
22
22
  Object.defineProperty(exports, "loadTypeIndexes", { enumerable: true, get: function () { return typeIndexLogic_1.loadTypeIndexes; } });
23
23
  Object.defineProperty(exports, "registerInTypeIndex", { enumerable: true, get: function () { return typeIndexLogic_1.registerInTypeIndex; } });
24
24
  Object.defineProperty(exports, "loadIndex", { enumerable: true, get: function () { return typeIndexLogic_1.loadIndex; } });
25
+ // Generate by
26
+ // grep export src/discovery/discoveryLogic.ts | sed -e 's/export //g' | sed -e 's/async //g'| sed -e 's/function //g' | sed -e 's/ .*/,/g' | sort
25
27
  var discoveryLogic_1 = require("./discovery/discoveryLogic");
26
- Object.defineProperty(exports, "loadProfile", { enumerable: true, get: function () { return discoveryLogic_1.loadProfile; } });
28
+ Object.defineProperty(exports, "deleteTypeIndexRegistration", { enumerable: true, get: function () { return discoveryLogic_1.deleteTypeIndexRegistration; } });
29
+ Object.defineProperty(exports, "followOrCreateLink", { enumerable: true, get: function () { return discoveryLogic_1.followOrCreateLink; } });
30
+ Object.defineProperty(exports, "getAppInstances", { enumerable: true, get: function () { return discoveryLogic_1.getAppInstances; } });
31
+ Object.defineProperty(exports, "getScopedAppInstances", { enumerable: true, get: function () { return discoveryLogic_1.getScopedAppInstances; } });
32
+ Object.defineProperty(exports, "getScopedAppsFromIndex", { enumerable: true, get: function () { return discoveryLogic_1.getScopedAppsFromIndex; } });
33
+ Object.defineProperty(exports, "loadAllTypeIndexes", { enumerable: true, get: function () { return discoveryLogic_1.loadAllTypeIndexes; } });
34
+ Object.defineProperty(exports, "loadCommunityTypeIndexes", { enumerable: true, get: function () { return discoveryLogic_1.loadCommunityTypeIndexes; } });
35
+ Object.defineProperty(exports, "loadOrCreateIfNotExists", { enumerable: true, get: function () { return discoveryLogic_1.loadOrCreateIfNotExists; } });
27
36
  Object.defineProperty(exports, "loadPreferences", { enumerable: true, get: function () { return discoveryLogic_1.loadPreferences; } });
37
+ Object.defineProperty(exports, "loadProfile", { enumerable: true, get: function () { return discoveryLogic_1.loadProfile; } });
28
38
  Object.defineProperty(exports, "loadTypeIndexesFor", { enumerable: true, get: function () { return discoveryLogic_1.loadTypeIndexesFor; } });
29
- Object.defineProperty(exports, "loadCommunityTypeIndexes", { enumerable: true, get: function () { return discoveryLogic_1.loadCommunityTypeIndexes; } });
30
- Object.defineProperty(exports, "loadAllTypeIndexes", { enumerable: true, get: function () { return discoveryLogic_1.loadAllTypeIndexes; } });
39
+ Object.defineProperty(exports, "registerInstanceInTypeIndex", { enumerable: true, get: function () { return discoveryLogic_1.registerInstanceInTypeIndex; } });
40
+ Object.defineProperty(exports, "suggestPreferencesFile", { enumerable: true, get: function () { return discoveryLogic_1.suggestPreferencesFile; } });
41
+ Object.defineProperty(exports, "suggestPrivateTypeIndex", { enumerable: true, get: function () { return discoveryLogic_1.suggestPrivateTypeIndex; } });
42
+ Object.defineProperty(exports, "suggestPublicTypeIndex", { enumerable: true, get: function () { return discoveryLogic_1.suggestPublicTypeIndex; } });
43
+ Object.defineProperty(exports, "uniqueNodes", { enumerable: true, get: function () { return discoveryLogic_1.uniqueNodes; } });
31
44
  var SolidLogic_1 = require("./logic/SolidLogic");
32
45
  Object.defineProperty(exports, "SolidLogic", { enumerable: true, get: function () { return SolidLogic_1.SolidLogic; } });
33
46
  var authUtil_1 = require("./authn/authUtil");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mFAAmF;AACnF,8DAA8D;AAC9D,mEAAiE;AACjE,IAAM,KAAK,GAAG,yCAAmB,CAAC,KAAK,CAAA;AAmC9B,sBAAK;AAlCd,IAAM,WAAW,GAAG,yCAAmB,CAAC,KAAK,CAAC,WAAW,CAAA;AAkCzC,kCAAW;AAjC3B,IAAM,KAAK,GAAG,yCAAmB,CAAC,KAAK,CAAA;AAiCV,sBAAK;AA/BlC,IAAM,IAAI,GAAG,yCAAmB,CAAC,IAAI,CAAA;AA+BD,oBAAI;AA9BxC,IAAM,OAAO,GAAG,yCAAmB,CAAC,OAAO,CAAA;AA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FrB,4GAAA,gBAAgB,OAAA;AAChB,sGAAA,UAAU,OAAA;AAGZ,6DAKmC;AAJjC,mHAAA,iBAAiB,OAAA;AACjB,iHAAA,eAAe,OAAA;AACf,qHAAA,mBAAmB,OAAA;AACnB,2GAAA,SAAS,OAAA;AAGX,cAAc;AACd,oJAAoJ;AACpJ,6DAiBmC;AAhBjC,6HAAA,2BAA2B,OAAA;AAC3B,oHAAA,kBAAkB,OAAA;AAClB,iHAAA,eAAe,OAAA;AACf,uHAAA,qBAAqB,OAAA;AACrB,wHAAA,sBAAsB,OAAA;AACtB,oHAAA,kBAAkB,OAAA;AAClB,0HAAA,wBAAwB,OAAA;AACxB,yHAAA,uBAAuB,OAAA;AACvB,iHAAA,eAAe,OAAA;AACf,6GAAA,WAAW,OAAA;AACX,oHAAA,kBAAkB,OAAA;AAClB,6HAAA,2BAA2B,OAAA;AAC3B,wHAAA,sBAAsB,OAAA;AACtB,yHAAA,uBAAuB,OAAA;AACvB,wHAAA,sBAAsB,OAAA;AACtB,6GAAA,WAAW,OAAA;AAGb,iDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,6CAA4D;AAAnD,yGAAA,aAAa,OAAA;AAAE,sGAAA,UAAU,OAAA;AAClC,oDAA8C;AAArC,wGAAA,QAAQ,OAAA;AACjB,oDAA0D;AAAjD,kHAAA,mBAAmB,OAAA;AAE5B,6EAA6E;AAC7E,mEAAiE;AAAxD,0HAAA,mBAAmB,OAAA;AAC5B,mDAAuI;AAA9H,gHAAA,iBAAiB,OAAA;AAAE,wHAAA,yBAAyB,OAAA;AAAE,uHAAA,wBAAwB,OAAA;AAAE,4GAAA,aAAa,OAAA;AAAE,yGAAA,UAAU,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-logic",
3
- "version": "1.3.17-f5eebe26",
3
+ "version": "1.3.17-f7a7b156",
4
4
  "description": "Core business logic of Solid OS",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@
8
8
  "clean": "rm -rf lib",
9
9
  "lint": "eslint ./src",
10
10
  "test": "jest",
11
+ "test-debug": "node --inspect-brk ./node_modules/.bin/jest -i --env jest-environment-node-debug",
11
12
  "preversion": "npm test",
12
13
  "postversion": "git push --follow-tags",
13
14
  "ignore:prepublishOnly": "npm run build",
@@ -35,6 +36,7 @@
35
36
  "@typescript-eslint/parser": "^5.19.0",
36
37
  "eslint": "^8.13.0",
37
38
  "jest": "^27.5.1",
39
+ "jest-environment-node-debug": "^2.0.0",
38
40
  "jest-fetch-mock": "^3.0.3",
39
41
  "typescript": "^4.6.3"
40
42
  },
@@ -1,8 +1,8 @@
1
+ import { NamedNode, LiveStore, sym, st } from 'rdflib'
1
2
  import * as $rdf from 'rdflib'
2
- import { LiveStore, NamedNode, st, sym } from 'rdflib'
3
+ import { solidLogicSingleton } from "../logic/solidLogicSingleton"
4
+ import { newThing } from "../util/uri"
3
5
  import solidNamespace from 'solid-namespace'
4
- import { solidLogicSingleton } from '../logic/solidLogicSingleton'
5
- import { newThing } from '../util/uri'
6
6
 
7
7
  const { authn } = solidLogicSingleton
8
8
  const { currentUser } = authn
@@ -18,30 +18,24 @@ type ScopedApp = { instance: NamedNode, scope: TypeIndexScope }
18
18
  * @param doc {NamedNode} - The resource
19
19
  */
20
20
  export async function loadOrCreateIfNotExists (store: LiveStore, doc: NamedNode) {
21
- let response
22
- // console.log('@@ loadOrCreateIfNotExists doc ', doc)
23
- try {
24
- response = await store.fetcher.load(doc)
25
- } catch (err) {
26
- if (err.response.status === 404) {
27
- // console.log('createIfNotExists doc does NOT exist, will create: ' + doc)
28
- try {
29
- store.fetcher.webOperation('PUT', doc, {data: '', contentType: 'text/turtle'})
30
- } catch (err) {
31
- const msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err
32
- // console.log(msg)
33
- throw new Error(msg)
21
+ let response
22
+ try {
23
+ response = await store.fetcher.load(doc)
24
+ } catch (err) {
25
+ if (err.response.status === 404) {
26
+ try {
27
+ store.fetcher.webOperation('PUT', doc, {data: '', contentType: 'text/turtle'})
28
+ } catch (err) {
29
+ const msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err
30
+ throw new Error(msg)
31
+ }
32
+ delete store.fetcher.requested[doc.uri] // delete cached 404 error
33
+ } else {
34
+ const msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
35
+ throw new Error(msg) // @@ add nested errors
34
36
  }
35
- delete store.fetcher.requested[doc.uri] // delete cached 404 error
36
- // console.log('createIfNotExists doc created ok ' + doc)
37
- } else {
38
- const msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
39
- // console.log(msg)
40
- throw new Error(msg) // @@ add nested errors
41
- }
42
- }
43
- // console.log('createIfNotExists doc exists, all good ' + doc)
44
- return response
37
+ }
38
+ return response
45
39
  }
46
40
 
47
41
  export function suggestPreferencesFile (me:NamedNode) {
@@ -65,16 +59,13 @@ export function suggestPrivateTypeIndex (preferencesFile:NamedNode) {
65
59
  **
66
60
  ** return: null no ld one and failed to make a new one
67
61
  */
68
- export async function followOrCreateLink(store: LiveStore, subject: NamedNode, predicate: NamedNode,
69
- object: NamedNode, doc:NamedNode):Promise<NamedNode | null> {
62
+ export async function followOrCreateLink (store: LiveStore, subject: NamedNode, predicate: NamedNode,
63
+ object: NamedNode, doc:NamedNode):Promise<NamedNode | null> {
70
64
  await store.fetcher.load(doc)
71
65
  const result = store.any(subject, predicate, null, doc)
72
- // console.log('@@ followOrCreateLink result ', result)
73
66
 
74
67
  if (result) return result as NamedNode
75
68
  if (!store.updater.editable(doc)) {
76
- // console.log(`followOrCreateLink: Can't modify ${doc} so can't make new link to ${object}.`)
77
- // console.log('followOrCreateLink @@ connectedStatements', store.connectedStatements(subject))
78
69
  return null
79
70
  }
80
71
  try {
@@ -84,57 +75,48 @@ export async function followOrCreateLink(store: LiveStore, subject: NamedNode, p
84
75
  return null
85
76
  }
86
77
 
87
- // console.log(`Success making link in ${doc} to ${object}` )
88
-
89
78
  try {
90
79
  await loadOrCreateIfNotExists(store, object)
91
80
  // store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
92
81
  } catch (err) {
93
82
  console.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)
94
83
  }
95
- // console.log(`followOrCreateLink: Success loading or saving new linked document: ${object}.`)
96
84
  return object
97
85
  }
98
86
 
99
- export async function loadProfile(store: LiveStore, user: NamedNode) {
100
- // console.log(' @@ loadProfile: user', user)
87
+ export async function loadProfile (store: LiveStore, user: NamedNode) {
101
88
  if (!user) {
102
89
  throw new Error(`loadProfile: no user given.`)
103
90
  }
104
- // try {
91
+ try {
105
92
  await store.fetcher.load(user.doc())
106
- // } catch (err) {
107
- // throw new Error(`Unable to load profile of user ${user}: ${err}`)
108
- //}
93
+ } catch (err) {
94
+ throw new Error(`Unable to load profile of user ${user}: ${err}`)
95
+ }
109
96
  return user.doc()
110
97
  }
111
98
 
112
- export async function loadPreferences(store: LiveStore, user: NamedNode): Promise <NamedNode | undefined > {
113
- // console.log('loadPreferences @@ user', user)
99
+ export async function loadPreferences (store: LiveStore, user: NamedNode): Promise <NamedNode | undefined > {
114
100
  await loadProfile(store as LiveStore, user)
115
101
 
116
102
  const possiblePreferencesFile = suggestPreferencesFile(user)
117
103
 
118
104
  const preferencesFile = await followOrCreateLink(store, user, ns.space('preferencesFile') as NamedNode, possiblePreferencesFile, user.doc())
119
105
 
120
- // console.log('loadPreferences @@ pref file', preferencesFile)
121
106
  if (!preferencesFile) {
122
107
  const message = `User ${user} has no pointer in profile to preferences file.`
123
108
  console.warn(message)
124
- // throw new Error()
125
109
  return undefined
126
110
  }
127
111
  try {
128
112
  await store.fetcher.load(preferencesFile as NamedNode)
129
113
  } catch (err) { // Maybe a permission propblem or origin problem
130
114
  return undefined
131
- // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
132
115
  }
133
116
  return preferencesFile as NamedNode
134
117
  }
135
118
 
136
- export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<TypeIndexScope>> {
137
- // console.log('@@ loadTypeIndexesFor user', user)
119
+ export async function loadTypeIndexesFor (store: LiveStore, user:NamedNode): Promise<Array<TypeIndexScope>> {
138
120
  if (!user) throw new Error(`loadTypeIndexesFor: No user given`)
139
121
  const profile = await loadProfile(store, user)
140
122
 
@@ -142,9 +124,6 @@ export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Prom
142
124
 
143
125
  const publicTypeIndex = await followOrCreateLink(store, user, ns.solid('publicTypeIndex') as NamedNode, suggestion, profile)
144
126
 
145
- // const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
146
- // console.log('@@ loadTypeIndexesFor publicTypeIndex', publicTypeIndex)
147
-
148
127
  const publicScopes = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
149
128
 
150
129
  let preferencesFile
@@ -171,7 +150,6 @@ export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Prom
171
150
  const scopes = publicScopes.concat(privateScopes)
172
151
  if (scopes.length === 0) return scopes
173
152
  const files = scopes.map(scope => scope.index)
174
- // console.log('@@ loadTypeIndexesFor files ', files)
175
153
  try {
176
154
  await store.fetcher.load(files)
177
155
  } catch (err) {
@@ -183,14 +161,13 @@ export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Prom
183
161
  export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<TypeIndexScope[][]> {
184
162
  const preferencesFile = await loadPreferences(store, user)
185
163
  if (preferencesFile) { // For now, pick up communities as simple links from the preferences file.
186
- const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode)
187
- // console.log('loadCommunityTypeIndexes communities: ',communities)
164
+ const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode).concat(
165
+ store.each(user, ns.solid('community'), undefined, user.doc() as NamedNode)
166
+ )
188
167
  let result = []
189
168
  for (const org of communities) {
190
169
  result = result.concat(await loadTypeIndexesFor(store, org as NamedNode) as any)
191
170
  }
192
- // const communityTypeIndexesPromises = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
193
- // const result1 = Promise.all(communityTypeIndexesPromises)
194
171
  return result
195
172
  }
196
173
  return [] // No communities
@@ -209,38 +186,36 @@ export function uniqueNodes (arr: NamedNode[]): NamedNode[] {
209
186
  return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
210
187
  }
211
188
 
212
- export async function getScopedAppsfromIndex (store, scope, theClass: NamedNode) {
213
- // console.log(`getScopedAppsfromIndex agent ${scope.agent} index: ${scope.index}` )
189
+ export async function getScopedAppsFromIndex (store, scope, theClass: NamedNode | null) {
214
190
  const index = scope.index
215
- const registrations = store.each(undefined, ns.solid('forClass'), theClass, index)
216
- // console.log(' registrations', registrations )
217
-
218
- const directInstances = registrations.map(reg => store.each(reg as NamedNode, ns.solid('instance'), null, index)).flat()
219
- // console.log(' directInstances', directInstances )
191
+ const registrations = store.statementsMatching(null, ns.solid('instance'), null, index)
192
+ .concat(store.statementsMatching(null, ns.solid('instanceContainer'), null, index))
193
+ .map(st => st.subject)
194
+ const relevant = theClass ? registrations.filter(reg => store.any(reg, ns.solid('forClass'), null, index).sameTerm(theClass))
195
+ : registrations
196
+ const directInstances = relevant.map(reg => store.each(reg as NamedNode, ns.solid('instance'), null, index)).flat()
220
197
  let instances = uniqueNodes(directInstances)
221
198
 
222
- const instanceContainers = registrations.map(
223
- reg => store.each(reg as NamedNode, ns.solid('instanceContainer'), null, index)
224
- ).flat()
199
+ const instanceContainers = relevant.map(
200
+ reg => store.each(reg as NamedNode, ns.solid('instanceContainer'), null, index)).flat()
225
201
 
226
202
  // instanceContainers may be deprocatable if no one has used them
227
203
  const containers = uniqueNodes(instanceContainers)
204
+ if (containers.length > 0) { console.log('@@ getScopedAppsFromIndex containers ', containers)}
228
205
  for (let i = 0; i < containers.length; i++) {
229
206
  const cont = containers[i]
230
207
  await store.fetcher.load(cont)
231
208
  const contents = store.each(cont, ns.ldp('contains'), null, cont)
232
- // if (contents.length) console.log('getScopedAppsfromIndex @@ instanceContainer contents:', contents)
233
209
  instances = instances.concat(contents)
234
210
  }
235
211
  return instances.map(instance => { return {instance, scope}})
236
212
  }
237
213
 
238
214
  export async function getScopedAppInstances (store:LiveStore, klass: NamedNode, user: NamedNode):Promise<ScopedApp[]> {
239
- // console.log('getScopedAppInstances @@ ' + user)
240
215
  const scopes = await loadAllTypeIndexes(store, user)
241
216
  let scopedApps = []
242
217
  for (const scope of scopes) {
243
- const scopedApps0 = await getScopedAppsfromIndex(store, scope, klass) as any
218
+ const scopedApps0 = await getScopedAppsFromIndex(store, scope, klass) as any
244
219
  scopedApps = scopedApps.concat(scopedApps0)
245
220
  }
246
221
  return scopedApps
@@ -268,21 +243,27 @@ export async function registerInstanceInTypeIndex (
268
243
  theClass: NamedNode,
269
244
  // agent: NamedNode
270
245
  ): Promise<NamedNode | null> {
271
- const registration = newThing(index)
272
- const ins = [
273
- // See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
274
- st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
275
- st(registration, ns.solid('forClass'), theClass, index),
276
- st(registration, ns.solid('instance'), instance, index)
277
- ]
278
- try {
279
- console.log('patching index', ins)
280
- await store.updater.update([], ins)
281
- } catch (err) {
282
- const msg = `Unable to register ${instance} in index ${index}: ${err}`
283
- console.warn(msg)
284
- return null
285
- }
286
- return registration
246
+ const registration = newThing(index)
247
+ const ins = [
248
+ // See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
249
+ st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
250
+ st(registration, ns.solid('forClass'), theClass, index),
251
+ st(registration, ns.solid('instance'), instance, index)
252
+ ]
253
+ try {
254
+ await store.updater.update([], ins)
255
+ } catch (err) {
256
+ const msg = `Unable to register ${instance} in index ${index}: ${err}`
257
+ console.warn(msg)
258
+ return null
259
+ }
260
+ return registration
261
+ }
262
+
263
+ export async function deleteTypeIndexRegistration (store: LiveStore, item) {
264
+ const reg = store.the(null, ns.solid('instance'), item.instance, item.scope.index) as NamedNode
265
+ if (!reg) throw new Error(`deleteTypeIndexRegistration: No registration found for ${item.instance}`)
266
+ const statements = store.statementsMatching(reg, null, null, item.scope.index)
267
+ await store.updater.update(statements, [])
287
268
  }
288
269
  // ENDS
package/src/index.ts CHANGED
@@ -20,12 +20,25 @@ export {
20
20
  loadIndex
21
21
  } from './typeIndex/typeIndexLogic'
22
22
 
23
+ // Generate by
24
+ // grep export src/discovery/discoveryLogic.ts | sed -e 's/export //g' | sed -e 's/async //g'| sed -e 's/function //g' | sed -e 's/ .*/,/g' | sort
23
25
  export {
24
- loadProfile,
26
+ deleteTypeIndexRegistration,
27
+ followOrCreateLink,
28
+ getAppInstances,
29
+ getScopedAppInstances,
30
+ getScopedAppsFromIndex,
31
+ loadAllTypeIndexes,
32
+ loadCommunityTypeIndexes,
33
+ loadOrCreateIfNotExists,
25
34
  loadPreferences,
35
+ loadProfile,
26
36
  loadTypeIndexesFor,
27
- loadCommunityTypeIndexes,
28
- loadAllTypeIndexes
37
+ registerInstanceInTypeIndex,
38
+ suggestPreferencesFile,
39
+ suggestPrivateTypeIndex,
40
+ suggestPublicTypeIndex,
41
+ uniqueNodes
29
42
  } from './discovery/discoveryLogic'
30
43
 
31
44
  export { SolidLogic } from './logic/SolidLogic'
@@ -363,29 +363,29 @@ const ClubScopes =
363
363
  },
364
364
  "label": "public",
365
365
  },
366
- {
367
- "agent": {
366
+ {
367
+ "agent": {
368
368
  "classOrder": 5,
369
369
  "termType": "NamedNode",
370
370
  "value": "https://club.example.com/profile/card.ttl#it",
371
371
  },
372
- "index": {
372
+ "index": {
373
373
  "classOrder": 5,
374
374
  "termType": "NamedNode",
375
375
  "value": "https://club.example.com/settings/private-type-index.ttl",
376
376
  },
377
377
  "label": "private",
378
- },
379
- ];
380
- describe('loadCommunityTypeIndexes', () => {
381
- it('exists', () => {
382
- expect(loadCommunityTypeIndexes).toBeInstanceOf(Function)
383
- })
384
- it('loads data', async () => {
385
- const result = await loadCommunityTypeIndexes(store, user) // @@ tbd
386
- expect(result).toEqual(ClubScopes)
387
- })
388
- })
378
+ }
379
+ ]
380
+ describe('loadCommunityTypeIndexes', () => {
381
+ it('exists', () => {
382
+ expect(loadCommunityTypeIndexes).toBeInstanceOf(Function)
383
+ })
384
+ it('loads data', async () => {
385
+ const result = await loadCommunityTypeIndexes(store, user)
386
+ expect(result).toEqual(ClubScopes)
387
+ })
388
+ })
389
389
 
390
390
  const AliceAndClubScopes =
391
391
  [