@authhero/drizzle 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +646 -635
- package/drizzle/0004_action_executions_created_at_index.sql +1 -0
- package/drizzle/meta/0004_snapshot.json +6586 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +3 -3
- package/src/schema/sqlite/actions.ts +1 -0
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -121,7 +121,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
121
121
|
}, (e) => [C({
|
|
122
122
|
columns: [e.tenant_id, e.id],
|
|
123
123
|
name: "action_executions_pk"
|
|
124
|
-
})]), j = w("users", {
|
|
124
|
+
}), x("action_executions_created_at_ts_index").on(e.created_at_ts)]), j = w("users", {
|
|
125
125
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
126
126
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
127
127
|
email: T("email", { length: 255 }),
|
|
@@ -464,7 +464,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
464
464
|
C({ columns: [e.tenant_id, e.id] }),
|
|
465
465
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
466
466
|
E("connections_id_unique").on(e.id)
|
|
467
|
-
]),
|
|
467
|
+
]), Me = w("custom_domains", {
|
|
468
468
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
469
469
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
470
470
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -478,7 +478,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
478
478
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
479
479
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
480
480
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
481
|
-
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]),
|
|
481
|
+
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]), Ne = w("domains", {
|
|
482
482
|
id: T("id", { length: 255 }).primaryKey(),
|
|
483
483
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
484
484
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -488,7 +488,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
488
488
|
dkim_public_key: T("dkim_public_key", { length: 2048 }),
|
|
489
489
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
490
490
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
491
|
-
}),
|
|
491
|
+
}), H = w("organizations", {
|
|
492
492
|
id: T("id", { length: 21 }).primaryKey(),
|
|
493
493
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
494
494
|
name: T("name", { length: 256 }).notNull(),
|
|
@@ -499,7 +499,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
499
499
|
token_quota: T("token_quota"),
|
|
500
500
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
501
501
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
502
|
-
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]),
|
|
502
|
+
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]), U = w("user_organizations", {
|
|
503
503
|
id: T("id", { length: 21 }).primaryKey(),
|
|
504
504
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
505
505
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
@@ -511,7 +511,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
511
511
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
512
512
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
513
513
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
514
|
-
]),
|
|
514
|
+
]), Pe = w("invites", {
|
|
515
515
|
id: T("id", { length: 21 }).primaryKey(),
|
|
516
516
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
517
517
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -533,7 +533,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
533
533
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
534
534
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
535
535
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
536
|
-
]),
|
|
536
|
+
]), W = w("roles", {
|
|
537
537
|
id: T("id", { length: 21 }).notNull(),
|
|
538
538
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
539
539
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -545,7 +545,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
545
545
|
}, (e) => [C({
|
|
546
546
|
columns: [e.tenant_id, e.id],
|
|
547
547
|
name: "roles_pk"
|
|
548
|
-
})]),
|
|
548
|
+
})]), Fe = w("role_permissions", {
|
|
549
549
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
550
550
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
551
551
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -563,7 +563,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
563
563
|
}),
|
|
564
564
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
565
565
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
566
|
-
]),
|
|
566
|
+
]), Ie = w("user_permissions", {
|
|
567
567
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
568
568
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
569
569
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -584,7 +584,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
584
584
|
x("user_permissions_user_fk").on(e.tenant_id, e.user_id),
|
|
585
585
|
x("user_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name),
|
|
586
586
|
x("user_permissions_organization_fk").on(e.organization_id)
|
|
587
|
-
]),
|
|
587
|
+
]), G = w("user_roles", {
|
|
588
588
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
589
589
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
590
590
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
@@ -603,7 +603,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
603
603
|
x("user_roles_user_fk").on(e.tenant_id, e.user_id),
|
|
604
604
|
x("user_roles_role_fk").on(e.tenant_id, e.role_id),
|
|
605
605
|
x("user_roles_organization_fk").on(e.organization_id)
|
|
606
|
-
]),
|
|
606
|
+
]), K = w("resource_servers", {
|
|
607
607
|
id: T("id", { length: 21 }).notNull(),
|
|
608
608
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
609
609
|
identifier: T("identifier", { length: 191 }).notNull(),
|
|
@@ -624,7 +624,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
624
624
|
}, (e) => [C({
|
|
625
625
|
columns: [e.tenant_id, e.id],
|
|
626
626
|
name: "resource_servers_pk"
|
|
627
|
-
})]),
|
|
627
|
+
})]), Le = w("branding", {
|
|
628
628
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
629
629
|
logo_url: T("logo_url", { length: 512 }),
|
|
630
630
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -635,12 +635,12 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
635
635
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
636
636
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
637
637
|
dark_mode: T("dark_mode", { length: 8 })
|
|
638
|
-
}),
|
|
638
|
+
}), Re = w("universal_login_templates", {
|
|
639
639
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
640
640
|
body: T("body").notNull(),
|
|
641
641
|
created_at_ts: S("created_at_ts").notNull(),
|
|
642
642
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
643
|
-
}),
|
|
643
|
+
}), ze = w("themes", {
|
|
644
644
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
645
645
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
646
646
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -700,7 +700,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
700
700
|
}, (e) => [C({
|
|
701
701
|
columns: [e.tenant_id, e.themeId],
|
|
702
702
|
name: "themes_pkey"
|
|
703
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
703
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), Be = w("forms", {
|
|
704
704
|
id: T("id", { length: 255 }).primaryKey(),
|
|
705
705
|
name: T("name", { length: 255 }).notNull(),
|
|
706
706
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
@@ -713,21 +713,21 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
713
713
|
style: T("style", { length: 1042 }),
|
|
714
714
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
715
715
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
716
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
716
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Ve = w("flows", {
|
|
717
717
|
id: T("id", { length: 24 }).primaryKey(),
|
|
718
718
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
719
719
|
name: T("name", { length: 150 }).notNull(),
|
|
720
720
|
actions: T("actions"),
|
|
721
721
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
722
722
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
723
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
723
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), He = w("prompt_settings", {
|
|
724
724
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
725
725
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
726
726
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
727
727
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
728
728
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
729
729
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
730
|
-
}),
|
|
730
|
+
}), Ue = w("email_providers", {
|
|
731
731
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
732
732
|
name: T("name", { length: 255 }).notNull(),
|
|
733
733
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -736,7 +736,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
736
736
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
737
737
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
738
738
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
739
|
-
}),
|
|
739
|
+
}), We = w("email_templates", {
|
|
740
740
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
741
741
|
template: T("template", { length: 64 }).notNull(),
|
|
742
742
|
body: T("body").notNull(),
|
|
@@ -749,7 +749,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
749
749
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
750
750
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
751
751
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
752
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
752
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), Ge = w("hooks", {
|
|
753
753
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
754
754
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
755
755
|
url: T("url", { length: 512 }),
|
|
@@ -763,14 +763,14 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
763
763
|
template_id: T("template_id", { length: 64 }),
|
|
764
764
|
code_id: T("code_id", { length: 21 }),
|
|
765
765
|
metadata: T("metadata")
|
|
766
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
766
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), Ke = w("hook_code", {
|
|
767
767
|
id: T("id", { length: 21 }).primaryKey(),
|
|
768
768
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
769
769
|
code: T("code").notNull(),
|
|
770
770
|
secrets: T("secrets"),
|
|
771
771
|
created_at_ts: S("created_at_ts").notNull(),
|
|
772
772
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
773
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
773
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), qe = w("keys", {
|
|
774
774
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
775
775
|
tenant_id: T("tenant_id", { length: 191 }).references(() => k.id, { onDelete: "cascade" }),
|
|
776
776
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -783,7 +783,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
783
783
|
current_until: T("current_until", { length: 35 }),
|
|
784
784
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
785
785
|
connection: T("connection", { length: 255 }).references(() => V.id, { onDelete: "cascade" })
|
|
786
|
-
}),
|
|
786
|
+
}), Je = w("custom_text", {
|
|
787
787
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
788
788
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
789
789
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -794,7 +794,7 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
794
794
|
e.tenant_id,
|
|
795
795
|
e.prompt,
|
|
796
796
|
e.language
|
|
797
|
-
] })]),
|
|
797
|
+
] })]), q = w("authentication_methods", {
|
|
798
798
|
id: T("id", { length: 26 }).primaryKey(),
|
|
799
799
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
800
800
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -911,49 +911,49 @@ var we = Object.defineProperty, Te = (e, t) => {
|
|
|
911
911
|
actionVersions: () => A,
|
|
912
912
|
actions: () => Ee,
|
|
913
913
|
authenticationCodes: () => ke,
|
|
914
|
-
authenticationMethods: () =>
|
|
915
|
-
branding: () =>
|
|
914
|
+
authenticationMethods: () => q,
|
|
915
|
+
branding: () => Le,
|
|
916
916
|
clientGrants: () => z,
|
|
917
917
|
clientRegistrationTokens: () => R,
|
|
918
918
|
clients: () => L,
|
|
919
919
|
codes: () => I,
|
|
920
920
|
connections: () => V,
|
|
921
|
-
customDomains: () =>
|
|
922
|
-
customText: () =>
|
|
923
|
-
domains: () =>
|
|
924
|
-
emailProviders: () =>
|
|
925
|
-
emailTemplates: () =>
|
|
926
|
-
flows: () =>
|
|
927
|
-
forms: () =>
|
|
921
|
+
customDomains: () => Me,
|
|
922
|
+
customText: () => Je,
|
|
923
|
+
domains: () => Ne,
|
|
924
|
+
emailProviders: () => Ue,
|
|
925
|
+
emailTemplates: () => We,
|
|
926
|
+
flows: () => Ve,
|
|
927
|
+
forms: () => Be,
|
|
928
928
|
grants: () => B,
|
|
929
|
-
hookCode: () =>
|
|
930
|
-
hooks: () =>
|
|
931
|
-
invites: () =>
|
|
932
|
-
keys: () =>
|
|
929
|
+
hookCode: () => Ke,
|
|
930
|
+
hooks: () => Ge,
|
|
931
|
+
invites: () => Pe,
|
|
932
|
+
keys: () => qe,
|
|
933
933
|
loginSessions: () => F,
|
|
934
934
|
logs: () => J,
|
|
935
|
-
organizations: () =>
|
|
935
|
+
organizations: () => H,
|
|
936
936
|
otps: () => Ae,
|
|
937
937
|
outboxEvents: () => Y,
|
|
938
938
|
passwords: () => M,
|
|
939
|
-
promptSettings: () =>
|
|
939
|
+
promptSettings: () => He,
|
|
940
940
|
proxyRoutes: () => X,
|
|
941
941
|
refreshTokens: () => P,
|
|
942
|
-
resourceServers: () =>
|
|
943
|
-
rolePermissions: () =>
|
|
944
|
-
roles: () =>
|
|
942
|
+
resourceServers: () => K,
|
|
943
|
+
rolePermissions: () => Fe,
|
|
944
|
+
roles: () => W,
|
|
945
945
|
scimConfigurations: () => Ye,
|
|
946
946
|
scimExternalIds: () => Xe,
|
|
947
947
|
scimTokens: () => Z,
|
|
948
948
|
sessions: () => N,
|
|
949
949
|
tenants: () => k,
|
|
950
|
-
themes: () =>
|
|
950
|
+
themes: () => ze,
|
|
951
951
|
tickets: () => je,
|
|
952
|
-
universalLoginTemplates: () =>
|
|
952
|
+
universalLoginTemplates: () => Re,
|
|
953
953
|
userActivity: () => Oe,
|
|
954
|
-
userOrganizations: () =>
|
|
955
|
-
userPermissions: () =>
|
|
956
|
-
userRoles: () =>
|
|
954
|
+
userOrganizations: () => U,
|
|
955
|
+
userPermissions: () => Ie,
|
|
956
|
+
userRoles: () => G,
|
|
957
957
|
users: () => j
|
|
958
958
|
});
|
|
959
959
|
//#endregion
|
|
@@ -1194,7 +1194,8 @@ function at(e) {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
//#endregion
|
|
1196
1196
|
//#region src/adapters/actionExecutions.ts
|
|
1197
|
-
|
|
1197
|
+
var ot = 500;
|
|
1198
|
+
function st(e) {
|
|
1198
1199
|
return {
|
|
1199
1200
|
async create(t, n) {
|
|
1200
1201
|
let r = Date.now();
|
|
@@ -1230,17 +1231,27 @@ function ot(e) {
|
|
|
1230
1231
|
created_at: new Date(Number(i.created_at_ts)).toISOString(),
|
|
1231
1232
|
updated_at: new Date(Number(i.updated_at_ts)).toISOString()
|
|
1232
1233
|
} : null;
|
|
1234
|
+
},
|
|
1235
|
+
async cleanup(t) {
|
|
1236
|
+
let n = Date.parse(t);
|
|
1237
|
+
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1238
|
+
let r = 0;
|
|
1239
|
+
for (;;) {
|
|
1240
|
+
let t = await e.delete(De).where(y`rowid IN (SELECT rowid FROM ${De} WHERE ${De.created_at_ts} < ${n} LIMIT ${ot})`).returning({ id: De.id });
|
|
1241
|
+
if (r += t.length, t.length < ot) break;
|
|
1242
|
+
}
|
|
1243
|
+
return r;
|
|
1233
1244
|
}
|
|
1234
1245
|
};
|
|
1235
1246
|
}
|
|
1236
1247
|
//#endregion
|
|
1237
1248
|
//#region src/adapters/atomic.ts
|
|
1238
|
-
function
|
|
1249
|
+
function ct(e) {
|
|
1239
1250
|
let t = e;
|
|
1240
1251
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1241
1252
|
}
|
|
1242
|
-
async function
|
|
1243
|
-
if (
|
|
1253
|
+
async function lt(e, t) {
|
|
1254
|
+
if (ct(e)) return e.batch(t);
|
|
1244
1255
|
await e.run(y`BEGIN`);
|
|
1245
1256
|
try {
|
|
1246
1257
|
let n = [];
|
|
@@ -1257,7 +1268,7 @@ async function ct(e, t) {
|
|
|
1257
1268
|
}
|
|
1258
1269
|
//#endregion
|
|
1259
1270
|
//#region src/adapters/actionVersions.ts
|
|
1260
|
-
function
|
|
1271
|
+
function ut(e) {
|
|
1261
1272
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1262
1273
|
return {
|
|
1263
1274
|
...c,
|
|
@@ -1270,7 +1281,7 @@ function lt(e) {
|
|
|
1270
1281
|
updated_at: new Date(Number(n)).toISOString()
|
|
1271
1282
|
};
|
|
1272
1283
|
}
|
|
1273
|
-
function
|
|
1284
|
+
function dt(e) {
|
|
1274
1285
|
return {
|
|
1275
1286
|
async create(n, r) {
|
|
1276
1287
|
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: A.number }).from(A).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id))).orderBy(i(A.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(A).values({
|
|
@@ -1287,7 +1298,7 @@ function ut(e) {
|
|
|
1287
1298
|
created_at_ts: o,
|
|
1288
1299
|
updated_at_ts: o
|
|
1289
1300
|
});
|
|
1290
|
-
return await
|
|
1301
|
+
return await lt(e, c ? [e.update(A).set({
|
|
1291
1302
|
deployed: 0,
|
|
1292
1303
|
updated_at_ts: o
|
|
1293
1304
|
}).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id), a(A.deployed, 1))), u] : [u]), {
|
|
@@ -1307,10 +1318,10 @@ function ut(e) {
|
|
|
1307
1318
|
},
|
|
1308
1319
|
async get(n, r, i) {
|
|
1309
1320
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.action_id, r), a(A.id, i))).get();
|
|
1310
|
-
return o ?
|
|
1321
|
+
return o ? ut(o) : null;
|
|
1311
1322
|
},
|
|
1312
1323
|
async list(n, o, s = {}) {
|
|
1313
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(
|
|
1324
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(ut);
|
|
1314
1325
|
if (!u) return {
|
|
1315
1326
|
versions: f,
|
|
1316
1327
|
start: 0,
|
|
@@ -1332,13 +1343,13 @@ function ut(e) {
|
|
|
1332
1343
|
}
|
|
1333
1344
|
//#endregion
|
|
1334
1345
|
//#region src/adapters/branding.ts
|
|
1335
|
-
function
|
|
1346
|
+
function ft(e) {
|
|
1336
1347
|
return e === "dark" || e === "light" || e === "auto";
|
|
1337
1348
|
}
|
|
1338
|
-
function
|
|
1349
|
+
function pt(e) {
|
|
1339
1350
|
return {
|
|
1340
1351
|
async get(t) {
|
|
1341
|
-
let n = await e.select().from(
|
|
1352
|
+
let n = await e.select().from(Le).where(a(Le.tenant_id, t)).get();
|
|
1342
1353
|
if (!n) return null;
|
|
1343
1354
|
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;
|
|
1344
1355
|
return O({
|
|
@@ -1353,7 +1364,7 @@ function ft(e) {
|
|
|
1353
1364
|
}
|
|
1354
1365
|
},
|
|
1355
1366
|
font: u ? { url: u } : void 0,
|
|
1356
|
-
dark_mode:
|
|
1367
|
+
dark_mode: ft(d) ? d : void 0
|
|
1357
1368
|
});
|
|
1358
1369
|
},
|
|
1359
1370
|
async set(t, n) {
|
|
@@ -1367,11 +1378,11 @@ function ft(e) {
|
|
|
1367
1378
|
font_url: i?.url,
|
|
1368
1379
|
dark_mode: a
|
|
1369
1380
|
};
|
|
1370
|
-
await e.insert(
|
|
1381
|
+
await e.insert(Le).values({
|
|
1371
1382
|
tenant_id: t,
|
|
1372
1383
|
...l
|
|
1373
1384
|
}).onConflictDoUpdate({
|
|
1374
|
-
target:
|
|
1385
|
+
target: Le.tenant_id,
|
|
1375
1386
|
set: l
|
|
1376
1387
|
});
|
|
1377
1388
|
}
|
|
@@ -1379,18 +1390,18 @@ function ft(e) {
|
|
|
1379
1390
|
}
|
|
1380
1391
|
//#endregion
|
|
1381
1392
|
//#region src/helpers/paginate.ts
|
|
1382
|
-
function
|
|
1393
|
+
function mt(e) {
|
|
1383
1394
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1384
1395
|
}
|
|
1385
|
-
function
|
|
1396
|
+
function ht(e) {
|
|
1386
1397
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1387
1398
|
return n >= 1 ? n : 50;
|
|
1388
1399
|
}
|
|
1389
|
-
function
|
|
1400
|
+
function gt(e) {
|
|
1390
1401
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1391
1402
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1392
1403
|
}
|
|
1393
|
-
function
|
|
1404
|
+
function _t(e, t) {
|
|
1394
1405
|
let n = e?.from ? ue(e.from) : null;
|
|
1395
1406
|
if (!n) return;
|
|
1396
1407
|
if (n.k !== t.sortKey) throw new Ce(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
@@ -1398,7 +1409,7 @@ function gt(e, t) {
|
|
|
1398
1409
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1399
1410
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1400
1411
|
}
|
|
1401
|
-
function
|
|
1412
|
+
function vt(e, t, n, r = "id", i) {
|
|
1402
1413
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1403
1414
|
if (a && c) {
|
|
1404
1415
|
let e = c[n];
|
|
@@ -1415,7 +1426,7 @@ function _t(e, t, n, r = "id", i) {
|
|
|
1415
1426
|
}
|
|
1416
1427
|
//#endregion
|
|
1417
1428
|
//#region src/adapters/clients.ts
|
|
1418
|
-
var
|
|
1429
|
+
var yt = [
|
|
1419
1430
|
"global",
|
|
1420
1431
|
"is_first_party",
|
|
1421
1432
|
"oidc_conformant",
|
|
@@ -1427,7 +1438,7 @@ var vt = [
|
|
|
1427
1438
|
"require_pushed_authorization_requests",
|
|
1428
1439
|
"require_proof_of_possession",
|
|
1429
1440
|
"hide_sign_up_disabled_error"
|
|
1430
|
-
],
|
|
1441
|
+
], bt = [
|
|
1431
1442
|
"callbacks",
|
|
1432
1443
|
"allowed_origins",
|
|
1433
1444
|
"web_origins",
|
|
@@ -1436,7 +1447,7 @@ var vt = [
|
|
|
1436
1447
|
"allowed_logout_urls",
|
|
1437
1448
|
"grant_types",
|
|
1438
1449
|
"signing_keys"
|
|
1439
|
-
],
|
|
1450
|
+
], xt = [
|
|
1440
1451
|
"session_transfer",
|
|
1441
1452
|
"oidc_logout",
|
|
1442
1453
|
"jwt_configuration",
|
|
@@ -1452,21 +1463,21 @@ var vt = [
|
|
|
1452
1463
|
"token_quota",
|
|
1453
1464
|
"registration_metadata"
|
|
1454
1465
|
];
|
|
1455
|
-
function
|
|
1466
|
+
function St(e) {
|
|
1456
1467
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1457
|
-
for (let e of
|
|
1458
|
-
for (let e of
|
|
1459
|
-
for (let e of
|
|
1468
|
+
for (let e of yt) i[e] = !!r[e];
|
|
1469
|
+
for (let e of bt) i[e] = Q(r[e], []);
|
|
1470
|
+
for (let e of xt) i[e] = Q(r[e], {});
|
|
1460
1471
|
return i.connections = Q(n, []), O(i);
|
|
1461
1472
|
}
|
|
1462
|
-
function
|
|
1473
|
+
function Ct(e) {
|
|
1463
1474
|
let t = { ...e };
|
|
1464
|
-
re(e,
|
|
1465
|
-
for (let n of
|
|
1466
|
-
for (let n of
|
|
1475
|
+
re(e, yt, t);
|
|
1476
|
+
for (let n of bt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1477
|
+
for (let n of xt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1467
1478
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), se(t);
|
|
1468
1479
|
}
|
|
1469
|
-
function
|
|
1480
|
+
function wt(e) {
|
|
1470
1481
|
return {
|
|
1471
1482
|
async create(t, n) {
|
|
1472
1483
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1490,12 +1501,12 @@ function Ct(e) {
|
|
|
1490
1501
|
created_at: r,
|
|
1491
1502
|
updated_at: r
|
|
1492
1503
|
};
|
|
1493
|
-
for (let e of
|
|
1504
|
+
for (let e of yt) i[e] = n[e] ?? !1;
|
|
1494
1505
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1495
|
-
for (let e of
|
|
1496
|
-
for (let e of
|
|
1506
|
+
for (let e of bt) i[e] = n[e] || [];
|
|
1507
|
+
for (let e of xt) i[e] = n[e] || {};
|
|
1497
1508
|
i.connections = n.connections || [];
|
|
1498
|
-
let a =
|
|
1509
|
+
let a = Ct(i);
|
|
1499
1510
|
try {
|
|
1500
1511
|
await e.insert(L).values({
|
|
1501
1512
|
...a,
|
|
@@ -1504,24 +1515,24 @@ function Ct(e) {
|
|
|
1504
1515
|
} catch (e) {
|
|
1505
1516
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Client already exists" }) : e;
|
|
1506
1517
|
}
|
|
1507
|
-
return
|
|
1518
|
+
return St({
|
|
1508
1519
|
...a,
|
|
1509
1520
|
tenant_id: t
|
|
1510
1521
|
});
|
|
1511
1522
|
},
|
|
1512
1523
|
async get(n, r) {
|
|
1513
1524
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1514
|
-
return i ?
|
|
1525
|
+
return i ? St(i) : null;
|
|
1515
1526
|
},
|
|
1516
1527
|
async getByClientId(t) {
|
|
1517
1528
|
let n = await e.select().from(L).where(a(L.client_id, t)).get();
|
|
1518
1529
|
return n ? {
|
|
1519
|
-
...
|
|
1530
|
+
...St(n),
|
|
1520
1531
|
tenant_id: n.tenant_id
|
|
1521
1532
|
} : null;
|
|
1522
1533
|
},
|
|
1523
1534
|
async update(n, r, i) {
|
|
1524
|
-
let o =
|
|
1535
|
+
let o = Ct({
|
|
1525
1536
|
...i,
|
|
1526
1537
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1527
1538
|
});
|
|
@@ -1529,12 +1540,12 @@ function Ct(e) {
|
|
|
1529
1540
|
},
|
|
1530
1541
|
async list(o, s) {
|
|
1531
1542
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(L, f, ["name", "client_id"]) : void 0, m = p ? t(a(L.tenant_id, o), p) : a(L.tenant_id, o);
|
|
1532
|
-
if (
|
|
1543
|
+
if (mt(s)) {
|
|
1533
1544
|
let n = {
|
|
1534
1545
|
sortColumn: L.created_at,
|
|
1535
1546
|
idColumn: L.client_id,
|
|
1536
1547
|
sortOrder: "desc"
|
|
1537
|
-
}, r =
|
|
1548
|
+
}, r = _t(s, n), i = ht(s), { rows: a, next: o } = vt(await e.select().from(L).where(r ? t(m, r) : m).orderBy(...gt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(St);
|
|
1538
1549
|
return {
|
|
1539
1550
|
clients: c,
|
|
1540
1551
|
totals: {
|
|
@@ -1550,7 +1561,7 @@ function Ct(e) {
|
|
|
1550
1561
|
let e = L[d.sort_by];
|
|
1551
1562
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1552
1563
|
}
|
|
1553
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1564
|
+
let g = (await h.offset(c * l).limit(l)).map(St);
|
|
1554
1565
|
if (!u) return { clients: g };
|
|
1555
1566
|
let [_] = await e.select({ count: r() }).from(L).where(m);
|
|
1556
1567
|
return {
|
|
@@ -1570,7 +1581,7 @@ function Ct(e) {
|
|
|
1570
1581
|
}
|
|
1571
1582
|
//#endregion
|
|
1572
1583
|
//#region src/adapters/clientConnections.ts
|
|
1573
|
-
function
|
|
1584
|
+
function Tt(e) {
|
|
1574
1585
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1575
1586
|
return O({
|
|
1576
1587
|
...a,
|
|
@@ -1579,14 +1590,14 @@ function wt(e) {
|
|
|
1579
1590
|
is_system: n ? !0 : void 0
|
|
1580
1591
|
});
|
|
1581
1592
|
}
|
|
1582
|
-
function
|
|
1593
|
+
function Et(e) {
|
|
1583
1594
|
return {
|
|
1584
1595
|
async listByClient(n, r) {
|
|
1585
1596
|
let i = await e.select({ connections: L.connections }).from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1586
1597
|
if (!i) return [];
|
|
1587
1598
|
let o = Q(i.connections, []) || [];
|
|
1588
1599
|
if (o.length === 0) return [];
|
|
1589
|
-
let s = (await e.select().from(V).where(t(a(V.tenant_id, n), l(V.id, o))).all()).map(
|
|
1600
|
+
let s = (await e.select().from(V).where(t(a(V.tenant_id, n), l(V.id, o))).all()).map(Tt);
|
|
1590
1601
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1591
1602
|
},
|
|
1592
1603
|
async updateByClient(n, r, i) {
|
|
@@ -1623,7 +1634,7 @@ function Tt(e) {
|
|
|
1623
1634
|
}
|
|
1624
1635
|
//#endregion
|
|
1625
1636
|
//#region src/adapters/clientGrants.ts
|
|
1626
|
-
function
|
|
1637
|
+
function Dt(e) {
|
|
1627
1638
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1628
1639
|
return O({
|
|
1629
1640
|
...o,
|
|
@@ -1633,7 +1644,7 @@ function Et(e) {
|
|
|
1633
1644
|
is_system: !!a
|
|
1634
1645
|
});
|
|
1635
1646
|
}
|
|
1636
|
-
function
|
|
1647
|
+
function Ot(e) {
|
|
1637
1648
|
return {
|
|
1638
1649
|
async create(t, n) {
|
|
1639
1650
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1650,14 +1661,14 @@ function Dt(e) {
|
|
|
1650
1661
|
created_at: r,
|
|
1651
1662
|
updated_at: r
|
|
1652
1663
|
};
|
|
1653
|
-
return await e.insert(z).values(i),
|
|
1664
|
+
return await e.insert(z).values(i), Dt({
|
|
1654
1665
|
...i,
|
|
1655
1666
|
tenant_id: t
|
|
1656
1667
|
});
|
|
1657
1668
|
},
|
|
1658
1669
|
async get(n, r) {
|
|
1659
1670
|
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1660
|
-
return i ?
|
|
1671
|
+
return i ? Dt(i) : null;
|
|
1661
1672
|
},
|
|
1662
1673
|
async update(n, r, i) {
|
|
1663
1674
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1668,12 +1679,12 @@ function Dt(e) {
|
|
|
1668
1679
|
},
|
|
1669
1680
|
async list(o, s) {
|
|
1670
1681
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(z, f, ["client_id", "audience"]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o);
|
|
1671
|
-
if (
|
|
1682
|
+
if (mt(s)) {
|
|
1672
1683
|
let n = {
|
|
1673
1684
|
sortColumn: z.created_at,
|
|
1674
1685
|
idColumn: z.id,
|
|
1675
1686
|
sortOrder: "desc"
|
|
1676
|
-
}, r =
|
|
1687
|
+
}, r = _t(s, n), i = ht(s), { rows: a, next: o } = vt(await e.select().from(z).where(r ? t(m, r) : m).orderBy(...gt(n)).limit(i + 1), i, "created_at"), c = a.map(Dt);
|
|
1677
1688
|
return {
|
|
1678
1689
|
client_grants: c,
|
|
1679
1690
|
start: 0,
|
|
@@ -1687,7 +1698,7 @@ function Dt(e) {
|
|
|
1687
1698
|
let e = z[d.sort_by];
|
|
1688
1699
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1689
1700
|
} else h = h.orderBy(n(z.created_at));
|
|
1690
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1701
|
+
let g = (await h.offset(c * l).limit(l)).map(Dt);
|
|
1691
1702
|
if (!u) return { client_grants: g };
|
|
1692
1703
|
let [_] = await e.select({ count: r() }).from(z).where(m);
|
|
1693
1704
|
return {
|
|
@@ -1704,20 +1715,20 @@ function Dt(e) {
|
|
|
1704
1715
|
}
|
|
1705
1716
|
//#endregion
|
|
1706
1717
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1707
|
-
function
|
|
1718
|
+
function kt(e) {
|
|
1708
1719
|
if (!e) return;
|
|
1709
1720
|
let t = JSON.parse(e);
|
|
1710
1721
|
return pe(t) ? t : void 0;
|
|
1711
1722
|
}
|
|
1712
|
-
function
|
|
1723
|
+
function At(e) {
|
|
1713
1724
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1714
1725
|
}
|
|
1715
|
-
function
|
|
1726
|
+
function jt(e) {
|
|
1716
1727
|
if (!e) return null;
|
|
1717
1728
|
let t = new Date(e);
|
|
1718
1729
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1719
1730
|
}
|
|
1720
|
-
function
|
|
1731
|
+
function Mt(e) {
|
|
1721
1732
|
let t = le.parse(e.type);
|
|
1722
1733
|
return {
|
|
1723
1734
|
id: e.id,
|
|
@@ -1725,15 +1736,15 @@ function jt(e) {
|
|
|
1725
1736
|
type: t,
|
|
1726
1737
|
client_id: e.client_id ?? void 0,
|
|
1727
1738
|
sub: e.sub ?? void 0,
|
|
1728
|
-
constraints:
|
|
1739
|
+
constraints: kt(e.constraints),
|
|
1729
1740
|
single_use: !!e.single_use,
|
|
1730
|
-
expires_at:
|
|
1731
|
-
used_at:
|
|
1732
|
-
revoked_at:
|
|
1741
|
+
expires_at: At(e.expires_at_ts),
|
|
1742
|
+
used_at: At(e.used_at_ts),
|
|
1743
|
+
revoked_at: At(e.revoked_at_ts),
|
|
1733
1744
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1734
1745
|
};
|
|
1735
1746
|
}
|
|
1736
|
-
function
|
|
1747
|
+
function Nt(e) {
|
|
1737
1748
|
return {
|
|
1738
1749
|
async create(t, n) {
|
|
1739
1750
|
let r = Date.now();
|
|
@@ -1746,7 +1757,7 @@ function Mt(e) {
|
|
|
1746
1757
|
sub: n.sub ?? null,
|
|
1747
1758
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1748
1759
|
single_use: +!!n.single_use,
|
|
1749
|
-
expires_at_ts:
|
|
1760
|
+
expires_at_ts: jt(n.expires_at),
|
|
1750
1761
|
created_at_ts: r
|
|
1751
1762
|
}), {
|
|
1752
1763
|
id: n.id,
|
|
@@ -1762,23 +1773,23 @@ function Mt(e) {
|
|
|
1762
1773
|
},
|
|
1763
1774
|
async get(n, r) {
|
|
1764
1775
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1765
|
-
return i ?
|
|
1776
|
+
return i ? Mt(i) : null;
|
|
1766
1777
|
},
|
|
1767
1778
|
async getByHash(n, r) {
|
|
1768
1779
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.token_hash, r))).get();
|
|
1769
|
-
return i ?
|
|
1780
|
+
return i ? Mt(i) : null;
|
|
1770
1781
|
},
|
|
1771
1782
|
async listByClient(n, r) {
|
|
1772
|
-
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(
|
|
1783
|
+
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(Mt);
|
|
1773
1784
|
},
|
|
1774
1785
|
async markUsed(n, r, i) {
|
|
1775
|
-
return (await e.update(R).set({ used_at_ts:
|
|
1786
|
+
return (await e.update(R).set({ used_at_ts: jt(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.used_at_ts))).returning()).length > 0;
|
|
1776
1787
|
},
|
|
1777
1788
|
async revoke(n, r, i) {
|
|
1778
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1789
|
+
return (await e.update(R).set({ revoked_at_ts: jt(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.revoked_at_ts))).returning()).length > 0;
|
|
1779
1790
|
},
|
|
1780
1791
|
async revokeByClient(n, r, i) {
|
|
1781
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1792
|
+
return (await e.update(R).set({ revoked_at_ts: jt(i) }).where(t(a(R.tenant_id, n), a(R.client_id, r), f(R.revoked_at_ts))).returning()).length;
|
|
1782
1793
|
},
|
|
1783
1794
|
async remove(n, r) {
|
|
1784
1795
|
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
@@ -1787,12 +1798,12 @@ function Mt(e) {
|
|
|
1787
1798
|
}
|
|
1788
1799
|
//#endregion
|
|
1789
1800
|
//#region src/adapters/codes.ts
|
|
1790
|
-
var
|
|
1791
|
-
function
|
|
1801
|
+
var Pt = ["code_id", "login_id"], Ft = 500;
|
|
1802
|
+
function It(e) {
|
|
1792
1803
|
let { tenant_id: t, ...n } = e;
|
|
1793
1804
|
return O(n);
|
|
1794
1805
|
}
|
|
1795
|
-
function
|
|
1806
|
+
function Lt(e) {
|
|
1796
1807
|
return {
|
|
1797
1808
|
async create(t, n) {
|
|
1798
1809
|
let r = {
|
|
@@ -1801,18 +1812,18 @@ function It(e) {
|
|
|
1801
1812
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1802
1813
|
expires_at: n.expires_at
|
|
1803
1814
|
};
|
|
1804
|
-
return await e.insert(I).values(r),
|
|
1815
|
+
return await e.insert(I).values(r), It(r);
|
|
1805
1816
|
},
|
|
1806
1817
|
async get(n, r, i) {
|
|
1807
1818
|
let o = n ? t(a(I.tenant_id, n), a(I.code_id, r), a(I.code_type, i)) : t(a(I.code_id, r), a(I.code_type, i)), s = await e.select().from(I).where(o).get();
|
|
1808
|
-
return s ?
|
|
1819
|
+
return s ? It(s) : null;
|
|
1809
1820
|
},
|
|
1810
1821
|
async list(o, s) {
|
|
1811
1822
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(I.tenant_id, o)];
|
|
1812
1823
|
if (f) {
|
|
1813
|
-
let e = _e(f,
|
|
1824
|
+
let e = _e(f, Pt);
|
|
1814
1825
|
if (e) {
|
|
1815
|
-
let t = nt(I, e,
|
|
1826
|
+
let t = nt(I, e, Pt);
|
|
1816
1827
|
t && p.push(t);
|
|
1817
1828
|
}
|
|
1818
1829
|
}
|
|
@@ -1821,7 +1832,7 @@ function It(e) {
|
|
|
1821
1832
|
let e = I[d.sort_by];
|
|
1822
1833
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1823
1834
|
}
|
|
1824
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1835
|
+
let g = (await h.offset(c * l).limit(l)).map(It);
|
|
1825
1836
|
if (!u) return { codes: g };
|
|
1826
1837
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1827
1838
|
return {
|
|
@@ -1843,8 +1854,8 @@ function It(e) {
|
|
|
1843
1854
|
async cleanup(t) {
|
|
1844
1855
|
let n = 0;
|
|
1845
1856
|
for (;;) {
|
|
1846
|
-
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${
|
|
1847
|
-
if (n += r.length, r.length <
|
|
1857
|
+
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${Ft})`).returning({ code_id: I.code_id });
|
|
1858
|
+
if (n += r.length, r.length < Ft) break;
|
|
1848
1859
|
}
|
|
1849
1860
|
return n;
|
|
1850
1861
|
}
|
|
@@ -1852,10 +1863,10 @@ function It(e) {
|
|
|
1852
1863
|
}
|
|
1853
1864
|
//#endregion
|
|
1854
1865
|
//#region src/adapters/connections.ts
|
|
1855
|
-
function
|
|
1866
|
+
function Rt() {
|
|
1856
1867
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1857
1868
|
}
|
|
1858
|
-
function
|
|
1869
|
+
function zt(e) {
|
|
1859
1870
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1860
1871
|
return O({
|
|
1861
1872
|
...a,
|
|
@@ -1864,11 +1875,11 @@ function Rt(e) {
|
|
|
1864
1875
|
is_system: n ? !0 : void 0
|
|
1865
1876
|
});
|
|
1866
1877
|
}
|
|
1867
|
-
function
|
|
1878
|
+
function Bt(e) {
|
|
1868
1879
|
return {
|
|
1869
1880
|
async create(t, n) {
|
|
1870
1881
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1871
|
-
id: n.id ||
|
|
1882
|
+
id: n.id || Rt(),
|
|
1872
1883
|
...n,
|
|
1873
1884
|
tenant_id: t,
|
|
1874
1885
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1882,11 +1893,11 @@ function zt(e) {
|
|
|
1882
1893
|
} catch (e) {
|
|
1883
1894
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Connection already exists" }) : e;
|
|
1884
1895
|
}
|
|
1885
|
-
return
|
|
1896
|
+
return zt(i);
|
|
1886
1897
|
},
|
|
1887
1898
|
async get(n, r) {
|
|
1888
1899
|
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
1889
|
-
return i ?
|
|
1900
|
+
return i ? zt(i) : null;
|
|
1890
1901
|
},
|
|
1891
1902
|
async update(n, r, i) {
|
|
1892
1903
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1903,7 +1914,7 @@ function zt(e) {
|
|
|
1903
1914
|
let e = V[d.sort_by];
|
|
1904
1915
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1905
1916
|
}
|
|
1906
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1917
|
+
let h = (await m.offset(c * l).limit(l)).map(zt);
|
|
1907
1918
|
if (!u) return { connections: h };
|
|
1908
1919
|
let [g] = await e.select({ count: r() }).from(V).where(p);
|
|
1909
1920
|
return {
|
|
@@ -1920,7 +1931,7 @@ function zt(e) {
|
|
|
1920
1931
|
}
|
|
1921
1932
|
//#endregion
|
|
1922
1933
|
//#region src/adapters/customDomains.ts
|
|
1923
|
-
function
|
|
1934
|
+
function Vt(e) {
|
|
1924
1935
|
let { tenant_id: t, domain_metadata: n, ...r } = e;
|
|
1925
1936
|
return O({
|
|
1926
1937
|
...r,
|
|
@@ -1928,7 +1939,7 @@ function Bt(e) {
|
|
|
1928
1939
|
domain_metadata: Q(n)
|
|
1929
1940
|
});
|
|
1930
1941
|
}
|
|
1931
|
-
function
|
|
1942
|
+
function Ht(e) {
|
|
1932
1943
|
return {
|
|
1933
1944
|
async create(t, n) {
|
|
1934
1945
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1946,40 +1957,40 @@ function Vt(e) {
|
|
|
1946
1957
|
created_at: r,
|
|
1947
1958
|
updated_at: r
|
|
1948
1959
|
};
|
|
1949
|
-
return await e.insert(
|
|
1960
|
+
return await e.insert(Me).values(i), Vt({
|
|
1950
1961
|
...i,
|
|
1951
1962
|
tenant_id: t
|
|
1952
1963
|
});
|
|
1953
1964
|
},
|
|
1954
1965
|
async get(n, r) {
|
|
1955
|
-
let i = await e.select().from(
|
|
1956
|
-
return i ?
|
|
1966
|
+
let i = await e.select().from(Me).where(t(a(Me.tenant_id, n), a(Me.custom_domain_id, r))).get();
|
|
1967
|
+
return i ? Vt(i) : null;
|
|
1957
1968
|
},
|
|
1958
1969
|
async getByDomain(t) {
|
|
1959
|
-
let n = await e.select().from(
|
|
1970
|
+
let n = await e.select().from(Me).where(a(Me.domain, t)).get();
|
|
1960
1971
|
return n ? {
|
|
1961
|
-
...
|
|
1972
|
+
...Vt(n),
|
|
1962
1973
|
tenant_id: n.tenant_id
|
|
1963
1974
|
} : null;
|
|
1964
1975
|
},
|
|
1965
1976
|
async list(t) {
|
|
1966
|
-
return (await e.select().from(
|
|
1977
|
+
return (await e.select().from(Me).where(a(Me.tenant_id, t)).all()).map(Vt);
|
|
1967
1978
|
},
|
|
1968
1979
|
async update(n, r, i) {
|
|
1969
1980
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1970
|
-
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 = 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(
|
|
1981
|
+
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 = 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(Me).set(o).where(t(a(Me.tenant_id, n), a(Me.custom_domain_id, r))).returning()).length > 0;
|
|
1971
1982
|
},
|
|
1972
1983
|
async remove(n, r) {
|
|
1973
|
-
return (await e.delete(
|
|
1984
|
+
return (await e.delete(Me).where(t(a(Me.tenant_id, n), a(Me.custom_domain_id, r))).returning()).length > 0;
|
|
1974
1985
|
}
|
|
1975
1986
|
};
|
|
1976
1987
|
}
|
|
1977
1988
|
//#endregion
|
|
1978
1989
|
//#region src/adapters/customText.ts
|
|
1979
|
-
function
|
|
1990
|
+
function Ut(e) {
|
|
1980
1991
|
return {
|
|
1981
1992
|
async get(n, r, i) {
|
|
1982
|
-
let o = await e.select().from(
|
|
1993
|
+
let o = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.prompt, r), a(Je.language, i))).get();
|
|
1983
1994
|
if (!o) return null;
|
|
1984
1995
|
try {
|
|
1985
1996
|
return JSON.parse(o.custom_text);
|
|
@@ -1989,7 +2000,7 @@ function Ht(e) {
|
|
|
1989
2000
|
},
|
|
1990
2001
|
async set(t, n, r, i) {
|
|
1991
2002
|
let a = Date.now(), o = JSON.stringify(i);
|
|
1992
|
-
await e.insert(
|
|
2003
|
+
await e.insert(Je).values({
|
|
1993
2004
|
tenant_id: t,
|
|
1994
2005
|
prompt: n,
|
|
1995
2006
|
language: r,
|
|
@@ -1998,9 +2009,9 @@ function Ht(e) {
|
|
|
1998
2009
|
updated_at_ts: a
|
|
1999
2010
|
}).onConflictDoUpdate({
|
|
2000
2011
|
target: [
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2012
|
+
Je.tenant_id,
|
|
2013
|
+
Je.prompt,
|
|
2014
|
+
Je.language
|
|
2004
2015
|
],
|
|
2005
2016
|
set: {
|
|
2006
2017
|
custom_text: o,
|
|
@@ -2009,23 +2020,23 @@ function Ht(e) {
|
|
|
2009
2020
|
});
|
|
2010
2021
|
},
|
|
2011
2022
|
async delete(n, r, i) {
|
|
2012
|
-
await e.delete(
|
|
2023
|
+
await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.prompt, r), a(Je.language, i)));
|
|
2013
2024
|
},
|
|
2014
2025
|
async list(t) {
|
|
2015
2026
|
return await e.select({
|
|
2016
|
-
prompt:
|
|
2017
|
-
language:
|
|
2018
|
-
}).from(
|
|
2027
|
+
prompt: Je.prompt,
|
|
2028
|
+
language: Je.language
|
|
2029
|
+
}).from(Je).where(a(Je.tenant_id, t)).all();
|
|
2019
2030
|
}
|
|
2020
2031
|
};
|
|
2021
2032
|
}
|
|
2022
2033
|
//#endregion
|
|
2023
2034
|
//#region src/adapters/emailProviders.ts
|
|
2024
|
-
function
|
|
2035
|
+
function Wt(e) {
|
|
2025
2036
|
return {
|
|
2026
2037
|
async create(t, n) {
|
|
2027
2038
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2028
|
-
await e.insert(
|
|
2039
|
+
await e.insert(Ue).values({
|
|
2029
2040
|
tenant_id: t,
|
|
2030
2041
|
name: n.name,
|
|
2031
2042
|
enabled: n.enabled,
|
|
@@ -2037,7 +2048,7 @@ function Ut(e) {
|
|
|
2037
2048
|
});
|
|
2038
2049
|
},
|
|
2039
2050
|
async get(t) {
|
|
2040
|
-
let n = await e.select().from(
|
|
2051
|
+
let n = await e.select().from(Ue).where(a(Ue.tenant_id, t)).get();
|
|
2041
2052
|
if (!n) return null;
|
|
2042
2053
|
let { tenant_id: r, ...i } = n;
|
|
2043
2054
|
return O({
|
|
@@ -2049,16 +2060,16 @@ function Ut(e) {
|
|
|
2049
2060
|
},
|
|
2050
2061
|
async update(t, n) {
|
|
2051
2062
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2052
|
-
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(
|
|
2063
|
+
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(Ue).set(r).where(a(Ue.tenant_id, t));
|
|
2053
2064
|
},
|
|
2054
2065
|
async remove(t) {
|
|
2055
|
-
await e.delete(
|
|
2066
|
+
await e.delete(Ue).where(a(Ue.tenant_id, t));
|
|
2056
2067
|
}
|
|
2057
2068
|
};
|
|
2058
2069
|
}
|
|
2059
2070
|
//#endregion
|
|
2060
2071
|
//#region src/adapters/emailTemplates.ts
|
|
2061
|
-
function
|
|
2072
|
+
function Gt(e) {
|
|
2062
2073
|
return O({
|
|
2063
2074
|
template: e.template,
|
|
2064
2075
|
body: e.body,
|
|
@@ -2071,18 +2082,18 @@ function Wt(e) {
|
|
|
2071
2082
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2072
2083
|
});
|
|
2073
2084
|
}
|
|
2074
|
-
function
|
|
2085
|
+
function Kt(e) {
|
|
2075
2086
|
return {
|
|
2076
2087
|
async get(n, r) {
|
|
2077
|
-
let i = await e.select().from(
|
|
2078
|
-
return i ?
|
|
2088
|
+
let i = await e.select().from(We).where(t(a(We.tenant_id, n), a(We.template, r))).get();
|
|
2089
|
+
return i ? Gt(i) : null;
|
|
2079
2090
|
},
|
|
2080
2091
|
async list(t) {
|
|
2081
|
-
return (await e.select().from(
|
|
2092
|
+
return (await e.select().from(We).where(a(We.tenant_id, t)).all()).map(Gt);
|
|
2082
2093
|
},
|
|
2083
2094
|
async create(t, n) {
|
|
2084
2095
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2085
|
-
return await e.insert(
|
|
2096
|
+
return await e.insert(We).values({
|
|
2086
2097
|
tenant_id: t,
|
|
2087
2098
|
template: n.template,
|
|
2088
2099
|
body: n.body,
|
|
@@ -2100,23 +2111,23 @@ function Gt(e) {
|
|
|
2100
2111
|
async update(n, r, i) {
|
|
2101
2112
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2102
2113
|
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);
|
|
2103
|
-
let s = await e.update(
|
|
2114
|
+
let s = await e.update(We).set(o).where(t(a(We.tenant_id, n), a(We.template, r))).run();
|
|
2104
2115
|
return Number(s.changes ?? 0) > 0;
|
|
2105
2116
|
},
|
|
2106
2117
|
async remove(n, r) {
|
|
2107
|
-
let i = await e.delete(
|
|
2118
|
+
let i = await e.delete(We).where(t(a(We.tenant_id, n), a(We.template, r))).run();
|
|
2108
2119
|
return Number(i.changes ?? 0) > 0;
|
|
2109
2120
|
}
|
|
2110
2121
|
};
|
|
2111
2122
|
}
|
|
2112
2123
|
//#endregion
|
|
2113
2124
|
//#region src/adapters/flows.ts
|
|
2114
|
-
var
|
|
2115
|
-
function
|
|
2125
|
+
var qt = ["id", "name"];
|
|
2126
|
+
function Jt(e) {
|
|
2116
2127
|
return {
|
|
2117
2128
|
async create(t, n) {
|
|
2118
2129
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2119
|
-
return await e.insert(
|
|
2130
|
+
return await e.insert(Ve).values({
|
|
2120
2131
|
id: i,
|
|
2121
2132
|
tenant_id: t,
|
|
2122
2133
|
name: n.name,
|
|
@@ -2132,7 +2143,7 @@ function qt(e) {
|
|
|
2132
2143
|
};
|
|
2133
2144
|
},
|
|
2134
2145
|
async get(n, r) {
|
|
2135
|
-
let i = await e.select().from(
|
|
2146
|
+
let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
|
|
2136
2147
|
if (!i) return null;
|
|
2137
2148
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2138
2149
|
return O({
|
|
@@ -2142,20 +2153,20 @@ function qt(e) {
|
|
|
2142
2153
|
},
|
|
2143
2154
|
async update(n, r, i) {
|
|
2144
2155
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2145
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2156
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(Ve).set(o).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2146
2157
|
},
|
|
2147
2158
|
async list(o, s) {
|
|
2148
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2159
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Ve.tenant_id, o)];
|
|
2149
2160
|
if (f) {
|
|
2150
|
-
let e = _e(f,
|
|
2161
|
+
let e = _e(f, qt);
|
|
2151
2162
|
if (e) {
|
|
2152
|
-
let t = nt(
|
|
2163
|
+
let t = nt(Ve, e, []);
|
|
2153
2164
|
t && p.push(t);
|
|
2154
2165
|
}
|
|
2155
2166
|
}
|
|
2156
|
-
let m = t(...p), h = e.select().from(
|
|
2167
|
+
let m = t(...p), h = e.select().from(Ve).where(m).$dynamic();
|
|
2157
2168
|
if (d?.sort_by) {
|
|
2158
|
-
let e =
|
|
2169
|
+
let e = Ve[d.sort_by];
|
|
2159
2170
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2160
2171
|
}
|
|
2161
2172
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2166,7 +2177,7 @@ function qt(e) {
|
|
|
2166
2177
|
});
|
|
2167
2178
|
});
|
|
2168
2179
|
if (!u) return { flows: g };
|
|
2169
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2180
|
+
let [_] = await e.select({ count: r() }).from(Ve).where(m);
|
|
2170
2181
|
return {
|
|
2171
2182
|
flows: g,
|
|
2172
2183
|
start: c * l,
|
|
@@ -2175,18 +2186,18 @@ function qt(e) {
|
|
|
2175
2186
|
};
|
|
2176
2187
|
},
|
|
2177
2188
|
async remove(n, r) {
|
|
2178
|
-
return (await e.delete(
|
|
2189
|
+
return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
|
|
2179
2190
|
}
|
|
2180
2191
|
};
|
|
2181
2192
|
}
|
|
2182
2193
|
//#endregion
|
|
2183
2194
|
//#region src/adapters/forms.ts
|
|
2184
|
-
var
|
|
2195
|
+
var Yt = [
|
|
2185
2196
|
"nodes",
|
|
2186
2197
|
"start",
|
|
2187
2198
|
"ending"
|
|
2188
|
-
],
|
|
2189
|
-
function
|
|
2199
|
+
], Xt = ["name"];
|
|
2200
|
+
function Zt(e) {
|
|
2190
2201
|
return {
|
|
2191
2202
|
async create(t, n) {
|
|
2192
2203
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2200,8 +2211,8 @@ function Xt(e) {
|
|
|
2200
2211
|
created_at: r,
|
|
2201
2212
|
updated_at: r
|
|
2202
2213
|
};
|
|
2203
|
-
for (let e of
|
|
2204
|
-
return await e.insert(
|
|
2214
|
+
for (let e of Yt) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2215
|
+
return await e.insert(Be).values(a), {
|
|
2205
2216
|
id: i,
|
|
2206
2217
|
...n,
|
|
2207
2218
|
created_at: r,
|
|
@@ -2209,38 +2220,38 @@ function Xt(e) {
|
|
|
2209
2220
|
};
|
|
2210
2221
|
},
|
|
2211
2222
|
async get(n, r) {
|
|
2212
|
-
let i = await e.select().from(
|
|
2223
|
+
let i = await e.select().from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get();
|
|
2213
2224
|
if (!i) return null;
|
|
2214
2225
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2215
|
-
for (let e of
|
|
2226
|
+
for (let e of Yt) c[e] = Q(s[e]);
|
|
2216
2227
|
return O(c);
|
|
2217
2228
|
},
|
|
2218
2229
|
async update(n, r, i) {
|
|
2219
2230
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2220
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2221
|
-
return (await e.update(
|
|
2231
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (Yt.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2232
|
+
return (await e.update(Be).set(o).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
|
|
2222
2233
|
},
|
|
2223
2234
|
async list(o, s) {
|
|
2224
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2235
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Be.tenant_id, o)];
|
|
2225
2236
|
if (f) {
|
|
2226
|
-
let e = _e(f,
|
|
2237
|
+
let e = _e(f, Xt);
|
|
2227
2238
|
if (e) {
|
|
2228
|
-
let t = nt(
|
|
2239
|
+
let t = nt(Be, e, Xt);
|
|
2229
2240
|
t && p.push(t);
|
|
2230
2241
|
}
|
|
2231
2242
|
}
|
|
2232
|
-
let m = t(...p), h = e.select().from(
|
|
2243
|
+
let m = t(...p), h = e.select().from(Be).where(m).$dynamic();
|
|
2233
2244
|
if (d?.sort_by) {
|
|
2234
|
-
let e =
|
|
2245
|
+
let e = Be[d.sort_by];
|
|
2235
2246
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2236
2247
|
}
|
|
2237
2248
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2238
2249
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2239
|
-
for (let e of
|
|
2250
|
+
for (let e of Yt) r[e] = Q(n[e]);
|
|
2240
2251
|
return O(r);
|
|
2241
2252
|
});
|
|
2242
2253
|
if (!u) return { forms: g };
|
|
2243
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2254
|
+
let [_] = await e.select({ count: r() }).from(Be).where(m);
|
|
2244
2255
|
return {
|
|
2245
2256
|
forms: g,
|
|
2246
2257
|
start: c * l,
|
|
@@ -2249,13 +2260,13 @@ function Xt(e) {
|
|
|
2249
2260
|
};
|
|
2250
2261
|
},
|
|
2251
2262
|
async remove(n, r) {
|
|
2252
|
-
return (await e.delete(
|
|
2263
|
+
return (await e.delete(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
|
|
2253
2264
|
}
|
|
2254
2265
|
};
|
|
2255
2266
|
}
|
|
2256
2267
|
//#endregion
|
|
2257
2268
|
//#region src/adapters/grants.ts
|
|
2258
|
-
function
|
|
2269
|
+
function Qt(e) {
|
|
2259
2270
|
return {
|
|
2260
2271
|
id: e.id,
|
|
2261
2272
|
user_id: e.user_id,
|
|
@@ -2264,17 +2275,17 @@ function Zt(e) {
|
|
|
2264
2275
|
scope: Q(e.scope, []) ?? []
|
|
2265
2276
|
};
|
|
2266
2277
|
}
|
|
2267
|
-
var
|
|
2278
|
+
var $t = {
|
|
2268
2279
|
user_id: B.user_id,
|
|
2269
2280
|
client_id: B.client_id,
|
|
2270
2281
|
audience: B.audience,
|
|
2271
2282
|
created_at: B.created_at,
|
|
2272
2283
|
updated_at: B.updated_at
|
|
2273
2284
|
};
|
|
2274
|
-
function $t(e) {
|
|
2275
|
-
return Object.hasOwn(Qt, e) ? Qt[e] : void 0;
|
|
2276
|
-
}
|
|
2277
2285
|
function en(e) {
|
|
2286
|
+
return Object.hasOwn($t, e) ? $t[e] : void 0;
|
|
2287
|
+
}
|
|
2288
|
+
function tn(e) {
|
|
2278
2289
|
return {
|
|
2279
2290
|
async create(n, r) {
|
|
2280
2291
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r.user_id), a(B.client_id, r.clientID), a(B.audience, s))).get();
|
|
@@ -2283,7 +2294,7 @@ function en(e) {
|
|
|
2283
2294
|
return await e.update(B).set({
|
|
2284
2295
|
scope: JSON.stringify(s),
|
|
2285
2296
|
updated_at: i
|
|
2286
|
-
}).where(t(a(B.tenant_id, n), a(B.id, c.id))),
|
|
2297
|
+
}).where(t(a(B.tenant_id, n), a(B.id, c.id))), Qt({
|
|
2287
2298
|
...c,
|
|
2288
2299
|
scope: JSON.stringify(s)
|
|
2289
2300
|
});
|
|
@@ -2308,16 +2319,16 @@ function en(e) {
|
|
|
2308
2319
|
},
|
|
2309
2320
|
async get(n, r, i, o) {
|
|
2310
2321
|
let s = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r), a(B.client_id, i), a(B.audience, o ?? ""))).get();
|
|
2311
|
-
return s ?
|
|
2322
|
+
return s ? Qt(s) : null;
|
|
2312
2323
|
},
|
|
2313
2324
|
async list(o, s) {
|
|
2314
2325
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(B, f, [
|
|
2315
2326
|
"user_id",
|
|
2316
2327
|
"client_id",
|
|
2317
2328
|
"audience"
|
|
2318
|
-
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ?
|
|
2329
|
+
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ? en(d.sort_by) : void 0;
|
|
2319
2330
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(B.created_at));
|
|
2320
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2331
|
+
let _ = (await h.offset(c * l).limit(l)).map(Qt);
|
|
2321
2332
|
if (!u) return {
|
|
2322
2333
|
grants: _,
|
|
2323
2334
|
start: 0,
|
|
@@ -2342,11 +2353,11 @@ function en(e) {
|
|
|
2342
2353
|
}
|
|
2343
2354
|
//#endregion
|
|
2344
2355
|
//#region src/adapters/hookCode.ts
|
|
2345
|
-
var
|
|
2346
|
-
function
|
|
2347
|
-
return `hc_${
|
|
2356
|
+
var nn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2357
|
+
function rn() {
|
|
2358
|
+
return `hc_${nn()}`;
|
|
2348
2359
|
}
|
|
2349
|
-
function
|
|
2360
|
+
function an(e) {
|
|
2350
2361
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ie({
|
|
2351
2362
|
created_at_ts: t,
|
|
2352
2363
|
updated_at_ts: n
|
|
@@ -2357,41 +2368,41 @@ function rn(e) {
|
|
|
2357
2368
|
secrets: r ? JSON.parse(r) : void 0
|
|
2358
2369
|
};
|
|
2359
2370
|
}
|
|
2360
|
-
function
|
|
2371
|
+
function on(e) {
|
|
2361
2372
|
return {
|
|
2362
2373
|
async create(t, n) {
|
|
2363
2374
|
let r = Date.now(), i = {
|
|
2364
|
-
id:
|
|
2375
|
+
id: rn(),
|
|
2365
2376
|
tenant_id: t,
|
|
2366
2377
|
code: n.code,
|
|
2367
2378
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2368
2379
|
created_at_ts: r,
|
|
2369
2380
|
updated_at_ts: r
|
|
2370
2381
|
};
|
|
2371
|
-
return await e.insert(
|
|
2382
|
+
return await e.insert(Ke).values(i), an({
|
|
2372
2383
|
...i,
|
|
2373
2384
|
tenant_id: t
|
|
2374
2385
|
});
|
|
2375
2386
|
},
|
|
2376
2387
|
async get(n, r) {
|
|
2377
|
-
let i = await e.select().from(
|
|
2378
|
-
return i ?
|
|
2388
|
+
let i = await e.select().from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).get();
|
|
2389
|
+
return i ? an(i) : null;
|
|
2379
2390
|
},
|
|
2380
2391
|
async update(n, r, i) {
|
|
2381
2392
|
let o = { updated_at_ts: Date.now() };
|
|
2382
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2393
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(Ke).set(o).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).returning()).length > 0;
|
|
2383
2394
|
},
|
|
2384
2395
|
async remove(n, r) {
|
|
2385
|
-
return (await e.delete(
|
|
2396
|
+
return (await e.delete(Ke).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).returning()).length > 0;
|
|
2386
2397
|
}
|
|
2387
2398
|
};
|
|
2388
2399
|
}
|
|
2389
2400
|
//#endregion
|
|
2390
2401
|
//#region src/adapters/hooks.ts
|
|
2391
|
-
function
|
|
2402
|
+
function sn() {
|
|
2392
2403
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2393
2404
|
}
|
|
2394
|
-
function
|
|
2405
|
+
function cn(e) {
|
|
2395
2406
|
if (!(typeof e != "string" || !e)) try {
|
|
2396
2407
|
let t = JSON.parse(e);
|
|
2397
2408
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2399,7 +2410,7 @@ function sn(e) {
|
|
|
2399
2410
|
return;
|
|
2400
2411
|
}
|
|
2401
2412
|
}
|
|
2402
|
-
function
|
|
2413
|
+
function ln(e) {
|
|
2403
2414
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ie({
|
|
2404
2415
|
created_at_ts: n,
|
|
2405
2416
|
updated_at_ts: r
|
|
@@ -2408,15 +2419,15 @@ function cn(e) {
|
|
|
2408
2419
|
...a,
|
|
2409
2420
|
enabled: !!a.enabled,
|
|
2410
2421
|
synchronous: !!a.synchronous,
|
|
2411
|
-
metadata:
|
|
2422
|
+
metadata: cn(i),
|
|
2412
2423
|
...o
|
|
2413
2424
|
});
|
|
2414
2425
|
}
|
|
2415
|
-
function
|
|
2426
|
+
function un(e) {
|
|
2416
2427
|
return {
|
|
2417
2428
|
async create(t, n) {
|
|
2418
2429
|
let r = Date.now(), i = {
|
|
2419
|
-
hook_id: n.hook_id ||
|
|
2430
|
+
hook_id: n.hook_id || sn(),
|
|
2420
2431
|
tenant_id: t,
|
|
2421
2432
|
trigger_id: n.trigger_id,
|
|
2422
2433
|
url: n.url,
|
|
@@ -2430,30 +2441,30 @@ function ln(e) {
|
|
|
2430
2441
|
created_at_ts: r,
|
|
2431
2442
|
updated_at_ts: r
|
|
2432
2443
|
};
|
|
2433
|
-
return await e.insert(
|
|
2444
|
+
return await e.insert(Ge).values(i), ln({
|
|
2434
2445
|
...i,
|
|
2435
2446
|
tenant_id: t
|
|
2436
2447
|
});
|
|
2437
2448
|
},
|
|
2438
2449
|
async get(n, r) {
|
|
2439
|
-
let i = await e.select().from(
|
|
2440
|
-
return i ?
|
|
2450
|
+
let i = await e.select().from(Ge).where(t(a(Ge.tenant_id, n), a(Ge.hook_id, r))).get();
|
|
2451
|
+
return i ? ln(i) : null;
|
|
2441
2452
|
},
|
|
2442
2453
|
async update(n, r, i) {
|
|
2443
2454
|
let o = { updated_at_ts: Date.now() };
|
|
2444
|
-
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.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(
|
|
2455
|
+
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.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(Ge).set(o).where(t(a(Ge.tenant_id, n), a(Ge.hook_id, r))).returning()).length > 0;
|
|
2445
2456
|
},
|
|
2446
2457
|
async list(o, s) {
|
|
2447
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(
|
|
2458
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(Ge, f, [
|
|
2448
2459
|
"url",
|
|
2449
2460
|
"form_id",
|
|
2450
2461
|
"template_id",
|
|
2451
2462
|
"code_id"
|
|
2452
|
-
]) : void 0, m = p ? t(a(
|
|
2453
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2454
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2463
|
+
]) : void 0, m = p ? t(a(Ge.tenant_id, o), p) : a(Ge.tenant_id, o), h = e.select().from(Ge).where(m).$dynamic(), g = d?.sort_by ? Ge[d.sort_by] : void 0;
|
|
2464
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(Ge.priority), n(Ge.created_at_ts));
|
|
2465
|
+
let _ = (await h.offset(c * l).limit(l)).map(ln);
|
|
2455
2466
|
if (!u) return { hooks: _ };
|
|
2456
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2467
|
+
let [v] = await e.select({ count: r() }).from(Ge).where(m);
|
|
2457
2468
|
return {
|
|
2458
2469
|
hooks: _,
|
|
2459
2470
|
start: c * l,
|
|
@@ -2462,31 +2473,31 @@ function ln(e) {
|
|
|
2462
2473
|
};
|
|
2463
2474
|
},
|
|
2464
2475
|
async remove(n, r) {
|
|
2465
|
-
return (await e.delete(
|
|
2476
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.hook_id, r))).returning()).length > 0;
|
|
2466
2477
|
}
|
|
2467
2478
|
};
|
|
2468
2479
|
}
|
|
2469
2480
|
//#endregion
|
|
2470
2481
|
//#region src/adapters/invites.ts
|
|
2471
|
-
function
|
|
2482
|
+
function dn() {
|
|
2472
2483
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2473
2484
|
}
|
|
2474
|
-
var
|
|
2485
|
+
var fn = [
|
|
2475
2486
|
"inviter",
|
|
2476
2487
|
"invitee",
|
|
2477
2488
|
"app_metadata",
|
|
2478
2489
|
"user_metadata",
|
|
2479
2490
|
"roles"
|
|
2480
2491
|
];
|
|
2481
|
-
function
|
|
2492
|
+
function pn(e) {
|
|
2482
2493
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2483
|
-
for (let e of
|
|
2494
|
+
for (let e of fn) i[e] = Q(r[e], e === "roles" ? [] : {});
|
|
2484
2495
|
return i.send_invitation_email = !!n, O(i);
|
|
2485
2496
|
}
|
|
2486
|
-
function
|
|
2497
|
+
function mn(e) {
|
|
2487
2498
|
return {
|
|
2488
2499
|
async create(t, n) {
|
|
2489
|
-
let r = n.id ||
|
|
2500
|
+
let r = n.id || dn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2490
2501
|
id: r,
|
|
2491
2502
|
tenant_id: t,
|
|
2492
2503
|
organization_id: n.organization_id,
|
|
@@ -2499,35 +2510,35 @@ function pn(e) {
|
|
|
2499
2510
|
created_at: a.toISOString(),
|
|
2500
2511
|
expires_at: o
|
|
2501
2512
|
};
|
|
2502
|
-
for (let e of
|
|
2513
|
+
for (let e of fn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2503
2514
|
try {
|
|
2504
|
-
await e.insert(
|
|
2515
|
+
await e.insert(Pe).values(s);
|
|
2505
2516
|
} catch (e) {
|
|
2506
2517
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Invite already exists" }) : e;
|
|
2507
2518
|
}
|
|
2508
|
-
return
|
|
2519
|
+
return pn({
|
|
2509
2520
|
...s,
|
|
2510
2521
|
tenant_id: t
|
|
2511
2522
|
});
|
|
2512
2523
|
},
|
|
2513
2524
|
async get(n, r) {
|
|
2514
|
-
let i = await e.select().from(
|
|
2515
|
-
return i ?
|
|
2525
|
+
let i = await e.select().from(Pe).where(t(a(Pe.tenant_id, n), a(Pe.id, r))).get();
|
|
2526
|
+
return i ? pn(i) : null;
|
|
2516
2527
|
},
|
|
2517
2528
|
async update(n, r, i) {
|
|
2518
2529
|
let o = {};
|
|
2519
|
-
for (let e of
|
|
2520
|
-
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(
|
|
2530
|
+
for (let e of fn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2531
|
+
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(Pe).set(o).where(t(a(Pe.tenant_id, n), a(Pe.id, r))).returning()).length > 0;
|
|
2521
2532
|
},
|
|
2522
2533
|
async list(t, o) {
|
|
2523
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2534
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Pe).where(a(Pe.tenant_id, t)).$dynamic();
|
|
2524
2535
|
if (u?.sort_by) {
|
|
2525
|
-
let e =
|
|
2536
|
+
let e = Pe[u.sort_by];
|
|
2526
2537
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2527
2538
|
}
|
|
2528
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2539
|
+
let f = (await d.offset(s * c).limit(c)).map(pn);
|
|
2529
2540
|
if (!l) return { invites: f };
|
|
2530
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2541
|
+
let [p] = await e.select({ count: r() }).from(Pe).where(a(Pe.tenant_id, t));
|
|
2531
2542
|
return {
|
|
2532
2543
|
invites: f,
|
|
2533
2544
|
start: s * c,
|
|
@@ -2536,39 +2547,39 @@ function pn(e) {
|
|
|
2536
2547
|
};
|
|
2537
2548
|
},
|
|
2538
2549
|
async remove(n, r) {
|
|
2539
|
-
return (await e.delete(
|
|
2550
|
+
return (await e.delete(Pe).where(t(a(Pe.tenant_id, n), a(Pe.id, r))).returning()).length > 0;
|
|
2540
2551
|
}
|
|
2541
2552
|
};
|
|
2542
2553
|
}
|
|
2543
2554
|
//#endregion
|
|
2544
2555
|
//#region src/adapters/keys.ts
|
|
2545
|
-
var
|
|
2556
|
+
var hn = [
|
|
2546
2557
|
"kid",
|
|
2547
2558
|
"connection",
|
|
2548
2559
|
"fingerprint",
|
|
2549
2560
|
"thumbprint",
|
|
2550
2561
|
"type"
|
|
2551
2562
|
];
|
|
2552
|
-
function
|
|
2563
|
+
function gn(e) {
|
|
2553
2564
|
return {
|
|
2554
2565
|
async create(t) {
|
|
2555
|
-
await e.insert(
|
|
2566
|
+
await e.insert(qe).values({
|
|
2556
2567
|
...t,
|
|
2557
2568
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2558
2569
|
});
|
|
2559
2570
|
},
|
|
2560
2571
|
async list(a) {
|
|
2561
|
-
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(
|
|
2572
|
+
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(qe.revoked_at, p), f(qe.revoked_at))];
|
|
2562
2573
|
if (d) {
|
|
2563
|
-
let e = _e(d,
|
|
2574
|
+
let e = _e(d, hn);
|
|
2564
2575
|
if (e) {
|
|
2565
|
-
let t = nt(
|
|
2576
|
+
let t = nt(qe, e, hn);
|
|
2566
2577
|
t && m.push(t);
|
|
2567
2578
|
}
|
|
2568
2579
|
}
|
|
2569
|
-
let h = t(...m), g = e.select().from(
|
|
2580
|
+
let h = t(...m), g = e.select().from(qe).where(h).$dynamic();
|
|
2570
2581
|
if (u?.sort_by) {
|
|
2571
|
-
let e =
|
|
2582
|
+
let e = qe[u.sort_by];
|
|
2572
2583
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2573
2584
|
}
|
|
2574
2585
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2576,7 +2587,7 @@ function hn(e) {
|
|
|
2576
2587
|
return O(n);
|
|
2577
2588
|
});
|
|
2578
2589
|
if (!l) return { signingKeys: _ };
|
|
2579
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2590
|
+
let [y] = await e.select({ count: r() }).from(qe).where(h);
|
|
2580
2591
|
return {
|
|
2581
2592
|
signingKeys: _,
|
|
2582
2593
|
start: o * c,
|
|
@@ -2585,22 +2596,22 @@ function hn(e) {
|
|
|
2585
2596
|
};
|
|
2586
2597
|
},
|
|
2587
2598
|
async update(t, n) {
|
|
2588
|
-
return (await e.update(
|
|
2599
|
+
return (await e.update(qe).set(n).where(a(qe.kid, t)).returning()).length > 0;
|
|
2589
2600
|
}
|
|
2590
2601
|
};
|
|
2591
2602
|
}
|
|
2592
2603
|
//#endregion
|
|
2593
2604
|
//#region src/adapters/loginSessions.ts
|
|
2594
|
-
var
|
|
2595
|
-
function
|
|
2605
|
+
var _n = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", vn = 32;
|
|
2606
|
+
function yn() {
|
|
2596
2607
|
let e = Date.now(), t = "";
|
|
2597
|
-
for (let n = 10; n > 0; n--) t =
|
|
2608
|
+
for (let n = 10; n > 0; n--) t = _n.charAt(e % vn) + t, e = Math.floor(e / vn);
|
|
2598
2609
|
let n = new Uint8Array(16);
|
|
2599
2610
|
crypto.getRandomValues(n);
|
|
2600
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2611
|
+
for (let e = 0; e < 16; e++) t += _n.charAt(n[e] % vn);
|
|
2601
2612
|
return t;
|
|
2602
2613
|
}
|
|
2603
|
-
function
|
|
2614
|
+
function bn(e) {
|
|
2604
2615
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, state_data: a, auth_params: o, ...s } = e, c = ie({
|
|
2605
2616
|
created_at_ts: n,
|
|
2606
2617
|
updated_at_ts: r,
|
|
@@ -2618,11 +2629,11 @@ function yn(e) {
|
|
|
2618
2629
|
state_data: Q(a)
|
|
2619
2630
|
});
|
|
2620
2631
|
}
|
|
2621
|
-
function
|
|
2632
|
+
function xn(e) {
|
|
2622
2633
|
return {
|
|
2623
2634
|
async create(t, n) {
|
|
2624
2635
|
let r = Date.now(), i = {
|
|
2625
|
-
id:
|
|
2636
|
+
id: yn(),
|
|
2626
2637
|
tenant_id: t,
|
|
2627
2638
|
session_id: n.session_id,
|
|
2628
2639
|
csrf_token: n.csrf_token,
|
|
@@ -2643,14 +2654,14 @@ function bn(e) {
|
|
|
2643
2654
|
updated_at_ts: r,
|
|
2644
2655
|
expires_at_ts: n.expires_at ? D(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2645
2656
|
};
|
|
2646
|
-
return await e.insert(F).values(i),
|
|
2657
|
+
return await e.insert(F).values(i), bn({
|
|
2647
2658
|
...i,
|
|
2648
2659
|
tenant_id: t
|
|
2649
2660
|
});
|
|
2650
2661
|
},
|
|
2651
2662
|
async get(n, r) {
|
|
2652
2663
|
let i = n ? t(a(F.tenant_id, n), a(F.id, r)) : a(F.id, r), o = await e.select().from(F).where(i).get();
|
|
2653
|
-
return o ?
|
|
2664
|
+
return o ? bn(o) : null;
|
|
2654
2665
|
},
|
|
2655
2666
|
async update(n, r, i) {
|
|
2656
2667
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2670,7 +2681,7 @@ function bn(e) {
|
|
|
2670
2681
|
}
|
|
2671
2682
|
//#endregion
|
|
2672
2683
|
//#region src/adapters/logs.ts
|
|
2673
|
-
function
|
|
2684
|
+
function Sn(e) {
|
|
2674
2685
|
let { tenant_id: t, isMobile: n, auth0_client: r, details: i, country_code: a, city_name: o, latitude: s, longitude: c, time_zone: l, continent_code: u, scope: d, ...f } = e, p = {
|
|
2675
2686
|
...f,
|
|
2676
2687
|
isMobile: !!n,
|
|
@@ -2687,7 +2698,7 @@ function xn(e) {
|
|
|
2687
2698
|
continent_code: u
|
|
2688
2699
|
})), O(p);
|
|
2689
2700
|
}
|
|
2690
|
-
function
|
|
2701
|
+
function Cn(e) {
|
|
2691
2702
|
return {
|
|
2692
2703
|
async create(t, n) {
|
|
2693
2704
|
let r = {
|
|
@@ -2713,7 +2724,7 @@ function Sn(e) {
|
|
|
2713
2724
|
hostname: n.hostname,
|
|
2714
2725
|
session_connection: n.session_connection
|
|
2715
2726
|
};
|
|
2716
|
-
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(J).values(r),
|
|
2727
|
+
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(J).values(r), Sn({
|
|
2717
2728
|
...r,
|
|
2718
2729
|
tenant_id: t
|
|
2719
2730
|
});
|
|
@@ -2731,14 +2742,14 @@ function Sn(e) {
|
|
|
2731
2742
|
}
|
|
2732
2743
|
typeof h == "number" && Number.isFinite(h) && _.push(c(J.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(J.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2733
2744
|
let v = t(..._);
|
|
2734
|
-
if (
|
|
2745
|
+
if (mt(s)) {
|
|
2735
2746
|
if (f?.sort_by && f.sort_by !== "date") throw new Ce(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2736
2747
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2737
2748
|
sortColumn: J.date,
|
|
2738
2749
|
idColumn: J.log_id,
|
|
2739
2750
|
sortOrder: n,
|
|
2740
2751
|
sortKey: `date:${n}`
|
|
2741
|
-
}, i =
|
|
2752
|
+
}, i = _t(s, r), a = ht(s), { rows: o, next: c } = vt(await e.select().from(J).where(i ? t(v, i) : v).orderBy(...gt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Sn);
|
|
2742
2753
|
return {
|
|
2743
2754
|
logs: l,
|
|
2744
2755
|
start: 0,
|
|
@@ -2752,7 +2763,7 @@ function Sn(e) {
|
|
|
2752
2763
|
let e = J[f.sort_by];
|
|
2753
2764
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2754
2765
|
} else y = y.orderBy(i(J.date));
|
|
2755
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2766
|
+
let ee = (await y.offset(l * u).limit(u)).map(Sn);
|
|
2756
2767
|
if (!d) return { logs: ee };
|
|
2757
2768
|
let [b] = await e.select({ count: r() }).from(J).where(v);
|
|
2758
2769
|
return {
|
|
@@ -2764,22 +2775,22 @@ function Sn(e) {
|
|
|
2764
2775
|
},
|
|
2765
2776
|
async get(n, r) {
|
|
2766
2777
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.log_id, r))).get();
|
|
2767
|
-
return i ?
|
|
2778
|
+
return i ? Sn(i) : null;
|
|
2768
2779
|
}
|
|
2769
2780
|
};
|
|
2770
2781
|
}
|
|
2771
2782
|
//#endregion
|
|
2772
2783
|
//#region src/adapters/authenticationMethods.ts
|
|
2773
|
-
var
|
|
2774
|
-
function
|
|
2784
|
+
var wn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Tn = 32;
|
|
2785
|
+
function En() {
|
|
2775
2786
|
let e = Date.now(), t = "";
|
|
2776
|
-
for (let n = 10; n > 0; n--) t =
|
|
2787
|
+
for (let n = 10; n > 0; n--) t = wn.charAt(e % Tn) + t, e = Math.floor(e / Tn);
|
|
2777
2788
|
let n = new Uint8Array(16);
|
|
2778
2789
|
crypto.getRandomValues(n);
|
|
2779
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2790
|
+
for (let e = 0; e < 16; e++) t += wn.charAt(n[e] % Tn);
|
|
2780
2791
|
return t;
|
|
2781
2792
|
}
|
|
2782
|
-
function
|
|
2793
|
+
function Dn(e) {
|
|
2783
2794
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2784
2795
|
return O({
|
|
2785
2796
|
...s,
|
|
@@ -2790,11 +2801,11 @@ function En(e) {
|
|
|
2790
2801
|
updated_at: ae(r)
|
|
2791
2802
|
});
|
|
2792
2803
|
}
|
|
2793
|
-
function
|
|
2804
|
+
function On(e) {
|
|
2794
2805
|
return {
|
|
2795
2806
|
async create(t, n) {
|
|
2796
2807
|
let r = Date.now(), i = {
|
|
2797
|
-
id: n.id ||
|
|
2808
|
+
id: n.id || En(),
|
|
2798
2809
|
tenant_id: t,
|
|
2799
2810
|
user_id: n.user_id,
|
|
2800
2811
|
type: n.type,
|
|
@@ -2810,41 +2821,41 @@ function Dn(e) {
|
|
|
2810
2821
|
created_at_ts: r,
|
|
2811
2822
|
updated_at_ts: r
|
|
2812
2823
|
};
|
|
2813
|
-
return await e.insert(
|
|
2824
|
+
return await e.insert(q).values(i), Dn({
|
|
2814
2825
|
...i,
|
|
2815
2826
|
tenant_id: t
|
|
2816
2827
|
});
|
|
2817
2828
|
},
|
|
2818
2829
|
async get(n, r) {
|
|
2819
|
-
let i = await e.select().from(
|
|
2820
|
-
return i ?
|
|
2830
|
+
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.id, r))).get();
|
|
2831
|
+
return i ? Dn(i) : null;
|
|
2821
2832
|
},
|
|
2822
2833
|
async getByCredentialId(n, r) {
|
|
2823
|
-
let i = await e.select().from(
|
|
2824
|
-
return i ?
|
|
2834
|
+
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.credential_id, r))).get();
|
|
2835
|
+
return i ? Dn(i) : null;
|
|
2825
2836
|
},
|
|
2826
2837
|
async list(n, r) {
|
|
2827
|
-
return (await e.select().from(
|
|
2838
|
+
return (await e.select().from(q).where(t(a(q.tenant_id, n), a(q.user_id, r))).all()).map(Dn);
|
|
2828
2839
|
},
|
|
2829
2840
|
async update(n, r, i) {
|
|
2830
2841
|
let o = { updated_at_ts: Date.now() };
|
|
2831
|
-
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(
|
|
2842
|
+
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(q).set(o).where(t(a(q.tenant_id, n), a(q.id, r)));
|
|
2832
2843
|
let s = await this.get(n, r);
|
|
2833
2844
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2834
2845
|
return s;
|
|
2835
2846
|
},
|
|
2836
2847
|
async remove(n, r) {
|
|
2837
|
-
return (await e.delete(
|
|
2848
|
+
return (await e.delete(q).where(t(a(q.tenant_id, n), a(q.id, r))).returning()).length > 0;
|
|
2838
2849
|
}
|
|
2839
2850
|
};
|
|
2840
2851
|
}
|
|
2841
2852
|
//#endregion
|
|
2842
2853
|
//#region src/adapters/organizations.ts
|
|
2843
|
-
var
|
|
2844
|
-
function
|
|
2854
|
+
var kn = ["name", "display_name"];
|
|
2855
|
+
function An() {
|
|
2845
2856
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2846
2857
|
}
|
|
2847
|
-
function
|
|
2858
|
+
function jn(e) {
|
|
2848
2859
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2849
2860
|
return O({
|
|
2850
2861
|
...o,
|
|
@@ -2854,11 +2865,11 @@ function An(e) {
|
|
|
2854
2865
|
token_quota: Q(a, {})
|
|
2855
2866
|
});
|
|
2856
2867
|
}
|
|
2857
|
-
function
|
|
2868
|
+
function Mn(e) {
|
|
2858
2869
|
return {
|
|
2859
2870
|
async create(t, n) {
|
|
2860
2871
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2861
|
-
id: n.id ||
|
|
2872
|
+
id: n.id || An(),
|
|
2862
2873
|
tenant_id: t,
|
|
2863
2874
|
name: n.name,
|
|
2864
2875
|
display_name: n.display_name,
|
|
@@ -2870,39 +2881,39 @@ function jn(e) {
|
|
|
2870
2881
|
updated_at: r
|
|
2871
2882
|
};
|
|
2872
2883
|
try {
|
|
2873
|
-
await e.insert(
|
|
2884
|
+
await e.insert(H).values(i);
|
|
2874
2885
|
} catch (e) {
|
|
2875
2886
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Ce(409, { message: "Organization already exists" }) : e;
|
|
2876
2887
|
}
|
|
2877
|
-
return
|
|
2888
|
+
return jn({
|
|
2878
2889
|
...i,
|
|
2879
2890
|
tenant_id: t
|
|
2880
2891
|
});
|
|
2881
2892
|
},
|
|
2882
2893
|
async get(n, r) {
|
|
2883
|
-
let i = await e.select().from(
|
|
2884
|
-
return i ||= await e.select().from(
|
|
2894
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
2895
|
+
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ? jn(i) : null;
|
|
2885
2896
|
},
|
|
2886
2897
|
async update(n, r, i) {
|
|
2887
2898
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2888
|
-
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(
|
|
2899
|
+
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;
|
|
2889
2900
|
},
|
|
2890
2901
|
async list(o, s) {
|
|
2891
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2902
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(H.tenant_id, o)];
|
|
2892
2903
|
if (f) {
|
|
2893
|
-
let e = _e(f,
|
|
2904
|
+
let e = _e(f, kn);
|
|
2894
2905
|
if (e) {
|
|
2895
|
-
let t = nt(
|
|
2906
|
+
let t = nt(H, e, kn);
|
|
2896
2907
|
t && p.push(t);
|
|
2897
2908
|
}
|
|
2898
2909
|
}
|
|
2899
2910
|
let m = t(...p);
|
|
2900
|
-
if (
|
|
2911
|
+
if (mt(s)) {
|
|
2901
2912
|
let n = {
|
|
2902
|
-
sortColumn:
|
|
2903
|
-
idColumn:
|
|
2913
|
+
sortColumn: H.created_at,
|
|
2914
|
+
idColumn: H.id,
|
|
2904
2915
|
sortOrder: "desc"
|
|
2905
|
-
}, r =
|
|
2916
|
+
}, r = _t(s, n), i = ht(s), { rows: a, next: o } = vt(await e.select().from(H).where(r ? t(m, r) : m).orderBy(...gt(n)).limit(i + 1), i, "created_at"), c = a.map(jn);
|
|
2906
2917
|
return {
|
|
2907
2918
|
organizations: c,
|
|
2908
2919
|
start: 0,
|
|
@@ -2912,14 +2923,14 @@ function jn(e) {
|
|
|
2912
2923
|
next: o
|
|
2913
2924
|
};
|
|
2914
2925
|
}
|
|
2915
|
-
let h = e.select().from(
|
|
2926
|
+
let h = e.select().from(H).where(m).$dynamic();
|
|
2916
2927
|
if (d?.sort_by) {
|
|
2917
|
-
let e =
|
|
2928
|
+
let e = H[d.sort_by];
|
|
2918
2929
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2919
2930
|
}
|
|
2920
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2931
|
+
let g = (await h.offset(c * l).limit(l)).map(jn);
|
|
2921
2932
|
if (!u) return { organizations: g };
|
|
2922
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2933
|
+
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2923
2934
|
return {
|
|
2924
2935
|
organizations: g,
|
|
2925
2936
|
start: c * l,
|
|
@@ -2928,20 +2939,20 @@ function jn(e) {
|
|
|
2928
2939
|
};
|
|
2929
2940
|
},
|
|
2930
2941
|
async remove(n, r) {
|
|
2931
|
-
return (await e.delete(
|
|
2942
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2932
2943
|
}
|
|
2933
2944
|
};
|
|
2934
2945
|
}
|
|
2935
2946
|
//#endregion
|
|
2936
2947
|
//#region src/adapters/passwords.ts
|
|
2937
|
-
function
|
|
2948
|
+
function Nn(e) {
|
|
2938
2949
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2939
2950
|
return {
|
|
2940
2951
|
...r,
|
|
2941
2952
|
is_current: !!n
|
|
2942
2953
|
};
|
|
2943
2954
|
}
|
|
2944
|
-
function
|
|
2955
|
+
function Pn(e) {
|
|
2945
2956
|
return {
|
|
2946
2957
|
async create(n, r) {
|
|
2947
2958
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2956,18 +2967,18 @@ function Nn(e) {
|
|
|
2956
2967
|
created_at: i,
|
|
2957
2968
|
updated_at: i
|
|
2958
2969
|
};
|
|
2959
|
-
return await e.insert(M).values(s),
|
|
2970
|
+
return await e.insert(M).values(s), Nn({
|
|
2960
2971
|
...s,
|
|
2961
2972
|
tenant_id: n
|
|
2962
2973
|
});
|
|
2963
2974
|
},
|
|
2964
2975
|
async get(n, r) {
|
|
2965
2976
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r), a(M.is_current, 1))).get();
|
|
2966
|
-
return i ?
|
|
2977
|
+
return i ? Nn(i) : null;
|
|
2967
2978
|
},
|
|
2968
2979
|
async list(n, r, o) {
|
|
2969
2980
|
let s = e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r))).orderBy(i(M.created_at)).$dynamic();
|
|
2970
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
2981
|
+
return o && (s = s.limit(o)), (await s).map(Nn);
|
|
2971
2982
|
},
|
|
2972
2983
|
async update(n, r) {
|
|
2973
2984
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2977,10 +2988,10 @@ function Nn(e) {
|
|
|
2977
2988
|
}
|
|
2978
2989
|
//#endregion
|
|
2979
2990
|
//#region src/adapters/promptSettings.ts
|
|
2980
|
-
function
|
|
2991
|
+
function Fn(e) {
|
|
2981
2992
|
return {
|
|
2982
2993
|
async get(t) {
|
|
2983
|
-
let n = await e.select().from(
|
|
2994
|
+
let n = await e.select().from(He).where(a(He.tenant_id, t)).get();
|
|
2984
2995
|
return n ? {
|
|
2985
2996
|
universal_login_experience: n.universal_login_experience,
|
|
2986
2997
|
identifier_first: !!n.identifier_first,
|
|
@@ -2996,7 +3007,7 @@ function Pn(e) {
|
|
|
2996
3007
|
};
|
|
2997
3008
|
},
|
|
2998
3009
|
async set(t, n) {
|
|
2999
|
-
await e.insert(
|
|
3010
|
+
await e.insert(He).values({
|
|
3000
3011
|
tenant_id: t,
|
|
3001
3012
|
universal_login_experience: n.universal_login_experience,
|
|
3002
3013
|
identifier_first: n.identifier_first,
|
|
@@ -3004,7 +3015,7 @@ function Pn(e) {
|
|
|
3004
3015
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3005
3016
|
show_last_used_connection: n.show_last_used_connection
|
|
3006
3017
|
}).onConflictDoUpdate({
|
|
3007
|
-
target:
|
|
3018
|
+
target: He.tenant_id,
|
|
3008
3019
|
set: {
|
|
3009
3020
|
universal_login_experience: n.universal_login_experience,
|
|
3010
3021
|
identifier_first: n.identifier_first,
|
|
@@ -3018,7 +3029,7 @@ function Pn(e) {
|
|
|
3018
3029
|
}
|
|
3019
3030
|
//#endregion
|
|
3020
3031
|
//#region src/adapters/proxyRoutes.ts
|
|
3021
|
-
function
|
|
3032
|
+
function In(e) {
|
|
3022
3033
|
if (!e) return { path: "/*" };
|
|
3023
3034
|
try {
|
|
3024
3035
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -3026,7 +3037,7 @@ function Fn(e) {
|
|
|
3026
3037
|
} catch {}
|
|
3027
3038
|
return { path: "/*" };
|
|
3028
3039
|
}
|
|
3029
|
-
function
|
|
3040
|
+
function Ln(e) {
|
|
3030
3041
|
if (!e) return [];
|
|
3031
3042
|
try {
|
|
3032
3043
|
let t = JSON.parse(e);
|
|
@@ -3041,19 +3052,19 @@ function In(e) {
|
|
|
3041
3052
|
return [];
|
|
3042
3053
|
}
|
|
3043
3054
|
}
|
|
3044
|
-
function
|
|
3055
|
+
function Rn(e) {
|
|
3045
3056
|
return {
|
|
3046
3057
|
id: e.id,
|
|
3047
3058
|
tenant_id: e.tenant_id,
|
|
3048
3059
|
custom_domain_id: e.custom_domain_id,
|
|
3049
3060
|
priority: e.priority,
|
|
3050
|
-
match:
|
|
3051
|
-
handlers:
|
|
3061
|
+
match: In(e.match),
|
|
3062
|
+
handlers: Ln(e.handlers),
|
|
3052
3063
|
created_at: e.created_at,
|
|
3053
3064
|
updated_at: e.updated_at
|
|
3054
3065
|
};
|
|
3055
3066
|
}
|
|
3056
|
-
function
|
|
3067
|
+
function zn(e) {
|
|
3057
3068
|
return {
|
|
3058
3069
|
async create(t, n) {
|
|
3059
3070
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3079,14 +3090,14 @@ function Rn(e) {
|
|
|
3079
3090
|
},
|
|
3080
3091
|
async get(n, r) {
|
|
3081
3092
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1);
|
|
3082
|
-
return i[0] ?
|
|
3093
|
+
return i[0] ? Rn(i[0]) : null;
|
|
3083
3094
|
},
|
|
3084
3095
|
async list(r, i = {}) {
|
|
3085
3096
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(X.tenant_id, r)];
|
|
3086
3097
|
i.custom_domain_id && c.push(a(X.custom_domain_id, i.custom_domain_id));
|
|
3087
3098
|
let l = await e.select().from(X).where(t(...c)).orderBy(n(X.priority), n(X.created_at)).offset(o * s).limit(s);
|
|
3088
3099
|
return {
|
|
3089
|
-
proxy_routes: l.map(
|
|
3100
|
+
proxy_routes: l.map(Rn),
|
|
3090
3101
|
start: o * s,
|
|
3091
3102
|
limit: s,
|
|
3092
3103
|
length: l.length
|
|
@@ -3105,7 +3116,7 @@ function Rn(e) {
|
|
|
3105
3116
|
}
|
|
3106
3117
|
//#endregion
|
|
3107
3118
|
//#region src/adapters/scim.ts
|
|
3108
|
-
function
|
|
3119
|
+
function Bn(e) {
|
|
3109
3120
|
if (!e) return [];
|
|
3110
3121
|
try {
|
|
3111
3122
|
let t = JSON.parse(e);
|
|
@@ -3120,7 +3131,7 @@ function zn(e) {
|
|
|
3120
3131
|
return [];
|
|
3121
3132
|
}
|
|
3122
3133
|
}
|
|
3123
|
-
function
|
|
3134
|
+
function Vn(e) {
|
|
3124
3135
|
if (!e) return [];
|
|
3125
3136
|
try {
|
|
3126
3137
|
let t = JSON.parse(e);
|
|
@@ -3129,16 +3140,16 @@ function Bn(e) {
|
|
|
3129
3140
|
return [];
|
|
3130
3141
|
}
|
|
3131
3142
|
}
|
|
3132
|
-
function
|
|
3143
|
+
function Hn(e) {
|
|
3133
3144
|
return {
|
|
3134
3145
|
connection_id: e.connection_id,
|
|
3135
3146
|
user_id_attribute: e.user_id_attribute,
|
|
3136
|
-
mapping:
|
|
3147
|
+
mapping: Bn(e.mapping),
|
|
3137
3148
|
created_at: e.created_at,
|
|
3138
3149
|
updated_at: e.updated_at
|
|
3139
3150
|
};
|
|
3140
3151
|
}
|
|
3141
|
-
function
|
|
3152
|
+
function Un(e) {
|
|
3142
3153
|
return {
|
|
3143
3154
|
async create(t, n) {
|
|
3144
3155
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3159,7 +3170,7 @@ function Hn(e) {
|
|
|
3159
3170
|
},
|
|
3160
3171
|
async get(n, r) {
|
|
3161
3172
|
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))).limit(1);
|
|
3162
|
-
return i[0] ?
|
|
3173
|
+
return i[0] ? Hn(i[0]) : null;
|
|
3163
3174
|
},
|
|
3164
3175
|
async update(n, r, i) {
|
|
3165
3176
|
if ((await e.select({ connection_id: Ye.connection_id }).from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))).limit(1)).length === 0) return !1;
|
|
@@ -3171,18 +3182,18 @@ function Hn(e) {
|
|
|
3171
3182
|
}
|
|
3172
3183
|
};
|
|
3173
3184
|
}
|
|
3174
|
-
function
|
|
3185
|
+
function Wn(e) {
|
|
3175
3186
|
return {
|
|
3176
3187
|
token_id: e.token_id,
|
|
3177
3188
|
connection_id: e.connection_id,
|
|
3178
3189
|
token_hash: e.token_hash,
|
|
3179
|
-
scopes:
|
|
3190
|
+
scopes: Vn(e.scopes),
|
|
3180
3191
|
valid_until: e.valid_until ?? void 0,
|
|
3181
3192
|
created_at: e.created_at,
|
|
3182
3193
|
last_used_at: e.last_used_at ?? void 0
|
|
3183
3194
|
};
|
|
3184
3195
|
}
|
|
3185
|
-
function
|
|
3196
|
+
function Gn(e) {
|
|
3186
3197
|
return {
|
|
3187
3198
|
async create(t, n) {
|
|
3188
3199
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3205,14 +3216,14 @@ function Wn(e) {
|
|
|
3205
3216
|
},
|
|
3206
3217
|
async get(n, r) {
|
|
3207
3218
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1);
|
|
3208
|
-
return i[0] ?
|
|
3219
|
+
return i[0] ? Wn(i[0]) : null;
|
|
3209
3220
|
},
|
|
3210
3221
|
async getByHash(n, r) {
|
|
3211
3222
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_hash, r))).limit(1);
|
|
3212
|
-
return i[0] ?
|
|
3223
|
+
return i[0] ? Wn(i[0]) : null;
|
|
3213
3224
|
},
|
|
3214
3225
|
async listByConnection(n, r) {
|
|
3215
|
-
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(
|
|
3226
|
+
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(Wn);
|
|
3216
3227
|
},
|
|
3217
3228
|
async markUsed(n, r, i) {
|
|
3218
3229
|
return (await e.select({ token_id: Z.token_id }).from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(Z).set({ last_used_at: i }).where(t(a(Z.tenant_id, n), a(Z.token_id, r))), !0);
|
|
@@ -3222,7 +3233,7 @@ function Wn(e) {
|
|
|
3222
3233
|
}
|
|
3223
3234
|
};
|
|
3224
3235
|
}
|
|
3225
|
-
function
|
|
3236
|
+
function Kn(e) {
|
|
3226
3237
|
return {
|
|
3227
3238
|
connection_id: e.connection_id,
|
|
3228
3239
|
external_id: e.external_id,
|
|
@@ -3230,7 +3241,7 @@ function Gn(e) {
|
|
|
3230
3241
|
created_at: e.created_at
|
|
3231
3242
|
};
|
|
3232
3243
|
}
|
|
3233
|
-
function
|
|
3244
|
+
function qn(e) {
|
|
3234
3245
|
return {
|
|
3235
3246
|
async create(t, n) {
|
|
3236
3247
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3249,11 +3260,11 @@ function Kn(e) {
|
|
|
3249
3260
|
},
|
|
3250
3261
|
async getByExternalId(n, r, i) {
|
|
3251
3262
|
let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.external_id, i))).limit(1);
|
|
3252
|
-
return o[0] ?
|
|
3263
|
+
return o[0] ? Kn(o[0]) : null;
|
|
3253
3264
|
},
|
|
3254
3265
|
async getByUserId(n, r, i) {
|
|
3255
3266
|
let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))).limit(1);
|
|
3256
|
-
return o[0] ?
|
|
3267
|
+
return o[0] ? Kn(o[0]) : null;
|
|
3257
3268
|
},
|
|
3258
3269
|
async remove(n, r, i) {
|
|
3259
3270
|
return (await e.select({ user_id: Xe.user_id }).from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))), !0);
|
|
@@ -3262,7 +3273,7 @@ function Kn(e) {
|
|
|
3262
3273
|
}
|
|
3263
3274
|
//#endregion
|
|
3264
3275
|
//#region src/adapters/refreshTokens.ts
|
|
3265
|
-
function
|
|
3276
|
+
function Jn(e) {
|
|
3266
3277
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: r, idle_expires_at_ts: i, last_exchanged_at_ts: a, revoked_at_ts: o, rotated_at_ts: s, device: c, resource_servers: l, rotating: u, ...d } = e, f = ie({
|
|
3267
3278
|
created_at_ts: n,
|
|
3268
3279
|
expires_at_ts: r,
|
|
@@ -3285,10 +3296,10 @@ function qn(e) {
|
|
|
3285
3296
|
resource_servers: Q(l, [])
|
|
3286
3297
|
});
|
|
3287
3298
|
}
|
|
3288
|
-
function
|
|
3299
|
+
function Yn(e, t) {
|
|
3289
3300
|
return Math.max(e ?? 0, t ?? 0);
|
|
3290
3301
|
}
|
|
3291
|
-
function
|
|
3302
|
+
function Xn(e) {
|
|
3292
3303
|
return {
|
|
3293
3304
|
async create(n, r) {
|
|
3294
3305
|
let i = Date.now(), o = {
|
|
@@ -3309,22 +3320,22 @@ function Yn(e) {
|
|
|
3309
3320
|
expires_at_ts: D(r.expires_at),
|
|
3310
3321
|
idle_expires_at_ts: D(r.idle_expires_at),
|
|
3311
3322
|
last_exchanged_at_ts: D(r.last_exchanged_at)
|
|
3312
|
-
}, s = [e.insert(P).values(o)], c =
|
|
3323
|
+
}, s = [e.insert(P).values(o)], c = Yn(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3313
3324
|
return c > 0 && o.login_id && s.push(e.update(F).set({
|
|
3314
3325
|
expires_at_ts: c,
|
|
3315
3326
|
updated_at_ts: i
|
|
3316
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await
|
|
3327
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await lt(e, s), Jn({
|
|
3317
3328
|
...o,
|
|
3318
3329
|
tenant_id: n
|
|
3319
3330
|
});
|
|
3320
3331
|
},
|
|
3321
3332
|
async get(n, r) {
|
|
3322
3333
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.id, r))).get();
|
|
3323
|
-
return i ?
|
|
3334
|
+
return i ? Jn(i) : null;
|
|
3324
3335
|
},
|
|
3325
3336
|
async getByLookup(n, r) {
|
|
3326
3337
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.token_lookup, r))).get();
|
|
3327
|
-
return i ?
|
|
3338
|
+
return i ? Jn(i) : null;
|
|
3328
3339
|
},
|
|
3329
3340
|
async update(n, r, i, o) {
|
|
3330
3341
|
let s = {};
|
|
@@ -3345,7 +3356,7 @@ function Yn(e) {
|
|
|
3345
3356
|
let e = P[d.sort_by];
|
|
3346
3357
|
e && (p = p.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3347
3358
|
}
|
|
3348
|
-
let m = (await p.offset(c * l).limit(l)).map(
|
|
3359
|
+
let m = (await p.offset(c * l).limit(l)).map(Jn);
|
|
3349
3360
|
if (!u) return { refresh_tokens: m };
|
|
3350
3361
|
let [h] = await e.select({ count: r() }).from(P).where(a(P.tenant_id, o));
|
|
3351
3362
|
return {
|
|
@@ -3368,15 +3379,15 @@ function Yn(e) {
|
|
|
3368
3379
|
}
|
|
3369
3380
|
//#endregion
|
|
3370
3381
|
//#region src/adapters/resourceServers.ts
|
|
3371
|
-
var
|
|
3372
|
-
function
|
|
3382
|
+
var Zn = ["name", "identifier"];
|
|
3383
|
+
function Qn() {
|
|
3373
3384
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3374
3385
|
}
|
|
3375
|
-
var
|
|
3386
|
+
var $n = [
|
|
3376
3387
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3377
3388
|
"allow_offline_access",
|
|
3378
3389
|
"is_system"
|
|
3379
|
-
],
|
|
3390
|
+
], er = new Set([
|
|
3380
3391
|
"id",
|
|
3381
3392
|
"tenant_id",
|
|
3382
3393
|
"identifier",
|
|
@@ -3395,17 +3406,17 @@ var Qn = [
|
|
|
3395
3406
|
"created_at",
|
|
3396
3407
|
"updated_at"
|
|
3397
3408
|
]);
|
|
3398
|
-
function
|
|
3409
|
+
function tr(e) {
|
|
3399
3410
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3400
3411
|
s.scopes = Q(r, []), s.options = Q(i, {}), s.metadata = Q(a), n !== void 0 && (s.verificationKey = n);
|
|
3401
|
-
for (let e of
|
|
3412
|
+
for (let e of $n) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3402
3413
|
return O(s);
|
|
3403
3414
|
}
|
|
3404
|
-
function
|
|
3415
|
+
function nr(e) {
|
|
3405
3416
|
return {
|
|
3406
3417
|
async create(t, n) {
|
|
3407
3418
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3408
|
-
id: n.id ||
|
|
3419
|
+
id: n.id || Qn(),
|
|
3409
3420
|
tenant_id: t,
|
|
3410
3421
|
identifier: n.identifier,
|
|
3411
3422
|
name: n.name,
|
|
@@ -3420,39 +3431,39 @@ function tr(e) {
|
|
|
3420
3431
|
created_at: r,
|
|
3421
3432
|
updated_at: r
|
|
3422
3433
|
};
|
|
3423
|
-
for (let e of
|
|
3424
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(
|
|
3434
|
+
for (let e of $n) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3435
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), tr({
|
|
3425
3436
|
...i,
|
|
3426
3437
|
tenant_id: t
|
|
3427
3438
|
});
|
|
3428
3439
|
},
|
|
3429
3440
|
async get(n, r) {
|
|
3430
|
-
let i = await e.select().from(
|
|
3431
|
-
return i ?
|
|
3441
|
+
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3442
|
+
return i ? tr(i) : null;
|
|
3432
3443
|
},
|
|
3433
3444
|
async update(n, r, i) {
|
|
3434
3445
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3435
|
-
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(${
|
|
3436
|
-
for (let e of
|
|
3437
|
-
return (await e.update(
|
|
3446
|
+
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);
|
|
3447
|
+
for (let e of $n) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3448
|
+
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3438
3449
|
},
|
|
3439
3450
|
async list(o, s) {
|
|
3440
|
-
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(
|
|
3451
|
+
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)];
|
|
3441
3452
|
if (f) {
|
|
3442
|
-
let e = _e(f,
|
|
3453
|
+
let e = _e(f, Zn);
|
|
3443
3454
|
if (e) {
|
|
3444
|
-
let t = nt(
|
|
3455
|
+
let t = nt(K, e, Zn, ["name", "identifier"]);
|
|
3445
3456
|
t && h.push(t);
|
|
3446
3457
|
}
|
|
3447
3458
|
}
|
|
3448
|
-
let g = e.select().from(
|
|
3449
|
-
if (d?.sort_by &&
|
|
3450
|
-
let e =
|
|
3459
|
+
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3460
|
+
if (d?.sort_by && er.has(d.sort_by)) {
|
|
3461
|
+
let e = K[d.sort_by];
|
|
3451
3462
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3452
3463
|
}
|
|
3453
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3464
|
+
let _ = (await g.offset(p * m).limit(m)).map(tr);
|
|
3454
3465
|
if (!u) return { resource_servers: _ };
|
|
3455
|
-
let [v] = await e.select({ count: r() }).from(
|
|
3466
|
+
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3456
3467
|
return {
|
|
3457
3468
|
resource_servers: _,
|
|
3458
3469
|
start: p * m,
|
|
@@ -3461,17 +3472,17 @@ function tr(e) {
|
|
|
3461
3472
|
};
|
|
3462
3473
|
},
|
|
3463
3474
|
async remove(n, r) {
|
|
3464
|
-
return (await e.delete(
|
|
3475
|
+
return (await e.delete(K).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3465
3476
|
}
|
|
3466
3477
|
};
|
|
3467
3478
|
}
|
|
3468
3479
|
//#endregion
|
|
3469
3480
|
//#region src/adapters/rolePermissions.ts
|
|
3470
|
-
function
|
|
3481
|
+
function rr(e) {
|
|
3471
3482
|
return {
|
|
3472
3483
|
async assign(t, n, r) {
|
|
3473
3484
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3474
|
-
return await e.insert(
|
|
3485
|
+
return await e.insert(Fe).values(r.map((e) => ({
|
|
3475
3486
|
tenant_id: t,
|
|
3476
3487
|
role_id: n,
|
|
3477
3488
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3481,15 +3492,15 @@ function nr(e) {
|
|
|
3481
3492
|
},
|
|
3482
3493
|
async list(n, r, i) {
|
|
3483
3494
|
let o = await e.select({
|
|
3484
|
-
resource_server_identifier:
|
|
3485
|
-
permission_name:
|
|
3486
|
-
created_at:
|
|
3487
|
-
}).from(
|
|
3495
|
+
resource_server_identifier: Fe.resource_server_identifier,
|
|
3496
|
+
permission_name: Fe.permission_name,
|
|
3497
|
+
created_at: Fe.created_at
|
|
3498
|
+
}).from(Fe).where(t(a(Fe.tenant_id, n), a(Fe.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3488
3499
|
if (s.length > 0) {
|
|
3489
3500
|
let r = await e.select({
|
|
3490
|
-
identifier:
|
|
3491
|
-
name:
|
|
3492
|
-
}).from(
|
|
3501
|
+
identifier: K.identifier,
|
|
3502
|
+
name: K.name
|
|
3503
|
+
}).from(K).where(t(a(K.tenant_id, n), l(K.identifier, s))).all();
|
|
3493
3504
|
for (let e of r) c.set(e.identifier, e.name);
|
|
3494
3505
|
}
|
|
3495
3506
|
return o.map((e) => ({
|
|
@@ -3498,18 +3509,18 @@ function nr(e) {
|
|
|
3498
3509
|
}));
|
|
3499
3510
|
},
|
|
3500
3511
|
async remove(n, r, i) {
|
|
3501
|
-
let o = i.map((e) => t(a(
|
|
3502
|
-
return (await e.delete(
|
|
3512
|
+
let o = i.map((e) => t(a(Fe.resource_server_identifier, e.resource_server_identifier), a(Fe.permission_name, e.permission_name)));
|
|
3513
|
+
return (await e.delete(Fe).where(t(a(Fe.tenant_id, n), a(Fe.role_id, r), v(...o))).returning()).length > 0;
|
|
3503
3514
|
}
|
|
3504
3515
|
};
|
|
3505
3516
|
}
|
|
3506
3517
|
//#endregion
|
|
3507
3518
|
//#region src/adapters/userPermissions.ts
|
|
3508
|
-
function
|
|
3519
|
+
function ir(e) {
|
|
3509
3520
|
return {
|
|
3510
3521
|
async create(t, n, r, i) {
|
|
3511
3522
|
try {
|
|
3512
|
-
await e.insert(
|
|
3523
|
+
await e.insert(Ie).values({
|
|
3513
3524
|
tenant_id: t,
|
|
3514
3525
|
user_id: n,
|
|
3515
3526
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3524,11 +3535,11 @@ function rr(e) {
|
|
|
3524
3535
|
return !0;
|
|
3525
3536
|
},
|
|
3526
3537
|
async list(n, r, i, o) {
|
|
3527
|
-
let s = [a(
|
|
3528
|
-
o && s.push(a(
|
|
3529
|
-
let c = await e.select().from(
|
|
3538
|
+
let s = [a(Ie.tenant_id, n), a(Ie.user_id, r)];
|
|
3539
|
+
o && s.push(a(Ie.organization_id, o));
|
|
3540
|
+
let c = await e.select().from(Ie).where(t(...s)).all();
|
|
3530
3541
|
return await Promise.all(c.map(async (r) => {
|
|
3531
|
-
let i = await e.select({ name:
|
|
3542
|
+
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();
|
|
3532
3543
|
return {
|
|
3533
3544
|
resource_server_identifier: r.resource_server_identifier,
|
|
3534
3545
|
permission_name: r.permission_name,
|
|
@@ -3538,13 +3549,13 @@ function rr(e) {
|
|
|
3538
3549
|
}));
|
|
3539
3550
|
},
|
|
3540
3551
|
async remove(n, r, i, o) {
|
|
3541
|
-
return (await e.delete(
|
|
3552
|
+
return (await e.delete(Ie).where(t(a(Ie.tenant_id, n), a(Ie.user_id, r), a(Ie.resource_server_identifier, i.resource_server_identifier), a(Ie.permission_name, i.permission_name), a(Ie.organization_id, o || ""))).returning()).length > 0;
|
|
3542
3553
|
}
|
|
3543
3554
|
};
|
|
3544
3555
|
}
|
|
3545
3556
|
//#endregion
|
|
3546
3557
|
//#region src/adapters/roles.ts
|
|
3547
|
-
function
|
|
3558
|
+
function ar(e) {
|
|
3548
3559
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3549
3560
|
return O({
|
|
3550
3561
|
...i,
|
|
@@ -3552,7 +3563,7 @@ function ir(e) {
|
|
|
3552
3563
|
metadata: Q(r)
|
|
3553
3564
|
});
|
|
3554
3565
|
}
|
|
3555
|
-
function
|
|
3566
|
+
function or(e) {
|
|
3556
3567
|
return {
|
|
3557
3568
|
async create(t, n) {
|
|
3558
3569
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3565,28 +3576,28 @@ function ar(e) {
|
|
|
3565
3576
|
created_at: r,
|
|
3566
3577
|
updated_at: r
|
|
3567
3578
|
};
|
|
3568
|
-
return await e.insert(
|
|
3579
|
+
return await e.insert(W).values(i), ar({
|
|
3569
3580
|
...i,
|
|
3570
3581
|
tenant_id: t
|
|
3571
3582
|
});
|
|
3572
3583
|
},
|
|
3573
3584
|
async get(n, r) {
|
|
3574
|
-
let i = await e.select().from(
|
|
3575
|
-
return i ?
|
|
3585
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3586
|
+
return i ? ar(i) : null;
|
|
3576
3587
|
},
|
|
3577
3588
|
async update(n, r, i) {
|
|
3578
3589
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3579
|
-
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(
|
|
3590
|
+
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;
|
|
3580
3591
|
},
|
|
3581
3592
|
async list(o, s) {
|
|
3582
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(
|
|
3593
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(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();
|
|
3583
3594
|
if (d?.sort_by) {
|
|
3584
|
-
let e =
|
|
3595
|
+
let e = W[d.sort_by];
|
|
3585
3596
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3586
3597
|
}
|
|
3587
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3598
|
+
let g = (await h.offset(c * l).limit(l)).map(ar);
|
|
3588
3599
|
if (!u) return { roles: g };
|
|
3589
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3600
|
+
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3590
3601
|
return {
|
|
3591
3602
|
roles: g,
|
|
3592
3603
|
start: c * l,
|
|
@@ -3595,13 +3606,13 @@ function ar(e) {
|
|
|
3595
3606
|
};
|
|
3596
3607
|
},
|
|
3597
3608
|
async remove(n, r) {
|
|
3598
|
-
return (await e.delete(
|
|
3609
|
+
return (await e.delete(W).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3599
3610
|
}
|
|
3600
3611
|
};
|
|
3601
3612
|
}
|
|
3602
3613
|
//#endregion
|
|
3603
3614
|
//#region src/adapters/sessions.ts
|
|
3604
|
-
var
|
|
3615
|
+
var sr = ["created_at_ts", "updated_at_ts"], cr = [
|
|
3605
3616
|
"expires_at_ts",
|
|
3606
3617
|
"idle_expires_at_ts",
|
|
3607
3618
|
"authenticated_at_ts",
|
|
@@ -3609,7 +3620,7 @@ var or = ["created_at_ts", "updated_at_ts"], sr = [
|
|
|
3609
3620
|
"used_at_ts",
|
|
3610
3621
|
"revoked_at_ts"
|
|
3611
3622
|
];
|
|
3612
|
-
function
|
|
3623
|
+
function lr(e) {
|
|
3613
3624
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, p = ie({
|
|
3614
3625
|
created_at_ts: n,
|
|
3615
3626
|
updated_at_ts: r,
|
|
@@ -3619,7 +3630,7 @@ function cr(e) {
|
|
|
3619
3630
|
last_interaction_at_ts: s,
|
|
3620
3631
|
used_at_ts: c,
|
|
3621
3632
|
revoked_at_ts: l
|
|
3622
|
-
}, [...
|
|
3633
|
+
}, [...sr], [...cr]);
|
|
3623
3634
|
return O({
|
|
3624
3635
|
...f,
|
|
3625
3636
|
...p,
|
|
@@ -3627,10 +3638,10 @@ function cr(e) {
|
|
|
3627
3638
|
clients: Q(d, [])
|
|
3628
3639
|
});
|
|
3629
3640
|
}
|
|
3630
|
-
function
|
|
3641
|
+
function ur(e, t) {
|
|
3631
3642
|
return Math.max(e ?? 0, t ?? 0);
|
|
3632
3643
|
}
|
|
3633
|
-
function
|
|
3644
|
+
function dr(e) {
|
|
3634
3645
|
return {
|
|
3635
3646
|
async create(n, r) {
|
|
3636
3647
|
let i = Date.now(), o = {
|
|
@@ -3648,23 +3659,23 @@ function ur(e) {
|
|
|
3648
3659
|
last_interaction_at_ts: r.last_interaction_at ? D(r.last_interaction_at) : i,
|
|
3649
3660
|
used_at_ts: D(r.used_at),
|
|
3650
3661
|
revoked_at_ts: D(r.revoked_at)
|
|
3651
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3662
|
+
}, s = [e.insert(N).values(o)], c = ur(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3652
3663
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3653
3664
|
expires_at_ts: c,
|
|
3654
3665
|
updated_at_ts: i
|
|
3655
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await
|
|
3666
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await lt(e, s), lr({
|
|
3656
3667
|
...o,
|
|
3657
3668
|
tenant_id: n
|
|
3658
3669
|
});
|
|
3659
3670
|
},
|
|
3660
3671
|
async get(n, r) {
|
|
3661
3672
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3662
|
-
return i ?
|
|
3673
|
+
return i ? lr(i) : null;
|
|
3663
3674
|
},
|
|
3664
3675
|
async update(n, r, i) {
|
|
3665
3676
|
let o = { updated_at_ts: Date.now() };
|
|
3666
3677
|
i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = D(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = D(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = D(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = D(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = D(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = D(i.revoked_at));
|
|
3667
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3678
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = ur(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3668
3679
|
if (c > 0 && l) {
|
|
3669
3680
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3670
3681
|
r && await e.update(F).set({
|
|
@@ -3680,7 +3691,7 @@ function ur(e) {
|
|
|
3680
3691
|
let e = N[d.sort_by];
|
|
3681
3692
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3682
3693
|
}
|
|
3683
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3694
|
+
let g = (await h.offset(c * l).limit(l)).map(lr);
|
|
3684
3695
|
if (!u) return { sessions: g };
|
|
3685
3696
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3686
3697
|
return {
|
|
@@ -3697,7 +3708,7 @@ function ur(e) {
|
|
|
3697
3708
|
}
|
|
3698
3709
|
//#endregion
|
|
3699
3710
|
//#region src/adapters/tenants.ts
|
|
3700
|
-
var
|
|
3711
|
+
var fr = [
|
|
3701
3712
|
"session_cookie",
|
|
3702
3713
|
"enabled_locales",
|
|
3703
3714
|
"error_page",
|
|
@@ -3713,25 +3724,25 @@ var dr = [
|
|
|
3713
3724
|
"acr_values_supported",
|
|
3714
3725
|
"mtls",
|
|
3715
3726
|
"mfa"
|
|
3716
|
-
],
|
|
3727
|
+
], pr = [
|
|
3717
3728
|
"allow_organization_name_in_authentication_api",
|
|
3718
3729
|
"customize_mfa_in_postlogin_action",
|
|
3719
3730
|
"pushed_authorization_requests_supported",
|
|
3720
3731
|
"authorization_response_iss_parameter_supported"
|
|
3721
3732
|
];
|
|
3722
|
-
function
|
|
3733
|
+
function mr(e) {
|
|
3723
3734
|
let t = { ...e };
|
|
3724
|
-
for (let e of
|
|
3725
|
-
for (let e of
|
|
3735
|
+
for (let e of fr) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3736
|
+
for (let e of pr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3726
3737
|
return O(t);
|
|
3727
3738
|
}
|
|
3728
|
-
function
|
|
3739
|
+
function hr(e) {
|
|
3729
3740
|
let t = { ...e };
|
|
3730
|
-
ce(e,
|
|
3731
|
-
for (let n of
|
|
3741
|
+
ce(e, fr, t);
|
|
3742
|
+
for (let n of pr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3732
3743
|
return se(t);
|
|
3733
3744
|
}
|
|
3734
|
-
function
|
|
3745
|
+
function gr(e) {
|
|
3735
3746
|
return {
|
|
3736
3747
|
async create(t) {
|
|
3737
3748
|
let n = {
|
|
@@ -3739,7 +3750,7 @@ function hr(e) {
|
|
|
3739
3750
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3740
3751
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3741
3752
|
...t
|
|
3742
|
-
}, r =
|
|
3753
|
+
}, r = hr(n);
|
|
3743
3754
|
try {
|
|
3744
3755
|
await e.insert(k).values(r);
|
|
3745
3756
|
} catch (e) {
|
|
@@ -3750,7 +3761,7 @@ function hr(e) {
|
|
|
3750
3761
|
},
|
|
3751
3762
|
async get(t) {
|
|
3752
3763
|
let n = await e.select().from(k).where(a(k.id, t)).get();
|
|
3753
|
-
return n ?
|
|
3764
|
+
return n ? mr(n) : null;
|
|
3754
3765
|
},
|
|
3755
3766
|
async list(t) {
|
|
3756
3767
|
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? nt(k, l, ["friendly_name"]) : void 0, d = e.select().from(k).$dynamic();
|
|
@@ -3758,7 +3769,7 @@ function hr(e) {
|
|
|
3758
3769
|
let e = k[c.sort_by];
|
|
3759
3770
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3760
3771
|
}
|
|
3761
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3772
|
+
let f = (await d.offset(a * o).limit(o)).map(mr);
|
|
3762
3773
|
if (!s) return { tenants: f };
|
|
3763
3774
|
let p = e.select({ count: r() }).from(k).$dynamic();
|
|
3764
3775
|
u && (p = p.where(u));
|
|
@@ -3771,7 +3782,7 @@ function hr(e) {
|
|
|
3771
3782
|
};
|
|
3772
3783
|
},
|
|
3773
3784
|
async update(t, n) {
|
|
3774
|
-
let r =
|
|
3785
|
+
let r = hr({
|
|
3775
3786
|
...n,
|
|
3776
3787
|
id: t,
|
|
3777
3788
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3785,18 +3796,18 @@ function hr(e) {
|
|
|
3785
3796
|
}
|
|
3786
3797
|
//#endregion
|
|
3787
3798
|
//#region src/adapters/themes.ts
|
|
3788
|
-
var
|
|
3799
|
+
var _r = [
|
|
3789
3800
|
"colors",
|
|
3790
3801
|
"borders",
|
|
3791
3802
|
"fonts",
|
|
3792
3803
|
"page_background",
|
|
3793
3804
|
"widget"
|
|
3794
3805
|
];
|
|
3795
|
-
function
|
|
3796
|
-
let { tenant_id: t, ...n } = e, r = $e(n,
|
|
3806
|
+
function vr(e) {
|
|
3807
|
+
let { tenant_id: t, ...n } = e, r = $e(n, _r);
|
|
3797
3808
|
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), O(r);
|
|
3798
3809
|
}
|
|
3799
|
-
function
|
|
3810
|
+
function yr(e) {
|
|
3800
3811
|
return {
|
|
3801
3812
|
async create(t, n, r, i) {
|
|
3802
3813
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
@@ -3806,41 +3817,41 @@ function vr(e) {
|
|
|
3806
3817
|
created_at: a?.created_at ?? o,
|
|
3807
3818
|
updated_at: a?.updated_at ?? o
|
|
3808
3819
|
};
|
|
3809
|
-
return await e.insert(
|
|
3820
|
+
return await e.insert(ze).values(c), vr({
|
|
3810
3821
|
...c,
|
|
3811
3822
|
tenant_id: t
|
|
3812
3823
|
});
|
|
3813
3824
|
},
|
|
3814
3825
|
async get(n, r) {
|
|
3815
|
-
let i = await e.select().from(
|
|
3816
|
-
return i ?
|
|
3826
|
+
let i = await e.select().from(ze).where(t(a(ze.tenant_id, n), a(ze.themeId, r))).get();
|
|
3827
|
+
return i ? vr(i) : null;
|
|
3817
3828
|
},
|
|
3818
3829
|
async update(n, r, i) {
|
|
3819
3830
|
let o = Qe(i);
|
|
3820
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3831
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(ze).set(o).where(t(a(ze.tenant_id, n), a(ze.themeId, r))), !0;
|
|
3821
3832
|
},
|
|
3822
3833
|
async remove(n, r) {
|
|
3823
|
-
return (await e.delete(
|
|
3834
|
+
return (await e.delete(ze).where(t(a(ze.tenant_id, n), a(ze.themeId, r))).returning()).length > 0;
|
|
3824
3835
|
}
|
|
3825
3836
|
};
|
|
3826
3837
|
}
|
|
3827
3838
|
//#endregion
|
|
3828
3839
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3829
|
-
function
|
|
3840
|
+
function br(e) {
|
|
3830
3841
|
return {
|
|
3831
3842
|
async get(t) {
|
|
3832
|
-
let n = await e.select({ body:
|
|
3843
|
+
let n = await e.select({ body: Re.body }).from(Re).where(a(Re.tenant_id, t)).get();
|
|
3833
3844
|
return n ? { body: n.body } : null;
|
|
3834
3845
|
},
|
|
3835
3846
|
async set(t, n) {
|
|
3836
3847
|
let r = Date.now();
|
|
3837
|
-
await e.insert(
|
|
3848
|
+
await e.insert(Re).values({
|
|
3838
3849
|
tenant_id: t,
|
|
3839
3850
|
body: n.body,
|
|
3840
3851
|
created_at_ts: r,
|
|
3841
3852
|
updated_at_ts: r
|
|
3842
3853
|
}).onConflictDoUpdate({
|
|
3843
|
-
target:
|
|
3854
|
+
target: Re.tenant_id,
|
|
3844
3855
|
set: {
|
|
3845
3856
|
body: n.body,
|
|
3846
3857
|
updated_at_ts: r
|
|
@@ -3848,17 +3859,17 @@ function yr(e) {
|
|
|
3848
3859
|
});
|
|
3849
3860
|
},
|
|
3850
3861
|
async delete(t) {
|
|
3851
|
-
await e.delete(
|
|
3862
|
+
await e.delete(Re).where(a(Re.tenant_id, t));
|
|
3852
3863
|
}
|
|
3853
3864
|
};
|
|
3854
3865
|
}
|
|
3855
3866
|
//#endregion
|
|
3856
3867
|
//#region src/adapters/userActivity.ts
|
|
3857
|
-
function
|
|
3868
|
+
function xr(e) {
|
|
3858
3869
|
let t = {};
|
|
3859
3870
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
3860
3871
|
}
|
|
3861
|
-
function
|
|
3872
|
+
function Sr(e) {
|
|
3862
3873
|
return {
|
|
3863
3874
|
async get(n, r) {
|
|
3864
3875
|
let i = await e.select().from(Oe).where(t(a(Oe.tenant_id, n), a(Oe.user_id, r))).get();
|
|
@@ -3872,7 +3883,7 @@ function xr(e) {
|
|
|
3872
3883
|
} : null;
|
|
3873
3884
|
},
|
|
3874
3885
|
async upsert(t, n, r) {
|
|
3875
|
-
let i =
|
|
3886
|
+
let i = xr(r), a = e.insert(Oe).values({
|
|
3876
3887
|
tenant_id: t,
|
|
3877
3888
|
user_id: n,
|
|
3878
3889
|
login_count: 0,
|
|
@@ -3891,13 +3902,13 @@ function xr(e) {
|
|
|
3891
3902
|
}
|
|
3892
3903
|
//#endregion
|
|
3893
3904
|
//#region src/adapters/outbox.ts
|
|
3894
|
-
function
|
|
3905
|
+
function Cr(e) {
|
|
3895
3906
|
return {
|
|
3896
3907
|
...e,
|
|
3897
3908
|
payload: Q(e.payload, {})
|
|
3898
3909
|
};
|
|
3899
3910
|
}
|
|
3900
|
-
function
|
|
3911
|
+
function wr(e, t, n, r) {
|
|
3901
3912
|
return e.insert(Y).values({
|
|
3902
3913
|
id: t,
|
|
3903
3914
|
tenant_id: n,
|
|
@@ -3918,18 +3929,18 @@ function Cr(e, t, n, r) {
|
|
|
3918
3929
|
claim_expires_at: null
|
|
3919
3930
|
});
|
|
3920
3931
|
}
|
|
3921
|
-
function
|
|
3932
|
+
function Tr(e) {
|
|
3922
3933
|
return {
|
|
3923
3934
|
async create(t, n) {
|
|
3924
3935
|
let r = b();
|
|
3925
|
-
return await
|
|
3936
|
+
return await wr(e, r, t, n), r;
|
|
3926
3937
|
},
|
|
3927
3938
|
async getByIds(t) {
|
|
3928
|
-
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(
|
|
3939
|
+
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(Cr);
|
|
3929
3940
|
},
|
|
3930
3941
|
async getUnprocessed(n) {
|
|
3931
3942
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3932
|
-
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(
|
|
3943
|
+
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(Cr);
|
|
3933
3944
|
},
|
|
3934
3945
|
async claimEvents(n, r, i) {
|
|
3935
3946
|
if (n.length === 0) return [];
|
|
@@ -3999,10 +4010,10 @@ function wr(e) {
|
|
|
3999
4010
|
}
|
|
4000
4011
|
//#endregion
|
|
4001
4012
|
//#region src/adapters/users.ts
|
|
4002
|
-
function
|
|
4003
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4013
|
+
function Er(e, t, n) {
|
|
4014
|
+
return (n?.outboxEvents ?? []).map((n) => wr(e, n.id, t, n));
|
|
4004
4015
|
}
|
|
4005
|
-
var
|
|
4016
|
+
var Dr = [
|
|
4006
4017
|
"user_id",
|
|
4007
4018
|
"email",
|
|
4008
4019
|
"email_verified",
|
|
@@ -4024,23 +4035,23 @@ var Er = [
|
|
|
4024
4035
|
"login_count",
|
|
4025
4036
|
"created_at",
|
|
4026
4037
|
"updated_at"
|
|
4027
|
-
],
|
|
4038
|
+
], Or = [
|
|
4028
4039
|
"email",
|
|
4029
4040
|
"name",
|
|
4030
4041
|
"phone_number",
|
|
4031
4042
|
"user_id"
|
|
4032
|
-
],
|
|
4043
|
+
], kr = new Set([
|
|
4033
4044
|
"last_login",
|
|
4034
4045
|
"last_ip",
|
|
4035
4046
|
"login_count"
|
|
4036
|
-
]),
|
|
4047
|
+
]), Ar = o(j), jr = o(Oe), Mr = Object.fromEntries(Dr.map((e) => [e, e === "login_count" ? {
|
|
4037
4048
|
coalesce: Oe.login_count,
|
|
4038
4049
|
defaultValue: 0
|
|
4039
|
-
} :
|
|
4040
|
-
function
|
|
4050
|
+
} : kr.has(e) ? jr[e] : Ar[e]]));
|
|
4051
|
+
function Nr() {
|
|
4041
4052
|
return t(a(Oe.tenant_id, j.tenant_id), a(Oe.user_id, j.user_id));
|
|
4042
4053
|
}
|
|
4043
|
-
function
|
|
4054
|
+
function Pr(e, t) {
|
|
4044
4055
|
return {
|
|
4045
4056
|
...e,
|
|
4046
4057
|
last_login: t?.last_login,
|
|
@@ -4048,7 +4059,7 @@ function Nr(e, t) {
|
|
|
4048
4059
|
login_count: t?.login_count ?? 0
|
|
4049
4060
|
};
|
|
4050
4061
|
}
|
|
4051
|
-
function
|
|
4062
|
+
function Fr(e, t) {
|
|
4052
4063
|
let n = {
|
|
4053
4064
|
connection: e.connection,
|
|
4054
4065
|
provider: e.provider,
|
|
@@ -4061,8 +4072,8 @@ function Pr(e, t) {
|
|
|
4061
4072
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
4062
4073
|
}, n;
|
|
4063
4074
|
}
|
|
4064
|
-
function
|
|
4065
|
-
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p =
|
|
4075
|
+
function Ir(e, t = []) {
|
|
4076
|
+
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = Fr(e, !0), m = t.map((e) => Fr(e, !1));
|
|
4066
4077
|
return O({
|
|
4067
4078
|
...f,
|
|
4068
4079
|
email: e.email || "",
|
|
@@ -4076,7 +4087,7 @@ function Fr(e, t = []) {
|
|
|
4076
4087
|
identities: [p, ...m]
|
|
4077
4088
|
});
|
|
4078
4089
|
}
|
|
4079
|
-
function
|
|
4090
|
+
function Lr(e) {
|
|
4080
4091
|
let o = async (t, n, r) => {
|
|
4081
4092
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4082
4093
|
user_id: n.user_id,
|
|
@@ -4130,12 +4141,12 @@ function Ir(e) {
|
|
|
4130
4141
|
created_at: i,
|
|
4131
4142
|
updated_at: i
|
|
4132
4143
|
}));
|
|
4133
|
-
for (let n of
|
|
4134
|
-
c.length > 1 ? await
|
|
4144
|
+
for (let n of Er(e, t, r)) c.push(n);
|
|
4145
|
+
c.length > 1 ? await lt(e, c) : await e.insert(j).values(a);
|
|
4135
4146
|
} catch (e) {
|
|
4136
4147
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Ce(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Ce(500, { message: "Internal server error" }));
|
|
4137
4148
|
}
|
|
4138
|
-
return
|
|
4149
|
+
return Ir({
|
|
4139
4150
|
...a,
|
|
4140
4151
|
last_login: n.last_login,
|
|
4141
4152
|
last_ip: n.last_ip,
|
|
@@ -4146,10 +4157,10 @@ function Ir(e) {
|
|
|
4146
4157
|
create: o,
|
|
4147
4158
|
rawCreate: o,
|
|
4148
4159
|
async get(n, r) {
|
|
4149
|
-
let i = await e.select().from(j).leftJoin(Oe,
|
|
4160
|
+
let i = await e.select().from(j).leftJoin(Oe, Nr()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
4150
4161
|
if (!i) return null;
|
|
4151
4162
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
4152
|
-
return
|
|
4163
|
+
return Ir(Pr(i.users, i.user_activity), o);
|
|
4153
4164
|
},
|
|
4154
4165
|
async update(n, r, i, o) {
|
|
4155
4166
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4176,8 +4187,8 @@ function Ir(e) {
|
|
|
4176
4187
|
"zoneinfo"
|
|
4177
4188
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4178
4189
|
i.email_verified !== void 0 && (s.email_verified = i.email_verified), i.phone_verified !== void 0 && (s.phone_verified = i.phone_verified), i.is_social !== void 0 && (s.is_social = i.is_social), i.blocked !== void 0 && (s.blocked = i.blocked), i.app_metadata !== void 0 && (s.app_metadata = JSON.stringify(i.app_metadata)), i.user_metadata !== void 0 && (s.user_metadata = JSON.stringify(i.user_metadata)), i.address !== void 0 && (s.address = JSON.stringify(i.address)), i.profileData !== void 0 && (s.profileData = JSON.stringify(i.profileData));
|
|
4179
|
-
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l =
|
|
4180
|
-
return u = l.length > 0 ? (await
|
|
4190
|
+
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l = Er(e, n, o), u;
|
|
4191
|
+
return u = l.length > 0 ? (await lt(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await Sr(e).upsert(n, r, {
|
|
4181
4192
|
last_login: i.last_login,
|
|
4182
4193
|
last_ip: i.last_ip,
|
|
4183
4194
|
login_count: i.login_count
|
|
@@ -4186,24 +4197,24 @@ function Ir(e) {
|
|
|
4186
4197
|
async list(o, s) {
|
|
4187
4198
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(j.tenant_id, o), f(j.linked_to)];
|
|
4188
4199
|
if (m) {
|
|
4189
|
-
let e = _e(m,
|
|
4200
|
+
let e = _e(m, Dr);
|
|
4190
4201
|
if (e) {
|
|
4191
|
-
let t = nt(
|
|
4202
|
+
let t = nt(Mr, e, Or);
|
|
4192
4203
|
t && h.push(t);
|
|
4193
4204
|
}
|
|
4194
4205
|
}
|
|
4195
4206
|
let g = t(...h), _ = async (n) => {
|
|
4196
4207
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(j).where(t(a(j.tenant_id, o), l(j.linked_to, r))) : [];
|
|
4197
|
-
return n.map((e) =>
|
|
4208
|
+
return n.map((e) => Ir(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4198
4209
|
};
|
|
4199
|
-
if (
|
|
4210
|
+
if (mt(s)) {
|
|
4200
4211
|
if (p?.sort_by && p.sort_by !== "created_at") throw new Ce(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4201
4212
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4202
4213
|
sortColumn: j.created_at,
|
|
4203
4214
|
idColumn: j.user_id,
|
|
4204
4215
|
sortOrder: n,
|
|
4205
4216
|
sortKey: `created_at:${n}`
|
|
4206
|
-
}, i =
|
|
4217
|
+
}, i = ht(s), a = _t(s, r), { rows: o, next: c } = vt((await e.select().from(j).leftJoin(Oe, Nr()).where(a ? t(g, a) : g).orderBy(...gt(r)).limit(i + 1)).map((e) => Pr(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4207
4218
|
return {
|
|
4208
4219
|
users: l,
|
|
4209
4220
|
start: 0,
|
|
@@ -4212,17 +4223,17 @@ function Ir(e) {
|
|
|
4212
4223
|
next: c
|
|
4213
4224
|
};
|
|
4214
4225
|
}
|
|
4215
|
-
let v = e.select().from(j).leftJoin(Oe,
|
|
4226
|
+
let v = e.select().from(j).leftJoin(Oe, Nr()).where(g).$dynamic();
|
|
4216
4227
|
if (p?.sort_by) {
|
|
4217
|
-
let e =
|
|
4228
|
+
let e = Mr[p.sort_by];
|
|
4218
4229
|
if (e) {
|
|
4219
4230
|
let t = et(e) ? tt(e) : e;
|
|
4220
4231
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4221
4232
|
}
|
|
4222
4233
|
}
|
|
4223
|
-
let y = await _((await v.offset(c * u).limit(u)).map((e) =>
|
|
4234
|
+
let y = await _((await v.offset(c * u).limit(u)).map((e) => Pr(e.users, e.user_activity)));
|
|
4224
4235
|
if (!d) return { users: y };
|
|
4225
|
-
let [ee] = await e.select({ count: r() }).from(j).leftJoin(Oe,
|
|
4236
|
+
let [ee] = await e.select({ count: r() }).from(j).leftJoin(Oe, Nr()).where(g);
|
|
4226
4237
|
return {
|
|
4227
4238
|
users: y,
|
|
4228
4239
|
start: c * u,
|
|
@@ -4232,14 +4243,14 @@ function Ir(e) {
|
|
|
4232
4243
|
},
|
|
4233
4244
|
async remove(n, r, i) {
|
|
4234
4245
|
let o = await e.select({ user_id: j.user_id }).from(j).where(t(a(j.tenant_id, n), v(a(j.user_id, r), a(j.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 = [
|
|
4235
|
-
e.delete(
|
|
4246
|
+
e.delete(q).where(t(a(q.tenant_id, n), l(q.user_id, u))),
|
|
4236
4247
|
e.delete(M).where(t(a(M.tenant_id, n), l(M.user_id, u))),
|
|
4237
4248
|
e.delete(Oe).where(t(a(Oe.tenant_id, n), l(Oe.user_id, u))),
|
|
4238
4249
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4239
4250
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4240
4251
|
], f = d.length - 1;
|
|
4241
|
-
if (s) for (let t of
|
|
4242
|
-
let p = (await
|
|
4252
|
+
if (s) for (let t of Er(e, n, i)) d.push(t);
|
|
4253
|
+
let p = (await lt(e, d))[f];
|
|
4243
4254
|
return Array.isArray(p) && p.length > 0;
|
|
4244
4255
|
},
|
|
4245
4256
|
async unlink(n, r, i, o) {
|
|
@@ -4250,11 +4261,11 @@ function Ir(e) {
|
|
|
4250
4261
|
}
|
|
4251
4262
|
//#endregion
|
|
4252
4263
|
//#region src/adapters/userRoles.ts
|
|
4253
|
-
function
|
|
4264
|
+
function Rr(e) {
|
|
4254
4265
|
return {
|
|
4255
4266
|
async create(t, n, r, i) {
|
|
4256
4267
|
try {
|
|
4257
|
-
await e.insert(
|
|
4268
|
+
await e.insert(G).values({
|
|
4258
4269
|
tenant_id: t,
|
|
4259
4270
|
user_id: n,
|
|
4260
4271
|
role_id: r,
|
|
@@ -4268,11 +4279,11 @@ function Lr(e) {
|
|
|
4268
4279
|
return !0;
|
|
4269
4280
|
},
|
|
4270
4281
|
async list(n, r, i, o) {
|
|
4271
|
-
let s = [a(
|
|
4272
|
-
o !== void 0 && s.push(a(
|
|
4273
|
-
let c = await e.select({ role_id:
|
|
4282
|
+
let s = [a(G.tenant_id, n), a(G.user_id, r)];
|
|
4283
|
+
o !== void 0 && s.push(a(G.organization_id, o));
|
|
4284
|
+
let c = await e.select({ role_id: G.role_id }).from(G).where(t(...s)).all();
|
|
4274
4285
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4275
|
-
let i = await e.select().from(
|
|
4286
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r.role_id))).get();
|
|
4276
4287
|
if (!i) return null;
|
|
4277
4288
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4278
4289
|
return O({
|
|
@@ -4283,13 +4294,13 @@ function Lr(e) {
|
|
|
4283
4294
|
}))).filter(Boolean);
|
|
4284
4295
|
},
|
|
4285
4296
|
async listUsers(r, i, o) {
|
|
4286
|
-
let s = t(a(
|
|
4287
|
-
if (
|
|
4297
|
+
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4298
|
+
if (mt(o)) {
|
|
4288
4299
|
let n = {
|
|
4289
|
-
sortColumn:
|
|
4290
|
-
idColumn:
|
|
4300
|
+
sortColumn: G.user_id,
|
|
4301
|
+
idColumn: G.user_id,
|
|
4291
4302
|
sortOrder: "asc"
|
|
4292
|
-
}, r =
|
|
4303
|
+
}, r = _t(o, n), i = ht(o), { rows: a, next: c } = vt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...gt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4293
4304
|
return {
|
|
4294
4305
|
userIds: a.map((e) => e.user_id),
|
|
4295
4306
|
start: 0,
|
|
@@ -4298,7 +4309,7 @@ function Lr(e) {
|
|
|
4298
4309
|
next: c
|
|
4299
4310
|
};
|
|
4300
4311
|
}
|
|
4301
|
-
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id:
|
|
4312
|
+
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();
|
|
4302
4313
|
return {
|
|
4303
4314
|
userIds: d.map((e) => e.user_id),
|
|
4304
4315
|
start: u,
|
|
@@ -4307,13 +4318,13 @@ function Lr(e) {
|
|
|
4307
4318
|
};
|
|
4308
4319
|
},
|
|
4309
4320
|
async remove(n, r, i, o) {
|
|
4310
|
-
return (await e.delete(
|
|
4321
|
+
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;
|
|
4311
4322
|
}
|
|
4312
4323
|
};
|
|
4313
4324
|
}
|
|
4314
4325
|
//#endregion
|
|
4315
4326
|
//#region src/adapters/userOrganizations.ts
|
|
4316
|
-
function
|
|
4327
|
+
function zr(e) {
|
|
4317
4328
|
return {
|
|
4318
4329
|
async create(t, n) {
|
|
4319
4330
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4325,7 +4336,7 @@ function Rr(e) {
|
|
|
4325
4336
|
updated_at: r
|
|
4326
4337
|
};
|
|
4327
4338
|
try {
|
|
4328
|
-
await e.insert(
|
|
4339
|
+
await e.insert(U).values(i);
|
|
4329
4340
|
} catch (e) {
|
|
4330
4341
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "User organization already exists" }) : e;
|
|
4331
4342
|
}
|
|
@@ -4333,31 +4344,31 @@ function Rr(e) {
|
|
|
4333
4344
|
return o;
|
|
4334
4345
|
},
|
|
4335
4346
|
async get(n, r) {
|
|
4336
|
-
let i = await e.select().from(
|
|
4347
|
+
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
4337
4348
|
if (!i) return null;
|
|
4338
4349
|
let { tenant_id: o, ...s } = i;
|
|
4339
4350
|
return s;
|
|
4340
4351
|
},
|
|
4341
4352
|
async update(n, r, i) {
|
|
4342
4353
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4343
|
-
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(
|
|
4354
|
+
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;
|
|
4344
4355
|
},
|
|
4345
4356
|
async list(n, o) {
|
|
4346
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4357
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4347
4358
|
if (c) {
|
|
4348
|
-
let e = nt(
|
|
4359
|
+
let e = nt(U, c, ["user_id", "organization_id"]);
|
|
4349
4360
|
e && (u = t(l, e));
|
|
4350
4361
|
}
|
|
4351
4362
|
let d = (e) => {
|
|
4352
4363
|
let { tenant_id: t, ...n } = e;
|
|
4353
4364
|
return n;
|
|
4354
4365
|
};
|
|
4355
|
-
if (
|
|
4366
|
+
if (mt(o)) {
|
|
4356
4367
|
let n = {
|
|
4357
|
-
sortColumn:
|
|
4358
|
-
idColumn:
|
|
4368
|
+
sortColumn: U.created_at,
|
|
4369
|
+
idColumn: U.id,
|
|
4359
4370
|
sortOrder: "desc"
|
|
4360
|
-
}, r =
|
|
4371
|
+
}, r = _t(o, n), i = ht(o), { rows: a, next: s } = vt((await e.select().from(U).where(r ? t(u, r) : u).orderBy(...gt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4361
4372
|
return {
|
|
4362
4373
|
userOrganizations: a,
|
|
4363
4374
|
start: 0,
|
|
@@ -4366,9 +4377,9 @@ function Rr(e) {
|
|
|
4366
4377
|
next: s
|
|
4367
4378
|
};
|
|
4368
4379
|
}
|
|
4369
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4380
|
+
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);
|
|
4370
4381
|
if (!s) return { userOrganizations: h };
|
|
4371
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4382
|
+
let [g] = await e.select({ count: r() }).from(U).where(u);
|
|
4372
4383
|
return {
|
|
4373
4384
|
userOrganizations: h,
|
|
4374
4385
|
start: m,
|
|
@@ -4377,8 +4388,8 @@ function Rr(e) {
|
|
|
4377
4388
|
};
|
|
4378
4389
|
},
|
|
4379
4390
|
async listUserOrganizations(n, i, o) {
|
|
4380
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(
|
|
4381
|
-
let i = await e.select().from(
|
|
4391
|
+
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) => {
|
|
4392
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r.organization_id))).get();
|
|
4382
4393
|
if (!i) return null;
|
|
4383
4394
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4384
4395
|
return O({
|
|
@@ -4390,7 +4401,7 @@ function Rr(e) {
|
|
|
4390
4401
|
});
|
|
4391
4402
|
}))).filter(Boolean);
|
|
4392
4403
|
if (!l) return { organizations: d };
|
|
4393
|
-
let [f] = await e.select({ count: r() }).from(
|
|
4404
|
+
let [f] = await e.select({ count: r() }).from(U).where(t(a(U.tenant_id, n), a(U.user_id, i)));
|
|
4394
4405
|
return {
|
|
4395
4406
|
organizations: d,
|
|
4396
4407
|
start: s * c,
|
|
@@ -4399,25 +4410,25 @@ function Rr(e) {
|
|
|
4399
4410
|
};
|
|
4400
4411
|
},
|
|
4401
4412
|
async remove(n, r) {
|
|
4402
|
-
return (await e.delete(
|
|
4413
|
+
return (await e.delete(U).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4403
4414
|
}
|
|
4404
4415
|
};
|
|
4405
4416
|
}
|
|
4406
4417
|
//#endregion
|
|
4407
4418
|
//#region src/adapters/stats.ts
|
|
4408
|
-
var
|
|
4409
|
-
function
|
|
4419
|
+
var Br = ["s"], Vr = ["pwd_leak"];
|
|
4420
|
+
function Hr(e) {
|
|
4410
4421
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4411
4422
|
}
|
|
4412
|
-
function
|
|
4423
|
+
function Ur(e) {
|
|
4413
4424
|
return {
|
|
4414
4425
|
async getDaily(n, r) {
|
|
4415
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4426
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? Hr(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? Hr(r.to) : i.toISOString().split("T")[0];
|
|
4416
4427
|
return (await e.select({
|
|
4417
4428
|
date: y`substr(${J.date}, 1, 10)`.as("date"),
|
|
4418
|
-
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4429
|
+
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(Br.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4419
4430
|
signups: y`SUM(CASE WHEN ${J.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4420
|
-
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4431
|
+
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(Vr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4421
4432
|
}).from(J).where(t(a(J.tenant_id, n), c(J.date, o), h(J.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${J.date}, 1, 10)`).orderBy(y`substr(${J.date}, 1, 10)`).all()).map((e) => ({
|
|
4422
4433
|
date: e.date,
|
|
4423
4434
|
logins: Number(e.logins) || 0,
|
|
@@ -4428,14 +4439,14 @@ function Hr(e) {
|
|
|
4428
4439
|
}));
|
|
4429
4440
|
},
|
|
4430
4441
|
async getActiveUsers(n) {
|
|
4431
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(
|
|
4442
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(Br.map((e) => y`${e}`), y`, `)})`));
|
|
4432
4443
|
return Number(i?.count) || 0;
|
|
4433
4444
|
}
|
|
4434
4445
|
};
|
|
4435
4446
|
}
|
|
4436
4447
|
//#endregion
|
|
4437
4448
|
//#region src/adapters/analytics.ts
|
|
4438
|
-
var
|
|
4449
|
+
var Wr = {
|
|
4439
4450
|
"active-users": ["s", "seacft"],
|
|
4440
4451
|
logins: [
|
|
4441
4452
|
"s",
|
|
@@ -4465,7 +4476,7 @@ var Ur = {
|
|
|
4465
4476
|
"fvr"
|
|
4466
4477
|
],
|
|
4467
4478
|
"codes-sent": ["cls", "cs"]
|
|
4468
|
-
},
|
|
4479
|
+
}, Gr = {
|
|
4469
4480
|
"active-users": {
|
|
4470
4481
|
alias: "active_users",
|
|
4471
4482
|
type: "UInt64",
|
|
@@ -4522,7 +4533,7 @@ var Ur = {
|
|
|
4522
4533
|
agg: "count"
|
|
4523
4534
|
}
|
|
4524
4535
|
};
|
|
4525
|
-
function
|
|
4536
|
+
function Kr(e) {
|
|
4526
4537
|
switch (e) {
|
|
4527
4538
|
case "hour": return y`substr(${J.date}, 1, 13)`;
|
|
4528
4539
|
case "month": return y`substr(${J.date}, 1, 7)`;
|
|
@@ -4531,10 +4542,10 @@ function Gr(e) {
|
|
|
4531
4542
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4532
4543
|
}
|
|
4533
4544
|
}
|
|
4534
|
-
function
|
|
4545
|
+
function qr(e) {
|
|
4535
4546
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4536
4547
|
}
|
|
4537
|
-
function
|
|
4548
|
+
function Jr(e) {
|
|
4538
4549
|
switch (e) {
|
|
4539
4550
|
case "connection": return J.connection;
|
|
4540
4551
|
case "client_id": return J.client_id;
|
|
@@ -4543,9 +4554,9 @@ function qr(e) {
|
|
|
4543
4554
|
case "time": throw Error("time dimension handled separately");
|
|
4544
4555
|
}
|
|
4545
4556
|
}
|
|
4546
|
-
function
|
|
4557
|
+
function Yr(e) {
|
|
4547
4558
|
return { async query(n, r, i) {
|
|
4548
|
-
let o = Date.now(), s =
|
|
4559
|
+
let o = Date.now(), s = Wr[r], u = Gr[r], d = [
|
|
4549
4560
|
a(J.tenant_id, n),
|
|
4550
4561
|
c(J.date, i.from),
|
|
4551
4562
|
m(J.date, i.to),
|
|
@@ -4554,13 +4565,13 @@ function Jr(e) {
|
|
|
4554
4565
|
i.filters.connection?.length && d.push(l(J.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(J.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(J.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(J.user_id, i.filters.user_id));
|
|
4555
4566
|
let f = {}, p = [], h = [];
|
|
4556
4567
|
for (let e of i.group_by) if (e === "time") {
|
|
4557
|
-
let e =
|
|
4568
|
+
let e = Kr(i.interval);
|
|
4558
4569
|
f.time = e, p.push(e), h.push({
|
|
4559
4570
|
name: "time",
|
|
4560
4571
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4561
4572
|
});
|
|
4562
4573
|
} else {
|
|
4563
|
-
let t =
|
|
4574
|
+
let t = Jr(e);
|
|
4564
4575
|
f[e] = t, p.push(t), h.push({
|
|
4565
4576
|
name: e,
|
|
4566
4577
|
type: "String"
|
|
@@ -4576,9 +4587,9 @@ function Jr(e) {
|
|
|
4576
4587
|
if (i.order_by) {
|
|
4577
4588
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4578
4589
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4579
|
-
let n =
|
|
4590
|
+
let n = qr(t);
|
|
4580
4591
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4581
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4592
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${qr("time")} ASC`)) : g.orderBy(y.raw(`${qr(u.alias)} DESC`));
|
|
4582
4593
|
g = g.limit(i.limit).offset(i.offset);
|
|
4583
4594
|
let v = (await g.all()).map((e) => {
|
|
4584
4595
|
let t = {};
|
|
@@ -4599,10 +4610,10 @@ function Jr(e) {
|
|
|
4599
4610
|
}
|
|
4600
4611
|
//#endregion
|
|
4601
4612
|
//#region src/adapters/cleanup.ts
|
|
4602
|
-
var
|
|
4603
|
-
function
|
|
4613
|
+
var Xr = 10080 * 60 * 1e3;
|
|
4614
|
+
function Zr(e) {
|
|
4604
4615
|
return async (n) => {
|
|
4605
|
-
let r = Date.now() -
|
|
4616
|
+
let r = Date.now() - Xr;
|
|
4606
4617
|
try {
|
|
4607
4618
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4608
4619
|
n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i)), i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), n?.user_id && i.push(a(N.user_id, n.user_id)), await e.delete(N).where(t(...i)), i = [m(F.expires_at_ts, r)], n?.tenant_id && i.push(a(F.tenant_id, n.tenant_id)), await e.delete(F).where(t(...i));
|
|
@@ -4633,7 +4644,7 @@ var $ = w("tenant_operations", {
|
|
|
4633
4644
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4634
4645
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4635
4646
|
x("tenant_operations_status_idx").on(e.status)
|
|
4636
|
-
]),
|
|
4647
|
+
]), Qr = w("tenant_operation_events", {
|
|
4637
4648
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4638
4649
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4639
4650
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4645,7 +4656,7 @@ var $ = w("tenant_operations", {
|
|
|
4645
4656
|
columns: [e.operation_id],
|
|
4646
4657
|
foreignColumns: [$.id],
|
|
4647
4658
|
name: "tenant_operation_events_operation_id_constraint"
|
|
4648
|
-
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]),
|
|
4659
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), $r = w("rollouts", {
|
|
4649
4660
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4650
4661
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4651
4662
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4661,7 +4672,7 @@ var $ = w("tenant_operations", {
|
|
|
4661
4672
|
});
|
|
4662
4673
|
//#endregion
|
|
4663
4674
|
//#region src/adapters/tenantOperations.ts
|
|
4664
|
-
function
|
|
4675
|
+
function ei(e) {
|
|
4665
4676
|
return Se.parse({
|
|
4666
4677
|
id: e.id,
|
|
4667
4678
|
tenant_id: e.tenant_id,
|
|
@@ -4680,7 +4691,7 @@ function $r(e) {
|
|
|
4680
4691
|
finished_at: e.finished_at
|
|
4681
4692
|
});
|
|
4682
4693
|
}
|
|
4683
|
-
function
|
|
4694
|
+
function ti(e) {
|
|
4684
4695
|
return {
|
|
4685
4696
|
async create(t) {
|
|
4686
4697
|
let n = xe.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4707,7 +4718,7 @@ function ei(e) {
|
|
|
4707
4718
|
},
|
|
4708
4719
|
async get(t) {
|
|
4709
4720
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4710
|
-
return n[0] ?
|
|
4721
|
+
return n[0] ? ei(n[0]) : null;
|
|
4711
4722
|
},
|
|
4712
4723
|
async list(n = {}) {
|
|
4713
4724
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4718,7 +4729,7 @@ function ei(e) {
|
|
|
4718
4729
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4719
4730
|
let c = await e.select().from($).where(s.length ? t(...s) : void 0).orderBy(i($.created_at), i($.id)).offset(r * o).limit(o);
|
|
4720
4731
|
return {
|
|
4721
|
-
operations: c.map(
|
|
4732
|
+
operations: c.map(ei),
|
|
4722
4733
|
start: r * o,
|
|
4723
4734
|
limit: o,
|
|
4724
4735
|
length: c.length
|
|
@@ -4736,27 +4747,27 @@ function ei(e) {
|
|
|
4736
4747
|
}
|
|
4737
4748
|
//#endregion
|
|
4738
4749
|
//#region src/helpers/monotonic-id.ts
|
|
4739
|
-
var
|
|
4740
|
-
function
|
|
4750
|
+
var ni = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ri = 32, ii = 10, ai = 4, oi = 10;
|
|
4751
|
+
function si(e, t) {
|
|
4741
4752
|
let n = "";
|
|
4742
|
-
for (let r = t; r > 0; r--) n =
|
|
4753
|
+
for (let r = t; r > 0; r--) n = ni.charAt(e % ri) + n, e = Math.floor(e / ri);
|
|
4743
4754
|
return n;
|
|
4744
4755
|
}
|
|
4745
|
-
function
|
|
4746
|
-
let e = new Uint8Array(
|
|
4756
|
+
function ci() {
|
|
4757
|
+
let e = new Uint8Array(oi);
|
|
4747
4758
|
crypto.getRandomValues(e);
|
|
4748
4759
|
let t = "";
|
|
4749
|
-
for (let n = 0; n <
|
|
4760
|
+
for (let n = 0; n < oi; n++) t += ni.charAt(e[n] % ri);
|
|
4750
4761
|
return t;
|
|
4751
4762
|
}
|
|
4752
|
-
var
|
|
4753
|
-
function
|
|
4763
|
+
var li = 0, ui = 0;
|
|
4764
|
+
function di() {
|
|
4754
4765
|
let e = Date.now();
|
|
4755
|
-
return e ===
|
|
4766
|
+
return e === li ? ui++ : (li = e, ui = 0), si(e, ii) + si(ui, ai) + ci();
|
|
4756
4767
|
}
|
|
4757
4768
|
//#endregion
|
|
4758
4769
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4759
|
-
function
|
|
4770
|
+
function fi(e) {
|
|
4760
4771
|
if (!e) return null;
|
|
4761
4772
|
try {
|
|
4762
4773
|
let t = JSON.parse(e);
|
|
@@ -4764,22 +4775,22 @@ function di(e) {
|
|
|
4764
4775
|
} catch {}
|
|
4765
4776
|
return null;
|
|
4766
4777
|
}
|
|
4767
|
-
function
|
|
4778
|
+
function pi(e) {
|
|
4768
4779
|
return be.parse({
|
|
4769
4780
|
id: e.id,
|
|
4770
4781
|
operation_id: e.operation_id,
|
|
4771
4782
|
step: e.step,
|
|
4772
4783
|
outcome: e.outcome,
|
|
4773
|
-
detail:
|
|
4784
|
+
detail: fi(e.detail),
|
|
4774
4785
|
attempt: e.attempt,
|
|
4775
4786
|
created_at: e.created_at
|
|
4776
4787
|
});
|
|
4777
4788
|
}
|
|
4778
|
-
function
|
|
4789
|
+
function mi(e) {
|
|
4779
4790
|
return {
|
|
4780
4791
|
async create(t) {
|
|
4781
4792
|
let n = ye.parse(t), r = {
|
|
4782
|
-
id: `evt_${
|
|
4793
|
+
id: `evt_${di()}`,
|
|
4783
4794
|
operation_id: n.operation_id,
|
|
4784
4795
|
step: n.step,
|
|
4785
4796
|
outcome: n.outcome,
|
|
@@ -4787,7 +4798,7 @@ function pi(e) {
|
|
|
4787
4798
|
attempt: n.attempt,
|
|
4788
4799
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4789
4800
|
};
|
|
4790
|
-
return await e.insert(
|
|
4801
|
+
return await e.insert(Qr).values(r), be.parse({
|
|
4791
4802
|
id: r.id,
|
|
4792
4803
|
operation_id: r.operation_id,
|
|
4793
4804
|
step: r.step,
|
|
@@ -4798,9 +4809,9 @@ function pi(e) {
|
|
|
4798
4809
|
});
|
|
4799
4810
|
},
|
|
4800
4811
|
async listByOperation(t, r = {}) {
|
|
4801
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4812
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Qr).where(a(Qr.operation_id, t)).orderBy(n(Qr.created_at), n(Qr.id)).offset(i * o).limit(o);
|
|
4802
4813
|
return {
|
|
4803
|
-
events: s.map(
|
|
4814
|
+
events: s.map(pi),
|
|
4804
4815
|
start: i * o,
|
|
4805
4816
|
limit: o,
|
|
4806
4817
|
length: s.length
|
|
@@ -4810,7 +4821,7 @@ function pi(e) {
|
|
|
4810
4821
|
}
|
|
4811
4822
|
//#endregion
|
|
4812
4823
|
//#region src/adapters/rollouts.ts
|
|
4813
|
-
function
|
|
4824
|
+
function hi(e) {
|
|
4814
4825
|
if (!e) return null;
|
|
4815
4826
|
try {
|
|
4816
4827
|
return JSON.parse(e);
|
|
@@ -4818,7 +4829,7 @@ function mi(e) {
|
|
|
4818
4829
|
return null;
|
|
4819
4830
|
}
|
|
4820
4831
|
}
|
|
4821
|
-
function
|
|
4832
|
+
function gi(e) {
|
|
4822
4833
|
return ge.parse({
|
|
4823
4834
|
id: e.id,
|
|
4824
4835
|
kind: e.kind,
|
|
@@ -4826,15 +4837,15 @@ function hi(e) {
|
|
|
4826
4837
|
target_worker_version: e.target_worker_version,
|
|
4827
4838
|
target_database_version: e.target_database_version,
|
|
4828
4839
|
wave_size: e.wave_size,
|
|
4829
|
-
canary_tenant_ids:
|
|
4830
|
-
filter:
|
|
4840
|
+
canary_tenant_ids: hi(e.canary_tenant_ids),
|
|
4841
|
+
filter: hi(e.filter),
|
|
4831
4842
|
initiated_by: e.initiated_by,
|
|
4832
4843
|
created_at: e.created_at,
|
|
4833
4844
|
updated_at: e.updated_at,
|
|
4834
4845
|
finished_at: e.finished_at
|
|
4835
4846
|
});
|
|
4836
4847
|
}
|
|
4837
|
-
function
|
|
4848
|
+
function _i(e) {
|
|
4838
4849
|
return {
|
|
4839
4850
|
async create(t) {
|
|
4840
4851
|
let n = he.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4851,93 +4862,93 @@ function gi(e) {
|
|
|
4851
4862
|
updated_at: r,
|
|
4852
4863
|
finished_at: null
|
|
4853
4864
|
};
|
|
4854
|
-
await e.insert(
|
|
4865
|
+
await e.insert($r).values(i);
|
|
4855
4866
|
let a = await this.get(i.id);
|
|
4856
4867
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4857
4868
|
return a;
|
|
4858
4869
|
},
|
|
4859
4870
|
async get(t) {
|
|
4860
|
-
let n = await e.select().from(
|
|
4861
|
-
return n[0] ?
|
|
4871
|
+
let n = await e.select().from($r).where(a($r.id, t)).limit(1);
|
|
4872
|
+
return n[0] ? gi(n[0]) : null;
|
|
4862
4873
|
},
|
|
4863
4874
|
async list(t = {}) {
|
|
4864
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4875
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from($r).orderBy(i($r.created_at), i($r.id)).offset(n * r).limit(r);
|
|
4865
4876
|
return {
|
|
4866
|
-
rollouts: a.map(
|
|
4877
|
+
rollouts: a.map(gi),
|
|
4867
4878
|
start: n * r,
|
|
4868
4879
|
limit: r,
|
|
4869
4880
|
length: a.length
|
|
4870
4881
|
};
|
|
4871
4882
|
},
|
|
4872
4883
|
async update(t, n) {
|
|
4873
|
-
if ((await e.select({ id:
|
|
4884
|
+
if ((await e.select({ id: $r.id }).from($r).where(a($r.id, t)).limit(1)).length === 0) return !1;
|
|
4874
4885
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4875
|
-
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(
|
|
4886
|
+
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update($r).set(r).where(a($r.id, t)), !0;
|
|
4876
4887
|
},
|
|
4877
4888
|
async remove(t) {
|
|
4878
|
-
return (await e.select({ id:
|
|
4889
|
+
return (await e.select({ id: $r.id }).from($r).where(a($r.id, t)).limit(1)).length === 0 ? !1 : (await e.delete($r).where(a($r.id, t)), !0);
|
|
4879
4890
|
}
|
|
4880
4891
|
};
|
|
4881
4892
|
}
|
|
4882
4893
|
//#endregion
|
|
4883
4894
|
//#region src/adapters/index.ts
|
|
4884
|
-
function
|
|
4895
|
+
function vi(e, t = { useTransactions: !0 }) {
|
|
4885
4896
|
let n = {
|
|
4886
4897
|
actions: at(e),
|
|
4887
|
-
actionExecutions:
|
|
4888
|
-
actionVersions:
|
|
4889
|
-
branding:
|
|
4890
|
-
clients:
|
|
4891
|
-
clientConnections:
|
|
4892
|
-
clientGrants:
|
|
4893
|
-
clientRegistrationTokens:
|
|
4894
|
-
codes:
|
|
4895
|
-
connections:
|
|
4896
|
-
customDomains:
|
|
4897
|
-
customText:
|
|
4898
|
-
emailProviders:
|
|
4899
|
-
emailTemplates:
|
|
4900
|
-
flows:
|
|
4901
|
-
forms:
|
|
4902
|
-
grants:
|
|
4903
|
-
hookCode:
|
|
4904
|
-
hooks:
|
|
4905
|
-
invites:
|
|
4906
|
-
keys:
|
|
4907
|
-
loginSessions:
|
|
4908
|
-
logs:
|
|
4909
|
-
authenticationMethods:
|
|
4910
|
-
organizations:
|
|
4911
|
-
passwords:
|
|
4912
|
-
promptSettings:
|
|
4913
|
-
proxyRoutes:
|
|
4914
|
-
scimConfigurations:
|
|
4915
|
-
scimTokens:
|
|
4916
|
-
scimExternalIds:
|
|
4917
|
-
refreshTokens:
|
|
4918
|
-
resourceServers:
|
|
4919
|
-
rolePermissions:
|
|
4920
|
-
userPermissions:
|
|
4921
|
-
roles:
|
|
4922
|
-
sessions:
|
|
4923
|
-
sessionCleanup:
|
|
4924
|
-
tenants:
|
|
4898
|
+
actionExecutions: st(e),
|
|
4899
|
+
actionVersions: dt(e),
|
|
4900
|
+
branding: pt(e),
|
|
4901
|
+
clients: wt(e),
|
|
4902
|
+
clientConnections: Et(e),
|
|
4903
|
+
clientGrants: Ot(e),
|
|
4904
|
+
clientRegistrationTokens: Nt(e),
|
|
4905
|
+
codes: Lt(e),
|
|
4906
|
+
connections: Bt(e),
|
|
4907
|
+
customDomains: Ht(e),
|
|
4908
|
+
customText: Ut(e),
|
|
4909
|
+
emailProviders: Wt(e),
|
|
4910
|
+
emailTemplates: Kt(e),
|
|
4911
|
+
flows: Jt(e),
|
|
4912
|
+
forms: Zt(e),
|
|
4913
|
+
grants: tn(e),
|
|
4914
|
+
hookCode: on(e),
|
|
4915
|
+
hooks: un(e),
|
|
4916
|
+
invites: mn(e),
|
|
4917
|
+
keys: gn(e),
|
|
4918
|
+
loginSessions: xn(e),
|
|
4919
|
+
logs: Cn(e),
|
|
4920
|
+
authenticationMethods: On(e),
|
|
4921
|
+
organizations: Mn(e),
|
|
4922
|
+
passwords: Pn(e),
|
|
4923
|
+
promptSettings: Fn(e),
|
|
4924
|
+
proxyRoutes: zn(e),
|
|
4925
|
+
scimConfigurations: Un(e),
|
|
4926
|
+
scimTokens: Gn(e),
|
|
4927
|
+
scimExternalIds: qn(e),
|
|
4928
|
+
refreshTokens: Xn(e),
|
|
4929
|
+
resourceServers: nr(e),
|
|
4930
|
+
rolePermissions: rr(e),
|
|
4931
|
+
userPermissions: ir(e),
|
|
4932
|
+
roles: or(e),
|
|
4933
|
+
sessions: dr(e),
|
|
4934
|
+
sessionCleanup: Zr(e),
|
|
4935
|
+
tenants: gr(e),
|
|
4925
4936
|
...t.controlPlane ? {
|
|
4926
|
-
tenantOperations:
|
|
4927
|
-
tenantOperationEvents:
|
|
4928
|
-
rollouts:
|
|
4937
|
+
tenantOperations: ti(e),
|
|
4938
|
+
tenantOperationEvents: mi(e),
|
|
4939
|
+
rollouts: _i(e)
|
|
4929
4940
|
} : {},
|
|
4930
|
-
themes:
|
|
4931
|
-
universalLoginTemplates:
|
|
4932
|
-
users:
|
|
4933
|
-
userActivity:
|
|
4934
|
-
userRoles:
|
|
4935
|
-
userOrganizations:
|
|
4936
|
-
stats:
|
|
4937
|
-
analytics:
|
|
4938
|
-
outbox:
|
|
4941
|
+
themes: yr(e),
|
|
4942
|
+
universalLoginTemplates: br(e),
|
|
4943
|
+
users: Lr(e),
|
|
4944
|
+
userActivity: Sr(e),
|
|
4945
|
+
userRoles: Rr(e),
|
|
4946
|
+
userOrganizations: zr(e),
|
|
4947
|
+
stats: Ur(e),
|
|
4948
|
+
analytics: Yr(e),
|
|
4949
|
+
outbox: Tr(e),
|
|
4939
4950
|
async transaction(r) {
|
|
4940
|
-
if (t.useTransactions === !1 ||
|
|
4951
|
+
if (t.useTransactions === !1 || ct(e)) return r(n);
|
|
4941
4952
|
await e.run(y`BEGIN`);
|
|
4942
4953
|
try {
|
|
4943
4954
|
let t = await r(n);
|
|
@@ -4951,7 +4962,7 @@ function _i(e, t = { useTransactions: !0 }) {
|
|
|
4951
4962
|
}
|
|
4952
4963
|
//#endregion
|
|
4953
4964
|
//#region src/adapters/resolveHost.ts
|
|
4954
|
-
function
|
|
4965
|
+
function yi(e) {
|
|
4955
4966
|
if (!e) return { path: "/*" };
|
|
4956
4967
|
try {
|
|
4957
4968
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -4959,7 +4970,7 @@ function vi(e) {
|
|
|
4959
4970
|
} catch {}
|
|
4960
4971
|
return { path: "/*" };
|
|
4961
4972
|
}
|
|
4962
|
-
function
|
|
4973
|
+
function bi(e) {
|
|
4963
4974
|
if (!e) return [];
|
|
4964
4975
|
try {
|
|
4965
4976
|
let t = JSON.parse(e);
|
|
@@ -4974,20 +4985,20 @@ function yi(e) {
|
|
|
4974
4985
|
return [];
|
|
4975
4986
|
}
|
|
4976
4987
|
}
|
|
4977
|
-
async function
|
|
4988
|
+
async function xi(e, r) {
|
|
4978
4989
|
let i = r.toLowerCase(), o = (await e.select({
|
|
4979
|
-
custom_domain_id:
|
|
4980
|
-
tenant_id:
|
|
4981
|
-
domain:
|
|
4982
|
-
}).from(
|
|
4990
|
+
custom_domain_id: Me.custom_domain_id,
|
|
4991
|
+
tenant_id: Me.tenant_id,
|
|
4992
|
+
domain: Me.domain
|
|
4993
|
+
}).from(Me).where(a(Me.domain, i)).limit(1))[0];
|
|
4983
4994
|
if (!o) return null;
|
|
4984
4995
|
let s = (await e.select().from(X).where(t(a(X.tenant_id, o.tenant_id), a(X.custom_domain_id, o.custom_domain_id))).orderBy(n(X.priority), n(X.created_at))).map((e) => ({
|
|
4985
4996
|
id: e.id,
|
|
4986
4997
|
tenant_id: e.tenant_id,
|
|
4987
4998
|
custom_domain_id: e.custom_domain_id,
|
|
4988
4999
|
priority: e.priority,
|
|
4989
|
-
match:
|
|
4990
|
-
handlers:
|
|
5000
|
+
match: yi(e.match),
|
|
5001
|
+
handlers: bi(e.handlers),
|
|
4991
5002
|
created_at: e.created_at,
|
|
4992
5003
|
updated_at: e.updated_at
|
|
4993
5004
|
}));
|
|
@@ -5000,11 +5011,11 @@ async function bi(e, r) {
|
|
|
5000
5011
|
}
|
|
5001
5012
|
//#endregion
|
|
5002
5013
|
//#region src/adapters/proxyData.ts
|
|
5003
|
-
function
|
|
5014
|
+
function Si(e) {
|
|
5004
5015
|
return {
|
|
5005
|
-
proxyRoutes:
|
|
5006
|
-
resolveHost: (t) =>
|
|
5016
|
+
proxyRoutes: zn(e),
|
|
5017
|
+
resolveHost: (t) => xi(e, t)
|
|
5007
5018
|
};
|
|
5008
5019
|
}
|
|
5009
5020
|
//#endregion
|
|
5010
|
-
export {
|
|
5021
|
+
export { Si as createProxyDataAdapter, zn as createProxyRoutesAdapter, vi as default, Ze as sqlite };
|