@pod-os/core 0.23.1-rc.d5481ff.0 → 0.24.0-rc.47722fb.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,
@@ -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/picture/createPictureLinkOperation.ts
37755
+ // src/files/createFileLinkOperation.ts
37739
37756
  init_esm();
37740
- var SCHEMA_IMAGE = "http://schema.org/image";
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(SCHEMA_IMAGE),
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/picture/PictureGateway.ts
37757
- var PictureGateway = class {
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 picture file and associates it with a thing.
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 picture to
37768
- * @param pictureFile - The picture file to upload
37769
- * @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
37770
37787
  */
37771
- uploadAndAddPicture(thing, pictureFile) {
37788
+ uploadAndLinkFile(thing, predicateUri, fileToUpload) {
37772
37789
  const container2 = this.getContainerFromThing(thing);
37773
- 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));
37774
37791
  }
37775
- linkPictureToThing(thing, file2) {
37776
- const operation3 = createPictureLinkOperation(thing, file2);
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 picture to thing"
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 te URI of the preferences document
37948
+ * Returns the URI of the preferences document
37801
37949
  */
37802
37950
  getPreferencesFile() {
37803
- return this.store.anyValue(
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
- namedNode("http://www.w3.org/ns/pim/space#preferencesFile"),
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,31 @@ _: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
+ 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
+
37835
38022
  // src/search/SearchIndex.ts
37836
38023
  var import_lunr = __toESM(require_lunr(), 1);
37837
38024
  var SearchIndex = class {
@@ -37915,11 +38102,6 @@ _:patch
37915
38102
  }
37916
38103
  };
37917
38104
 
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
38105
  // src/search/LabelIndex.ts
37924
38106
  var LabelIndex = class extends RdfDocument {
37925
38107
  constructor(uri6, store, editable = false) {
@@ -37952,32 +38134,6 @@ _:patch
37952
38134
 
37953
38135
  // src/search/createDefaultLabelIndex.ts
37954
38136
  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
38137
  function createDefaultLabelIndex(profile2) {
37982
38138
  const webId = namedNode(profile2.webId);
37983
38139
  const preferencesFile2 = profile2.getPreferencesFile();
@@ -38291,7 +38447,7 @@ _:patch
38291
38447
  rdf: () => rdf5,
38292
38448
  rdfs: () => rdfs2,
38293
38449
  sched: () => sched,
38294
- schema: () => schema,
38450
+ schema: () => schema2,
38295
38451
  schema_https: () => schema_https,
38296
38452
  sec: () => sec,
38297
38453
  shacl: () => shacl,
@@ -59545,7 +59701,7 @@ _:patch
59545
59701
  var rdf5 = rdfImport;
59546
59702
  var rdfs2 = rdfsImport;
59547
59703
  var sched = schedImport;
59548
- var schema = schemaImport;
59704
+ var schema2 = schemaImport;
59549
59705
  var schema_https = schema_httpsImport;
59550
59706
  var sec = secImport;
59551
59707
  var shacl = shaclImport;
@@ -59617,6 +59773,53 @@ _:patch
59617
59773
  }
59618
59774
  };
59619
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
+
59620
59823
  // src/index.ts
59621
59824
  var PodOS = class {
59622
59825
  constructor({
@@ -59635,9 +59838,12 @@ _:patch
59635
59838
  );
59636
59839
  this.searchGateway = new SearchGateway(this.store);
59637
59840
  this.fileFetcher = new FileFetcher(this.session);
59638
- 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);
59639
59844
  this.flagAuthorizationMetaDataOnSessionChange();
59640
59845
  this.uriService = new UriService(this.store);
59846
+ this.profileGateway = new ProfileGateway(this.store);
59641
59847
  }
59642
59848
  /*
59643
59849
  Flagging authorization metadata is necessary every time the user
@@ -59697,13 +59903,7 @@ _:patch
59697
59903
  * @param webId
59698
59904
  */
59699
59905
  async fetchProfile(webId) {
59700
- await this.fetch(webId);
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;
59906
+ return this.profileGateway.fetchProfile(webId);
59707
59907
  }
59708
59908
  /**
59709
59909
  * Fetch the private label index for the given profile and build a search index from it
@@ -59750,6 +59950,13 @@ _:patch
59750
59950
  uploadAndAddPicture(thing, pictureFile) {
59751
59951
  return this.pictureGateway.uploadAndAddPicture(thing, pictureFile);
59752
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
+ }
59753
59960
  };
59754
59961
  return __toCommonJS(index_exports);
59755
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.1-rc.d5481ff.0",
4
+ "version": "0.24.0-rc.47722fb.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);
@@ -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 {};
@@ -3,3 +3,4 @@ export * from "./BinaryFile";
3
3
  export * from "./BrokenFile";
4
4
  export * from "./HttpStatus";
5
5
  export * from "./FileFetcher";
6
+ export * from "./FileGateway";
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 { SessionInfo, PodOsSession } from "./authentication";
4
- import { SolidFile } from "./files";
5
- import { FileFetcher } from "./files/FileFetcher";
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
  }