@authhero/drizzle 1.3.0 → 1.4.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 +1 -1
- package/dist/drizzle-adapter.mjs +702 -685
- package/package.json +3 -3
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 { MONDAY_EPOCH_SHIFT_MS as le, WEEK_MS as ue,
|
|
6
|
-
import { HTTPException as
|
|
5
|
+
import { MONDAY_EPOCH_SHIFT_MS as le, WEEK_MS as ue, buildRefreshTokenRetention as de, buildSessionRetention as fe, clientRegistrationTokenTypeSchema as pe, decodeCursor as me, encodeCursor as he, handlerConfigSchema as ge, isPlainObject as _e, matchSchema as ve, rolloutInsertSchema as ye, rolloutSchema as be, sanitizeLuceneQuery as xe, scimMappingEntrySchema as Se, sessionRetentionWindow as Ce, tenantOperationEventInsertSchema as we, tenantOperationEventSchema as Te, tenantOperationInsertSchema as Ee, tenantOperationSchema as De } from "@authhero/adapter-interfaces";
|
|
6
|
+
import { HTTPException as Oe } from "hono/http-exception";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var ke = Object.defineProperty, Ae = (e, t) => {
|
|
9
9
|
let n = {};
|
|
10
|
-
for (var r in e)
|
|
10
|
+
for (var r in e) ke(n, r, {
|
|
11
11
|
get: e[r],
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
|
-
return t ||
|
|
14
|
+
return t || ke(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 Oe = Object.defineProperty, ke = (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
|
+
}), je = 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 Oe = Object.defineProperty, ke = (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
|
+
]), Me = 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(),
|
|
@@ -175,7 +175,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
175
175
|
password: T("password", { length: 255 }).notNull(),
|
|
176
176
|
algorithm: T("algorithm", { length: 16 }).notNull().default("bcrypt"),
|
|
177
177
|
is_current: S("is_current").notNull().default(1)
|
|
178
|
-
}),
|
|
178
|
+
}), Ne = w("user_activity", {
|
|
179
179
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
180
180
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
181
181
|
last_login: T("last_login", { length: 35 }),
|
|
@@ -292,7 +292,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
292
292
|
}, (e) => [C({
|
|
293
293
|
columns: [e.code_id, e.code_type],
|
|
294
294
|
name: "PK_codes_code_id_code_type"
|
|
295
|
-
}), x("codes_expires_at_index").on(e.expires_at)]),
|
|
295
|
+
}), x("codes_expires_at_index").on(e.expires_at)]), Pe = w("authentication_codes", {
|
|
296
296
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
297
297
|
code: T("code", { length: 255 }).primaryKey(),
|
|
298
298
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -306,7 +306,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
306
306
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
307
307
|
expires_at: T("expires_at", { length: 35 }).notNull(),
|
|
308
308
|
used_at: T("used_at", { length: 35 })
|
|
309
|
-
}),
|
|
309
|
+
}), Fe = w("otps", {
|
|
310
310
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
311
311
|
id: T("id", { length: 255 }).primaryKey(),
|
|
312
312
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -325,7 +325,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
325
325
|
used_at: T("used_at", { length: 35 }),
|
|
326
326
|
audience: T("audience", { length: 255 }),
|
|
327
327
|
ip: T("ip", { length: 64 })
|
|
328
|
-
}, (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)]), Ie = w("tickets", {
|
|
329
329
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
330
330
|
id: T("id", { length: 255 }).primaryKey(),
|
|
331
331
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -445,7 +445,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
445
445
|
}).onDelete("cascade"),
|
|
446
446
|
E("grants_natural_key_idx").on(e.tenant_id, e.user_id, e.client_id, e.audience),
|
|
447
447
|
x("grants_tenant_user_idx").on(e.tenant_id, e.user_id)
|
|
448
|
-
]),
|
|
448
|
+
]), Le = w("connections", {
|
|
449
449
|
id: T("id", { length: 255 }).notNull(),
|
|
450
450
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
451
451
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -464,7 +464,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
464
464
|
C({ columns: [e.tenant_id, e.id] }),
|
|
465
465
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
466
466
|
E("connections_id_unique").on(e.id)
|
|
467
|
-
]),
|
|
467
|
+
]), V = w("custom_domains", {
|
|
468
468
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
469
469
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
470
470
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -478,7 +478,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
478
478
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
479
479
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
480
480
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
481
|
-
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]),
|
|
481
|
+
}, (e) => [E("custom_domains_domain_unique").on(e.domain)]), Re = w("domains", {
|
|
482
482
|
id: T("id", { length: 255 }).primaryKey(),
|
|
483
483
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
484
484
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -511,7 +511,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
511
511
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
512
512
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
513
513
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
514
|
-
]),
|
|
514
|
+
]), ze = w("invites", {
|
|
515
515
|
id: T("id", { length: 21 }).primaryKey(),
|
|
516
516
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
517
517
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -545,7 +545,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
545
545
|
}, (e) => [C({
|
|
546
546
|
columns: [e.tenant_id, e.id],
|
|
547
547
|
name: "roles_pk"
|
|
548
|
-
})]),
|
|
548
|
+
})]), Be = w("role_permissions", {
|
|
549
549
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
550
550
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
551
551
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -563,7 +563,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
563
563
|
}),
|
|
564
564
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
565
565
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
566
|
-
]),
|
|
566
|
+
]), Ve = w("user_permissions", {
|
|
567
567
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
568
568
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
569
569
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -624,7 +624,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
624
624
|
}, (e) => [C({
|
|
625
625
|
columns: [e.tenant_id, e.id],
|
|
626
626
|
name: "resource_servers_pk"
|
|
627
|
-
})]),
|
|
627
|
+
})]), He = w("branding", {
|
|
628
628
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
629
629
|
logo_url: T("logo_url", { length: 512 }),
|
|
630
630
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -635,12 +635,12 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
635
635
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
636
636
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
637
637
|
dark_mode: T("dark_mode", { length: 8 })
|
|
638
|
-
}),
|
|
638
|
+
}), Ue = w("universal_login_templates", {
|
|
639
639
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => k.id, { onDelete: "cascade" }),
|
|
640
640
|
body: T("body").notNull(),
|
|
641
641
|
created_at_ts: S("created_at_ts").notNull(),
|
|
642
642
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
643
|
-
}),
|
|
643
|
+
}), We = w("themes", {
|
|
644
644
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
645
645
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
646
646
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -700,7 +700,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
700
700
|
}, (e) => [C({
|
|
701
701
|
columns: [e.tenant_id, e.themeId],
|
|
702
702
|
name: "themes_pkey"
|
|
703
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
703
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), Ge = w("forms", {
|
|
704
704
|
id: T("id", { length: 255 }).primaryKey(),
|
|
705
705
|
name: T("name", { length: 255 }).notNull(),
|
|
706
706
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
@@ -713,21 +713,21 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
713
713
|
style: T("style", { length: 1042 }),
|
|
714
714
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
715
715
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
716
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
716
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Ke = w("flows", {
|
|
717
717
|
id: T("id", { length: 24 }).primaryKey(),
|
|
718
718
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
719
719
|
name: T("name", { length: 150 }).notNull(),
|
|
720
720
|
actions: T("actions"),
|
|
721
721
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
722
722
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
723
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
723
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), qe = w("prompt_settings", {
|
|
724
724
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
725
725
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
726
726
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
727
727
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
728
728
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
729
729
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
730
|
-
}),
|
|
730
|
+
}), Je = w("email_providers", {
|
|
731
731
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
732
732
|
name: T("name", { length: 255 }).notNull(),
|
|
733
733
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -736,7 +736,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
736
736
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
737
737
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
738
738
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
739
|
-
}),
|
|
739
|
+
}), Ye = w("email_templates", {
|
|
740
740
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
741
741
|
template: T("template", { length: 64 }).notNull(),
|
|
742
742
|
body: T("body").notNull(),
|
|
@@ -749,7 +749,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
749
749
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
750
750
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
751
751
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
752
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
752
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), Xe = w("hooks", {
|
|
753
753
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
754
754
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
755
755
|
url: T("url", { length: 512 }),
|
|
@@ -765,14 +765,14 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
765
765
|
page_id: T("page_id", { length: 64 }),
|
|
766
766
|
permission_required: T("permission_required", { length: 255 }),
|
|
767
767
|
metadata: T("metadata")
|
|
768
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
768
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), Ze = w("hook_code", {
|
|
769
769
|
id: T("id", { length: 21 }).primaryKey(),
|
|
770
770
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
771
771
|
code: T("code").notNull(),
|
|
772
772
|
secrets: T("secrets"),
|
|
773
773
|
created_at_ts: S("created_at_ts").notNull(),
|
|
774
774
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
775
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
775
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), Qe = w("keys", {
|
|
776
776
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
777
777
|
tenant_id: T("tenant_id", { length: 191 }).references(() => k.id, { onDelete: "cascade" }),
|
|
778
778
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -784,8 +784,8 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
784
784
|
current_since: T("current_since", { length: 35 }),
|
|
785
785
|
current_until: T("current_until", { length: 35 }),
|
|
786
786
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
787
|
-
connection: T("connection", { length: 255 }).references(() =>
|
|
788
|
-
}),
|
|
787
|
+
connection: T("connection", { length: 255 }).references(() => Le.id, { onDelete: "cascade" })
|
|
788
|
+
}), $e = w("custom_text", {
|
|
789
789
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => k.id, { onDelete: "cascade" }),
|
|
790
790
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
791
791
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -878,7 +878,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
878
878
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
879
879
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
880
880
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
881
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
881
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), et = w("scim_configurations", {
|
|
882
882
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
883
883
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
884
884
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -898,7 +898,7 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
898
898
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
899
899
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
900
900
|
E("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
901
|
-
]),
|
|
901
|
+
]), tt = w("scim_external_ids", {
|
|
902
902
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
903
903
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
904
904
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -908,53 +908,53 @@ var Oe = Object.defineProperty, ke = (e, t) => {
|
|
|
908
908
|
e.tenant_id,
|
|
909
909
|
e.connection_id,
|
|
910
910
|
e.user_id
|
|
911
|
-
] }), E("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
912
|
-
actionExecutions: () =>
|
|
911
|
+
] }), E("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), nt = /* @__PURE__ */ Ae({
|
|
912
|
+
actionExecutions: () => Me,
|
|
913
913
|
actionVersions: () => A,
|
|
914
|
-
actions: () =>
|
|
915
|
-
authenticationCodes: () =>
|
|
914
|
+
actions: () => je,
|
|
915
|
+
authenticationCodes: () => Pe,
|
|
916
916
|
authenticationMethods: () => q,
|
|
917
|
-
branding: () =>
|
|
917
|
+
branding: () => He,
|
|
918
918
|
clientGrants: () => z,
|
|
919
919
|
clientRegistrationTokens: () => R,
|
|
920
920
|
clients: () => L,
|
|
921
921
|
codes: () => I,
|
|
922
|
-
connections: () =>
|
|
923
|
-
customDomains: () =>
|
|
924
|
-
customText: () =>
|
|
925
|
-
domains: () =>
|
|
926
|
-
emailProviders: () =>
|
|
927
|
-
emailTemplates: () =>
|
|
928
|
-
flows: () =>
|
|
929
|
-
forms: () =>
|
|
922
|
+
connections: () => Le,
|
|
923
|
+
customDomains: () => V,
|
|
924
|
+
customText: () => $e,
|
|
925
|
+
domains: () => Re,
|
|
926
|
+
emailProviders: () => Je,
|
|
927
|
+
emailTemplates: () => Ye,
|
|
928
|
+
flows: () => Ke,
|
|
929
|
+
forms: () => Ge,
|
|
930
930
|
grants: () => B,
|
|
931
|
-
hookCode: () =>
|
|
932
|
-
hooks: () =>
|
|
933
|
-
invites: () =>
|
|
934
|
-
keys: () =>
|
|
931
|
+
hookCode: () => Ze,
|
|
932
|
+
hooks: () => Xe,
|
|
933
|
+
invites: () => ze,
|
|
934
|
+
keys: () => Qe,
|
|
935
935
|
loginSessions: () => F,
|
|
936
936
|
logs: () => J,
|
|
937
937
|
organizations: () => H,
|
|
938
|
-
otps: () =>
|
|
938
|
+
otps: () => Fe,
|
|
939
939
|
outboxEvents: () => Y,
|
|
940
940
|
passwords: () => M,
|
|
941
|
-
promptSettings: () =>
|
|
941
|
+
promptSettings: () => qe,
|
|
942
942
|
proxyRoutes: () => X,
|
|
943
943
|
refreshTokens: () => P,
|
|
944
944
|
resourceServers: () => K,
|
|
945
|
-
rolePermissions: () =>
|
|
945
|
+
rolePermissions: () => Be,
|
|
946
946
|
roles: () => W,
|
|
947
|
-
scimConfigurations: () =>
|
|
948
|
-
scimExternalIds: () =>
|
|
947
|
+
scimConfigurations: () => et,
|
|
948
|
+
scimExternalIds: () => tt,
|
|
949
949
|
scimTokens: () => Z,
|
|
950
950
|
sessions: () => N,
|
|
951
951
|
tenants: () => k,
|
|
952
|
-
themes: () =>
|
|
953
|
-
tickets: () =>
|
|
954
|
-
universalLoginTemplates: () =>
|
|
955
|
-
userActivity: () =>
|
|
952
|
+
themes: () => We,
|
|
953
|
+
tickets: () => Ie,
|
|
954
|
+
universalLoginTemplates: () => Ue,
|
|
955
|
+
userActivity: () => Ne,
|
|
956
956
|
userOrganizations: () => U,
|
|
957
|
-
userPermissions: () =>
|
|
957
|
+
userPermissions: () => Ve,
|
|
958
958
|
userRoles: () => G,
|
|
959
959
|
users: () => j
|
|
960
960
|
});
|
|
@@ -969,14 +969,14 @@ function Q(e, t) {
|
|
|
969
969
|
}
|
|
970
970
|
return e;
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function rt(e, t = "", n = {}) {
|
|
973
973
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
974
974
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
975
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
975
|
+
typeof a == "object" && a && !Array.isArray(a) ? rt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
976
976
|
}
|
|
977
977
|
return n;
|
|
978
978
|
}
|
|
979
|
-
function
|
|
979
|
+
function it(e, t) {
|
|
980
980
|
let n = {};
|
|
981
981
|
for (let [r, i] of Object.entries(e)) {
|
|
982
982
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -993,13 +993,13 @@ function rt(e, t) {
|
|
|
993
993
|
}
|
|
994
994
|
//#endregion
|
|
995
995
|
//#region src/helpers/filter.ts
|
|
996
|
-
function
|
|
996
|
+
function at(e) {
|
|
997
997
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
998
998
|
}
|
|
999
|
-
function
|
|
999
|
+
function ot(e) {
|
|
1000
1000
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function st(n, r, i, l = []) {
|
|
1003
1003
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1004
1004
|
let t = Number(e);
|
|
1005
1005
|
return Number.isFinite(t) ? t : e;
|
|
@@ -1011,7 +1011,7 @@ function ot(n, r, i, l = []) {
|
|
|
1011
1011
|
let [, t, r] = n;
|
|
1012
1012
|
if (!t || !r) return null;
|
|
1013
1013
|
let i = t.trim(), o = r.replace(/^"(.*)"$/, "$1").trim(), s = ee[i];
|
|
1014
|
-
return
|
|
1014
|
+
return at(s) ? a(ot(s), ne(o)) : u(s, e) ? b.has(i) ? p(s, `%${o}%`) : a(s, o) : null;
|
|
1015
1015
|
}
|
|
1016
1016
|
return null;
|
|
1017
1017
|
}).filter((e) => e !== null);
|
|
@@ -1040,12 +1040,12 @@ function ot(n, r, i, l = []) {
|
|
|
1040
1040
|
};
|
|
1041
1041
|
}), E = [];
|
|
1042
1042
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of T) if (t) {
|
|
1043
|
-
let i = ee[t], v =
|
|
1043
|
+
let i = ee[t], v = at(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1044
1044
|
if (!te) {
|
|
1045
1045
|
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}`);
|
|
1046
1046
|
continue;
|
|
1047
1047
|
}
|
|
1048
|
-
let S = v ?
|
|
1048
|
+
let S = v ? ot(i) : y`${te}`;
|
|
1049
1049
|
if (o) E.push(r ? f(te) : d(te));
|
|
1050
1050
|
else if (b.has(t) && l === "=") E.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1051
1051
|
else if (r) switch (l) {
|
|
@@ -1089,11 +1089,11 @@ function ot(n, r, i, l = []) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
//#endregion
|
|
1091
1091
|
//#region src/adapters/actions.ts
|
|
1092
|
-
function
|
|
1092
|
+
function ct(e) {
|
|
1093
1093
|
let t = Q(e);
|
|
1094
1094
|
return Array.isArray(t) ? t : [];
|
|
1095
1095
|
}
|
|
1096
|
-
function
|
|
1096
|
+
function lt(e) {
|
|
1097
1097
|
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;
|
|
1098
1098
|
return {
|
|
1099
1099
|
...f,
|
|
@@ -1110,11 +1110,11 @@ function ct(e) {
|
|
|
1110
1110
|
updated_at: new Date(Number(n)).toISOString()
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
|
-
function
|
|
1113
|
+
function ut(e) {
|
|
1114
1114
|
return {
|
|
1115
1115
|
async create(t, n) {
|
|
1116
1116
|
let r = Date.now(), i = `act_${b()}`;
|
|
1117
|
-
return await e.insert(
|
|
1117
|
+
return await e.insert(je).values({
|
|
1118
1118
|
id: i,
|
|
1119
1119
|
tenant_id: t,
|
|
1120
1120
|
name: n.name,
|
|
@@ -1145,28 +1145,28 @@ function lt(e) {
|
|
|
1145
1145
|
};
|
|
1146
1146
|
},
|
|
1147
1147
|
async get(n, r) {
|
|
1148
|
-
let i = await e.select().from(
|
|
1149
|
-
return i ?
|
|
1148
|
+
let i = await e.select().from(je).where(t(a(je.tenant_id, n), a(je.id, r))).get();
|
|
1149
|
+
return i ? lt(i) : null;
|
|
1150
1150
|
},
|
|
1151
1151
|
async list(o, s = {}) {
|
|
1152
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1152
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(je.tenant_id, o)];
|
|
1153
1153
|
if (f) {
|
|
1154
|
-
let e =
|
|
1154
|
+
let e = st(je, f, ["name"]);
|
|
1155
1155
|
e && p.push(e);
|
|
1156
1156
|
}
|
|
1157
|
-
let m = t(...p), h = e.select().from(
|
|
1157
|
+
let m = t(...p), h = e.select().from(je).where(m).$dynamic();
|
|
1158
1158
|
if (d?.sort_by) {
|
|
1159
|
-
let e =
|
|
1159
|
+
let e = je[d.sort_by];
|
|
1160
1160
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1161
1161
|
}
|
|
1162
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1162
|
+
let g = (await h.offset(c * l).limit(l)).map(lt);
|
|
1163
1163
|
if (!u) return {
|
|
1164
1164
|
actions: g,
|
|
1165
1165
|
start: 0,
|
|
1166
1166
|
limit: 0,
|
|
1167
1167
|
length: 0
|
|
1168
1168
|
};
|
|
1169
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1169
|
+
let [_] = await e.select({ count: r() }).from(je).where(m);
|
|
1170
1170
|
return {
|
|
1171
1171
|
actions: g,
|
|
1172
1172
|
start: c * l,
|
|
@@ -1177,7 +1177,7 @@ function lt(e) {
|
|
|
1177
1177
|
async update(n, r, i) {
|
|
1178
1178
|
let o = { updated_at_ts: Date.now() };
|
|
1179
1179
|
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) {
|
|
1180
|
-
let s = await e.select({ secrets:
|
|
1180
|
+
let s = await e.select({ secrets: je.secrets }).from(je).where(t(a(je.tenant_id, n), a(je.id, r))).get(), c = new Map(ct(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1181
1181
|
name: e.name,
|
|
1182
1182
|
value: c.get(e.name)?.value
|
|
1183
1183
|
} : e);
|
|
@@ -1187,21 +1187,21 @@ function lt(e) {
|
|
|
1187
1187
|
let e = new Date(i.deployed_at).getTime();
|
|
1188
1188
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1189
1189
|
}
|
|
1190
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1190
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(je).set(o).where(t(a(je.tenant_id, n), a(je.id, r))).returning()).length > 0;
|
|
1191
1191
|
},
|
|
1192
1192
|
async remove(n, r) {
|
|
1193
|
-
return (await e.delete(
|
|
1193
|
+
return (await e.delete(je).where(t(a(je.tenant_id, n), a(je.id, r))).returning()).length > 0;
|
|
1194
1194
|
}
|
|
1195
1195
|
};
|
|
1196
1196
|
}
|
|
1197
1197
|
//#endregion
|
|
1198
1198
|
//#region src/adapters/actionExecutions.ts
|
|
1199
|
-
var
|
|
1200
|
-
function
|
|
1199
|
+
var dt = 500;
|
|
1200
|
+
function ft(e) {
|
|
1201
1201
|
return {
|
|
1202
1202
|
async create(t, n) {
|
|
1203
1203
|
let r = Date.now();
|
|
1204
|
-
return await e.insert(
|
|
1204
|
+
return await e.insert(Me).values({
|
|
1205
1205
|
id: n.id,
|
|
1206
1206
|
tenant_id: t,
|
|
1207
1207
|
trigger_id: n.trigger_id,
|
|
@@ -1222,7 +1222,7 @@ function dt(e) {
|
|
|
1222
1222
|
};
|
|
1223
1223
|
},
|
|
1224
1224
|
async get(n, r) {
|
|
1225
|
-
let i = await e.select().from(
|
|
1225
|
+
let i = await e.select().from(Me).where(t(a(Me.tenant_id, n), a(Me.id, r))).get();
|
|
1226
1226
|
return i ? {
|
|
1227
1227
|
id: i.id,
|
|
1228
1228
|
tenant_id: i.tenant_id,
|
|
@@ -1239,8 +1239,8 @@ function dt(e) {
|
|
|
1239
1239
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1240
1240
|
let r = 0;
|
|
1241
1241
|
for (;;) {
|
|
1242
|
-
let t = await e.delete(
|
|
1243
|
-
if (r += t.length, t.length <
|
|
1242
|
+
let t = await e.delete(Me).where(y`rowid IN (SELECT rowid FROM ${Me} WHERE ${Me.created_at_ts} < ${n} LIMIT ${dt})`).returning({ id: Me.id });
|
|
1243
|
+
if (r += t.length, t.length < dt) break;
|
|
1244
1244
|
}
|
|
1245
1245
|
return r;
|
|
1246
1246
|
}
|
|
@@ -1248,12 +1248,12 @@ function dt(e) {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
//#endregion
|
|
1250
1250
|
//#region src/adapters/atomic.ts
|
|
1251
|
-
function
|
|
1251
|
+
function pt(e) {
|
|
1252
1252
|
let t = e;
|
|
1253
1253
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1254
1254
|
}
|
|
1255
|
-
async function
|
|
1256
|
-
if (
|
|
1255
|
+
async function mt(e, t) {
|
|
1256
|
+
if (pt(e)) return e.batch(t);
|
|
1257
1257
|
await e.run(y`BEGIN`);
|
|
1258
1258
|
try {
|
|
1259
1259
|
let n = [];
|
|
@@ -1270,7 +1270,7 @@ async function pt(e, t) {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
//#endregion
|
|
1272
1272
|
//#region src/adapters/actionVersions.ts
|
|
1273
|
-
function
|
|
1273
|
+
function ht(e) {
|
|
1274
1274
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1275
1275
|
return {
|
|
1276
1276
|
...c,
|
|
@@ -1283,7 +1283,7 @@ function mt(e) {
|
|
|
1283
1283
|
updated_at: new Date(Number(n)).toISOString()
|
|
1284
1284
|
};
|
|
1285
1285
|
}
|
|
1286
|
-
function
|
|
1286
|
+
function gt(e) {
|
|
1287
1287
|
return {
|
|
1288
1288
|
async create(n, r) {
|
|
1289
1289
|
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({
|
|
@@ -1300,7 +1300,7 @@ function ht(e) {
|
|
|
1300
1300
|
created_at_ts: o,
|
|
1301
1301
|
updated_at_ts: o
|
|
1302
1302
|
});
|
|
1303
|
-
return await
|
|
1303
|
+
return await mt(e, c ? [e.update(A).set({
|
|
1304
1304
|
deployed: 0,
|
|
1305
1305
|
updated_at_ts: o
|
|
1306
1306
|
}).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id), a(A.deployed, 1))), u] : [u]), {
|
|
@@ -1320,10 +1320,10 @@ function ht(e) {
|
|
|
1320
1320
|
},
|
|
1321
1321
|
async get(n, r, i) {
|
|
1322
1322
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.action_id, r), a(A.id, i))).get();
|
|
1323
|
-
return o ?
|
|
1323
|
+
return o ? ht(o) : null;
|
|
1324
1324
|
},
|
|
1325
1325
|
async list(n, o, s = {}) {
|
|
1326
|
-
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(
|
|
1326
|
+
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(ht);
|
|
1327
1327
|
if (!u) return {
|
|
1328
1328
|
versions: f,
|
|
1329
1329
|
start: 0,
|
|
@@ -1345,13 +1345,13 @@ function ht(e) {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
//#endregion
|
|
1347
1347
|
//#region src/adapters/branding.ts
|
|
1348
|
-
function
|
|
1348
|
+
function _t(e) {
|
|
1349
1349
|
return e === "dark" || e === "light" || e === "auto";
|
|
1350
1350
|
}
|
|
1351
|
-
function
|
|
1351
|
+
function vt(e) {
|
|
1352
1352
|
return {
|
|
1353
1353
|
async get(t) {
|
|
1354
|
-
let n = await e.select().from(
|
|
1354
|
+
let n = await e.select().from(He).where(a(He.tenant_id, t)).get();
|
|
1355
1355
|
if (!n) return null;
|
|
1356
1356
|
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;
|
|
1357
1357
|
return O({
|
|
@@ -1366,7 +1366,7 @@ function _t(e) {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
},
|
|
1368
1368
|
font: u ? { url: u } : void 0,
|
|
1369
|
-
dark_mode:
|
|
1369
|
+
dark_mode: _t(d) ? d : void 0
|
|
1370
1370
|
});
|
|
1371
1371
|
},
|
|
1372
1372
|
async set(t, n) {
|
|
@@ -1380,11 +1380,11 @@ function _t(e) {
|
|
|
1380
1380
|
font_url: i?.url,
|
|
1381
1381
|
dark_mode: a
|
|
1382
1382
|
};
|
|
1383
|
-
await e.insert(
|
|
1383
|
+
await e.insert(He).values({
|
|
1384
1384
|
tenant_id: t,
|
|
1385
1385
|
...l
|
|
1386
1386
|
}).onConflictDoUpdate({
|
|
1387
|
-
target:
|
|
1387
|
+
target: He.tenant_id,
|
|
1388
1388
|
set: l
|
|
1389
1389
|
});
|
|
1390
1390
|
}
|
|
@@ -1392,30 +1392,30 @@ function _t(e) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
//#endregion
|
|
1394
1394
|
//#region src/helpers/paginate.ts
|
|
1395
|
-
function
|
|
1395
|
+
function yt(e) {
|
|
1396
1396
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1397
1397
|
}
|
|
1398
|
-
function
|
|
1398
|
+
function bt(e) {
|
|
1399
1399
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1400
1400
|
return n >= 1 ? n : 50;
|
|
1401
1401
|
}
|
|
1402
|
-
function
|
|
1402
|
+
function xt(e) {
|
|
1403
1403
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1404
1404
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1405
1405
|
}
|
|
1406
|
-
function
|
|
1407
|
-
let n = e?.from ?
|
|
1406
|
+
function St(e, t) {
|
|
1407
|
+
let n = e?.from ? me(e.from) : null;
|
|
1408
1408
|
if (!n) return;
|
|
1409
|
-
if (n.k !== t.sortKey) throw new
|
|
1409
|
+
if (n.k !== t.sortKey) throw new Oe(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
1410
1410
|
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1411
1411
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1412
1412
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1413
1413
|
}
|
|
1414
|
-
function
|
|
1414
|
+
function Ct(e, t, n, r = "id", i) {
|
|
1415
1415
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1416
1416
|
if (a && c) {
|
|
1417
1417
|
let e = c[n];
|
|
1418
|
-
s =
|
|
1418
|
+
s = he({
|
|
1419
1419
|
s: typeof e == "string" || typeof e == "number" || e === null ? e : String(e),
|
|
1420
1420
|
i: String(c[r]),
|
|
1421
1421
|
...i !== void 0 && { k: i }
|
|
@@ -1428,7 +1428,7 @@ function St(e, t, n, r = "id", i) {
|
|
|
1428
1428
|
}
|
|
1429
1429
|
//#endregion
|
|
1430
1430
|
//#region src/adapters/clients.ts
|
|
1431
|
-
var
|
|
1431
|
+
var wt = [
|
|
1432
1432
|
"global",
|
|
1433
1433
|
"is_first_party",
|
|
1434
1434
|
"oidc_conformant",
|
|
@@ -1440,7 +1440,7 @@ var Ct = [
|
|
|
1440
1440
|
"require_pushed_authorization_requests",
|
|
1441
1441
|
"require_proof_of_possession",
|
|
1442
1442
|
"hide_sign_up_disabled_error"
|
|
1443
|
-
],
|
|
1443
|
+
], Tt = [
|
|
1444
1444
|
"callbacks",
|
|
1445
1445
|
"allowed_origins",
|
|
1446
1446
|
"web_origins",
|
|
@@ -1449,7 +1449,7 @@ var Ct = [
|
|
|
1449
1449
|
"allowed_logout_urls",
|
|
1450
1450
|
"grant_types",
|
|
1451
1451
|
"signing_keys"
|
|
1452
|
-
],
|
|
1452
|
+
], Et = [
|
|
1453
1453
|
"session_transfer",
|
|
1454
1454
|
"oidc_logout",
|
|
1455
1455
|
"jwt_configuration",
|
|
@@ -1465,21 +1465,21 @@ var Ct = [
|
|
|
1465
1465
|
"token_quota",
|
|
1466
1466
|
"registration_metadata"
|
|
1467
1467
|
];
|
|
1468
|
-
function
|
|
1468
|
+
function Dt(e) {
|
|
1469
1469
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1470
|
-
for (let e of
|
|
1471
|
-
for (let e of
|
|
1472
|
-
for (let e of
|
|
1470
|
+
for (let e of wt) i[e] = !!r[e];
|
|
1471
|
+
for (let e of Tt) i[e] = Q(r[e], []);
|
|
1472
|
+
for (let e of Et) i[e] = Q(r[e], {});
|
|
1473
1473
|
return i.connections = Q(n, []), O(i);
|
|
1474
1474
|
}
|
|
1475
|
-
function
|
|
1475
|
+
function Ot(e) {
|
|
1476
1476
|
let t = { ...e };
|
|
1477
|
-
re(e,
|
|
1478
|
-
for (let n of
|
|
1479
|
-
for (let n of
|
|
1477
|
+
re(e, wt, t);
|
|
1478
|
+
for (let n of Tt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1479
|
+
for (let n of Et) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1480
1480
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), se(t);
|
|
1481
1481
|
}
|
|
1482
|
-
function
|
|
1482
|
+
function kt(e) {
|
|
1483
1483
|
return {
|
|
1484
1484
|
async create(t, n) {
|
|
1485
1485
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1503,51 +1503,51 @@ function Ot(e) {
|
|
|
1503
1503
|
created_at: r,
|
|
1504
1504
|
updated_at: r
|
|
1505
1505
|
};
|
|
1506
|
-
for (let e of
|
|
1506
|
+
for (let e of wt) i[e] = n[e] ?? !1;
|
|
1507
1507
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1508
|
-
for (let e of
|
|
1509
|
-
for (let e of
|
|
1508
|
+
for (let e of Tt) i[e] = n[e] || [];
|
|
1509
|
+
for (let e of Et) i[e] = n[e] || {};
|
|
1510
1510
|
i.connections = n.connections || [];
|
|
1511
|
-
let a =
|
|
1511
|
+
let a = Ot(i);
|
|
1512
1512
|
try {
|
|
1513
1513
|
await e.insert(L).values({
|
|
1514
1514
|
...a,
|
|
1515
1515
|
tenant_id: t
|
|
1516
1516
|
});
|
|
1517
1517
|
} catch (e) {
|
|
1518
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1518
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Oe(409, { message: "Client already exists" }) : e;
|
|
1519
1519
|
}
|
|
1520
|
-
return
|
|
1520
|
+
return Dt({
|
|
1521
1521
|
...a,
|
|
1522
1522
|
tenant_id: t
|
|
1523
1523
|
});
|
|
1524
1524
|
},
|
|
1525
1525
|
async get(n, r) {
|
|
1526
1526
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1527
|
-
return i ?
|
|
1527
|
+
return i ? Dt(i) : null;
|
|
1528
1528
|
},
|
|
1529
1529
|
async getByClientId(t) {
|
|
1530
1530
|
let n = await e.select().from(L).where(a(L.client_id, t)).get();
|
|
1531
1531
|
return n ? {
|
|
1532
|
-
...
|
|
1532
|
+
...Dt(n),
|
|
1533
1533
|
tenant_id: n.tenant_id
|
|
1534
1534
|
} : null;
|
|
1535
1535
|
},
|
|
1536
1536
|
async update(n, r, i) {
|
|
1537
|
-
let o =
|
|
1537
|
+
let o = Ot({
|
|
1538
1538
|
...i,
|
|
1539
1539
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1540
1540
|
});
|
|
1541
1541
|
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;
|
|
1542
1542
|
},
|
|
1543
1543
|
async list(o, s) {
|
|
1544
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1545
|
-
if (
|
|
1544
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(L, f, ["name", "client_id"]) : void 0, m = p ? t(a(L.tenant_id, o), p) : a(L.tenant_id, o);
|
|
1545
|
+
if (yt(s)) {
|
|
1546
1546
|
let n = {
|
|
1547
1547
|
sortColumn: L.created_at,
|
|
1548
1548
|
idColumn: L.client_id,
|
|
1549
1549
|
sortOrder: "desc"
|
|
1550
|
-
}, r =
|
|
1550
|
+
}, r = St(s, n), i = bt(s), { rows: a, next: o } = Ct(await e.select().from(L).where(r ? t(m, r) : m).orderBy(...xt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Dt);
|
|
1551
1551
|
return {
|
|
1552
1552
|
clients: c,
|
|
1553
1553
|
totals: {
|
|
@@ -1563,7 +1563,7 @@ function Ot(e) {
|
|
|
1563
1563
|
let e = L[d.sort_by];
|
|
1564
1564
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1565
1565
|
}
|
|
1566
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1566
|
+
let g = (await h.offset(c * l).limit(l)).map(Dt);
|
|
1567
1567
|
if (!u) return { clients: g };
|
|
1568
1568
|
let [_] = await e.select({ count: r() }).from(L).where(m);
|
|
1569
1569
|
return {
|
|
@@ -1583,7 +1583,7 @@ function Ot(e) {
|
|
|
1583
1583
|
}
|
|
1584
1584
|
//#endregion
|
|
1585
1585
|
//#region src/adapters/clientConnections.ts
|
|
1586
|
-
function
|
|
1586
|
+
function At(e) {
|
|
1587
1587
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1588
1588
|
return O({
|
|
1589
1589
|
...a,
|
|
@@ -1592,14 +1592,14 @@ function kt(e) {
|
|
|
1592
1592
|
is_system: n ? !0 : void 0
|
|
1593
1593
|
});
|
|
1594
1594
|
}
|
|
1595
|
-
function
|
|
1595
|
+
function jt(e) {
|
|
1596
1596
|
return {
|
|
1597
1597
|
async listByClient(n, r) {
|
|
1598
1598
|
let i = await e.select({ connections: L.connections }).from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1599
1599
|
if (!i) return [];
|
|
1600
1600
|
let o = Q(i.connections, []) || [];
|
|
1601
1601
|
if (o.length === 0) return [];
|
|
1602
|
-
let s = (await e.select().from(
|
|
1602
|
+
let s = (await e.select().from(Le).where(t(a(Le.tenant_id, n), l(Le.id, o))).all()).map(At);
|
|
1603
1603
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1604
1604
|
},
|
|
1605
1605
|
async updateByClient(n, r, i) {
|
|
@@ -1636,7 +1636,7 @@ function At(e) {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
//#endregion
|
|
1638
1638
|
//#region src/adapters/clientGrants.ts
|
|
1639
|
-
function
|
|
1639
|
+
function Mt(e) {
|
|
1640
1640
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1641
1641
|
return O({
|
|
1642
1642
|
...o,
|
|
@@ -1646,7 +1646,7 @@ function jt(e) {
|
|
|
1646
1646
|
is_system: !!a
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
|
-
function
|
|
1649
|
+
function Nt(e) {
|
|
1650
1650
|
return {
|
|
1651
1651
|
async create(t, n) {
|
|
1652
1652
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1663,14 +1663,14 @@ function Mt(e) {
|
|
|
1663
1663
|
created_at: r,
|
|
1664
1664
|
updated_at: r
|
|
1665
1665
|
};
|
|
1666
|
-
return await e.insert(z).values(i),
|
|
1666
|
+
return await e.insert(z).values(i), Mt({
|
|
1667
1667
|
...i,
|
|
1668
1668
|
tenant_id: t
|
|
1669
1669
|
});
|
|
1670
1670
|
},
|
|
1671
1671
|
async get(n, r) {
|
|
1672
1672
|
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1673
|
-
return i ?
|
|
1673
|
+
return i ? Mt(i) : null;
|
|
1674
1674
|
},
|
|
1675
1675
|
async update(n, r, i) {
|
|
1676
1676
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1680,13 +1680,13 @@ function Mt(e) {
|
|
|
1680
1680
|
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;
|
|
1681
1681
|
},
|
|
1682
1682
|
async list(o, s) {
|
|
1683
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1684
|
-
if (
|
|
1683
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(z, f, ["client_id", "audience"]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o);
|
|
1684
|
+
if (yt(s)) {
|
|
1685
1685
|
let n = {
|
|
1686
1686
|
sortColumn: z.created_at,
|
|
1687
1687
|
idColumn: z.id,
|
|
1688
1688
|
sortOrder: "desc"
|
|
1689
|
-
}, r =
|
|
1689
|
+
}, r = St(s, n), i = bt(s), { rows: a, next: o } = Ct(await e.select().from(z).where(r ? t(m, r) : m).orderBy(...xt(n)).limit(i + 1), i, "created_at"), c = a.map(Mt);
|
|
1690
1690
|
return {
|
|
1691
1691
|
client_grants: c,
|
|
1692
1692
|
start: 0,
|
|
@@ -1700,7 +1700,7 @@ function Mt(e) {
|
|
|
1700
1700
|
let e = z[d.sort_by];
|
|
1701
1701
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1702
1702
|
} else h = h.orderBy(n(z.created_at));
|
|
1703
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1703
|
+
let g = (await h.offset(c * l).limit(l)).map(Mt);
|
|
1704
1704
|
if (!u) return { client_grants: g };
|
|
1705
1705
|
let [_] = await e.select({ count: r() }).from(z).where(m);
|
|
1706
1706
|
return {
|
|
@@ -1717,36 +1717,36 @@ function Mt(e) {
|
|
|
1717
1717
|
}
|
|
1718
1718
|
//#endregion
|
|
1719
1719
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1720
|
-
function
|
|
1720
|
+
function Pt(e) {
|
|
1721
1721
|
if (!e) return;
|
|
1722
1722
|
let t = JSON.parse(e);
|
|
1723
|
-
return
|
|
1723
|
+
return _e(t) ? t : void 0;
|
|
1724
1724
|
}
|
|
1725
|
-
function
|
|
1725
|
+
function Ft(e) {
|
|
1726
1726
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1727
1727
|
}
|
|
1728
|
-
function
|
|
1728
|
+
function It(e) {
|
|
1729
1729
|
if (!e) return null;
|
|
1730
1730
|
let t = new Date(e);
|
|
1731
1731
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1732
1732
|
}
|
|
1733
|
-
function
|
|
1734
|
-
let t =
|
|
1733
|
+
function Lt(e) {
|
|
1734
|
+
let t = pe.parse(e.type);
|
|
1735
1735
|
return {
|
|
1736
1736
|
id: e.id,
|
|
1737
1737
|
token_hash: e.token_hash,
|
|
1738
1738
|
type: t,
|
|
1739
1739
|
client_id: e.client_id ?? void 0,
|
|
1740
1740
|
sub: e.sub ?? void 0,
|
|
1741
|
-
constraints:
|
|
1741
|
+
constraints: Pt(e.constraints),
|
|
1742
1742
|
single_use: !!e.single_use,
|
|
1743
|
-
expires_at:
|
|
1744
|
-
used_at:
|
|
1745
|
-
revoked_at:
|
|
1743
|
+
expires_at: Ft(e.expires_at_ts),
|
|
1744
|
+
used_at: Ft(e.used_at_ts),
|
|
1745
|
+
revoked_at: Ft(e.revoked_at_ts),
|
|
1746
1746
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1747
1747
|
};
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function Rt(e) {
|
|
1750
1750
|
return {
|
|
1751
1751
|
async create(t, n) {
|
|
1752
1752
|
let r = Date.now();
|
|
@@ -1759,7 +1759,7 @@ function Lt(e) {
|
|
|
1759
1759
|
sub: n.sub ?? null,
|
|
1760
1760
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1761
1761
|
single_use: +!!n.single_use,
|
|
1762
|
-
expires_at_ts:
|
|
1762
|
+
expires_at_ts: It(n.expires_at),
|
|
1763
1763
|
created_at_ts: r
|
|
1764
1764
|
}), {
|
|
1765
1765
|
id: n.id,
|
|
@@ -1775,23 +1775,23 @@ function Lt(e) {
|
|
|
1775
1775
|
},
|
|
1776
1776
|
async get(n, r) {
|
|
1777
1777
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1778
|
-
return i ?
|
|
1778
|
+
return i ? Lt(i) : null;
|
|
1779
1779
|
},
|
|
1780
1780
|
async getByHash(n, r) {
|
|
1781
1781
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.token_hash, r))).get();
|
|
1782
|
-
return i ?
|
|
1782
|
+
return i ? Lt(i) : null;
|
|
1783
1783
|
},
|
|
1784
1784
|
async listByClient(n, r) {
|
|
1785
|
-
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(
|
|
1785
|
+
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(Lt);
|
|
1786
1786
|
},
|
|
1787
1787
|
async markUsed(n, r, i) {
|
|
1788
|
-
return (await e.update(R).set({ used_at_ts:
|
|
1788
|
+
return (await e.update(R).set({ used_at_ts: It(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.used_at_ts))).returning()).length > 0;
|
|
1789
1789
|
},
|
|
1790
1790
|
async revoke(n, r, i) {
|
|
1791
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1791
|
+
return (await e.update(R).set({ revoked_at_ts: It(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.revoked_at_ts))).returning()).length > 0;
|
|
1792
1792
|
},
|
|
1793
1793
|
async revokeByClient(n, r, i) {
|
|
1794
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1794
|
+
return (await e.update(R).set({ revoked_at_ts: It(i) }).where(t(a(R.tenant_id, n), a(R.client_id, r), f(R.revoked_at_ts))).returning()).length;
|
|
1795
1795
|
},
|
|
1796
1796
|
async remove(n, r) {
|
|
1797
1797
|
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
@@ -1800,12 +1800,12 @@ function Lt(e) {
|
|
|
1800
1800
|
}
|
|
1801
1801
|
//#endregion
|
|
1802
1802
|
//#region src/adapters/codes.ts
|
|
1803
|
-
var
|
|
1804
|
-
function
|
|
1803
|
+
var zt = ["code_id", "login_id"], Bt = 500;
|
|
1804
|
+
function Vt(e) {
|
|
1805
1805
|
let { tenant_id: t, ...n } = e;
|
|
1806
1806
|
return O(n);
|
|
1807
1807
|
}
|
|
1808
|
-
function
|
|
1808
|
+
function Ht(e) {
|
|
1809
1809
|
return {
|
|
1810
1810
|
async create(t, n) {
|
|
1811
1811
|
let r = {
|
|
@@ -1814,18 +1814,18 @@ function Vt(e) {
|
|
|
1814
1814
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1815
1815
|
expires_at: n.expires_at
|
|
1816
1816
|
};
|
|
1817
|
-
return await e.insert(I).values(r),
|
|
1817
|
+
return await e.insert(I).values(r), Vt(r);
|
|
1818
1818
|
},
|
|
1819
1819
|
async get(n, r, i) {
|
|
1820
1820
|
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();
|
|
1821
|
-
return s ?
|
|
1821
|
+
return s ? Vt(s) : null;
|
|
1822
1822
|
},
|
|
1823
1823
|
async list(o, s) {
|
|
1824
1824
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(I.tenant_id, o)];
|
|
1825
1825
|
if (f) {
|
|
1826
|
-
let e =
|
|
1826
|
+
let e = xe(f, zt);
|
|
1827
1827
|
if (e) {
|
|
1828
|
-
let t =
|
|
1828
|
+
let t = st(I, e, zt);
|
|
1829
1829
|
t && p.push(t);
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
@@ -1834,7 +1834,7 @@ function Vt(e) {
|
|
|
1834
1834
|
let e = I[d.sort_by];
|
|
1835
1835
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1836
1836
|
}
|
|
1837
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1837
|
+
let g = (await h.offset(c * l).limit(l)).map(Vt);
|
|
1838
1838
|
if (!u) return { codes: g };
|
|
1839
1839
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1840
1840
|
return {
|
|
@@ -1856,8 +1856,8 @@ function Vt(e) {
|
|
|
1856
1856
|
async cleanup(t) {
|
|
1857
1857
|
let n = 0;
|
|
1858
1858
|
for (;;) {
|
|
1859
|
-
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${
|
|
1860
|
-
if (n += r.length, r.length <
|
|
1859
|
+
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${Bt})`).returning({ code_id: I.code_id });
|
|
1860
|
+
if (n += r.length, r.length < Bt) break;
|
|
1861
1861
|
}
|
|
1862
1862
|
return n;
|
|
1863
1863
|
}
|
|
@@ -1865,10 +1865,10 @@ function Vt(e) {
|
|
|
1865
1865
|
}
|
|
1866
1866
|
//#endregion
|
|
1867
1867
|
//#region src/adapters/connections.ts
|
|
1868
|
-
function
|
|
1868
|
+
function Ut() {
|
|
1869
1869
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1870
1870
|
}
|
|
1871
|
-
function
|
|
1871
|
+
function Wt(e) {
|
|
1872
1872
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1873
1873
|
return O({
|
|
1874
1874
|
...a,
|
|
@@ -1877,11 +1877,11 @@ function Ut(e) {
|
|
|
1877
1877
|
is_system: n ? !0 : void 0
|
|
1878
1878
|
});
|
|
1879
1879
|
}
|
|
1880
|
-
function
|
|
1880
|
+
function Gt(e) {
|
|
1881
1881
|
return {
|
|
1882
1882
|
async create(t, n) {
|
|
1883
1883
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1884
|
-
id: n.id ||
|
|
1884
|
+
id: n.id || Ut(),
|
|
1885
1885
|
...n,
|
|
1886
1886
|
tenant_id: t,
|
|
1887
1887
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1891,34 +1891,34 @@ function Wt(e) {
|
|
|
1891
1891
|
updated_at: r
|
|
1892
1892
|
};
|
|
1893
1893
|
try {
|
|
1894
|
-
await e.insert(
|
|
1894
|
+
await e.insert(Le).values(i);
|
|
1895
1895
|
} catch (e) {
|
|
1896
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1896
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Oe(409, { message: "Connection already exists" }) : e;
|
|
1897
1897
|
}
|
|
1898
|
-
return
|
|
1898
|
+
return Wt(i);
|
|
1899
1899
|
},
|
|
1900
1900
|
async get(n, r) {
|
|
1901
|
-
let i = await e.select().from(
|
|
1902
|
-
return i ?
|
|
1901
|
+
let i = await e.select().from(Le).where(t(a(Le.tenant_id, n), a(Le.id, r))).get();
|
|
1902
|
+
return i ? Wt(i) : null;
|
|
1903
1903
|
},
|
|
1904
1904
|
async update(n, r, i) {
|
|
1905
1905
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1906
|
-
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(
|
|
1906
|
+
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(Le).set(o).where(t(a(Le.tenant_id, n), a(Le.id, r))), !0;
|
|
1907
1907
|
},
|
|
1908
1908
|
async list(o, s) {
|
|
1909
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(
|
|
1909
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(Le.tenant_id, o);
|
|
1910
1910
|
if (f) {
|
|
1911
|
-
let e =
|
|
1911
|
+
let e = st(Le, f, ["name"]);
|
|
1912
1912
|
e && (p = t(p, e));
|
|
1913
1913
|
}
|
|
1914
|
-
let m = e.select().from(
|
|
1914
|
+
let m = e.select().from(Le).where(p).$dynamic();
|
|
1915
1915
|
if (d?.sort_by) {
|
|
1916
|
-
let e =
|
|
1916
|
+
let e = Le[d.sort_by];
|
|
1917
1917
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1918
1918
|
}
|
|
1919
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1919
|
+
let h = (await m.offset(c * l).limit(l)).map(Wt);
|
|
1920
1920
|
if (!u) return { connections: h };
|
|
1921
|
-
let [g] = await e.select({ count: r() }).from(
|
|
1921
|
+
let [g] = await e.select({ count: r() }).from(Le).where(p);
|
|
1922
1922
|
return {
|
|
1923
1923
|
connections: h,
|
|
1924
1924
|
start: c * l,
|
|
@@ -1927,13 +1927,13 @@ function Wt(e) {
|
|
|
1927
1927
|
};
|
|
1928
1928
|
},
|
|
1929
1929
|
async remove(n, r) {
|
|
1930
|
-
return (await e.delete(
|
|
1930
|
+
return (await e.delete(Le).where(t(a(Le.tenant_id, n), a(Le.id, r))).returning()).length > 0;
|
|
1931
1931
|
}
|
|
1932
1932
|
};
|
|
1933
1933
|
}
|
|
1934
1934
|
//#endregion
|
|
1935
1935
|
//#region src/adapters/customDomains.ts
|
|
1936
|
-
function
|
|
1936
|
+
function Kt(e) {
|
|
1937
1937
|
let { tenant_id: t, domain_metadata: n, ...r } = e;
|
|
1938
1938
|
return O({
|
|
1939
1939
|
...r,
|
|
@@ -1941,7 +1941,7 @@ function Gt(e) {
|
|
|
1941
1941
|
domain_metadata: Q(n)
|
|
1942
1942
|
});
|
|
1943
1943
|
}
|
|
1944
|
-
function
|
|
1944
|
+
function qt(e) {
|
|
1945
1945
|
return {
|
|
1946
1946
|
async create(t, n) {
|
|
1947
1947
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1959,40 +1959,40 @@ function Kt(e) {
|
|
|
1959
1959
|
created_at: r,
|
|
1960
1960
|
updated_at: r
|
|
1961
1961
|
};
|
|
1962
|
-
return await e.insert(
|
|
1962
|
+
return await e.insert(V).values(i), Kt({
|
|
1963
1963
|
...i,
|
|
1964
1964
|
tenant_id: t
|
|
1965
1965
|
});
|
|
1966
1966
|
},
|
|
1967
1967
|
async get(n, r) {
|
|
1968
|
-
let i = await e.select().from(
|
|
1969
|
-
return i ?
|
|
1968
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).get();
|
|
1969
|
+
return i ? Kt(i) : null;
|
|
1970
1970
|
},
|
|
1971
1971
|
async getByDomain(t) {
|
|
1972
|
-
let n = await e.select().from(
|
|
1972
|
+
let n = await e.select().from(V).where(a(V.domain, t)).get();
|
|
1973
1973
|
return n ? {
|
|
1974
|
-
...
|
|
1974
|
+
...Kt(n),
|
|
1975
1975
|
tenant_id: n.tenant_id
|
|
1976
1976
|
} : null;
|
|
1977
1977
|
},
|
|
1978
1978
|
async list(t) {
|
|
1979
|
-
return (await e.select().from(
|
|
1979
|
+
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map(Kt);
|
|
1980
1980
|
},
|
|
1981
1981
|
async update(n, r, i) {
|
|
1982
1982
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1983
|
-
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = i.verification), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(
|
|
1983
|
+
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = i.verification), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(V).set(o).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1984
1984
|
},
|
|
1985
1985
|
async remove(n, r) {
|
|
1986
|
-
return (await e.delete(
|
|
1986
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1987
1987
|
}
|
|
1988
1988
|
};
|
|
1989
1989
|
}
|
|
1990
1990
|
//#endregion
|
|
1991
1991
|
//#region src/adapters/customText.ts
|
|
1992
|
-
function
|
|
1992
|
+
function Jt(e) {
|
|
1993
1993
|
return {
|
|
1994
1994
|
async get(n, r, i) {
|
|
1995
|
-
let o = await e.select().from(
|
|
1995
|
+
let o = await e.select().from($e).where(t(a($e.tenant_id, n), a($e.prompt, r), a($e.language, i))).get();
|
|
1996
1996
|
if (!o) return null;
|
|
1997
1997
|
try {
|
|
1998
1998
|
return JSON.parse(o.custom_text);
|
|
@@ -2002,7 +2002,7 @@ function qt(e) {
|
|
|
2002
2002
|
},
|
|
2003
2003
|
async set(t, n, r, i) {
|
|
2004
2004
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2005
|
-
await e.insert(
|
|
2005
|
+
await e.insert($e).values({
|
|
2006
2006
|
tenant_id: t,
|
|
2007
2007
|
prompt: n,
|
|
2008
2008
|
language: r,
|
|
@@ -2011,9 +2011,9 @@ function qt(e) {
|
|
|
2011
2011
|
updated_at_ts: a
|
|
2012
2012
|
}).onConflictDoUpdate({
|
|
2013
2013
|
target: [
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2014
|
+
$e.tenant_id,
|
|
2015
|
+
$e.prompt,
|
|
2016
|
+
$e.language
|
|
2017
2017
|
],
|
|
2018
2018
|
set: {
|
|
2019
2019
|
custom_text: o,
|
|
@@ -2022,23 +2022,23 @@ function qt(e) {
|
|
|
2022
2022
|
});
|
|
2023
2023
|
},
|
|
2024
2024
|
async delete(n, r, i) {
|
|
2025
|
-
await e.delete(
|
|
2025
|
+
await e.delete($e).where(t(a($e.tenant_id, n), a($e.prompt, r), a($e.language, i)));
|
|
2026
2026
|
},
|
|
2027
2027
|
async list(t) {
|
|
2028
2028
|
return await e.select({
|
|
2029
|
-
prompt:
|
|
2030
|
-
language:
|
|
2031
|
-
}).from(
|
|
2029
|
+
prompt: $e.prompt,
|
|
2030
|
+
language: $e.language
|
|
2031
|
+
}).from($e).where(a($e.tenant_id, t)).all();
|
|
2032
2032
|
}
|
|
2033
2033
|
};
|
|
2034
2034
|
}
|
|
2035
2035
|
//#endregion
|
|
2036
2036
|
//#region src/adapters/emailProviders.ts
|
|
2037
|
-
function
|
|
2037
|
+
function Yt(e) {
|
|
2038
2038
|
return {
|
|
2039
2039
|
async create(t, n) {
|
|
2040
2040
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2041
|
-
await e.insert(
|
|
2041
|
+
await e.insert(Je).values({
|
|
2042
2042
|
tenant_id: t,
|
|
2043
2043
|
name: n.name,
|
|
2044
2044
|
enabled: n.enabled,
|
|
@@ -2050,7 +2050,7 @@ function Jt(e) {
|
|
|
2050
2050
|
});
|
|
2051
2051
|
},
|
|
2052
2052
|
async get(t) {
|
|
2053
|
-
let n = await e.select().from(
|
|
2053
|
+
let n = await e.select().from(Je).where(a(Je.tenant_id, t)).get();
|
|
2054
2054
|
if (!n) return null;
|
|
2055
2055
|
let { tenant_id: r, ...i } = n;
|
|
2056
2056
|
return O({
|
|
@@ -2062,16 +2062,16 @@ function Jt(e) {
|
|
|
2062
2062
|
},
|
|
2063
2063
|
async update(t, n) {
|
|
2064
2064
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2065
|
-
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(
|
|
2065
|
+
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(Je).set(r).where(a(Je.tenant_id, t));
|
|
2066
2066
|
},
|
|
2067
2067
|
async remove(t) {
|
|
2068
|
-
await e.delete(
|
|
2068
|
+
await e.delete(Je).where(a(Je.tenant_id, t));
|
|
2069
2069
|
}
|
|
2070
2070
|
};
|
|
2071
2071
|
}
|
|
2072
2072
|
//#endregion
|
|
2073
2073
|
//#region src/adapters/emailTemplates.ts
|
|
2074
|
-
function
|
|
2074
|
+
function Xt(e) {
|
|
2075
2075
|
return O({
|
|
2076
2076
|
template: e.template,
|
|
2077
2077
|
body: e.body,
|
|
@@ -2084,18 +2084,18 @@ function Yt(e) {
|
|
|
2084
2084
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2085
2085
|
});
|
|
2086
2086
|
}
|
|
2087
|
-
function
|
|
2087
|
+
function Zt(e) {
|
|
2088
2088
|
return {
|
|
2089
2089
|
async get(n, r) {
|
|
2090
|
-
let i = await e.select().from(
|
|
2091
|
-
return i ?
|
|
2090
|
+
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.template, r))).get();
|
|
2091
|
+
return i ? Xt(i) : null;
|
|
2092
2092
|
},
|
|
2093
2093
|
async list(t) {
|
|
2094
|
-
return (await e.select().from(
|
|
2094
|
+
return (await e.select().from(Ye).where(a(Ye.tenant_id, t)).all()).map(Xt);
|
|
2095
2095
|
},
|
|
2096
2096
|
async create(t, n) {
|
|
2097
2097
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2098
|
-
return await e.insert(
|
|
2098
|
+
return await e.insert(Ye).values({
|
|
2099
2099
|
tenant_id: t,
|
|
2100
2100
|
template: n.template,
|
|
2101
2101
|
body: n.body,
|
|
@@ -2113,23 +2113,23 @@ function Xt(e) {
|
|
|
2113
2113
|
async update(n, r, i) {
|
|
2114
2114
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2115
2115
|
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);
|
|
2116
|
-
let s = await e.update(
|
|
2116
|
+
let s = await e.update(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.template, r))).run();
|
|
2117
2117
|
return Number(s.changes ?? 0) > 0;
|
|
2118
2118
|
},
|
|
2119
2119
|
async remove(n, r) {
|
|
2120
|
-
let i = await e.delete(
|
|
2120
|
+
let i = await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.template, r))).run();
|
|
2121
2121
|
return Number(i.changes ?? 0) > 0;
|
|
2122
2122
|
}
|
|
2123
2123
|
};
|
|
2124
2124
|
}
|
|
2125
2125
|
//#endregion
|
|
2126
2126
|
//#region src/adapters/flows.ts
|
|
2127
|
-
var
|
|
2128
|
-
function
|
|
2127
|
+
var Qt = ["id", "name"];
|
|
2128
|
+
function $t(e) {
|
|
2129
2129
|
return {
|
|
2130
2130
|
async create(t, n) {
|
|
2131
2131
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2132
|
-
return await e.insert(
|
|
2132
|
+
return await e.insert(Ke).values({
|
|
2133
2133
|
id: i,
|
|
2134
2134
|
tenant_id: t,
|
|
2135
2135
|
name: n.name,
|
|
@@ -2145,7 +2145,7 @@ function Qt(e) {
|
|
|
2145
2145
|
};
|
|
2146
2146
|
},
|
|
2147
2147
|
async get(n, r) {
|
|
2148
|
-
let i = await e.select().from(
|
|
2148
|
+
let i = await e.select().from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).get();
|
|
2149
2149
|
if (!i) return null;
|
|
2150
2150
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2151
2151
|
return O({
|
|
@@ -2155,20 +2155,20 @@ function Qt(e) {
|
|
|
2155
2155
|
},
|
|
2156
2156
|
async update(n, r, i) {
|
|
2157
2157
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2158
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2158
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(Ke).set(o).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2159
2159
|
},
|
|
2160
2160
|
async list(o, s) {
|
|
2161
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2161
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Ke.tenant_id, o)];
|
|
2162
2162
|
if (f) {
|
|
2163
|
-
let e =
|
|
2163
|
+
let e = xe(f, Qt);
|
|
2164
2164
|
if (e) {
|
|
2165
|
-
let t =
|
|
2165
|
+
let t = st(Ke, e, []);
|
|
2166
2166
|
t && p.push(t);
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
|
-
let m = t(...p), h = e.select().from(
|
|
2169
|
+
let m = t(...p), h = e.select().from(Ke).where(m).$dynamic();
|
|
2170
2170
|
if (d?.sort_by) {
|
|
2171
|
-
let e =
|
|
2171
|
+
let e = Ke[d.sort_by];
|
|
2172
2172
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2173
2173
|
}
|
|
2174
2174
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2179,7 +2179,7 @@ function Qt(e) {
|
|
|
2179
2179
|
});
|
|
2180
2180
|
});
|
|
2181
2181
|
if (!u) return { flows: g };
|
|
2182
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2182
|
+
let [_] = await e.select({ count: r() }).from(Ke).where(m);
|
|
2183
2183
|
return {
|
|
2184
2184
|
flows: g,
|
|
2185
2185
|
start: c * l,
|
|
@@ -2188,18 +2188,18 @@ function Qt(e) {
|
|
|
2188
2188
|
};
|
|
2189
2189
|
},
|
|
2190
2190
|
async remove(n, r) {
|
|
2191
|
-
return (await e.delete(
|
|
2191
|
+
return (await e.delete(Ke).where(t(a(Ke.tenant_id, n), a(Ke.id, r))).returning()).length > 0;
|
|
2192
2192
|
}
|
|
2193
2193
|
};
|
|
2194
2194
|
}
|
|
2195
2195
|
//#endregion
|
|
2196
2196
|
//#region src/adapters/forms.ts
|
|
2197
|
-
var
|
|
2197
|
+
var en = [
|
|
2198
2198
|
"nodes",
|
|
2199
2199
|
"start",
|
|
2200
2200
|
"ending"
|
|
2201
|
-
],
|
|
2202
|
-
function
|
|
2201
|
+
], tn = ["name"];
|
|
2202
|
+
function nn(e) {
|
|
2203
2203
|
return {
|
|
2204
2204
|
async create(t, n) {
|
|
2205
2205
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2213,8 +2213,8 @@ function tn(e) {
|
|
|
2213
2213
|
created_at: r,
|
|
2214
2214
|
updated_at: r
|
|
2215
2215
|
};
|
|
2216
|
-
for (let e of
|
|
2217
|
-
return await e.insert(
|
|
2216
|
+
for (let e of en) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2217
|
+
return await e.insert(Ge).values(a), {
|
|
2218
2218
|
id: i,
|
|
2219
2219
|
...n,
|
|
2220
2220
|
created_at: r,
|
|
@@ -2222,38 +2222,38 @@ function tn(e) {
|
|
|
2222
2222
|
};
|
|
2223
2223
|
},
|
|
2224
2224
|
async get(n, r) {
|
|
2225
|
-
let i = await e.select().from(
|
|
2225
|
+
let i = await e.select().from(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).get();
|
|
2226
2226
|
if (!i) return null;
|
|
2227
2227
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2228
|
-
for (let e of
|
|
2228
|
+
for (let e of en) c[e] = Q(s[e]);
|
|
2229
2229
|
return O(c);
|
|
2230
2230
|
},
|
|
2231
2231
|
async update(n, r, i) {
|
|
2232
2232
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2233
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2234
|
-
return (await e.update(
|
|
2233
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (en.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2234
|
+
return (await e.update(Ge).set(o).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2235
2235
|
},
|
|
2236
2236
|
async list(o, s) {
|
|
2237
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2237
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Ge.tenant_id, o)];
|
|
2238
2238
|
if (f) {
|
|
2239
|
-
let e =
|
|
2239
|
+
let e = xe(f, tn);
|
|
2240
2240
|
if (e) {
|
|
2241
|
-
let t =
|
|
2241
|
+
let t = st(Ge, e, tn);
|
|
2242
2242
|
t && p.push(t);
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
|
-
let m = t(...p), h = e.select().from(
|
|
2245
|
+
let m = t(...p), h = e.select().from(Ge).where(m).$dynamic();
|
|
2246
2246
|
if (d?.sort_by) {
|
|
2247
|
-
let e =
|
|
2247
|
+
let e = Ge[d.sort_by];
|
|
2248
2248
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2249
2249
|
}
|
|
2250
2250
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2251
2251
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2252
|
-
for (let e of
|
|
2252
|
+
for (let e of en) r[e] = Q(n[e]);
|
|
2253
2253
|
return O(r);
|
|
2254
2254
|
});
|
|
2255
2255
|
if (!u) return { forms: g };
|
|
2256
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2256
|
+
let [_] = await e.select({ count: r() }).from(Ge).where(m);
|
|
2257
2257
|
return {
|
|
2258
2258
|
forms: g,
|
|
2259
2259
|
start: c * l,
|
|
@@ -2262,13 +2262,13 @@ function tn(e) {
|
|
|
2262
2262
|
};
|
|
2263
2263
|
},
|
|
2264
2264
|
async remove(n, r) {
|
|
2265
|
-
return (await e.delete(
|
|
2265
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.id, r))).returning()).length > 0;
|
|
2266
2266
|
}
|
|
2267
2267
|
};
|
|
2268
2268
|
}
|
|
2269
2269
|
//#endregion
|
|
2270
2270
|
//#region src/adapters/grants.ts
|
|
2271
|
-
function
|
|
2271
|
+
function rn(e) {
|
|
2272
2272
|
return {
|
|
2273
2273
|
id: e.id,
|
|
2274
2274
|
user_id: e.user_id,
|
|
@@ -2277,17 +2277,17 @@ function nn(e) {
|
|
|
2277
2277
|
scope: Q(e.scope, []) ?? []
|
|
2278
2278
|
};
|
|
2279
2279
|
}
|
|
2280
|
-
var
|
|
2280
|
+
var an = {
|
|
2281
2281
|
user_id: B.user_id,
|
|
2282
2282
|
client_id: B.client_id,
|
|
2283
2283
|
audience: B.audience,
|
|
2284
2284
|
created_at: B.created_at,
|
|
2285
2285
|
updated_at: B.updated_at
|
|
2286
2286
|
};
|
|
2287
|
-
function an(e) {
|
|
2288
|
-
return Object.hasOwn(rn, e) ? rn[e] : void 0;
|
|
2289
|
-
}
|
|
2290
2287
|
function on(e) {
|
|
2288
|
+
return Object.hasOwn(an, e) ? an[e] : void 0;
|
|
2289
|
+
}
|
|
2290
|
+
function sn(e) {
|
|
2291
2291
|
return {
|
|
2292
2292
|
async create(n, r) {
|
|
2293
2293
|
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();
|
|
@@ -2296,7 +2296,7 @@ function on(e) {
|
|
|
2296
2296
|
return await e.update(B).set({
|
|
2297
2297
|
scope: JSON.stringify(s),
|
|
2298
2298
|
updated_at: i
|
|
2299
|
-
}).where(t(a(B.tenant_id, n), a(B.id, c.id))),
|
|
2299
|
+
}).where(t(a(B.tenant_id, n), a(B.id, c.id))), rn({
|
|
2300
2300
|
...c,
|
|
2301
2301
|
scope: JSON.stringify(s)
|
|
2302
2302
|
});
|
|
@@ -2321,16 +2321,16 @@ function on(e) {
|
|
|
2321
2321
|
},
|
|
2322
2322
|
async get(n, r, i, o) {
|
|
2323
2323
|
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();
|
|
2324
|
-
return s ?
|
|
2324
|
+
return s ? rn(s) : null;
|
|
2325
2325
|
},
|
|
2326
2326
|
async list(o, s) {
|
|
2327
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2327
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(B, f, [
|
|
2328
2328
|
"user_id",
|
|
2329
2329
|
"client_id",
|
|
2330
2330
|
"audience"
|
|
2331
|
-
]) : 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 ?
|
|
2331
|
+
]) : 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 ? on(d.sort_by) : void 0;
|
|
2332
2332
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(B.created_at));
|
|
2333
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2333
|
+
let _ = (await h.offset(c * l).limit(l)).map(rn);
|
|
2334
2334
|
if (!u) return {
|
|
2335
2335
|
grants: _,
|
|
2336
2336
|
start: 0,
|
|
@@ -2355,11 +2355,11 @@ function on(e) {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
//#endregion
|
|
2357
2357
|
//#region src/adapters/hookCode.ts
|
|
2358
|
-
var
|
|
2359
|
-
function
|
|
2360
|
-
return `hc_${
|
|
2358
|
+
var cn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2359
|
+
function ln() {
|
|
2360
|
+
return `hc_${cn()}`;
|
|
2361
2361
|
}
|
|
2362
|
-
function
|
|
2362
|
+
function un(e) {
|
|
2363
2363
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ie({
|
|
2364
2364
|
created_at_ts: t,
|
|
2365
2365
|
updated_at_ts: n
|
|
@@ -2370,41 +2370,41 @@ function ln(e) {
|
|
|
2370
2370
|
secrets: r ? JSON.parse(r) : void 0
|
|
2371
2371
|
};
|
|
2372
2372
|
}
|
|
2373
|
-
function
|
|
2373
|
+
function dn(e) {
|
|
2374
2374
|
return {
|
|
2375
2375
|
async create(t, n) {
|
|
2376
2376
|
let r = Date.now(), i = {
|
|
2377
|
-
id:
|
|
2377
|
+
id: ln(),
|
|
2378
2378
|
tenant_id: t,
|
|
2379
2379
|
code: n.code,
|
|
2380
2380
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2381
2381
|
created_at_ts: r,
|
|
2382
2382
|
updated_at_ts: r
|
|
2383
2383
|
};
|
|
2384
|
-
return await e.insert(
|
|
2384
|
+
return await e.insert(Ze).values(i), un({
|
|
2385
2385
|
...i,
|
|
2386
2386
|
tenant_id: t
|
|
2387
2387
|
});
|
|
2388
2388
|
},
|
|
2389
2389
|
async get(n, r) {
|
|
2390
|
-
let i = await e.select().from(
|
|
2391
|
-
return i ?
|
|
2390
|
+
let i = await e.select().from(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).get();
|
|
2391
|
+
return i ? un(i) : null;
|
|
2392
2392
|
},
|
|
2393
2393
|
async update(n, r, i) {
|
|
2394
2394
|
let o = { updated_at_ts: Date.now() };
|
|
2395
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2395
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(Ze).set(o).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2396
2396
|
},
|
|
2397
2397
|
async remove(n, r) {
|
|
2398
|
-
return (await e.delete(
|
|
2398
|
+
return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.id, r))).returning()).length > 0;
|
|
2399
2399
|
}
|
|
2400
2400
|
};
|
|
2401
2401
|
}
|
|
2402
2402
|
//#endregion
|
|
2403
2403
|
//#region src/adapters/hooks.ts
|
|
2404
|
-
function
|
|
2404
|
+
function fn() {
|
|
2405
2405
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2406
2406
|
}
|
|
2407
|
-
function
|
|
2407
|
+
function pn(e) {
|
|
2408
2408
|
if (!(typeof e != "string" || !e)) try {
|
|
2409
2409
|
let t = JSON.parse(e);
|
|
2410
2410
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2412,7 +2412,7 @@ function fn(e) {
|
|
|
2412
2412
|
return;
|
|
2413
2413
|
}
|
|
2414
2414
|
}
|
|
2415
|
-
function
|
|
2415
|
+
function mn(e) {
|
|
2416
2416
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ie({
|
|
2417
2417
|
created_at_ts: n,
|
|
2418
2418
|
updated_at_ts: r
|
|
@@ -2421,15 +2421,15 @@ function pn(e) {
|
|
|
2421
2421
|
...a,
|
|
2422
2422
|
enabled: !!a.enabled,
|
|
2423
2423
|
synchronous: !!a.synchronous,
|
|
2424
|
-
metadata:
|
|
2424
|
+
metadata: pn(i),
|
|
2425
2425
|
...o
|
|
2426
2426
|
});
|
|
2427
2427
|
}
|
|
2428
|
-
function
|
|
2428
|
+
function hn(e) {
|
|
2429
2429
|
return {
|
|
2430
2430
|
async create(t, n) {
|
|
2431
2431
|
let r = Date.now(), i = {
|
|
2432
|
-
hook_id: n.hook_id ||
|
|
2432
|
+
hook_id: n.hook_id || fn(),
|
|
2433
2433
|
tenant_id: t,
|
|
2434
2434
|
trigger_id: n.trigger_id,
|
|
2435
2435
|
url: n.url,
|
|
@@ -2445,30 +2445,30 @@ function mn(e) {
|
|
|
2445
2445
|
created_at_ts: r,
|
|
2446
2446
|
updated_at_ts: r
|
|
2447
2447
|
};
|
|
2448
|
-
return await e.insert(
|
|
2448
|
+
return await e.insert(Xe).values(i), mn({
|
|
2449
2449
|
...i,
|
|
2450
2450
|
tenant_id: t
|
|
2451
2451
|
});
|
|
2452
2452
|
},
|
|
2453
2453
|
async get(n, r) {
|
|
2454
|
-
let i = await e.select().from(
|
|
2455
|
-
return i ?
|
|
2454
|
+
let i = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.hook_id, r))).get();
|
|
2455
|
+
return i ? mn(i) : null;
|
|
2456
2456
|
},
|
|
2457
2457
|
async update(n, r, i) {
|
|
2458
2458
|
let o = { updated_at_ts: Date.now() };
|
|
2459
|
-
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(
|
|
2459
|
+
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(Xe).set(o).where(t(a(Xe.tenant_id, n), a(Xe.hook_id, r))).returning()).length > 0;
|
|
2460
2460
|
},
|
|
2461
2461
|
async list(o, s) {
|
|
2462
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2462
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(Xe, f, [
|
|
2463
2463
|
"url",
|
|
2464
2464
|
"form_id",
|
|
2465
2465
|
"template_id",
|
|
2466
2466
|
"code_id"
|
|
2467
|
-
]) : void 0, m = p ? t(a(
|
|
2468
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2469
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2467
|
+
]) : void 0, m = p ? t(a(Xe.tenant_id, o), p) : a(Xe.tenant_id, o), h = e.select().from(Xe).where(m).$dynamic(), g = d?.sort_by ? Xe[d.sort_by] : void 0;
|
|
2468
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(Xe.priority), n(Xe.created_at_ts));
|
|
2469
|
+
let _ = (await h.offset(c * l).limit(l)).map(mn);
|
|
2470
2470
|
if (!u) return { hooks: _ };
|
|
2471
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2471
|
+
let [v] = await e.select({ count: r() }).from(Xe).where(m);
|
|
2472
2472
|
return {
|
|
2473
2473
|
hooks: _,
|
|
2474
2474
|
start: c * l,
|
|
@@ -2477,31 +2477,31 @@ function mn(e) {
|
|
|
2477
2477
|
};
|
|
2478
2478
|
},
|
|
2479
2479
|
async remove(n, r) {
|
|
2480
|
-
return (await e.delete(
|
|
2480
|
+
return (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.hook_id, r))).returning()).length > 0;
|
|
2481
2481
|
}
|
|
2482
2482
|
};
|
|
2483
2483
|
}
|
|
2484
2484
|
//#endregion
|
|
2485
2485
|
//#region src/adapters/invites.ts
|
|
2486
|
-
function
|
|
2486
|
+
function gn() {
|
|
2487
2487
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2488
2488
|
}
|
|
2489
|
-
var
|
|
2489
|
+
var _n = [
|
|
2490
2490
|
"inviter",
|
|
2491
2491
|
"invitee",
|
|
2492
2492
|
"app_metadata",
|
|
2493
2493
|
"user_metadata",
|
|
2494
2494
|
"roles"
|
|
2495
2495
|
];
|
|
2496
|
-
function
|
|
2496
|
+
function vn(e) {
|
|
2497
2497
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2498
|
-
for (let e of
|
|
2498
|
+
for (let e of _n) i[e] = Q(r[e], e === "roles" ? [] : {});
|
|
2499
2499
|
return i.send_invitation_email = !!n, O(i);
|
|
2500
2500
|
}
|
|
2501
|
-
function
|
|
2501
|
+
function yn(e) {
|
|
2502
2502
|
return {
|
|
2503
2503
|
async create(t, n) {
|
|
2504
|
-
let r = n.id ||
|
|
2504
|
+
let r = n.id || gn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2505
2505
|
id: r,
|
|
2506
2506
|
tenant_id: t,
|
|
2507
2507
|
organization_id: n.organization_id,
|
|
@@ -2514,35 +2514,35 @@ function vn(e) {
|
|
|
2514
2514
|
created_at: a.toISOString(),
|
|
2515
2515
|
expires_at: o
|
|
2516
2516
|
};
|
|
2517
|
-
for (let e of
|
|
2517
|
+
for (let e of _n) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2518
2518
|
try {
|
|
2519
|
-
await e.insert(
|
|
2519
|
+
await e.insert(ze).values(s);
|
|
2520
2520
|
} catch (e) {
|
|
2521
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
2521
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Oe(409, { message: "Invite already exists" }) : e;
|
|
2522
2522
|
}
|
|
2523
|
-
return
|
|
2523
|
+
return vn({
|
|
2524
2524
|
...s,
|
|
2525
2525
|
tenant_id: t
|
|
2526
2526
|
});
|
|
2527
2527
|
},
|
|
2528
2528
|
async get(n, r) {
|
|
2529
|
-
let i = await e.select().from(
|
|
2530
|
-
return i ?
|
|
2529
|
+
let i = await e.select().from(ze).where(t(a(ze.tenant_id, n), a(ze.id, r))).get();
|
|
2530
|
+
return i ? vn(i) : null;
|
|
2531
2531
|
},
|
|
2532
2532
|
async update(n, r, i) {
|
|
2533
2533
|
let o = {};
|
|
2534
|
-
for (let e of
|
|
2535
|
-
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(
|
|
2534
|
+
for (let e of _n) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2535
|
+
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(ze).set(o).where(t(a(ze.tenant_id, n), a(ze.id, r))).returning()).length > 0;
|
|
2536
2536
|
},
|
|
2537
2537
|
async list(t, o) {
|
|
2538
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2538
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(ze).where(a(ze.tenant_id, t)).$dynamic();
|
|
2539
2539
|
if (u?.sort_by) {
|
|
2540
|
-
let e =
|
|
2540
|
+
let e = ze[u.sort_by];
|
|
2541
2541
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2542
2542
|
}
|
|
2543
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2543
|
+
let f = (await d.offset(s * c).limit(c)).map(vn);
|
|
2544
2544
|
if (!l) return { invites: f };
|
|
2545
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2545
|
+
let [p] = await e.select({ count: r() }).from(ze).where(a(ze.tenant_id, t));
|
|
2546
2546
|
return {
|
|
2547
2547
|
invites: f,
|
|
2548
2548
|
start: s * c,
|
|
@@ -2551,39 +2551,39 @@ function vn(e) {
|
|
|
2551
2551
|
};
|
|
2552
2552
|
},
|
|
2553
2553
|
async remove(n, r) {
|
|
2554
|
-
return (await e.delete(
|
|
2554
|
+
return (await e.delete(ze).where(t(a(ze.tenant_id, n), a(ze.id, r))).returning()).length > 0;
|
|
2555
2555
|
}
|
|
2556
2556
|
};
|
|
2557
2557
|
}
|
|
2558
2558
|
//#endregion
|
|
2559
2559
|
//#region src/adapters/keys.ts
|
|
2560
|
-
var
|
|
2560
|
+
var bn = [
|
|
2561
2561
|
"kid",
|
|
2562
2562
|
"connection",
|
|
2563
2563
|
"fingerprint",
|
|
2564
2564
|
"thumbprint",
|
|
2565
2565
|
"type"
|
|
2566
2566
|
];
|
|
2567
|
-
function
|
|
2567
|
+
function xn(e) {
|
|
2568
2568
|
return {
|
|
2569
2569
|
async create(t) {
|
|
2570
|
-
await e.insert(
|
|
2570
|
+
await e.insert(Qe).values({
|
|
2571
2571
|
...t,
|
|
2572
2572
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2573
2573
|
});
|
|
2574
2574
|
},
|
|
2575
2575
|
async list(a) {
|
|
2576
|
-
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(
|
|
2576
|
+
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(Qe.revoked_at, p), f(Qe.revoked_at))];
|
|
2577
2577
|
if (d) {
|
|
2578
|
-
let e =
|
|
2578
|
+
let e = xe(d, bn);
|
|
2579
2579
|
if (e) {
|
|
2580
|
-
let t =
|
|
2580
|
+
let t = st(Qe, e, bn);
|
|
2581
2581
|
t && m.push(t);
|
|
2582
2582
|
}
|
|
2583
2583
|
}
|
|
2584
|
-
let h = t(...m), g = e.select().from(
|
|
2584
|
+
let h = t(...m), g = e.select().from(Qe).where(h).$dynamic();
|
|
2585
2585
|
if (u?.sort_by) {
|
|
2586
|
-
let e =
|
|
2586
|
+
let e = Qe[u.sort_by];
|
|
2587
2587
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2588
2588
|
}
|
|
2589
2589
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2591,7 +2591,7 @@ function bn(e) {
|
|
|
2591
2591
|
return O(n);
|
|
2592
2592
|
});
|
|
2593
2593
|
if (!l) return { signingKeys: _ };
|
|
2594
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2594
|
+
let [y] = await e.select({ count: r() }).from(Qe).where(h);
|
|
2595
2595
|
return {
|
|
2596
2596
|
signingKeys: _,
|
|
2597
2597
|
start: o * c,
|
|
@@ -2600,22 +2600,22 @@ function bn(e) {
|
|
|
2600
2600
|
};
|
|
2601
2601
|
},
|
|
2602
2602
|
async update(t, n) {
|
|
2603
|
-
return (await e.update(
|
|
2603
|
+
return (await e.update(Qe).set(n).where(a(Qe.kid, t)).returning()).length > 0;
|
|
2604
2604
|
}
|
|
2605
2605
|
};
|
|
2606
2606
|
}
|
|
2607
2607
|
//#endregion
|
|
2608
2608
|
//#region src/adapters/loginSessions.ts
|
|
2609
|
-
var
|
|
2610
|
-
function
|
|
2609
|
+
var Sn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Cn = 32;
|
|
2610
|
+
function wn() {
|
|
2611
2611
|
let e = Date.now(), t = "";
|
|
2612
|
-
for (let n = 10; n > 0; n--) t =
|
|
2612
|
+
for (let n = 10; n > 0; n--) t = Sn.charAt(e % Cn) + t, e = Math.floor(e / Cn);
|
|
2613
2613
|
let n = new Uint8Array(16);
|
|
2614
2614
|
crypto.getRandomValues(n);
|
|
2615
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2615
|
+
for (let e = 0; e < 16; e++) t += Sn.charAt(n[e] % Cn);
|
|
2616
2616
|
return t;
|
|
2617
2617
|
}
|
|
2618
|
-
function
|
|
2618
|
+
function Tn(e) {
|
|
2619
2619
|
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({
|
|
2620
2620
|
created_at_ts: n,
|
|
2621
2621
|
updated_at_ts: r,
|
|
@@ -2627,17 +2627,17 @@ function wn(e) {
|
|
|
2627
2627
|
]), l = {};
|
|
2628
2628
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2629
2629
|
return O({
|
|
2630
|
-
...
|
|
2630
|
+
...it(l, ["auth_strategy"]),
|
|
2631
2631
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2632
2632
|
...c,
|
|
2633
2633
|
state_data: Q(a)
|
|
2634
2634
|
});
|
|
2635
2635
|
}
|
|
2636
|
-
function
|
|
2636
|
+
function En(e) {
|
|
2637
2637
|
return {
|
|
2638
2638
|
async create(t, n) {
|
|
2639
2639
|
let r = Date.now(), i = {
|
|
2640
|
-
id:
|
|
2640
|
+
id: wn(),
|
|
2641
2641
|
tenant_id: t,
|
|
2642
2642
|
session_id: n.session_id,
|
|
2643
2643
|
csrf_token: n.csrf_token,
|
|
@@ -2658,14 +2658,14 @@ function Tn(e) {
|
|
|
2658
2658
|
updated_at_ts: r,
|
|
2659
2659
|
expires_at_ts: n.expires_at ? D(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2660
2660
|
};
|
|
2661
|
-
return await e.insert(F).values(i),
|
|
2661
|
+
return await e.insert(F).values(i), Tn({
|
|
2662
2662
|
...i,
|
|
2663
2663
|
tenant_id: t
|
|
2664
2664
|
});
|
|
2665
2665
|
},
|
|
2666
2666
|
async get(n, r) {
|
|
2667
2667
|
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();
|
|
2668
|
-
return o ?
|
|
2668
|
+
return o ? Tn(o) : null;
|
|
2669
2669
|
},
|
|
2670
2670
|
async update(n, r, i) {
|
|
2671
2671
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2685,7 +2685,7 @@ function Tn(e) {
|
|
|
2685
2685
|
}
|
|
2686
2686
|
//#endregion
|
|
2687
2687
|
//#region src/adapters/logs.ts
|
|
2688
|
-
function
|
|
2688
|
+
function Dn(e) {
|
|
2689
2689
|
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 = {
|
|
2690
2690
|
...f,
|
|
2691
2691
|
isMobile: !!n,
|
|
@@ -2702,7 +2702,7 @@ function En(e) {
|
|
|
2702
2702
|
continent_code: u
|
|
2703
2703
|
})), O(p);
|
|
2704
2704
|
}
|
|
2705
|
-
function
|
|
2705
|
+
function On(e) {
|
|
2706
2706
|
return {
|
|
2707
2707
|
async create(t, n) {
|
|
2708
2708
|
let r = {
|
|
@@ -2728,7 +2728,7 @@ function Dn(e) {
|
|
|
2728
2728
|
hostname: n.hostname,
|
|
2729
2729
|
session_connection: n.session_connection
|
|
2730
2730
|
};
|
|
2731
|
-
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),
|
|
2731
|
+
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), Dn({
|
|
2732
2732
|
...r,
|
|
2733
2733
|
tenant_id: t
|
|
2734
2734
|
});
|
|
@@ -2736,7 +2736,7 @@ function Dn(e) {
|
|
|
2736
2736
|
async list(o, s) {
|
|
2737
2737
|
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)];
|
|
2738
2738
|
if (p) {
|
|
2739
|
-
let e =
|
|
2739
|
+
let e = st(J, p, [
|
|
2740
2740
|
"user_id",
|
|
2741
2741
|
"ip",
|
|
2742
2742
|
"type",
|
|
@@ -2746,14 +2746,14 @@ function Dn(e) {
|
|
|
2746
2746
|
}
|
|
2747
2747
|
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()));
|
|
2748
2748
|
let v = t(..._);
|
|
2749
|
-
if (
|
|
2750
|
-
if (f?.sort_by && f.sort_by !== "date") throw new
|
|
2749
|
+
if (yt(s)) {
|
|
2750
|
+
if (f?.sort_by && f.sort_by !== "date") throw new Oe(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2751
2751
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2752
2752
|
sortColumn: J.date,
|
|
2753
2753
|
idColumn: J.log_id,
|
|
2754
2754
|
sortOrder: n,
|
|
2755
2755
|
sortKey: `date:${n}`
|
|
2756
|
-
}, i =
|
|
2756
|
+
}, i = St(s, r), a = bt(s), { rows: o, next: c } = Ct(await e.select().from(J).where(i ? t(v, i) : v).orderBy(...xt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Dn);
|
|
2757
2757
|
return {
|
|
2758
2758
|
logs: l,
|
|
2759
2759
|
start: 0,
|
|
@@ -2767,7 +2767,7 @@ function Dn(e) {
|
|
|
2767
2767
|
let e = J[f.sort_by];
|
|
2768
2768
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2769
2769
|
} else y = y.orderBy(i(J.date));
|
|
2770
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2770
|
+
let ee = (await y.offset(l * u).limit(u)).map(Dn);
|
|
2771
2771
|
if (!d) return { logs: ee };
|
|
2772
2772
|
let [b] = await e.select({ count: r() }).from(J).where(v);
|
|
2773
2773
|
return {
|
|
@@ -2779,22 +2779,22 @@ function Dn(e) {
|
|
|
2779
2779
|
},
|
|
2780
2780
|
async get(n, r) {
|
|
2781
2781
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.log_id, r))).get();
|
|
2782
|
-
return i ?
|
|
2782
|
+
return i ? Dn(i) : null;
|
|
2783
2783
|
}
|
|
2784
2784
|
};
|
|
2785
2785
|
}
|
|
2786
2786
|
//#endregion
|
|
2787
2787
|
//#region src/adapters/authenticationMethods.ts
|
|
2788
|
-
var
|
|
2789
|
-
function
|
|
2788
|
+
var kn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", An = 32;
|
|
2789
|
+
function jn() {
|
|
2790
2790
|
let e = Date.now(), t = "";
|
|
2791
|
-
for (let n = 10; n > 0; n--) t =
|
|
2791
|
+
for (let n = 10; n > 0; n--) t = kn.charAt(e % An) + t, e = Math.floor(e / An);
|
|
2792
2792
|
let n = new Uint8Array(16);
|
|
2793
2793
|
crypto.getRandomValues(n);
|
|
2794
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2794
|
+
for (let e = 0; e < 16; e++) t += kn.charAt(n[e] % An);
|
|
2795
2795
|
return t;
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function Mn(e) {
|
|
2798
2798
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2799
2799
|
return O({
|
|
2800
2800
|
...s,
|
|
@@ -2805,11 +2805,11 @@ function jn(e) {
|
|
|
2805
2805
|
updated_at: ae(r)
|
|
2806
2806
|
});
|
|
2807
2807
|
}
|
|
2808
|
-
function
|
|
2808
|
+
function Nn(e) {
|
|
2809
2809
|
return {
|
|
2810
2810
|
async create(t, n) {
|
|
2811
2811
|
let r = Date.now(), i = {
|
|
2812
|
-
id: n.id ||
|
|
2812
|
+
id: n.id || jn(),
|
|
2813
2813
|
tenant_id: t,
|
|
2814
2814
|
user_id: n.user_id,
|
|
2815
2815
|
type: n.type,
|
|
@@ -2825,21 +2825,21 @@ function Mn(e) {
|
|
|
2825
2825
|
created_at_ts: r,
|
|
2826
2826
|
updated_at_ts: r
|
|
2827
2827
|
};
|
|
2828
|
-
return await e.insert(q).values(i),
|
|
2828
|
+
return await e.insert(q).values(i), Mn({
|
|
2829
2829
|
...i,
|
|
2830
2830
|
tenant_id: t
|
|
2831
2831
|
});
|
|
2832
2832
|
},
|
|
2833
2833
|
async get(n, r) {
|
|
2834
2834
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.id, r))).get();
|
|
2835
|
-
return i ?
|
|
2835
|
+
return i ? Mn(i) : null;
|
|
2836
2836
|
},
|
|
2837
2837
|
async getByCredentialId(n, r) {
|
|
2838
2838
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.credential_id, r))).get();
|
|
2839
|
-
return i ?
|
|
2839
|
+
return i ? Mn(i) : null;
|
|
2840
2840
|
},
|
|
2841
2841
|
async list(n, r) {
|
|
2842
|
-
return (await e.select().from(q).where(t(a(q.tenant_id, n), a(q.user_id, r))).all()).map(
|
|
2842
|
+
return (await e.select().from(q).where(t(a(q.tenant_id, n), a(q.user_id, r))).all()).map(Mn);
|
|
2843
2843
|
},
|
|
2844
2844
|
async update(n, r, i) {
|
|
2845
2845
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2855,11 +2855,11 @@ function Mn(e) {
|
|
|
2855
2855
|
}
|
|
2856
2856
|
//#endregion
|
|
2857
2857
|
//#region src/adapters/organizations.ts
|
|
2858
|
-
var
|
|
2859
|
-
function
|
|
2858
|
+
var Pn = ["name", "display_name"];
|
|
2859
|
+
function Fn() {
|
|
2860
2860
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2861
2861
|
}
|
|
2862
|
-
function
|
|
2862
|
+
function In(e) {
|
|
2863
2863
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2864
2864
|
return O({
|
|
2865
2865
|
...o,
|
|
@@ -2869,11 +2869,11 @@ function Fn(e) {
|
|
|
2869
2869
|
token_quota: Q(a, {})
|
|
2870
2870
|
});
|
|
2871
2871
|
}
|
|
2872
|
-
function
|
|
2872
|
+
function Ln(e) {
|
|
2873
2873
|
return {
|
|
2874
2874
|
async create(t, n) {
|
|
2875
2875
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2876
|
-
id: n.id ||
|
|
2876
|
+
id: n.id || Fn(),
|
|
2877
2877
|
tenant_id: t,
|
|
2878
2878
|
name: n.name,
|
|
2879
2879
|
display_name: n.display_name,
|
|
@@ -2887,16 +2887,16 @@ function In(e) {
|
|
|
2887
2887
|
try {
|
|
2888
2888
|
await e.insert(H).values(i);
|
|
2889
2889
|
} catch (e) {
|
|
2890
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new
|
|
2890
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Oe(409, { message: "Organization already exists" }) : e;
|
|
2891
2891
|
}
|
|
2892
|
-
return
|
|
2892
|
+
return In({
|
|
2893
2893
|
...i,
|
|
2894
2894
|
tenant_id: t
|
|
2895
2895
|
});
|
|
2896
2896
|
},
|
|
2897
2897
|
async get(n, r) {
|
|
2898
2898
|
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
2899
|
-
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ?
|
|
2899
|
+
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ? In(i) : null;
|
|
2900
2900
|
},
|
|
2901
2901
|
async update(n, r, i) {
|
|
2902
2902
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2905,19 +2905,19 @@ function In(e) {
|
|
|
2905
2905
|
async list(o, s) {
|
|
2906
2906
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(H.tenant_id, o)];
|
|
2907
2907
|
if (f) {
|
|
2908
|
-
let e =
|
|
2908
|
+
let e = xe(f, Pn);
|
|
2909
2909
|
if (e) {
|
|
2910
|
-
let t =
|
|
2910
|
+
let t = st(H, e, Pn);
|
|
2911
2911
|
t && p.push(t);
|
|
2912
2912
|
}
|
|
2913
2913
|
}
|
|
2914
2914
|
let m = t(...p);
|
|
2915
|
-
if (
|
|
2915
|
+
if (yt(s)) {
|
|
2916
2916
|
let n = {
|
|
2917
2917
|
sortColumn: H.created_at,
|
|
2918
2918
|
idColumn: H.id,
|
|
2919
2919
|
sortOrder: "desc"
|
|
2920
|
-
}, r =
|
|
2920
|
+
}, r = St(s, n), i = bt(s), { rows: a, next: o } = Ct(await e.select().from(H).where(r ? t(m, r) : m).orderBy(...xt(n)).limit(i + 1), i, "created_at"), c = a.map(In);
|
|
2921
2921
|
return {
|
|
2922
2922
|
organizations: c,
|
|
2923
2923
|
start: 0,
|
|
@@ -2932,7 +2932,7 @@ function In(e) {
|
|
|
2932
2932
|
let e = H[d.sort_by];
|
|
2933
2933
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2934
2934
|
}
|
|
2935
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2935
|
+
let g = (await h.offset(c * l).limit(l)).map(In);
|
|
2936
2936
|
if (!u) return { organizations: g };
|
|
2937
2937
|
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2938
2938
|
return {
|
|
@@ -2949,14 +2949,14 @@ function In(e) {
|
|
|
2949
2949
|
}
|
|
2950
2950
|
//#endregion
|
|
2951
2951
|
//#region src/adapters/passwords.ts
|
|
2952
|
-
function
|
|
2952
|
+
function Rn(e) {
|
|
2953
2953
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2954
2954
|
return {
|
|
2955
2955
|
...r,
|
|
2956
2956
|
is_current: !!n
|
|
2957
2957
|
};
|
|
2958
2958
|
}
|
|
2959
|
-
function
|
|
2959
|
+
function zn(e) {
|
|
2960
2960
|
return {
|
|
2961
2961
|
async create(n, r) {
|
|
2962
2962
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2971,18 +2971,18 @@ function Rn(e) {
|
|
|
2971
2971
|
created_at: i,
|
|
2972
2972
|
updated_at: i
|
|
2973
2973
|
};
|
|
2974
|
-
return await e.insert(M).values(s),
|
|
2974
|
+
return await e.insert(M).values(s), Rn({
|
|
2975
2975
|
...s,
|
|
2976
2976
|
tenant_id: n
|
|
2977
2977
|
});
|
|
2978
2978
|
},
|
|
2979
2979
|
async get(n, r) {
|
|
2980
2980
|
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();
|
|
2981
|
-
return i ?
|
|
2981
|
+
return i ? Rn(i) : null;
|
|
2982
2982
|
},
|
|
2983
2983
|
async list(n, r, o) {
|
|
2984
2984
|
let s = e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r))).orderBy(i(M.created_at)).$dynamic();
|
|
2985
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
2985
|
+
return o && (s = s.limit(o)), (await s).map(Rn);
|
|
2986
2986
|
},
|
|
2987
2987
|
async update(n, r) {
|
|
2988
2988
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2992,10 +2992,10 @@ function Rn(e) {
|
|
|
2992
2992
|
}
|
|
2993
2993
|
//#endregion
|
|
2994
2994
|
//#region src/adapters/promptSettings.ts
|
|
2995
|
-
function
|
|
2995
|
+
function Bn(e) {
|
|
2996
2996
|
return {
|
|
2997
2997
|
async get(t) {
|
|
2998
|
-
let n = await e.select().from(
|
|
2998
|
+
let n = await e.select().from(qe).where(a(qe.tenant_id, t)).get();
|
|
2999
2999
|
return n ? {
|
|
3000
3000
|
universal_login_experience: n.universal_login_experience,
|
|
3001
3001
|
identifier_first: !!n.identifier_first,
|
|
@@ -3011,7 +3011,7 @@ function zn(e) {
|
|
|
3011
3011
|
};
|
|
3012
3012
|
},
|
|
3013
3013
|
async set(t, n) {
|
|
3014
|
-
await e.insert(
|
|
3014
|
+
await e.insert(qe).values({
|
|
3015
3015
|
tenant_id: t,
|
|
3016
3016
|
universal_login_experience: n.universal_login_experience,
|
|
3017
3017
|
identifier_first: n.identifier_first,
|
|
@@ -3019,7 +3019,7 @@ function zn(e) {
|
|
|
3019
3019
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3020
3020
|
show_last_used_connection: n.show_last_used_connection
|
|
3021
3021
|
}).onConflictDoUpdate({
|
|
3022
|
-
target:
|
|
3022
|
+
target: qe.tenant_id,
|
|
3023
3023
|
set: {
|
|
3024
3024
|
universal_login_experience: n.universal_login_experience,
|
|
3025
3025
|
identifier_first: n.identifier_first,
|
|
@@ -3033,22 +3033,22 @@ function zn(e) {
|
|
|
3033
3033
|
}
|
|
3034
3034
|
//#endregion
|
|
3035
3035
|
//#region src/adapters/proxyRoutes.ts
|
|
3036
|
-
function
|
|
3036
|
+
function Vn(e) {
|
|
3037
3037
|
if (!e) return { path: "/*" };
|
|
3038
3038
|
try {
|
|
3039
|
-
let t = JSON.parse(e), n =
|
|
3039
|
+
let t = JSON.parse(e), n = ve.safeParse(t);
|
|
3040
3040
|
if (n.success) return n.data;
|
|
3041
3041
|
} catch {}
|
|
3042
3042
|
return { path: "/*" };
|
|
3043
3043
|
}
|
|
3044
|
-
function
|
|
3044
|
+
function Hn(e) {
|
|
3045
3045
|
if (!e) return [];
|
|
3046
3046
|
try {
|
|
3047
3047
|
let t = JSON.parse(e);
|
|
3048
3048
|
if (!Array.isArray(t)) return [];
|
|
3049
3049
|
let n = [];
|
|
3050
3050
|
for (let e of t) {
|
|
3051
|
-
let t =
|
|
3051
|
+
let t = ge.safeParse(e);
|
|
3052
3052
|
t.success && n.push(t.data);
|
|
3053
3053
|
}
|
|
3054
3054
|
return n;
|
|
@@ -3056,19 +3056,19 @@ function Vn(e) {
|
|
|
3056
3056
|
return [];
|
|
3057
3057
|
}
|
|
3058
3058
|
}
|
|
3059
|
-
function
|
|
3059
|
+
function Un(e) {
|
|
3060
3060
|
return {
|
|
3061
3061
|
id: e.id,
|
|
3062
3062
|
tenant_id: e.tenant_id,
|
|
3063
3063
|
custom_domain_id: e.custom_domain_id,
|
|
3064
3064
|
priority: e.priority,
|
|
3065
|
-
match:
|
|
3066
|
-
handlers:
|
|
3065
|
+
match: Vn(e.match),
|
|
3066
|
+
handlers: Hn(e.handlers),
|
|
3067
3067
|
created_at: e.created_at,
|
|
3068
3068
|
updated_at: e.updated_at
|
|
3069
3069
|
};
|
|
3070
3070
|
}
|
|
3071
|
-
function
|
|
3071
|
+
function Wn(e) {
|
|
3072
3072
|
return {
|
|
3073
3073
|
async create(t, n) {
|
|
3074
3074
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3094,14 +3094,14 @@ function Un(e) {
|
|
|
3094
3094
|
},
|
|
3095
3095
|
async get(n, r) {
|
|
3096
3096
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1);
|
|
3097
|
-
return i[0] ?
|
|
3097
|
+
return i[0] ? Un(i[0]) : null;
|
|
3098
3098
|
},
|
|
3099
3099
|
async list(r, i = {}) {
|
|
3100
3100
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(X.tenant_id, r)];
|
|
3101
3101
|
i.custom_domain_id && c.push(a(X.custom_domain_id, i.custom_domain_id));
|
|
3102
3102
|
let l = await e.select().from(X).where(t(...c)).orderBy(n(X.priority), n(X.created_at)).offset(o * s).limit(s);
|
|
3103
3103
|
return {
|
|
3104
|
-
proxy_routes: l.map(
|
|
3104
|
+
proxy_routes: l.map(Un),
|
|
3105
3105
|
start: o * s,
|
|
3106
3106
|
limit: s,
|
|
3107
3107
|
length: l.length
|
|
@@ -3120,14 +3120,14 @@ function Un(e) {
|
|
|
3120
3120
|
}
|
|
3121
3121
|
//#endregion
|
|
3122
3122
|
//#region src/adapters/scim.ts
|
|
3123
|
-
function
|
|
3123
|
+
function Gn(e) {
|
|
3124
3124
|
if (!e) return [];
|
|
3125
3125
|
try {
|
|
3126
3126
|
let t = JSON.parse(e);
|
|
3127
3127
|
if (!Array.isArray(t)) return [];
|
|
3128
3128
|
let n = [];
|
|
3129
3129
|
for (let e of t) {
|
|
3130
|
-
let t =
|
|
3130
|
+
let t = Se.safeParse(e);
|
|
3131
3131
|
t.success && n.push(t.data);
|
|
3132
3132
|
}
|
|
3133
3133
|
return n;
|
|
@@ -3135,7 +3135,7 @@ function Wn(e) {
|
|
|
3135
3135
|
return [];
|
|
3136
3136
|
}
|
|
3137
3137
|
}
|
|
3138
|
-
function
|
|
3138
|
+
function Kn(e) {
|
|
3139
3139
|
if (!e) return [];
|
|
3140
3140
|
try {
|
|
3141
3141
|
let t = JSON.parse(e);
|
|
@@ -3144,16 +3144,16 @@ function Gn(e) {
|
|
|
3144
3144
|
return [];
|
|
3145
3145
|
}
|
|
3146
3146
|
}
|
|
3147
|
-
function
|
|
3147
|
+
function qn(e) {
|
|
3148
3148
|
return {
|
|
3149
3149
|
connection_id: e.connection_id,
|
|
3150
3150
|
user_id_attribute: e.user_id_attribute,
|
|
3151
|
-
mapping:
|
|
3151
|
+
mapping: Gn(e.mapping),
|
|
3152
3152
|
created_at: e.created_at,
|
|
3153
3153
|
updated_at: e.updated_at
|
|
3154
3154
|
};
|
|
3155
3155
|
}
|
|
3156
|
-
function
|
|
3156
|
+
function Jn(e) {
|
|
3157
3157
|
return {
|
|
3158
3158
|
async create(t, n) {
|
|
3159
3159
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3163,7 +3163,7 @@ function qn(e) {
|
|
|
3163
3163
|
created_at: r,
|
|
3164
3164
|
updated_at: r
|
|
3165
3165
|
};
|
|
3166
|
-
return await e.insert(
|
|
3166
|
+
return await e.insert(et).values({
|
|
3167
3167
|
connection_id: i.connection_id,
|
|
3168
3168
|
tenant_id: t,
|
|
3169
3169
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3173,31 +3173,31 @@ function qn(e) {
|
|
|
3173
3173
|
}), i;
|
|
3174
3174
|
},
|
|
3175
3175
|
async get(n, r) {
|
|
3176
|
-
let i = await e.select().from(
|
|
3177
|
-
return i[0] ?
|
|
3176
|
+
let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.connection_id, r))).limit(1);
|
|
3177
|
+
return i[0] ? qn(i[0]) : null;
|
|
3178
3178
|
},
|
|
3179
3179
|
async update(n, r, i) {
|
|
3180
|
-
if ((await e.select({ connection_id:
|
|
3180
|
+
if ((await e.select({ connection_id: et.connection_id }).from(et).where(t(a(et.tenant_id, n), a(et.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3181
3181
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3182
|
-
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(
|
|
3182
|
+
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(et).set(o).where(t(a(et.tenant_id, n), a(et.connection_id, r))), !0;
|
|
3183
3183
|
},
|
|
3184
3184
|
async remove(n, r) {
|
|
3185
|
-
return (await e.select({ connection_id:
|
|
3185
|
+
return (await e.select({ connection_id: et.connection_id }).from(et).where(t(a(et.tenant_id, n), a(et.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(et).where(t(a(et.tenant_id, n), a(et.connection_id, r))), !0);
|
|
3186
3186
|
}
|
|
3187
3187
|
};
|
|
3188
3188
|
}
|
|
3189
|
-
function
|
|
3189
|
+
function Yn(e) {
|
|
3190
3190
|
return {
|
|
3191
3191
|
token_id: e.token_id,
|
|
3192
3192
|
connection_id: e.connection_id,
|
|
3193
3193
|
token_hash: e.token_hash,
|
|
3194
|
-
scopes:
|
|
3194
|
+
scopes: Kn(e.scopes),
|
|
3195
3195
|
valid_until: e.valid_until ?? void 0,
|
|
3196
3196
|
created_at: e.created_at,
|
|
3197
3197
|
last_used_at: e.last_used_at ?? void 0
|
|
3198
3198
|
};
|
|
3199
3199
|
}
|
|
3200
|
-
function
|
|
3200
|
+
function Xn(e) {
|
|
3201
3201
|
return {
|
|
3202
3202
|
async create(t, n) {
|
|
3203
3203
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3220,14 +3220,14 @@ function Yn(e) {
|
|
|
3220
3220
|
},
|
|
3221
3221
|
async get(n, r) {
|
|
3222
3222
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1);
|
|
3223
|
-
return i[0] ?
|
|
3223
|
+
return i[0] ? Yn(i[0]) : null;
|
|
3224
3224
|
},
|
|
3225
3225
|
async getByHash(n, r) {
|
|
3226
3226
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_hash, r))).limit(1);
|
|
3227
|
-
return i[0] ?
|
|
3227
|
+
return i[0] ? Yn(i[0]) : null;
|
|
3228
3228
|
},
|
|
3229
3229
|
async listByConnection(n, r) {
|
|
3230
|
-
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(
|
|
3230
|
+
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(Yn);
|
|
3231
3231
|
},
|
|
3232
3232
|
async markUsed(n, r, i) {
|
|
3233
3233
|
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);
|
|
@@ -3237,7 +3237,7 @@ function Yn(e) {
|
|
|
3237
3237
|
}
|
|
3238
3238
|
};
|
|
3239
3239
|
}
|
|
3240
|
-
function
|
|
3240
|
+
function Zn(e) {
|
|
3241
3241
|
return {
|
|
3242
3242
|
connection_id: e.connection_id,
|
|
3243
3243
|
external_id: e.external_id,
|
|
@@ -3245,7 +3245,7 @@ function Xn(e) {
|
|
|
3245
3245
|
created_at: e.created_at
|
|
3246
3246
|
};
|
|
3247
3247
|
}
|
|
3248
|
-
function
|
|
3248
|
+
function Qn(e) {
|
|
3249
3249
|
return {
|
|
3250
3250
|
async create(t, n) {
|
|
3251
3251
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3254,7 +3254,7 @@ function Zn(e) {
|
|
|
3254
3254
|
user_id: n.user_id,
|
|
3255
3255
|
created_at: r
|
|
3256
3256
|
};
|
|
3257
|
-
return await e.insert(
|
|
3257
|
+
return await e.insert(tt).values({
|
|
3258
3258
|
tenant_id: t,
|
|
3259
3259
|
connection_id: i.connection_id,
|
|
3260
3260
|
external_id: i.external_id,
|
|
@@ -3263,21 +3263,21 @@ function Zn(e) {
|
|
|
3263
3263
|
}), i;
|
|
3264
3264
|
},
|
|
3265
3265
|
async getByExternalId(n, r, i) {
|
|
3266
|
-
let o = await e.select().from(
|
|
3267
|
-
return o[0] ?
|
|
3266
|
+
let o = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.connection_id, r), a(tt.external_id, i))).limit(1);
|
|
3267
|
+
return o[0] ? Zn(o[0]) : null;
|
|
3268
3268
|
},
|
|
3269
3269
|
async getByUserId(n, r, i) {
|
|
3270
|
-
let o = await e.select().from(
|
|
3271
|
-
return o[0] ?
|
|
3270
|
+
let o = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.connection_id, r), a(tt.user_id, i))).limit(1);
|
|
3271
|
+
return o[0] ? Zn(o[0]) : null;
|
|
3272
3272
|
},
|
|
3273
3273
|
async remove(n, r, i) {
|
|
3274
|
-
return (await e.select({ user_id:
|
|
3274
|
+
return (await e.select({ user_id: tt.user_id }).from(tt).where(t(a(tt.tenant_id, n), a(tt.connection_id, r), a(tt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.connection_id, r), a(tt.user_id, i))), !0);
|
|
3275
3275
|
}
|
|
3276
3276
|
};
|
|
3277
3277
|
}
|
|
3278
3278
|
//#endregion
|
|
3279
3279
|
//#region src/adapters/refreshTokens.ts
|
|
3280
|
-
function
|
|
3280
|
+
function $n(e) {
|
|
3281
3281
|
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({
|
|
3282
3282
|
created_at_ts: n,
|
|
3283
3283
|
expires_at_ts: r,
|
|
@@ -3300,10 +3300,10 @@ function Qn(e) {
|
|
|
3300
3300
|
resource_servers: Q(l, [])
|
|
3301
3301
|
});
|
|
3302
3302
|
}
|
|
3303
|
-
function
|
|
3303
|
+
function er(e, t) {
|
|
3304
3304
|
return Math.max(e ?? 0, t ?? 0);
|
|
3305
3305
|
}
|
|
3306
|
-
function
|
|
3306
|
+
function tr(e) {
|
|
3307
3307
|
return {
|
|
3308
3308
|
async create(n, r) {
|
|
3309
3309
|
let i = Date.now(), o = {
|
|
@@ -3324,22 +3324,22 @@ function er(e) {
|
|
|
3324
3324
|
expires_at_ts: D(r.expires_at),
|
|
3325
3325
|
idle_expires_at_ts: D(r.idle_expires_at),
|
|
3326
3326
|
last_exchanged_at_ts: D(r.last_exchanged_at)
|
|
3327
|
-
}, s = [e.insert(P).values(o)], c =
|
|
3327
|
+
}, s = [e.insert(P).values(o)], c = er(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3328
3328
|
return c > 0 && o.login_id && s.push(e.update(F).set({
|
|
3329
3329
|
expires_at_ts: c,
|
|
3330
3330
|
updated_at_ts: i
|
|
3331
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await
|
|
3331
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await mt(e, s), $n({
|
|
3332
3332
|
...o,
|
|
3333
3333
|
tenant_id: n
|
|
3334
3334
|
});
|
|
3335
3335
|
},
|
|
3336
3336
|
async get(n, r) {
|
|
3337
3337
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.id, r))).get();
|
|
3338
|
-
return i ?
|
|
3338
|
+
return i ? $n(i) : null;
|
|
3339
3339
|
},
|
|
3340
3340
|
async getByLookup(n, r) {
|
|
3341
3341
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.token_lookup, r))).get();
|
|
3342
|
-
return i ?
|
|
3342
|
+
return i ? $n(i) : null;
|
|
3343
3343
|
},
|
|
3344
3344
|
async update(n, r, i, o) {
|
|
3345
3345
|
let s = {};
|
|
@@ -3353,14 +3353,14 @@ function er(e) {
|
|
|
3353
3353
|
async list(o, s) {
|
|
3354
3354
|
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();
|
|
3355
3355
|
if (f) {
|
|
3356
|
-
let e =
|
|
3356
|
+
let e = st(P, f, ["user_id", "login_id"]);
|
|
3357
3357
|
e && (p = p.where(t(a(P.tenant_id, o), e)));
|
|
3358
3358
|
}
|
|
3359
3359
|
if (d?.sort_by) {
|
|
3360
3360
|
let e = P[d.sort_by];
|
|
3361
3361
|
e && (p = p.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3362
3362
|
}
|
|
3363
|
-
let m = (await p.offset(c * l).limit(l)).map(
|
|
3363
|
+
let m = (await p.offset(c * l).limit(l)).map($n);
|
|
3364
3364
|
if (!u) return { refresh_tokens: m };
|
|
3365
3365
|
let [h] = await e.select({ count: r() }).from(P).where(a(P.tenant_id, o));
|
|
3366
3366
|
return {
|
|
@@ -3383,15 +3383,15 @@ function er(e) {
|
|
|
3383
3383
|
}
|
|
3384
3384
|
//#endregion
|
|
3385
3385
|
//#region src/adapters/resourceServers.ts
|
|
3386
|
-
var
|
|
3387
|
-
function
|
|
3386
|
+
var nr = ["name", "identifier"];
|
|
3387
|
+
function rr() {
|
|
3388
3388
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3389
3389
|
}
|
|
3390
|
-
var
|
|
3390
|
+
var ir = [
|
|
3391
3391
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3392
3392
|
"allow_offline_access",
|
|
3393
3393
|
"is_system"
|
|
3394
|
-
],
|
|
3394
|
+
], ar = new Set([
|
|
3395
3395
|
"id",
|
|
3396
3396
|
"tenant_id",
|
|
3397
3397
|
"identifier",
|
|
@@ -3410,17 +3410,17 @@ var rr = [
|
|
|
3410
3410
|
"created_at",
|
|
3411
3411
|
"updated_at"
|
|
3412
3412
|
]);
|
|
3413
|
-
function
|
|
3413
|
+
function or(e) {
|
|
3414
3414
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3415
3415
|
s.scopes = Q(r, []), s.options = Q(i, {}), s.metadata = Q(a), n !== void 0 && (s.verificationKey = n);
|
|
3416
|
-
for (let e of
|
|
3416
|
+
for (let e of ir) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3417
3417
|
return O(s);
|
|
3418
3418
|
}
|
|
3419
|
-
function
|
|
3419
|
+
function sr(e) {
|
|
3420
3420
|
return {
|
|
3421
3421
|
async create(t, n) {
|
|
3422
3422
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3423
|
-
id: n.id ||
|
|
3423
|
+
id: n.id || rr(),
|
|
3424
3424
|
tenant_id: t,
|
|
3425
3425
|
identifier: n.identifier,
|
|
3426
3426
|
name: n.name,
|
|
@@ -3435,37 +3435,37 @@ function or(e) {
|
|
|
3435
3435
|
created_at: r,
|
|
3436
3436
|
updated_at: r
|
|
3437
3437
|
};
|
|
3438
|
-
for (let e of
|
|
3439
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i),
|
|
3438
|
+
for (let e of ir) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3439
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), or({
|
|
3440
3440
|
...i,
|
|
3441
3441
|
tenant_id: t
|
|
3442
3442
|
});
|
|
3443
3443
|
},
|
|
3444
3444
|
async get(n, r) {
|
|
3445
3445
|
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3446
|
-
return i ?
|
|
3446
|
+
return i ? or(i) : null;
|
|
3447
3447
|
},
|
|
3448
3448
|
async update(n, r, i) {
|
|
3449
3449
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3450
3450
|
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${K.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3451
|
-
for (let e of
|
|
3451
|
+
for (let e of ir) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3452
3452
|
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3453
3453
|
},
|
|
3454
3454
|
async list(o, s) {
|
|
3455
3455
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(K.tenant_id, o)];
|
|
3456
3456
|
if (f) {
|
|
3457
|
-
let e =
|
|
3457
|
+
let e = xe(f, nr);
|
|
3458
3458
|
if (e) {
|
|
3459
|
-
let t =
|
|
3459
|
+
let t = st(K, e, nr, ["name", "identifier"]);
|
|
3460
3460
|
t && h.push(t);
|
|
3461
3461
|
}
|
|
3462
3462
|
}
|
|
3463
3463
|
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3464
|
-
if (d?.sort_by &&
|
|
3464
|
+
if (d?.sort_by && ar.has(d.sort_by)) {
|
|
3465
3465
|
let e = K[d.sort_by];
|
|
3466
3466
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3467
3467
|
}
|
|
3468
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3468
|
+
let _ = (await g.offset(p * m).limit(m)).map(or);
|
|
3469
3469
|
if (!u) return { resource_servers: _ };
|
|
3470
3470
|
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3471
3471
|
return {
|
|
@@ -3482,11 +3482,12 @@ function or(e) {
|
|
|
3482
3482
|
}
|
|
3483
3483
|
//#endregion
|
|
3484
3484
|
//#region src/adapters/rolePermissions.ts
|
|
3485
|
-
function
|
|
3485
|
+
function cr(e) {
|
|
3486
3486
|
return {
|
|
3487
3487
|
async assign(t, n, r) {
|
|
3488
|
+
if (r.length === 0) return !0;
|
|
3488
3489
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3489
|
-
return await e.insert(
|
|
3490
|
+
return await e.insert(Be).values(r.map((e) => ({
|
|
3490
3491
|
tenant_id: t,
|
|
3491
3492
|
role_id: n,
|
|
3492
3493
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3496,10 +3497,10 @@ function sr(e) {
|
|
|
3496
3497
|
},
|
|
3497
3498
|
async list(n, r, i) {
|
|
3498
3499
|
let o = await e.select({
|
|
3499
|
-
resource_server_identifier:
|
|
3500
|
-
permission_name:
|
|
3501
|
-
created_at:
|
|
3502
|
-
}).from(
|
|
3500
|
+
resource_server_identifier: Be.resource_server_identifier,
|
|
3501
|
+
permission_name: Be.permission_name,
|
|
3502
|
+
created_at: Be.created_at
|
|
3503
|
+
}).from(Be).where(t(a(Be.tenant_id, n), a(Be.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3503
3504
|
if (s.length > 0) {
|
|
3504
3505
|
let r = await e.select({
|
|
3505
3506
|
identifier: K.identifier,
|
|
@@ -3513,18 +3514,19 @@ function sr(e) {
|
|
|
3513
3514
|
}));
|
|
3514
3515
|
},
|
|
3515
3516
|
async remove(n, r, i) {
|
|
3516
|
-
|
|
3517
|
-
|
|
3517
|
+
if (i.length === 0) return !0;
|
|
3518
|
+
let o = i.map((e) => t(a(Be.resource_server_identifier, e.resource_server_identifier), a(Be.permission_name, e.permission_name)));
|
|
3519
|
+
return await e.delete(Be).where(t(a(Be.tenant_id, n), a(Be.role_id, r), v(...o))).returning(), !0;
|
|
3518
3520
|
}
|
|
3519
3521
|
};
|
|
3520
3522
|
}
|
|
3521
3523
|
//#endregion
|
|
3522
3524
|
//#region src/adapters/userPermissions.ts
|
|
3523
|
-
function
|
|
3525
|
+
function lr(e) {
|
|
3524
3526
|
return {
|
|
3525
3527
|
async create(t, n, r, i) {
|
|
3526
3528
|
try {
|
|
3527
|
-
await e.insert(
|
|
3529
|
+
await e.insert(Ve).values({
|
|
3528
3530
|
tenant_id: t,
|
|
3529
3531
|
user_id: n,
|
|
3530
3532
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3539,9 +3541,9 @@ function cr(e) {
|
|
|
3539
3541
|
return !0;
|
|
3540
3542
|
},
|
|
3541
3543
|
async list(n, r, i, o) {
|
|
3542
|
-
let s = [a(
|
|
3543
|
-
o && s.push(a(
|
|
3544
|
-
let c = await e.select().from(
|
|
3544
|
+
let s = [a(Ve.tenant_id, n), a(Ve.user_id, r)];
|
|
3545
|
+
o && s.push(a(Ve.organization_id, o));
|
|
3546
|
+
let c = await e.select().from(Ve).where(t(...s)).all();
|
|
3545
3547
|
return await Promise.all(c.map(async (r) => {
|
|
3546
3548
|
let i = await e.select({ name: K.name }).from(K).where(t(a(K.tenant_id, n), a(K.identifier, r.resource_server_identifier))).get();
|
|
3547
3549
|
return {
|
|
@@ -3553,13 +3555,13 @@ function cr(e) {
|
|
|
3553
3555
|
}));
|
|
3554
3556
|
},
|
|
3555
3557
|
async remove(n, r, i, o) {
|
|
3556
|
-
return (await e.delete(
|
|
3558
|
+
return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.user_id, r), a(Ve.resource_server_identifier, i.resource_server_identifier), a(Ve.permission_name, i.permission_name), a(Ve.organization_id, o || ""))).returning()).length > 0;
|
|
3557
3559
|
}
|
|
3558
3560
|
};
|
|
3559
3561
|
}
|
|
3560
3562
|
//#endregion
|
|
3561
3563
|
//#region src/adapters/roles.ts
|
|
3562
|
-
function
|
|
3564
|
+
function ur(e) {
|
|
3563
3565
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3564
3566
|
return O({
|
|
3565
3567
|
...i,
|
|
@@ -3567,7 +3569,7 @@ function lr(e) {
|
|
|
3567
3569
|
metadata: Q(r)
|
|
3568
3570
|
});
|
|
3569
3571
|
}
|
|
3570
|
-
function
|
|
3572
|
+
function dr(e) {
|
|
3571
3573
|
return {
|
|
3572
3574
|
async create(t, n) {
|
|
3573
3575
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3580,26 +3582,26 @@ function ur(e) {
|
|
|
3580
3582
|
created_at: r,
|
|
3581
3583
|
updated_at: r
|
|
3582
3584
|
};
|
|
3583
|
-
return await e.insert(W).values(i),
|
|
3585
|
+
return await e.insert(W).values(i), ur({
|
|
3584
3586
|
...i,
|
|
3585
3587
|
tenant_id: t
|
|
3586
3588
|
});
|
|
3587
3589
|
},
|
|
3588
3590
|
async get(n, r) {
|
|
3589
3591
|
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3590
|
-
return i ?
|
|
3592
|
+
return i ? ur(i) : null;
|
|
3591
3593
|
},
|
|
3592
3594
|
async update(n, r, i) {
|
|
3593
3595
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3594
3596
|
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(W).set(o).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3595
3597
|
},
|
|
3596
3598
|
async list(o, s) {
|
|
3597
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3599
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(W, f, ["name"]) : void 0, m = p ? t(a(W.tenant_id, o), p) : a(W.tenant_id, o), h = e.select().from(W).where(m).$dynamic();
|
|
3598
3600
|
if (d?.sort_by) {
|
|
3599
3601
|
let e = W[d.sort_by];
|
|
3600
3602
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3601
3603
|
}
|
|
3602
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3604
|
+
let g = (await h.offset(c * l).limit(l)).map(ur);
|
|
3603
3605
|
if (!u) return { roles: g };
|
|
3604
3606
|
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3605
3607
|
return {
|
|
@@ -3616,7 +3618,7 @@ function ur(e) {
|
|
|
3616
3618
|
}
|
|
3617
3619
|
//#endregion
|
|
3618
3620
|
//#region src/adapters/sessions.ts
|
|
3619
|
-
var
|
|
3621
|
+
var fr = ["created_at_ts", "updated_at_ts"], pr = [
|
|
3620
3622
|
"expires_at_ts",
|
|
3621
3623
|
"idle_expires_at_ts",
|
|
3622
3624
|
"authenticated_at_ts",
|
|
@@ -3624,7 +3626,7 @@ var dr = ["created_at_ts", "updated_at_ts"], fr = [
|
|
|
3624
3626
|
"used_at_ts",
|
|
3625
3627
|
"revoked_at_ts"
|
|
3626
3628
|
];
|
|
3627
|
-
function
|
|
3629
|
+
function mr(e) {
|
|
3628
3630
|
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({
|
|
3629
3631
|
created_at_ts: n,
|
|
3630
3632
|
updated_at_ts: r,
|
|
@@ -3634,7 +3636,7 @@ function pr(e) {
|
|
|
3634
3636
|
last_interaction_at_ts: s,
|
|
3635
3637
|
used_at_ts: c,
|
|
3636
3638
|
revoked_at_ts: l
|
|
3637
|
-
}, [...
|
|
3639
|
+
}, [...fr], [...pr]);
|
|
3638
3640
|
return O({
|
|
3639
3641
|
...f,
|
|
3640
3642
|
...p,
|
|
@@ -3642,10 +3644,10 @@ function pr(e) {
|
|
|
3642
3644
|
clients: Q(d, [])
|
|
3643
3645
|
});
|
|
3644
3646
|
}
|
|
3645
|
-
function
|
|
3647
|
+
function hr(e, t) {
|
|
3646
3648
|
return Math.max(e ?? 0, t ?? 0);
|
|
3647
3649
|
}
|
|
3648
|
-
function
|
|
3650
|
+
function gr(e) {
|
|
3649
3651
|
return {
|
|
3650
3652
|
async create(n, r) {
|
|
3651
3653
|
let i = Date.now(), o = {
|
|
@@ -3663,23 +3665,23 @@ function hr(e) {
|
|
|
3663
3665
|
last_interaction_at_ts: r.last_interaction_at ? D(r.last_interaction_at) : i,
|
|
3664
3666
|
used_at_ts: D(r.used_at),
|
|
3665
3667
|
revoked_at_ts: D(r.revoked_at)
|
|
3666
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3668
|
+
}, s = [e.insert(N).values(o)], c = hr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3667
3669
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3668
3670
|
expires_at_ts: c,
|
|
3669
3671
|
updated_at_ts: i
|
|
3670
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await
|
|
3672
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await mt(e, s), mr({
|
|
3671
3673
|
...o,
|
|
3672
3674
|
tenant_id: n
|
|
3673
3675
|
});
|
|
3674
3676
|
},
|
|
3675
3677
|
async get(n, r) {
|
|
3676
3678
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3677
|
-
return i ?
|
|
3679
|
+
return i ? mr(i) : null;
|
|
3678
3680
|
},
|
|
3679
3681
|
async update(n, r, i) {
|
|
3680
3682
|
let o = { updated_at_ts: Date.now() };
|
|
3681
3683
|
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));
|
|
3682
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3684
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = hr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3683
3685
|
if (c > 0 && l) {
|
|
3684
3686
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3685
3687
|
r && await e.update(F).set({
|
|
@@ -3690,12 +3692,12 @@ function hr(e) {
|
|
|
3690
3692
|
return s.length > 0;
|
|
3691
3693
|
},
|
|
3692
3694
|
async list(o, s) {
|
|
3693
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3695
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? st(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();
|
|
3694
3696
|
if (d?.sort_by) {
|
|
3695
3697
|
let e = N[d.sort_by];
|
|
3696
3698
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3697
3699
|
}
|
|
3698
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3700
|
+
let g = (await h.offset(c * l).limit(l)).map(mr);
|
|
3699
3701
|
if (!u) return { sessions: g };
|
|
3700
3702
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3701
3703
|
return {
|
|
@@ -3712,7 +3714,7 @@ function hr(e) {
|
|
|
3712
3714
|
}
|
|
3713
3715
|
//#endregion
|
|
3714
3716
|
//#region src/adapters/tenants.ts
|
|
3715
|
-
var
|
|
3717
|
+
var _r = [
|
|
3716
3718
|
"session_cookie",
|
|
3717
3719
|
"enabled_locales",
|
|
3718
3720
|
"error_page",
|
|
@@ -3728,25 +3730,25 @@ var gr = [
|
|
|
3728
3730
|
"acr_values_supported",
|
|
3729
3731
|
"mtls",
|
|
3730
3732
|
"mfa"
|
|
3731
|
-
],
|
|
3733
|
+
], vr = [
|
|
3732
3734
|
"allow_organization_name_in_authentication_api",
|
|
3733
3735
|
"customize_mfa_in_postlogin_action",
|
|
3734
3736
|
"pushed_authorization_requests_supported",
|
|
3735
3737
|
"authorization_response_iss_parameter_supported"
|
|
3736
3738
|
];
|
|
3737
|
-
function
|
|
3739
|
+
function yr(e) {
|
|
3738
3740
|
let t = { ...e };
|
|
3739
|
-
for (let e of
|
|
3740
|
-
for (let e of
|
|
3741
|
+
for (let e of _r) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3742
|
+
for (let e of vr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3741
3743
|
return O(t);
|
|
3742
3744
|
}
|
|
3743
|
-
function
|
|
3745
|
+
function br(e) {
|
|
3744
3746
|
let t = { ...e };
|
|
3745
|
-
ce(e,
|
|
3746
|
-
for (let n of
|
|
3747
|
+
ce(e, _r, t);
|
|
3748
|
+
for (let n of vr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3747
3749
|
return se(t);
|
|
3748
3750
|
}
|
|
3749
|
-
function
|
|
3751
|
+
function xr(e) {
|
|
3750
3752
|
return {
|
|
3751
3753
|
async create(t) {
|
|
3752
3754
|
let n = {
|
|
@@ -3754,26 +3756,26 @@ function br(e) {
|
|
|
3754
3756
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3755
3757
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3756
3758
|
...t
|
|
3757
|
-
}, r =
|
|
3759
|
+
}, r = br(n);
|
|
3758
3760
|
try {
|
|
3759
3761
|
await e.insert(k).values(r);
|
|
3760
3762
|
} catch (e) {
|
|
3761
3763
|
let t = e?.message ?? "";
|
|
3762
|
-
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
|
|
3764
|
+
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 Oe(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3763
3765
|
}
|
|
3764
3766
|
return n;
|
|
3765
3767
|
},
|
|
3766
3768
|
async get(t) {
|
|
3767
3769
|
let n = await e.select().from(k).where(a(k.id, t)).get();
|
|
3768
|
-
return n ?
|
|
3770
|
+
return n ? yr(n) : null;
|
|
3769
3771
|
},
|
|
3770
3772
|
async list(t) {
|
|
3771
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3773
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? st(k, l, ["friendly_name"]) : void 0, d = e.select().from(k).$dynamic();
|
|
3772
3774
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3773
3775
|
let e = k[c.sort_by];
|
|
3774
3776
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3775
3777
|
}
|
|
3776
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3778
|
+
let f = (await d.offset(a * o).limit(o)).map(yr);
|
|
3777
3779
|
if (!s) return { tenants: f };
|
|
3778
3780
|
let p = e.select({ count: r() }).from(k).$dynamic();
|
|
3779
3781
|
u && (p = p.where(u));
|
|
@@ -3786,7 +3788,7 @@ function br(e) {
|
|
|
3786
3788
|
};
|
|
3787
3789
|
},
|
|
3788
3790
|
async update(t, n) {
|
|
3789
|
-
let r =
|
|
3791
|
+
let r = br({
|
|
3790
3792
|
...n,
|
|
3791
3793
|
id: t,
|
|
3792
3794
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3800,62 +3802,62 @@ function br(e) {
|
|
|
3800
3802
|
}
|
|
3801
3803
|
//#endregion
|
|
3802
3804
|
//#region src/adapters/themes.ts
|
|
3803
|
-
var
|
|
3805
|
+
var Sr = [
|
|
3804
3806
|
"colors",
|
|
3805
3807
|
"borders",
|
|
3806
3808
|
"fonts",
|
|
3807
3809
|
"page_background",
|
|
3808
3810
|
"widget"
|
|
3809
3811
|
];
|
|
3810
|
-
function
|
|
3811
|
-
let { tenant_id: t, ...n } = e, r =
|
|
3812
|
+
function Cr(e) {
|
|
3813
|
+
let { tenant_id: t, ...n } = e, r = it(n, Sr);
|
|
3812
3814
|
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);
|
|
3813
3815
|
}
|
|
3814
|
-
function
|
|
3816
|
+
function wr(e) {
|
|
3815
3817
|
return {
|
|
3816
3818
|
async create(t, n, r, i) {
|
|
3817
3819
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3818
|
-
...
|
|
3820
|
+
...rt(n),
|
|
3819
3821
|
tenant_id: t,
|
|
3820
3822
|
themeId: s,
|
|
3821
3823
|
created_at: a?.created_at ?? o,
|
|
3822
3824
|
updated_at: a?.updated_at ?? o
|
|
3823
3825
|
};
|
|
3824
|
-
return await e.insert(
|
|
3826
|
+
return await e.insert(We).values(c), Cr({
|
|
3825
3827
|
...c,
|
|
3826
3828
|
tenant_id: t
|
|
3827
3829
|
});
|
|
3828
3830
|
},
|
|
3829
3831
|
async get(n, r) {
|
|
3830
|
-
let i = await e.select().from(
|
|
3831
|
-
return i ?
|
|
3832
|
+
let i = await e.select().from(We).where(t(a(We.tenant_id, n), a(We.themeId, r))).get();
|
|
3833
|
+
return i ? Cr(i) : null;
|
|
3832
3834
|
},
|
|
3833
3835
|
async update(n, r, i) {
|
|
3834
|
-
let o =
|
|
3835
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3836
|
+
let o = rt(i);
|
|
3837
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(We).set(o).where(t(a(We.tenant_id, n), a(We.themeId, r))), !0;
|
|
3836
3838
|
},
|
|
3837
3839
|
async remove(n, r) {
|
|
3838
|
-
return (await e.delete(
|
|
3840
|
+
return (await e.delete(We).where(t(a(We.tenant_id, n), a(We.themeId, r))).returning()).length > 0;
|
|
3839
3841
|
}
|
|
3840
3842
|
};
|
|
3841
3843
|
}
|
|
3842
3844
|
//#endregion
|
|
3843
3845
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3844
|
-
function
|
|
3846
|
+
function Tr(e) {
|
|
3845
3847
|
return {
|
|
3846
3848
|
async get(t) {
|
|
3847
|
-
let n = await e.select({ body:
|
|
3849
|
+
let n = await e.select({ body: Ue.body }).from(Ue).where(a(Ue.tenant_id, t)).get();
|
|
3848
3850
|
return n ? { body: n.body } : null;
|
|
3849
3851
|
},
|
|
3850
3852
|
async set(t, n) {
|
|
3851
3853
|
let r = Date.now();
|
|
3852
|
-
await e.insert(
|
|
3854
|
+
await e.insert(Ue).values({
|
|
3853
3855
|
tenant_id: t,
|
|
3854
3856
|
body: n.body,
|
|
3855
3857
|
created_at_ts: r,
|
|
3856
3858
|
updated_at_ts: r
|
|
3857
3859
|
}).onConflictDoUpdate({
|
|
3858
|
-
target:
|
|
3860
|
+
target: Ue.tenant_id,
|
|
3859
3861
|
set: {
|
|
3860
3862
|
body: n.body,
|
|
3861
3863
|
updated_at_ts: r
|
|
@@ -3863,20 +3865,20 @@ function wr(e) {
|
|
|
3863
3865
|
});
|
|
3864
3866
|
},
|
|
3865
3867
|
async delete(t) {
|
|
3866
|
-
await e.delete(
|
|
3868
|
+
await e.delete(Ue).where(a(Ue.tenant_id, t));
|
|
3867
3869
|
}
|
|
3868
3870
|
};
|
|
3869
3871
|
}
|
|
3870
3872
|
//#endregion
|
|
3871
3873
|
//#region src/adapters/userActivity.ts
|
|
3872
|
-
function
|
|
3874
|
+
function Er(e) {
|
|
3873
3875
|
let t = {};
|
|
3874
3876
|
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;
|
|
3875
3877
|
}
|
|
3876
|
-
function
|
|
3878
|
+
function Dr(e) {
|
|
3877
3879
|
return {
|
|
3878
3880
|
async get(n, r) {
|
|
3879
|
-
let i = await e.select().from(
|
|
3881
|
+
let i = await e.select().from(Ne).where(t(a(Ne.tenant_id, n), a(Ne.user_id, r))).get();
|
|
3880
3882
|
return i ? {
|
|
3881
3883
|
user_id: i.user_id,
|
|
3882
3884
|
last_login: i.last_login ?? void 0,
|
|
@@ -3887,7 +3889,7 @@ function Er(e) {
|
|
|
3887
3889
|
} : null;
|
|
3888
3890
|
},
|
|
3889
3891
|
async upsert(t, n, r) {
|
|
3890
|
-
let i =
|
|
3892
|
+
let i = Er(r), a = e.insert(Ne).values({
|
|
3891
3893
|
tenant_id: t,
|
|
3892
3894
|
user_id: n,
|
|
3893
3895
|
login_count: 0,
|
|
@@ -3898,7 +3900,7 @@ function Er(e) {
|
|
|
3898
3900
|
return;
|
|
3899
3901
|
}
|
|
3900
3902
|
await a.onConflictDoUpdate({
|
|
3901
|
-
target: [
|
|
3903
|
+
target: [Ne.tenant_id, Ne.user_id],
|
|
3902
3904
|
set: i
|
|
3903
3905
|
});
|
|
3904
3906
|
}
|
|
@@ -3906,13 +3908,13 @@ function Er(e) {
|
|
|
3906
3908
|
}
|
|
3907
3909
|
//#endregion
|
|
3908
3910
|
//#region src/adapters/outbox.ts
|
|
3909
|
-
function
|
|
3911
|
+
function Or(e) {
|
|
3910
3912
|
return {
|
|
3911
3913
|
...e,
|
|
3912
3914
|
payload: Q(e.payload, {})
|
|
3913
3915
|
};
|
|
3914
3916
|
}
|
|
3915
|
-
function
|
|
3917
|
+
function kr(e, t, n, r) {
|
|
3916
3918
|
return e.insert(Y).values({
|
|
3917
3919
|
id: t,
|
|
3918
3920
|
tenant_id: n,
|
|
@@ -3933,18 +3935,18 @@ function Or(e, t, n, r) {
|
|
|
3933
3935
|
claim_expires_at: null
|
|
3934
3936
|
});
|
|
3935
3937
|
}
|
|
3936
|
-
function
|
|
3938
|
+
function Ar(e) {
|
|
3937
3939
|
return {
|
|
3938
3940
|
async create(t, n) {
|
|
3939
3941
|
let r = b();
|
|
3940
|
-
return await
|
|
3942
|
+
return await kr(e, r, t, n), r;
|
|
3941
3943
|
},
|
|
3942
3944
|
async getByIds(t) {
|
|
3943
|
-
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(
|
|
3945
|
+
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(Or);
|
|
3944
3946
|
},
|
|
3945
3947
|
async getUnprocessed(n) {
|
|
3946
3948
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3947
|
-
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(
|
|
3949
|
+
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(Or);
|
|
3948
3950
|
},
|
|
3949
3951
|
async claimEvents(n, r, i) {
|
|
3950
3952
|
if (n.length === 0) return [];
|
|
@@ -4014,10 +4016,10 @@ function kr(e) {
|
|
|
4014
4016
|
}
|
|
4015
4017
|
//#endregion
|
|
4016
4018
|
//#region src/adapters/users.ts
|
|
4017
|
-
function
|
|
4018
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4019
|
+
function jr(e, t, n) {
|
|
4020
|
+
return (n?.outboxEvents ?? []).map((n) => kr(e, n.id, t, n));
|
|
4019
4021
|
}
|
|
4020
|
-
var
|
|
4022
|
+
var Mr = [
|
|
4021
4023
|
"user_id",
|
|
4022
4024
|
"email",
|
|
4023
4025
|
"email_verified",
|
|
@@ -4039,23 +4041,23 @@ var jr = [
|
|
|
4039
4041
|
"login_count",
|
|
4040
4042
|
"created_at",
|
|
4041
4043
|
"updated_at"
|
|
4042
|
-
],
|
|
4044
|
+
], Nr = [
|
|
4043
4045
|
"email",
|
|
4044
4046
|
"name",
|
|
4045
4047
|
"phone_number",
|
|
4046
4048
|
"user_id"
|
|
4047
|
-
],
|
|
4049
|
+
], Pr = new Set([
|
|
4048
4050
|
"last_login",
|
|
4049
4051
|
"last_ip",
|
|
4050
4052
|
"login_count"
|
|
4051
|
-
]),
|
|
4052
|
-
coalesce:
|
|
4053
|
+
]), Fr = o(j), Ir = o(Ne), Lr = Object.fromEntries(Mr.map((e) => [e, e === "login_count" ? {
|
|
4054
|
+
coalesce: Ne.login_count,
|
|
4053
4055
|
defaultValue: 0
|
|
4054
|
-
} :
|
|
4055
|
-
function
|
|
4056
|
-
return t(a(
|
|
4056
|
+
} : Pr.has(e) ? Ir[e] : Fr[e]]));
|
|
4057
|
+
function Rr() {
|
|
4058
|
+
return t(a(Ne.tenant_id, j.tenant_id), a(Ne.user_id, j.user_id));
|
|
4057
4059
|
}
|
|
4058
|
-
function
|
|
4060
|
+
function zr(e, t) {
|
|
4059
4061
|
return {
|
|
4060
4062
|
...e,
|
|
4061
4063
|
last_login: t?.last_login,
|
|
@@ -4063,7 +4065,7 @@ function Rr(e, t) {
|
|
|
4063
4065
|
login_count: t?.login_count ?? 0
|
|
4064
4066
|
};
|
|
4065
4067
|
}
|
|
4066
|
-
function
|
|
4068
|
+
function Br(e, t) {
|
|
4067
4069
|
let n = {
|
|
4068
4070
|
connection: e.connection,
|
|
4069
4071
|
provider: e.provider,
|
|
@@ -4076,8 +4078,8 @@ function zr(e, t) {
|
|
|
4076
4078
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
4077
4079
|
}, n;
|
|
4078
4080
|
}
|
|
4079
|
-
function
|
|
4080
|
-
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 =
|
|
4081
|
+
function Vr(e, t = []) {
|
|
4082
|
+
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 = Br(e, !0), m = t.map((e) => Br(e, !1));
|
|
4081
4083
|
return O({
|
|
4082
4084
|
...f,
|
|
4083
4085
|
email: e.email || "",
|
|
@@ -4091,7 +4093,7 @@ function Br(e, t = []) {
|
|
|
4091
4093
|
identities: [p, ...m]
|
|
4092
4094
|
});
|
|
4093
4095
|
}
|
|
4094
|
-
function
|
|
4096
|
+
function Hr(e) {
|
|
4095
4097
|
let o = async (t, n, r) => {
|
|
4096
4098
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4097
4099
|
user_id: n.user_id,
|
|
@@ -4129,7 +4131,7 @@ function Vr(e) {
|
|
|
4129
4131
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4130
4132
|
try {
|
|
4131
4133
|
let c = [e.insert(j).values(a)];
|
|
4132
|
-
s && c.push(e.insert(
|
|
4134
|
+
s && c.push(e.insert(Ne).values({
|
|
4133
4135
|
tenant_id: t,
|
|
4134
4136
|
user_id: n.user_id,
|
|
4135
4137
|
last_login: n.last_login,
|
|
@@ -4145,12 +4147,12 @@ function Vr(e) {
|
|
|
4145
4147
|
created_at: i,
|
|
4146
4148
|
updated_at: i
|
|
4147
4149
|
}));
|
|
4148
|
-
for (let n of
|
|
4149
|
-
c.length > 1 ? await
|
|
4150
|
+
for (let n of jr(e, t, r)) c.push(n);
|
|
4151
|
+
c.length > 1 ? await mt(e, c) : await e.insert(j).values(a);
|
|
4150
4152
|
} catch (e) {
|
|
4151
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4153
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Oe(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Oe(500, { message: "Internal server error" }));
|
|
4152
4154
|
}
|
|
4153
|
-
return
|
|
4155
|
+
return Vr({
|
|
4154
4156
|
...a,
|
|
4155
4157
|
last_login: n.last_login,
|
|
4156
4158
|
last_ip: n.last_ip,
|
|
@@ -4161,10 +4163,10 @@ function Vr(e) {
|
|
|
4161
4163
|
create: o,
|
|
4162
4164
|
rawCreate: o,
|
|
4163
4165
|
async get(n, r) {
|
|
4164
|
-
let i = await e.select().from(j).leftJoin(
|
|
4166
|
+
let i = await e.select().from(j).leftJoin(Ne, Rr()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
4165
4167
|
if (!i) return null;
|
|
4166
4168
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
4167
|
-
return
|
|
4169
|
+
return Vr(zr(i.users, i.user_activity), o);
|
|
4168
4170
|
},
|
|
4169
4171
|
async update(n, r, i, o) {
|
|
4170
4172
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4191,8 +4193,8 @@ function Vr(e) {
|
|
|
4191
4193
|
"zoneinfo"
|
|
4192
4194
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4193
4195
|
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));
|
|
4194
|
-
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l =
|
|
4195
|
-
return u = l.length > 0 ? (await
|
|
4196
|
+
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l = jr(e, n, o), u;
|
|
4197
|
+
return u = l.length > 0 ? (await mt(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 Dr(e).upsert(n, r, {
|
|
4196
4198
|
last_login: i.last_login,
|
|
4197
4199
|
last_ip: i.last_ip,
|
|
4198
4200
|
login_count: i.login_count
|
|
@@ -4201,24 +4203,24 @@ function Vr(e) {
|
|
|
4201
4203
|
async list(o, s) {
|
|
4202
4204
|
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)];
|
|
4203
4205
|
if (m) {
|
|
4204
|
-
let e =
|
|
4206
|
+
let e = xe(m, Mr);
|
|
4205
4207
|
if (e) {
|
|
4206
|
-
let t =
|
|
4208
|
+
let t = st(Lr, e, Nr);
|
|
4207
4209
|
t && h.push(t);
|
|
4208
4210
|
}
|
|
4209
4211
|
}
|
|
4210
4212
|
let g = t(...h), _ = async (n) => {
|
|
4211
4213
|
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))) : [];
|
|
4212
|
-
return n.map((e) =>
|
|
4214
|
+
return n.map((e) => Vr(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4213
4215
|
};
|
|
4214
|
-
if (
|
|
4215
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4216
|
+
if (yt(s)) {
|
|
4217
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Oe(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4216
4218
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4217
4219
|
sortColumn: j.created_at,
|
|
4218
4220
|
idColumn: j.user_id,
|
|
4219
4221
|
sortOrder: n,
|
|
4220
4222
|
sortKey: `created_at:${n}`
|
|
4221
|
-
}, i =
|
|
4223
|
+
}, i = bt(s), a = St(s, r), { rows: o, next: c } = Ct((await e.select().from(j).leftJoin(Ne, Rr()).where(a ? t(g, a) : g).orderBy(...xt(r)).limit(i + 1)).map((e) => zr(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4222
4224
|
return {
|
|
4223
4225
|
users: l,
|
|
4224
4226
|
start: 0,
|
|
@@ -4227,17 +4229,17 @@ function Vr(e) {
|
|
|
4227
4229
|
next: c
|
|
4228
4230
|
};
|
|
4229
4231
|
}
|
|
4230
|
-
let v = e.select().from(j).leftJoin(
|
|
4232
|
+
let v = e.select().from(j).leftJoin(Ne, Rr()).where(g).$dynamic();
|
|
4231
4233
|
if (p?.sort_by) {
|
|
4232
|
-
let e =
|
|
4234
|
+
let e = Lr[p.sort_by];
|
|
4233
4235
|
if (e) {
|
|
4234
|
-
let t =
|
|
4236
|
+
let t = at(e) ? ot(e) : e;
|
|
4235
4237
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4236
4238
|
}
|
|
4237
4239
|
}
|
|
4238
|
-
let y = await _((await v.offset(c * u).limit(u)).map((e) =>
|
|
4240
|
+
let y = await _((await v.offset(c * u).limit(u)).map((e) => zr(e.users, e.user_activity)));
|
|
4239
4241
|
if (!d) return { users: y };
|
|
4240
|
-
let [ee] = await e.select({ count: r() }).from(j).leftJoin(
|
|
4242
|
+
let [ee] = await e.select({ count: r() }).from(j).leftJoin(Ne, Rr()).where(g);
|
|
4241
4243
|
return {
|
|
4242
4244
|
users: y,
|
|
4243
4245
|
start: c * u,
|
|
@@ -4249,12 +4251,12 @@ function Vr(e) {
|
|
|
4249
4251
|
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 = [
|
|
4250
4252
|
e.delete(q).where(t(a(q.tenant_id, n), l(q.user_id, u))),
|
|
4251
4253
|
e.delete(M).where(t(a(M.tenant_id, n), l(M.user_id, u))),
|
|
4252
|
-
e.delete(
|
|
4254
|
+
e.delete(Ne).where(t(a(Ne.tenant_id, n), l(Ne.user_id, u))),
|
|
4253
4255
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4254
4256
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4255
4257
|
], f = d.length - 1;
|
|
4256
|
-
if (s) for (let t of
|
|
4257
|
-
let p = (await
|
|
4258
|
+
if (s) for (let t of jr(e, n, i)) d.push(t);
|
|
4259
|
+
let p = (await mt(e, d))[f];
|
|
4258
4260
|
return Array.isArray(p) && p.length > 0;
|
|
4259
4261
|
},
|
|
4260
4262
|
async unlink(n, r, i, o) {
|
|
@@ -4265,7 +4267,7 @@ function Vr(e) {
|
|
|
4265
4267
|
}
|
|
4266
4268
|
//#endregion
|
|
4267
4269
|
//#region src/adapters/userRoles.ts
|
|
4268
|
-
function
|
|
4270
|
+
function Ur(e) {
|
|
4269
4271
|
return {
|
|
4270
4272
|
async create(t, n, r, i) {
|
|
4271
4273
|
try {
|
|
@@ -4299,12 +4301,12 @@ function Hr(e) {
|
|
|
4299
4301
|
},
|
|
4300
4302
|
async listUsers(r, i, o) {
|
|
4301
4303
|
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4302
|
-
if (
|
|
4304
|
+
if (yt(o)) {
|
|
4303
4305
|
let n = {
|
|
4304
4306
|
sortColumn: G.user_id,
|
|
4305
4307
|
idColumn: G.user_id,
|
|
4306
4308
|
sortOrder: "asc"
|
|
4307
|
-
}, r =
|
|
4309
|
+
}, r = St(o, n), i = bt(o), { rows: a, next: c } = Ct(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...xt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4308
4310
|
return {
|
|
4309
4311
|
userIds: a.map((e) => e.user_id),
|
|
4310
4312
|
start: 0,
|
|
@@ -4328,7 +4330,7 @@ function Hr(e) {
|
|
|
4328
4330
|
}
|
|
4329
4331
|
//#endregion
|
|
4330
4332
|
//#region src/adapters/userOrganizations.ts
|
|
4331
|
-
function
|
|
4333
|
+
function Wr(e) {
|
|
4332
4334
|
return {
|
|
4333
4335
|
async create(t, n) {
|
|
4334
4336
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4342,7 +4344,7 @@ function Ur(e) {
|
|
|
4342
4344
|
try {
|
|
4343
4345
|
await e.insert(U).values(i);
|
|
4344
4346
|
} catch (e) {
|
|
4345
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4347
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Oe(409, { message: "User organization already exists" }) : e;
|
|
4346
4348
|
}
|
|
4347
4349
|
let { tenant_id: a, ...o } = i;
|
|
4348
4350
|
return o;
|
|
@@ -4360,19 +4362,19 @@ function Ur(e) {
|
|
|
4360
4362
|
async list(n, o) {
|
|
4361
4363
|
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4362
4364
|
if (c) {
|
|
4363
|
-
let e =
|
|
4365
|
+
let e = st(U, c, ["user_id", "organization_id"]);
|
|
4364
4366
|
e && (u = t(l, e));
|
|
4365
4367
|
}
|
|
4366
4368
|
let d = (e) => {
|
|
4367
4369
|
let { tenant_id: t, ...n } = e;
|
|
4368
4370
|
return n;
|
|
4369
4371
|
};
|
|
4370
|
-
if (
|
|
4372
|
+
if (yt(o)) {
|
|
4371
4373
|
let n = {
|
|
4372
4374
|
sortColumn: U.created_at,
|
|
4373
4375
|
idColumn: U.id,
|
|
4374
4376
|
sortOrder: "desc"
|
|
4375
|
-
}, r =
|
|
4377
|
+
}, r = St(o, n), i = bt(o), { rows: a, next: s } = Ct((await e.select().from(U).where(r ? t(u, r) : u).orderBy(...xt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4376
4378
|
return {
|
|
4377
4379
|
userOrganizations: a,
|
|
4378
4380
|
start: 0,
|
|
@@ -4420,19 +4422,19 @@ function Ur(e) {
|
|
|
4420
4422
|
}
|
|
4421
4423
|
//#endregion
|
|
4422
4424
|
//#region src/adapters/stats.ts
|
|
4423
|
-
var
|
|
4424
|
-
function
|
|
4425
|
+
var Gr = ["s"], Kr = ["pwd_leak"];
|
|
4426
|
+
function qr(e) {
|
|
4425
4427
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4426
4428
|
}
|
|
4427
|
-
function
|
|
4429
|
+
function Jr(e) {
|
|
4428
4430
|
return {
|
|
4429
4431
|
async getDaily(n, r) {
|
|
4430
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4432
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? qr(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? qr(r.to) : i.toISOString().split("T")[0];
|
|
4431
4433
|
return (await e.select({
|
|
4432
4434
|
date: y`substr(${J.date}, 1, 10)`.as("date"),
|
|
4433
|
-
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4435
|
+
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(Gr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4434
4436
|
signups: y`SUM(CASE WHEN ${J.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4435
|
-
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4437
|
+
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(Kr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4436
4438
|
}).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) => ({
|
|
4437
4439
|
date: e.date,
|
|
4438
4440
|
logins: Number(e.logins) || 0,
|
|
@@ -4443,14 +4445,14 @@ function qr(e) {
|
|
|
4443
4445
|
}));
|
|
4444
4446
|
},
|
|
4445
4447
|
async getActiveUsers(n) {
|
|
4446
|
-
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(
|
|
4448
|
+
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(Gr.map((e) => y`${e}`), y`, `)})`));
|
|
4447
4449
|
return Number(i?.count) || 0;
|
|
4448
4450
|
}
|
|
4449
4451
|
};
|
|
4450
4452
|
}
|
|
4451
4453
|
//#endregion
|
|
4452
4454
|
//#region src/adapters/analytics.ts
|
|
4453
|
-
var
|
|
4455
|
+
var Yr = {
|
|
4454
4456
|
"active-users": ["s", "seacft"],
|
|
4455
4457
|
logins: [
|
|
4456
4458
|
"s",
|
|
@@ -4480,7 +4482,7 @@ var Jr = {
|
|
|
4480
4482
|
"fvr"
|
|
4481
4483
|
],
|
|
4482
4484
|
"codes-sent": ["cls", "cs"]
|
|
4483
|
-
},
|
|
4485
|
+
}, Xr = {
|
|
4484
4486
|
"active-users": {
|
|
4485
4487
|
alias: "active_users",
|
|
4486
4488
|
type: "UInt64",
|
|
@@ -4537,7 +4539,7 @@ var Jr = {
|
|
|
4537
4539
|
agg: "count"
|
|
4538
4540
|
}
|
|
4539
4541
|
};
|
|
4540
|
-
function
|
|
4542
|
+
function Zr(e) {
|
|
4541
4543
|
switch (e) {
|
|
4542
4544
|
case "hour": return y`substr(${J.date}, 1, 13)`;
|
|
4543
4545
|
case "month": return y`substr(${J.date}, 1, 7)`;
|
|
@@ -4546,10 +4548,10 @@ function Xr(e) {
|
|
|
4546
4548
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4547
4549
|
}
|
|
4548
4550
|
}
|
|
4549
|
-
function
|
|
4551
|
+
function Qr(e) {
|
|
4550
4552
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4551
4553
|
}
|
|
4552
|
-
function
|
|
4554
|
+
function $r(e) {
|
|
4553
4555
|
switch (e) {
|
|
4554
4556
|
case "connection": return J.connection;
|
|
4555
4557
|
case "client_id": return J.client_id;
|
|
@@ -4558,10 +4560,10 @@ function Qr(e) {
|
|
|
4558
4560
|
case "time": throw Error("time dimension handled separately");
|
|
4559
4561
|
}
|
|
4560
4562
|
}
|
|
4561
|
-
function
|
|
4563
|
+
function ei(e) {
|
|
4562
4564
|
return {
|
|
4563
4565
|
async query(n, r, i) {
|
|
4564
|
-
let o = Date.now(), s =
|
|
4566
|
+
let o = Date.now(), s = Yr[r], u = Xr[r], d = [
|
|
4565
4567
|
a(J.tenant_id, n),
|
|
4566
4568
|
c(J.date, i.from),
|
|
4567
4569
|
m(J.date, i.to),
|
|
@@ -4570,13 +4572,13 @@ function $r(e) {
|
|
|
4570
4572
|
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));
|
|
4571
4573
|
let f = {}, p = [], h = [];
|
|
4572
4574
|
for (let e of i.group_by) if (e === "time") {
|
|
4573
|
-
let e =
|
|
4575
|
+
let e = Zr(i.interval);
|
|
4574
4576
|
f.time = e, p.push(e), h.push({
|
|
4575
4577
|
name: "time",
|
|
4576
4578
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4577
4579
|
});
|
|
4578
4580
|
} else {
|
|
4579
|
-
let t =
|
|
4581
|
+
let t = $r(e);
|
|
4580
4582
|
f[e] = t, p.push(t), h.push({
|
|
4581
4583
|
name: e,
|
|
4582
4584
|
type: "String"
|
|
@@ -4592,9 +4594,9 @@ function $r(e) {
|
|
|
4592
4594
|
if (i.order_by) {
|
|
4593
4595
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4594
4596
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4595
|
-
let n =
|
|
4597
|
+
let n = Qr(t);
|
|
4596
4598
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4597
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4599
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Qr("time")} ASC`)) : g.orderBy(y.raw(`${Qr(u.alias)} DESC`));
|
|
4598
4600
|
g = g.limit(i.limit).offset(i.offset);
|
|
4599
4601
|
let v = (await g.all()).map((e) => {
|
|
4600
4602
|
let t = {};
|
|
@@ -4613,8 +4615,8 @@ function $r(e) {
|
|
|
4613
4615
|
};
|
|
4614
4616
|
},
|
|
4615
4617
|
async sessionRetention(n, r) {
|
|
4616
|
-
let i = Date.now(), { sinceMs: o } =
|
|
4617
|
-
return
|
|
4618
|
+
let i = Date.now(), { sinceMs: o } = Ce(r.weeks, i), s = y`(${N.created_at_ts} + ${le}) / ${ue}`, l = y`(COALESCE(${N.used_at_ts}, ${N.created_at_ts}) + ${le}) / ${ue}`;
|
|
4619
|
+
return fe((await e.select({
|
|
4618
4620
|
created_week: s,
|
|
4619
4621
|
used_week: l,
|
|
4620
4622
|
count: y`COUNT(*)`
|
|
@@ -4623,15 +4625,30 @@ function $r(e) {
|
|
|
4623
4625
|
used_week: Math.floor(Number(e.used_week)),
|
|
4624
4626
|
count: Number(e.count)
|
|
4625
4627
|
})), r.weeks, i);
|
|
4628
|
+
},
|
|
4629
|
+
async refreshTokenRetention(n, r) {
|
|
4630
|
+
let i = Date.now(), { sinceMs: o } = Ce(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(P.client_id, r.client_id) : void 0, u = e.select({
|
|
4631
|
+
min_created: y`MIN(${P.created_at_ts})`.as("min_created"),
|
|
4632
|
+
max_used: y`MAX(COALESCE(${P.last_exchanged_at_ts}, ${P.created_at_ts}))`.as("max_used")
|
|
4633
|
+
}).from(P).where(t(a(P.tenant_id, n), s)).groupBy(y`COALESCE(${P.family_id}, ${P.id})`).as("families"), d = y`(${u.min_created} + ${le}) / ${ue}`, f = y`(${u.max_used} + ${le}) / ${ue}`;
|
|
4634
|
+
return de((await e.select({
|
|
4635
|
+
created_week: d,
|
|
4636
|
+
used_week: f,
|
|
4637
|
+
count: y`COUNT(*)`
|
|
4638
|
+
}).from(u).where(c(u.min_created, o)).groupBy(d, f).all()).map((e) => ({
|
|
4639
|
+
created_week: Math.floor(Number(e.created_week)),
|
|
4640
|
+
used_week: Math.floor(Number(e.used_week)),
|
|
4641
|
+
count: Number(e.count)
|
|
4642
|
+
})), r.weeks, i);
|
|
4626
4643
|
}
|
|
4627
4644
|
};
|
|
4628
4645
|
}
|
|
4629
4646
|
//#endregion
|
|
4630
4647
|
//#region src/adapters/cleanup.ts
|
|
4631
|
-
var
|
|
4632
|
-
function
|
|
4648
|
+
var ti = 10080 * 60 * 1e3;
|
|
4649
|
+
function ni(e) {
|
|
4633
4650
|
return async (n) => {
|
|
4634
|
-
let r = Date.now() -
|
|
4651
|
+
let r = Date.now() - ti;
|
|
4635
4652
|
try {
|
|
4636
4653
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4637
4654
|
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));
|
|
@@ -4662,7 +4679,7 @@ var $ = w("tenant_operations", {
|
|
|
4662
4679
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4663
4680
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4664
4681
|
x("tenant_operations_status_idx").on(e.status)
|
|
4665
|
-
]),
|
|
4682
|
+
]), ri = w("tenant_operation_events", {
|
|
4666
4683
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4667
4684
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4668
4685
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4674,7 +4691,7 @@ var $ = w("tenant_operations", {
|
|
|
4674
4691
|
columns: [e.operation_id],
|
|
4675
4692
|
foreignColumns: [$.id],
|
|
4676
4693
|
name: "tenant_operation_events_operation_id_constraint"
|
|
4677
|
-
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]),
|
|
4694
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), ii = w("rollouts", {
|
|
4678
4695
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4679
4696
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4680
4697
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4690,8 +4707,8 @@ var $ = w("tenant_operations", {
|
|
|
4690
4707
|
});
|
|
4691
4708
|
//#endregion
|
|
4692
4709
|
//#region src/adapters/tenantOperations.ts
|
|
4693
|
-
function
|
|
4694
|
-
return
|
|
4710
|
+
function ai(e) {
|
|
4711
|
+
return De.parse({
|
|
4695
4712
|
id: e.id,
|
|
4696
4713
|
tenant_id: e.tenant_id,
|
|
4697
4714
|
rollout_id: e.rollout_id,
|
|
@@ -4709,10 +4726,10 @@ function ii(e) {
|
|
|
4709
4726
|
finished_at: e.finished_at
|
|
4710
4727
|
});
|
|
4711
4728
|
}
|
|
4712
|
-
function
|
|
4729
|
+
function oi(e) {
|
|
4713
4730
|
return {
|
|
4714
4731
|
async create(t) {
|
|
4715
|
-
let n =
|
|
4732
|
+
let n = Ee.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4716
4733
|
id: `op_${b()}`,
|
|
4717
4734
|
tenant_id: n.tenant_id,
|
|
4718
4735
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4736,7 +4753,7 @@ function ai(e) {
|
|
|
4736
4753
|
},
|
|
4737
4754
|
async get(t) {
|
|
4738
4755
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4739
|
-
return n[0] ?
|
|
4756
|
+
return n[0] ? ai(n[0]) : null;
|
|
4740
4757
|
},
|
|
4741
4758
|
async list(n = {}) {
|
|
4742
4759
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4747,7 +4764,7 @@ function ai(e) {
|
|
|
4747
4764
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4748
4765
|
let c = await e.select().from($).where(s.length ? t(...s) : void 0).orderBy(i($.created_at), i($.id)).offset(r * o).limit(o);
|
|
4749
4766
|
return {
|
|
4750
|
-
operations: c.map(
|
|
4767
|
+
operations: c.map(ai),
|
|
4751
4768
|
start: r * o,
|
|
4752
4769
|
limit: o,
|
|
4753
4770
|
length: c.length
|
|
@@ -4765,27 +4782,27 @@ function ai(e) {
|
|
|
4765
4782
|
}
|
|
4766
4783
|
//#endregion
|
|
4767
4784
|
//#region src/helpers/monotonic-id.ts
|
|
4768
|
-
var
|
|
4769
|
-
function
|
|
4785
|
+
var si = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ci = 32, li = 10, ui = 4, di = 10;
|
|
4786
|
+
function fi(e, t) {
|
|
4770
4787
|
let n = "";
|
|
4771
|
-
for (let r = t; r > 0; r--) n =
|
|
4788
|
+
for (let r = t; r > 0; r--) n = si.charAt(e % ci) + n, e = Math.floor(e / ci);
|
|
4772
4789
|
return n;
|
|
4773
4790
|
}
|
|
4774
|
-
function
|
|
4775
|
-
let e = new Uint8Array(
|
|
4791
|
+
function pi() {
|
|
4792
|
+
let e = new Uint8Array(di);
|
|
4776
4793
|
crypto.getRandomValues(e);
|
|
4777
4794
|
let t = "";
|
|
4778
|
-
for (let n = 0; n <
|
|
4795
|
+
for (let n = 0; n < di; n++) t += si.charAt(e[n] % ci);
|
|
4779
4796
|
return t;
|
|
4780
4797
|
}
|
|
4781
|
-
var
|
|
4782
|
-
function
|
|
4798
|
+
var mi = 0, hi = 0;
|
|
4799
|
+
function gi() {
|
|
4783
4800
|
let e = Date.now();
|
|
4784
|
-
return e ===
|
|
4801
|
+
return e === mi ? hi++ : (mi = e, hi = 0), fi(e, li) + fi(hi, ui) + pi();
|
|
4785
4802
|
}
|
|
4786
4803
|
//#endregion
|
|
4787
4804
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4788
|
-
function
|
|
4805
|
+
function _i(e) {
|
|
4789
4806
|
if (!e) return null;
|
|
4790
4807
|
try {
|
|
4791
4808
|
let t = JSON.parse(e);
|
|
@@ -4793,22 +4810,22 @@ function gi(e) {
|
|
|
4793
4810
|
} catch {}
|
|
4794
4811
|
return null;
|
|
4795
4812
|
}
|
|
4796
|
-
function
|
|
4797
|
-
return
|
|
4813
|
+
function vi(e) {
|
|
4814
|
+
return Te.parse({
|
|
4798
4815
|
id: e.id,
|
|
4799
4816
|
operation_id: e.operation_id,
|
|
4800
4817
|
step: e.step,
|
|
4801
4818
|
outcome: e.outcome,
|
|
4802
|
-
detail:
|
|
4819
|
+
detail: _i(e.detail),
|
|
4803
4820
|
attempt: e.attempt,
|
|
4804
4821
|
created_at: e.created_at
|
|
4805
4822
|
});
|
|
4806
4823
|
}
|
|
4807
|
-
function
|
|
4824
|
+
function yi(e) {
|
|
4808
4825
|
return {
|
|
4809
4826
|
async create(t) {
|
|
4810
|
-
let n =
|
|
4811
|
-
id: `evt_${
|
|
4827
|
+
let n = we.parse(t), r = {
|
|
4828
|
+
id: `evt_${gi()}`,
|
|
4812
4829
|
operation_id: n.operation_id,
|
|
4813
4830
|
step: n.step,
|
|
4814
4831
|
outcome: n.outcome,
|
|
@@ -4816,7 +4833,7 @@ function vi(e) {
|
|
|
4816
4833
|
attempt: n.attempt,
|
|
4817
4834
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4818
4835
|
};
|
|
4819
|
-
return await e.insert(
|
|
4836
|
+
return await e.insert(ri).values(r), Te.parse({
|
|
4820
4837
|
id: r.id,
|
|
4821
4838
|
operation_id: r.operation_id,
|
|
4822
4839
|
step: r.step,
|
|
@@ -4827,9 +4844,9 @@ function vi(e) {
|
|
|
4827
4844
|
});
|
|
4828
4845
|
},
|
|
4829
4846
|
async listByOperation(t, r = {}) {
|
|
4830
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4847
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(ri).where(a(ri.operation_id, t)).orderBy(n(ri.created_at), n(ri.id)).offset(i * o).limit(o);
|
|
4831
4848
|
return {
|
|
4832
|
-
events: s.map(
|
|
4849
|
+
events: s.map(vi),
|
|
4833
4850
|
start: i * o,
|
|
4834
4851
|
limit: o,
|
|
4835
4852
|
length: s.length
|
|
@@ -4839,7 +4856,7 @@ function vi(e) {
|
|
|
4839
4856
|
}
|
|
4840
4857
|
//#endregion
|
|
4841
4858
|
//#region src/adapters/rollouts.ts
|
|
4842
|
-
function
|
|
4859
|
+
function bi(e) {
|
|
4843
4860
|
if (!e) return null;
|
|
4844
4861
|
try {
|
|
4845
4862
|
return JSON.parse(e);
|
|
@@ -4847,26 +4864,26 @@ function yi(e) {
|
|
|
4847
4864
|
return null;
|
|
4848
4865
|
}
|
|
4849
4866
|
}
|
|
4850
|
-
function
|
|
4851
|
-
return
|
|
4867
|
+
function xi(e) {
|
|
4868
|
+
return be.parse({
|
|
4852
4869
|
id: e.id,
|
|
4853
4870
|
kind: e.kind,
|
|
4854
4871
|
status: e.status,
|
|
4855
4872
|
target_worker_version: e.target_worker_version,
|
|
4856
4873
|
target_database_version: e.target_database_version,
|
|
4857
4874
|
wave_size: e.wave_size,
|
|
4858
|
-
canary_tenant_ids:
|
|
4859
|
-
filter:
|
|
4875
|
+
canary_tenant_ids: bi(e.canary_tenant_ids),
|
|
4876
|
+
filter: bi(e.filter),
|
|
4860
4877
|
initiated_by: e.initiated_by,
|
|
4861
4878
|
created_at: e.created_at,
|
|
4862
4879
|
updated_at: e.updated_at,
|
|
4863
4880
|
finished_at: e.finished_at
|
|
4864
4881
|
});
|
|
4865
4882
|
}
|
|
4866
|
-
function
|
|
4883
|
+
function Si(e) {
|
|
4867
4884
|
return {
|
|
4868
4885
|
async create(t) {
|
|
4869
|
-
let n =
|
|
4886
|
+
let n = ye.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4870
4887
|
id: `rol_${b()}`,
|
|
4871
4888
|
kind: n.kind,
|
|
4872
4889
|
status: "pending",
|
|
@@ -4880,93 +4897,93 @@ function xi(e) {
|
|
|
4880
4897
|
updated_at: r,
|
|
4881
4898
|
finished_at: null
|
|
4882
4899
|
};
|
|
4883
|
-
await e.insert(
|
|
4900
|
+
await e.insert(ii).values(i);
|
|
4884
4901
|
let a = await this.get(i.id);
|
|
4885
4902
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4886
4903
|
return a;
|
|
4887
4904
|
},
|
|
4888
4905
|
async get(t) {
|
|
4889
|
-
let n = await e.select().from(
|
|
4890
|
-
return n[0] ?
|
|
4906
|
+
let n = await e.select().from(ii).where(a(ii.id, t)).limit(1);
|
|
4907
|
+
return n[0] ? xi(n[0]) : null;
|
|
4891
4908
|
},
|
|
4892
4909
|
async list(t = {}) {
|
|
4893
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4910
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(ii).orderBy(i(ii.created_at), i(ii.id)).offset(n * r).limit(r);
|
|
4894
4911
|
return {
|
|
4895
|
-
rollouts: a.map(
|
|
4912
|
+
rollouts: a.map(xi),
|
|
4896
4913
|
start: n * r,
|
|
4897
4914
|
limit: r,
|
|
4898
4915
|
length: a.length
|
|
4899
4916
|
};
|
|
4900
4917
|
},
|
|
4901
4918
|
async update(t, n) {
|
|
4902
|
-
if ((await e.select({ id:
|
|
4919
|
+
if ((await e.select({ id: ii.id }).from(ii).where(a(ii.id, t)).limit(1)).length === 0) return !1;
|
|
4903
4920
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4904
|
-
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(
|
|
4921
|
+
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(ii).set(r).where(a(ii.id, t)), !0;
|
|
4905
4922
|
},
|
|
4906
4923
|
async remove(t) {
|
|
4907
|
-
return (await e.select({ id:
|
|
4924
|
+
return (await e.select({ id: ii.id }).from(ii).where(a(ii.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(ii).where(a(ii.id, t)), !0);
|
|
4908
4925
|
}
|
|
4909
4926
|
};
|
|
4910
4927
|
}
|
|
4911
4928
|
//#endregion
|
|
4912
4929
|
//#region src/adapters/index.ts
|
|
4913
|
-
function
|
|
4930
|
+
function Ci(e, t = { useTransactions: !0 }) {
|
|
4914
4931
|
let n = {
|
|
4915
|
-
actions:
|
|
4916
|
-
actionExecutions:
|
|
4917
|
-
actionVersions:
|
|
4918
|
-
branding:
|
|
4919
|
-
clients:
|
|
4920
|
-
clientConnections:
|
|
4921
|
-
clientGrants:
|
|
4922
|
-
clientRegistrationTokens:
|
|
4923
|
-
codes:
|
|
4924
|
-
connections:
|
|
4925
|
-
customDomains:
|
|
4926
|
-
customText:
|
|
4927
|
-
emailProviders:
|
|
4928
|
-
emailTemplates:
|
|
4929
|
-
flows:
|
|
4930
|
-
forms:
|
|
4931
|
-
grants:
|
|
4932
|
-
hookCode:
|
|
4933
|
-
hooks:
|
|
4934
|
-
invites:
|
|
4935
|
-
keys:
|
|
4936
|
-
loginSessions:
|
|
4937
|
-
logs:
|
|
4938
|
-
authenticationMethods:
|
|
4939
|
-
organizations:
|
|
4940
|
-
passwords:
|
|
4941
|
-
promptSettings:
|
|
4942
|
-
proxyRoutes:
|
|
4943
|
-
scimConfigurations:
|
|
4944
|
-
scimTokens:
|
|
4945
|
-
scimExternalIds:
|
|
4946
|
-
refreshTokens:
|
|
4947
|
-
resourceServers:
|
|
4948
|
-
rolePermissions:
|
|
4949
|
-
userPermissions:
|
|
4950
|
-
roles:
|
|
4951
|
-
sessions:
|
|
4952
|
-
sessionCleanup:
|
|
4953
|
-
tenants:
|
|
4932
|
+
actions: ut(e),
|
|
4933
|
+
actionExecutions: ft(e),
|
|
4934
|
+
actionVersions: gt(e),
|
|
4935
|
+
branding: vt(e),
|
|
4936
|
+
clients: kt(e),
|
|
4937
|
+
clientConnections: jt(e),
|
|
4938
|
+
clientGrants: Nt(e),
|
|
4939
|
+
clientRegistrationTokens: Rt(e),
|
|
4940
|
+
codes: Ht(e),
|
|
4941
|
+
connections: Gt(e),
|
|
4942
|
+
customDomains: qt(e),
|
|
4943
|
+
customText: Jt(e),
|
|
4944
|
+
emailProviders: Yt(e),
|
|
4945
|
+
emailTemplates: Zt(e),
|
|
4946
|
+
flows: $t(e),
|
|
4947
|
+
forms: nn(e),
|
|
4948
|
+
grants: sn(e),
|
|
4949
|
+
hookCode: dn(e),
|
|
4950
|
+
hooks: hn(e),
|
|
4951
|
+
invites: yn(e),
|
|
4952
|
+
keys: xn(e),
|
|
4953
|
+
loginSessions: En(e),
|
|
4954
|
+
logs: On(e),
|
|
4955
|
+
authenticationMethods: Nn(e),
|
|
4956
|
+
organizations: Ln(e),
|
|
4957
|
+
passwords: zn(e),
|
|
4958
|
+
promptSettings: Bn(e),
|
|
4959
|
+
proxyRoutes: Wn(e),
|
|
4960
|
+
scimConfigurations: Jn(e),
|
|
4961
|
+
scimTokens: Xn(e),
|
|
4962
|
+
scimExternalIds: Qn(e),
|
|
4963
|
+
refreshTokens: tr(e),
|
|
4964
|
+
resourceServers: sr(e),
|
|
4965
|
+
rolePermissions: cr(e),
|
|
4966
|
+
userPermissions: lr(e),
|
|
4967
|
+
roles: dr(e),
|
|
4968
|
+
sessions: gr(e),
|
|
4969
|
+
sessionCleanup: ni(e),
|
|
4970
|
+
tenants: xr(e),
|
|
4954
4971
|
...t.controlPlane ? {
|
|
4955
|
-
tenantOperations:
|
|
4956
|
-
tenantOperationEvents:
|
|
4957
|
-
rollouts:
|
|
4972
|
+
tenantOperations: oi(e),
|
|
4973
|
+
tenantOperationEvents: yi(e),
|
|
4974
|
+
rollouts: Si(e)
|
|
4958
4975
|
} : {},
|
|
4959
|
-
themes:
|
|
4960
|
-
universalLoginTemplates:
|
|
4961
|
-
users:
|
|
4962
|
-
userActivity:
|
|
4963
|
-
userRoles:
|
|
4964
|
-
userOrganizations:
|
|
4965
|
-
stats:
|
|
4966
|
-
analytics:
|
|
4967
|
-
outbox:
|
|
4976
|
+
themes: wr(e),
|
|
4977
|
+
universalLoginTemplates: Tr(e),
|
|
4978
|
+
users: Hr(e),
|
|
4979
|
+
userActivity: Dr(e),
|
|
4980
|
+
userRoles: Ur(e),
|
|
4981
|
+
userOrganizations: Wr(e),
|
|
4982
|
+
stats: Jr(e),
|
|
4983
|
+
analytics: ei(e),
|
|
4984
|
+
outbox: Ar(e),
|
|
4968
4985
|
async transaction(r) {
|
|
4969
|
-
if (t.useTransactions === !1 ||
|
|
4986
|
+
if (t.useTransactions === !1 || pt(e)) return r(n);
|
|
4970
4987
|
await e.run(y`BEGIN`);
|
|
4971
4988
|
try {
|
|
4972
4989
|
let t = await r(n);
|
|
@@ -4980,22 +4997,22 @@ function Si(e, t = { useTransactions: !0 }) {
|
|
|
4980
4997
|
}
|
|
4981
4998
|
//#endregion
|
|
4982
4999
|
//#region src/adapters/resolveHost.ts
|
|
4983
|
-
function
|
|
5000
|
+
function wi(e) {
|
|
4984
5001
|
if (!e) return { path: "/*" };
|
|
4985
5002
|
try {
|
|
4986
|
-
let t = JSON.parse(e), n =
|
|
5003
|
+
let t = JSON.parse(e), n = ve.safeParse(t);
|
|
4987
5004
|
if (n.success) return n.data;
|
|
4988
5005
|
} catch {}
|
|
4989
5006
|
return { path: "/*" };
|
|
4990
5007
|
}
|
|
4991
|
-
function
|
|
5008
|
+
function Ti(e) {
|
|
4992
5009
|
if (!e) return [];
|
|
4993
5010
|
try {
|
|
4994
5011
|
let t = JSON.parse(e);
|
|
4995
5012
|
if (!Array.isArray(t)) return [];
|
|
4996
5013
|
let n = [];
|
|
4997
5014
|
for (let e of t) {
|
|
4998
|
-
let t =
|
|
5015
|
+
let t = ge.safeParse(e);
|
|
4999
5016
|
t.success && n.push(t.data);
|
|
5000
5017
|
}
|
|
5001
5018
|
return n;
|
|
@@ -5003,20 +5020,20 @@ function wi(e) {
|
|
|
5003
5020
|
return [];
|
|
5004
5021
|
}
|
|
5005
5022
|
}
|
|
5006
|
-
async function
|
|
5023
|
+
async function Ei(e, r) {
|
|
5007
5024
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5008
|
-
custom_domain_id:
|
|
5009
|
-
tenant_id:
|
|
5010
|
-
domain:
|
|
5011
|
-
}).from(
|
|
5025
|
+
custom_domain_id: V.custom_domain_id,
|
|
5026
|
+
tenant_id: V.tenant_id,
|
|
5027
|
+
domain: V.domain
|
|
5028
|
+
}).from(V).where(a(V.domain, i)).limit(1))[0];
|
|
5012
5029
|
if (!o) return null;
|
|
5013
5030
|
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) => ({
|
|
5014
5031
|
id: e.id,
|
|
5015
5032
|
tenant_id: e.tenant_id,
|
|
5016
5033
|
custom_domain_id: e.custom_domain_id,
|
|
5017
5034
|
priority: e.priority,
|
|
5018
|
-
match:
|
|
5019
|
-
handlers:
|
|
5035
|
+
match: wi(e.match),
|
|
5036
|
+
handlers: Ti(e.handlers),
|
|
5020
5037
|
created_at: e.created_at,
|
|
5021
5038
|
updated_at: e.updated_at
|
|
5022
5039
|
}));
|
|
@@ -5029,11 +5046,11 @@ async function Ti(e, r) {
|
|
|
5029
5046
|
}
|
|
5030
5047
|
//#endregion
|
|
5031
5048
|
//#region src/adapters/proxyData.ts
|
|
5032
|
-
function
|
|
5049
|
+
function Di(e) {
|
|
5033
5050
|
return {
|
|
5034
|
-
proxyRoutes:
|
|
5035
|
-
resolveHost: (t) =>
|
|
5051
|
+
proxyRoutes: Wn(e),
|
|
5052
|
+
resolveHost: (t) => Ei(e, t)
|
|
5036
5053
|
};
|
|
5037
5054
|
}
|
|
5038
5055
|
//#endregion
|
|
5039
|
-
export {
|
|
5056
|
+
export { Di as createProxyDataAdapter, Wn as createProxyRoutesAdapter, Ci as default, nt as sqlite };
|