@pod-os/core 0.20.1-rc.0634a47.0 → 0.20.1-rc.44379ec.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 CHANGED
@@ -2768,6 +2768,22 @@ var FileFetcher = class {
2768
2768
  body: newContent
2769
2769
  });
2770
2770
  }
2771
+ async createNewFile(container2, name9) {
2772
+ const encodedName = encodeURIComponent(name9);
2773
+ await this.session.authenticatedFetch(container2.uri + encodedName, {
2774
+ method: "PUT",
2775
+ headers: {
2776
+ "Content-Type": "text/turtle",
2777
+ "If-None-Match": "*"
2778
+ }
2779
+ });
2780
+ }
2781
+ async createNewFolder(container2, name9) {
2782
+ const encodedName = encodeURIComponent(name9);
2783
+ await this.session.authenticatedFetch(container2.uri + encodedName + "/", {
2784
+ method: "PUT"
2785
+ });
2786
+ }
2771
2787
  };
2772
2788
 
2773
2789
  // src/modules/contacts.ts
@@ -2816,7 +2832,8 @@ function labelFromUri(uri6) {
2816
2832
  if (isTooGeneric(url7.hash)) {
2817
2833
  return (getFilename(url7) || url7.host + url7.pathname) + url7.hash;
2818
2834
  }
2819
- return labelFromFragment(url7.hash) || getFilename(url7) || url7.host;
2835
+ const name9 = labelFromFragment(url7.hash) || getFilename(url7) || url7.host;
2836
+ return name9.endsWith("/") ? name9.slice(0, -1) : name9;
2820
2837
  }
2821
2838
  function labelFromFragment(fragment) {
2822
2839
  return fragment ? fragment.split("#")[1] : null;
@@ -2828,9 +2845,10 @@ function isTooGeneric(fragment) {
2828
2845
  function getFilename(url7) {
2829
2846
  if (url7.pathname.endsWith("/")) {
2830
2847
  const containerName = url7.pathname.split("/").at(-2);
2831
- return containerName ? containerName + "/" : null;
2848
+ return containerName ? decodeURIComponent(containerName) + "/" : null;
2832
2849
  } else {
2833
- return url7.pathname.split("/").pop();
2850
+ const name9 = url7.pathname.split("/").pop();
2851
+ return name9 ? decodeURIComponent(name9) : null;
2834
2852
  }
2835
2853
  }
2836
2854
 
@@ -24809,10 +24827,7 @@ var LdpContainer = class extends Thing {
24809
24827
  );
24810
24828
  return contains3.map((content5) => ({
24811
24829
  uri: content5.object.value,
24812
- name: content5.object.value.replace(
24813
- new RegExp(`${this.uri}([^/]*)/?`),
24814
- "$1"
24815
- )
24830
+ name: labelFromUri(content5.object.value)
24816
24831
  }));
24817
24832
  }
24818
24833
  };
package/lib/index.js CHANGED
@@ -35730,6 +35730,22 @@ _:patch
35730
35730
  body: newContent
35731
35731
  });
35732
35732
  }
35733
+ async createNewFile(container2, name9) {
35734
+ const encodedName = encodeURIComponent(name9);
35735
+ await this.session.authenticatedFetch(container2.uri + encodedName, {
35736
+ method: "PUT",
35737
+ headers: {
35738
+ "Content-Type": "text/turtle",
35739
+ "If-None-Match": "*"
35740
+ }
35741
+ });
35742
+ }
35743
+ async createNewFolder(container2, name9) {
35744
+ const encodedName = encodeURIComponent(name9);
35745
+ await this.session.authenticatedFetch(container2.uri + encodedName + "/", {
35746
+ method: "PUT"
35747
+ });
35748
+ }
35733
35749
  };
35734
35750
 
35735
35751
  // src/modules/contacts.ts
@@ -35785,7 +35801,8 @@ _:patch
35785
35801
  if (isTooGeneric(url7.hash)) {
35786
35802
  return (getFilename(url7) || url7.host + url7.pathname) + url7.hash;
35787
35803
  }
35788
- return labelFromFragment(url7.hash) || getFilename(url7) || url7.host;
35804
+ const name9 = labelFromFragment(url7.hash) || getFilename(url7) || url7.host;
35805
+ return name9.endsWith("/") ? name9.slice(0, -1) : name9;
35789
35806
  }
35790
35807
  function labelFromFragment(fragment) {
35791
35808
  return fragment ? fragment.split("#")[1] : null;
@@ -35797,9 +35814,10 @@ _:patch
35797
35814
  function getFilename(url7) {
35798
35815
  if (url7.pathname.endsWith("/")) {
35799
35816
  const containerName = url7.pathname.split("/").at(-2);
35800
- return containerName ? containerName + "/" : null;
35817
+ return containerName ? decodeURIComponent(containerName) + "/" : null;
35801
35818
  } else {
35802
- return url7.pathname.split("/").pop();
35819
+ const name9 = url7.pathname.split("/").pop();
35820
+ return name9 ? decodeURIComponent(name9) : null;
35803
35821
  }
35804
35822
  }
35805
35823
 
@@ -57793,10 +57811,7 @@ _:patch
57793
57811
  );
57794
57812
  return contains3.map((content5) => ({
57795
57813
  uri: content5.object.value,
57796
- name: content5.object.value.replace(
57797
- new RegExp(`${this.uri}([^/]*)/?`),
57798
- "$1"
57799
- )
57814
+ name: labelFromUri(content5.object.value)
57800
57815
  }));
57801
57816
  }
57802
57817
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pod-os/core",
3
- "version": "0.20.1-rc.0634a47.0",
3
+ "version": "0.20.1-rc.44379ec.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./types/index.d.ts",
6
6
  "files": [
@@ -1,5 +1,6 @@
1
1
  import { PodOsSession } from "../authentication";
2
2
  import { SolidFile } from "./SolidFile";
3
+ import { LdpContainer } from "../ldp-container";
3
4
  export declare class FileFetcher {
4
5
  private session;
5
6
  constructor(session: PodOsSession);
@@ -16,4 +17,6 @@ export declare class FileFetcher {
16
17
  * @returns {Promise<Response>} The HTTP response
17
18
  */
18
19
  putFile(file: SolidFile, newContent: string): Promise<Response>;
20
+ createNewFile(container: LdpContainer, name: string): Promise<void>;
21
+ createNewFolder(container: LdpContainer, name: string): Promise<void>;
19
22
  }