@pod-os/core 0.15.1-c576356.0 → 0.15.1-rc.f1a6ca3.0
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/dist/{chunk-RI2OJWF3.js → chunk-L3UW6YAT.js} +8483 -8480
- package/dist/{dist-SZGBZENE.js → dist-I5XL2ENU.js} +1 -1
- package/dist/index.js +120 -21
- package/lib/index.js +126 -23
- package/package.json +2 -2
- package/types/PodOs.spec.d.ts +1 -0
- package/types/Store.d.ts +2 -1
- package/types/index.d.ts +12 -4
- package/types/offline-cache/OfflineCache.d.ts +15 -0
- package/types/offline-cache/OfflineCapableFetcher.d.ts +18 -0
- package/types/offline-cache/OfflineCapableFetcher.spec.d.ts +1 -0
- package/types/offline-cache/OnlineStatus.d.ts +6 -0
- package/types/offline-cache/index.d.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Fetcher,
|
|
2
3
|
Namespace,
|
|
3
4
|
UpdateManager,
|
|
4
|
-
fetcher,
|
|
5
5
|
graph,
|
|
6
6
|
isBlankNode,
|
|
7
7
|
isLiteral,
|
|
8
8
|
isNamedNode,
|
|
9
9
|
lit,
|
|
10
10
|
namedNode,
|
|
11
|
+
parse,
|
|
11
12
|
require_short_unique_id,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
serialize,
|
|
14
|
+
st,
|
|
15
|
+
termValue
|
|
16
|
+
} from "./chunk-L3UW6YAT.js";
|
|
14
17
|
import {
|
|
15
18
|
__commonJS,
|
|
16
19
|
__export,
|
|
@@ -10573,7 +10576,7 @@ function subtleMapping(jwk) {
|
|
|
10573
10576
|
}
|
|
10574
10577
|
return { algorithm: algorithm3, keyUsages };
|
|
10575
10578
|
}
|
|
10576
|
-
var
|
|
10579
|
+
var parse2 = async (jwk) => {
|
|
10577
10580
|
if (!jwk.alg) {
|
|
10578
10581
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
10579
10582
|
}
|
|
@@ -10588,7 +10591,7 @@ var parse = async (jwk) => {
|
|
|
10588
10591
|
delete keyData.use;
|
|
10589
10592
|
return webcrypto_default.subtle.importKey("jwk", keyData, ...rest3);
|
|
10590
10593
|
};
|
|
10591
|
-
var jwk_to_key_default =
|
|
10594
|
+
var jwk_to_key_default = parse2;
|
|
10592
10595
|
|
|
10593
10596
|
// ../node_modules/@inrupt/solid-client-authn-core/node_modules/jose/dist/browser/runtime/normalize_key.js
|
|
10594
10597
|
var exportKeyValue = (k) => decode(k);
|
|
@@ -13589,7 +13592,7 @@ var FileFetcher = class {
|
|
|
13589
13592
|
|
|
13590
13593
|
// src/modules/contacts.ts
|
|
13591
13594
|
async function loadContactsModule(store) {
|
|
13592
|
-
const module2 = await import("./dist-
|
|
13595
|
+
const module2 = await import("./dist-I5XL2ENU.js");
|
|
13593
13596
|
return new module2.default({
|
|
13594
13597
|
store: store.graph,
|
|
13595
13598
|
fetcher: store.fetcher,
|
|
@@ -13944,14 +13947,14 @@ var LabelIndex = class extends RdfDocument {
|
|
|
13944
13947
|
};
|
|
13945
13948
|
|
|
13946
13949
|
// node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
13947
|
-
async function executeUpdate(
|
|
13950
|
+
async function executeUpdate(fetcher, updater, operation3) {
|
|
13948
13951
|
await updater.updateMany(operation3.deletions, operation3.insertions);
|
|
13949
13952
|
operation3.filesToCreate.map((file2) => {
|
|
13950
|
-
createEmptyTurtleFile(
|
|
13953
|
+
createEmptyTurtleFile(fetcher, file2.url);
|
|
13951
13954
|
});
|
|
13952
13955
|
}
|
|
13953
|
-
function createEmptyTurtleFile(
|
|
13954
|
-
return
|
|
13956
|
+
function createEmptyTurtleFile(fetcher, url7) {
|
|
13957
|
+
return fetcher.webOperation("PUT", url7, {
|
|
13955
13958
|
contentType: "text/turtle"
|
|
13956
13959
|
});
|
|
13957
13960
|
}
|
|
@@ -14036,11 +14039,98 @@ var SearchGateway = class {
|
|
|
14036
14039
|
}
|
|
14037
14040
|
};
|
|
14038
14041
|
|
|
14042
|
+
// src/offline-cache/OfflineCapableFetcher.ts
|
|
14043
|
+
var OfflineCapableFetcher = class extends Fetcher {
|
|
14044
|
+
constructor(store, options) {
|
|
14045
|
+
const { offlineCache, isOnline, ...rest3 } = options;
|
|
14046
|
+
super(store, rest3);
|
|
14047
|
+
this.store = store;
|
|
14048
|
+
this.offlineCache = offlineCache;
|
|
14049
|
+
this.isOnline = isOnline;
|
|
14050
|
+
}
|
|
14051
|
+
async load(oneOrMoreUris, options) {
|
|
14052
|
+
if (Array.isArray(oneOrMoreUris)) {
|
|
14053
|
+
return await super.load(
|
|
14054
|
+
oneOrMoreUris,
|
|
14055
|
+
options
|
|
14056
|
+
);
|
|
14057
|
+
}
|
|
14058
|
+
const node2 = namedNode(termValue(oneOrMoreUris));
|
|
14059
|
+
const doc = node2.doc();
|
|
14060
|
+
if (this.isOnline()) {
|
|
14061
|
+
try {
|
|
14062
|
+
const response6 = await super.load(node2, options);
|
|
14063
|
+
const etag2 = response6.headers.get("etag");
|
|
14064
|
+
this.putToCache(doc, etag2);
|
|
14065
|
+
return response6;
|
|
14066
|
+
} catch (e) {
|
|
14067
|
+
const error4 = e;
|
|
14068
|
+
if (error4.status === 999) {
|
|
14069
|
+
return await this.retrieveFromCache(doc, error4);
|
|
14070
|
+
} else {
|
|
14071
|
+
throw error4;
|
|
14072
|
+
}
|
|
14073
|
+
}
|
|
14074
|
+
} else {
|
|
14075
|
+
return await this.retrieveFromCache(
|
|
14076
|
+
doc,
|
|
14077
|
+
new Error(
|
|
14078
|
+
`You are offline and no data was found in the offline cache for ${doc.uri}`
|
|
14079
|
+
)
|
|
14080
|
+
);
|
|
14081
|
+
}
|
|
14082
|
+
}
|
|
14083
|
+
putToCache(doc, etag2) {
|
|
14084
|
+
const triples = serialize(doc, this.store, null, "application/n-triples");
|
|
14085
|
+
this.offlineCache.put({
|
|
14086
|
+
url: doc.uri,
|
|
14087
|
+
revision: etag2 ?? `timestamp-${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
14088
|
+
statements: triples?.trim() ?? ""
|
|
14089
|
+
});
|
|
14090
|
+
}
|
|
14091
|
+
async retrieveFromCache(doc, errorOnCacheMiss) {
|
|
14092
|
+
const cache = await this.offlineCache.get(doc.uri);
|
|
14093
|
+
if (!cache) {
|
|
14094
|
+
throw errorOnCacheMiss;
|
|
14095
|
+
}
|
|
14096
|
+
parse(cache.statements, this.store, doc.uri, "text/turtle");
|
|
14097
|
+
return new Response(cache.statements, {
|
|
14098
|
+
status: 200,
|
|
14099
|
+
headers: {
|
|
14100
|
+
"Content-Type": "text/turtle",
|
|
14101
|
+
etag: cache.revision
|
|
14102
|
+
}
|
|
14103
|
+
});
|
|
14104
|
+
}
|
|
14105
|
+
};
|
|
14106
|
+
|
|
14107
|
+
// src/offline-cache/OfflineCache.ts
|
|
14108
|
+
var NoOfflineCache = class {
|
|
14109
|
+
put() {
|
|
14110
|
+
}
|
|
14111
|
+
async get() {
|
|
14112
|
+
return void 0;
|
|
14113
|
+
}
|
|
14114
|
+
clear() {
|
|
14115
|
+
}
|
|
14116
|
+
};
|
|
14117
|
+
|
|
14118
|
+
// src/offline-cache/OnlineStatus.ts
|
|
14119
|
+
var AssumeAlwaysOnline = class {
|
|
14120
|
+
isOnline() {
|
|
14121
|
+
return true;
|
|
14122
|
+
}
|
|
14123
|
+
};
|
|
14124
|
+
|
|
14039
14125
|
// src/Store.ts
|
|
14040
14126
|
var Store = class {
|
|
14041
|
-
constructor(session4) {
|
|
14127
|
+
constructor(session4, offlineCache = new NoOfflineCache(), onlineStatus = new AssumeAlwaysOnline()) {
|
|
14042
14128
|
this.graph = graph();
|
|
14043
|
-
this.fetcher =
|
|
14129
|
+
this.fetcher = new OfflineCapableFetcher(this.graph, {
|
|
14130
|
+
fetch: session4.authenticatedFetch,
|
|
14131
|
+
offlineCache,
|
|
14132
|
+
isOnline: onlineStatus.isOnline
|
|
14133
|
+
});
|
|
14044
14134
|
this.updater = new UpdateManager(this.graph);
|
|
14045
14135
|
}
|
|
14046
14136
|
/**
|
|
@@ -23652,7 +23742,7 @@ var Document3 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
23652
23742
|
var Mailbox = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
23653
23743
|
var ProtocolEvent = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
23654
23744
|
var RDFDocument = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
23655
|
-
var
|
|
23745
|
+
var Response2 = "http://www.w3.org/2007/ont/link#Response";
|
|
23656
23746
|
var Session3 = "http://www.w3.org/2007/ont/link#Session";
|
|
23657
23747
|
var isMentionedIn = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
23658
23748
|
var mentionsClass = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -23672,7 +23762,7 @@ var linkImport = /* @__PURE__ */ Object.freeze({
|
|
|
23672
23762
|
Mailbox,
|
|
23673
23763
|
ProtocolEvent,
|
|
23674
23764
|
RDFDocument,
|
|
23675
|
-
Response,
|
|
23765
|
+
Response: Response2,
|
|
23676
23766
|
Session: Session3,
|
|
23677
23767
|
isMentionedIn,
|
|
23678
23768
|
mentionsClass,
|
|
@@ -33938,7 +34028,7 @@ var Document4 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
33938
34028
|
var Mailbox2 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
33939
34029
|
var ProtocolEvent2 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
33940
34030
|
var RDFDocument2 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
33941
|
-
var
|
|
34031
|
+
var Response3 = "http://www.w3.org/2007/ont/link#Response";
|
|
33942
34032
|
var Session4 = "http://www.w3.org/2007/ont/link#Session";
|
|
33943
34033
|
var isMentionedIn2 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
33944
34034
|
var mentionsClass2 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -33958,7 +34048,7 @@ var tabImport = /* @__PURE__ */ Object.freeze({
|
|
|
33958
34048
|
Mailbox: Mailbox2,
|
|
33959
34049
|
ProtocolEvent: ProtocolEvent2,
|
|
33960
34050
|
RDFDocument: RDFDocument2,
|
|
33961
|
-
Response:
|
|
34051
|
+
Response: Response3,
|
|
33962
34052
|
Session: Session4,
|
|
33963
34053
|
isMentionedIn: isMentionedIn2,
|
|
33964
34054
|
mentionsClass: mentionsClass2,
|
|
@@ -33980,7 +34070,7 @@ var Document5 = "http://www.w3.org/2007/ont/link#Document";
|
|
|
33980
34070
|
var Mailbox3 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
33981
34071
|
var ProtocolEvent3 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
33982
34072
|
var RDFDocument3 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
33983
|
-
var
|
|
34073
|
+
var Response4 = "http://www.w3.org/2007/ont/link#Response";
|
|
33984
34074
|
var Session5 = "http://www.w3.org/2007/ont/link#Session";
|
|
33985
34075
|
var isMentionedIn3 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
33986
34076
|
var mentionsClass3 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -34000,7 +34090,7 @@ var tabontImport = /* @__PURE__ */ Object.freeze({
|
|
|
34000
34090
|
Mailbox: Mailbox3,
|
|
34001
34091
|
ProtocolEvent: ProtocolEvent3,
|
|
34002
34092
|
RDFDocument: RDFDocument3,
|
|
34003
|
-
Response:
|
|
34093
|
+
Response: Response4,
|
|
34004
34094
|
Session: Session5,
|
|
34005
34095
|
isMentionedIn: isMentionedIn3,
|
|
34006
34096
|
mentionsClass: mentionsClass3,
|
|
@@ -34472,9 +34562,14 @@ var LdpContainer = class extends Thing {
|
|
|
34472
34562
|
|
|
34473
34563
|
// src/index.ts
|
|
34474
34564
|
var PodOS = class {
|
|
34475
|
-
constructor(
|
|
34476
|
-
|
|
34477
|
-
|
|
34565
|
+
constructor({
|
|
34566
|
+
session: session4 = new BrowserSession(),
|
|
34567
|
+
offlineCache = new NoOfflineCache(),
|
|
34568
|
+
onlineStatus = new AssumeAlwaysOnline()
|
|
34569
|
+
} = {}) {
|
|
34570
|
+
this.session = session4;
|
|
34571
|
+
this.offlineCache = offlineCache;
|
|
34572
|
+
this.store = new Store(this.session, offlineCache, onlineStatus);
|
|
34478
34573
|
this.searchGateway = new SearchGateway(this.store);
|
|
34479
34574
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
34480
34575
|
this.uriService = new UriService(this.store);
|
|
@@ -34561,6 +34656,7 @@ var PodOS = class {
|
|
|
34561
34656
|
return this.searchGateway.buildSearchIndex(profile2);
|
|
34562
34657
|
}
|
|
34563
34658
|
logout() {
|
|
34659
|
+
this.offlineCache.clear();
|
|
34564
34660
|
return this.session.logout();
|
|
34565
34661
|
}
|
|
34566
34662
|
login(oidcIssuer2 = "http://localhost:3000") {
|
|
@@ -34588,12 +34684,15 @@ var PodOS = class {
|
|
|
34588
34684
|
}
|
|
34589
34685
|
};
|
|
34590
34686
|
export {
|
|
34687
|
+
AssumeAlwaysOnline,
|
|
34591
34688
|
BinaryFile,
|
|
34592
34689
|
BrokenFile,
|
|
34593
34690
|
BrowserSession,
|
|
34594
34691
|
HttpStatus,
|
|
34595
34692
|
LabelIndex,
|
|
34596
34693
|
LdpContainer,
|
|
34694
|
+
NoOfflineCache,
|
|
34695
|
+
OfflineCapableFetcher,
|
|
34597
34696
|
PodOS,
|
|
34598
34697
|
RdfDocument,
|
|
34599
34698
|
SearchGateway,
|
package/lib/index.js
CHANGED
|
@@ -35733,8 +35733,8 @@ var PodOS = (() => {
|
|
|
35733
35733
|
return headers;
|
|
35734
35734
|
}
|
|
35735
35735
|
Body.call(Request.prototype);
|
|
35736
|
-
function
|
|
35737
|
-
if (!(this instanceof
|
|
35736
|
+
function Response5(bodyInit, options) {
|
|
35737
|
+
if (!(this instanceof Response5)) {
|
|
35738
35738
|
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
35739
35739
|
}
|
|
35740
35740
|
if (!options) {
|
|
@@ -35751,28 +35751,28 @@ var PodOS = (() => {
|
|
|
35751
35751
|
this.url = options.url || "";
|
|
35752
35752
|
this._initBody(bodyInit);
|
|
35753
35753
|
}
|
|
35754
|
-
Body.call(
|
|
35755
|
-
|
|
35756
|
-
return new
|
|
35754
|
+
Body.call(Response5.prototype);
|
|
35755
|
+
Response5.prototype.clone = function() {
|
|
35756
|
+
return new Response5(this._bodyInit, {
|
|
35757
35757
|
status: this.status,
|
|
35758
35758
|
statusText: this.statusText,
|
|
35759
35759
|
headers: new Headers3(this.headers),
|
|
35760
35760
|
url: this.url
|
|
35761
35761
|
});
|
|
35762
35762
|
};
|
|
35763
|
-
|
|
35764
|
-
var response6 = new
|
|
35763
|
+
Response5.error = function() {
|
|
35764
|
+
var response6 = new Response5(null, { status: 200, statusText: "" });
|
|
35765
35765
|
response6.ok = false;
|
|
35766
35766
|
response6.status = 0;
|
|
35767
35767
|
response6.type = "error";
|
|
35768
35768
|
return response6;
|
|
35769
35769
|
};
|
|
35770
35770
|
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
35771
|
-
|
|
35771
|
+
Response5.redirect = function(url7, status9) {
|
|
35772
35772
|
if (redirectStatuses.indexOf(status9) === -1) {
|
|
35773
35773
|
throw new RangeError("Invalid status code");
|
|
35774
35774
|
}
|
|
35775
|
-
return new
|
|
35775
|
+
return new Response5(null, { status: status9, headers: { location: url7 } });
|
|
35776
35776
|
};
|
|
35777
35777
|
exports2.DOMException = g.DOMException;
|
|
35778
35778
|
try {
|
|
@@ -35810,7 +35810,7 @@ var PodOS = (() => {
|
|
|
35810
35810
|
options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
|
|
35811
35811
|
var body = "response" in xhr ? xhr.response : xhr.responseText;
|
|
35812
35812
|
setTimeout(function() {
|
|
35813
|
-
resolve(new
|
|
35813
|
+
resolve(new Response5(body, options));
|
|
35814
35814
|
}, 0);
|
|
35815
35815
|
};
|
|
35816
35816
|
xhr.onerror = function() {
|
|
@@ -35880,11 +35880,11 @@ var PodOS = (() => {
|
|
|
35880
35880
|
g.fetch = fetch2;
|
|
35881
35881
|
g.Headers = Headers3;
|
|
35882
35882
|
g.Request = Request;
|
|
35883
|
-
g.Response =
|
|
35883
|
+
g.Response = Response5;
|
|
35884
35884
|
}
|
|
35885
35885
|
exports2.Headers = Headers3;
|
|
35886
35886
|
exports2.Request = Request;
|
|
35887
|
-
exports2.Response =
|
|
35887
|
+
exports2.Response = Response5;
|
|
35888
35888
|
exports2.fetch = fetch2;
|
|
35889
35889
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
35890
35890
|
return exports2;
|
|
@@ -38337,12 +38337,16 @@ _:patch
|
|
|
38337
38337
|
"../node_modules/rdflib/esm/index.js"() {
|
|
38338
38338
|
init_defineProperty();
|
|
38339
38339
|
init_blank_node();
|
|
38340
|
+
init_fetcher();
|
|
38340
38341
|
init_formula();
|
|
38341
38342
|
init_namespace();
|
|
38342
38343
|
init_node();
|
|
38344
|
+
init_parse();
|
|
38345
|
+
init_serialize();
|
|
38343
38346
|
init_update_manager();
|
|
38344
38347
|
init_rdflib_data_factory();
|
|
38345
38348
|
init_terms();
|
|
38349
|
+
init_termValue();
|
|
38346
38350
|
boundDataFactory = {};
|
|
38347
38351
|
for (const name7 in rdflib_data_factory_default) {
|
|
38348
38352
|
if (typeof rdflib_data_factory_default[name7] === "function") boundDataFactory[name7] = rdflib_data_factory_default[name7].bind(rdflib_data_factory_default);
|
|
@@ -41428,12 +41432,15 @@ _:patch
|
|
|
41428
41432
|
// src/index.ts
|
|
41429
41433
|
var index_exports = {};
|
|
41430
41434
|
__export(index_exports, {
|
|
41435
|
+
AssumeAlwaysOnline: () => AssumeAlwaysOnline,
|
|
41431
41436
|
BinaryFile: () => BinaryFile,
|
|
41432
41437
|
BrokenFile: () => BrokenFile,
|
|
41433
41438
|
BrowserSession: () => BrowserSession,
|
|
41434
41439
|
HttpStatus: () => HttpStatus,
|
|
41435
41440
|
LabelIndex: () => LabelIndex,
|
|
41436
41441
|
LdpContainer: () => LdpContainer,
|
|
41442
|
+
NoOfflineCache: () => NoOfflineCache,
|
|
41443
|
+
OfflineCapableFetcher: () => OfflineCapableFetcher,
|
|
41437
41444
|
PodOS: () => PodOS,
|
|
41438
41445
|
RdfDocument: () => RdfDocument,
|
|
41439
41446
|
SearchGateway: () => SearchGateway,
|
|
@@ -47011,10 +47018,100 @@ _:patch
|
|
|
47011
47018
|
|
|
47012
47019
|
// src/Store.ts
|
|
47013
47020
|
init_esm();
|
|
47021
|
+
|
|
47022
|
+
// src/offline-cache/OfflineCapableFetcher.ts
|
|
47023
|
+
init_esm();
|
|
47024
|
+
var OfflineCapableFetcher = class extends Fetcher {
|
|
47025
|
+
constructor(store, options) {
|
|
47026
|
+
const { offlineCache, isOnline, ...rest3 } = options;
|
|
47027
|
+
super(store, rest3);
|
|
47028
|
+
this.store = store;
|
|
47029
|
+
this.offlineCache = offlineCache;
|
|
47030
|
+
this.isOnline = isOnline;
|
|
47031
|
+
}
|
|
47032
|
+
async load(oneOrMoreUris, options) {
|
|
47033
|
+
if (Array.isArray(oneOrMoreUris)) {
|
|
47034
|
+
return await super.load(
|
|
47035
|
+
oneOrMoreUris,
|
|
47036
|
+
options
|
|
47037
|
+
);
|
|
47038
|
+
}
|
|
47039
|
+
const node2 = namedNode(termValue(oneOrMoreUris));
|
|
47040
|
+
const doc = node2.doc();
|
|
47041
|
+
if (this.isOnline()) {
|
|
47042
|
+
try {
|
|
47043
|
+
const response6 = await super.load(node2, options);
|
|
47044
|
+
const etag2 = response6.headers.get("etag");
|
|
47045
|
+
this.putToCache(doc, etag2);
|
|
47046
|
+
return response6;
|
|
47047
|
+
} catch (e) {
|
|
47048
|
+
const error4 = e;
|
|
47049
|
+
if (error4.status === 999) {
|
|
47050
|
+
return await this.retrieveFromCache(doc, error4);
|
|
47051
|
+
} else {
|
|
47052
|
+
throw error4;
|
|
47053
|
+
}
|
|
47054
|
+
}
|
|
47055
|
+
} else {
|
|
47056
|
+
return await this.retrieveFromCache(
|
|
47057
|
+
doc,
|
|
47058
|
+
new Error(
|
|
47059
|
+
`You are offline and no data was found in the offline cache for ${doc.uri}`
|
|
47060
|
+
)
|
|
47061
|
+
);
|
|
47062
|
+
}
|
|
47063
|
+
}
|
|
47064
|
+
putToCache(doc, etag2) {
|
|
47065
|
+
const triples = serialize(doc, this.store, null, "application/n-triples");
|
|
47066
|
+
this.offlineCache.put({
|
|
47067
|
+
url: doc.uri,
|
|
47068
|
+
revision: etag2 ?? `timestamp-${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
47069
|
+
statements: triples?.trim() ?? ""
|
|
47070
|
+
});
|
|
47071
|
+
}
|
|
47072
|
+
async retrieveFromCache(doc, errorOnCacheMiss) {
|
|
47073
|
+
const cache = await this.offlineCache.get(doc.uri);
|
|
47074
|
+
if (!cache) {
|
|
47075
|
+
throw errorOnCacheMiss;
|
|
47076
|
+
}
|
|
47077
|
+
parse3(cache.statements, this.store, doc.uri, "text/turtle");
|
|
47078
|
+
return new Response(cache.statements, {
|
|
47079
|
+
status: 200,
|
|
47080
|
+
headers: {
|
|
47081
|
+
"Content-Type": "text/turtle",
|
|
47082
|
+
etag: cache.revision
|
|
47083
|
+
}
|
|
47084
|
+
});
|
|
47085
|
+
}
|
|
47086
|
+
};
|
|
47087
|
+
|
|
47088
|
+
// src/offline-cache/OfflineCache.ts
|
|
47089
|
+
var NoOfflineCache = class {
|
|
47090
|
+
put() {
|
|
47091
|
+
}
|
|
47092
|
+
async get() {
|
|
47093
|
+
return void 0;
|
|
47094
|
+
}
|
|
47095
|
+
clear() {
|
|
47096
|
+
}
|
|
47097
|
+
};
|
|
47098
|
+
|
|
47099
|
+
// src/offline-cache/OnlineStatus.ts
|
|
47100
|
+
var AssumeAlwaysOnline = class {
|
|
47101
|
+
isOnline() {
|
|
47102
|
+
return true;
|
|
47103
|
+
}
|
|
47104
|
+
};
|
|
47105
|
+
|
|
47106
|
+
// src/Store.ts
|
|
47014
47107
|
var Store = class {
|
|
47015
|
-
constructor(session4) {
|
|
47108
|
+
constructor(session4, offlineCache = new NoOfflineCache(), onlineStatus = new AssumeAlwaysOnline()) {
|
|
47016
47109
|
this.graph = graph();
|
|
47017
|
-
this.fetcher =
|
|
47110
|
+
this.fetcher = new OfflineCapableFetcher(this.graph, {
|
|
47111
|
+
fetch: session4.authenticatedFetch,
|
|
47112
|
+
offlineCache,
|
|
47113
|
+
isOnline: onlineStatus.isOnline
|
|
47114
|
+
});
|
|
47018
47115
|
this.updater = new UpdateManager(this.graph);
|
|
47019
47116
|
}
|
|
47020
47117
|
/**
|
|
@@ -56626,7 +56723,7 @@ _:patch
|
|
|
56626
56723
|
var Mailbox = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
56627
56724
|
var ProtocolEvent = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
56628
56725
|
var RDFDocument = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
56629
|
-
var
|
|
56726
|
+
var Response2 = "http://www.w3.org/2007/ont/link#Response";
|
|
56630
56727
|
var Session3 = "http://www.w3.org/2007/ont/link#Session";
|
|
56631
56728
|
var isMentionedIn = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
56632
56729
|
var mentionsClass = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -56646,7 +56743,7 @@ _:patch
|
|
|
56646
56743
|
Mailbox,
|
|
56647
56744
|
ProtocolEvent,
|
|
56648
56745
|
RDFDocument,
|
|
56649
|
-
Response,
|
|
56746
|
+
Response: Response2,
|
|
56650
56747
|
Session: Session3,
|
|
56651
56748
|
isMentionedIn,
|
|
56652
56749
|
mentionsClass,
|
|
@@ -66912,7 +67009,7 @@ _:patch
|
|
|
66912
67009
|
var Mailbox2 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
66913
67010
|
var ProtocolEvent2 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
66914
67011
|
var RDFDocument2 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
66915
|
-
var
|
|
67012
|
+
var Response3 = "http://www.w3.org/2007/ont/link#Response";
|
|
66916
67013
|
var Session4 = "http://www.w3.org/2007/ont/link#Session";
|
|
66917
67014
|
var isMentionedIn2 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
66918
67015
|
var mentionsClass2 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -66932,7 +67029,7 @@ _:patch
|
|
|
66932
67029
|
Mailbox: Mailbox2,
|
|
66933
67030
|
ProtocolEvent: ProtocolEvent2,
|
|
66934
67031
|
RDFDocument: RDFDocument2,
|
|
66935
|
-
Response:
|
|
67032
|
+
Response: Response3,
|
|
66936
67033
|
Session: Session4,
|
|
66937
67034
|
isMentionedIn: isMentionedIn2,
|
|
66938
67035
|
mentionsClass: mentionsClass2,
|
|
@@ -66954,7 +67051,7 @@ _:patch
|
|
|
66954
67051
|
var Mailbox3 = "http://www.w3.org/2007/ont/link#Mailbox";
|
|
66955
67052
|
var ProtocolEvent3 = "http://www.w3.org/2007/ont/link#ProtocolEvent";
|
|
66956
67053
|
var RDFDocument3 = "http://www.w3.org/2007/ont/link#RDFDocument";
|
|
66957
|
-
var
|
|
67054
|
+
var Response4 = "http://www.w3.org/2007/ont/link#Response";
|
|
66958
67055
|
var Session5 = "http://www.w3.org/2007/ont/link#Session";
|
|
66959
67056
|
var isMentionedIn3 = "http://www.w3.org/2007/ont/link#isMentionedIn";
|
|
66960
67057
|
var mentionsClass3 = "http://www.w3.org/2007/ont/link#mentionsClass";
|
|
@@ -66974,7 +67071,7 @@ _:patch
|
|
|
66974
67071
|
Mailbox: Mailbox3,
|
|
66975
67072
|
ProtocolEvent: ProtocolEvent3,
|
|
66976
67073
|
RDFDocument: RDFDocument3,
|
|
66977
|
-
Response:
|
|
67074
|
+
Response: Response4,
|
|
66978
67075
|
Session: Session5,
|
|
66979
67076
|
isMentionedIn: isMentionedIn3,
|
|
66980
67077
|
mentionsClass: mentionsClass3,
|
|
@@ -67447,9 +67544,14 @@ _:patch
|
|
|
67447
67544
|
|
|
67448
67545
|
// src/index.ts
|
|
67449
67546
|
var PodOS = class {
|
|
67450
|
-
constructor(
|
|
67451
|
-
|
|
67452
|
-
|
|
67547
|
+
constructor({
|
|
67548
|
+
session: session4 = new BrowserSession(),
|
|
67549
|
+
offlineCache = new NoOfflineCache(),
|
|
67550
|
+
onlineStatus = new AssumeAlwaysOnline()
|
|
67551
|
+
} = {}) {
|
|
67552
|
+
this.session = session4;
|
|
67553
|
+
this.offlineCache = offlineCache;
|
|
67554
|
+
this.store = new Store(this.session, offlineCache, onlineStatus);
|
|
67453
67555
|
this.searchGateway = new SearchGateway(this.store);
|
|
67454
67556
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
67455
67557
|
this.uriService = new UriService(this.store);
|
|
@@ -67536,6 +67638,7 @@ _:patch
|
|
|
67536
67638
|
return this.searchGateway.buildSearchIndex(profile2);
|
|
67537
67639
|
}
|
|
67538
67640
|
logout() {
|
|
67641
|
+
this.offlineCache.clear();
|
|
67539
67642
|
return this.session.logout();
|
|
67540
67643
|
}
|
|
67541
67644
|
login(oidcIssuer2 = "http://localhost:3000") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pod-os/core",
|
|
3
|
-
"version": "0.15.1-
|
|
3
|
+
"version": "0.15.1-rc.f1a6ca3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@inrupt/solid-client-authn-browser": "^2.3.0",
|
|
46
46
|
"@solid-data-modules/contacts-rdflib": "^0.7.0",
|
|
47
|
-
"@solid-data-modules/rdflib-utils": "^0.
|
|
47
|
+
"@solid-data-modules/rdflib-utils": "^0.6.0",
|
|
48
48
|
"@types/lunr": "^2.3.7",
|
|
49
49
|
"buffer": "^6.0.3",
|
|
50
50
|
"lunr": "^2.3.9",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/Store.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Fetcher, IndexedFormula, UpdateManager } from "rdflib";
|
|
|
2
2
|
import { PodOsSession } from "./authentication";
|
|
3
3
|
import { Thing } from "./thing";
|
|
4
4
|
import { UpdateOperation } from "@solid-data-modules/rdflib-utils";
|
|
5
|
+
import { OfflineCache, OnlineStatus } from "./offline-cache";
|
|
5
6
|
/**
|
|
6
7
|
* The store contains all data that is known locally.
|
|
7
8
|
* It can be used to fetch additional data from the web and also update data and sync it back to editable resources.
|
|
@@ -10,7 +11,7 @@ export declare class Store {
|
|
|
10
11
|
fetcher: Fetcher;
|
|
11
12
|
updater: UpdateManager;
|
|
12
13
|
graph: IndexedFormula;
|
|
13
|
-
constructor(session: PodOsSession);
|
|
14
|
+
constructor(session: PodOsSession, offlineCache?: OfflineCache, onlineStatus?: OnlineStatus);
|
|
14
15
|
/**
|
|
15
16
|
* Fetch data for the given URI to the store
|
|
16
17
|
* @param uri
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContactsModule } from "@solid-data-modules/contacts-rdflib";
|
|
2
2
|
import { BehaviorSubject } from "rxjs";
|
|
3
|
-
import { SessionInfo } from "./authentication";
|
|
3
|
+
import { BrowserSession, SessionInfo } from "./authentication";
|
|
4
4
|
import { SolidFile } from "./files";
|
|
5
5
|
import { WebIdProfile } from "./profile";
|
|
6
6
|
import { LabelIndex } from "./search";
|
|
@@ -8,6 +8,7 @@ import { Store } from "./Store";
|
|
|
8
8
|
import { Term } from "./terms";
|
|
9
9
|
import { Thing } from "./thing";
|
|
10
10
|
import { UriService } from "./uri/UriService";
|
|
11
|
+
import { OfflineCache, OnlineStatus } from "./offline-cache";
|
|
11
12
|
export * from "./authentication";
|
|
12
13
|
export * from "./files";
|
|
13
14
|
export * from "./thing";
|
|
@@ -15,13 +16,20 @@ export * from "./rdf-document";
|
|
|
15
16
|
export * from "./ldp-container";
|
|
16
17
|
export * from "./profile";
|
|
17
18
|
export * from "./search";
|
|
19
|
+
export * from "./offline-cache";
|
|
20
|
+
export interface PodOsConfiguration {
|
|
21
|
+
offlineCache?: OfflineCache;
|
|
22
|
+
onlineStatus?: OnlineStatus;
|
|
23
|
+
session?: BrowserSession;
|
|
24
|
+
}
|
|
18
25
|
export declare class PodOS {
|
|
19
26
|
private readonly session;
|
|
20
27
|
readonly store: Store;
|
|
21
28
|
readonly uriService: UriService;
|
|
22
|
-
private fileFetcher;
|
|
23
|
-
private searchGateway;
|
|
24
|
-
|
|
29
|
+
private readonly fileFetcher;
|
|
30
|
+
private readonly searchGateway;
|
|
31
|
+
private readonly offlineCache;
|
|
32
|
+
constructor({ session, offlineCache, onlineStatus, }?: PodOsConfiguration);
|
|
25
33
|
private flagAuthorizationMetaDataOnSessionChange;
|
|
26
34
|
handleIncomingRedirect(restorePreviousSession?: boolean): void;
|
|
27
35
|
fetch(uri: string): Promise<Response>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CachedRdfDocument {
|
|
2
|
+
url: string;
|
|
3
|
+
revision: string;
|
|
4
|
+
statements: string;
|
|
5
|
+
}
|
|
6
|
+
export interface OfflineCache {
|
|
7
|
+
put(document: CachedRdfDocument): void;
|
|
8
|
+
get(url: string): Promise<CachedRdfDocument | undefined>;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class NoOfflineCache implements OfflineCache {
|
|
12
|
+
put(): void;
|
|
13
|
+
get(): Promise<undefined>;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AutoInitOptions, Fetcher, IndexedFormula, NamedNode } from "rdflib";
|
|
2
|
+
import { OfflineCache } from "./OfflineCache";
|
|
3
|
+
export interface OfflineCapableFetcherOptions {
|
|
4
|
+
fetch: (uri: string) => Promise<Response>;
|
|
5
|
+
isOnline: () => boolean;
|
|
6
|
+
offlineCache: OfflineCache;
|
|
7
|
+
}
|
|
8
|
+
export declare class OfflineCapableFetcher extends Fetcher {
|
|
9
|
+
private readonly offlineCache;
|
|
10
|
+
private readonly isOnline;
|
|
11
|
+
private readonly store;
|
|
12
|
+
constructor(store: IndexedFormula, options: Partial<AutoInitOptions> & OfflineCapableFetcherOptions);
|
|
13
|
+
load(uri: string, options?: Partial<AutoInitOptions>): Promise<Response>;
|
|
14
|
+
load(uri: NamedNode, options?: Partial<AutoInitOptions>): Promise<Response>;
|
|
15
|
+
load(uri: Array<string | NamedNode>, options?: Partial<AutoInitOptions>): Promise<Response[]>;
|
|
16
|
+
private putToCache;
|
|
17
|
+
private retrieveFromCache;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|