solid-logic 1.3.14-73b319bb → 1.3.14-82390443
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.
- package/.github/workflows/ci.yml +1 -0
- package/lib/discovery/discoveryLogic.d.ts +13 -0
- package/lib/discovery/discoveryLogic.d.ts.map +1 -0
- package/lib/discovery/discoveryLogic.js +203 -0
- package/lib/discovery/discoveryLogic.js.map +1 -0
- package/lib/inbox/InboxLogic.js +2 -2
- package/lib/inbox/InboxLogic.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/logic/SolidLogic.d.ts +1 -2
- package/lib/logic/SolidLogic.d.ts.map +1 -1
- package/lib/logic/SolidLogic.js +38 -39
- package/lib/logic/SolidLogic.js.map +1 -1
- package/lib/typeIndex/typeIndexLogic.d.ts +4 -4
- package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/lib/typeIndex/typeIndexLogic.js +93 -31
- package/lib/typeIndex/typeIndexLogic.js.map +1 -1
- package/lib/util/UtilityLogic.d.ts +2 -2
- package/lib/util/UtilityLogic.d.ts.map +1 -1
- package/lib/util/UtilityLogic.js +6 -6
- package/lib/util/UtilityLogic.js.map +1 -1
- package/package.json +2 -2
- package/src/discovery/discoveryLogic.ts +90 -0
- package/src/inbox/InboxLogic.ts +2 -2
- package/src/index.ts +10 -0
- package/src/logic/SolidLogic.ts +28 -31
- package/src/typeIndex/typeIndexLogic.ts +92 -61
- package/src/util/UtilityLogic.ts +8 -8
- package/test/typeIndexLogic.test.ts +4 -3
- package/.nvmrc +0 -1
|
@@ -65,11 +65,35 @@ var solid_namespace_1 = __importDefault(require("solid-namespace"));
|
|
|
65
65
|
var $rdf = __importStar(require("rdflib"));
|
|
66
66
|
var uri_1 = require("../util/uri");
|
|
67
67
|
var solidLogicSingleton_1 = require("../logic/solidLogicSingleton");
|
|
68
|
+
// import { ensureLoadedPreferences } from '../logic/logic'
|
|
69
|
+
var discoveryLogic_1 = require("../discovery/discoveryLogic");
|
|
68
70
|
exports.ns = (0, solid_namespace_1.default)($rdf);
|
|
71
|
+
var store = solidLogicSingleton_1.solidLogicSingleton.store;
|
|
72
|
+
function ensureLoadedPreferences(context) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return __generator(this, function (_c) {
|
|
76
|
+
switch (_c.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
if (!context.me)
|
|
79
|
+
throw new Error('@@ ensureLoadedPreferences: no user specified');
|
|
80
|
+
_a = context;
|
|
81
|
+
return [4 /*yield*/, (0, discoveryLogic_1.loadProfile)(store, context.me)];
|
|
82
|
+
case 1:
|
|
83
|
+
_a.publicProfile = _c.sent();
|
|
84
|
+
_b = context;
|
|
85
|
+
return [4 /*yield*/, (0, discoveryLogic_1.loadPreferences)(store, context.me)];
|
|
86
|
+
case 2:
|
|
87
|
+
_b.preferencesFile = _c.sent();
|
|
88
|
+
return [2 /*return*/, context];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
69
93
|
/**
|
|
70
94
|
* Resolves with the same context, outputting
|
|
71
95
|
* output: index.public, index.private
|
|
72
|
-
*
|
|
96
|
+
* @@ This is a very bizare function
|
|
73
97
|
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
74
98
|
*/
|
|
75
99
|
function loadIndex(context, isPublic) {
|
|
@@ -86,8 +110,8 @@ function loadIndex(context, isPublic) {
|
|
|
86
110
|
case 1:
|
|
87
111
|
indexes = _a.sent();
|
|
88
112
|
context.index = context.index || {};
|
|
89
|
-
context.index.private = indexes.private
|
|
90
|
-
context.index.public = indexes.public
|
|
113
|
+
context.index.private = indexes.private.concat(context.index.private);
|
|
114
|
+
context.index.public = indexes.public.concat(context.index.public);
|
|
91
115
|
return [2 /*return*/, context];
|
|
92
116
|
}
|
|
93
117
|
});
|
|
@@ -96,21 +120,36 @@ function loadIndex(context, isPublic) {
|
|
|
96
120
|
exports.loadIndex = loadIndex;
|
|
97
121
|
function loadTypeIndexes(context) {
|
|
98
122
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var indexes;
|
|
123
|
+
var error_1, indexes, error_2;
|
|
100
124
|
var _this = this;
|
|
101
125
|
return __generator(this, function (_a) {
|
|
102
126
|
switch (_a.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return [2 /*return*/, debug.warn(err.message)];
|
|
107
|
-
}); }); })];
|
|
127
|
+
case 0:
|
|
128
|
+
_a.trys.push([0, 2, , 3]);
|
|
129
|
+
return [4 /*yield*/, (0, discoveryLogic_1.loadPreferences)(solidLogicSingleton_1.solidLogicSingleton.store, context.me)];
|
|
108
130
|
case 1:
|
|
131
|
+
_a.sent();
|
|
132
|
+
return [3 /*break*/, 3];
|
|
133
|
+
case 2:
|
|
134
|
+
error_1 = _a.sent();
|
|
135
|
+
debug.warn(error_1.message);
|
|
136
|
+
return [3 /*break*/, 3];
|
|
137
|
+
case 3:
|
|
138
|
+
_a.trys.push([3, 5, , 6]);
|
|
139
|
+
return [4 /*yield*/, solidLogicSingleton_1.solidLogicSingleton.loadIndexes(context.me, context.publicProfile || null, context.preferencesFile || null)];
|
|
140
|
+
case 4:
|
|
109
141
|
indexes = _a.sent();
|
|
110
142
|
context.index = context.index || {};
|
|
111
143
|
context.index.private = indexes.private || context.index.private;
|
|
112
144
|
context.index.public = indexes.public || context.index.public;
|
|
113
145
|
return [2 /*return*/, context];
|
|
146
|
+
case 5:
|
|
147
|
+
error_2 = _a.sent();
|
|
148
|
+
(function (error) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
149
|
+
return [2 /*return*/, debug.warn(error.message)];
|
|
150
|
+
}); }); });
|
|
151
|
+
return [3 /*break*/, 6];
|
|
152
|
+
case 6: return [2 /*return*/];
|
|
114
153
|
}
|
|
115
154
|
});
|
|
116
155
|
});
|
|
@@ -120,14 +159,18 @@ exports.loadTypeIndexes = loadTypeIndexes;
|
|
|
120
159
|
* Resolves with the same context, outputting
|
|
121
160
|
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
122
161
|
*/
|
|
123
|
-
function ensureTypeIndexes(context) {
|
|
162
|
+
function ensureTypeIndexes(context, agent) {
|
|
124
163
|
return __awaiter(this, void 0, void 0, function () {
|
|
125
164
|
return __generator(this, function (_a) {
|
|
126
165
|
switch (_a.label) {
|
|
127
|
-
case 0:
|
|
166
|
+
case 0:
|
|
167
|
+
if (!context.me) {
|
|
168
|
+
throw new Error("ensureTypeIndexes: @@ no user");
|
|
169
|
+
}
|
|
170
|
+
return [4 /*yield*/, ensureOneTypeIndex(context, true, agent)];
|
|
128
171
|
case 1:
|
|
129
172
|
_a.sent();
|
|
130
|
-
return [4 /*yield*/, ensureOneTypeIndex(context, false)];
|
|
173
|
+
return [4 /*yield*/, ensureOneTypeIndex(context, false, agent)];
|
|
131
174
|
case 2:
|
|
132
175
|
_a.sent();
|
|
133
176
|
return [2 /*return*/, context];
|
|
@@ -144,7 +187,7 @@ exports.ensureTypeIndexes = ensureTypeIndexes;
|
|
|
144
187
|
* Adds its output to the context
|
|
145
188
|
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
146
189
|
*/
|
|
147
|
-
function ensureOneTypeIndex(context, isPublic) {
|
|
190
|
+
function ensureOneTypeIndex(context, isPublic, agent) {
|
|
148
191
|
return __awaiter(this, void 0, void 0, function () {
|
|
149
192
|
function makeIndexIfNecessary(context, isPublic) {
|
|
150
193
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -175,10 +218,16 @@ function ensureOneTypeIndex(context, isPublic) {
|
|
|
175
218
|
switch (_a.label) {
|
|
176
219
|
case 0:
|
|
177
220
|
relevant = isPublic ? context.publicProfile : context.preferencesFile;
|
|
221
|
+
if (!relevant)
|
|
222
|
+
alert('@@@@ relevent null');
|
|
178
223
|
visibility = isPublic ? 'public' : 'private';
|
|
179
224
|
context.index = context.index || {};
|
|
180
225
|
context.index[visibility] = context.index[visibility] || [];
|
|
181
226
|
if (!(context.index[visibility].length === 0)) return [3 /*break*/, 6];
|
|
227
|
+
if (!store.updater.editable(relevant)) {
|
|
228
|
+
debug.log("Not adding new type index as ".concat(relevant, " is not editable"));
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
182
231
|
newIndex = (0, rdflib_1.sym)("".concat(relevant.dir().uri + visibility, "TypeIndex.ttl"));
|
|
183
232
|
debug.log("Linking to new fresh type index ".concat(newIndex));
|
|
184
233
|
if (!confirm("OK to create a new empty index file at ".concat(newIndex, ", overwriting anything that is now there?"))) {
|
|
@@ -227,29 +276,41 @@ function ensureOneTypeIndex(context, isPublic) {
|
|
|
227
276
|
});
|
|
228
277
|
});
|
|
229
278
|
} // makeIndexIfNecessary
|
|
230
|
-
var
|
|
279
|
+
var context2, relevant, pp, error_3;
|
|
231
280
|
return __generator(this, function (_a) {
|
|
232
281
|
switch (_a.label) {
|
|
233
|
-
case 0:
|
|
234
|
-
_a.trys.push([0, 2, , 4]);
|
|
235
|
-
return [4 /*yield*/, loadIndex(context, isPublic)];
|
|
282
|
+
case 0: return [4 /*yield*/, ensureLoadedPreferences(context)];
|
|
236
283
|
case 1:
|
|
284
|
+
context2 = _a.sent();
|
|
285
|
+
if (!context2.publicProfile)
|
|
286
|
+
throw new Error("@@ type index: no publicProfile");
|
|
287
|
+
if (!context2.preferencesFile)
|
|
288
|
+
throw new Error("@@ type index: no preferencesFile for profile ".concat(context2.publicProfile));
|
|
289
|
+
relevant = isPublic ? context2.publicProfile : context2.preferencesFile;
|
|
290
|
+
_a.label = 2;
|
|
291
|
+
case 2:
|
|
292
|
+
_a.trys.push([2, 5, , 7]);
|
|
293
|
+
return [4 /*yield*/, loadIndex(context2, isPublic)];
|
|
294
|
+
case 3:
|
|
237
295
|
_a.sent();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
296
|
+
pp = isPublic ? 'public' : 'private';
|
|
297
|
+
if (context2.index && context2.index[pp] && context2.index[pp].length > 0) {
|
|
298
|
+
debug.log("ensureOneTypeIndex: Type index exists already ".concat(context2.index[pp]));
|
|
299
|
+
return [2 /*return*/, context2];
|
|
242
300
|
}
|
|
243
|
-
return [
|
|
244
|
-
case
|
|
245
|
-
|
|
246
|
-
return [
|
|
247
|
-
|
|
301
|
+
return [4 /*yield*/, makeIndexIfNecessary(context2, isPublic)];
|
|
302
|
+
case 4:
|
|
303
|
+
_a.sent();
|
|
304
|
+
return [3 /*break*/, 7];
|
|
305
|
+
case 5:
|
|
306
|
+
error_3 = _a.sent();
|
|
307
|
+
return [4 /*yield*/, makeIndexIfNecessary(context2, isPublic)
|
|
308
|
+
// widgets.complain(context2, 'calling loadIndex:' + error)
|
|
248
309
|
];
|
|
249
|
-
case
|
|
310
|
+
case 6:
|
|
250
311
|
_a.sent();
|
|
251
|
-
return [3 /*break*/,
|
|
252
|
-
case
|
|
312
|
+
return [3 /*break*/, 7];
|
|
313
|
+
case 7: return [2 /*return*/];
|
|
253
314
|
}
|
|
254
315
|
});
|
|
255
316
|
});
|
|
@@ -258,12 +319,13 @@ function ensureOneTypeIndex(context, isPublic) {
|
|
|
258
319
|
* Register a new app in a type index
|
|
259
320
|
* used in chat in bookmark.js (solid-ui)
|
|
260
321
|
*/
|
|
261
|
-
function registerInTypeIndex(context, instance, theClass, isPublic
|
|
322
|
+
function registerInTypeIndex(context, instance, theClass, isPublic, agent // Defaults to current user
|
|
323
|
+
) {
|
|
262
324
|
return __awaiter(this, void 0, void 0, function () {
|
|
263
325
|
var indexes, index, registration, ins, e_2;
|
|
264
326
|
return __generator(this, function (_a) {
|
|
265
327
|
switch (_a.label) {
|
|
266
|
-
case 0: return [4 /*yield*/, ensureOneTypeIndex(context, isPublic)];
|
|
328
|
+
case 0: return [4 /*yield*/, ensureOneTypeIndex(context, isPublic, agent)];
|
|
267
329
|
case 1:
|
|
268
330
|
_a.sent();
|
|
269
331
|
if (!context.index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeIndexLogic.js","sourceRoot":"","sources":["../../src/typeIndex/typeIndexLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,mDAAsC;AACtC,oEAA4C;AAC5C,2CAA8B;AAC9B,mCAAsC;AAEtC,oEAAkE;
|
|
1
|
+
{"version":3,"file":"typeIndexLogic.js","sourceRoot":"","sources":["../../src/typeIndex/typeIndexLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,mDAAsC;AACtC,oEAA4C;AAC5C,2CAA8B;AAC9B,mCAAsC;AAEtC,oEAAkE;AAClE,2DAA2D;AAC3D,8DAA0E;AAC7D,QAAA,EAAE,GAAG,IAAA,yBAAc,EAAC,IAAI,CAAC,CAAA;AAEtC,IAAM,KAAK,GAAG,yCAAmB,CAAC,KAAK,CAAA;AAEvC,SAAe,uBAAuB,CAAE,OAA6B;;;;;;oBACnE,IAAI,CAAC,OAAO,CAAC,EAAE;wBAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;oBACjF,KAAA,OAAO,CAAA;oBAAiB,qBAAM,IAAA,4BAAW,EAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,EAAA;;oBAA5D,GAAQ,aAAa,GAAG,SAAoC,CAAA;oBAC5D,KAAA,OAAO,CAAA;oBAAmB,qBAAM,IAAA,gCAAe,EAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,EAAA;;oBAAlE,GAAQ,eAAe,GAAG,SAAwC,CAAA;oBAClE,sBAAO,OAAO,EAAA;;;;CACf;AAED;;;;;GAKG;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AK,CAAC,CAAA;oBAC9B,GAAG,GAAG;wBACR,2EAA2E;wBAC3E,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,UAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC;wBACrE,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC;wBACvD,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC;qBAC1D,CAAA;;;;oBAEG,qBAAM,yCAAmB,CAAC,aAAa,CAAC,EAAE,EAAE,GAAG,CAAC,EAAA;;oBAAhD,SAAgD,CAAA;;;;oBAEhD,KAAK,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;oBACZ,KAAK,CAAC,GAAC,CAAC,CAAA;;wBAEZ,sBAAO,OAAO,EAAA;;;;CACjB;AA9BD,kDA8BC"}
|
|
@@ -7,10 +7,10 @@ export declare const ACL_LINK: NamedNode;
|
|
|
7
7
|
export declare class UtilityLogic {
|
|
8
8
|
store: LiveStore;
|
|
9
9
|
ns: SolidNamespace;
|
|
10
|
-
|
|
10
|
+
underlyingFetch: {
|
|
11
11
|
fetch: (url: string, options?: any) => any;
|
|
12
12
|
};
|
|
13
|
-
constructor(store: LiveStore, ns: SolidNamespace,
|
|
13
|
+
constructor(store: LiveStore, ns: SolidNamespace, underlyingFetch: {
|
|
14
14
|
fetch: (url: string, options?: any) => any;
|
|
15
15
|
});
|
|
16
16
|
findAclDocUrl(url: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityLogic.d.ts","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO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;IAWrD,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAO5D,eAAe,CAAC,GAAG,EAAE,MAAM;IAgBjC,UAAU;IAIV,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAQ1C"}
|
package/lib/util/UtilityLogic.js
CHANGED
|
@@ -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,
|
|
46
|
+
function UtilityLogic(store, ns, underlyingFetch) {
|
|
47
47
|
this.store = store;
|
|
48
48
|
this.ns = ns;
|
|
49
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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,eAA+D;QAC/G,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,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AG,cAAI,QAAQ,CAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtF,CAAC;IACH,mBAAC;AAAD,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-
|
|
3
|
+
"version": "1.3.14-82390443",
|
|
4
4
|
"description": "Core business logic of Solid OS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@inrupt/solid-client-authn-browser": "^1.11.5",
|
|
46
|
-
"rdflib": "^2.2.
|
|
46
|
+
"rdflib": "^2.2.18",
|
|
47
47
|
"solid-namespace": "^0.5.2"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { NamedNode, Namespace, LiveStore } from "rdflib";
|
|
2
|
+
|
|
3
|
+
type TypeIndex = { label: string, index: NamedNode, agent: NamedNode } ;
|
|
4
|
+
|
|
5
|
+
const ns ={
|
|
6
|
+
solid: Namespace('http://www.w3.org/ns/solid/terms#'),
|
|
7
|
+
space: Namespace('http://www.w3.org/ns/pim/space#')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function loadProfile(store: LiveStore, user) {
|
|
11
|
+
if (!user) {
|
|
12
|
+
throw new Error(`loadProfile: no user given.`)
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
await store.fetcher.load(user.doc())
|
|
16
|
+
} catch (err) {
|
|
17
|
+
throw new Error(`Unable to load profile of user <${user}>: ${err}`)
|
|
18
|
+
}
|
|
19
|
+
return user.doc()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function loadPreferences(store: LiveStore, user): Promise <NamedNode | undefined > {
|
|
23
|
+
const profile = await loadProfile(store as LiveStore, user)
|
|
24
|
+
const preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile)
|
|
25
|
+
if (!preferencesFile) {
|
|
26
|
+
// throw new Error(`USer ${user} has no pointer in profile to preferences file.`)
|
|
27
|
+
return undefined
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
store.fetcher.load(preferencesFile as NamedNode)
|
|
31
|
+
} catch (err) { // Mabeb a permission propblem or origin problem
|
|
32
|
+
return undefined
|
|
33
|
+
// throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
|
|
34
|
+
}
|
|
35
|
+
return preferencesFile as NamedNode
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<TypeIndex>> {
|
|
39
|
+
if (!user) throw new Error(`loadTypeIndexesFor: No user given`)
|
|
40
|
+
const profile = await loadProfile(store, user)
|
|
41
|
+
const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
|
|
42
|
+
if (publicTypeIndex) {
|
|
43
|
+
try {
|
|
44
|
+
await store.fetcher.load(publicTypeIndex as NamedNode)
|
|
45
|
+
} catch {
|
|
46
|
+
// never mind
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const pub = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
|
|
50
|
+
|
|
51
|
+
const preferencesFile = await loadPreferences(store, user)
|
|
52
|
+
if (preferencesFile) { // watch out - can be in either as spec was not clear
|
|
53
|
+
const privateTypeIndexes = store.each(user, ns.solid('privateTypeIndex'), undefined, preferencesFile as NamedNode)
|
|
54
|
+
.concat(store.each(user, ns.solid('privateTypeIndex'), undefined, profile))
|
|
55
|
+
const priv = privateTypeIndexes.length > 0 ? [ { label: 'priSo @@@@@vate', index: privateTypeIndexes[0] as NamedNode, agent: user } ] : []
|
|
56
|
+
return pub.concat(priv)
|
|
57
|
+
}
|
|
58
|
+
return pub
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<TypeIndex[][]> {
|
|
62
|
+
const preferencesFile = await loadPreferences(store, user)
|
|
63
|
+
if (preferencesFile) {
|
|
64
|
+
const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode)
|
|
65
|
+
const communityTypeIndexesPromise = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
|
|
66
|
+
const result1 = Promise.all(communityTypeIndexesPromise)
|
|
67
|
+
// const result2 = Promise.all(result1)
|
|
68
|
+
// const flat = result2.flat()
|
|
69
|
+
return result1
|
|
70
|
+
// const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
|
|
71
|
+
/*
|
|
72
|
+
let result = [] as TypeIndex[]
|
|
73
|
+
for(const community of communities) {
|
|
74
|
+
result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
|
|
75
|
+
}
|
|
76
|
+
*/
|
|
77
|
+
// return communityTypeIndexesPromise.resolve()
|
|
78
|
+
}
|
|
79
|
+
return []
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function loadAllTypeIndexes (store:LiveStore, user:NamedNode) {
|
|
83
|
+
return (await loadTypeIndexesFor(store, user)).concat((await loadCommunityTypeIndexes(store, user)).flat())
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
export async function getAppInstances (store:LiveStore, klass: NamedNode) {
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
*/
|
package/src/inbox/InboxLogic.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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'
|
package/src/logic/SolidLogic.ts
CHANGED
|
@@ -9,7 +9,12 @@ import { AuthnLogic, SolidNamespace } from "../types";
|
|
|
9
9
|
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
|
+
** It is important to distinquish `fetch`, a function provided by the browser
|
|
14
|
+
** and `Fetcher`, a helper object for the rdflib Store which turns it
|
|
15
|
+
** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
|
|
16
|
+
** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
|
|
17
|
+
*/
|
|
13
18
|
|
|
14
19
|
const ns: SolidNamespace = solidNamespace(rdf);
|
|
15
20
|
|
|
@@ -25,7 +30,7 @@ export class SolidLogic {
|
|
|
25
30
|
|
|
26
31
|
store: LiveStore;
|
|
27
32
|
me: string | undefined;
|
|
28
|
-
|
|
33
|
+
underlyingFetch: { fetch: (url: string, options?: any) => any };
|
|
29
34
|
|
|
30
35
|
chat: ChatLogic;
|
|
31
36
|
profile: ProfileLogic;
|
|
@@ -33,52 +38,56 @@ export class SolidLogic {
|
|
|
33
38
|
util: UtilityLogic;
|
|
34
39
|
|
|
35
40
|
constructor(fetcher: { fetch: (url: any, requestInit: any) => any }, session: Session) {
|
|
41
|
+
// would xpect to be able to do it this way: but get TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation status: 999
|
|
42
|
+
// this.store = new rdf.LiveStore({})
|
|
43
|
+
// this.store.fetcher._fetch = fetch
|
|
44
|
+
|
|
36
45
|
this.store = rdf.graph() as LiveStore; // Make a Quad store
|
|
37
|
-
rdf.fetcher(this.store,
|
|
46
|
+
rdf.fetcher(this.store, fetch); // Attach a web I/O module, store.fetcher
|
|
38
47
|
this.store.updater = new rdf.UpdateManager(this.store); // Add real-time live updates store.updater
|
|
48
|
+
|
|
39
49
|
this.store.features = [] // disable automatic node merging on store load
|
|
40
50
|
this.cache = {
|
|
41
51
|
profileDocument: {},
|
|
42
52
|
preferencesFile: {},
|
|
43
53
|
};
|
|
44
|
-
this.
|
|
54
|
+
this.underlyingFetch = { fetch: fetch };
|
|
45
55
|
this.authn = new SolidAuthnLogic(session);
|
|
46
56
|
debug.log('SolidAuthnLogic initialized')
|
|
47
57
|
this.profile = new ProfileLogic(this.store, ns, this.authn);
|
|
48
58
|
this.chat = new ChatLogic(this.store, ns, this.profile);
|
|
49
|
-
this.util = new UtilityLogic(this.store, ns, this.
|
|
59
|
+
this.util = new UtilityLogic(this.store, ns, this.underlyingFetch);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
findAclDocUrl(url: string) {
|
|
53
63
|
return this.util.findAclDocUrl(url);
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
loadDoc(doc: NamedNode): Promise<void> {
|
|
57
|
-
return this.util.loadDoc(doc);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
66
|
async loadProfile(me: NamedNode): Promise<NamedNode> {
|
|
61
|
-
|
|
67
|
+
/*
|
|
68
|
+
// console.log('loadProfile cache ', this.cache)
|
|
62
69
|
if (this.cache.profileDocument[me.value]) {
|
|
63
70
|
return this.cache.profileDocument[me.value];
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
} @@ just use the cache in the store
|
|
72
|
+
*/
|
|
73
|
+
console.log('loadProfile me ', me)
|
|
74
|
+
const profileDocument = me.doc()
|
|
66
75
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return profileDocument;
|
|
76
|
+
await this.store.fetcher.load(profileDocument);
|
|
77
|
+
return profileDocument;
|
|
70
78
|
} catch (err) {
|
|
71
|
-
const message = `
|
|
79
|
+
const message = `Cannot load profile ${profileDocument} : ${err}`;
|
|
72
80
|
throw new Error(message);
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
async loadPreferences(me: NamedNode): Promise<NamedNode> {
|
|
77
|
-
|
|
85
|
+
console.log('loadPreferences cache ', this.cache)
|
|
78
86
|
if (this.cache.preferencesFile[me.value]) {
|
|
79
87
|
return this.cache.preferencesFile[me.value];
|
|
80
88
|
}
|
|
81
|
-
|
|
89
|
+
await this.loadProfile(me) // Load pointer to pref file
|
|
90
|
+
const preferencesFile = this.store.any(me, ns.space('preferencesFile'), null, me.doc());
|
|
82
91
|
|
|
83
92
|
// console.log('this.store.any()', this.store.any())
|
|
84
93
|
/**
|
|
@@ -100,9 +109,6 @@ export class SolidLogic {
|
|
|
100
109
|
);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
if (!this.store.fetcher) {
|
|
104
|
-
throw new Error("Cannot load doc, have no fetcher");
|
|
105
|
-
}
|
|
106
112
|
// //// Load preference file
|
|
107
113
|
try {
|
|
108
114
|
await this.store.fetcher.load(preferencesFile as NamedNode, {
|
|
@@ -152,9 +158,6 @@ export class SolidLogic {
|
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
load(doc: NamedNode | NamedNode[] | string) {
|
|
155
|
-
if (!this.store.fetcher) {
|
|
156
|
-
throw new Error("Cannot load doc(s), have no fetcher");
|
|
157
|
-
}
|
|
158
161
|
return this.store.fetcher.load(doc);
|
|
159
162
|
}
|
|
160
163
|
|
|
@@ -210,9 +213,6 @@ export class SolidLogic {
|
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
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
216
|
await this.store.fetcher.webOperation("PUT", doc.uri, {
|
|
217
217
|
data: `# ${new Date()} ${comment}
|
|
218
218
|
`,
|
|
@@ -226,9 +226,6 @@ export class SolidLogic {
|
|
|
226
226
|
ins: Array<Statement> = []
|
|
227
227
|
): Promise<void> {
|
|
228
228
|
return new Promise((resolve, reject) => {
|
|
229
|
-
if (!this.store.updater) {
|
|
230
|
-
throw new Error("Cannot updatePromise, have no updater");
|
|
231
|
-
}
|
|
232
229
|
this.store.updater.update(del, ins, function (_uri, ok, errorBody) {
|
|
233
230
|
if (!ok) {
|
|
234
231
|
reject(new Error(errorBody));
|
|
@@ -260,6 +257,6 @@ export class SolidLogic {
|
|
|
260
257
|
}
|
|
261
258
|
|
|
262
259
|
async fetch(url: string, options?: any) {
|
|
263
|
-
return this.
|
|
260
|
+
return this.underlyingFetch.fetch(url, options);
|
|
264
261
|
}
|
|
265
262
|
}
|