@pod-os/core 0.23.0 → 0.23.1-rc.28ee385.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/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, pim, ldp;
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
- pim = Namespace("http://www.w3.org/ns/pim/space#");
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 = pim("preferencesFile");
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/picture/createPictureLinkOperation.ts
37755
+ // src/files/createFileLinkOperation.ts
37740
37756
  init_esm();
37741
- var SCHEMA_IMAGE = "http://schema.org/image";
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(SCHEMA_IMAGE),
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/picture/PictureGateway.ts
37758
- var PictureGateway = class {
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 picture file and associates it with a thing.
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 picture to
37769
- * @param pictureFile - The picture file to upload
37770
- * @returns Result with the uploaded picture metadata (url, name, contentType) or error
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
- uploadAndAddPicture(thing, pictureFile) {
37788
+ uploadAndLinkFile(thing, predicateUri, fileToUpload) {
37773
37789
  const container2 = this.getContainerFromThing(thing);
37774
- return this.fileFetcher.createNewFile(container2, pictureFile).andThen((file2) => this.linkPictureToThing(thing, file2));
37790
+ return this.fileFetcher.createNewFile(container2, fileToUpload).andThen((file2) => this.linkFileToThing(thing, predicateUri, file2));
37775
37791
  }
37776
- linkPictureToThing(thing, file2) {
37777
- const operation3 = createPictureLinkOperation(thing, file2);
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 picture to thing"
37798
+ title: "Failed to link file to thing"
37783
37799
  })
37784
37800
  );
37785
37801
  }
@@ -37788,6 +37804,221 @@ _: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
+ try {
38008
+ await this.store.fetch(preferences);
38009
+ } catch (error4) {
38010
+ console.warn(`Failed to fetch preferences file ${preferences}:`, error4);
38011
+ }
38012
+ }
38013
+ const publicTypeIndex2 = profile2.getPublicTypeIndex();
38014
+ const privateTypeIndex2 = profile2.getPrivateTypeIndex();
38015
+ await this.store.fetchAll(
38016
+ [privateTypeIndex2, publicTypeIndex2].filter((it) => it !== void 0)
38017
+ );
38018
+ return profile2;
38019
+ }
38020
+ };
38021
+
37791
38022
  // src/search/SearchIndex.ts
37792
38023
  var import_lunr = __toESM(require_lunr(), 1);
37793
38024
  var SearchIndex = class {
@@ -37871,12 +38102,6 @@ _:patch
37871
38102
  }
37872
38103
  };
37873
38104
 
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
38105
  // src/search/LabelIndex.ts
37881
38106
  var LabelIndex = class extends RdfDocument {
37882
38107
  constructor(uri6, store, editable = false) {
@@ -37909,84 +38134,6 @@ _:patch
37909
38134
 
37910
38135
  // src/search/createDefaultLabelIndex.ts
37911
38136
  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
38137
  function createDefaultLabelIndex(profile2) {
37991
38138
  const webId = namedNode(profile2.webId);
37992
38139
  const preferencesFile2 = profile2.getPreferencesFile();
@@ -59604,87 +59751,6 @@ _:patch
59604
59751
  }
59605
59752
  };
59606
59753
 
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
59754
  // src/authentication/index.ts
59689
59755
  var AnonymousSession = class {
59690
59756
  constructor() {
@@ -59707,6 +59773,53 @@ _:patch
59707
59773
  }
59708
59774
  };
59709
59775
 
59776
+ // src/type-index/TypeIndex.ts
59777
+ init_esm();
59778
+ var TypeIndex2 = class extends Thing {
59779
+ constructor(uri6, store, editable = false) {
59780
+ super(uri6, store, editable);
59781
+ this.uri = uri6;
59782
+ this.store = store;
59783
+ this.editable = editable;
59784
+ }
59785
+ listAll() {
59786
+ const forClassStatements = this.store.statementsMatching(
59787
+ null,
59788
+ solid2("forClass"),
59789
+ null,
59790
+ namedNode(this.uri)
59791
+ );
59792
+ return forClassStatements.map((statement2) => {
59793
+ const subject8 = statement2.subject;
59794
+ const instanceContainerStatements = this.store.statementsMatching(
59795
+ subject8,
59796
+ solid2("instanceContainer"),
59797
+ null,
59798
+ namedNode(this.uri)
59799
+ );
59800
+ const instanceStatements = this.store.statementsMatching(
59801
+ subject8,
59802
+ solid2("instance"),
59803
+ null,
59804
+ namedNode(this.uri)
59805
+ );
59806
+ const instances2 = instanceStatements.map((it) => ({
59807
+ type: "instance",
59808
+ uri: it.object.value
59809
+ }));
59810
+ const instanceContainers = instanceContainerStatements.map((it) => ({
59811
+ type: "container",
59812
+ uri: it.object.value
59813
+ }));
59814
+ return {
59815
+ targets: [...instanceContainers, ...instances2],
59816
+ forClass: statement2.object.value,
59817
+ label: labelForType(statement2.object.value)
59818
+ };
59819
+ });
59820
+ }
59821
+ };
59822
+
59710
59823
  // src/index.ts
59711
59824
  var PodOS = class {
59712
59825
  constructor({
@@ -59725,7 +59838,9 @@ _:patch
59725
59838
  );
59726
59839
  this.searchGateway = new SearchGateway(this.store);
59727
59840
  this.fileFetcher = new FileFetcher(this.session);
59728
- this.pictureGateway = new PictureGateway(this.store, this.fileFetcher);
59841
+ this.fileGateway = new FileGateway(this.store, this.fileFetcher);
59842
+ this.attachmentGateway = new AttachmentGateway(this.fileGateway);
59843
+ this.pictureGateway = new PictureGateway(this.fileGateway);
59729
59844
  this.flagAuthorizationMetaDataOnSessionChange();
59730
59845
  this.uriService = new UriService(this.store);
59731
59846
  this.profileGateway = new ProfileGateway(this.store);
@@ -59835,6 +59950,13 @@ _:patch
59835
59950
  uploadAndAddPicture(thing, pictureFile) {
59836
59951
  return this.pictureGateway.uploadAndAddPicture(thing, pictureFile);
59837
59952
  }
59953
+ /**
59954
+ * Provides access to attachment operations such as uploading and linking attachments to things
59955
+ * @returns {AttachmentGateway} An instance of AttachmentGateway that handles attachment operations
59956
+ */
59957
+ attachments() {
59958
+ return this.attachmentGateway;
59959
+ }
59838
59960
  };
59839
59961
  return __toCommonJS(index_exports);
59840
59962
  })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pod-os/core",
3
3
  "description": "Core module of PodOS",
4
- "version": "0.23.0",
4
+ "version": "0.23.1-rc.28ee385.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./types/index.d.ts",
@@ -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);