@darseen/vaze 2.0.0 → 2.2.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/README.md +22 -0
- package/dist/index.cjs +47 -3
- package/dist/index.d.cts +76 -2
- package/dist/index.d.ts +76 -2
- package/dist/index.js +47 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -109,6 +109,17 @@ if (data) {
|
|
|
109
109
|
}
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
`downloadMany(ids)` Download several files as one zip. Entries keep their paths below the folder the files share.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const { data, error } = await vaze.files.downloadMany(["file-id-123", "file-id-456"]);
|
|
116
|
+
|
|
117
|
+
if (data) {
|
|
118
|
+
console.log(data.filename); // e.g. "photos.zip"
|
|
119
|
+
const buffer = Buffer.from(await data.blob.arrayBuffer());
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
112
123
|
`rename(data)` Rename an existing file.
|
|
113
124
|
|
|
114
125
|
- data:
|
|
@@ -171,6 +182,17 @@ const { data, error } = await vaze.folders.rename({
|
|
|
171
182
|
});
|
|
172
183
|
```
|
|
173
184
|
|
|
185
|
+
`download(options?)` Download a folder and everything below it as one zip. With no `id` or `key`, the root folder is archived.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const { data, error } = await vaze.folders.download({ key: "projects/work" });
|
|
189
|
+
|
|
190
|
+
if (data) {
|
|
191
|
+
console.log(data.filename); // "work.zip", with every entry under work/
|
|
192
|
+
const buffer = Buffer.from(await data.blob.arrayBuffer());
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
174
196
|
`delete(id)` Delete a folder by its ID.
|
|
175
197
|
|
|
176
198
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -92,10 +92,14 @@ var Base = class {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async requestBlob(url) {
|
|
95
|
+
async requestBlob(url, method = "GET", body) {
|
|
96
96
|
try {
|
|
97
|
+
const headers = { "API-Key": this.apiKey };
|
|
98
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
97
99
|
const response = await fetch(url, {
|
|
98
|
-
|
|
100
|
+
method,
|
|
101
|
+
headers,
|
|
102
|
+
body: body !== void 0 ? JSON.stringify(body) : null
|
|
99
103
|
});
|
|
100
104
|
const contentType = _nullishCoalesce(response.headers.get("content-type"), () => ( ""));
|
|
101
105
|
if (!response.ok) {
|
|
@@ -196,10 +200,11 @@ var Files = class extends Base {
|
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
202
|
async upload(data) {
|
|
199
|
-
const { files, folder } = data;
|
|
203
|
+
const { files, folder, visibility } = data;
|
|
200
204
|
const url = this.apiUrl("/api/files");
|
|
201
205
|
const formData = new FormData();
|
|
202
206
|
if (folder) formData.append("folder", folder);
|
|
207
|
+
if (visibility) formData.append("visibility", visibility);
|
|
203
208
|
files.forEach((file) => {
|
|
204
209
|
formData.append("files", file);
|
|
205
210
|
});
|
|
@@ -218,14 +223,43 @@ var Files = class extends Base {
|
|
|
218
223
|
const url = this.apiUrl(`/api/files/download/${encodeURIComponent(id)}`);
|
|
219
224
|
return await this.requestBlob(url);
|
|
220
225
|
}
|
|
226
|
+
/** Download several files as one zip, with paths below their shared folder. */
|
|
227
|
+
async downloadMany(ids) {
|
|
228
|
+
return await this.requestBlob(this.apiUrl("/api/files/download"), "POST", {
|
|
229
|
+
ids
|
|
230
|
+
});
|
|
231
|
+
}
|
|
221
232
|
async rename(data) {
|
|
222
233
|
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
223
234
|
}
|
|
235
|
+
async setVisibility(data) {
|
|
236
|
+
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
237
|
+
}
|
|
238
|
+
/** Mint a time-limited URL that reads a file without an API key. */
|
|
239
|
+
async sign(options) {
|
|
240
|
+
const { data, error } = await this.request(
|
|
241
|
+
"POST",
|
|
242
|
+
this.apiUrl("/api/files/sign"),
|
|
243
|
+
options
|
|
244
|
+
);
|
|
245
|
+
return {
|
|
246
|
+
error,
|
|
247
|
+
data: data ? { ...data, url: new URL(data.url, this.vazeUrl).toString() } : null
|
|
248
|
+
};
|
|
249
|
+
}
|
|
224
250
|
async delete(id) {
|
|
225
251
|
return await this.request("DELETE", this.apiUrl("/api/files"), {
|
|
226
252
|
id
|
|
227
253
|
});
|
|
228
254
|
}
|
|
255
|
+
/** Delete several files in one request; each id reports its own outcome. */
|
|
256
|
+
async deleteMany(ids) {
|
|
257
|
+
return await this.request(
|
|
258
|
+
"DELETE",
|
|
259
|
+
this.apiUrl("/api/files"),
|
|
260
|
+
{ ids }
|
|
261
|
+
);
|
|
262
|
+
}
|
|
229
263
|
};
|
|
230
264
|
|
|
231
265
|
// src/folders.ts
|
|
@@ -244,6 +278,12 @@ var Folders = class extends Base {
|
|
|
244
278
|
} : null
|
|
245
279
|
};
|
|
246
280
|
}
|
|
281
|
+
/** Download a folder and everything below it as a zip; the root by default. */
|
|
282
|
+
async download(options) {
|
|
283
|
+
return await this.requestBlob(
|
|
284
|
+
this.apiUrl("/api/folders/download", options)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
247
287
|
async create(folder) {
|
|
248
288
|
return await this.request(
|
|
249
289
|
"POST",
|
|
@@ -254,6 +294,10 @@ var Folders = class extends Base {
|
|
|
254
294
|
async rename(data) {
|
|
255
295
|
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
256
296
|
}
|
|
297
|
+
/** Apply a visibility to every file at or below this folder. */
|
|
298
|
+
async setVisibility(data) {
|
|
299
|
+
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
300
|
+
}
|
|
257
301
|
async delete(id) {
|
|
258
302
|
return await this.request("DELETE", this.apiUrl("/api/folders"), {
|
|
259
303
|
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;
|
|
@@ -758,11 +779,33 @@ declare class Files extends Base {
|
|
|
758
779
|
filename: string | null;
|
|
759
780
|
contentType: string;
|
|
760
781
|
}>>;
|
|
782
|
+
/** Download several files as one zip, with paths below their shared folder. */
|
|
783
|
+
downloadMany(ids: string[]): Promise<ApiResponse<{
|
|
784
|
+
blob: Blob;
|
|
785
|
+
filename: string | null;
|
|
786
|
+
contentType: string;
|
|
787
|
+
}>>;
|
|
761
788
|
rename(data: {
|
|
762
789
|
id: string;
|
|
763
790
|
name: string;
|
|
764
791
|
}): Promise<ApiResponse<null>>;
|
|
792
|
+
setVisibility(data: {
|
|
793
|
+
id: string;
|
|
794
|
+
visibility: Visibility;
|
|
795
|
+
}): Promise<ApiResponse<null>>;
|
|
796
|
+
/** Mint a time-limited URL that reads a file without an API key. */
|
|
797
|
+
sign(options: SignOptions): Promise<{
|
|
798
|
+
error: {
|
|
799
|
+
message: string;
|
|
800
|
+
} | null;
|
|
801
|
+
data: {
|
|
802
|
+
url: string;
|
|
803
|
+
expiresAt: string;
|
|
804
|
+
} | null;
|
|
805
|
+
}>;
|
|
765
806
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
807
|
+
/** Delete several files in one request; each id reports its own outcome. */
|
|
808
|
+
deleteMany(ids: string[]): Promise<ApiResponse<BulkDeleteResult>>;
|
|
766
809
|
}
|
|
767
810
|
|
|
768
811
|
declare class Folders extends Base {
|
|
@@ -779,6 +822,15 @@ declare class Folders extends Base {
|
|
|
779
822
|
folders: Folder[];
|
|
780
823
|
} | null;
|
|
781
824
|
}>;
|
|
825
|
+
/** Download a folder and everything below it as a zip; the root by default. */
|
|
826
|
+
download(options?: {
|
|
827
|
+
id?: string;
|
|
828
|
+
key?: string;
|
|
829
|
+
}): Promise<ApiResponse<{
|
|
830
|
+
blob: Blob;
|
|
831
|
+
filename: string | null;
|
|
832
|
+
contentType: string;
|
|
833
|
+
}>>;
|
|
782
834
|
create(folder: string): Promise<ApiResponse<{
|
|
783
835
|
folder: Folder;
|
|
784
836
|
}>>;
|
|
@@ -786,6 +838,11 @@ declare class Folders extends Base {
|
|
|
786
838
|
id: string;
|
|
787
839
|
name: string;
|
|
788
840
|
}): Promise<ApiResponse<null>>;
|
|
841
|
+
/** Apply a visibility to every file at or below this folder. */
|
|
842
|
+
setVisibility(data: {
|
|
843
|
+
id: string;
|
|
844
|
+
visibility: Visibility;
|
|
845
|
+
}): Promise<ApiResponse<null>>;
|
|
789
846
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
790
847
|
}
|
|
791
848
|
|
|
@@ -803,6 +860,23 @@ type ListOptions = {
|
|
|
803
860
|
orderBy?: "createdAt" | "updatedAt" | "name" | "size";
|
|
804
861
|
orderDirection?: "ASC" | "DESC";
|
|
805
862
|
};
|
|
863
|
+
type SignOptions = {
|
|
864
|
+
id?: string;
|
|
865
|
+
key?: string;
|
|
866
|
+
/** Seconds the link stays valid. Capped server-side, default one hour. */
|
|
867
|
+
expiresIn?: number;
|
|
868
|
+
};
|
|
869
|
+
type SignedUrl = {
|
|
870
|
+
url: string;
|
|
871
|
+
expiresAt: string;
|
|
872
|
+
};
|
|
873
|
+
type BulkDeleteResult = {
|
|
874
|
+
deleted: string[];
|
|
875
|
+
failed: {
|
|
876
|
+
id: string;
|
|
877
|
+
message: string;
|
|
878
|
+
}[];
|
|
879
|
+
};
|
|
806
880
|
|
|
807
881
|
declare class Base {
|
|
808
882
|
private apiKey;
|
|
@@ -810,7 +884,7 @@ declare class Base {
|
|
|
810
884
|
constructor(options?: VazeOptions);
|
|
811
885
|
protected apiUrl(path: string, params?: Record<string, string | number | undefined>): string;
|
|
812
886
|
protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
813
|
-
protected requestBlob(url: string): Promise<ApiResponse<{
|
|
887
|
+
protected requestBlob(url: string, method?: string, body?: Record<string, any>): Promise<ApiResponse<{
|
|
814
888
|
blob: Blob;
|
|
815
889
|
filename: string | null;
|
|
816
890
|
contentType: string;
|
|
@@ -826,4 +900,4 @@ declare class Vaze extends Base implements IVaze {
|
|
|
826
900
|
}>>;
|
|
827
901
|
}
|
|
828
902
|
|
|
829
|
-
export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type VazeOptions, Vaze as default };
|
|
903
|
+
export { type ApiResponse, type BulkDeleteResult, 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;
|
|
@@ -758,11 +779,33 @@ declare class Files extends Base {
|
|
|
758
779
|
filename: string | null;
|
|
759
780
|
contentType: string;
|
|
760
781
|
}>>;
|
|
782
|
+
/** Download several files as one zip, with paths below their shared folder. */
|
|
783
|
+
downloadMany(ids: string[]): Promise<ApiResponse<{
|
|
784
|
+
blob: Blob;
|
|
785
|
+
filename: string | null;
|
|
786
|
+
contentType: string;
|
|
787
|
+
}>>;
|
|
761
788
|
rename(data: {
|
|
762
789
|
id: string;
|
|
763
790
|
name: string;
|
|
764
791
|
}): Promise<ApiResponse<null>>;
|
|
792
|
+
setVisibility(data: {
|
|
793
|
+
id: string;
|
|
794
|
+
visibility: Visibility;
|
|
795
|
+
}): Promise<ApiResponse<null>>;
|
|
796
|
+
/** Mint a time-limited URL that reads a file without an API key. */
|
|
797
|
+
sign(options: SignOptions): Promise<{
|
|
798
|
+
error: {
|
|
799
|
+
message: string;
|
|
800
|
+
} | null;
|
|
801
|
+
data: {
|
|
802
|
+
url: string;
|
|
803
|
+
expiresAt: string;
|
|
804
|
+
} | null;
|
|
805
|
+
}>;
|
|
765
806
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
807
|
+
/** Delete several files in one request; each id reports its own outcome. */
|
|
808
|
+
deleteMany(ids: string[]): Promise<ApiResponse<BulkDeleteResult>>;
|
|
766
809
|
}
|
|
767
810
|
|
|
768
811
|
declare class Folders extends Base {
|
|
@@ -779,6 +822,15 @@ declare class Folders extends Base {
|
|
|
779
822
|
folders: Folder[];
|
|
780
823
|
} | null;
|
|
781
824
|
}>;
|
|
825
|
+
/** Download a folder and everything below it as a zip; the root by default. */
|
|
826
|
+
download(options?: {
|
|
827
|
+
id?: string;
|
|
828
|
+
key?: string;
|
|
829
|
+
}): Promise<ApiResponse<{
|
|
830
|
+
blob: Blob;
|
|
831
|
+
filename: string | null;
|
|
832
|
+
contentType: string;
|
|
833
|
+
}>>;
|
|
782
834
|
create(folder: string): Promise<ApiResponse<{
|
|
783
835
|
folder: Folder;
|
|
784
836
|
}>>;
|
|
@@ -786,6 +838,11 @@ declare class Folders extends Base {
|
|
|
786
838
|
id: string;
|
|
787
839
|
name: string;
|
|
788
840
|
}): Promise<ApiResponse<null>>;
|
|
841
|
+
/** Apply a visibility to every file at or below this folder. */
|
|
842
|
+
setVisibility(data: {
|
|
843
|
+
id: string;
|
|
844
|
+
visibility: Visibility;
|
|
845
|
+
}): Promise<ApiResponse<null>>;
|
|
789
846
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
790
847
|
}
|
|
791
848
|
|
|
@@ -803,6 +860,23 @@ type ListOptions = {
|
|
|
803
860
|
orderBy?: "createdAt" | "updatedAt" | "name" | "size";
|
|
804
861
|
orderDirection?: "ASC" | "DESC";
|
|
805
862
|
};
|
|
863
|
+
type SignOptions = {
|
|
864
|
+
id?: string;
|
|
865
|
+
key?: string;
|
|
866
|
+
/** Seconds the link stays valid. Capped server-side, default one hour. */
|
|
867
|
+
expiresIn?: number;
|
|
868
|
+
};
|
|
869
|
+
type SignedUrl = {
|
|
870
|
+
url: string;
|
|
871
|
+
expiresAt: string;
|
|
872
|
+
};
|
|
873
|
+
type BulkDeleteResult = {
|
|
874
|
+
deleted: string[];
|
|
875
|
+
failed: {
|
|
876
|
+
id: string;
|
|
877
|
+
message: string;
|
|
878
|
+
}[];
|
|
879
|
+
};
|
|
806
880
|
|
|
807
881
|
declare class Base {
|
|
808
882
|
private apiKey;
|
|
@@ -810,7 +884,7 @@ declare class Base {
|
|
|
810
884
|
constructor(options?: VazeOptions);
|
|
811
885
|
protected apiUrl(path: string, params?: Record<string, string | number | undefined>): string;
|
|
812
886
|
protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
813
|
-
protected requestBlob(url: string): Promise<ApiResponse<{
|
|
887
|
+
protected requestBlob(url: string, method?: string, body?: Record<string, any>): Promise<ApiResponse<{
|
|
814
888
|
blob: Blob;
|
|
815
889
|
filename: string | null;
|
|
816
890
|
contentType: string;
|
|
@@ -826,4 +900,4 @@ declare class Vaze extends Base implements IVaze {
|
|
|
826
900
|
}>>;
|
|
827
901
|
}
|
|
828
902
|
|
|
829
|
-
export { type ApiResponse, type FileWithUrl as File, type Folder, type ListOptions, type VazeOptions, Vaze as default };
|
|
903
|
+
export { type ApiResponse, type BulkDeleteResult, type FileWithUrl as File, type Folder, type ListOptions, type SignOptions, type SignedUrl, type VazeOptions, type Visibility, Vaze as default };
|
package/dist/index.js
CHANGED
|
@@ -92,10 +92,14 @@ var Base = class {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async requestBlob(url) {
|
|
95
|
+
async requestBlob(url, method = "GET", body) {
|
|
96
96
|
try {
|
|
97
|
+
const headers = { "API-Key": this.apiKey };
|
|
98
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
97
99
|
const response = await fetch(url, {
|
|
98
|
-
|
|
100
|
+
method,
|
|
101
|
+
headers,
|
|
102
|
+
body: body !== void 0 ? JSON.stringify(body) : null
|
|
99
103
|
});
|
|
100
104
|
const contentType = response.headers.get("content-type") ?? "";
|
|
101
105
|
if (!response.ok) {
|
|
@@ -196,10 +200,11 @@ var Files = class extends Base {
|
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
202
|
async upload(data) {
|
|
199
|
-
const { files, folder } = data;
|
|
203
|
+
const { files, folder, visibility } = data;
|
|
200
204
|
const url = this.apiUrl("/api/files");
|
|
201
205
|
const formData = new FormData();
|
|
202
206
|
if (folder) formData.append("folder", folder);
|
|
207
|
+
if (visibility) formData.append("visibility", visibility);
|
|
203
208
|
files.forEach((file) => {
|
|
204
209
|
formData.append("files", file);
|
|
205
210
|
});
|
|
@@ -218,14 +223,43 @@ var Files = class extends Base {
|
|
|
218
223
|
const url = this.apiUrl(`/api/files/download/${encodeURIComponent(id)}`);
|
|
219
224
|
return await this.requestBlob(url);
|
|
220
225
|
}
|
|
226
|
+
/** Download several files as one zip, with paths below their shared folder. */
|
|
227
|
+
async downloadMany(ids) {
|
|
228
|
+
return await this.requestBlob(this.apiUrl("/api/files/download"), "POST", {
|
|
229
|
+
ids
|
|
230
|
+
});
|
|
231
|
+
}
|
|
221
232
|
async rename(data) {
|
|
222
233
|
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
223
234
|
}
|
|
235
|
+
async setVisibility(data) {
|
|
236
|
+
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
237
|
+
}
|
|
238
|
+
/** Mint a time-limited URL that reads a file without an API key. */
|
|
239
|
+
async sign(options) {
|
|
240
|
+
const { data, error } = await this.request(
|
|
241
|
+
"POST",
|
|
242
|
+
this.apiUrl("/api/files/sign"),
|
|
243
|
+
options
|
|
244
|
+
);
|
|
245
|
+
return {
|
|
246
|
+
error,
|
|
247
|
+
data: data ? { ...data, url: new URL(data.url, this.vazeUrl).toString() } : null
|
|
248
|
+
};
|
|
249
|
+
}
|
|
224
250
|
async delete(id) {
|
|
225
251
|
return await this.request("DELETE", this.apiUrl("/api/files"), {
|
|
226
252
|
id
|
|
227
253
|
});
|
|
228
254
|
}
|
|
255
|
+
/** Delete several files in one request; each id reports its own outcome. */
|
|
256
|
+
async deleteMany(ids) {
|
|
257
|
+
return await this.request(
|
|
258
|
+
"DELETE",
|
|
259
|
+
this.apiUrl("/api/files"),
|
|
260
|
+
{ ids }
|
|
261
|
+
);
|
|
262
|
+
}
|
|
229
263
|
};
|
|
230
264
|
|
|
231
265
|
// src/folders.ts
|
|
@@ -244,6 +278,12 @@ var Folders = class extends Base {
|
|
|
244
278
|
} : null
|
|
245
279
|
};
|
|
246
280
|
}
|
|
281
|
+
/** Download a folder and everything below it as a zip; the root by default. */
|
|
282
|
+
async download(options) {
|
|
283
|
+
return await this.requestBlob(
|
|
284
|
+
this.apiUrl("/api/folders/download", options)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
247
287
|
async create(folder) {
|
|
248
288
|
return await this.request(
|
|
249
289
|
"POST",
|
|
@@ -254,6 +294,10 @@ var Folders = class extends Base {
|
|
|
254
294
|
async rename(data) {
|
|
255
295
|
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
256
296
|
}
|
|
297
|
+
/** Apply a visibility to every file at or below this folder. */
|
|
298
|
+
async setVisibility(data) {
|
|
299
|
+
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
300
|
+
}
|
|
257
301
|
async delete(id) {
|
|
258
302
|
return await this.request("DELETE", this.apiUrl("/api/folders"), {
|
|
259
303
|
id
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darseen/vaze",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Vaze Self-Hosted file storage and hosting service SDK.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types
|
|
45
|
+
"@repo/types": "1.0.0",
|
|
46
|
+
"@types/node": "^26.6.2",
|
|
46
47
|
"rimraf": "^6.1.3",
|
|
47
|
-
"tsup": "^8.5.1"
|
|
48
|
-
"@repo/types": "1.0.0"
|
|
48
|
+
"tsup": "^8.5.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"lint": "tsc --noEmit",
|