@authhero/drizzle 1.7.1 → 1.7.3
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 +238 -210
- package/package.json +2 -2
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -474,7 +474,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
474
474
|
C({ columns: [e.tenant_id, e.id] }),
|
|
475
475
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
476
476
|
re("connections_id_unique").on(e.id)
|
|
477
|
-
]),
|
|
477
|
+
]), V = w("custom_domains", {
|
|
478
478
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
479
479
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
480
480
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -488,7 +488,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
488
488
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
489
489
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
490
490
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
491
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
491
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), We = w("domains", {
|
|
492
492
|
id: T("id", { length: 255 }).primaryKey(),
|
|
493
493
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
494
494
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -498,7 +498,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
498
498
|
dkim_public_key: T("dkim_public_key", { length: 2048 }),
|
|
499
499
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
500
500
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
501
|
-
}),
|
|
501
|
+
}), H = w("organizations", {
|
|
502
502
|
id: T("id", { length: 21 }).primaryKey(),
|
|
503
503
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
504
504
|
name: T("name", { length: 256 }).notNull(),
|
|
@@ -509,7 +509,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
509
509
|
token_quota: T("token_quota"),
|
|
510
510
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
511
511
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
512
|
-
}, (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", {
|
|
513
513
|
id: T("id", { length: 21 }).primaryKey(),
|
|
514
514
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
515
515
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
@@ -521,7 +521,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
521
521
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
522
522
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
523
523
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
524
|
-
]),
|
|
524
|
+
]), Ge = w("invites", {
|
|
525
525
|
id: T("id", { length: 21 }).primaryKey(),
|
|
526
526
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
527
527
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -543,7 +543,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
543
543
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
544
544
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
545
545
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
546
|
-
]),
|
|
546
|
+
]), W = w("roles", {
|
|
547
547
|
id: T("id", { length: 21 }).notNull(),
|
|
548
548
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
549
549
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -555,7 +555,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
555
555
|
}, (e) => [C({
|
|
556
556
|
columns: [e.tenant_id, e.id],
|
|
557
557
|
name: "roles_pk"
|
|
558
|
-
})]),
|
|
558
|
+
})]), Ke = w("role_permissions", {
|
|
559
559
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
560
560
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
561
561
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -573,7 +573,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
573
573
|
}),
|
|
574
574
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
575
575
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
576
|
-
]),
|
|
576
|
+
]), qe = w("user_permissions", {
|
|
577
577
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
578
578
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
579
579
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -594,7 +594,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
594
594
|
x("user_permissions_user_fk").on(e.tenant_id, e.user_id),
|
|
595
595
|
x("user_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name),
|
|
596
596
|
x("user_permissions_organization_fk").on(e.organization_id)
|
|
597
|
-
]),
|
|
597
|
+
]), G = w("user_roles", {
|
|
598
598
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
599
599
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
600
600
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
@@ -613,7 +613,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
613
613
|
x("user_roles_user_fk").on(e.tenant_id, e.user_id),
|
|
614
614
|
x("user_roles_role_fk").on(e.tenant_id, e.role_id),
|
|
615
615
|
x("user_roles_organization_fk").on(e.organization_id)
|
|
616
|
-
]),
|
|
616
|
+
]), K = w("resource_servers", {
|
|
617
617
|
id: T("id", { length: 21 }).notNull(),
|
|
618
618
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
619
619
|
identifier: T("identifier", { length: 191 }).notNull(),
|
|
@@ -634,7 +634,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
634
634
|
}, (e) => [C({
|
|
635
635
|
columns: [e.tenant_id, e.id],
|
|
636
636
|
name: "resource_servers_pk"
|
|
637
|
-
})]),
|
|
637
|
+
})]), Je = w("branding", {
|
|
638
638
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
639
639
|
logo_url: T("logo_url", { length: 512 }),
|
|
640
640
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -645,12 +645,12 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
645
645
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
646
646
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
647
647
|
dark_mode: T("dark_mode", { length: 8 })
|
|
648
|
-
}),
|
|
648
|
+
}), Ye = w("universal_login_templates", {
|
|
649
649
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
650
650
|
body: T("body").notNull(),
|
|
651
651
|
created_at_ts: S("created_at_ts").notNull(),
|
|
652
652
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
653
|
-
}),
|
|
653
|
+
}), Xe = w("themes", {
|
|
654
654
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
655
655
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
656
656
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -710,7 +710,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
710
710
|
}, (e) => [C({
|
|
711
711
|
columns: [e.tenant_id, e.themeId],
|
|
712
712
|
name: "themes_pkey"
|
|
713
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
713
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), Ze = w("forms", {
|
|
714
714
|
id: T("id", { length: 255 }).primaryKey(),
|
|
715
715
|
name: T("name", { length: 255 }).notNull(),
|
|
716
716
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -723,21 +723,21 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
723
723
|
style: T("style", { length: 1042 }),
|
|
724
724
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
725
725
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
726
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
726
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Qe = w("flows", {
|
|
727
727
|
id: T("id", { length: 24 }).primaryKey(),
|
|
728
728
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
729
729
|
name: T("name", { length: 150 }).notNull(),
|
|
730
730
|
actions: T("actions"),
|
|
731
731
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
732
732
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
733
|
-
}, (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", {
|
|
734
734
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
735
735
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
736
736
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
737
737
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
738
738
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
739
739
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
740
|
-
}),
|
|
740
|
+
}), et = w("email_providers", {
|
|
741
741
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
742
742
|
name: T("name", { length: 255 }).notNull(),
|
|
743
743
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -746,7 +746,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
746
746
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
747
747
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
748
748
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
749
|
-
}),
|
|
749
|
+
}), tt = w("email_templates", {
|
|
750
750
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
751
751
|
template: T("template", { length: 64 }).notNull(),
|
|
752
752
|
body: T("body").notNull(),
|
|
@@ -759,7 +759,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
759
759
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
760
760
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
761
761
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
762
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
762
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), nt = w("hooks", {
|
|
763
763
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
764
764
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
765
765
|
url: T("url", { length: 512 }),
|
|
@@ -775,14 +775,14 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
775
775
|
page_id: T("page_id", { length: 64 }),
|
|
776
776
|
permission_required: T("permission_required", { length: 255 }),
|
|
777
777
|
metadata: T("metadata")
|
|
778
|
-
}, (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", {
|
|
779
779
|
id: T("id", { length: 21 }).primaryKey(),
|
|
780
780
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
781
781
|
code: T("code").notNull(),
|
|
782
782
|
secrets: T("secrets"),
|
|
783
783
|
created_at_ts: S("created_at_ts").notNull(),
|
|
784
784
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
785
|
-
}, (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", {
|
|
786
786
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
787
787
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
788
788
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -795,7 +795,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
795
795
|
current_until: T("current_until", { length: 35 }),
|
|
796
796
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
797
797
|
connection: T("connection", { length: 255 }).references(() => B.id, { onDelete: "cascade" })
|
|
798
|
-
}),
|
|
798
|
+
}), at = w("custom_text", {
|
|
799
799
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
800
800
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
801
801
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -806,7 +806,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
806
806
|
e.tenant_id,
|
|
807
807
|
e.prompt,
|
|
808
808
|
e.language
|
|
809
|
-
] })]),
|
|
809
|
+
] })]), ot = w("authentication_methods", {
|
|
810
810
|
id: T("id", { length: 26 }).primaryKey(),
|
|
811
811
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
812
812
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -923,49 +923,49 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
923
923
|
actionVersions: () => k,
|
|
924
924
|
actions: () => Re,
|
|
925
925
|
authenticationCodes: () => Ve,
|
|
926
|
-
authenticationMethods: () =>
|
|
927
|
-
branding: () =>
|
|
926
|
+
authenticationMethods: () => ot,
|
|
927
|
+
branding: () => Je,
|
|
928
928
|
clientGrants: () => R,
|
|
929
929
|
clientRegistrationTokens: () => L,
|
|
930
930
|
clients: () => I,
|
|
931
931
|
codes: () => F,
|
|
932
932
|
connections: () => B,
|
|
933
|
-
customDomains: () =>
|
|
934
|
-
customText: () =>
|
|
935
|
-
domains: () =>
|
|
936
|
-
emailProviders: () =>
|
|
937
|
-
emailTemplates: () =>
|
|
938
|
-
flows: () =>
|
|
939
|
-
forms: () =>
|
|
933
|
+
customDomains: () => V,
|
|
934
|
+
customText: () => at,
|
|
935
|
+
domains: () => We,
|
|
936
|
+
emailProviders: () => et,
|
|
937
|
+
emailTemplates: () => tt,
|
|
938
|
+
flows: () => Qe,
|
|
939
|
+
forms: () => Ze,
|
|
940
940
|
grants: () => z,
|
|
941
|
-
hookCode: () =>
|
|
942
|
-
hooks: () =>
|
|
943
|
-
invites: () =>
|
|
944
|
-
keys: () =>
|
|
941
|
+
hookCode: () => rt,
|
|
942
|
+
hooks: () => nt,
|
|
943
|
+
invites: () => Ge,
|
|
944
|
+
keys: () => it,
|
|
945
945
|
loginSessions: () => P,
|
|
946
946
|
logs: () => q,
|
|
947
|
-
organizations: () =>
|
|
947
|
+
organizations: () => H,
|
|
948
948
|
otps: () => He,
|
|
949
949
|
outboxEvents: () => J,
|
|
950
950
|
passwords: () => j,
|
|
951
|
-
promptSettings: () =>
|
|
951
|
+
promptSettings: () => $e,
|
|
952
952
|
proxyRoutes: () => Y,
|
|
953
953
|
refreshTokens: () => N,
|
|
954
|
-
resourceServers: () =>
|
|
955
|
-
rolePermissions: () =>
|
|
956
|
-
roles: () =>
|
|
954
|
+
resourceServers: () => K,
|
|
955
|
+
rolePermissions: () => Ke,
|
|
956
|
+
roles: () => W,
|
|
957
957
|
scimConfigurations: () => st,
|
|
958
958
|
scimExternalIds: () => ct,
|
|
959
959
|
scimTokens: () => X,
|
|
960
960
|
sessions: () => M,
|
|
961
961
|
tenants: () => O,
|
|
962
|
-
themes: () =>
|
|
962
|
+
themes: () => Xe,
|
|
963
963
|
tickets: () => Ue,
|
|
964
|
-
universalLoginTemplates: () =>
|
|
964
|
+
universalLoginTemplates: () => Ye,
|
|
965
965
|
userActivity: () => Be,
|
|
966
|
-
userOrganizations: () =>
|
|
967
|
-
userPermissions: () =>
|
|
968
|
-
userRoles: () =>
|
|
966
|
+
userOrganizations: () => U,
|
|
967
|
+
userPermissions: () => qe,
|
|
968
|
+
userRoles: () => G,
|
|
969
969
|
users: () => A
|
|
970
970
|
});
|
|
971
971
|
//#endregion
|
|
@@ -1361,7 +1361,7 @@ function wt(e) {
|
|
|
1361
1361
|
function Tt(e) {
|
|
1362
1362
|
return {
|
|
1363
1363
|
async get(t) {
|
|
1364
|
-
let n = await e.select().from(
|
|
1364
|
+
let n = await e.select().from(Je).where(a(Je.tenant_id, t)).get();
|
|
1365
1365
|
if (!n) return null;
|
|
1366
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;
|
|
1367
1367
|
return D({
|
|
@@ -1390,11 +1390,11 @@ function Tt(e) {
|
|
|
1390
1390
|
font_url: i?.url,
|
|
1391
1391
|
dark_mode: a
|
|
1392
1392
|
};
|
|
1393
|
-
await e.insert(
|
|
1393
|
+
await e.insert(Je).values({
|
|
1394
1394
|
tenant_id: t,
|
|
1395
1395
|
...l
|
|
1396
1396
|
}).onConflictDoUpdate({
|
|
1397
|
-
target:
|
|
1397
|
+
target: Je.tenant_id,
|
|
1398
1398
|
set: l
|
|
1399
1399
|
});
|
|
1400
1400
|
}
|
|
@@ -1921,6 +1921,20 @@ function Qt(e) {
|
|
|
1921
1921
|
let e = mt(B, f, ["name"]);
|
|
1922
1922
|
e && (p = t(p, e));
|
|
1923
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
|
+
}
|
|
1924
1938
|
let m = e.select().from(B).where(p).$dynamic();
|
|
1925
1939
|
if (d?.sort_by) {
|
|
1926
1940
|
let e = B[d.sort_by];
|
|
@@ -1970,31 +1984,31 @@ function en(e) {
|
|
|
1970
1984
|
created_at: r,
|
|
1971
1985
|
updated_at: r
|
|
1972
1986
|
};
|
|
1973
|
-
return await e.insert(
|
|
1987
|
+
return await e.insert(V).values(i), $t({
|
|
1974
1988
|
...i,
|
|
1975
1989
|
tenant_id: t
|
|
1976
1990
|
});
|
|
1977
1991
|
},
|
|
1978
1992
|
async get(n, r) {
|
|
1979
|
-
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();
|
|
1980
1994
|
return i ? $t(i) : null;
|
|
1981
1995
|
},
|
|
1982
1996
|
async getByDomain(t) {
|
|
1983
|
-
let n = await e.select().from(
|
|
1997
|
+
let n = await e.select().from(V).where(a(V.domain, t)).get();
|
|
1984
1998
|
return n ? {
|
|
1985
1999
|
...$t(n),
|
|
1986
2000
|
tenant_id: n.tenant_id
|
|
1987
2001
|
} : null;
|
|
1988
2002
|
},
|
|
1989
2003
|
async list(t) {
|
|
1990
|
-
return (await e.select().from(
|
|
2004
|
+
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map($t);
|
|
1991
2005
|
},
|
|
1992
2006
|
async update(n, r, i) {
|
|
1993
2007
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1994
|
-
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;
|
|
1995
2009
|
},
|
|
1996
2010
|
async remove(n, r) {
|
|
1997
|
-
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;
|
|
1998
2012
|
}
|
|
1999
2013
|
};
|
|
2000
2014
|
}
|
|
@@ -2003,7 +2017,7 @@ function en(e) {
|
|
|
2003
2017
|
function tn(e) {
|
|
2004
2018
|
return {
|
|
2005
2019
|
async get(n, r, i) {
|
|
2006
|
-
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();
|
|
2007
2021
|
if (!o) return null;
|
|
2008
2022
|
try {
|
|
2009
2023
|
return JSON.parse(o.custom_text);
|
|
@@ -2013,7 +2027,7 @@ function tn(e) {
|
|
|
2013
2027
|
},
|
|
2014
2028
|
async set(t, n, r, i) {
|
|
2015
2029
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2016
|
-
await e.insert(
|
|
2030
|
+
await e.insert(at).values({
|
|
2017
2031
|
tenant_id: t,
|
|
2018
2032
|
prompt: n,
|
|
2019
2033
|
language: r,
|
|
@@ -2022,9 +2036,9 @@ function tn(e) {
|
|
|
2022
2036
|
updated_at_ts: a
|
|
2023
2037
|
}).onConflictDoUpdate({
|
|
2024
2038
|
target: [
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2039
|
+
at.tenant_id,
|
|
2040
|
+
at.prompt,
|
|
2041
|
+
at.language
|
|
2028
2042
|
],
|
|
2029
2043
|
set: {
|
|
2030
2044
|
custom_text: o,
|
|
@@ -2033,13 +2047,13 @@ function tn(e) {
|
|
|
2033
2047
|
});
|
|
2034
2048
|
},
|
|
2035
2049
|
async delete(n, r, i) {
|
|
2036
|
-
await e.delete(
|
|
2050
|
+
await e.delete(at).where(t(a(at.tenant_id, n), a(at.prompt, r), a(at.language, i)));
|
|
2037
2051
|
},
|
|
2038
2052
|
async list(t) {
|
|
2039
2053
|
return await e.select({
|
|
2040
|
-
prompt:
|
|
2041
|
-
language:
|
|
2042
|
-
}).from(
|
|
2054
|
+
prompt: at.prompt,
|
|
2055
|
+
language: at.language
|
|
2056
|
+
}).from(at).where(a(at.tenant_id, t)).all();
|
|
2043
2057
|
}
|
|
2044
2058
|
};
|
|
2045
2059
|
}
|
|
@@ -2049,7 +2063,7 @@ function nn(e) {
|
|
|
2049
2063
|
return {
|
|
2050
2064
|
async create(t, n) {
|
|
2051
2065
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2052
|
-
await e.insert(
|
|
2066
|
+
await e.insert(et).values({
|
|
2053
2067
|
tenant_id: t,
|
|
2054
2068
|
name: n.name,
|
|
2055
2069
|
enabled: n.enabled,
|
|
@@ -2061,7 +2075,7 @@ function nn(e) {
|
|
|
2061
2075
|
});
|
|
2062
2076
|
},
|
|
2063
2077
|
async get(t) {
|
|
2064
|
-
let n = await e.select().from(
|
|
2078
|
+
let n = await e.select().from(et).where(a(et.tenant_id, t)).get();
|
|
2065
2079
|
if (!n) return null;
|
|
2066
2080
|
let { tenant_id: r, ...i } = n;
|
|
2067
2081
|
return D({
|
|
@@ -2073,10 +2087,10 @@ function nn(e) {
|
|
|
2073
2087
|
},
|
|
2074
2088
|
async update(t, n) {
|
|
2075
2089
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2076
|
-
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));
|
|
2077
2091
|
},
|
|
2078
2092
|
async remove(t) {
|
|
2079
|
-
await e.delete(
|
|
2093
|
+
await e.delete(et).where(a(et.tenant_id, t));
|
|
2080
2094
|
}
|
|
2081
2095
|
};
|
|
2082
2096
|
}
|
|
@@ -2098,15 +2112,15 @@ function rn(e) {
|
|
|
2098
2112
|
function an(e) {
|
|
2099
2113
|
return {
|
|
2100
2114
|
async get(n, r) {
|
|
2101
|
-
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();
|
|
2102
2116
|
return i ? rn(i) : null;
|
|
2103
2117
|
},
|
|
2104
2118
|
async list(t) {
|
|
2105
|
-
return (await e.select().from(
|
|
2119
|
+
return (await e.select().from(tt).where(a(tt.tenant_id, t)).all()).map(rn);
|
|
2106
2120
|
},
|
|
2107
2121
|
async create(t, n) {
|
|
2108
2122
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2109
|
-
return await e.insert(
|
|
2123
|
+
return await e.insert(tt).values({
|
|
2110
2124
|
tenant_id: t,
|
|
2111
2125
|
template: n.template,
|
|
2112
2126
|
body: n.body,
|
|
@@ -2124,11 +2138,11 @@ function an(e) {
|
|
|
2124
2138
|
async update(n, r, i) {
|
|
2125
2139
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2126
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);
|
|
2127
|
-
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();
|
|
2128
2142
|
return Number(s.changes ?? 0) > 0;
|
|
2129
2143
|
},
|
|
2130
2144
|
async remove(n, r) {
|
|
2131
|
-
let i = await e.delete(
|
|
2145
|
+
let i = await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.template, r))).run();
|
|
2132
2146
|
return Number(i.changes ?? 0) > 0;
|
|
2133
2147
|
}
|
|
2134
2148
|
};
|
|
@@ -2140,7 +2154,7 @@ function sn(e) {
|
|
|
2140
2154
|
return {
|
|
2141
2155
|
async create(t, n) {
|
|
2142
2156
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2143
|
-
return await e.insert(
|
|
2157
|
+
return await e.insert(Qe).values({
|
|
2144
2158
|
id: i,
|
|
2145
2159
|
tenant_id: t,
|
|
2146
2160
|
name: n.name,
|
|
@@ -2156,7 +2170,7 @@ function sn(e) {
|
|
|
2156
2170
|
};
|
|
2157
2171
|
},
|
|
2158
2172
|
async get(n, r) {
|
|
2159
|
-
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();
|
|
2160
2174
|
if (!i) return null;
|
|
2161
2175
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2162
2176
|
return D({
|
|
@@ -2166,20 +2180,20 @@ function sn(e) {
|
|
|
2166
2180
|
},
|
|
2167
2181
|
async update(n, r, i) {
|
|
2168
2182
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2169
|
-
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);
|
|
2170
2184
|
},
|
|
2171
2185
|
async list(o, s) {
|
|
2172
|
-
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)];
|
|
2173
2187
|
if (f) {
|
|
2174
2188
|
let e = we(f, on);
|
|
2175
2189
|
if (e) {
|
|
2176
|
-
let t = mt(
|
|
2190
|
+
let t = mt(Qe, e, []);
|
|
2177
2191
|
t && p.push(t);
|
|
2178
2192
|
}
|
|
2179
2193
|
}
|
|
2180
|
-
let m = t(...p), h = e.select().from(
|
|
2194
|
+
let m = t(...p), h = e.select().from(Qe).where(m).$dynamic();
|
|
2181
2195
|
if (d?.sort_by) {
|
|
2182
|
-
let e =
|
|
2196
|
+
let e = Qe[d.sort_by];
|
|
2183
2197
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2184
2198
|
}
|
|
2185
2199
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2190,7 +2204,7 @@ function sn(e) {
|
|
|
2190
2204
|
});
|
|
2191
2205
|
});
|
|
2192
2206
|
if (!u) return { flows: g };
|
|
2193
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2207
|
+
let [_] = await e.select({ count: r() }).from(Qe).where(m);
|
|
2194
2208
|
return {
|
|
2195
2209
|
flows: g,
|
|
2196
2210
|
start: c * l,
|
|
@@ -2199,7 +2213,7 @@ function sn(e) {
|
|
|
2199
2213
|
};
|
|
2200
2214
|
},
|
|
2201
2215
|
async remove(n, r) {
|
|
2202
|
-
return (await e.delete(
|
|
2216
|
+
return (await e.delete(Qe).where(t(a(Qe.tenant_id, n), a(Qe.id, r))).returning()).length > 0;
|
|
2203
2217
|
}
|
|
2204
2218
|
};
|
|
2205
2219
|
}
|
|
@@ -2225,7 +2239,7 @@ function un(e) {
|
|
|
2225
2239
|
updated_at: r
|
|
2226
2240
|
};
|
|
2227
2241
|
for (let e of cn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2228
|
-
return await e.insert(
|
|
2242
|
+
return await e.insert(Ze).values(a), {
|
|
2229
2243
|
id: i,
|
|
2230
2244
|
...n,
|
|
2231
2245
|
created_at: r,
|
|
@@ -2233,7 +2247,7 @@ function un(e) {
|
|
|
2233
2247
|
};
|
|
2234
2248
|
},
|
|
2235
2249
|
async get(n, r) {
|
|
2236
|
-
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();
|
|
2237
2251
|
if (!i) return null;
|
|
2238
2252
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2239
2253
|
for (let e of cn) c[e] = Z(s[e]);
|
|
@@ -2242,20 +2256,20 @@ function un(e) {
|
|
|
2242
2256
|
async update(n, r, i) {
|
|
2243
2257
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2244
2258
|
for (let [e, t] of Object.entries(i)) t !== void 0 && (cn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2245
|
-
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;
|
|
2246
2260
|
},
|
|
2247
2261
|
async list(o, s) {
|
|
2248
|
-
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)];
|
|
2249
2263
|
if (f) {
|
|
2250
2264
|
let e = we(f, ln);
|
|
2251
2265
|
if (e) {
|
|
2252
|
-
let t = mt(
|
|
2266
|
+
let t = mt(Ze, e, ln);
|
|
2253
2267
|
t && p.push(t);
|
|
2254
2268
|
}
|
|
2255
2269
|
}
|
|
2256
|
-
let m = t(...p), h = e.select().from(
|
|
2270
|
+
let m = t(...p), h = e.select().from(Ze).where(m).$dynamic();
|
|
2257
2271
|
if (d?.sort_by) {
|
|
2258
|
-
let e =
|
|
2272
|
+
let e = Ze[d.sort_by];
|
|
2259
2273
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2260
2274
|
}
|
|
2261
2275
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2264,7 +2278,7 @@ function un(e) {
|
|
|
2264
2278
|
return D(r);
|
|
2265
2279
|
});
|
|
2266
2280
|
if (!u) return { forms: g };
|
|
2267
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2281
|
+
let [_] = await e.select({ count: r() }).from(Ze).where(m);
|
|
2268
2282
|
return {
|
|
2269
2283
|
forms: g,
|
|
2270
2284
|
start: c * l,
|
|
@@ -2273,7 +2287,7 @@ function un(e) {
|
|
|
2273
2287
|
};
|
|
2274
2288
|
},
|
|
2275
2289
|
async remove(n, r) {
|
|
2276
|
-
return (await e.delete(
|
|
2290
|
+
return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2277
2291
|
}
|
|
2278
2292
|
};
|
|
2279
2293
|
}
|
|
@@ -2392,21 +2406,21 @@ function vn(e) {
|
|
|
2392
2406
|
created_at_ts: r,
|
|
2393
2407
|
updated_at_ts: r
|
|
2394
2408
|
};
|
|
2395
|
-
return await e.insert(
|
|
2409
|
+
return await e.insert(rt).values(i), _n({
|
|
2396
2410
|
...i,
|
|
2397
2411
|
tenant_id: t
|
|
2398
2412
|
});
|
|
2399
2413
|
},
|
|
2400
2414
|
async get(n, r) {
|
|
2401
|
-
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();
|
|
2402
2416
|
return i ? _n(i) : null;
|
|
2403
2417
|
},
|
|
2404
2418
|
async update(n, r, i) {
|
|
2405
2419
|
let o = { updated_at_ts: Date.now() };
|
|
2406
|
-
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;
|
|
2407
2421
|
},
|
|
2408
2422
|
async remove(n, r) {
|
|
2409
|
-
return (await e.delete(
|
|
2423
|
+
return (await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2410
2424
|
}
|
|
2411
2425
|
};
|
|
2412
2426
|
}
|
|
@@ -2456,30 +2470,30 @@ function Sn(e) {
|
|
|
2456
2470
|
created_at_ts: r,
|
|
2457
2471
|
updated_at_ts: r
|
|
2458
2472
|
};
|
|
2459
|
-
return await e.insert(
|
|
2473
|
+
return await e.insert(nt).values(i), xn({
|
|
2460
2474
|
...i,
|
|
2461
2475
|
tenant_id: t
|
|
2462
2476
|
});
|
|
2463
2477
|
},
|
|
2464
2478
|
async get(n, r) {
|
|
2465
|
-
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();
|
|
2466
2480
|
return i ? xn(i) : null;
|
|
2467
2481
|
},
|
|
2468
2482
|
async update(n, r, i) {
|
|
2469
2483
|
let o = { updated_at_ts: Date.now() };
|
|
2470
|
-
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;
|
|
2471
2485
|
},
|
|
2472
2486
|
async list(o, s) {
|
|
2473
|
-
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, [
|
|
2474
2488
|
"url",
|
|
2475
2489
|
"form_id",
|
|
2476
2490
|
"template_id",
|
|
2477
2491
|
"code_id"
|
|
2478
|
-
]) : void 0, m = p ? t(a(
|
|
2479
|
-
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));
|
|
2480
2494
|
let _ = (await h.offset(c * l).limit(l)).map(xn);
|
|
2481
2495
|
if (!u) return { hooks: _ };
|
|
2482
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2496
|
+
let [v] = await e.select({ count: r() }).from(nt).where(m);
|
|
2483
2497
|
return {
|
|
2484
2498
|
hooks: _,
|
|
2485
2499
|
start: c * l,
|
|
@@ -2488,7 +2502,7 @@ function Sn(e) {
|
|
|
2488
2502
|
};
|
|
2489
2503
|
},
|
|
2490
2504
|
async remove(n, r) {
|
|
2491
|
-
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;
|
|
2492
2506
|
}
|
|
2493
2507
|
};
|
|
2494
2508
|
}
|
|
@@ -2527,7 +2541,7 @@ function En(e) {
|
|
|
2527
2541
|
};
|
|
2528
2542
|
for (let e of wn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2529
2543
|
try {
|
|
2530
|
-
await e.insert(
|
|
2544
|
+
await e.insert(Ge).values(s);
|
|
2531
2545
|
} catch (e) {
|
|
2532
2546
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Fe(409, { message: "Invite already exists" }) : e;
|
|
2533
2547
|
}
|
|
@@ -2537,23 +2551,23 @@ function En(e) {
|
|
|
2537
2551
|
});
|
|
2538
2552
|
},
|
|
2539
2553
|
async get(n, r) {
|
|
2540
|
-
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();
|
|
2541
2555
|
return i ? Tn(i) : null;
|
|
2542
2556
|
},
|
|
2543
2557
|
async update(n, r, i) {
|
|
2544
2558
|
let o = {};
|
|
2545
2559
|
for (let e of wn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2546
|
-
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;
|
|
2547
2561
|
},
|
|
2548
2562
|
async list(t, o) {
|
|
2549
|
-
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();
|
|
2550
2564
|
if (u?.sort_by) {
|
|
2551
|
-
let e =
|
|
2565
|
+
let e = Ge[u.sort_by];
|
|
2552
2566
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2553
2567
|
}
|
|
2554
2568
|
let f = (await d.offset(s * c).limit(c)).map(Tn);
|
|
2555
2569
|
if (!l) return { invites: f };
|
|
2556
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2570
|
+
let [p] = await e.select({ count: r() }).from(Ge).where(a(Ge.tenant_id, t));
|
|
2557
2571
|
return {
|
|
2558
2572
|
invites: f,
|
|
2559
2573
|
start: s * c,
|
|
@@ -2562,7 +2576,7 @@ function En(e) {
|
|
|
2562
2576
|
};
|
|
2563
2577
|
},
|
|
2564
2578
|
async remove(n, r) {
|
|
2565
|
-
return (await e.delete(
|
|
2579
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2566
2580
|
}
|
|
2567
2581
|
};
|
|
2568
2582
|
}
|
|
@@ -2578,23 +2592,23 @@ var Dn = [
|
|
|
2578
2592
|
function On(e) {
|
|
2579
2593
|
return {
|
|
2580
2594
|
async create(t) {
|
|
2581
|
-
await e.insert(
|
|
2595
|
+
await e.insert(it).values({
|
|
2582
2596
|
...t,
|
|
2583
2597
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2584
2598
|
});
|
|
2585
2599
|
},
|
|
2586
2600
|
async list(a) {
|
|
2587
|
-
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))];
|
|
2588
2602
|
if (d) {
|
|
2589
2603
|
let e = we(d, Dn);
|
|
2590
2604
|
if (e) {
|
|
2591
|
-
let t = mt(
|
|
2605
|
+
let t = mt(it, e, Dn);
|
|
2592
2606
|
t && m.push(t);
|
|
2593
2607
|
}
|
|
2594
2608
|
}
|
|
2595
|
-
let h = t(...m), g = e.select().from(
|
|
2609
|
+
let h = t(...m), g = e.select().from(it).where(h).$dynamic();
|
|
2596
2610
|
if (u?.sort_by) {
|
|
2597
|
-
let e =
|
|
2611
|
+
let e = it[u.sort_by];
|
|
2598
2612
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2599
2613
|
}
|
|
2600
2614
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2602,7 +2616,7 @@ function On(e) {
|
|
|
2602
2616
|
return D(n);
|
|
2603
2617
|
});
|
|
2604
2618
|
if (!l) return { signingKeys: _ };
|
|
2605
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2619
|
+
let [y] = await e.select({ count: r() }).from(it).where(h);
|
|
2606
2620
|
return {
|
|
2607
2621
|
signingKeys: _,
|
|
2608
2622
|
start: o * c,
|
|
@@ -2611,7 +2625,7 @@ function On(e) {
|
|
|
2611
2625
|
};
|
|
2612
2626
|
},
|
|
2613
2627
|
async update(t, n) {
|
|
2614
|
-
return (await e.update(
|
|
2628
|
+
return (await e.update(it).set(n).where(a(it.kid, t)).returning()).length > 0;
|
|
2615
2629
|
}
|
|
2616
2630
|
};
|
|
2617
2631
|
}
|
|
@@ -2836,31 +2850,31 @@ function Bn(e) {
|
|
|
2836
2850
|
created_at_ts: r,
|
|
2837
2851
|
updated_at_ts: r
|
|
2838
2852
|
};
|
|
2839
|
-
return await e.insert(
|
|
2853
|
+
return await e.insert(ot).values(i), zn({
|
|
2840
2854
|
...i,
|
|
2841
2855
|
tenant_id: t
|
|
2842
2856
|
});
|
|
2843
2857
|
},
|
|
2844
2858
|
async get(n, r) {
|
|
2845
|
-
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();
|
|
2846
2860
|
return i ? zn(i) : null;
|
|
2847
2861
|
},
|
|
2848
2862
|
async getByCredentialId(n, r) {
|
|
2849
|
-
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();
|
|
2850
2864
|
return i ? zn(i) : null;
|
|
2851
2865
|
},
|
|
2852
2866
|
async list(n, r) {
|
|
2853
|
-
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);
|
|
2854
2868
|
},
|
|
2855
2869
|
async update(n, r, i) {
|
|
2856
2870
|
let o = { updated_at_ts: Date.now() };
|
|
2857
|
-
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)));
|
|
2858
2872
|
let s = await this.get(n, r);
|
|
2859
2873
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2860
2874
|
return s;
|
|
2861
2875
|
},
|
|
2862
2876
|
async remove(n, r) {
|
|
2863
|
-
return (await e.delete(
|
|
2877
|
+
return (await e.delete(ot).where(t(a(ot.tenant_id, n), a(ot.id, r))).returning()).length > 0;
|
|
2864
2878
|
}
|
|
2865
2879
|
};
|
|
2866
2880
|
}
|
|
@@ -2896,7 +2910,7 @@ function Wn(e) {
|
|
|
2896
2910
|
updated_at: r
|
|
2897
2911
|
};
|
|
2898
2912
|
try {
|
|
2899
|
-
await e.insert(
|
|
2913
|
+
await e.insert(H).values(i);
|
|
2900
2914
|
} catch (e) {
|
|
2901
2915
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Fe(409, { message: "Organization already exists" }) : e;
|
|
2902
2916
|
}
|
|
@@ -2906,29 +2920,29 @@ function Wn(e) {
|
|
|
2906
2920
|
});
|
|
2907
2921
|
},
|
|
2908
2922
|
async get(n, r) {
|
|
2909
|
-
let i = await e.select().from(
|
|
2910
|
-
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;
|
|
2911
2925
|
},
|
|
2912
2926
|
async update(n, r, i) {
|
|
2913
2927
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2914
|
-
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;
|
|
2915
2929
|
},
|
|
2916
2930
|
async list(o, s) {
|
|
2917
|
-
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)];
|
|
2918
2932
|
if (f) {
|
|
2919
2933
|
let e = we(f, Vn);
|
|
2920
2934
|
if (e) {
|
|
2921
|
-
let t = mt(
|
|
2935
|
+
let t = mt(H, e, Vn);
|
|
2922
2936
|
t && p.push(t);
|
|
2923
2937
|
}
|
|
2924
2938
|
}
|
|
2925
2939
|
let m = t(...p);
|
|
2926
2940
|
if (Et(s)) {
|
|
2927
2941
|
let n = {
|
|
2928
|
-
sortColumn:
|
|
2929
|
-
idColumn:
|
|
2942
|
+
sortColumn: H.created_at,
|
|
2943
|
+
idColumn: H.id,
|
|
2930
2944
|
sortOrder: "desc"
|
|
2931
|
-
}, 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);
|
|
2932
2946
|
return {
|
|
2933
2947
|
organizations: c,
|
|
2934
2948
|
start: 0,
|
|
@@ -2938,14 +2952,14 @@ function Wn(e) {
|
|
|
2938
2952
|
next: o
|
|
2939
2953
|
};
|
|
2940
2954
|
}
|
|
2941
|
-
let h = e.select().from(
|
|
2955
|
+
let h = e.select().from(H).where(m).$dynamic();
|
|
2942
2956
|
if (d?.sort_by) {
|
|
2943
|
-
let e =
|
|
2957
|
+
let e = H[d.sort_by];
|
|
2944
2958
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2945
2959
|
}
|
|
2946
2960
|
let g = (await h.offset(c * l).limit(l)).map(Un);
|
|
2947
2961
|
if (!u) return { organizations: g };
|
|
2948
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2962
|
+
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2949
2963
|
return {
|
|
2950
2964
|
organizations: g,
|
|
2951
2965
|
start: c * l,
|
|
@@ -2954,7 +2968,7 @@ function Wn(e) {
|
|
|
2954
2968
|
};
|
|
2955
2969
|
},
|
|
2956
2970
|
async remove(n, r) {
|
|
2957
|
-
return (await e.delete(
|
|
2971
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2958
2972
|
}
|
|
2959
2973
|
};
|
|
2960
2974
|
}
|
|
@@ -3006,7 +3020,7 @@ function Kn(e) {
|
|
|
3006
3020
|
function qn(e) {
|
|
3007
3021
|
return {
|
|
3008
3022
|
async get(t) {
|
|
3009
|
-
let n = await e.select().from(
|
|
3023
|
+
let n = await e.select().from($e).where(a($e.tenant_id, t)).get();
|
|
3010
3024
|
return n ? {
|
|
3011
3025
|
universal_login_experience: n.universal_login_experience,
|
|
3012
3026
|
identifier_first: !!n.identifier_first,
|
|
@@ -3022,7 +3036,7 @@ function qn(e) {
|
|
|
3022
3036
|
};
|
|
3023
3037
|
},
|
|
3024
3038
|
async set(t, n) {
|
|
3025
|
-
await e.insert(
|
|
3039
|
+
await e.insert($e).values({
|
|
3026
3040
|
tenant_id: t,
|
|
3027
3041
|
universal_login_experience: n.universal_login_experience,
|
|
3028
3042
|
identifier_first: n.identifier_first,
|
|
@@ -3030,7 +3044,7 @@ function qn(e) {
|
|
|
3030
3044
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3031
3045
|
show_last_used_connection: n.show_last_used_connection
|
|
3032
3046
|
}).onConflictDoUpdate({
|
|
3033
|
-
target:
|
|
3047
|
+
target: $e.tenant_id,
|
|
3034
3048
|
set: {
|
|
3035
3049
|
universal_login_experience: n.universal_login_experience,
|
|
3036
3050
|
identifier_first: n.identifier_first,
|
|
@@ -3477,38 +3491,52 @@ function mr(e) {
|
|
|
3477
3491
|
updated_at: r
|
|
3478
3492
|
};
|
|
3479
3493
|
for (let e of dr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3480
|
-
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({
|
|
3481
3495
|
...i,
|
|
3482
3496
|
tenant_id: t
|
|
3483
3497
|
});
|
|
3484
3498
|
},
|
|
3485
3499
|
async get(n, r) {
|
|
3486
|
-
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();
|
|
3487
3501
|
return i ? pr(i) : null;
|
|
3488
3502
|
},
|
|
3489
3503
|
async update(n, r, i) {
|
|
3490
3504
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3491
|
-
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);
|
|
3492
3506
|
for (let e of dr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3493
|
-
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;
|
|
3494
3508
|
},
|
|
3495
3509
|
async list(o, s) {
|
|
3496
|
-
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)];
|
|
3497
3511
|
if (f) {
|
|
3498
3512
|
let e = we(f, lr);
|
|
3499
3513
|
if (e) {
|
|
3500
|
-
let t = mt(
|
|
3514
|
+
let t = mt(K, e, lr, ["name", "identifier"]);
|
|
3501
3515
|
t && h.push(t);
|
|
3502
3516
|
}
|
|
3503
3517
|
}
|
|
3504
|
-
|
|
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();
|
|
3505
3533
|
if (d?.sort_by && fr.has(d.sort_by)) {
|
|
3506
|
-
let e =
|
|
3534
|
+
let e = K[d.sort_by];
|
|
3507
3535
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3508
3536
|
}
|
|
3509
3537
|
let _ = (await g.offset(p * m).limit(m)).map(pr);
|
|
3510
3538
|
if (!u) return { resource_servers: _ };
|
|
3511
|
-
let [v] = await e.select({ count: r() }).from(
|
|
3539
|
+
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3512
3540
|
return {
|
|
3513
3541
|
resource_servers: _,
|
|
3514
3542
|
start: p * m,
|
|
@@ -3517,7 +3545,7 @@ function mr(e) {
|
|
|
3517
3545
|
};
|
|
3518
3546
|
},
|
|
3519
3547
|
async remove(n, r) {
|
|
3520
|
-
return (await e.delete(
|
|
3548
|
+
return (await e.delete(K).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3521
3549
|
}
|
|
3522
3550
|
};
|
|
3523
3551
|
}
|
|
@@ -3528,7 +3556,7 @@ function hr(e) {
|
|
|
3528
3556
|
async assign(t, n, r) {
|
|
3529
3557
|
if (r.length === 0) return !0;
|
|
3530
3558
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3531
|
-
return await e.insert(
|
|
3559
|
+
return await e.insert(Ke).values(r.map((e) => ({
|
|
3532
3560
|
tenant_id: t,
|
|
3533
3561
|
role_id: n,
|
|
3534
3562
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3538,15 +3566,15 @@ function hr(e) {
|
|
|
3538
3566
|
},
|
|
3539
3567
|
async list(n, r, i) {
|
|
3540
3568
|
let o = await e.select({
|
|
3541
|
-
resource_server_identifier:
|
|
3542
|
-
permission_name:
|
|
3543
|
-
created_at:
|
|
3544
|
-
}).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();
|
|
3545
3573
|
if (s.length > 0) {
|
|
3546
3574
|
let r = await e.select({
|
|
3547
|
-
identifier:
|
|
3548
|
-
name:
|
|
3549
|
-
}).from(
|
|
3575
|
+
identifier: K.identifier,
|
|
3576
|
+
name: K.name
|
|
3577
|
+
}).from(K).where(t(a(K.tenant_id, n), l(K.identifier, s))).all();
|
|
3550
3578
|
for (let e of r) c.set(e.identifier, e.name);
|
|
3551
3579
|
}
|
|
3552
3580
|
return o.map((e) => ({
|
|
@@ -3556,8 +3584,8 @@ function hr(e) {
|
|
|
3556
3584
|
},
|
|
3557
3585
|
async remove(n, r, i) {
|
|
3558
3586
|
if (i.length === 0) return !0;
|
|
3559
|
-
let o = i.map((e) => t(a(
|
|
3560
|
-
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;
|
|
3561
3589
|
}
|
|
3562
3590
|
};
|
|
3563
3591
|
}
|
|
@@ -3567,7 +3595,7 @@ function gr(e) {
|
|
|
3567
3595
|
return {
|
|
3568
3596
|
async create(t, n, r, i) {
|
|
3569
3597
|
try {
|
|
3570
|
-
await e.insert(
|
|
3598
|
+
await e.insert(qe).values({
|
|
3571
3599
|
tenant_id: t,
|
|
3572
3600
|
user_id: n,
|
|
3573
3601
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3582,11 +3610,11 @@ function gr(e) {
|
|
|
3582
3610
|
return !0;
|
|
3583
3611
|
},
|
|
3584
3612
|
async list(n, r, i, o) {
|
|
3585
|
-
let s = [a(
|
|
3586
|
-
o && s.push(a(
|
|
3587
|
-
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();
|
|
3588
3616
|
return await Promise.all(c.map(async (r) => {
|
|
3589
|
-
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();
|
|
3590
3618
|
return {
|
|
3591
3619
|
resource_server_identifier: r.resource_server_identifier,
|
|
3592
3620
|
permission_name: r.permission_name,
|
|
@@ -3596,7 +3624,7 @@ function gr(e) {
|
|
|
3596
3624
|
}));
|
|
3597
3625
|
},
|
|
3598
3626
|
async remove(n, r, i, o) {
|
|
3599
|
-
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;
|
|
3600
3628
|
}
|
|
3601
3629
|
};
|
|
3602
3630
|
}
|
|
@@ -3623,28 +3651,28 @@ function vr(e) {
|
|
|
3623
3651
|
created_at: r,
|
|
3624
3652
|
updated_at: r
|
|
3625
3653
|
};
|
|
3626
|
-
return await e.insert(
|
|
3654
|
+
return await e.insert(W).values(i), _r({
|
|
3627
3655
|
...i,
|
|
3628
3656
|
tenant_id: t
|
|
3629
3657
|
});
|
|
3630
3658
|
},
|
|
3631
3659
|
async get(n, r) {
|
|
3632
|
-
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();
|
|
3633
3661
|
return i ? _r(i) : null;
|
|
3634
3662
|
},
|
|
3635
3663
|
async update(n, r, i) {
|
|
3636
3664
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3637
|
-
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;
|
|
3638
3666
|
},
|
|
3639
3667
|
async list(o, s) {
|
|
3640
|
-
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();
|
|
3641
3669
|
if (d?.sort_by) {
|
|
3642
|
-
let e =
|
|
3670
|
+
let e = W[d.sort_by];
|
|
3643
3671
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3644
3672
|
}
|
|
3645
3673
|
let g = (await h.offset(c * l).limit(l)).map(_r);
|
|
3646
3674
|
if (!u) return { roles: g };
|
|
3647
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3675
|
+
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3648
3676
|
return {
|
|
3649
3677
|
roles: g,
|
|
3650
3678
|
start: c * l,
|
|
@@ -3653,7 +3681,7 @@ function vr(e) {
|
|
|
3653
3681
|
};
|
|
3654
3682
|
},
|
|
3655
3683
|
async remove(n, r) {
|
|
3656
|
-
return (await e.delete(
|
|
3684
|
+
return (await e.delete(W).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3657
3685
|
}
|
|
3658
3686
|
};
|
|
3659
3687
|
}
|
|
@@ -3864,21 +3892,21 @@ function jr(e) {
|
|
|
3864
3892
|
created_at: a?.created_at ?? o,
|
|
3865
3893
|
updated_at: a?.updated_at ?? o
|
|
3866
3894
|
};
|
|
3867
|
-
return await e.insert(
|
|
3895
|
+
return await e.insert(Xe).values(c), Ar({
|
|
3868
3896
|
...c,
|
|
3869
3897
|
tenant_id: t
|
|
3870
3898
|
});
|
|
3871
3899
|
},
|
|
3872
3900
|
async get(n, r) {
|
|
3873
|
-
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();
|
|
3874
3902
|
return i ? Ar(i) : null;
|
|
3875
3903
|
},
|
|
3876
3904
|
async update(n, r, i) {
|
|
3877
3905
|
let o = ut(i);
|
|
3878
|
-
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;
|
|
3879
3907
|
},
|
|
3880
3908
|
async remove(n, r) {
|
|
3881
|
-
return (await e.delete(
|
|
3909
|
+
return (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.themeId, r))).returning()).length > 0;
|
|
3882
3910
|
}
|
|
3883
3911
|
};
|
|
3884
3912
|
}
|
|
@@ -3887,18 +3915,18 @@ function jr(e) {
|
|
|
3887
3915
|
function Mr(e) {
|
|
3888
3916
|
return {
|
|
3889
3917
|
async get(t) {
|
|
3890
|
-
let n = await e.select({ body:
|
|
3918
|
+
let n = await e.select({ body: Ye.body }).from(Ye).where(a(Ye.tenant_id, t)).get();
|
|
3891
3919
|
return n ? { body: n.body } : null;
|
|
3892
3920
|
},
|
|
3893
3921
|
async set(t, n) {
|
|
3894
3922
|
let r = Date.now();
|
|
3895
|
-
await e.insert(
|
|
3923
|
+
await e.insert(Ye).values({
|
|
3896
3924
|
tenant_id: t,
|
|
3897
3925
|
body: n.body,
|
|
3898
3926
|
created_at_ts: r,
|
|
3899
3927
|
updated_at_ts: r
|
|
3900
3928
|
}).onConflictDoUpdate({
|
|
3901
|
-
target:
|
|
3929
|
+
target: Ye.tenant_id,
|
|
3902
3930
|
set: {
|
|
3903
3931
|
body: n.body,
|
|
3904
3932
|
updated_at_ts: r
|
|
@@ -3906,7 +3934,7 @@ function Mr(e) {
|
|
|
3906
3934
|
});
|
|
3907
3935
|
},
|
|
3908
3936
|
async delete(t) {
|
|
3909
|
-
await e.delete(
|
|
3937
|
+
await e.delete(Ye).where(a(Ye.tenant_id, t));
|
|
3910
3938
|
}
|
|
3911
3939
|
};
|
|
3912
3940
|
}
|
|
@@ -4292,7 +4320,7 @@ function Yr(e) {
|
|
|
4292
4320
|
},
|
|
4293
4321
|
async remove(n, r, i) {
|
|
4294
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 = [
|
|
4295
|
-
e.delete(
|
|
4323
|
+
e.delete(ot).where(t(a(ot.tenant_id, n), l(ot.user_id, u))),
|
|
4296
4324
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4297
4325
|
e.delete(Be).where(t(a(Be.tenant_id, n), l(Be.user_id, u))),
|
|
4298
4326
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
@@ -4314,7 +4342,7 @@ function Xr(e) {
|
|
|
4314
4342
|
return {
|
|
4315
4343
|
async create(t, n, r, i) {
|
|
4316
4344
|
try {
|
|
4317
|
-
await e.insert(
|
|
4345
|
+
await e.insert(G).values({
|
|
4318
4346
|
tenant_id: t,
|
|
4319
4347
|
user_id: n,
|
|
4320
4348
|
role_id: r,
|
|
@@ -4328,11 +4356,11 @@ function Xr(e) {
|
|
|
4328
4356
|
return !0;
|
|
4329
4357
|
},
|
|
4330
4358
|
async list(n, r, i, o) {
|
|
4331
|
-
let s = [a(
|
|
4332
|
-
o !== void 0 && s.push(a(
|
|
4333
|
-
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();
|
|
4334
4362
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4335
|
-
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();
|
|
4336
4364
|
if (!i) return null;
|
|
4337
4365
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4338
4366
|
return D({
|
|
@@ -4343,13 +4371,13 @@ function Xr(e) {
|
|
|
4343
4371
|
}))).filter(Boolean);
|
|
4344
4372
|
},
|
|
4345
4373
|
async listUsers(r, i, o) {
|
|
4346
|
-
let s = t(a(
|
|
4374
|
+
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4347
4375
|
if (Et(o)) {
|
|
4348
4376
|
let n = {
|
|
4349
|
-
sortColumn:
|
|
4350
|
-
idColumn:
|
|
4377
|
+
sortColumn: G.user_id,
|
|
4378
|
+
idColumn: G.user_id,
|
|
4351
4379
|
sortOrder: "asc"
|
|
4352
|
-
}, 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");
|
|
4353
4381
|
return {
|
|
4354
4382
|
userIds: a.map((e) => e.user_id),
|
|
4355
4383
|
start: 0,
|
|
@@ -4358,7 +4386,7 @@ function Xr(e) {
|
|
|
4358
4386
|
next: c
|
|
4359
4387
|
};
|
|
4360
4388
|
}
|
|
4361
|
-
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();
|
|
4362
4390
|
return {
|
|
4363
4391
|
userIds: d.map((e) => e.user_id),
|
|
4364
4392
|
start: u,
|
|
@@ -4367,7 +4395,7 @@ function Xr(e) {
|
|
|
4367
4395
|
};
|
|
4368
4396
|
},
|
|
4369
4397
|
async remove(n, r, i, o) {
|
|
4370
|
-
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;
|
|
4371
4399
|
}
|
|
4372
4400
|
};
|
|
4373
4401
|
}
|
|
@@ -4385,7 +4413,7 @@ function Zr(e) {
|
|
|
4385
4413
|
updated_at: r
|
|
4386
4414
|
};
|
|
4387
4415
|
try {
|
|
4388
|
-
await e.insert(
|
|
4416
|
+
await e.insert(U).values(i);
|
|
4389
4417
|
} catch (e) {
|
|
4390
4418
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Fe(409, { message: "User organization already exists" }) : e;
|
|
4391
4419
|
}
|
|
@@ -4393,19 +4421,19 @@ function Zr(e) {
|
|
|
4393
4421
|
return o;
|
|
4394
4422
|
},
|
|
4395
4423
|
async get(n, r) {
|
|
4396
|
-
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();
|
|
4397
4425
|
if (!i) return null;
|
|
4398
4426
|
let { tenant_id: o, ...s } = i;
|
|
4399
4427
|
return s;
|
|
4400
4428
|
},
|
|
4401
4429
|
async update(n, r, i) {
|
|
4402
4430
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4403
|
-
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;
|
|
4404
4432
|
},
|
|
4405
4433
|
async list(n, o) {
|
|
4406
|
-
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;
|
|
4407
4435
|
if (c) {
|
|
4408
|
-
let e = mt(
|
|
4436
|
+
let e = mt(U, c, ["user_id", "organization_id"]);
|
|
4409
4437
|
e && (u = t(l, e));
|
|
4410
4438
|
}
|
|
4411
4439
|
let d = (e) => {
|
|
@@ -4414,10 +4442,10 @@ function Zr(e) {
|
|
|
4414
4442
|
};
|
|
4415
4443
|
if (Et(o)) {
|
|
4416
4444
|
let n = {
|
|
4417
|
-
sortColumn:
|
|
4418
|
-
idColumn:
|
|
4445
|
+
sortColumn: U.created_at,
|
|
4446
|
+
idColumn: U.id,
|
|
4419
4447
|
sortOrder: "desc"
|
|
4420
|
-
}, 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");
|
|
4421
4449
|
return {
|
|
4422
4450
|
userOrganizations: a,
|
|
4423
4451
|
start: 0,
|
|
@@ -4426,9 +4454,9 @@ function Zr(e) {
|
|
|
4426
4454
|
next: s
|
|
4427
4455
|
};
|
|
4428
4456
|
}
|
|
4429
|
-
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);
|
|
4430
4458
|
if (!s) return { userOrganizations: h };
|
|
4431
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4459
|
+
let [g] = await e.select({ count: r() }).from(U).where(u);
|
|
4432
4460
|
return {
|
|
4433
4461
|
userOrganizations: h,
|
|
4434
4462
|
start: m,
|
|
@@ -4437,8 +4465,8 @@ function Zr(e) {
|
|
|
4437
4465
|
};
|
|
4438
4466
|
},
|
|
4439
4467
|
async listUserOrganizations(n, i, o) {
|
|
4440
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(
|
|
4441
|
-
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();
|
|
4442
4470
|
if (!i) return null;
|
|
4443
4471
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4444
4472
|
return D({
|
|
@@ -4450,7 +4478,7 @@ function Zr(e) {
|
|
|
4450
4478
|
});
|
|
4451
4479
|
}))).filter(Boolean);
|
|
4452
4480
|
if (!l) return { organizations: d };
|
|
4453
|
-
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)));
|
|
4454
4482
|
return {
|
|
4455
4483
|
organizations: d,
|
|
4456
4484
|
start: s * c,
|
|
@@ -4459,7 +4487,7 @@ function Zr(e) {
|
|
|
4459
4487
|
};
|
|
4460
4488
|
},
|
|
4461
4489
|
async remove(n, r) {
|
|
4462
|
-
return (await e.delete(
|
|
4490
|
+
return (await e.delete(U).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4463
4491
|
}
|
|
4464
4492
|
};
|
|
4465
4493
|
}
|
|
@@ -5244,10 +5272,10 @@ function Bi(e) {
|
|
|
5244
5272
|
}
|
|
5245
5273
|
async function Vi(e, r) {
|
|
5246
5274
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5247
|
-
custom_domain_id:
|
|
5248
|
-
tenant_id:
|
|
5249
|
-
domain:
|
|
5250
|
-
}).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];
|
|
5251
5279
|
if (!o) return null;
|
|
5252
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) => ({
|
|
5253
5281
|
id: e.id,
|