@pod-os/core 0.23.1-rc.f73863c.0 → 0.24.0-rc.e770383.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 +308 -178
- package/lib/index.js +322 -191
- package/package.json +1 -1
- package/types/attachments/AttachmentGateway.d.ts +25 -0
- package/types/attachments/index.d.ts +1 -0
- package/types/files/FileFetcher.d.ts +3 -0
- package/types/files/FileGateway.d.ts +27 -0
- package/types/files/FileGateway.spec.d.ts +1 -0
- package/types/files/createFileLinkOperation.d.ts +16 -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 +1 -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/WebIdProfile.d.ts +2 -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 +1 -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,229 @@ _: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
|
+
* @since 0.24.0
|
|
37956
|
+
*/
|
|
37957
|
+
getPublicTypeIndex() {
|
|
37958
|
+
return this.profileQuery.queryPublicTypeIndex()?.value;
|
|
37959
|
+
}
|
|
37960
|
+
/**
|
|
37961
|
+
* Returns the URI of the private type index document
|
|
37962
|
+
* @since 0.24.0
|
|
37963
|
+
*/
|
|
37964
|
+
getPrivateTypeIndex() {
|
|
37965
|
+
const preferences = this.profileQuery.queryPreferencesFile();
|
|
37966
|
+
if (!preferences) return void 0;
|
|
37967
|
+
const query4 = new PreferencesQuery2(
|
|
37968
|
+
this.store,
|
|
37969
|
+
namedNode(this.webId),
|
|
37970
|
+
preferences
|
|
37971
|
+
);
|
|
37972
|
+
return query4.queryPrivateTypeIndex()?.value;
|
|
37973
|
+
}
|
|
37974
|
+
/**
|
|
37975
|
+
* Returns the URIs of the private label indexes
|
|
37976
|
+
*/
|
|
37977
|
+
getPrivateLabelIndexes() {
|
|
37978
|
+
const profileNodes = this.store.each(
|
|
37979
|
+
namedNode(this.webId),
|
|
37980
|
+
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
37981
|
+
void 0,
|
|
37982
|
+
namedNode(this.webId).doc()
|
|
37983
|
+
);
|
|
37984
|
+
const preferences = this.getPreferencesFile();
|
|
37985
|
+
if (preferences) {
|
|
37986
|
+
const preferencesNodes = this.store.each(
|
|
37987
|
+
namedNode(this.webId),
|
|
37988
|
+
namedNode("http://www.w3.org/ns/solid/terms#privateLabelIndex"),
|
|
37989
|
+
void 0,
|
|
37990
|
+
namedNode(preferences)
|
|
37991
|
+
);
|
|
37992
|
+
return [...profileNodes, ...preferencesNodes].map((it) => it.value);
|
|
37993
|
+
} else {
|
|
37994
|
+
return profileNodes.map((it) => it.value);
|
|
37995
|
+
}
|
|
37996
|
+
}
|
|
37997
|
+
};
|
|
37998
|
+
|
|
37999
|
+
// src/profile/ProfileGateway.ts
|
|
38000
|
+
var ProfileGateway = class {
|
|
38001
|
+
constructor(store) {
|
|
38002
|
+
this.store = store;
|
|
38003
|
+
}
|
|
38004
|
+
/**
|
|
38005
|
+
* Fetches the profile for the given WebID and all linked documents
|
|
38006
|
+
* @since 0.24.0
|
|
38007
|
+
* @param webId The WebID to fetch the profile for
|
|
38008
|
+
* @returns {Promise<WebIdProfile>} The fetched profile
|
|
38009
|
+
*/
|
|
38010
|
+
async fetchProfile(webId) {
|
|
38011
|
+
await this.store.fetch(webId);
|
|
38012
|
+
const profile2 = this.store.get(webId).assume(WebIdProfile);
|
|
38013
|
+
const preferences = profile2.getPreferencesFile();
|
|
38014
|
+
if (preferences) {
|
|
38015
|
+
try {
|
|
38016
|
+
await this.store.fetch(preferences);
|
|
38017
|
+
} catch (error4) {
|
|
38018
|
+
console.warn(`Failed to fetch preferences file ${preferences}:`, error4);
|
|
38019
|
+
}
|
|
38020
|
+
}
|
|
38021
|
+
const publicTypeIndex2 = profile2.getPublicTypeIndex();
|
|
38022
|
+
const privateTypeIndex2 = profile2.getPrivateTypeIndex();
|
|
38023
|
+
await this.store.fetchAll(
|
|
38024
|
+
[privateTypeIndex2, publicTypeIndex2].filter((it) => it !== void 0)
|
|
38025
|
+
);
|
|
38026
|
+
return profile2;
|
|
38027
|
+
}
|
|
38028
|
+
};
|
|
38029
|
+
|
|
37791
38030
|
// src/search/SearchIndex.ts
|
|
37792
38031
|
var import_lunr = __toESM(require_lunr(), 1);
|
|
37793
38032
|
var SearchIndex = class {
|
|
@@ -37871,12 +38110,6 @@ _:patch
|
|
|
37871
38110
|
}
|
|
37872
38111
|
};
|
|
37873
38112
|
|
|
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
38113
|
// src/search/LabelIndex.ts
|
|
37881
38114
|
var LabelIndex = class extends RdfDocument {
|
|
37882
38115
|
constructor(uri6, store, editable = false) {
|
|
@@ -37909,84 +38142,6 @@ _:patch
|
|
|
37909
38142
|
|
|
37910
38143
|
// src/search/createDefaultLabelIndex.ts
|
|
37911
38144
|
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
38145
|
function createDefaultLabelIndex(profile2) {
|
|
37991
38146
|
const webId = namedNode(profile2.webId);
|
|
37992
38147
|
const preferencesFile2 = profile2.getPreferencesFile();
|
|
@@ -59604,87 +59759,6 @@ _:patch
|
|
|
59604
59759
|
}
|
|
59605
59760
|
};
|
|
59606
59761
|
|
|
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
59762
|
// src/authentication/index.ts
|
|
59689
59763
|
var AnonymousSession = class {
|
|
59690
59764
|
constructor() {
|
|
@@ -59707,6 +59781,53 @@ _:patch
|
|
|
59707
59781
|
}
|
|
59708
59782
|
};
|
|
59709
59783
|
|
|
59784
|
+
// src/type-index/TypeIndex.ts
|
|
59785
|
+
init_esm();
|
|
59786
|
+
var TypeIndex2 = class extends Thing {
|
|
59787
|
+
constructor(uri6, store, editable = false) {
|
|
59788
|
+
super(uri6, store, editable);
|
|
59789
|
+
this.uri = uri6;
|
|
59790
|
+
this.store = store;
|
|
59791
|
+
this.editable = editable;
|
|
59792
|
+
}
|
|
59793
|
+
listAll() {
|
|
59794
|
+
const forClassStatements = this.store.statementsMatching(
|
|
59795
|
+
null,
|
|
59796
|
+
solid2("forClass"),
|
|
59797
|
+
null,
|
|
59798
|
+
namedNode(this.uri)
|
|
59799
|
+
);
|
|
59800
|
+
return forClassStatements.map((statement2) => {
|
|
59801
|
+
const subject8 = statement2.subject;
|
|
59802
|
+
const instanceContainerStatements = this.store.statementsMatching(
|
|
59803
|
+
subject8,
|
|
59804
|
+
solid2("instanceContainer"),
|
|
59805
|
+
null,
|
|
59806
|
+
namedNode(this.uri)
|
|
59807
|
+
);
|
|
59808
|
+
const instanceStatements = this.store.statementsMatching(
|
|
59809
|
+
subject8,
|
|
59810
|
+
solid2("instance"),
|
|
59811
|
+
null,
|
|
59812
|
+
namedNode(this.uri)
|
|
59813
|
+
);
|
|
59814
|
+
const instances2 = instanceStatements.map((it) => ({
|
|
59815
|
+
type: "instance",
|
|
59816
|
+
uri: it.object.value
|
|
59817
|
+
}));
|
|
59818
|
+
const instanceContainers = instanceContainerStatements.map((it) => ({
|
|
59819
|
+
type: "container",
|
|
59820
|
+
uri: it.object.value
|
|
59821
|
+
}));
|
|
59822
|
+
return {
|
|
59823
|
+
targets: [...instanceContainers, ...instances2],
|
|
59824
|
+
forClass: statement2.object.value,
|
|
59825
|
+
label: labelForType(statement2.object.value)
|
|
59826
|
+
};
|
|
59827
|
+
});
|
|
59828
|
+
}
|
|
59829
|
+
};
|
|
59830
|
+
|
|
59710
59831
|
// src/index.ts
|
|
59711
59832
|
var PodOS = class {
|
|
59712
59833
|
constructor({
|
|
@@ -59725,7 +59846,9 @@ _:patch
|
|
|
59725
59846
|
);
|
|
59726
59847
|
this.searchGateway = new SearchGateway(this.store);
|
|
59727
59848
|
this.fileFetcher = new FileFetcher(this.session);
|
|
59728
|
-
this.
|
|
59849
|
+
this.fileGateway = new FileGateway(this.store, this.fileFetcher);
|
|
59850
|
+
this.attachmentGateway = new AttachmentGateway(this.fileGateway);
|
|
59851
|
+
this.pictureGateway = new PictureGateway(this.fileGateway);
|
|
59729
59852
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
59730
59853
|
this.uriService = new UriService(this.store);
|
|
59731
59854
|
this.profileGateway = new ProfileGateway(this.store);
|
|
@@ -59835,6 +59958,14 @@ _:patch
|
|
|
59835
59958
|
uploadAndAddPicture(thing, pictureFile) {
|
|
59836
59959
|
return this.pictureGateway.uploadAndAddPicture(thing, pictureFile);
|
|
59837
59960
|
}
|
|
59961
|
+
/**
|
|
59962
|
+
* Provides access to attachment operations such as uploading and linking attachments to things
|
|
59963
|
+
* @since 0.24.0
|
|
59964
|
+
* @returns {AttachmentGateway} An instance of AttachmentGateway that handles attachment operations
|
|
59965
|
+
*/
|
|
59966
|
+
attachments() {
|
|
59967
|
+
return this.attachmentGateway;
|
|
59968
|
+
}
|
|
59838
59969
|
};
|
|
59839
59970
|
return __toCommonJS(index_exports);
|
|
59840
59971
|
})();
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
* @since 0.24.0
|
|
9
|
+
*/
|
|
10
|
+
export declare class AttachmentGateway {
|
|
11
|
+
private readonly fileGateway;
|
|
12
|
+
constructor(fileGateway: FileGateway);
|
|
13
|
+
/**
|
|
14
|
+
* Uploads an attachment file and associates it with a thing.
|
|
15
|
+
* The container is automatically derived from the thing's URI.
|
|
16
|
+
* Uses flow:attachment as the predicate.
|
|
17
|
+
*
|
|
18
|
+
* @param thing - The thing to add the attachment to
|
|
19
|
+
* @param attachmentFile - The attachment file to upload
|
|
20
|
+
* @returns Result with the uploaded attachment metadata (url, name, contentType) or error
|
|
21
|
+
*/
|
|
22
|
+
uploadAndAddAttachment(thing: Thing, attachmentFile: File): ResultAsync<UploadedAttachment, HttpProblem | NetworkProblem>;
|
|
23
|
+
}
|
|
24
|
+
type UploadedAttachment = NewFile;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AttachmentGateway";
|