@remit/drizzle-pg-schema 0.0.34 → 0.0.35
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/schema.d.ts +222 -341
- package/dist/schema.js +22 -30
- package/dist/types.d.ts +55 -1
- package/dist/types.js +132 -6
- package/package.json +1 -4
- package/schema.ts +28 -40
- package/types.ts +142 -6
package/dist/schema.d.ts
CHANGED
|
@@ -601,6 +601,168 @@ export declare const quarantines: import("drizzle-orm/pg-core").PgTableWithColum
|
|
|
601
601
|
};
|
|
602
602
|
dialect: "pg";
|
|
603
603
|
}>;
|
|
604
|
+
export declare const syncWarnings: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
605
|
+
name: "sync_warning";
|
|
606
|
+
schema: undefined;
|
|
607
|
+
columns: {
|
|
608
|
+
syncWarningId: import("drizzle-orm/pg-core").PgColumn<{
|
|
609
|
+
name: "sync_warning_id";
|
|
610
|
+
tableName: "sync_warning";
|
|
611
|
+
dataType: "string";
|
|
612
|
+
columnType: "PgText";
|
|
613
|
+
data: string;
|
|
614
|
+
driverParam: string;
|
|
615
|
+
notNull: true;
|
|
616
|
+
hasDefault: true;
|
|
617
|
+
isPrimaryKey: true;
|
|
618
|
+
isAutoincrement: false;
|
|
619
|
+
hasRuntimeDefault: true;
|
|
620
|
+
enumValues: [string, ...string[]];
|
|
621
|
+
baseColumn: never;
|
|
622
|
+
identity: undefined;
|
|
623
|
+
generated: undefined;
|
|
624
|
+
}, {}, {}>;
|
|
625
|
+
accountConfigId: import("drizzle-orm/pg-core").PgColumn<{
|
|
626
|
+
name: "account_config_id";
|
|
627
|
+
tableName: "sync_warning";
|
|
628
|
+
dataType: "string";
|
|
629
|
+
columnType: "PgText";
|
|
630
|
+
data: string;
|
|
631
|
+
driverParam: string;
|
|
632
|
+
notNull: true;
|
|
633
|
+
hasDefault: false;
|
|
634
|
+
isPrimaryKey: false;
|
|
635
|
+
isAutoincrement: false;
|
|
636
|
+
hasRuntimeDefault: false;
|
|
637
|
+
enumValues: [string, ...string[]];
|
|
638
|
+
baseColumn: never;
|
|
639
|
+
identity: undefined;
|
|
640
|
+
generated: undefined;
|
|
641
|
+
}, {}, {}>;
|
|
642
|
+
accountId: import("drizzle-orm/pg-core").PgColumn<{
|
|
643
|
+
name: "account_id";
|
|
644
|
+
tableName: "sync_warning";
|
|
645
|
+
dataType: "string";
|
|
646
|
+
columnType: "PgText";
|
|
647
|
+
data: string;
|
|
648
|
+
driverParam: string;
|
|
649
|
+
notNull: true;
|
|
650
|
+
hasDefault: false;
|
|
651
|
+
isPrimaryKey: false;
|
|
652
|
+
isAutoincrement: false;
|
|
653
|
+
hasRuntimeDefault: false;
|
|
654
|
+
enumValues: [string, ...string[]];
|
|
655
|
+
baseColumn: never;
|
|
656
|
+
identity: undefined;
|
|
657
|
+
generated: undefined;
|
|
658
|
+
}, {}, {}>;
|
|
659
|
+
mailboxId: import("drizzle-orm/pg-core").PgColumn<{
|
|
660
|
+
name: "mailbox_id";
|
|
661
|
+
tableName: "sync_warning";
|
|
662
|
+
dataType: "string";
|
|
663
|
+
columnType: "PgText";
|
|
664
|
+
data: string;
|
|
665
|
+
driverParam: string;
|
|
666
|
+
notNull: true;
|
|
667
|
+
hasDefault: false;
|
|
668
|
+
isPrimaryKey: false;
|
|
669
|
+
isAutoincrement: false;
|
|
670
|
+
hasRuntimeDefault: false;
|
|
671
|
+
enumValues: [string, ...string[]];
|
|
672
|
+
baseColumn: never;
|
|
673
|
+
identity: undefined;
|
|
674
|
+
generated: undefined;
|
|
675
|
+
}, {}, {}>;
|
|
676
|
+
uidValidity: import("drizzle-orm/pg-core").PgColumn<{
|
|
677
|
+
name: "uid_validity";
|
|
678
|
+
tableName: "sync_warning";
|
|
679
|
+
dataType: "number";
|
|
680
|
+
columnType: "PgBigInt53";
|
|
681
|
+
data: number;
|
|
682
|
+
driverParam: string | number;
|
|
683
|
+
notNull: true;
|
|
684
|
+
hasDefault: false;
|
|
685
|
+
isPrimaryKey: false;
|
|
686
|
+
isAutoincrement: false;
|
|
687
|
+
hasRuntimeDefault: false;
|
|
688
|
+
enumValues: undefined;
|
|
689
|
+
baseColumn: never;
|
|
690
|
+
identity: undefined;
|
|
691
|
+
generated: undefined;
|
|
692
|
+
}, {}, {}>;
|
|
693
|
+
uid: import("drizzle-orm/pg-core").PgColumn<{
|
|
694
|
+
name: "uid";
|
|
695
|
+
tableName: "sync_warning";
|
|
696
|
+
dataType: "number";
|
|
697
|
+
columnType: "PgBigInt53";
|
|
698
|
+
data: number;
|
|
699
|
+
driverParam: string | number;
|
|
700
|
+
notNull: true;
|
|
701
|
+
hasDefault: false;
|
|
702
|
+
isPrimaryKey: false;
|
|
703
|
+
isAutoincrement: false;
|
|
704
|
+
hasRuntimeDefault: false;
|
|
705
|
+
enumValues: undefined;
|
|
706
|
+
baseColumn: never;
|
|
707
|
+
identity: undefined;
|
|
708
|
+
generated: undefined;
|
|
709
|
+
}, {}, {}>;
|
|
710
|
+
stage: import("drizzle-orm/pg-core").PgColumn<{
|
|
711
|
+
name: "stage";
|
|
712
|
+
tableName: "sync_warning";
|
|
713
|
+
dataType: "string";
|
|
714
|
+
columnType: "PgText";
|
|
715
|
+
data: "Header" | "Body";
|
|
716
|
+
driverParam: string;
|
|
717
|
+
notNull: true;
|
|
718
|
+
hasDefault: false;
|
|
719
|
+
isPrimaryKey: false;
|
|
720
|
+
isAutoincrement: false;
|
|
721
|
+
hasRuntimeDefault: false;
|
|
722
|
+
enumValues: [string, ...string[]];
|
|
723
|
+
baseColumn: never;
|
|
724
|
+
identity: undefined;
|
|
725
|
+
generated: undefined;
|
|
726
|
+
}, {}, {
|
|
727
|
+
$type: "Header" | "Body";
|
|
728
|
+
}>;
|
|
729
|
+
attempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
730
|
+
name: "attempts";
|
|
731
|
+
tableName: "sync_warning";
|
|
732
|
+
dataType: "number";
|
|
733
|
+
columnType: "PgInteger";
|
|
734
|
+
data: number;
|
|
735
|
+
driverParam: string | number;
|
|
736
|
+
notNull: true;
|
|
737
|
+
hasDefault: false;
|
|
738
|
+
isPrimaryKey: false;
|
|
739
|
+
isAutoincrement: false;
|
|
740
|
+
hasRuntimeDefault: false;
|
|
741
|
+
enumValues: undefined;
|
|
742
|
+
baseColumn: never;
|
|
743
|
+
identity: undefined;
|
|
744
|
+
generated: undefined;
|
|
745
|
+
}, {}, {}>;
|
|
746
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
747
|
+
name: "created_at";
|
|
748
|
+
tableName: "sync_warning";
|
|
749
|
+
dataType: "number";
|
|
750
|
+
columnType: "PgBigInt53";
|
|
751
|
+
data: number;
|
|
752
|
+
driverParam: string | number;
|
|
753
|
+
notNull: true;
|
|
754
|
+
hasDefault: false;
|
|
755
|
+
isPrimaryKey: false;
|
|
756
|
+
isAutoincrement: false;
|
|
757
|
+
hasRuntimeDefault: false;
|
|
758
|
+
enumValues: undefined;
|
|
759
|
+
baseColumn: never;
|
|
760
|
+
identity: undefined;
|
|
761
|
+
generated: undefined;
|
|
762
|
+
}, {}, {}>;
|
|
763
|
+
};
|
|
764
|
+
dialect: "pg";
|
|
765
|
+
}>;
|
|
604
766
|
export declare const accountConfigs: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
605
767
|
name: "account_config";
|
|
606
768
|
schema: undefined;
|
|
@@ -1921,23 +2083,6 @@ export declare const filters: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
1921
2083
|
}, {}, {
|
|
1922
2084
|
$type: "None" | "UserDisabled" | "AwaitingFolder" | "FolderCreateFailed" | "FolderMissing";
|
|
1923
2085
|
}>;
|
|
1924
|
-
hasAnchor: import("drizzle-orm/pg-core").PgColumn<{
|
|
1925
|
-
name: "has_anchor";
|
|
1926
|
-
tableName: "filter";
|
|
1927
|
-
dataType: "boolean";
|
|
1928
|
-
columnType: "PgBoolean";
|
|
1929
|
-
data: boolean;
|
|
1930
|
-
driverParam: boolean;
|
|
1931
|
-
notNull: true;
|
|
1932
|
-
hasDefault: true;
|
|
1933
|
-
isPrimaryKey: false;
|
|
1934
|
-
isAutoincrement: false;
|
|
1935
|
-
hasRuntimeDefault: false;
|
|
1936
|
-
enumValues: undefined;
|
|
1937
|
-
baseColumn: never;
|
|
1938
|
-
identity: undefined;
|
|
1939
|
-
generated: undefined;
|
|
1940
|
-
}, {}, {}>;
|
|
1941
2086
|
ruleChangedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1942
2087
|
name: "rule_changed_at";
|
|
1943
2088
|
tableName: "filter";
|
|
@@ -1999,7 +2144,7 @@ export declare const filters: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
1999
2144
|
data: unknown;
|
|
2000
2145
|
driverParam: unknown;
|
|
2001
2146
|
notNull: true;
|
|
2002
|
-
hasDefault:
|
|
2147
|
+
hasDefault: false;
|
|
2003
2148
|
isPrimaryKey: false;
|
|
2004
2149
|
isAutoincrement: false;
|
|
2005
2150
|
hasRuntimeDefault: false;
|
|
@@ -2298,23 +2443,6 @@ export declare const organizeJobRequests: import("drizzle-orm/pg-core").PgTableW
|
|
|
2298
2443
|
identity: undefined;
|
|
2299
2444
|
generated: undefined;
|
|
2300
2445
|
}, {}, {}>;
|
|
2301
|
-
anchorMessageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
2302
|
-
name: "anchor_message_id";
|
|
2303
|
-
tableName: "organize_job_request";
|
|
2304
|
-
dataType: "string";
|
|
2305
|
-
columnType: "PgText";
|
|
2306
|
-
data: string;
|
|
2307
|
-
driverParam: string;
|
|
2308
|
-
notNull: true;
|
|
2309
|
-
hasDefault: true;
|
|
2310
|
-
isPrimaryKey: false;
|
|
2311
|
-
isAutoincrement: false;
|
|
2312
|
-
hasRuntimeDefault: false;
|
|
2313
|
-
enumValues: [string, ...string[]];
|
|
2314
|
-
baseColumn: never;
|
|
2315
|
-
identity: undefined;
|
|
2316
|
-
generated: undefined;
|
|
2317
|
-
}, {}, {}>;
|
|
2318
2446
|
matchOperator: import("drizzle-orm/pg-core").PgColumn<{
|
|
2319
2447
|
name: "match_operator";
|
|
2320
2448
|
tableName: "organize_job_request";
|
|
@@ -2351,23 +2479,6 @@ export declare const organizeJobRequests: import("drizzle-orm/pg-core").PgTableW
|
|
|
2351
2479
|
identity: undefined;
|
|
2352
2480
|
generated: undefined;
|
|
2353
2481
|
}, {}, {}>;
|
|
2354
|
-
similarityThreshold: import("drizzle-orm/pg-core").PgColumn<{
|
|
2355
|
-
name: "similarity_threshold";
|
|
2356
|
-
tableName: "organize_job_request";
|
|
2357
|
-
dataType: "number";
|
|
2358
|
-
columnType: "PgDoublePrecision";
|
|
2359
|
-
data: number;
|
|
2360
|
-
driverParam: string | number;
|
|
2361
|
-
notNull: true;
|
|
2362
|
-
hasDefault: true;
|
|
2363
|
-
isPrimaryKey: false;
|
|
2364
|
-
isAutoincrement: false;
|
|
2365
|
-
hasRuntimeDefault: false;
|
|
2366
|
-
enumValues: undefined;
|
|
2367
|
-
baseColumn: never;
|
|
2368
|
-
identity: undefined;
|
|
2369
|
-
generated: undefined;
|
|
2370
|
-
}, {}, {}>;
|
|
2371
2482
|
actionLabelId: import("drizzle-orm/pg-core").PgColumn<{
|
|
2372
2483
|
name: "action_label_id";
|
|
2373
2484
|
tableName: "organize_job_request";
|
|
@@ -4494,7 +4605,7 @@ export declare const addresses: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
4494
4605
|
};
|
|
4495
4606
|
dialect: "pg";
|
|
4496
4607
|
}>;
|
|
4497
|
-
export declare const
|
|
4608
|
+
export declare const messageRecords: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4498
4609
|
name: "message";
|
|
4499
4610
|
schema: undefined;
|
|
4500
4611
|
columns: {
|
|
@@ -4600,25 +4711,6 @@ export declare const messages: import("drizzle-orm/pg-core").PgTableWithColumns<
|
|
|
4600
4711
|
identity: undefined;
|
|
4601
4712
|
generated: undefined;
|
|
4602
4713
|
}, {}, {}>;
|
|
4603
|
-
messageIdHeader: import("drizzle-orm/pg-core").PgColumn<{
|
|
4604
|
-
name: "message_id_header";
|
|
4605
|
-
tableName: "message";
|
|
4606
|
-
dataType: "custom";
|
|
4607
|
-
columnType: "PgCustomColumn";
|
|
4608
|
-
data: string;
|
|
4609
|
-
driverParam: string;
|
|
4610
|
-
notNull: false;
|
|
4611
|
-
hasDefault: false;
|
|
4612
|
-
isPrimaryKey: false;
|
|
4613
|
-
isAutoincrement: false;
|
|
4614
|
-
hasRuntimeDefault: false;
|
|
4615
|
-
enumValues: undefined;
|
|
4616
|
-
baseColumn: never;
|
|
4617
|
-
identity: undefined;
|
|
4618
|
-
generated: undefined;
|
|
4619
|
-
}, {}, {
|
|
4620
|
-
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
4621
|
-
}>;
|
|
4622
4714
|
envelopeId: import("drizzle-orm/pg-core").PgColumn<{
|
|
4623
4715
|
name: "envelope_id";
|
|
4624
4716
|
tableName: "message";
|
|
@@ -7528,6 +7620,64 @@ export declare const bodyPartParameters: import("drizzle-orm/pg-core").PgTableWi
|
|
|
7528
7620
|
};
|
|
7529
7621
|
dialect: "pg";
|
|
7530
7622
|
}>;
|
|
7623
|
+
export declare const bodyStructureRefetches: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
7624
|
+
name: "body_structure_refetch";
|
|
7625
|
+
schema: undefined;
|
|
7626
|
+
columns: {
|
|
7627
|
+
messageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
7628
|
+
name: "message_id";
|
|
7629
|
+
tableName: "body_structure_refetch";
|
|
7630
|
+
dataType: "string";
|
|
7631
|
+
columnType: "PgText";
|
|
7632
|
+
data: string;
|
|
7633
|
+
driverParam: string;
|
|
7634
|
+
notNull: true;
|
|
7635
|
+
hasDefault: true;
|
|
7636
|
+
isPrimaryKey: true;
|
|
7637
|
+
isAutoincrement: false;
|
|
7638
|
+
hasRuntimeDefault: true;
|
|
7639
|
+
enumValues: [string, ...string[]];
|
|
7640
|
+
baseColumn: never;
|
|
7641
|
+
identity: undefined;
|
|
7642
|
+
generated: undefined;
|
|
7643
|
+
}, {}, {}>;
|
|
7644
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
7645
|
+
name: "created_at";
|
|
7646
|
+
tableName: "body_structure_refetch";
|
|
7647
|
+
dataType: "number";
|
|
7648
|
+
columnType: "PgBigInt53";
|
|
7649
|
+
data: number;
|
|
7650
|
+
driverParam: string | number;
|
|
7651
|
+
notNull: true;
|
|
7652
|
+
hasDefault: false;
|
|
7653
|
+
isPrimaryKey: false;
|
|
7654
|
+
isAutoincrement: false;
|
|
7655
|
+
hasRuntimeDefault: false;
|
|
7656
|
+
enumValues: undefined;
|
|
7657
|
+
baseColumn: never;
|
|
7658
|
+
identity: undefined;
|
|
7659
|
+
generated: undefined;
|
|
7660
|
+
}, {}, {}>;
|
|
7661
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
7662
|
+
name: "updated_at";
|
|
7663
|
+
tableName: "body_structure_refetch";
|
|
7664
|
+
dataType: "number";
|
|
7665
|
+
columnType: "PgBigInt53";
|
|
7666
|
+
data: number;
|
|
7667
|
+
driverParam: string | number;
|
|
7668
|
+
notNull: true;
|
|
7669
|
+
hasDefault: false;
|
|
7670
|
+
isPrimaryKey: false;
|
|
7671
|
+
isAutoincrement: false;
|
|
7672
|
+
hasRuntimeDefault: false;
|
|
7673
|
+
enumValues: undefined;
|
|
7674
|
+
baseColumn: never;
|
|
7675
|
+
identity: undefined;
|
|
7676
|
+
generated: undefined;
|
|
7677
|
+
}, {}, {}>;
|
|
7678
|
+
};
|
|
7679
|
+
dialect: "pg";
|
|
7680
|
+
}>;
|
|
7531
7681
|
export declare const rawMessageStorages: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
7532
7682
|
name: "raw_message_storage";
|
|
7533
7683
|
schema: undefined;
|
|
@@ -7996,132 +8146,6 @@ export declare const bodyPartStorages: import("drizzle-orm/pg-core").PgTableWith
|
|
|
7996
8146
|
};
|
|
7997
8147
|
dialect: "pg";
|
|
7998
8148
|
}>;
|
|
7999
|
-
export declare const bodyPartContents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
8000
|
-
name: "body_part_content";
|
|
8001
|
-
schema: undefined;
|
|
8002
|
-
columns: {
|
|
8003
|
-
bodyPartContentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8004
|
-
name: "body_part_content_id";
|
|
8005
|
-
tableName: "body_part_content";
|
|
8006
|
-
dataType: "string";
|
|
8007
|
-
columnType: "PgText";
|
|
8008
|
-
data: string;
|
|
8009
|
-
driverParam: string;
|
|
8010
|
-
notNull: true;
|
|
8011
|
-
hasDefault: true;
|
|
8012
|
-
isPrimaryKey: true;
|
|
8013
|
-
isAutoincrement: false;
|
|
8014
|
-
hasRuntimeDefault: true;
|
|
8015
|
-
enumValues: [string, ...string[]];
|
|
8016
|
-
baseColumn: never;
|
|
8017
|
-
identity: undefined;
|
|
8018
|
-
generated: undefined;
|
|
8019
|
-
}, {}, {}>;
|
|
8020
|
-
messageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8021
|
-
name: "message_id";
|
|
8022
|
-
tableName: "body_part_content";
|
|
8023
|
-
dataType: "string";
|
|
8024
|
-
columnType: "PgText";
|
|
8025
|
-
data: string;
|
|
8026
|
-
driverParam: string;
|
|
8027
|
-
notNull: true;
|
|
8028
|
-
hasDefault: false;
|
|
8029
|
-
isPrimaryKey: false;
|
|
8030
|
-
isAutoincrement: false;
|
|
8031
|
-
hasRuntimeDefault: false;
|
|
8032
|
-
enumValues: [string, ...string[]];
|
|
8033
|
-
baseColumn: never;
|
|
8034
|
-
identity: undefined;
|
|
8035
|
-
generated: undefined;
|
|
8036
|
-
}, {}, {}>;
|
|
8037
|
-
bodyPartId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8038
|
-
name: "body_part_id";
|
|
8039
|
-
tableName: "body_part_content";
|
|
8040
|
-
dataType: "string";
|
|
8041
|
-
columnType: "PgText";
|
|
8042
|
-
data: string;
|
|
8043
|
-
driverParam: string;
|
|
8044
|
-
notNull: true;
|
|
8045
|
-
hasDefault: false;
|
|
8046
|
-
isPrimaryKey: false;
|
|
8047
|
-
isAutoincrement: false;
|
|
8048
|
-
hasRuntimeDefault: false;
|
|
8049
|
-
enumValues: [string, ...string[]];
|
|
8050
|
-
baseColumn: never;
|
|
8051
|
-
identity: undefined;
|
|
8052
|
-
generated: undefined;
|
|
8053
|
-
}, {}, {}>;
|
|
8054
|
-
content: import("drizzle-orm/pg-core").PgColumn<{
|
|
8055
|
-
name: "content";
|
|
8056
|
-
tableName: "body_part_content";
|
|
8057
|
-
dataType: "string";
|
|
8058
|
-
columnType: "PgText";
|
|
8059
|
-
data: string;
|
|
8060
|
-
driverParam: string;
|
|
8061
|
-
notNull: true;
|
|
8062
|
-
hasDefault: false;
|
|
8063
|
-
isPrimaryKey: false;
|
|
8064
|
-
isAutoincrement: false;
|
|
8065
|
-
hasRuntimeDefault: false;
|
|
8066
|
-
enumValues: [string, ...string[]];
|
|
8067
|
-
baseColumn: never;
|
|
8068
|
-
identity: undefined;
|
|
8069
|
-
generated: undefined;
|
|
8070
|
-
}, {}, {}>;
|
|
8071
|
-
contentLength: import("drizzle-orm/pg-core").PgColumn<{
|
|
8072
|
-
name: "content_length";
|
|
8073
|
-
tableName: "body_part_content";
|
|
8074
|
-
dataType: "number";
|
|
8075
|
-
columnType: "PgBigInt53";
|
|
8076
|
-
data: number;
|
|
8077
|
-
driverParam: string | number;
|
|
8078
|
-
notNull: true;
|
|
8079
|
-
hasDefault: false;
|
|
8080
|
-
isPrimaryKey: false;
|
|
8081
|
-
isAutoincrement: false;
|
|
8082
|
-
hasRuntimeDefault: false;
|
|
8083
|
-
enumValues: undefined;
|
|
8084
|
-
baseColumn: never;
|
|
8085
|
-
identity: undefined;
|
|
8086
|
-
generated: undefined;
|
|
8087
|
-
}, {}, {}>;
|
|
8088
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
8089
|
-
name: "created_at";
|
|
8090
|
-
tableName: "body_part_content";
|
|
8091
|
-
dataType: "number";
|
|
8092
|
-
columnType: "PgBigInt53";
|
|
8093
|
-
data: number;
|
|
8094
|
-
driverParam: string | number;
|
|
8095
|
-
notNull: true;
|
|
8096
|
-
hasDefault: false;
|
|
8097
|
-
isPrimaryKey: false;
|
|
8098
|
-
isAutoincrement: false;
|
|
8099
|
-
hasRuntimeDefault: false;
|
|
8100
|
-
enumValues: undefined;
|
|
8101
|
-
baseColumn: never;
|
|
8102
|
-
identity: undefined;
|
|
8103
|
-
generated: undefined;
|
|
8104
|
-
}, {}, {}>;
|
|
8105
|
-
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
8106
|
-
name: "updated_at";
|
|
8107
|
-
tableName: "body_part_content";
|
|
8108
|
-
dataType: "number";
|
|
8109
|
-
columnType: "PgBigInt53";
|
|
8110
|
-
data: number;
|
|
8111
|
-
driverParam: string | number;
|
|
8112
|
-
notNull: true;
|
|
8113
|
-
hasDefault: false;
|
|
8114
|
-
isPrimaryKey: false;
|
|
8115
|
-
isAutoincrement: false;
|
|
8116
|
-
hasRuntimeDefault: false;
|
|
8117
|
-
enumValues: undefined;
|
|
8118
|
-
baseColumn: never;
|
|
8119
|
-
identity: undefined;
|
|
8120
|
-
generated: undefined;
|
|
8121
|
-
}, {}, {}>;
|
|
8122
|
-
};
|
|
8123
|
-
dialect: "pg";
|
|
8124
|
-
}>;
|
|
8125
8149
|
export declare const calendarEventIndexes: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
8126
8150
|
name: "calendar_event_index";
|
|
8127
8151
|
schema: undefined;
|
|
@@ -8574,146 +8598,3 @@ export declare const messageLabels: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
8574
8598
|
};
|
|
8575
8599
|
dialect: "pg";
|
|
8576
8600
|
}>;
|
|
8577
|
-
export declare const filterAnchors: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
8578
|
-
name: "filter_anchor";
|
|
8579
|
-
schema: undefined;
|
|
8580
|
-
columns: {
|
|
8581
|
-
accountConfigId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8582
|
-
name: "account_config_id";
|
|
8583
|
-
tableName: "filter_anchor";
|
|
8584
|
-
dataType: "string";
|
|
8585
|
-
columnType: "PgText";
|
|
8586
|
-
data: string;
|
|
8587
|
-
driverParam: string;
|
|
8588
|
-
notNull: true;
|
|
8589
|
-
hasDefault: false;
|
|
8590
|
-
isPrimaryKey: false;
|
|
8591
|
-
isAutoincrement: false;
|
|
8592
|
-
hasRuntimeDefault: false;
|
|
8593
|
-
enumValues: [string, ...string[]];
|
|
8594
|
-
baseColumn: never;
|
|
8595
|
-
identity: undefined;
|
|
8596
|
-
generated: undefined;
|
|
8597
|
-
}, {}, {}>;
|
|
8598
|
-
filterId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8599
|
-
name: "filter_id";
|
|
8600
|
-
tableName: "filter_anchor";
|
|
8601
|
-
dataType: "string";
|
|
8602
|
-
columnType: "PgText";
|
|
8603
|
-
data: string;
|
|
8604
|
-
driverParam: string;
|
|
8605
|
-
notNull: true;
|
|
8606
|
-
hasDefault: false;
|
|
8607
|
-
isPrimaryKey: false;
|
|
8608
|
-
isAutoincrement: false;
|
|
8609
|
-
hasRuntimeDefault: false;
|
|
8610
|
-
enumValues: [string, ...string[]];
|
|
8611
|
-
baseColumn: never;
|
|
8612
|
-
identity: undefined;
|
|
8613
|
-
generated: undefined;
|
|
8614
|
-
}, {}, {}>;
|
|
8615
|
-
anchorEmbedding: import("drizzle-orm/pg-core").PgColumn<{
|
|
8616
|
-
name: "anchor_embedding";
|
|
8617
|
-
tableName: "filter_anchor";
|
|
8618
|
-
dataType: "json";
|
|
8619
|
-
columnType: "PgJsonb";
|
|
8620
|
-
data: unknown;
|
|
8621
|
-
driverParam: unknown;
|
|
8622
|
-
notNull: true;
|
|
8623
|
-
hasDefault: false;
|
|
8624
|
-
isPrimaryKey: false;
|
|
8625
|
-
isAutoincrement: false;
|
|
8626
|
-
hasRuntimeDefault: false;
|
|
8627
|
-
enumValues: undefined;
|
|
8628
|
-
baseColumn: never;
|
|
8629
|
-
identity: undefined;
|
|
8630
|
-
generated: undefined;
|
|
8631
|
-
}, {}, {}>;
|
|
8632
|
-
anchorEmbeddingId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8633
|
-
name: "anchor_embedding_id";
|
|
8634
|
-
tableName: "filter_anchor";
|
|
8635
|
-
dataType: "string";
|
|
8636
|
-
columnType: "PgText";
|
|
8637
|
-
data: string;
|
|
8638
|
-
driverParam: string;
|
|
8639
|
-
notNull: true;
|
|
8640
|
-
hasDefault: false;
|
|
8641
|
-
isPrimaryKey: false;
|
|
8642
|
-
isAutoincrement: false;
|
|
8643
|
-
hasRuntimeDefault: false;
|
|
8644
|
-
enumValues: [string, ...string[]];
|
|
8645
|
-
baseColumn: never;
|
|
8646
|
-
identity: undefined;
|
|
8647
|
-
generated: undefined;
|
|
8648
|
-
}, {}, {}>;
|
|
8649
|
-
anchorSourceText: import("drizzle-orm/pg-core").PgColumn<{
|
|
8650
|
-
name: "anchor_source_text";
|
|
8651
|
-
tableName: "filter_anchor";
|
|
8652
|
-
dataType: "string";
|
|
8653
|
-
columnType: "PgText";
|
|
8654
|
-
data: string;
|
|
8655
|
-
driverParam: string;
|
|
8656
|
-
notNull: true;
|
|
8657
|
-
hasDefault: false;
|
|
8658
|
-
isPrimaryKey: false;
|
|
8659
|
-
isAutoincrement: false;
|
|
8660
|
-
hasRuntimeDefault: false;
|
|
8661
|
-
enumValues: [string, ...string[]];
|
|
8662
|
-
baseColumn: never;
|
|
8663
|
-
identity: undefined;
|
|
8664
|
-
generated: undefined;
|
|
8665
|
-
}, {}, {}>;
|
|
8666
|
-
anchorMessageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
8667
|
-
name: "anchor_message_id";
|
|
8668
|
-
tableName: "filter_anchor";
|
|
8669
|
-
dataType: "string";
|
|
8670
|
-
columnType: "PgText";
|
|
8671
|
-
data: string;
|
|
8672
|
-
driverParam: string;
|
|
8673
|
-
notNull: true;
|
|
8674
|
-
hasDefault: false;
|
|
8675
|
-
isPrimaryKey: false;
|
|
8676
|
-
isAutoincrement: false;
|
|
8677
|
-
hasRuntimeDefault: false;
|
|
8678
|
-
enumValues: [string, ...string[]];
|
|
8679
|
-
baseColumn: never;
|
|
8680
|
-
identity: undefined;
|
|
8681
|
-
generated: undefined;
|
|
8682
|
-
}, {}, {}>;
|
|
8683
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
8684
|
-
name: "created_at";
|
|
8685
|
-
tableName: "filter_anchor";
|
|
8686
|
-
dataType: "number";
|
|
8687
|
-
columnType: "PgBigInt53";
|
|
8688
|
-
data: number;
|
|
8689
|
-
driverParam: string | number;
|
|
8690
|
-
notNull: true;
|
|
8691
|
-
hasDefault: false;
|
|
8692
|
-
isPrimaryKey: false;
|
|
8693
|
-
isAutoincrement: false;
|
|
8694
|
-
hasRuntimeDefault: false;
|
|
8695
|
-
enumValues: undefined;
|
|
8696
|
-
baseColumn: never;
|
|
8697
|
-
identity: undefined;
|
|
8698
|
-
generated: undefined;
|
|
8699
|
-
}, {}, {}>;
|
|
8700
|
-
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
8701
|
-
name: "updated_at";
|
|
8702
|
-
tableName: "filter_anchor";
|
|
8703
|
-
dataType: "number";
|
|
8704
|
-
columnType: "PgBigInt53";
|
|
8705
|
-
data: number;
|
|
8706
|
-
driverParam: string | number;
|
|
8707
|
-
notNull: true;
|
|
8708
|
-
hasDefault: false;
|
|
8709
|
-
isPrimaryKey: false;
|
|
8710
|
-
isAutoincrement: false;
|
|
8711
|
-
hasRuntimeDefault: false;
|
|
8712
|
-
enumValues: undefined;
|
|
8713
|
-
baseColumn: never;
|
|
8714
|
-
identity: undefined;
|
|
8715
|
-
generated: undefined;
|
|
8716
|
-
}, {}, {}>;
|
|
8717
|
-
};
|
|
8718
|
-
dialect: "pg";
|
|
8719
|
-
}>;
|
package/dist/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bigint, boolean,
|
|
1
|
+
import { bigint, boolean, index, integer, jsonb, pgTable, primaryKey, text, uniqueIndex } from "drizzle-orm/pg-core";
|
|
2
2
|
import { generateBase36Id, nullableBigint, nullableInteger, nullableText } from "./types.js";
|
|
3
3
|
export const accountExportRequests = pgTable("account_export_request", {
|
|
4
4
|
accountExportRequestId: text("account_export_request_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
@@ -41,6 +41,20 @@ export const quarantines = pgTable("quarantine", {
|
|
|
41
41
|
}, (table) => [
|
|
42
42
|
index("quarantine_by_account_config_id").on(table.accountConfigId, table.quarantinedAt),
|
|
43
43
|
]);
|
|
44
|
+
export const syncWarnings = pgTable("sync_warning", {
|
|
45
|
+
syncWarningId: text("sync_warning_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
46
|
+
accountConfigId: text("account_config_id").notNull(),
|
|
47
|
+
accountId: text("account_id").notNull(),
|
|
48
|
+
mailboxId: text("mailbox_id").notNull(),
|
|
49
|
+
uidValidity: bigint("uid_validity", { mode: "number" }).notNull(),
|
|
50
|
+
uid: bigint("uid", { mode: "number" }).notNull(),
|
|
51
|
+
stage: text("stage").$type().notNull(),
|
|
52
|
+
attempts: integer("attempts").notNull(),
|
|
53
|
+
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
54
|
+
}, (table) => [
|
|
55
|
+
index("sync_warning_by_mailbox_id").on(table.mailboxId),
|
|
56
|
+
index("sync_warning_by_account_config_id").on(table.accountConfigId, table.createdAt),
|
|
57
|
+
]);
|
|
44
58
|
export const accountConfigs = pgTable("account_config", {
|
|
45
59
|
accountConfigId: text("account_config_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
46
60
|
userId: text("user_id").notNull(),
|
|
@@ -128,11 +142,10 @@ export const filters = pgTable("filter", {
|
|
|
128
142
|
ttl: nullableBigint("ttl"),
|
|
129
143
|
state: text("state").$type().notNull().default("Active"),
|
|
130
144
|
disabledReason: text("disabled_reason").$type().notNull().default("None"),
|
|
131
|
-
hasAnchor: boolean("has_anchor").notNull().default(false),
|
|
132
145
|
ruleChangedAt: bigint("rule_changed_at", { mode: "number" }).notNull(),
|
|
133
146
|
actionChangedAt: bigint("action_changed_at", { mode: "number" }).notNull(),
|
|
134
147
|
matchOperator: text("match_operator").$type().notNull().default("And"),
|
|
135
|
-
literalClauses: jsonb("literal_clauses").notNull()
|
|
148
|
+
literalClauses: jsonb("literal_clauses").notNull(),
|
|
136
149
|
actionLabelId: text("action_label_id").notNull().default("None"),
|
|
137
150
|
actionMailboxId: text("action_mailbox_id").notNull().default("None"),
|
|
138
151
|
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
@@ -159,10 +172,8 @@ export const organizeJobRequests = pgTable("organize_job_request", {
|
|
|
159
172
|
userId: text("user_id").notNull(),
|
|
160
173
|
state: text("state").$type().notNull().default("Pending"),
|
|
161
174
|
filterId: text("filter_id").notNull().default("None"),
|
|
162
|
-
anchorMessageId: text("anchor_message_id").notNull().default("None"),
|
|
163
175
|
matchOperator: text("match_operator").$type().notNull().default("And"),
|
|
164
176
|
literalClauses: jsonb("literal_clauses").notNull().default([]),
|
|
165
|
-
similarityThreshold: doublePrecision("similarity_threshold").notNull().default(0.75),
|
|
166
177
|
actionLabelId: text("action_label_id").notNull().default("None"),
|
|
167
178
|
actionMailboxId: text("action_mailbox_id").notNull().default("None"),
|
|
168
179
|
matchedCount: integer("matched_count").notNull().default(0),
|
|
@@ -321,14 +332,13 @@ export const addresses = pgTable("address", {
|
|
|
321
332
|
}, (table) => [
|
|
322
333
|
index("address_by_account_config_id").on(table.accountConfigId, table.normalizedCompound),
|
|
323
334
|
]);
|
|
324
|
-
export const
|
|
335
|
+
export const messageRecords = pgTable("message", {
|
|
325
336
|
messageId: text("message_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
326
337
|
mailboxId: text("mailbox_id").notNull(),
|
|
327
338
|
uid: bigint("uid", { mode: "number" }).notNull(),
|
|
328
339
|
sequenceNumber: integer("sequence_number").notNull(),
|
|
329
340
|
rfc822Size: bigint("rfc822_size", { mode: "number" }).notNull(),
|
|
330
341
|
internalDate: bigint("internal_date", { mode: "number" }).notNull(),
|
|
331
|
-
messageIdHeader: nullableText("message_id_header"),
|
|
332
342
|
envelopeId: text("envelope_id").notNull(),
|
|
333
343
|
rootBodyPartId: text("root_body_part_id").notNull(),
|
|
334
344
|
bodyStorageKey: nullableText("body_storage_key"),
|
|
@@ -563,6 +573,11 @@ export const bodyPartParameters = pgTable("body_part_parameter", {
|
|
|
563
573
|
}, (table) => [
|
|
564
574
|
index("body_part_parameter_by_message_id").on(table.messageId, table.bodyPartParameterId),
|
|
565
575
|
]);
|
|
576
|
+
export const bodyStructureRefetches = pgTable("body_structure_refetch", {
|
|
577
|
+
messageId: text("message_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
578
|
+
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
579
|
+
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
580
|
+
});
|
|
566
581
|
export const rawMessageStorages = pgTable("raw_message_storage", {
|
|
567
582
|
rawStorageId: text("raw_storage_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
568
583
|
messageId: text("message_id").notNull(),
|
|
@@ -597,17 +612,6 @@ export const bodyPartStorages = pgTable("body_part_storage", {
|
|
|
597
612
|
}, (table) => [
|
|
598
613
|
index("body_part_storage_by_message_id").on(table.messageId, table.bodyPartStorageId),
|
|
599
614
|
]);
|
|
600
|
-
export const bodyPartContents = pgTable("body_part_content", {
|
|
601
|
-
bodyPartContentId: text("body_part_content_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
602
|
-
messageId: text("message_id").notNull(),
|
|
603
|
-
bodyPartId: text("body_part_id").notNull(),
|
|
604
|
-
content: text("content").notNull(),
|
|
605
|
-
contentLength: bigint("content_length", { mode: "number" }).notNull(),
|
|
606
|
-
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
607
|
-
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
608
|
-
}, (table) => [
|
|
609
|
-
index("body_part_content_by_message_id").on(table.messageId, table.bodyPartContentId),
|
|
610
|
-
]);
|
|
611
615
|
export const calendarEventIndexes = pgTable("calendar_event_index", {
|
|
612
616
|
calendarId: text("calendar_id").notNull(),
|
|
613
617
|
calendarObjectId: text("calendar_object_id").notNull(),
|
|
@@ -648,15 +652,3 @@ export const messageLabels = pgTable("message_label", {
|
|
|
648
652
|
index("message_label_by_label_id").on(table.accountConfigId, table.labelId, table.createdAt),
|
|
649
653
|
index("message_label_by_message_id").on(table.messageId, table.labelId),
|
|
650
654
|
]);
|
|
651
|
-
export const filterAnchors = pgTable("filter_anchor", {
|
|
652
|
-
accountConfigId: text("account_config_id").notNull(),
|
|
653
|
-
filterId: text("filter_id").notNull(),
|
|
654
|
-
anchorEmbedding: jsonb("anchor_embedding").notNull(),
|
|
655
|
-
anchorEmbeddingId: text("anchor_embedding_id").notNull(),
|
|
656
|
-
anchorSourceText: text("anchor_source_text").notNull(),
|
|
657
|
-
anchorMessageId: text("anchor_message_id").notNull(),
|
|
658
|
-
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
659
|
-
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
660
|
-
}, (table) => [
|
|
661
|
-
primaryKey({ name: "filter_anchor_pk", columns: [table.accountConfigId, table.filterId] }),
|
|
662
|
-
]);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
/** UUID column
|
|
1
|
+
/** UUID column stored as native pg uuid, reads/writes as base36 */
|
|
2
|
+
export declare const canonicalUuid: {
|
|
3
|
+
(): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
4
|
+
name: "";
|
|
5
|
+
dataType: "custom";
|
|
6
|
+
columnType: "PgCustomColumn";
|
|
7
|
+
data: string;
|
|
8
|
+
driverParam: string;
|
|
9
|
+
enumValues: undefined;
|
|
10
|
+
}>;
|
|
11
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
12
|
+
name: "";
|
|
13
|
+
dataType: "custom";
|
|
14
|
+
columnType: "PgCustomColumn";
|
|
15
|
+
data: string;
|
|
16
|
+
driverParam: string;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
20
|
+
name: TName;
|
|
21
|
+
dataType: "custom";
|
|
22
|
+
columnType: "PgCustomColumn";
|
|
23
|
+
data: string;
|
|
24
|
+
driverParam: string;
|
|
25
|
+
enumValues: undefined;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
/** UUID column stored as the 25-character base36 string, reads/writes as base36 */
|
|
2
29
|
export declare const base36Uuid: {
|
|
3
30
|
(): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
4
31
|
name: "";
|
|
@@ -25,6 +52,33 @@ export declare const base36Uuid: {
|
|
|
25
52
|
enumValues: undefined;
|
|
26
53
|
}>;
|
|
27
54
|
};
|
|
55
|
+
/** UUID column stored as native pg uuid — 16 bytes on disk — reads/writes as base36 */
|
|
56
|
+
export declare const rawUuid: {
|
|
57
|
+
(): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
58
|
+
name: "";
|
|
59
|
+
dataType: "custom";
|
|
60
|
+
columnType: "PgCustomColumn";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
enumValues: undefined;
|
|
64
|
+
}>;
|
|
65
|
+
<TConfig extends Record<string, any>>(fieldConfig?: TConfig): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
66
|
+
name: "";
|
|
67
|
+
dataType: "custom";
|
|
68
|
+
columnType: "PgCustomColumn";
|
|
69
|
+
data: string;
|
|
70
|
+
driverParam: string;
|
|
71
|
+
enumValues: undefined;
|
|
72
|
+
}>;
|
|
73
|
+
<TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
|
74
|
+
name: TName;
|
|
75
|
+
dataType: "custom";
|
|
76
|
+
columnType: "PgCustomColumn";
|
|
77
|
+
data: string;
|
|
78
|
+
driverParam: string;
|
|
79
|
+
enumValues: undefined;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
28
82
|
export declare function generateBase36Id(): string;
|
|
29
83
|
export declare const nullableText: {
|
|
30
84
|
(): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
|
package/dist/types.js
CHANGED
|
@@ -1,14 +1,140 @@
|
|
|
1
1
|
import { customType } from "drizzle-orm/pg-core";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
const base36Digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
const hexDigits = "0123456789abcdef";
|
|
4
|
+
const base36Values = (() => {
|
|
5
|
+
const table = new Int8Array(128).fill(-1);
|
|
6
|
+
for (let i = 0; i < base36Digits.length; i += 1)
|
|
7
|
+
table[base36Digits.charCodeAt(i)] = i;
|
|
8
|
+
return table;
|
|
9
|
+
})();
|
|
10
|
+
const hexValues = (() => {
|
|
11
|
+
const table = new Int8Array(128).fill(-1);
|
|
12
|
+
for (let i = 0; i < hexDigits.length; i += 1) {
|
|
13
|
+
table[hexDigits.charCodeAt(i)] = i;
|
|
14
|
+
table[hexDigits.toUpperCase().charCodeAt(i)] = i;
|
|
15
|
+
}
|
|
16
|
+
return table;
|
|
17
|
+
})();
|
|
18
|
+
const hexOctets = (() => {
|
|
19
|
+
const table = [];
|
|
20
|
+
for (let i = 0; i < 256; i += 1)
|
|
21
|
+
table.push(i.toString(16).padStart(2, "0"));
|
|
22
|
+
return table;
|
|
23
|
+
})();
|
|
24
|
+
const base36Scales = [1, 36, 1296, 46656, 1679616, 60466176];
|
|
25
|
+
function readBase36(id, start, count) {
|
|
26
|
+
let value = 0;
|
|
27
|
+
for (let i = start; i < start + count; i += 1) {
|
|
28
|
+
const code = id.charCodeAt(i);
|
|
29
|
+
const digit = code < 128 ? base36Values[code] : -1;
|
|
30
|
+
if (digit < 0)
|
|
31
|
+
throw new Error(`Not a base36 uuid: ${id}`);
|
|
32
|
+
value = value * 36 + digit;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function scaleAndAdd(limbs, scale, addend) {
|
|
37
|
+
let carry = addend;
|
|
38
|
+
for (let i = 7; i >= 0; i -= 1) {
|
|
39
|
+
const product = limbs[i] * scale + carry;
|
|
40
|
+
const low = product % 65536;
|
|
41
|
+
limbs[i] = low;
|
|
42
|
+
carry = (product - low) / 65536;
|
|
43
|
+
}
|
|
44
|
+
return carry;
|
|
45
|
+
}
|
|
46
|
+
function base36ToBytes(id) {
|
|
47
|
+
if (id.length === 0 || id.length > 25)
|
|
48
|
+
throw new Error(`Not a base36 uuid: ${id}`);
|
|
49
|
+
const limbs = new Uint32Array(8);
|
|
50
|
+
const head = id.length % 5;
|
|
51
|
+
if (head > 0 && scaleAndAdd(limbs, base36Scales[head], readBase36(id, 0, head)) !== 0) {
|
|
52
|
+
throw new Error(`base36 uuid does not fit in 128 bits: ${id}`);
|
|
53
|
+
}
|
|
54
|
+
for (let cursor = head; cursor < id.length; cursor += 5) {
|
|
55
|
+
if (scaleAndAdd(limbs, 60466176, readBase36(id, cursor, 5)) !== 0) {
|
|
56
|
+
throw new Error(`base36 uuid does not fit in 128 bits: ${id}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const bytes = new Uint8Array(16);
|
|
60
|
+
for (let i = 0; i < 8; i += 1) {
|
|
61
|
+
bytes[i * 2] = limbs[i] >>> 8;
|
|
62
|
+
bytes[i * 2 + 1] = limbs[i] & 0xff;
|
|
63
|
+
}
|
|
64
|
+
return bytes;
|
|
65
|
+
}
|
|
66
|
+
function bytesToBase36(bytes) {
|
|
67
|
+
if (bytes.length !== 16)
|
|
68
|
+
throw new Error(`Not a 16-byte uuid: ${bytes.length} bytes`);
|
|
69
|
+
const limbs = new Uint32Array(8);
|
|
70
|
+
for (let i = 0; i < 8; i += 1)
|
|
71
|
+
limbs[i] = (bytes[i * 2] << 8) | bytes[i * 2 + 1];
|
|
72
|
+
let id = "";
|
|
73
|
+
for (let chunk = 0; chunk < 5; chunk += 1) {
|
|
74
|
+
let remainder = 0;
|
|
75
|
+
for (let i = 0; i < 8; i += 1) {
|
|
76
|
+
const current = remainder * 65536 + limbs[i];
|
|
77
|
+
const quotient = Math.floor(current / 60466176);
|
|
78
|
+
limbs[i] = quotient;
|
|
79
|
+
remainder = current - quotient * 60466176;
|
|
80
|
+
}
|
|
81
|
+
let piece = "";
|
|
82
|
+
for (let i = 0; i < 5; i += 1) {
|
|
83
|
+
const digit = remainder % 36;
|
|
84
|
+
piece = base36Digits[digit] + piece;
|
|
85
|
+
remainder = (remainder - digit) / 36;
|
|
86
|
+
}
|
|
87
|
+
id = piece + id;
|
|
88
|
+
}
|
|
89
|
+
return id;
|
|
90
|
+
}
|
|
91
|
+
function uuidToBytes(uuid) {
|
|
92
|
+
const bytes = new Uint8Array(16);
|
|
93
|
+
let cursor = 0;
|
|
94
|
+
for (let i = 0; i < 16; i += 1) {
|
|
95
|
+
if (uuid.charCodeAt(cursor) === 45)
|
|
96
|
+
cursor += 1;
|
|
97
|
+
const high = readHex(uuid, cursor);
|
|
98
|
+
const low = readHex(uuid, cursor + 1);
|
|
99
|
+
bytes[i] = (high << 4) | low;
|
|
100
|
+
cursor += 2;
|
|
101
|
+
}
|
|
102
|
+
if (cursor !== uuid.length)
|
|
103
|
+
throw new Error(`Not a uuid: ${uuid}`);
|
|
104
|
+
return bytes;
|
|
105
|
+
}
|
|
106
|
+
function readHex(uuid, index) {
|
|
107
|
+
const code = uuid.charCodeAt(index);
|
|
108
|
+
const value = code < 128 ? hexValues[code] : -1;
|
|
109
|
+
if (value < 0)
|
|
110
|
+
throw new Error(`Not a uuid: ${uuid}`);
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function bytesToUuid(bytes) {
|
|
114
|
+
return `${hexOctets[bytes[0]]}${hexOctets[bytes[1]]}${hexOctets[bytes[2]]}${hexOctets[bytes[3]]}-${hexOctets[bytes[4]]}${hexOctets[bytes[5]]}-${hexOctets[bytes[6]]}${hexOctets[bytes[7]]}-${hexOctets[bytes[8]]}${hexOctets[bytes[9]]}-${hexOctets[bytes[10]]}${hexOctets[bytes[11]]}${hexOctets[bytes[12]]}${hexOctets[bytes[13]]}${hexOctets[bytes[14]]}${hexOctets[bytes[15]]}`;
|
|
115
|
+
}
|
|
116
|
+
/** UUID column stored as native pg uuid, reads/writes as base36 */
|
|
117
|
+
export const canonicalUuid = customType({
|
|
118
|
+
dataType: () => "uuid",
|
|
119
|
+
toDriver: (value) => bytesToUuid(base36ToBytes(value)),
|
|
120
|
+
fromDriver: (value) => bytesToBase36(uuidToBytes(value)),
|
|
121
|
+
});
|
|
122
|
+
/** UUID column stored as the 25-character base36 string, reads/writes as base36 */
|
|
5
123
|
export const base36Uuid = customType({
|
|
124
|
+
dataType: () => "text",
|
|
125
|
+
});
|
|
126
|
+
/** UUID column stored as native pg uuid — 16 bytes on disk — reads/writes as base36 */
|
|
127
|
+
export const rawUuid = customType({
|
|
6
128
|
dataType: () => "uuid",
|
|
7
|
-
toDriver: (value) =>
|
|
8
|
-
fromDriver: (value) =>
|
|
129
|
+
toDriver: (value) => bytesToUuid(base36ToBytes(value)),
|
|
130
|
+
fromDriver: (value) => bytesToBase36(uuidToBytes(value)),
|
|
9
131
|
});
|
|
10
132
|
export function generateBase36Id() {
|
|
11
|
-
|
|
133
|
+
const bytes = new Uint8Array(16);
|
|
134
|
+
crypto.getRandomValues(bytes);
|
|
135
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
136
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
137
|
+
return bytesToBase36(bytes);
|
|
12
138
|
}
|
|
13
139
|
export const nullableText = customType({
|
|
14
140
|
dataType: () => "text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/drizzle-pg-schema",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"prepare": "tsc"
|
|
17
17
|
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"short-uuid": "^5.2.0"
|
|
20
|
-
},
|
|
21
18
|
"peerDependencies": {
|
|
22
19
|
"drizzle-orm": ">=0.30.0",
|
|
23
20
|
"typescript": ">=5.0.0"
|
package/schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bigint, boolean,
|
|
1
|
+
import { bigint, boolean, index, integer, jsonb, pgTable, primaryKey, text, uniqueIndex } from "drizzle-orm/pg-core";
|
|
2
2
|
import { generateBase36Id, nullableBigint, nullableInteger, nullableText } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export const accountExportRequests = pgTable(
|
|
@@ -52,6 +52,25 @@ export const quarantines = pgTable(
|
|
|
52
52
|
],
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
+
export const syncWarnings = pgTable(
|
|
56
|
+
"sync_warning",
|
|
57
|
+
{
|
|
58
|
+
syncWarningId: text("sync_warning_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
59
|
+
accountConfigId: text("account_config_id").notNull(),
|
|
60
|
+
accountId: text("account_id").notNull(),
|
|
61
|
+
mailboxId: text("mailbox_id").notNull(),
|
|
62
|
+
uidValidity: bigint("uid_validity", { mode: "number" }).notNull(),
|
|
63
|
+
uid: bigint("uid", { mode: "number" }).notNull(),
|
|
64
|
+
stage: text("stage").$type<"Header" | "Body">().notNull(),
|
|
65
|
+
attempts: integer("attempts").notNull(),
|
|
66
|
+
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
67
|
+
},
|
|
68
|
+
(table) => [
|
|
69
|
+
index("sync_warning_by_mailbox_id").on(table.mailboxId),
|
|
70
|
+
index("sync_warning_by_account_config_id").on(table.accountConfigId, table.createdAt),
|
|
71
|
+
],
|
|
72
|
+
);
|
|
73
|
+
|
|
55
74
|
export const accountConfigs = pgTable(
|
|
56
75
|
"account_config",
|
|
57
76
|
{
|
|
@@ -156,11 +175,10 @@ export const filters = pgTable(
|
|
|
156
175
|
ttl: nullableBigint("ttl"),
|
|
157
176
|
state: text("state").$type<"Active" | "Expired" | "Disabled">().notNull().default("Active"),
|
|
158
177
|
disabledReason: text("disabled_reason").$type<"None" | "UserDisabled" | "AwaitingFolder" | "FolderCreateFailed" | "FolderMissing">().notNull().default("None"),
|
|
159
|
-
hasAnchor: boolean("has_anchor").notNull().default(false),
|
|
160
178
|
ruleChangedAt: bigint("rule_changed_at", { mode: "number" }).notNull(),
|
|
161
179
|
actionChangedAt: bigint("action_changed_at", { mode: "number" }).notNull(),
|
|
162
180
|
matchOperator: text("match_operator").$type<"And" | "Or">().notNull().default("And"),
|
|
163
|
-
literalClauses: jsonb("literal_clauses").notNull()
|
|
181
|
+
literalClauses: jsonb("literal_clauses").notNull(),
|
|
164
182
|
actionLabelId: text("action_label_id").notNull().default("None"),
|
|
165
183
|
actionMailboxId: text("action_mailbox_id").notNull().default("None"),
|
|
166
184
|
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
@@ -197,10 +215,8 @@ export const organizeJobRequests = pgTable(
|
|
|
197
215
|
userId: text("user_id").notNull(),
|
|
198
216
|
state: text("state").$type<"Pending" | "Running" | "Complete" | "Failed">().notNull().default("Pending"),
|
|
199
217
|
filterId: text("filter_id").notNull().default("None"),
|
|
200
|
-
anchorMessageId: text("anchor_message_id").notNull().default("None"),
|
|
201
218
|
matchOperator: text("match_operator").$type<"And" | "Or">().notNull().default("And"),
|
|
202
219
|
literalClauses: jsonb("literal_clauses").notNull().default([]),
|
|
203
|
-
similarityThreshold: doublePrecision("similarity_threshold").notNull().default(0.75),
|
|
204
220
|
actionLabelId: text("action_label_id").notNull().default("None"),
|
|
205
221
|
actionMailboxId: text("action_mailbox_id").notNull().default("None"),
|
|
206
222
|
matchedCount: integer("matched_count").notNull().default(0),
|
|
@@ -392,7 +408,7 @@ export const addresses = pgTable(
|
|
|
392
408
|
],
|
|
393
409
|
);
|
|
394
410
|
|
|
395
|
-
export const
|
|
411
|
+
export const messageRecords = pgTable(
|
|
396
412
|
"message",
|
|
397
413
|
{
|
|
398
414
|
messageId: text("message_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
@@ -401,7 +417,6 @@ export const messages = pgTable(
|
|
|
401
417
|
sequenceNumber: integer("sequence_number").notNull(),
|
|
402
418
|
rfc822Size: bigint("rfc822_size", { mode: "number" }).notNull(),
|
|
403
419
|
internalDate: bigint("internal_date", { mode: "number" }).notNull(),
|
|
404
|
-
messageIdHeader: nullableText("message_id_header"),
|
|
405
420
|
envelopeId: text("envelope_id").notNull(),
|
|
406
421
|
rootBodyPartId: text("root_body_part_id").notNull(),
|
|
407
422
|
bodyStorageKey: nullableText("body_storage_key"),
|
|
@@ -719,6 +734,12 @@ export const bodyPartParameters = pgTable(
|
|
|
719
734
|
],
|
|
720
735
|
);
|
|
721
736
|
|
|
737
|
+
export const bodyStructureRefetches = pgTable("body_structure_refetch", {
|
|
738
|
+
messageId: text("message_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
739
|
+
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
740
|
+
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
741
|
+
});
|
|
742
|
+
|
|
722
743
|
export const rawMessageStorages = pgTable(
|
|
723
744
|
"raw_message_storage",
|
|
724
745
|
{
|
|
@@ -763,22 +784,6 @@ export const bodyPartStorages = pgTable(
|
|
|
763
784
|
],
|
|
764
785
|
);
|
|
765
786
|
|
|
766
|
-
export const bodyPartContents = pgTable(
|
|
767
|
-
"body_part_content",
|
|
768
|
-
{
|
|
769
|
-
bodyPartContentId: text("body_part_content_id").primaryKey().$defaultFn(() => generateBase36Id()),
|
|
770
|
-
messageId: text("message_id").notNull(),
|
|
771
|
-
bodyPartId: text("body_part_id").notNull(),
|
|
772
|
-
content: text("content").notNull(),
|
|
773
|
-
contentLength: bigint("content_length", { mode: "number" }).notNull(),
|
|
774
|
-
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
775
|
-
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
776
|
-
},
|
|
777
|
-
(table) => [
|
|
778
|
-
index("body_part_content_by_message_id").on(table.messageId, table.bodyPartContentId),
|
|
779
|
-
],
|
|
780
|
-
);
|
|
781
|
-
|
|
782
787
|
export const calendarEventIndexes = pgTable(
|
|
783
788
|
"calendar_event_index",
|
|
784
789
|
{
|
|
@@ -833,20 +838,3 @@ export const messageLabels = pgTable(
|
|
|
833
838
|
index("message_label_by_message_id").on(table.messageId, table.labelId),
|
|
834
839
|
],
|
|
835
840
|
);
|
|
836
|
-
|
|
837
|
-
export const filterAnchors = pgTable(
|
|
838
|
-
"filter_anchor",
|
|
839
|
-
{
|
|
840
|
-
accountConfigId: text("account_config_id").notNull(),
|
|
841
|
-
filterId: text("filter_id").notNull(),
|
|
842
|
-
anchorEmbedding: jsonb("anchor_embedding").notNull(),
|
|
843
|
-
anchorEmbeddingId: text("anchor_embedding_id").notNull(),
|
|
844
|
-
anchorSourceText: text("anchor_source_text").notNull(),
|
|
845
|
-
anchorMessageId: text("anchor_message_id").notNull(),
|
|
846
|
-
createdAt: bigint("created_at", { mode: "number" }).notNull(),
|
|
847
|
-
updatedAt: bigint("updated_at", { mode: "number" }).notNull(),
|
|
848
|
-
},
|
|
849
|
-
(table) => [
|
|
850
|
-
primaryKey({ name: "filter_anchor_pk", columns: [table.accountConfigId, table.filterId] }),
|
|
851
|
-
],
|
|
852
|
-
);
|
package/types.ts
CHANGED
|
@@ -1,20 +1,156 @@
|
|
|
1
1
|
import { customType } from "drizzle-orm/pg-core";
|
|
2
|
-
import short from "short-uuid";
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
const base36Digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
4
|
+
const hexDigits = "0123456789abcdef";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const base36Values = ((): Int8Array => {
|
|
7
|
+
const table = new Int8Array(128).fill(-1);
|
|
8
|
+
for (let i = 0; i < base36Digits.length; i += 1) table[base36Digits.charCodeAt(i)] = i;
|
|
9
|
+
return table;
|
|
10
|
+
})();
|
|
11
|
+
|
|
12
|
+
const hexValues = ((): Int8Array => {
|
|
13
|
+
const table = new Int8Array(128).fill(-1);
|
|
14
|
+
for (let i = 0; i < hexDigits.length; i += 1) {
|
|
15
|
+
table[hexDigits.charCodeAt(i)] = i;
|
|
16
|
+
table[hexDigits.toUpperCase().charCodeAt(i)] = i;
|
|
17
|
+
}
|
|
18
|
+
return table;
|
|
19
|
+
})();
|
|
20
|
+
|
|
21
|
+
const hexOctets = ((): string[] => {
|
|
22
|
+
const table: string[] = [];
|
|
23
|
+
for (let i = 0; i < 256; i += 1) table.push(i.toString(16).padStart(2, "0"));
|
|
24
|
+
return table;
|
|
25
|
+
})();
|
|
26
|
+
|
|
27
|
+
const base36Scales = [1, 36, 1296, 46656, 1679616, 60466176];
|
|
28
|
+
|
|
29
|
+
function readBase36(id: string, start: number, count: number): number {
|
|
30
|
+
let value = 0;
|
|
31
|
+
for (let i = start; i < start + count; i += 1) {
|
|
32
|
+
const code = id.charCodeAt(i);
|
|
33
|
+
const digit = code < 128 ? base36Values[code] : -1;
|
|
34
|
+
if (digit < 0) throw new Error(`Not a base36 uuid: ${id}`);
|
|
35
|
+
value = value * 36 + digit;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function scaleAndAdd(limbs: Uint32Array, scale: number, addend: number): number {
|
|
41
|
+
let carry = addend;
|
|
42
|
+
for (let i = 7; i >= 0; i -= 1) {
|
|
43
|
+
const product = limbs[i] * scale + carry;
|
|
44
|
+
const low = product % 65536;
|
|
45
|
+
limbs[i] = low;
|
|
46
|
+
carry = (product - low) / 65536;
|
|
47
|
+
}
|
|
48
|
+
return carry;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function base36ToBytes(id: string): Uint8Array {
|
|
52
|
+
if (id.length === 0 || id.length > 25) throw new Error(`Not a base36 uuid: ${id}`);
|
|
53
|
+
const limbs = new Uint32Array(8);
|
|
54
|
+
const head = id.length % 5;
|
|
55
|
+
if (head > 0 && scaleAndAdd(limbs, base36Scales[head], readBase36(id, 0, head)) !== 0) {
|
|
56
|
+
throw new Error(`base36 uuid does not fit in 128 bits: ${id}`);
|
|
57
|
+
}
|
|
58
|
+
for (let cursor = head; cursor < id.length; cursor += 5) {
|
|
59
|
+
if (scaleAndAdd(limbs, 60466176, readBase36(id, cursor, 5)) !== 0) {
|
|
60
|
+
throw new Error(`base36 uuid does not fit in 128 bits: ${id}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const bytes = new Uint8Array(16);
|
|
64
|
+
for (let i = 0; i < 8; i += 1) {
|
|
65
|
+
bytes[i * 2] = limbs[i] >>> 8;
|
|
66
|
+
bytes[i * 2 + 1] = limbs[i] & 0xff;
|
|
67
|
+
}
|
|
68
|
+
return bytes;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function bytesToBase36(bytes: Uint8Array): string {
|
|
72
|
+
if (bytes.length !== 16) throw new Error(`Not a 16-byte uuid: ${bytes.length} bytes`);
|
|
73
|
+
const limbs = new Uint32Array(8);
|
|
74
|
+
for (let i = 0; i < 8; i += 1) limbs[i] = (bytes[i * 2] << 8) | bytes[i * 2 + 1];
|
|
75
|
+
let id = "";
|
|
76
|
+
for (let chunk = 0; chunk < 5; chunk += 1) {
|
|
77
|
+
let remainder = 0;
|
|
78
|
+
for (let i = 0; i < 8; i += 1) {
|
|
79
|
+
const current = remainder * 65536 + limbs[i];
|
|
80
|
+
const quotient = Math.floor(current / 60466176);
|
|
81
|
+
limbs[i] = quotient;
|
|
82
|
+
remainder = current - quotient * 60466176;
|
|
83
|
+
}
|
|
84
|
+
let piece = "";
|
|
85
|
+
for (let i = 0; i < 5; i += 1) {
|
|
86
|
+
const digit = remainder % 36;
|
|
87
|
+
piece = base36Digits[digit] + piece;
|
|
88
|
+
remainder = (remainder - digit) / 36;
|
|
89
|
+
}
|
|
90
|
+
id = piece + id;
|
|
91
|
+
}
|
|
92
|
+
return id;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function uuidToBytes(uuid: string): Uint8Array {
|
|
96
|
+
const bytes = new Uint8Array(16);
|
|
97
|
+
let cursor = 0;
|
|
98
|
+
for (let i = 0; i < 16; i += 1) {
|
|
99
|
+
if (uuid.charCodeAt(cursor) === 45) cursor += 1;
|
|
100
|
+
const high = readHex(uuid, cursor);
|
|
101
|
+
const low = readHex(uuid, cursor + 1);
|
|
102
|
+
bytes[i] = (high << 4) | low;
|
|
103
|
+
cursor += 2;
|
|
104
|
+
}
|
|
105
|
+
if (cursor !== uuid.length) throw new Error(`Not a uuid: ${uuid}`);
|
|
106
|
+
return bytes;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function readHex(uuid: string, index: number): number {
|
|
110
|
+
const code = uuid.charCodeAt(index);
|
|
111
|
+
const value = code < 128 ? hexValues[code] : -1;
|
|
112
|
+
if (value < 0) throw new Error(`Not a uuid: ${uuid}`);
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function bytesToUuid(bytes: Uint8Array): string {
|
|
117
|
+
return `${hexOctets[bytes[0]]}${hexOctets[bytes[1]]}${hexOctets[bytes[2]]}${hexOctets[bytes[3]]}-${hexOctets[bytes[4]]}${hexOctets[bytes[5]]}-${hexOctets[bytes[6]]}${hexOctets[bytes[7]]}-${hexOctets[bytes[8]]}${hexOctets[bytes[9]]}-${hexOctets[bytes[10]]}${hexOctets[bytes[11]]}${hexOctets[bytes[12]]}${hexOctets[bytes[13]]}${hexOctets[bytes[14]]}${hexOctets[bytes[15]]}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** UUID column stored as native pg uuid, reads/writes as base36 */
|
|
121
|
+
export const canonicalUuid = customType<{
|
|
122
|
+
data: string;
|
|
123
|
+
driverData: string;
|
|
124
|
+
}>({
|
|
125
|
+
dataType: () => "uuid",
|
|
126
|
+
toDriver: (value: string): string => bytesToUuid(base36ToBytes(value)),
|
|
127
|
+
fromDriver: (value: string): string => bytesToBase36(uuidToBytes(value)),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/** UUID column stored as the 25-character base36 string, reads/writes as base36 */
|
|
7
131
|
export const base36Uuid = customType<{
|
|
8
132
|
data: string;
|
|
9
133
|
driverData: string;
|
|
134
|
+
}>({
|
|
135
|
+
dataType: () => "text",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
/** UUID column stored as native pg uuid — 16 bytes on disk — reads/writes as base36 */
|
|
139
|
+
export const rawUuid = customType<{
|
|
140
|
+
data: string;
|
|
141
|
+
driverData: string;
|
|
10
142
|
}>({
|
|
11
143
|
dataType: () => "uuid",
|
|
12
|
-
toDriver: (value: string): string =>
|
|
13
|
-
fromDriver: (value: string): string =>
|
|
144
|
+
toDriver: (value: string): string => bytesToUuid(base36ToBytes(value)),
|
|
145
|
+
fromDriver: (value: string): string => bytesToBase36(uuidToBytes(value)),
|
|
14
146
|
});
|
|
15
147
|
|
|
16
148
|
export function generateBase36Id(): string {
|
|
17
|
-
|
|
149
|
+
const bytes = new Uint8Array(16);
|
|
150
|
+
crypto.getRandomValues(bytes);
|
|
151
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
152
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
153
|
+
return bytesToBase36(bytes);
|
|
18
154
|
}
|
|
19
155
|
|
|
20
156
|
export const nullableText = customType<{
|