@darseen/vaze 2.3.0 → 2.5.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.d.ts CHANGED
@@ -414,6 +414,360 @@ declare abstract class Column<T extends ColumnBaseConfig<ColumnDataType, string>
414
414
  type AnyColumn<TPartial extends Partial<ColumnBaseConfig<ColumnDataType, string>> = {}> = Column<Required<Update<ColumnBaseConfig<ColumnDataType, string>, TPartial>>>;
415
415
  type GetColumnData<TColumn extends Column, TInferMode extends 'query' | 'raw' = 'query'> = TInferMode extends 'raw' ? TColumn['_']['data'] : TColumn['_']['notNull'] extends true ? TColumn['_']['data'] : TColumn['_']['data'] | null;
416
416
 
417
+ declare const activities: SQLiteTableWithColumns<{
418
+ name: "activities";
419
+ schema: undefined;
420
+ columns: {
421
+ id: SQLiteColumn<{
422
+ name: "id";
423
+ tableName: "activities";
424
+ dataType: "string";
425
+ columnType: "SQLiteText";
426
+ data: string;
427
+ driverParam: string;
428
+ notNull: true;
429
+ hasDefault: false;
430
+ isPrimaryKey: true;
431
+ isAutoincrement: false;
432
+ hasRuntimeDefault: false;
433
+ enumValues: [string, ...string[]];
434
+ baseColumn: never;
435
+ identity: undefined;
436
+ generated: undefined;
437
+ }, {}, {
438
+ length: number | undefined;
439
+ }>;
440
+ userId: SQLiteColumn<{
441
+ name: "user_id";
442
+ tableName: "activities";
443
+ dataType: "string";
444
+ columnType: "SQLiteText";
445
+ data: string;
446
+ driverParam: string;
447
+ notNull: true;
448
+ hasDefault: false;
449
+ isPrimaryKey: false;
450
+ isAutoincrement: false;
451
+ hasRuntimeDefault: false;
452
+ enumValues: [string, ...string[]];
453
+ baseColumn: never;
454
+ identity: undefined;
455
+ generated: undefined;
456
+ }, {}, {
457
+ length: number | undefined;
458
+ }>;
459
+ type: SQLiteColumn<{
460
+ name: "type";
461
+ tableName: "activities";
462
+ dataType: "string";
463
+ columnType: "SQLiteText";
464
+ data: "upload.succeeded" | "upload.failed" | "upload.canceled" | "file.deleted" | "file.delete-failed" | "folder.deleted" | "folder.delete-failed" | "api-key.created" | "api-key.renamed" | "api-key.deleted" | "user.created" | "user.access-changed" | "user.password-reset" | "user.disabled" | "user.enabled" | "user.deleted";
465
+ driverParam: string;
466
+ notNull: true;
467
+ hasDefault: false;
468
+ isPrimaryKey: false;
469
+ isAutoincrement: false;
470
+ hasRuntimeDefault: false;
471
+ enumValues: ["upload.succeeded", "upload.failed", "upload.canceled", "file.deleted", "file.delete-failed", "folder.deleted", "folder.delete-failed", "api-key.created", "api-key.renamed", "api-key.deleted", "user.created", "user.access-changed", "user.password-reset", "user.disabled", "user.enabled", "user.deleted"];
472
+ baseColumn: never;
473
+ identity: undefined;
474
+ generated: undefined;
475
+ }, {}, {
476
+ length: number | undefined;
477
+ }>;
478
+ target: SQLiteColumn<{
479
+ name: "target";
480
+ tableName: "activities";
481
+ dataType: "string";
482
+ columnType: "SQLiteText";
483
+ data: string;
484
+ driverParam: string;
485
+ notNull: false;
486
+ hasDefault: false;
487
+ isPrimaryKey: false;
488
+ isAutoincrement: false;
489
+ hasRuntimeDefault: false;
490
+ enumValues: [string, ...string[]];
491
+ baseColumn: never;
492
+ identity: undefined;
493
+ generated: undefined;
494
+ }, {}, {
495
+ length: number | undefined;
496
+ }>;
497
+ detail: SQLiteColumn<{
498
+ name: "detail";
499
+ tableName: "activities";
500
+ dataType: "string";
501
+ columnType: "SQLiteText";
502
+ data: string;
503
+ driverParam: string;
504
+ notNull: false;
505
+ hasDefault: false;
506
+ isPrimaryKey: false;
507
+ isAutoincrement: false;
508
+ hasRuntimeDefault: false;
509
+ enumValues: [string, ...string[]];
510
+ baseColumn: never;
511
+ identity: undefined;
512
+ generated: undefined;
513
+ }, {}, {
514
+ length: number | undefined;
515
+ }>;
516
+ createdAt: SQLiteColumn<{
517
+ name: "created_at";
518
+ tableName: "activities";
519
+ dataType: "string";
520
+ columnType: "SQLiteText";
521
+ data: string;
522
+ driverParam: string;
523
+ notNull: true;
524
+ hasDefault: true;
525
+ isPrimaryKey: false;
526
+ isAutoincrement: false;
527
+ hasRuntimeDefault: false;
528
+ enumValues: [string, ...string[]];
529
+ baseColumn: never;
530
+ identity: undefined;
531
+ generated: undefined;
532
+ }, {}, {
533
+ length: number | undefined;
534
+ }>;
535
+ };
536
+ dialect: "sqlite";
537
+ }>;
538
+ type Activity$1 = InferSelectModel<typeof activities>;
539
+ type ActivityType = Activity$1["type"];
540
+
541
+ declare const SCOPES: readonly ["files:read", "files:write", "files:delete", "api-keys:manage", "settings:manage", "users:manage"];
542
+ declare const users: SQLiteTableWithColumns<{
543
+ name: "users";
544
+ schema: undefined;
545
+ columns: {
546
+ id: SQLiteColumn<{
547
+ name: "id";
548
+ tableName: "users";
549
+ dataType: "string";
550
+ columnType: "SQLiteText";
551
+ data: string;
552
+ driverParam: string;
553
+ notNull: true;
554
+ hasDefault: false;
555
+ isPrimaryKey: true;
556
+ isAutoincrement: false;
557
+ hasRuntimeDefault: false;
558
+ enumValues: [string, ...string[]];
559
+ baseColumn: never;
560
+ identity: undefined;
561
+ generated: undefined;
562
+ }, {}, {
563
+ length: number | undefined;
564
+ }>;
565
+ name: SQLiteColumn<{
566
+ name: "name";
567
+ tableName: "users";
568
+ dataType: "string";
569
+ columnType: "SQLiteText";
570
+ data: string;
571
+ driverParam: string;
572
+ notNull: true;
573
+ hasDefault: false;
574
+ isPrimaryKey: false;
575
+ isAutoincrement: false;
576
+ hasRuntimeDefault: false;
577
+ enumValues: [string, ...string[]];
578
+ baseColumn: never;
579
+ identity: undefined;
580
+ generated: undefined;
581
+ }, {}, {
582
+ length: number | undefined;
583
+ }>;
584
+ email: SQLiteColumn<{
585
+ name: "email";
586
+ tableName: "users";
587
+ dataType: "string";
588
+ columnType: "SQLiteText";
589
+ data: string;
590
+ driverParam: string;
591
+ notNull: true;
592
+ hasDefault: false;
593
+ isPrimaryKey: false;
594
+ isAutoincrement: false;
595
+ hasRuntimeDefault: false;
596
+ enumValues: [string, ...string[]];
597
+ baseColumn: never;
598
+ identity: undefined;
599
+ generated: undefined;
600
+ }, {}, {
601
+ length: number | undefined;
602
+ }>;
603
+ emailVerified: SQLiteColumn<{
604
+ name: "email_verified";
605
+ tableName: "users";
606
+ dataType: "boolean";
607
+ columnType: "SQLiteBoolean";
608
+ data: boolean;
609
+ driverParam: number;
610
+ notNull: true;
611
+ hasDefault: true;
612
+ isPrimaryKey: false;
613
+ isAutoincrement: false;
614
+ hasRuntimeDefault: false;
615
+ enumValues: undefined;
616
+ baseColumn: never;
617
+ identity: undefined;
618
+ generated: undefined;
619
+ }, {}, {}>;
620
+ image: SQLiteColumn<{
621
+ name: "image";
622
+ tableName: "users";
623
+ dataType: "string";
624
+ columnType: "SQLiteText";
625
+ data: string;
626
+ driverParam: string;
627
+ notNull: false;
628
+ hasDefault: false;
629
+ isPrimaryKey: false;
630
+ isAutoincrement: false;
631
+ hasRuntimeDefault: false;
632
+ enumValues: [string, ...string[]];
633
+ baseColumn: never;
634
+ identity: undefined;
635
+ generated: undefined;
636
+ }, {}, {
637
+ length: number | undefined;
638
+ }>;
639
+ role: SQLiteColumn<{
640
+ name: "role";
641
+ tableName: "users";
642
+ dataType: "string";
643
+ columnType: "SQLiteText";
644
+ data: "custom" | "admin" | "editor" | "viewer";
645
+ driverParam: string;
646
+ notNull: true;
647
+ hasDefault: true;
648
+ isPrimaryKey: false;
649
+ isAutoincrement: false;
650
+ hasRuntimeDefault: false;
651
+ enumValues: ["admin", "editor", "viewer", "custom"];
652
+ baseColumn: never;
653
+ identity: undefined;
654
+ generated: undefined;
655
+ }, {}, {
656
+ length: number | undefined;
657
+ }>;
658
+ scopes: SQLiteColumn<{
659
+ name: "scopes";
660
+ tableName: "users";
661
+ dataType: "string";
662
+ columnType: "SQLiteText";
663
+ data: string;
664
+ driverParam: string;
665
+ notNull: false;
666
+ hasDefault: false;
667
+ isPrimaryKey: false;
668
+ isAutoincrement: false;
669
+ hasRuntimeDefault: false;
670
+ enumValues: [string, ...string[]];
671
+ baseColumn: never;
672
+ identity: undefined;
673
+ generated: undefined;
674
+ }, {}, {
675
+ length: number | undefined;
676
+ }>;
677
+ banned: SQLiteColumn<{
678
+ name: "banned";
679
+ tableName: "users";
680
+ dataType: "boolean";
681
+ columnType: "SQLiteBoolean";
682
+ data: boolean;
683
+ driverParam: number;
684
+ notNull: true;
685
+ hasDefault: true;
686
+ isPrimaryKey: false;
687
+ isAutoincrement: false;
688
+ hasRuntimeDefault: false;
689
+ enumValues: undefined;
690
+ baseColumn: never;
691
+ identity: undefined;
692
+ generated: undefined;
693
+ }, {}, {}>;
694
+ banReason: SQLiteColumn<{
695
+ name: "ban_reason";
696
+ tableName: "users";
697
+ dataType: "string";
698
+ columnType: "SQLiteText";
699
+ data: string;
700
+ driverParam: string;
701
+ notNull: false;
702
+ hasDefault: false;
703
+ isPrimaryKey: false;
704
+ isAutoincrement: false;
705
+ hasRuntimeDefault: false;
706
+ enumValues: [string, ...string[]];
707
+ baseColumn: never;
708
+ identity: undefined;
709
+ generated: undefined;
710
+ }, {}, {
711
+ length: number | undefined;
712
+ }>;
713
+ banExpires: SQLiteColumn<{
714
+ name: "ban_expires";
715
+ tableName: "users";
716
+ dataType: "date";
717
+ columnType: "SQLiteTimestamp";
718
+ data: Date;
719
+ driverParam: number;
720
+ notNull: false;
721
+ hasDefault: false;
722
+ isPrimaryKey: false;
723
+ isAutoincrement: false;
724
+ hasRuntimeDefault: false;
725
+ enumValues: undefined;
726
+ baseColumn: never;
727
+ identity: undefined;
728
+ generated: undefined;
729
+ }, {}, {}>;
730
+ createdAt: SQLiteColumn<{
731
+ name: "created_at";
732
+ tableName: "users";
733
+ dataType: "date";
734
+ columnType: "SQLiteTimestamp";
735
+ data: Date;
736
+ driverParam: number;
737
+ notNull: true;
738
+ hasDefault: true;
739
+ isPrimaryKey: false;
740
+ isAutoincrement: false;
741
+ hasRuntimeDefault: false;
742
+ enumValues: undefined;
743
+ baseColumn: never;
744
+ identity: undefined;
745
+ generated: undefined;
746
+ }, {}, {}>;
747
+ updatedAt: SQLiteColumn<{
748
+ name: "updated_at";
749
+ tableName: "users";
750
+ dataType: "date";
751
+ columnType: "SQLiteTimestamp";
752
+ data: Date;
753
+ driverParam: number;
754
+ notNull: true;
755
+ hasDefault: true;
756
+ isPrimaryKey: false;
757
+ isAutoincrement: false;
758
+ hasRuntimeDefault: false;
759
+ enumValues: undefined;
760
+ baseColumn: never;
761
+ identity: undefined;
762
+ generated: undefined;
763
+ }, {}, {}>;
764
+ };
765
+ dialect: "sqlite";
766
+ }>;
767
+ type User = InferSelectModel<typeof users>;
768
+ type Role = User["role"];
769
+ type Scope = (typeof SCOPES)[number];
770
+
417
771
  declare const files: SQLiteTableWithColumns<{
418
772
  name: "files";
419
773
  schema: undefined;
@@ -721,18 +1075,123 @@ type ApiResponse<T> = {
721
1075
  error: null;
722
1076
  } | {
723
1077
  data: null;
1078
+ /** `status` is the HTTP status, absent when no response arrived. */
724
1079
  error: {
725
1080
  message: string;
1081
+ status?: number;
726
1082
  };
727
1083
  };
728
1084
  type FileWithUrl = File$1 & {
729
1085
  url: string;
730
1086
  };
1087
+ type Me = {
1088
+ user: Pick<User, "id" | "name" | "email" | "image" | "role">;
1089
+ /** What this caller may do; an API key is capped by its own scopes. */
1090
+ scopes: Scope[];
1091
+ };
1092
+ /** An API key as its owner sees it; the secret itself is never stored. */
1093
+ type ApiKeySummary = {
1094
+ id: string;
1095
+ name: string;
1096
+ /** Capped by the owner's current role on every request. */
1097
+ scopes: Scope[];
1098
+ createdAt: string;
1099
+ lastUsed: string | null;
1100
+ expiresAt: string | null;
1101
+ };
1102
+ /** A key just created, with the secret that is only returned this once. */
1103
+ type CreatedApiKey = ApiKeySummary & {
1104
+ key: string;
1105
+ };
1106
+ /** One row of the caller's activity history. */
1107
+ type ActivityEntry = Pick<Activity$1, "id" | "type" | "target" | "detail" | "createdAt">;
1108
+ /** A device signed in to the caller's account. */
1109
+ type SessionSummary = {
1110
+ id: string;
1111
+ ipAddress: string | null;
1112
+ userAgent: string | null;
1113
+ createdAt: string;
1114
+ /** The session making this request. */
1115
+ current: boolean;
1116
+ };
1117
+ /** An account as an admin sees it. */
1118
+ type UserSummary = {
1119
+ id: string;
1120
+ name: string;
1121
+ email: string;
1122
+ role: Role;
1123
+ /** What the account can actually do. */
1124
+ scopes: Scope[];
1125
+ /** The picks saved for the custom role, kept to prefill an editor. */
1126
+ customScopes: Scope[];
1127
+ disabled: boolean;
1128
+ apiKeys: number;
1129
+ createdAt: string;
1130
+ };
1131
+ /** Byte, second and day limits an admin can change at runtime. */
1132
+ type Limits = {
1133
+ maxUploadSize: number;
1134
+ defaultPresignTtl: number;
1135
+ maxPresignTtl: number;
1136
+ hostingCacheMaxAge: number;
1137
+ activityRetentionDays: number;
1138
+ apiRequestRetentionDays: number;
1139
+ };
1140
+ type InstanceSettings = {
1141
+ /** Applied to uploads and new folders that don't ask for one. */
1142
+ defaultVisibility: Visibility;
1143
+ /** How many existing files are public and private. */
1144
+ visibilityCounts: Record<Visibility, number>;
1145
+ limits: Limits;
1146
+ };
1147
+ type Stats = {
1148
+ /** Present when the caller holds `files:read`. */
1149
+ files: {
1150
+ total: number;
1151
+ folders: number;
1152
+ storage: {
1153
+ used: number;
1154
+ available: number;
1155
+ };
1156
+ types: {
1157
+ mimeType: string;
1158
+ size: number;
1159
+ count: number;
1160
+ }[];
1161
+ largest: FileWithUrl[];
1162
+ recent: FileWithUrl[];
1163
+ } | null;
1164
+ /** Present for signed-in users holding `api-keys:manage`. */
1165
+ apiKeys: {
1166
+ total: number;
1167
+ /** The last seven UTC days, oldest first. */
1168
+ requests: {
1169
+ date: string;
1170
+ count: number;
1171
+ }[];
1172
+ } | null;
1173
+ };
1174
+
1175
+ /** The caller's activity history. These calls need a session, not a key. */
1176
+ declare class Activity extends Base {
1177
+ /** The most recent entries, newest first. */
1178
+ getAll(): Promise<ApiResponse<{
1179
+ activities: ActivityEntry[];
1180
+ }>>;
1181
+ delete(ids: string[]): Promise<ApiResponse<{
1182
+ deleted: number;
1183
+ }>>;
1184
+ /** Deletes every entry. Files, keys and accounts are not affected. */
1185
+ clear(): Promise<ApiResponse<{
1186
+ deleted: number;
1187
+ }>>;
1188
+ }
731
1189
 
732
1190
  declare class Files extends Base {
733
1191
  getAll(options?: ListOptions): Promise<{
734
1192
  error: {
735
1193
  message: string;
1194
+ status?: number;
736
1195
  } | null;
737
1196
  data: {
738
1197
  files: any[];
@@ -741,6 +1200,7 @@ declare class Files extends Base {
741
1200
  getById(id: string): Promise<{
742
1201
  error: {
743
1202
  message: string;
1203
+ status?: number;
744
1204
  } | null;
745
1205
  data: {
746
1206
  file: any;
@@ -749,6 +1209,7 @@ declare class Files extends Base {
749
1209
  getByKey(key: string): Promise<{
750
1210
  error: {
751
1211
  message: string;
1212
+ status?: number;
752
1213
  } | null;
753
1214
  data: {
754
1215
  file: any;
@@ -757,34 +1218,46 @@ declare class Files extends Base {
757
1218
  getByName(name: string, options?: ListOptions): Promise<{
758
1219
  error: {
759
1220
  message: string;
1221
+ status?: number;
760
1222
  } | null;
761
1223
  data: {
762
1224
  files: any[];
763
1225
  } | null;
764
1226
  }>;
765
1227
  upload(data: {
766
- files: File[];
1228
+ files: (File | FileReference)[];
767
1229
  folder?: string;
768
1230
  visibility?: Visibility;
769
1231
  }): Promise<{
770
1232
  error: {
771
1233
  message: string;
1234
+ status?: number;
772
1235
  } | null;
773
1236
  data: {
774
1237
  files: any[];
775
1238
  } | null;
776
1239
  }>;
1240
+ /** Where `upload` posts its form, for upload managers that report progress. */
1241
+ uploadUrl(): string;
1242
+ /** Record uploads canceled before they were sent, in the activity history. */
1243
+ reportCanceled(names: string[]): Promise<ApiResponse<null>>;
777
1244
  download(id: string): Promise<ApiResponse<{
778
1245
  blob: Blob;
779
1246
  filename: string | null;
780
1247
  contentType: string;
781
1248
  }>>;
1249
+ /** Where `download` reads from; fetch it yourself with `authHeaders()`. */
1250
+ downloadUrl(id: string): string;
1251
+ /** A WebP thumbnail of an image file; fetch it with `authHeaders()`. */
1252
+ thumbnailUrl(id: string): string;
782
1253
  /** Download several files as one zip, with paths below their shared folder. */
783
1254
  downloadMany(ids: string[]): Promise<ApiResponse<{
784
1255
  blob: Blob;
785
1256
  filename: string | null;
786
1257
  contentType: string;
787
1258
  }>>;
1259
+ /** Where `downloadMany` posts `{ ids }`; stream it yourself with `authHeaders()`. */
1260
+ downloadManyUrl(): string;
788
1261
  rename(data: {
789
1262
  id: string;
790
1263
  name: string;
@@ -799,6 +1272,7 @@ declare class Files extends Base {
799
1272
  } & MoveDestination): Promise<{
800
1273
  error: {
801
1274
  message: string;
1275
+ status?: number;
802
1276
  } | null;
803
1277
  data: {
804
1278
  file: any;
@@ -808,6 +1282,7 @@ declare class Files extends Base {
808
1282
  moveMany(ids: string[], destination: MoveDestination): Promise<{
809
1283
  error: {
810
1284
  message: string;
1285
+ status?: number;
811
1286
  } | null;
812
1287
  data: {
813
1288
  files: any[];
@@ -821,6 +1296,7 @@ declare class Files extends Base {
821
1296
  sign(options: SignOptions): Promise<{
822
1297
  error: {
823
1298
  message: string;
1299
+ status?: number;
824
1300
  } | null;
825
1301
  data: {
826
1302
  url: string;
@@ -840,6 +1316,7 @@ declare class Folders extends Base {
840
1316
  }): Promise<{
841
1317
  error: {
842
1318
  message: string;
1319
+ status?: number;
843
1320
  } | null;
844
1321
  data: {
845
1322
  files: any[];
@@ -855,6 +1332,11 @@ declare class Folders extends Base {
855
1332
  filename: string | null;
856
1333
  contentType: string;
857
1334
  }>>;
1335
+ /** Where `download` reads from; fetch it yourself with `authHeaders()`. */
1336
+ downloadUrl(options?: {
1337
+ id?: string;
1338
+ key?: string;
1339
+ }): string;
858
1340
  create(folder: string): Promise<ApiResponse<{
859
1341
  folder: Folder;
860
1342
  }>>;
@@ -876,13 +1358,94 @@ declare class Folders extends Base {
876
1358
  delete(id: string): Promise<ApiResponse<null>>;
877
1359
  }
878
1360
 
1361
+ /** The caller's API keys. These calls need a signed-in session, not a key. */
1362
+ declare class Keys extends Base {
1363
+ /** Every key the caller owns, newest first. */
1364
+ getAll(): Promise<ApiResponse<{
1365
+ keys: ApiKeySummary[];
1366
+ }>>;
1367
+ /** The response holds the key's secret, which can't be read again later. */
1368
+ create({ name, scopes, expiresAt }: NewKeyOptions): Promise<ApiResponse<{
1369
+ key: CreatedApiKey;
1370
+ }>>;
1371
+ rename(data: {
1372
+ id: string;
1373
+ name: string;
1374
+ }): Promise<ApiResponse<null>>;
1375
+ /** Revokes the key at once for anything using it. */
1376
+ delete(id: string): Promise<ApiResponse<null>>;
1377
+ }
1378
+
1379
+ /** Instance-wide settings. These calls need an admin's session. */
1380
+ declare class Settings extends Base {
1381
+ get(): Promise<ApiResponse<InstanceSettings>>;
1382
+ /** Limits left out keep their current values. */
1383
+ update(changes: SettingsChanges): Promise<ApiResponse<InstanceSettings>>;
1384
+ /** Gives every existing file this visibility. */
1385
+ applyVisibility(visibility: Visibility): Promise<ApiResponse<{
1386
+ updated: number;
1387
+ }>>;
1388
+ }
1389
+
1390
+ /** Accounts on the instance. These calls need an admin's session. */
1391
+ declare class Users extends Base {
1392
+ /** Every account, oldest first. */
1393
+ getAll(): Promise<ApiResponse<{
1394
+ users: UserSummary[];
1395
+ }>>;
1396
+ create(options: NewUserOptions): Promise<ApiResponse<{
1397
+ user: UserSummary;
1398
+ }>>;
1399
+ /** Applies right away, to the user's sessions and API keys alike. */
1400
+ setAccess({ id, role, scopes, }: UserAccess & {
1401
+ id: string;
1402
+ }): Promise<ApiResponse<{
1403
+ user: UserSummary;
1404
+ }>>;
1405
+ /** Also signs the user out of every device. */
1406
+ resetPassword({ id, password, }: {
1407
+ id: string;
1408
+ password: string;
1409
+ }): Promise<ApiResponse<{
1410
+ user: UserSummary;
1411
+ }>>;
1412
+ /** A disabled user is signed out and their API keys stop until re-enabled. */
1413
+ setDisabled({ id, disabled, }: {
1414
+ id: string;
1415
+ disabled: boolean;
1416
+ }): Promise<ApiResponse<{
1417
+ user: UserSummary;
1418
+ }>>;
1419
+ /** Removes the account, its API keys and its history. Files stay. */
1420
+ delete(id: string): Promise<ApiResponse<null>>;
1421
+ }
1422
+
879
1423
  interface IVaze {
880
1424
  files: Files;
881
1425
  folders: Folders;
1426
+ keys: Keys;
1427
+ account: Account;
1428
+ activity: Activity;
1429
+ users: Users;
1430
+ settings: Settings;
882
1431
  }
1432
+ type VazeHeaders = Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
883
1433
  type VazeOptions = {
884
1434
  apiKey?: string;
885
1435
  vazeUrl?: string;
1436
+ /**
1437
+ * Headers sent with every request, such as a Better Auth session cookie.
1438
+ * A function is called before each request. Replaces the need for `apiKey`.
1439
+ */
1440
+ headers?: VazeHeaders;
1441
+ /** Replaces the global `fetch`, e.g. to set `credentials` or a timeout. */
1442
+ fetch?: typeof fetch;
1443
+ };
1444
+ /** A file on disk in React Native, which streams it from `uri` on upload. */
1445
+ type FileReference = {
1446
+ uri: string;
1447
+ name: string;
1448
+ type: string;
886
1449
  };
887
1450
  type ListOptions = {
888
1451
  limit?: number;
@@ -913,6 +1476,40 @@ type BulkMoveResult = {
913
1476
  message: string;
914
1477
  }[];
915
1478
  };
1479
+ type NewKeyOptions = {
1480
+ name: string;
1481
+ /** Only `files:read`, `files:write` and `files:delete`, and only ones the caller holds. */
1482
+ scopes: Scope[];
1483
+ /** Leave it out, or pass `null`, for a key that never expires. */
1484
+ expiresAt?: Date | string | null;
1485
+ };
1486
+ type ProfileChanges = {
1487
+ name?: string;
1488
+ /** The new sign-in email; it applies right away. */
1489
+ email?: string;
1490
+ };
1491
+ type PasswordChange = {
1492
+ currentPassword: string;
1493
+ /** At least 8 characters. */
1494
+ newPassword: string;
1495
+ /** Signs out every other device too. */
1496
+ revokeOtherSessions?: boolean;
1497
+ };
1498
+ type UserAccess = {
1499
+ role: Role;
1500
+ /** Only read for the `custom` role, which needs at least one. `users:manage` can't be picked. */
1501
+ scopes?: Scope[];
1502
+ };
1503
+ type NewUserOptions = UserAccess & {
1504
+ name: string;
1505
+ email: string;
1506
+ /** At least 8 characters. */
1507
+ password: string;
1508
+ };
1509
+ type SettingsChanges = {
1510
+ defaultVisibility?: Visibility;
1511
+ limits?: Partial<Limits>;
1512
+ };
916
1513
  type BulkDeleteResult = {
917
1514
  deleted: string[];
918
1515
  failed: {
@@ -923,9 +1520,13 @@ type BulkDeleteResult = {
923
1520
 
924
1521
  declare class Base {
925
1522
  private apiKey;
1523
+ private headers;
1524
+ private fetch;
926
1525
  protected vazeUrl: string;
927
1526
  constructor(options?: VazeOptions);
928
1527
  protected apiUrl(path: string, params?: Record<string, string | number | undefined>): string;
1528
+ /** The headers every request carries, for clients fetching an SDK URL themselves. */
1529
+ authHeaders(): Promise<Record<string, string>>;
929
1530
  protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
930
1531
  protected requestBlob(url: string, method?: string, body?: Record<string, any>): Promise<ApiResponse<{
931
1532
  blob: Blob;
@@ -934,13 +1535,70 @@ declare class Base {
934
1535
  }>>;
935
1536
  }
936
1537
 
1538
+ /** The signed-in user's own account. These calls need a session, not a key. */
1539
+ declare class Account extends Base {
1540
+ /** Changes the display name, the sign-in email, or both. */
1541
+ update(changes: ProfileChanges): Promise<ApiResponse<Me>>;
1542
+ changePassword({ currentPassword, newPassword, revokeOtherSessions, }: PasswordChange): Promise<ApiResponse<null>>;
1543
+ /** Every device signed in to the account, the current one first. */
1544
+ getSessions(): Promise<ApiResponse<{
1545
+ sessions: SessionSummary[];
1546
+ }>>;
1547
+ /** Signs out another device. The current session ends with a sign-out instead. */
1548
+ revokeSession(id: string): Promise<ApiResponse<null>>;
1549
+ /** Signs out every device but the current one. */
1550
+ revokeOtherSessions(): Promise<ApiResponse<null>>;
1551
+ }
1552
+
937
1553
  declare class Vaze extends Base implements IVaze {
938
1554
  files: Files;
939
1555
  folders: Folders;
1556
+ keys: Keys;
1557
+ account: Account;
1558
+ activity: Activity;
1559
+ users: Users;
1560
+ settings: Settings;
940
1561
  constructor(options?: VazeOptions);
941
1562
  health(): Promise<ApiResponse<{
942
1563
  message: string;
943
1564
  }>>;
1565
+ /** Whether the instance still needs its first account, which becomes the admin. */
1566
+ setupStatus(): Promise<ApiResponse<{
1567
+ needed: boolean;
1568
+ }>>;
1569
+ /** The caller's account and the scopes it may use. */
1570
+ me(): Promise<ApiResponse<Me>>;
1571
+ /** Dashboard numbers, with each section limited to the caller's scopes. */
1572
+ stats(): Promise<{
1573
+ error: {
1574
+ message: string;
1575
+ status?: number;
1576
+ } | null;
1577
+ data: {
1578
+ files: {
1579
+ largest: any[];
1580
+ recent: any[];
1581
+ total: number;
1582
+ folders: number;
1583
+ storage: {
1584
+ used: number;
1585
+ available: number;
1586
+ };
1587
+ types: {
1588
+ mimeType: string;
1589
+ size: number;
1590
+ count: number;
1591
+ }[];
1592
+ } | null;
1593
+ apiKeys: {
1594
+ total: number;
1595
+ requests: {
1596
+ date: string;
1597
+ count: number;
1598
+ }[];
1599
+ } | null;
1600
+ } | null;
1601
+ }>;
944
1602
  }
945
1603
 
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 };
1604
+ export { type ActivityEntry as Activity, type ActivityType, type ApiKeySummary as ApiKey, type ApiResponse, type BulkDeleteResult, type BulkMoveResult, type CreatedApiKey, type FileWithUrl as File, type FileReference, type Folder, type InstanceSettings, type Limits, type ListOptions, type Me, type MoveDestination, type NewKeyOptions, type NewUserOptions, type PasswordChange, type ProfileChanges, type Role, type Scope, type SessionSummary as Session, type SettingsChanges, type SignOptions, type SignedUrl, type Stats, type UserSummary as User, type UserAccess, type VazeHeaders, type VazeOptions, type Visibility, Vaze as default };