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