@darseen/vaze 2.0.0 → 2.1.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.cjs CHANGED
@@ -196,10 +196,11 @@ var Files = class extends Base {
196
196
  };
197
197
  }
198
198
  async upload(data) {
199
- const { files, folder } = data;
199
+ const { files, folder, visibility } = data;
200
200
  const url = this.apiUrl("/api/files");
201
201
  const formData = new FormData();
202
202
  if (folder) formData.append("folder", folder);
203
+ if (visibility) formData.append("visibility", visibility);
203
204
  files.forEach((file) => {
204
205
  formData.append("files", file);
205
206
  });
@@ -221,6 +222,21 @@ var Files = class extends Base {
221
222
  async rename(data) {
222
223
  return await this.request("PUT", this.apiUrl("/api/files"), data);
223
224
  }
225
+ async setVisibility(data) {
226
+ return await this.request("PUT", this.apiUrl("/api/files"), data);
227
+ }
228
+ /** Mint a time-limited URL that reads a file without an API key. */
229
+ async sign(options) {
230
+ const { data, error } = await this.request(
231
+ "POST",
232
+ this.apiUrl("/api/files/sign"),
233
+ options
234
+ );
235
+ return {
236
+ error,
237
+ data: data ? { ...data, url: new URL(data.url, this.vazeUrl).toString() } : null
238
+ };
239
+ }
224
240
  async delete(id) {
225
241
  return await this.request("DELETE", this.apiUrl("/api/files"), {
226
242
  id
@@ -254,6 +270,10 @@ var Folders = class extends Base {
254
270
  async rename(data) {
255
271
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
256
272
  }
273
+ /** Apply a visibility to every file at or below this folder. */
274
+ async setVisibility(data) {
275
+ return await this.request("PUT", this.apiUrl("/api/folders"), data);
276
+ }
257
277
  async delete(id) {
258
278
  return await this.request("DELETE", this.apiUrl("/api/folders"), {
259
279
  id
package/dist/index.d.cts CHANGED
@@ -568,10 +568,30 @@ declare const files: SQLiteTableWithColumns<{
568
568
  identity: undefined;
569
569
  generated: undefined;
570
570
  }, {}, {}>;
571
+ visibility: SQLiteColumn<{
572
+ name: "visibility";
573
+ tableName: "files";
574
+ dataType: "string";
575
+ columnType: "SQLiteText";
576
+ data: "public" | "private";
577
+ driverParam: string;
578
+ notNull: true;
579
+ hasDefault: true;
580
+ isPrimaryKey: false;
581
+ isAutoincrement: false;
582
+ hasRuntimeDefault: false;
583
+ enumValues: ["public", "private"];
584
+ baseColumn: never;
585
+ identity: undefined;
586
+ generated: undefined;
587
+ }, {}, {
588
+ length: number | undefined;
589
+ }>;
571
590
  };
572
591
  dialect: "sqlite";
573
592
  }>;
574
593
  type File$1 = InferSelectModel<typeof files>;
594
+ type Visibility = File$1["visibility"];
575
595
 
576
596
  declare const folders: SQLiteTableWithColumns<{
577
597
  name: "folders";
@@ -745,6 +765,7 @@ declare class Files extends Base {
745
765
  upload(data: {
746
766
  files: File[];
747
767
  folder?: string;
768
+ visibility?: Visibility;
748
769
  }): Promise<{
749
770
  error: {
750
771
  message: string;
@@ -762,6 +783,20 @@ declare class Files extends Base {
762
783
  id: string;
763
784
  name: string;
764
785
  }): Promise<ApiResponse<null>>;
786
+ setVisibility(data: {
787
+ id: string;
788
+ visibility: Visibility;
789
+ }): Promise<ApiResponse<null>>;
790
+ /** Mint a time-limited URL that reads a file without an API key. */
791
+ sign(options: SignOptions): Promise<{
792
+ error: {
793
+ message: string;
794
+ } | null;
795
+ data: {
796
+ url: string;
797
+ expiresAt: string;
798
+ } | null;
799
+ }>;
765
800
  delete(id: string): Promise<ApiResponse<null>>;
766
801
  }
767
802
 
@@ -786,6 +821,11 @@ declare class Folders extends Base {
786
821
  id: string;
787
822
  name: string;
788
823
  }): Promise<ApiResponse<null>>;
824
+ /** Apply a visibility to every file at or below this folder. */
825
+ setVisibility(data: {
826
+ id: string;
827
+ visibility: Visibility;
828
+ }): Promise<ApiResponse<null>>;
789
829
  delete(id: string): Promise<ApiResponse<null>>;
790
830
  }
791
831
 
@@ -803,6 +843,16 @@ type ListOptions = {
803
843
  orderBy?: "createdAt" | "updatedAt" | "name" | "size";
804
844
  orderDirection?: "ASC" | "DESC";
805
845
  };
846
+ type SignOptions = {
847
+ id?: string;
848
+ key?: string;
849
+ /** Seconds the link stays valid. Capped server-side, default one hour. */
850
+ expiresIn?: number;
851
+ };
852
+ type SignedUrl = {
853
+ url: string;
854
+ expiresAt: string;
855
+ };
806
856
 
807
857
  declare class Base {
808
858
  private apiKey;
@@ -826,4 +876,4 @@ declare class Vaze extends Base implements IVaze {
826
876
  }>>;
827
877
  }
828
878
 
829
- export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type VazeOptions, Vaze as default };
879
+ export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type SignOptions, type SignedUrl, type VazeOptions, type Visibility, Vaze as default };
package/dist/index.d.ts CHANGED
@@ -568,10 +568,30 @@ declare const files: SQLiteTableWithColumns<{
568
568
  identity: undefined;
569
569
  generated: undefined;
570
570
  }, {}, {}>;
571
+ visibility: SQLiteColumn<{
572
+ name: "visibility";
573
+ tableName: "files";
574
+ dataType: "string";
575
+ columnType: "SQLiteText";
576
+ data: "public" | "private";
577
+ driverParam: string;
578
+ notNull: true;
579
+ hasDefault: true;
580
+ isPrimaryKey: false;
581
+ isAutoincrement: false;
582
+ hasRuntimeDefault: false;
583
+ enumValues: ["public", "private"];
584
+ baseColumn: never;
585
+ identity: undefined;
586
+ generated: undefined;
587
+ }, {}, {
588
+ length: number | undefined;
589
+ }>;
571
590
  };
572
591
  dialect: "sqlite";
573
592
  }>;
574
593
  type File$1 = InferSelectModel<typeof files>;
594
+ type Visibility = File$1["visibility"];
575
595
 
576
596
  declare const folders: SQLiteTableWithColumns<{
577
597
  name: "folders";
@@ -745,6 +765,7 @@ declare class Files extends Base {
745
765
  upload(data: {
746
766
  files: File[];
747
767
  folder?: string;
768
+ visibility?: Visibility;
748
769
  }): Promise<{
749
770
  error: {
750
771
  message: string;
@@ -762,6 +783,20 @@ declare class Files extends Base {
762
783
  id: string;
763
784
  name: string;
764
785
  }): Promise<ApiResponse<null>>;
786
+ setVisibility(data: {
787
+ id: string;
788
+ visibility: Visibility;
789
+ }): Promise<ApiResponse<null>>;
790
+ /** Mint a time-limited URL that reads a file without an API key. */
791
+ sign(options: SignOptions): Promise<{
792
+ error: {
793
+ message: string;
794
+ } | null;
795
+ data: {
796
+ url: string;
797
+ expiresAt: string;
798
+ } | null;
799
+ }>;
765
800
  delete(id: string): Promise<ApiResponse<null>>;
766
801
  }
767
802
 
@@ -786,6 +821,11 @@ declare class Folders extends Base {
786
821
  id: string;
787
822
  name: string;
788
823
  }): Promise<ApiResponse<null>>;
824
+ /** Apply a visibility to every file at or below this folder. */
825
+ setVisibility(data: {
826
+ id: string;
827
+ visibility: Visibility;
828
+ }): Promise<ApiResponse<null>>;
789
829
  delete(id: string): Promise<ApiResponse<null>>;
790
830
  }
791
831
 
@@ -803,6 +843,16 @@ type ListOptions = {
803
843
  orderBy?: "createdAt" | "updatedAt" | "name" | "size";
804
844
  orderDirection?: "ASC" | "DESC";
805
845
  };
846
+ type SignOptions = {
847
+ id?: string;
848
+ key?: string;
849
+ /** Seconds the link stays valid. Capped server-side, default one hour. */
850
+ expiresIn?: number;
851
+ };
852
+ type SignedUrl = {
853
+ url: string;
854
+ expiresAt: string;
855
+ };
806
856
 
807
857
  declare class Base {
808
858
  private apiKey;
@@ -826,4 +876,4 @@ declare class Vaze extends Base implements IVaze {
826
876
  }>>;
827
877
  }
828
878
 
829
- export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type VazeOptions, Vaze as default };
879
+ export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type SignOptions, type SignedUrl, type VazeOptions, type Visibility, Vaze as default };
package/dist/index.js CHANGED
@@ -196,10 +196,11 @@ var Files = class extends Base {
196
196
  };
197
197
  }
198
198
  async upload(data) {
199
- const { files, folder } = data;
199
+ const { files, folder, visibility } = data;
200
200
  const url = this.apiUrl("/api/files");
201
201
  const formData = new FormData();
202
202
  if (folder) formData.append("folder", folder);
203
+ if (visibility) formData.append("visibility", visibility);
203
204
  files.forEach((file) => {
204
205
  formData.append("files", file);
205
206
  });
@@ -221,6 +222,21 @@ var Files = class extends Base {
221
222
  async rename(data) {
222
223
  return await this.request("PUT", this.apiUrl("/api/files"), data);
223
224
  }
225
+ async setVisibility(data) {
226
+ return await this.request("PUT", this.apiUrl("/api/files"), data);
227
+ }
228
+ /** Mint a time-limited URL that reads a file without an API key. */
229
+ async sign(options) {
230
+ const { data, error } = await this.request(
231
+ "POST",
232
+ this.apiUrl("/api/files/sign"),
233
+ options
234
+ );
235
+ return {
236
+ error,
237
+ data: data ? { ...data, url: new URL(data.url, this.vazeUrl).toString() } : null
238
+ };
239
+ }
224
240
  async delete(id) {
225
241
  return await this.request("DELETE", this.apiUrl("/api/files"), {
226
242
  id
@@ -254,6 +270,10 @@ var Folders = class extends Base {
254
270
  async rename(data) {
255
271
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
256
272
  }
273
+ /** Apply a visibility to every file at or below this folder. */
274
+ async setVisibility(data) {
275
+ return await this.request("PUT", this.apiUrl("/api/folders"), data);
276
+ }
257
277
  async delete(id) {
258
278
  return await this.request("DELETE", this.apiUrl("/api/folders"), {
259
279
  id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darseen/vaze",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Vaze Self-Hosted file storage and hosting service SDK.",
5
5
  "keywords": [
6
6
  "api",