@pod-os/core 0.22.1-rc.f2eaee2.0 → 0.23.1-rc.11e4e07.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/index.js +261 -63
- package/lib/index.js +274 -71
- package/package.json +1 -1
- package/types/attachments/AttachmentGateway.d.ts +23 -0
- package/types/attachments/index.d.ts +1 -0
- package/types/files/FileFetcher.d.ts +3 -0
- package/types/files/FileGateway.d.ts +26 -0
- package/types/files/FileGateway.spec.d.ts +1 -0
- package/types/files/createFileLinkOperation.d.ts +13 -0
- package/types/files/createFileLinkOperation.spec.d.ts +1 -0
- package/types/files/index.d.ts +1 -0
- package/types/index.d.ts +13 -3
- package/types/namespaces/index.d.ts +2 -0
- package/types/picture/PictureGateway.d.ts +6 -7
- package/types/picture/index.d.ts +0 -1
- package/types/profile/ProfileGateway.d.ts +10 -0
- package/types/profile/ProfileGateway.spec.d.ts +1 -0
- package/types/profile/WebIdProfile.d.ts +12 -3
- package/types/profile/index.d.ts +1 -0
- package/types/thing/Thing.attachments.spec.d.ts +1 -0
- package/types/thing/Thing.d.ts +8 -0
- package/types/type-index/TypeIndex.d.ts +13 -0
- package/types/type-index/TypeIndex.spec.d.ts +1 -0
- package/types/type-index/TypeRegistration.d.ts +30 -0
- package/types/type-index/index.d.ts +2 -0
- package/types/picture/createPictureLinkOperation.d.ts +0 -12
- /package/types/{picture/createPictureLinkOperation.spec.d.ts → attachments/AttachmentGateway.spec.d.ts} +0 -0
package/lib/index.js
CHANGED
|
@@ -32272,13 +32272,13 @@ _:patch
|
|
|
32272
32272
|
});
|
|
32273
32273
|
|
|
32274
32274
|
// ../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
32275
|
-
var rdf3, solid,
|
|
32275
|
+
var rdf3, solid, pim2, ldp;
|
|
32276
32276
|
var init_namespaces2 = __esm({
|
|
32277
32277
|
"../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js"() {
|
|
32278
32278
|
init_esm();
|
|
32279
32279
|
rdf3 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
32280
32280
|
solid = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
32281
|
-
|
|
32281
|
+
pim2 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
32282
32282
|
ldp = Namespace("http://www.w3.org/ns/ldp#");
|
|
32283
32283
|
}
|
|
32284
32284
|
});
|
|
@@ -32331,7 +32331,7 @@ _:patch
|
|
|
32331
32331
|
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
|
|
32332
32332
|
*/
|
|
32333
32333
|
queryPreferencesFile() {
|
|
32334
|
-
const predicate4 =
|
|
32334
|
+
const predicate4 = pim2("preferencesFile");
|
|
32335
32335
|
return this.queryNamedNode(predicate4);
|
|
32336
32336
|
}
|
|
32337
32337
|
queryNamedNode(predicate4) {
|
|
@@ -34743,9 +34743,11 @@ _:patch
|
|
|
34743
34743
|
__export(index_exports, {
|
|
34744
34744
|
AnonymousSession: () => AnonymousSession,
|
|
34745
34745
|
AssumeAlwaysOnline: () => AssumeAlwaysOnline,
|
|
34746
|
+
AttachmentGateway: () => AttachmentGateway,
|
|
34746
34747
|
BinaryFile: () => BinaryFile,
|
|
34747
34748
|
BrokenFile: () => BrokenFile,
|
|
34748
34749
|
FileFetcher: () => FileFetcher,
|
|
34750
|
+
FileGateway: () => FileGateway,
|
|
34749
34751
|
HttpStatus: () => HttpStatus,
|
|
34750
34752
|
LabelIndex: () => LabelIndex,
|
|
34751
34753
|
LdpContainer: () => LdpContainer,
|
|
@@ -34753,14 +34755,15 @@ _:patch
|
|
|
34753
34755
|
OfflineCapableFetcher: () => OfflineCapableFetcher,
|
|
34754
34756
|
PictureGateway: () => PictureGateway,
|
|
34755
34757
|
PodOS: () => PodOS,
|
|
34758
|
+
ProfileGateway: () => ProfileGateway,
|
|
34756
34759
|
RdfDocument: () => RdfDocument,
|
|
34757
34760
|
SearchGateway: () => SearchGateway,
|
|
34758
34761
|
SearchIndex: () => SearchIndex,
|
|
34759
34762
|
Store: () => Store,
|
|
34760
34763
|
Thing: () => Thing,
|
|
34764
|
+
TypeIndex: () => TypeIndex2,
|
|
34761
34765
|
UriService: () => UriService,
|
|
34762
34766
|
WebIdProfile: () => WebIdProfile,
|
|
34763
|
-
createPictureLinkOperation: () => createPictureLinkOperation,
|
|
34764
34767
|
httpProblem: () => httpProblem,
|
|
34765
34768
|
labelFromUri: () => labelFromUri,
|
|
34766
34769
|
listKnownTerms: () => listKnownTerms,
|
|
@@ -37458,18 +37461,19 @@ _:patch
|
|
|
37458
37461
|
}
|
|
37459
37462
|
};
|
|
37460
37463
|
|
|
37461
|
-
// src/modules/contacts.ts
|
|
37462
|
-
async function loadContactsModule(store) {
|
|
37463
|
-
const module3 = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
37464
|
-
return store.loadModule(module3);
|
|
37465
|
-
}
|
|
37466
|
-
|
|
37467
37464
|
// src/ldp-container/LdpContainer.ts
|
|
37468
37465
|
init_esm();
|
|
37469
37466
|
|
|
37470
37467
|
// src/thing/Thing.ts
|
|
37471
37468
|
init_esm();
|
|
37472
37469
|
|
|
37470
|
+
// src/namespaces/index.ts
|
|
37471
|
+
init_esm();
|
|
37472
|
+
var rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#");
|
|
37473
|
+
var pim = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37474
|
+
var schema = Namespace("https://schema.org/");
|
|
37475
|
+
var flow = Namespace("http://www.w3.org/2005/01/wf/flow#");
|
|
37476
|
+
|
|
37473
37477
|
// src/thing/accumulateSubjects.ts
|
|
37474
37478
|
var accumulateSubjects = (accumulator, current3) => {
|
|
37475
37479
|
const existing = accumulator[current3.predicate.uri];
|
|
@@ -37693,6 +37697,19 @@ _:patch
|
|
|
37693
37697
|
label: labelForType(uri6)
|
|
37694
37698
|
}));
|
|
37695
37699
|
}
|
|
37700
|
+
/**
|
|
37701
|
+
* Returns all attachments linked to this thing
|
|
37702
|
+
*/
|
|
37703
|
+
attachments() {
|
|
37704
|
+
const statements = this.store.statementsMatching(
|
|
37705
|
+
namedNode(this.uri),
|
|
37706
|
+
flow("attachment")
|
|
37707
|
+
);
|
|
37708
|
+
return statements.filter((it) => isNamedNode(it.object)).map((statement2) => ({
|
|
37709
|
+
uri: statement2.object.value,
|
|
37710
|
+
label: labelFromUri(statement2.object.value)
|
|
37711
|
+
}));
|
|
37712
|
+
}
|
|
37696
37713
|
/**
|
|
37697
37714
|
* Call this method to switch to a more specific subclass of Thing.
|
|
37698
37715
|
*
|
|
@@ -37735,17 +37752,16 @@ _:patch
|
|
|
37735
37752
|
}
|
|
37736
37753
|
};
|
|
37737
37754
|
|
|
37738
|
-
// src/
|
|
37755
|
+
// src/files/createFileLinkOperation.ts
|
|
37739
37756
|
init_esm();
|
|
37740
|
-
|
|
37741
|
-
function createPictureLinkOperation(thing, file2) {
|
|
37757
|
+
function createFileLinkOperation(thing, predicateUri, file2) {
|
|
37742
37758
|
return {
|
|
37743
37759
|
deletions: [],
|
|
37744
37760
|
filesToCreate: [],
|
|
37745
37761
|
insertions: [
|
|
37746
37762
|
st(
|
|
37747
37763
|
namedNode(thing.uri),
|
|
37748
|
-
namedNode(
|
|
37764
|
+
namedNode(predicateUri),
|
|
37749
37765
|
namedNode(file2.url),
|
|
37750
37766
|
namedNode(thing.uri).doc()
|
|
37751
37767
|
)
|
|
@@ -37753,32 +37769,33 @@ _:patch
|
|
|
37753
37769
|
};
|
|
37754
37770
|
}
|
|
37755
37771
|
|
|
37756
|
-
// src/
|
|
37757
|
-
var
|
|
37772
|
+
// src/files/FileGateway.ts
|
|
37773
|
+
var FileGateway = class {
|
|
37758
37774
|
constructor(store, fileFetcher) {
|
|
37759
37775
|
this.store = store;
|
|
37760
37776
|
this.fileFetcher = fileFetcher;
|
|
37761
37777
|
}
|
|
37762
37778
|
/**
|
|
37763
|
-
* Uploads a
|
|
37779
|
+
* Uploads a file and associates it with a thing.
|
|
37764
37780
|
* The container is automatically derived from the thing's URI.
|
|
37765
37781
|
* Uses schema:image as the predicate.
|
|
37766
37782
|
*
|
|
37767
|
-
* @param thing - The thing to add the
|
|
37768
|
-
* @param
|
|
37769
|
-
* @
|
|
37783
|
+
* @param thing - The thing to add the file to
|
|
37784
|
+
* @param predicateUri - The URI of the predicate to use
|
|
37785
|
+
* @param fileToUpload - The file to upload
|
|
37786
|
+
* @returns Result with the uploaded metadata (url, name, contentType) or error
|
|
37770
37787
|
*/
|
|
37771
|
-
|
|
37788
|
+
uploadAndLinkFile(thing, predicateUri, fileToUpload) {
|
|
37772
37789
|
const container2 = this.getContainerFromThing(thing);
|
|
37773
|
-
return this.fileFetcher.createNewFile(container2,
|
|
37790
|
+
return this.fileFetcher.createNewFile(container2, fileToUpload).andThen((file2) => this.linkFileToThing(thing, predicateUri, file2));
|
|
37774
37791
|
}
|
|
37775
|
-
|
|
37776
|
-
const operation3 =
|
|
37792
|
+
linkFileToThing(thing, predicateUri, file2) {
|
|
37793
|
+
const operation3 = createFileLinkOperation(thing, predicateUri, file2);
|
|
37777
37794
|
return ResultAsync.fromPromise(
|
|
37778
37795
|
this.store.executeUpdate(operation3).then(() => file2),
|
|
37779
37796
|
() => ({
|
|
37780
37797
|
type: "network",
|
|
37781
|
-
title: "Failed to link
|
|
37798
|
+
title: "Failed to link file to thing"
|
|
37782
37799
|
})
|
|
37783
37800
|
);
|
|
37784
37801
|
}
|
|
@@ -37787,25 +37804,170 @@ _:patch
|
|
|
37787
37804
|
}
|
|
37788
37805
|
};
|
|
37789
37806
|
|
|
37807
|
+
// src/modules/contacts.ts
|
|
37808
|
+
async function loadContactsModule(store) {
|
|
37809
|
+
const module3 = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
37810
|
+
return store.loadModule(module3);
|
|
37811
|
+
}
|
|
37812
|
+
|
|
37813
|
+
// src/attachments/AttachmentGateway.ts
|
|
37814
|
+
var AttachmentGateway = class {
|
|
37815
|
+
constructor(fileGateway) {
|
|
37816
|
+
this.fileGateway = fileGateway;
|
|
37817
|
+
}
|
|
37818
|
+
/**
|
|
37819
|
+
* Uploads an attachment file and associates it with a thing.
|
|
37820
|
+
* The container is automatically derived from the thing's URI.
|
|
37821
|
+
* Uses flow:attachment as the predicate.
|
|
37822
|
+
*
|
|
37823
|
+
* @param thing - The thing to add the attachment to
|
|
37824
|
+
* @param attachmentFile - The attachment file to upload
|
|
37825
|
+
* @returns Result with the uploaded attachment metadata (url, name, contentType) or error
|
|
37826
|
+
*/
|
|
37827
|
+
uploadAndAddAttachment(thing, attachmentFile) {
|
|
37828
|
+
return this.fileGateway.uploadAndLinkFile(
|
|
37829
|
+
thing,
|
|
37830
|
+
"http://www.w3.org/2005/01/wf/flow#attachment",
|
|
37831
|
+
attachmentFile
|
|
37832
|
+
);
|
|
37833
|
+
}
|
|
37834
|
+
};
|
|
37835
|
+
|
|
37836
|
+
// src/picture/PictureGateway.ts
|
|
37837
|
+
var PictureGateway = class {
|
|
37838
|
+
constructor(attachmentGateway) {
|
|
37839
|
+
this.attachmentGateway = attachmentGateway;
|
|
37840
|
+
}
|
|
37841
|
+
/**
|
|
37842
|
+
* Uploads a picture file and associates it with a thing.
|
|
37843
|
+
* The container is automatically derived from the thing's URI.
|
|
37844
|
+
* Uses schema:image as the predicate.
|
|
37845
|
+
*
|
|
37846
|
+
* @param thing - The thing to add the picture to
|
|
37847
|
+
* @param pictureFile - The picture file to upload
|
|
37848
|
+
* @returns Result with the uploaded picture metadata (url, name, contentType) or error
|
|
37849
|
+
*/
|
|
37850
|
+
uploadAndAddPicture(thing, pictureFile) {
|
|
37851
|
+
return this.attachmentGateway.uploadAndLinkFile(
|
|
37852
|
+
thing,
|
|
37853
|
+
"http://schema.org/image",
|
|
37854
|
+
pictureFile
|
|
37855
|
+
);
|
|
37856
|
+
}
|
|
37857
|
+
};
|
|
37858
|
+
|
|
37790
37859
|
// src/profile/WebIdProfile.ts
|
|
37791
37860
|
init_esm();
|
|
37861
|
+
|
|
37862
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
37863
|
+
async function executeUpdate2(fetcher2, updater, operation3) {
|
|
37864
|
+
await updater.updateMany(operation3.deletions, operation3.insertions);
|
|
37865
|
+
operation3.filesToCreate.map((file2) => {
|
|
37866
|
+
createEmptyTurtleFile2(fetcher2, file2.url);
|
|
37867
|
+
});
|
|
37868
|
+
}
|
|
37869
|
+
function createEmptyTurtleFile2(fetcher2, url7) {
|
|
37870
|
+
return fetcher2.webOperation("PUT", url7, {
|
|
37871
|
+
contentType: "text/turtle"
|
|
37872
|
+
});
|
|
37873
|
+
}
|
|
37874
|
+
|
|
37875
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
37876
|
+
init_esm();
|
|
37877
|
+
|
|
37878
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
37879
|
+
init_esm();
|
|
37880
|
+
var rdf4 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
37881
|
+
var solid2 = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
37882
|
+
var pim3 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37883
|
+
var ldp2 = Namespace("http://www.w3.org/ns/ldp#");
|
|
37884
|
+
|
|
37885
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
37886
|
+
var PreferencesQuery2 = class {
|
|
37887
|
+
constructor(store, webIdNode, preferencesDoc) {
|
|
37888
|
+
this.store = store;
|
|
37889
|
+
this.webIdNode = webIdNode;
|
|
37890
|
+
this.preferencesDoc = preferencesDoc;
|
|
37891
|
+
}
|
|
37892
|
+
/**
|
|
37893
|
+
* Look up the private type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37894
|
+
*/
|
|
37895
|
+
queryPrivateTypeIndex() {
|
|
37896
|
+
const node3 = this.store.any(this.webIdNode, solid2("privateTypeIndex"), null, this.preferencesDoc);
|
|
37897
|
+
if (isNamedNode(node3)) {
|
|
37898
|
+
return node3;
|
|
37899
|
+
}
|
|
37900
|
+
return null;
|
|
37901
|
+
}
|
|
37902
|
+
};
|
|
37903
|
+
|
|
37904
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js
|
|
37905
|
+
init_esm();
|
|
37906
|
+
var ProfileQuery2 = class {
|
|
37907
|
+
constructor(webIdNode, store) {
|
|
37908
|
+
this.webIdNode = webIdNode;
|
|
37909
|
+
this.store = store;
|
|
37910
|
+
}
|
|
37911
|
+
/**
|
|
37912
|
+
* Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37913
|
+
*/
|
|
37914
|
+
queryPublicTypeIndex() {
|
|
37915
|
+
const predicate4 = solid2("publicTypeIndex");
|
|
37916
|
+
return this.queryNamedNode(predicate4);
|
|
37917
|
+
}
|
|
37918
|
+
/**
|
|
37919
|
+
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37920
|
+
*/
|
|
37921
|
+
queryPreferencesFile() {
|
|
37922
|
+
const predicate4 = pim3("preferencesFile");
|
|
37923
|
+
return this.queryNamedNode(predicate4);
|
|
37924
|
+
}
|
|
37925
|
+
queryNamedNode(predicate4) {
|
|
37926
|
+
const node3 = this.store.any(this.webIdNode, predicate4, null, this.webIdNode.doc());
|
|
37927
|
+
if (isNamedNode(node3)) {
|
|
37928
|
+
return node3;
|
|
37929
|
+
}
|
|
37930
|
+
return null;
|
|
37931
|
+
}
|
|
37932
|
+
};
|
|
37933
|
+
|
|
37934
|
+
// node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
37935
|
+
var import_short_unique_id2 = __toESM(require_short_unique_id(), 1);
|
|
37936
|
+
var uid2 = new import_short_unique_id2.default({ length: 10 });
|
|
37937
|
+
|
|
37938
|
+
// src/profile/WebIdProfile.ts
|
|
37792
37939
|
var WebIdProfile = class extends Thing {
|
|
37793
37940
|
constructor(webId, store, editable = false) {
|
|
37794
37941
|
super(webId, store, editable);
|
|
37795
37942
|
this.webId = webId;
|
|
37796
37943
|
this.store = store;
|
|
37797
37944
|
this.editable = editable;
|
|
37945
|
+
this.profileQuery = new ProfileQuery2(namedNode(this.webId), this.store);
|
|
37798
37946
|
}
|
|
37799
37947
|
/**
|
|
37800
|
-
* Returns
|
|
37948
|
+
* Returns the URI of the preferences document
|
|
37801
37949
|
*/
|
|
37802
37950
|
getPreferencesFile() {
|
|
37803
|
-
return this.
|
|
37951
|
+
return this.profileQuery.queryPreferencesFile()?.value;
|
|
37952
|
+
}
|
|
37953
|
+
/**
|
|
37954
|
+
* Returns the URI of the public type index document
|
|
37955
|
+
*/
|
|
37956
|
+
getPublicTypeIndex() {
|
|
37957
|
+
return this.profileQuery.queryPublicTypeIndex()?.value;
|
|
37958
|
+
}
|
|
37959
|
+
/**
|
|
37960
|
+
* Returns the URI of the private type index document
|
|
37961
|
+
*/
|
|
37962
|
+
getPrivateTypeIndex() {
|
|
37963
|
+
const preferences = this.profileQuery.queryPreferencesFile();
|
|
37964
|
+
if (!preferences) return void 0;
|
|
37965
|
+
const query4 = new PreferencesQuery2(
|
|
37966
|
+
this.store,
|
|
37804
37967
|
namedNode(this.webId),
|
|
37805
|
-
|
|
37806
|
-
void 0,
|
|
37807
|
-
namedNode(this.webId).doc()
|
|
37968
|
+
preferences
|
|
37808
37969
|
);
|
|
37970
|
+
return query4.queryPrivateTypeIndex()?.value;
|
|
37809
37971
|
}
|
|
37810
37972
|
/**
|
|
37811
37973
|
* Returns the URIs of the private label indexes
|
|
@@ -37832,6 +37994,27 @@ _:patch
|
|
|
37832
37994
|
}
|
|
37833
37995
|
};
|
|
37834
37996
|
|
|
37997
|
+
// src/profile/ProfileGateway.ts
|
|
37998
|
+
var ProfileGateway = class {
|
|
37999
|
+
constructor(store) {
|
|
38000
|
+
this.store = store;
|
|
38001
|
+
}
|
|
38002
|
+
async fetchProfile(webId) {
|
|
38003
|
+
await this.store.fetch(webId);
|
|
38004
|
+
const profile2 = this.store.get(webId).assume(WebIdProfile);
|
|
38005
|
+
const preferences = profile2.getPreferencesFile();
|
|
38006
|
+
if (preferences) {
|
|
38007
|
+
await this.store.fetch(preferences);
|
|
38008
|
+
}
|
|
38009
|
+
const publicTypeIndex2 = profile2.getPublicTypeIndex();
|
|
38010
|
+
const privateTypeIndex2 = profile2.getPrivateTypeIndex();
|
|
38011
|
+
await this.store.fetchAll(
|
|
38012
|
+
[privateTypeIndex2, publicTypeIndex2].filter((it) => it !== void 0)
|
|
38013
|
+
);
|
|
38014
|
+
return profile2;
|
|
38015
|
+
}
|
|
38016
|
+
};
|
|
38017
|
+
|
|
37835
38018
|
// src/search/SearchIndex.ts
|
|
37836
38019
|
var import_lunr = __toESM(require_lunr(), 1);
|
|
37837
38020
|
var SearchIndex = class {
|
|
@@ -37915,11 +38098,6 @@ _:patch
|
|
|
37915
38098
|
}
|
|
37916
38099
|
};
|
|
37917
38100
|
|
|
37918
|
-
// src/namespaces/index.ts
|
|
37919
|
-
init_esm();
|
|
37920
|
-
var rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#");
|
|
37921
|
-
var pim2 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37922
|
-
|
|
37923
38101
|
// src/search/LabelIndex.ts
|
|
37924
38102
|
var LabelIndex = class extends RdfDocument {
|
|
37925
38103
|
constructor(uri6, store, editable = false) {
|
|
@@ -37952,32 +38130,6 @@ _:patch
|
|
|
37952
38130
|
|
|
37953
38131
|
// src/search/createDefaultLabelIndex.ts
|
|
37954
38132
|
init_esm();
|
|
37955
|
-
|
|
37956
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
37957
|
-
async function executeUpdate2(fetcher2, updater, operation3) {
|
|
37958
|
-
await updater.updateMany(operation3.deletions, operation3.insertions);
|
|
37959
|
-
operation3.filesToCreate.map((file2) => {
|
|
37960
|
-
createEmptyTurtleFile2(fetcher2, file2.url);
|
|
37961
|
-
});
|
|
37962
|
-
}
|
|
37963
|
-
function createEmptyTurtleFile2(fetcher2, url7) {
|
|
37964
|
-
return fetcher2.webOperation("PUT", url7, {
|
|
37965
|
-
contentType: "text/turtle"
|
|
37966
|
-
});
|
|
37967
|
-
}
|
|
37968
|
-
|
|
37969
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
37970
|
-
init_esm();
|
|
37971
|
-
var rdf4 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
37972
|
-
var solid2 = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
37973
|
-
var pim3 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37974
|
-
var ldp2 = Namespace("http://www.w3.org/ns/ldp#");
|
|
37975
|
-
|
|
37976
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
37977
|
-
var import_short_unique_id2 = __toESM(require_short_unique_id(), 1);
|
|
37978
|
-
var uid2 = new import_short_unique_id2.default({ length: 10 });
|
|
37979
|
-
|
|
37980
|
-
// src/search/createDefaultLabelIndex.ts
|
|
37981
38133
|
function createDefaultLabelIndex(profile2) {
|
|
37982
38134
|
const webId = namedNode(profile2.webId);
|
|
37983
38135
|
const preferencesFile2 = profile2.getPreferencesFile();
|
|
@@ -38291,7 +38443,7 @@ _:patch
|
|
|
38291
38443
|
rdf: () => rdf5,
|
|
38292
38444
|
rdfs: () => rdfs2,
|
|
38293
38445
|
sched: () => sched,
|
|
38294
|
-
schema: () =>
|
|
38446
|
+
schema: () => schema2,
|
|
38295
38447
|
schema_https: () => schema_https,
|
|
38296
38448
|
sec: () => sec,
|
|
38297
38449
|
shacl: () => shacl,
|
|
@@ -59545,7 +59697,7 @@ _:patch
|
|
|
59545
59697
|
var rdf5 = rdfImport;
|
|
59546
59698
|
var rdfs2 = rdfsImport;
|
|
59547
59699
|
var sched = schedImport;
|
|
59548
|
-
var
|
|
59700
|
+
var schema2 = schemaImport;
|
|
59549
59701
|
var schema_https = schema_httpsImport;
|
|
59550
59702
|
var sec = secImport;
|
|
59551
59703
|
var shacl = shaclImport;
|
|
@@ -59617,6 +59769,53 @@ _:patch
|
|
|
59617
59769
|
}
|
|
59618
59770
|
};
|
|
59619
59771
|
|
|
59772
|
+
// src/type-index/TypeIndex.ts
|
|
59773
|
+
init_esm();
|
|
59774
|
+
var TypeIndex2 = class extends Thing {
|
|
59775
|
+
constructor(uri6, store, editable = false) {
|
|
59776
|
+
super(uri6, store, editable);
|
|
59777
|
+
this.uri = uri6;
|
|
59778
|
+
this.store = store;
|
|
59779
|
+
this.editable = editable;
|
|
59780
|
+
}
|
|
59781
|
+
listAll() {
|
|
59782
|
+
const forClassStatements = this.store.statementsMatching(
|
|
59783
|
+
null,
|
|
59784
|
+
solid2("forClass"),
|
|
59785
|
+
null,
|
|
59786
|
+
namedNode(this.uri)
|
|
59787
|
+
);
|
|
59788
|
+
return forClassStatements.map((statement2) => {
|
|
59789
|
+
const subject8 = statement2.subject;
|
|
59790
|
+
const instanceContainerStatements = this.store.statementsMatching(
|
|
59791
|
+
subject8,
|
|
59792
|
+
solid2("instanceContainer"),
|
|
59793
|
+
null,
|
|
59794
|
+
namedNode(this.uri)
|
|
59795
|
+
);
|
|
59796
|
+
const instanceStatements = this.store.statementsMatching(
|
|
59797
|
+
subject8,
|
|
59798
|
+
solid2("instance"),
|
|
59799
|
+
null,
|
|
59800
|
+
namedNode(this.uri)
|
|
59801
|
+
);
|
|
59802
|
+
const instances2 = instanceStatements.map((it) => ({
|
|
59803
|
+
type: "instance",
|
|
59804
|
+
uri: it.object.value
|
|
59805
|
+
}));
|
|
59806
|
+
const instanceContainers = instanceContainerStatements.map((it) => ({
|
|
59807
|
+
type: "container",
|
|
59808
|
+
uri: it.object.value
|
|
59809
|
+
}));
|
|
59810
|
+
return {
|
|
59811
|
+
targets: [...instanceContainers, ...instances2],
|
|
59812
|
+
forClass: statement2.object.value,
|
|
59813
|
+
label: labelForType(statement2.object.value)
|
|
59814
|
+
};
|
|
59815
|
+
});
|
|
59816
|
+
}
|
|
59817
|
+
};
|
|
59818
|
+
|
|
59620
59819
|
// src/index.ts
|
|
59621
59820
|
var PodOS = class {
|
|
59622
59821
|
constructor({
|
|
@@ -59635,9 +59834,12 @@ _:patch
|
|
|
59635
59834
|
);
|
|
59636
59835
|
this.searchGateway = new SearchGateway(this.store);
|
|
59637
59836
|
this.fileFetcher = new FileFetcher(this.session);
|
|
59638
|
-
this.
|
|
59837
|
+
this.fileGateway = new FileGateway(this.store, this.fileFetcher);
|
|
59838
|
+
this.attachmentGateway = new AttachmentGateway(this.fileGateway);
|
|
59839
|
+
this.pictureGateway = new PictureGateway(this.fileGateway);
|
|
59639
59840
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
59640
59841
|
this.uriService = new UriService(this.store);
|
|
59842
|
+
this.profileGateway = new ProfileGateway(this.store);
|
|
59641
59843
|
}
|
|
59642
59844
|
/*
|
|
59643
59845
|
Flagging authorization metadata is necessary every time the user
|
|
@@ -59697,13 +59899,7 @@ _:patch
|
|
|
59697
59899
|
* @param webId
|
|
59698
59900
|
*/
|
|
59699
59901
|
async fetchProfile(webId) {
|
|
59700
|
-
|
|
59701
|
-
const profile2 = this.store.get(webId).assume(WebIdProfile);
|
|
59702
|
-
const preferences = profile2.getPreferencesFile();
|
|
59703
|
-
if (preferences) {
|
|
59704
|
-
await this.fetch(preferences);
|
|
59705
|
-
}
|
|
59706
|
-
return profile2;
|
|
59902
|
+
return this.profileGateway.fetchProfile(webId);
|
|
59707
59903
|
}
|
|
59708
59904
|
/**
|
|
59709
59905
|
* Fetch the private label index for the given profile and build a search index from it
|
|
@@ -59750,6 +59946,13 @@ _:patch
|
|
|
59750
59946
|
uploadAndAddPicture(thing, pictureFile) {
|
|
59751
59947
|
return this.pictureGateway.uploadAndAddPicture(thing, pictureFile);
|
|
59752
59948
|
}
|
|
59949
|
+
/**
|
|
59950
|
+
* Provides access to attachment operations such as uploading and linking attachments to things
|
|
59951
|
+
* @returns {AttachmentGateway} An instance of AttachmentGateway that handles attachment operations
|
|
59952
|
+
*/
|
|
59953
|
+
attachments() {
|
|
59954
|
+
return this.attachmentGateway;
|
|
59955
|
+
}
|
|
59753
59956
|
};
|
|
59754
59957
|
return __toCommonJS(index_exports);
|
|
59755
59958
|
})();
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ResultAsync } from "neverthrow";
|
|
2
|
+
import { Thing } from "../thing";
|
|
3
|
+
import { FileGateway, NewFile } from "../files";
|
|
4
|
+
import { HttpProblem, NetworkProblem } from "../problems";
|
|
5
|
+
/**
|
|
6
|
+
* Gateway for attachment-related operations on Solid Pods and the store.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AttachmentGateway {
|
|
9
|
+
private readonly fileGateway;
|
|
10
|
+
constructor(fileGateway: FileGateway);
|
|
11
|
+
/**
|
|
12
|
+
* Uploads an attachment file and associates it with a thing.
|
|
13
|
+
* The container is automatically derived from the thing's URI.
|
|
14
|
+
* Uses flow:attachment as the predicate.
|
|
15
|
+
*
|
|
16
|
+
* @param thing - The thing to add the attachment to
|
|
17
|
+
* @param attachmentFile - The attachment file to upload
|
|
18
|
+
* @returns Result with the uploaded attachment metadata (url, name, contentType) or error
|
|
19
|
+
*/
|
|
20
|
+
uploadAndAddAttachment(thing: Thing, attachmentFile: File): ResultAsync<UploadedAttachment, HttpProblem | NetworkProblem>;
|
|
21
|
+
}
|
|
22
|
+
type UploadedAttachment = NewFile;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AttachmentGateway";
|
|
@@ -3,6 +3,9 @@ import { SolidFile } from "./SolidFile";
|
|
|
3
3
|
import { LdpContainer } from "../ldp-container";
|
|
4
4
|
import { HttpProblem, NetworkProblem } from "../problems";
|
|
5
5
|
import { ResultAsync } from "neverthrow";
|
|
6
|
+
/**
|
|
7
|
+
* Handles HTTP operations for files, like fetching and updating file contents.
|
|
8
|
+
*/
|
|
6
9
|
export declare class FileFetcher {
|
|
7
10
|
private session;
|
|
8
11
|
constructor(session: PodOsSession);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResultAsync } from "neverthrow";
|
|
2
|
+
import { Thing } from "../thing";
|
|
3
|
+
import { Store } from "../Store";
|
|
4
|
+
import { FileFetcher, NewFile } from "../files";
|
|
5
|
+
import { HttpProblem, NetworkProblem } from "../problems";
|
|
6
|
+
/**
|
|
7
|
+
* Gateway for file-related operations on Solid Pods and the store.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FileGateway {
|
|
10
|
+
private readonly store;
|
|
11
|
+
private readonly fileFetcher;
|
|
12
|
+
constructor(store: Store, fileFetcher: FileFetcher);
|
|
13
|
+
/**
|
|
14
|
+
* Uploads a file and associates it with a thing.
|
|
15
|
+
* The container is automatically derived from the thing's URI.
|
|
16
|
+
* Uses schema:image as the predicate.
|
|
17
|
+
*
|
|
18
|
+
* @param thing - The thing to add the file to
|
|
19
|
+
* @param predicateUri - The URI of the predicate to use
|
|
20
|
+
* @param fileToUpload - The file to upload
|
|
21
|
+
* @returns Result with the uploaded metadata (url, name, contentType) or error
|
|
22
|
+
*/
|
|
23
|
+
uploadAndLinkFile(thing: Thing, predicateUri: string, fileToUpload: File): ResultAsync<NewFile, HttpProblem | NetworkProblem>;
|
|
24
|
+
private linkFileToThing;
|
|
25
|
+
private getContainerFromThing;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UpdateOperation } from "@solid-data-modules/rdflib-utils";
|
|
2
|
+
import { Thing } from "../thing";
|
|
3
|
+
import { NewFile } from "../files";
|
|
4
|
+
/**
|
|
5
|
+
* Creates an update operation to link a file to a thing.
|
|
6
|
+
* Uses given predicate to establish the relationship.
|
|
7
|
+
*
|
|
8
|
+
* @param thing - The thing to link the file to
|
|
9
|
+
* @param predicateUri - The URI of the predicate to use
|
|
10
|
+
* @param file - The uploaded file metadata
|
|
11
|
+
* @returns UpdateOperation that adds the file link to the thing's document
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFileLinkOperation(thing: Thing, predicateUri: string, file: NewFile): UpdateOperation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/files/index.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContactsModule } from "@solid-data-modules/contacts-rdflib";
|
|
2
2
|
import { BehaviorSubject } from "rxjs";
|
|
3
|
-
import {
|
|
4
|
-
import { SolidFile } from "./files";
|
|
5
|
-
import {
|
|
3
|
+
import { PodOsSession, SessionInfo } from "./authentication";
|
|
4
|
+
import { FileFetcher, SolidFile } from "./files";
|
|
5
|
+
import { AttachmentGateway } from "./attachments";
|
|
6
6
|
import { WebIdProfile } from "./profile";
|
|
7
7
|
import { LabelIndex } from "./search";
|
|
8
8
|
import { Store } from "./Store";
|
|
@@ -18,6 +18,7 @@ export * from "./files";
|
|
|
18
18
|
export * from "./thing";
|
|
19
19
|
export * from "./rdf-document";
|
|
20
20
|
export * from "./ldp-container";
|
|
21
|
+
export * from "./attachments";
|
|
21
22
|
export * from "./picture";
|
|
22
23
|
export * from "./profile";
|
|
23
24
|
export * from "./search";
|
|
@@ -26,6 +27,7 @@ export * from "./terms";
|
|
|
26
27
|
export * from "./Store";
|
|
27
28
|
export * from "./uri";
|
|
28
29
|
export * from "./problems";
|
|
30
|
+
export * from "./type-index";
|
|
29
31
|
export interface PodOsConfiguration {
|
|
30
32
|
offlineCache?: OfflineCache;
|
|
31
33
|
onlineStatus?: OnlineStatus;
|
|
@@ -38,8 +40,11 @@ export declare class PodOS {
|
|
|
38
40
|
readonly uriService: UriService;
|
|
39
41
|
private readonly fileFetcher;
|
|
40
42
|
private readonly searchGateway;
|
|
43
|
+
private readonly fileGateway;
|
|
44
|
+
private readonly attachmentGateway;
|
|
41
45
|
private readonly pictureGateway;
|
|
42
46
|
private readonly offlineCache;
|
|
47
|
+
private readonly profileGateway;
|
|
43
48
|
constructor({ session, offlineCache, onlineStatus, internalStore, }?: PodOsConfiguration);
|
|
44
49
|
private flagAuthorizationMetaDataOnSessionChange;
|
|
45
50
|
fetch(uri: string): Promise<Response>;
|
|
@@ -100,4 +105,9 @@ export declare class PodOS {
|
|
|
100
105
|
uploadAndAddPicture(thing: Thing, pictureFile: File): ResultAsync<{
|
|
101
106
|
url: string;
|
|
102
107
|
}, HttpProblem | NetworkProblem>;
|
|
108
|
+
/**
|
|
109
|
+
* Provides access to attachment operations such as uploading and linking attachments to things
|
|
110
|
+
* @returns {AttachmentGateway} An instance of AttachmentGateway that handles attachment operations
|
|
111
|
+
*/
|
|
112
|
+
attachments(): AttachmentGateway;
|
|
103
113
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const rdfs: (ln: string) => import("rdflib/lib/tf-types").NamedNode;
|
|
2
2
|
export declare const pim: (ln: string) => import("rdflib/lib/tf-types").NamedNode;
|
|
3
|
+
export declare const schema: (ln: string) => import("rdflib/lib/tf-types").NamedNode;
|
|
4
|
+
export declare const flow: (ln: string) => import("rdflib/lib/tf-types").NamedNode;
|