@darseen/vaze 1.2.1 → 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/README.md +2 -2
- package/dist/index.cjs +37 -1
- package/dist/index.d.cts +66 -7
- package/dist/index.d.ts +66 -7
- package/dist/index.js +37 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ Folders API Access folder-related methods via `vaze.folders`. `get(options?)` Re
|
|
|
132
132
|
|
|
133
133
|
- options (optional):
|
|
134
134
|
- `id`
|
|
135
|
-
- `
|
|
135
|
+
- `key` example: "projects/work"
|
|
136
136
|
- `limit`
|
|
137
137
|
- `offset`
|
|
138
138
|
- `orderBy`
|
|
@@ -140,7 +140,7 @@ Folders API Access folder-related methods via `vaze.folders`. `get(options?)` Re
|
|
|
140
140
|
|
|
141
141
|
```ts
|
|
142
142
|
const { data, error } = await vaze.folders.get({
|
|
143
|
-
|
|
143
|
+
key: "documents/work",
|
|
144
144
|
limit: 20,
|
|
145
145
|
});
|
|
146
146
|
|
package/dist/index.cjs
CHANGED
|
@@ -163,6 +163,22 @@ var Files = class extends Base {
|
|
|
163
163
|
} : null
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
async getByKey(key) {
|
|
167
|
+
const url = this.apiUrl("/api/files", { key });
|
|
168
|
+
const { data, error } = await this.request(
|
|
169
|
+
"GET",
|
|
170
|
+
url
|
|
171
|
+
);
|
|
172
|
+
return {
|
|
173
|
+
error,
|
|
174
|
+
data: data ? {
|
|
175
|
+
file: constructFileUrls({
|
|
176
|
+
vazeUrl: this.vazeUrl,
|
|
177
|
+
files: [data.file]
|
|
178
|
+
})[0]
|
|
179
|
+
} : null
|
|
180
|
+
};
|
|
181
|
+
}
|
|
166
182
|
async getByName(name, options) {
|
|
167
183
|
const url = this.apiUrl("/api/files", { name, ...options });
|
|
168
184
|
const { error, data } = await this.request(
|
|
@@ -180,10 +196,11 @@ var Files = class extends Base {
|
|
|
180
196
|
};
|
|
181
197
|
}
|
|
182
198
|
async upload(data) {
|
|
183
|
-
const { files, folder } = data;
|
|
199
|
+
const { files, folder, visibility } = data;
|
|
184
200
|
const url = this.apiUrl("/api/files");
|
|
185
201
|
const formData = new FormData();
|
|
186
202
|
if (folder) formData.append("folder", folder);
|
|
203
|
+
if (visibility) formData.append("visibility", visibility);
|
|
187
204
|
files.forEach((file) => {
|
|
188
205
|
formData.append("files", file);
|
|
189
206
|
});
|
|
@@ -205,6 +222,21 @@ var Files = class extends Base {
|
|
|
205
222
|
async rename(data) {
|
|
206
223
|
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
207
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
|
+
}
|
|
208
240
|
async delete(id) {
|
|
209
241
|
return await this.request("DELETE", this.apiUrl("/api/files"), {
|
|
210
242
|
id
|
|
@@ -238,6 +270,10 @@ var Folders = class extends Base {
|
|
|
238
270
|
async rename(data) {
|
|
239
271
|
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
240
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
|
+
}
|
|
241
277
|
async delete(id) {
|
|
242
278
|
return await this.request("DELETE", this.apiUrl("/api/folders"), {
|
|
243
279
|
id
|
package/dist/index.d.cts
CHANGED
|
@@ -494,8 +494,8 @@ declare const files: SQLiteTableWithColumns<{
|
|
|
494
494
|
}, {}, {
|
|
495
495
|
length: number | undefined;
|
|
496
496
|
}>;
|
|
497
|
-
|
|
498
|
-
name: "
|
|
497
|
+
key: SQLiteColumn<{
|
|
498
|
+
name: "key";
|
|
499
499
|
tableName: "files";
|
|
500
500
|
dataType: "string";
|
|
501
501
|
columnType: "SQLiteText";
|
|
@@ -513,8 +513,8 @@ declare const files: SQLiteTableWithColumns<{
|
|
|
513
513
|
}, {}, {
|
|
514
514
|
length: number | undefined;
|
|
515
515
|
}>;
|
|
516
|
-
|
|
517
|
-
name: "
|
|
516
|
+
mimeType: SQLiteColumn<{
|
|
517
|
+
name: "mime_type";
|
|
518
518
|
tableName: "files";
|
|
519
519
|
dataType: "string";
|
|
520
520
|
columnType: "SQLiteText";
|
|
@@ -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";
|
|
@@ -653,8 +673,8 @@ declare const folders: SQLiteTableWithColumns<{
|
|
|
653
673
|
}, {}, {
|
|
654
674
|
length: number | undefined;
|
|
655
675
|
}>;
|
|
656
|
-
|
|
657
|
-
name: "
|
|
676
|
+
key: SQLiteColumn<{
|
|
677
|
+
name: "key";
|
|
658
678
|
tableName: "folders";
|
|
659
679
|
dataType: "string";
|
|
660
680
|
columnType: "SQLiteText";
|
|
@@ -726,6 +746,14 @@ declare class Files extends Base {
|
|
|
726
746
|
file: any;
|
|
727
747
|
} | null;
|
|
728
748
|
}>;
|
|
749
|
+
getByKey(key: string): Promise<{
|
|
750
|
+
error: {
|
|
751
|
+
message: string;
|
|
752
|
+
} | null;
|
|
753
|
+
data: {
|
|
754
|
+
file: any;
|
|
755
|
+
} | null;
|
|
756
|
+
}>;
|
|
729
757
|
getByName(name: string, options?: ListOptions): Promise<{
|
|
730
758
|
error: {
|
|
731
759
|
message: string;
|
|
@@ -737,6 +765,7 @@ declare class Files extends Base {
|
|
|
737
765
|
upload(data: {
|
|
738
766
|
files: File[];
|
|
739
767
|
folder?: string;
|
|
768
|
+
visibility?: Visibility;
|
|
740
769
|
}): Promise<{
|
|
741
770
|
error: {
|
|
742
771
|
message: string;
|
|
@@ -754,12 +783,27 @@ declare class Files extends Base {
|
|
|
754
783
|
id: string;
|
|
755
784
|
name: string;
|
|
756
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
|
+
}>;
|
|
757
800
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
758
801
|
}
|
|
759
802
|
|
|
760
803
|
declare class Folders extends Base {
|
|
761
804
|
get(options?: ListOptions & {
|
|
762
805
|
id?: string;
|
|
806
|
+
key?: string;
|
|
763
807
|
path?: string;
|
|
764
808
|
}): Promise<{
|
|
765
809
|
error: {
|
|
@@ -777,6 +821,11 @@ declare class Folders extends Base {
|
|
|
777
821
|
id: string;
|
|
778
822
|
name: string;
|
|
779
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>>;
|
|
780
829
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
781
830
|
}
|
|
782
831
|
|
|
@@ -794,6 +843,16 @@ type ListOptions = {
|
|
|
794
843
|
orderBy?: "createdAt" | "updatedAt" | "name" | "size";
|
|
795
844
|
orderDirection?: "ASC" | "DESC";
|
|
796
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
|
+
};
|
|
797
856
|
|
|
798
857
|
declare class Base {
|
|
799
858
|
private apiKey;
|
|
@@ -817,4 +876,4 @@ declare class Vaze extends Base implements IVaze {
|
|
|
817
876
|
}>>;
|
|
818
877
|
}
|
|
819
878
|
|
|
820
|
-
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
|
@@ -494,8 +494,8 @@ declare const files: SQLiteTableWithColumns<{
|
|
|
494
494
|
}, {}, {
|
|
495
495
|
length: number | undefined;
|
|
496
496
|
}>;
|
|
497
|
-
|
|
498
|
-
name: "
|
|
497
|
+
key: SQLiteColumn<{
|
|
498
|
+
name: "key";
|
|
499
499
|
tableName: "files";
|
|
500
500
|
dataType: "string";
|
|
501
501
|
columnType: "SQLiteText";
|
|
@@ -513,8 +513,8 @@ declare const files: SQLiteTableWithColumns<{
|
|
|
513
513
|
}, {}, {
|
|
514
514
|
length: number | undefined;
|
|
515
515
|
}>;
|
|
516
|
-
|
|
517
|
-
name: "
|
|
516
|
+
mimeType: SQLiteColumn<{
|
|
517
|
+
name: "mime_type";
|
|
518
518
|
tableName: "files";
|
|
519
519
|
dataType: "string";
|
|
520
520
|
columnType: "SQLiteText";
|
|
@@ -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";
|
|
@@ -653,8 +673,8 @@ declare const folders: SQLiteTableWithColumns<{
|
|
|
653
673
|
}, {}, {
|
|
654
674
|
length: number | undefined;
|
|
655
675
|
}>;
|
|
656
|
-
|
|
657
|
-
name: "
|
|
676
|
+
key: SQLiteColumn<{
|
|
677
|
+
name: "key";
|
|
658
678
|
tableName: "folders";
|
|
659
679
|
dataType: "string";
|
|
660
680
|
columnType: "SQLiteText";
|
|
@@ -726,6 +746,14 @@ declare class Files extends Base {
|
|
|
726
746
|
file: any;
|
|
727
747
|
} | null;
|
|
728
748
|
}>;
|
|
749
|
+
getByKey(key: string): Promise<{
|
|
750
|
+
error: {
|
|
751
|
+
message: string;
|
|
752
|
+
} | null;
|
|
753
|
+
data: {
|
|
754
|
+
file: any;
|
|
755
|
+
} | null;
|
|
756
|
+
}>;
|
|
729
757
|
getByName(name: string, options?: ListOptions): Promise<{
|
|
730
758
|
error: {
|
|
731
759
|
message: string;
|
|
@@ -737,6 +765,7 @@ declare class Files extends Base {
|
|
|
737
765
|
upload(data: {
|
|
738
766
|
files: File[];
|
|
739
767
|
folder?: string;
|
|
768
|
+
visibility?: Visibility;
|
|
740
769
|
}): Promise<{
|
|
741
770
|
error: {
|
|
742
771
|
message: string;
|
|
@@ -754,12 +783,27 @@ declare class Files extends Base {
|
|
|
754
783
|
id: string;
|
|
755
784
|
name: string;
|
|
756
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
|
+
}>;
|
|
757
800
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
758
801
|
}
|
|
759
802
|
|
|
760
803
|
declare class Folders extends Base {
|
|
761
804
|
get(options?: ListOptions & {
|
|
762
805
|
id?: string;
|
|
806
|
+
key?: string;
|
|
763
807
|
path?: string;
|
|
764
808
|
}): Promise<{
|
|
765
809
|
error: {
|
|
@@ -777,6 +821,11 @@ declare class Folders extends Base {
|
|
|
777
821
|
id: string;
|
|
778
822
|
name: string;
|
|
779
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>>;
|
|
780
829
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
781
830
|
}
|
|
782
831
|
|
|
@@ -794,6 +843,16 @@ type ListOptions = {
|
|
|
794
843
|
orderBy?: "createdAt" | "updatedAt" | "name" | "size";
|
|
795
844
|
orderDirection?: "ASC" | "DESC";
|
|
796
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
|
+
};
|
|
797
856
|
|
|
798
857
|
declare class Base {
|
|
799
858
|
private apiKey;
|
|
@@ -817,4 +876,4 @@ declare class Vaze extends Base implements IVaze {
|
|
|
817
876
|
}>>;
|
|
818
877
|
}
|
|
819
878
|
|
|
820
|
-
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
|
@@ -163,6 +163,22 @@ var Files = class extends Base {
|
|
|
163
163
|
} : null
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
async getByKey(key) {
|
|
167
|
+
const url = this.apiUrl("/api/files", { key });
|
|
168
|
+
const { data, error } = await this.request(
|
|
169
|
+
"GET",
|
|
170
|
+
url
|
|
171
|
+
);
|
|
172
|
+
return {
|
|
173
|
+
error,
|
|
174
|
+
data: data ? {
|
|
175
|
+
file: constructFileUrls({
|
|
176
|
+
vazeUrl: this.vazeUrl,
|
|
177
|
+
files: [data.file]
|
|
178
|
+
})[0]
|
|
179
|
+
} : null
|
|
180
|
+
};
|
|
181
|
+
}
|
|
166
182
|
async getByName(name, options) {
|
|
167
183
|
const url = this.apiUrl("/api/files", { name, ...options });
|
|
168
184
|
const { error, data } = await this.request(
|
|
@@ -180,10 +196,11 @@ var Files = class extends Base {
|
|
|
180
196
|
};
|
|
181
197
|
}
|
|
182
198
|
async upload(data) {
|
|
183
|
-
const { files, folder } = data;
|
|
199
|
+
const { files, folder, visibility } = data;
|
|
184
200
|
const url = this.apiUrl("/api/files");
|
|
185
201
|
const formData = new FormData();
|
|
186
202
|
if (folder) formData.append("folder", folder);
|
|
203
|
+
if (visibility) formData.append("visibility", visibility);
|
|
187
204
|
files.forEach((file) => {
|
|
188
205
|
formData.append("files", file);
|
|
189
206
|
});
|
|
@@ -205,6 +222,21 @@ var Files = class extends Base {
|
|
|
205
222
|
async rename(data) {
|
|
206
223
|
return await this.request("PUT", this.apiUrl("/api/files"), data);
|
|
207
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
|
+
}
|
|
208
240
|
async delete(id) {
|
|
209
241
|
return await this.request("DELETE", this.apiUrl("/api/files"), {
|
|
210
242
|
id
|
|
@@ -238,6 +270,10 @@ var Folders = class extends Base {
|
|
|
238
270
|
async rename(data) {
|
|
239
271
|
return await this.request("PUT", this.apiUrl("/api/folders"), data);
|
|
240
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
|
+
}
|
|
241
277
|
async delete(id) {
|
|
242
278
|
return await this.request("DELETE", this.apiUrl("/api/folders"), {
|
|
243
279
|
id
|