@pod-os/core 0.23.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 +295 -178
- package/lib/index.js +309 -191
- 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 +12 -3
- package/types/namespaces/index.d.ts +1 -0
- package/types/picture/PictureGateway.d.ts +6 -7
- package/types/picture/index.d.ts +0 -1
- package/types/profile/ProfileGateway.d.ts +3 -0
- package/types/thing/Thing.attachments.spec.d.ts +1 -0
- package/types/thing/Thing.d.ts +8 -0
- package/types/type-index/TypeRegistration.d.ts +4 -0
- package/types/type-index/index.d.ts +1 -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,
|
|
@@ -34759,9 +34761,9 @@ _:patch
|
|
|
34759
34761
|
SearchIndex: () => SearchIndex,
|
|
34760
34762
|
Store: () => Store,
|
|
34761
34763
|
Thing: () => Thing,
|
|
34764
|
+
TypeIndex: () => TypeIndex2,
|
|
34762
34765
|
UriService: () => UriService,
|
|
34763
34766
|
WebIdProfile: () => WebIdProfile,
|
|
34764
|
-
createPictureLinkOperation: () => createPictureLinkOperation,
|
|
34765
34767
|
httpProblem: () => httpProblem,
|
|
34766
34768
|
labelFromUri: () => labelFromUri,
|
|
34767
34769
|
listKnownTerms: () => listKnownTerms,
|
|
@@ -37459,18 +37461,19 @@ _:patch
|
|
|
37459
37461
|
}
|
|
37460
37462
|
};
|
|
37461
37463
|
|
|
37462
|
-
// src/modules/contacts.ts
|
|
37463
|
-
async function loadContactsModule(store) {
|
|
37464
|
-
const module3 = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
37465
|
-
return store.loadModule(module3);
|
|
37466
|
-
}
|
|
37467
|
-
|
|
37468
37464
|
// src/ldp-container/LdpContainer.ts
|
|
37469
37465
|
init_esm();
|
|
37470
37466
|
|
|
37471
37467
|
// src/thing/Thing.ts
|
|
37472
37468
|
init_esm();
|
|
37473
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
|
+
|
|
37474
37477
|
// src/thing/accumulateSubjects.ts
|
|
37475
37478
|
var accumulateSubjects = (accumulator, current3) => {
|
|
37476
37479
|
const existing = accumulator[current3.predicate.uri];
|
|
@@ -37694,6 +37697,19 @@ _:patch
|
|
|
37694
37697
|
label: labelForType(uri6)
|
|
37695
37698
|
}));
|
|
37696
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
|
+
}
|
|
37697
37713
|
/**
|
|
37698
37714
|
* Call this method to switch to a more specific subclass of Thing.
|
|
37699
37715
|
*
|
|
@@ -37736,17 +37752,16 @@ _:patch
|
|
|
37736
37752
|
}
|
|
37737
37753
|
};
|
|
37738
37754
|
|
|
37739
|
-
// src/
|
|
37755
|
+
// src/files/createFileLinkOperation.ts
|
|
37740
37756
|
init_esm();
|
|
37741
|
-
|
|
37742
|
-
function createPictureLinkOperation(thing, file2) {
|
|
37757
|
+
function createFileLinkOperation(thing, predicateUri, file2) {
|
|
37743
37758
|
return {
|
|
37744
37759
|
deletions: [],
|
|
37745
37760
|
filesToCreate: [],
|
|
37746
37761
|
insertions: [
|
|
37747
37762
|
st(
|
|
37748
37763
|
namedNode(thing.uri),
|
|
37749
|
-
namedNode(
|
|
37764
|
+
namedNode(predicateUri),
|
|
37750
37765
|
namedNode(file2.url),
|
|
37751
37766
|
namedNode(thing.uri).doc()
|
|
37752
37767
|
)
|
|
@@ -37754,32 +37769,33 @@ _:patch
|
|
|
37754
37769
|
};
|
|
37755
37770
|
}
|
|
37756
37771
|
|
|
37757
|
-
// src/
|
|
37758
|
-
var
|
|
37772
|
+
// src/files/FileGateway.ts
|
|
37773
|
+
var FileGateway = class {
|
|
37759
37774
|
constructor(store, fileFetcher) {
|
|
37760
37775
|
this.store = store;
|
|
37761
37776
|
this.fileFetcher = fileFetcher;
|
|
37762
37777
|
}
|
|
37763
37778
|
/**
|
|
37764
|
-
* Uploads a
|
|
37779
|
+
* Uploads a file and associates it with a thing.
|
|
37765
37780
|
* The container is automatically derived from the thing's URI.
|
|
37766
37781
|
* Uses schema:image as the predicate.
|
|
37767
37782
|
*
|
|
37768
|
-
* @param thing - The thing to add the
|
|
37769
|
-
* @param
|
|
37770
|
-
* @
|
|
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
|
|
37771
37787
|
*/
|
|
37772
|
-
|
|
37788
|
+
uploadAndLinkFile(thing, predicateUri, fileToUpload) {
|
|
37773
37789
|
const container2 = this.getContainerFromThing(thing);
|
|
37774
|
-
return this.fileFetcher.createNewFile(container2,
|
|
37790
|
+
return this.fileFetcher.createNewFile(container2, fileToUpload).andThen((file2) => this.linkFileToThing(thing, predicateUri, file2));
|
|
37775
37791
|
}
|
|
37776
|
-
|
|
37777
|
-
const operation3 =
|
|
37792
|
+
linkFileToThing(thing, predicateUri, file2) {
|
|
37793
|
+
const operation3 = createFileLinkOperation(thing, predicateUri, file2);
|
|
37778
37794
|
return ResultAsync.fromPromise(
|
|
37779
37795
|
this.store.executeUpdate(operation3).then(() => file2),
|
|
37780
37796
|
() => ({
|
|
37781
37797
|
type: "network",
|
|
37782
|
-
title: "Failed to link
|
|
37798
|
+
title: "Failed to link file to thing"
|
|
37783
37799
|
})
|
|
37784
37800
|
);
|
|
37785
37801
|
}
|
|
@@ -37788,6 +37804,217 @@ _:patch
|
|
|
37788
37804
|
}
|
|
37789
37805
|
};
|
|
37790
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
|
+
|
|
37859
|
+
// src/profile/WebIdProfile.ts
|
|
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
|
|
37939
|
+
var WebIdProfile = class extends Thing {
|
|
37940
|
+
constructor(webId, store, editable = false) {
|
|
37941
|
+
super(webId, store, editable);
|
|
37942
|
+
this.webId = webId;
|
|
37943
|
+
this.store = store;
|
|
37944
|
+
this.editable = editable;
|
|
37945
|
+
this.profileQuery = new ProfileQuery2(namedNode(this.webId), this.store);
|
|
37946
|
+
}
|
|
37947
|
+
/**
|
|
37948
|
+
* Returns the URI of the preferences document
|
|
37949
|
+
*/
|
|
37950
|
+
getPreferencesFile() {
|
|
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,
|
|
37967
|
+
namedNode(this.webId),
|
|
37968
|
+
preferences
|
|
37969
|
+
);
|
|
37970
|
+
return query4.queryPrivateTypeIndex()?.value;
|
|
37971
|
+
}
|
|
37972
|
+
/**
|
|
37973
|
+
* Returns the URIs of the private label indexes
|
|
37974
|
+
*/
|
|
37975
|
+
getPrivateLabelIndexes() {
|
|
37976
|
+
const profileNodes = this.store.each(
|
|
37977
|
+
namedNode(this.webId),
|
|
37978
|
+
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
37979
|
+
void 0,
|
|
37980
|
+
namedNode(this.webId).doc()
|
|
37981
|
+
);
|
|
37982
|
+
const preferences = this.getPreferencesFile();
|
|
37983
|
+
if (preferences) {
|
|
37984
|
+
const preferencesNodes = this.store.each(
|
|
37985
|
+
namedNode(this.webId),
|
|
37986
|
+
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
37987
|
+
void 0,
|
|
37988
|
+
namedNode(preferences)
|
|
37989
|
+
);
|
|
37990
|
+
return [...profileNodes, ...preferencesNodes].map((it) => it.value);
|
|
37991
|
+
} else {
|
|
37992
|
+
return profileNodes.map((it) => it.value);
|
|
37993
|
+
}
|
|
37994
|
+
}
|
|
37995
|
+
};
|
|
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
|
+
|
|
37791
38018
|
// src/search/SearchIndex.ts
|
|
37792
38019
|
var import_lunr = __toESM(require_lunr(), 1);
|
|
37793
38020
|
var SearchIndex = class {
|
|
@@ -37871,12 +38098,6 @@ _:patch
|
|
|
37871
38098
|
}
|
|
37872
38099
|
};
|
|
37873
38100
|
|
|
37874
|
-
// src/namespaces/index.ts
|
|
37875
|
-
init_esm();
|
|
37876
|
-
var rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#");
|
|
37877
|
-
var pim2 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37878
|
-
var schema = Namespace("https://schema.org/");
|
|
37879
|
-
|
|
37880
38101
|
// src/search/LabelIndex.ts
|
|
37881
38102
|
var LabelIndex = class extends RdfDocument {
|
|
37882
38103
|
constructor(uri6, store, editable = false) {
|
|
@@ -37909,84 +38130,6 @@ _:patch
|
|
|
37909
38130
|
|
|
37910
38131
|
// src/search/createDefaultLabelIndex.ts
|
|
37911
38132
|
init_esm();
|
|
37912
|
-
|
|
37913
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
37914
|
-
async function executeUpdate2(fetcher2, updater, operation3) {
|
|
37915
|
-
await updater.updateMany(operation3.deletions, operation3.insertions);
|
|
37916
|
-
operation3.filesToCreate.map((file2) => {
|
|
37917
|
-
createEmptyTurtleFile2(fetcher2, file2.url);
|
|
37918
|
-
});
|
|
37919
|
-
}
|
|
37920
|
-
function createEmptyTurtleFile2(fetcher2, url7) {
|
|
37921
|
-
return fetcher2.webOperation("PUT", url7, {
|
|
37922
|
-
contentType: "text/turtle"
|
|
37923
|
-
});
|
|
37924
|
-
}
|
|
37925
|
-
|
|
37926
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
37927
|
-
init_esm();
|
|
37928
|
-
|
|
37929
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
37930
|
-
init_esm();
|
|
37931
|
-
var rdf4 = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
37932
|
-
var solid2 = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
37933
|
-
var pim3 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
37934
|
-
var ldp2 = Namespace("http://www.w3.org/ns/ldp#");
|
|
37935
|
-
|
|
37936
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
37937
|
-
var PreferencesQuery2 = class {
|
|
37938
|
-
constructor(store, webIdNode, preferencesDoc) {
|
|
37939
|
-
this.store = store;
|
|
37940
|
-
this.webIdNode = webIdNode;
|
|
37941
|
-
this.preferencesDoc = preferencesDoc;
|
|
37942
|
-
}
|
|
37943
|
-
/**
|
|
37944
|
-
* Look up the private type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37945
|
-
*/
|
|
37946
|
-
queryPrivateTypeIndex() {
|
|
37947
|
-
const node3 = this.store.any(this.webIdNode, solid2("privateTypeIndex"), null, this.preferencesDoc);
|
|
37948
|
-
if (isNamedNode(node3)) {
|
|
37949
|
-
return node3;
|
|
37950
|
-
}
|
|
37951
|
-
return null;
|
|
37952
|
-
}
|
|
37953
|
-
};
|
|
37954
|
-
|
|
37955
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js
|
|
37956
|
-
init_esm();
|
|
37957
|
-
var ProfileQuery2 = class {
|
|
37958
|
-
constructor(webIdNode, store) {
|
|
37959
|
-
this.webIdNode = webIdNode;
|
|
37960
|
-
this.store = store;
|
|
37961
|
-
}
|
|
37962
|
-
/**
|
|
37963
|
-
* Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37964
|
-
*/
|
|
37965
|
-
queryPublicTypeIndex() {
|
|
37966
|
-
const predicate4 = solid2("publicTypeIndex");
|
|
37967
|
-
return this.queryNamedNode(predicate4);
|
|
37968
|
-
}
|
|
37969
|
-
/**
|
|
37970
|
-
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
|
|
37971
|
-
*/
|
|
37972
|
-
queryPreferencesFile() {
|
|
37973
|
-
const predicate4 = pim3("preferencesFile");
|
|
37974
|
-
return this.queryNamedNode(predicate4);
|
|
37975
|
-
}
|
|
37976
|
-
queryNamedNode(predicate4) {
|
|
37977
|
-
const node3 = this.store.any(this.webIdNode, predicate4, null, this.webIdNode.doc());
|
|
37978
|
-
if (isNamedNode(node3)) {
|
|
37979
|
-
return node3;
|
|
37980
|
-
}
|
|
37981
|
-
return null;
|
|
37982
|
-
}
|
|
37983
|
-
};
|
|
37984
|
-
|
|
37985
|
-
// node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
37986
|
-
var import_short_unique_id2 = __toESM(require_short_unique_id(), 1);
|
|
37987
|
-
var uid2 = new import_short_unique_id2.default({ length: 10 });
|
|
37988
|
-
|
|
37989
|
-
// src/search/createDefaultLabelIndex.ts
|
|
37990
38133
|
function createDefaultLabelIndex(profile2) {
|
|
37991
38134
|
const webId = namedNode(profile2.webId);
|
|
37992
38135
|
const preferencesFile2 = profile2.getPreferencesFile();
|
|
@@ -59604,87 +59747,6 @@ _:patch
|
|
|
59604
59747
|
}
|
|
59605
59748
|
};
|
|
59606
59749
|
|
|
59607
|
-
// src/profile/WebIdProfile.ts
|
|
59608
|
-
init_esm();
|
|
59609
|
-
var WebIdProfile = class extends Thing {
|
|
59610
|
-
constructor(webId, store, editable = false) {
|
|
59611
|
-
super(webId, store, editable);
|
|
59612
|
-
this.webId = webId;
|
|
59613
|
-
this.store = store;
|
|
59614
|
-
this.editable = editable;
|
|
59615
|
-
this.profileQuery = new ProfileQuery2(namedNode(this.webId), this.store);
|
|
59616
|
-
}
|
|
59617
|
-
/**
|
|
59618
|
-
* Returns the URI of the preferences document
|
|
59619
|
-
*/
|
|
59620
|
-
getPreferencesFile() {
|
|
59621
|
-
return this.profileQuery.queryPreferencesFile()?.value;
|
|
59622
|
-
}
|
|
59623
|
-
/**
|
|
59624
|
-
* Returns the URI of the public type index document
|
|
59625
|
-
*/
|
|
59626
|
-
getPublicTypeIndex() {
|
|
59627
|
-
return this.profileQuery.queryPublicTypeIndex()?.value;
|
|
59628
|
-
}
|
|
59629
|
-
/**
|
|
59630
|
-
* Returns the URI of the private type index document
|
|
59631
|
-
*/
|
|
59632
|
-
getPrivateTypeIndex() {
|
|
59633
|
-
const preferences = this.profileQuery.queryPreferencesFile();
|
|
59634
|
-
if (!preferences) return void 0;
|
|
59635
|
-
const query4 = new PreferencesQuery2(
|
|
59636
|
-
this.store,
|
|
59637
|
-
namedNode(this.webId),
|
|
59638
|
-
preferences
|
|
59639
|
-
);
|
|
59640
|
-
return query4.queryPrivateTypeIndex()?.value;
|
|
59641
|
-
}
|
|
59642
|
-
/**
|
|
59643
|
-
* Returns the URIs of the private label indexes
|
|
59644
|
-
*/
|
|
59645
|
-
getPrivateLabelIndexes() {
|
|
59646
|
-
const profileNodes = this.store.each(
|
|
59647
|
-
namedNode(this.webId),
|
|
59648
|
-
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
59649
|
-
void 0,
|
|
59650
|
-
namedNode(this.webId).doc()
|
|
59651
|
-
);
|
|
59652
|
-
const preferences = this.getPreferencesFile();
|
|
59653
|
-
if (preferences) {
|
|
59654
|
-
const preferencesNodes = this.store.each(
|
|
59655
|
-
namedNode(this.webId),
|
|
59656
|
-
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
59657
|
-
void 0,
|
|
59658
|
-
namedNode(preferences)
|
|
59659
|
-
);
|
|
59660
|
-
return [...profileNodes, ...preferencesNodes].map((it) => it.value);
|
|
59661
|
-
} else {
|
|
59662
|
-
return profileNodes.map((it) => it.value);
|
|
59663
|
-
}
|
|
59664
|
-
}
|
|
59665
|
-
};
|
|
59666
|
-
|
|
59667
|
-
// src/profile/ProfileGateway.ts
|
|
59668
|
-
var ProfileGateway = class {
|
|
59669
|
-
constructor(store) {
|
|
59670
|
-
this.store = store;
|
|
59671
|
-
}
|
|
59672
|
-
async fetchProfile(webId) {
|
|
59673
|
-
await this.store.fetch(webId);
|
|
59674
|
-
const profile2 = this.store.get(webId).assume(WebIdProfile);
|
|
59675
|
-
const preferences = profile2.getPreferencesFile();
|
|
59676
|
-
if (preferences) {
|
|
59677
|
-
await this.store.fetch(preferences);
|
|
59678
|
-
}
|
|
59679
|
-
const publicTypeIndex2 = profile2.getPublicTypeIndex();
|
|
59680
|
-
const privateTypeIndex2 = profile2.getPrivateTypeIndex();
|
|
59681
|
-
await this.store.fetchAll(
|
|
59682
|
-
[privateTypeIndex2, publicTypeIndex2].filter((it) => it !== void 0)
|
|
59683
|
-
);
|
|
59684
|
-
return profile2;
|
|
59685
|
-
}
|
|
59686
|
-
};
|
|
59687
|
-
|
|
59688
59750
|
// src/authentication/index.ts
|
|
59689
59751
|
var AnonymousSession = class {
|
|
59690
59752
|
constructor() {
|
|
@@ -59707,6 +59769,53 @@ _:patch
|
|
|
59707
59769
|
}
|
|
59708
59770
|
};
|
|
59709
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
|
+
|
|
59710
59819
|
// src/index.ts
|
|
59711
59820
|
var PodOS = class {
|
|
59712
59821
|
constructor({
|
|
@@ -59725,7 +59834,9 @@ _:patch
|
|
|
59725
59834
|
);
|
|
59726
59835
|
this.searchGateway = new SearchGateway(this.store);
|
|
59727
59836
|
this.fileFetcher = new FileFetcher(this.session);
|
|
59728
|
-
this.
|
|
59837
|
+
this.fileGateway = new FileGateway(this.store, this.fileFetcher);
|
|
59838
|
+
this.attachmentGateway = new AttachmentGateway(this.fileGateway);
|
|
59839
|
+
this.pictureGateway = new PictureGateway(this.fileGateway);
|
|
59729
59840
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
59730
59841
|
this.uriService = new UriService(this.store);
|
|
59731
59842
|
this.profileGateway = new ProfileGateway(this.store);
|
|
@@ -59835,6 +59946,13 @@ _:patch
|
|
|
59835
59946
|
uploadAndAddPicture(thing, pictureFile) {
|
|
59836
59947
|
return this.pictureGateway.uploadAndAddPicture(thing, pictureFile);
|
|
59837
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
|
+
}
|
|
59838
59956
|
};
|
|
59839
59957
|
return __toCommonJS(index_exports);
|
|
59840
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);
|