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