@authhero/drizzle 1.2.0 → 1.3.1
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,12 @@ 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) {
|
|
3488
|
+
if (r.length === 0) return !0;
|
|
3484
3489
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3485
|
-
return await e.insert(
|
|
3490
|
+
return await e.insert(ze).values(r.map((e) => ({
|
|
3486
3491
|
tenant_id: t,
|
|
3487
3492
|
role_id: n,
|
|
3488
3493
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3492,10 +3497,10 @@ function rr(e) {
|
|
|
3492
3497
|
},
|
|
3493
3498
|
async list(n, r, i) {
|
|
3494
3499
|
let o = await e.select({
|
|
3495
|
-
resource_server_identifier:
|
|
3496
|
-
permission_name:
|
|
3497
|
-
created_at:
|
|
3498
|
-
}).from(
|
|
3500
|
+
resource_server_identifier: ze.resource_server_identifier,
|
|
3501
|
+
permission_name: ze.permission_name,
|
|
3502
|
+
created_at: ze.created_at
|
|
3503
|
+
}).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
3504
|
if (s.length > 0) {
|
|
3500
3505
|
let r = await e.select({
|
|
3501
3506
|
identifier: K.identifier,
|
|
@@ -3509,18 +3514,19 @@ function rr(e) {
|
|
|
3509
3514
|
}));
|
|
3510
3515
|
},
|
|
3511
3516
|
async remove(n, r, i) {
|
|
3512
|
-
|
|
3513
|
-
|
|
3517
|
+
if (i.length === 0) return !0;
|
|
3518
|
+
let o = i.map((e) => t(a(ze.resource_server_identifier, e.resource_server_identifier), a(ze.permission_name, e.permission_name)));
|
|
3519
|
+
return await e.delete(ze).where(t(a(ze.tenant_id, n), a(ze.role_id, r), v(...o))).returning(), !0;
|
|
3514
3520
|
}
|
|
3515
3521
|
};
|
|
3516
3522
|
}
|
|
3517
3523
|
//#endregion
|
|
3518
3524
|
//#region src/adapters/userPermissions.ts
|
|
3519
|
-
function
|
|
3525
|
+
function cr(e) {
|
|
3520
3526
|
return {
|
|
3521
3527
|
async create(t, n, r, i) {
|
|
3522
3528
|
try {
|
|
3523
|
-
await e.insert(
|
|
3529
|
+
await e.insert(Be).values({
|
|
3524
3530
|
tenant_id: t,
|
|
3525
3531
|
user_id: n,
|
|
3526
3532
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3535,9 +3541,9 @@ function ir(e) {
|
|
|
3535
3541
|
return !0;
|
|
3536
3542
|
},
|
|
3537
3543
|
async list(n, r, i, o) {
|
|
3538
|
-
let s = [a(
|
|
3539
|
-
o && s.push(a(
|
|
3540
|
-
let c = await e.select().from(
|
|
3544
|
+
let s = [a(Be.tenant_id, n), a(Be.user_id, r)];
|
|
3545
|
+
o && s.push(a(Be.organization_id, o));
|
|
3546
|
+
let c = await e.select().from(Be).where(t(...s)).all();
|
|
3541
3547
|
return await Promise.all(c.map(async (r) => {
|
|
3542
3548
|
let i = await e.select({ name: K.name }).from(K).where(t(a(K.tenant_id, n), a(K.identifier, r.resource_server_identifier))).get();
|
|
3543
3549
|
return {
|
|
@@ -3549,13 +3555,13 @@ function ir(e) {
|
|
|
3549
3555
|
}));
|
|
3550
3556
|
},
|
|
3551
3557
|
async remove(n, r, i, o) {
|
|
3552
|
-
return (await e.delete(
|
|
3558
|
+
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
3559
|
}
|
|
3554
3560
|
};
|
|
3555
3561
|
}
|
|
3556
3562
|
//#endregion
|
|
3557
3563
|
//#region src/adapters/roles.ts
|
|
3558
|
-
function
|
|
3564
|
+
function lr(e) {
|
|
3559
3565
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3560
3566
|
return O({
|
|
3561
3567
|
...i,
|
|
@@ -3563,7 +3569,7 @@ function ar(e) {
|
|
|
3563
3569
|
metadata: Q(r)
|
|
3564
3570
|
});
|
|
3565
3571
|
}
|
|
3566
|
-
function
|
|
3572
|
+
function ur(e) {
|
|
3567
3573
|
return {
|
|
3568
3574
|
async create(t, n) {
|
|
3569
3575
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3576,26 +3582,26 @@ function or(e) {
|
|
|
3576
3582
|
created_at: r,
|
|
3577
3583
|
updated_at: r
|
|
3578
3584
|
};
|
|
3579
|
-
return await e.insert(W).values(i),
|
|
3585
|
+
return await e.insert(W).values(i), lr({
|
|
3580
3586
|
...i,
|
|
3581
3587
|
tenant_id: t
|
|
3582
3588
|
});
|
|
3583
3589
|
},
|
|
3584
3590
|
async get(n, r) {
|
|
3585
3591
|
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3586
|
-
return i ?
|
|
3592
|
+
return i ? lr(i) : null;
|
|
3587
3593
|
},
|
|
3588
3594
|
async update(n, r, i) {
|
|
3589
3595
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3590
3596
|
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(W).set(o).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3591
3597
|
},
|
|
3592
3598
|
async list(o, s) {
|
|
3593
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3599
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? 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
3600
|
if (d?.sort_by) {
|
|
3595
3601
|
let e = W[d.sort_by];
|
|
3596
3602
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3597
3603
|
}
|
|
3598
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3604
|
+
let g = (await h.offset(c * l).limit(l)).map(lr);
|
|
3599
3605
|
if (!u) return { roles: g };
|
|
3600
3606
|
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3601
3607
|
return {
|
|
@@ -3612,7 +3618,7 @@ function or(e) {
|
|
|
3612
3618
|
}
|
|
3613
3619
|
//#endregion
|
|
3614
3620
|
//#region src/adapters/sessions.ts
|
|
3615
|
-
var
|
|
3621
|
+
var dr = ["created_at_ts", "updated_at_ts"], fr = [
|
|
3616
3622
|
"expires_at_ts",
|
|
3617
3623
|
"idle_expires_at_ts",
|
|
3618
3624
|
"authenticated_at_ts",
|
|
@@ -3620,7 +3626,7 @@ var sr = ["created_at_ts", "updated_at_ts"], cr = [
|
|
|
3620
3626
|
"used_at_ts",
|
|
3621
3627
|
"revoked_at_ts"
|
|
3622
3628
|
];
|
|
3623
|
-
function
|
|
3629
|
+
function pr(e) {
|
|
3624
3630
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, p = ie({
|
|
3625
3631
|
created_at_ts: n,
|
|
3626
3632
|
updated_at_ts: r,
|
|
@@ -3630,7 +3636,7 @@ function lr(e) {
|
|
|
3630
3636
|
last_interaction_at_ts: s,
|
|
3631
3637
|
used_at_ts: c,
|
|
3632
3638
|
revoked_at_ts: l
|
|
3633
|
-
}, [...
|
|
3639
|
+
}, [...dr], [...fr]);
|
|
3634
3640
|
return O({
|
|
3635
3641
|
...f,
|
|
3636
3642
|
...p,
|
|
@@ -3638,10 +3644,10 @@ function lr(e) {
|
|
|
3638
3644
|
clients: Q(d, [])
|
|
3639
3645
|
});
|
|
3640
3646
|
}
|
|
3641
|
-
function
|
|
3647
|
+
function mr(e, t) {
|
|
3642
3648
|
return Math.max(e ?? 0, t ?? 0);
|
|
3643
3649
|
}
|
|
3644
|
-
function
|
|
3650
|
+
function hr(e) {
|
|
3645
3651
|
return {
|
|
3646
3652
|
async create(n, r) {
|
|
3647
3653
|
let i = Date.now(), o = {
|
|
@@ -3659,23 +3665,23 @@ function dr(e) {
|
|
|
3659
3665
|
last_interaction_at_ts: r.last_interaction_at ? D(r.last_interaction_at) : i,
|
|
3660
3666
|
used_at_ts: D(r.used_at),
|
|
3661
3667
|
revoked_at_ts: D(r.revoked_at)
|
|
3662
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3668
|
+
}, s = [e.insert(N).values(o)], c = mr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3663
3669
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3664
3670
|
expires_at_ts: c,
|
|
3665
3671
|
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
|
|
3672
|
+
}).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
3673
|
...o,
|
|
3668
3674
|
tenant_id: n
|
|
3669
3675
|
});
|
|
3670
3676
|
},
|
|
3671
3677
|
async get(n, r) {
|
|
3672
3678
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3673
|
-
return i ?
|
|
3679
|
+
return i ? pr(i) : null;
|
|
3674
3680
|
},
|
|
3675
3681
|
async update(n, r, i) {
|
|
3676
3682
|
let o = { updated_at_ts: Date.now() };
|
|
3677
3683
|
i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = D(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = D(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = D(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = D(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = D(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = D(i.revoked_at));
|
|
3678
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3684
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = mr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3679
3685
|
if (c > 0 && l) {
|
|
3680
3686
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3681
3687
|
r && await e.update(F).set({
|
|
@@ -3686,12 +3692,12 @@ function dr(e) {
|
|
|
3686
3692
|
return s.length > 0;
|
|
3687
3693
|
},
|
|
3688
3694
|
async list(o, s) {
|
|
3689
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3695
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? 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
3696
|
if (d?.sort_by) {
|
|
3691
3697
|
let e = N[d.sort_by];
|
|
3692
3698
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3693
3699
|
}
|
|
3694
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3700
|
+
let g = (await h.offset(c * l).limit(l)).map(pr);
|
|
3695
3701
|
if (!u) return { sessions: g };
|
|
3696
3702
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3697
3703
|
return {
|
|
@@ -3708,7 +3714,7 @@ function dr(e) {
|
|
|
3708
3714
|
}
|
|
3709
3715
|
//#endregion
|
|
3710
3716
|
//#region src/adapters/tenants.ts
|
|
3711
|
-
var
|
|
3717
|
+
var gr = [
|
|
3712
3718
|
"session_cookie",
|
|
3713
3719
|
"enabled_locales",
|
|
3714
3720
|
"error_page",
|
|
@@ -3724,25 +3730,25 @@ var fr = [
|
|
|
3724
3730
|
"acr_values_supported",
|
|
3725
3731
|
"mtls",
|
|
3726
3732
|
"mfa"
|
|
3727
|
-
],
|
|
3733
|
+
], _r = [
|
|
3728
3734
|
"allow_organization_name_in_authentication_api",
|
|
3729
3735
|
"customize_mfa_in_postlogin_action",
|
|
3730
3736
|
"pushed_authorization_requests_supported",
|
|
3731
3737
|
"authorization_response_iss_parameter_supported"
|
|
3732
3738
|
];
|
|
3733
|
-
function
|
|
3739
|
+
function vr(e) {
|
|
3734
3740
|
let t = { ...e };
|
|
3735
|
-
for (let e of
|
|
3736
|
-
for (let e of
|
|
3741
|
+
for (let e of gr) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3742
|
+
for (let e of _r) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3737
3743
|
return O(t);
|
|
3738
3744
|
}
|
|
3739
|
-
function
|
|
3745
|
+
function yr(e) {
|
|
3740
3746
|
let t = { ...e };
|
|
3741
|
-
ce(e,
|
|
3742
|
-
for (let n of
|
|
3747
|
+
ce(e, gr, t);
|
|
3748
|
+
for (let n of _r) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3743
3749
|
return se(t);
|
|
3744
3750
|
}
|
|
3745
|
-
function
|
|
3751
|
+
function br(e) {
|
|
3746
3752
|
return {
|
|
3747
3753
|
async create(t) {
|
|
3748
3754
|
let n = {
|
|
@@ -3750,26 +3756,26 @@ function gr(e) {
|
|
|
3750
3756
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3751
3757
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3752
3758
|
...t
|
|
3753
|
-
}, r =
|
|
3759
|
+
}, r = yr(n);
|
|
3754
3760
|
try {
|
|
3755
3761
|
await e.insert(k).values(r);
|
|
3756
3762
|
} catch (e) {
|
|
3757
3763
|
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
|
|
3764
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new De(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3759
3765
|
}
|
|
3760
3766
|
return n;
|
|
3761
3767
|
},
|
|
3762
3768
|
async get(t) {
|
|
3763
3769
|
let n = await e.select().from(k).where(a(k.id, t)).get();
|
|
3764
|
-
return n ?
|
|
3770
|
+
return n ? vr(n) : null;
|
|
3765
3771
|
},
|
|
3766
3772
|
async list(t) {
|
|
3767
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3773
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? ot(k, l, ["friendly_name"]) : void 0, d = e.select().from(k).$dynamic();
|
|
3768
3774
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3769
3775
|
let e = k[c.sort_by];
|
|
3770
3776
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3771
3777
|
}
|
|
3772
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3778
|
+
let f = (await d.offset(a * o).limit(o)).map(vr);
|
|
3773
3779
|
if (!s) return { tenants: f };
|
|
3774
3780
|
let p = e.select({ count: r() }).from(k).$dynamic();
|
|
3775
3781
|
u && (p = p.where(u));
|
|
@@ -3782,7 +3788,7 @@ function gr(e) {
|
|
|
3782
3788
|
};
|
|
3783
3789
|
},
|
|
3784
3790
|
async update(t, n) {
|
|
3785
|
-
let r =
|
|
3791
|
+
let r = yr({
|
|
3786
3792
|
...n,
|
|
3787
3793
|
id: t,
|
|
3788
3794
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3796,62 +3802,62 @@ function gr(e) {
|
|
|
3796
3802
|
}
|
|
3797
3803
|
//#endregion
|
|
3798
3804
|
//#region src/adapters/themes.ts
|
|
3799
|
-
var
|
|
3805
|
+
var xr = [
|
|
3800
3806
|
"colors",
|
|
3801
3807
|
"borders",
|
|
3802
3808
|
"fonts",
|
|
3803
3809
|
"page_background",
|
|
3804
3810
|
"widget"
|
|
3805
3811
|
];
|
|
3806
|
-
function
|
|
3807
|
-
let { tenant_id: t, ...n } = e, r =
|
|
3812
|
+
function Sr(e) {
|
|
3813
|
+
let { tenant_id: t, ...n } = e, r = rt(n, xr);
|
|
3808
3814
|
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), O(r);
|
|
3809
3815
|
}
|
|
3810
|
-
function
|
|
3816
|
+
function Cr(e) {
|
|
3811
3817
|
return {
|
|
3812
3818
|
async create(t, n, r, i) {
|
|
3813
3819
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3814
|
-
...
|
|
3820
|
+
...nt(n),
|
|
3815
3821
|
tenant_id: t,
|
|
3816
3822
|
themeId: s,
|
|
3817
3823
|
created_at: a?.created_at ?? o,
|
|
3818
3824
|
updated_at: a?.updated_at ?? o
|
|
3819
3825
|
};
|
|
3820
|
-
return await e.insert(
|
|
3826
|
+
return await e.insert(Ue).values(c), Sr({
|
|
3821
3827
|
...c,
|
|
3822
3828
|
tenant_id: t
|
|
3823
3829
|
});
|
|
3824
3830
|
},
|
|
3825
3831
|
async get(n, r) {
|
|
3826
|
-
let i = await e.select().from(
|
|
3827
|
-
return i ?
|
|
3832
|
+
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.themeId, r))).get();
|
|
3833
|
+
return i ? Sr(i) : null;
|
|
3828
3834
|
},
|
|
3829
3835
|
async update(n, r, i) {
|
|
3830
|
-
let o =
|
|
3831
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3836
|
+
let o = nt(i);
|
|
3837
|
+
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
3838
|
},
|
|
3833
3839
|
async remove(n, r) {
|
|
3834
|
-
return (await e.delete(
|
|
3840
|
+
return (await e.delete(Ue).where(t(a(Ue.tenant_id, n), a(Ue.themeId, r))).returning()).length > 0;
|
|
3835
3841
|
}
|
|
3836
3842
|
};
|
|
3837
3843
|
}
|
|
3838
3844
|
//#endregion
|
|
3839
3845
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3840
|
-
function
|
|
3846
|
+
function wr(e) {
|
|
3841
3847
|
return {
|
|
3842
3848
|
async get(t) {
|
|
3843
|
-
let n = await e.select({ body:
|
|
3849
|
+
let n = await e.select({ body: He.body }).from(He).where(a(He.tenant_id, t)).get();
|
|
3844
3850
|
return n ? { body: n.body } : null;
|
|
3845
3851
|
},
|
|
3846
3852
|
async set(t, n) {
|
|
3847
3853
|
let r = Date.now();
|
|
3848
|
-
await e.insert(
|
|
3854
|
+
await e.insert(He).values({
|
|
3849
3855
|
tenant_id: t,
|
|
3850
3856
|
body: n.body,
|
|
3851
3857
|
created_at_ts: r,
|
|
3852
3858
|
updated_at_ts: r
|
|
3853
3859
|
}).onConflictDoUpdate({
|
|
3854
|
-
target:
|
|
3860
|
+
target: He.tenant_id,
|
|
3855
3861
|
set: {
|
|
3856
3862
|
body: n.body,
|
|
3857
3863
|
updated_at_ts: r
|
|
@@ -3859,20 +3865,20 @@ function br(e) {
|
|
|
3859
3865
|
});
|
|
3860
3866
|
},
|
|
3861
3867
|
async delete(t) {
|
|
3862
|
-
await e.delete(
|
|
3868
|
+
await e.delete(He).where(a(He.tenant_id, t));
|
|
3863
3869
|
}
|
|
3864
3870
|
};
|
|
3865
3871
|
}
|
|
3866
3872
|
//#endregion
|
|
3867
3873
|
//#region src/adapters/userActivity.ts
|
|
3868
|
-
function
|
|
3874
|
+
function Tr(e) {
|
|
3869
3875
|
let t = {};
|
|
3870
3876
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
3871
3877
|
}
|
|
3872
|
-
function
|
|
3878
|
+
function Er(e) {
|
|
3873
3879
|
return {
|
|
3874
3880
|
async get(n, r) {
|
|
3875
|
-
let i = await e.select().from(
|
|
3881
|
+
let i = await e.select().from(Me).where(t(a(Me.tenant_id, n), a(Me.user_id, r))).get();
|
|
3876
3882
|
return i ? {
|
|
3877
3883
|
user_id: i.user_id,
|
|
3878
3884
|
last_login: i.last_login ?? void 0,
|
|
@@ -3883,7 +3889,7 @@ function Sr(e) {
|
|
|
3883
3889
|
} : null;
|
|
3884
3890
|
},
|
|
3885
3891
|
async upsert(t, n, r) {
|
|
3886
|
-
let i =
|
|
3892
|
+
let i = Tr(r), a = e.insert(Me).values({
|
|
3887
3893
|
tenant_id: t,
|
|
3888
3894
|
user_id: n,
|
|
3889
3895
|
login_count: 0,
|
|
@@ -3894,7 +3900,7 @@ function Sr(e) {
|
|
|
3894
3900
|
return;
|
|
3895
3901
|
}
|
|
3896
3902
|
await a.onConflictDoUpdate({
|
|
3897
|
-
target: [
|
|
3903
|
+
target: [Me.tenant_id, Me.user_id],
|
|
3898
3904
|
set: i
|
|
3899
3905
|
});
|
|
3900
3906
|
}
|
|
@@ -3902,13 +3908,13 @@ function Sr(e) {
|
|
|
3902
3908
|
}
|
|
3903
3909
|
//#endregion
|
|
3904
3910
|
//#region src/adapters/outbox.ts
|
|
3905
|
-
function
|
|
3911
|
+
function Dr(e) {
|
|
3906
3912
|
return {
|
|
3907
3913
|
...e,
|
|
3908
3914
|
payload: Q(e.payload, {})
|
|
3909
3915
|
};
|
|
3910
3916
|
}
|
|
3911
|
-
function
|
|
3917
|
+
function Or(e, t, n, r) {
|
|
3912
3918
|
return e.insert(Y).values({
|
|
3913
3919
|
id: t,
|
|
3914
3920
|
tenant_id: n,
|
|
@@ -3929,18 +3935,18 @@ function wr(e, t, n, r) {
|
|
|
3929
3935
|
claim_expires_at: null
|
|
3930
3936
|
});
|
|
3931
3937
|
}
|
|
3932
|
-
function
|
|
3938
|
+
function kr(e) {
|
|
3933
3939
|
return {
|
|
3934
3940
|
async create(t, n) {
|
|
3935
3941
|
let r = b();
|
|
3936
|
-
return await
|
|
3942
|
+
return await Or(e, r, t, n), r;
|
|
3937
3943
|
},
|
|
3938
3944
|
async getByIds(t) {
|
|
3939
|
-
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(
|
|
3945
|
+
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(Dr);
|
|
3940
3946
|
},
|
|
3941
3947
|
async getUnprocessed(n) {
|
|
3942
3948
|
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(
|
|
3949
|
+
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(Dr);
|
|
3944
3950
|
},
|
|
3945
3951
|
async claimEvents(n, r, i) {
|
|
3946
3952
|
if (n.length === 0) return [];
|
|
@@ -4010,10 +4016,10 @@ function Tr(e) {
|
|
|
4010
4016
|
}
|
|
4011
4017
|
//#endregion
|
|
4012
4018
|
//#region src/adapters/users.ts
|
|
4013
|
-
function
|
|
4014
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4019
|
+
function Ar(e, t, n) {
|
|
4020
|
+
return (n?.outboxEvents ?? []).map((n) => Or(e, n.id, t, n));
|
|
4015
4021
|
}
|
|
4016
|
-
var
|
|
4022
|
+
var jr = [
|
|
4017
4023
|
"user_id",
|
|
4018
4024
|
"email",
|
|
4019
4025
|
"email_verified",
|
|
@@ -4035,23 +4041,23 @@ var Dr = [
|
|
|
4035
4041
|
"login_count",
|
|
4036
4042
|
"created_at",
|
|
4037
4043
|
"updated_at"
|
|
4038
|
-
],
|
|
4044
|
+
], Mr = [
|
|
4039
4045
|
"email",
|
|
4040
4046
|
"name",
|
|
4041
4047
|
"phone_number",
|
|
4042
4048
|
"user_id"
|
|
4043
|
-
],
|
|
4049
|
+
], Nr = new Set([
|
|
4044
4050
|
"last_login",
|
|
4045
4051
|
"last_ip",
|
|
4046
4052
|
"login_count"
|
|
4047
|
-
]),
|
|
4048
|
-
coalesce:
|
|
4053
|
+
]), Pr = o(j), Fr = o(Me), Ir = Object.fromEntries(jr.map((e) => [e, e === "login_count" ? {
|
|
4054
|
+
coalesce: Me.login_count,
|
|
4049
4055
|
defaultValue: 0
|
|
4050
|
-
} :
|
|
4051
|
-
function
|
|
4052
|
-
return t(a(
|
|
4056
|
+
} : Nr.has(e) ? Fr[e] : Pr[e]]));
|
|
4057
|
+
function Lr() {
|
|
4058
|
+
return t(a(Me.tenant_id, j.tenant_id), a(Me.user_id, j.user_id));
|
|
4053
4059
|
}
|
|
4054
|
-
function
|
|
4060
|
+
function Rr(e, t) {
|
|
4055
4061
|
return {
|
|
4056
4062
|
...e,
|
|
4057
4063
|
last_login: t?.last_login,
|
|
@@ -4059,7 +4065,7 @@ function Pr(e, t) {
|
|
|
4059
4065
|
login_count: t?.login_count ?? 0
|
|
4060
4066
|
};
|
|
4061
4067
|
}
|
|
4062
|
-
function
|
|
4068
|
+
function zr(e, t) {
|
|
4063
4069
|
let n = {
|
|
4064
4070
|
connection: e.connection,
|
|
4065
4071
|
provider: e.provider,
|
|
@@ -4072,8 +4078,8 @@ function Fr(e, t) {
|
|
|
4072
4078
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
4073
4079
|
}, n;
|
|
4074
4080
|
}
|
|
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 =
|
|
4081
|
+
function Br(e, t = []) {
|
|
4082
|
+
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = zr(e, !0), m = t.map((e) => zr(e, !1));
|
|
4077
4083
|
return O({
|
|
4078
4084
|
...f,
|
|
4079
4085
|
email: e.email || "",
|
|
@@ -4087,7 +4093,7 @@ function Ir(e, t = []) {
|
|
|
4087
4093
|
identities: [p, ...m]
|
|
4088
4094
|
});
|
|
4089
4095
|
}
|
|
4090
|
-
function
|
|
4096
|
+
function Vr(e) {
|
|
4091
4097
|
let o = async (t, n, r) => {
|
|
4092
4098
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4093
4099
|
user_id: n.user_id,
|
|
@@ -4125,7 +4131,7 @@ function Lr(e) {
|
|
|
4125
4131
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4126
4132
|
try {
|
|
4127
4133
|
let c = [e.insert(j).values(a)];
|
|
4128
|
-
s && c.push(e.insert(
|
|
4134
|
+
s && c.push(e.insert(Me).values({
|
|
4129
4135
|
tenant_id: t,
|
|
4130
4136
|
user_id: n.user_id,
|
|
4131
4137
|
last_login: n.last_login,
|
|
@@ -4141,12 +4147,12 @@ function Lr(e) {
|
|
|
4141
4147
|
created_at: i,
|
|
4142
4148
|
updated_at: i
|
|
4143
4149
|
}));
|
|
4144
|
-
for (let n of
|
|
4145
|
-
c.length > 1 ? await
|
|
4150
|
+
for (let n of Ar(e, t, r)) c.push(n);
|
|
4151
|
+
c.length > 1 ? await pt(e, c) : await e.insert(j).values(a);
|
|
4146
4152
|
} catch (e) {
|
|
4147
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4153
|
+
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
4154
|
}
|
|
4149
|
-
return
|
|
4155
|
+
return Br({
|
|
4150
4156
|
...a,
|
|
4151
4157
|
last_login: n.last_login,
|
|
4152
4158
|
last_ip: n.last_ip,
|
|
@@ -4157,10 +4163,10 @@ function Lr(e) {
|
|
|
4157
4163
|
create: o,
|
|
4158
4164
|
rawCreate: o,
|
|
4159
4165
|
async get(n, r) {
|
|
4160
|
-
let i = await e.select().from(j).leftJoin(
|
|
4166
|
+
let i = await e.select().from(j).leftJoin(Me, Lr()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
4161
4167
|
if (!i) return null;
|
|
4162
4168
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
4163
|
-
return
|
|
4169
|
+
return Br(Rr(i.users, i.user_activity), o);
|
|
4164
4170
|
},
|
|
4165
4171
|
async update(n, r, i, o) {
|
|
4166
4172
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4187,8 +4193,8 @@ function Lr(e) {
|
|
|
4187
4193
|
"zoneinfo"
|
|
4188
4194
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4189
4195
|
i.email_verified !== void 0 && (s.email_verified = i.email_verified), i.phone_verified !== void 0 && (s.phone_verified = i.phone_verified), i.is_social !== void 0 && (s.is_social = i.is_social), i.blocked !== void 0 && (s.blocked = i.blocked), i.app_metadata !== void 0 && (s.app_metadata = JSON.stringify(i.app_metadata)), i.user_metadata !== void 0 && (s.user_metadata = JSON.stringify(i.user_metadata)), i.address !== void 0 && (s.address = JSON.stringify(i.address)), i.profileData !== void 0 && (s.profileData = JSON.stringify(i.profileData));
|
|
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
|
|
4196
|
+
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;
|
|
4197
|
+
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
4198
|
last_login: i.last_login,
|
|
4193
4199
|
last_ip: i.last_ip,
|
|
4194
4200
|
login_count: i.login_count
|
|
@@ -4197,24 +4203,24 @@ function Lr(e) {
|
|
|
4197
4203
|
async list(o, s) {
|
|
4198
4204
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(j.tenant_id, o), f(j.linked_to)];
|
|
4199
4205
|
if (m) {
|
|
4200
|
-
let e =
|
|
4206
|
+
let e = be(m, jr);
|
|
4201
4207
|
if (e) {
|
|
4202
|
-
let t =
|
|
4208
|
+
let t = ot(Ir, e, Mr);
|
|
4203
4209
|
t && h.push(t);
|
|
4204
4210
|
}
|
|
4205
4211
|
}
|
|
4206
4212
|
let g = t(...h), _ = async (n) => {
|
|
4207
4213
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(j).where(t(a(j.tenant_id, o), l(j.linked_to, r))) : [];
|
|
4208
|
-
return n.map((e) =>
|
|
4214
|
+
return n.map((e) => Br(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4209
4215
|
};
|
|
4210
|
-
if (
|
|
4211
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4216
|
+
if (vt(s)) {
|
|
4217
|
+
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
4218
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4213
4219
|
sortColumn: j.created_at,
|
|
4214
4220
|
idColumn: j.user_id,
|
|
4215
4221
|
sortOrder: n,
|
|
4216
4222
|
sortKey: `created_at:${n}`
|
|
4217
|
-
}, i =
|
|
4223
|
+
}, 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
4224
|
return {
|
|
4219
4225
|
users: l,
|
|
4220
4226
|
start: 0,
|
|
@@ -4223,17 +4229,17 @@ function Lr(e) {
|
|
|
4223
4229
|
next: c
|
|
4224
4230
|
};
|
|
4225
4231
|
}
|
|
4226
|
-
let v = e.select().from(j).leftJoin(
|
|
4232
|
+
let v = e.select().from(j).leftJoin(Me, Lr()).where(g).$dynamic();
|
|
4227
4233
|
if (p?.sort_by) {
|
|
4228
|
-
let e =
|
|
4234
|
+
let e = Ir[p.sort_by];
|
|
4229
4235
|
if (e) {
|
|
4230
|
-
let t =
|
|
4236
|
+
let t = it(e) ? at(e) : e;
|
|
4231
4237
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4232
4238
|
}
|
|
4233
4239
|
}
|
|
4234
|
-
let y = await _((await v.offset(c * u).limit(u)).map((e) =>
|
|
4240
|
+
let y = await _((await v.offset(c * u).limit(u)).map((e) => Rr(e.users, e.user_activity)));
|
|
4235
4241
|
if (!d) return { users: y };
|
|
4236
|
-
let [ee] = await e.select({ count: r() }).from(j).leftJoin(
|
|
4242
|
+
let [ee] = await e.select({ count: r() }).from(j).leftJoin(Me, Lr()).where(g);
|
|
4237
4243
|
return {
|
|
4238
4244
|
users: y,
|
|
4239
4245
|
start: c * u,
|
|
@@ -4245,12 +4251,12 @@ function Lr(e) {
|
|
|
4245
4251
|
let o = await e.select({ user_id: j.user_id }).from(j).where(t(a(j.tenant_id, n), v(a(j.user_id, r), a(j.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
|
|
4246
4252
|
e.delete(q).where(t(a(q.tenant_id, n), l(q.user_id, u))),
|
|
4247
4253
|
e.delete(M).where(t(a(M.tenant_id, n), l(M.user_id, u))),
|
|
4248
|
-
e.delete(
|
|
4254
|
+
e.delete(Me).where(t(a(Me.tenant_id, n), l(Me.user_id, u))),
|
|
4249
4255
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4250
4256
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4251
4257
|
], f = d.length - 1;
|
|
4252
|
-
if (s) for (let t of
|
|
4253
|
-
let p = (await
|
|
4258
|
+
if (s) for (let t of Ar(e, n, i)) d.push(t);
|
|
4259
|
+
let p = (await pt(e, d))[f];
|
|
4254
4260
|
return Array.isArray(p) && p.length > 0;
|
|
4255
4261
|
},
|
|
4256
4262
|
async unlink(n, r, i, o) {
|
|
@@ -4261,7 +4267,7 @@ function Lr(e) {
|
|
|
4261
4267
|
}
|
|
4262
4268
|
//#endregion
|
|
4263
4269
|
//#region src/adapters/userRoles.ts
|
|
4264
|
-
function
|
|
4270
|
+
function Hr(e) {
|
|
4265
4271
|
return {
|
|
4266
4272
|
async create(t, n, r, i) {
|
|
4267
4273
|
try {
|
|
@@ -4295,12 +4301,12 @@ function Rr(e) {
|
|
|
4295
4301
|
},
|
|
4296
4302
|
async listUsers(r, i, o) {
|
|
4297
4303
|
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4298
|
-
if (
|
|
4304
|
+
if (vt(o)) {
|
|
4299
4305
|
let n = {
|
|
4300
4306
|
sortColumn: G.user_id,
|
|
4301
4307
|
idColumn: G.user_id,
|
|
4302
4308
|
sortOrder: "asc"
|
|
4303
|
-
}, r =
|
|
4309
|
+
}, 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
4310
|
return {
|
|
4305
4311
|
userIds: a.map((e) => e.user_id),
|
|
4306
4312
|
start: 0,
|
|
@@ -4324,7 +4330,7 @@ function Rr(e) {
|
|
|
4324
4330
|
}
|
|
4325
4331
|
//#endregion
|
|
4326
4332
|
//#region src/adapters/userOrganizations.ts
|
|
4327
|
-
function
|
|
4333
|
+
function Ur(e) {
|
|
4328
4334
|
return {
|
|
4329
4335
|
async create(t, n) {
|
|
4330
4336
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4338,7 +4344,7 @@ function zr(e) {
|
|
|
4338
4344
|
try {
|
|
4339
4345
|
await e.insert(U).values(i);
|
|
4340
4346
|
} catch (e) {
|
|
4341
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4347
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new De(409, { message: "User organization already exists" }) : e;
|
|
4342
4348
|
}
|
|
4343
4349
|
let { tenant_id: a, ...o } = i;
|
|
4344
4350
|
return o;
|
|
@@ -4356,19 +4362,19 @@ function zr(e) {
|
|
|
4356
4362
|
async list(n, o) {
|
|
4357
4363
|
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4358
4364
|
if (c) {
|
|
4359
|
-
let e =
|
|
4365
|
+
let e = ot(U, c, ["user_id", "organization_id"]);
|
|
4360
4366
|
e && (u = t(l, e));
|
|
4361
4367
|
}
|
|
4362
4368
|
let d = (e) => {
|
|
4363
4369
|
let { tenant_id: t, ...n } = e;
|
|
4364
4370
|
return n;
|
|
4365
4371
|
};
|
|
4366
|
-
if (
|
|
4372
|
+
if (vt(o)) {
|
|
4367
4373
|
let n = {
|
|
4368
4374
|
sortColumn: U.created_at,
|
|
4369
4375
|
idColumn: U.id,
|
|
4370
4376
|
sortOrder: "desc"
|
|
4371
|
-
}, r =
|
|
4377
|
+
}, 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
4378
|
return {
|
|
4373
4379
|
userOrganizations: a,
|
|
4374
4380
|
start: 0,
|
|
@@ -4416,19 +4422,19 @@ function zr(e) {
|
|
|
4416
4422
|
}
|
|
4417
4423
|
//#endregion
|
|
4418
4424
|
//#region src/adapters/stats.ts
|
|
4419
|
-
var
|
|
4420
|
-
function
|
|
4425
|
+
var Wr = ["s"], Gr = ["pwd_leak"];
|
|
4426
|
+
function Kr(e) {
|
|
4421
4427
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4422
4428
|
}
|
|
4423
|
-
function
|
|
4429
|
+
function qr(e) {
|
|
4424
4430
|
return {
|
|
4425
4431
|
async getDaily(n, r) {
|
|
4426
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4432
|
+
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
4433
|
return (await e.select({
|
|
4428
4434
|
date: y`substr(${J.date}, 1, 10)`.as("date"),
|
|
4429
|
-
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4435
|
+
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(Wr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4430
4436
|
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(
|
|
4437
|
+
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
4438
|
}).from(J).where(t(a(J.tenant_id, n), c(J.date, o), h(J.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${J.date}, 1, 10)`).orderBy(y`substr(${J.date}, 1, 10)`).all()).map((e) => ({
|
|
4433
4439
|
date: e.date,
|
|
4434
4440
|
logins: Number(e.logins) || 0,
|
|
@@ -4439,14 +4445,14 @@ function Ur(e) {
|
|
|
4439
4445
|
}));
|
|
4440
4446
|
},
|
|
4441
4447
|
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(
|
|
4448
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(Wr.map((e) => y`${e}`), y`, `)})`));
|
|
4443
4449
|
return Number(i?.count) || 0;
|
|
4444
4450
|
}
|
|
4445
4451
|
};
|
|
4446
4452
|
}
|
|
4447
4453
|
//#endregion
|
|
4448
4454
|
//#region src/adapters/analytics.ts
|
|
4449
|
-
var
|
|
4455
|
+
var Jr = {
|
|
4450
4456
|
"active-users": ["s", "seacft"],
|
|
4451
4457
|
logins: [
|
|
4452
4458
|
"s",
|
|
@@ -4476,7 +4482,7 @@ var Wr = {
|
|
|
4476
4482
|
"fvr"
|
|
4477
4483
|
],
|
|
4478
4484
|
"codes-sent": ["cls", "cs"]
|
|
4479
|
-
},
|
|
4485
|
+
}, Yr = {
|
|
4480
4486
|
"active-users": {
|
|
4481
4487
|
alias: "active_users",
|
|
4482
4488
|
type: "UInt64",
|
|
@@ -4533,7 +4539,7 @@ var Wr = {
|
|
|
4533
4539
|
agg: "count"
|
|
4534
4540
|
}
|
|
4535
4541
|
};
|
|
4536
|
-
function
|
|
4542
|
+
function Xr(e) {
|
|
4537
4543
|
switch (e) {
|
|
4538
4544
|
case "hour": return y`substr(${J.date}, 1, 13)`;
|
|
4539
4545
|
case "month": return y`substr(${J.date}, 1, 7)`;
|
|
@@ -4542,10 +4548,10 @@ function Kr(e) {
|
|
|
4542
4548
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4543
4549
|
}
|
|
4544
4550
|
}
|
|
4545
|
-
function
|
|
4551
|
+
function Zr(e) {
|
|
4546
4552
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4547
4553
|
}
|
|
4548
|
-
function
|
|
4554
|
+
function Qr(e) {
|
|
4549
4555
|
switch (e) {
|
|
4550
4556
|
case "connection": return J.connection;
|
|
4551
4557
|
case "client_id": return J.client_id;
|
|
@@ -4554,66 +4560,80 @@ function Jr(e) {
|
|
|
4554
4560
|
case "time": throw Error("time dimension handled separately");
|
|
4555
4561
|
}
|
|
4556
4562
|
}
|
|
4557
|
-
function
|
|
4558
|
-
return {
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
let e
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4563
|
+
function $r(e) {
|
|
4564
|
+
return {
|
|
4565
|
+
async query(n, r, i) {
|
|
4566
|
+
let o = Date.now(), s = Jr[r], u = Yr[r], d = [
|
|
4567
|
+
a(J.tenant_id, n),
|
|
4568
|
+
c(J.date, i.from),
|
|
4569
|
+
m(J.date, i.to),
|
|
4570
|
+
l(J.type, s)
|
|
4571
|
+
];
|
|
4572
|
+
i.filters.connection?.length && d.push(l(J.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(J.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(J.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(J.user_id, i.filters.user_id));
|
|
4573
|
+
let f = {}, p = [], h = [];
|
|
4574
|
+
for (let e of i.group_by) if (e === "time") {
|
|
4575
|
+
let e = Xr(i.interval);
|
|
4576
|
+
f.time = e, p.push(e), h.push({
|
|
4577
|
+
name: "time",
|
|
4578
|
+
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4579
|
+
});
|
|
4580
|
+
} else {
|
|
4581
|
+
let t = Qr(e);
|
|
4582
|
+
f[e] = t, p.push(t), h.push({
|
|
4583
|
+
name: e,
|
|
4584
|
+
type: "String"
|
|
4585
|
+
});
|
|
4586
|
+
}
|
|
4587
|
+
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${J.user_id})` : y`COUNT(*)`, h.push({
|
|
4588
|
+
name: u.alias,
|
|
4589
|
+
type: u.type
|
|
4572
4590
|
});
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4591
|
+
let g = e.select(f).from(J).where(t(...d));
|
|
4592
|
+
p.length > 0 && (g = g.groupBy(...p));
|
|
4593
|
+
let _ = new Set([...Object.keys(f)]);
|
|
4594
|
+
if (i.order_by) {
|
|
4595
|
+
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4596
|
+
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4597
|
+
let n = Zr(t);
|
|
4598
|
+
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4599
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Zr("time")} ASC`)) : g.orderBy(y.raw(`${Zr(u.alias)} DESC`));
|
|
4600
|
+
g = g.limit(i.limit).offset(i.offset);
|
|
4601
|
+
let v = (await g.all()).map((e) => {
|
|
4602
|
+
let t = {};
|
|
4603
|
+
for (let n of h) {
|
|
4604
|
+
let r = e[n.name];
|
|
4605
|
+
t[n.name] = n.type === "UInt64" ? Number(r) || 0 : r ?? "";
|
|
4606
|
+
}
|
|
4607
|
+
return t;
|
|
4578
4608
|
});
|
|
4609
|
+
return {
|
|
4610
|
+
meta: h,
|
|
4611
|
+
data: v,
|
|
4612
|
+
rows: v.length,
|
|
4613
|
+
rows_before_limit_at_least: v.length,
|
|
4614
|
+
statistics: { elapsed: (Date.now() - o) / 1e3 }
|
|
4615
|
+
};
|
|
4616
|
+
},
|
|
4617
|
+
async sessionRetention(n, r) {
|
|
4618
|
+
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}`;
|
|
4619
|
+
return de((await e.select({
|
|
4620
|
+
created_week: s,
|
|
4621
|
+
used_week: l,
|
|
4622
|
+
count: y`COUNT(*)`
|
|
4623
|
+
}).from(N).where(t(a(N.tenant_id, n), c(N.created_at_ts, o))).groupBy(s, l).all()).map((e) => ({
|
|
4624
|
+
created_week: Math.floor(Number(e.created_week)),
|
|
4625
|
+
used_week: Math.floor(Number(e.used_week)),
|
|
4626
|
+
count: Number(e.count)
|
|
4627
|
+
})), r.weeks, i);
|
|
4579
4628
|
}
|
|
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
|
-
} };
|
|
4629
|
+
};
|
|
4610
4630
|
}
|
|
4611
4631
|
//#endregion
|
|
4612
4632
|
//#region src/adapters/cleanup.ts
|
|
4613
|
-
var
|
|
4614
|
-
function
|
|
4633
|
+
var ei = 10080 * 60 * 1e3;
|
|
4634
|
+
function ti(e) {
|
|
4615
4635
|
return async (n) => {
|
|
4616
|
-
let r = Date.now() -
|
|
4636
|
+
let r = Date.now() - ei;
|
|
4617
4637
|
try {
|
|
4618
4638
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4619
4639
|
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 +4664,7 @@ var $ = w("tenant_operations", {
|
|
|
4644
4664
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4645
4665
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4646
4666
|
x("tenant_operations_status_idx").on(e.status)
|
|
4647
|
-
]),
|
|
4667
|
+
]), ni = w("tenant_operation_events", {
|
|
4648
4668
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4649
4669
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4650
4670
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4656,7 +4676,7 @@ var $ = w("tenant_operations", {
|
|
|
4656
4676
|
columns: [e.operation_id],
|
|
4657
4677
|
foreignColumns: [$.id],
|
|
4658
4678
|
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)]),
|
|
4679
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), ri = w("rollouts", {
|
|
4660
4680
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4661
4681
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4662
4682
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4672,8 +4692,8 @@ var $ = w("tenant_operations", {
|
|
|
4672
4692
|
});
|
|
4673
4693
|
//#endregion
|
|
4674
4694
|
//#region src/adapters/tenantOperations.ts
|
|
4675
|
-
function
|
|
4676
|
-
return
|
|
4695
|
+
function ii(e) {
|
|
4696
|
+
return Ee.parse({
|
|
4677
4697
|
id: e.id,
|
|
4678
4698
|
tenant_id: e.tenant_id,
|
|
4679
4699
|
rollout_id: e.rollout_id,
|
|
@@ -4691,10 +4711,10 @@ function ei(e) {
|
|
|
4691
4711
|
finished_at: e.finished_at
|
|
4692
4712
|
});
|
|
4693
4713
|
}
|
|
4694
|
-
function
|
|
4714
|
+
function ai(e) {
|
|
4695
4715
|
return {
|
|
4696
4716
|
async create(t) {
|
|
4697
|
-
let n =
|
|
4717
|
+
let n = Te.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4698
4718
|
id: `op_${b()}`,
|
|
4699
4719
|
tenant_id: n.tenant_id,
|
|
4700
4720
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4718,7 +4738,7 @@ function ti(e) {
|
|
|
4718
4738
|
},
|
|
4719
4739
|
async get(t) {
|
|
4720
4740
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4721
|
-
return n[0] ?
|
|
4741
|
+
return n[0] ? ii(n[0]) : null;
|
|
4722
4742
|
},
|
|
4723
4743
|
async list(n = {}) {
|
|
4724
4744
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4729,7 +4749,7 @@ function ti(e) {
|
|
|
4729
4749
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4730
4750
|
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
4751
|
return {
|
|
4732
|
-
operations: c.map(
|
|
4752
|
+
operations: c.map(ii),
|
|
4733
4753
|
start: r * o,
|
|
4734
4754
|
limit: o,
|
|
4735
4755
|
length: c.length
|
|
@@ -4747,27 +4767,27 @@ function ti(e) {
|
|
|
4747
4767
|
}
|
|
4748
4768
|
//#endregion
|
|
4749
4769
|
//#region src/helpers/monotonic-id.ts
|
|
4750
|
-
var
|
|
4751
|
-
function
|
|
4770
|
+
var oi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", si = 32, ci = 10, li = 4, ui = 10;
|
|
4771
|
+
function di(e, t) {
|
|
4752
4772
|
let n = "";
|
|
4753
|
-
for (let r = t; r > 0; r--) n =
|
|
4773
|
+
for (let r = t; r > 0; r--) n = oi.charAt(e % si) + n, e = Math.floor(e / si);
|
|
4754
4774
|
return n;
|
|
4755
4775
|
}
|
|
4756
|
-
function
|
|
4757
|
-
let e = new Uint8Array(
|
|
4776
|
+
function fi() {
|
|
4777
|
+
let e = new Uint8Array(ui);
|
|
4758
4778
|
crypto.getRandomValues(e);
|
|
4759
4779
|
let t = "";
|
|
4760
|
-
for (let n = 0; n <
|
|
4780
|
+
for (let n = 0; n < ui; n++) t += oi.charAt(e[n] % si);
|
|
4761
4781
|
return t;
|
|
4762
4782
|
}
|
|
4763
|
-
var
|
|
4764
|
-
function
|
|
4783
|
+
var pi = 0, mi = 0;
|
|
4784
|
+
function hi() {
|
|
4765
4785
|
let e = Date.now();
|
|
4766
|
-
return e ===
|
|
4786
|
+
return e === pi ? mi++ : (pi = e, mi = 0), di(e, ci) + di(mi, li) + fi();
|
|
4767
4787
|
}
|
|
4768
4788
|
//#endregion
|
|
4769
4789
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4770
|
-
function
|
|
4790
|
+
function gi(e) {
|
|
4771
4791
|
if (!e) return null;
|
|
4772
4792
|
try {
|
|
4773
4793
|
let t = JSON.parse(e);
|
|
@@ -4775,22 +4795,22 @@ function fi(e) {
|
|
|
4775
4795
|
} catch {}
|
|
4776
4796
|
return null;
|
|
4777
4797
|
}
|
|
4778
|
-
function
|
|
4779
|
-
return
|
|
4798
|
+
function _i(e) {
|
|
4799
|
+
return we.parse({
|
|
4780
4800
|
id: e.id,
|
|
4781
4801
|
operation_id: e.operation_id,
|
|
4782
4802
|
step: e.step,
|
|
4783
4803
|
outcome: e.outcome,
|
|
4784
|
-
detail:
|
|
4804
|
+
detail: gi(e.detail),
|
|
4785
4805
|
attempt: e.attempt,
|
|
4786
4806
|
created_at: e.created_at
|
|
4787
4807
|
});
|
|
4788
4808
|
}
|
|
4789
|
-
function
|
|
4809
|
+
function vi(e) {
|
|
4790
4810
|
return {
|
|
4791
4811
|
async create(t) {
|
|
4792
|
-
let n =
|
|
4793
|
-
id: `evt_${
|
|
4812
|
+
let n = Ce.parse(t), r = {
|
|
4813
|
+
id: `evt_${hi()}`,
|
|
4794
4814
|
operation_id: n.operation_id,
|
|
4795
4815
|
step: n.step,
|
|
4796
4816
|
outcome: n.outcome,
|
|
@@ -4798,7 +4818,7 @@ function mi(e) {
|
|
|
4798
4818
|
attempt: n.attempt,
|
|
4799
4819
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4800
4820
|
};
|
|
4801
|
-
return await e.insert(
|
|
4821
|
+
return await e.insert(ni).values(r), we.parse({
|
|
4802
4822
|
id: r.id,
|
|
4803
4823
|
operation_id: r.operation_id,
|
|
4804
4824
|
step: r.step,
|
|
@@ -4809,9 +4829,9 @@ function mi(e) {
|
|
|
4809
4829
|
});
|
|
4810
4830
|
},
|
|
4811
4831
|
async listByOperation(t, r = {}) {
|
|
4812
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4832
|
+
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
4833
|
return {
|
|
4814
|
-
events: s.map(
|
|
4834
|
+
events: s.map(_i),
|
|
4815
4835
|
start: i * o,
|
|
4816
4836
|
limit: o,
|
|
4817
4837
|
length: s.length
|
|
@@ -4821,7 +4841,7 @@ function mi(e) {
|
|
|
4821
4841
|
}
|
|
4822
4842
|
//#endregion
|
|
4823
4843
|
//#region src/adapters/rollouts.ts
|
|
4824
|
-
function
|
|
4844
|
+
function yi(e) {
|
|
4825
4845
|
if (!e) return null;
|
|
4826
4846
|
try {
|
|
4827
4847
|
return JSON.parse(e);
|
|
@@ -4829,26 +4849,26 @@ function hi(e) {
|
|
|
4829
4849
|
return null;
|
|
4830
4850
|
}
|
|
4831
4851
|
}
|
|
4832
|
-
function
|
|
4833
|
-
return
|
|
4852
|
+
function bi(e) {
|
|
4853
|
+
return ye.parse({
|
|
4834
4854
|
id: e.id,
|
|
4835
4855
|
kind: e.kind,
|
|
4836
4856
|
status: e.status,
|
|
4837
4857
|
target_worker_version: e.target_worker_version,
|
|
4838
4858
|
target_database_version: e.target_database_version,
|
|
4839
4859
|
wave_size: e.wave_size,
|
|
4840
|
-
canary_tenant_ids:
|
|
4841
|
-
filter:
|
|
4860
|
+
canary_tenant_ids: yi(e.canary_tenant_ids),
|
|
4861
|
+
filter: yi(e.filter),
|
|
4842
4862
|
initiated_by: e.initiated_by,
|
|
4843
4863
|
created_at: e.created_at,
|
|
4844
4864
|
updated_at: e.updated_at,
|
|
4845
4865
|
finished_at: e.finished_at
|
|
4846
4866
|
});
|
|
4847
4867
|
}
|
|
4848
|
-
function
|
|
4868
|
+
function xi(e) {
|
|
4849
4869
|
return {
|
|
4850
4870
|
async create(t) {
|
|
4851
|
-
let n =
|
|
4871
|
+
let n = ve.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4852
4872
|
id: `rol_${b()}`,
|
|
4853
4873
|
kind: n.kind,
|
|
4854
4874
|
status: "pending",
|
|
@@ -4862,93 +4882,93 @@ function _i(e) {
|
|
|
4862
4882
|
updated_at: r,
|
|
4863
4883
|
finished_at: null
|
|
4864
4884
|
};
|
|
4865
|
-
await e.insert(
|
|
4885
|
+
await e.insert(ri).values(i);
|
|
4866
4886
|
let a = await this.get(i.id);
|
|
4867
4887
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4868
4888
|
return a;
|
|
4869
4889
|
},
|
|
4870
4890
|
async get(t) {
|
|
4871
|
-
let n = await e.select().from(
|
|
4872
|
-
return n[0] ?
|
|
4891
|
+
let n = await e.select().from(ri).where(a(ri.id, t)).limit(1);
|
|
4892
|
+
return n[0] ? bi(n[0]) : null;
|
|
4873
4893
|
},
|
|
4874
4894
|
async list(t = {}) {
|
|
4875
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4895
|
+
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
4896
|
return {
|
|
4877
|
-
rollouts: a.map(
|
|
4897
|
+
rollouts: a.map(bi),
|
|
4878
4898
|
start: n * r,
|
|
4879
4899
|
limit: r,
|
|
4880
4900
|
length: a.length
|
|
4881
4901
|
};
|
|
4882
4902
|
},
|
|
4883
4903
|
async update(t, n) {
|
|
4884
|
-
if ((await e.select({ id:
|
|
4904
|
+
if ((await e.select({ id: ri.id }).from(ri).where(a(ri.id, t)).limit(1)).length === 0) return !1;
|
|
4885
4905
|
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(
|
|
4906
|
+
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
4907
|
},
|
|
4888
4908
|
async remove(t) {
|
|
4889
|
-
return (await e.select({ id:
|
|
4909
|
+
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
4910
|
}
|
|
4891
4911
|
};
|
|
4892
4912
|
}
|
|
4893
4913
|
//#endregion
|
|
4894
4914
|
//#region src/adapters/index.ts
|
|
4895
|
-
function
|
|
4915
|
+
function Si(e, t = { useTransactions: !0 }) {
|
|
4896
4916
|
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:
|
|
4917
|
+
actions: lt(e),
|
|
4918
|
+
actionExecutions: dt(e),
|
|
4919
|
+
actionVersions: ht(e),
|
|
4920
|
+
branding: _t(e),
|
|
4921
|
+
clients: Ot(e),
|
|
4922
|
+
clientConnections: At(e),
|
|
4923
|
+
clientGrants: Mt(e),
|
|
4924
|
+
clientRegistrationTokens: Lt(e),
|
|
4925
|
+
codes: Vt(e),
|
|
4926
|
+
connections: Wt(e),
|
|
4927
|
+
customDomains: Kt(e),
|
|
4928
|
+
customText: qt(e),
|
|
4929
|
+
emailProviders: Jt(e),
|
|
4930
|
+
emailTemplates: Xt(e),
|
|
4931
|
+
flows: Qt(e),
|
|
4932
|
+
forms: tn(e),
|
|
4933
|
+
grants: on(e),
|
|
4934
|
+
hookCode: un(e),
|
|
4935
|
+
hooks: mn(e),
|
|
4936
|
+
invites: vn(e),
|
|
4937
|
+
keys: bn(e),
|
|
4938
|
+
loginSessions: Tn(e),
|
|
4939
|
+
logs: Dn(e),
|
|
4940
|
+
authenticationMethods: Mn(e),
|
|
4941
|
+
organizations: In(e),
|
|
4942
|
+
passwords: Rn(e),
|
|
4943
|
+
promptSettings: zn(e),
|
|
4944
|
+
proxyRoutes: Un(e),
|
|
4945
|
+
scimConfigurations: qn(e),
|
|
4946
|
+
scimTokens: Yn(e),
|
|
4947
|
+
scimExternalIds: Zn(e),
|
|
4948
|
+
refreshTokens: er(e),
|
|
4949
|
+
resourceServers: or(e),
|
|
4950
|
+
rolePermissions: sr(e),
|
|
4951
|
+
userPermissions: cr(e),
|
|
4952
|
+
roles: ur(e),
|
|
4953
|
+
sessions: hr(e),
|
|
4954
|
+
sessionCleanup: ti(e),
|
|
4955
|
+
tenants: br(e),
|
|
4936
4956
|
...t.controlPlane ? {
|
|
4937
|
-
tenantOperations:
|
|
4938
|
-
tenantOperationEvents:
|
|
4939
|
-
rollouts:
|
|
4957
|
+
tenantOperations: ai(e),
|
|
4958
|
+
tenantOperationEvents: vi(e),
|
|
4959
|
+
rollouts: xi(e)
|
|
4940
4960
|
} : {},
|
|
4941
|
-
themes:
|
|
4942
|
-
universalLoginTemplates:
|
|
4943
|
-
users:
|
|
4944
|
-
userActivity:
|
|
4945
|
-
userRoles:
|
|
4946
|
-
userOrganizations:
|
|
4947
|
-
stats:
|
|
4948
|
-
analytics:
|
|
4949
|
-
outbox:
|
|
4961
|
+
themes: Cr(e),
|
|
4962
|
+
universalLoginTemplates: wr(e),
|
|
4963
|
+
users: Vr(e),
|
|
4964
|
+
userActivity: Er(e),
|
|
4965
|
+
userRoles: Hr(e),
|
|
4966
|
+
userOrganizations: Ur(e),
|
|
4967
|
+
stats: qr(e),
|
|
4968
|
+
analytics: $r(e),
|
|
4969
|
+
outbox: kr(e),
|
|
4950
4970
|
async transaction(r) {
|
|
4951
|
-
if (t.useTransactions === !1 ||
|
|
4971
|
+
if (t.useTransactions === !1 || ft(e)) return r(n);
|
|
4952
4972
|
await e.run(y`BEGIN`);
|
|
4953
4973
|
try {
|
|
4954
4974
|
let t = await r(n);
|
|
@@ -4962,22 +4982,22 @@ function vi(e, t = { useTransactions: !0 }) {
|
|
|
4962
4982
|
}
|
|
4963
4983
|
//#endregion
|
|
4964
4984
|
//#region src/adapters/resolveHost.ts
|
|
4965
|
-
function
|
|
4985
|
+
function Ci(e) {
|
|
4966
4986
|
if (!e) return { path: "/*" };
|
|
4967
4987
|
try {
|
|
4968
|
-
let t = JSON.parse(e), n =
|
|
4988
|
+
let t = JSON.parse(e), n = _e.safeParse(t);
|
|
4969
4989
|
if (n.success) return n.data;
|
|
4970
4990
|
} catch {}
|
|
4971
4991
|
return { path: "/*" };
|
|
4972
4992
|
}
|
|
4973
|
-
function
|
|
4993
|
+
function wi(e) {
|
|
4974
4994
|
if (!e) return [];
|
|
4975
4995
|
try {
|
|
4976
4996
|
let t = JSON.parse(e);
|
|
4977
4997
|
if (!Array.isArray(t)) return [];
|
|
4978
4998
|
let n = [];
|
|
4979
4999
|
for (let e of t) {
|
|
4980
|
-
let t =
|
|
5000
|
+
let t = he.safeParse(e);
|
|
4981
5001
|
t.success && n.push(t.data);
|
|
4982
5002
|
}
|
|
4983
5003
|
return n;
|
|
@@ -4985,20 +5005,20 @@ function bi(e) {
|
|
|
4985
5005
|
return [];
|
|
4986
5006
|
}
|
|
4987
5007
|
}
|
|
4988
|
-
async function
|
|
5008
|
+
async function Ti(e, r) {
|
|
4989
5009
|
let i = r.toLowerCase(), o = (await e.select({
|
|
4990
|
-
custom_domain_id:
|
|
4991
|
-
tenant_id:
|
|
4992
|
-
domain:
|
|
4993
|
-
}).from(
|
|
5010
|
+
custom_domain_id: Ie.custom_domain_id,
|
|
5011
|
+
tenant_id: Ie.tenant_id,
|
|
5012
|
+
domain: Ie.domain
|
|
5013
|
+
}).from(Ie).where(a(Ie.domain, i)).limit(1))[0];
|
|
4994
5014
|
if (!o) return null;
|
|
4995
5015
|
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
5016
|
id: e.id,
|
|
4997
5017
|
tenant_id: e.tenant_id,
|
|
4998
5018
|
custom_domain_id: e.custom_domain_id,
|
|
4999
5019
|
priority: e.priority,
|
|
5000
|
-
match:
|
|
5001
|
-
handlers:
|
|
5020
|
+
match: Ci(e.match),
|
|
5021
|
+
handlers: wi(e.handlers),
|
|
5002
5022
|
created_at: e.created_at,
|
|
5003
5023
|
updated_at: e.updated_at
|
|
5004
5024
|
}));
|
|
@@ -5011,11 +5031,11 @@ async function xi(e, r) {
|
|
|
5011
5031
|
}
|
|
5012
5032
|
//#endregion
|
|
5013
5033
|
//#region src/adapters/proxyData.ts
|
|
5014
|
-
function
|
|
5034
|
+
function Ei(e) {
|
|
5015
5035
|
return {
|
|
5016
|
-
proxyRoutes:
|
|
5017
|
-
resolveHost: (t) =>
|
|
5036
|
+
proxyRoutes: Un(e),
|
|
5037
|
+
resolveHost: (t) => Ti(e, t)
|
|
5018
5038
|
};
|
|
5019
5039
|
}
|
|
5020
5040
|
//#endregion
|
|
5021
|
-
export {
|
|
5041
|
+
export { Ei as createProxyDataAdapter, Un as createProxyRoutesAdapter, Si as default, tt as sqlite };
|