@darseen/vaze 2.3.0 → 2.4.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 +102 -3
- package/dist/index.cjs +264 -17
- package/dist/index.d.cts +645 -2
- package/dist/index.d.ts +645 -2
- package/dist/index.js +262 -15
- package/package.json +1 -1
package/dist/index.d.cts
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,18 +1218,20 @@ 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[];
|
|
@@ -779,6 +1242,10 @@ declare class Files extends Base {
|
|
|
779
1242
|
filename: string | null;
|
|
780
1243
|
contentType: string;
|
|
781
1244
|
}>>;
|
|
1245
|
+
/** Where `download` reads from; fetch it yourself with `authHeaders()`. */
|
|
1246
|
+
downloadUrl(id: string): string;
|
|
1247
|
+
/** A WebP thumbnail of an image file; fetch it with `authHeaders()`. */
|
|
1248
|
+
thumbnailUrl(id: string): string;
|
|
782
1249
|
/** Download several files as one zip, with paths below their shared folder. */
|
|
783
1250
|
downloadMany(ids: string[]): Promise<ApiResponse<{
|
|
784
1251
|
blob: Blob;
|
|
@@ -799,6 +1266,7 @@ declare class Files extends Base {
|
|
|
799
1266
|
} & MoveDestination): Promise<{
|
|
800
1267
|
error: {
|
|
801
1268
|
message: string;
|
|
1269
|
+
status?: number;
|
|
802
1270
|
} | null;
|
|
803
1271
|
data: {
|
|
804
1272
|
file: any;
|
|
@@ -808,6 +1276,7 @@ declare class Files extends Base {
|
|
|
808
1276
|
moveMany(ids: string[], destination: MoveDestination): Promise<{
|
|
809
1277
|
error: {
|
|
810
1278
|
message: string;
|
|
1279
|
+
status?: number;
|
|
811
1280
|
} | null;
|
|
812
1281
|
data: {
|
|
813
1282
|
files: any[];
|
|
@@ -821,6 +1290,7 @@ declare class Files extends Base {
|
|
|
821
1290
|
sign(options: SignOptions): Promise<{
|
|
822
1291
|
error: {
|
|
823
1292
|
message: string;
|
|
1293
|
+
status?: number;
|
|
824
1294
|
} | null;
|
|
825
1295
|
data: {
|
|
826
1296
|
url: string;
|
|
@@ -840,6 +1310,7 @@ declare class Folders extends Base {
|
|
|
840
1310
|
}): Promise<{
|
|
841
1311
|
error: {
|
|
842
1312
|
message: string;
|
|
1313
|
+
status?: number;
|
|
843
1314
|
} | null;
|
|
844
1315
|
data: {
|
|
845
1316
|
files: any[];
|
|
@@ -876,13 +1347,94 @@ declare class Folders extends Base {
|
|
|
876
1347
|
delete(id: string): Promise<ApiResponse<null>>;
|
|
877
1348
|
}
|
|
878
1349
|
|
|
1350
|
+
/** The caller's API keys. These calls need a signed-in session, not a key. */
|
|
1351
|
+
declare class Keys extends Base {
|
|
1352
|
+
/** Every key the caller owns, newest first. */
|
|
1353
|
+
getAll(): Promise<ApiResponse<{
|
|
1354
|
+
keys: ApiKeySummary[];
|
|
1355
|
+
}>>;
|
|
1356
|
+
/** The response holds the key's secret, which can't be read again later. */
|
|
1357
|
+
create({ name, scopes, expiresAt }: NewKeyOptions): Promise<ApiResponse<{
|
|
1358
|
+
key: CreatedApiKey;
|
|
1359
|
+
}>>;
|
|
1360
|
+
rename(data: {
|
|
1361
|
+
id: string;
|
|
1362
|
+
name: string;
|
|
1363
|
+
}): Promise<ApiResponse<null>>;
|
|
1364
|
+
/** Revokes the key at once for anything using it. */
|
|
1365
|
+
delete(id: string): Promise<ApiResponse<null>>;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/** Instance-wide settings. These calls need an admin's session. */
|
|
1369
|
+
declare class Settings extends Base {
|
|
1370
|
+
get(): Promise<ApiResponse<InstanceSettings>>;
|
|
1371
|
+
/** Limits left out keep their current values. */
|
|
1372
|
+
update(changes: SettingsChanges): Promise<ApiResponse<InstanceSettings>>;
|
|
1373
|
+
/** Gives every existing file this visibility. */
|
|
1374
|
+
applyVisibility(visibility: Visibility): Promise<ApiResponse<{
|
|
1375
|
+
updated: number;
|
|
1376
|
+
}>>;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/** Accounts on the instance. These calls need an admin's session. */
|
|
1380
|
+
declare class Users extends Base {
|
|
1381
|
+
/** Every account, oldest first. */
|
|
1382
|
+
getAll(): Promise<ApiResponse<{
|
|
1383
|
+
users: UserSummary[];
|
|
1384
|
+
}>>;
|
|
1385
|
+
create(options: NewUserOptions): Promise<ApiResponse<{
|
|
1386
|
+
user: UserSummary;
|
|
1387
|
+
}>>;
|
|
1388
|
+
/** Applies right away, to the user's sessions and API keys alike. */
|
|
1389
|
+
setAccess({ id, role, scopes, }: UserAccess & {
|
|
1390
|
+
id: string;
|
|
1391
|
+
}): Promise<ApiResponse<{
|
|
1392
|
+
user: UserSummary;
|
|
1393
|
+
}>>;
|
|
1394
|
+
/** Also signs the user out of every device. */
|
|
1395
|
+
resetPassword({ id, password, }: {
|
|
1396
|
+
id: string;
|
|
1397
|
+
password: string;
|
|
1398
|
+
}): Promise<ApiResponse<{
|
|
1399
|
+
user: UserSummary;
|
|
1400
|
+
}>>;
|
|
1401
|
+
/** A disabled user is signed out and their API keys stop until re-enabled. */
|
|
1402
|
+
setDisabled({ id, disabled, }: {
|
|
1403
|
+
id: string;
|
|
1404
|
+
disabled: boolean;
|
|
1405
|
+
}): Promise<ApiResponse<{
|
|
1406
|
+
user: UserSummary;
|
|
1407
|
+
}>>;
|
|
1408
|
+
/** Removes the account, its API keys and its history. Files stay. */
|
|
1409
|
+
delete(id: string): Promise<ApiResponse<null>>;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
879
1412
|
interface IVaze {
|
|
880
1413
|
files: Files;
|
|
881
1414
|
folders: Folders;
|
|
1415
|
+
keys: Keys;
|
|
1416
|
+
account: Account;
|
|
1417
|
+
activity: Activity;
|
|
1418
|
+
users: Users;
|
|
1419
|
+
settings: Settings;
|
|
882
1420
|
}
|
|
1421
|
+
type VazeHeaders = Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
883
1422
|
type VazeOptions = {
|
|
884
1423
|
apiKey?: string;
|
|
885
1424
|
vazeUrl?: string;
|
|
1425
|
+
/**
|
|
1426
|
+
* Headers sent with every request, such as a Better Auth session cookie.
|
|
1427
|
+
* A function is called before each request. Replaces the need for `apiKey`.
|
|
1428
|
+
*/
|
|
1429
|
+
headers?: VazeHeaders;
|
|
1430
|
+
/** Replaces the global `fetch`, e.g. to set `credentials` or a timeout. */
|
|
1431
|
+
fetch?: typeof fetch;
|
|
1432
|
+
};
|
|
1433
|
+
/** A file on disk in React Native, which streams it from `uri` on upload. */
|
|
1434
|
+
type FileReference = {
|
|
1435
|
+
uri: string;
|
|
1436
|
+
name: string;
|
|
1437
|
+
type: string;
|
|
886
1438
|
};
|
|
887
1439
|
type ListOptions = {
|
|
888
1440
|
limit?: number;
|
|
@@ -913,6 +1465,40 @@ type BulkMoveResult = {
|
|
|
913
1465
|
message: string;
|
|
914
1466
|
}[];
|
|
915
1467
|
};
|
|
1468
|
+
type NewKeyOptions = {
|
|
1469
|
+
name: string;
|
|
1470
|
+
/** Only `files:read`, `files:write` and `files:delete`, and only ones the caller holds. */
|
|
1471
|
+
scopes: Scope[];
|
|
1472
|
+
/** Leave it out, or pass `null`, for a key that never expires. */
|
|
1473
|
+
expiresAt?: Date | string | null;
|
|
1474
|
+
};
|
|
1475
|
+
type ProfileChanges = {
|
|
1476
|
+
name?: string;
|
|
1477
|
+
/** The new sign-in email; it applies right away. */
|
|
1478
|
+
email?: string;
|
|
1479
|
+
};
|
|
1480
|
+
type PasswordChange = {
|
|
1481
|
+
currentPassword: string;
|
|
1482
|
+
/** At least 8 characters. */
|
|
1483
|
+
newPassword: string;
|
|
1484
|
+
/** Signs out every other device too. */
|
|
1485
|
+
revokeOtherSessions?: boolean;
|
|
1486
|
+
};
|
|
1487
|
+
type UserAccess = {
|
|
1488
|
+
role: Role;
|
|
1489
|
+
/** Only read for the `custom` role, which needs at least one. `users:manage` can't be picked. */
|
|
1490
|
+
scopes?: Scope[];
|
|
1491
|
+
};
|
|
1492
|
+
type NewUserOptions = UserAccess & {
|
|
1493
|
+
name: string;
|
|
1494
|
+
email: string;
|
|
1495
|
+
/** At least 8 characters. */
|
|
1496
|
+
password: string;
|
|
1497
|
+
};
|
|
1498
|
+
type SettingsChanges = {
|
|
1499
|
+
defaultVisibility?: Visibility;
|
|
1500
|
+
limits?: Partial<Limits>;
|
|
1501
|
+
};
|
|
916
1502
|
type BulkDeleteResult = {
|
|
917
1503
|
deleted: string[];
|
|
918
1504
|
failed: {
|
|
@@ -923,9 +1509,13 @@ type BulkDeleteResult = {
|
|
|
923
1509
|
|
|
924
1510
|
declare class Base {
|
|
925
1511
|
private apiKey;
|
|
1512
|
+
private headers;
|
|
1513
|
+
private fetch;
|
|
926
1514
|
protected vazeUrl: string;
|
|
927
1515
|
constructor(options?: VazeOptions);
|
|
928
1516
|
protected apiUrl(path: string, params?: Record<string, string | number | undefined>): string;
|
|
1517
|
+
/** The headers every request carries, for clients fetching an SDK URL themselves. */
|
|
1518
|
+
authHeaders(): Promise<Record<string, string>>;
|
|
929
1519
|
protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
930
1520
|
protected requestBlob(url: string, method?: string, body?: Record<string, any>): Promise<ApiResponse<{
|
|
931
1521
|
blob: Blob;
|
|
@@ -934,13 +1524,66 @@ declare class Base {
|
|
|
934
1524
|
}>>;
|
|
935
1525
|
}
|
|
936
1526
|
|
|
1527
|
+
/** The signed-in user's own account. These calls need a session, not a key. */
|
|
1528
|
+
declare class Account extends Base {
|
|
1529
|
+
/** Changes the display name, the sign-in email, or both. */
|
|
1530
|
+
update(changes: ProfileChanges): Promise<ApiResponse<Me>>;
|
|
1531
|
+
changePassword({ currentPassword, newPassword, revokeOtherSessions, }: PasswordChange): Promise<ApiResponse<null>>;
|
|
1532
|
+
/** Every device signed in to the account, the current one first. */
|
|
1533
|
+
getSessions(): Promise<ApiResponse<{
|
|
1534
|
+
sessions: SessionSummary[];
|
|
1535
|
+
}>>;
|
|
1536
|
+
/** Signs out another device. The current session ends with a sign-out instead. */
|
|
1537
|
+
revokeSession(id: string): Promise<ApiResponse<null>>;
|
|
1538
|
+
/** Signs out every device but the current one. */
|
|
1539
|
+
revokeOtherSessions(): Promise<ApiResponse<null>>;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
937
1542
|
declare class Vaze extends Base implements IVaze {
|
|
938
1543
|
files: Files;
|
|
939
1544
|
folders: Folders;
|
|
1545
|
+
keys: Keys;
|
|
1546
|
+
account: Account;
|
|
1547
|
+
activity: Activity;
|
|
1548
|
+
users: Users;
|
|
1549
|
+
settings: Settings;
|
|
940
1550
|
constructor(options?: VazeOptions);
|
|
941
1551
|
health(): Promise<ApiResponse<{
|
|
942
1552
|
message: string;
|
|
943
1553
|
}>>;
|
|
1554
|
+
/** The caller's account and the scopes it may use. */
|
|
1555
|
+
me(): Promise<ApiResponse<Me>>;
|
|
1556
|
+
/** Dashboard numbers, with each section limited to the caller's scopes. */
|
|
1557
|
+
stats(): Promise<{
|
|
1558
|
+
error: {
|
|
1559
|
+
message: string;
|
|
1560
|
+
status?: number;
|
|
1561
|
+
} | null;
|
|
1562
|
+
data: {
|
|
1563
|
+
files: {
|
|
1564
|
+
largest: any[];
|
|
1565
|
+
recent: any[];
|
|
1566
|
+
total: number;
|
|
1567
|
+
folders: number;
|
|
1568
|
+
storage: {
|
|
1569
|
+
used: number;
|
|
1570
|
+
available: number;
|
|
1571
|
+
};
|
|
1572
|
+
types: {
|
|
1573
|
+
mimeType: string;
|
|
1574
|
+
size: number;
|
|
1575
|
+
count: number;
|
|
1576
|
+
}[];
|
|
1577
|
+
} | null;
|
|
1578
|
+
apiKeys: {
|
|
1579
|
+
total: number;
|
|
1580
|
+
requests: {
|
|
1581
|
+
date: string;
|
|
1582
|
+
count: number;
|
|
1583
|
+
}[];
|
|
1584
|
+
} | null;
|
|
1585
|
+
} | null;
|
|
1586
|
+
}>;
|
|
944
1587
|
}
|
|
945
1588
|
|
|
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 };
|
|
1589
|
+
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 };
|