@authhero/drizzle 1.14.0 → 1.15.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 +854 -799
- package/drizzle/0012_config_inheritance.sql +32 -0
- package/drizzle/meta/0012_snapshot.json +7209 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +3 -3
- package/src/schema/sqlite/actions.ts +2 -0
- package/src/schema/sqlite/branding.ts +5 -0
- package/src/schema/sqlite/configInheritance.ts +18 -0
- package/src/schema/sqlite/connections.ts +2 -0
- package/src/schema/sqlite/roles.ts +2 -0
- package/src/schema/sqlite/tenants.ts +1 -0
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -14,6 +14,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
14
14
|
return t || ze(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
15
15
|
}, O = w("tenants", {
|
|
16
16
|
id: T("id", { length: 191 }).primaryKey(),
|
|
17
|
+
parent_tenant_id: T("parent_tenant_id", { length: 191 }),
|
|
17
18
|
name: T("name", { length: 255 }),
|
|
18
19
|
audience: T("audience", { length: 255 }),
|
|
19
20
|
sender_email: T("sender_email", { length: 255 }),
|
|
@@ -67,6 +68,24 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
67
68
|
worker_script_name: T("worker_script_name", { length: 255 }),
|
|
68
69
|
storage_kind: T("storage_kind", { length: 32 }),
|
|
69
70
|
d1_database_id: T("d1_database_id", { length: 64 })
|
|
71
|
+
}), Ve = () => ({
|
|
72
|
+
scope: T("scope", {
|
|
73
|
+
length: 16,
|
|
74
|
+
enum: [
|
|
75
|
+
"local",
|
|
76
|
+
"shared",
|
|
77
|
+
"platform"
|
|
78
|
+
]
|
|
79
|
+
}),
|
|
80
|
+
override: T("override", {
|
|
81
|
+
length: 16,
|
|
82
|
+
enum: [
|
|
83
|
+
"none",
|
|
84
|
+
"secrets",
|
|
85
|
+
"fields"
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
enforce: S("enforce", { mode: "boolean" })
|
|
70
89
|
}), k = w("actions", {
|
|
71
90
|
id: T("id", { length: 255 }).notNull(),
|
|
72
91
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -80,6 +99,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
80
99
|
deployed_at_ts: S("deployed_at_ts"),
|
|
81
100
|
is_system: S("is_system"),
|
|
82
101
|
inherit: S("inherit"),
|
|
102
|
+
...Ve(),
|
|
83
103
|
created_at_ts: S("created_at_ts").notNull(),
|
|
84
104
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
85
105
|
}, (e) => [
|
|
@@ -89,7 +109,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
89
109
|
}),
|
|
90
110
|
x("idx_actions_tenant_id").on(e.tenant_id),
|
|
91
111
|
x("idx_actions_name").on(e.tenant_id, e.name)
|
|
92
|
-
]),
|
|
112
|
+
]), He = w("action_versions", {
|
|
93
113
|
id: T("id", { length: 255 }).notNull(),
|
|
94
114
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
95
115
|
action_id: T("action_id", { length: 255 }).notNull(),
|
|
@@ -109,7 +129,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
109
129
|
}),
|
|
110
130
|
re("uq_action_versions_number").on(e.tenant_id, e.action_id, e.number),
|
|
111
131
|
x("idx_action_versions_action_id").on(e.tenant_id, e.action_id)
|
|
112
|
-
]),
|
|
132
|
+
]), Ue = w("action_executions", {
|
|
113
133
|
id: T("id", { length: 255 }).notNull(),
|
|
114
134
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
115
135
|
trigger_id: T("trigger_id", { length: 255 }).notNull(),
|
|
@@ -175,7 +195,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
175
195
|
password: T("password", { length: 255 }).notNull(),
|
|
176
196
|
algorithm: T("algorithm", { length: 16 }).notNull().default("bcrypt"),
|
|
177
197
|
is_current: S("is_current").notNull().default(1)
|
|
178
|
-
}),
|
|
198
|
+
}), We = w("user_activity", {
|
|
179
199
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
180
200
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
181
201
|
last_login: T("last_login", { length: 35 }),
|
|
@@ -298,7 +318,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
298
318
|
}, (e) => [C({
|
|
299
319
|
columns: [e.code_id, e.code_type],
|
|
300
320
|
name: "PK_codes_code_id_code_type"
|
|
301
|
-
}), x("codes_expires_at_index").on(e.expires_at)]),
|
|
321
|
+
}), x("codes_expires_at_index").on(e.expires_at)]), Ge = w("authentication_codes", {
|
|
302
322
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
303
323
|
code: T("code", { length: 255 }).primaryKey(),
|
|
304
324
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -312,7 +332,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
312
332
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
313
333
|
expires_at: T("expires_at", { length: 35 }).notNull(),
|
|
314
334
|
used_at: T("used_at", { length: 35 })
|
|
315
|
-
}),
|
|
335
|
+
}), Ke = w("otps", {
|
|
316
336
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
317
337
|
id: T("id", { length: 255 }).primaryKey(),
|
|
318
338
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -331,7 +351,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
331
351
|
used_at: T("used_at", { length: 35 }),
|
|
332
352
|
audience: T("audience", { length: 255 }),
|
|
333
353
|
ip: T("ip", { length: 64 })
|
|
334
|
-
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]),
|
|
354
|
+
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), qe = w("tickets", {
|
|
335
355
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
336
356
|
id: T("id", { length: 255 }).primaryKey(),
|
|
337
357
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -419,7 +439,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
419
439
|
expires_at_ts: S("expires_at_ts"),
|
|
420
440
|
created_at_ts: S("created_at_ts").notNull(),
|
|
421
441
|
revoked_at_ts: S("revoked_at_ts")
|
|
422
|
-
}, (e) => [re("idx_client_registration_tokens_hash").on(e.tenant_id, e.token_hash), x("idx_client_registration_tokens_client").on(e.tenant_id, e.client_id)]),
|
|
442
|
+
}, (e) => [re("idx_client_registration_tokens_hash").on(e.tenant_id, e.token_hash), x("idx_client_registration_tokens_client").on(e.tenant_id, e.client_id)]), Je = w("client_grants", {
|
|
423
443
|
id: T("id", { length: 21 }).notNull(),
|
|
424
444
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
425
445
|
client_id: T("client_id", { length: 191 }).notNull(),
|
|
@@ -470,12 +490,13 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
470
490
|
is_domain_connection: S("is_domain_connection"),
|
|
471
491
|
show_as_button: S("show_as_button"),
|
|
472
492
|
is_system: S("is_system").notNull().default(0),
|
|
493
|
+
...Ve(),
|
|
473
494
|
metadata: T("metadata", { length: 4096 })
|
|
474
495
|
}, (e) => [
|
|
475
496
|
C({ columns: [e.tenant_id, e.id] }),
|
|
476
497
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
477
498
|
re("connections_id_unique").on(e.id)
|
|
478
|
-
]),
|
|
499
|
+
]), Ye = w("custom_domains", {
|
|
479
500
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
480
501
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
481
502
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -489,7 +510,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
489
510
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
490
511
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
491
512
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
492
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
513
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), Xe = w("domains", {
|
|
493
514
|
id: T("id", { length: 255 }).primaryKey(),
|
|
494
515
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
495
516
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -522,7 +543,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
522
543
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
523
544
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
524
545
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
525
|
-
]),
|
|
546
|
+
]), Ze = w("invites", {
|
|
526
547
|
id: T("id", { length: 21 }).primaryKey(),
|
|
527
548
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
528
549
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -544,7 +565,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
544
565
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
545
566
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
546
567
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
547
|
-
]),
|
|
568
|
+
]), Qe = w("organization_connections", {
|
|
548
569
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
549
570
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
550
571
|
connection_id: T("connection_id", { length: 191 }).notNull(),
|
|
@@ -587,7 +608,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
587
608
|
}),
|
|
588
609
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
589
610
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
590
|
-
]),
|
|
611
|
+
]), $e = w("user_permissions", {
|
|
591
612
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
592
613
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
593
614
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -642,14 +663,16 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
642
663
|
verification_key: T("verification_key", { length: 4096 }),
|
|
643
664
|
options: T("options", { length: 4096 }),
|
|
644
665
|
is_system: S("is_system").notNull().default(0),
|
|
666
|
+
...Ve(),
|
|
645
667
|
metadata: T("metadata", { length: 4096 }),
|
|
646
668
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
647
669
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
648
670
|
}, (e) => [C({
|
|
649
671
|
columns: [e.tenant_id, e.id],
|
|
650
672
|
name: "resource_servers_pk"
|
|
651
|
-
})]),
|
|
673
|
+
})]), et = w("branding", {
|
|
652
674
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
675
|
+
...Ve(),
|
|
653
676
|
logo_url: T("logo_url", { length: 512 }),
|
|
654
677
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
655
678
|
font_url: T("font_url", { length: 512 }),
|
|
@@ -659,12 +682,12 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
659
682
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
660
683
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
661
684
|
dark_mode: T("dark_mode", { length: 8 })
|
|
662
|
-
}),
|
|
685
|
+
}), tt = w("universal_login_templates", {
|
|
663
686
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
664
687
|
body: T("body").notNull(),
|
|
665
688
|
created_at_ts: S("created_at_ts").notNull(),
|
|
666
689
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
667
|
-
}),
|
|
690
|
+
}), nt = w("themes", {
|
|
668
691
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
669
692
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
670
693
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -724,7 +747,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
724
747
|
}, (e) => [C({
|
|
725
748
|
columns: [e.tenant_id, e.themeId],
|
|
726
749
|
name: "themes_pkey"
|
|
727
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
750
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), rt = w("forms", {
|
|
728
751
|
id: T("id", { length: 255 }).primaryKey(),
|
|
729
752
|
name: T("name", { length: 255 }).notNull(),
|
|
730
753
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -737,22 +760,24 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
737
760
|
style: T("style", { length: 1042 }),
|
|
738
761
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
739
762
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
740
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
763
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), it = w("flows", {
|
|
741
764
|
id: T("id", { length: 24 }).primaryKey(),
|
|
742
765
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
743
766
|
name: T("name", { length: 150 }).notNull(),
|
|
744
767
|
actions: T("actions"),
|
|
745
768
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
746
769
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
747
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
770
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), at = w("prompt_settings", {
|
|
748
771
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
772
|
+
...Ve(),
|
|
749
773
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
750
774
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
751
775
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
752
776
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
753
777
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
754
|
-
}),
|
|
778
|
+
}), ot = w("email_providers", {
|
|
755
779
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
780
|
+
...Ve(),
|
|
756
781
|
name: T("name", { length: 255 }).notNull(),
|
|
757
782
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
758
783
|
default_from_address: T("default_from_address", { length: 255 }),
|
|
@@ -760,7 +785,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
760
785
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
761
786
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
762
787
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
763
|
-
}),
|
|
788
|
+
}), st = w("email_templates", {
|
|
764
789
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
765
790
|
template: T("template", { length: 64 }).notNull(),
|
|
766
791
|
body: T("body").notNull(),
|
|
@@ -773,7 +798,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
773
798
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
774
799
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
775
800
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
776
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
801
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), ct = w("hooks", {
|
|
777
802
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
778
803
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
779
804
|
url: T("url", { length: 512 }),
|
|
@@ -788,15 +813,16 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
788
813
|
code_id: T("code_id", { length: 21 }),
|
|
789
814
|
page_id: T("page_id", { length: 64 }),
|
|
790
815
|
permission_required: T("permission_required", { length: 255 }),
|
|
791
|
-
metadata: T("metadata")
|
|
792
|
-
|
|
816
|
+
metadata: T("metadata"),
|
|
817
|
+
...Ve()
|
|
818
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), lt = w("hook_code", {
|
|
793
819
|
id: T("id", { length: 21 }).primaryKey(),
|
|
794
820
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
795
821
|
code: T("code").notNull(),
|
|
796
822
|
secrets: T("secrets"),
|
|
797
823
|
created_at_ts: S("created_at_ts").notNull(),
|
|
798
824
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
799
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
825
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), ut = w("keys", {
|
|
800
826
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
801
827
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
802
828
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -809,7 +835,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
809
835
|
current_until: T("current_until", { length: 35 }),
|
|
810
836
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
811
837
|
connection: T("connection", { length: 255 }).references(() => z.id, { onDelete: "cascade" })
|
|
812
|
-
}),
|
|
838
|
+
}), dt = w("custom_text", {
|
|
813
839
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
814
840
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
815
841
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -820,13 +846,13 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
820
846
|
e.tenant_id,
|
|
821
847
|
e.prompt,
|
|
822
848
|
e.language
|
|
823
|
-
] })]),
|
|
849
|
+
] })]), ft = w("prompt_partials", {
|
|
824
850
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
825
851
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
826
852
|
body: T("body").notNull(),
|
|
827
853
|
created_at_ts: S("created_at_ts").notNull(),
|
|
828
854
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
829
|
-
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]),
|
|
855
|
+
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), pt = w("authentication_methods", {
|
|
830
856
|
id: T("id", { length: 26 }).primaryKey(),
|
|
831
857
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
832
858
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -908,7 +934,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
908
934
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
909
935
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
910
936
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
911
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
937
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), mt = w("scim_configurations", {
|
|
912
938
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
913
939
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
914
940
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -928,7 +954,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
928
954
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
929
955
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
930
956
|
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
931
|
-
]),
|
|
957
|
+
]), ht = w("scim_external_ids", {
|
|
932
958
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
933
959
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
934
960
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -938,7 +964,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
938
964
|
e.tenant_id,
|
|
939
965
|
e.connection_id,
|
|
940
966
|
e.user_id
|
|
941
|
-
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
967
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), gt = w("token_exchange_profiles", {
|
|
942
968
|
id: T("id", { length: 64 }).primaryKey(),
|
|
943
969
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
944
970
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -948,7 +974,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
948
974
|
jwt_verification: T("jwt_verification"),
|
|
949
975
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
950
976
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
951
|
-
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]),
|
|
977
|
+
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), _t = w("log_streams", {
|
|
952
978
|
id: T("id", { length: 64 }).primaryKey(),
|
|
953
979
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
954
980
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -959,7 +985,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
959
985
|
is_priority: S("is_priority"),
|
|
960
986
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
961
987
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
962
|
-
}, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]),
|
|
988
|
+
}, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]), vt = w("migration_sources", {
|
|
963
989
|
id: T("id", { length: 64 }).primaryKey(),
|
|
964
990
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
965
991
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -969,58 +995,58 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
969
995
|
credentials: T("credentials").notNull(),
|
|
970
996
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
971
997
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
972
|
-
}, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]),
|
|
973
|
-
actionExecutions: () =>
|
|
974
|
-
actionVersions: () =>
|
|
998
|
+
}, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]), yt = /* @__PURE__ */ Be({
|
|
999
|
+
actionExecutions: () => Ue,
|
|
1000
|
+
actionVersions: () => He,
|
|
975
1001
|
actions: () => k,
|
|
976
|
-
authenticationCodes: () =>
|
|
977
|
-
authenticationMethods: () =>
|
|
978
|
-
branding: () =>
|
|
979
|
-
clientGrants: () =>
|
|
1002
|
+
authenticationCodes: () => Ge,
|
|
1003
|
+
authenticationMethods: () => pt,
|
|
1004
|
+
branding: () => et,
|
|
1005
|
+
clientGrants: () => Je,
|
|
980
1006
|
clientRegistrationTokens: () => L,
|
|
981
1007
|
clients: () => I,
|
|
982
1008
|
codes: () => F,
|
|
983
1009
|
connections: () => z,
|
|
984
|
-
customDomains: () =>
|
|
985
|
-
customText: () =>
|
|
986
|
-
domains: () =>
|
|
987
|
-
emailProviders: () =>
|
|
988
|
-
emailTemplates: () =>
|
|
989
|
-
flows: () =>
|
|
990
|
-
forms: () =>
|
|
1010
|
+
customDomains: () => Ye,
|
|
1011
|
+
customText: () => dt,
|
|
1012
|
+
domains: () => Xe,
|
|
1013
|
+
emailProviders: () => ot,
|
|
1014
|
+
emailTemplates: () => st,
|
|
1015
|
+
flows: () => it,
|
|
1016
|
+
forms: () => rt,
|
|
991
1017
|
grants: () => R,
|
|
992
|
-
hookCode: () =>
|
|
993
|
-
hooks: () =>
|
|
994
|
-
invites: () =>
|
|
995
|
-
keys: () =>
|
|
996
|
-
logStreams: () =>
|
|
1018
|
+
hookCode: () => lt,
|
|
1019
|
+
hooks: () => ct,
|
|
1020
|
+
invites: () => Ze,
|
|
1021
|
+
keys: () => ut,
|
|
1022
|
+
logStreams: () => _t,
|
|
997
1023
|
loginSessions: () => P,
|
|
998
1024
|
logs: () => K,
|
|
999
|
-
migrationSources: () =>
|
|
1000
|
-
organizationConnections: () =>
|
|
1025
|
+
migrationSources: () => vt,
|
|
1026
|
+
organizationConnections: () => Qe,
|
|
1001
1027
|
organizations: () => B,
|
|
1002
|
-
otps: () =>
|
|
1028
|
+
otps: () => Ke,
|
|
1003
1029
|
outboxEvents: () => q,
|
|
1004
1030
|
passwords: () => j,
|
|
1005
|
-
promptPartials: () =>
|
|
1006
|
-
promptSettings: () =>
|
|
1031
|
+
promptPartials: () => ft,
|
|
1032
|
+
promptSettings: () => at,
|
|
1007
1033
|
proxyRoutes: () => J,
|
|
1008
1034
|
refreshTokens: () => N,
|
|
1009
1035
|
resourceServers: () => G,
|
|
1010
1036
|
rolePermissions: () => U,
|
|
1011
1037
|
roles: () => H,
|
|
1012
|
-
scimConfigurations: () =>
|
|
1013
|
-
scimExternalIds: () =>
|
|
1038
|
+
scimConfigurations: () => mt,
|
|
1039
|
+
scimExternalIds: () => ht,
|
|
1014
1040
|
scimTokens: () => Y,
|
|
1015
1041
|
sessions: () => M,
|
|
1016
1042
|
tenants: () => O,
|
|
1017
|
-
themes: () =>
|
|
1018
|
-
tickets: () =>
|
|
1019
|
-
tokenExchangeProfiles: () =>
|
|
1020
|
-
universalLoginTemplates: () =>
|
|
1021
|
-
userActivity: () =>
|
|
1043
|
+
themes: () => nt,
|
|
1044
|
+
tickets: () => qe,
|
|
1045
|
+
tokenExchangeProfiles: () => gt,
|
|
1046
|
+
universalLoginTemplates: () => tt,
|
|
1047
|
+
userActivity: () => We,
|
|
1022
1048
|
userOrganizations: () => V,
|
|
1023
|
-
userPermissions: () =>
|
|
1049
|
+
userPermissions: () => $e,
|
|
1024
1050
|
userRoles: () => W,
|
|
1025
1051
|
users: () => A
|
|
1026
1052
|
});
|
|
@@ -1035,14 +1061,14 @@ function X(e, t) {
|
|
|
1035
1061
|
}
|
|
1036
1062
|
return e;
|
|
1037
1063
|
}
|
|
1038
|
-
function
|
|
1064
|
+
function bt(e, t = "", n = {}) {
|
|
1039
1065
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
1040
1066
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
1041
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
1067
|
+
typeof a == "object" && a && !Array.isArray(a) ? bt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
1042
1068
|
}
|
|
1043
1069
|
return n;
|
|
1044
1070
|
}
|
|
1045
|
-
function
|
|
1071
|
+
function xt(e, t) {
|
|
1046
1072
|
let n = {};
|
|
1047
1073
|
for (let [r, i] of Object.entries(e)) {
|
|
1048
1074
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -1059,13 +1085,13 @@ function bt(e, t) {
|
|
|
1059
1085
|
}
|
|
1060
1086
|
//#endregion
|
|
1061
1087
|
//#region src/helpers/filter.ts
|
|
1062
|
-
function
|
|
1088
|
+
function St(e) {
|
|
1063
1089
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1064
1090
|
}
|
|
1065
|
-
function
|
|
1091
|
+
function Ct(e) {
|
|
1066
1092
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1067
1093
|
}
|
|
1068
|
-
function
|
|
1094
|
+
function wt(n, r, i, l = []) {
|
|
1069
1095
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1070
1096
|
let t = Number(e);
|
|
1071
1097
|
return Number.isFinite(t) ? t : e;
|
|
@@ -1078,7 +1104,7 @@ function Ct(n, r, i, l = []) {
|
|
|
1078
1104
|
let [, r, i] = n;
|
|
1079
1105
|
if (!r || !i) return null;
|
|
1080
1106
|
let o = r.trim(), s = Le(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1081
|
-
return
|
|
1107
|
+
return St(c) ? a(Ct(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1082
1108
|
}).filter((e) => e !== null);
|
|
1083
1109
|
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1084
1110
|
}).filter((e) => e !== null);
|
|
@@ -1101,12 +1127,12 @@ function Ct(n, r, i, l = []) {
|
|
|
1101
1127
|
};
|
|
1102
1128
|
}), C = [];
|
|
1103
1129
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1104
|
-
let i = ee[t], v =
|
|
1130
|
+
let i = ee[t], v = St(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1105
1131
|
if (!te) {
|
|
1106
1132
|
o ? C.push(r ? y`${y.identifier(t)} IS NULL` : y`${y.identifier(t)} IS NOT NULL`) : C.push(y`${y.identifier(t)} ${y.raw(r ? "!=" : l ?? "=")} ${n}`);
|
|
1107
1133
|
continue;
|
|
1108
1134
|
}
|
|
1109
|
-
let S = v ?
|
|
1135
|
+
let S = v ? Ct(i) : y`${te}`;
|
|
1110
1136
|
if (o) C.push(r ? f(te) : d(te));
|
|
1111
1137
|
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1112
1138
|
else if (r) switch (l) {
|
|
@@ -1155,18 +1181,18 @@ function Ct(n, r, i, l = []) {
|
|
|
1155
1181
|
}
|
|
1156
1182
|
//#endregion
|
|
1157
1183
|
//#region src/helpers/paginate.ts
|
|
1158
|
-
function
|
|
1184
|
+
function Tt(e) {
|
|
1159
1185
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1160
1186
|
}
|
|
1161
1187
|
function Z(e) {
|
|
1162
1188
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1163
1189
|
return n >= 1 ? n : 50;
|
|
1164
1190
|
}
|
|
1165
|
-
function
|
|
1191
|
+
function Et(e) {
|
|
1166
1192
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1167
1193
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1168
1194
|
}
|
|
1169
|
-
function
|
|
1195
|
+
function Dt(e, t) {
|
|
1170
1196
|
let n = e?.from ? ge(e.from) : null;
|
|
1171
1197
|
if (!n) return;
|
|
1172
1198
|
if (n.k !== t.sortKey) throw new Re(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
@@ -1174,7 +1200,7 @@ function Et(e, t) {
|
|
|
1174
1200
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1175
1201
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1176
1202
|
}
|
|
1177
|
-
function
|
|
1203
|
+
function Ot(e, t, n, r = "id", i) {
|
|
1178
1204
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1179
1205
|
if (a && c) {
|
|
1180
1206
|
let e = c[n];
|
|
@@ -1191,28 +1217,31 @@ function Dt(e, t, n, r = "id", i) {
|
|
|
1191
1217
|
}
|
|
1192
1218
|
//#endregion
|
|
1193
1219
|
//#region src/adapters/actions.ts
|
|
1194
|
-
function
|
|
1220
|
+
function kt(e) {
|
|
1195
1221
|
let t = X(e);
|
|
1196
1222
|
return Array.isArray(t) ? t : [];
|
|
1197
1223
|
}
|
|
1198
|
-
function
|
|
1199
|
-
let { created_at_ts: t, updated_at_ts: n, deployed_at_ts: r, secrets: i, dependencies: a, supported_triggers: o, is_system: s, inherit: c,
|
|
1224
|
+
function At(e) {
|
|
1225
|
+
let { created_at_ts: t, updated_at_ts: n, deployed_at_ts: r, secrets: i, dependencies: a, supported_triggers: o, is_system: s, inherit: c, scope: l, override: u, enforce: d, tenant_id: f, runtime: p, status: m, ...h } = e;
|
|
1200
1226
|
return {
|
|
1201
|
-
...
|
|
1202
|
-
tenant_id:
|
|
1203
|
-
runtime:
|
|
1204
|
-
status:
|
|
1227
|
+
...h,
|
|
1228
|
+
tenant_id: f,
|
|
1229
|
+
runtime: p ?? void 0,
|
|
1230
|
+
status: m || "built",
|
|
1205
1231
|
deployed_at: r ? new Date(Number(r)).toISOString() : void 0,
|
|
1206
1232
|
secrets: X(i),
|
|
1207
1233
|
dependencies: X(a),
|
|
1208
1234
|
supported_triggers: X(o),
|
|
1209
1235
|
is_system: !!s,
|
|
1210
1236
|
inherit: !!c,
|
|
1237
|
+
scope: l ?? void 0,
|
|
1238
|
+
override: u ?? void 0,
|
|
1239
|
+
enforce: d ?? void 0,
|
|
1211
1240
|
created_at: new Date(Number(t)).toISOString(),
|
|
1212
1241
|
updated_at: new Date(Number(n)).toISOString()
|
|
1213
1242
|
};
|
|
1214
1243
|
}
|
|
1215
|
-
function
|
|
1244
|
+
function jt(e) {
|
|
1216
1245
|
return {
|
|
1217
1246
|
async create(t, n) {
|
|
1218
1247
|
let r = Date.now(), i = `act_${b()}`;
|
|
@@ -1228,6 +1257,9 @@ function At(e) {
|
|
|
1228
1257
|
supported_triggers: n.supported_triggers ? JSON.stringify(n.supported_triggers) : null,
|
|
1229
1258
|
is_system: +!!n.is_system,
|
|
1230
1259
|
inherit: +!!n.inherit,
|
|
1260
|
+
scope: n.scope ?? null,
|
|
1261
|
+
override: n.override ?? null,
|
|
1262
|
+
enforce: n.enforce ?? null,
|
|
1231
1263
|
created_at_ts: r,
|
|
1232
1264
|
updated_at_ts: r
|
|
1233
1265
|
}), {
|
|
@@ -1242,27 +1274,30 @@ function At(e) {
|
|
|
1242
1274
|
supported_triggers: n.supported_triggers,
|
|
1243
1275
|
is_system: n.is_system ?? !1,
|
|
1244
1276
|
inherit: n.inherit ?? !1,
|
|
1277
|
+
scope: n.scope,
|
|
1278
|
+
override: n.override,
|
|
1279
|
+
enforce: n.enforce,
|
|
1245
1280
|
created_at: new Date(r).toISOString(),
|
|
1246
1281
|
updated_at: new Date(r).toISOString()
|
|
1247
1282
|
};
|
|
1248
1283
|
},
|
|
1249
1284
|
async get(n, r) {
|
|
1250
1285
|
let i = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get();
|
|
1251
|
-
return i ?
|
|
1286
|
+
return i ? At(i) : null;
|
|
1252
1287
|
},
|
|
1253
1288
|
async list(o, s = {}) {
|
|
1254
1289
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(k.tenant_id, o)];
|
|
1255
1290
|
if (f) {
|
|
1256
|
-
let e =
|
|
1291
|
+
let e = wt(k, f, ["name"]);
|
|
1257
1292
|
e && p.push(e);
|
|
1258
1293
|
}
|
|
1259
1294
|
let m = t(...p);
|
|
1260
|
-
if (
|
|
1295
|
+
if (Tt(s)) {
|
|
1261
1296
|
let n = {
|
|
1262
1297
|
sortColumn: k.created_at_ts,
|
|
1263
1298
|
idColumn: k.id,
|
|
1264
1299
|
sortOrder: "desc"
|
|
1265
|
-
}, r = Z(s), i =
|
|
1300
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(k).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at_ts", "id"), c = a.map(At);
|
|
1266
1301
|
return {
|
|
1267
1302
|
actions: c,
|
|
1268
1303
|
start: 0,
|
|
@@ -1276,7 +1311,7 @@ function At(e) {
|
|
|
1276
1311
|
let e = k[d.sort_by];
|
|
1277
1312
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1278
1313
|
}
|
|
1279
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1314
|
+
let g = (await h.offset(c * l).limit(l)).map(At);
|
|
1280
1315
|
if (!u) return {
|
|
1281
1316
|
actions: g,
|
|
1282
1317
|
start: 0,
|
|
@@ -1294,7 +1329,7 @@ function At(e) {
|
|
|
1294
1329
|
async update(n, r, i) {
|
|
1295
1330
|
let o = { updated_at_ts: Date.now() };
|
|
1296
1331
|
if (i.name !== void 0 && (o.name = i.name), i.code !== void 0 && (o.code = i.code), i.runtime !== void 0 && (o.runtime = i.runtime), i.secrets !== void 0) {
|
|
1297
|
-
let s = await e.select({ secrets: k.secrets }).from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get(), c = new Map(
|
|
1332
|
+
let s = await e.select({ secrets: k.secrets }).from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get(), c = new Map(kt(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1298
1333
|
name: e.name,
|
|
1299
1334
|
value: c.get(e.name)?.value
|
|
1300
1335
|
} : e);
|
|
@@ -1304,7 +1339,7 @@ function At(e) {
|
|
|
1304
1339
|
let e = new Date(i.deployed_at).getTime();
|
|
1305
1340
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1306
1341
|
}
|
|
1307
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(k).set(o).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1342
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.scope !== void 0 && (o.scope = i.scope), i.override !== void 0 && (o.override = i.override), i.enforce !== void 0 && (o.enforce = i.enforce), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(k).set(o).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1308
1343
|
},
|
|
1309
1344
|
async remove(n, r) {
|
|
1310
1345
|
return (await e.delete(k).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
@@ -1313,12 +1348,12 @@ function At(e) {
|
|
|
1313
1348
|
}
|
|
1314
1349
|
//#endregion
|
|
1315
1350
|
//#region src/adapters/actionExecutions.ts
|
|
1316
|
-
var
|
|
1317
|
-
function
|
|
1351
|
+
var Mt = 500;
|
|
1352
|
+
function Nt(e) {
|
|
1318
1353
|
return {
|
|
1319
1354
|
async create(t, n) {
|
|
1320
1355
|
let r = Date.now();
|
|
1321
|
-
return await e.insert(
|
|
1356
|
+
return await e.insert(Ue).values({
|
|
1322
1357
|
id: n.id,
|
|
1323
1358
|
tenant_id: t,
|
|
1324
1359
|
trigger_id: n.trigger_id,
|
|
@@ -1339,7 +1374,7 @@ function Mt(e) {
|
|
|
1339
1374
|
};
|
|
1340
1375
|
},
|
|
1341
1376
|
async get(n, r) {
|
|
1342
|
-
let i = await e.select().from(
|
|
1377
|
+
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.id, r))).get();
|
|
1343
1378
|
return i ? {
|
|
1344
1379
|
id: i.id,
|
|
1345
1380
|
tenant_id: i.tenant_id,
|
|
@@ -1356,8 +1391,8 @@ function Mt(e) {
|
|
|
1356
1391
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1357
1392
|
let r = 0;
|
|
1358
1393
|
for (;;) {
|
|
1359
|
-
let t = await e.delete(
|
|
1360
|
-
if (r += t.length, t.length <
|
|
1394
|
+
let t = await e.delete(Ue).where(y`rowid IN (SELECT rowid FROM ${Ue} WHERE ${Ue.created_at_ts} < ${n} LIMIT ${Mt})`).returning({ id: Ue.id });
|
|
1395
|
+
if (r += t.length, t.length < Mt) break;
|
|
1361
1396
|
}
|
|
1362
1397
|
return r;
|
|
1363
1398
|
}
|
|
@@ -1365,12 +1400,12 @@ function Mt(e) {
|
|
|
1365
1400
|
}
|
|
1366
1401
|
//#endregion
|
|
1367
1402
|
//#region src/adapters/atomic.ts
|
|
1368
|
-
function
|
|
1403
|
+
function Pt(e) {
|
|
1369
1404
|
let t = e;
|
|
1370
1405
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1371
1406
|
}
|
|
1372
|
-
async function
|
|
1373
|
-
if (
|
|
1407
|
+
async function Ft(e, t) {
|
|
1408
|
+
if (Pt(e)) return e.batch(t);
|
|
1374
1409
|
await e.run(y`BEGIN`);
|
|
1375
1410
|
try {
|
|
1376
1411
|
let n = [];
|
|
@@ -1387,7 +1422,7 @@ async function Pt(e, t) {
|
|
|
1387
1422
|
}
|
|
1388
1423
|
//#endregion
|
|
1389
1424
|
//#region src/adapters/actionVersions.ts
|
|
1390
|
-
function
|
|
1425
|
+
function It(e) {
|
|
1391
1426
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1392
1427
|
return {
|
|
1393
1428
|
...c,
|
|
@@ -1400,10 +1435,10 @@ function Ft(e) {
|
|
|
1400
1435
|
updated_at: new Date(Number(n)).toISOString()
|
|
1401
1436
|
};
|
|
1402
1437
|
}
|
|
1403
|
-
function
|
|
1438
|
+
function Lt(e) {
|
|
1404
1439
|
return {
|
|
1405
1440
|
async create(n, r) {
|
|
1406
|
-
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number:
|
|
1441
|
+
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: He.number }).from(He).where(t(a(He.tenant_id, n), a(He.action_id, r.action_id))).orderBy(i(He.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(He).values({
|
|
1407
1442
|
id: s,
|
|
1408
1443
|
tenant_id: n,
|
|
1409
1444
|
action_id: r.action_id,
|
|
@@ -1417,10 +1452,10 @@ function It(e) {
|
|
|
1417
1452
|
created_at_ts: o,
|
|
1418
1453
|
updated_at_ts: o
|
|
1419
1454
|
});
|
|
1420
|
-
return await
|
|
1455
|
+
return await Ft(e, c ? [e.update(He).set({
|
|
1421
1456
|
deployed: 0,
|
|
1422
1457
|
updated_at_ts: o
|
|
1423
|
-
}).where(t(a(
|
|
1458
|
+
}).where(t(a(He.tenant_id, n), a(He.action_id, r.action_id), a(He.deployed, 1))), u] : [u]), {
|
|
1424
1459
|
id: s,
|
|
1425
1460
|
tenant_id: n,
|
|
1426
1461
|
action_id: r.action_id,
|
|
@@ -1436,18 +1471,18 @@ function It(e) {
|
|
|
1436
1471
|
};
|
|
1437
1472
|
},
|
|
1438
1473
|
async get(n, r, i) {
|
|
1439
|
-
let o = await e.select().from(
|
|
1440
|
-
return o ?
|
|
1474
|
+
let o = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.action_id, r), a(He.id, i))).get();
|
|
1475
|
+
return o ? It(o) : null;
|
|
1441
1476
|
},
|
|
1442
1477
|
async list(n, o, s = {}) {
|
|
1443
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(
|
|
1478
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(He.tenant_id, n), a(He.action_id, o)), f = (await e.select().from(He).where(d).orderBy(i(He.number)).offset(c * l).limit(l)).map(It);
|
|
1444
1479
|
if (!u) return {
|
|
1445
1480
|
versions: f,
|
|
1446
1481
|
start: 0,
|
|
1447
1482
|
limit: 0,
|
|
1448
1483
|
length: 0
|
|
1449
1484
|
};
|
|
1450
|
-
let [p] = await e.select({ count: r() }).from(
|
|
1485
|
+
let [p] = await e.select({ count: r() }).from(He).where(d);
|
|
1451
1486
|
return {
|
|
1452
1487
|
versions: f,
|
|
1453
1488
|
start: c * l,
|
|
@@ -1456,19 +1491,19 @@ function It(e) {
|
|
|
1456
1491
|
};
|
|
1457
1492
|
},
|
|
1458
1493
|
async removeForAction(n, r) {
|
|
1459
|
-
return (await e.delete(
|
|
1494
|
+
return (await e.delete(He).where(t(a(He.tenant_id, n), a(He.action_id, r))).returning()).length;
|
|
1460
1495
|
}
|
|
1461
1496
|
};
|
|
1462
1497
|
}
|
|
1463
1498
|
//#endregion
|
|
1464
1499
|
//#region src/adapters/branding.ts
|
|
1465
|
-
function
|
|
1500
|
+
function Rt(e) {
|
|
1466
1501
|
return e === "dark" || e === "light" || e === "auto";
|
|
1467
1502
|
}
|
|
1468
|
-
function
|
|
1503
|
+
function zt(e) {
|
|
1469
1504
|
return {
|
|
1470
1505
|
async get(t) {
|
|
1471
|
-
let n = await e.select().from(
|
|
1506
|
+
let n = await e.select().from(et).where(a(et.tenant_id, t)).get();
|
|
1472
1507
|
if (!n) return null;
|
|
1473
1508
|
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;
|
|
1474
1509
|
return D({
|
|
@@ -1483,7 +1518,7 @@ function Rt(e) {
|
|
|
1483
1518
|
}
|
|
1484
1519
|
},
|
|
1485
1520
|
font: u ? { url: u } : void 0,
|
|
1486
|
-
dark_mode:
|
|
1521
|
+
dark_mode: Rt(d) ? d : void 0
|
|
1487
1522
|
});
|
|
1488
1523
|
},
|
|
1489
1524
|
async set(t, n) {
|
|
@@ -1497,11 +1532,11 @@ function Rt(e) {
|
|
|
1497
1532
|
font_url: i?.url,
|
|
1498
1533
|
dark_mode: a
|
|
1499
1534
|
};
|
|
1500
|
-
await e.insert(
|
|
1535
|
+
await e.insert(et).values({
|
|
1501
1536
|
tenant_id: t,
|
|
1502
1537
|
...l
|
|
1503
1538
|
}).onConflictDoUpdate({
|
|
1504
|
-
target:
|
|
1539
|
+
target: et.tenant_id,
|
|
1505
1540
|
set: l
|
|
1506
1541
|
});
|
|
1507
1542
|
}
|
|
@@ -1509,7 +1544,7 @@ function Rt(e) {
|
|
|
1509
1544
|
}
|
|
1510
1545
|
//#endregion
|
|
1511
1546
|
//#region src/adapters/clients.ts
|
|
1512
|
-
var
|
|
1547
|
+
var Bt = [
|
|
1513
1548
|
"global",
|
|
1514
1549
|
"is_first_party",
|
|
1515
1550
|
"oidc_conformant",
|
|
@@ -1521,7 +1556,7 @@ var zt = [
|
|
|
1521
1556
|
"require_pushed_authorization_requests",
|
|
1522
1557
|
"require_proof_of_possession",
|
|
1523
1558
|
"hide_sign_up_disabled_error"
|
|
1524
|
-
],
|
|
1559
|
+
], Vt = [
|
|
1525
1560
|
"callbacks",
|
|
1526
1561
|
"allowed_origins",
|
|
1527
1562
|
"web_origins",
|
|
@@ -1530,7 +1565,7 @@ var zt = [
|
|
|
1530
1565
|
"allowed_logout_urls",
|
|
1531
1566
|
"grant_types",
|
|
1532
1567
|
"signing_keys"
|
|
1533
|
-
],
|
|
1568
|
+
], Ht = [
|
|
1534
1569
|
"session_transfer",
|
|
1535
1570
|
"oidc_logout",
|
|
1536
1571
|
"jwt_configuration",
|
|
@@ -1547,21 +1582,21 @@ var zt = [
|
|
|
1547
1582
|
"registration_metadata",
|
|
1548
1583
|
"token_exchange"
|
|
1549
1584
|
];
|
|
1550
|
-
function
|
|
1585
|
+
function Ut(e) {
|
|
1551
1586
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1552
|
-
for (let e of
|
|
1553
|
-
for (let e of
|
|
1554
|
-
for (let e of
|
|
1587
|
+
for (let e of Bt) i[e] = !!r[e];
|
|
1588
|
+
for (let e of Vt) i[e] = X(r[e], []);
|
|
1589
|
+
for (let e of Ht) i[e] = X(r[e], {});
|
|
1555
1590
|
return i.connections = X(n, []), D(i);
|
|
1556
1591
|
}
|
|
1557
|
-
function
|
|
1592
|
+
function Wt(e) {
|
|
1558
1593
|
let t = { ...e };
|
|
1559
|
-
ie(e,
|
|
1560
|
-
for (let n of
|
|
1561
|
-
for (let n of
|
|
1594
|
+
ie(e, Bt, t);
|
|
1595
|
+
for (let n of Vt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1596
|
+
for (let n of Ht) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1562
1597
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
|
|
1563
1598
|
}
|
|
1564
|
-
function
|
|
1599
|
+
function Gt(e) {
|
|
1565
1600
|
return {
|
|
1566
1601
|
async create(t, n) {
|
|
1567
1602
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1585,12 +1620,12 @@ function Wt(e) {
|
|
|
1585
1620
|
created_at: r,
|
|
1586
1621
|
updated_at: r
|
|
1587
1622
|
};
|
|
1588
|
-
for (let e of
|
|
1623
|
+
for (let e of Bt) i[e] = n[e] ?? !1;
|
|
1589
1624
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1590
|
-
for (let e of
|
|
1591
|
-
for (let e of
|
|
1625
|
+
for (let e of Vt) i[e] = n[e] || [];
|
|
1626
|
+
for (let e of Ht) i[e] = n[e] || {};
|
|
1592
1627
|
i.connections = n.connections || [];
|
|
1593
|
-
let a =
|
|
1628
|
+
let a = Wt(i);
|
|
1594
1629
|
try {
|
|
1595
1630
|
await e.insert(I).values({
|
|
1596
1631
|
...a,
|
|
@@ -1599,37 +1634,37 @@ function Wt(e) {
|
|
|
1599
1634
|
} catch (e) {
|
|
1600
1635
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Client already exists" }) : e;
|
|
1601
1636
|
}
|
|
1602
|
-
return
|
|
1637
|
+
return Ut({
|
|
1603
1638
|
...a,
|
|
1604
1639
|
tenant_id: t
|
|
1605
1640
|
});
|
|
1606
1641
|
},
|
|
1607
1642
|
async get(n, r) {
|
|
1608
1643
|
let i = await e.select().from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1609
|
-
return i ?
|
|
1644
|
+
return i ? Ut(i) : null;
|
|
1610
1645
|
},
|
|
1611
1646
|
async getByClientId(t) {
|
|
1612
1647
|
let n = await e.select().from(I).where(a(I.client_id, t)).get();
|
|
1613
1648
|
return n ? {
|
|
1614
|
-
...
|
|
1649
|
+
...Ut(n),
|
|
1615
1650
|
tenant_id: n.tenant_id
|
|
1616
1651
|
} : null;
|
|
1617
1652
|
},
|
|
1618
1653
|
async update(n, r, i) {
|
|
1619
|
-
let o =
|
|
1654
|
+
let o = Wt({
|
|
1620
1655
|
...i,
|
|
1621
1656
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1622
1657
|
});
|
|
1623
1658
|
return delete o.client_id, delete o.tenant_id, await e.update(I).set(o).where(t(a(I.tenant_id, n), a(I.client_id, r))), !0;
|
|
1624
1659
|
},
|
|
1625
1660
|
async list(o, s) {
|
|
1626
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1627
|
-
if (
|
|
1661
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
|
|
1662
|
+
if (Tt(s)) {
|
|
1628
1663
|
let n = {
|
|
1629
1664
|
sortColumn: I.created_at,
|
|
1630
1665
|
idColumn: I.client_id,
|
|
1631
1666
|
sortOrder: "desc"
|
|
1632
|
-
}, r =
|
|
1667
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...Et(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Ut);
|
|
1633
1668
|
return {
|
|
1634
1669
|
clients: c,
|
|
1635
1670
|
totals: {
|
|
@@ -1645,7 +1680,7 @@ function Wt(e) {
|
|
|
1645
1680
|
let e = I[d.sort_by];
|
|
1646
1681
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1647
1682
|
}
|
|
1648
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1683
|
+
let g = (await h.offset(c * l).limit(l)).map(Ut);
|
|
1649
1684
|
if (!u) return { clients: g };
|
|
1650
1685
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1651
1686
|
return {
|
|
@@ -1665,7 +1700,7 @@ function Wt(e) {
|
|
|
1665
1700
|
}
|
|
1666
1701
|
//#endregion
|
|
1667
1702
|
//#region src/adapters/clientConnections.ts
|
|
1668
|
-
function
|
|
1703
|
+
function Kt(e) {
|
|
1669
1704
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1670
1705
|
return D({
|
|
1671
1706
|
...a,
|
|
@@ -1674,14 +1709,14 @@ function Gt(e) {
|
|
|
1674
1709
|
is_system: n ? !0 : void 0
|
|
1675
1710
|
});
|
|
1676
1711
|
}
|
|
1677
|
-
function
|
|
1712
|
+
function qt(e) {
|
|
1678
1713
|
return {
|
|
1679
1714
|
async listByClient(n, r) {
|
|
1680
1715
|
let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1681
1716
|
if (!i) return [];
|
|
1682
1717
|
let o = X(i.connections, []) || [];
|
|
1683
1718
|
if (o.length === 0) return [];
|
|
1684
|
-
let s = (await e.select().from(z).where(t(a(z.tenant_id, n), l(z.id, o))).all()).map(
|
|
1719
|
+
let s = (await e.select().from(z).where(t(a(z.tenant_id, n), l(z.id, o))).all()).map(Kt);
|
|
1685
1720
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1686
1721
|
},
|
|
1687
1722
|
async updateByClient(n, r, i) {
|
|
@@ -1718,7 +1753,7 @@ function Kt(e) {
|
|
|
1718
1753
|
}
|
|
1719
1754
|
//#endregion
|
|
1720
1755
|
//#region src/adapters/clientGrants.ts
|
|
1721
|
-
function
|
|
1756
|
+
function Jt(e) {
|
|
1722
1757
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1723
1758
|
return D({
|
|
1724
1759
|
...o,
|
|
@@ -1728,7 +1763,7 @@ function qt(e) {
|
|
|
1728
1763
|
is_system: !!a
|
|
1729
1764
|
});
|
|
1730
1765
|
}
|
|
1731
|
-
function
|
|
1766
|
+
function Yt(e) {
|
|
1732
1767
|
return {
|
|
1733
1768
|
async create(t, n) {
|
|
1734
1769
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1745,30 +1780,30 @@ function Jt(e) {
|
|
|
1745
1780
|
created_at: r,
|
|
1746
1781
|
updated_at: r
|
|
1747
1782
|
};
|
|
1748
|
-
return await e.insert(
|
|
1783
|
+
return await e.insert(Je).values(i), Jt({
|
|
1749
1784
|
...i,
|
|
1750
1785
|
tenant_id: t
|
|
1751
1786
|
});
|
|
1752
1787
|
},
|
|
1753
1788
|
async get(n, r) {
|
|
1754
|
-
let i = await e.select().from(
|
|
1755
|
-
return i ?
|
|
1789
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).get();
|
|
1790
|
+
return i ? Jt(i) : null;
|
|
1756
1791
|
},
|
|
1757
1792
|
async update(n, r, i) {
|
|
1758
1793
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
1759
1794
|
...u,
|
|
1760
1795
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1761
1796
|
};
|
|
1762
|
-
return o !== void 0 && (d.scope = JSON.stringify(o)), s !== void 0 && (d.authorization_details_types = JSON.stringify(s)), c !== void 0 && (d.allow_any_organization = +!!c), l !== void 0 && (d.is_system = +!!l), (await e.update(
|
|
1797
|
+
return o !== void 0 && (d.scope = JSON.stringify(o)), s !== void 0 && (d.authorization_details_types = JSON.stringify(s)), c !== void 0 && (d.allow_any_organization = +!!c), l !== void 0 && (d.is_system = +!!l), (await e.update(Je).set(d).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
|
|
1763
1798
|
},
|
|
1764
1799
|
async list(o, s) {
|
|
1765
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1766
|
-
if (
|
|
1800
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(Je, f, ["client_id", "audience"]) : void 0, m = p ? t(a(Je.tenant_id, o), p) : a(Je.tenant_id, o);
|
|
1801
|
+
if (Tt(s)) {
|
|
1767
1802
|
let n = {
|
|
1768
|
-
sortColumn:
|
|
1769
|
-
idColumn:
|
|
1803
|
+
sortColumn: Je.created_at,
|
|
1804
|
+
idColumn: Je.id,
|
|
1770
1805
|
sortOrder: "desc"
|
|
1771
|
-
}, r =
|
|
1806
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(Je).where(r ? t(m, r) : m).orderBy(...Et(n)).limit(i + 1), i, "created_at"), c = a.map(Jt);
|
|
1772
1807
|
return {
|
|
1773
1808
|
client_grants: c,
|
|
1774
1809
|
start: 0,
|
|
@@ -1777,14 +1812,14 @@ function Jt(e) {
|
|
|
1777
1812
|
next: o
|
|
1778
1813
|
};
|
|
1779
1814
|
}
|
|
1780
|
-
let h = e.select().from(
|
|
1815
|
+
let h = e.select().from(Je).where(m).$dynamic();
|
|
1781
1816
|
if (d?.sort_by) {
|
|
1782
|
-
let e =
|
|
1817
|
+
let e = Je[d.sort_by];
|
|
1783
1818
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1784
|
-
} else h = h.orderBy(i(
|
|
1785
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1819
|
+
} else h = h.orderBy(i(Je.created_at), i(Je.id));
|
|
1820
|
+
let g = (await h.offset(c * l).limit(l)).map(Jt);
|
|
1786
1821
|
if (!u) return { client_grants: g };
|
|
1787
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1822
|
+
let [_] = await e.select({ count: r() }).from(Je).where(m);
|
|
1788
1823
|
return {
|
|
1789
1824
|
client_grants: g,
|
|
1790
1825
|
start: c * l,
|
|
@@ -1793,26 +1828,26 @@ function Jt(e) {
|
|
|
1793
1828
|
};
|
|
1794
1829
|
},
|
|
1795
1830
|
async remove(n, r) {
|
|
1796
|
-
return (await e.delete(
|
|
1831
|
+
return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
|
|
1797
1832
|
}
|
|
1798
1833
|
};
|
|
1799
1834
|
}
|
|
1800
1835
|
//#endregion
|
|
1801
1836
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1802
|
-
function
|
|
1837
|
+
function Xt(e) {
|
|
1803
1838
|
if (!e) return;
|
|
1804
1839
|
let t = JSON.parse(e);
|
|
1805
1840
|
return be(t) ? t : void 0;
|
|
1806
1841
|
}
|
|
1807
|
-
function
|
|
1842
|
+
function Zt(e) {
|
|
1808
1843
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1809
1844
|
}
|
|
1810
|
-
function
|
|
1845
|
+
function Qt(e) {
|
|
1811
1846
|
if (!e) return null;
|
|
1812
1847
|
let t = new Date(e);
|
|
1813
1848
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1814
1849
|
}
|
|
1815
|
-
function
|
|
1850
|
+
function $t(e) {
|
|
1816
1851
|
let t = he.parse(e.type);
|
|
1817
1852
|
return {
|
|
1818
1853
|
id: e.id,
|
|
@@ -1820,15 +1855,15 @@ function Qt(e) {
|
|
|
1820
1855
|
type: t,
|
|
1821
1856
|
client_id: e.client_id ?? void 0,
|
|
1822
1857
|
sub: e.sub ?? void 0,
|
|
1823
|
-
constraints:
|
|
1858
|
+
constraints: Xt(e.constraints),
|
|
1824
1859
|
single_use: !!e.single_use,
|
|
1825
|
-
expires_at:
|
|
1826
|
-
used_at:
|
|
1827
|
-
revoked_at:
|
|
1860
|
+
expires_at: Zt(e.expires_at_ts),
|
|
1861
|
+
used_at: Zt(e.used_at_ts),
|
|
1862
|
+
revoked_at: Zt(e.revoked_at_ts),
|
|
1828
1863
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1829
1864
|
};
|
|
1830
1865
|
}
|
|
1831
|
-
function
|
|
1866
|
+
function en(e) {
|
|
1832
1867
|
return {
|
|
1833
1868
|
async create(t, n) {
|
|
1834
1869
|
let r = Date.now();
|
|
@@ -1841,7 +1876,7 @@ function $t(e) {
|
|
|
1841
1876
|
sub: n.sub ?? null,
|
|
1842
1877
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1843
1878
|
single_use: +!!n.single_use,
|
|
1844
|
-
expires_at_ts:
|
|
1879
|
+
expires_at_ts: Qt(n.expires_at),
|
|
1845
1880
|
created_at_ts: r
|
|
1846
1881
|
}), {
|
|
1847
1882
|
id: n.id,
|
|
@@ -1857,23 +1892,23 @@ function $t(e) {
|
|
|
1857
1892
|
},
|
|
1858
1893
|
async get(n, r) {
|
|
1859
1894
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.id, r))).get();
|
|
1860
|
-
return i ?
|
|
1895
|
+
return i ? $t(i) : null;
|
|
1861
1896
|
},
|
|
1862
1897
|
async getByHash(n, r) {
|
|
1863
1898
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.token_hash, r))).get();
|
|
1864
|
-
return i ?
|
|
1899
|
+
return i ? $t(i) : null;
|
|
1865
1900
|
},
|
|
1866
1901
|
async listByClient(n, r) {
|
|
1867
|
-
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(
|
|
1902
|
+
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map($t);
|
|
1868
1903
|
},
|
|
1869
1904
|
async markUsed(n, r, i) {
|
|
1870
|
-
return (await e.update(L).set({ used_at_ts:
|
|
1905
|
+
return (await e.update(L).set({ used_at_ts: Qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
|
|
1871
1906
|
},
|
|
1872
1907
|
async revoke(n, r, i) {
|
|
1873
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1908
|
+
return (await e.update(L).set({ revoked_at_ts: Qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
|
|
1874
1909
|
},
|
|
1875
1910
|
async revokeByClient(n, r, i) {
|
|
1876
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1911
|
+
return (await e.update(L).set({ revoked_at_ts: Qt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
|
|
1877
1912
|
},
|
|
1878
1913
|
async remove(n, r) {
|
|
1879
1914
|
return (await e.delete(L).where(t(a(L.tenant_id, n), a(L.id, r))).returning()).length > 0;
|
|
@@ -1882,12 +1917,12 @@ function $t(e) {
|
|
|
1882
1917
|
}
|
|
1883
1918
|
//#endregion
|
|
1884
1919
|
//#region src/adapters/codes.ts
|
|
1885
|
-
var
|
|
1886
|
-
function
|
|
1920
|
+
var tn = ["code_id", "login_id"], nn = 500;
|
|
1921
|
+
function rn(e) {
|
|
1887
1922
|
let { tenant_id: t, ...n } = e;
|
|
1888
1923
|
return D(n);
|
|
1889
1924
|
}
|
|
1890
|
-
function
|
|
1925
|
+
function an(e) {
|
|
1891
1926
|
return {
|
|
1892
1927
|
async create(t, n) {
|
|
1893
1928
|
let r = {
|
|
@@ -1896,18 +1931,18 @@ function rn(e) {
|
|
|
1896
1931
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1897
1932
|
expires_at: n.expires_at
|
|
1898
1933
|
};
|
|
1899
|
-
return await e.insert(F).values(r),
|
|
1934
|
+
return await e.insert(F).values(r), rn(r);
|
|
1900
1935
|
},
|
|
1901
1936
|
async get(n, r, i) {
|
|
1902
1937
|
let o = n ? t(a(F.tenant_id, n), a(F.code_id, r), a(F.code_type, i)) : t(a(F.code_id, r), a(F.code_type, i)), s = await e.select().from(F).where(o).get();
|
|
1903
|
-
return s ?
|
|
1938
|
+
return s ? rn(s) : null;
|
|
1904
1939
|
},
|
|
1905
1940
|
async list(o, s) {
|
|
1906
1941
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(F.tenant_id, o)];
|
|
1907
1942
|
if (f) {
|
|
1908
|
-
let e = Ee(f,
|
|
1943
|
+
let e = Ee(f, tn);
|
|
1909
1944
|
if (e) {
|
|
1910
|
-
let t =
|
|
1945
|
+
let t = wt(F, e, tn);
|
|
1911
1946
|
t && p.push(t);
|
|
1912
1947
|
}
|
|
1913
1948
|
}
|
|
@@ -1916,7 +1951,7 @@ function rn(e) {
|
|
|
1916
1951
|
let e = F[d.sort_by];
|
|
1917
1952
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1918
1953
|
}
|
|
1919
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1954
|
+
let g = (await h.offset(c * l).limit(l)).map(rn);
|
|
1920
1955
|
if (!u) return { codes: g };
|
|
1921
1956
|
let [_] = await e.select({ count: r() }).from(F).where(m);
|
|
1922
1957
|
return {
|
|
@@ -1938,8 +1973,8 @@ function rn(e) {
|
|
|
1938
1973
|
async cleanup(t) {
|
|
1939
1974
|
let n = 0;
|
|
1940
1975
|
for (;;) {
|
|
1941
|
-
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${
|
|
1942
|
-
if (n += r.length, r.length <
|
|
1976
|
+
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${nn})`).returning({ code_id: F.code_id });
|
|
1977
|
+
if (n += r.length, r.length < nn) break;
|
|
1943
1978
|
}
|
|
1944
1979
|
return n;
|
|
1945
1980
|
}
|
|
@@ -1947,10 +1982,10 @@ function rn(e) {
|
|
|
1947
1982
|
}
|
|
1948
1983
|
//#endregion
|
|
1949
1984
|
//#region src/adapters/connections.ts
|
|
1950
|
-
function
|
|
1985
|
+
function on() {
|
|
1951
1986
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1952
1987
|
}
|
|
1953
|
-
function
|
|
1988
|
+
function sn(e) {
|
|
1954
1989
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1955
1990
|
return D({
|
|
1956
1991
|
...a,
|
|
@@ -1959,11 +1994,11 @@ function on(e) {
|
|
|
1959
1994
|
is_system: n ? !0 : void 0
|
|
1960
1995
|
});
|
|
1961
1996
|
}
|
|
1962
|
-
function
|
|
1997
|
+
function cn(e) {
|
|
1963
1998
|
return {
|
|
1964
1999
|
async create(t, n) {
|
|
1965
2000
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1966
|
-
id: n.id ||
|
|
2001
|
+
id: n.id || on(),
|
|
1967
2002
|
...n,
|
|
1968
2003
|
tenant_id: t,
|
|
1969
2004
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1977,28 +2012,28 @@ function sn(e) {
|
|
|
1977
2012
|
} catch (e) {
|
|
1978
2013
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Connection already exists" }) : e;
|
|
1979
2014
|
}
|
|
1980
|
-
return
|
|
2015
|
+
return sn(i);
|
|
1981
2016
|
},
|
|
1982
2017
|
async get(n, r) {
|
|
1983
2018
|
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1984
|
-
return i ?
|
|
2019
|
+
return i ? sn(i) : null;
|
|
1985
2020
|
},
|
|
1986
2021
|
async update(n, r, i) {
|
|
1987
2022
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1988
|
-
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(z).set(o).where(t(a(z.tenant_id, n), a(z.id, r))), !0;
|
|
2023
|
+
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), i.scope !== void 0 && (o.scope = i.scope), i.override !== void 0 && (o.override = i.override), i.enforce !== void 0 && (o.enforce = i.enforce), await e.update(z).set(o).where(t(a(z.tenant_id, n), a(z.id, r))), !0;
|
|
1989
2024
|
},
|
|
1990
2025
|
async list(o, s) {
|
|
1991
2026
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(z.tenant_id, o);
|
|
1992
2027
|
if (f) {
|
|
1993
|
-
let e =
|
|
2028
|
+
let e = wt(z, f, ["name"]);
|
|
1994
2029
|
e && (p = t(p, e));
|
|
1995
2030
|
}
|
|
1996
|
-
if (
|
|
2031
|
+
if (Tt(s)) {
|
|
1997
2032
|
let n = {
|
|
1998
2033
|
sortColumn: z.created_at,
|
|
1999
2034
|
idColumn: z.id,
|
|
2000
2035
|
sortOrder: "desc"
|
|
2001
|
-
}, r =
|
|
2036
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(z).where(r ? t(p, r) : p).orderBy(...Et(n)).limit(i + 1), i, "created_at", "id"), c = a.map(sn);
|
|
2002
2037
|
return {
|
|
2003
2038
|
connections: c,
|
|
2004
2039
|
start: 0,
|
|
@@ -2012,7 +2047,7 @@ function sn(e) {
|
|
|
2012
2047
|
let e = z[d.sort_by];
|
|
2013
2048
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2014
2049
|
}
|
|
2015
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
2050
|
+
let h = (await m.offset(c * l).limit(l)).map(sn);
|
|
2016
2051
|
if (!u) return { connections: h };
|
|
2017
2052
|
let [g] = await e.select({ count: r() }).from(z).where(p);
|
|
2018
2053
|
return {
|
|
@@ -2029,7 +2064,7 @@ function sn(e) {
|
|
|
2029
2064
|
}
|
|
2030
2065
|
//#endregion
|
|
2031
2066
|
//#region src/adapters/customDomains.ts
|
|
2032
|
-
function
|
|
2067
|
+
function ln(e) {
|
|
2033
2068
|
let { tenant_id: t, domain_metadata: n, verification: r, ...i } = e;
|
|
2034
2069
|
return D({
|
|
2035
2070
|
...i,
|
|
@@ -2038,7 +2073,7 @@ function cn(e) {
|
|
|
2038
2073
|
verification: X(r)
|
|
2039
2074
|
});
|
|
2040
2075
|
}
|
|
2041
|
-
function
|
|
2076
|
+
function un(e) {
|
|
2042
2077
|
return {
|
|
2043
2078
|
async create(t, n) {
|
|
2044
2079
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -2056,40 +2091,40 @@ function ln(e) {
|
|
|
2056
2091
|
created_at: r,
|
|
2057
2092
|
updated_at: r
|
|
2058
2093
|
};
|
|
2059
|
-
return await e.insert(
|
|
2094
|
+
return await e.insert(Ye).values(i), ln({
|
|
2060
2095
|
...i,
|
|
2061
2096
|
tenant_id: t
|
|
2062
2097
|
});
|
|
2063
2098
|
},
|
|
2064
2099
|
async get(n, r) {
|
|
2065
|
-
let i = await e.select().from(
|
|
2066
|
-
return i ?
|
|
2100
|
+
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.custom_domain_id, r))).get();
|
|
2101
|
+
return i ? ln(i) : null;
|
|
2067
2102
|
},
|
|
2068
2103
|
async getByDomain(t) {
|
|
2069
|
-
let n = await e.select().from(
|
|
2104
|
+
let n = await e.select().from(Ye).where(a(Ye.domain, t)).get();
|
|
2070
2105
|
return n ? {
|
|
2071
|
-
...
|
|
2106
|
+
...ln(n),
|
|
2072
2107
|
tenant_id: n.tenant_id
|
|
2073
2108
|
} : null;
|
|
2074
2109
|
},
|
|
2075
2110
|
async list(t) {
|
|
2076
|
-
return (await e.select().from(
|
|
2111
|
+
return (await e.select().from(Ye).where(a(Ye.tenant_id, t)).all()).map(ln);
|
|
2077
2112
|
},
|
|
2078
2113
|
async update(n, r, i) {
|
|
2079
2114
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2080
|
-
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(
|
|
2115
|
+
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.custom_domain_id, r))).returning()).length > 0;
|
|
2081
2116
|
},
|
|
2082
2117
|
async remove(n, r) {
|
|
2083
|
-
return (await e.delete(
|
|
2118
|
+
return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.custom_domain_id, r))).returning()).length > 0;
|
|
2084
2119
|
}
|
|
2085
2120
|
};
|
|
2086
2121
|
}
|
|
2087
2122
|
//#endregion
|
|
2088
2123
|
//#region src/adapters/customText.ts
|
|
2089
|
-
function
|
|
2124
|
+
function dn(e) {
|
|
2090
2125
|
return {
|
|
2091
2126
|
async get(n, r, i) {
|
|
2092
|
-
let o = await e.select().from(
|
|
2127
|
+
let o = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.prompt, r), a(dt.language, i))).get();
|
|
2093
2128
|
if (!o) return null;
|
|
2094
2129
|
try {
|
|
2095
2130
|
return JSON.parse(o.custom_text);
|
|
@@ -2099,7 +2134,7 @@ function un(e) {
|
|
|
2099
2134
|
},
|
|
2100
2135
|
async set(t, n, r, i) {
|
|
2101
2136
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2102
|
-
await e.insert(
|
|
2137
|
+
await e.insert(dt).values({
|
|
2103
2138
|
tenant_id: t,
|
|
2104
2139
|
prompt: n,
|
|
2105
2140
|
language: r,
|
|
@@ -2108,9 +2143,9 @@ function un(e) {
|
|
|
2108
2143
|
updated_at_ts: a
|
|
2109
2144
|
}).onConflictDoUpdate({
|
|
2110
2145
|
target: [
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2146
|
+
dt.tenant_id,
|
|
2147
|
+
dt.prompt,
|
|
2148
|
+
dt.language
|
|
2114
2149
|
],
|
|
2115
2150
|
set: {
|
|
2116
2151
|
custom_text: o,
|
|
@@ -2119,27 +2154,30 @@ function un(e) {
|
|
|
2119
2154
|
});
|
|
2120
2155
|
},
|
|
2121
2156
|
async delete(n, r, i) {
|
|
2122
|
-
await e.delete(
|
|
2157
|
+
await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.prompt, r), a(dt.language, i)));
|
|
2123
2158
|
},
|
|
2124
2159
|
async list(t) {
|
|
2125
2160
|
return await e.select({
|
|
2126
|
-
prompt:
|
|
2127
|
-
language:
|
|
2128
|
-
}).from(
|
|
2161
|
+
prompt: dt.prompt,
|
|
2162
|
+
language: dt.language
|
|
2163
|
+
}).from(dt).where(a(dt.tenant_id, t)).all();
|
|
2129
2164
|
}
|
|
2130
2165
|
};
|
|
2131
2166
|
}
|
|
2132
2167
|
//#endregion
|
|
2133
2168
|
//#region src/adapters/emailProviders.ts
|
|
2134
|
-
function
|
|
2169
|
+
function fn(e) {
|
|
2135
2170
|
return {
|
|
2136
2171
|
async create(t, n) {
|
|
2137
2172
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2138
|
-
await e.insert(
|
|
2173
|
+
await e.insert(ot).values({
|
|
2139
2174
|
tenant_id: t,
|
|
2140
2175
|
name: n.name,
|
|
2141
2176
|
enabled: n.enabled,
|
|
2142
2177
|
default_from_address: n.default_from_address,
|
|
2178
|
+
scope: n.scope,
|
|
2179
|
+
override: n.override,
|
|
2180
|
+
enforce: n.enforce,
|
|
2143
2181
|
credentials: JSON.stringify(n.credentials || {}),
|
|
2144
2182
|
settings: JSON.stringify(n.settings || {}),
|
|
2145
2183
|
created_at: r,
|
|
@@ -2147,7 +2185,7 @@ function dn(e) {
|
|
|
2147
2185
|
});
|
|
2148
2186
|
},
|
|
2149
2187
|
async get(t) {
|
|
2150
|
-
let n = await e.select().from(
|
|
2188
|
+
let n = await e.select().from(ot).where(a(ot.tenant_id, t)).get();
|
|
2151
2189
|
if (!n) return null;
|
|
2152
2190
|
let { tenant_id: r, ...i } = n;
|
|
2153
2191
|
return D({
|
|
@@ -2159,16 +2197,16 @@ function dn(e) {
|
|
|
2159
2197
|
},
|
|
2160
2198
|
async update(t, n) {
|
|
2161
2199
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2162
|
-
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(
|
|
2200
|
+
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.scope !== void 0 && (r.scope = n.scope), n.override !== void 0 && (r.override = n.override), n.enforce !== void 0 && (r.enforce = n.enforce), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(ot).set(r).where(a(ot.tenant_id, t));
|
|
2163
2201
|
},
|
|
2164
2202
|
async remove(t) {
|
|
2165
|
-
await e.delete(
|
|
2203
|
+
await e.delete(ot).where(a(ot.tenant_id, t));
|
|
2166
2204
|
}
|
|
2167
2205
|
};
|
|
2168
2206
|
}
|
|
2169
2207
|
//#endregion
|
|
2170
2208
|
//#region src/adapters/emailTemplates.ts
|
|
2171
|
-
function
|
|
2209
|
+
function pn(e) {
|
|
2172
2210
|
return D({
|
|
2173
2211
|
template: e.template,
|
|
2174
2212
|
body: e.body,
|
|
@@ -2181,18 +2219,18 @@ function fn(e) {
|
|
|
2181
2219
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2182
2220
|
});
|
|
2183
2221
|
}
|
|
2184
|
-
function
|
|
2222
|
+
function mn(e) {
|
|
2185
2223
|
return {
|
|
2186
2224
|
async get(n, r) {
|
|
2187
|
-
let i = await e.select().from(
|
|
2188
|
-
return i ?
|
|
2225
|
+
let i = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.template, r))).get();
|
|
2226
|
+
return i ? pn(i) : null;
|
|
2189
2227
|
},
|
|
2190
2228
|
async list(t) {
|
|
2191
|
-
return (await e.select().from(
|
|
2229
|
+
return (await e.select().from(st).where(a(st.tenant_id, t)).all()).map(pn);
|
|
2192
2230
|
},
|
|
2193
2231
|
async create(t, n) {
|
|
2194
2232
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2195
|
-
return await e.insert(
|
|
2233
|
+
return await e.insert(st).values({
|
|
2196
2234
|
tenant_id: t,
|
|
2197
2235
|
template: n.template,
|
|
2198
2236
|
body: n.body,
|
|
@@ -2210,30 +2248,30 @@ function pn(e) {
|
|
|
2210
2248
|
async update(n, r, i) {
|
|
2211
2249
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2212
2250
|
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);
|
|
2213
|
-
let s = await e.update(
|
|
2251
|
+
let s = await e.update(st).set(o).where(t(a(st.tenant_id, n), a(st.template, r))).run();
|
|
2214
2252
|
return Number(s.changes ?? 0) > 0;
|
|
2215
2253
|
},
|
|
2216
2254
|
async remove(n, r) {
|
|
2217
|
-
let i = await e.delete(
|
|
2255
|
+
let i = await e.delete(st).where(t(a(st.tenant_id, n), a(st.template, r))).run();
|
|
2218
2256
|
return Number(i.changes ?? 0) > 0;
|
|
2219
2257
|
}
|
|
2220
2258
|
};
|
|
2221
2259
|
}
|
|
2222
2260
|
//#endregion
|
|
2223
2261
|
//#region src/adapters/flows.ts
|
|
2224
|
-
var
|
|
2225
|
-
function
|
|
2262
|
+
var hn = ["id", "name"];
|
|
2263
|
+
function gn(e) {
|
|
2226
2264
|
let { tenant_id: t, actions: n, ...r } = e;
|
|
2227
2265
|
return D({
|
|
2228
2266
|
...r,
|
|
2229
2267
|
actions: X(n, [])
|
|
2230
2268
|
});
|
|
2231
2269
|
}
|
|
2232
|
-
function
|
|
2270
|
+
function _n(e) {
|
|
2233
2271
|
return {
|
|
2234
2272
|
async create(t, n) {
|
|
2235
2273
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2236
|
-
return await e.insert(
|
|
2274
|
+
return await e.insert(it).values({
|
|
2237
2275
|
id: i,
|
|
2238
2276
|
tenant_id: t,
|
|
2239
2277
|
name: n.name,
|
|
@@ -2249,7 +2287,7 @@ function gn(e) {
|
|
|
2249
2287
|
};
|
|
2250
2288
|
},
|
|
2251
2289
|
async get(n, r) {
|
|
2252
|
-
let i = await e.select().from(
|
|
2290
|
+
let i = await e.select().from(it).where(t(a(it.tenant_id, n), a(it.id, r))).get();
|
|
2253
2291
|
if (!i) return null;
|
|
2254
2292
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2255
2293
|
return D({
|
|
@@ -2259,24 +2297,24 @@ function gn(e) {
|
|
|
2259
2297
|
},
|
|
2260
2298
|
async update(n, r, i) {
|
|
2261
2299
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2262
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2300
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(it).set(o).where(t(a(it.tenant_id, n), a(it.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2263
2301
|
},
|
|
2264
2302
|
async list(o, s) {
|
|
2265
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2303
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(it.tenant_id, o)];
|
|
2266
2304
|
if (f) {
|
|
2267
|
-
let e = Ee(f,
|
|
2305
|
+
let e = Ee(f, hn);
|
|
2268
2306
|
if (e) {
|
|
2269
|
-
let t =
|
|
2307
|
+
let t = wt(it, e, []);
|
|
2270
2308
|
t && p.push(t);
|
|
2271
2309
|
}
|
|
2272
2310
|
}
|
|
2273
2311
|
let m = t(...p);
|
|
2274
|
-
if (
|
|
2312
|
+
if (Tt(s)) {
|
|
2275
2313
|
let n = {
|
|
2276
|
-
sortColumn:
|
|
2277
|
-
idColumn:
|
|
2314
|
+
sortColumn: it.created_at,
|
|
2315
|
+
idColumn: it.id,
|
|
2278
2316
|
sortOrder: "desc"
|
|
2279
|
-
}, r = Z(s), i =
|
|
2317
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(it).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at", "id"), c = a.map(gn);
|
|
2280
2318
|
return {
|
|
2281
2319
|
flows: c,
|
|
2282
2320
|
start: 0,
|
|
@@ -2285,14 +2323,14 @@ function gn(e) {
|
|
|
2285
2323
|
next: o
|
|
2286
2324
|
};
|
|
2287
2325
|
}
|
|
2288
|
-
let h = e.select().from(
|
|
2326
|
+
let h = e.select().from(it).where(m).$dynamic();
|
|
2289
2327
|
if (d?.sort_by) {
|
|
2290
|
-
let e =
|
|
2328
|
+
let e = it[d.sort_by];
|
|
2291
2329
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2292
2330
|
}
|
|
2293
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2331
|
+
let g = (await h.offset(c * l).limit(l)).map(gn);
|
|
2294
2332
|
if (!u) return { flows: g };
|
|
2295
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2333
|
+
let [_] = await e.select({ count: r() }).from(it).where(m);
|
|
2296
2334
|
return {
|
|
2297
2335
|
flows: g,
|
|
2298
2336
|
start: c * l,
|
|
@@ -2301,23 +2339,23 @@ function gn(e) {
|
|
|
2301
2339
|
};
|
|
2302
2340
|
},
|
|
2303
2341
|
async remove(n, r) {
|
|
2304
|
-
return (await e.delete(
|
|
2342
|
+
return (await e.delete(it).where(t(a(it.tenant_id, n), a(it.id, r))).returning()).length > 0;
|
|
2305
2343
|
}
|
|
2306
2344
|
};
|
|
2307
2345
|
}
|
|
2308
2346
|
//#endregion
|
|
2309
2347
|
//#region src/adapters/forms.ts
|
|
2310
|
-
var
|
|
2348
|
+
var vn = [
|
|
2311
2349
|
"nodes",
|
|
2312
2350
|
"start",
|
|
2313
2351
|
"ending"
|
|
2314
|
-
],
|
|
2315
|
-
function
|
|
2352
|
+
], yn = ["name"];
|
|
2353
|
+
function bn(e) {
|
|
2316
2354
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2317
|
-
for (let e of
|
|
2355
|
+
for (let e of vn) r[e] = X(n[e]);
|
|
2318
2356
|
return D(r);
|
|
2319
2357
|
}
|
|
2320
|
-
function
|
|
2358
|
+
function xn(e) {
|
|
2321
2359
|
return {
|
|
2322
2360
|
async create(t, n) {
|
|
2323
2361
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2331,8 +2369,8 @@ function bn(e) {
|
|
|
2331
2369
|
created_at: r,
|
|
2332
2370
|
updated_at: r
|
|
2333
2371
|
};
|
|
2334
|
-
for (let e of
|
|
2335
|
-
return await e.insert(
|
|
2372
|
+
for (let e of vn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2373
|
+
return await e.insert(rt).values(a), {
|
|
2336
2374
|
id: i,
|
|
2337
2375
|
...n,
|
|
2338
2376
|
created_at: r,
|
|
@@ -2340,33 +2378,33 @@ function bn(e) {
|
|
|
2340
2378
|
};
|
|
2341
2379
|
},
|
|
2342
2380
|
async get(n, r) {
|
|
2343
|
-
let i = await e.select().from(
|
|
2381
|
+
let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).get();
|
|
2344
2382
|
if (!i) return null;
|
|
2345
2383
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2346
|
-
for (let e of
|
|
2384
|
+
for (let e of vn) c[e] = X(s[e]);
|
|
2347
2385
|
return D(c);
|
|
2348
2386
|
},
|
|
2349
2387
|
async update(n, r, i) {
|
|
2350
2388
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2351
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2352
|
-
return (await e.update(
|
|
2389
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (vn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2390
|
+
return (await e.update(rt).set(o).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2353
2391
|
},
|
|
2354
2392
|
async list(o, s) {
|
|
2355
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2393
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(rt.tenant_id, o)];
|
|
2356
2394
|
if (f) {
|
|
2357
|
-
let e = Ee(f,
|
|
2395
|
+
let e = Ee(f, yn);
|
|
2358
2396
|
if (e) {
|
|
2359
|
-
let t =
|
|
2397
|
+
let t = wt(rt, e, yn);
|
|
2360
2398
|
t && p.push(t);
|
|
2361
2399
|
}
|
|
2362
2400
|
}
|
|
2363
2401
|
let m = t(...p);
|
|
2364
|
-
if (
|
|
2402
|
+
if (Tt(s)) {
|
|
2365
2403
|
let n = {
|
|
2366
|
-
sortColumn:
|
|
2367
|
-
idColumn:
|
|
2404
|
+
sortColumn: rt.created_at,
|
|
2405
|
+
idColumn: rt.id,
|
|
2368
2406
|
sortOrder: "desc"
|
|
2369
|
-
}, r = Z(s), i =
|
|
2407
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(rt).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at", "id"), c = a.map(bn);
|
|
2370
2408
|
return {
|
|
2371
2409
|
forms: c,
|
|
2372
2410
|
start: 0,
|
|
@@ -2375,14 +2413,14 @@ function bn(e) {
|
|
|
2375
2413
|
next: o
|
|
2376
2414
|
};
|
|
2377
2415
|
}
|
|
2378
|
-
let h = e.select().from(
|
|
2416
|
+
let h = e.select().from(rt).where(m).$dynamic();
|
|
2379
2417
|
if (d?.sort_by) {
|
|
2380
|
-
let e =
|
|
2418
|
+
let e = rt[d.sort_by];
|
|
2381
2419
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2382
2420
|
}
|
|
2383
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2421
|
+
let g = (await h.offset(c * l).limit(l)).map(bn);
|
|
2384
2422
|
if (!u) return { forms: g };
|
|
2385
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2423
|
+
let [_] = await e.select({ count: r() }).from(rt).where(m);
|
|
2386
2424
|
return {
|
|
2387
2425
|
forms: g,
|
|
2388
2426
|
start: c * l,
|
|
@@ -2391,13 +2429,13 @@ function bn(e) {
|
|
|
2391
2429
|
};
|
|
2392
2430
|
},
|
|
2393
2431
|
async remove(n, r) {
|
|
2394
|
-
return (await e.delete(
|
|
2432
|
+
return (await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2395
2433
|
}
|
|
2396
2434
|
};
|
|
2397
2435
|
}
|
|
2398
2436
|
//#endregion
|
|
2399
2437
|
//#region src/adapters/grants.ts
|
|
2400
|
-
function
|
|
2438
|
+
function Sn(e) {
|
|
2401
2439
|
return {
|
|
2402
2440
|
id: e.id,
|
|
2403
2441
|
user_id: e.user_id,
|
|
@@ -2406,17 +2444,17 @@ function xn(e) {
|
|
|
2406
2444
|
scope: X(e.scope, []) ?? []
|
|
2407
2445
|
};
|
|
2408
2446
|
}
|
|
2409
|
-
var
|
|
2447
|
+
var Cn = {
|
|
2410
2448
|
user_id: R.user_id,
|
|
2411
2449
|
client_id: R.client_id,
|
|
2412
2450
|
audience: R.audience,
|
|
2413
2451
|
created_at: R.created_at,
|
|
2414
2452
|
updated_at: R.updated_at
|
|
2415
2453
|
};
|
|
2416
|
-
function Cn(e) {
|
|
2417
|
-
return Object.hasOwn(Sn, e) ? Sn[e] : void 0;
|
|
2418
|
-
}
|
|
2419
2454
|
function wn(e) {
|
|
2455
|
+
return Object.hasOwn(Cn, e) ? Cn[e] : void 0;
|
|
2456
|
+
}
|
|
2457
|
+
function Tn(e) {
|
|
2420
2458
|
return {
|
|
2421
2459
|
async create(n, r) {
|
|
2422
2460
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.user_id, r.user_id), a(R.client_id, r.clientID), a(R.audience, s))).get();
|
|
@@ -2425,7 +2463,7 @@ function wn(e) {
|
|
|
2425
2463
|
return await e.update(R).set({
|
|
2426
2464
|
scope: JSON.stringify(s),
|
|
2427
2465
|
updated_at: i
|
|
2428
|
-
}).where(t(a(R.tenant_id, n), a(R.id, c.id))),
|
|
2466
|
+
}).where(t(a(R.tenant_id, n), a(R.id, c.id))), Sn({
|
|
2429
2467
|
...c,
|
|
2430
2468
|
scope: JSON.stringify(s)
|
|
2431
2469
|
});
|
|
@@ -2450,20 +2488,20 @@ function wn(e) {
|
|
|
2450
2488
|
},
|
|
2451
2489
|
async get(n, r, i, o) {
|
|
2452
2490
|
let s = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.user_id, r), a(R.client_id, i), a(R.audience, o ?? ""))).get();
|
|
2453
|
-
return s ?
|
|
2491
|
+
return s ? Sn(s) : null;
|
|
2454
2492
|
},
|
|
2455
2493
|
async list(o, s) {
|
|
2456
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2494
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(R, f, [
|
|
2457
2495
|
"user_id",
|
|
2458
2496
|
"client_id",
|
|
2459
2497
|
"audience"
|
|
2460
2498
|
]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
|
|
2461
|
-
if (
|
|
2499
|
+
if (Tt(s)) {
|
|
2462
2500
|
let n = {
|
|
2463
2501
|
sortColumn: R.created_at,
|
|
2464
2502
|
idColumn: R.id,
|
|
2465
2503
|
sortOrder: "desc"
|
|
2466
|
-
}, r = Z(s), i =
|
|
2504
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(R).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at", "id"), c = a.map(Sn);
|
|
2467
2505
|
return {
|
|
2468
2506
|
grants: c,
|
|
2469
2507
|
start: 0,
|
|
@@ -2472,9 +2510,9 @@ function wn(e) {
|
|
|
2472
2510
|
next: o
|
|
2473
2511
|
};
|
|
2474
2512
|
}
|
|
2475
|
-
let h = e.select().from(R).where(m).$dynamic(), g = d?.sort_by ?
|
|
2513
|
+
let h = e.select().from(R).where(m).$dynamic(), g = d?.sort_by ? wn(d.sort_by) : void 0;
|
|
2476
2514
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(R.created_at));
|
|
2477
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2515
|
+
let _ = (await h.offset(c * l).limit(l)).map(Sn);
|
|
2478
2516
|
if (!u) return {
|
|
2479
2517
|
grants: _,
|
|
2480
2518
|
start: 0,
|
|
@@ -2499,11 +2537,11 @@ function wn(e) {
|
|
|
2499
2537
|
}
|
|
2500
2538
|
//#endregion
|
|
2501
2539
|
//#region src/adapters/hookCode.ts
|
|
2502
|
-
var
|
|
2503
|
-
function
|
|
2504
|
-
return `hc_${
|
|
2540
|
+
var En = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2541
|
+
function Dn() {
|
|
2542
|
+
return `hc_${En()}`;
|
|
2505
2543
|
}
|
|
2506
|
-
function
|
|
2544
|
+
function On(e) {
|
|
2507
2545
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2508
2546
|
created_at_ts: t,
|
|
2509
2547
|
updated_at_ts: n
|
|
@@ -2514,41 +2552,41 @@ function Dn(e) {
|
|
|
2514
2552
|
secrets: r ? JSON.parse(r) : void 0
|
|
2515
2553
|
};
|
|
2516
2554
|
}
|
|
2517
|
-
function
|
|
2555
|
+
function kn(e) {
|
|
2518
2556
|
return {
|
|
2519
2557
|
async create(t, n) {
|
|
2520
2558
|
let r = Date.now(), i = {
|
|
2521
|
-
id:
|
|
2559
|
+
id: Dn(),
|
|
2522
2560
|
tenant_id: t,
|
|
2523
2561
|
code: n.code,
|
|
2524
2562
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2525
2563
|
created_at_ts: r,
|
|
2526
2564
|
updated_at_ts: r
|
|
2527
2565
|
};
|
|
2528
|
-
return await e.insert(
|
|
2566
|
+
return await e.insert(lt).values(i), On({
|
|
2529
2567
|
...i,
|
|
2530
2568
|
tenant_id: t
|
|
2531
2569
|
});
|
|
2532
2570
|
},
|
|
2533
2571
|
async get(n, r) {
|
|
2534
|
-
let i = await e.select().from(
|
|
2535
|
-
return i ?
|
|
2572
|
+
let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).get();
|
|
2573
|
+
return i ? On(i) : null;
|
|
2536
2574
|
},
|
|
2537
2575
|
async update(n, r, i) {
|
|
2538
2576
|
let o = { updated_at_ts: Date.now() };
|
|
2539
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2577
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(lt).set(o).where(t(a(lt.tenant_id, n), a(lt.id, r))).returning()).length > 0;
|
|
2540
2578
|
},
|
|
2541
2579
|
async remove(n, r) {
|
|
2542
|
-
return (await e.delete(
|
|
2580
|
+
return (await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).returning()).length > 0;
|
|
2543
2581
|
}
|
|
2544
2582
|
};
|
|
2545
2583
|
}
|
|
2546
2584
|
//#endregion
|
|
2547
2585
|
//#region src/adapters/hooks.ts
|
|
2548
|
-
function
|
|
2586
|
+
function An() {
|
|
2549
2587
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2550
2588
|
}
|
|
2551
|
-
function
|
|
2589
|
+
function jn(e) {
|
|
2552
2590
|
if (!(typeof e != "string" || !e)) try {
|
|
2553
2591
|
let t = JSON.parse(e);
|
|
2554
2592
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2556,7 +2594,7 @@ function An(e) {
|
|
|
2556
2594
|
return;
|
|
2557
2595
|
}
|
|
2558
2596
|
}
|
|
2559
|
-
function
|
|
2597
|
+
function Mn(e) {
|
|
2560
2598
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2561
2599
|
created_at_ts: n,
|
|
2562
2600
|
updated_at_ts: r
|
|
@@ -2565,15 +2603,15 @@ function jn(e) {
|
|
|
2565
2603
|
...a,
|
|
2566
2604
|
enabled: !!a.enabled,
|
|
2567
2605
|
synchronous: !!a.synchronous,
|
|
2568
|
-
metadata:
|
|
2606
|
+
metadata: jn(i),
|
|
2569
2607
|
...o
|
|
2570
2608
|
});
|
|
2571
2609
|
}
|
|
2572
|
-
function
|
|
2610
|
+
function Nn(e) {
|
|
2573
2611
|
return {
|
|
2574
2612
|
async create(t, n) {
|
|
2575
2613
|
let r = Date.now(), i = {
|
|
2576
|
-
hook_id: n.hook_id ||
|
|
2614
|
+
hook_id: n.hook_id || An(),
|
|
2577
2615
|
tenant_id: t,
|
|
2578
2616
|
trigger_id: n.trigger_id,
|
|
2579
2617
|
url: n.url,
|
|
@@ -2585,36 +2623,39 @@ function Mn(e) {
|
|
|
2585
2623
|
code_id: n.code_id,
|
|
2586
2624
|
page_id: n.page_id,
|
|
2587
2625
|
permission_required: n.permission_required,
|
|
2626
|
+
scope: n.scope,
|
|
2627
|
+
override: n.override,
|
|
2628
|
+
enforce: n.enforce,
|
|
2588
2629
|
metadata: n.metadata ? JSON.stringify(n.metadata) : null,
|
|
2589
2630
|
created_at_ts: r,
|
|
2590
2631
|
updated_at_ts: r
|
|
2591
2632
|
};
|
|
2592
|
-
return await e.insert(
|
|
2633
|
+
return await e.insert(ct).values(i), Mn({
|
|
2593
2634
|
...i,
|
|
2594
2635
|
tenant_id: t
|
|
2595
2636
|
});
|
|
2596
2637
|
},
|
|
2597
2638
|
async get(n, r) {
|
|
2598
|
-
let i = await e.select().from(
|
|
2599
|
-
return i ?
|
|
2639
|
+
let i = await e.select().from(ct).where(t(a(ct.tenant_id, n), a(ct.hook_id, r))).get();
|
|
2640
|
+
return i ? Mn(i) : null;
|
|
2600
2641
|
},
|
|
2601
2642
|
async update(n, r, i) {
|
|
2602
2643
|
let o = { updated_at_ts: Date.now() };
|
|
2603
|
-
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(
|
|
2644
|
+
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.scope !== void 0 && (o.scope = i.scope), i.override !== void 0 && (o.override = i.override), i.enforce !== void 0 && (o.enforce = i.enforce), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(ct).set(o).where(t(a(ct.tenant_id, n), a(ct.hook_id, r))).returning()).length > 0;
|
|
2604
2645
|
},
|
|
2605
2646
|
async list(o, s) {
|
|
2606
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2647
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(ct, f, [
|
|
2607
2648
|
"url",
|
|
2608
2649
|
"form_id",
|
|
2609
2650
|
"template_id",
|
|
2610
2651
|
"code_id"
|
|
2611
|
-
]) : void 0, m = p ? t(a(
|
|
2612
|
-
if (
|
|
2652
|
+
]) : void 0, m = p ? t(a(ct.tenant_id, o), p) : a(ct.tenant_id, o);
|
|
2653
|
+
if (Tt(s)) {
|
|
2613
2654
|
let n = {
|
|
2614
|
-
sortColumn:
|
|
2615
|
-
idColumn:
|
|
2655
|
+
sortColumn: ct.created_at_ts,
|
|
2656
|
+
idColumn: ct.hook_id,
|
|
2616
2657
|
sortOrder: "desc"
|
|
2617
|
-
}, r = Z(s), i =
|
|
2658
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(ct).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at_ts", "hook_id"), c = a.map(Mn);
|
|
2618
2659
|
return {
|
|
2619
2660
|
hooks: c,
|
|
2620
2661
|
start: 0,
|
|
@@ -2623,11 +2664,11 @@ function Mn(e) {
|
|
|
2623
2664
|
next: o
|
|
2624
2665
|
};
|
|
2625
2666
|
}
|
|
2626
|
-
let h = e.select().from(
|
|
2627
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2628
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2667
|
+
let h = e.select().from(ct).where(m).$dynamic(), g = d?.sort_by ? ct[d.sort_by] : void 0;
|
|
2668
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(ct.priority), n(ct.created_at_ts));
|
|
2669
|
+
let _ = (await h.offset(c * l).limit(l)).map(Mn);
|
|
2629
2670
|
if (!u) return { hooks: _ };
|
|
2630
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2671
|
+
let [v] = await e.select({ count: r() }).from(ct).where(m);
|
|
2631
2672
|
return {
|
|
2632
2673
|
hooks: _,
|
|
2633
2674
|
start: c * l,
|
|
@@ -2636,31 +2677,31 @@ function Mn(e) {
|
|
|
2636
2677
|
};
|
|
2637
2678
|
},
|
|
2638
2679
|
async remove(n, r) {
|
|
2639
|
-
return (await e.delete(
|
|
2680
|
+
return (await e.delete(ct).where(t(a(ct.tenant_id, n), a(ct.hook_id, r))).returning()).length > 0;
|
|
2640
2681
|
}
|
|
2641
2682
|
};
|
|
2642
2683
|
}
|
|
2643
2684
|
//#endregion
|
|
2644
2685
|
//#region src/adapters/invites.ts
|
|
2645
|
-
function
|
|
2686
|
+
function Pn() {
|
|
2646
2687
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2647
2688
|
}
|
|
2648
|
-
var
|
|
2689
|
+
var Fn = [
|
|
2649
2690
|
"inviter",
|
|
2650
2691
|
"invitee",
|
|
2651
2692
|
"app_metadata",
|
|
2652
2693
|
"user_metadata",
|
|
2653
2694
|
"roles"
|
|
2654
2695
|
];
|
|
2655
|
-
function
|
|
2696
|
+
function In(e) {
|
|
2656
2697
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2657
|
-
for (let e of
|
|
2698
|
+
for (let e of Fn) i[e] = X(r[e], e === "roles" ? [] : {});
|
|
2658
2699
|
return i.send_invitation_email = !!n, D(i);
|
|
2659
2700
|
}
|
|
2660
|
-
function
|
|
2701
|
+
function Ln(e) {
|
|
2661
2702
|
return {
|
|
2662
2703
|
async create(t, n) {
|
|
2663
|
-
let r = n.id ||
|
|
2704
|
+
let r = n.id || Pn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2664
2705
|
id: r,
|
|
2665
2706
|
tenant_id: t,
|
|
2666
2707
|
organization_id: n.organization_id,
|
|
@@ -2673,34 +2714,34 @@ function In(e) {
|
|
|
2673
2714
|
created_at: a.toISOString(),
|
|
2674
2715
|
expires_at: o
|
|
2675
2716
|
};
|
|
2676
|
-
for (let e of
|
|
2717
|
+
for (let e of Fn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2677
2718
|
try {
|
|
2678
|
-
await e.insert(
|
|
2719
|
+
await e.insert(Ze).values(s);
|
|
2679
2720
|
} catch (e) {
|
|
2680
2721
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Invite already exists" }) : e;
|
|
2681
2722
|
}
|
|
2682
|
-
return
|
|
2723
|
+
return In({
|
|
2683
2724
|
...s,
|
|
2684
2725
|
tenant_id: t
|
|
2685
2726
|
});
|
|
2686
2727
|
},
|
|
2687
2728
|
async get(n, r) {
|
|
2688
|
-
let i = await e.select().from(
|
|
2689
|
-
return i ?
|
|
2729
|
+
let i = await e.select().from(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).get();
|
|
2730
|
+
return i ? In(i) : null;
|
|
2690
2731
|
},
|
|
2691
2732
|
async update(n, r, i) {
|
|
2692
2733
|
let o = {};
|
|
2693
|
-
for (let e of
|
|
2694
|
-
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(
|
|
2734
|
+
for (let e of Fn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2735
|
+
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(Ze).set(o).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2695
2736
|
},
|
|
2696
2737
|
async list(o, s) {
|
|
2697
2738
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d } = s || {};
|
|
2698
|
-
if (
|
|
2739
|
+
if (Tt(s)) {
|
|
2699
2740
|
let n = {
|
|
2700
|
-
sortColumn:
|
|
2701
|
-
idColumn:
|
|
2741
|
+
sortColumn: Ze.created_at,
|
|
2742
|
+
idColumn: Ze.id,
|
|
2702
2743
|
sortOrder: "desc"
|
|
2703
|
-
}, r = Z(s), i = s?.q ?
|
|
2744
|
+
}, r = Z(s), i = s?.q ? wt(Ze, s.q, ["invitee", "inviter"]) : void 0, { rows: c, next: l } = Ot(await e.select().from(Ze).where(t(a(Ze.tenant_id, o), i, Dt(s, n))).orderBy(...Et(n)).limit(r + 1), r, "created_at"), u = c.map(In);
|
|
2704
2745
|
return {
|
|
2705
2746
|
invites: u,
|
|
2706
2747
|
start: 0,
|
|
@@ -2709,14 +2750,14 @@ function In(e) {
|
|
|
2709
2750
|
next: l
|
|
2710
2751
|
};
|
|
2711
2752
|
}
|
|
2712
|
-
let f = e.select().from(
|
|
2753
|
+
let f = e.select().from(Ze).where(a(Ze.tenant_id, o)).$dynamic();
|
|
2713
2754
|
if (d?.sort_by) {
|
|
2714
|
-
let e =
|
|
2755
|
+
let e = Ze[d.sort_by];
|
|
2715
2756
|
e && (f = f.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2716
2757
|
}
|
|
2717
|
-
let p = (await f.offset(c * l).limit(l)).map(
|
|
2758
|
+
let p = (await f.offset(c * l).limit(l)).map(In);
|
|
2718
2759
|
if (!u) return { invites: p };
|
|
2719
|
-
let [m] = await e.select({ count: r() }).from(
|
|
2760
|
+
let [m] = await e.select({ count: r() }).from(Ze).where(a(Ze.tenant_id, o));
|
|
2720
2761
|
return {
|
|
2721
2762
|
invites: p,
|
|
2722
2763
|
start: c * l,
|
|
@@ -2725,39 +2766,39 @@ function In(e) {
|
|
|
2725
2766
|
};
|
|
2726
2767
|
},
|
|
2727
2768
|
async remove(n, r) {
|
|
2728
|
-
return (await e.delete(
|
|
2769
|
+
return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2729
2770
|
}
|
|
2730
2771
|
};
|
|
2731
2772
|
}
|
|
2732
2773
|
//#endregion
|
|
2733
2774
|
//#region src/adapters/keys.ts
|
|
2734
|
-
var
|
|
2775
|
+
var Rn = [
|
|
2735
2776
|
"kid",
|
|
2736
2777
|
"connection",
|
|
2737
2778
|
"fingerprint",
|
|
2738
2779
|
"thumbprint",
|
|
2739
2780
|
"type"
|
|
2740
2781
|
];
|
|
2741
|
-
function
|
|
2782
|
+
function zn(e) {
|
|
2742
2783
|
return {
|
|
2743
2784
|
async create(t) {
|
|
2744
|
-
await e.insert(
|
|
2785
|
+
await e.insert(ut).values({
|
|
2745
2786
|
...t,
|
|
2746
2787
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2747
2788
|
});
|
|
2748
2789
|
},
|
|
2749
2790
|
async list(a) {
|
|
2750
|
-
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(
|
|
2791
|
+
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(ut.revoked_at, p), f(ut.revoked_at))];
|
|
2751
2792
|
if (d) {
|
|
2752
|
-
let e = Ee(d,
|
|
2793
|
+
let e = Ee(d, Rn);
|
|
2753
2794
|
if (e) {
|
|
2754
|
-
let t =
|
|
2795
|
+
let t = wt(ut, e, Rn);
|
|
2755
2796
|
t && m.push(t);
|
|
2756
2797
|
}
|
|
2757
2798
|
}
|
|
2758
|
-
let h = t(...m), g = e.select().from(
|
|
2799
|
+
let h = t(...m), g = e.select().from(ut).where(h).$dynamic();
|
|
2759
2800
|
if (u?.sort_by) {
|
|
2760
|
-
let e =
|
|
2801
|
+
let e = ut[u.sort_by];
|
|
2761
2802
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2762
2803
|
}
|
|
2763
2804
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2765,7 +2806,7 @@ function Rn(e) {
|
|
|
2765
2806
|
return D(n);
|
|
2766
2807
|
});
|
|
2767
2808
|
if (!l) return { signingKeys: _ };
|
|
2768
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2809
|
+
let [y] = await e.select({ count: r() }).from(ut).where(h);
|
|
2769
2810
|
return {
|
|
2770
2811
|
signingKeys: _,
|
|
2771
2812
|
start: o * c,
|
|
@@ -2774,22 +2815,22 @@ function Rn(e) {
|
|
|
2774
2815
|
};
|
|
2775
2816
|
},
|
|
2776
2817
|
async update(t, n) {
|
|
2777
|
-
return (await e.update(
|
|
2818
|
+
return (await e.update(ut).set(n).where(a(ut.kid, t)).returning()).length > 0;
|
|
2778
2819
|
}
|
|
2779
2820
|
};
|
|
2780
2821
|
}
|
|
2781
2822
|
//#endregion
|
|
2782
2823
|
//#region src/adapters/loginSessions.ts
|
|
2783
|
-
var
|
|
2784
|
-
function
|
|
2824
|
+
var Bn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Vn = 32;
|
|
2825
|
+
function Hn() {
|
|
2785
2826
|
let e = Date.now(), t = "";
|
|
2786
|
-
for (let n = 10; n > 0; n--) t =
|
|
2827
|
+
for (let n = 10; n > 0; n--) t = Bn.charAt(e % Vn) + t, e = Math.floor(e / Vn);
|
|
2787
2828
|
let n = new Uint8Array(16);
|
|
2788
2829
|
crypto.getRandomValues(n);
|
|
2789
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2830
|
+
for (let e = 0; e < 16; e++) t += Bn.charAt(n[e] % Vn);
|
|
2790
2831
|
return t;
|
|
2791
2832
|
}
|
|
2792
|
-
function
|
|
2833
|
+
function Un(e) {
|
|
2793
2834
|
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 = ae({
|
|
2794
2835
|
created_at_ts: n,
|
|
2795
2836
|
updated_at_ts: r,
|
|
@@ -2801,17 +2842,17 @@ function Hn(e) {
|
|
|
2801
2842
|
]), l = {};
|
|
2802
2843
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2803
2844
|
return D({
|
|
2804
|
-
...
|
|
2845
|
+
...xt(l, ["auth_strategy"]),
|
|
2805
2846
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2806
2847
|
...c,
|
|
2807
2848
|
state_data: X(a)
|
|
2808
2849
|
});
|
|
2809
2850
|
}
|
|
2810
|
-
function
|
|
2851
|
+
function Wn(e) {
|
|
2811
2852
|
return {
|
|
2812
2853
|
async create(t, n) {
|
|
2813
2854
|
let r = Date.now(), i = {
|
|
2814
|
-
id:
|
|
2855
|
+
id: Hn(),
|
|
2815
2856
|
tenant_id: t,
|
|
2816
2857
|
session_id: n.session_id,
|
|
2817
2858
|
csrf_token: n.csrf_token,
|
|
@@ -2832,14 +2873,14 @@ function Un(e) {
|
|
|
2832
2873
|
updated_at_ts: r,
|
|
2833
2874
|
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2834
2875
|
};
|
|
2835
|
-
return await e.insert(P).values(i),
|
|
2876
|
+
return await e.insert(P).values(i), Un({
|
|
2836
2877
|
...i,
|
|
2837
2878
|
tenant_id: t
|
|
2838
2879
|
});
|
|
2839
2880
|
},
|
|
2840
2881
|
async get(n, r) {
|
|
2841
2882
|
let i = n ? t(a(P.tenant_id, n), a(P.id, r)) : a(P.id, r), o = await e.select().from(P).where(i).get();
|
|
2842
|
-
return o ?
|
|
2883
|
+
return o ? Un(o) : null;
|
|
2843
2884
|
},
|
|
2844
2885
|
async update(n, r, i) {
|
|
2845
2886
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2859,7 +2900,7 @@ function Un(e) {
|
|
|
2859
2900
|
}
|
|
2860
2901
|
//#endregion
|
|
2861
2902
|
//#region src/adapters/logs.ts
|
|
2862
|
-
function
|
|
2903
|
+
function Gn(e) {
|
|
2863
2904
|
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 = {
|
|
2864
2905
|
...f,
|
|
2865
2906
|
isMobile: !!n,
|
|
@@ -2876,7 +2917,7 @@ function Wn(e) {
|
|
|
2876
2917
|
continent_code: u
|
|
2877
2918
|
})), D(p);
|
|
2878
2919
|
}
|
|
2879
|
-
function
|
|
2920
|
+
function Kn(e) {
|
|
2880
2921
|
return {
|
|
2881
2922
|
async create(t, n) {
|
|
2882
2923
|
let r = {
|
|
@@ -2902,7 +2943,7 @@ function Gn(e) {
|
|
|
2902
2943
|
hostname: n.hostname,
|
|
2903
2944
|
session_connection: n.session_connection
|
|
2904
2945
|
};
|
|
2905
|
-
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(K).values(r),
|
|
2946
|
+
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(K).values(r), Gn({
|
|
2906
2947
|
...r,
|
|
2907
2948
|
tenant_id: t
|
|
2908
2949
|
});
|
|
@@ -2910,7 +2951,7 @@ function Gn(e) {
|
|
|
2910
2951
|
async list(o, s) {
|
|
2911
2952
|
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(K.tenant_id, o)];
|
|
2912
2953
|
if (p) {
|
|
2913
|
-
let e =
|
|
2954
|
+
let e = wt(K, p, [
|
|
2914
2955
|
"user_id",
|
|
2915
2956
|
"ip",
|
|
2916
2957
|
"type",
|
|
@@ -2920,14 +2961,14 @@ function Gn(e) {
|
|
|
2920
2961
|
}
|
|
2921
2962
|
typeof h == "number" && Number.isFinite(h) && _.push(c(K.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(K.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2922
2963
|
let v = t(..._);
|
|
2923
|
-
if (
|
|
2964
|
+
if (Tt(s)) {
|
|
2924
2965
|
if (f?.sort_by && f.sort_by !== "date") throw new Re(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2925
2966
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2926
2967
|
sortColumn: K.date,
|
|
2927
2968
|
idColumn: K.log_id,
|
|
2928
2969
|
sortOrder: n,
|
|
2929
2970
|
sortKey: `date:${n}`
|
|
2930
|
-
}, i =
|
|
2971
|
+
}, i = Dt(s, r), a = Z(s), { rows: o, next: c } = Ot(await e.select().from(K).where(i ? t(v, i) : v).orderBy(...Et(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Gn);
|
|
2931
2972
|
return {
|
|
2932
2973
|
logs: l,
|
|
2933
2974
|
start: 0,
|
|
@@ -2941,7 +2982,7 @@ function Gn(e) {
|
|
|
2941
2982
|
let e = K[f.sort_by];
|
|
2942
2983
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2943
2984
|
} else y = y.orderBy(i(K.date));
|
|
2944
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2985
|
+
let ee = (await y.offset(l * u).limit(u)).map(Gn);
|
|
2945
2986
|
if (!d) return { logs: ee };
|
|
2946
2987
|
let [b] = await e.select({ count: r() }).from(K).where(v);
|
|
2947
2988
|
return {
|
|
@@ -2953,22 +2994,22 @@ function Gn(e) {
|
|
|
2953
2994
|
},
|
|
2954
2995
|
async get(n, r) {
|
|
2955
2996
|
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.log_id, r))).get();
|
|
2956
|
-
return i ?
|
|
2997
|
+
return i ? Gn(i) : null;
|
|
2957
2998
|
}
|
|
2958
2999
|
};
|
|
2959
3000
|
}
|
|
2960
3001
|
//#endregion
|
|
2961
3002
|
//#region src/adapters/authenticationMethods.ts
|
|
2962
|
-
var
|
|
2963
|
-
function
|
|
3003
|
+
var qn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Jn = 32;
|
|
3004
|
+
function Yn() {
|
|
2964
3005
|
let e = Date.now(), t = "";
|
|
2965
|
-
for (let n = 10; n > 0; n--) t =
|
|
3006
|
+
for (let n = 10; n > 0; n--) t = qn.charAt(e % Jn) + t, e = Math.floor(e / Jn);
|
|
2966
3007
|
let n = new Uint8Array(16);
|
|
2967
3008
|
crypto.getRandomValues(n);
|
|
2968
|
-
for (let e = 0; e < 16; e++) t +=
|
|
3009
|
+
for (let e = 0; e < 16; e++) t += qn.charAt(n[e] % Jn);
|
|
2969
3010
|
return t;
|
|
2970
3011
|
}
|
|
2971
|
-
function
|
|
3012
|
+
function Xn(e) {
|
|
2972
3013
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2973
3014
|
return D({
|
|
2974
3015
|
...s,
|
|
@@ -2979,11 +3020,11 @@ function Yn(e) {
|
|
|
2979
3020
|
updated_at: oe(r)
|
|
2980
3021
|
});
|
|
2981
3022
|
}
|
|
2982
|
-
function
|
|
3023
|
+
function Zn(e) {
|
|
2983
3024
|
return {
|
|
2984
3025
|
async create(t, n) {
|
|
2985
3026
|
let r = Date.now(), i = {
|
|
2986
|
-
id: n.id ||
|
|
3027
|
+
id: n.id || Yn(),
|
|
2987
3028
|
tenant_id: t,
|
|
2988
3029
|
user_id: n.user_id,
|
|
2989
3030
|
type: n.type,
|
|
@@ -2999,41 +3040,41 @@ function Xn(e) {
|
|
|
2999
3040
|
created_at_ts: r,
|
|
3000
3041
|
updated_at_ts: r
|
|
3001
3042
|
};
|
|
3002
|
-
return await e.insert(
|
|
3043
|
+
return await e.insert(pt).values(i), Xn({
|
|
3003
3044
|
...i,
|
|
3004
3045
|
tenant_id: t
|
|
3005
3046
|
});
|
|
3006
3047
|
},
|
|
3007
3048
|
async get(n, r) {
|
|
3008
|
-
let i = await e.select().from(
|
|
3009
|
-
return i ?
|
|
3049
|
+
let i = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.id, r))).get();
|
|
3050
|
+
return i ? Xn(i) : null;
|
|
3010
3051
|
},
|
|
3011
3052
|
async getByCredentialId(n, r) {
|
|
3012
|
-
let i = await e.select().from(
|
|
3013
|
-
return i ?
|
|
3053
|
+
let i = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.credential_id, r))).get();
|
|
3054
|
+
return i ? Xn(i) : null;
|
|
3014
3055
|
},
|
|
3015
3056
|
async list(n, r) {
|
|
3016
|
-
return (await e.select().from(
|
|
3057
|
+
return (await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.user_id, r))).all()).map(Xn);
|
|
3017
3058
|
},
|
|
3018
3059
|
async update(n, r, i) {
|
|
3019
3060
|
let o = { updated_at_ts: Date.now() };
|
|
3020
|
-
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(
|
|
3061
|
+
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(pt).set(o).where(t(a(pt.tenant_id, n), a(pt.id, r)));
|
|
3021
3062
|
let s = await this.get(n, r);
|
|
3022
3063
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
3023
3064
|
return s;
|
|
3024
3065
|
},
|
|
3025
3066
|
async remove(n, r) {
|
|
3026
|
-
return (await e.delete(
|
|
3067
|
+
return (await e.delete(pt).where(t(a(pt.tenant_id, n), a(pt.id, r))).returning()).length > 0;
|
|
3027
3068
|
}
|
|
3028
3069
|
};
|
|
3029
3070
|
}
|
|
3030
3071
|
//#endregion
|
|
3031
3072
|
//#region src/adapters/organizations.ts
|
|
3032
|
-
var
|
|
3033
|
-
function
|
|
3073
|
+
var Qn = ["name", "display_name"];
|
|
3074
|
+
function $n() {
|
|
3034
3075
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3035
3076
|
}
|
|
3036
|
-
function
|
|
3077
|
+
function er(e) {
|
|
3037
3078
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
3038
3079
|
return D({
|
|
3039
3080
|
...o,
|
|
@@ -3043,11 +3084,11 @@ function $n(e) {
|
|
|
3043
3084
|
token_quota: X(a, {})
|
|
3044
3085
|
});
|
|
3045
3086
|
}
|
|
3046
|
-
function
|
|
3087
|
+
function tr(e) {
|
|
3047
3088
|
return {
|
|
3048
3089
|
async create(t, n) {
|
|
3049
3090
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3050
|
-
id: n.id ||
|
|
3091
|
+
id: n.id || $n(),
|
|
3051
3092
|
tenant_id: t,
|
|
3052
3093
|
name: n.name,
|
|
3053
3094
|
display_name: n.display_name,
|
|
@@ -3063,14 +3104,14 @@ function er(e) {
|
|
|
3063
3104
|
} catch (e) {
|
|
3064
3105
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "Organization already exists" }) : e;
|
|
3065
3106
|
}
|
|
3066
|
-
return
|
|
3107
|
+
return er({
|
|
3067
3108
|
...i,
|
|
3068
3109
|
tenant_id: t
|
|
3069
3110
|
});
|
|
3070
3111
|
},
|
|
3071
3112
|
async get(n, r) {
|
|
3072
3113
|
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
3073
|
-
return i ||= await e.select().from(B).where(t(a(B.tenant_id, n), a(B.name, r))).get(), i ?
|
|
3114
|
+
return i ||= await e.select().from(B).where(t(a(B.tenant_id, n), a(B.name, r))).get(), i ? er(i) : null;
|
|
3074
3115
|
},
|
|
3075
3116
|
async update(n, r, i) {
|
|
3076
3117
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3079,19 +3120,19 @@ function er(e) {
|
|
|
3079
3120
|
async list(o, s) {
|
|
3080
3121
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(B.tenant_id, o)];
|
|
3081
3122
|
if (f) {
|
|
3082
|
-
let e = Ee(f,
|
|
3123
|
+
let e = Ee(f, Qn);
|
|
3083
3124
|
if (e) {
|
|
3084
|
-
let t =
|
|
3125
|
+
let t = wt(B, e, Qn);
|
|
3085
3126
|
t && p.push(t);
|
|
3086
3127
|
}
|
|
3087
3128
|
}
|
|
3088
3129
|
let m = t(...p);
|
|
3089
|
-
if (
|
|
3130
|
+
if (Tt(s)) {
|
|
3090
3131
|
let n = {
|
|
3091
3132
|
sortColumn: B.created_at,
|
|
3092
3133
|
idColumn: B.id,
|
|
3093
3134
|
sortOrder: "desc"
|
|
3094
|
-
}, r =
|
|
3135
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(B).where(r ? t(m, r) : m).orderBy(...Et(n)).limit(i + 1), i, "created_at"), c = a.map(er);
|
|
3095
3136
|
return {
|
|
3096
3137
|
organizations: c,
|
|
3097
3138
|
start: 0,
|
|
@@ -3106,7 +3147,7 @@ function er(e) {
|
|
|
3106
3147
|
let e = B[d.sort_by];
|
|
3107
3148
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3108
3149
|
}
|
|
3109
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3150
|
+
let g = (await h.offset(c * l).limit(l)).map(er);
|
|
3110
3151
|
if (!u) return { organizations: g };
|
|
3111
3152
|
let [_] = await e.select({ count: r() }).from(B).where(m);
|
|
3112
3153
|
return {
|
|
@@ -3123,7 +3164,7 @@ function er(e) {
|
|
|
3123
3164
|
}
|
|
3124
3165
|
//#endregion
|
|
3125
3166
|
//#region src/adapters/organizationConnections.ts
|
|
3126
|
-
function
|
|
3167
|
+
function nr(e, t) {
|
|
3127
3168
|
return {
|
|
3128
3169
|
connection_id: e.connection_id,
|
|
3129
3170
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -3137,7 +3178,7 @@ function tr(e, t) {
|
|
|
3137
3178
|
updated_at: e.updated_at
|
|
3138
3179
|
};
|
|
3139
3180
|
}
|
|
3140
|
-
function
|
|
3181
|
+
function rr(e) {
|
|
3141
3182
|
async function n(n, r) {
|
|
3142
3183
|
let i = await e.select({
|
|
3143
3184
|
name: z.name,
|
|
@@ -3148,7 +3189,7 @@ function nr(e) {
|
|
|
3148
3189
|
strategy: typeof i.strategy == "string" ? i.strategy : void 0
|
|
3149
3190
|
};
|
|
3150
3191
|
}
|
|
3151
|
-
let r = (e, n, r) => t(a(
|
|
3192
|
+
let r = (e, n, r) => t(a(Qe.tenant_id, e), a(Qe.organization_id, n), a(Qe.connection_id, r));
|
|
3152
3193
|
return {
|
|
3153
3194
|
async create(t, r, i, a) {
|
|
3154
3195
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
@@ -3161,43 +3202,43 @@ function nr(e) {
|
|
|
3161
3202
|
created_at: o?.created_at ?? s,
|
|
3162
3203
|
updated_at: o?.updated_at ?? s
|
|
3163
3204
|
};
|
|
3164
|
-
return await e.insert(
|
|
3205
|
+
return await e.insert(Qe).values(c), nr(c, await n(t, i.connection_id));
|
|
3165
3206
|
},
|
|
3166
3207
|
async list(r, i) {
|
|
3167
|
-
let o = await e.select().from(
|
|
3168
|
-
for (let e of o) s.push(
|
|
3208
|
+
let o = await e.select().from(Qe).where(t(a(Qe.tenant_id, r), a(Qe.organization_id, i))).all(), s = [];
|
|
3209
|
+
for (let e of o) s.push(nr(e, await n(r, e.connection_id)));
|
|
3169
3210
|
return s;
|
|
3170
3211
|
},
|
|
3171
3212
|
async listCheckpoint(r, i, o = {}) {
|
|
3172
3213
|
let s = {
|
|
3173
|
-
sortColumn:
|
|
3174
|
-
idColumn:
|
|
3214
|
+
sortColumn: Qe.connection_id,
|
|
3215
|
+
idColumn: Qe.connection_id,
|
|
3175
3216
|
sortOrder: "asc"
|
|
3176
|
-
}, c = Z(o), { rows: l, next: u } =
|
|
3177
|
-
for (let e of l) d.push(
|
|
3217
|
+
}, c = Z(o), { rows: l, next: u } = Ot(await e.select().from(Qe).where(t(a(Qe.tenant_id, r), a(Qe.organization_id, i), Dt(o, s))).orderBy(...Et(s)).limit(c + 1).all(), c, "connection_id", "connection_id"), d = [];
|
|
3218
|
+
for (let e of l) d.push(nr(e, await n(r, e.connection_id)));
|
|
3178
3219
|
return {
|
|
3179
3220
|
connections: d,
|
|
3180
3221
|
next: u
|
|
3181
3222
|
};
|
|
3182
3223
|
},
|
|
3183
3224
|
async get(t, i, a) {
|
|
3184
|
-
let o = await e.select().from(
|
|
3185
|
-
return o ?
|
|
3225
|
+
let o = await e.select().from(Qe).where(r(t, i, a)).get();
|
|
3226
|
+
return o ? nr(o, await n(t, a)) : null;
|
|
3186
3227
|
},
|
|
3187
3228
|
async update(t, i, a, o) {
|
|
3188
3229
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3189
3230
|
o.assign_membership_on_login !== void 0 && (s.assign_membership_on_login = +!!o.assign_membership_on_login), o.show_as_button !== void 0 && (s.show_as_button = +!!o.show_as_button), o.is_signup_enabled !== void 0 && (s.is_signup_enabled = +!!o.is_signup_enabled);
|
|
3190
|
-
let c = await e.update(
|
|
3191
|
-
return c.length === 0 ? null :
|
|
3231
|
+
let c = await e.update(Qe).set(s).where(r(t, i, a)).returning();
|
|
3232
|
+
return c.length === 0 ? null : nr(c[0], await n(t, a));
|
|
3192
3233
|
},
|
|
3193
3234
|
async remove(t, n, i) {
|
|
3194
|
-
return (await e.delete(
|
|
3235
|
+
return (await e.delete(Qe).where(r(t, n, i)).returning({ id: Qe.connection_id })).length > 0;
|
|
3195
3236
|
}
|
|
3196
3237
|
};
|
|
3197
3238
|
}
|
|
3198
3239
|
//#endregion
|
|
3199
3240
|
//#region src/adapters/logStreams.ts
|
|
3200
|
-
function
|
|
3241
|
+
function ir(e) {
|
|
3201
3242
|
return {
|
|
3202
3243
|
id: e.id,
|
|
3203
3244
|
name: e.name,
|
|
@@ -3210,7 +3251,7 @@ function rr(e) {
|
|
|
3210
3251
|
updated_at: e.updated_at
|
|
3211
3252
|
};
|
|
3212
3253
|
}
|
|
3213
|
-
function
|
|
3254
|
+
function ar(e) {
|
|
3214
3255
|
return {
|
|
3215
3256
|
async create(t, n, r) {
|
|
3216
3257
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -3225,27 +3266,27 @@ function ir(e) {
|
|
|
3225
3266
|
created_at: i?.created_at ?? a,
|
|
3226
3267
|
updated_at: i?.updated_at ?? a
|
|
3227
3268
|
};
|
|
3228
|
-
return await e.insert(
|
|
3269
|
+
return await e.insert(_t).values(o), ir(o);
|
|
3229
3270
|
},
|
|
3230
3271
|
async get(n, r) {
|
|
3231
|
-
let i = await e.select().from(
|
|
3232
|
-
return i ?
|
|
3272
|
+
let i = await e.select().from(_t).where(t(a(_t.tenant_id, n), a(_t.id, r))).get();
|
|
3273
|
+
return i ? ir(i) : null;
|
|
3233
3274
|
},
|
|
3234
3275
|
async list(t) {
|
|
3235
|
-
return (await e.select().from(
|
|
3276
|
+
return (await e.select().from(_t).where(a(_t.tenant_id, t)).all()).map(ir);
|
|
3236
3277
|
},
|
|
3237
3278
|
async update(n, r, i) {
|
|
3238
3279
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3239
|
-
return i.name !== void 0 && (o.name = i.name), i.type !== void 0 && (o.type = i.type), i.status !== void 0 && (o.status = i.status), i.sink !== void 0 && (o.sink = JSON.stringify(i.sink)), i.filters !== void 0 && (o.filters = i.filters ? JSON.stringify(i.filters) : null), i.isPriority !== void 0 && (o.is_priority = +!!i.isPriority), (await e.update(
|
|
3280
|
+
return i.name !== void 0 && (o.name = i.name), i.type !== void 0 && (o.type = i.type), i.status !== void 0 && (o.status = i.status), i.sink !== void 0 && (o.sink = JSON.stringify(i.sink)), i.filters !== void 0 && (o.filters = i.filters ? JSON.stringify(i.filters) : null), i.isPriority !== void 0 && (o.is_priority = +!!i.isPriority), (await e.update(_t).set(o).where(t(a(_t.tenant_id, n), a(_t.id, r))).returning({ id: _t.id })).length > 0;
|
|
3240
3281
|
},
|
|
3241
3282
|
async remove(n, r) {
|
|
3242
|
-
return (await e.delete(
|
|
3283
|
+
return (await e.delete(_t).where(t(a(_t.tenant_id, n), a(_t.id, r))).returning({ id: _t.id })).length > 0;
|
|
3243
3284
|
}
|
|
3244
3285
|
};
|
|
3245
3286
|
}
|
|
3246
3287
|
//#endregion
|
|
3247
3288
|
//#region src/adapters/migrationSources.ts
|
|
3248
|
-
function
|
|
3289
|
+
function or(e) {
|
|
3249
3290
|
return {
|
|
3250
3291
|
id: e.id,
|
|
3251
3292
|
name: e.name,
|
|
@@ -3257,8 +3298,8 @@ function ar(e) {
|
|
|
3257
3298
|
updated_at: e.updated_at
|
|
3258
3299
|
};
|
|
3259
3300
|
}
|
|
3260
|
-
function
|
|
3261
|
-
let n = (e, n) => t(a(
|
|
3301
|
+
function sr(e) {
|
|
3302
|
+
let n = (e, n) => t(a(vt.tenant_id, e), a(vt.id, n));
|
|
3262
3303
|
return {
|
|
3263
3304
|
async create(t, n, r) {
|
|
3264
3305
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -3272,34 +3313,34 @@ function or(e) {
|
|
|
3272
3313
|
created_at: i?.created_at ?? a,
|
|
3273
3314
|
updated_at: i?.updated_at ?? a
|
|
3274
3315
|
};
|
|
3275
|
-
return await e.insert(
|
|
3316
|
+
return await e.insert(vt).values(o), or(o);
|
|
3276
3317
|
},
|
|
3277
3318
|
async get(t, r) {
|
|
3278
|
-
let i = await e.select().from(
|
|
3279
|
-
return i ?
|
|
3319
|
+
let i = await e.select().from(vt).where(n(t, r)).get();
|
|
3320
|
+
return i ? or(i) : null;
|
|
3280
3321
|
},
|
|
3281
3322
|
async list(t) {
|
|
3282
|
-
return (await e.select().from(
|
|
3323
|
+
return (await e.select().from(vt).where(a(vt.tenant_id, t)).all()).map(or);
|
|
3283
3324
|
},
|
|
3284
3325
|
async update(t, r, i) {
|
|
3285
3326
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3286
|
-
return i.name !== void 0 && (a.name = i.name), i.provider !== void 0 && (a.provider = i.provider), i.connection !== void 0 && (a.connection = i.connection), i.enabled !== void 0 && (a.enabled = +!!i.enabled), i.credentials !== void 0 && (a.credentials = JSON.stringify(i.credentials)), (await e.update(
|
|
3327
|
+
return i.name !== void 0 && (a.name = i.name), i.provider !== void 0 && (a.provider = i.provider), i.connection !== void 0 && (a.connection = i.connection), i.enabled !== void 0 && (a.enabled = +!!i.enabled), i.credentials !== void 0 && (a.credentials = JSON.stringify(i.credentials)), (await e.update(vt).set(a).where(n(t, r)).returning({ id: vt.id })).length > 0;
|
|
3287
3328
|
},
|
|
3288
3329
|
async remove(t, r) {
|
|
3289
|
-
return (await e.delete(
|
|
3330
|
+
return (await e.delete(vt).where(n(t, r)).returning({ id: vt.id })).length > 0;
|
|
3290
3331
|
}
|
|
3291
3332
|
};
|
|
3292
3333
|
}
|
|
3293
3334
|
//#endregion
|
|
3294
3335
|
//#region src/adapters/passwords.ts
|
|
3295
|
-
function
|
|
3336
|
+
function cr(e) {
|
|
3296
3337
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
3297
3338
|
return {
|
|
3298
3339
|
...r,
|
|
3299
3340
|
is_current: !!n
|
|
3300
3341
|
};
|
|
3301
3342
|
}
|
|
3302
|
-
function
|
|
3343
|
+
function lr(e) {
|
|
3303
3344
|
return {
|
|
3304
3345
|
async create(n, r) {
|
|
3305
3346
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -3314,18 +3355,18 @@ function cr(e) {
|
|
|
3314
3355
|
created_at: i,
|
|
3315
3356
|
updated_at: i
|
|
3316
3357
|
};
|
|
3317
|
-
return await e.insert(j).values(s),
|
|
3358
|
+
return await e.insert(j).values(s), cr({
|
|
3318
3359
|
...s,
|
|
3319
3360
|
tenant_id: n
|
|
3320
3361
|
});
|
|
3321
3362
|
},
|
|
3322
3363
|
async get(n, r) {
|
|
3323
3364
|
let i = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r), a(j.is_current, 1))).get();
|
|
3324
|
-
return i ?
|
|
3365
|
+
return i ? cr(i) : null;
|
|
3325
3366
|
},
|
|
3326
3367
|
async list(n, r, o) {
|
|
3327
3368
|
let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
|
|
3328
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
3369
|
+
return o && (s = s.limit(o)), (await s).map(cr);
|
|
3329
3370
|
},
|
|
3330
3371
|
async update(n, r) {
|
|
3331
3372
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3335,16 +3376,19 @@ function cr(e) {
|
|
|
3335
3376
|
}
|
|
3336
3377
|
//#endregion
|
|
3337
3378
|
//#region src/adapters/promptSettings.ts
|
|
3338
|
-
function
|
|
3379
|
+
function ur(e) {
|
|
3339
3380
|
return {
|
|
3340
3381
|
async get(t) {
|
|
3341
|
-
let n = await e.select().from(
|
|
3382
|
+
let n = await e.select().from(at).where(a(at.tenant_id, t)).get();
|
|
3342
3383
|
return n ? {
|
|
3343
3384
|
universal_login_experience: n.universal_login_experience,
|
|
3344
3385
|
identifier_first: !!n.identifier_first,
|
|
3345
3386
|
password_first: !!n.password_first,
|
|
3346
3387
|
webauthn_platform_first_factor: !!n.webauthn_platform_first_factor,
|
|
3347
|
-
show_last_used_connection: !!n.show_last_used_connection
|
|
3388
|
+
show_last_used_connection: !!n.show_last_used_connection,
|
|
3389
|
+
...n.scope ? { scope: n.scope } : {},
|
|
3390
|
+
...n.override ? { override: n.override } : {},
|
|
3391
|
+
...n.enforce == null ? {} : { enforce: !!n.enforce }
|
|
3348
3392
|
} : {
|
|
3349
3393
|
universal_login_experience: "new",
|
|
3350
3394
|
identifier_first: !0,
|
|
@@ -3354,21 +3398,27 @@ function lr(e) {
|
|
|
3354
3398
|
};
|
|
3355
3399
|
},
|
|
3356
3400
|
async set(t, n) {
|
|
3357
|
-
await e.insert(
|
|
3401
|
+
await e.insert(at).values({
|
|
3358
3402
|
tenant_id: t,
|
|
3359
3403
|
universal_login_experience: n.universal_login_experience,
|
|
3360
3404
|
identifier_first: n.identifier_first,
|
|
3361
3405
|
password_first: n.password_first,
|
|
3362
3406
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3363
|
-
show_last_used_connection: n.show_last_used_connection
|
|
3407
|
+
show_last_used_connection: n.show_last_used_connection,
|
|
3408
|
+
scope: n.scope,
|
|
3409
|
+
override: n.override,
|
|
3410
|
+
enforce: n.enforce
|
|
3364
3411
|
}).onConflictDoUpdate({
|
|
3365
|
-
target:
|
|
3412
|
+
target: at.tenant_id,
|
|
3366
3413
|
set: {
|
|
3367
3414
|
universal_login_experience: n.universal_login_experience,
|
|
3368
3415
|
identifier_first: n.identifier_first,
|
|
3369
3416
|
password_first: n.password_first,
|
|
3370
3417
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3371
|
-
show_last_used_connection: n.show_last_used_connection
|
|
3418
|
+
show_last_used_connection: n.show_last_used_connection,
|
|
3419
|
+
scope: n.scope,
|
|
3420
|
+
override: n.override,
|
|
3421
|
+
enforce: n.enforce
|
|
3372
3422
|
}
|
|
3373
3423
|
});
|
|
3374
3424
|
}
|
|
@@ -3376,10 +3426,10 @@ function lr(e) {
|
|
|
3376
3426
|
}
|
|
3377
3427
|
//#endregion
|
|
3378
3428
|
//#region src/adapters/promptPartials.ts
|
|
3379
|
-
function
|
|
3429
|
+
function dr(e) {
|
|
3380
3430
|
return {
|
|
3381
3431
|
async get(n, r) {
|
|
3382
|
-
let i = await e.select({ body:
|
|
3432
|
+
let i = await e.select({ body: ft.body }).from(ft).where(t(a(ft.tenant_id, n), a(ft.prompt, r))).get();
|
|
3383
3433
|
if (!i) return null;
|
|
3384
3434
|
try {
|
|
3385
3435
|
return JSON.parse(i.body);
|
|
@@ -3389,14 +3439,14 @@ function ur(e) {
|
|
|
3389
3439
|
},
|
|
3390
3440
|
async set(t, n, r, i) {
|
|
3391
3441
|
let a = Date.now(), o = i?.importMetadata?.created_at, s = i?.importMetadata?.updated_at, c = o ? new Date(o).getTime() : a, l = s ? new Date(s).getTime() : c, u = JSON.stringify(r);
|
|
3392
|
-
await e.insert(
|
|
3442
|
+
await e.insert(ft).values({
|
|
3393
3443
|
tenant_id: t,
|
|
3394
3444
|
prompt: n,
|
|
3395
3445
|
body: u,
|
|
3396
3446
|
created_at_ts: c,
|
|
3397
3447
|
updated_at_ts: l
|
|
3398
3448
|
}).onConflictDoUpdate({
|
|
3399
|
-
target: [
|
|
3449
|
+
target: [ft.tenant_id, ft.prompt],
|
|
3400
3450
|
set: {
|
|
3401
3451
|
body: u,
|
|
3402
3452
|
updated_at_ts: s ? l : a
|
|
@@ -3404,16 +3454,16 @@ function ur(e) {
|
|
|
3404
3454
|
});
|
|
3405
3455
|
},
|
|
3406
3456
|
async delete(n, r) {
|
|
3407
|
-
await e.delete(
|
|
3457
|
+
await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.prompt, r)));
|
|
3408
3458
|
},
|
|
3409
3459
|
async list(t) {
|
|
3410
|
-
return (await e.select({ prompt:
|
|
3460
|
+
return (await e.select({ prompt: ft.prompt }).from(ft).where(a(ft.tenant_id, t)).all()).map(({ prompt: e }) => e);
|
|
3411
3461
|
}
|
|
3412
3462
|
};
|
|
3413
3463
|
}
|
|
3414
3464
|
//#endregion
|
|
3415
3465
|
//#region src/adapters/proxyRoutes.ts
|
|
3416
|
-
function
|
|
3466
|
+
function fr(e) {
|
|
3417
3467
|
if (!e) return { path: "/*" };
|
|
3418
3468
|
try {
|
|
3419
3469
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -3421,7 +3471,7 @@ function dr(e) {
|
|
|
3421
3471
|
} catch {}
|
|
3422
3472
|
return { path: "/*" };
|
|
3423
3473
|
}
|
|
3424
|
-
function
|
|
3474
|
+
function pr(e) {
|
|
3425
3475
|
if (!e) return [];
|
|
3426
3476
|
try {
|
|
3427
3477
|
let t = JSON.parse(e);
|
|
@@ -3436,19 +3486,19 @@ function fr(e) {
|
|
|
3436
3486
|
return [];
|
|
3437
3487
|
}
|
|
3438
3488
|
}
|
|
3439
|
-
function
|
|
3489
|
+
function mr(e) {
|
|
3440
3490
|
return {
|
|
3441
3491
|
id: e.id,
|
|
3442
3492
|
tenant_id: e.tenant_id,
|
|
3443
3493
|
custom_domain_id: e.custom_domain_id,
|
|
3444
3494
|
priority: e.priority,
|
|
3445
|
-
match:
|
|
3446
|
-
handlers:
|
|
3495
|
+
match: fr(e.match),
|
|
3496
|
+
handlers: pr(e.handlers),
|
|
3447
3497
|
created_at: e.created_at,
|
|
3448
3498
|
updated_at: e.updated_at
|
|
3449
3499
|
};
|
|
3450
3500
|
}
|
|
3451
|
-
function
|
|
3501
|
+
function hr(e) {
|
|
3452
3502
|
return {
|
|
3453
3503
|
async create(t, n) {
|
|
3454
3504
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3474,14 +3524,14 @@ function mr(e) {
|
|
|
3474
3524
|
},
|
|
3475
3525
|
async get(n, r) {
|
|
3476
3526
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.id, r))).limit(1);
|
|
3477
|
-
return i[0] ?
|
|
3527
|
+
return i[0] ? mr(i[0]) : null;
|
|
3478
3528
|
},
|
|
3479
3529
|
async list(r, i = {}) {
|
|
3480
3530
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(J.tenant_id, r)];
|
|
3481
3531
|
i.custom_domain_id && c.push(a(J.custom_domain_id, i.custom_domain_id));
|
|
3482
3532
|
let l = await e.select().from(J).where(t(...c)).orderBy(n(J.priority), n(J.created_at)).offset(o * s).limit(s);
|
|
3483
3533
|
return {
|
|
3484
|
-
proxy_routes: l.map(
|
|
3534
|
+
proxy_routes: l.map(mr),
|
|
3485
3535
|
start: o * s,
|
|
3486
3536
|
limit: s,
|
|
3487
3537
|
length: l.length
|
|
@@ -3500,8 +3550,8 @@ function mr(e) {
|
|
|
3500
3550
|
}
|
|
3501
3551
|
//#endregion
|
|
3502
3552
|
//#region src/adapters/tokenExchangeProfiles.ts
|
|
3503
|
-
var
|
|
3504
|
-
function
|
|
3553
|
+
var gr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3554
|
+
function _r(e) {
|
|
3505
3555
|
if (e) try {
|
|
3506
3556
|
let t = Ie.safeParse(JSON.parse(e));
|
|
3507
3557
|
return t.success ? t.data : void 0;
|
|
@@ -3509,7 +3559,7 @@ function gr(e) {
|
|
|
3509
3559
|
return;
|
|
3510
3560
|
}
|
|
3511
3561
|
}
|
|
3512
|
-
function
|
|
3562
|
+
function vr(e) {
|
|
3513
3563
|
let t = {
|
|
3514
3564
|
id: e.id,
|
|
3515
3565
|
name: e.name,
|
|
@@ -3519,14 +3569,14 @@ function _r(e) {
|
|
|
3519
3569
|
updated_at: e.updated_at
|
|
3520
3570
|
};
|
|
3521
3571
|
e.action_id && (t.action_id = e.action_id);
|
|
3522
|
-
let n =
|
|
3572
|
+
let n = _r(e.jwt_verification);
|
|
3523
3573
|
return n && (t.jwt_verification = n), t;
|
|
3524
3574
|
}
|
|
3525
|
-
function
|
|
3575
|
+
function yr(e) {
|
|
3526
3576
|
return {
|
|
3527
3577
|
async create(t, n, r) {
|
|
3528
3578
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3529
|
-
id: i?.id ?? `tep_${
|
|
3579
|
+
id: i?.id ?? `tep_${gr()}`,
|
|
3530
3580
|
tenant_id: t,
|
|
3531
3581
|
name: n.name,
|
|
3532
3582
|
subject_token_type: n.subject_token_type,
|
|
@@ -3536,27 +3586,27 @@ function vr(e) {
|
|
|
3536
3586
|
created_at: i?.created_at ?? a,
|
|
3537
3587
|
updated_at: i?.updated_at ?? a
|
|
3538
3588
|
};
|
|
3539
|
-
return await e.insert(
|
|
3589
|
+
return await e.insert(gt).values(o), vr(o);
|
|
3540
3590
|
},
|
|
3541
3591
|
async get(n, r) {
|
|
3542
|
-
let i = await e.select().from(
|
|
3543
|
-
return i[0] ?
|
|
3592
|
+
let i = await e.select().from(gt).where(t(a(gt.tenant_id, n), a(gt.id, r))).limit(1);
|
|
3593
|
+
return i[0] ? vr(i[0]) : null;
|
|
3544
3594
|
},
|
|
3545
3595
|
async list(t) {
|
|
3546
|
-
return (await e.select().from(
|
|
3596
|
+
return (await e.select().from(gt).where(a(gt.tenant_id, t)).orderBy(n(gt.created_at), n(gt.id))).map(vr);
|
|
3547
3597
|
},
|
|
3548
3598
|
async update(n, r, i) {
|
|
3549
3599
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3550
|
-
return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(
|
|
3600
|
+
return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(gt).set(o).where(t(a(gt.tenant_id, n), a(gt.id, r))).returning({ id: gt.id })).length > 0;
|
|
3551
3601
|
},
|
|
3552
3602
|
async remove(n, r) {
|
|
3553
|
-
return (await e.delete(
|
|
3603
|
+
return (await e.delete(gt).where(t(a(gt.tenant_id, n), a(gt.id, r))).returning({ id: gt.id })).length > 0;
|
|
3554
3604
|
}
|
|
3555
3605
|
};
|
|
3556
3606
|
}
|
|
3557
3607
|
//#endregion
|
|
3558
3608
|
//#region src/adapters/scim.ts
|
|
3559
|
-
function
|
|
3609
|
+
function br(e) {
|
|
3560
3610
|
if (!e) return [];
|
|
3561
3611
|
try {
|
|
3562
3612
|
let t = JSON.parse(e);
|
|
@@ -3571,7 +3621,7 @@ function yr(e) {
|
|
|
3571
3621
|
return [];
|
|
3572
3622
|
}
|
|
3573
3623
|
}
|
|
3574
|
-
function
|
|
3624
|
+
function xr(e) {
|
|
3575
3625
|
if (!e) return [];
|
|
3576
3626
|
try {
|
|
3577
3627
|
let t = JSON.parse(e);
|
|
@@ -3580,16 +3630,16 @@ function br(e) {
|
|
|
3580
3630
|
return [];
|
|
3581
3631
|
}
|
|
3582
3632
|
}
|
|
3583
|
-
function
|
|
3633
|
+
function Sr(e) {
|
|
3584
3634
|
return {
|
|
3585
3635
|
connection_id: e.connection_id,
|
|
3586
3636
|
user_id_attribute: e.user_id_attribute,
|
|
3587
|
-
mapping:
|
|
3637
|
+
mapping: br(e.mapping),
|
|
3588
3638
|
created_at: e.created_at,
|
|
3589
3639
|
updated_at: e.updated_at
|
|
3590
3640
|
};
|
|
3591
3641
|
}
|
|
3592
|
-
function
|
|
3642
|
+
function Cr(e) {
|
|
3593
3643
|
return {
|
|
3594
3644
|
async create(t, n) {
|
|
3595
3645
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3599,7 +3649,7 @@ function Sr(e) {
|
|
|
3599
3649
|
created_at: r,
|
|
3600
3650
|
updated_at: r
|
|
3601
3651
|
};
|
|
3602
|
-
return await e.insert(
|
|
3652
|
+
return await e.insert(mt).values({
|
|
3603
3653
|
connection_id: i.connection_id,
|
|
3604
3654
|
tenant_id: t,
|
|
3605
3655
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3609,31 +3659,31 @@ function Sr(e) {
|
|
|
3609
3659
|
}), i;
|
|
3610
3660
|
},
|
|
3611
3661
|
async get(n, r) {
|
|
3612
|
-
let i = await e.select().from(
|
|
3613
|
-
return i[0] ?
|
|
3662
|
+
let i = await e.select().from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r))).limit(1);
|
|
3663
|
+
return i[0] ? Sr(i[0]) : null;
|
|
3614
3664
|
},
|
|
3615
3665
|
async update(n, r, i) {
|
|
3616
|
-
if ((await e.select({ connection_id:
|
|
3666
|
+
if ((await e.select({ connection_id: mt.connection_id }).from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3617
3667
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3618
|
-
return i.user_id_attribute !== void 0 && (o.user_id_attribute = i.user_id_attribute), i.mapping !== void 0 && (o.mapping = JSON.stringify(i.mapping)), await e.update(
|
|
3668
|
+
return i.user_id_attribute !== void 0 && (o.user_id_attribute = i.user_id_attribute), i.mapping !== void 0 && (o.mapping = JSON.stringify(i.mapping)), await e.update(mt).set(o).where(t(a(mt.tenant_id, n), a(mt.connection_id, r))), !0;
|
|
3619
3669
|
},
|
|
3620
3670
|
async remove(n, r) {
|
|
3621
|
-
return (await e.select({ connection_id:
|
|
3671
|
+
return (await e.select({ connection_id: mt.connection_id }).from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r))), !0);
|
|
3622
3672
|
}
|
|
3623
3673
|
};
|
|
3624
3674
|
}
|
|
3625
|
-
function
|
|
3675
|
+
function wr(e) {
|
|
3626
3676
|
return {
|
|
3627
3677
|
token_id: e.token_id,
|
|
3628
3678
|
connection_id: e.connection_id,
|
|
3629
3679
|
token_hash: e.token_hash,
|
|
3630
|
-
scopes:
|
|
3680
|
+
scopes: xr(e.scopes),
|
|
3631
3681
|
valid_until: e.valid_until ?? void 0,
|
|
3632
3682
|
created_at: e.created_at,
|
|
3633
3683
|
last_used_at: e.last_used_at ?? void 0
|
|
3634
3684
|
};
|
|
3635
3685
|
}
|
|
3636
|
-
function
|
|
3686
|
+
function Tr(e) {
|
|
3637
3687
|
return {
|
|
3638
3688
|
async create(t, n) {
|
|
3639
3689
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3656,14 +3706,14 @@ function wr(e) {
|
|
|
3656
3706
|
},
|
|
3657
3707
|
async get(n, r) {
|
|
3658
3708
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))).limit(1);
|
|
3659
|
-
return i[0] ?
|
|
3709
|
+
return i[0] ? wr(i[0]) : null;
|
|
3660
3710
|
},
|
|
3661
3711
|
async getByHash(n, r) {
|
|
3662
3712
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.token_hash, r))).limit(1);
|
|
3663
|
-
return i[0] ?
|
|
3713
|
+
return i[0] ? wr(i[0]) : null;
|
|
3664
3714
|
},
|
|
3665
3715
|
async listByConnection(n, r) {
|
|
3666
|
-
return (await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.connection_id, r)))).map(
|
|
3716
|
+
return (await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.connection_id, r)))).map(wr);
|
|
3667
3717
|
},
|
|
3668
3718
|
async markUsed(n, r, i) {
|
|
3669
3719
|
return (await e.select({ token_id: Y.token_id }).from(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(Y).set({ last_used_at: i }).where(t(a(Y.tenant_id, n), a(Y.token_id, r))), !0);
|
|
@@ -3673,7 +3723,7 @@ function wr(e) {
|
|
|
3673
3723
|
}
|
|
3674
3724
|
};
|
|
3675
3725
|
}
|
|
3676
|
-
function
|
|
3726
|
+
function Er(e) {
|
|
3677
3727
|
return {
|
|
3678
3728
|
connection_id: e.connection_id,
|
|
3679
3729
|
external_id: e.external_id,
|
|
@@ -3681,7 +3731,7 @@ function Tr(e) {
|
|
|
3681
3731
|
created_at: e.created_at
|
|
3682
3732
|
};
|
|
3683
3733
|
}
|
|
3684
|
-
function
|
|
3734
|
+
function Dr(e) {
|
|
3685
3735
|
return {
|
|
3686
3736
|
async create(t, n) {
|
|
3687
3737
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3690,7 +3740,7 @@ function Er(e) {
|
|
|
3690
3740
|
user_id: n.user_id,
|
|
3691
3741
|
created_at: r
|
|
3692
3742
|
};
|
|
3693
|
-
return await e.insert(
|
|
3743
|
+
return await e.insert(ht).values({
|
|
3694
3744
|
tenant_id: t,
|
|
3695
3745
|
connection_id: i.connection_id,
|
|
3696
3746
|
external_id: i.external_id,
|
|
@@ -3699,21 +3749,21 @@ function Er(e) {
|
|
|
3699
3749
|
}), i;
|
|
3700
3750
|
},
|
|
3701
3751
|
async getByExternalId(n, r, i) {
|
|
3702
|
-
let o = await e.select().from(
|
|
3703
|
-
return o[0] ?
|
|
3752
|
+
let o = await e.select().from(ht).where(t(a(ht.tenant_id, n), a(ht.connection_id, r), a(ht.external_id, i))).limit(1);
|
|
3753
|
+
return o[0] ? Er(o[0]) : null;
|
|
3704
3754
|
},
|
|
3705
3755
|
async getByUserId(n, r, i) {
|
|
3706
|
-
let o = await e.select().from(
|
|
3707
|
-
return o[0] ?
|
|
3756
|
+
let o = await e.select().from(ht).where(t(a(ht.tenant_id, n), a(ht.connection_id, r), a(ht.user_id, i))).limit(1);
|
|
3757
|
+
return o[0] ? Er(o[0]) : null;
|
|
3708
3758
|
},
|
|
3709
3759
|
async remove(n, r, i) {
|
|
3710
|
-
return (await e.select({ user_id:
|
|
3760
|
+
return (await e.select({ user_id: ht.user_id }).from(ht).where(t(a(ht.tenant_id, n), a(ht.connection_id, r), a(ht.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(ht).where(t(a(ht.tenant_id, n), a(ht.connection_id, r), a(ht.user_id, i))), !0);
|
|
3711
3761
|
}
|
|
3712
3762
|
};
|
|
3713
3763
|
}
|
|
3714
3764
|
//#endregion
|
|
3715
3765
|
//#region src/adapters/refreshTokens.ts
|
|
3716
|
-
function
|
|
3766
|
+
function Or(e) {
|
|
3717
3767
|
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, auth_strategy_strategy: d, auth_strategy_strategy_type: f, ...p } = e, m = ae({
|
|
3718
3768
|
created_at_ts: n,
|
|
3719
3769
|
expires_at_ts: r,
|
|
@@ -3740,10 +3790,10 @@ function Dr(e) {
|
|
|
3740
3790
|
} } : {}
|
|
3741
3791
|
});
|
|
3742
3792
|
}
|
|
3743
|
-
function
|
|
3793
|
+
function kr(e, t) {
|
|
3744
3794
|
return Math.max(e ?? 0, t ?? 0);
|
|
3745
3795
|
}
|
|
3746
|
-
function
|
|
3796
|
+
function Ar(e) {
|
|
3747
3797
|
return {
|
|
3748
3798
|
async create(n, r) {
|
|
3749
3799
|
let i = Date.now(), o = {
|
|
@@ -3769,39 +3819,39 @@ function kr(e) {
|
|
|
3769
3819
|
expires_at_ts: E(r.expires_at),
|
|
3770
3820
|
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3771
3821
|
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3772
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3822
|
+
}, s = [e.insert(N).values(o)], c = kr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3773
3823
|
return c > 0 && o.login_id && s.push(e.update(P).set({
|
|
3774
3824
|
expires_at_ts: c,
|
|
3775
3825
|
updated_at_ts: i
|
|
3776
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await
|
|
3826
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await Ft(e, s), Or({
|
|
3777
3827
|
...o,
|
|
3778
3828
|
tenant_id: n
|
|
3779
3829
|
});
|
|
3780
3830
|
},
|
|
3781
3831
|
async get(n, r) {
|
|
3782
3832
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3783
|
-
return i ?
|
|
3833
|
+
return i ? Or(i) : null;
|
|
3784
3834
|
},
|
|
3785
3835
|
async getByLookup(n, r) {
|
|
3786
3836
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
|
|
3787
|
-
return i ?
|
|
3837
|
+
return i ? Or(i) : null;
|
|
3788
3838
|
},
|
|
3789
3839
|
async update(n, r, i) {
|
|
3790
3840
|
let o = {};
|
|
3791
3841
|
return i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.resource_servers !== void 0 && (o.resource_servers = JSON.stringify(i.resource_servers)), i.rotating !== void 0 && (o.rotating = i.rotating), i.token_lookup !== void 0 && (o.token_lookup = i.token_lookup), i.token_hash !== void 0 && (o.token_hash = i.token_hash), i.family_id !== void 0 && (o.family_id = i.family_id), i.rotated_to !== void 0 && (o.rotated_to = i.rotated_to), i.rotated_at !== void 0 && (o.rotated_at_ts = E(i.rotated_at)), i.expires_at !== void 0 && (o.expires_at_ts = E(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = E(i.idle_expires_at)), i.last_exchanged_at !== void 0 && (o.last_exchanged_at_ts = E(i.last_exchanged_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = E(i.revoked_at)), (await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning()).length > 0;
|
|
3792
3842
|
},
|
|
3793
3843
|
async list(o, s) {
|
|
3794
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3844
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(N, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3795
3845
|
a(N.tenant_id, o),
|
|
3796
3846
|
...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
|
|
3797
3847
|
...p ? [p] : []
|
|
3798
3848
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3799
|
-
if (
|
|
3849
|
+
if (Tt(s)) {
|
|
3800
3850
|
let n = {
|
|
3801
3851
|
sortColumn: N.created_at_ts,
|
|
3802
3852
|
idColumn: N.id,
|
|
3803
3853
|
sortOrder: "desc"
|
|
3804
|
-
}, r =
|
|
3854
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...Et(n)).limit(i + 1), i, "created_at_ts"), c = a.map(Or);
|
|
3805
3855
|
return {
|
|
3806
3856
|
refresh_tokens: c,
|
|
3807
3857
|
start: 0,
|
|
@@ -3815,7 +3865,7 @@ function kr(e) {
|
|
|
3815
3865
|
let e = N[d.sort_by];
|
|
3816
3866
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3817
3867
|
}
|
|
3818
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3868
|
+
let _ = (await g.offset(c * l).limit(l)).map(Or);
|
|
3819
3869
|
if (!u) return { refresh_tokens: _ };
|
|
3820
3870
|
let [v] = await e.select({ count: r() }).from(N).where(h);
|
|
3821
3871
|
return {
|
|
@@ -3844,15 +3894,15 @@ function kr(e) {
|
|
|
3844
3894
|
}
|
|
3845
3895
|
//#endregion
|
|
3846
3896
|
//#region src/adapters/resourceServers.ts
|
|
3847
|
-
var
|
|
3848
|
-
function
|
|
3897
|
+
var jr = ["name", "identifier"];
|
|
3898
|
+
function Mr() {
|
|
3849
3899
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3850
3900
|
}
|
|
3851
|
-
var
|
|
3901
|
+
var Nr = [
|
|
3852
3902
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3853
3903
|
"allow_offline_access",
|
|
3854
3904
|
"is_system"
|
|
3855
|
-
],
|
|
3905
|
+
], Pr = new Set([
|
|
3856
3906
|
"id",
|
|
3857
3907
|
"tenant_id",
|
|
3858
3908
|
"identifier",
|
|
@@ -3871,17 +3921,17 @@ var Mr = [
|
|
|
3871
3921
|
"created_at",
|
|
3872
3922
|
"updated_at"
|
|
3873
3923
|
]);
|
|
3874
|
-
function
|
|
3924
|
+
function Fr(e) {
|
|
3875
3925
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3876
3926
|
s.scopes = X(r, []), s.options = X(i, {}), s.metadata = X(a), n !== void 0 && (s.verificationKey = n);
|
|
3877
|
-
for (let e of
|
|
3927
|
+
for (let e of Nr) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3878
3928
|
return D(s);
|
|
3879
3929
|
}
|
|
3880
|
-
function
|
|
3930
|
+
function Ir(e) {
|
|
3881
3931
|
return {
|
|
3882
3932
|
async create(t, n) {
|
|
3883
3933
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3884
|
-
id: n.id ||
|
|
3934
|
+
id: n.id || Mr(),
|
|
3885
3935
|
tenant_id: t,
|
|
3886
3936
|
identifier: n.identifier,
|
|
3887
3937
|
name: n.name,
|
|
@@ -3892,41 +3942,44 @@ function Fr(e) {
|
|
|
3892
3942
|
scopes: JSON.stringify(n.scopes || []),
|
|
3893
3943
|
options: JSON.stringify(n.options || {}),
|
|
3894
3944
|
metadata: n.metadata ? JSON.stringify(n.metadata) : void 0,
|
|
3945
|
+
scope: n.scope,
|
|
3946
|
+
override: n.override,
|
|
3947
|
+
enforce: n.enforce,
|
|
3895
3948
|
verification_key: n.verificationKey || n.verification_key,
|
|
3896
3949
|
created_at: r,
|
|
3897
3950
|
updated_at: r
|
|
3898
3951
|
};
|
|
3899
|
-
for (let e of
|
|
3900
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(G).values(i),
|
|
3952
|
+
for (let e of Nr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3953
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(G).values(i), Fr({
|
|
3901
3954
|
...i,
|
|
3902
3955
|
tenant_id: t
|
|
3903
3956
|
});
|
|
3904
3957
|
},
|
|
3905
3958
|
async get(n, r) {
|
|
3906
3959
|
let i = await e.select().from(G).where(t(a(G.tenant_id, n), a(G.id, r))).get();
|
|
3907
|
-
return i ?
|
|
3960
|
+
return i ? Fr(i) : null;
|
|
3908
3961
|
},
|
|
3909
3962
|
async update(n, r, i) {
|
|
3910
3963
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3911
|
-
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(${G.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3912
|
-
for (let e of
|
|
3964
|
+
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(${G.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.scope !== void 0 && (o.scope = i.scope), i.override !== void 0 && (o.override = i.override), i.enforce !== void 0 && (o.enforce = i.enforce), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3965
|
+
for (let e of Nr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3913
3966
|
return (await e.update(G).set(o).where(t(a(G.tenant_id, n), a(G.id, r))).returning()).length > 0;
|
|
3914
3967
|
},
|
|
3915
3968
|
async list(o, s) {
|
|
3916
3969
|
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(G.tenant_id, o)];
|
|
3917
3970
|
if (f) {
|
|
3918
|
-
let e = Ee(f,
|
|
3971
|
+
let e = Ee(f, jr);
|
|
3919
3972
|
if (e) {
|
|
3920
|
-
let t =
|
|
3973
|
+
let t = wt(G, e, jr, ["name", "identifier"]);
|
|
3921
3974
|
t && h.push(t);
|
|
3922
3975
|
}
|
|
3923
3976
|
}
|
|
3924
|
-
if (
|
|
3977
|
+
if (Tt(s)) {
|
|
3925
3978
|
let n = {
|
|
3926
3979
|
sortColumn: G.created_at,
|
|
3927
3980
|
idColumn: G.id,
|
|
3928
3981
|
sortOrder: "desc"
|
|
3929
|
-
}, r =
|
|
3982
|
+
}, r = Dt(s, n), i = Z(s), { rows: a, next: o } = Ot(await e.select().from(G).where(t(...h, r)).orderBy(...Et(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Fr);
|
|
3930
3983
|
return {
|
|
3931
3984
|
resource_servers: c,
|
|
3932
3985
|
start: 0,
|
|
@@ -3936,11 +3989,11 @@ function Fr(e) {
|
|
|
3936
3989
|
};
|
|
3937
3990
|
}
|
|
3938
3991
|
let g = e.select().from(G).where(t(...h)).$dynamic();
|
|
3939
|
-
if (d?.sort_by &&
|
|
3992
|
+
if (d?.sort_by && Pr.has(d.sort_by)) {
|
|
3940
3993
|
let e = G[d.sort_by];
|
|
3941
3994
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3942
3995
|
}
|
|
3943
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3996
|
+
let _ = (await g.offset(p * m).limit(m)).map(Fr);
|
|
3944
3997
|
if (!u) return { resource_servers: _ };
|
|
3945
3998
|
let [v] = await e.select({ count: r() }).from(G).where(t(...h));
|
|
3946
3999
|
return {
|
|
@@ -3957,7 +4010,7 @@ function Fr(e) {
|
|
|
3957
4010
|
}
|
|
3958
4011
|
//#endregion
|
|
3959
4012
|
//#region src/adapters/rolePermissions.ts
|
|
3960
|
-
function
|
|
4013
|
+
function Lr(e) {
|
|
3961
4014
|
return {
|
|
3962
4015
|
async assign(t, n, r) {
|
|
3963
4016
|
if (r.length === 0) return !0;
|
|
@@ -3976,21 +4029,21 @@ function Ir(e) {
|
|
|
3976
4029
|
permission_name: U.permission_name,
|
|
3977
4030
|
created_at: U.created_at
|
|
3978
4031
|
}).from(U).where(t(a(U.tenant_id, n), a(U.role_id, r))).orderBy(U.resource_server_identifier, U.permission_name).$dynamic();
|
|
3979
|
-
return
|
|
4032
|
+
return Rr(e, n, await (o === void 0 ? s : s.limit(o).offset((i?.page ?? 0) * o)).all());
|
|
3980
4033
|
},
|
|
3981
4034
|
async listCheckpoint(n, r, i = {}) {
|
|
3982
4035
|
let o = {
|
|
3983
4036
|
sortColumn: U.resource_server_identifier,
|
|
3984
4037
|
idColumn: U.permission_name,
|
|
3985
4038
|
sortOrder: "asc"
|
|
3986
|
-
}, s = Z(i), { rows: c, next: l } =
|
|
4039
|
+
}, s = Z(i), { rows: c, next: l } = Ot(await e.select({
|
|
3987
4040
|
role_id: U.role_id,
|
|
3988
4041
|
resource_server_identifier: U.resource_server_identifier,
|
|
3989
4042
|
permission_name: U.permission_name,
|
|
3990
4043
|
created_at: U.created_at
|
|
3991
|
-
}).from(U).where(t(a(U.tenant_id, n), a(U.role_id, r),
|
|
4044
|
+
}).from(U).where(t(a(U.tenant_id, n), a(U.role_id, r), Dt(i, o))).orderBy(...Et(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
|
|
3992
4045
|
return {
|
|
3993
|
-
permissions: await
|
|
4046
|
+
permissions: await Rr(e, n, c),
|
|
3994
4047
|
next: l
|
|
3995
4048
|
};
|
|
3996
4049
|
},
|
|
@@ -4001,7 +4054,7 @@ function Ir(e) {
|
|
|
4001
4054
|
}
|
|
4002
4055
|
};
|
|
4003
4056
|
}
|
|
4004
|
-
async function
|
|
4057
|
+
async function Rr(e, n, r) {
|
|
4005
4058
|
let i = [...new Set(r.map((e) => e.resource_server_identifier))], o = /* @__PURE__ */ new Map();
|
|
4006
4059
|
if (i.length > 0) {
|
|
4007
4060
|
let r = await e.select({
|
|
@@ -4017,18 +4070,18 @@ async function Lr(e, n, r) {
|
|
|
4017
4070
|
}
|
|
4018
4071
|
//#endregion
|
|
4019
4072
|
//#region src/adapters/userPermissions.ts
|
|
4020
|
-
function
|
|
4073
|
+
function zr(e) {
|
|
4021
4074
|
try {
|
|
4022
4075
|
let t = JSON.parse(e);
|
|
4023
4076
|
if (Array.isArray(t) && t.length === 2 && t.every((e) => typeof e == "string")) return t;
|
|
4024
4077
|
} catch {}
|
|
4025
4078
|
throw new Re(400, { message: "The `from` cursor is not valid" });
|
|
4026
4079
|
}
|
|
4027
|
-
function
|
|
4080
|
+
function Br(e) {
|
|
4028
4081
|
return {
|
|
4029
4082
|
async create(t, n, r, i) {
|
|
4030
4083
|
try {
|
|
4031
|
-
await e.insert(
|
|
4084
|
+
await e.insert($e).values({
|
|
4032
4085
|
tenant_id: t,
|
|
4033
4086
|
user_id: n,
|
|
4034
4087
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -4043,9 +4096,9 @@ function zr(e) {
|
|
|
4043
4096
|
return !0;
|
|
4044
4097
|
},
|
|
4045
4098
|
async list(n, r, i, o) {
|
|
4046
|
-
let s = [a(
|
|
4047
|
-
o && s.push(a(
|
|
4048
|
-
let c = await e.select().from(
|
|
4099
|
+
let s = [a($e.tenant_id, n), a($e.user_id, r)];
|
|
4100
|
+
o && s.push(a($e.organization_id, o));
|
|
4101
|
+
let c = await e.select().from($e).where(t(...s)).all();
|
|
4049
4102
|
return await Promise.all(c.map(async (r) => {
|
|
4050
4103
|
let i = await e.select({ name: G.name }).from(G).where(t(a(G.tenant_id, n), a(G.identifier, r.resource_server_identifier))).get();
|
|
4051
4104
|
return {
|
|
@@ -4057,15 +4110,15 @@ function zr(e) {
|
|
|
4057
4110
|
}));
|
|
4058
4111
|
},
|
|
4059
4112
|
async listCheckpoint(r, i, o = {}, s) {
|
|
4060
|
-
let c = Z(o), u = [a(
|
|
4061
|
-
s !== void 0 && u.push(a(
|
|
4113
|
+
let c = Z(o), u = [a($e.tenant_id, r), a($e.user_id, i)];
|
|
4114
|
+
s !== void 0 && u.push(a($e.organization_id, s));
|
|
4062
4115
|
let d = o.from ? ge(o.from) : null;
|
|
4063
4116
|
if (d) {
|
|
4064
4117
|
if (d.k !== void 0) throw new Re(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
4065
|
-
let [e, t] =
|
|
4066
|
-
u.push(y`(${
|
|
4118
|
+
let [e, t] = zr(d.i);
|
|
4119
|
+
u.push(y`(${$e.resource_server_identifier}, ${$e.permission_name}, ${$e.organization_id}) > (${d.s}, ${e}, ${t})`);
|
|
4067
4120
|
}
|
|
4068
|
-
let f = await e.select().from(
|
|
4121
|
+
let f = await e.select().from($e).where(t(...u)).orderBy(n($e.resource_server_identifier), n($e.permission_name), n($e.organization_id)).limit(c + 1).all(), p = f.length > c, m = p ? f.slice(0, c) : f, h = m[m.length - 1], g = p && h ? _e({
|
|
4069
4122
|
s: h.resource_server_identifier,
|
|
4070
4123
|
i: JSON.stringify([h.permission_name, h.organization_id])
|
|
4071
4124
|
}) : void 0, _ = [...new Set(m.map((e) => e.resource_server_identifier))], v = /* @__PURE__ */ new Map();
|
|
@@ -4089,13 +4142,13 @@ function zr(e) {
|
|
|
4089
4142
|
};
|
|
4090
4143
|
},
|
|
4091
4144
|
async remove(n, r, i, o) {
|
|
4092
|
-
return (await e.delete(
|
|
4145
|
+
return (await e.delete($e).where(t(a($e.tenant_id, n), a($e.user_id, r), a($e.resource_server_identifier, i.resource_server_identifier), a($e.permission_name, i.permission_name), a($e.organization_id, o || ""))).returning()).length > 0;
|
|
4093
4146
|
}
|
|
4094
4147
|
};
|
|
4095
4148
|
}
|
|
4096
4149
|
//#endregion
|
|
4097
4150
|
//#region src/adapters/roles.ts
|
|
4098
|
-
function
|
|
4151
|
+
function Vr(e) {
|
|
4099
4152
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
4100
4153
|
return D({
|
|
4101
4154
|
...i,
|
|
@@ -4103,7 +4156,7 @@ function Br(e) {
|
|
|
4103
4156
|
metadata: X(r)
|
|
4104
4157
|
});
|
|
4105
4158
|
}
|
|
4106
|
-
function
|
|
4159
|
+
function Hr(e) {
|
|
4107
4160
|
return {
|
|
4108
4161
|
async create(t, n) {
|
|
4109
4162
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4116,29 +4169,29 @@ function Vr(e) {
|
|
|
4116
4169
|
created_at: r,
|
|
4117
4170
|
updated_at: r
|
|
4118
4171
|
};
|
|
4119
|
-
return await e.insert(H).values(i),
|
|
4172
|
+
return await e.insert(H).values(i), Vr({
|
|
4120
4173
|
...i,
|
|
4121
4174
|
tenant_id: t
|
|
4122
4175
|
});
|
|
4123
4176
|
},
|
|
4124
4177
|
async get(n, r) {
|
|
4125
4178
|
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
4126
|
-
return i ?
|
|
4179
|
+
return i ? Vr(i) : null;
|
|
4127
4180
|
},
|
|
4128
4181
|
async update(n, r, i) {
|
|
4129
4182
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4130
4183
|
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(H).set(o).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
4131
4184
|
},
|
|
4132
4185
|
async list(o, s) {
|
|
4133
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
4134
|
-
if (
|
|
4186
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(H, f, ["name"]) : void 0, m = p ? t(a(H.tenant_id, o), p) : a(H.tenant_id, o);
|
|
4187
|
+
if (Tt(s)) {
|
|
4135
4188
|
let n = {
|
|
4136
4189
|
sortColumn: H.created_at,
|
|
4137
4190
|
idColumn: H.id,
|
|
4138
4191
|
sortOrder: "desc"
|
|
4139
|
-
}, r = Z(s), { rows: i, next: a } =
|
|
4192
|
+
}, r = Z(s), { rows: i, next: a } = Ot(await e.select().from(H).where(t(m, Dt(s, n))).orderBy(...Et(n)).limit(r + 1), r, "created_at");
|
|
4140
4193
|
return {
|
|
4141
|
-
roles: i.map(
|
|
4194
|
+
roles: i.map(Vr),
|
|
4142
4195
|
start: 0,
|
|
4143
4196
|
limit: r,
|
|
4144
4197
|
length: i.length,
|
|
@@ -4150,7 +4203,7 @@ function Vr(e) {
|
|
|
4150
4203
|
let e = H[d.sort_by];
|
|
4151
4204
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
4152
4205
|
}
|
|
4153
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4206
|
+
let g = (await h.offset(c * l).limit(l)).map(Vr);
|
|
4154
4207
|
if (!u) return { roles: g };
|
|
4155
4208
|
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
4156
4209
|
return {
|
|
@@ -4167,7 +4220,7 @@ function Vr(e) {
|
|
|
4167
4220
|
}
|
|
4168
4221
|
//#endregion
|
|
4169
4222
|
//#region src/adapters/sessions.ts
|
|
4170
|
-
var
|
|
4223
|
+
var Ur = ["created_at_ts", "updated_at_ts"], Wr = [
|
|
4171
4224
|
"expires_at_ts",
|
|
4172
4225
|
"idle_expires_at_ts",
|
|
4173
4226
|
"authenticated_at_ts",
|
|
@@ -4175,7 +4228,7 @@ var Hr = ["created_at_ts", "updated_at_ts"], Ur = [
|
|
|
4175
4228
|
"used_at_ts",
|
|
4176
4229
|
"revoked_at_ts"
|
|
4177
4230
|
];
|
|
4178
|
-
function
|
|
4231
|
+
function Gr(e) {
|
|
4179
4232
|
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 = ae({
|
|
4180
4233
|
created_at_ts: n,
|
|
4181
4234
|
updated_at_ts: r,
|
|
@@ -4185,7 +4238,7 @@ function Wr(e) {
|
|
|
4185
4238
|
last_interaction_at_ts: s,
|
|
4186
4239
|
used_at_ts: c,
|
|
4187
4240
|
revoked_at_ts: l
|
|
4188
|
-
}, [...
|
|
4241
|
+
}, [...Ur], [...Wr]);
|
|
4189
4242
|
return D({
|
|
4190
4243
|
...f,
|
|
4191
4244
|
...p,
|
|
@@ -4193,10 +4246,10 @@ function Wr(e) {
|
|
|
4193
4246
|
clients: X(d, [])
|
|
4194
4247
|
});
|
|
4195
4248
|
}
|
|
4196
|
-
function
|
|
4249
|
+
function Kr(e, t) {
|
|
4197
4250
|
return Math.max(e ?? 0, t ?? 0);
|
|
4198
4251
|
}
|
|
4199
|
-
function
|
|
4252
|
+
function qr(e) {
|
|
4200
4253
|
return {
|
|
4201
4254
|
async create(n, r) {
|
|
4202
4255
|
let i = Date.now(), o = {
|
|
@@ -4214,23 +4267,23 @@ function Kr(e) {
|
|
|
4214
4267
|
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
4215
4268
|
used_at_ts: E(r.used_at),
|
|
4216
4269
|
revoked_at_ts: E(r.revoked_at)
|
|
4217
|
-
}, s = [e.insert(M).values(o)], c =
|
|
4270
|
+
}, s = [e.insert(M).values(o)], c = Kr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
4218
4271
|
return c > 0 && o.login_session_id && s.push(e.update(P).set({
|
|
4219
4272
|
expires_at_ts: c,
|
|
4220
4273
|
updated_at_ts: i
|
|
4221
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await
|
|
4274
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await Ft(e, s), Gr({
|
|
4222
4275
|
...o,
|
|
4223
4276
|
tenant_id: n
|
|
4224
4277
|
});
|
|
4225
4278
|
},
|
|
4226
4279
|
async get(n, r) {
|
|
4227
4280
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
|
|
4228
|
-
return i ?
|
|
4281
|
+
return i ? Gr(i) : null;
|
|
4229
4282
|
},
|
|
4230
4283
|
async update(n, r, i) {
|
|
4231
4284
|
let o = { updated_at_ts: Date.now() };
|
|
4232
4285
|
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 = E(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = E(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = E(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = E(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = E(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = E(i.revoked_at));
|
|
4233
|
-
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c =
|
|
4286
|
+
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Kr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
4234
4287
|
if (c > 0 && l) {
|
|
4235
4288
|
let r = i.login_session_id ?? l.login_session_id;
|
|
4236
4289
|
r && await e.update(P).set({
|
|
@@ -4241,13 +4294,13 @@ function Kr(e) {
|
|
|
4241
4294
|
return s.length > 0;
|
|
4242
4295
|
},
|
|
4243
4296
|
async list(o, s) {
|
|
4244
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
4245
|
-
if (
|
|
4297
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? wt(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o);
|
|
4298
|
+
if (Tt(s)) {
|
|
4246
4299
|
let n = {
|
|
4247
4300
|
sortColumn: M.created_at_ts,
|
|
4248
4301
|
idColumn: M.id,
|
|
4249
4302
|
sortOrder: "desc"
|
|
4250
|
-
}, r = Z(s), i =
|
|
4303
|
+
}, r = Z(s), i = Dt(s, n), { rows: a, next: o } = Ot(await e.select().from(M).where(i ? t(m, i) : m).orderBy(...Et(n)).limit(r + 1), r, "created_at_ts"), c = a.map(Gr);
|
|
4251
4304
|
return {
|
|
4252
4305
|
sessions: c,
|
|
4253
4306
|
start: 0,
|
|
@@ -4261,7 +4314,7 @@ function Kr(e) {
|
|
|
4261
4314
|
let e = M[d.sort_by];
|
|
4262
4315
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
4263
4316
|
}
|
|
4264
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4317
|
+
let g = (await h.offset(c * l).limit(l)).map(Gr);
|
|
4265
4318
|
if (!u) return { sessions: g };
|
|
4266
4319
|
let [_] = await e.select({ count: r() }).from(M).where(m);
|
|
4267
4320
|
return {
|
|
@@ -4278,7 +4331,7 @@ function Kr(e) {
|
|
|
4278
4331
|
}
|
|
4279
4332
|
//#endregion
|
|
4280
4333
|
//#region src/adapters/tenants.ts
|
|
4281
|
-
var
|
|
4334
|
+
var Jr = [
|
|
4282
4335
|
"session_cookie",
|
|
4283
4336
|
"enabled_locales",
|
|
4284
4337
|
"error_page",
|
|
@@ -4294,25 +4347,25 @@ var qr = [
|
|
|
4294
4347
|
"acr_values_supported",
|
|
4295
4348
|
"mtls",
|
|
4296
4349
|
"mfa"
|
|
4297
|
-
],
|
|
4350
|
+
], Yr = [
|
|
4298
4351
|
"allow_organization_name_in_authentication_api",
|
|
4299
4352
|
"customize_mfa_in_postlogin_action",
|
|
4300
4353
|
"pushed_authorization_requests_supported",
|
|
4301
4354
|
"authorization_response_iss_parameter_supported"
|
|
4302
4355
|
];
|
|
4303
|
-
function
|
|
4356
|
+
function Xr(e) {
|
|
4304
4357
|
let t = { ...e };
|
|
4305
|
-
for (let e of
|
|
4306
|
-
for (let e of
|
|
4358
|
+
for (let e of Jr) typeof t[e] == "string" && (t[e] = X(t[e]));
|
|
4359
|
+
for (let e of Yr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
4307
4360
|
return D(t);
|
|
4308
4361
|
}
|
|
4309
|
-
function
|
|
4362
|
+
function Zr(e) {
|
|
4310
4363
|
let t = { ...e };
|
|
4311
|
-
le(e,
|
|
4312
|
-
for (let n of
|
|
4364
|
+
le(e, Jr, t);
|
|
4365
|
+
for (let n of Yr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
4313
4366
|
return ce(t);
|
|
4314
4367
|
}
|
|
4315
|
-
function
|
|
4368
|
+
function Qr(e) {
|
|
4316
4369
|
return {
|
|
4317
4370
|
async create(t) {
|
|
4318
4371
|
let n = {
|
|
@@ -4320,7 +4373,7 @@ function Zr(e) {
|
|
|
4320
4373
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4321
4374
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4322
4375
|
...t
|
|
4323
|
-
}, r =
|
|
4376
|
+
}, r = Zr(n);
|
|
4324
4377
|
try {
|
|
4325
4378
|
await e.insert(O).values(r);
|
|
4326
4379
|
} catch (e) {
|
|
@@ -4331,28 +4384,30 @@ function Zr(e) {
|
|
|
4331
4384
|
},
|
|
4332
4385
|
async get(t) {
|
|
4333
4386
|
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
4334
|
-
return n ?
|
|
4387
|
+
return n ? Xr(n) : null;
|
|
4335
4388
|
},
|
|
4336
4389
|
async list(t) {
|
|
4337
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
4390
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? wt(O, l, ["id", "friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
4338
4391
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
4339
4392
|
let e = O[c.sort_by];
|
|
4340
4393
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
4341
4394
|
}
|
|
4342
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
4395
|
+
let f = (await d.offset(a * o).limit(o)).map(Xr);
|
|
4343
4396
|
if (!s) return { tenants: f };
|
|
4344
4397
|
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
4345
4398
|
u && (p = p.where(u));
|
|
4346
4399
|
let [m] = await p;
|
|
4347
4400
|
return {
|
|
4348
4401
|
tenants: f,
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4402
|
+
totals: {
|
|
4403
|
+
start: a * o,
|
|
4404
|
+
limit: o,
|
|
4405
|
+
length: Number(m?.count ?? 0)
|
|
4406
|
+
}
|
|
4352
4407
|
};
|
|
4353
4408
|
},
|
|
4354
4409
|
async update(t, n) {
|
|
4355
|
-
let r =
|
|
4410
|
+
let r = Zr({
|
|
4356
4411
|
...n,
|
|
4357
4412
|
id: t,
|
|
4358
4413
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -4366,62 +4421,62 @@ function Zr(e) {
|
|
|
4366
4421
|
}
|
|
4367
4422
|
//#endregion
|
|
4368
4423
|
//#region src/adapters/themes.ts
|
|
4369
|
-
var
|
|
4424
|
+
var $r = [
|
|
4370
4425
|
"colors",
|
|
4371
4426
|
"borders",
|
|
4372
4427
|
"fonts",
|
|
4373
4428
|
"page_background",
|
|
4374
4429
|
"widget"
|
|
4375
4430
|
];
|
|
4376
|
-
function
|
|
4377
|
-
let { tenant_id: t, ...n } = e, r =
|
|
4431
|
+
function ei(e) {
|
|
4432
|
+
let { tenant_id: t, ...n } = e, r = xt(n, $r);
|
|
4378
4433
|
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), D(r);
|
|
4379
4434
|
}
|
|
4380
|
-
function
|
|
4435
|
+
function ti(e) {
|
|
4381
4436
|
return {
|
|
4382
4437
|
async create(t, n, r, i) {
|
|
4383
4438
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
4384
|
-
...
|
|
4439
|
+
...bt(n),
|
|
4385
4440
|
tenant_id: t,
|
|
4386
4441
|
themeId: s,
|
|
4387
4442
|
created_at: a?.created_at ?? o,
|
|
4388
4443
|
updated_at: a?.updated_at ?? o
|
|
4389
4444
|
};
|
|
4390
|
-
return await e.insert(
|
|
4445
|
+
return await e.insert(nt).values(c), ei({
|
|
4391
4446
|
...c,
|
|
4392
4447
|
tenant_id: t
|
|
4393
4448
|
});
|
|
4394
4449
|
},
|
|
4395
4450
|
async get(n, r) {
|
|
4396
|
-
let i = await e.select().from(
|
|
4397
|
-
return i ?
|
|
4451
|
+
let i = await e.select().from(nt).where(t(a(nt.tenant_id, n), a(nt.themeId, r))).get();
|
|
4452
|
+
return i ? ei(i) : null;
|
|
4398
4453
|
},
|
|
4399
4454
|
async update(n, r, i) {
|
|
4400
|
-
let o =
|
|
4401
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
4455
|
+
let o = bt(i);
|
|
4456
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(nt).set(o).where(t(a(nt.tenant_id, n), a(nt.themeId, r))), !0;
|
|
4402
4457
|
},
|
|
4403
4458
|
async remove(n, r) {
|
|
4404
|
-
return (await e.delete(
|
|
4459
|
+
return (await e.delete(nt).where(t(a(nt.tenant_id, n), a(nt.themeId, r))).returning()).length > 0;
|
|
4405
4460
|
}
|
|
4406
4461
|
};
|
|
4407
4462
|
}
|
|
4408
4463
|
//#endregion
|
|
4409
4464
|
//#region src/adapters/universalLoginTemplates.ts
|
|
4410
|
-
function
|
|
4465
|
+
function ni(e) {
|
|
4411
4466
|
return {
|
|
4412
4467
|
async get(t) {
|
|
4413
|
-
let n = await e.select({ body:
|
|
4468
|
+
let n = await e.select({ body: tt.body }).from(tt).where(a(tt.tenant_id, t)).get();
|
|
4414
4469
|
return n ? { body: n.body } : null;
|
|
4415
4470
|
},
|
|
4416
4471
|
async set(t, n) {
|
|
4417
4472
|
let r = Date.now();
|
|
4418
|
-
await e.insert(
|
|
4473
|
+
await e.insert(tt).values({
|
|
4419
4474
|
tenant_id: t,
|
|
4420
4475
|
body: n.body,
|
|
4421
4476
|
created_at_ts: r,
|
|
4422
4477
|
updated_at_ts: r
|
|
4423
4478
|
}).onConflictDoUpdate({
|
|
4424
|
-
target:
|
|
4479
|
+
target: tt.tenant_id,
|
|
4425
4480
|
set: {
|
|
4426
4481
|
body: n.body,
|
|
4427
4482
|
updated_at_ts: r
|
|
@@ -4429,20 +4484,20 @@ function ti(e) {
|
|
|
4429
4484
|
});
|
|
4430
4485
|
},
|
|
4431
4486
|
async delete(t) {
|
|
4432
|
-
await e.delete(
|
|
4487
|
+
await e.delete(tt).where(a(tt.tenant_id, t));
|
|
4433
4488
|
}
|
|
4434
4489
|
};
|
|
4435
4490
|
}
|
|
4436
4491
|
//#endregion
|
|
4437
4492
|
//#region src/adapters/userActivity.ts
|
|
4438
|
-
function
|
|
4493
|
+
function ri(e) {
|
|
4439
4494
|
let t = {};
|
|
4440
4495
|
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;
|
|
4441
4496
|
}
|
|
4442
|
-
function
|
|
4497
|
+
function ii(e) {
|
|
4443
4498
|
return {
|
|
4444
4499
|
async get(n, r) {
|
|
4445
|
-
let i = await e.select().from(
|
|
4500
|
+
let i = await e.select().from(We).where(t(a(We.tenant_id, n), a(We.user_id, r))).get();
|
|
4446
4501
|
return i ? {
|
|
4447
4502
|
user_id: i.user_id,
|
|
4448
4503
|
last_login: i.last_login ?? void 0,
|
|
@@ -4453,7 +4508,7 @@ function ri(e) {
|
|
|
4453
4508
|
} : null;
|
|
4454
4509
|
},
|
|
4455
4510
|
async upsert(t, n, r) {
|
|
4456
|
-
let i =
|
|
4511
|
+
let i = ri(r), a = e.insert(We).values({
|
|
4457
4512
|
tenant_id: t,
|
|
4458
4513
|
user_id: n,
|
|
4459
4514
|
login_count: 0,
|
|
@@ -4464,7 +4519,7 @@ function ri(e) {
|
|
|
4464
4519
|
return;
|
|
4465
4520
|
}
|
|
4466
4521
|
await a.onConflictDoUpdate({
|
|
4467
|
-
target: [
|
|
4522
|
+
target: [We.tenant_id, We.user_id],
|
|
4468
4523
|
set: i
|
|
4469
4524
|
});
|
|
4470
4525
|
}
|
|
@@ -4472,13 +4527,13 @@ function ri(e) {
|
|
|
4472
4527
|
}
|
|
4473
4528
|
//#endregion
|
|
4474
4529
|
//#region src/adapters/outbox.ts
|
|
4475
|
-
function
|
|
4530
|
+
function ai(e) {
|
|
4476
4531
|
return {
|
|
4477
4532
|
...e,
|
|
4478
4533
|
payload: X(e.payload, {})
|
|
4479
4534
|
};
|
|
4480
4535
|
}
|
|
4481
|
-
function
|
|
4536
|
+
function oi(e, t, n, r) {
|
|
4482
4537
|
return e.insert(q).values({
|
|
4483
4538
|
id: t,
|
|
4484
4539
|
tenant_id: n,
|
|
@@ -4499,7 +4554,7 @@ function ai(e, t, n, r) {
|
|
|
4499
4554
|
claim_expires_at: null
|
|
4500
4555
|
});
|
|
4501
4556
|
}
|
|
4502
|
-
function
|
|
4557
|
+
function si(e) {
|
|
4503
4558
|
return {
|
|
4504
4559
|
...X(e.payload, {}),
|
|
4505
4560
|
id: e.id,
|
|
@@ -4512,18 +4567,18 @@ function oi(e) {
|
|
|
4512
4567
|
final_error: e.final_error
|
|
4513
4568
|
};
|
|
4514
4569
|
}
|
|
4515
|
-
function
|
|
4570
|
+
function ci(e) {
|
|
4516
4571
|
return {
|
|
4517
4572
|
async create(t, n) {
|
|
4518
4573
|
let r = b();
|
|
4519
|
-
return await
|
|
4574
|
+
return await oi(e, r, t, n), r;
|
|
4520
4575
|
},
|
|
4521
4576
|
async getByIds(t) {
|
|
4522
|
-
return t.length === 0 ? [] : (await e.select().from(q).where(l(q.id, t)).all()).map(
|
|
4577
|
+
return t.length === 0 ? [] : (await e.select().from(q).where(l(q.id, t)).all()).map(ai);
|
|
4523
4578
|
},
|
|
4524
4579
|
async getUnprocessed(n) {
|
|
4525
4580
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4526
|
-
return (await e.select().from(q).where(t(f(q.processed_at), v(f(q.next_retry_at), h(q.next_retry_at, r)), v(f(q.claimed_by), h(q.claim_expires_at, r)))).orderBy(q.created_at, q.id).limit(n).all()).map(
|
|
4581
|
+
return (await e.select().from(q).where(t(f(q.processed_at), v(f(q.next_retry_at), h(q.next_retry_at, r)), v(f(q.claimed_by), h(q.claim_expires_at, r)))).orderBy(q.created_at, q.id).limit(n).all()).map(ai);
|
|
4527
4582
|
},
|
|
4528
4583
|
async claimEvents(n, r, i) {
|
|
4529
4584
|
if (n.length === 0) return [];
|
|
@@ -4558,12 +4613,12 @@ function si(e) {
|
|
|
4558
4613
|
},
|
|
4559
4614
|
async listFailed(o, s = {}) {
|
|
4560
4615
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s;
|
|
4561
|
-
if (
|
|
4616
|
+
if (Tt(s)) {
|
|
4562
4617
|
let n = {
|
|
4563
4618
|
sortColumn: q.dead_lettered_at,
|
|
4564
4619
|
idColumn: q.id,
|
|
4565
4620
|
sortOrder: "desc"
|
|
4566
|
-
}, r = Z(s), { rows: i, next: c } =
|
|
4621
|
+
}, r = Z(s), { rows: i, next: c } = Ot(await e.select().from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at), Dt(s, n))).orderBy(...Et(n)).limit(r + 1).all(), r, "dead_lettered_at"), l = i.map(si);
|
|
4567
4622
|
return {
|
|
4568
4623
|
events: l,
|
|
4569
4624
|
start: 0,
|
|
@@ -4572,7 +4627,7 @@ function si(e) {
|
|
|
4572
4627
|
next: c
|
|
4573
4628
|
};
|
|
4574
4629
|
}
|
|
4575
|
-
let f = (await e.select().from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at))).orderBy(i(q.dead_lettered_at), n(q.id)).offset(c * l).limit(l).all()).map(
|
|
4630
|
+
let f = (await e.select().from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at))).orderBy(i(q.dead_lettered_at), n(q.id)).offset(c * l).limit(l).all()).map(si), p = f.length;
|
|
4576
4631
|
if (u) {
|
|
4577
4632
|
let [n] = await e.select({ total: r() }).from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at)));
|
|
4578
4633
|
p = Number(n?.total ?? f.length);
|
|
@@ -4603,10 +4658,10 @@ function si(e) {
|
|
|
4603
4658
|
}
|
|
4604
4659
|
//#endregion
|
|
4605
4660
|
//#region src/adapters/users.ts
|
|
4606
|
-
function
|
|
4607
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4661
|
+
function li(e, t, n) {
|
|
4662
|
+
return (n?.outboxEvents ?? []).map((n) => oi(e, n.id, t, n));
|
|
4608
4663
|
}
|
|
4609
|
-
var
|
|
4664
|
+
var ui = [
|
|
4610
4665
|
"user_id",
|
|
4611
4666
|
"email",
|
|
4612
4667
|
"email_verified",
|
|
@@ -4628,23 +4683,23 @@ var li = [
|
|
|
4628
4683
|
"login_count",
|
|
4629
4684
|
"created_at",
|
|
4630
4685
|
"updated_at"
|
|
4631
|
-
],
|
|
4686
|
+
], di = [
|
|
4632
4687
|
"email",
|
|
4633
4688
|
"name",
|
|
4634
4689
|
"phone_number",
|
|
4635
4690
|
"user_id"
|
|
4636
|
-
],
|
|
4691
|
+
], fi = new Set([
|
|
4637
4692
|
"last_login",
|
|
4638
4693
|
"last_ip",
|
|
4639
4694
|
"login_count"
|
|
4640
|
-
]),
|
|
4641
|
-
coalesce:
|
|
4695
|
+
]), pi = o(A), mi = o(We), hi = Object.fromEntries(ui.map((e) => [e, e === "login_count" ? {
|
|
4696
|
+
coalesce: We.login_count,
|
|
4642
4697
|
defaultValue: 0
|
|
4643
|
-
} :
|
|
4644
|
-
function
|
|
4645
|
-
return t(a(
|
|
4698
|
+
} : fi.has(e) ? mi[e] : pi[e]]));
|
|
4699
|
+
function gi() {
|
|
4700
|
+
return t(a(We.tenant_id, A.tenant_id), a(We.user_id, A.user_id));
|
|
4646
4701
|
}
|
|
4647
|
-
function
|
|
4702
|
+
function _i(e, t) {
|
|
4648
4703
|
return {
|
|
4649
4704
|
...e,
|
|
4650
4705
|
last_login: t?.last_login,
|
|
@@ -4652,7 +4707,7 @@ function gi(e, t) {
|
|
|
4652
4707
|
login_count: t?.login_count ?? 0
|
|
4653
4708
|
};
|
|
4654
4709
|
}
|
|
4655
|
-
function
|
|
4710
|
+
function vi(e, t) {
|
|
4656
4711
|
let n = {
|
|
4657
4712
|
connection: e.connection,
|
|
4658
4713
|
provider: e.provider,
|
|
@@ -4665,8 +4720,8 @@ function _i(e, t) {
|
|
|
4665
4720
|
...typeof e.profileData == "string" ? X(e.profileData, {}) : {}
|
|
4666
4721
|
}, n;
|
|
4667
4722
|
}
|
|
4668
|
-
function
|
|
4669
|
-
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 =
|
|
4723
|
+
function yi(e, t = []) {
|
|
4724
|
+
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 = vi(e, !0), m = t.map((e) => vi(e, !1));
|
|
4670
4725
|
return D({
|
|
4671
4726
|
...f,
|
|
4672
4727
|
email: e.email || "",
|
|
@@ -4680,7 +4735,7 @@ function vi(e, t = []) {
|
|
|
4680
4735
|
identities: [p, ...m]
|
|
4681
4736
|
});
|
|
4682
4737
|
}
|
|
4683
|
-
function
|
|
4738
|
+
function bi(e) {
|
|
4684
4739
|
let o = async (t, n, r) => {
|
|
4685
4740
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4686
4741
|
user_id: n.user_id,
|
|
@@ -4718,7 +4773,7 @@ function yi(e) {
|
|
|
4718
4773
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4719
4774
|
try {
|
|
4720
4775
|
let c = [e.insert(A).values(a)];
|
|
4721
|
-
s && c.push(e.insert(
|
|
4776
|
+
s && c.push(e.insert(We).values({
|
|
4722
4777
|
tenant_id: t,
|
|
4723
4778
|
user_id: n.user_id,
|
|
4724
4779
|
last_login: n.last_login,
|
|
@@ -4734,12 +4789,12 @@ function yi(e) {
|
|
|
4734
4789
|
created_at: i,
|
|
4735
4790
|
updated_at: i
|
|
4736
4791
|
}));
|
|
4737
|
-
for (let n of
|
|
4738
|
-
c.length > 1 ? await
|
|
4792
|
+
for (let n of li(e, t, r)) c.push(n);
|
|
4793
|
+
c.length > 1 ? await Ft(e, c) : await e.insert(A).values(a);
|
|
4739
4794
|
} catch (e) {
|
|
4740
4795
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Re(500, { message: "Internal server error" }));
|
|
4741
4796
|
}
|
|
4742
|
-
return
|
|
4797
|
+
return yi({
|
|
4743
4798
|
...a,
|
|
4744
4799
|
last_login: n.last_login,
|
|
4745
4800
|
last_ip: n.last_ip,
|
|
@@ -4750,10 +4805,10 @@ function yi(e) {
|
|
|
4750
4805
|
create: o,
|
|
4751
4806
|
rawCreate: o,
|
|
4752
4807
|
async get(n, r) {
|
|
4753
|
-
let i = await e.select().from(A).leftJoin(
|
|
4808
|
+
let i = await e.select().from(A).leftJoin(We, gi()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4754
4809
|
if (!i) return null;
|
|
4755
4810
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4756
|
-
return
|
|
4811
|
+
return yi(_i(i.users, i.user_activity), o);
|
|
4757
4812
|
},
|
|
4758
4813
|
async update(n, r, i, o) {
|
|
4759
4814
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4780,8 +4835,8 @@ function yi(e) {
|
|
|
4780
4835
|
"zoneinfo"
|
|
4781
4836
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4782
4837
|
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));
|
|
4783
|
-
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l =
|
|
4784
|
-
return u = l.length > 0 ? (await
|
|
4838
|
+
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = li(e, n, o), u;
|
|
4839
|
+
return u = l.length > 0 ? (await Ft(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 ii(e).upsert(n, r, {
|
|
4785
4840
|
last_login: i.last_login,
|
|
4786
4841
|
last_ip: i.last_ip,
|
|
4787
4842
|
login_count: i.login_count
|
|
@@ -4790,24 +4845,24 @@ function yi(e) {
|
|
|
4790
4845
|
async list(o, s) {
|
|
4791
4846
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(A.tenant_id, o), f(A.linked_to)];
|
|
4792
4847
|
if (m) {
|
|
4793
|
-
let e = Ee(m,
|
|
4848
|
+
let e = Ee(m, ui);
|
|
4794
4849
|
if (e) {
|
|
4795
|
-
let t =
|
|
4850
|
+
let t = wt(hi, e, di);
|
|
4796
4851
|
t && h.push(t);
|
|
4797
4852
|
}
|
|
4798
4853
|
}
|
|
4799
4854
|
let g = t(...h), _ = async (n) => {
|
|
4800
4855
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(A).where(t(a(A.tenant_id, o), l(A.linked_to, r))) : [];
|
|
4801
|
-
return n.map((e) =>
|
|
4856
|
+
return n.map((e) => yi(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4802
4857
|
};
|
|
4803
|
-
if (
|
|
4858
|
+
if (Tt(s)) {
|
|
4804
4859
|
if (p?.sort_by && p.sort_by !== "created_at") throw new Re(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4805
4860
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4806
4861
|
sortColumn: A.created_at,
|
|
4807
4862
|
idColumn: A.user_id,
|
|
4808
4863
|
sortOrder: n,
|
|
4809
4864
|
sortKey: `created_at:${n}`
|
|
4810
|
-
}, i = Z(s), a =
|
|
4865
|
+
}, i = Z(s), a = Dt(s, r), { rows: o, next: c } = Ot((await e.select().from(A).leftJoin(We, gi()).where(a ? t(g, a) : g).orderBy(...Et(r)).limit(i + 1)).map((e) => _i(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4811
4866
|
return {
|
|
4812
4867
|
users: l,
|
|
4813
4868
|
start: 0,
|
|
@@ -4816,15 +4871,15 @@ function yi(e) {
|
|
|
4816
4871
|
next: c
|
|
4817
4872
|
};
|
|
4818
4873
|
}
|
|
4819
|
-
let v = e.select().from(A).leftJoin(
|
|
4874
|
+
let v = e.select().from(A).leftJoin(We, gi()).where(g).$dynamic();
|
|
4820
4875
|
if (p?.sort_by) {
|
|
4821
|
-
let e =
|
|
4876
|
+
let e = hi[p.sort_by];
|
|
4822
4877
|
if (e) {
|
|
4823
|
-
let t =
|
|
4878
|
+
let t = St(e) ? Ct(e) : e;
|
|
4824
4879
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4825
4880
|
}
|
|
4826
4881
|
}
|
|
4827
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(
|
|
4882
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(We, gi()).where(g) : void 0]), b = await _(y.map((e) => _i(e.users, e.user_activity)));
|
|
4828
4883
|
if (!ee) return { users: b };
|
|
4829
4884
|
let [te] = ee;
|
|
4830
4885
|
return {
|
|
@@ -4836,14 +4891,14 @@ function yi(e) {
|
|
|
4836
4891
|
},
|
|
4837
4892
|
async remove(n, r, i) {
|
|
4838
4893
|
let o = await e.select({ user_id: A.user_id }).from(A).where(t(a(A.tenant_id, n), v(a(A.user_id, r), a(A.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
|
|
4839
|
-
e.delete(
|
|
4894
|
+
e.delete(pt).where(t(a(pt.tenant_id, n), l(pt.user_id, u))),
|
|
4840
4895
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4841
|
-
e.delete(
|
|
4896
|
+
e.delete(We).where(t(a(We.tenant_id, n), l(We.user_id, u))),
|
|
4842
4897
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4843
4898
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4844
4899
|
], f = d.length - 1;
|
|
4845
|
-
if (s) for (let t of
|
|
4846
|
-
let p = (await
|
|
4900
|
+
if (s) for (let t of li(e, n, i)) d.push(t);
|
|
4901
|
+
let p = (await Ft(e, d))[f];
|
|
4847
4902
|
return Array.isArray(p) && p.length > 0;
|
|
4848
4903
|
},
|
|
4849
4904
|
async unlink(n, r, i, o) {
|
|
@@ -4854,7 +4909,7 @@ function yi(e) {
|
|
|
4854
4909
|
}
|
|
4855
4910
|
//#endregion
|
|
4856
4911
|
//#region src/adapters/userRoles.ts
|
|
4857
|
-
function
|
|
4912
|
+
function xi(e) {
|
|
4858
4913
|
return {
|
|
4859
4914
|
async create(t, n, r, i) {
|
|
4860
4915
|
try {
|
|
@@ -4893,7 +4948,7 @@ function bi(e) {
|
|
|
4893
4948
|
sortColumn: H.id,
|
|
4894
4949
|
idColumn: H.id,
|
|
4895
4950
|
sortOrder: "asc"
|
|
4896
|
-
}, l =
|
|
4951
|
+
}, l = Dt(i, c), u = Z(i), { rows: d, next: f } = Ot((await e.selectDistinct({ role: H }).from(W).innerJoin(H, t(a(H.tenant_id, W.tenant_id), a(H.id, W.role_id))).where(t(...s, l)).orderBy(...Et(c)).limit(u + 1).all()).map((e) => e.role), u, "id", "id");
|
|
4897
4952
|
return {
|
|
4898
4953
|
roles: d.map((e) => {
|
|
4899
4954
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
@@ -4908,12 +4963,12 @@ function bi(e) {
|
|
|
4908
4963
|
},
|
|
4909
4964
|
async listUsers(r, i, o) {
|
|
4910
4965
|
let s = t(a(W.tenant_id, r), a(W.role_id, i));
|
|
4911
|
-
if (
|
|
4966
|
+
if (Tt(o)) {
|
|
4912
4967
|
let n = {
|
|
4913
4968
|
sortColumn: W.user_id,
|
|
4914
4969
|
idColumn: W.user_id,
|
|
4915
4970
|
sortOrder: "asc"
|
|
4916
|
-
}, r =
|
|
4971
|
+
}, r = Dt(o, n), i = Z(o), { rows: a, next: c } = Ot(await e.selectDistinct({ user_id: W.user_id }).from(W).where(r ? t(s, r) : s).orderBy(...Et(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4917
4972
|
return {
|
|
4918
4973
|
userIds: a.map((e) => e.user_id),
|
|
4919
4974
|
start: 0,
|
|
@@ -4937,7 +4992,7 @@ function bi(e) {
|
|
|
4937
4992
|
}
|
|
4938
4993
|
//#endregion
|
|
4939
4994
|
//#region src/adapters/userOrganizations.ts
|
|
4940
|
-
function
|
|
4995
|
+
function Si(e) {
|
|
4941
4996
|
return {
|
|
4942
4997
|
async create(t, n) {
|
|
4943
4998
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4969,19 +5024,19 @@ function xi(e) {
|
|
|
4969
5024
|
async list(n, o) {
|
|
4970
5025
|
let { include_totals: s = !1, q: c } = o || {}, l = a(V.tenant_id, n), u = l;
|
|
4971
5026
|
if (c) {
|
|
4972
|
-
let e =
|
|
5027
|
+
let e = wt(V, c, ["user_id", "organization_id"]);
|
|
4973
5028
|
e && (u = t(l, e));
|
|
4974
5029
|
}
|
|
4975
5030
|
let d = (e) => {
|
|
4976
5031
|
let { tenant_id: t, ...n } = e;
|
|
4977
5032
|
return n;
|
|
4978
5033
|
};
|
|
4979
|
-
if (
|
|
5034
|
+
if (Tt(o)) {
|
|
4980
5035
|
let n = {
|
|
4981
5036
|
sortColumn: V.created_at,
|
|
4982
5037
|
idColumn: V.id,
|
|
4983
5038
|
sortOrder: "desc"
|
|
4984
|
-
}, r =
|
|
5039
|
+
}, r = Dt(o, n), i = Z(o), { rows: a, next: s } = Ot((await e.select().from(V).where(r ? t(u, r) : u).orderBy(...Et(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4985
5040
|
return {
|
|
4986
5041
|
userOrganizations: a,
|
|
4987
5042
|
start: 0,
|
|
@@ -5002,12 +5057,12 @@ function xi(e) {
|
|
|
5002
5057
|
},
|
|
5003
5058
|
async listUserOrganizations(n, i, o) {
|
|
5004
5059
|
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {};
|
|
5005
|
-
if (
|
|
5060
|
+
if (Tt(o)) {
|
|
5006
5061
|
let r = {
|
|
5007
5062
|
sortColumn: V.created_at,
|
|
5008
5063
|
idColumn: V.id,
|
|
5009
5064
|
sortOrder: "desc"
|
|
5010
|
-
}, s = Z(o), c =
|
|
5065
|
+
}, s = Z(o), c = Dt(o, r), { rows: l, next: u } = Ot(await e.select().from(V).where(t(a(V.tenant_id, n), a(V.user_id, i), c)).orderBy(...Et(r)).limit(s + 1).all(), s, "created_at"), d = (await Promise.all(l.map((r) => e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r.organization_id))).get()))).filter(Boolean).map((e) => {
|
|
5011
5066
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
5012
5067
|
return D({
|
|
5013
5068
|
...o,
|
|
@@ -5053,19 +5108,19 @@ function xi(e) {
|
|
|
5053
5108
|
}
|
|
5054
5109
|
//#endregion
|
|
5055
5110
|
//#region src/adapters/stats.ts
|
|
5056
|
-
var
|
|
5057
|
-
function
|
|
5111
|
+
var Ci = ["s"], wi = ["pwd_leak"];
|
|
5112
|
+
function Ti(e) {
|
|
5058
5113
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
5059
5114
|
}
|
|
5060
|
-
function
|
|
5115
|
+
function Ei(e) {
|
|
5061
5116
|
return {
|
|
5062
5117
|
async getDaily(n, r) {
|
|
5063
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
5118
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? Ti(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? Ti(r.to) : i.toISOString().split("T")[0];
|
|
5064
5119
|
return (await e.select({
|
|
5065
5120
|
date: y`substr(${K.date}, 1, 10)`.as("date"),
|
|
5066
|
-
logins: y`SUM(CASE WHEN ${K.type} IN (${y.join(
|
|
5121
|
+
logins: y`SUM(CASE WHEN ${K.type} IN (${y.join(Ci.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
5067
5122
|
signups: y`SUM(CASE WHEN ${K.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
5068
|
-
leaked_passwords: y`SUM(CASE WHEN ${K.type} IN (${y.join(
|
|
5123
|
+
leaked_passwords: y`SUM(CASE WHEN ${K.type} IN (${y.join(wi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
5069
5124
|
}).from(K).where(t(a(K.tenant_id, n), c(K.date, o), h(K.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${K.date}, 1, 10)`).orderBy(y`substr(${K.date}, 1, 10)`).all()).map((e) => ({
|
|
5070
5125
|
date: e.date,
|
|
5071
5126
|
logins: Number(e.logins) || 0,
|
|
@@ -5076,14 +5131,14 @@ function Ti(e) {
|
|
|
5076
5131
|
}));
|
|
5077
5132
|
},
|
|
5078
5133
|
async getActiveUsers(n) {
|
|
5079
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${K.user_id})`.as("count") }).from(K).where(t(a(K.tenant_id, n), c(K.date, r), y`${K.type} IN (${y.join(
|
|
5134
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${K.user_id})`.as("count") }).from(K).where(t(a(K.tenant_id, n), c(K.date, r), y`${K.type} IN (${y.join(Ci.map((e) => y`${e}`), y`, `)})`));
|
|
5080
5135
|
return Number(i?.count) || 0;
|
|
5081
5136
|
}
|
|
5082
5137
|
};
|
|
5083
5138
|
}
|
|
5084
5139
|
//#endregion
|
|
5085
5140
|
//#region src/adapters/analytics.ts
|
|
5086
|
-
var
|
|
5141
|
+
var Di = {
|
|
5087
5142
|
"active-users": ["s", "seacft"],
|
|
5088
5143
|
logins: [
|
|
5089
5144
|
"s",
|
|
@@ -5113,7 +5168,7 @@ var Ei = {
|
|
|
5113
5168
|
"fvr"
|
|
5114
5169
|
],
|
|
5115
5170
|
"codes-sent": ["cls", "cs"]
|
|
5116
|
-
},
|
|
5171
|
+
}, Oi = {
|
|
5117
5172
|
"active-users": {
|
|
5118
5173
|
alias: "active_users",
|
|
5119
5174
|
type: "UInt64",
|
|
@@ -5170,7 +5225,7 @@ var Ei = {
|
|
|
5170
5225
|
agg: "count"
|
|
5171
5226
|
}
|
|
5172
5227
|
};
|
|
5173
|
-
function
|
|
5228
|
+
function ki(e) {
|
|
5174
5229
|
switch (e) {
|
|
5175
5230
|
case "hour": return y`substr(${K.date}, 1, 13)`;
|
|
5176
5231
|
case "month": return y`substr(${K.date}, 1, 7)`;
|
|
@@ -5179,10 +5234,10 @@ function Oi(e) {
|
|
|
5179
5234
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
5180
5235
|
}
|
|
5181
5236
|
}
|
|
5182
|
-
function
|
|
5237
|
+
function Ai(e) {
|
|
5183
5238
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
5184
5239
|
}
|
|
5185
|
-
function
|
|
5240
|
+
function ji(e) {
|
|
5186
5241
|
switch (e) {
|
|
5187
5242
|
case "connection": return K.connection;
|
|
5188
5243
|
case "client_id": return K.client_id;
|
|
@@ -5191,10 +5246,10 @@ function Ai(e) {
|
|
|
5191
5246
|
case "time": throw Error("time dimension handled separately");
|
|
5192
5247
|
}
|
|
5193
5248
|
}
|
|
5194
|
-
function
|
|
5249
|
+
function Mi(e) {
|
|
5195
5250
|
return {
|
|
5196
5251
|
async query(n, r, i) {
|
|
5197
|
-
let o = Date.now(), s =
|
|
5252
|
+
let o = Date.now(), s = Di[r], u = Oi[r], d = [
|
|
5198
5253
|
a(K.tenant_id, n),
|
|
5199
5254
|
c(K.date, i.from),
|
|
5200
5255
|
m(K.date, i.to),
|
|
@@ -5203,13 +5258,13 @@ function ji(e) {
|
|
|
5203
5258
|
i.filters.connection?.length && d.push(l(K.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(K.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(K.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(K.user_id, i.filters.user_id));
|
|
5204
5259
|
let f = {}, p = [], h = [];
|
|
5205
5260
|
for (let e of i.group_by) if (e === "time") {
|
|
5206
|
-
let e =
|
|
5261
|
+
let e = ki(i.interval);
|
|
5207
5262
|
f.time = e, p.push(e), h.push({
|
|
5208
5263
|
name: "time",
|
|
5209
5264
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
5210
5265
|
});
|
|
5211
5266
|
} else {
|
|
5212
|
-
let t =
|
|
5267
|
+
let t = ji(e);
|
|
5213
5268
|
f[e] = t, p.push(t), h.push({
|
|
5214
5269
|
name: e,
|
|
5215
5270
|
type: "String"
|
|
@@ -5225,9 +5280,9 @@ function ji(e) {
|
|
|
5225
5280
|
if (i.order_by) {
|
|
5226
5281
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
5227
5282
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
5228
|
-
let n =
|
|
5283
|
+
let n = Ai(t);
|
|
5229
5284
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
5230
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
5285
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Ai("time")} ASC`)) : g.orderBy(y.raw(`${Ai(u.alias)} DESC`));
|
|
5231
5286
|
g = g.limit(i.limit).offset(i.offset);
|
|
5232
5287
|
let v = (await g.all()).map((e) => {
|
|
5233
5288
|
let t = {};
|
|
@@ -5276,10 +5331,10 @@ function ji(e) {
|
|
|
5276
5331
|
}
|
|
5277
5332
|
//#endregion
|
|
5278
5333
|
//#region src/adapters/cleanup.ts
|
|
5279
|
-
var
|
|
5280
|
-
function
|
|
5334
|
+
var Ni = 10080 * 60 * 1e3;
|
|
5335
|
+
function Pi(e) {
|
|
5281
5336
|
return async (n) => {
|
|
5282
|
-
let r = Date.now() -
|
|
5337
|
+
let r = Date.now() - Ni;
|
|
5283
5338
|
try {
|
|
5284
5339
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
5285
5340
|
n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), await e.delete(N).where(t(...i)), i = [v(m(M.expires_at_ts, r), m(M.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(M.tenant_id, n.tenant_id)), n?.user_id && i.push(a(M.user_id, n.user_id)), await e.delete(M).where(t(...i)), i = [m(P.expires_at_ts, r)], n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i));
|
|
@@ -5314,7 +5369,7 @@ var Q = w("tenant_operations", {
|
|
|
5314
5369
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
5315
5370
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
5316
5371
|
x("tenant_operations_status_idx").on(e.status)
|
|
5317
|
-
]),
|
|
5372
|
+
]), Fi = w("tenant_operation_events", {
|
|
5318
5373
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5319
5374
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
5320
5375
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -5345,7 +5400,7 @@ var Q = w("tenant_operations", {
|
|
|
5345
5400
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
5346
5401
|
}).onDelete("cascade"),
|
|
5347
5402
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
5348
|
-
]),
|
|
5403
|
+
]), Ii = w("rollouts", {
|
|
5349
5404
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5350
5405
|
kind: T("kind", { length: 32 }).notNull(),
|
|
5351
5406
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -5361,7 +5416,7 @@ var Q = w("tenant_operations", {
|
|
|
5361
5416
|
});
|
|
5362
5417
|
//#endregion
|
|
5363
5418
|
//#region src/adapters/tenantOperations.ts
|
|
5364
|
-
function
|
|
5419
|
+
function Li(e) {
|
|
5365
5420
|
if (!e) return null;
|
|
5366
5421
|
try {
|
|
5367
5422
|
return JSON.parse(e);
|
|
@@ -5369,7 +5424,7 @@ function Ii(e) {
|
|
|
5369
5424
|
return null;
|
|
5370
5425
|
}
|
|
5371
5426
|
}
|
|
5372
|
-
function
|
|
5427
|
+
function Ri(e) {
|
|
5373
5428
|
return Fe.parse({
|
|
5374
5429
|
id: e.id,
|
|
5375
5430
|
tenant_id: e.tenant_id,
|
|
@@ -5383,8 +5438,8 @@ function Li(e) {
|
|
|
5383
5438
|
target_database_version: e.target_database_version,
|
|
5384
5439
|
error: e.error,
|
|
5385
5440
|
initiated_by: e.initiated_by,
|
|
5386
|
-
input:
|
|
5387
|
-
result:
|
|
5441
|
+
input: Li(e.input),
|
|
5442
|
+
result: Li(e.result),
|
|
5388
5443
|
claimed_by: e.claimed_by,
|
|
5389
5444
|
claim_expires_at: e.claim_expires_at,
|
|
5390
5445
|
created_at: e.created_at,
|
|
@@ -5392,7 +5447,7 @@ function Li(e) {
|
|
|
5392
5447
|
finished_at: e.finished_at
|
|
5393
5448
|
});
|
|
5394
5449
|
}
|
|
5395
|
-
function
|
|
5450
|
+
function zi(e) {
|
|
5396
5451
|
return {
|
|
5397
5452
|
async create(t) {
|
|
5398
5453
|
let n = Me.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5423,7 +5478,7 @@ function Ri(e) {
|
|
|
5423
5478
|
},
|
|
5424
5479
|
async get(t) {
|
|
5425
5480
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
5426
|
-
return n[0] ?
|
|
5481
|
+
return n[0] ? Ri(n[0]) : null;
|
|
5427
5482
|
},
|
|
5428
5483
|
async list(n = {}) {
|
|
5429
5484
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -5434,7 +5489,7 @@ function Ri(e) {
|
|
|
5434
5489
|
n.engine !== void 0 && s.push(a(Q.engine, n.engine)), n.updated_before !== void 0 && s.push(m(Q.updated_at, n.updated_before));
|
|
5435
5490
|
let c = await e.select().from(Q).where(s.length ? t(...s) : void 0).orderBy(i(Q.created_at), i(Q.id)).offset(r * o).limit(o);
|
|
5436
5491
|
return {
|
|
5437
|
-
operations: c.map(
|
|
5492
|
+
operations: c.map(Ri),
|
|
5438
5493
|
start: r * o,
|
|
5439
5494
|
limit: o,
|
|
5440
5495
|
length: c.length
|
|
@@ -5460,7 +5515,7 @@ function Ri(e) {
|
|
|
5460
5515
|
},
|
|
5461
5516
|
async listResumable(r) {
|
|
5462
5517
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
5463
|
-
return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(
|
|
5518
|
+
return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(Ri);
|
|
5464
5519
|
},
|
|
5465
5520
|
async remove(t) {
|
|
5466
5521
|
return (await e.select({ id: Q.id }).from(Q).where(a(Q.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Q).where(a(Q.id, t)), !0);
|
|
@@ -5469,19 +5524,19 @@ function Ri(e) {
|
|
|
5469
5524
|
}
|
|
5470
5525
|
//#endregion
|
|
5471
5526
|
//#region src/adapters/tenantOperationRows.ts
|
|
5472
|
-
var
|
|
5473
|
-
function
|
|
5527
|
+
var Bi = 50, Vi = 50;
|
|
5528
|
+
function Hi(e) {
|
|
5474
5529
|
try {
|
|
5475
5530
|
return JSON.parse(e);
|
|
5476
5531
|
} catch {
|
|
5477
5532
|
return {};
|
|
5478
5533
|
}
|
|
5479
5534
|
}
|
|
5480
|
-
function
|
|
5535
|
+
function Ui(e) {
|
|
5481
5536
|
return Pe.parse({
|
|
5482
5537
|
operation_id: e.operation_id,
|
|
5483
5538
|
seq: e.seq,
|
|
5484
|
-
payload:
|
|
5539
|
+
payload: Hi(e.payload),
|
|
5485
5540
|
status: e.status,
|
|
5486
5541
|
error_code: e.error_code,
|
|
5487
5542
|
error_message: e.error_message,
|
|
@@ -5491,12 +5546,12 @@ function Hi(e) {
|
|
|
5491
5546
|
updated_at: e.updated_at
|
|
5492
5547
|
});
|
|
5493
5548
|
}
|
|
5494
|
-
function
|
|
5549
|
+
function Wi(e, t) {
|
|
5495
5550
|
let n = [];
|
|
5496
5551
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5497
5552
|
return n;
|
|
5498
5553
|
}
|
|
5499
|
-
function
|
|
5554
|
+
function Gi(e, n, r, i) {
|
|
5500
5555
|
return e.update($).set({
|
|
5501
5556
|
status: r.status,
|
|
5502
5557
|
error_code: r.error_code ?? null,
|
|
@@ -5506,7 +5561,7 @@ function Wi(e, n, r, i) {
|
|
|
5506
5561
|
updated_at: i
|
|
5507
5562
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
5508
5563
|
}
|
|
5509
|
-
function
|
|
5564
|
+
function Ki(e) {
|
|
5510
5565
|
return {
|
|
5511
5566
|
async createMany(t) {
|
|
5512
5567
|
if (t.length === 0) return 0;
|
|
@@ -5525,24 +5580,24 @@ function Gi(e) {
|
|
|
5525
5580
|
updated_at: n
|
|
5526
5581
|
};
|
|
5527
5582
|
});
|
|
5528
|
-
for (let t of
|
|
5583
|
+
for (let t of Wi(r, Bi)) await e.insert($).values(t);
|
|
5529
5584
|
return r.length;
|
|
5530
5585
|
},
|
|
5531
5586
|
async claimPending(r, i) {
|
|
5532
|
-
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(
|
|
5587
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Ui);
|
|
5533
5588
|
},
|
|
5534
5589
|
async recordOutcomes(n, r) {
|
|
5535
5590
|
if (r.length === 0) return 0;
|
|
5536
5591
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
5537
|
-
for (let r of
|
|
5592
|
+
for (let r of Wi(o, Vi)) {
|
|
5538
5593
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
5539
5594
|
for (let e of i) s.add(e.seq);
|
|
5540
5595
|
}
|
|
5541
5596
|
let c = r.filter((e) => s.has(e.seq));
|
|
5542
5597
|
if (c.length === 0) return 0;
|
|
5543
|
-
for (let t of
|
|
5544
|
-
let [r, ...a] = t.map((t) =>
|
|
5545
|
-
r && await
|
|
5598
|
+
for (let t of Wi(c, Vi)) {
|
|
5599
|
+
let [r, ...a] = t.map((t) => Gi(e, n, t, i));
|
|
5600
|
+
r && await Ft(e, [r, ...a]);
|
|
5546
5601
|
}
|
|
5547
5602
|
return c.length;
|
|
5548
5603
|
},
|
|
@@ -5577,7 +5632,7 @@ function Gi(e) {
|
|
|
5577
5632
|
}
|
|
5578
5633
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5579
5634
|
return {
|
|
5580
|
-
rows: u.map(
|
|
5635
|
+
rows: u.map(Ui),
|
|
5581
5636
|
start: o * s,
|
|
5582
5637
|
limit: s,
|
|
5583
5638
|
length: u.length
|
|
@@ -5591,27 +5646,27 @@ function Gi(e) {
|
|
|
5591
5646
|
}
|
|
5592
5647
|
//#endregion
|
|
5593
5648
|
//#region src/helpers/monotonic-id.ts
|
|
5594
|
-
var
|
|
5595
|
-
function
|
|
5649
|
+
var qi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ji = 32, Yi = 10, Xi = 4, Zi = 10;
|
|
5650
|
+
function Qi(e, t) {
|
|
5596
5651
|
let n = "";
|
|
5597
|
-
for (let r = t; r > 0; r--) n =
|
|
5652
|
+
for (let r = t; r > 0; r--) n = qi.charAt(e % Ji) + n, e = Math.floor(e / Ji);
|
|
5598
5653
|
return n;
|
|
5599
5654
|
}
|
|
5600
|
-
function
|
|
5601
|
-
let e = new Uint8Array(
|
|
5655
|
+
function $i() {
|
|
5656
|
+
let e = new Uint8Array(Zi);
|
|
5602
5657
|
crypto.getRandomValues(e);
|
|
5603
5658
|
let t = "";
|
|
5604
|
-
for (let n = 0; n <
|
|
5659
|
+
for (let n = 0; n < Zi; n++) t += qi.charAt(e[n] % Ji);
|
|
5605
5660
|
return t;
|
|
5606
5661
|
}
|
|
5607
|
-
var
|
|
5608
|
-
function
|
|
5662
|
+
var ea = 0, ta = 0;
|
|
5663
|
+
function na() {
|
|
5609
5664
|
let e = Date.now();
|
|
5610
|
-
return e ===
|
|
5665
|
+
return e === ea ? ta++ : (ea = e, ta = 0), Qi(e, Yi) + Qi(ta, Xi) + $i();
|
|
5611
5666
|
}
|
|
5612
5667
|
//#endregion
|
|
5613
5668
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5614
|
-
function
|
|
5669
|
+
function ra(e) {
|
|
5615
5670
|
if (!e) return null;
|
|
5616
5671
|
try {
|
|
5617
5672
|
let t = JSON.parse(e);
|
|
@@ -5619,22 +5674,22 @@ function na(e) {
|
|
|
5619
5674
|
} catch {}
|
|
5620
5675
|
return null;
|
|
5621
5676
|
}
|
|
5622
|
-
function
|
|
5677
|
+
function ia(e) {
|
|
5623
5678
|
return je.parse({
|
|
5624
5679
|
id: e.id,
|
|
5625
5680
|
operation_id: e.operation_id,
|
|
5626
5681
|
step: e.step,
|
|
5627
5682
|
outcome: e.outcome,
|
|
5628
|
-
detail:
|
|
5683
|
+
detail: ra(e.detail),
|
|
5629
5684
|
attempt: e.attempt,
|
|
5630
5685
|
created_at: e.created_at
|
|
5631
5686
|
});
|
|
5632
5687
|
}
|
|
5633
|
-
function
|
|
5688
|
+
function aa(e) {
|
|
5634
5689
|
return {
|
|
5635
5690
|
async create(t) {
|
|
5636
5691
|
let n = Ae.parse(t), r = {
|
|
5637
|
-
id: `evt_${
|
|
5692
|
+
id: `evt_${na()}`,
|
|
5638
5693
|
operation_id: n.operation_id,
|
|
5639
5694
|
step: n.step,
|
|
5640
5695
|
outcome: n.outcome,
|
|
@@ -5642,7 +5697,7 @@ function ia(e) {
|
|
|
5642
5697
|
attempt: n.attempt,
|
|
5643
5698
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5644
5699
|
};
|
|
5645
|
-
return await e.insert(
|
|
5700
|
+
return await e.insert(Fi).values(r), je.parse({
|
|
5646
5701
|
id: r.id,
|
|
5647
5702
|
operation_id: r.operation_id,
|
|
5648
5703
|
step: r.step,
|
|
@@ -5653,9 +5708,9 @@ function ia(e) {
|
|
|
5653
5708
|
});
|
|
5654
5709
|
},
|
|
5655
5710
|
async listByOperation(t, r = {}) {
|
|
5656
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5711
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Fi).where(a(Fi.operation_id, t)).orderBy(n(Fi.created_at), n(Fi.id)).offset(i * o).limit(o);
|
|
5657
5712
|
return {
|
|
5658
|
-
events: s.map(
|
|
5713
|
+
events: s.map(ia),
|
|
5659
5714
|
start: i * o,
|
|
5660
5715
|
limit: o,
|
|
5661
5716
|
length: s.length
|
|
@@ -5665,7 +5720,7 @@ function ia(e) {
|
|
|
5665
5720
|
}
|
|
5666
5721
|
//#endregion
|
|
5667
5722
|
//#region src/adapters/rollouts.ts
|
|
5668
|
-
function
|
|
5723
|
+
function oa(e) {
|
|
5669
5724
|
if (!e) return null;
|
|
5670
5725
|
try {
|
|
5671
5726
|
return JSON.parse(e);
|
|
@@ -5673,7 +5728,7 @@ function aa(e) {
|
|
|
5673
5728
|
return null;
|
|
5674
5729
|
}
|
|
5675
5730
|
}
|
|
5676
|
-
function
|
|
5731
|
+
function sa(e) {
|
|
5677
5732
|
return Te.parse({
|
|
5678
5733
|
id: e.id,
|
|
5679
5734
|
kind: e.kind,
|
|
@@ -5681,15 +5736,15 @@ function oa(e) {
|
|
|
5681
5736
|
target_worker_version: e.target_worker_version,
|
|
5682
5737
|
target_database_version: e.target_database_version,
|
|
5683
5738
|
wave_size: e.wave_size,
|
|
5684
|
-
canary_tenant_ids:
|
|
5685
|
-
filter:
|
|
5739
|
+
canary_tenant_ids: oa(e.canary_tenant_ids),
|
|
5740
|
+
filter: oa(e.filter),
|
|
5686
5741
|
initiated_by: e.initiated_by,
|
|
5687
5742
|
created_at: e.created_at,
|
|
5688
5743
|
updated_at: e.updated_at,
|
|
5689
5744
|
finished_at: e.finished_at
|
|
5690
5745
|
});
|
|
5691
5746
|
}
|
|
5692
|
-
function
|
|
5747
|
+
function ca(e) {
|
|
5693
5748
|
return {
|
|
5694
5749
|
async create(t) {
|
|
5695
5750
|
let n = we.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5706,99 +5761,99 @@ function sa(e) {
|
|
|
5706
5761
|
updated_at: r,
|
|
5707
5762
|
finished_at: null
|
|
5708
5763
|
};
|
|
5709
|
-
await e.insert(
|
|
5764
|
+
await e.insert(Ii).values(i);
|
|
5710
5765
|
let a = await this.get(i.id);
|
|
5711
5766
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5712
5767
|
return a;
|
|
5713
5768
|
},
|
|
5714
5769
|
async get(t) {
|
|
5715
|
-
let n = await e.select().from(
|
|
5716
|
-
return n[0] ?
|
|
5770
|
+
let n = await e.select().from(Ii).where(a(Ii.id, t)).limit(1);
|
|
5771
|
+
return n[0] ? sa(n[0]) : null;
|
|
5717
5772
|
},
|
|
5718
5773
|
async list(t = {}) {
|
|
5719
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5774
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(Ii).orderBy(i(Ii.created_at), i(Ii.id)).offset(n * r).limit(r);
|
|
5720
5775
|
return {
|
|
5721
|
-
rollouts: a.map(
|
|
5776
|
+
rollouts: a.map(sa),
|
|
5722
5777
|
start: n * r,
|
|
5723
5778
|
limit: r,
|
|
5724
5779
|
length: a.length
|
|
5725
5780
|
};
|
|
5726
5781
|
},
|
|
5727
5782
|
async update(t, n) {
|
|
5728
|
-
if ((await e.select({ id:
|
|
5783
|
+
if ((await e.select({ id: Ii.id }).from(Ii).where(a(Ii.id, t)).limit(1)).length === 0) return !1;
|
|
5729
5784
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5730
|
-
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(
|
|
5785
|
+
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(Ii).set(r).where(a(Ii.id, t)), !0;
|
|
5731
5786
|
},
|
|
5732
5787
|
async remove(t) {
|
|
5733
|
-
return (await e.select({ id:
|
|
5788
|
+
return (await e.select({ id: Ii.id }).from(Ii).where(a(Ii.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Ii).where(a(Ii.id, t)), !0);
|
|
5734
5789
|
}
|
|
5735
5790
|
};
|
|
5736
5791
|
}
|
|
5737
5792
|
//#endregion
|
|
5738
5793
|
//#region src/adapters/index.ts
|
|
5739
|
-
function
|
|
5794
|
+
function la(e, t = { useTransactions: !0 }) {
|
|
5740
5795
|
let n = {
|
|
5741
|
-
actions:
|
|
5742
|
-
actionExecutions:
|
|
5743
|
-
actionVersions:
|
|
5744
|
-
branding:
|
|
5745
|
-
clients:
|
|
5746
|
-
clientConnections:
|
|
5747
|
-
clientGrants:
|
|
5748
|
-
clientRegistrationTokens:
|
|
5749
|
-
codes:
|
|
5750
|
-
connections:
|
|
5751
|
-
customDomains:
|
|
5752
|
-
customText:
|
|
5753
|
-
emailProviders:
|
|
5754
|
-
emailTemplates:
|
|
5755
|
-
flows:
|
|
5756
|
-
forms:
|
|
5757
|
-
grants:
|
|
5758
|
-
hookCode:
|
|
5759
|
-
hooks:
|
|
5760
|
-
invites:
|
|
5761
|
-
keys:
|
|
5762
|
-
loginSessions:
|
|
5763
|
-
logs:
|
|
5764
|
-
logStreams:
|
|
5765
|
-
migrationSources:
|
|
5766
|
-
authenticationMethods:
|
|
5767
|
-
organizations:
|
|
5768
|
-
organizationConnections:
|
|
5769
|
-
passwords:
|
|
5770
|
-
promptSettings:
|
|
5771
|
-
promptPartials:
|
|
5772
|
-
proxyRoutes:
|
|
5773
|
-
scimConfigurations:
|
|
5774
|
-
scimTokens:
|
|
5775
|
-
scimExternalIds:
|
|
5776
|
-
refreshTokens:
|
|
5777
|
-
resourceServers:
|
|
5778
|
-
rolePermissions:
|
|
5779
|
-
userPermissions:
|
|
5780
|
-
roles:
|
|
5781
|
-
sessions:
|
|
5782
|
-
sessionCleanup:
|
|
5783
|
-
tenants:
|
|
5784
|
-
tokenExchangeProfiles:
|
|
5796
|
+
actions: jt(e),
|
|
5797
|
+
actionExecutions: Nt(e),
|
|
5798
|
+
actionVersions: Lt(e),
|
|
5799
|
+
branding: zt(e),
|
|
5800
|
+
clients: Gt(e),
|
|
5801
|
+
clientConnections: qt(e),
|
|
5802
|
+
clientGrants: Yt(e),
|
|
5803
|
+
clientRegistrationTokens: en(e),
|
|
5804
|
+
codes: an(e),
|
|
5805
|
+
connections: cn(e),
|
|
5806
|
+
customDomains: un(e),
|
|
5807
|
+
customText: dn(e),
|
|
5808
|
+
emailProviders: fn(e),
|
|
5809
|
+
emailTemplates: mn(e),
|
|
5810
|
+
flows: _n(e),
|
|
5811
|
+
forms: xn(e),
|
|
5812
|
+
grants: Tn(e),
|
|
5813
|
+
hookCode: kn(e),
|
|
5814
|
+
hooks: Nn(e),
|
|
5815
|
+
invites: Ln(e),
|
|
5816
|
+
keys: zn(e),
|
|
5817
|
+
loginSessions: Wn(e),
|
|
5818
|
+
logs: Kn(e),
|
|
5819
|
+
logStreams: ar(e),
|
|
5820
|
+
migrationSources: sr(e),
|
|
5821
|
+
authenticationMethods: Zn(e),
|
|
5822
|
+
organizations: tr(e),
|
|
5823
|
+
organizationConnections: rr(e),
|
|
5824
|
+
passwords: lr(e),
|
|
5825
|
+
promptSettings: ur(e),
|
|
5826
|
+
promptPartials: dr(e),
|
|
5827
|
+
proxyRoutes: hr(e),
|
|
5828
|
+
scimConfigurations: Cr(e),
|
|
5829
|
+
scimTokens: Tr(e),
|
|
5830
|
+
scimExternalIds: Dr(e),
|
|
5831
|
+
refreshTokens: Ar(e),
|
|
5832
|
+
resourceServers: Ir(e),
|
|
5833
|
+
rolePermissions: Lr(e),
|
|
5834
|
+
userPermissions: Br(e),
|
|
5835
|
+
roles: Hr(e),
|
|
5836
|
+
sessions: qr(e),
|
|
5837
|
+
sessionCleanup: Pi(e),
|
|
5838
|
+
tenants: Qr(e),
|
|
5839
|
+
tokenExchangeProfiles: yr(e),
|
|
5785
5840
|
...t.controlPlane ? {
|
|
5786
|
-
tenantOperations:
|
|
5787
|
-
tenantOperationEvents:
|
|
5788
|
-
tenantOperationRows:
|
|
5789
|
-
rollouts:
|
|
5841
|
+
tenantOperations: zi(e),
|
|
5842
|
+
tenantOperationEvents: aa(e),
|
|
5843
|
+
tenantOperationRows: Ki(e),
|
|
5844
|
+
rollouts: ca(e)
|
|
5790
5845
|
} : {},
|
|
5791
|
-
themes:
|
|
5792
|
-
universalLoginTemplates:
|
|
5793
|
-
users:
|
|
5794
|
-
userActivity:
|
|
5795
|
-
userRoles:
|
|
5796
|
-
userOrganizations:
|
|
5797
|
-
stats:
|
|
5798
|
-
analytics:
|
|
5799
|
-
outbox:
|
|
5846
|
+
themes: ti(e),
|
|
5847
|
+
universalLoginTemplates: ni(e),
|
|
5848
|
+
users: bi(e),
|
|
5849
|
+
userActivity: ii(e),
|
|
5850
|
+
userRoles: xi(e),
|
|
5851
|
+
userOrganizations: Si(e),
|
|
5852
|
+
stats: Ei(e),
|
|
5853
|
+
analytics: Mi(e),
|
|
5854
|
+
outbox: ci(e),
|
|
5800
5855
|
async transaction(r) {
|
|
5801
|
-
if (t.useTransactions === !1 ||
|
|
5856
|
+
if (t.useTransactions === !1 || Pt(e)) return r(n);
|
|
5802
5857
|
await e.run(y`BEGIN`);
|
|
5803
5858
|
try {
|
|
5804
5859
|
let t = await r(n);
|
|
@@ -5812,7 +5867,7 @@ function ca(e, t = { useTransactions: !0 }) {
|
|
|
5812
5867
|
}
|
|
5813
5868
|
//#endregion
|
|
5814
5869
|
//#region src/adapters/resolveHost.ts
|
|
5815
|
-
function
|
|
5870
|
+
function ua(e) {
|
|
5816
5871
|
if (!e) return { path: "/*" };
|
|
5817
5872
|
try {
|
|
5818
5873
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -5820,7 +5875,7 @@ function la(e) {
|
|
|
5820
5875
|
} catch {}
|
|
5821
5876
|
return { path: "/*" };
|
|
5822
5877
|
}
|
|
5823
|
-
function
|
|
5878
|
+
function da(e) {
|
|
5824
5879
|
if (!e) return [];
|
|
5825
5880
|
try {
|
|
5826
5881
|
let t = JSON.parse(e);
|
|
@@ -5835,20 +5890,20 @@ function ua(e) {
|
|
|
5835
5890
|
return [];
|
|
5836
5891
|
}
|
|
5837
5892
|
}
|
|
5838
|
-
async function
|
|
5893
|
+
async function fa(e, r) {
|
|
5839
5894
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5840
|
-
custom_domain_id:
|
|
5841
|
-
tenant_id:
|
|
5842
|
-
domain:
|
|
5843
|
-
}).from(
|
|
5895
|
+
custom_domain_id: Ye.custom_domain_id,
|
|
5896
|
+
tenant_id: Ye.tenant_id,
|
|
5897
|
+
domain: Ye.domain
|
|
5898
|
+
}).from(Ye).where(a(Ye.domain, i)).limit(1))[0];
|
|
5844
5899
|
if (!o) return null;
|
|
5845
5900
|
let s = (await e.select().from(J).where(t(a(J.tenant_id, o.tenant_id), a(J.custom_domain_id, o.custom_domain_id))).orderBy(n(J.priority), n(J.created_at))).map((e) => ({
|
|
5846
5901
|
id: e.id,
|
|
5847
5902
|
tenant_id: e.tenant_id,
|
|
5848
5903
|
custom_domain_id: e.custom_domain_id,
|
|
5849
5904
|
priority: e.priority,
|
|
5850
|
-
match:
|
|
5851
|
-
handlers:
|
|
5905
|
+
match: ua(e.match),
|
|
5906
|
+
handlers: da(e.handlers),
|
|
5852
5907
|
created_at: e.created_at,
|
|
5853
5908
|
updated_at: e.updated_at
|
|
5854
5909
|
}));
|
|
@@ -5861,11 +5916,11 @@ async function da(e, r) {
|
|
|
5861
5916
|
}
|
|
5862
5917
|
//#endregion
|
|
5863
5918
|
//#region src/adapters/proxyData.ts
|
|
5864
|
-
function
|
|
5919
|
+
function pa(e) {
|
|
5865
5920
|
return {
|
|
5866
|
-
proxyRoutes:
|
|
5867
|
-
resolveHost: (t) =>
|
|
5921
|
+
proxyRoutes: hr(e),
|
|
5922
|
+
resolveHost: (t) => fa(e, t)
|
|
5868
5923
|
};
|
|
5869
5924
|
}
|
|
5870
5925
|
//#endregion
|
|
5871
|
-
export {
|
|
5926
|
+
export { pa as createProxyDataAdapter, hr as createProxyRoutesAdapter, la as default, yt as sqlite };
|