@darseen/vaze 2.2.0 → 2.3.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
@@ -235,6 +235,37 @@ var Files = class extends Base {
235
235
  async setVisibility(data) {
236
236
  return await this.request("PUT", this.apiUrl("/api/files"), data);
237
237
  }
238
+ /** Move a file into another folder; its key and URL change with it. */
239
+ async move(data) {
240
+ const { data: responseData, error } = await this.request("POST", this.apiUrl("/api/files/move"), data);
241
+ return {
242
+ error,
243
+ data: responseData ? {
244
+ file: constructFileUrls({
245
+ vazeUrl: this.vazeUrl,
246
+ files: [responseData.file]
247
+ })[0]
248
+ } : null
249
+ };
250
+ }
251
+ /** Move several files into one folder; each id reports its own outcome. */
252
+ async moveMany(ids, destination) {
253
+ const { data, error } = await this.request(
254
+ "POST",
255
+ this.apiUrl("/api/files/move"),
256
+ { ids, ...destination }
257
+ );
258
+ return {
259
+ error,
260
+ data: data ? {
261
+ files: constructFileUrls({
262
+ vazeUrl: this.vazeUrl,
263
+ files: data.files
264
+ }),
265
+ failed: data.failed
266
+ } : null
267
+ };
268
+ }
238
269
  /** Mint a time-limited URL that reads a file without an API key. */
239
270
  async sign(options) {
240
271
  const { data, error } = await this.request(
@@ -294,6 +325,14 @@ var Folders = class extends Base {
294
325
  async rename(data) {
295
326
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
296
327
  }
328
+ /** Move a folder, and everything inside it, into another folder. */
329
+ async move(data) {
330
+ return await this.request(
331
+ "POST",
332
+ this.apiUrl("/api/folders/move"),
333
+ data
334
+ );
335
+ }
297
336
  /** Apply a visibility to every file at or below this folder. */
298
337
  async setVisibility(data) {
299
338
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
package/dist/index.d.cts CHANGED
@@ -793,6 +793,30 @@ declare class Files extends Base {
793
793
  id: string;
794
794
  visibility: Visibility;
795
795
  }): Promise<ApiResponse<null>>;
796
+ /** Move a file into another folder; its key and URL change with it. */
797
+ move(data: {
798
+ id: string;
799
+ } & MoveDestination): Promise<{
800
+ error: {
801
+ message: string;
802
+ } | null;
803
+ data: {
804
+ file: any;
805
+ } | null;
806
+ }>;
807
+ /** Move several files into one folder; each id reports its own outcome. */
808
+ moveMany(ids: string[], destination: MoveDestination): Promise<{
809
+ error: {
810
+ message: string;
811
+ } | null;
812
+ data: {
813
+ files: any[];
814
+ failed: {
815
+ id: string;
816
+ message: string;
817
+ }[];
818
+ } | null;
819
+ }>;
796
820
  /** Mint a time-limited URL that reads a file without an API key. */
797
821
  sign(options: SignOptions): Promise<{
798
822
  error: {
@@ -838,6 +862,12 @@ declare class Folders extends Base {
838
862
  id: string;
839
863
  name: string;
840
864
  }): Promise<ApiResponse<null>>;
865
+ /** Move a folder, and everything inside it, into another folder. */
866
+ move(data: {
867
+ id: string;
868
+ } & MoveDestination): Promise<ApiResponse<{
869
+ folder: Folder;
870
+ }>>;
841
871
  /** Apply a visibility to every file at or below this folder. */
842
872
  setVisibility(data: {
843
873
  id: string;
@@ -870,6 +900,19 @@ type SignedUrl = {
870
900
  url: string;
871
901
  expiresAt: string;
872
902
  };
903
+ type MoveDestination = {
904
+ /** The destination folder's id. Either this or `folder` is required. */
905
+ folderId?: string;
906
+ /** The destination folder's key, created if missing; `""` is the root. */
907
+ folder?: string;
908
+ };
909
+ type BulkMoveResult = {
910
+ files: FileWithUrl[];
911
+ failed: {
912
+ id: string;
913
+ message: string;
914
+ }[];
915
+ };
873
916
  type BulkDeleteResult = {
874
917
  deleted: string[];
875
918
  failed: {
@@ -900,4 +943,4 @@ declare class Vaze extends Base implements IVaze {
900
943
  }>>;
901
944
  }
902
945
 
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 };
946
+ export { type ApiResponse, type BulkDeleteResult, type BulkMoveResult, type FileWithUrl as File, type Folder, type ListOptions, type MoveDestination, type SignOptions, type SignedUrl, type VazeOptions, type Visibility, Vaze as default };
package/dist/index.d.ts CHANGED
@@ -793,6 +793,30 @@ declare class Files extends Base {
793
793
  id: string;
794
794
  visibility: Visibility;
795
795
  }): Promise<ApiResponse<null>>;
796
+ /** Move a file into another folder; its key and URL change with it. */
797
+ move(data: {
798
+ id: string;
799
+ } & MoveDestination): Promise<{
800
+ error: {
801
+ message: string;
802
+ } | null;
803
+ data: {
804
+ file: any;
805
+ } | null;
806
+ }>;
807
+ /** Move several files into one folder; each id reports its own outcome. */
808
+ moveMany(ids: string[], destination: MoveDestination): Promise<{
809
+ error: {
810
+ message: string;
811
+ } | null;
812
+ data: {
813
+ files: any[];
814
+ failed: {
815
+ id: string;
816
+ message: string;
817
+ }[];
818
+ } | null;
819
+ }>;
796
820
  /** Mint a time-limited URL that reads a file without an API key. */
797
821
  sign(options: SignOptions): Promise<{
798
822
  error: {
@@ -838,6 +862,12 @@ declare class Folders extends Base {
838
862
  id: string;
839
863
  name: string;
840
864
  }): Promise<ApiResponse<null>>;
865
+ /** Move a folder, and everything inside it, into another folder. */
866
+ move(data: {
867
+ id: string;
868
+ } & MoveDestination): Promise<ApiResponse<{
869
+ folder: Folder;
870
+ }>>;
841
871
  /** Apply a visibility to every file at or below this folder. */
842
872
  setVisibility(data: {
843
873
  id: string;
@@ -870,6 +900,19 @@ type SignedUrl = {
870
900
  url: string;
871
901
  expiresAt: string;
872
902
  };
903
+ type MoveDestination = {
904
+ /** The destination folder's id. Either this or `folder` is required. */
905
+ folderId?: string;
906
+ /** The destination folder's key, created if missing; `""` is the root. */
907
+ folder?: string;
908
+ };
909
+ type BulkMoveResult = {
910
+ files: FileWithUrl[];
911
+ failed: {
912
+ id: string;
913
+ message: string;
914
+ }[];
915
+ };
873
916
  type BulkDeleteResult = {
874
917
  deleted: string[];
875
918
  failed: {
@@ -900,4 +943,4 @@ declare class Vaze extends Base implements IVaze {
900
943
  }>>;
901
944
  }
902
945
 
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 };
946
+ export { type ApiResponse, type BulkDeleteResult, type BulkMoveResult, type FileWithUrl as File, type Folder, type ListOptions, type MoveDestination, type SignOptions, type SignedUrl, type VazeOptions, type Visibility, Vaze as default };
package/dist/index.js CHANGED
@@ -235,6 +235,37 @@ var Files = class extends Base {
235
235
  async setVisibility(data) {
236
236
  return await this.request("PUT", this.apiUrl("/api/files"), data);
237
237
  }
238
+ /** Move a file into another folder; its key and URL change with it. */
239
+ async move(data) {
240
+ const { data: responseData, error } = await this.request("POST", this.apiUrl("/api/files/move"), data);
241
+ return {
242
+ error,
243
+ data: responseData ? {
244
+ file: constructFileUrls({
245
+ vazeUrl: this.vazeUrl,
246
+ files: [responseData.file]
247
+ })[0]
248
+ } : null
249
+ };
250
+ }
251
+ /** Move several files into one folder; each id reports its own outcome. */
252
+ async moveMany(ids, destination) {
253
+ const { data, error } = await this.request(
254
+ "POST",
255
+ this.apiUrl("/api/files/move"),
256
+ { ids, ...destination }
257
+ );
258
+ return {
259
+ error,
260
+ data: data ? {
261
+ files: constructFileUrls({
262
+ vazeUrl: this.vazeUrl,
263
+ files: data.files
264
+ }),
265
+ failed: data.failed
266
+ } : null
267
+ };
268
+ }
238
269
  /** Mint a time-limited URL that reads a file without an API key. */
239
270
  async sign(options) {
240
271
  const { data, error } = await this.request(
@@ -294,6 +325,14 @@ var Folders = class extends Base {
294
325
  async rename(data) {
295
326
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
296
327
  }
328
+ /** Move a folder, and everything inside it, into another folder. */
329
+ async move(data) {
330
+ return await this.request(
331
+ "POST",
332
+ this.apiUrl("/api/folders/move"),
333
+ data
334
+ );
335
+ }
297
336
  /** Apply a visibility to every file at or below this folder. */
298
337
  async setVisibility(data) {
299
338
  return await this.request("PUT", this.apiUrl("/api/folders"), data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darseen/vaze",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Vaze Self-Hosted file storage and hosting service SDK.",
5
5
  "keywords": [
6
6
  "api",