@authhero/drizzle 1.0.0 → 1.1.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 +888 -687
- package/drizzle/0001_scim_inbound_provisioning.sql +34 -0
- package/drizzle/0002_user_blocked.sql +1 -0
- package/drizzle/0003_prompt_settings_last_used.sql +1 -0
- package/drizzle/meta/0001_snapshot.json +6563 -0
- package/drizzle/meta/0002_snapshot.json +6570 -0
- package/drizzle/meta/0003_snapshot.json +6578 -0
- package/drizzle/meta/_journal.json +21 -0
- package/package.json +3 -3
- package/src/schema/sqlite/branding.ts +5 -0
- package/src/schema/sqlite/index.ts +3 -0
- package/src/schema/sqlite/scim.ts +79 -0
- package/src/schema/sqlite/users.ts +2 -0
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -2,16 +2,16 @@ import { Column as e, and as t, asc as n, count as r, desc as i, eq as a, getTab
|
|
|
2
2
|
import { customAlphabet as ee, nanoid as b } from "nanoid";
|
|
3
3
|
import { SQLiteTable as te, foreignKey as ne, index as x, integer as S, primaryKey as C, sqliteTable as w, text as T, uniqueIndex as E } from "drizzle-orm/sqlite-core";
|
|
4
4
|
import { booleanToInt as re, convertDatesToAdapter as ie, dbDateToIsoRequired as ae, getCountAsInt as oe, isoToDbDate as D, removeNullProperties as O, removeUndefinedAndNull as se, stringifyProperties as ce } from "@authhero/adapter-interfaces/sql";
|
|
5
|
-
import { clientRegistrationTokenTypeSchema as le, decodeCursor as ue, encodeCursor as de, handlerConfigSchema as fe, isPlainObject as pe, matchSchema as me, rolloutInsertSchema as he, rolloutSchema as ge, sanitizeLuceneQuery as _e,
|
|
6
|
-
import { HTTPException as
|
|
5
|
+
import { clientRegistrationTokenTypeSchema as le, decodeCursor as ue, encodeCursor as de, handlerConfigSchema as fe, isPlainObject as pe, matchSchema as me, rolloutInsertSchema as he, rolloutSchema as ge, sanitizeLuceneQuery as _e, scimMappingEntrySchema as ve, tenantOperationEventInsertSchema as ye, tenantOperationEventSchema as be, tenantOperationInsertSchema as xe, tenantOperationSchema as Se } from "@authhero/adapter-interfaces";
|
|
6
|
+
import { HTTPException as Ce } from "hono/http-exception";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var we = Object.defineProperty, Te = (e, t) => {
|
|
9
9
|
let n = {};
|
|
10
|
-
for (var r in e)
|
|
10
|
+
for (var r in e) we(n, r, {
|
|
11
11
|
get: e[r],
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
|
-
return t ||
|
|
14
|
+
return t || we(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
15
15
|
}, k = w("tenants", {
|
|
16
16
|
id: T("id", { length: 191 }).primaryKey(),
|
|
17
17
|
name: T("name", { length: 255 }),
|
|
@@ -67,7 +67,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
67
67
|
worker_script_name: T("worker_script_name", { length: 255 }),
|
|
68
68
|
storage_kind: T("storage_kind", { length: 32 }),
|
|
69
69
|
d1_database_id: T("d1_database_id", { length: 64 })
|
|
70
|
-
}),
|
|
70
|
+
}), Ee = w("actions", {
|
|
71
71
|
id: T("id", { length: 255 }).notNull(),
|
|
72
72
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
73
73
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -109,7 +109,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
109
109
|
}),
|
|
110
110
|
E("uq_action_versions_number").on(e.tenant_id, e.action_id, e.number),
|
|
111
111
|
x("idx_action_versions_action_id").on(e.tenant_id, e.action_id)
|
|
112
|
-
]),
|
|
112
|
+
]), De = w("action_executions", {
|
|
113
113
|
id: T("id", { length: 255 }).notNull(),
|
|
114
114
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
115
115
|
trigger_id: T("trigger_id", { length: 255 }).notNull(),
|
|
@@ -142,6 +142,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
142
142
|
connection: T("connection", { length: 255 }),
|
|
143
143
|
email_verified: S("email_verified", { mode: "boolean" }).notNull(),
|
|
144
144
|
is_social: S("is_social", { mode: "boolean" }).notNull(),
|
|
145
|
+
blocked: S("blocked", { mode: "boolean" }),
|
|
145
146
|
app_metadata: T("app_metadata", { length: 4096 }).notNull().default("{}"),
|
|
146
147
|
user_metadata: T("user_metadata").notNull().default("{}"),
|
|
147
148
|
profileData: T("profileData", { length: 2048 }),
|
|
@@ -174,7 +175,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
174
175
|
password: T("password", { length: 255 }).notNull(),
|
|
175
176
|
algorithm: T("algorithm", { length: 16 }).notNull().default("bcrypt"),
|
|
176
177
|
is_current: S("is_current").notNull().default(1)
|
|
177
|
-
}),
|
|
178
|
+
}), Oe = w("user_activity", {
|
|
178
179
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
179
180
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
180
181
|
last_login: T("last_login", { length: 35 }),
|
|
@@ -291,7 +292,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
291
292
|
}, (e) => [C({
|
|
292
293
|
columns: [e.code_id, e.code_type],
|
|
293
294
|
name: "PK_codes_code_id_code_type"
|
|
294
|
-
}), x("codes_expires_at_index").on(e.expires_at)]),
|
|
295
|
+
}), x("codes_expires_at_index").on(e.expires_at)]), ke = w("authentication_codes", {
|
|
295
296
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
296
297
|
code: T("code", { length: 255 }).primaryKey(),
|
|
297
298
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -305,7 +306,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
305
306
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
306
307
|
expires_at: T("expires_at", { length: 35 }).notNull(),
|
|
307
308
|
used_at: T("used_at", { length: 35 })
|
|
308
|
-
}),
|
|
309
|
+
}), Ae = w("otps", {
|
|
309
310
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
310
311
|
id: T("id", { length: 255 }).primaryKey(),
|
|
311
312
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -324,7 +325,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
324
325
|
used_at: T("used_at", { length: 35 }),
|
|
325
326
|
audience: T("audience", { length: 255 }),
|
|
326
327
|
ip: T("ip", { length: 64 })
|
|
327
|
-
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]),
|
|
328
|
+
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), je = w("tickets", {
|
|
328
329
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
329
330
|
id: T("id", { length: 255 }).primaryKey(),
|
|
330
331
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -477,7 +478,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
477
478
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
478
479
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
479
480
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
480
|
-
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]),
|
|
481
|
+
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]), Me = w("domains", {
|
|
481
482
|
id: T("id", { length: 255 }).primaryKey(),
|
|
482
483
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
483
484
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -510,7 +511,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
510
511
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
511
512
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
512
513
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
513
|
-
]),
|
|
514
|
+
]), Ne = w("invites", {
|
|
514
515
|
id: T("id", { length: 21 }).primaryKey(),
|
|
515
516
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
516
517
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -544,7 +545,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
544
545
|
}, (e) => [C({
|
|
545
546
|
columns: [e.tenant_id, e.id],
|
|
546
547
|
name: "roles_pk"
|
|
547
|
-
})]),
|
|
548
|
+
})]), Pe = w("role_permissions", {
|
|
548
549
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
549
550
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
550
551
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -562,7 +563,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
562
563
|
}),
|
|
563
564
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
564
565
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
565
|
-
]),
|
|
566
|
+
]), Fe = w("user_permissions", {
|
|
566
567
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
567
568
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
568
569
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -623,7 +624,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
623
624
|
}, (e) => [C({
|
|
624
625
|
columns: [e.tenant_id, e.id],
|
|
625
626
|
name: "resource_servers_pk"
|
|
626
|
-
})]),
|
|
627
|
+
})]), Ie = w("branding", {
|
|
627
628
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
628
629
|
logo_url: T("logo_url", { length: 512 }),
|
|
629
630
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -634,12 +635,12 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
634
635
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
635
636
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
636
637
|
dark_mode: T("dark_mode", { length: 8 })
|
|
637
|
-
}),
|
|
638
|
+
}), Le = w("universal_login_templates", {
|
|
638
639
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
639
640
|
body: T("body").notNull(),
|
|
640
641
|
created_at_ts: S("created_at_ts").notNull(),
|
|
641
642
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
642
|
-
}),
|
|
643
|
+
}), Re = w("themes", {
|
|
643
644
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
644
645
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
645
646
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -699,7 +700,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
699
700
|
}, (e) => [C({
|
|
700
701
|
columns: [e.tenant_id, e.themeId],
|
|
701
702
|
name: "themes_pkey"
|
|
702
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
703
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), ze = w("forms", {
|
|
703
704
|
id: T("id", { length: 255 }).primaryKey(),
|
|
704
705
|
name: T("name", { length: 255 }).notNull(),
|
|
705
706
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
@@ -712,20 +713,21 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
712
713
|
style: T("style", { length: 1042 }),
|
|
713
714
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
714
715
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
715
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
716
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Be = w("flows", {
|
|
716
717
|
id: T("id", { length: 24 }).primaryKey(),
|
|
717
718
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
718
719
|
name: T("name", { length: 150 }).notNull(),
|
|
719
720
|
actions: T("actions"),
|
|
720
721
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
721
722
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
722
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
723
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), Ve = w("prompt_settings", {
|
|
723
724
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
724
725
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
725
726
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
726
727
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
727
|
-
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1)
|
|
728
|
-
|
|
728
|
+
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
729
|
+
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
730
|
+
}), He = w("email_providers", {
|
|
729
731
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
730
732
|
name: T("name", { length: 255 }).notNull(),
|
|
731
733
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -734,7 +736,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
734
736
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
735
737
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
736
738
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
737
|
-
}),
|
|
739
|
+
}), Ue = w("email_templates", {
|
|
738
740
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
739
741
|
template: T("template", { length: 64 }).notNull(),
|
|
740
742
|
body: T("body").notNull(),
|
|
@@ -747,7 +749,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
747
749
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
748
750
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
749
751
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
750
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
752
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), We = w("hooks", {
|
|
751
753
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
752
754
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
753
755
|
url: T("url", { length: 512 }),
|
|
@@ -761,14 +763,14 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
761
763
|
template_id: T("template_id", { length: 64 }),
|
|
762
764
|
code_id: T("code_id", { length: 21 }),
|
|
763
765
|
metadata: T("metadata")
|
|
764
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
766
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), Ge = w("hook_code", {
|
|
765
767
|
id: T("id", { length: 21 }).primaryKey(),
|
|
766
768
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
767
769
|
code: T("code").notNull(),
|
|
768
770
|
secrets: T("secrets"),
|
|
769
771
|
created_at_ts: S("created_at_ts").notNull(),
|
|
770
772
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
771
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
773
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), Ke = w("keys", {
|
|
772
774
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
773
775
|
tenant_id: T("tenant_id", { length: 191 }).references(() => k.id, { onDelete: "cascade" }),
|
|
774
776
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -781,7 +783,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
781
783
|
current_until: T("current_until", { length: 35 }),
|
|
782
784
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
783
785
|
connection: T("connection", { length: 255 }).references(() => V.id, { onDelete: "cascade" })
|
|
784
|
-
}),
|
|
786
|
+
}), qe = w("custom_text", {
|
|
785
787
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
786
788
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
787
789
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -792,7 +794,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
792
794
|
e.tenant_id,
|
|
793
795
|
e.prompt,
|
|
794
796
|
e.language
|
|
795
|
-
] })]),
|
|
797
|
+
] })]), Je = w("authentication_methods", {
|
|
796
798
|
id: T("id", { length: 26 }).primaryKey(),
|
|
797
799
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
798
800
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -808,7 +810,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
808
810
|
confirmed: S("confirmed").notNull().default(0),
|
|
809
811
|
created_at_ts: S("created_at_ts").notNull(),
|
|
810
812
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
811
|
-
}, (e) => [x("authentication_methods_tenant_user_idx").on(e.tenant_id, e.user_id), x("authentication_methods_credential_id_idx").on(e.credential_id)]),
|
|
813
|
+
}, (e) => [x("authentication_methods_tenant_user_idx").on(e.tenant_id, e.user_id), x("authentication_methods_credential_id_idx").on(e.credential_id)]), J = w("logs", {
|
|
812
814
|
log_id: T("log_id", { length: 21 }).primaryKey(),
|
|
813
815
|
category: T("category", { length: 255 }),
|
|
814
816
|
tenant_id: T("tenant_id", { length: 64 }),
|
|
@@ -843,7 +845,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
843
845
|
x("logs_tenant_id").on(e.tenant_id),
|
|
844
846
|
x("logs_date").on(e.date),
|
|
845
847
|
x("IDX_logs_tenant_date_type_user").on(e.tenant_id, e.date, e.type, e.user_id)
|
|
846
|
-
]),
|
|
848
|
+
]), Y = w("outbox_events", {
|
|
847
849
|
id: T("id", { length: 26 }).primaryKey(),
|
|
848
850
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
849
851
|
event_type: T("event_type", { length: 64 }).notNull(),
|
|
@@ -865,7 +867,7 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
865
867
|
x("idx_outbox_events_processed_at").on(e.processed_at),
|
|
866
868
|
x("idx_outbox_events_claimed_by").on(e.claimed_by),
|
|
867
869
|
x("idx_outbox_events_tenant_dead_lettered").on(e.tenant_id, e.dead_lettered_at)
|
|
868
|
-
]),
|
|
870
|
+
]), X = w("proxy_routes", {
|
|
869
871
|
id: T("id", { length: 64 }).primaryKey(),
|
|
870
872
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
871
873
|
custom_domain_id: T("custom_domain_id", { length: 256 }).notNull(),
|
|
@@ -874,50 +876,83 @@ var Ce = Object.defineProperty, we = (e, t) => {
|
|
|
874
876
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
875
877
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
876
878
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
877
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
878
|
-
|
|
879
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), Ye = w("scim_configurations", {
|
|
880
|
+
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
881
|
+
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
882
|
+
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
883
|
+
mapping: T("mapping", { length: 16384 }).notNull().default("[]"),
|
|
884
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
885
|
+
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
886
|
+
}, (e) => [C({ columns: [e.tenant_id, e.connection_id] })]), Z = w("scim_tokens", {
|
|
887
|
+
token_id: T("token_id", { length: 64 }).notNull(),
|
|
888
|
+
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
889
|
+
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
890
|
+
token_hash: T("token_hash", { length: 128 }).notNull(),
|
|
891
|
+
scopes: T("scopes", { length: 4096 }).notNull().default("[]"),
|
|
892
|
+
valid_until: T("valid_until", { length: 35 }),
|
|
893
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
894
|
+
last_used_at: T("last_used_at", { length: 35 })
|
|
895
|
+
}, (e) => [
|
|
896
|
+
C({ columns: [e.tenant_id, e.token_id] }),
|
|
897
|
+
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
898
|
+
E("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
899
|
+
]), Xe = w("scim_external_ids", {
|
|
900
|
+
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
901
|
+
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
902
|
+
external_id: T("external_id", { length: 255 }).notNull(),
|
|
903
|
+
user_id: T("user_id", { length: 255 }).notNull(),
|
|
904
|
+
created_at: T("created_at", { length: 35 }).notNull()
|
|
905
|
+
}, (e) => [C({ columns: [
|
|
906
|
+
e.tenant_id,
|
|
907
|
+
e.connection_id,
|
|
908
|
+
e.user_id
|
|
909
|
+
] }), E("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), Ze = /* @__PURE__ */ Te({
|
|
910
|
+
actionExecutions: () => De,
|
|
879
911
|
actionVersions: () => A,
|
|
880
|
-
actions: () =>
|
|
881
|
-
authenticationCodes: () =>
|
|
882
|
-
authenticationMethods: () =>
|
|
883
|
-
branding: () =>
|
|
912
|
+
actions: () => Ee,
|
|
913
|
+
authenticationCodes: () => ke,
|
|
914
|
+
authenticationMethods: () => Je,
|
|
915
|
+
branding: () => Ie,
|
|
884
916
|
clientGrants: () => z,
|
|
885
917
|
clientRegistrationTokens: () => R,
|
|
886
918
|
clients: () => L,
|
|
887
919
|
codes: () => I,
|
|
888
920
|
connections: () => V,
|
|
889
921
|
customDomains: () => H,
|
|
890
|
-
customText: () =>
|
|
891
|
-
domains: () =>
|
|
892
|
-
emailProviders: () =>
|
|
893
|
-
emailTemplates: () =>
|
|
894
|
-
flows: () =>
|
|
895
|
-
forms: () =>
|
|
922
|
+
customText: () => qe,
|
|
923
|
+
domains: () => Me,
|
|
924
|
+
emailProviders: () => He,
|
|
925
|
+
emailTemplates: () => Ue,
|
|
926
|
+
flows: () => Be,
|
|
927
|
+
forms: () => ze,
|
|
896
928
|
grants: () => B,
|
|
897
|
-
hookCode: () =>
|
|
898
|
-
hooks: () =>
|
|
899
|
-
invites: () =>
|
|
900
|
-
keys: () =>
|
|
929
|
+
hookCode: () => Ge,
|
|
930
|
+
hooks: () => We,
|
|
931
|
+
invites: () => Ne,
|
|
932
|
+
keys: () => Ke,
|
|
901
933
|
loginSessions: () => F,
|
|
902
|
-
logs: () =>
|
|
934
|
+
logs: () => J,
|
|
903
935
|
organizations: () => U,
|
|
904
|
-
otps: () =>
|
|
905
|
-
outboxEvents: () =>
|
|
936
|
+
otps: () => Ae,
|
|
937
|
+
outboxEvents: () => Y,
|
|
906
938
|
passwords: () => M,
|
|
907
|
-
promptSettings: () =>
|
|
908
|
-
proxyRoutes: () =>
|
|
939
|
+
promptSettings: () => Ve,
|
|
940
|
+
proxyRoutes: () => X,
|
|
909
941
|
refreshTokens: () => P,
|
|
910
942
|
resourceServers: () => q,
|
|
911
|
-
rolePermissions: () =>
|
|
943
|
+
rolePermissions: () => Pe,
|
|
912
944
|
roles: () => G,
|
|
945
|
+
scimConfigurations: () => Ye,
|
|
946
|
+
scimExternalIds: () => Xe,
|
|
947
|
+
scimTokens: () => Z,
|
|
913
948
|
sessions: () => N,
|
|
914
949
|
tenants: () => k,
|
|
915
|
-
themes: () =>
|
|
916
|
-
tickets: () =>
|
|
917
|
-
universalLoginTemplates: () =>
|
|
918
|
-
userActivity: () =>
|
|
950
|
+
themes: () => Re,
|
|
951
|
+
tickets: () => je,
|
|
952
|
+
universalLoginTemplates: () => Le,
|
|
953
|
+
userActivity: () => Oe,
|
|
919
954
|
userOrganizations: () => W,
|
|
920
|
-
userPermissions: () =>
|
|
955
|
+
userPermissions: () => Fe,
|
|
921
956
|
userRoles: () => K,
|
|
922
957
|
users: () => j
|
|
923
958
|
});
|
|
@@ -932,14 +967,14 @@ function Q(e, t) {
|
|
|
932
967
|
}
|
|
933
968
|
return e;
|
|
934
969
|
}
|
|
935
|
-
function
|
|
970
|
+
function Qe(e, t = "", n = {}) {
|
|
936
971
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
937
972
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
938
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
973
|
+
typeof a == "object" && a && !Array.isArray(a) ? Qe(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
939
974
|
}
|
|
940
975
|
return n;
|
|
941
976
|
}
|
|
942
|
-
function
|
|
977
|
+
function $e(e, t) {
|
|
943
978
|
let n = {};
|
|
944
979
|
for (let [r, i] of Object.entries(e)) {
|
|
945
980
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -956,13 +991,13 @@ function Ye(e, t) {
|
|
|
956
991
|
}
|
|
957
992
|
//#endregion
|
|
958
993
|
//#region src/helpers/filter.ts
|
|
959
|
-
function
|
|
994
|
+
function et(e) {
|
|
960
995
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
961
996
|
}
|
|
962
|
-
function
|
|
997
|
+
function tt(e) {
|
|
963
998
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
964
999
|
}
|
|
965
|
-
function
|
|
1000
|
+
function nt(n, r, i, l = []) {
|
|
966
1001
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
967
1002
|
let t = Number(e);
|
|
968
1003
|
return Number.isFinite(t) ? t : e;
|
|
@@ -974,7 +1009,7 @@ function Qe(n, r, i, l = []) {
|
|
|
974
1009
|
let [, t, r] = n;
|
|
975
1010
|
if (!t || !r) return null;
|
|
976
1011
|
let i = t.trim(), o = r.replace(/^"(.*)"$/, "$1").trim(), s = ee[i];
|
|
977
|
-
return
|
|
1012
|
+
return et(s) ? a(tt(s), ne(o)) : u(s, e) ? b.has(i) ? p(s, `%${o}%`) : a(s, o) : null;
|
|
978
1013
|
}
|
|
979
1014
|
return null;
|
|
980
1015
|
}).filter((e) => e !== null);
|
|
@@ -1003,12 +1038,12 @@ function Qe(n, r, i, l = []) {
|
|
|
1003
1038
|
};
|
|
1004
1039
|
}), E = [];
|
|
1005
1040
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of T) if (t) {
|
|
1006
|
-
let i = ee[t], v =
|
|
1041
|
+
let i = ee[t], v = et(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1007
1042
|
if (!te) {
|
|
1008
1043
|
o ? E.push(r ? y`${y.identifier(t)} IS NULL` : y`${y.identifier(t)} IS NOT NULL`) : E.push(y`${y.identifier(t)} ${y.raw(r ? "!=" : l ?? "=")} ${n}`);
|
|
1009
1044
|
continue;
|
|
1010
1045
|
}
|
|
1011
|
-
let S = v ?
|
|
1046
|
+
let S = v ? tt(i) : y`${te}`;
|
|
1012
1047
|
if (o) E.push(r ? f(te) : d(te));
|
|
1013
1048
|
else if (b.has(t) && l === "=") E.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1014
1049
|
else if (r) switch (l) {
|
|
@@ -1052,11 +1087,11 @@ function Qe(n, r, i, l = []) {
|
|
|
1052
1087
|
}
|
|
1053
1088
|
//#endregion
|
|
1054
1089
|
//#region src/adapters/actions.ts
|
|
1055
|
-
function
|
|
1090
|
+
function rt(e) {
|
|
1056
1091
|
let t = Q(e);
|
|
1057
1092
|
return Array.isArray(t) ? t : [];
|
|
1058
1093
|
}
|
|
1059
|
-
function
|
|
1094
|
+
function it(e) {
|
|
1060
1095
|
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, tenant_id: l, runtime: u, status: d, ...f } = e;
|
|
1061
1096
|
return {
|
|
1062
1097
|
...f,
|
|
@@ -1073,11 +1108,11 @@ function et(e) {
|
|
|
1073
1108
|
updated_at: new Date(Number(n)).toISOString()
|
|
1074
1109
|
};
|
|
1075
1110
|
}
|
|
1076
|
-
function
|
|
1111
|
+
function at(e) {
|
|
1077
1112
|
return {
|
|
1078
1113
|
async create(t, n) {
|
|
1079
1114
|
let r = Date.now(), i = `act_${b()}`;
|
|
1080
|
-
return await e.insert(
|
|
1115
|
+
return await e.insert(Ee).values({
|
|
1081
1116
|
id: i,
|
|
1082
1117
|
tenant_id: t,
|
|
1083
1118
|
name: n.name,
|
|
@@ -1108,28 +1143,28 @@ function tt(e) {
|
|
|
1108
1143
|
};
|
|
1109
1144
|
},
|
|
1110
1145
|
async get(n, r) {
|
|
1111
|
-
let i = await e.select().from(
|
|
1112
|
-
return i ?
|
|
1146
|
+
let i = await e.select().from(Ee).where(t(a(Ee.tenant_id, n), a(Ee.id, r))).get();
|
|
1147
|
+
return i ? it(i) : null;
|
|
1113
1148
|
},
|
|
1114
1149
|
async list(o, s = {}) {
|
|
1115
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1150
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Ee.tenant_id, o)];
|
|
1116
1151
|
if (f) {
|
|
1117
|
-
let e =
|
|
1152
|
+
let e = nt(Ee, f, ["name"]);
|
|
1118
1153
|
e && p.push(e);
|
|
1119
1154
|
}
|
|
1120
|
-
let m = t(...p), h = e.select().from(
|
|
1155
|
+
let m = t(...p), h = e.select().from(Ee).where(m).$dynamic();
|
|
1121
1156
|
if (d?.sort_by) {
|
|
1122
|
-
let e =
|
|
1157
|
+
let e = Ee[d.sort_by];
|
|
1123
1158
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1124
1159
|
}
|
|
1125
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1160
|
+
let g = (await h.offset(c * l).limit(l)).map(it);
|
|
1126
1161
|
if (!u) return {
|
|
1127
1162
|
actions: g,
|
|
1128
1163
|
start: 0,
|
|
1129
1164
|
limit: 0,
|
|
1130
1165
|
length: 0
|
|
1131
1166
|
};
|
|
1132
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1167
|
+
let [_] = await e.select({ count: r() }).from(Ee).where(m);
|
|
1133
1168
|
return {
|
|
1134
1169
|
actions: g,
|
|
1135
1170
|
start: c * l,
|
|
@@ -1140,7 +1175,7 @@ function tt(e) {
|
|
|
1140
1175
|
async update(n, r, i) {
|
|
1141
1176
|
let o = { updated_at_ts: Date.now() };
|
|
1142
1177
|
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) {
|
|
1143
|
-
let s = await e.select({ secrets:
|
|
1178
|
+
let s = await e.select({ secrets: Ee.secrets }).from(Ee).where(t(a(Ee.tenant_id, n), a(Ee.id, r))).get(), c = new Map(rt(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1144
1179
|
name: e.name,
|
|
1145
1180
|
value: c.get(e.name)?.value
|
|
1146
1181
|
} : e);
|
|
@@ -1150,20 +1185,20 @@ function tt(e) {
|
|
|
1150
1185
|
let e = new Date(i.deployed_at).getTime();
|
|
1151
1186
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1152
1187
|
}
|
|
1153
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1188
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(Ee).set(o).where(t(a(Ee.tenant_id, n), a(Ee.id, r))).returning()).length > 0;
|
|
1154
1189
|
},
|
|
1155
1190
|
async remove(n, r) {
|
|
1156
|
-
return (await e.delete(
|
|
1191
|
+
return (await e.delete(Ee).where(t(a(Ee.tenant_id, n), a(Ee.id, r))).returning()).length > 0;
|
|
1157
1192
|
}
|
|
1158
1193
|
};
|
|
1159
1194
|
}
|
|
1160
1195
|
//#endregion
|
|
1161
1196
|
//#region src/adapters/actionExecutions.ts
|
|
1162
|
-
function
|
|
1197
|
+
function ot(e) {
|
|
1163
1198
|
return {
|
|
1164
1199
|
async create(t, n) {
|
|
1165
1200
|
let r = Date.now();
|
|
1166
|
-
return await e.insert(
|
|
1201
|
+
return await e.insert(De).values({
|
|
1167
1202
|
id: n.id,
|
|
1168
1203
|
tenant_id: t,
|
|
1169
1204
|
trigger_id: n.trigger_id,
|
|
@@ -1184,7 +1219,7 @@ function nt(e) {
|
|
|
1184
1219
|
};
|
|
1185
1220
|
},
|
|
1186
1221
|
async get(n, r) {
|
|
1187
|
-
let i = await e.select().from(
|
|
1222
|
+
let i = await e.select().from(De).where(t(a(De.tenant_id, n), a(De.id, r))).get();
|
|
1188
1223
|
return i ? {
|
|
1189
1224
|
id: i.id,
|
|
1190
1225
|
tenant_id: i.tenant_id,
|
|
@@ -1200,12 +1235,12 @@ function nt(e) {
|
|
|
1200
1235
|
}
|
|
1201
1236
|
//#endregion
|
|
1202
1237
|
//#region src/adapters/atomic.ts
|
|
1203
|
-
function
|
|
1238
|
+
function st(e) {
|
|
1204
1239
|
let t = e;
|
|
1205
1240
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1206
1241
|
}
|
|
1207
|
-
async function
|
|
1208
|
-
if (
|
|
1242
|
+
async function ct(e, t) {
|
|
1243
|
+
if (st(e)) return e.batch(t);
|
|
1209
1244
|
await e.run(y`BEGIN`);
|
|
1210
1245
|
try {
|
|
1211
1246
|
let n = [];
|
|
@@ -1222,7 +1257,7 @@ async function it(e, t) {
|
|
|
1222
1257
|
}
|
|
1223
1258
|
//#endregion
|
|
1224
1259
|
//#region src/adapters/actionVersions.ts
|
|
1225
|
-
function
|
|
1260
|
+
function lt(e) {
|
|
1226
1261
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1227
1262
|
return {
|
|
1228
1263
|
...c,
|
|
@@ -1235,7 +1270,7 @@ function at(e) {
|
|
|
1235
1270
|
updated_at: new Date(Number(n)).toISOString()
|
|
1236
1271
|
};
|
|
1237
1272
|
}
|
|
1238
|
-
function
|
|
1273
|
+
function ut(e) {
|
|
1239
1274
|
return {
|
|
1240
1275
|
async create(n, r) {
|
|
1241
1276
|
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: A.number }).from(A).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id))).orderBy(i(A.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(A).values({
|
|
@@ -1252,7 +1287,7 @@ function ot(e) {
|
|
|
1252
1287
|
created_at_ts: o,
|
|
1253
1288
|
updated_at_ts: o
|
|
1254
1289
|
});
|
|
1255
|
-
return await
|
|
1290
|
+
return await ct(e, c ? [e.update(A).set({
|
|
1256
1291
|
deployed: 0,
|
|
1257
1292
|
updated_at_ts: o
|
|
1258
1293
|
}).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id), a(A.deployed, 1))), u] : [u]), {
|
|
@@ -1272,10 +1307,10 @@ function ot(e) {
|
|
|
1272
1307
|
},
|
|
1273
1308
|
async get(n, r, i) {
|
|
1274
1309
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.action_id, r), a(A.id, i))).get();
|
|
1275
|
-
return o ?
|
|
1310
|
+
return o ? lt(o) : null;
|
|
1276
1311
|
},
|
|
1277
1312
|
async list(n, o, s = {}) {
|
|
1278
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(
|
|
1313
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(lt);
|
|
1279
1314
|
if (!u) return {
|
|
1280
1315
|
versions: f,
|
|
1281
1316
|
start: 0,
|
|
@@ -1297,13 +1332,13 @@ function ot(e) {
|
|
|
1297
1332
|
}
|
|
1298
1333
|
//#endregion
|
|
1299
1334
|
//#region src/adapters/branding.ts
|
|
1300
|
-
function
|
|
1335
|
+
function dt(e) {
|
|
1301
1336
|
return e === "dark" || e === "light" || e === "auto";
|
|
1302
1337
|
}
|
|
1303
|
-
function
|
|
1338
|
+
function ft(e) {
|
|
1304
1339
|
return {
|
|
1305
1340
|
async get(t) {
|
|
1306
|
-
let n = await e.select().from(
|
|
1341
|
+
let n = await e.select().from(Ie).where(a(Ie.tenant_id, t)).get();
|
|
1307
1342
|
if (!n) return null;
|
|
1308
1343
|
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;
|
|
1309
1344
|
return O({
|
|
@@ -1318,7 +1353,7 @@ function ct(e) {
|
|
|
1318
1353
|
}
|
|
1319
1354
|
},
|
|
1320
1355
|
font: u ? { url: u } : void 0,
|
|
1321
|
-
dark_mode:
|
|
1356
|
+
dark_mode: dt(d) ? d : void 0
|
|
1322
1357
|
});
|
|
1323
1358
|
},
|
|
1324
1359
|
async set(t, n) {
|
|
@@ -1332,11 +1367,11 @@ function ct(e) {
|
|
|
1332
1367
|
font_url: i?.url,
|
|
1333
1368
|
dark_mode: a
|
|
1334
1369
|
};
|
|
1335
|
-
await e.insert(
|
|
1370
|
+
await e.insert(Ie).values({
|
|
1336
1371
|
tenant_id: t,
|
|
1337
1372
|
...l
|
|
1338
1373
|
}).onConflictDoUpdate({
|
|
1339
|
-
target:
|
|
1374
|
+
target: Ie.tenant_id,
|
|
1340
1375
|
set: l
|
|
1341
1376
|
});
|
|
1342
1377
|
}
|
|
@@ -1344,26 +1379,26 @@ function ct(e) {
|
|
|
1344
1379
|
}
|
|
1345
1380
|
//#endregion
|
|
1346
1381
|
//#region src/helpers/paginate.ts
|
|
1347
|
-
function
|
|
1382
|
+
function pt(e) {
|
|
1348
1383
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1349
1384
|
}
|
|
1350
|
-
function
|
|
1385
|
+
function mt(e) {
|
|
1351
1386
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1352
1387
|
return n >= 1 ? n : 50;
|
|
1353
1388
|
}
|
|
1354
|
-
function
|
|
1389
|
+
function ht(e) {
|
|
1355
1390
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1356
1391
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1357
1392
|
}
|
|
1358
|
-
function
|
|
1393
|
+
function gt(e, t) {
|
|
1359
1394
|
let n = e?.from ? ue(e.from) : null;
|
|
1360
1395
|
if (!n) return;
|
|
1361
|
-
if (n.k !== t.sortKey) throw new
|
|
1396
|
+
if (n.k !== t.sortKey) throw new Ce(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
1362
1397
|
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1363
1398
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1364
1399
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1365
1400
|
}
|
|
1366
|
-
function
|
|
1401
|
+
function _t(e, t, n, r = "id", i) {
|
|
1367
1402
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1368
1403
|
if (a && c) {
|
|
1369
1404
|
let e = c[n];
|
|
@@ -1380,7 +1415,7 @@ function pt(e, t, n, r = "id", i) {
|
|
|
1380
1415
|
}
|
|
1381
1416
|
//#endregion
|
|
1382
1417
|
//#region src/adapters/clients.ts
|
|
1383
|
-
var
|
|
1418
|
+
var vt = [
|
|
1384
1419
|
"global",
|
|
1385
1420
|
"is_first_party",
|
|
1386
1421
|
"oidc_conformant",
|
|
@@ -1392,7 +1427,7 @@ var mt = [
|
|
|
1392
1427
|
"require_pushed_authorization_requests",
|
|
1393
1428
|
"require_proof_of_possession",
|
|
1394
1429
|
"hide_sign_up_disabled_error"
|
|
1395
|
-
],
|
|
1430
|
+
], yt = [
|
|
1396
1431
|
"callbacks",
|
|
1397
1432
|
"allowed_origins",
|
|
1398
1433
|
"web_origins",
|
|
@@ -1401,7 +1436,7 @@ var mt = [
|
|
|
1401
1436
|
"allowed_logout_urls",
|
|
1402
1437
|
"grant_types",
|
|
1403
1438
|
"signing_keys"
|
|
1404
|
-
],
|
|
1439
|
+
], bt = [
|
|
1405
1440
|
"session_transfer",
|
|
1406
1441
|
"oidc_logout",
|
|
1407
1442
|
"jwt_configuration",
|
|
@@ -1417,21 +1452,21 @@ var mt = [
|
|
|
1417
1452
|
"token_quota",
|
|
1418
1453
|
"registration_metadata"
|
|
1419
1454
|
];
|
|
1420
|
-
function
|
|
1455
|
+
function xt(e) {
|
|
1421
1456
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1422
|
-
for (let e of
|
|
1423
|
-
for (let e of
|
|
1424
|
-
for (let e of
|
|
1457
|
+
for (let e of vt) i[e] = !!r[e];
|
|
1458
|
+
for (let e of yt) i[e] = Q(r[e], []);
|
|
1459
|
+
for (let e of bt) i[e] = Q(r[e], {});
|
|
1425
1460
|
return i.connections = Q(n, []), O(i);
|
|
1426
1461
|
}
|
|
1427
|
-
function
|
|
1462
|
+
function St(e) {
|
|
1428
1463
|
let t = { ...e };
|
|
1429
|
-
re(e,
|
|
1430
|
-
for (let n of
|
|
1431
|
-
for (let n of
|
|
1464
|
+
re(e, vt, t);
|
|
1465
|
+
for (let n of yt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1466
|
+
for (let n of bt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1432
1467
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), se(t);
|
|
1433
1468
|
}
|
|
1434
|
-
function
|
|
1469
|
+
function Ct(e) {
|
|
1435
1470
|
return {
|
|
1436
1471
|
async create(t, n) {
|
|
1437
1472
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1455,51 +1490,51 @@ function yt(e) {
|
|
|
1455
1490
|
created_at: r,
|
|
1456
1491
|
updated_at: r
|
|
1457
1492
|
};
|
|
1458
|
-
for (let e of
|
|
1493
|
+
for (let e of vt) i[e] = n[e] ?? !1;
|
|
1459
1494
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1460
|
-
for (let e of
|
|
1461
|
-
for (let e of
|
|
1495
|
+
for (let e of yt) i[e] = n[e] || [];
|
|
1496
|
+
for (let e of bt) i[e] = n[e] || {};
|
|
1462
1497
|
i.connections = n.connections || [];
|
|
1463
|
-
let a =
|
|
1498
|
+
let a = St(i);
|
|
1464
1499
|
try {
|
|
1465
1500
|
await e.insert(L).values({
|
|
1466
1501
|
...a,
|
|
1467
1502
|
tenant_id: t
|
|
1468
1503
|
});
|
|
1469
1504
|
} catch (e) {
|
|
1470
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1505
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Client already exists" }) : e;
|
|
1471
1506
|
}
|
|
1472
|
-
return
|
|
1507
|
+
return xt({
|
|
1473
1508
|
...a,
|
|
1474
1509
|
tenant_id: t
|
|
1475
1510
|
});
|
|
1476
1511
|
},
|
|
1477
1512
|
async get(n, r) {
|
|
1478
1513
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1479
|
-
return i ?
|
|
1514
|
+
return i ? xt(i) : null;
|
|
1480
1515
|
},
|
|
1481
1516
|
async getByClientId(t) {
|
|
1482
1517
|
let n = await e.select().from(L).where(a(L.client_id, t)).get();
|
|
1483
1518
|
return n ? {
|
|
1484
|
-
...
|
|
1519
|
+
...xt(n),
|
|
1485
1520
|
tenant_id: n.tenant_id
|
|
1486
1521
|
} : null;
|
|
1487
1522
|
},
|
|
1488
1523
|
async update(n, r, i) {
|
|
1489
|
-
let o =
|
|
1524
|
+
let o = St({
|
|
1490
1525
|
...i,
|
|
1491
1526
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1492
1527
|
});
|
|
1493
1528
|
return delete o.client_id, delete o.tenant_id, await e.update(L).set(o).where(t(a(L.tenant_id, n), a(L.client_id, r))), !0;
|
|
1494
1529
|
},
|
|
1495
1530
|
async list(o, s) {
|
|
1496
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1497
|
-
if (
|
|
1531
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(L, f, ["name", "client_id"]) : void 0, m = p ? t(a(L.tenant_id, o), p) : a(L.tenant_id, o);
|
|
1532
|
+
if (pt(s)) {
|
|
1498
1533
|
let n = {
|
|
1499
1534
|
sortColumn: L.created_at,
|
|
1500
1535
|
idColumn: L.client_id,
|
|
1501
1536
|
sortOrder: "desc"
|
|
1502
|
-
}, r =
|
|
1537
|
+
}, r = gt(s, n), i = mt(s), { rows: a, next: o } = _t(await e.select().from(L).where(r ? t(m, r) : m).orderBy(...ht(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(xt);
|
|
1503
1538
|
return {
|
|
1504
1539
|
clients: c,
|
|
1505
1540
|
totals: {
|
|
@@ -1515,7 +1550,7 @@ function yt(e) {
|
|
|
1515
1550
|
let e = L[d.sort_by];
|
|
1516
1551
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1517
1552
|
}
|
|
1518
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1553
|
+
let g = (await h.offset(c * l).limit(l)).map(xt);
|
|
1519
1554
|
if (!u) return { clients: g };
|
|
1520
1555
|
let [_] = await e.select({ count: r() }).from(L).where(m);
|
|
1521
1556
|
return {
|
|
@@ -1535,7 +1570,7 @@ function yt(e) {
|
|
|
1535
1570
|
}
|
|
1536
1571
|
//#endregion
|
|
1537
1572
|
//#region src/adapters/clientConnections.ts
|
|
1538
|
-
function
|
|
1573
|
+
function wt(e) {
|
|
1539
1574
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1540
1575
|
return O({
|
|
1541
1576
|
...a,
|
|
@@ -1544,14 +1579,14 @@ function bt(e) {
|
|
|
1544
1579
|
is_system: n ? !0 : void 0
|
|
1545
1580
|
});
|
|
1546
1581
|
}
|
|
1547
|
-
function
|
|
1582
|
+
function Tt(e) {
|
|
1548
1583
|
return {
|
|
1549
1584
|
async listByClient(n, r) {
|
|
1550
1585
|
let i = await e.select({ connections: L.connections }).from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1551
1586
|
if (!i) return [];
|
|
1552
1587
|
let o = Q(i.connections, []) || [];
|
|
1553
1588
|
if (o.length === 0) return [];
|
|
1554
|
-
let s = (await e.select().from(V).where(t(a(V.tenant_id, n), l(V.id, o))).all()).map(
|
|
1589
|
+
let s = (await e.select().from(V).where(t(a(V.tenant_id, n), l(V.id, o))).all()).map(wt);
|
|
1555
1590
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1556
1591
|
},
|
|
1557
1592
|
async updateByClient(n, r, i) {
|
|
@@ -1588,7 +1623,7 @@ function xt(e) {
|
|
|
1588
1623
|
}
|
|
1589
1624
|
//#endregion
|
|
1590
1625
|
//#region src/adapters/clientGrants.ts
|
|
1591
|
-
function
|
|
1626
|
+
function Et(e) {
|
|
1592
1627
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1593
1628
|
return O({
|
|
1594
1629
|
...o,
|
|
@@ -1598,7 +1633,7 @@ function St(e) {
|
|
|
1598
1633
|
is_system: !!a
|
|
1599
1634
|
});
|
|
1600
1635
|
}
|
|
1601
|
-
function
|
|
1636
|
+
function Dt(e) {
|
|
1602
1637
|
return {
|
|
1603
1638
|
async create(t, n) {
|
|
1604
1639
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1615,14 +1650,14 @@ function Ct(e) {
|
|
|
1615
1650
|
created_at: r,
|
|
1616
1651
|
updated_at: r
|
|
1617
1652
|
};
|
|
1618
|
-
return await e.insert(z).values(i),
|
|
1653
|
+
return await e.insert(z).values(i), Et({
|
|
1619
1654
|
...i,
|
|
1620
1655
|
tenant_id: t
|
|
1621
1656
|
});
|
|
1622
1657
|
},
|
|
1623
1658
|
async get(n, r) {
|
|
1624
1659
|
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1625
|
-
return i ?
|
|
1660
|
+
return i ? Et(i) : null;
|
|
1626
1661
|
},
|
|
1627
1662
|
async update(n, r, i) {
|
|
1628
1663
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1632,13 +1667,13 @@ function Ct(e) {
|
|
|
1632
1667
|
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(z).set(d).where(t(a(z.tenant_id, n), a(z.id, r))).returning()).length > 0;
|
|
1633
1668
|
},
|
|
1634
1669
|
async list(o, s) {
|
|
1635
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1636
|
-
if (
|
|
1670
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(z, f, ["client_id", "audience"]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o);
|
|
1671
|
+
if (pt(s)) {
|
|
1637
1672
|
let n = {
|
|
1638
1673
|
sortColumn: z.created_at,
|
|
1639
1674
|
idColumn: z.id,
|
|
1640
1675
|
sortOrder: "desc"
|
|
1641
|
-
}, r =
|
|
1676
|
+
}, r = gt(s, n), i = mt(s), { rows: a, next: o } = _t(await e.select().from(z).where(r ? t(m, r) : m).orderBy(...ht(n)).limit(i + 1), i, "created_at"), c = a.map(Et);
|
|
1642
1677
|
return {
|
|
1643
1678
|
client_grants: c,
|
|
1644
1679
|
start: 0,
|
|
@@ -1652,7 +1687,7 @@ function Ct(e) {
|
|
|
1652
1687
|
let e = z[d.sort_by];
|
|
1653
1688
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1654
1689
|
} else h = h.orderBy(n(z.created_at));
|
|
1655
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1690
|
+
let g = (await h.offset(c * l).limit(l)).map(Et);
|
|
1656
1691
|
if (!u) return { client_grants: g };
|
|
1657
1692
|
let [_] = await e.select({ count: r() }).from(z).where(m);
|
|
1658
1693
|
return {
|
|
@@ -1669,20 +1704,20 @@ function Ct(e) {
|
|
|
1669
1704
|
}
|
|
1670
1705
|
//#endregion
|
|
1671
1706
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1672
|
-
function
|
|
1707
|
+
function Ot(e) {
|
|
1673
1708
|
if (!e) return;
|
|
1674
1709
|
let t = JSON.parse(e);
|
|
1675
1710
|
return pe(t) ? t : void 0;
|
|
1676
1711
|
}
|
|
1677
|
-
function
|
|
1712
|
+
function kt(e) {
|
|
1678
1713
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1679
1714
|
}
|
|
1680
|
-
function
|
|
1715
|
+
function At(e) {
|
|
1681
1716
|
if (!e) return null;
|
|
1682
1717
|
let t = new Date(e);
|
|
1683
1718
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1684
1719
|
}
|
|
1685
|
-
function
|
|
1720
|
+
function jt(e) {
|
|
1686
1721
|
let t = le.parse(e.type);
|
|
1687
1722
|
return {
|
|
1688
1723
|
id: e.id,
|
|
@@ -1690,15 +1725,15 @@ function Dt(e) {
|
|
|
1690
1725
|
type: t,
|
|
1691
1726
|
client_id: e.client_id ?? void 0,
|
|
1692
1727
|
sub: e.sub ?? void 0,
|
|
1693
|
-
constraints:
|
|
1728
|
+
constraints: Ot(e.constraints),
|
|
1694
1729
|
single_use: !!e.single_use,
|
|
1695
|
-
expires_at:
|
|
1696
|
-
used_at:
|
|
1697
|
-
revoked_at:
|
|
1730
|
+
expires_at: kt(e.expires_at_ts),
|
|
1731
|
+
used_at: kt(e.used_at_ts),
|
|
1732
|
+
revoked_at: kt(e.revoked_at_ts),
|
|
1698
1733
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1699
1734
|
};
|
|
1700
1735
|
}
|
|
1701
|
-
function
|
|
1736
|
+
function Mt(e) {
|
|
1702
1737
|
return {
|
|
1703
1738
|
async create(t, n) {
|
|
1704
1739
|
let r = Date.now();
|
|
@@ -1711,7 +1746,7 @@ function Ot(e) {
|
|
|
1711
1746
|
sub: n.sub ?? null,
|
|
1712
1747
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1713
1748
|
single_use: +!!n.single_use,
|
|
1714
|
-
expires_at_ts:
|
|
1749
|
+
expires_at_ts: At(n.expires_at),
|
|
1715
1750
|
created_at_ts: r
|
|
1716
1751
|
}), {
|
|
1717
1752
|
id: n.id,
|
|
@@ -1727,23 +1762,23 @@ function Ot(e) {
|
|
|
1727
1762
|
},
|
|
1728
1763
|
async get(n, r) {
|
|
1729
1764
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1730
|
-
return i ?
|
|
1765
|
+
return i ? jt(i) : null;
|
|
1731
1766
|
},
|
|
1732
1767
|
async getByHash(n, r) {
|
|
1733
1768
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.token_hash, r))).get();
|
|
1734
|
-
return i ?
|
|
1769
|
+
return i ? jt(i) : null;
|
|
1735
1770
|
},
|
|
1736
1771
|
async listByClient(n, r) {
|
|
1737
|
-
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(
|
|
1772
|
+
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(jt);
|
|
1738
1773
|
},
|
|
1739
1774
|
async markUsed(n, r, i) {
|
|
1740
|
-
return (await e.update(R).set({ used_at_ts:
|
|
1775
|
+
return (await e.update(R).set({ used_at_ts: At(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.used_at_ts))).returning()).length > 0;
|
|
1741
1776
|
},
|
|
1742
1777
|
async revoke(n, r, i) {
|
|
1743
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1778
|
+
return (await e.update(R).set({ revoked_at_ts: At(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.revoked_at_ts))).returning()).length > 0;
|
|
1744
1779
|
},
|
|
1745
1780
|
async revokeByClient(n, r, i) {
|
|
1746
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1781
|
+
return (await e.update(R).set({ revoked_at_ts: At(i) }).where(t(a(R.tenant_id, n), a(R.client_id, r), f(R.revoked_at_ts))).returning()).length;
|
|
1747
1782
|
},
|
|
1748
1783
|
async remove(n, r) {
|
|
1749
1784
|
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
@@ -1752,12 +1787,12 @@ function Ot(e) {
|
|
|
1752
1787
|
}
|
|
1753
1788
|
//#endregion
|
|
1754
1789
|
//#region src/adapters/codes.ts
|
|
1755
|
-
var
|
|
1756
|
-
function
|
|
1790
|
+
var Nt = ["code_id", "login_id"], Pt = 500;
|
|
1791
|
+
function Ft(e) {
|
|
1757
1792
|
let { tenant_id: t, ...n } = e;
|
|
1758
1793
|
return O(n);
|
|
1759
1794
|
}
|
|
1760
|
-
function
|
|
1795
|
+
function It(e) {
|
|
1761
1796
|
return {
|
|
1762
1797
|
async create(t, n) {
|
|
1763
1798
|
let r = {
|
|
@@ -1766,18 +1801,18 @@ function Mt(e) {
|
|
|
1766
1801
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1767
1802
|
expires_at: n.expires_at
|
|
1768
1803
|
};
|
|
1769
|
-
return await e.insert(I).values(r),
|
|
1804
|
+
return await e.insert(I).values(r), Ft(r);
|
|
1770
1805
|
},
|
|
1771
1806
|
async get(n, r, i) {
|
|
1772
1807
|
let o = n ? t(a(I.tenant_id, n), a(I.code_id, r), a(I.code_type, i)) : t(a(I.code_id, r), a(I.code_type, i)), s = await e.select().from(I).where(o).get();
|
|
1773
|
-
return s ?
|
|
1808
|
+
return s ? Ft(s) : null;
|
|
1774
1809
|
},
|
|
1775
1810
|
async list(o, s) {
|
|
1776
1811
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(I.tenant_id, o)];
|
|
1777
1812
|
if (f) {
|
|
1778
|
-
let e = _e(f,
|
|
1813
|
+
let e = _e(f, Nt);
|
|
1779
1814
|
if (e) {
|
|
1780
|
-
let t =
|
|
1815
|
+
let t = nt(I, e, Nt);
|
|
1781
1816
|
t && p.push(t);
|
|
1782
1817
|
}
|
|
1783
1818
|
}
|
|
@@ -1786,7 +1821,7 @@ function Mt(e) {
|
|
|
1786
1821
|
let e = I[d.sort_by];
|
|
1787
1822
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1788
1823
|
}
|
|
1789
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1824
|
+
let g = (await h.offset(c * l).limit(l)).map(Ft);
|
|
1790
1825
|
if (!u) return { codes: g };
|
|
1791
1826
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1792
1827
|
return {
|
|
@@ -1808,8 +1843,8 @@ function Mt(e) {
|
|
|
1808
1843
|
async cleanup(t) {
|
|
1809
1844
|
let n = 0;
|
|
1810
1845
|
for (;;) {
|
|
1811
|
-
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${
|
|
1812
|
-
if (n += r.length, r.length <
|
|
1846
|
+
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${Pt})`).returning({ code_id: I.code_id });
|
|
1847
|
+
if (n += r.length, r.length < Pt) break;
|
|
1813
1848
|
}
|
|
1814
1849
|
return n;
|
|
1815
1850
|
}
|
|
@@ -1817,10 +1852,10 @@ function Mt(e) {
|
|
|
1817
1852
|
}
|
|
1818
1853
|
//#endregion
|
|
1819
1854
|
//#region src/adapters/connections.ts
|
|
1820
|
-
function
|
|
1855
|
+
function Lt() {
|
|
1821
1856
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1822
1857
|
}
|
|
1823
|
-
function
|
|
1858
|
+
function Rt(e) {
|
|
1824
1859
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1825
1860
|
return O({
|
|
1826
1861
|
...a,
|
|
@@ -1829,11 +1864,11 @@ function Pt(e) {
|
|
|
1829
1864
|
is_system: n ? !0 : void 0
|
|
1830
1865
|
});
|
|
1831
1866
|
}
|
|
1832
|
-
function
|
|
1867
|
+
function zt(e) {
|
|
1833
1868
|
return {
|
|
1834
1869
|
async create(t, n) {
|
|
1835
1870
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1836
|
-
id: n.id ||
|
|
1871
|
+
id: n.id || Lt(),
|
|
1837
1872
|
...n,
|
|
1838
1873
|
tenant_id: t,
|
|
1839
1874
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1845,13 +1880,13 @@ function Ft(e) {
|
|
|
1845
1880
|
try {
|
|
1846
1881
|
await e.insert(V).values(i);
|
|
1847
1882
|
} catch (e) {
|
|
1848
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1883
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Connection already exists" }) : e;
|
|
1849
1884
|
}
|
|
1850
|
-
return
|
|
1885
|
+
return Rt(i);
|
|
1851
1886
|
},
|
|
1852
1887
|
async get(n, r) {
|
|
1853
1888
|
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
1854
|
-
return i ?
|
|
1889
|
+
return i ? Rt(i) : null;
|
|
1855
1890
|
},
|
|
1856
1891
|
async update(n, r, i) {
|
|
1857
1892
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1860,7 +1895,7 @@ function Ft(e) {
|
|
|
1860
1895
|
async list(o, s) {
|
|
1861
1896
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(V.tenant_id, o);
|
|
1862
1897
|
if (f) {
|
|
1863
|
-
let e =
|
|
1898
|
+
let e = nt(V, f, ["name"]);
|
|
1864
1899
|
e && (p = t(p, e));
|
|
1865
1900
|
}
|
|
1866
1901
|
let m = e.select().from(V).where(p).$dynamic();
|
|
@@ -1868,7 +1903,7 @@ function Ft(e) {
|
|
|
1868
1903
|
let e = V[d.sort_by];
|
|
1869
1904
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1870
1905
|
}
|
|
1871
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1906
|
+
let h = (await m.offset(c * l).limit(l)).map(Rt);
|
|
1872
1907
|
if (!u) return { connections: h };
|
|
1873
1908
|
let [g] = await e.select({ count: r() }).from(V).where(p);
|
|
1874
1909
|
return {
|
|
@@ -1885,7 +1920,7 @@ function Ft(e) {
|
|
|
1885
1920
|
}
|
|
1886
1921
|
//#endregion
|
|
1887
1922
|
//#region src/adapters/customDomains.ts
|
|
1888
|
-
function
|
|
1923
|
+
function Bt(e) {
|
|
1889
1924
|
let { tenant_id: t, domain_metadata: n, ...r } = e;
|
|
1890
1925
|
return O({
|
|
1891
1926
|
...r,
|
|
@@ -1893,7 +1928,7 @@ function It(e) {
|
|
|
1893
1928
|
domain_metadata: Q(n)
|
|
1894
1929
|
});
|
|
1895
1930
|
}
|
|
1896
|
-
function
|
|
1931
|
+
function Vt(e) {
|
|
1897
1932
|
return {
|
|
1898
1933
|
async create(t, n) {
|
|
1899
1934
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1911,24 +1946,24 @@ function Lt(e) {
|
|
|
1911
1946
|
created_at: r,
|
|
1912
1947
|
updated_at: r
|
|
1913
1948
|
};
|
|
1914
|
-
return await e.insert(H).values(i),
|
|
1949
|
+
return await e.insert(H).values(i), Bt({
|
|
1915
1950
|
...i,
|
|
1916
1951
|
tenant_id: t
|
|
1917
1952
|
});
|
|
1918
1953
|
},
|
|
1919
1954
|
async get(n, r) {
|
|
1920
1955
|
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.custom_domain_id, r))).get();
|
|
1921
|
-
return i ?
|
|
1956
|
+
return i ? Bt(i) : null;
|
|
1922
1957
|
},
|
|
1923
1958
|
async getByDomain(t) {
|
|
1924
1959
|
let n = await e.select().from(H).where(a(H.domain, t)).get();
|
|
1925
1960
|
return n ? {
|
|
1926
|
-
...
|
|
1961
|
+
...Bt(n),
|
|
1927
1962
|
tenant_id: n.tenant_id
|
|
1928
1963
|
} : null;
|
|
1929
1964
|
},
|
|
1930
1965
|
async list(t) {
|
|
1931
|
-
return (await e.select().from(H).where(a(H.tenant_id, t)).all()).map(
|
|
1966
|
+
return (await e.select().from(H).where(a(H.tenant_id, t)).all()).map(Bt);
|
|
1932
1967
|
},
|
|
1933
1968
|
async update(n, r, i) {
|
|
1934
1969
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1941,10 +1976,10 @@ function Lt(e) {
|
|
|
1941
1976
|
}
|
|
1942
1977
|
//#endregion
|
|
1943
1978
|
//#region src/adapters/customText.ts
|
|
1944
|
-
function
|
|
1979
|
+
function Ht(e) {
|
|
1945
1980
|
return {
|
|
1946
1981
|
async get(n, r, i) {
|
|
1947
|
-
let o = await e.select().from(
|
|
1982
|
+
let o = await e.select().from(qe).where(t(a(qe.tenant_id, n), a(qe.prompt, r), a(qe.language, i))).get();
|
|
1948
1983
|
if (!o) return null;
|
|
1949
1984
|
try {
|
|
1950
1985
|
return JSON.parse(o.custom_text);
|
|
@@ -1954,7 +1989,7 @@ function Rt(e) {
|
|
|
1954
1989
|
},
|
|
1955
1990
|
async set(t, n, r, i) {
|
|
1956
1991
|
let a = Date.now(), o = JSON.stringify(i);
|
|
1957
|
-
await e.insert(
|
|
1992
|
+
await e.insert(qe).values({
|
|
1958
1993
|
tenant_id: t,
|
|
1959
1994
|
prompt: n,
|
|
1960
1995
|
language: r,
|
|
@@ -1963,9 +1998,9 @@ function Rt(e) {
|
|
|
1963
1998
|
updated_at_ts: a
|
|
1964
1999
|
}).onConflictDoUpdate({
|
|
1965
2000
|
target: [
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2001
|
+
qe.tenant_id,
|
|
2002
|
+
qe.prompt,
|
|
2003
|
+
qe.language
|
|
1969
2004
|
],
|
|
1970
2005
|
set: {
|
|
1971
2006
|
custom_text: o,
|
|
@@ -1974,23 +2009,23 @@ function Rt(e) {
|
|
|
1974
2009
|
});
|
|
1975
2010
|
},
|
|
1976
2011
|
async delete(n, r, i) {
|
|
1977
|
-
await e.delete(
|
|
2012
|
+
await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.prompt, r), a(qe.language, i)));
|
|
1978
2013
|
},
|
|
1979
2014
|
async list(t) {
|
|
1980
2015
|
return await e.select({
|
|
1981
|
-
prompt:
|
|
1982
|
-
language:
|
|
1983
|
-
}).from(
|
|
2016
|
+
prompt: qe.prompt,
|
|
2017
|
+
language: qe.language
|
|
2018
|
+
}).from(qe).where(a(qe.tenant_id, t)).all();
|
|
1984
2019
|
}
|
|
1985
2020
|
};
|
|
1986
2021
|
}
|
|
1987
2022
|
//#endregion
|
|
1988
2023
|
//#region src/adapters/emailProviders.ts
|
|
1989
|
-
function
|
|
2024
|
+
function Ut(e) {
|
|
1990
2025
|
return {
|
|
1991
2026
|
async create(t, n) {
|
|
1992
2027
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
1993
|
-
await e.insert(
|
|
2028
|
+
await e.insert(He).values({
|
|
1994
2029
|
tenant_id: t,
|
|
1995
2030
|
name: n.name,
|
|
1996
2031
|
enabled: n.enabled,
|
|
@@ -2002,7 +2037,7 @@ function zt(e) {
|
|
|
2002
2037
|
});
|
|
2003
2038
|
},
|
|
2004
2039
|
async get(t) {
|
|
2005
|
-
let n = await e.select().from(
|
|
2040
|
+
let n = await e.select().from(He).where(a(He.tenant_id, t)).get();
|
|
2006
2041
|
if (!n) return null;
|
|
2007
2042
|
let { tenant_id: r, ...i } = n;
|
|
2008
2043
|
return O({
|
|
@@ -2014,16 +2049,16 @@ function zt(e) {
|
|
|
2014
2049
|
},
|
|
2015
2050
|
async update(t, n) {
|
|
2016
2051
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2017
|
-
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(
|
|
2052
|
+
n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(He).set(r).where(a(He.tenant_id, t));
|
|
2018
2053
|
},
|
|
2019
2054
|
async remove(t) {
|
|
2020
|
-
await e.delete(
|
|
2055
|
+
await e.delete(He).where(a(He.tenant_id, t));
|
|
2021
2056
|
}
|
|
2022
2057
|
};
|
|
2023
2058
|
}
|
|
2024
2059
|
//#endregion
|
|
2025
2060
|
//#region src/adapters/emailTemplates.ts
|
|
2026
|
-
function
|
|
2061
|
+
function Wt(e) {
|
|
2027
2062
|
return O({
|
|
2028
2063
|
template: e.template,
|
|
2029
2064
|
body: e.body,
|
|
@@ -2036,18 +2071,18 @@ function Bt(e) {
|
|
|
2036
2071
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2037
2072
|
});
|
|
2038
2073
|
}
|
|
2039
|
-
function
|
|
2074
|
+
function Gt(e) {
|
|
2040
2075
|
return {
|
|
2041
2076
|
async get(n, r) {
|
|
2042
|
-
let i = await e.select().from(
|
|
2043
|
-
return i ?
|
|
2077
|
+
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.template, r))).get();
|
|
2078
|
+
return i ? Wt(i) : null;
|
|
2044
2079
|
},
|
|
2045
2080
|
async list(t) {
|
|
2046
|
-
return (await e.select().from(
|
|
2081
|
+
return (await e.select().from(Ue).where(a(Ue.tenant_id, t)).all()).map(Wt);
|
|
2047
2082
|
},
|
|
2048
2083
|
async create(t, n) {
|
|
2049
2084
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2050
|
-
return await e.insert(
|
|
2085
|
+
return await e.insert(Ue).values({
|
|
2051
2086
|
tenant_id: t,
|
|
2052
2087
|
template: n.template,
|
|
2053
2088
|
body: n.body,
|
|
@@ -2065,23 +2100,23 @@ function Vt(e) {
|
|
|
2065
2100
|
async update(n, r, i) {
|
|
2066
2101
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2067
2102
|
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);
|
|
2068
|
-
let s = await e.update(
|
|
2103
|
+
let s = await e.update(Ue).set(o).where(t(a(Ue.tenant_id, n), a(Ue.template, r))).run();
|
|
2069
2104
|
return Number(s.changes ?? 0) > 0;
|
|
2070
2105
|
},
|
|
2071
2106
|
async remove(n, r) {
|
|
2072
|
-
let i = await e.delete(
|
|
2107
|
+
let i = await e.delete(Ue).where(t(a(Ue.tenant_id, n), a(Ue.template, r))).run();
|
|
2073
2108
|
return Number(i.changes ?? 0) > 0;
|
|
2074
2109
|
}
|
|
2075
2110
|
};
|
|
2076
2111
|
}
|
|
2077
2112
|
//#endregion
|
|
2078
2113
|
//#region src/adapters/flows.ts
|
|
2079
|
-
var
|
|
2080
|
-
function
|
|
2114
|
+
var Kt = ["id", "name"];
|
|
2115
|
+
function qt(e) {
|
|
2081
2116
|
return {
|
|
2082
2117
|
async create(t, n) {
|
|
2083
2118
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2084
|
-
return await e.insert(
|
|
2119
|
+
return await e.insert(Be).values({
|
|
2085
2120
|
id: i,
|
|
2086
2121
|
tenant_id: t,
|
|
2087
2122
|
name: n.name,
|
|
@@ -2097,7 +2132,7 @@ function Ut(e) {
|
|
|
2097
2132
|
};
|
|
2098
2133
|
},
|
|
2099
2134
|
async get(n, r) {
|
|
2100
|
-
let i = await e.select().from(
|
|
2135
|
+
let i = await e.select().from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get();
|
|
2101
2136
|
if (!i) return null;
|
|
2102
2137
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2103
2138
|
return O({
|
|
@@ -2107,20 +2142,20 @@ function Ut(e) {
|
|
|
2107
2142
|
},
|
|
2108
2143
|
async update(n, r, i) {
|
|
2109
2144
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2110
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2145
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(Be).set(o).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2111
2146
|
},
|
|
2112
2147
|
async list(o, s) {
|
|
2113
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2148
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Be.tenant_id, o)];
|
|
2114
2149
|
if (f) {
|
|
2115
|
-
let e = _e(f,
|
|
2150
|
+
let e = _e(f, Kt);
|
|
2116
2151
|
if (e) {
|
|
2117
|
-
let t =
|
|
2152
|
+
let t = nt(Be, e, []);
|
|
2118
2153
|
t && p.push(t);
|
|
2119
2154
|
}
|
|
2120
2155
|
}
|
|
2121
|
-
let m = t(...p), h = e.select().from(
|
|
2156
|
+
let m = t(...p), h = e.select().from(Be).where(m).$dynamic();
|
|
2122
2157
|
if (d?.sort_by) {
|
|
2123
|
-
let e =
|
|
2158
|
+
let e = Be[d.sort_by];
|
|
2124
2159
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2125
2160
|
}
|
|
2126
2161
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2131,7 +2166,7 @@ function Ut(e) {
|
|
|
2131
2166
|
});
|
|
2132
2167
|
});
|
|
2133
2168
|
if (!u) return { flows: g };
|
|
2134
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2169
|
+
let [_] = await e.select({ count: r() }).from(Be).where(m);
|
|
2135
2170
|
return {
|
|
2136
2171
|
flows: g,
|
|
2137
2172
|
start: c * l,
|
|
@@ -2140,18 +2175,18 @@ function Ut(e) {
|
|
|
2140
2175
|
};
|
|
2141
2176
|
},
|
|
2142
2177
|
async remove(n, r) {
|
|
2143
|
-
return (await e.delete(
|
|
2178
|
+
return (await e.delete(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
|
|
2144
2179
|
}
|
|
2145
2180
|
};
|
|
2146
2181
|
}
|
|
2147
2182
|
//#endregion
|
|
2148
2183
|
//#region src/adapters/forms.ts
|
|
2149
|
-
var
|
|
2184
|
+
var Jt = [
|
|
2150
2185
|
"nodes",
|
|
2151
2186
|
"start",
|
|
2152
2187
|
"ending"
|
|
2153
|
-
],
|
|
2154
|
-
function
|
|
2188
|
+
], Yt = ["name"];
|
|
2189
|
+
function Xt(e) {
|
|
2155
2190
|
return {
|
|
2156
2191
|
async create(t, n) {
|
|
2157
2192
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2165,8 +2200,8 @@ function Kt(e) {
|
|
|
2165
2200
|
created_at: r,
|
|
2166
2201
|
updated_at: r
|
|
2167
2202
|
};
|
|
2168
|
-
for (let e of
|
|
2169
|
-
return await e.insert(
|
|
2203
|
+
for (let e of Jt) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2204
|
+
return await e.insert(ze).values(a), {
|
|
2170
2205
|
id: i,
|
|
2171
2206
|
...n,
|
|
2172
2207
|
created_at: r,
|
|
@@ -2174,38 +2209,38 @@ function Kt(e) {
|
|
|
2174
2209
|
};
|
|
2175
2210
|
},
|
|
2176
2211
|
async get(n, r) {
|
|
2177
|
-
let i = await e.select().from(
|
|
2212
|
+
let i = await e.select().from(ze).where(t(a(ze.tenant_id, n), a(ze.id, r))).get();
|
|
2178
2213
|
if (!i) return null;
|
|
2179
2214
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2180
|
-
for (let e of
|
|
2215
|
+
for (let e of Jt) c[e] = Q(s[e]);
|
|
2181
2216
|
return O(c);
|
|
2182
2217
|
},
|
|
2183
2218
|
async update(n, r, i) {
|
|
2184
2219
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2185
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2186
|
-
return (await e.update(
|
|
2220
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (Jt.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2221
|
+
return (await e.update(ze).set(o).where(t(a(ze.tenant_id, n), a(ze.id, r))).returning()).length > 0;
|
|
2187
2222
|
},
|
|
2188
2223
|
async list(o, s) {
|
|
2189
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2224
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(ze.tenant_id, o)];
|
|
2190
2225
|
if (f) {
|
|
2191
|
-
let e = _e(f,
|
|
2226
|
+
let e = _e(f, Yt);
|
|
2192
2227
|
if (e) {
|
|
2193
|
-
let t =
|
|
2228
|
+
let t = nt(ze, e, Yt);
|
|
2194
2229
|
t && p.push(t);
|
|
2195
2230
|
}
|
|
2196
2231
|
}
|
|
2197
|
-
let m = t(...p), h = e.select().from(
|
|
2232
|
+
let m = t(...p), h = e.select().from(ze).where(m).$dynamic();
|
|
2198
2233
|
if (d?.sort_by) {
|
|
2199
|
-
let e =
|
|
2234
|
+
let e = ze[d.sort_by];
|
|
2200
2235
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2201
2236
|
}
|
|
2202
2237
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2203
2238
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2204
|
-
for (let e of
|
|
2239
|
+
for (let e of Jt) r[e] = Q(n[e]);
|
|
2205
2240
|
return O(r);
|
|
2206
2241
|
});
|
|
2207
2242
|
if (!u) return { forms: g };
|
|
2208
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2243
|
+
let [_] = await e.select({ count: r() }).from(ze).where(m);
|
|
2209
2244
|
return {
|
|
2210
2245
|
forms: g,
|
|
2211
2246
|
start: c * l,
|
|
@@ -2214,13 +2249,13 @@ function Kt(e) {
|
|
|
2214
2249
|
};
|
|
2215
2250
|
},
|
|
2216
2251
|
async remove(n, r) {
|
|
2217
|
-
return (await e.delete(
|
|
2252
|
+
return (await e.delete(ze).where(t(a(ze.tenant_id, n), a(ze.id, r))).returning()).length > 0;
|
|
2218
2253
|
}
|
|
2219
2254
|
};
|
|
2220
2255
|
}
|
|
2221
2256
|
//#endregion
|
|
2222
2257
|
//#region src/adapters/grants.ts
|
|
2223
|
-
function
|
|
2258
|
+
function Zt(e) {
|
|
2224
2259
|
return {
|
|
2225
2260
|
id: e.id,
|
|
2226
2261
|
user_id: e.user_id,
|
|
@@ -2229,17 +2264,17 @@ function qt(e) {
|
|
|
2229
2264
|
scope: Q(e.scope, []) ?? []
|
|
2230
2265
|
};
|
|
2231
2266
|
}
|
|
2232
|
-
var
|
|
2267
|
+
var Qt = {
|
|
2233
2268
|
user_id: B.user_id,
|
|
2234
2269
|
client_id: B.client_id,
|
|
2235
2270
|
audience: B.audience,
|
|
2236
2271
|
created_at: B.created_at,
|
|
2237
2272
|
updated_at: B.updated_at
|
|
2238
2273
|
};
|
|
2239
|
-
function
|
|
2240
|
-
return Object.hasOwn(
|
|
2274
|
+
function $t(e) {
|
|
2275
|
+
return Object.hasOwn(Qt, e) ? Qt[e] : void 0;
|
|
2241
2276
|
}
|
|
2242
|
-
function
|
|
2277
|
+
function en(e) {
|
|
2243
2278
|
return {
|
|
2244
2279
|
async create(n, r) {
|
|
2245
2280
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r.user_id), a(B.client_id, r.clientID), a(B.audience, s))).get();
|
|
@@ -2248,7 +2283,7 @@ function Xt(e) {
|
|
|
2248
2283
|
return await e.update(B).set({
|
|
2249
2284
|
scope: JSON.stringify(s),
|
|
2250
2285
|
updated_at: i
|
|
2251
|
-
}).where(t(a(B.tenant_id, n), a(B.id, c.id))),
|
|
2286
|
+
}).where(t(a(B.tenant_id, n), a(B.id, c.id))), Zt({
|
|
2252
2287
|
...c,
|
|
2253
2288
|
scope: JSON.stringify(s)
|
|
2254
2289
|
});
|
|
@@ -2273,16 +2308,16 @@ function Xt(e) {
|
|
|
2273
2308
|
},
|
|
2274
2309
|
async get(n, r, i, o) {
|
|
2275
2310
|
let s = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r), a(B.client_id, i), a(B.audience, o ?? ""))).get();
|
|
2276
|
-
return s ?
|
|
2311
|
+
return s ? Zt(s) : null;
|
|
2277
2312
|
},
|
|
2278
2313
|
async list(o, s) {
|
|
2279
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2314
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(B, f, [
|
|
2280
2315
|
"user_id",
|
|
2281
2316
|
"client_id",
|
|
2282
2317
|
"audience"
|
|
2283
|
-
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ?
|
|
2318
|
+
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ? $t(d.sort_by) : void 0;
|
|
2284
2319
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(B.created_at));
|
|
2285
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2320
|
+
let _ = (await h.offset(c * l).limit(l)).map(Zt);
|
|
2286
2321
|
if (!u) return {
|
|
2287
2322
|
grants: _,
|
|
2288
2323
|
start: 0,
|
|
@@ -2307,11 +2342,11 @@ function Xt(e) {
|
|
|
2307
2342
|
}
|
|
2308
2343
|
//#endregion
|
|
2309
2344
|
//#region src/adapters/hookCode.ts
|
|
2310
|
-
var
|
|
2311
|
-
function
|
|
2312
|
-
return `hc_${
|
|
2345
|
+
var tn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2346
|
+
function nn() {
|
|
2347
|
+
return `hc_${tn()}`;
|
|
2313
2348
|
}
|
|
2314
|
-
function
|
|
2349
|
+
function rn(e) {
|
|
2315
2350
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ie({
|
|
2316
2351
|
created_at_ts: t,
|
|
2317
2352
|
updated_at_ts: n
|
|
@@ -2322,41 +2357,41 @@ function $t(e) {
|
|
|
2322
2357
|
secrets: r ? JSON.parse(r) : void 0
|
|
2323
2358
|
};
|
|
2324
2359
|
}
|
|
2325
|
-
function
|
|
2360
|
+
function an(e) {
|
|
2326
2361
|
return {
|
|
2327
2362
|
async create(t, n) {
|
|
2328
2363
|
let r = Date.now(), i = {
|
|
2329
|
-
id:
|
|
2364
|
+
id: nn(),
|
|
2330
2365
|
tenant_id: t,
|
|
2331
2366
|
code: n.code,
|
|
2332
2367
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2333
2368
|
created_at_ts: r,
|
|
2334
2369
|
updated_at_ts: r
|
|
2335
2370
|
};
|
|
2336
|
-
return await e.insert(
|
|
2371
|
+
return await e.insert(Ge).values(i), rn({
|
|
2337
2372
|
...i,
|
|
2338
2373
|
tenant_id: t
|
|
2339
2374
|
});
|
|
2340
2375
|
},
|
|
2341
2376
|
async get(n, r) {
|
|
2342
|
-
let i = await e.select().from(
|
|
2343
|
-
return i ?
|
|
2377
|
+
let i = await e.select().from(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).get();
|
|
2378
|
+
return i ? rn(i) : null;
|
|
2344
2379
|
},
|
|
2345
2380
|
async update(n, r, i) {
|
|
2346
2381
|
let o = { updated_at_ts: Date.now() };
|
|
2347
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2382
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(Ge).set(o).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2348
2383
|
},
|
|
2349
2384
|
async remove(n, r) {
|
|
2350
|
-
return (await e.delete(
|
|
2385
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2351
2386
|
}
|
|
2352
2387
|
};
|
|
2353
2388
|
}
|
|
2354
2389
|
//#endregion
|
|
2355
2390
|
//#region src/adapters/hooks.ts
|
|
2356
|
-
function
|
|
2391
|
+
function on() {
|
|
2357
2392
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2358
2393
|
}
|
|
2359
|
-
function
|
|
2394
|
+
function sn(e) {
|
|
2360
2395
|
if (!(typeof e != "string" || !e)) try {
|
|
2361
2396
|
let t = JSON.parse(e);
|
|
2362
2397
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2364,7 +2399,7 @@ function nn(e) {
|
|
|
2364
2399
|
return;
|
|
2365
2400
|
}
|
|
2366
2401
|
}
|
|
2367
|
-
function
|
|
2402
|
+
function cn(e) {
|
|
2368
2403
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ie({
|
|
2369
2404
|
created_at_ts: n,
|
|
2370
2405
|
updated_at_ts: r
|
|
@@ -2373,15 +2408,15 @@ function rn(e) {
|
|
|
2373
2408
|
...a,
|
|
2374
2409
|
enabled: !!a.enabled,
|
|
2375
2410
|
synchronous: !!a.synchronous,
|
|
2376
|
-
metadata:
|
|
2411
|
+
metadata: sn(i),
|
|
2377
2412
|
...o
|
|
2378
2413
|
});
|
|
2379
2414
|
}
|
|
2380
|
-
function
|
|
2415
|
+
function ln(e) {
|
|
2381
2416
|
return {
|
|
2382
2417
|
async create(t, n) {
|
|
2383
2418
|
let r = Date.now(), i = {
|
|
2384
|
-
hook_id: n.hook_id ||
|
|
2419
|
+
hook_id: n.hook_id || on(),
|
|
2385
2420
|
tenant_id: t,
|
|
2386
2421
|
trigger_id: n.trigger_id,
|
|
2387
2422
|
url: n.url,
|
|
@@ -2395,30 +2430,30 @@ function an(e) {
|
|
|
2395
2430
|
created_at_ts: r,
|
|
2396
2431
|
updated_at_ts: r
|
|
2397
2432
|
};
|
|
2398
|
-
return await e.insert(
|
|
2433
|
+
return await e.insert(We).values(i), cn({
|
|
2399
2434
|
...i,
|
|
2400
2435
|
tenant_id: t
|
|
2401
2436
|
});
|
|
2402
2437
|
},
|
|
2403
2438
|
async get(n, r) {
|
|
2404
|
-
let i = await e.select().from(
|
|
2405
|
-
return i ?
|
|
2439
|
+
let i = await e.select().from(We).where(t(a(We.tenant_id, n), a(We.hook_id, r))).get();
|
|
2440
|
+
return i ? cn(i) : null;
|
|
2406
2441
|
},
|
|
2407
2442
|
async update(n, r, i) {
|
|
2408
2443
|
let o = { updated_at_ts: Date.now() };
|
|
2409
|
-
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(
|
|
2444
|
+
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(We).set(o).where(t(a(We.tenant_id, n), a(We.hook_id, r))).returning()).length > 0;
|
|
2410
2445
|
},
|
|
2411
2446
|
async list(o, s) {
|
|
2412
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2447
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(We, f, [
|
|
2413
2448
|
"url",
|
|
2414
2449
|
"form_id",
|
|
2415
2450
|
"template_id",
|
|
2416
2451
|
"code_id"
|
|
2417
|
-
]) : void 0, m = p ? t(a(
|
|
2418
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2419
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2452
|
+
]) : void 0, m = p ? t(a(We.tenant_id, o), p) : a(We.tenant_id, o), h = e.select().from(We).where(m).$dynamic(), g = d?.sort_by ? We[d.sort_by] : void 0;
|
|
2453
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(We.priority), n(We.created_at_ts));
|
|
2454
|
+
let _ = (await h.offset(c * l).limit(l)).map(cn);
|
|
2420
2455
|
if (!u) return { hooks: _ };
|
|
2421
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2456
|
+
let [v] = await e.select({ count: r() }).from(We).where(m);
|
|
2422
2457
|
return {
|
|
2423
2458
|
hooks: _,
|
|
2424
2459
|
start: c * l,
|
|
@@ -2427,31 +2462,31 @@ function an(e) {
|
|
|
2427
2462
|
};
|
|
2428
2463
|
},
|
|
2429
2464
|
async remove(n, r) {
|
|
2430
|
-
return (await e.delete(
|
|
2465
|
+
return (await e.delete(We).where(t(a(We.tenant_id, n), a(We.hook_id, r))).returning()).length > 0;
|
|
2431
2466
|
}
|
|
2432
2467
|
};
|
|
2433
2468
|
}
|
|
2434
2469
|
//#endregion
|
|
2435
2470
|
//#region src/adapters/invites.ts
|
|
2436
|
-
function
|
|
2471
|
+
function un() {
|
|
2437
2472
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2438
2473
|
}
|
|
2439
|
-
var
|
|
2474
|
+
var dn = [
|
|
2440
2475
|
"inviter",
|
|
2441
2476
|
"invitee",
|
|
2442
2477
|
"app_metadata",
|
|
2443
2478
|
"user_metadata",
|
|
2444
2479
|
"roles"
|
|
2445
2480
|
];
|
|
2446
|
-
function
|
|
2481
|
+
function fn(e) {
|
|
2447
2482
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2448
|
-
for (let e of
|
|
2483
|
+
for (let e of dn) i[e] = Q(r[e], e === "roles" ? [] : {});
|
|
2449
2484
|
return i.send_invitation_email = !!n, O(i);
|
|
2450
2485
|
}
|
|
2451
|
-
function
|
|
2486
|
+
function pn(e) {
|
|
2452
2487
|
return {
|
|
2453
2488
|
async create(t, n) {
|
|
2454
|
-
let r = n.id ||
|
|
2489
|
+
let r = n.id || un(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2455
2490
|
id: r,
|
|
2456
2491
|
tenant_id: t,
|
|
2457
2492
|
organization_id: n.organization_id,
|
|
@@ -2464,35 +2499,35 @@ function ln(e) {
|
|
|
2464
2499
|
created_at: a.toISOString(),
|
|
2465
2500
|
expires_at: o
|
|
2466
2501
|
};
|
|
2467
|
-
for (let e of
|
|
2502
|
+
for (let e of dn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2468
2503
|
try {
|
|
2469
|
-
await e.insert(
|
|
2504
|
+
await e.insert(Ne).values(s);
|
|
2470
2505
|
} catch (e) {
|
|
2471
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
2506
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "Invite already exists" }) : e;
|
|
2472
2507
|
}
|
|
2473
|
-
return
|
|
2508
|
+
return fn({
|
|
2474
2509
|
...s,
|
|
2475
2510
|
tenant_id: t
|
|
2476
2511
|
});
|
|
2477
2512
|
},
|
|
2478
2513
|
async get(n, r) {
|
|
2479
|
-
let i = await e.select().from(
|
|
2480
|
-
return i ?
|
|
2514
|
+
let i = await e.select().from(Ne).where(t(a(Ne.tenant_id, n), a(Ne.id, r))).get();
|
|
2515
|
+
return i ? fn(i) : null;
|
|
2481
2516
|
},
|
|
2482
2517
|
async update(n, r, i) {
|
|
2483
2518
|
let o = {};
|
|
2484
|
-
for (let e of
|
|
2485
|
-
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(
|
|
2519
|
+
for (let e of dn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2520
|
+
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Ne).set(o).where(t(a(Ne.tenant_id, n), a(Ne.id, r))).returning()).length > 0;
|
|
2486
2521
|
},
|
|
2487
2522
|
async list(t, o) {
|
|
2488
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2523
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Ne).where(a(Ne.tenant_id, t)).$dynamic();
|
|
2489
2524
|
if (u?.sort_by) {
|
|
2490
|
-
let e =
|
|
2525
|
+
let e = Ne[u.sort_by];
|
|
2491
2526
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2492
2527
|
}
|
|
2493
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2528
|
+
let f = (await d.offset(s * c).limit(c)).map(fn);
|
|
2494
2529
|
if (!l) return { invites: f };
|
|
2495
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2530
|
+
let [p] = await e.select({ count: r() }).from(Ne).where(a(Ne.tenant_id, t));
|
|
2496
2531
|
return {
|
|
2497
2532
|
invites: f,
|
|
2498
2533
|
start: s * c,
|
|
@@ -2501,39 +2536,39 @@ function ln(e) {
|
|
|
2501
2536
|
};
|
|
2502
2537
|
},
|
|
2503
2538
|
async remove(n, r) {
|
|
2504
|
-
return (await e.delete(
|
|
2539
|
+
return (await e.delete(Ne).where(t(a(Ne.tenant_id, n), a(Ne.id, r))).returning()).length > 0;
|
|
2505
2540
|
}
|
|
2506
2541
|
};
|
|
2507
2542
|
}
|
|
2508
2543
|
//#endregion
|
|
2509
2544
|
//#region src/adapters/keys.ts
|
|
2510
|
-
var
|
|
2545
|
+
var mn = [
|
|
2511
2546
|
"kid",
|
|
2512
2547
|
"connection",
|
|
2513
2548
|
"fingerprint",
|
|
2514
2549
|
"thumbprint",
|
|
2515
2550
|
"type"
|
|
2516
2551
|
];
|
|
2517
|
-
function
|
|
2552
|
+
function hn(e) {
|
|
2518
2553
|
return {
|
|
2519
2554
|
async create(t) {
|
|
2520
|
-
await e.insert(
|
|
2555
|
+
await e.insert(Ke).values({
|
|
2521
2556
|
...t,
|
|
2522
2557
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2523
2558
|
});
|
|
2524
2559
|
},
|
|
2525
2560
|
async list(a) {
|
|
2526
|
-
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(
|
|
2561
|
+
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(Ke.revoked_at, p), f(Ke.revoked_at))];
|
|
2527
2562
|
if (d) {
|
|
2528
|
-
let e = _e(d,
|
|
2563
|
+
let e = _e(d, mn);
|
|
2529
2564
|
if (e) {
|
|
2530
|
-
let t =
|
|
2565
|
+
let t = nt(Ke, e, mn);
|
|
2531
2566
|
t && m.push(t);
|
|
2532
2567
|
}
|
|
2533
2568
|
}
|
|
2534
|
-
let h = t(...m), g = e.select().from(
|
|
2569
|
+
let h = t(...m), g = e.select().from(Ke).where(h).$dynamic();
|
|
2535
2570
|
if (u?.sort_by) {
|
|
2536
|
-
let e =
|
|
2571
|
+
let e = Ke[u.sort_by];
|
|
2537
2572
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2538
2573
|
}
|
|
2539
2574
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2541,7 +2576,7 @@ function dn(e) {
|
|
|
2541
2576
|
return O(n);
|
|
2542
2577
|
});
|
|
2543
2578
|
if (!l) return { signingKeys: _ };
|
|
2544
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2579
|
+
let [y] = await e.select({ count: r() }).from(Ke).where(h);
|
|
2545
2580
|
return {
|
|
2546
2581
|
signingKeys: _,
|
|
2547
2582
|
start: o * c,
|
|
@@ -2550,22 +2585,22 @@ function dn(e) {
|
|
|
2550
2585
|
};
|
|
2551
2586
|
},
|
|
2552
2587
|
async update(t, n) {
|
|
2553
|
-
return (await e.update(
|
|
2588
|
+
return (await e.update(Ke).set(n).where(a(Ke.kid, t)).returning()).length > 0;
|
|
2554
2589
|
}
|
|
2555
2590
|
};
|
|
2556
2591
|
}
|
|
2557
2592
|
//#endregion
|
|
2558
2593
|
//#region src/adapters/loginSessions.ts
|
|
2559
|
-
var
|
|
2560
|
-
function
|
|
2594
|
+
var gn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", _n = 32;
|
|
2595
|
+
function vn() {
|
|
2561
2596
|
let e = Date.now(), t = "";
|
|
2562
|
-
for (let n = 10; n > 0; n--) t =
|
|
2597
|
+
for (let n = 10; n > 0; n--) t = gn.charAt(e % _n) + t, e = Math.floor(e / _n);
|
|
2563
2598
|
let n = new Uint8Array(16);
|
|
2564
2599
|
crypto.getRandomValues(n);
|
|
2565
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2600
|
+
for (let e = 0; e < 16; e++) t += gn.charAt(n[e] % _n);
|
|
2566
2601
|
return t;
|
|
2567
2602
|
}
|
|
2568
|
-
function
|
|
2603
|
+
function yn(e) {
|
|
2569
2604
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, state_data: a, auth_params: o, ...s } = e, c = ie({
|
|
2570
2605
|
created_at_ts: n,
|
|
2571
2606
|
updated_at_ts: r,
|
|
@@ -2577,17 +2612,17 @@ function hn(e) {
|
|
|
2577
2612
|
]), l = {};
|
|
2578
2613
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2579
2614
|
return O({
|
|
2580
|
-
|
|
2615
|
+
...$e(l, ["auth_strategy"]),
|
|
2581
2616
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2582
2617
|
...c,
|
|
2583
2618
|
state_data: Q(a)
|
|
2584
2619
|
});
|
|
2585
2620
|
}
|
|
2586
|
-
function
|
|
2621
|
+
function bn(e) {
|
|
2587
2622
|
return {
|
|
2588
2623
|
async create(t, n) {
|
|
2589
2624
|
let r = Date.now(), i = {
|
|
2590
|
-
id:
|
|
2625
|
+
id: vn(),
|
|
2591
2626
|
tenant_id: t,
|
|
2592
2627
|
session_id: n.session_id,
|
|
2593
2628
|
csrf_token: n.csrf_token,
|
|
@@ -2608,14 +2643,14 @@ function gn(e) {
|
|
|
2608
2643
|
updated_at_ts: r,
|
|
2609
2644
|
expires_at_ts: n.expires_at ? D(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2610
2645
|
};
|
|
2611
|
-
return await e.insert(F).values(i),
|
|
2646
|
+
return await e.insert(F).values(i), yn({
|
|
2612
2647
|
...i,
|
|
2613
2648
|
tenant_id: t
|
|
2614
2649
|
});
|
|
2615
2650
|
},
|
|
2616
2651
|
async get(n, r) {
|
|
2617
2652
|
let i = n ? t(a(F.tenant_id, n), a(F.id, r)) : a(F.id, r), o = await e.select().from(F).where(i).get();
|
|
2618
|
-
return o ?
|
|
2653
|
+
return o ? yn(o) : null;
|
|
2619
2654
|
},
|
|
2620
2655
|
async update(n, r, i) {
|
|
2621
2656
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2635,7 +2670,7 @@ function gn(e) {
|
|
|
2635
2670
|
}
|
|
2636
2671
|
//#endregion
|
|
2637
2672
|
//#region src/adapters/logs.ts
|
|
2638
|
-
function
|
|
2673
|
+
function xn(e) {
|
|
2639
2674
|
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 = {
|
|
2640
2675
|
...f,
|
|
2641
2676
|
isMobile: !!n,
|
|
@@ -2652,7 +2687,7 @@ function _n(e) {
|
|
|
2652
2687
|
continent_code: u
|
|
2653
2688
|
})), O(p);
|
|
2654
2689
|
}
|
|
2655
|
-
function
|
|
2690
|
+
function Sn(e) {
|
|
2656
2691
|
return {
|
|
2657
2692
|
async create(t, n) {
|
|
2658
2693
|
let r = {
|
|
@@ -2678,15 +2713,15 @@ function vn(e) {
|
|
|
2678
2713
|
hostname: n.hostname,
|
|
2679
2714
|
session_connection: n.session_connection
|
|
2680
2715
|
};
|
|
2681
|
-
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(
|
|
2716
|
+
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(J).values(r), xn({
|
|
2682
2717
|
...r,
|
|
2683
2718
|
tenant_id: t
|
|
2684
2719
|
});
|
|
2685
2720
|
},
|
|
2686
2721
|
async list(o, s) {
|
|
2687
|
-
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(
|
|
2722
|
+
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(J.tenant_id, o)];
|
|
2688
2723
|
if (p) {
|
|
2689
|
-
let e =
|
|
2724
|
+
let e = nt(J, p, [
|
|
2690
2725
|
"user_id",
|
|
2691
2726
|
"ip",
|
|
2692
2727
|
"type",
|
|
@@ -2694,16 +2729,16 @@ function vn(e) {
|
|
|
2694
2729
|
], ["description"]);
|
|
2695
2730
|
e && _.push(e);
|
|
2696
2731
|
}
|
|
2697
|
-
typeof h == "number" && Number.isFinite(h) && _.push(c(
|
|
2732
|
+
typeof h == "number" && Number.isFinite(h) && _.push(c(J.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(J.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2698
2733
|
let v = t(..._);
|
|
2699
|
-
if (
|
|
2700
|
-
if (f?.sort_by && f.sort_by !== "date") throw new
|
|
2734
|
+
if (pt(s)) {
|
|
2735
|
+
if (f?.sort_by && f.sort_by !== "date") throw new Ce(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2701
2736
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2702
|
-
sortColumn:
|
|
2703
|
-
idColumn:
|
|
2737
|
+
sortColumn: J.date,
|
|
2738
|
+
idColumn: J.log_id,
|
|
2704
2739
|
sortOrder: n,
|
|
2705
2740
|
sortKey: `date:${n}`
|
|
2706
|
-
}, i =
|
|
2741
|
+
}, i = gt(s, r), a = mt(s), { rows: o, next: c } = _t(await e.select().from(J).where(i ? t(v, i) : v).orderBy(...ht(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(xn);
|
|
2707
2742
|
return {
|
|
2708
2743
|
logs: l,
|
|
2709
2744
|
start: 0,
|
|
@@ -2712,14 +2747,14 @@ function vn(e) {
|
|
|
2712
2747
|
next: c
|
|
2713
2748
|
};
|
|
2714
2749
|
}
|
|
2715
|
-
let y = e.select().from(
|
|
2750
|
+
let y = e.select().from(J).where(v).$dynamic();
|
|
2716
2751
|
if (f?.sort_by) {
|
|
2717
|
-
let e =
|
|
2752
|
+
let e = J[f.sort_by];
|
|
2718
2753
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2719
|
-
} else y = y.orderBy(i(
|
|
2720
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2754
|
+
} else y = y.orderBy(i(J.date));
|
|
2755
|
+
let ee = (await y.offset(l * u).limit(u)).map(xn);
|
|
2721
2756
|
if (!d) return { logs: ee };
|
|
2722
|
-
let [b] = await e.select({ count: r() }).from(
|
|
2757
|
+
let [b] = await e.select({ count: r() }).from(J).where(v);
|
|
2723
2758
|
return {
|
|
2724
2759
|
logs: ee,
|
|
2725
2760
|
start: l * u,
|
|
@@ -2728,23 +2763,23 @@ function vn(e) {
|
|
|
2728
2763
|
};
|
|
2729
2764
|
},
|
|
2730
2765
|
async get(n, r) {
|
|
2731
|
-
let i = await e.select().from(
|
|
2732
|
-
return i ?
|
|
2766
|
+
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.log_id, r))).get();
|
|
2767
|
+
return i ? xn(i) : null;
|
|
2733
2768
|
}
|
|
2734
2769
|
};
|
|
2735
2770
|
}
|
|
2736
2771
|
//#endregion
|
|
2737
2772
|
//#region src/adapters/authenticationMethods.ts
|
|
2738
|
-
var
|
|
2739
|
-
function
|
|
2773
|
+
var Cn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", wn = 32;
|
|
2774
|
+
function Tn() {
|
|
2740
2775
|
let e = Date.now(), t = "";
|
|
2741
|
-
for (let n = 10; n > 0; n--) t =
|
|
2776
|
+
for (let n = 10; n > 0; n--) t = Cn.charAt(e % wn) + t, e = Math.floor(e / wn);
|
|
2742
2777
|
let n = new Uint8Array(16);
|
|
2743
2778
|
crypto.getRandomValues(n);
|
|
2744
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2779
|
+
for (let e = 0; e < 16; e++) t += Cn.charAt(n[e] % wn);
|
|
2745
2780
|
return t;
|
|
2746
2781
|
}
|
|
2747
|
-
function
|
|
2782
|
+
function En(e) {
|
|
2748
2783
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2749
2784
|
return O({
|
|
2750
2785
|
...s,
|
|
@@ -2755,11 +2790,11 @@ function Sn(e) {
|
|
|
2755
2790
|
updated_at: ae(r)
|
|
2756
2791
|
});
|
|
2757
2792
|
}
|
|
2758
|
-
function
|
|
2793
|
+
function Dn(e) {
|
|
2759
2794
|
return {
|
|
2760
2795
|
async create(t, n) {
|
|
2761
2796
|
let r = Date.now(), i = {
|
|
2762
|
-
id: n.id ||
|
|
2797
|
+
id: n.id || Tn(),
|
|
2763
2798
|
tenant_id: t,
|
|
2764
2799
|
user_id: n.user_id,
|
|
2765
2800
|
type: n.type,
|
|
@@ -2775,41 +2810,41 @@ function Cn(e) {
|
|
|
2775
2810
|
created_at_ts: r,
|
|
2776
2811
|
updated_at_ts: r
|
|
2777
2812
|
};
|
|
2778
|
-
return await e.insert(
|
|
2813
|
+
return await e.insert(Je).values(i), En({
|
|
2779
2814
|
...i,
|
|
2780
2815
|
tenant_id: t
|
|
2781
2816
|
});
|
|
2782
2817
|
},
|
|
2783
2818
|
async get(n, r) {
|
|
2784
|
-
let i = await e.select().from(
|
|
2785
|
-
return i ?
|
|
2819
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).get();
|
|
2820
|
+
return i ? En(i) : null;
|
|
2786
2821
|
},
|
|
2787
2822
|
async getByCredentialId(n, r) {
|
|
2788
|
-
let i = await e.select().from(
|
|
2789
|
-
return i ?
|
|
2823
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.credential_id, r))).get();
|
|
2824
|
+
return i ? En(i) : null;
|
|
2790
2825
|
},
|
|
2791
2826
|
async list(n, r) {
|
|
2792
|
-
return (await e.select().from(
|
|
2827
|
+
return (await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.user_id, r))).all()).map(En);
|
|
2793
2828
|
},
|
|
2794
2829
|
async update(n, r, i) {
|
|
2795
2830
|
let o = { updated_at_ts: Date.now() };
|
|
2796
|
-
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(
|
|
2831
|
+
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(Je).set(o).where(t(a(Je.tenant_id, n), a(Je.id, r)));
|
|
2797
2832
|
let s = await this.get(n, r);
|
|
2798
2833
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2799
2834
|
return s;
|
|
2800
2835
|
},
|
|
2801
2836
|
async remove(n, r) {
|
|
2802
|
-
return (await e.delete(
|
|
2837
|
+
return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
|
|
2803
2838
|
}
|
|
2804
2839
|
};
|
|
2805
2840
|
}
|
|
2806
2841
|
//#endregion
|
|
2807
2842
|
//#region src/adapters/organizations.ts
|
|
2808
|
-
var
|
|
2809
|
-
function
|
|
2843
|
+
var On = ["name", "display_name"];
|
|
2844
|
+
function kn() {
|
|
2810
2845
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2811
2846
|
}
|
|
2812
|
-
function
|
|
2847
|
+
function An(e) {
|
|
2813
2848
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2814
2849
|
return O({
|
|
2815
2850
|
...o,
|
|
@@ -2819,11 +2854,11 @@ function En(e) {
|
|
|
2819
2854
|
token_quota: Q(a, {})
|
|
2820
2855
|
});
|
|
2821
2856
|
}
|
|
2822
|
-
function
|
|
2857
|
+
function jn(e) {
|
|
2823
2858
|
return {
|
|
2824
2859
|
async create(t, n) {
|
|
2825
2860
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2826
|
-
id: n.id ||
|
|
2861
|
+
id: n.id || kn(),
|
|
2827
2862
|
tenant_id: t,
|
|
2828
2863
|
name: n.name,
|
|
2829
2864
|
display_name: n.display_name,
|
|
@@ -2837,16 +2872,16 @@ function Dn(e) {
|
|
|
2837
2872
|
try {
|
|
2838
2873
|
await e.insert(U).values(i);
|
|
2839
2874
|
} catch (e) {
|
|
2840
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new
|
|
2875
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Ce(409, { message: "Organization already exists" }) : e;
|
|
2841
2876
|
}
|
|
2842
|
-
return
|
|
2877
|
+
return An({
|
|
2843
2878
|
...i,
|
|
2844
2879
|
tenant_id: t
|
|
2845
2880
|
});
|
|
2846
2881
|
},
|
|
2847
2882
|
async get(n, r) {
|
|
2848
2883
|
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
2849
|
-
return i ||= await e.select().from(U).where(t(a(U.tenant_id, n), a(U.name, r))).get(), i ?
|
|
2884
|
+
return i ||= await e.select().from(U).where(t(a(U.tenant_id, n), a(U.name, r))).get(), i ? An(i) : null;
|
|
2850
2885
|
},
|
|
2851
2886
|
async update(n, r, i) {
|
|
2852
2887
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2855,19 +2890,19 @@ function Dn(e) {
|
|
|
2855
2890
|
async list(o, s) {
|
|
2856
2891
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(U.tenant_id, o)];
|
|
2857
2892
|
if (f) {
|
|
2858
|
-
let e = _e(f,
|
|
2893
|
+
let e = _e(f, On);
|
|
2859
2894
|
if (e) {
|
|
2860
|
-
let t =
|
|
2895
|
+
let t = nt(U, e, On);
|
|
2861
2896
|
t && p.push(t);
|
|
2862
2897
|
}
|
|
2863
2898
|
}
|
|
2864
2899
|
let m = t(...p);
|
|
2865
|
-
if (
|
|
2900
|
+
if (pt(s)) {
|
|
2866
2901
|
let n = {
|
|
2867
2902
|
sortColumn: U.created_at,
|
|
2868
2903
|
idColumn: U.id,
|
|
2869
2904
|
sortOrder: "desc"
|
|
2870
|
-
}, r =
|
|
2905
|
+
}, r = gt(s, n), i = mt(s), { rows: a, next: o } = _t(await e.select().from(U).where(r ? t(m, r) : m).orderBy(...ht(n)).limit(i + 1), i, "created_at"), c = a.map(An);
|
|
2871
2906
|
return {
|
|
2872
2907
|
organizations: c,
|
|
2873
2908
|
start: 0,
|
|
@@ -2882,7 +2917,7 @@ function Dn(e) {
|
|
|
2882
2917
|
let e = U[d.sort_by];
|
|
2883
2918
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2884
2919
|
}
|
|
2885
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2920
|
+
let g = (await h.offset(c * l).limit(l)).map(An);
|
|
2886
2921
|
if (!u) return { organizations: g };
|
|
2887
2922
|
let [_] = await e.select({ count: r() }).from(U).where(m);
|
|
2888
2923
|
return {
|
|
@@ -2899,14 +2934,14 @@ function Dn(e) {
|
|
|
2899
2934
|
}
|
|
2900
2935
|
//#endregion
|
|
2901
2936
|
//#region src/adapters/passwords.ts
|
|
2902
|
-
function
|
|
2937
|
+
function Mn(e) {
|
|
2903
2938
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2904
2939
|
return {
|
|
2905
2940
|
...r,
|
|
2906
2941
|
is_current: !!n
|
|
2907
2942
|
};
|
|
2908
2943
|
}
|
|
2909
|
-
function
|
|
2944
|
+
function Nn(e) {
|
|
2910
2945
|
return {
|
|
2911
2946
|
async create(n, r) {
|
|
2912
2947
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2921,18 +2956,18 @@ function kn(e) {
|
|
|
2921
2956
|
created_at: i,
|
|
2922
2957
|
updated_at: i
|
|
2923
2958
|
};
|
|
2924
|
-
return await e.insert(M).values(s),
|
|
2959
|
+
return await e.insert(M).values(s), Mn({
|
|
2925
2960
|
...s,
|
|
2926
2961
|
tenant_id: n
|
|
2927
2962
|
});
|
|
2928
2963
|
},
|
|
2929
2964
|
async get(n, r) {
|
|
2930
2965
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r), a(M.is_current, 1))).get();
|
|
2931
|
-
return i ?
|
|
2966
|
+
return i ? Mn(i) : null;
|
|
2932
2967
|
},
|
|
2933
2968
|
async list(n, r, o) {
|
|
2934
2969
|
let s = e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r))).orderBy(i(M.created_at)).$dynamic();
|
|
2935
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
2970
|
+
return o && (s = s.limit(o)), (await s).map(Mn);
|
|
2936
2971
|
},
|
|
2937
2972
|
async update(n, r) {
|
|
2938
2973
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2942,36 +2977,40 @@ function kn(e) {
|
|
|
2942
2977
|
}
|
|
2943
2978
|
//#endregion
|
|
2944
2979
|
//#region src/adapters/promptSettings.ts
|
|
2945
|
-
function
|
|
2980
|
+
function Pn(e) {
|
|
2946
2981
|
return {
|
|
2947
2982
|
async get(t) {
|
|
2948
|
-
let n = await e.select().from(
|
|
2983
|
+
let n = await e.select().from(Ve).where(a(Ve.tenant_id, t)).get();
|
|
2949
2984
|
return n ? {
|
|
2950
2985
|
universal_login_experience: n.universal_login_experience,
|
|
2951
2986
|
identifier_first: !!n.identifier_first,
|
|
2952
2987
|
password_first: !!n.password_first,
|
|
2953
|
-
webauthn_platform_first_factor: !!n.webauthn_platform_first_factor
|
|
2988
|
+
webauthn_platform_first_factor: !!n.webauthn_platform_first_factor,
|
|
2989
|
+
show_last_used_connection: !!n.show_last_used_connection
|
|
2954
2990
|
} : {
|
|
2955
2991
|
universal_login_experience: "new",
|
|
2956
2992
|
identifier_first: !0,
|
|
2957
2993
|
password_first: !1,
|
|
2958
|
-
webauthn_platform_first_factor: !1
|
|
2994
|
+
webauthn_platform_first_factor: !1,
|
|
2995
|
+
show_last_used_connection: !1
|
|
2959
2996
|
};
|
|
2960
2997
|
},
|
|
2961
2998
|
async set(t, n) {
|
|
2962
|
-
await e.insert(
|
|
2999
|
+
await e.insert(Ve).values({
|
|
2963
3000
|
tenant_id: t,
|
|
2964
3001
|
universal_login_experience: n.universal_login_experience,
|
|
2965
3002
|
identifier_first: n.identifier_first,
|
|
2966
3003
|
password_first: n.password_first,
|
|
2967
|
-
webauthn_platform_first_factor: n.webauthn_platform_first_factor
|
|
3004
|
+
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3005
|
+
show_last_used_connection: n.show_last_used_connection
|
|
2968
3006
|
}).onConflictDoUpdate({
|
|
2969
|
-
target:
|
|
3007
|
+
target: Ve.tenant_id,
|
|
2970
3008
|
set: {
|
|
2971
3009
|
universal_login_experience: n.universal_login_experience,
|
|
2972
3010
|
identifier_first: n.identifier_first,
|
|
2973
3011
|
password_first: n.password_first,
|
|
2974
|
-
webauthn_platform_first_factor: n.webauthn_platform_first_factor
|
|
3012
|
+
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3013
|
+
show_last_used_connection: n.show_last_used_connection
|
|
2975
3014
|
}
|
|
2976
3015
|
});
|
|
2977
3016
|
}
|
|
@@ -2979,7 +3018,7 @@ function An(e) {
|
|
|
2979
3018
|
}
|
|
2980
3019
|
//#endregion
|
|
2981
3020
|
//#region src/adapters/proxyRoutes.ts
|
|
2982
|
-
function
|
|
3021
|
+
function Fn(e) {
|
|
2983
3022
|
if (!e) return { path: "/*" };
|
|
2984
3023
|
try {
|
|
2985
3024
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -2987,7 +3026,7 @@ function jn(e) {
|
|
|
2987
3026
|
} catch {}
|
|
2988
3027
|
return { path: "/*" };
|
|
2989
3028
|
}
|
|
2990
|
-
function
|
|
3029
|
+
function In(e) {
|
|
2991
3030
|
if (!e) return [];
|
|
2992
3031
|
try {
|
|
2993
3032
|
let t = JSON.parse(e);
|
|
@@ -3002,19 +3041,19 @@ function Mn(e) {
|
|
|
3002
3041
|
return [];
|
|
3003
3042
|
}
|
|
3004
3043
|
}
|
|
3005
|
-
function
|
|
3044
|
+
function Ln(e) {
|
|
3006
3045
|
return {
|
|
3007
3046
|
id: e.id,
|
|
3008
3047
|
tenant_id: e.tenant_id,
|
|
3009
3048
|
custom_domain_id: e.custom_domain_id,
|
|
3010
3049
|
priority: e.priority,
|
|
3011
|
-
match:
|
|
3012
|
-
handlers:
|
|
3050
|
+
match: Fn(e.match),
|
|
3051
|
+
handlers: In(e.handlers),
|
|
3013
3052
|
created_at: e.created_at,
|
|
3014
3053
|
updated_at: e.updated_at
|
|
3015
3054
|
};
|
|
3016
3055
|
}
|
|
3017
|
-
function
|
|
3056
|
+
function Rn(e) {
|
|
3018
3057
|
return {
|
|
3019
3058
|
async create(t, n) {
|
|
3020
3059
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3027,7 +3066,7 @@ function Pn(e) {
|
|
|
3027
3066
|
created_at: r,
|
|
3028
3067
|
updated_at: r
|
|
3029
3068
|
};
|
|
3030
|
-
return await e.insert(
|
|
3069
|
+
return await e.insert(X).values({
|
|
3031
3070
|
id: i.id,
|
|
3032
3071
|
tenant_id: i.tenant_id,
|
|
3033
3072
|
custom_domain_id: i.custom_domain_id,
|
|
@@ -3039,15 +3078,15 @@ function Pn(e) {
|
|
|
3039
3078
|
}), i;
|
|
3040
3079
|
},
|
|
3041
3080
|
async get(n, r) {
|
|
3042
|
-
let i = await e.select().from(
|
|
3043
|
-
return i[0] ?
|
|
3081
|
+
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1);
|
|
3082
|
+
return i[0] ? Ln(i[0]) : null;
|
|
3044
3083
|
},
|
|
3045
3084
|
async list(r, i = {}) {
|
|
3046
|
-
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(
|
|
3047
|
-
i.custom_domain_id && c.push(a(
|
|
3048
|
-
let l = await e.select().from(
|
|
3085
|
+
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(X.tenant_id, r)];
|
|
3086
|
+
i.custom_domain_id && c.push(a(X.custom_domain_id, i.custom_domain_id));
|
|
3087
|
+
let l = await e.select().from(X).where(t(...c)).orderBy(n(X.priority), n(X.created_at)).offset(o * s).limit(s);
|
|
3049
3088
|
return {
|
|
3050
|
-
proxy_routes: l.map(
|
|
3089
|
+
proxy_routes: l.map(Ln),
|
|
3051
3090
|
start: o * s,
|
|
3052
3091
|
limit: s,
|
|
3053
3092
|
length: l.length
|
|
@@ -3056,17 +3095,174 @@ function Pn(e) {
|
|
|
3056
3095
|
async update(n, r, i) {
|
|
3057
3096
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3058
3097
|
i.priority !== void 0 && (o.priority = i.priority), i.match !== void 0 && (o.match = JSON.stringify(i.match)), i.handlers !== void 0 && (o.handlers = JSON.stringify(i.handlers));
|
|
3059
|
-
let s = (await e.update(
|
|
3060
|
-
return typeof s == "number" ? s > 0 : (await e.select({ id:
|
|
3098
|
+
let s = (await e.update(X).set(o).where(t(a(X.tenant_id, n), a(X.id, r))))?.changes;
|
|
3099
|
+
return typeof s == "number" ? s > 0 : (await e.select({ id: X.id }).from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1)).length > 0;
|
|
3100
|
+
},
|
|
3101
|
+
async remove(n, r) {
|
|
3102
|
+
return (await e.select({ id: X.id }).from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1)).length === 0 ? !1 : (await e.delete(X).where(t(a(X.tenant_id, n), a(X.id, r))), !0);
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
3106
|
+
//#endregion
|
|
3107
|
+
//#region src/adapters/scim.ts
|
|
3108
|
+
function zn(e) {
|
|
3109
|
+
if (!e) return [];
|
|
3110
|
+
try {
|
|
3111
|
+
let t = JSON.parse(e);
|
|
3112
|
+
if (!Array.isArray(t)) return [];
|
|
3113
|
+
let n = [];
|
|
3114
|
+
for (let e of t) {
|
|
3115
|
+
let t = ve.safeParse(e);
|
|
3116
|
+
t.success && n.push(t.data);
|
|
3117
|
+
}
|
|
3118
|
+
return n;
|
|
3119
|
+
} catch {
|
|
3120
|
+
return [];
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
function Bn(e) {
|
|
3124
|
+
if (!e) return [];
|
|
3125
|
+
try {
|
|
3126
|
+
let t = JSON.parse(e);
|
|
3127
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
3128
|
+
} catch {
|
|
3129
|
+
return [];
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
function Vn(e) {
|
|
3133
|
+
return {
|
|
3134
|
+
connection_id: e.connection_id,
|
|
3135
|
+
user_id_attribute: e.user_id_attribute,
|
|
3136
|
+
mapping: zn(e.mapping),
|
|
3137
|
+
created_at: e.created_at,
|
|
3138
|
+
updated_at: e.updated_at
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
function Hn(e) {
|
|
3142
|
+
return {
|
|
3143
|
+
async create(t, n) {
|
|
3144
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3145
|
+
connection_id: n.connection_id,
|
|
3146
|
+
user_id_attribute: n.user_id_attribute,
|
|
3147
|
+
mapping: n.mapping,
|
|
3148
|
+
created_at: r,
|
|
3149
|
+
updated_at: r
|
|
3150
|
+
};
|
|
3151
|
+
return await e.insert(Ye).values({
|
|
3152
|
+
connection_id: i.connection_id,
|
|
3153
|
+
tenant_id: t,
|
|
3154
|
+
user_id_attribute: i.user_id_attribute,
|
|
3155
|
+
mapping: JSON.stringify(i.mapping),
|
|
3156
|
+
created_at: r,
|
|
3157
|
+
updated_at: r
|
|
3158
|
+
}), i;
|
|
3159
|
+
},
|
|
3160
|
+
async get(n, r) {
|
|
3161
|
+
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))).limit(1);
|
|
3162
|
+
return i[0] ? Vn(i[0]) : null;
|
|
3163
|
+
},
|
|
3164
|
+
async update(n, r, i) {
|
|
3165
|
+
if ((await e.select({ connection_id: Ye.connection_id }).from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3166
|
+
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3167
|
+
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(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))), !0;
|
|
3061
3168
|
},
|
|
3062
3169
|
async remove(n, r) {
|
|
3063
|
-
return (await e.select({
|
|
3170
|
+
return (await e.select({ connection_id: Ye.connection_id }).from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.connection_id, r))), !0);
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
function Un(e) {
|
|
3175
|
+
return {
|
|
3176
|
+
token_id: e.token_id,
|
|
3177
|
+
connection_id: e.connection_id,
|
|
3178
|
+
token_hash: e.token_hash,
|
|
3179
|
+
scopes: Bn(e.scopes),
|
|
3180
|
+
valid_until: e.valid_until ?? void 0,
|
|
3181
|
+
created_at: e.created_at,
|
|
3182
|
+
last_used_at: e.last_used_at ?? void 0
|
|
3183
|
+
};
|
|
3184
|
+
}
|
|
3185
|
+
function Wn(e) {
|
|
3186
|
+
return {
|
|
3187
|
+
async create(t, n) {
|
|
3188
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3189
|
+
token_id: n.token_id,
|
|
3190
|
+
connection_id: n.connection_id,
|
|
3191
|
+
token_hash: n.token_hash,
|
|
3192
|
+
scopes: n.scopes,
|
|
3193
|
+
valid_until: n.valid_until,
|
|
3194
|
+
created_at: r
|
|
3195
|
+
};
|
|
3196
|
+
return await e.insert(Z).values({
|
|
3197
|
+
token_id: i.token_id,
|
|
3198
|
+
tenant_id: t,
|
|
3199
|
+
connection_id: i.connection_id,
|
|
3200
|
+
token_hash: i.token_hash,
|
|
3201
|
+
scopes: JSON.stringify(i.scopes),
|
|
3202
|
+
valid_until: i.valid_until,
|
|
3203
|
+
created_at: r
|
|
3204
|
+
}), i;
|
|
3205
|
+
},
|
|
3206
|
+
async get(n, r) {
|
|
3207
|
+
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1);
|
|
3208
|
+
return i[0] ? Un(i[0]) : null;
|
|
3209
|
+
},
|
|
3210
|
+
async getByHash(n, r) {
|
|
3211
|
+
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_hash, r))).limit(1);
|
|
3212
|
+
return i[0] ? Un(i[0]) : null;
|
|
3213
|
+
},
|
|
3214
|
+
async listByConnection(n, r) {
|
|
3215
|
+
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(Un);
|
|
3216
|
+
},
|
|
3217
|
+
async markUsed(n, r, i) {
|
|
3218
|
+
return (await e.select({ token_id: Z.token_id }).from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(Z).set({ last_used_at: i }).where(t(a(Z.tenant_id, n), a(Z.token_id, r))), !0);
|
|
3219
|
+
},
|
|
3220
|
+
async remove(n, r) {
|
|
3221
|
+
return (await e.select({ token_id: Z.token_id }).from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))), !0);
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
}
|
|
3225
|
+
function Gn(e) {
|
|
3226
|
+
return {
|
|
3227
|
+
connection_id: e.connection_id,
|
|
3228
|
+
external_id: e.external_id,
|
|
3229
|
+
user_id: e.user_id,
|
|
3230
|
+
created_at: e.created_at
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
function Kn(e) {
|
|
3234
|
+
return {
|
|
3235
|
+
async create(t, n) {
|
|
3236
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3237
|
+
connection_id: n.connection_id,
|
|
3238
|
+
external_id: n.external_id,
|
|
3239
|
+
user_id: n.user_id,
|
|
3240
|
+
created_at: r
|
|
3241
|
+
};
|
|
3242
|
+
return await e.insert(Xe).values({
|
|
3243
|
+
tenant_id: t,
|
|
3244
|
+
connection_id: i.connection_id,
|
|
3245
|
+
external_id: i.external_id,
|
|
3246
|
+
user_id: i.user_id,
|
|
3247
|
+
created_at: r
|
|
3248
|
+
}), i;
|
|
3249
|
+
},
|
|
3250
|
+
async getByExternalId(n, r, i) {
|
|
3251
|
+
let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.external_id, i))).limit(1);
|
|
3252
|
+
return o[0] ? Gn(o[0]) : null;
|
|
3253
|
+
},
|
|
3254
|
+
async getByUserId(n, r, i) {
|
|
3255
|
+
let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))).limit(1);
|
|
3256
|
+
return o[0] ? Gn(o[0]) : null;
|
|
3257
|
+
},
|
|
3258
|
+
async remove(n, r, i) {
|
|
3259
|
+
return (await e.select({ user_id: Xe.user_id }).from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.connection_id, r), a(Xe.user_id, i))), !0);
|
|
3064
3260
|
}
|
|
3065
3261
|
};
|
|
3066
3262
|
}
|
|
3067
3263
|
//#endregion
|
|
3068
3264
|
//#region src/adapters/refreshTokens.ts
|
|
3069
|
-
function
|
|
3265
|
+
function qn(e) {
|
|
3070
3266
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: r, idle_expires_at_ts: i, last_exchanged_at_ts: a, revoked_at_ts: o, rotated_at_ts: s, device: c, resource_servers: l, rotating: u, ...d } = e, f = ie({
|
|
3071
3267
|
created_at_ts: n,
|
|
3072
3268
|
expires_at_ts: r,
|
|
@@ -3089,10 +3285,10 @@ function Fn(e) {
|
|
|
3089
3285
|
resource_servers: Q(l, [])
|
|
3090
3286
|
});
|
|
3091
3287
|
}
|
|
3092
|
-
function
|
|
3288
|
+
function Jn(e, t) {
|
|
3093
3289
|
return Math.max(e ?? 0, t ?? 0);
|
|
3094
3290
|
}
|
|
3095
|
-
function
|
|
3291
|
+
function Yn(e) {
|
|
3096
3292
|
return {
|
|
3097
3293
|
async create(n, r) {
|
|
3098
3294
|
let i = Date.now(), o = {
|
|
@@ -3113,22 +3309,22 @@ function Ln(e) {
|
|
|
3113
3309
|
expires_at_ts: D(r.expires_at),
|
|
3114
3310
|
idle_expires_at_ts: D(r.idle_expires_at),
|
|
3115
3311
|
last_exchanged_at_ts: D(r.last_exchanged_at)
|
|
3116
|
-
}, s = [e.insert(P).values(o)], c =
|
|
3312
|
+
}, s = [e.insert(P).values(o)], c = Jn(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3117
3313
|
return c > 0 && o.login_id && s.push(e.update(F).set({
|
|
3118
3314
|
expires_at_ts: c,
|
|
3119
3315
|
updated_at_ts: i
|
|
3120
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await
|
|
3316
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await ct(e, s), qn({
|
|
3121
3317
|
...o,
|
|
3122
3318
|
tenant_id: n
|
|
3123
3319
|
});
|
|
3124
3320
|
},
|
|
3125
3321
|
async get(n, r) {
|
|
3126
3322
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.id, r))).get();
|
|
3127
|
-
return i ?
|
|
3323
|
+
return i ? qn(i) : null;
|
|
3128
3324
|
},
|
|
3129
3325
|
async getByLookup(n, r) {
|
|
3130
3326
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.token_lookup, r))).get();
|
|
3131
|
-
return i ?
|
|
3327
|
+
return i ? qn(i) : null;
|
|
3132
3328
|
},
|
|
3133
3329
|
async update(n, r, i, o) {
|
|
3134
3330
|
let s = {};
|
|
@@ -3142,14 +3338,14 @@ function Ln(e) {
|
|
|
3142
3338
|
async list(o, s) {
|
|
3143
3339
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = e.select().from(P).where(a(P.tenant_id, o)).$dynamic();
|
|
3144
3340
|
if (f) {
|
|
3145
|
-
let e =
|
|
3341
|
+
let e = nt(P, f, ["user_id", "login_id"]);
|
|
3146
3342
|
e && (p = p.where(t(a(P.tenant_id, o), e)));
|
|
3147
3343
|
}
|
|
3148
3344
|
if (d?.sort_by) {
|
|
3149
3345
|
let e = P[d.sort_by];
|
|
3150
3346
|
e && (p = p.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3151
3347
|
}
|
|
3152
|
-
let m = (await p.offset(c * l).limit(l)).map(
|
|
3348
|
+
let m = (await p.offset(c * l).limit(l)).map(qn);
|
|
3153
3349
|
if (!u) return { refresh_tokens: m };
|
|
3154
3350
|
let [h] = await e.select({ count: r() }).from(P).where(a(P.tenant_id, o));
|
|
3155
3351
|
return {
|
|
@@ -3172,15 +3368,15 @@ function Ln(e) {
|
|
|
3172
3368
|
}
|
|
3173
3369
|
//#endregion
|
|
3174
3370
|
//#region src/adapters/resourceServers.ts
|
|
3175
|
-
var
|
|
3176
|
-
function
|
|
3371
|
+
var Xn = ["name", "identifier"];
|
|
3372
|
+
function Zn() {
|
|
3177
3373
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3178
3374
|
}
|
|
3179
|
-
var
|
|
3375
|
+
var Qn = [
|
|
3180
3376
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3181
3377
|
"allow_offline_access",
|
|
3182
3378
|
"is_system"
|
|
3183
|
-
],
|
|
3379
|
+
], $n = new Set([
|
|
3184
3380
|
"id",
|
|
3185
3381
|
"tenant_id",
|
|
3186
3382
|
"identifier",
|
|
@@ -3199,17 +3395,17 @@ var Bn = [
|
|
|
3199
3395
|
"created_at",
|
|
3200
3396
|
"updated_at"
|
|
3201
3397
|
]);
|
|
3202
|
-
function
|
|
3398
|
+
function er(e) {
|
|
3203
3399
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3204
3400
|
s.scopes = Q(r, []), s.options = Q(i, {}), s.metadata = Q(a), n !== void 0 && (s.verificationKey = n);
|
|
3205
|
-
for (let e of
|
|
3401
|
+
for (let e of Qn) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3206
3402
|
return O(s);
|
|
3207
3403
|
}
|
|
3208
|
-
function
|
|
3404
|
+
function tr(e) {
|
|
3209
3405
|
return {
|
|
3210
3406
|
async create(t, n) {
|
|
3211
3407
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3212
|
-
id: n.id ||
|
|
3408
|
+
id: n.id || Zn(),
|
|
3213
3409
|
tenant_id: t,
|
|
3214
3410
|
identifier: n.identifier,
|
|
3215
3411
|
name: n.name,
|
|
@@ -3224,37 +3420,37 @@ function Un(e) {
|
|
|
3224
3420
|
created_at: r,
|
|
3225
3421
|
updated_at: r
|
|
3226
3422
|
};
|
|
3227
|
-
for (let e of
|
|
3228
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(q).values(i),
|
|
3423
|
+
for (let e of Qn) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3424
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(q).values(i), er({
|
|
3229
3425
|
...i,
|
|
3230
3426
|
tenant_id: t
|
|
3231
3427
|
});
|
|
3232
3428
|
},
|
|
3233
3429
|
async get(n, r) {
|
|
3234
3430
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.id, r))).get();
|
|
3235
|
-
return i ?
|
|
3431
|
+
return i ? er(i) : null;
|
|
3236
3432
|
},
|
|
3237
3433
|
async update(n, r, i) {
|
|
3238
3434
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3239
3435
|
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${q.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3240
|
-
for (let e of
|
|
3436
|
+
for (let e of Qn) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3241
3437
|
return (await e.update(q).set(o).where(t(a(q.tenant_id, n), a(q.id, r))).returning()).length > 0;
|
|
3242
3438
|
},
|
|
3243
3439
|
async list(o, s) {
|
|
3244
3440
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(q.tenant_id, o)];
|
|
3245
3441
|
if (f) {
|
|
3246
|
-
let e = _e(f,
|
|
3442
|
+
let e = _e(f, Xn);
|
|
3247
3443
|
if (e) {
|
|
3248
|
-
let t =
|
|
3444
|
+
let t = nt(q, e, Xn, ["name", "identifier"]);
|
|
3249
3445
|
t && h.push(t);
|
|
3250
3446
|
}
|
|
3251
3447
|
}
|
|
3252
3448
|
let g = e.select().from(q).where(t(...h)).$dynamic();
|
|
3253
|
-
if (d?.sort_by &&
|
|
3449
|
+
if (d?.sort_by && $n.has(d.sort_by)) {
|
|
3254
3450
|
let e = q[d.sort_by];
|
|
3255
3451
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3256
3452
|
}
|
|
3257
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3453
|
+
let _ = (await g.offset(p * m).limit(m)).map(er);
|
|
3258
3454
|
if (!u) return { resource_servers: _ };
|
|
3259
3455
|
let [v] = await e.select({ count: r() }).from(q).where(t(...h));
|
|
3260
3456
|
return {
|
|
@@ -3271,11 +3467,11 @@ function Un(e) {
|
|
|
3271
3467
|
}
|
|
3272
3468
|
//#endregion
|
|
3273
3469
|
//#region src/adapters/rolePermissions.ts
|
|
3274
|
-
function
|
|
3470
|
+
function nr(e) {
|
|
3275
3471
|
return {
|
|
3276
3472
|
async assign(t, n, r) {
|
|
3277
3473
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3278
|
-
return await e.insert(
|
|
3474
|
+
return await e.insert(Pe).values(r.map((e) => ({
|
|
3279
3475
|
tenant_id: t,
|
|
3280
3476
|
role_id: n,
|
|
3281
3477
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3285,10 +3481,10 @@ function Wn(e) {
|
|
|
3285
3481
|
},
|
|
3286
3482
|
async list(n, r, i) {
|
|
3287
3483
|
let o = await e.select({
|
|
3288
|
-
resource_server_identifier:
|
|
3289
|
-
permission_name:
|
|
3290
|
-
created_at:
|
|
3291
|
-
}).from(
|
|
3484
|
+
resource_server_identifier: Pe.resource_server_identifier,
|
|
3485
|
+
permission_name: Pe.permission_name,
|
|
3486
|
+
created_at: Pe.created_at
|
|
3487
|
+
}).from(Pe).where(t(a(Pe.tenant_id, n), a(Pe.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3292
3488
|
if (s.length > 0) {
|
|
3293
3489
|
let r = await e.select({
|
|
3294
3490
|
identifier: q.identifier,
|
|
@@ -3302,18 +3498,18 @@ function Wn(e) {
|
|
|
3302
3498
|
}));
|
|
3303
3499
|
},
|
|
3304
3500
|
async remove(n, r, i) {
|
|
3305
|
-
let o = i.map((e) => t(a(
|
|
3306
|
-
return (await e.delete(
|
|
3501
|
+
let o = i.map((e) => t(a(Pe.resource_server_identifier, e.resource_server_identifier), a(Pe.permission_name, e.permission_name)));
|
|
3502
|
+
return (await e.delete(Pe).where(t(a(Pe.tenant_id, n), a(Pe.role_id, r), v(...o))).returning()).length > 0;
|
|
3307
3503
|
}
|
|
3308
3504
|
};
|
|
3309
3505
|
}
|
|
3310
3506
|
//#endregion
|
|
3311
3507
|
//#region src/adapters/userPermissions.ts
|
|
3312
|
-
function
|
|
3508
|
+
function rr(e) {
|
|
3313
3509
|
return {
|
|
3314
3510
|
async create(t, n, r, i) {
|
|
3315
3511
|
try {
|
|
3316
|
-
await e.insert(
|
|
3512
|
+
await e.insert(Fe).values({
|
|
3317
3513
|
tenant_id: t,
|
|
3318
3514
|
user_id: n,
|
|
3319
3515
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3328,9 +3524,9 @@ function Gn(e) {
|
|
|
3328
3524
|
return !0;
|
|
3329
3525
|
},
|
|
3330
3526
|
async list(n, r, i, o) {
|
|
3331
|
-
let s = [a(
|
|
3332
|
-
o && s.push(a(
|
|
3333
|
-
let c = await e.select().from(
|
|
3527
|
+
let s = [a(Fe.tenant_id, n), a(Fe.user_id, r)];
|
|
3528
|
+
o && s.push(a(Fe.organization_id, o));
|
|
3529
|
+
let c = await e.select().from(Fe).where(t(...s)).all();
|
|
3334
3530
|
return await Promise.all(c.map(async (r) => {
|
|
3335
3531
|
let i = await e.select({ name: q.name }).from(q).where(t(a(q.tenant_id, n), a(q.identifier, r.resource_server_identifier))).get();
|
|
3336
3532
|
return {
|
|
@@ -3342,13 +3538,13 @@ function Gn(e) {
|
|
|
3342
3538
|
}));
|
|
3343
3539
|
},
|
|
3344
3540
|
async remove(n, r, i, o) {
|
|
3345
|
-
return (await e.delete(
|
|
3541
|
+
return (await e.delete(Fe).where(t(a(Fe.tenant_id, n), a(Fe.user_id, r), a(Fe.resource_server_identifier, i.resource_server_identifier), a(Fe.permission_name, i.permission_name), a(Fe.organization_id, o || ""))).returning()).length > 0;
|
|
3346
3542
|
}
|
|
3347
3543
|
};
|
|
3348
3544
|
}
|
|
3349
3545
|
//#endregion
|
|
3350
3546
|
//#region src/adapters/roles.ts
|
|
3351
|
-
function
|
|
3547
|
+
function ir(e) {
|
|
3352
3548
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3353
3549
|
return O({
|
|
3354
3550
|
...i,
|
|
@@ -3356,7 +3552,7 @@ function Kn(e) {
|
|
|
3356
3552
|
metadata: Q(r)
|
|
3357
3553
|
});
|
|
3358
3554
|
}
|
|
3359
|
-
function
|
|
3555
|
+
function ar(e) {
|
|
3360
3556
|
return {
|
|
3361
3557
|
async create(t, n) {
|
|
3362
3558
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3369,26 +3565,26 @@ function qn(e) {
|
|
|
3369
3565
|
created_at: r,
|
|
3370
3566
|
updated_at: r
|
|
3371
3567
|
};
|
|
3372
|
-
return await e.insert(G).values(i),
|
|
3568
|
+
return await e.insert(G).values(i), ir({
|
|
3373
3569
|
...i,
|
|
3374
3570
|
tenant_id: t
|
|
3375
3571
|
});
|
|
3376
3572
|
},
|
|
3377
3573
|
async get(n, r) {
|
|
3378
3574
|
let i = await e.select().from(G).where(t(a(G.tenant_id, n), a(G.id, r))).get();
|
|
3379
|
-
return i ?
|
|
3575
|
+
return i ? ir(i) : null;
|
|
3380
3576
|
},
|
|
3381
3577
|
async update(n, r, i) {
|
|
3382
3578
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3383
3579
|
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(G).set(o).where(t(a(G.tenant_id, n), a(G.id, r))).returning()).length > 0;
|
|
3384
3580
|
},
|
|
3385
3581
|
async list(o, s) {
|
|
3386
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3582
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(G, f, ["name"]) : void 0, m = p ? t(a(G.tenant_id, o), p) : a(G.tenant_id, o), h = e.select().from(G).where(m).$dynamic();
|
|
3387
3583
|
if (d?.sort_by) {
|
|
3388
3584
|
let e = G[d.sort_by];
|
|
3389
3585
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3390
3586
|
}
|
|
3391
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3587
|
+
let g = (await h.offset(c * l).limit(l)).map(ir);
|
|
3392
3588
|
if (!u) return { roles: g };
|
|
3393
3589
|
let [_] = await e.select({ count: r() }).from(G).where(m);
|
|
3394
3590
|
return {
|
|
@@ -3405,7 +3601,7 @@ function qn(e) {
|
|
|
3405
3601
|
}
|
|
3406
3602
|
//#endregion
|
|
3407
3603
|
//#region src/adapters/sessions.ts
|
|
3408
|
-
var
|
|
3604
|
+
var or = ["created_at_ts", "updated_at_ts"], sr = [
|
|
3409
3605
|
"expires_at_ts",
|
|
3410
3606
|
"idle_expires_at_ts",
|
|
3411
3607
|
"authenticated_at_ts",
|
|
@@ -3413,7 +3609,7 @@ var Jn = ["created_at_ts", "updated_at_ts"], Yn = [
|
|
|
3413
3609
|
"used_at_ts",
|
|
3414
3610
|
"revoked_at_ts"
|
|
3415
3611
|
];
|
|
3416
|
-
function
|
|
3612
|
+
function cr(e) {
|
|
3417
3613
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, p = ie({
|
|
3418
3614
|
created_at_ts: n,
|
|
3419
3615
|
updated_at_ts: r,
|
|
@@ -3423,7 +3619,7 @@ function Xn(e) {
|
|
|
3423
3619
|
last_interaction_at_ts: s,
|
|
3424
3620
|
used_at_ts: c,
|
|
3425
3621
|
revoked_at_ts: l
|
|
3426
|
-
}, [...
|
|
3622
|
+
}, [...or], [...sr]);
|
|
3427
3623
|
return O({
|
|
3428
3624
|
...f,
|
|
3429
3625
|
...p,
|
|
@@ -3431,10 +3627,10 @@ function Xn(e) {
|
|
|
3431
3627
|
clients: Q(d, [])
|
|
3432
3628
|
});
|
|
3433
3629
|
}
|
|
3434
|
-
function
|
|
3630
|
+
function lr(e, t) {
|
|
3435
3631
|
return Math.max(e ?? 0, t ?? 0);
|
|
3436
3632
|
}
|
|
3437
|
-
function
|
|
3633
|
+
function ur(e) {
|
|
3438
3634
|
return {
|
|
3439
3635
|
async create(n, r) {
|
|
3440
3636
|
let i = Date.now(), o = {
|
|
@@ -3452,23 +3648,23 @@ function Qn(e) {
|
|
|
3452
3648
|
last_interaction_at_ts: r.last_interaction_at ? D(r.last_interaction_at) : i,
|
|
3453
3649
|
used_at_ts: D(r.used_at),
|
|
3454
3650
|
revoked_at_ts: D(r.revoked_at)
|
|
3455
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3651
|
+
}, s = [e.insert(N).values(o)], c = lr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3456
3652
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3457
3653
|
expires_at_ts: c,
|
|
3458
3654
|
updated_at_ts: i
|
|
3459
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await
|
|
3655
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await ct(e, s), cr({
|
|
3460
3656
|
...o,
|
|
3461
3657
|
tenant_id: n
|
|
3462
3658
|
});
|
|
3463
3659
|
},
|
|
3464
3660
|
async get(n, r) {
|
|
3465
3661
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3466
|
-
return i ?
|
|
3662
|
+
return i ? cr(i) : null;
|
|
3467
3663
|
},
|
|
3468
3664
|
async update(n, r, i) {
|
|
3469
3665
|
let o = { updated_at_ts: Date.now() };
|
|
3470
3666
|
i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = D(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = D(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = D(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = D(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = D(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = D(i.revoked_at));
|
|
3471
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3667
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = lr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3472
3668
|
if (c > 0 && l) {
|
|
3473
3669
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3474
3670
|
r && await e.update(F).set({
|
|
@@ -3479,12 +3675,12 @@ function Qn(e) {
|
|
|
3479
3675
|
return s.length > 0;
|
|
3480
3676
|
},
|
|
3481
3677
|
async list(o, s) {
|
|
3482
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3678
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? nt(N, f, ["user_id", "id"]) : void 0, m = p ? t(a(N.tenant_id, o), p) : a(N.tenant_id, o), h = e.select().from(N).where(m).$dynamic();
|
|
3483
3679
|
if (d?.sort_by) {
|
|
3484
3680
|
let e = N[d.sort_by];
|
|
3485
3681
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3486
3682
|
}
|
|
3487
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3683
|
+
let g = (await h.offset(c * l).limit(l)).map(cr);
|
|
3488
3684
|
if (!u) return { sessions: g };
|
|
3489
3685
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3490
3686
|
return {
|
|
@@ -3501,7 +3697,7 @@ function Qn(e) {
|
|
|
3501
3697
|
}
|
|
3502
3698
|
//#endregion
|
|
3503
3699
|
//#region src/adapters/tenants.ts
|
|
3504
|
-
var
|
|
3700
|
+
var dr = [
|
|
3505
3701
|
"session_cookie",
|
|
3506
3702
|
"enabled_locales",
|
|
3507
3703
|
"error_page",
|
|
@@ -3517,25 +3713,25 @@ var $n = [
|
|
|
3517
3713
|
"acr_values_supported",
|
|
3518
3714
|
"mtls",
|
|
3519
3715
|
"mfa"
|
|
3520
|
-
],
|
|
3716
|
+
], fr = [
|
|
3521
3717
|
"allow_organization_name_in_authentication_api",
|
|
3522
3718
|
"customize_mfa_in_postlogin_action",
|
|
3523
3719
|
"pushed_authorization_requests_supported",
|
|
3524
3720
|
"authorization_response_iss_parameter_supported"
|
|
3525
3721
|
];
|
|
3526
|
-
function
|
|
3722
|
+
function pr(e) {
|
|
3527
3723
|
let t = { ...e };
|
|
3528
|
-
for (let e of
|
|
3529
|
-
for (let e of
|
|
3724
|
+
for (let e of dr) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3725
|
+
for (let e of fr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3530
3726
|
return O(t);
|
|
3531
3727
|
}
|
|
3532
|
-
function
|
|
3728
|
+
function mr(e) {
|
|
3533
3729
|
let t = { ...e };
|
|
3534
|
-
ce(e,
|
|
3535
|
-
for (let n of
|
|
3730
|
+
ce(e, dr, t);
|
|
3731
|
+
for (let n of fr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3536
3732
|
return se(t);
|
|
3537
3733
|
}
|
|
3538
|
-
function
|
|
3734
|
+
function hr(e) {
|
|
3539
3735
|
return {
|
|
3540
3736
|
async create(t) {
|
|
3541
3737
|
let n = {
|
|
@@ -3543,26 +3739,26 @@ function rr(e) {
|
|
|
3543
3739
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3544
3740
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3545
3741
|
...t
|
|
3546
|
-
}, r =
|
|
3742
|
+
}, r = mr(n);
|
|
3547
3743
|
try {
|
|
3548
3744
|
await e.insert(k).values(r);
|
|
3549
3745
|
} catch (e) {
|
|
3550
3746
|
let t = e?.message ?? "";
|
|
3551
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
3747
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new Ce(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3552
3748
|
}
|
|
3553
3749
|
return n;
|
|
3554
3750
|
},
|
|
3555
3751
|
async get(t) {
|
|
3556
3752
|
let n = await e.select().from(k).where(a(k.id, t)).get();
|
|
3557
|
-
return n ?
|
|
3753
|
+
return n ? pr(n) : null;
|
|
3558
3754
|
},
|
|
3559
3755
|
async list(t) {
|
|
3560
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3756
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? nt(k, l, ["friendly_name"]) : void 0, d = e.select().from(k).$dynamic();
|
|
3561
3757
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3562
3758
|
let e = k[c.sort_by];
|
|
3563
3759
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3564
3760
|
}
|
|
3565
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3761
|
+
let f = (await d.offset(a * o).limit(o)).map(pr);
|
|
3566
3762
|
if (!s) return { tenants: f };
|
|
3567
3763
|
let p = e.select({ count: r() }).from(k).$dynamic();
|
|
3568
3764
|
u && (p = p.where(u));
|
|
@@ -3575,7 +3771,7 @@ function rr(e) {
|
|
|
3575
3771
|
};
|
|
3576
3772
|
},
|
|
3577
3773
|
async update(t, n) {
|
|
3578
|
-
let r =
|
|
3774
|
+
let r = mr({
|
|
3579
3775
|
...n,
|
|
3580
3776
|
id: t,
|
|
3581
3777
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3589,62 +3785,62 @@ function rr(e) {
|
|
|
3589
3785
|
}
|
|
3590
3786
|
//#endregion
|
|
3591
3787
|
//#region src/adapters/themes.ts
|
|
3592
|
-
var
|
|
3788
|
+
var gr = [
|
|
3593
3789
|
"colors",
|
|
3594
3790
|
"borders",
|
|
3595
3791
|
"fonts",
|
|
3596
3792
|
"page_background",
|
|
3597
3793
|
"widget"
|
|
3598
3794
|
];
|
|
3599
|
-
function
|
|
3600
|
-
let { tenant_id: t, ...n } = e, r =
|
|
3795
|
+
function _r(e) {
|
|
3796
|
+
let { tenant_id: t, ...n } = e, r = $e(n, gr);
|
|
3601
3797
|
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), O(r);
|
|
3602
3798
|
}
|
|
3603
|
-
function
|
|
3799
|
+
function vr(e) {
|
|
3604
3800
|
return {
|
|
3605
3801
|
async create(t, n, r, i) {
|
|
3606
3802
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3607
|
-
...
|
|
3803
|
+
...Qe(n),
|
|
3608
3804
|
tenant_id: t,
|
|
3609
3805
|
themeId: s,
|
|
3610
3806
|
created_at: a?.created_at ?? o,
|
|
3611
3807
|
updated_at: a?.updated_at ?? o
|
|
3612
3808
|
};
|
|
3613
|
-
return await e.insert(
|
|
3809
|
+
return await e.insert(Re).values(c), _r({
|
|
3614
3810
|
...c,
|
|
3615
3811
|
tenant_id: t
|
|
3616
3812
|
});
|
|
3617
3813
|
},
|
|
3618
3814
|
async get(n, r) {
|
|
3619
|
-
let i = await e.select().from(
|
|
3620
|
-
return i ?
|
|
3815
|
+
let i = await e.select().from(Re).where(t(a(Re.tenant_id, n), a(Re.themeId, r))).get();
|
|
3816
|
+
return i ? _r(i) : null;
|
|
3621
3817
|
},
|
|
3622
3818
|
async update(n, r, i) {
|
|
3623
|
-
let o =
|
|
3624
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3819
|
+
let o = Qe(i);
|
|
3820
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Re).set(o).where(t(a(Re.tenant_id, n), a(Re.themeId, r))), !0;
|
|
3625
3821
|
},
|
|
3626
3822
|
async remove(n, r) {
|
|
3627
|
-
return (await e.delete(
|
|
3823
|
+
return (await e.delete(Re).where(t(a(Re.tenant_id, n), a(Re.themeId, r))).returning()).length > 0;
|
|
3628
3824
|
}
|
|
3629
3825
|
};
|
|
3630
3826
|
}
|
|
3631
3827
|
//#endregion
|
|
3632
3828
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3633
|
-
function
|
|
3829
|
+
function yr(e) {
|
|
3634
3830
|
return {
|
|
3635
3831
|
async get(t) {
|
|
3636
|
-
let n = await e.select({ body:
|
|
3832
|
+
let n = await e.select({ body: Le.body }).from(Le).where(a(Le.tenant_id, t)).get();
|
|
3637
3833
|
return n ? { body: n.body } : null;
|
|
3638
3834
|
},
|
|
3639
3835
|
async set(t, n) {
|
|
3640
3836
|
let r = Date.now();
|
|
3641
|
-
await e.insert(
|
|
3837
|
+
await e.insert(Le).values({
|
|
3642
3838
|
tenant_id: t,
|
|
3643
3839
|
body: n.body,
|
|
3644
3840
|
created_at_ts: r,
|
|
3645
3841
|
updated_at_ts: r
|
|
3646
3842
|
}).onConflictDoUpdate({
|
|
3647
|
-
target:
|
|
3843
|
+
target: Le.tenant_id,
|
|
3648
3844
|
set: {
|
|
3649
3845
|
body: n.body,
|
|
3650
3846
|
updated_at_ts: r
|
|
@@ -3652,20 +3848,20 @@ function sr(e) {
|
|
|
3652
3848
|
});
|
|
3653
3849
|
},
|
|
3654
3850
|
async delete(t) {
|
|
3655
|
-
await e.delete(
|
|
3851
|
+
await e.delete(Le).where(a(Le.tenant_id, t));
|
|
3656
3852
|
}
|
|
3657
3853
|
};
|
|
3658
3854
|
}
|
|
3659
3855
|
//#endregion
|
|
3660
3856
|
//#region src/adapters/userActivity.ts
|
|
3661
|
-
function
|
|
3857
|
+
function br(e) {
|
|
3662
3858
|
let t = {};
|
|
3663
3859
|
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;
|
|
3664
3860
|
}
|
|
3665
|
-
function
|
|
3861
|
+
function xr(e) {
|
|
3666
3862
|
return {
|
|
3667
3863
|
async get(n, r) {
|
|
3668
|
-
let i = await e.select().from(
|
|
3864
|
+
let i = await e.select().from(Oe).where(t(a(Oe.tenant_id, n), a(Oe.user_id, r))).get();
|
|
3669
3865
|
return i ? {
|
|
3670
3866
|
user_id: i.user_id,
|
|
3671
3867
|
last_login: i.last_login ?? void 0,
|
|
@@ -3676,7 +3872,7 @@ function lr(e) {
|
|
|
3676
3872
|
} : null;
|
|
3677
3873
|
},
|
|
3678
3874
|
async upsert(t, n, r) {
|
|
3679
|
-
let i =
|
|
3875
|
+
let i = br(r), a = e.insert(Oe).values({
|
|
3680
3876
|
tenant_id: t,
|
|
3681
3877
|
user_id: n,
|
|
3682
3878
|
login_count: 0,
|
|
@@ -3687,7 +3883,7 @@ function lr(e) {
|
|
|
3687
3883
|
return;
|
|
3688
3884
|
}
|
|
3689
3885
|
await a.onConflictDoUpdate({
|
|
3690
|
-
target: [
|
|
3886
|
+
target: [Oe.tenant_id, Oe.user_id],
|
|
3691
3887
|
set: i
|
|
3692
3888
|
});
|
|
3693
3889
|
}
|
|
@@ -3695,14 +3891,14 @@ function lr(e) {
|
|
|
3695
3891
|
}
|
|
3696
3892
|
//#endregion
|
|
3697
3893
|
//#region src/adapters/outbox.ts
|
|
3698
|
-
function
|
|
3894
|
+
function Sr(e) {
|
|
3699
3895
|
return {
|
|
3700
3896
|
...e,
|
|
3701
3897
|
payload: Q(e.payload, {})
|
|
3702
3898
|
};
|
|
3703
3899
|
}
|
|
3704
|
-
function
|
|
3705
|
-
return e.insert(
|
|
3900
|
+
function Cr(e, t, n, r) {
|
|
3901
|
+
return e.insert(Y).values({
|
|
3706
3902
|
id: t,
|
|
3707
3903
|
tenant_id: n,
|
|
3708
3904
|
event_type: r.event_type,
|
|
@@ -3722,52 +3918,52 @@ function dr(e, t, n, r) {
|
|
|
3722
3918
|
claim_expires_at: null
|
|
3723
3919
|
});
|
|
3724
3920
|
}
|
|
3725
|
-
function
|
|
3921
|
+
function wr(e) {
|
|
3726
3922
|
return {
|
|
3727
3923
|
async create(t, n) {
|
|
3728
3924
|
let r = b();
|
|
3729
|
-
return await
|
|
3925
|
+
return await Cr(e, r, t, n), r;
|
|
3730
3926
|
},
|
|
3731
3927
|
async getByIds(t) {
|
|
3732
|
-
return t.length === 0 ? [] : (await e.select().from(
|
|
3928
|
+
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(Sr);
|
|
3733
3929
|
},
|
|
3734
3930
|
async getUnprocessed(n) {
|
|
3735
3931
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3736
|
-
return (await e.select().from(
|
|
3932
|
+
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(Sr);
|
|
3737
3933
|
},
|
|
3738
3934
|
async claimEvents(n, r, i) {
|
|
3739
3935
|
if (n.length === 0) return [];
|
|
3740
3936
|
let o = (/* @__PURE__ */ new Date()).toISOString(), s = new Date(Date.now() + i).toISOString();
|
|
3741
|
-
return await e.update(
|
|
3937
|
+
return await e.update(Y).set({
|
|
3742
3938
|
claimed_by: r,
|
|
3743
3939
|
claim_expires_at: s
|
|
3744
|
-
}).where(t(l(
|
|
3940
|
+
}).where(t(l(Y.id, n), f(Y.processed_at), v(f(Y.claimed_by), h(Y.claim_expires_at, o)))), (await e.select({ id: Y.id }).from(Y).where(t(l(Y.id, n), a(Y.claimed_by, r))).all()).map((e) => e.id);
|
|
3745
3941
|
},
|
|
3746
3942
|
async markProcessed(t) {
|
|
3747
|
-
t.length !== 0 && await e.update(
|
|
3943
|
+
t.length !== 0 && await e.update(Y).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(l(Y.id, t));
|
|
3748
3944
|
},
|
|
3749
3945
|
async markRetry(t, n, r) {
|
|
3750
|
-
await e.update(
|
|
3946
|
+
await e.update(Y).set({
|
|
3751
3947
|
error: n,
|
|
3752
3948
|
next_retry_at: r,
|
|
3753
|
-
retry_count: y`${
|
|
3949
|
+
retry_count: y`${Y.retry_count} + 1`,
|
|
3754
3950
|
claimed_by: null,
|
|
3755
3951
|
claim_expires_at: null
|
|
3756
|
-
}).where(a(
|
|
3952
|
+
}).where(a(Y.id, t));
|
|
3757
3953
|
},
|
|
3758
3954
|
async cleanup(n) {
|
|
3759
|
-
return (await e.delete(
|
|
3955
|
+
return (await e.delete(Y).where(t(y`${Y.processed_at} IS NOT NULL`, h(Y.processed_at, n))).returning()).length;
|
|
3760
3956
|
},
|
|
3761
3957
|
async deadLetter(t, n) {
|
|
3762
3958
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3763
|
-
await e.update(
|
|
3959
|
+
await e.update(Y).set({
|
|
3764
3960
|
processed_at: r,
|
|
3765
3961
|
dead_lettered_at: r,
|
|
3766
3962
|
final_error: n
|
|
3767
|
-
}).where(a(
|
|
3963
|
+
}).where(a(Y.id, t));
|
|
3768
3964
|
},
|
|
3769
3965
|
async listFailed(o, s = {}) {
|
|
3770
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, f = (await e.select().from(
|
|
3966
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, f = (await e.select().from(Y).where(t(a(Y.tenant_id, o), d(Y.dead_lettered_at))).orderBy(i(Y.dead_lettered_at), n(Y.id)).offset(c * l).limit(l).all()).map((e) => ({
|
|
3771
3967
|
...Q(e.payload, {}),
|
|
3772
3968
|
id: e.id,
|
|
3773
3969
|
created_at: e.created_at,
|
|
@@ -3779,7 +3975,7 @@ function fr(e) {
|
|
|
3779
3975
|
final_error: e.final_error
|
|
3780
3976
|
})), p = f.length;
|
|
3781
3977
|
if (u) {
|
|
3782
|
-
let [n] = await e.select({ total: r() }).from(
|
|
3978
|
+
let [n] = await e.select({ total: r() }).from(Y).where(t(a(Y.tenant_id, o), d(Y.dead_lettered_at)));
|
|
3783
3979
|
p = Number(n?.total ?? f.length);
|
|
3784
3980
|
}
|
|
3785
3981
|
return {
|
|
@@ -3790,23 +3986,23 @@ function fr(e) {
|
|
|
3790
3986
|
};
|
|
3791
3987
|
},
|
|
3792
3988
|
async replay(n, r) {
|
|
3793
|
-
return (await e.update(
|
|
3989
|
+
return (await e.update(Y).set({
|
|
3794
3990
|
processed_at: null,
|
|
3795
3991
|
dead_lettered_at: null,
|
|
3796
3992
|
final_error: null,
|
|
3797
3993
|
retry_count: 0,
|
|
3798
3994
|
next_retry_at: null,
|
|
3799
3995
|
error: null
|
|
3800
|
-
}).where(t(a(
|
|
3996
|
+
}).where(t(a(Y.id, n), a(Y.tenant_id, r), d(Y.dead_lettered_at))).returning()).length > 0;
|
|
3801
3997
|
}
|
|
3802
3998
|
};
|
|
3803
3999
|
}
|
|
3804
4000
|
//#endregion
|
|
3805
4001
|
//#region src/adapters/users.ts
|
|
3806
|
-
function
|
|
3807
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4002
|
+
function Tr(e, t, n) {
|
|
4003
|
+
return (n?.outboxEvents ?? []).map((n) => Cr(e, n.id, t, n));
|
|
3808
4004
|
}
|
|
3809
|
-
var
|
|
4005
|
+
var Er = [
|
|
3810
4006
|
"user_id",
|
|
3811
4007
|
"email",
|
|
3812
4008
|
"email_verified",
|
|
@@ -3828,23 +4024,23 @@ var mr = [
|
|
|
3828
4024
|
"login_count",
|
|
3829
4025
|
"created_at",
|
|
3830
4026
|
"updated_at"
|
|
3831
|
-
],
|
|
4027
|
+
], Dr = [
|
|
3832
4028
|
"email",
|
|
3833
4029
|
"name",
|
|
3834
4030
|
"phone_number",
|
|
3835
4031
|
"user_id"
|
|
3836
|
-
],
|
|
4032
|
+
], Or = new Set([
|
|
3837
4033
|
"last_login",
|
|
3838
4034
|
"last_ip",
|
|
3839
4035
|
"login_count"
|
|
3840
|
-
]),
|
|
3841
|
-
coalesce:
|
|
4036
|
+
]), kr = o(j), Ar = o(Oe), jr = Object.fromEntries(Er.map((e) => [e, e === "login_count" ? {
|
|
4037
|
+
coalesce: Oe.login_count,
|
|
3842
4038
|
defaultValue: 0
|
|
3843
|
-
} :
|
|
3844
|
-
function
|
|
3845
|
-
return t(a(
|
|
4039
|
+
} : Or.has(e) ? Ar[e] : kr[e]]));
|
|
4040
|
+
function Mr() {
|
|
4041
|
+
return t(a(Oe.tenant_id, j.tenant_id), a(Oe.user_id, j.user_id));
|
|
3846
4042
|
}
|
|
3847
|
-
function
|
|
4043
|
+
function Nr(e, t) {
|
|
3848
4044
|
return {
|
|
3849
4045
|
...e,
|
|
3850
4046
|
last_login: t?.last_login,
|
|
@@ -3852,7 +4048,7 @@ function xr(e, t) {
|
|
|
3852
4048
|
login_count: t?.login_count ?? 0
|
|
3853
4049
|
};
|
|
3854
4050
|
}
|
|
3855
|
-
function
|
|
4051
|
+
function Pr(e, t) {
|
|
3856
4052
|
let n = {
|
|
3857
4053
|
connection: e.connection,
|
|
3858
4054
|
provider: e.provider,
|
|
@@ -3865,21 +4061,22 @@ function Sr(e, t) {
|
|
|
3865
4061
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
3866
4062
|
}, n;
|
|
3867
4063
|
}
|
|
3868
|
-
function
|
|
3869
|
-
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c,
|
|
4064
|
+
function Fr(e, t = []) {
|
|
4065
|
+
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = Pr(e, !0), m = t.map((e) => Pr(e, !1));
|
|
3870
4066
|
return O({
|
|
3871
|
-
...
|
|
4067
|
+
...f,
|
|
3872
4068
|
email: e.email || "",
|
|
3873
4069
|
email_verified: !!o,
|
|
3874
4070
|
phone_verified: s == null ? void 0 : !!s,
|
|
3875
4071
|
is_social: !!c,
|
|
4072
|
+
blocked: l == null ? void 0 : !!l,
|
|
3876
4073
|
app_metadata: Q(r, {}),
|
|
3877
4074
|
user_metadata: Q(i, {}),
|
|
3878
4075
|
address: Q(a),
|
|
3879
|
-
identities: [
|
|
4076
|
+
identities: [p, ...m]
|
|
3880
4077
|
});
|
|
3881
4078
|
}
|
|
3882
|
-
function
|
|
4079
|
+
function Ir(e) {
|
|
3883
4080
|
let o = async (t, n, r) => {
|
|
3884
4081
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
3885
4082
|
user_id: n.user_id,
|
|
@@ -3899,6 +4096,7 @@ function wr(e) {
|
|
|
3899
4096
|
connection: n.connection,
|
|
3900
4097
|
email_verified: n.email_verified ?? !1,
|
|
3901
4098
|
is_social: n.is_social ?? !1,
|
|
4099
|
+
blocked: n.blocked ?? !1,
|
|
3902
4100
|
app_metadata: JSON.stringify(n.app_metadata || {}),
|
|
3903
4101
|
user_metadata: JSON.stringify(n.user_metadata || {}),
|
|
3904
4102
|
address: n.address ? JSON.stringify(n.address) : void 0,
|
|
@@ -3916,7 +4114,7 @@ function wr(e) {
|
|
|
3916
4114
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
3917
4115
|
try {
|
|
3918
4116
|
let c = [e.insert(j).values(a)];
|
|
3919
|
-
s && c.push(e.insert(
|
|
4117
|
+
s && c.push(e.insert(Oe).values({
|
|
3920
4118
|
tenant_id: t,
|
|
3921
4119
|
user_id: n.user_id,
|
|
3922
4120
|
last_login: n.last_login,
|
|
@@ -3932,12 +4130,12 @@ function wr(e) {
|
|
|
3932
4130
|
created_at: i,
|
|
3933
4131
|
updated_at: i
|
|
3934
4132
|
}));
|
|
3935
|
-
for (let n of
|
|
3936
|
-
c.length > 1 ? await
|
|
4133
|
+
for (let n of Tr(e, t, r)) c.push(n);
|
|
4134
|
+
c.length > 1 ? await ct(e, c) : await e.insert(j).values(a);
|
|
3937
4135
|
} catch (e) {
|
|
3938
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4136
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Ce(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Ce(500, { message: "Internal server error" }));
|
|
3939
4137
|
}
|
|
3940
|
-
return
|
|
4138
|
+
return Fr({
|
|
3941
4139
|
...a,
|
|
3942
4140
|
last_login: n.last_login,
|
|
3943
4141
|
last_ip: n.last_ip,
|
|
@@ -3948,10 +4146,10 @@ function wr(e) {
|
|
|
3948
4146
|
create: o,
|
|
3949
4147
|
rawCreate: o,
|
|
3950
4148
|
async get(n, r) {
|
|
3951
|
-
let i = await e.select().from(j).leftJoin(
|
|
4149
|
+
let i = await e.select().from(j).leftJoin(Oe, Mr()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
3952
4150
|
if (!i) return null;
|
|
3953
4151
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
3954
|
-
return
|
|
4152
|
+
return Fr(Nr(i.users, i.user_activity), o);
|
|
3955
4153
|
},
|
|
3956
4154
|
async update(n, r, i, o) {
|
|
3957
4155
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3977,9 +4175,9 @@ function wr(e) {
|
|
|
3977
4175
|
"birthdate",
|
|
3978
4176
|
"zoneinfo"
|
|
3979
4177
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
3980
|
-
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.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));
|
|
3981
|
-
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l =
|
|
3982
|
-
return u = l.length > 0 ? (await
|
|
4178
|
+
i.email_verified !== void 0 && (s.email_verified = i.email_verified), i.phone_verified !== void 0 && (s.phone_verified = i.phone_verified), i.is_social !== void 0 && (s.is_social = i.is_social), i.blocked !== void 0 && (s.blocked = i.blocked), i.app_metadata !== void 0 && (s.app_metadata = JSON.stringify(i.app_metadata)), i.user_metadata !== void 0 && (s.user_metadata = JSON.stringify(i.user_metadata)), i.address !== void 0 && (s.address = JSON.stringify(i.address)), i.profileData !== void 0 && (s.profileData = JSON.stringify(i.profileData));
|
|
4179
|
+
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l = Tr(e, n, o), u;
|
|
4180
|
+
return u = l.length > 0 ? (await ct(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 xr(e).upsert(n, r, {
|
|
3983
4181
|
last_login: i.last_login,
|
|
3984
4182
|
last_ip: i.last_ip,
|
|
3985
4183
|
login_count: i.login_count
|
|
@@ -3988,24 +4186,24 @@ function wr(e) {
|
|
|
3988
4186
|
async list(o, s) {
|
|
3989
4187
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(j.tenant_id, o), f(j.linked_to)];
|
|
3990
4188
|
if (m) {
|
|
3991
|
-
let e = _e(m,
|
|
4189
|
+
let e = _e(m, Er);
|
|
3992
4190
|
if (e) {
|
|
3993
|
-
let t =
|
|
4191
|
+
let t = nt(jr, e, Dr);
|
|
3994
4192
|
t && h.push(t);
|
|
3995
4193
|
}
|
|
3996
4194
|
}
|
|
3997
4195
|
let g = t(...h), _ = async (n) => {
|
|
3998
4196
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(j).where(t(a(j.tenant_id, o), l(j.linked_to, r))) : [];
|
|
3999
|
-
return n.map((e) =>
|
|
4197
|
+
return n.map((e) => Fr(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4000
4198
|
};
|
|
4001
|
-
if (
|
|
4002
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4199
|
+
if (pt(s)) {
|
|
4200
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Ce(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4003
4201
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4004
4202
|
sortColumn: j.created_at,
|
|
4005
4203
|
idColumn: j.user_id,
|
|
4006
4204
|
sortOrder: n,
|
|
4007
4205
|
sortKey: `created_at:${n}`
|
|
4008
|
-
}, i =
|
|
4206
|
+
}, i = mt(s), a = gt(s, r), { rows: o, next: c } = _t((await e.select().from(j).leftJoin(Oe, Mr()).where(a ? t(g, a) : g).orderBy(...ht(r)).limit(i + 1)).map((e) => Nr(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4009
4207
|
return {
|
|
4010
4208
|
users: l,
|
|
4011
4209
|
start: 0,
|
|
@@ -4014,17 +4212,17 @@ function wr(e) {
|
|
|
4014
4212
|
next: c
|
|
4015
4213
|
};
|
|
4016
4214
|
}
|
|
4017
|
-
let v = e.select().from(j).leftJoin(
|
|
4215
|
+
let v = e.select().from(j).leftJoin(Oe, Mr()).where(g).$dynamic();
|
|
4018
4216
|
if (p?.sort_by) {
|
|
4019
|
-
let e =
|
|
4217
|
+
let e = jr[p.sort_by];
|
|
4020
4218
|
if (e) {
|
|
4021
|
-
let t =
|
|
4219
|
+
let t = et(e) ? tt(e) : e;
|
|
4022
4220
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4023
4221
|
}
|
|
4024
4222
|
}
|
|
4025
|
-
let y = await _((await v.offset(c * u).limit(u)).map((e) =>
|
|
4223
|
+
let y = await _((await v.offset(c * u).limit(u)).map((e) => Nr(e.users, e.user_activity)));
|
|
4026
4224
|
if (!d) return { users: y };
|
|
4027
|
-
let [ee] = await e.select({ count: r() }).from(j).leftJoin(
|
|
4225
|
+
let [ee] = await e.select({ count: r() }).from(j).leftJoin(Oe, Mr()).where(g);
|
|
4028
4226
|
return {
|
|
4029
4227
|
users: y,
|
|
4030
4228
|
start: c * u,
|
|
@@ -4034,14 +4232,14 @@ function wr(e) {
|
|
|
4034
4232
|
},
|
|
4035
4233
|
async remove(n, r, i) {
|
|
4036
4234
|
let o = await e.select({ user_id: j.user_id }).from(j).where(t(a(j.tenant_id, n), v(a(j.user_id, r), a(j.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
|
|
4037
|
-
e.delete(
|
|
4235
|
+
e.delete(Je).where(t(a(Je.tenant_id, n), l(Je.user_id, u))),
|
|
4038
4236
|
e.delete(M).where(t(a(M.tenant_id, n), l(M.user_id, u))),
|
|
4039
|
-
e.delete(
|
|
4237
|
+
e.delete(Oe).where(t(a(Oe.tenant_id, n), l(Oe.user_id, u))),
|
|
4040
4238
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4041
4239
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4042
4240
|
], f = d.length - 1;
|
|
4043
|
-
if (s) for (let t of
|
|
4044
|
-
let p = (await
|
|
4241
|
+
if (s) for (let t of Tr(e, n, i)) d.push(t);
|
|
4242
|
+
let p = (await ct(e, d))[f];
|
|
4045
4243
|
return Array.isArray(p) && p.length > 0;
|
|
4046
4244
|
},
|
|
4047
4245
|
async unlink(n, r, i, o) {
|
|
@@ -4052,7 +4250,7 @@ function wr(e) {
|
|
|
4052
4250
|
}
|
|
4053
4251
|
//#endregion
|
|
4054
4252
|
//#region src/adapters/userRoles.ts
|
|
4055
|
-
function
|
|
4253
|
+
function Lr(e) {
|
|
4056
4254
|
return {
|
|
4057
4255
|
async create(t, n, r, i) {
|
|
4058
4256
|
try {
|
|
@@ -4086,12 +4284,12 @@ function Tr(e) {
|
|
|
4086
4284
|
},
|
|
4087
4285
|
async listUsers(r, i, o) {
|
|
4088
4286
|
let s = t(a(K.tenant_id, r), a(K.role_id, i));
|
|
4089
|
-
if (
|
|
4287
|
+
if (pt(o)) {
|
|
4090
4288
|
let n = {
|
|
4091
4289
|
sortColumn: K.user_id,
|
|
4092
4290
|
idColumn: K.user_id,
|
|
4093
4291
|
sortOrder: "asc"
|
|
4094
|
-
}, r =
|
|
4292
|
+
}, r = gt(o, n), i = mt(o), { rows: a, next: c } = _t(await e.selectDistinct({ user_id: K.user_id }).from(K).where(r ? t(s, r) : s).orderBy(...ht(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4095
4293
|
return {
|
|
4096
4294
|
userIds: a.map((e) => e.user_id),
|
|
4097
4295
|
start: 0,
|
|
@@ -4115,7 +4313,7 @@ function Tr(e) {
|
|
|
4115
4313
|
}
|
|
4116
4314
|
//#endregion
|
|
4117
4315
|
//#region src/adapters/userOrganizations.ts
|
|
4118
|
-
function
|
|
4316
|
+
function Rr(e) {
|
|
4119
4317
|
return {
|
|
4120
4318
|
async create(t, n) {
|
|
4121
4319
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4129,7 +4327,7 @@ function Er(e) {
|
|
|
4129
4327
|
try {
|
|
4130
4328
|
await e.insert(W).values(i);
|
|
4131
4329
|
} catch (e) {
|
|
4132
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4330
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Ce(409, { message: "User organization already exists" }) : e;
|
|
4133
4331
|
}
|
|
4134
4332
|
let { tenant_id: a, ...o } = i;
|
|
4135
4333
|
return o;
|
|
@@ -4147,19 +4345,19 @@ function Er(e) {
|
|
|
4147
4345
|
async list(n, o) {
|
|
4148
4346
|
let { include_totals: s = !1, q: c } = o || {}, l = a(W.tenant_id, n), u = l;
|
|
4149
4347
|
if (c) {
|
|
4150
|
-
let e =
|
|
4348
|
+
let e = nt(W, c, ["user_id", "organization_id"]);
|
|
4151
4349
|
e && (u = t(l, e));
|
|
4152
4350
|
}
|
|
4153
4351
|
let d = (e) => {
|
|
4154
4352
|
let { tenant_id: t, ...n } = e;
|
|
4155
4353
|
return n;
|
|
4156
4354
|
};
|
|
4157
|
-
if (
|
|
4355
|
+
if (pt(o)) {
|
|
4158
4356
|
let n = {
|
|
4159
4357
|
sortColumn: W.created_at,
|
|
4160
4358
|
idColumn: W.id,
|
|
4161
4359
|
sortOrder: "desc"
|
|
4162
|
-
}, r =
|
|
4360
|
+
}, r = gt(o, n), i = mt(o), { rows: a, next: s } = _t((await e.select().from(W).where(r ? t(u, r) : u).orderBy(...ht(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4163
4361
|
return {
|
|
4164
4362
|
userOrganizations: a,
|
|
4165
4363
|
start: 0,
|
|
@@ -4207,20 +4405,20 @@ function Er(e) {
|
|
|
4207
4405
|
}
|
|
4208
4406
|
//#endregion
|
|
4209
4407
|
//#region src/adapters/stats.ts
|
|
4210
|
-
var
|
|
4211
|
-
function
|
|
4408
|
+
var zr = ["s"], Br = ["pwd_leak"];
|
|
4409
|
+
function Vr(e) {
|
|
4212
4410
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4213
4411
|
}
|
|
4214
|
-
function
|
|
4412
|
+
function Hr(e) {
|
|
4215
4413
|
return {
|
|
4216
4414
|
async getDaily(n, r) {
|
|
4217
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4415
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? Vr(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? Vr(r.to) : i.toISOString().split("T")[0];
|
|
4218
4416
|
return (await e.select({
|
|
4219
|
-
date: y`substr(${
|
|
4220
|
-
logins: y`SUM(CASE WHEN ${
|
|
4221
|
-
signups: y`SUM(CASE WHEN ${
|
|
4222
|
-
leaked_passwords: y`SUM(CASE WHEN ${
|
|
4223
|
-
}).from(
|
|
4417
|
+
date: y`substr(${J.date}, 1, 10)`.as("date"),
|
|
4418
|
+
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(zr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4419
|
+
signups: y`SUM(CASE WHEN ${J.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4420
|
+
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(Br.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4421
|
+
}).from(J).where(t(a(J.tenant_id, n), c(J.date, o), h(J.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${J.date}, 1, 10)`).orderBy(y`substr(${J.date}, 1, 10)`).all()).map((e) => ({
|
|
4224
4422
|
date: e.date,
|
|
4225
4423
|
logins: Number(e.logins) || 0,
|
|
4226
4424
|
signups: Number(e.signups) || 0,
|
|
@@ -4230,14 +4428,14 @@ function Ar(e) {
|
|
|
4230
4428
|
}));
|
|
4231
4429
|
},
|
|
4232
4430
|
async getActiveUsers(n) {
|
|
4233
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${
|
|
4431
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(zr.map((e) => y`${e}`), y`, `)})`));
|
|
4234
4432
|
return Number(i?.count) || 0;
|
|
4235
4433
|
}
|
|
4236
4434
|
};
|
|
4237
4435
|
}
|
|
4238
4436
|
//#endregion
|
|
4239
4437
|
//#region src/adapters/analytics.ts
|
|
4240
|
-
var
|
|
4438
|
+
var Ur = {
|
|
4241
4439
|
"active-users": ["s", "seacft"],
|
|
4242
4440
|
logins: [
|
|
4243
4441
|
"s",
|
|
@@ -4267,7 +4465,7 @@ var jr = {
|
|
|
4267
4465
|
"fvr"
|
|
4268
4466
|
],
|
|
4269
4467
|
"codes-sent": ["cls", "cs"]
|
|
4270
|
-
},
|
|
4468
|
+
}, Wr = {
|
|
4271
4469
|
"active-users": {
|
|
4272
4470
|
alias: "active_users",
|
|
4273
4471
|
type: "UInt64",
|
|
@@ -4324,63 +4522,63 @@ var jr = {
|
|
|
4324
4522
|
agg: "count"
|
|
4325
4523
|
}
|
|
4326
4524
|
};
|
|
4327
|
-
function
|
|
4525
|
+
function Gr(e) {
|
|
4328
4526
|
switch (e) {
|
|
4329
|
-
case "hour": return y`substr(${
|
|
4330
|
-
case "month": return y`substr(${
|
|
4331
|
-
case "day": return y`substr(${
|
|
4332
|
-
case "week": return y`date(substr(${
|
|
4527
|
+
case "hour": return y`substr(${J.date}, 1, 13)`;
|
|
4528
|
+
case "month": return y`substr(${J.date}, 1, 7)`;
|
|
4529
|
+
case "day": return y`substr(${J.date}, 1, 10)`;
|
|
4530
|
+
case "week": return y`date(substr(${J.date}, 1, 10), '-' || ((cast(strftime('%w', substr(${J.date}, 1, 10)) as integer) + 6) % 7) || ' days')`;
|
|
4333
4531
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4334
4532
|
}
|
|
4335
4533
|
}
|
|
4336
|
-
function
|
|
4534
|
+
function Kr(e) {
|
|
4337
4535
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4338
4536
|
}
|
|
4339
|
-
function
|
|
4537
|
+
function qr(e) {
|
|
4340
4538
|
switch (e) {
|
|
4341
|
-
case "connection": return
|
|
4342
|
-
case "client_id": return
|
|
4343
|
-
case "user_type": return
|
|
4344
|
-
case "event": return
|
|
4539
|
+
case "connection": return J.connection;
|
|
4540
|
+
case "client_id": return J.client_id;
|
|
4541
|
+
case "user_type": return J.strategy_type;
|
|
4542
|
+
case "event": return J.type;
|
|
4345
4543
|
case "time": throw Error("time dimension handled separately");
|
|
4346
4544
|
}
|
|
4347
4545
|
}
|
|
4348
|
-
function
|
|
4546
|
+
function Jr(e) {
|
|
4349
4547
|
return { async query(n, r, i) {
|
|
4350
|
-
let o = Date.now(), s =
|
|
4351
|
-
a(
|
|
4352
|
-
c(
|
|
4353
|
-
m(
|
|
4354
|
-
l(
|
|
4548
|
+
let o = Date.now(), s = Ur[r], u = Wr[r], d = [
|
|
4549
|
+
a(J.tenant_id, n),
|
|
4550
|
+
c(J.date, i.from),
|
|
4551
|
+
m(J.date, i.to),
|
|
4552
|
+
l(J.type, s)
|
|
4355
4553
|
];
|
|
4356
|
-
i.filters.connection?.length && d.push(l(
|
|
4554
|
+
i.filters.connection?.length && d.push(l(J.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(J.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(J.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(J.user_id, i.filters.user_id));
|
|
4357
4555
|
let f = {}, p = [], h = [];
|
|
4358
4556
|
for (let e of i.group_by) if (e === "time") {
|
|
4359
|
-
let e =
|
|
4557
|
+
let e = Gr(i.interval);
|
|
4360
4558
|
f.time = e, p.push(e), h.push({
|
|
4361
4559
|
name: "time",
|
|
4362
4560
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4363
4561
|
});
|
|
4364
4562
|
} else {
|
|
4365
|
-
let t =
|
|
4563
|
+
let t = qr(e);
|
|
4366
4564
|
f[e] = t, p.push(t), h.push({
|
|
4367
4565
|
name: e,
|
|
4368
4566
|
type: "String"
|
|
4369
4567
|
});
|
|
4370
4568
|
}
|
|
4371
|
-
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${
|
|
4569
|
+
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${J.user_id})` : y`COUNT(*)`, h.push({
|
|
4372
4570
|
name: u.alias,
|
|
4373
4571
|
type: u.type
|
|
4374
4572
|
});
|
|
4375
|
-
let g = e.select(f).from(
|
|
4573
|
+
let g = e.select(f).from(J).where(t(...d));
|
|
4376
4574
|
p.length > 0 && (g = g.groupBy(...p));
|
|
4377
4575
|
let _ = new Set([...Object.keys(f)]);
|
|
4378
4576
|
if (i.order_by) {
|
|
4379
4577
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4380
4578
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4381
|
-
let n =
|
|
4579
|
+
let n = Kr(t);
|
|
4382
4580
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4383
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4581
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Kr("time")} ASC`)) : g.orderBy(y.raw(`${Kr(u.alias)} DESC`));
|
|
4384
4582
|
g = g.limit(i.limit).offset(i.offset);
|
|
4385
4583
|
let v = (await g.all()).map((e) => {
|
|
4386
4584
|
let t = {};
|
|
@@ -4401,10 +4599,10 @@ function Ir(e) {
|
|
|
4401
4599
|
}
|
|
4402
4600
|
//#endregion
|
|
4403
4601
|
//#region src/adapters/cleanup.ts
|
|
4404
|
-
var
|
|
4405
|
-
function
|
|
4602
|
+
var Yr = 10080 * 60 * 1e3;
|
|
4603
|
+
function Xr(e) {
|
|
4406
4604
|
return async (n) => {
|
|
4407
|
-
let r = Date.now() -
|
|
4605
|
+
let r = Date.now() - Yr;
|
|
4408
4606
|
try {
|
|
4409
4607
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4410
4608
|
n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i)), i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), n?.user_id && i.push(a(N.user_id, n.user_id)), await e.delete(N).where(t(...i)), i = [m(F.expires_at_ts, r)], n?.tenant_id && i.push(a(F.tenant_id, n.tenant_id)), await e.delete(F).where(t(...i));
|
|
@@ -4435,7 +4633,7 @@ var $ = w("tenant_operations", {
|
|
|
4435
4633
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4436
4634
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4437
4635
|
x("tenant_operations_status_idx").on(e.status)
|
|
4438
|
-
]),
|
|
4636
|
+
]), Zr = w("tenant_operation_events", {
|
|
4439
4637
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4440
4638
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4441
4639
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4447,7 +4645,7 @@ var $ = w("tenant_operations", {
|
|
|
4447
4645
|
columns: [e.operation_id],
|
|
4448
4646
|
foreignColumns: [$.id],
|
|
4449
4647
|
name: "tenant_operation_events_operation_id_constraint"
|
|
4450
|
-
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]),
|
|
4648
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), Qr = w("rollouts", {
|
|
4451
4649
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4452
4650
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4453
4651
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4463,8 +4661,8 @@ var $ = w("tenant_operations", {
|
|
|
4463
4661
|
});
|
|
4464
4662
|
//#endregion
|
|
4465
4663
|
//#region src/adapters/tenantOperations.ts
|
|
4466
|
-
function
|
|
4467
|
-
return
|
|
4664
|
+
function $r(e) {
|
|
4665
|
+
return Se.parse({
|
|
4468
4666
|
id: e.id,
|
|
4469
4667
|
tenant_id: e.tenant_id,
|
|
4470
4668
|
rollout_id: e.rollout_id,
|
|
@@ -4482,10 +4680,10 @@ function Vr(e) {
|
|
|
4482
4680
|
finished_at: e.finished_at
|
|
4483
4681
|
});
|
|
4484
4682
|
}
|
|
4485
|
-
function
|
|
4683
|
+
function ei(e) {
|
|
4486
4684
|
return {
|
|
4487
4685
|
async create(t) {
|
|
4488
|
-
let n =
|
|
4686
|
+
let n = xe.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4489
4687
|
id: `op_${b()}`,
|
|
4490
4688
|
tenant_id: n.tenant_id,
|
|
4491
4689
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4509,7 +4707,7 @@ function Hr(e) {
|
|
|
4509
4707
|
},
|
|
4510
4708
|
async get(t) {
|
|
4511
4709
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4512
|
-
return n[0] ?
|
|
4710
|
+
return n[0] ? $r(n[0]) : null;
|
|
4513
4711
|
},
|
|
4514
4712
|
async list(n = {}) {
|
|
4515
4713
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4520,7 +4718,7 @@ function Hr(e) {
|
|
|
4520
4718
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4521
4719
|
let c = await e.select().from($).where(s.length ? t(...s) : void 0).orderBy(i($.created_at), i($.id)).offset(r * o).limit(o);
|
|
4522
4720
|
return {
|
|
4523
|
-
operations: c.map(
|
|
4721
|
+
operations: c.map($r),
|
|
4524
4722
|
start: r * o,
|
|
4525
4723
|
limit: o,
|
|
4526
4724
|
length: c.length
|
|
@@ -4538,27 +4736,27 @@ function Hr(e) {
|
|
|
4538
4736
|
}
|
|
4539
4737
|
//#endregion
|
|
4540
4738
|
//#region src/helpers/monotonic-id.ts
|
|
4541
|
-
var
|
|
4542
|
-
function
|
|
4739
|
+
var ti = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ni = 32, ri = 10, ii = 4, ai = 10;
|
|
4740
|
+
function oi(e, t) {
|
|
4543
4741
|
let n = "";
|
|
4544
|
-
for (let r = t; r > 0; r--) n =
|
|
4742
|
+
for (let r = t; r > 0; r--) n = ti.charAt(e % ni) + n, e = Math.floor(e / ni);
|
|
4545
4743
|
return n;
|
|
4546
4744
|
}
|
|
4547
|
-
function
|
|
4548
|
-
let e = new Uint8Array(
|
|
4745
|
+
function si() {
|
|
4746
|
+
let e = new Uint8Array(ai);
|
|
4549
4747
|
crypto.getRandomValues(e);
|
|
4550
4748
|
let t = "";
|
|
4551
|
-
for (let n = 0; n <
|
|
4749
|
+
for (let n = 0; n < ai; n++) t += ti.charAt(e[n] % ni);
|
|
4552
4750
|
return t;
|
|
4553
4751
|
}
|
|
4554
|
-
var
|
|
4555
|
-
function
|
|
4752
|
+
var ci = 0, li = 0;
|
|
4753
|
+
function ui() {
|
|
4556
4754
|
let e = Date.now();
|
|
4557
|
-
return e ===
|
|
4755
|
+
return e === ci ? li++ : (ci = e, li = 0), oi(e, ri) + oi(li, ii) + si();
|
|
4558
4756
|
}
|
|
4559
4757
|
//#endregion
|
|
4560
4758
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4561
|
-
function
|
|
4759
|
+
function di(e) {
|
|
4562
4760
|
if (!e) return null;
|
|
4563
4761
|
try {
|
|
4564
4762
|
let t = JSON.parse(e);
|
|
@@ -4566,22 +4764,22 @@ function $r(e) {
|
|
|
4566
4764
|
} catch {}
|
|
4567
4765
|
return null;
|
|
4568
4766
|
}
|
|
4569
|
-
function
|
|
4570
|
-
return
|
|
4767
|
+
function fi(e) {
|
|
4768
|
+
return be.parse({
|
|
4571
4769
|
id: e.id,
|
|
4572
4770
|
operation_id: e.operation_id,
|
|
4573
4771
|
step: e.step,
|
|
4574
4772
|
outcome: e.outcome,
|
|
4575
|
-
detail:
|
|
4773
|
+
detail: di(e.detail),
|
|
4576
4774
|
attempt: e.attempt,
|
|
4577
4775
|
created_at: e.created_at
|
|
4578
4776
|
});
|
|
4579
4777
|
}
|
|
4580
|
-
function
|
|
4778
|
+
function pi(e) {
|
|
4581
4779
|
return {
|
|
4582
4780
|
async create(t) {
|
|
4583
|
-
let n =
|
|
4584
|
-
id: `evt_${
|
|
4781
|
+
let n = ye.parse(t), r = {
|
|
4782
|
+
id: `evt_${ui()}`,
|
|
4585
4783
|
operation_id: n.operation_id,
|
|
4586
4784
|
step: n.step,
|
|
4587
4785
|
outcome: n.outcome,
|
|
@@ -4589,7 +4787,7 @@ function ti(e) {
|
|
|
4589
4787
|
attempt: n.attempt,
|
|
4590
4788
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4591
4789
|
};
|
|
4592
|
-
return await e.insert(
|
|
4790
|
+
return await e.insert(Zr).values(r), be.parse({
|
|
4593
4791
|
id: r.id,
|
|
4594
4792
|
operation_id: r.operation_id,
|
|
4595
4793
|
step: r.step,
|
|
@@ -4600,9 +4798,9 @@ function ti(e) {
|
|
|
4600
4798
|
});
|
|
4601
4799
|
},
|
|
4602
4800
|
async listByOperation(t, r = {}) {
|
|
4603
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4801
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Zr).where(a(Zr.operation_id, t)).orderBy(n(Zr.created_at), n(Zr.id)).offset(i * o).limit(o);
|
|
4604
4802
|
return {
|
|
4605
|
-
events: s.map(
|
|
4803
|
+
events: s.map(fi),
|
|
4606
4804
|
start: i * o,
|
|
4607
4805
|
limit: o,
|
|
4608
4806
|
length: s.length
|
|
@@ -4612,7 +4810,7 @@ function ti(e) {
|
|
|
4612
4810
|
}
|
|
4613
4811
|
//#endregion
|
|
4614
4812
|
//#region src/adapters/rollouts.ts
|
|
4615
|
-
function
|
|
4813
|
+
function mi(e) {
|
|
4616
4814
|
if (!e) return null;
|
|
4617
4815
|
try {
|
|
4618
4816
|
return JSON.parse(e);
|
|
@@ -4620,7 +4818,7 @@ function ni(e) {
|
|
|
4620
4818
|
return null;
|
|
4621
4819
|
}
|
|
4622
4820
|
}
|
|
4623
|
-
function
|
|
4821
|
+
function hi(e) {
|
|
4624
4822
|
return ge.parse({
|
|
4625
4823
|
id: e.id,
|
|
4626
4824
|
kind: e.kind,
|
|
@@ -4628,15 +4826,15 @@ function ri(e) {
|
|
|
4628
4826
|
target_worker_version: e.target_worker_version,
|
|
4629
4827
|
target_database_version: e.target_database_version,
|
|
4630
4828
|
wave_size: e.wave_size,
|
|
4631
|
-
canary_tenant_ids:
|
|
4632
|
-
filter:
|
|
4829
|
+
canary_tenant_ids: mi(e.canary_tenant_ids),
|
|
4830
|
+
filter: mi(e.filter),
|
|
4633
4831
|
initiated_by: e.initiated_by,
|
|
4634
4832
|
created_at: e.created_at,
|
|
4635
4833
|
updated_at: e.updated_at,
|
|
4636
4834
|
finished_at: e.finished_at
|
|
4637
4835
|
});
|
|
4638
4836
|
}
|
|
4639
|
-
function
|
|
4837
|
+
function gi(e) {
|
|
4640
4838
|
return {
|
|
4641
4839
|
async create(t) {
|
|
4642
4840
|
let n = he.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4653,90 +4851,93 @@ function ii(e) {
|
|
|
4653
4851
|
updated_at: r,
|
|
4654
4852
|
finished_at: null
|
|
4655
4853
|
};
|
|
4656
|
-
await e.insert(
|
|
4854
|
+
await e.insert(Qr).values(i);
|
|
4657
4855
|
let a = await this.get(i.id);
|
|
4658
4856
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4659
4857
|
return a;
|
|
4660
4858
|
},
|
|
4661
4859
|
async get(t) {
|
|
4662
|
-
let n = await e.select().from(
|
|
4663
|
-
return n[0] ?
|
|
4860
|
+
let n = await e.select().from(Qr).where(a(Qr.id, t)).limit(1);
|
|
4861
|
+
return n[0] ? hi(n[0]) : null;
|
|
4664
4862
|
},
|
|
4665
4863
|
async list(t = {}) {
|
|
4666
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4864
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(Qr).orderBy(i(Qr.created_at), i(Qr.id)).offset(n * r).limit(r);
|
|
4667
4865
|
return {
|
|
4668
|
-
rollouts: a.map(
|
|
4866
|
+
rollouts: a.map(hi),
|
|
4669
4867
|
start: n * r,
|
|
4670
4868
|
limit: r,
|
|
4671
4869
|
length: a.length
|
|
4672
4870
|
};
|
|
4673
4871
|
},
|
|
4674
4872
|
async update(t, n) {
|
|
4675
|
-
if ((await e.select({ id:
|
|
4873
|
+
if ((await e.select({ id: Qr.id }).from(Qr).where(a(Qr.id, t)).limit(1)).length === 0) return !1;
|
|
4676
4874
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4677
|
-
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(
|
|
4875
|
+
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(Qr).set(r).where(a(Qr.id, t)), !0;
|
|
4678
4876
|
},
|
|
4679
4877
|
async remove(t) {
|
|
4680
|
-
return (await e.select({ id:
|
|
4878
|
+
return (await e.select({ id: Qr.id }).from(Qr).where(a(Qr.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Qr).where(a(Qr.id, t)), !0);
|
|
4681
4879
|
}
|
|
4682
4880
|
};
|
|
4683
4881
|
}
|
|
4684
4882
|
//#endregion
|
|
4685
4883
|
//#region src/adapters/index.ts
|
|
4686
|
-
function
|
|
4884
|
+
function _i(e, t = { useTransactions: !0 }) {
|
|
4687
4885
|
let n = {
|
|
4688
|
-
actions:
|
|
4689
|
-
actionExecutions:
|
|
4690
|
-
actionVersions:
|
|
4691
|
-
branding:
|
|
4692
|
-
clients:
|
|
4693
|
-
clientConnections:
|
|
4694
|
-
clientGrants:
|
|
4695
|
-
clientRegistrationTokens:
|
|
4696
|
-
codes:
|
|
4697
|
-
connections:
|
|
4698
|
-
customDomains:
|
|
4699
|
-
customText:
|
|
4700
|
-
emailProviders:
|
|
4701
|
-
emailTemplates:
|
|
4702
|
-
flows:
|
|
4703
|
-
forms:
|
|
4704
|
-
grants:
|
|
4705
|
-
hookCode:
|
|
4706
|
-
hooks:
|
|
4707
|
-
invites:
|
|
4708
|
-
keys:
|
|
4709
|
-
loginSessions:
|
|
4710
|
-
logs:
|
|
4711
|
-
authenticationMethods:
|
|
4712
|
-
organizations:
|
|
4713
|
-
passwords:
|
|
4714
|
-
promptSettings:
|
|
4715
|
-
proxyRoutes:
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4886
|
+
actions: at(e),
|
|
4887
|
+
actionExecutions: ot(e),
|
|
4888
|
+
actionVersions: ut(e),
|
|
4889
|
+
branding: ft(e),
|
|
4890
|
+
clients: Ct(e),
|
|
4891
|
+
clientConnections: Tt(e),
|
|
4892
|
+
clientGrants: Dt(e),
|
|
4893
|
+
clientRegistrationTokens: Mt(e),
|
|
4894
|
+
codes: It(e),
|
|
4895
|
+
connections: zt(e),
|
|
4896
|
+
customDomains: Vt(e),
|
|
4897
|
+
customText: Ht(e),
|
|
4898
|
+
emailProviders: Ut(e),
|
|
4899
|
+
emailTemplates: Gt(e),
|
|
4900
|
+
flows: qt(e),
|
|
4901
|
+
forms: Xt(e),
|
|
4902
|
+
grants: en(e),
|
|
4903
|
+
hookCode: an(e),
|
|
4904
|
+
hooks: ln(e),
|
|
4905
|
+
invites: pn(e),
|
|
4906
|
+
keys: hn(e),
|
|
4907
|
+
loginSessions: bn(e),
|
|
4908
|
+
logs: Sn(e),
|
|
4909
|
+
authenticationMethods: Dn(e),
|
|
4910
|
+
organizations: jn(e),
|
|
4911
|
+
passwords: Nn(e),
|
|
4912
|
+
promptSettings: Pn(e),
|
|
4913
|
+
proxyRoutes: Rn(e),
|
|
4914
|
+
scimConfigurations: Hn(e),
|
|
4915
|
+
scimTokens: Wn(e),
|
|
4916
|
+
scimExternalIds: Kn(e),
|
|
4917
|
+
refreshTokens: Yn(e),
|
|
4918
|
+
resourceServers: tr(e),
|
|
4919
|
+
rolePermissions: nr(e),
|
|
4920
|
+
userPermissions: rr(e),
|
|
4921
|
+
roles: ar(e),
|
|
4922
|
+
sessions: ur(e),
|
|
4923
|
+
sessionCleanup: Xr(e),
|
|
4924
|
+
tenants: hr(e),
|
|
4724
4925
|
...t.controlPlane ? {
|
|
4725
|
-
tenantOperations:
|
|
4726
|
-
tenantOperationEvents:
|
|
4727
|
-
rollouts:
|
|
4926
|
+
tenantOperations: ei(e),
|
|
4927
|
+
tenantOperationEvents: pi(e),
|
|
4928
|
+
rollouts: gi(e)
|
|
4728
4929
|
} : {},
|
|
4729
|
-
themes:
|
|
4730
|
-
universalLoginTemplates:
|
|
4731
|
-
users:
|
|
4732
|
-
userActivity:
|
|
4733
|
-
userRoles:
|
|
4734
|
-
userOrganizations:
|
|
4735
|
-
stats:
|
|
4736
|
-
analytics:
|
|
4737
|
-
outbox:
|
|
4930
|
+
themes: vr(e),
|
|
4931
|
+
universalLoginTemplates: yr(e),
|
|
4932
|
+
users: Ir(e),
|
|
4933
|
+
userActivity: xr(e),
|
|
4934
|
+
userRoles: Lr(e),
|
|
4935
|
+
userOrganizations: Rr(e),
|
|
4936
|
+
stats: Hr(e),
|
|
4937
|
+
analytics: Jr(e),
|
|
4938
|
+
outbox: wr(e),
|
|
4738
4939
|
async transaction(r) {
|
|
4739
|
-
if (t.useTransactions === !1 ||
|
|
4940
|
+
if (t.useTransactions === !1 || st(e)) return r(n);
|
|
4740
4941
|
await e.run(y`BEGIN`);
|
|
4741
4942
|
try {
|
|
4742
4943
|
let t = await r(n);
|
|
@@ -4750,7 +4951,7 @@ function ai(e, t = { useTransactions: !0 }) {
|
|
|
4750
4951
|
}
|
|
4751
4952
|
//#endregion
|
|
4752
4953
|
//#region src/adapters/resolveHost.ts
|
|
4753
|
-
function
|
|
4954
|
+
function vi(e) {
|
|
4754
4955
|
if (!e) return { path: "/*" };
|
|
4755
4956
|
try {
|
|
4756
4957
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -4758,7 +4959,7 @@ function oi(e) {
|
|
|
4758
4959
|
} catch {}
|
|
4759
4960
|
return { path: "/*" };
|
|
4760
4961
|
}
|
|
4761
|
-
function
|
|
4962
|
+
function yi(e) {
|
|
4762
4963
|
if (!e) return [];
|
|
4763
4964
|
try {
|
|
4764
4965
|
let t = JSON.parse(e);
|
|
@@ -4773,20 +4974,20 @@ function si(e) {
|
|
|
4773
4974
|
return [];
|
|
4774
4975
|
}
|
|
4775
4976
|
}
|
|
4776
|
-
async function
|
|
4977
|
+
async function bi(e, r) {
|
|
4777
4978
|
let i = r.toLowerCase(), o = (await e.select({
|
|
4778
4979
|
custom_domain_id: H.custom_domain_id,
|
|
4779
4980
|
tenant_id: H.tenant_id,
|
|
4780
4981
|
domain: H.domain
|
|
4781
4982
|
}).from(H).where(a(H.domain, i)).limit(1))[0];
|
|
4782
4983
|
if (!o) return null;
|
|
4783
|
-
let s = (await e.select().from(
|
|
4984
|
+
let s = (await e.select().from(X).where(t(a(X.tenant_id, o.tenant_id), a(X.custom_domain_id, o.custom_domain_id))).orderBy(n(X.priority), n(X.created_at))).map((e) => ({
|
|
4784
4985
|
id: e.id,
|
|
4785
4986
|
tenant_id: e.tenant_id,
|
|
4786
4987
|
custom_domain_id: e.custom_domain_id,
|
|
4787
4988
|
priority: e.priority,
|
|
4788
|
-
match:
|
|
4789
|
-
handlers:
|
|
4989
|
+
match: vi(e.match),
|
|
4990
|
+
handlers: yi(e.handlers),
|
|
4790
4991
|
created_at: e.created_at,
|
|
4791
4992
|
updated_at: e.updated_at
|
|
4792
4993
|
}));
|
|
@@ -4799,11 +5000,11 @@ async function ci(e, r) {
|
|
|
4799
5000
|
}
|
|
4800
5001
|
//#endregion
|
|
4801
5002
|
//#region src/adapters/proxyData.ts
|
|
4802
|
-
function
|
|
5003
|
+
function xi(e) {
|
|
4803
5004
|
return {
|
|
4804
|
-
proxyRoutes:
|
|
4805
|
-
resolveHost: (t) =>
|
|
5005
|
+
proxyRoutes: Rn(e),
|
|
5006
|
+
resolveHost: (t) => bi(e, t)
|
|
4806
5007
|
};
|
|
4807
5008
|
}
|
|
4808
5009
|
//#endregion
|
|
4809
|
-
export {
|
|
5010
|
+
export { xi as createProxyDataAdapter, Rn as createProxyRoutesAdapter, _i as default, Ze as sqlite };
|