solid-logic 1.3.17-2bf19bb6 → 1.3.17-9d25ceb7

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.
@@ -78,7 +78,7 @@ var SolidAuthnLogic = /** @class */ (function () {
78
78
  if (app.viewingNoAuthPage) {
79
79
  return (0, rdflib_1.sym)(app.webId);
80
80
  }
81
- if (this.session.info.webId && this.session.info.isLoggedIn) {
81
+ if (this && this.session && this.session.info && this.session.info.webId && this.session.info.isLoggedIn) {
82
82
  return (0, rdflib_1.sym)(this.session.info.webId);
83
83
  }
84
84
  return (0, authUtil_1.offlineTestID)(); // null unless testing
@@ -1 +1 @@
1
- {"version":3,"file":"SolidAuthnLogic.js","sourceRoot":"","sources":["../../src/authn/SolidAuthnLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAmD;AACnD,uCAAuD;AACvD,mDAAsC;AAGtC;IAGE,yBAAY,gBAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC;IAClC,CAAC;IAGD,sBAAI,wCAAW;QADf,6FAA6F;aAC7F,cAA4B,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;;;OAAA;IAEjD,qCAAW,GAAX;QACE,IAAM,GAAG,GAAG,IAAA,qBAAU,GAAE,CAAA;QACxB,IAAI,GAAG,CAAC,iBAAiB,EAAE;YACzB,OAAO,IAAA,YAAG,EAAC,GAAG,CAAC,KAAK,CAAC,CAAA;SACtB;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YAC3D,OAAO,IAAA,YAAG,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SACpC;QACD,OAAO,IAAA,wBAAa,GAAE,CAAA,CAAC,sBAAs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C,CAAC,IAAI,CAAA;QACzE,OAAO,KAAK,CAAA;IACd,CAAC;IAEH,sBAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,0CAAe"}
@@ -1,13 +1,37 @@
1
- import { NamedNode, LiveStore } from "rdflib";
2
- declare type TypeIndex = {
1
+ import * as $rdf from 'rdflib';
2
+ import { LiveStore, NamedNode } from 'rdflib';
3
+ declare type TypeIndexScope = {
3
4
  label: string;
4
5
  index: NamedNode;
5
6
  agent: NamedNode;
6
7
  };
7
- export declare function loadProfile(store: LiveStore, user: any): Promise<any>;
8
- export declare function loadPreferences(store: LiveStore, user: any): Promise<NamedNode | undefined>;
9
- export declare function loadTypeIndexesFor(store: LiveStore, user: NamedNode): Promise<Array<TypeIndex>>;
10
- export declare function loadCommunityTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndex[][]>;
11
- export declare function loadAllTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndex[]>;
8
+ declare type ScopedApp = {
9
+ instance: NamedNode;
10
+ scope: TypeIndexScope;
11
+ };
12
+ /**
13
+ * Create a resource if it really does not exist
14
+ * Be absolutely sure something does not exist before creating a new empty file
15
+ * as otherwise existing could be deleted.
16
+ * @param doc {NamedNode} - The resource
17
+ */
18
+ 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;
22
+ 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>;
24
+ export declare function loadPreferences(store: LiveStore, user: NamedNode): Promise<NamedNode | undefined>;
25
+ export declare function loadTypeIndexesFor(store: LiveStore, user: NamedNode): Promise<Array<TypeIndexScope>>;
26
+ export declare function loadCommunityTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndexScope[][]>;
27
+ export declare function loadAllTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndexScope[]>;
28
+ export declare function uniqueNodes(arr: NamedNode[]): NamedNode[];
29
+ export declare function getScopedAppsfromIndex(store: any, scope: any, theClass: NamedNode): Promise<{
30
+ instance: $rdf.NamedNode;
31
+ scope: any;
32
+ }[]>;
33
+ export declare function getScopedAppInstances(store: LiveStore, klass: NamedNode, user: NamedNode): Promise<ScopedApp[]>;
34
+ export declare function getAppInstances(store: LiveStore, klass: NamedNode): Promise<NamedNode[]>;
35
+ export declare function registerInstanceInTypeIndex(store: LiveStore, instance: NamedNode, index: NamedNode, theClass: NamedNode): Promise<NamedNode | null>;
12
36
  export {};
13
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,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzD,aAAK,SAAS,GAAG;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAE;AAOzE,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,KAAA,gBAUvD;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,KAAA,GAAG,OAAO,CAAE,SAAS,GAAG,SAAS,CAAE,CAc9F;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAqBpG;AAED,wBAAsB,wBAAwB,CAAE,KAAK,EAAC,SAAS,EAAE,IAAI,EAAC,SAAS,GAAG,OAAO,CAA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AAI,EAAC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CA6CzG;AAED,wBAAsB,wBAAwB,CAAE,KAAK,EAAC,SAAS,EAAE,IAAI,EAAC,SAAS,GAAG,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAc5G;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;;;KAwB9E;AAED,wBAAsB,qBAAqB,CAAE,KAAK,EAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CASpH;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,CAiB3B"}
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,33 +58,158 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
58
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
59
  }
37
60
  };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
38
64
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.loadAllTypeIndexes = exports.loadCommunityTypeIndexes = exports.loadTypeIndexesFor = exports.loadPreferences = exports.loadProfile = void 0;
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"));
40
67
  var rdflib_1 = require("rdflib");
41
- var ns = {
42
- solid: (0, rdflib_1.Namespace)('http://www.w3.org/ns/solid/terms#'),
43
- space: (0, rdflib_1.Namespace)('http://www.w3.org/ns/pim/space#')
44
- };
68
+ var solid_namespace_1 = __importDefault(require("solid-namespace"));
69
+ var solidLogicSingleton_1 = require("../logic/solidLogicSingleton");
70
+ var uri_1 = require("../util/uri");
71
+ var authn = solidLogicSingleton_1.solidLogicSingleton.authn;
72
+ var currentUser = authn.currentUser;
73
+ var ns = (0, solid_namespace_1.default)($rdf);
74
+ /**
75
+ * Create a resource if it really does not exist
76
+ * Be absolutely sure something does not exist before creating a new empty file
77
+ * as otherwise existing could be deleted.
78
+ * @param doc {NamedNode} - The resource
79
+ */
80
+ function loadOrCreateIfNotExists(store, doc) {
81
+ return __awaiter(this, void 0, void 0, function () {
82
+ var response, err_1, msg, msg;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0:
86
+ _a.trys.push([0, 2, , 3]);
87
+ return [4 /*yield*/, store.fetcher.load(doc)];
88
+ case 1:
89
+ response = _a.sent();
90
+ return [3 /*break*/, 3];
91
+ case 2:
92
+ err_1 = _a.sent();
93
+ if (err_1.response.status === 404) {
94
+ // console.log('createIfNotExists doc does NOT exist, will create: ' + doc)
95
+ try {
96
+ store.fetcher.webOperation('PUT', doc, { data: '', contentType: 'text/turtle' });
97
+ }
98
+ catch (err) {
99
+ msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err;
100
+ // console.log(msg)
101
+ throw new Error(msg);
102
+ }
103
+ delete store.fetcher.requested[doc.uri]; // delete cached 404 error
104
+ // console.log('createIfNotExists doc created ok ' + doc)
105
+ }
106
+ else {
107
+ msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err_1;
108
+ // console.log(msg)
109
+ throw new Error(msg); // @@ add nested errors
110
+ }
111
+ return [3 /*break*/, 3];
112
+ case 3:
113
+ // console.log('createIfNotExists doc exists, all good ' + doc)
114
+ return [2 /*return*/, response];
115
+ }
116
+ });
117
+ });
118
+ }
119
+ exports.loadOrCreateIfNotExists = loadOrCreateIfNotExists;
120
+ function suggestPreferencesFile(me) {
121
+ var stripped = me.uri.replace('/profile/', '/').replace('/public/', '/');
122
+ // const stripped = me.uri.replace(\/[p|P]rofile/\g, '/').replace(\/[p|P]ublic/\g, '/')
123
+ var folderURI = stripped.split('/').slice(0, -1).join('/') + '/Settings/';
124
+ var fileURI = folderURI + 'Preferences.ttl';
125
+ return (0, rdflib_1.sym)(fileURI);
126
+ }
127
+ exports.suggestPreferencesFile = suggestPreferencesFile;
128
+ function suggestPublicTypeIndex(me) {
129
+ var _a;
130
+ return (0, rdflib_1.sym)(((_a = me.doc().dir()) === null || _a === void 0 ? void 0 : _a.uri) + 'publicTypeIndex.ttl');
131
+ }
132
+ exports.suggestPublicTypeIndex = suggestPublicTypeIndex;
133
+ // Note this one is based off the pref file not the profile
134
+ function suggestPrivateTypeIndex(preferencesFile) {
135
+ var _a;
136
+ return (0, rdflib_1.sym)(((_a = preferencesFile.doc().dir()) === null || _a === void 0 ? void 0 : _a.uri) + 'privateTypeIndex.ttl');
137
+ }
138
+ exports.suggestPrivateTypeIndex = suggestPrivateTypeIndex;
139
+ /* Follow link from this doc to another thing, or else make a new link
140
+ **
141
+ ** return: null no ld one and failed to make a new one
142
+ */
143
+ function followOrCreateLink(store, subject, predicate, object, doc) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var result, err_2, err_3;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0: return [4 /*yield*/, store.fetcher.load(doc)];
149
+ case 1:
150
+ _a.sent();
151
+ result = store.any(subject, predicate, null, doc);
152
+ // console.log('@@ followOrCreateLink result ', result)
153
+ if (result)
154
+ return [2 /*return*/, result];
155
+ 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
+ return [2 /*return*/, null];
159
+ }
160
+ _a.label = 2;
161
+ case 2:
162
+ _a.trys.push([2, 4, , 5]);
163
+ return [4 /*yield*/, store.updater.update([], [(0, rdflib_1.st)(subject, predicate, object, doc)])];
164
+ case 3:
165
+ _a.sent();
166
+ return [3 /*break*/, 5];
167
+ case 4:
168
+ err_2 = _a.sent();
169
+ console.warn("followOrCreateLink: Error making link in ".concat(doc, " to ").concat(object, ": ").concat(err_2));
170
+ return [2 /*return*/, null];
171
+ case 5:
172
+ _a.trys.push([5, 7, , 8]);
173
+ return [4 /*yield*/, loadOrCreateIfNotExists(store, object)
174
+ // store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
175
+ ];
176
+ case 6:
177
+ _a.sent();
178
+ return [3 /*break*/, 8];
179
+ case 7:
180
+ err_3 = _a.sent();
181
+ console.warn("followOrCreateLink: Error loading or saving new linked document: ".concat(object, ": ").concat(err_3));
182
+ return [3 /*break*/, 8];
183
+ case 8:
184
+ // console.log(`followOrCreateLink: Success loading or saving new linked document: ${object}.`)
185
+ return [2 /*return*/, object];
186
+ }
187
+ });
188
+ });
189
+ }
190
+ exports.followOrCreateLink = followOrCreateLink;
45
191
  function loadProfile(store, user) {
46
192
  return __awaiter(this, void 0, void 0, function () {
47
- var err_1;
48
193
  return __generator(this, function (_a) {
49
194
  switch (_a.label) {
50
195
  case 0:
196
+ // console.log(' @@ loadProfile: user', user)
51
197
  if (!user) {
52
198
  throw new Error("loadProfile: no user given.");
53
199
  }
54
- _a.label = 1;
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
+ ];
55
206
  case 1:
56
- _a.trys.push([1, 3, , 4]);
57
- return [4 /*yield*/, store.fetcher.load(user.doc())];
58
- case 2:
207
+ // try {
59
208
  _a.sent();
60
- return [3 /*break*/, 4];
61
- case 3:
62
- err_1 = _a.sent();
63
- throw new Error("Unable to load profile of user <".concat(user, ">: ").concat(err_1));
64
- case 4: return [2 /*return*/, user.doc()];
209
+ // } catch (err) {
210
+ // throw new Error(`Unable to load profile of user ${user}: ${err}`)
211
+ //}
212
+ return [2 /*return*/, user.doc()];
65
213
  }
66
214
  });
67
215
  });
@@ -69,27 +217,41 @@ function loadProfile(store, user) {
69
217
  exports.loadProfile = loadProfile;
70
218
  function loadPreferences(store, user) {
71
219
  return __awaiter(this, void 0, void 0, function () {
72
- var profile, preferencesFile;
220
+ var possiblePreferencesFile, preferencesFile, message, err_4;
73
221
  return __generator(this, function (_a) {
74
222
  switch (_a.label) {
75
- case 0: return [4 /*yield*/, loadProfile(store, user)];
223
+ case 0:
224
+ // console.log('loadPreferences @@ user', user)
225
+ return [4 /*yield*/, loadProfile(store, user)];
76
226
  case 1:
77
- profile = _a.sent();
78
- preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile);
227
+ // console.log('loadPreferences @@ user', user)
228
+ _a.sent();
229
+ possiblePreferencesFile = suggestPreferencesFile(user);
230
+ return [4 /*yield*/, followOrCreateLink(store, user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc())
231
+ // console.log('loadPreferences @@ pref file', preferencesFile)
232
+ ];
233
+ case 2:
234
+ preferencesFile = _a.sent();
235
+ // console.log('loadPreferences @@ pref file', preferencesFile)
79
236
  if (!preferencesFile) {
80
- // throw new Error(`USer ${user} has no pointer in profile to preferences file.`)
237
+ message = "User ".concat(user, " has no pointer in profile to preferences file.");
238
+ console.warn(message);
239
+ // throw new Error()
81
240
  return [2 /*return*/, undefined];
82
241
  }
83
- try {
84
- store.fetcher.load(preferencesFile);
85
- }
86
- catch (err) { // Mabeb a permission propblem or origin problem
87
- return [2 /*return*/, undefined
88
- // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
89
- ];
242
+ _a.label = 3;
243
+ case 3:
244
+ _a.trys.push([3, 5, , 6]);
245
+ return [4 /*yield*/, store.fetcher.load(preferencesFile)];
246
+ case 4:
247
+ _a.sent();
248
+ return [3 /*break*/, 6];
249
+ case 5:
250
+ err_4 = _a.sent();
251
+ return [2 /*return*/, undefined
90
252
  // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
91
- }
92
- return [2 /*return*/, preferencesFile];
253
+ ];
254
+ case 6: return [2 /*return*/, preferencesFile];
93
255
  }
94
256
  });
95
257
  });
@@ -97,39 +259,68 @@ function loadPreferences(store, user) {
97
259
  exports.loadPreferences = loadPreferences;
98
260
  function loadTypeIndexesFor(store, user) {
99
261
  return __awaiter(this, void 0, void 0, function () {
100
- var profile, publicTypeIndex, _a, pub, preferencesFile, privateTypeIndexes, priv;
262
+ var profile, suggestion, publicTypeIndex, publicScopes, preferencesFile, err_5, privateScopes, suggestedPrivateTypeIndex, privateTypeIndex, _a, scopes, files, err_6;
101
263
  return __generator(this, function (_b) {
102
264
  switch (_b.label) {
103
265
  case 0:
266
+ // console.log('@@ loadTypeIndexesFor user', user)
104
267
  if (!user)
105
268
  throw new Error("loadTypeIndexesFor: No user given");
106
269
  return [4 /*yield*/, loadProfile(store, user)];
107
270
  case 1:
108
271
  profile = _b.sent();
109
- publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile);
110
- if (!publicTypeIndex) return [3 /*break*/, 5];
111
- _b.label = 2;
272
+ 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
+ ];
112
277
  case 2:
113
- _b.trys.push([2, 4, , 5]);
114
- return [4 /*yield*/, store.fetcher.load(publicTypeIndex)];
278
+ publicTypeIndex = _b.sent();
279
+ publicScopes = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex, agent: user }] : [];
280
+ _b.label = 3;
115
281
  case 3:
116
- _b.sent();
117
- return [3 /*break*/, 5];
282
+ _b.trys.push([3, 5, , 6]);
283
+ return [4 /*yield*/, loadPreferences(store, user)];
118
284
  case 4:
119
- _a = _b.sent();
120
- return [3 /*break*/, 5];
285
+ preferencesFile = _b.sent();
286
+ return [3 /*break*/, 6];
121
287
  case 5:
122
- pub = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex, agent: user }] : [];
123
- return [4 /*yield*/, loadPreferences(store, user)];
288
+ err_5 = _b.sent();
289
+ preferencesFile = null;
290
+ return [3 /*break*/, 6];
124
291
  case 6:
125
- preferencesFile = _b.sent();
126
- if (preferencesFile) { // watch out - can be in either as spec was not clear
127
- privateTypeIndexes = store.each(user, ns.solid('privateTypeIndex'), undefined, preferencesFile)
128
- .concat(store.each(user, ns.solid('privateTypeIndex'), undefined, profile));
129
- priv = privateTypeIndexes.length > 0 ? [{ label: 'priSo @@@@@vate', index: privateTypeIndexes[0], agent: user }] : [];
130
- return [2 /*return*/, pub.concat(priv)];
131
- }
132
- return [2 /*return*/, pub];
292
+ if (!preferencesFile) return [3 /*break*/, 9];
293
+ suggestedPrivateTypeIndex = suggestPrivateTypeIndex(preferencesFile);
294
+ _a = store.any(user, ns.solid('privateTypeIndex'), undefined, profile);
295
+ if (_a) return [3 /*break*/, 8];
296
+ return [4 /*yield*/, followOrCreateLink(store, user, ns.solid('privateTypeIndex'), suggestedPrivateTypeIndex, preferencesFile)];
297
+ case 7:
298
+ _a = (_b.sent());
299
+ _b.label = 8;
300
+ case 8:
301
+ privateTypeIndex = _a;
302
+ privateScopes = privateTypeIndex ? [{ label: 'private', index: privateTypeIndex, agent: user }] : [];
303
+ return [3 /*break*/, 10];
304
+ case 9:
305
+ privateScopes = [];
306
+ _b.label = 10;
307
+ case 10:
308
+ scopes = publicScopes.concat(privateScopes);
309
+ if (scopes.length === 0)
310
+ return [2 /*return*/, scopes];
311
+ files = scopes.map(function (scope) { return scope.index; });
312
+ _b.label = 11;
313
+ case 11:
314
+ _b.trys.push([11, 13, , 14]);
315
+ return [4 /*yield*/, store.fetcher.load(files)];
316
+ case 12:
317
+ _b.sent();
318
+ return [3 /*break*/, 14];
319
+ case 13:
320
+ err_6 = _b.sent();
321
+ console.warn('Problems loading type index: ', err_6);
322
+ return [3 /*break*/, 14];
323
+ case 14: return [2 /*return*/, scopes];
133
324
  }
134
325
  });
135
326
  });
@@ -137,44 +328,33 @@ function loadTypeIndexesFor(store, user) {
137
328
  exports.loadTypeIndexesFor = loadTypeIndexesFor;
138
329
  function loadCommunityTypeIndexes(store, user) {
139
330
  return __awaiter(this, void 0, void 0, function () {
140
- var preferencesFile, communities, communityTypeIndexesPromise, result1;
141
- var _this = this;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
331
+ var preferencesFile, communities, result, _i, communities_1, org, _a, _b;
332
+ return __generator(this, function (_c) {
333
+ switch (_c.label) {
144
334
  case 0: return [4 /*yield*/, loadPreferences(store, user)];
145
335
  case 1:
146
- preferencesFile = _a.sent();
147
- if (preferencesFile) {
148
- communities = store.each(user, ns.solid('community'), undefined, preferencesFile);
149
- communityTypeIndexesPromise = communities.map(function (community) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
150
- switch (_a.label) {
151
- case 0: return [4 /*yield*/, loadTypeIndexesFor(store, community)];
152
- case 1: return [2 /*return*/, _a.sent()];
153
- }
154
- }); }); });
155
- result1 = Promise.all(communityTypeIndexesPromise);
156
- // const result2 = Promise.all(result1)
157
- // const flat = result2.flat()
158
- return [2 /*return*/, result1
159
- // const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
160
- /*
161
- let result = [] as TypeIndex[]
162
- for(const community of communities) {
163
- result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
164
- }
165
- */
166
- // return communityTypeIndexesPromise.resolve()
167
- ];
168
- // const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
169
- /*
170
- let result = [] as TypeIndex[]
171
- for(const community of communities) {
172
- result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
173
- }
174
- */
175
- // return communityTypeIndexesPromise.resolve()
176
- }
177
- return [2 /*return*/, []];
336
+ preferencesFile = _c.sent();
337
+ if (!preferencesFile) return [3 /*break*/, 6];
338
+ communities = store.each(user, ns.solid('community'), undefined, preferencesFile);
339
+ result = [];
340
+ _i = 0, communities_1 = communities;
341
+ _c.label = 2;
342
+ case 2:
343
+ if (!(_i < communities_1.length)) return [3 /*break*/, 5];
344
+ org = communities_1[_i];
345
+ _b = (_a = result).concat;
346
+ return [4 /*yield*/, loadTypeIndexesFor(store, org)];
347
+ case 3:
348
+ result = _b.apply(_a, [_c.sent()]);
349
+ _c.label = 4;
350
+ case 4:
351
+ _i++;
352
+ 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];
357
+ case 6: return [2 /*return*/, []]; // No communities
178
358
  }
179
359
  });
180
360
  });
@@ -195,9 +375,133 @@ function loadAllTypeIndexes(store, user) {
195
375
  });
196
376
  }
197
377
  exports.loadAllTypeIndexes = loadAllTypeIndexes;
378
+ // Utility: remove duplicates from Array of NamedNodes
379
+ function uniqueNodes(arr) {
380
+ var uris = arr.map(function (x) { return x.uri; });
381
+ var set = new Set(uris);
382
+ var uris2 = Array.from(set);
383
+ var arr2 = uris2.map(function (u) { return new rdflib_1.NamedNode(u); });
384
+ return arr2; // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
385
+ }
386
+ exports.uniqueNodes = uniqueNodes;
387
+ function getScopedAppsfromIndex(store, scope, theClass) {
388
+ return __awaiter(this, void 0, void 0, function () {
389
+ var index, registrations, directInstances, instances, instanceContainers, containers, i, cont, contents;
390
+ return __generator(this, function (_a) {
391
+ switch (_a.label) {
392
+ case 0:
393
+ 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();
396
+ instances = uniqueNodes(directInstances);
397
+ instanceContainers = registrations.map(function (reg) { return store.each(reg, ns.solid('instanceContainer'), null, index); }).flat();
398
+ containers = uniqueNodes(instanceContainers);
399
+ i = 0;
400
+ _a.label = 1;
401
+ case 1:
402
+ if (!(i < containers.length)) return [3 /*break*/, 4];
403
+ cont = containers[i];
404
+ return [4 /*yield*/, store.fetcher.load(cont)];
405
+ case 2:
406
+ _a.sent();
407
+ contents = store.each(cont, ns.ldp('contains'), null, cont);
408
+ // if (contents.length) console.log('getScopedAppsfromIndex @@ instanceContainer contents:', contents)
409
+ instances = instances.concat(contents);
410
+ _a.label = 3;
411
+ case 3:
412
+ i++;
413
+ return [3 /*break*/, 1];
414
+ case 4: return [2 /*return*/, instances.map(function (instance) { return { instance: instance, scope: scope }; })];
415
+ }
416
+ });
417
+ });
418
+ }
419
+ exports.getScopedAppsfromIndex = getScopedAppsfromIndex;
420
+ function getScopedAppInstances(store, klass, user) {
421
+ return __awaiter(this, void 0, void 0, function () {
422
+ var scopes, scopedApps, _i, scopes_1, scope, scopedApps0;
423
+ return __generator(this, function (_a) {
424
+ switch (_a.label) {
425
+ case 0: return [4 /*yield*/, loadAllTypeIndexes(store, user)];
426
+ case 1:
427
+ scopes = _a.sent();
428
+ scopedApps = [];
429
+ _i = 0, scopes_1 = scopes;
430
+ _a.label = 2;
431
+ case 2:
432
+ if (!(_i < scopes_1.length)) return [3 /*break*/, 5];
433
+ scope = scopes_1[_i];
434
+ return [4 /*yield*/, getScopedAppsfromIndex(store, scope, klass)];
435
+ case 3:
436
+ scopedApps0 = _a.sent();
437
+ scopedApps = scopedApps.concat(scopedApps0);
438
+ _a.label = 4;
439
+ case 4:
440
+ _i++;
441
+ return [3 /*break*/, 2];
442
+ case 5: return [2 /*return*/, scopedApps];
443
+ }
444
+ });
445
+ });
446
+ }
447
+ exports.getScopedAppInstances = getScopedAppInstances;
448
+ // This is the function signature which used to be in solid-ui/logic
449
+ // Recommended to use getScopedAppInstances instead as it provides more information.
450
+ //
451
+ function getAppInstances(store, klass) {
452
+ return __awaiter(this, void 0, void 0, function () {
453
+ var user, scopedAppInstances;
454
+ return __generator(this, function (_a) {
455
+ switch (_a.label) {
456
+ case 0:
457
+ user = currentUser();
458
+ if (!user)
459
+ throw new Error('getAppInstances: Must be logged in to find apps.');
460
+ return [4 /*yield*/, getScopedAppInstances(store, klass, user)];
461
+ case 1:
462
+ scopedAppInstances = _a.sent();
463
+ return [2 /*return*/, scopedAppInstances.map(function (scoped) { return scoped.instance; })];
464
+ }
465
+ });
466
+ });
467
+ }
468
+ exports.getAppInstances = getAppInstances;
198
469
  /*
199
- export async function getAppInstances (store:LiveStore, klass: NamedNode) {
200
-
470
+ * Register a new app in a type index
471
+ * used in chat in bookmark.js (solid-ui)
472
+ * Returns the registration object if successful else null
473
+ */
474
+ function registerInstanceInTypeIndex(store, instance, index, theClass) {
475
+ return __awaiter(this, void 0, void 0, function () {
476
+ var registration, ins, err_7, msg;
477
+ return __generator(this, function (_a) {
478
+ switch (_a.label) {
479
+ case 0:
480
+ registration = (0, uri_1.newThing)(index);
481
+ ins = [
482
+ // See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
483
+ (0, rdflib_1.st)(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
484
+ (0, rdflib_1.st)(registration, ns.solid('forClass'), theClass, index),
485
+ (0, rdflib_1.st)(registration, ns.solid('instance'), instance, index)
486
+ ];
487
+ _a.label = 1;
488
+ case 1:
489
+ _a.trys.push([1, 3, , 4]);
490
+ console.log('patching index', ins);
491
+ return [4 /*yield*/, store.updater.update([], ins)];
492
+ case 2:
493
+ _a.sent();
494
+ return [3 /*break*/, 4];
495
+ case 3:
496
+ err_7 = _a.sent();
497
+ msg = "Unable to register ".concat(instance, " in index ").concat(index, ": ").concat(err_7);
498
+ console.warn(msg);
499
+ return [2 /*return*/, null];
500
+ case 4: return [2 /*return*/, registration];
501
+ }
502
+ });
503
+ });
201
504
  }
202
- */
505
+ exports.registerInstanceInTypeIndex = registerInstanceInTypeIndex;
506
+ // ENDS
203
507
  //# sourceMappingURL=discoveryLogic.js.map