@authhero/drizzle 1.7.0 → 1.7.2
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/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +247 -215
- package/drizzle/0008_client_grants_unique_audience.sql +18 -0
- package/drizzle/meta/0008_snapshot.json +6652 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +3 -3
- package/src/schema/sqlite/clients.ts +7 -0
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -431,10 +431,14 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
431
431
|
authorization_details_types: T("authorization_details_types").default("[]"),
|
|
432
432
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
433
433
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
434
|
-
}, (e) => [
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
}, (e) => [
|
|
435
|
+
C({
|
|
436
|
+
columns: [e.tenant_id, e.id],
|
|
437
|
+
name: "pk_client_grants"
|
|
438
|
+
}),
|
|
439
|
+
x("idx_client_grants_audience").on(e.audience),
|
|
440
|
+
re("uq_client_grants_tenant_client_audience").on(e.tenant_id, e.client_id, e.audience)
|
|
441
|
+
]), z = w("grants", {
|
|
438
442
|
id: T("id", { length: 21 }).primaryKey(),
|
|
439
443
|
tenant_id: T("tenant_id", { length: 255 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
440
444
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -470,7 +474,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
470
474
|
C({ columns: [e.tenant_id, e.id] }),
|
|
471
475
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
472
476
|
re("connections_id_unique").on(e.id)
|
|
473
|
-
]),
|
|
477
|
+
]), V = w("custom_domains", {
|
|
474
478
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
475
479
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
476
480
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -484,7 +488,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
484
488
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
485
489
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
486
490
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
487
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
491
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), We = w("domains", {
|
|
488
492
|
id: T("id", { length: 255 }).primaryKey(),
|
|
489
493
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
490
494
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -494,7 +498,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
494
498
|
dkim_public_key: T("dkim_public_key", { length: 2048 }),
|
|
495
499
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
496
500
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
497
|
-
}),
|
|
501
|
+
}), H = w("organizations", {
|
|
498
502
|
id: T("id", { length: 21 }).primaryKey(),
|
|
499
503
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
500
504
|
name: T("name", { length: 256 }).notNull(),
|
|
@@ -505,7 +509,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
505
509
|
token_quota: T("token_quota"),
|
|
506
510
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
507
511
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
508
|
-
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]),
|
|
512
|
+
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]), U = w("user_organizations", {
|
|
509
513
|
id: T("id", { length: 21 }).primaryKey(),
|
|
510
514
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
511
515
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
@@ -517,7 +521,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
517
521
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
518
522
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
519
523
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
520
|
-
]),
|
|
524
|
+
]), Ge = w("invites", {
|
|
521
525
|
id: T("id", { length: 21 }).primaryKey(),
|
|
522
526
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
523
527
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -539,7 +543,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
539
543
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
540
544
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
541
545
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
542
|
-
]),
|
|
546
|
+
]), W = w("roles", {
|
|
543
547
|
id: T("id", { length: 21 }).notNull(),
|
|
544
548
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
545
549
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -551,7 +555,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
551
555
|
}, (e) => [C({
|
|
552
556
|
columns: [e.tenant_id, e.id],
|
|
553
557
|
name: "roles_pk"
|
|
554
|
-
})]),
|
|
558
|
+
})]), Ke = w("role_permissions", {
|
|
555
559
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
556
560
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
557
561
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -569,7 +573,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
569
573
|
}),
|
|
570
574
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
571
575
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
572
|
-
]),
|
|
576
|
+
]), qe = w("user_permissions", {
|
|
573
577
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
574
578
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
575
579
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -590,7 +594,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
590
594
|
x("user_permissions_user_fk").on(e.tenant_id, e.user_id),
|
|
591
595
|
x("user_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name),
|
|
592
596
|
x("user_permissions_organization_fk").on(e.organization_id)
|
|
593
|
-
]),
|
|
597
|
+
]), G = w("user_roles", {
|
|
594
598
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
595
599
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
596
600
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
@@ -609,7 +613,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
609
613
|
x("user_roles_user_fk").on(e.tenant_id, e.user_id),
|
|
610
614
|
x("user_roles_role_fk").on(e.tenant_id, e.role_id),
|
|
611
615
|
x("user_roles_organization_fk").on(e.organization_id)
|
|
612
|
-
]),
|
|
616
|
+
]), K = w("resource_servers", {
|
|
613
617
|
id: T("id", { length: 21 }).notNull(),
|
|
614
618
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
615
619
|
identifier: T("identifier", { length: 191 }).notNull(),
|
|
@@ -630,7 +634,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
630
634
|
}, (e) => [C({
|
|
631
635
|
columns: [e.tenant_id, e.id],
|
|
632
636
|
name: "resource_servers_pk"
|
|
633
|
-
})]),
|
|
637
|
+
})]), Je = w("branding", {
|
|
634
638
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
635
639
|
logo_url: T("logo_url", { length: 512 }),
|
|
636
640
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -641,12 +645,12 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
641
645
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
642
646
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
643
647
|
dark_mode: T("dark_mode", { length: 8 })
|
|
644
|
-
}),
|
|
648
|
+
}), Ye = w("universal_login_templates", {
|
|
645
649
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
646
650
|
body: T("body").notNull(),
|
|
647
651
|
created_at_ts: S("created_at_ts").notNull(),
|
|
648
652
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
649
|
-
}),
|
|
653
|
+
}), Xe = w("themes", {
|
|
650
654
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
651
655
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
652
656
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -706,7 +710,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
706
710
|
}, (e) => [C({
|
|
707
711
|
columns: [e.tenant_id, e.themeId],
|
|
708
712
|
name: "themes_pkey"
|
|
709
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
713
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), Ze = w("forms", {
|
|
710
714
|
id: T("id", { length: 255 }).primaryKey(),
|
|
711
715
|
name: T("name", { length: 255 }).notNull(),
|
|
712
716
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -719,21 +723,21 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
719
723
|
style: T("style", { length: 1042 }),
|
|
720
724
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
721
725
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
722
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
726
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Qe = w("flows", {
|
|
723
727
|
id: T("id", { length: 24 }).primaryKey(),
|
|
724
728
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
725
729
|
name: T("name", { length: 150 }).notNull(),
|
|
726
730
|
actions: T("actions"),
|
|
727
731
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
728
732
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
729
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
733
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), $e = w("prompt_settings", {
|
|
730
734
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
731
735
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
732
736
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
733
737
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
734
738
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
735
739
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
736
|
-
}),
|
|
740
|
+
}), et = w("email_providers", {
|
|
737
741
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
738
742
|
name: T("name", { length: 255 }).notNull(),
|
|
739
743
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -742,7 +746,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
742
746
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
743
747
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
744
748
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
745
|
-
}),
|
|
749
|
+
}), tt = w("email_templates", {
|
|
746
750
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
747
751
|
template: T("template", { length: 64 }).notNull(),
|
|
748
752
|
body: T("body").notNull(),
|
|
@@ -755,7 +759,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
755
759
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
756
760
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
757
761
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
758
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
762
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), nt = w("hooks", {
|
|
759
763
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
760
764
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
761
765
|
url: T("url", { length: 512 }),
|
|
@@ -771,14 +775,14 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
771
775
|
page_id: T("page_id", { length: 64 }),
|
|
772
776
|
permission_required: T("permission_required", { length: 255 }),
|
|
773
777
|
metadata: T("metadata")
|
|
774
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
778
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), rt = w("hook_code", {
|
|
775
779
|
id: T("id", { length: 21 }).primaryKey(),
|
|
776
780
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
777
781
|
code: T("code").notNull(),
|
|
778
782
|
secrets: T("secrets"),
|
|
779
783
|
created_at_ts: S("created_at_ts").notNull(),
|
|
780
784
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
781
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
785
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), it = w("keys", {
|
|
782
786
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
783
787
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
784
788
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -791,7 +795,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
791
795
|
current_until: T("current_until", { length: 35 }),
|
|
792
796
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
793
797
|
connection: T("connection", { length: 255 }).references(() => B.id, { onDelete: "cascade" })
|
|
794
|
-
}),
|
|
798
|
+
}), at = w("custom_text", {
|
|
795
799
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
796
800
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
797
801
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -802,7 +806,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
802
806
|
e.tenant_id,
|
|
803
807
|
e.prompt,
|
|
804
808
|
e.language
|
|
805
|
-
] })]),
|
|
809
|
+
] })]), ot = w("authentication_methods", {
|
|
806
810
|
id: T("id", { length: 26 }).primaryKey(),
|
|
807
811
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
808
812
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -919,49 +923,49 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
919
923
|
actionVersions: () => k,
|
|
920
924
|
actions: () => Re,
|
|
921
925
|
authenticationCodes: () => Ve,
|
|
922
|
-
authenticationMethods: () =>
|
|
923
|
-
branding: () =>
|
|
926
|
+
authenticationMethods: () => ot,
|
|
927
|
+
branding: () => Je,
|
|
924
928
|
clientGrants: () => R,
|
|
925
929
|
clientRegistrationTokens: () => L,
|
|
926
930
|
clients: () => I,
|
|
927
931
|
codes: () => F,
|
|
928
932
|
connections: () => B,
|
|
929
|
-
customDomains: () =>
|
|
930
|
-
customText: () =>
|
|
931
|
-
domains: () =>
|
|
932
|
-
emailProviders: () =>
|
|
933
|
-
emailTemplates: () =>
|
|
934
|
-
flows: () =>
|
|
935
|
-
forms: () =>
|
|
933
|
+
customDomains: () => V,
|
|
934
|
+
customText: () => at,
|
|
935
|
+
domains: () => We,
|
|
936
|
+
emailProviders: () => et,
|
|
937
|
+
emailTemplates: () => tt,
|
|
938
|
+
flows: () => Qe,
|
|
939
|
+
forms: () => Ze,
|
|
936
940
|
grants: () => z,
|
|
937
|
-
hookCode: () =>
|
|
938
|
-
hooks: () =>
|
|
939
|
-
invites: () =>
|
|
940
|
-
keys: () =>
|
|
941
|
+
hookCode: () => rt,
|
|
942
|
+
hooks: () => nt,
|
|
943
|
+
invites: () => Ge,
|
|
944
|
+
keys: () => it,
|
|
941
945
|
loginSessions: () => P,
|
|
942
946
|
logs: () => q,
|
|
943
|
-
organizations: () =>
|
|
947
|
+
organizations: () => H,
|
|
944
948
|
otps: () => He,
|
|
945
949
|
outboxEvents: () => J,
|
|
946
950
|
passwords: () => j,
|
|
947
|
-
promptSettings: () =>
|
|
951
|
+
promptSettings: () => $e,
|
|
948
952
|
proxyRoutes: () => Y,
|
|
949
953
|
refreshTokens: () => N,
|
|
950
|
-
resourceServers: () =>
|
|
951
|
-
rolePermissions: () =>
|
|
952
|
-
roles: () =>
|
|
954
|
+
resourceServers: () => K,
|
|
955
|
+
rolePermissions: () => Ke,
|
|
956
|
+
roles: () => W,
|
|
953
957
|
scimConfigurations: () => st,
|
|
954
958
|
scimExternalIds: () => ct,
|
|
955
959
|
scimTokens: () => X,
|
|
956
960
|
sessions: () => M,
|
|
957
961
|
tenants: () => O,
|
|
958
|
-
themes: () =>
|
|
962
|
+
themes: () => Xe,
|
|
959
963
|
tickets: () => Ue,
|
|
960
|
-
universalLoginTemplates: () =>
|
|
964
|
+
universalLoginTemplates: () => Ye,
|
|
961
965
|
userActivity: () => Be,
|
|
962
|
-
userOrganizations: () =>
|
|
963
|
-
userPermissions: () =>
|
|
964
|
-
userRoles: () =>
|
|
966
|
+
userOrganizations: () => U,
|
|
967
|
+
userPermissions: () => qe,
|
|
968
|
+
userRoles: () => G,
|
|
965
969
|
users: () => A
|
|
966
970
|
});
|
|
967
971
|
//#endregion
|
|
@@ -1357,7 +1361,7 @@ function wt(e) {
|
|
|
1357
1361
|
function Tt(e) {
|
|
1358
1362
|
return {
|
|
1359
1363
|
async get(t) {
|
|
1360
|
-
let n = await e.select().from(
|
|
1364
|
+
let n = await e.select().from(Je).where(a(Je.tenant_id, t)).get();
|
|
1361
1365
|
if (!n) return null;
|
|
1362
1366
|
let { tenant_id: r, colors_primary: i, colors_page_background_type: o, colors_page_background_start: s, colors_page_background_end: c, colors_page_background_angle_dev: l, font_url: u, dark_mode: d, ...f } = n;
|
|
1363
1367
|
return D({
|
|
@@ -1386,11 +1390,11 @@ function Tt(e) {
|
|
|
1386
1390
|
font_url: i?.url,
|
|
1387
1391
|
dark_mode: a
|
|
1388
1392
|
};
|
|
1389
|
-
await e.insert(
|
|
1393
|
+
await e.insert(Je).values({
|
|
1390
1394
|
tenant_id: t,
|
|
1391
1395
|
...l
|
|
1392
1396
|
}).onConflictDoUpdate({
|
|
1393
|
-
target:
|
|
1397
|
+
target: Je.tenant_id,
|
|
1394
1398
|
set: l
|
|
1395
1399
|
});
|
|
1396
1400
|
}
|
|
@@ -1705,7 +1709,7 @@ function Bt(e) {
|
|
|
1705
1709
|
if (d?.sort_by) {
|
|
1706
1710
|
let e = R[d.sort_by];
|
|
1707
1711
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1708
|
-
} else h = h.orderBy(
|
|
1712
|
+
} else h = h.orderBy(i(R.created_at), i(R.id));
|
|
1709
1713
|
let g = (await h.offset(c * l).limit(l)).map(zt);
|
|
1710
1714
|
if (!u) return { client_grants: g };
|
|
1711
1715
|
let [_] = await e.select({ count: r() }).from(R).where(m);
|
|
@@ -1917,6 +1921,20 @@ function Qt(e) {
|
|
|
1917
1921
|
let e = mt(B, f, ["name"]);
|
|
1918
1922
|
e && (p = t(p, e));
|
|
1919
1923
|
}
|
|
1924
|
+
if (Et(s)) {
|
|
1925
|
+
let n = {
|
|
1926
|
+
sortColumn: B.created_at,
|
|
1927
|
+
idColumn: B.id,
|
|
1928
|
+
sortOrder: "desc"
|
|
1929
|
+
}, r = kt(s, n), i = Dt(s), { rows: a, next: o } = At(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...Ot(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Zt);
|
|
1930
|
+
return {
|
|
1931
|
+
connections: c,
|
|
1932
|
+
start: 0,
|
|
1933
|
+
limit: i,
|
|
1934
|
+
length: c.length,
|
|
1935
|
+
next: o
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1920
1938
|
let m = e.select().from(B).where(p).$dynamic();
|
|
1921
1939
|
if (d?.sort_by) {
|
|
1922
1940
|
let e = B[d.sort_by];
|
|
@@ -1966,31 +1984,31 @@ function en(e) {
|
|
|
1966
1984
|
created_at: r,
|
|
1967
1985
|
updated_at: r
|
|
1968
1986
|
};
|
|
1969
|
-
return await e.insert(
|
|
1987
|
+
return await e.insert(V).values(i), $t({
|
|
1970
1988
|
...i,
|
|
1971
1989
|
tenant_id: t
|
|
1972
1990
|
});
|
|
1973
1991
|
},
|
|
1974
1992
|
async get(n, r) {
|
|
1975
|
-
let i = await e.select().from(
|
|
1993
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).get();
|
|
1976
1994
|
return i ? $t(i) : null;
|
|
1977
1995
|
},
|
|
1978
1996
|
async getByDomain(t) {
|
|
1979
|
-
let n = await e.select().from(
|
|
1997
|
+
let n = await e.select().from(V).where(a(V.domain, t)).get();
|
|
1980
1998
|
return n ? {
|
|
1981
1999
|
...$t(n),
|
|
1982
2000
|
tenant_id: n.tenant_id
|
|
1983
2001
|
} : null;
|
|
1984
2002
|
},
|
|
1985
2003
|
async list(t) {
|
|
1986
|
-
return (await e.select().from(
|
|
2004
|
+
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map($t);
|
|
1987
2005
|
},
|
|
1988
2006
|
async update(n, r, i) {
|
|
1989
2007
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1990
|
-
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(
|
|
2008
|
+
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(V).set(o).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1991
2009
|
},
|
|
1992
2010
|
async remove(n, r) {
|
|
1993
|
-
return (await e.delete(
|
|
2011
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1994
2012
|
}
|
|
1995
2013
|
};
|
|
1996
2014
|
}
|
|
@@ -1999,7 +2017,7 @@ function en(e) {
|
|
|
1999
2017
|
function tn(e) {
|
|
2000
2018
|
return {
|
|
2001
2019
|
async get(n, r, i) {
|
|
2002
|
-
let o = await e.select().from(
|
|
2020
|
+
let o = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.prompt, r), a(at.language, i))).get();
|
|
2003
2021
|
if (!o) return null;
|
|
2004
2022
|
try {
|
|
2005
2023
|
return JSON.parse(o.custom_text);
|
|
@@ -2009,7 +2027,7 @@ function tn(e) {
|
|
|
2009
2027
|
},
|
|
2010
2028
|
async set(t, n, r, i) {
|
|
2011
2029
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2012
|
-
await e.insert(
|
|
2030
|
+
await e.insert(at).values({
|
|
2013
2031
|
tenant_id: t,
|
|
2014
2032
|
prompt: n,
|
|
2015
2033
|
language: r,
|
|
@@ -2018,9 +2036,9 @@ function tn(e) {
|
|
|
2018
2036
|
updated_at_ts: a
|
|
2019
2037
|
}).onConflictDoUpdate({
|
|
2020
2038
|
target: [
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2039
|
+
at.tenant_id,
|
|
2040
|
+
at.prompt,
|
|
2041
|
+
at.language
|
|
2024
2042
|
],
|
|
2025
2043
|
set: {
|
|
2026
2044
|
custom_text: o,
|
|
@@ -2029,13 +2047,13 @@ function tn(e) {
|
|
|
2029
2047
|
});
|
|
2030
2048
|
},
|
|
2031
2049
|
async delete(n, r, i) {
|
|
2032
|
-
await e.delete(
|
|
2050
|
+
await e.delete(at).where(t(a(at.tenant_id, n), a(at.prompt, r), a(at.language, i)));
|
|
2033
2051
|
},
|
|
2034
2052
|
async list(t) {
|
|
2035
2053
|
return await e.select({
|
|
2036
|
-
prompt:
|
|
2037
|
-
language:
|
|
2038
|
-
}).from(
|
|
2054
|
+
prompt: at.prompt,
|
|
2055
|
+
language: at.language
|
|
2056
|
+
}).from(at).where(a(at.tenant_id, t)).all();
|
|
2039
2057
|
}
|
|
2040
2058
|
};
|
|
2041
2059
|
}
|
|
@@ -2045,7 +2063,7 @@ function nn(e) {
|
|
|
2045
2063
|
return {
|
|
2046
2064
|
async create(t, n) {
|
|
2047
2065
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2048
|
-
await e.insert(
|
|
2066
|
+
await e.insert(et).values({
|
|
2049
2067
|
tenant_id: t,
|
|
2050
2068
|
name: n.name,
|
|
2051
2069
|
enabled: n.enabled,
|
|
@@ -2057,7 +2075,7 @@ function nn(e) {
|
|
|
2057
2075
|
});
|
|
2058
2076
|
},
|
|
2059
2077
|
async get(t) {
|
|
2060
|
-
let n = await e.select().from(
|
|
2078
|
+
let n = await e.select().from(et).where(a(et.tenant_id, t)).get();
|
|
2061
2079
|
if (!n) return null;
|
|
2062
2080
|
let { tenant_id: r, ...i } = n;
|
|
2063
2081
|
return D({
|
|
@@ -2069,10 +2087,10 @@ function nn(e) {
|
|
|
2069
2087
|
},
|
|
2070
2088
|
async update(t, n) {
|
|
2071
2089
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2072
|
-
n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(
|
|
2090
|
+
n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(et).set(r).where(a(et.tenant_id, t));
|
|
2073
2091
|
},
|
|
2074
2092
|
async remove(t) {
|
|
2075
|
-
await e.delete(
|
|
2093
|
+
await e.delete(et).where(a(et.tenant_id, t));
|
|
2076
2094
|
}
|
|
2077
2095
|
};
|
|
2078
2096
|
}
|
|
@@ -2094,15 +2112,15 @@ function rn(e) {
|
|
|
2094
2112
|
function an(e) {
|
|
2095
2113
|
return {
|
|
2096
2114
|
async get(n, r) {
|
|
2097
|
-
let i = await e.select().from(
|
|
2115
|
+
let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.template, r))).get();
|
|
2098
2116
|
return i ? rn(i) : null;
|
|
2099
2117
|
},
|
|
2100
2118
|
async list(t) {
|
|
2101
|
-
return (await e.select().from(
|
|
2119
|
+
return (await e.select().from(tt).where(a(tt.tenant_id, t)).all()).map(rn);
|
|
2102
2120
|
},
|
|
2103
2121
|
async create(t, n) {
|
|
2104
2122
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2105
|
-
return await e.insert(
|
|
2123
|
+
return await e.insert(tt).values({
|
|
2106
2124
|
tenant_id: t,
|
|
2107
2125
|
template: n.template,
|
|
2108
2126
|
body: n.body,
|
|
@@ -2120,11 +2138,11 @@ function an(e) {
|
|
|
2120
2138
|
async update(n, r, i) {
|
|
2121
2139
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2122
2140
|
i.body !== void 0 && (o.body = i.body), i.from !== void 0 && (o.from = i.from), i.subject !== void 0 && (o.subject = i.subject), i.syntax !== void 0 && (o.syntax = i.syntax), i.resultUrl !== void 0 && (o.result_url = i.resultUrl), i.urlLifetimeInSeconds !== void 0 && (o.url_lifetime_in_seconds = i.urlLifetimeInSeconds), i.includeEmailInRedirect !== void 0 && (o.include_email_in_redirect = i.includeEmailInRedirect), i.enabled !== void 0 && (o.enabled = i.enabled);
|
|
2123
|
-
let s = await e.update(
|
|
2141
|
+
let s = await e.update(tt).set(o).where(t(a(tt.tenant_id, n), a(tt.template, r))).run();
|
|
2124
2142
|
return Number(s.changes ?? 0) > 0;
|
|
2125
2143
|
},
|
|
2126
2144
|
async remove(n, r) {
|
|
2127
|
-
let i = await e.delete(
|
|
2145
|
+
let i = await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.template, r))).run();
|
|
2128
2146
|
return Number(i.changes ?? 0) > 0;
|
|
2129
2147
|
}
|
|
2130
2148
|
};
|
|
@@ -2136,7 +2154,7 @@ function sn(e) {
|
|
|
2136
2154
|
return {
|
|
2137
2155
|
async create(t, n) {
|
|
2138
2156
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2139
|
-
return await e.insert(
|
|
2157
|
+
return await e.insert(Qe).values({
|
|
2140
2158
|
id: i,
|
|
2141
2159
|
tenant_id: t,
|
|
2142
2160
|
name: n.name,
|
|
@@ -2152,7 +2170,7 @@ function sn(e) {
|
|
|
2152
2170
|
};
|
|
2153
2171
|
},
|
|
2154
2172
|
async get(n, r) {
|
|
2155
|
-
let i = await e.select().from(
|
|
2173
|
+
let i = await e.select().from(Qe).where(t(a(Qe.tenant_id, n), a(Qe.id, r))).get();
|
|
2156
2174
|
if (!i) return null;
|
|
2157
2175
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2158
2176
|
return D({
|
|
@@ -2162,20 +2180,20 @@ function sn(e) {
|
|
|
2162
2180
|
},
|
|
2163
2181
|
async update(n, r, i) {
|
|
2164
2182
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2165
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2183
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(Qe).set(o).where(t(a(Qe.tenant_id, n), a(Qe.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2166
2184
|
},
|
|
2167
2185
|
async list(o, s) {
|
|
2168
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2186
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Qe.tenant_id, o)];
|
|
2169
2187
|
if (f) {
|
|
2170
2188
|
let e = we(f, on);
|
|
2171
2189
|
if (e) {
|
|
2172
|
-
let t = mt(
|
|
2190
|
+
let t = mt(Qe, e, []);
|
|
2173
2191
|
t && p.push(t);
|
|
2174
2192
|
}
|
|
2175
2193
|
}
|
|
2176
|
-
let m = t(...p), h = e.select().from(
|
|
2194
|
+
let m = t(...p), h = e.select().from(Qe).where(m).$dynamic();
|
|
2177
2195
|
if (d?.sort_by) {
|
|
2178
|
-
let e =
|
|
2196
|
+
let e = Qe[d.sort_by];
|
|
2179
2197
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2180
2198
|
}
|
|
2181
2199
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2186,7 +2204,7 @@ function sn(e) {
|
|
|
2186
2204
|
});
|
|
2187
2205
|
});
|
|
2188
2206
|
if (!u) return { flows: g };
|
|
2189
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2207
|
+
let [_] = await e.select({ count: r() }).from(Qe).where(m);
|
|
2190
2208
|
return {
|
|
2191
2209
|
flows: g,
|
|
2192
2210
|
start: c * l,
|
|
@@ -2195,7 +2213,7 @@ function sn(e) {
|
|
|
2195
2213
|
};
|
|
2196
2214
|
},
|
|
2197
2215
|
async remove(n, r) {
|
|
2198
|
-
return (await e.delete(
|
|
2216
|
+
return (await e.delete(Qe).where(t(a(Qe.tenant_id, n), a(Qe.id, r))).returning()).length > 0;
|
|
2199
2217
|
}
|
|
2200
2218
|
};
|
|
2201
2219
|
}
|
|
@@ -2221,7 +2239,7 @@ function un(e) {
|
|
|
2221
2239
|
updated_at: r
|
|
2222
2240
|
};
|
|
2223
2241
|
for (let e of cn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2224
|
-
return await e.insert(
|
|
2242
|
+
return await e.insert(Ze).values(a), {
|
|
2225
2243
|
id: i,
|
|
2226
2244
|
...n,
|
|
2227
2245
|
created_at: r,
|
|
@@ -2229,7 +2247,7 @@ function un(e) {
|
|
|
2229
2247
|
};
|
|
2230
2248
|
},
|
|
2231
2249
|
async get(n, r) {
|
|
2232
|
-
let i = await e.select().from(
|
|
2250
|
+
let i = await e.select().from(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).get();
|
|
2233
2251
|
if (!i) return null;
|
|
2234
2252
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2235
2253
|
for (let e of cn) c[e] = Z(s[e]);
|
|
@@ -2238,20 +2256,20 @@ function un(e) {
|
|
|
2238
2256
|
async update(n, r, i) {
|
|
2239
2257
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2240
2258
|
for (let [e, t] of Object.entries(i)) t !== void 0 && (cn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2241
|
-
return (await e.update(
|
|
2259
|
+
return (await e.update(Ze).set(o).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2242
2260
|
},
|
|
2243
2261
|
async list(o, s) {
|
|
2244
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2262
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Ze.tenant_id, o)];
|
|
2245
2263
|
if (f) {
|
|
2246
2264
|
let e = we(f, ln);
|
|
2247
2265
|
if (e) {
|
|
2248
|
-
let t = mt(
|
|
2266
|
+
let t = mt(Ze, e, ln);
|
|
2249
2267
|
t && p.push(t);
|
|
2250
2268
|
}
|
|
2251
2269
|
}
|
|
2252
|
-
let m = t(...p), h = e.select().from(
|
|
2270
|
+
let m = t(...p), h = e.select().from(Ze).where(m).$dynamic();
|
|
2253
2271
|
if (d?.sort_by) {
|
|
2254
|
-
let e =
|
|
2272
|
+
let e = Ze[d.sort_by];
|
|
2255
2273
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2256
2274
|
}
|
|
2257
2275
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2260,7 +2278,7 @@ function un(e) {
|
|
|
2260
2278
|
return D(r);
|
|
2261
2279
|
});
|
|
2262
2280
|
if (!u) return { forms: g };
|
|
2263
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2281
|
+
let [_] = await e.select({ count: r() }).from(Ze).where(m);
|
|
2264
2282
|
return {
|
|
2265
2283
|
forms: g,
|
|
2266
2284
|
start: c * l,
|
|
@@ -2269,7 +2287,7 @@ function un(e) {
|
|
|
2269
2287
|
};
|
|
2270
2288
|
},
|
|
2271
2289
|
async remove(n, r) {
|
|
2272
|
-
return (await e.delete(
|
|
2290
|
+
return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2273
2291
|
}
|
|
2274
2292
|
};
|
|
2275
2293
|
}
|
|
@@ -2388,21 +2406,21 @@ function vn(e) {
|
|
|
2388
2406
|
created_at_ts: r,
|
|
2389
2407
|
updated_at_ts: r
|
|
2390
2408
|
};
|
|
2391
|
-
return await e.insert(
|
|
2409
|
+
return await e.insert(rt).values(i), _n({
|
|
2392
2410
|
...i,
|
|
2393
2411
|
tenant_id: t
|
|
2394
2412
|
});
|
|
2395
2413
|
},
|
|
2396
2414
|
async get(n, r) {
|
|
2397
|
-
let i = await e.select().from(
|
|
2415
|
+
let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).get();
|
|
2398
2416
|
return i ? _n(i) : null;
|
|
2399
2417
|
},
|
|
2400
2418
|
async update(n, r, i) {
|
|
2401
2419
|
let o = { updated_at_ts: Date.now() };
|
|
2402
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2420
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(rt).set(o).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2403
2421
|
},
|
|
2404
2422
|
async remove(n, r) {
|
|
2405
|
-
return (await e.delete(
|
|
2423
|
+
return (await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2406
2424
|
}
|
|
2407
2425
|
};
|
|
2408
2426
|
}
|
|
@@ -2452,30 +2470,30 @@ function Sn(e) {
|
|
|
2452
2470
|
created_at_ts: r,
|
|
2453
2471
|
updated_at_ts: r
|
|
2454
2472
|
};
|
|
2455
|
-
return await e.insert(
|
|
2473
|
+
return await e.insert(nt).values(i), xn({
|
|
2456
2474
|
...i,
|
|
2457
2475
|
tenant_id: t
|
|
2458
2476
|
});
|
|
2459
2477
|
},
|
|
2460
2478
|
async get(n, r) {
|
|
2461
|
-
let i = await e.select().from(
|
|
2479
|
+
let i = await e.select().from(nt).where(t(a(nt.tenant_id, n), a(nt.hook_id, r))).get();
|
|
2462
2480
|
return i ? xn(i) : null;
|
|
2463
2481
|
},
|
|
2464
2482
|
async update(n, r, i) {
|
|
2465
2483
|
let o = { updated_at_ts: Date.now() };
|
|
2466
|
-
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(
|
|
2484
|
+
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(nt).set(o).where(t(a(nt.tenant_id, n), a(nt.hook_id, r))).returning()).length > 0;
|
|
2467
2485
|
},
|
|
2468
2486
|
async list(o, s) {
|
|
2469
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? mt(
|
|
2487
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? mt(nt, f, [
|
|
2470
2488
|
"url",
|
|
2471
2489
|
"form_id",
|
|
2472
2490
|
"template_id",
|
|
2473
2491
|
"code_id"
|
|
2474
|
-
]) : void 0, m = p ? t(a(
|
|
2475
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2492
|
+
]) : void 0, m = p ? t(a(nt.tenant_id, o), p) : a(nt.tenant_id, o), h = e.select().from(nt).where(m).$dynamic(), g = d?.sort_by ? nt[d.sort_by] : void 0;
|
|
2493
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(nt.priority), n(nt.created_at_ts));
|
|
2476
2494
|
let _ = (await h.offset(c * l).limit(l)).map(xn);
|
|
2477
2495
|
if (!u) return { hooks: _ };
|
|
2478
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2496
|
+
let [v] = await e.select({ count: r() }).from(nt).where(m);
|
|
2479
2497
|
return {
|
|
2480
2498
|
hooks: _,
|
|
2481
2499
|
start: c * l,
|
|
@@ -2484,7 +2502,7 @@ function Sn(e) {
|
|
|
2484
2502
|
};
|
|
2485
2503
|
},
|
|
2486
2504
|
async remove(n, r) {
|
|
2487
|
-
return (await e.delete(
|
|
2505
|
+
return (await e.delete(nt).where(t(a(nt.tenant_id, n), a(nt.hook_id, r))).returning()).length > 0;
|
|
2488
2506
|
}
|
|
2489
2507
|
};
|
|
2490
2508
|
}
|
|
@@ -2523,7 +2541,7 @@ function En(e) {
|
|
|
2523
2541
|
};
|
|
2524
2542
|
for (let e of wn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2525
2543
|
try {
|
|
2526
|
-
await e.insert(
|
|
2544
|
+
await e.insert(Ge).values(s);
|
|
2527
2545
|
} catch (e) {
|
|
2528
2546
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Fe(409, { message: "Invite already exists" }) : e;
|
|
2529
2547
|
}
|
|
@@ -2533,23 +2551,23 @@ function En(e) {
|
|
|
2533
2551
|
});
|
|
2534
2552
|
},
|
|
2535
2553
|
async get(n, r) {
|
|
2536
|
-
let i = await e.select().from(
|
|
2554
|
+
let i = await e.select().from(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).get();
|
|
2537
2555
|
return i ? Tn(i) : null;
|
|
2538
2556
|
},
|
|
2539
2557
|
async update(n, r, i) {
|
|
2540
2558
|
let o = {};
|
|
2541
2559
|
for (let e of wn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2542
|
-
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(
|
|
2560
|
+
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Ge).set(o).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2543
2561
|
},
|
|
2544
2562
|
async list(t, o) {
|
|
2545
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2563
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Ge).where(a(Ge.tenant_id, t)).$dynamic();
|
|
2546
2564
|
if (u?.sort_by) {
|
|
2547
|
-
let e =
|
|
2565
|
+
let e = Ge[u.sort_by];
|
|
2548
2566
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2549
2567
|
}
|
|
2550
2568
|
let f = (await d.offset(s * c).limit(c)).map(Tn);
|
|
2551
2569
|
if (!l) return { invites: f };
|
|
2552
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2570
|
+
let [p] = await e.select({ count: r() }).from(Ge).where(a(Ge.tenant_id, t));
|
|
2553
2571
|
return {
|
|
2554
2572
|
invites: f,
|
|
2555
2573
|
start: s * c,
|
|
@@ -2558,7 +2576,7 @@ function En(e) {
|
|
|
2558
2576
|
};
|
|
2559
2577
|
},
|
|
2560
2578
|
async remove(n, r) {
|
|
2561
|
-
return (await e.delete(
|
|
2579
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2562
2580
|
}
|
|
2563
2581
|
};
|
|
2564
2582
|
}
|
|
@@ -2574,23 +2592,23 @@ var Dn = [
|
|
|
2574
2592
|
function On(e) {
|
|
2575
2593
|
return {
|
|
2576
2594
|
async create(t) {
|
|
2577
|
-
await e.insert(
|
|
2595
|
+
await e.insert(it).values({
|
|
2578
2596
|
...t,
|
|
2579
2597
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2580
2598
|
});
|
|
2581
2599
|
},
|
|
2582
2600
|
async list(a) {
|
|
2583
|
-
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(
|
|
2601
|
+
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(it.revoked_at, p), f(it.revoked_at))];
|
|
2584
2602
|
if (d) {
|
|
2585
2603
|
let e = we(d, Dn);
|
|
2586
2604
|
if (e) {
|
|
2587
|
-
let t = mt(
|
|
2605
|
+
let t = mt(it, e, Dn);
|
|
2588
2606
|
t && m.push(t);
|
|
2589
2607
|
}
|
|
2590
2608
|
}
|
|
2591
|
-
let h = t(...m), g = e.select().from(
|
|
2609
|
+
let h = t(...m), g = e.select().from(it).where(h).$dynamic();
|
|
2592
2610
|
if (u?.sort_by) {
|
|
2593
|
-
let e =
|
|
2611
|
+
let e = it[u.sort_by];
|
|
2594
2612
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2595
2613
|
}
|
|
2596
2614
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2598,7 +2616,7 @@ function On(e) {
|
|
|
2598
2616
|
return D(n);
|
|
2599
2617
|
});
|
|
2600
2618
|
if (!l) return { signingKeys: _ };
|
|
2601
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2619
|
+
let [y] = await e.select({ count: r() }).from(it).where(h);
|
|
2602
2620
|
return {
|
|
2603
2621
|
signingKeys: _,
|
|
2604
2622
|
start: o * c,
|
|
@@ -2607,7 +2625,7 @@ function On(e) {
|
|
|
2607
2625
|
};
|
|
2608
2626
|
},
|
|
2609
2627
|
async update(t, n) {
|
|
2610
|
-
return (await e.update(
|
|
2628
|
+
return (await e.update(it).set(n).where(a(it.kid, t)).returning()).length > 0;
|
|
2611
2629
|
}
|
|
2612
2630
|
};
|
|
2613
2631
|
}
|
|
@@ -2832,31 +2850,31 @@ function Bn(e) {
|
|
|
2832
2850
|
created_at_ts: r,
|
|
2833
2851
|
updated_at_ts: r
|
|
2834
2852
|
};
|
|
2835
|
-
return await e.insert(
|
|
2853
|
+
return await e.insert(ot).values(i), zn({
|
|
2836
2854
|
...i,
|
|
2837
2855
|
tenant_id: t
|
|
2838
2856
|
});
|
|
2839
2857
|
},
|
|
2840
2858
|
async get(n, r) {
|
|
2841
|
-
let i = await e.select().from(
|
|
2859
|
+
let i = await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.id, r))).get();
|
|
2842
2860
|
return i ? zn(i) : null;
|
|
2843
2861
|
},
|
|
2844
2862
|
async getByCredentialId(n, r) {
|
|
2845
|
-
let i = await e.select().from(
|
|
2863
|
+
let i = await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.credential_id, r))).get();
|
|
2846
2864
|
return i ? zn(i) : null;
|
|
2847
2865
|
},
|
|
2848
2866
|
async list(n, r) {
|
|
2849
|
-
return (await e.select().from(
|
|
2867
|
+
return (await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.user_id, r))).all()).map(zn);
|
|
2850
2868
|
},
|
|
2851
2869
|
async update(n, r, i) {
|
|
2852
2870
|
let o = { updated_at_ts: Date.now() };
|
|
2853
|
-
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(
|
|
2871
|
+
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(ot).set(o).where(t(a(ot.tenant_id, n), a(ot.id, r)));
|
|
2854
2872
|
let s = await this.get(n, r);
|
|
2855
2873
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2856
2874
|
return s;
|
|
2857
2875
|
},
|
|
2858
2876
|
async remove(n, r) {
|
|
2859
|
-
return (await e.delete(
|
|
2877
|
+
return (await e.delete(ot).where(t(a(ot.tenant_id, n), a(ot.id, r))).returning()).length > 0;
|
|
2860
2878
|
}
|
|
2861
2879
|
};
|
|
2862
2880
|
}
|
|
@@ -2892,7 +2910,7 @@ function Wn(e) {
|
|
|
2892
2910
|
updated_at: r
|
|
2893
2911
|
};
|
|
2894
2912
|
try {
|
|
2895
|
-
await e.insert(
|
|
2913
|
+
await e.insert(H).values(i);
|
|
2896
2914
|
} catch (e) {
|
|
2897
2915
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Fe(409, { message: "Organization already exists" }) : e;
|
|
2898
2916
|
}
|
|
@@ -2902,29 +2920,29 @@ function Wn(e) {
|
|
|
2902
2920
|
});
|
|
2903
2921
|
},
|
|
2904
2922
|
async get(n, r) {
|
|
2905
|
-
let i = await e.select().from(
|
|
2906
|
-
return i ||= await e.select().from(
|
|
2923
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
2924
|
+
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ? Un(i) : null;
|
|
2907
2925
|
},
|
|
2908
2926
|
async update(n, r, i) {
|
|
2909
2927
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2910
|
-
return i.name !== void 0 && (o.name = i.name), i.display_name !== void 0 && (o.display_name = i.display_name), i.branding !== void 0 && (o.branding = JSON.stringify(i.branding)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.enabled_connections !== void 0 && (o.enabled_connections = JSON.stringify(i.enabled_connections)), i.token_quota !== void 0 && (o.token_quota = JSON.stringify(i.token_quota)), (await e.update(
|
|
2928
|
+
return i.name !== void 0 && (o.name = i.name), i.display_name !== void 0 && (o.display_name = i.display_name), i.branding !== void 0 && (o.branding = JSON.stringify(i.branding)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.enabled_connections !== void 0 && (o.enabled_connections = JSON.stringify(i.enabled_connections)), i.token_quota !== void 0 && (o.token_quota = JSON.stringify(i.token_quota)), (await e.update(H).set(o).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2911
2929
|
},
|
|
2912
2930
|
async list(o, s) {
|
|
2913
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2931
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(H.tenant_id, o)];
|
|
2914
2932
|
if (f) {
|
|
2915
2933
|
let e = we(f, Vn);
|
|
2916
2934
|
if (e) {
|
|
2917
|
-
let t = mt(
|
|
2935
|
+
let t = mt(H, e, Vn);
|
|
2918
2936
|
t && p.push(t);
|
|
2919
2937
|
}
|
|
2920
2938
|
}
|
|
2921
2939
|
let m = t(...p);
|
|
2922
2940
|
if (Et(s)) {
|
|
2923
2941
|
let n = {
|
|
2924
|
-
sortColumn:
|
|
2925
|
-
idColumn:
|
|
2942
|
+
sortColumn: H.created_at,
|
|
2943
|
+
idColumn: H.id,
|
|
2926
2944
|
sortOrder: "desc"
|
|
2927
|
-
}, r = kt(s, n), i = Dt(s), { rows: a, next: o } = At(await e.select().from(
|
|
2945
|
+
}, r = kt(s, n), i = Dt(s), { rows: a, next: o } = At(await e.select().from(H).where(r ? t(m, r) : m).orderBy(...Ot(n)).limit(i + 1), i, "created_at"), c = a.map(Un);
|
|
2928
2946
|
return {
|
|
2929
2947
|
organizations: c,
|
|
2930
2948
|
start: 0,
|
|
@@ -2934,14 +2952,14 @@ function Wn(e) {
|
|
|
2934
2952
|
next: o
|
|
2935
2953
|
};
|
|
2936
2954
|
}
|
|
2937
|
-
let h = e.select().from(
|
|
2955
|
+
let h = e.select().from(H).where(m).$dynamic();
|
|
2938
2956
|
if (d?.sort_by) {
|
|
2939
|
-
let e =
|
|
2957
|
+
let e = H[d.sort_by];
|
|
2940
2958
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2941
2959
|
}
|
|
2942
2960
|
let g = (await h.offset(c * l).limit(l)).map(Un);
|
|
2943
2961
|
if (!u) return { organizations: g };
|
|
2944
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2962
|
+
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2945
2963
|
return {
|
|
2946
2964
|
organizations: g,
|
|
2947
2965
|
start: c * l,
|
|
@@ -2950,7 +2968,7 @@ function Wn(e) {
|
|
|
2950
2968
|
};
|
|
2951
2969
|
},
|
|
2952
2970
|
async remove(n, r) {
|
|
2953
|
-
return (await e.delete(
|
|
2971
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2954
2972
|
}
|
|
2955
2973
|
};
|
|
2956
2974
|
}
|
|
@@ -3002,7 +3020,7 @@ function Kn(e) {
|
|
|
3002
3020
|
function qn(e) {
|
|
3003
3021
|
return {
|
|
3004
3022
|
async get(t) {
|
|
3005
|
-
let n = await e.select().from(
|
|
3023
|
+
let n = await e.select().from($e).where(a($e.tenant_id, t)).get();
|
|
3006
3024
|
return n ? {
|
|
3007
3025
|
universal_login_experience: n.universal_login_experience,
|
|
3008
3026
|
identifier_first: !!n.identifier_first,
|
|
@@ -3018,7 +3036,7 @@ function qn(e) {
|
|
|
3018
3036
|
};
|
|
3019
3037
|
},
|
|
3020
3038
|
async set(t, n) {
|
|
3021
|
-
await e.insert(
|
|
3039
|
+
await e.insert($e).values({
|
|
3022
3040
|
tenant_id: t,
|
|
3023
3041
|
universal_login_experience: n.universal_login_experience,
|
|
3024
3042
|
identifier_first: n.identifier_first,
|
|
@@ -3026,7 +3044,7 @@ function qn(e) {
|
|
|
3026
3044
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3027
3045
|
show_last_used_connection: n.show_last_used_connection
|
|
3028
3046
|
}).onConflictDoUpdate({
|
|
3029
|
-
target:
|
|
3047
|
+
target: $e.tenant_id,
|
|
3030
3048
|
set: {
|
|
3031
3049
|
universal_login_experience: n.universal_login_experience,
|
|
3032
3050
|
identifier_first: n.identifier_first,
|
|
@@ -3473,38 +3491,52 @@ function mr(e) {
|
|
|
3473
3491
|
updated_at: r
|
|
3474
3492
|
};
|
|
3475
3493
|
for (let e of dr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3476
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(
|
|
3494
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), pr({
|
|
3477
3495
|
...i,
|
|
3478
3496
|
tenant_id: t
|
|
3479
3497
|
});
|
|
3480
3498
|
},
|
|
3481
3499
|
async get(n, r) {
|
|
3482
|
-
let i = await e.select().from(
|
|
3500
|
+
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3483
3501
|
return i ? pr(i) : null;
|
|
3484
3502
|
},
|
|
3485
3503
|
async update(n, r, i) {
|
|
3486
3504
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3487
|
-
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${
|
|
3505
|
+
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${K.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3488
3506
|
for (let e of dr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3489
|
-
return (await e.update(
|
|
3507
|
+
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3490
3508
|
},
|
|
3491
3509
|
async list(o, s) {
|
|
3492
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(
|
|
3510
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(K.tenant_id, o)];
|
|
3493
3511
|
if (f) {
|
|
3494
3512
|
let e = we(f, lr);
|
|
3495
3513
|
if (e) {
|
|
3496
|
-
let t = mt(
|
|
3514
|
+
let t = mt(K, e, lr, ["name", "identifier"]);
|
|
3497
3515
|
t && h.push(t);
|
|
3498
3516
|
}
|
|
3499
3517
|
}
|
|
3500
|
-
|
|
3518
|
+
if (Et(s)) {
|
|
3519
|
+
let n = {
|
|
3520
|
+
sortColumn: K.created_at,
|
|
3521
|
+
idColumn: K.id,
|
|
3522
|
+
sortOrder: "desc"
|
|
3523
|
+
}, r = kt(s, n), i = Dt(s), { rows: a, next: o } = At(await e.select().from(K).where(t(...h, r)).orderBy(...Ot(n)).limit(i + 1), i, "created_at", "id"), c = a.map(pr);
|
|
3524
|
+
return {
|
|
3525
|
+
resource_servers: c,
|
|
3526
|
+
start: 0,
|
|
3527
|
+
limit: i,
|
|
3528
|
+
length: c.length,
|
|
3529
|
+
next: o
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3501
3533
|
if (d?.sort_by && fr.has(d.sort_by)) {
|
|
3502
|
-
let e =
|
|
3534
|
+
let e = K[d.sort_by];
|
|
3503
3535
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3504
3536
|
}
|
|
3505
3537
|
let _ = (await g.offset(p * m).limit(m)).map(pr);
|
|
3506
3538
|
if (!u) return { resource_servers: _ };
|
|
3507
|
-
let [v] = await e.select({ count: r() }).from(
|
|
3539
|
+
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3508
3540
|
return {
|
|
3509
3541
|
resource_servers: _,
|
|
3510
3542
|
start: p * m,
|
|
@@ -3513,7 +3545,7 @@ function mr(e) {
|
|
|
3513
3545
|
};
|
|
3514
3546
|
},
|
|
3515
3547
|
async remove(n, r) {
|
|
3516
|
-
return (await e.delete(
|
|
3548
|
+
return (await e.delete(K).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3517
3549
|
}
|
|
3518
3550
|
};
|
|
3519
3551
|
}
|
|
@@ -3524,7 +3556,7 @@ function hr(e) {
|
|
|
3524
3556
|
async assign(t, n, r) {
|
|
3525
3557
|
if (r.length === 0) return !0;
|
|
3526
3558
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3527
|
-
return await e.insert(
|
|
3559
|
+
return await e.insert(Ke).values(r.map((e) => ({
|
|
3528
3560
|
tenant_id: t,
|
|
3529
3561
|
role_id: n,
|
|
3530
3562
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3534,15 +3566,15 @@ function hr(e) {
|
|
|
3534
3566
|
},
|
|
3535
3567
|
async list(n, r, i) {
|
|
3536
3568
|
let o = await e.select({
|
|
3537
|
-
resource_server_identifier:
|
|
3538
|
-
permission_name:
|
|
3539
|
-
created_at:
|
|
3540
|
-
}).from(
|
|
3569
|
+
resource_server_identifier: Ke.resource_server_identifier,
|
|
3570
|
+
permission_name: Ke.permission_name,
|
|
3571
|
+
created_at: Ke.created_at
|
|
3572
|
+
}).from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3541
3573
|
if (s.length > 0) {
|
|
3542
3574
|
let r = await e.select({
|
|
3543
|
-
identifier:
|
|
3544
|
-
name:
|
|
3545
|
-
}).from(
|
|
3575
|
+
identifier: K.identifier,
|
|
3576
|
+
name: K.name
|
|
3577
|
+
}).from(K).where(t(a(K.tenant_id, n), l(K.identifier, s))).all();
|
|
3546
3578
|
for (let e of r) c.set(e.identifier, e.name);
|
|
3547
3579
|
}
|
|
3548
3580
|
return o.map((e) => ({
|
|
@@ -3552,8 +3584,8 @@ function hr(e) {
|
|
|
3552
3584
|
},
|
|
3553
3585
|
async remove(n, r, i) {
|
|
3554
3586
|
if (i.length === 0) return !0;
|
|
3555
|
-
let o = i.map((e) => t(a(
|
|
3556
|
-
return await e.delete(
|
|
3587
|
+
let o = i.map((e) => t(a(Ke.resource_server_identifier, e.resource_server_identifier), a(Ke.permission_name, e.permission_name)));
|
|
3588
|
+
return await e.delete(Ke).where(t(a(Ke.tenant_id, n), a(Ke.role_id, r), v(...o))).returning(), !0;
|
|
3557
3589
|
}
|
|
3558
3590
|
};
|
|
3559
3591
|
}
|
|
@@ -3563,7 +3595,7 @@ function gr(e) {
|
|
|
3563
3595
|
return {
|
|
3564
3596
|
async create(t, n, r, i) {
|
|
3565
3597
|
try {
|
|
3566
|
-
await e.insert(
|
|
3598
|
+
await e.insert(qe).values({
|
|
3567
3599
|
tenant_id: t,
|
|
3568
3600
|
user_id: n,
|
|
3569
3601
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3578,11 +3610,11 @@ function gr(e) {
|
|
|
3578
3610
|
return !0;
|
|
3579
3611
|
},
|
|
3580
3612
|
async list(n, r, i, o) {
|
|
3581
|
-
let s = [a(
|
|
3582
|
-
o && s.push(a(
|
|
3583
|
-
let c = await e.select().from(
|
|
3613
|
+
let s = [a(qe.tenant_id, n), a(qe.user_id, r)];
|
|
3614
|
+
o && s.push(a(qe.organization_id, o));
|
|
3615
|
+
let c = await e.select().from(qe).where(t(...s)).all();
|
|
3584
3616
|
return await Promise.all(c.map(async (r) => {
|
|
3585
|
-
let i = await e.select({ name:
|
|
3617
|
+
let i = await e.select({ name: K.name }).from(K).where(t(a(K.tenant_id, n), a(K.identifier, r.resource_server_identifier))).get();
|
|
3586
3618
|
return {
|
|
3587
3619
|
resource_server_identifier: r.resource_server_identifier,
|
|
3588
3620
|
permission_name: r.permission_name,
|
|
@@ -3592,7 +3624,7 @@ function gr(e) {
|
|
|
3592
3624
|
}));
|
|
3593
3625
|
},
|
|
3594
3626
|
async remove(n, r, i, o) {
|
|
3595
|
-
return (await e.delete(
|
|
3627
|
+
return (await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.user_id, r), a(qe.resource_server_identifier, i.resource_server_identifier), a(qe.permission_name, i.permission_name), a(qe.organization_id, o || ""))).returning()).length > 0;
|
|
3596
3628
|
}
|
|
3597
3629
|
};
|
|
3598
3630
|
}
|
|
@@ -3619,28 +3651,28 @@ function vr(e) {
|
|
|
3619
3651
|
created_at: r,
|
|
3620
3652
|
updated_at: r
|
|
3621
3653
|
};
|
|
3622
|
-
return await e.insert(
|
|
3654
|
+
return await e.insert(W).values(i), _r({
|
|
3623
3655
|
...i,
|
|
3624
3656
|
tenant_id: t
|
|
3625
3657
|
});
|
|
3626
3658
|
},
|
|
3627
3659
|
async get(n, r) {
|
|
3628
|
-
let i = await e.select().from(
|
|
3660
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3629
3661
|
return i ? _r(i) : null;
|
|
3630
3662
|
},
|
|
3631
3663
|
async update(n, r, i) {
|
|
3632
3664
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3633
|
-
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(
|
|
3665
|
+
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(W).set(o).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3634
3666
|
},
|
|
3635
3667
|
async list(o, s) {
|
|
3636
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? mt(
|
|
3668
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? mt(W, f, ["name"]) : void 0, m = p ? t(a(W.tenant_id, o), p) : a(W.tenant_id, o), h = e.select().from(W).where(m).$dynamic();
|
|
3637
3669
|
if (d?.sort_by) {
|
|
3638
|
-
let e =
|
|
3670
|
+
let e = W[d.sort_by];
|
|
3639
3671
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3640
3672
|
}
|
|
3641
3673
|
let g = (await h.offset(c * l).limit(l)).map(_r);
|
|
3642
3674
|
if (!u) return { roles: g };
|
|
3643
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3675
|
+
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3644
3676
|
return {
|
|
3645
3677
|
roles: g,
|
|
3646
3678
|
start: c * l,
|
|
@@ -3649,7 +3681,7 @@ function vr(e) {
|
|
|
3649
3681
|
};
|
|
3650
3682
|
},
|
|
3651
3683
|
async remove(n, r) {
|
|
3652
|
-
return (await e.delete(
|
|
3684
|
+
return (await e.delete(W).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3653
3685
|
}
|
|
3654
3686
|
};
|
|
3655
3687
|
}
|
|
@@ -3860,21 +3892,21 @@ function jr(e) {
|
|
|
3860
3892
|
created_at: a?.created_at ?? o,
|
|
3861
3893
|
updated_at: a?.updated_at ?? o
|
|
3862
3894
|
};
|
|
3863
|
-
return await e.insert(
|
|
3895
|
+
return await e.insert(Xe).values(c), Ar({
|
|
3864
3896
|
...c,
|
|
3865
3897
|
tenant_id: t
|
|
3866
3898
|
});
|
|
3867
3899
|
},
|
|
3868
3900
|
async get(n, r) {
|
|
3869
|
-
let i = await e.select().from(
|
|
3901
|
+
let i = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.themeId, r))).get();
|
|
3870
3902
|
return i ? Ar(i) : null;
|
|
3871
3903
|
},
|
|
3872
3904
|
async update(n, r, i) {
|
|
3873
3905
|
let o = ut(i);
|
|
3874
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3906
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Xe).set(o).where(t(a(Xe.tenant_id, n), a(Xe.themeId, r))), !0;
|
|
3875
3907
|
},
|
|
3876
3908
|
async remove(n, r) {
|
|
3877
|
-
return (await e.delete(
|
|
3909
|
+
return (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.themeId, r))).returning()).length > 0;
|
|
3878
3910
|
}
|
|
3879
3911
|
};
|
|
3880
3912
|
}
|
|
@@ -3883,18 +3915,18 @@ function jr(e) {
|
|
|
3883
3915
|
function Mr(e) {
|
|
3884
3916
|
return {
|
|
3885
3917
|
async get(t) {
|
|
3886
|
-
let n = await e.select({ body:
|
|
3918
|
+
let n = await e.select({ body: Ye.body }).from(Ye).where(a(Ye.tenant_id, t)).get();
|
|
3887
3919
|
return n ? { body: n.body } : null;
|
|
3888
3920
|
},
|
|
3889
3921
|
async set(t, n) {
|
|
3890
3922
|
let r = Date.now();
|
|
3891
|
-
await e.insert(
|
|
3923
|
+
await e.insert(Ye).values({
|
|
3892
3924
|
tenant_id: t,
|
|
3893
3925
|
body: n.body,
|
|
3894
3926
|
created_at_ts: r,
|
|
3895
3927
|
updated_at_ts: r
|
|
3896
3928
|
}).onConflictDoUpdate({
|
|
3897
|
-
target:
|
|
3929
|
+
target: Ye.tenant_id,
|
|
3898
3930
|
set: {
|
|
3899
3931
|
body: n.body,
|
|
3900
3932
|
updated_at_ts: r
|
|
@@ -3902,7 +3934,7 @@ function Mr(e) {
|
|
|
3902
3934
|
});
|
|
3903
3935
|
},
|
|
3904
3936
|
async delete(t) {
|
|
3905
|
-
await e.delete(
|
|
3937
|
+
await e.delete(Ye).where(a(Ye.tenant_id, t));
|
|
3906
3938
|
}
|
|
3907
3939
|
};
|
|
3908
3940
|
}
|
|
@@ -4288,7 +4320,7 @@ function Yr(e) {
|
|
|
4288
4320
|
},
|
|
4289
4321
|
async remove(n, r, i) {
|
|
4290
4322
|
let o = await e.select({ user_id: A.user_id }).from(A).where(t(a(A.tenant_id, n), v(a(A.user_id, r), a(A.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
|
|
4291
|
-
e.delete(
|
|
4323
|
+
e.delete(ot).where(t(a(ot.tenant_id, n), l(ot.user_id, u))),
|
|
4292
4324
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4293
4325
|
e.delete(Be).where(t(a(Be.tenant_id, n), l(Be.user_id, u))),
|
|
4294
4326
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
@@ -4310,7 +4342,7 @@ function Xr(e) {
|
|
|
4310
4342
|
return {
|
|
4311
4343
|
async create(t, n, r, i) {
|
|
4312
4344
|
try {
|
|
4313
|
-
await e.insert(
|
|
4345
|
+
await e.insert(G).values({
|
|
4314
4346
|
tenant_id: t,
|
|
4315
4347
|
user_id: n,
|
|
4316
4348
|
role_id: r,
|
|
@@ -4324,11 +4356,11 @@ function Xr(e) {
|
|
|
4324
4356
|
return !0;
|
|
4325
4357
|
},
|
|
4326
4358
|
async list(n, r, i, o) {
|
|
4327
|
-
let s = [a(
|
|
4328
|
-
o !== void 0 && s.push(a(
|
|
4329
|
-
let c = await e.select({ role_id:
|
|
4359
|
+
let s = [a(G.tenant_id, n), a(G.user_id, r)];
|
|
4360
|
+
o !== void 0 && s.push(a(G.organization_id, o));
|
|
4361
|
+
let c = await e.select({ role_id: G.role_id }).from(G).where(t(...s)).all();
|
|
4330
4362
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4331
|
-
let i = await e.select().from(
|
|
4363
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r.role_id))).get();
|
|
4332
4364
|
if (!i) return null;
|
|
4333
4365
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4334
4366
|
return D({
|
|
@@ -4339,13 +4371,13 @@ function Xr(e) {
|
|
|
4339
4371
|
}))).filter(Boolean);
|
|
4340
4372
|
},
|
|
4341
4373
|
async listUsers(r, i, o) {
|
|
4342
|
-
let s = t(a(
|
|
4374
|
+
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4343
4375
|
if (Et(o)) {
|
|
4344
4376
|
let n = {
|
|
4345
|
-
sortColumn:
|
|
4346
|
-
idColumn:
|
|
4377
|
+
sortColumn: G.user_id,
|
|
4378
|
+
idColumn: G.user_id,
|
|
4347
4379
|
sortOrder: "asc"
|
|
4348
|
-
}, r = kt(o, n), i = Dt(o), { rows: a, next: c } = At(await e.selectDistinct({ user_id:
|
|
4380
|
+
}, r = kt(o, n), i = Dt(o), { rows: a, next: c } = At(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...Ot(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4349
4381
|
return {
|
|
4350
4382
|
userIds: a.map((e) => e.user_id),
|
|
4351
4383
|
start: 0,
|
|
@@ -4354,7 +4386,7 @@ function Xr(e) {
|
|
|
4354
4386
|
next: c
|
|
4355
4387
|
};
|
|
4356
4388
|
}
|
|
4357
|
-
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id:
|
|
4389
|
+
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id: G.user_id }).from(G).where(s).orderBy(n(G.user_id)).limit(l).offset(u).all(), f = await e.select({ count: y`count(distinct ${G.user_id})` }).from(G).where(s).get();
|
|
4358
4390
|
return {
|
|
4359
4391
|
userIds: d.map((e) => e.user_id),
|
|
4360
4392
|
start: u,
|
|
@@ -4363,7 +4395,7 @@ function Xr(e) {
|
|
|
4363
4395
|
};
|
|
4364
4396
|
},
|
|
4365
4397
|
async remove(n, r, i, o) {
|
|
4366
|
-
return (await e.delete(
|
|
4398
|
+
return (await e.delete(G).where(t(a(G.tenant_id, n), a(G.user_id, r), a(G.role_id, i), a(G.organization_id, o || ""))).returning()).length > 0;
|
|
4367
4399
|
}
|
|
4368
4400
|
};
|
|
4369
4401
|
}
|
|
@@ -4381,7 +4413,7 @@ function Zr(e) {
|
|
|
4381
4413
|
updated_at: r
|
|
4382
4414
|
};
|
|
4383
4415
|
try {
|
|
4384
|
-
await e.insert(
|
|
4416
|
+
await e.insert(U).values(i);
|
|
4385
4417
|
} catch (e) {
|
|
4386
4418
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Fe(409, { message: "User organization already exists" }) : e;
|
|
4387
4419
|
}
|
|
@@ -4389,19 +4421,19 @@ function Zr(e) {
|
|
|
4389
4421
|
return o;
|
|
4390
4422
|
},
|
|
4391
4423
|
async get(n, r) {
|
|
4392
|
-
let i = await e.select().from(
|
|
4424
|
+
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
4393
4425
|
if (!i) return null;
|
|
4394
4426
|
let { tenant_id: o, ...s } = i;
|
|
4395
4427
|
return s;
|
|
4396
4428
|
},
|
|
4397
4429
|
async update(n, r, i) {
|
|
4398
4430
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4399
|
-
return i.user_id !== void 0 && (o.user_id = i.user_id), i.organization_id !== void 0 && (o.organization_id = i.organization_id), (await e.update(
|
|
4431
|
+
return i.user_id !== void 0 && (o.user_id = i.user_id), i.organization_id !== void 0 && (o.organization_id = i.organization_id), (await e.update(U).set(o).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4400
4432
|
},
|
|
4401
4433
|
async list(n, o) {
|
|
4402
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4434
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4403
4435
|
if (c) {
|
|
4404
|
-
let e = mt(
|
|
4436
|
+
let e = mt(U, c, ["user_id", "organization_id"]);
|
|
4405
4437
|
e && (u = t(l, e));
|
|
4406
4438
|
}
|
|
4407
4439
|
let d = (e) => {
|
|
@@ -4410,10 +4442,10 @@ function Zr(e) {
|
|
|
4410
4442
|
};
|
|
4411
4443
|
if (Et(o)) {
|
|
4412
4444
|
let n = {
|
|
4413
|
-
sortColumn:
|
|
4414
|
-
idColumn:
|
|
4445
|
+
sortColumn: U.created_at,
|
|
4446
|
+
idColumn: U.id,
|
|
4415
4447
|
sortOrder: "desc"
|
|
4416
|
-
}, r = kt(o, n), i = Dt(o), { rows: a, next: s } = At((await e.select().from(
|
|
4448
|
+
}, r = kt(o, n), i = Dt(o), { rows: a, next: s } = At((await e.select().from(U).where(r ? t(u, r) : u).orderBy(...Ot(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4417
4449
|
return {
|
|
4418
4450
|
userOrganizations: a,
|
|
4419
4451
|
start: 0,
|
|
@@ -4422,9 +4454,9 @@ function Zr(e) {
|
|
|
4422
4454
|
next: s
|
|
4423
4455
|
};
|
|
4424
4456
|
}
|
|
4425
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4457
|
+
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(U).where(u).orderBy(i(U.created_at), i(U.id)).offset(m).limit(p)).map(d);
|
|
4426
4458
|
if (!s) return { userOrganizations: h };
|
|
4427
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4459
|
+
let [g] = await e.select({ count: r() }).from(U).where(u);
|
|
4428
4460
|
return {
|
|
4429
4461
|
userOrganizations: h,
|
|
4430
4462
|
start: m,
|
|
@@ -4433,8 +4465,8 @@ function Zr(e) {
|
|
|
4433
4465
|
};
|
|
4434
4466
|
},
|
|
4435
4467
|
async listUserOrganizations(n, i, o) {
|
|
4436
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(
|
|
4437
|
-
let i = await e.select().from(
|
|
4468
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.user_id, i))).offset(s * c).limit(c).all(), d = (await Promise.all(u.map(async (r) => {
|
|
4469
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r.organization_id))).get();
|
|
4438
4470
|
if (!i) return null;
|
|
4439
4471
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4440
4472
|
return D({
|
|
@@ -4446,7 +4478,7 @@ function Zr(e) {
|
|
|
4446
4478
|
});
|
|
4447
4479
|
}))).filter(Boolean);
|
|
4448
4480
|
if (!l) return { organizations: d };
|
|
4449
|
-
let [f] = await e.select({ count: r() }).from(
|
|
4481
|
+
let [f] = await e.select({ count: r() }).from(U).where(t(a(U.tenant_id, n), a(U.user_id, i)));
|
|
4450
4482
|
return {
|
|
4451
4483
|
organizations: d,
|
|
4452
4484
|
start: s * c,
|
|
@@ -4455,7 +4487,7 @@ function Zr(e) {
|
|
|
4455
4487
|
};
|
|
4456
4488
|
},
|
|
4457
4489
|
async remove(n, r) {
|
|
4458
|
-
return (await e.delete(
|
|
4490
|
+
return (await e.delete(U).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4459
4491
|
}
|
|
4460
4492
|
};
|
|
4461
4493
|
}
|
|
@@ -5240,10 +5272,10 @@ function Bi(e) {
|
|
|
5240
5272
|
}
|
|
5241
5273
|
async function Vi(e, r) {
|
|
5242
5274
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5243
|
-
custom_domain_id:
|
|
5244
|
-
tenant_id:
|
|
5245
|
-
domain:
|
|
5246
|
-
}).from(
|
|
5275
|
+
custom_domain_id: V.custom_domain_id,
|
|
5276
|
+
tenant_id: V.tenant_id,
|
|
5277
|
+
domain: V.domain
|
|
5278
|
+
}).from(V).where(a(V.domain, i)).limit(1))[0];
|
|
5247
5279
|
if (!o) return null;
|
|
5248
5280
|
let s = (await e.select().from(Y).where(t(a(Y.tenant_id, o.tenant_id), a(Y.custom_domain_id, o.custom_domain_id))).orderBy(n(Y.priority), n(Y.created_at))).map((e) => ({
|
|
5249
5281
|
id: e.id,
|