@authhero/drizzle 1.7.4 → 1.8.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.cjs +2 -2
- package/dist/drizzle-adapter.mjs +778 -708
- package/drizzle/0009_token_exchange_profiles.sql +14 -0
- package/drizzle/meta/0009_snapshot.json +6741 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +3 -3
- package/src/schema/sqlite/clients.ts +1 -0
- package/src/schema/sqlite/index.ts +3 -0
- package/src/schema/sqlite/tokenExchangeProfiles.ts +25 -0
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -2,16 +2,16 @@ import { Column as e, and as t, asc as n, count as r, desc as i, eq as a, getTab
|
|
|
2
2
|
import { customAlphabet as ee, nanoid as b } from "nanoid";
|
|
3
3
|
import { SQLiteTable as te, foreignKey as ne, index as x, integer as S, primaryKey as C, sqliteTable as w, text as T, uniqueIndex as re } from "drizzle-orm/sqlite-core";
|
|
4
4
|
import { booleanToInt as ie, convertDatesToAdapter as ae, dbDateToIsoRequired as oe, getCountAsInt as se, isoToDbDate as E, removeNullProperties as D, removeUndefinedAndNull as ce, stringifyProperties as le } from "@authhero/adapter-interfaces/sql";
|
|
5
|
-
import { MONDAY_EPOCH_SHIFT_MS as ue,
|
|
6
|
-
import { HTTPException as
|
|
5
|
+
import { MONDAY_EPOCH_SHIFT_MS as ue, TOKEN_EXCHANGE_PROFILE_TYPE as de, WEEK_MS as fe, buildRefreshTokenRetention as pe, buildSessionRetention as me, clientRegistrationTokenTypeSchema as he, decodeCursor as ge, encodeCursor as _e, handlerConfigSchema as ve, isEmailSearchTerm as ye, isPlainObject as be, matchSchema as xe, parseUserId as Se, rolloutInsertSchema as Ce, rolloutSchema as we, sanitizeLuceneQuery as Te, scimMappingEntrySchema as Ee, sessionRetentionWindow as De, splitLuceneOrGroups as Oe, tenantOperationEventInsertSchema as ke, tenantOperationEventSchema as Ae, tenantOperationInsertSchema as je, tenantOperationRowInsertSchema as Me, tenantOperationRowSchema as Ne, tenantOperationSchema as Pe, tokenExchangeJwtVerificationSchema as Fe, unescapeLuceneValue as Ie } from "@authhero/adapter-interfaces";
|
|
6
|
+
import { HTTPException as Le } from "hono/http-exception";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var Re = Object.defineProperty, ze = (e, t) => {
|
|
9
9
|
let n = {};
|
|
10
|
-
for (var r in e)
|
|
10
|
+
for (var r in e) Re(n, r, {
|
|
11
11
|
get: e[r],
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
|
-
return t ||
|
|
14
|
+
return t || Re(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
15
15
|
}, O = w("tenants", {
|
|
16
16
|
id: T("id", { length: 191 }).primaryKey(),
|
|
17
17
|
name: T("name", { length: 255 }),
|
|
@@ -67,7 +67,7 @@ var Ie = Object.defineProperty, Le = (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
|
+
}), Be = w("actions", {
|
|
71
71
|
id: T("id", { length: 255 }).notNull(),
|
|
72
72
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
73
73
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -109,7 +109,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
109
109
|
}),
|
|
110
110
|
re("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
|
+
]), Ve = w("action_executions", {
|
|
113
113
|
id: T("id", { length: 255 }).notNull(),
|
|
114
114
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
115
115
|
trigger_id: T("trigger_id", { length: 255 }).notNull(),
|
|
@@ -175,7 +175,7 @@ var Ie = Object.defineProperty, Le = (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
|
+
}), He = 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 }),
|
|
@@ -298,7 +298,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
298
298
|
}, (e) => [C({
|
|
299
299
|
columns: [e.code_id, e.code_type],
|
|
300
300
|
name: "PK_codes_code_id_code_type"
|
|
301
|
-
}), x("codes_expires_at_index").on(e.expires_at)]),
|
|
301
|
+
}), x("codes_expires_at_index").on(e.expires_at)]), Ue = w("authentication_codes", {
|
|
302
302
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
303
303
|
code: T("code", { length: 255 }).primaryKey(),
|
|
304
304
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -312,7 +312,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
312
312
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
313
313
|
expires_at: T("expires_at", { length: 35 }).notNull(),
|
|
314
314
|
used_at: T("used_at", { length: 35 })
|
|
315
|
-
}),
|
|
315
|
+
}), We = w("otps", {
|
|
316
316
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
317
317
|
id: T("id", { length: 255 }).primaryKey(),
|
|
318
318
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -331,7 +331,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
331
331
|
used_at: T("used_at", { length: 35 }),
|
|
332
332
|
audience: T("audience", { length: 255 }),
|
|
333
333
|
ip: T("ip", { length: 64 })
|
|
334
|
-
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]),
|
|
334
|
+
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), Ge = w("tickets", {
|
|
335
335
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
336
336
|
id: T("id", { length: 255 }).primaryKey(),
|
|
337
337
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
@@ -401,7 +401,8 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
401
401
|
owner_user_id: T("owner_user_id", { length: 255 }),
|
|
402
402
|
registration_type: T("registration_type", { length: 32 }),
|
|
403
403
|
registration_metadata: T("registration_metadata"),
|
|
404
|
-
user_linking_mode: T("user_linking_mode", { length: 16 })
|
|
404
|
+
user_linking_mode: T("user_linking_mode", { length: 16 }),
|
|
405
|
+
token_exchange: T("token_exchange")
|
|
405
406
|
}, (e) => [C({
|
|
406
407
|
columns: [e.tenant_id, e.client_id],
|
|
407
408
|
name: "clients_tenant_id_client_id"
|
|
@@ -488,7 +489,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
488
489
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
489
490
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
490
491
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
491
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
492
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), Ke = w("domains", {
|
|
492
493
|
id: T("id", { length: 255 }).primaryKey(),
|
|
493
494
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
494
495
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -521,7 +522,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
521
522
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
522
523
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
523
524
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
524
|
-
]),
|
|
525
|
+
]), qe = w("invites", {
|
|
525
526
|
id: T("id", { length: 21 }).primaryKey(),
|
|
526
527
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
527
528
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -555,7 +556,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
555
556
|
}, (e) => [C({
|
|
556
557
|
columns: [e.tenant_id, e.id],
|
|
557
558
|
name: "roles_pk"
|
|
558
|
-
})]),
|
|
559
|
+
})]), Je = w("role_permissions", {
|
|
559
560
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
560
561
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
561
562
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -573,7 +574,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
573
574
|
}),
|
|
574
575
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
575
576
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
576
|
-
]),
|
|
577
|
+
]), Ye = w("user_permissions", {
|
|
577
578
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
578
579
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
579
580
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -634,7 +635,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
634
635
|
}, (e) => [C({
|
|
635
636
|
columns: [e.tenant_id, e.id],
|
|
636
637
|
name: "resource_servers_pk"
|
|
637
|
-
})]),
|
|
638
|
+
})]), Xe = w("branding", {
|
|
638
639
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
639
640
|
logo_url: T("logo_url", { length: 512 }),
|
|
640
641
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -645,12 +646,12 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
645
646
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
646
647
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
647
648
|
dark_mode: T("dark_mode", { length: 8 })
|
|
648
|
-
}),
|
|
649
|
+
}), Ze = w("universal_login_templates", {
|
|
649
650
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
650
651
|
body: T("body").notNull(),
|
|
651
652
|
created_at_ts: S("created_at_ts").notNull(),
|
|
652
653
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
653
|
-
}),
|
|
654
|
+
}), Qe = w("themes", {
|
|
654
655
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
655
656
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
656
657
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -710,7 +711,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
710
711
|
}, (e) => [C({
|
|
711
712
|
columns: [e.tenant_id, e.themeId],
|
|
712
713
|
name: "themes_pkey"
|
|
713
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
714
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), $e = w("forms", {
|
|
714
715
|
id: T("id", { length: 255 }).primaryKey(),
|
|
715
716
|
name: T("name", { length: 255 }).notNull(),
|
|
716
717
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -723,21 +724,21 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
723
724
|
style: T("style", { length: 1042 }),
|
|
724
725
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
725
726
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
726
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
727
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), et = w("flows", {
|
|
727
728
|
id: T("id", { length: 24 }).primaryKey(),
|
|
728
729
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
729
730
|
name: T("name", { length: 150 }).notNull(),
|
|
730
731
|
actions: T("actions"),
|
|
731
732
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
732
733
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
733
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
734
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), tt = w("prompt_settings", {
|
|
734
735
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
735
736
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
736
737
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
737
738
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
738
739
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
739
740
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
740
|
-
}),
|
|
741
|
+
}), nt = w("email_providers", {
|
|
741
742
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
742
743
|
name: T("name", { length: 255 }).notNull(),
|
|
743
744
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -746,7 +747,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
746
747
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
747
748
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
748
749
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
749
|
-
}),
|
|
750
|
+
}), rt = w("email_templates", {
|
|
750
751
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
751
752
|
template: T("template", { length: 64 }).notNull(),
|
|
752
753
|
body: T("body").notNull(),
|
|
@@ -759,7 +760,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
759
760
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
760
761
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
761
762
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
762
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
763
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), it = w("hooks", {
|
|
763
764
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
764
765
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
765
766
|
url: T("url", { length: 512 }),
|
|
@@ -775,14 +776,14 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
775
776
|
page_id: T("page_id", { length: 64 }),
|
|
776
777
|
permission_required: T("permission_required", { length: 255 }),
|
|
777
778
|
metadata: T("metadata")
|
|
778
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
779
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), at = w("hook_code", {
|
|
779
780
|
id: T("id", { length: 21 }).primaryKey(),
|
|
780
781
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
781
782
|
code: T("code").notNull(),
|
|
782
783
|
secrets: T("secrets"),
|
|
783
784
|
created_at_ts: S("created_at_ts").notNull(),
|
|
784
785
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
785
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
786
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), ot = w("keys", {
|
|
786
787
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
787
788
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
788
789
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -795,7 +796,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
795
796
|
current_until: T("current_until", { length: 35 }),
|
|
796
797
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
797
798
|
connection: T("connection", { length: 255 }).references(() => B.id, { onDelete: "cascade" })
|
|
798
|
-
}),
|
|
799
|
+
}), st = w("custom_text", {
|
|
799
800
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
800
801
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
801
802
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -806,7 +807,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
806
807
|
e.tenant_id,
|
|
807
808
|
e.prompt,
|
|
808
809
|
e.language
|
|
809
|
-
] })]),
|
|
810
|
+
] })]), ct = w("authentication_methods", {
|
|
810
811
|
id: T("id", { length: 26 }).primaryKey(),
|
|
811
812
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
812
813
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -888,7 +889,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
888
889
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
889
890
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
890
891
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
891
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
892
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), lt = w("scim_configurations", {
|
|
892
893
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
893
894
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
894
895
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -908,7 +909,7 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
908
909
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
909
910
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
910
911
|
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
911
|
-
]),
|
|
912
|
+
]), ut = w("scim_external_ids", {
|
|
912
913
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
913
914
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
914
915
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -918,53 +919,64 @@ var Ie = Object.defineProperty, Le = (e, t) => {
|
|
|
918
919
|
e.tenant_id,
|
|
919
920
|
e.connection_id,
|
|
920
921
|
e.user_id
|
|
921
|
-
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
922
|
-
|
|
922
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), dt = w("token_exchange_profiles", {
|
|
923
|
+
id: T("id", { length: 64 }).primaryKey(),
|
|
924
|
+
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
925
|
+
name: T("name", { length: 255 }).notNull(),
|
|
926
|
+
subject_token_type: T("subject_token_type", { length: 255 }).notNull(),
|
|
927
|
+
action_id: T("action_id", { length: 255 }),
|
|
928
|
+
type: T("type", { length: 64 }).notNull(),
|
|
929
|
+
jwt_verification: T("jwt_verification"),
|
|
930
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
931
|
+
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
932
|
+
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), ft = /* @__PURE__ */ ze({
|
|
933
|
+
actionExecutions: () => Ve,
|
|
923
934
|
actionVersions: () => k,
|
|
924
|
-
actions: () =>
|
|
925
|
-
authenticationCodes: () =>
|
|
926
|
-
authenticationMethods: () =>
|
|
927
|
-
branding: () =>
|
|
935
|
+
actions: () => Be,
|
|
936
|
+
authenticationCodes: () => Ue,
|
|
937
|
+
authenticationMethods: () => ct,
|
|
938
|
+
branding: () => Xe,
|
|
928
939
|
clientGrants: () => R,
|
|
929
940
|
clientRegistrationTokens: () => L,
|
|
930
941
|
clients: () => I,
|
|
931
942
|
codes: () => F,
|
|
932
943
|
connections: () => B,
|
|
933
944
|
customDomains: () => V,
|
|
934
|
-
customText: () =>
|
|
935
|
-
domains: () =>
|
|
936
|
-
emailProviders: () =>
|
|
937
|
-
emailTemplates: () =>
|
|
938
|
-
flows: () =>
|
|
939
|
-
forms: () =>
|
|
945
|
+
customText: () => st,
|
|
946
|
+
domains: () => Ke,
|
|
947
|
+
emailProviders: () => nt,
|
|
948
|
+
emailTemplates: () => rt,
|
|
949
|
+
flows: () => et,
|
|
950
|
+
forms: () => $e,
|
|
940
951
|
grants: () => z,
|
|
941
|
-
hookCode: () =>
|
|
942
|
-
hooks: () =>
|
|
943
|
-
invites: () =>
|
|
944
|
-
keys: () =>
|
|
952
|
+
hookCode: () => at,
|
|
953
|
+
hooks: () => it,
|
|
954
|
+
invites: () => qe,
|
|
955
|
+
keys: () => ot,
|
|
945
956
|
loginSessions: () => P,
|
|
946
957
|
logs: () => q,
|
|
947
958
|
organizations: () => H,
|
|
948
|
-
otps: () =>
|
|
959
|
+
otps: () => We,
|
|
949
960
|
outboxEvents: () => J,
|
|
950
961
|
passwords: () => j,
|
|
951
|
-
promptSettings: () =>
|
|
962
|
+
promptSettings: () => tt,
|
|
952
963
|
proxyRoutes: () => Y,
|
|
953
964
|
refreshTokens: () => N,
|
|
954
965
|
resourceServers: () => K,
|
|
955
|
-
rolePermissions: () =>
|
|
966
|
+
rolePermissions: () => Je,
|
|
956
967
|
roles: () => W,
|
|
957
|
-
scimConfigurations: () =>
|
|
958
|
-
scimExternalIds: () =>
|
|
968
|
+
scimConfigurations: () => lt,
|
|
969
|
+
scimExternalIds: () => ut,
|
|
959
970
|
scimTokens: () => X,
|
|
960
971
|
sessions: () => M,
|
|
961
972
|
tenants: () => O,
|
|
962
|
-
themes: () =>
|
|
963
|
-
tickets: () =>
|
|
964
|
-
|
|
965
|
-
|
|
973
|
+
themes: () => Qe,
|
|
974
|
+
tickets: () => Ge,
|
|
975
|
+
tokenExchangeProfiles: () => dt,
|
|
976
|
+
universalLoginTemplates: () => Ze,
|
|
977
|
+
userActivity: () => He,
|
|
966
978
|
userOrganizations: () => U,
|
|
967
|
-
userPermissions: () =>
|
|
979
|
+
userPermissions: () => Ye,
|
|
968
980
|
userRoles: () => G,
|
|
969
981
|
users: () => A
|
|
970
982
|
});
|
|
@@ -979,14 +991,14 @@ function Z(e, t) {
|
|
|
979
991
|
}
|
|
980
992
|
return e;
|
|
981
993
|
}
|
|
982
|
-
function
|
|
994
|
+
function pt(e, t = "", n = {}) {
|
|
983
995
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
984
996
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
985
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
997
|
+
typeof a == "object" && a && !Array.isArray(a) ? pt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
986
998
|
}
|
|
987
999
|
return n;
|
|
988
1000
|
}
|
|
989
|
-
function
|
|
1001
|
+
function mt(e, t) {
|
|
990
1002
|
let n = {};
|
|
991
1003
|
for (let [r, i] of Object.entries(e)) {
|
|
992
1004
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -1003,17 +1015,17 @@ function dt(e, t) {
|
|
|
1003
1015
|
}
|
|
1004
1016
|
//#endregion
|
|
1005
1017
|
//#region src/helpers/filter.ts
|
|
1006
|
-
function
|
|
1018
|
+
function ht(e) {
|
|
1007
1019
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1008
1020
|
}
|
|
1009
|
-
function
|
|
1021
|
+
function gt(e) {
|
|
1010
1022
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1011
1023
|
}
|
|
1012
|
-
function
|
|
1024
|
+
function _t(n, r, i, l = []) {
|
|
1013
1025
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1014
1026
|
let t = Number(e);
|
|
1015
1027
|
return Number.isFinite(t) ? t : e;
|
|
1016
|
-
}, x =
|
|
1028
|
+
}, x = Oe(r);
|
|
1017
1029
|
if (x.length > 1) {
|
|
1018
1030
|
let n = x.map((n) => {
|
|
1019
1031
|
let r = n.map((t) => {
|
|
@@ -1021,8 +1033,8 @@ function mt(n, r, i, l = []) {
|
|
|
1021
1033
|
if (!n) return null;
|
|
1022
1034
|
let [, r, i] = n;
|
|
1023
1035
|
if (!r || !i) return null;
|
|
1024
|
-
let o = r.trim(), s =
|
|
1025
|
-
return
|
|
1036
|
+
let o = r.trim(), s = Ie(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1037
|
+
return ht(c) ? a(gt(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1026
1038
|
}).filter((e) => e !== null);
|
|
1027
1039
|
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1028
1040
|
}).filter((e) => e !== null);
|
|
@@ -1034,8 +1046,8 @@ function mt(n, r, i, l = []) {
|
|
|
1034
1046
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
1035
1047
|
else if (e.includes(":")) {
|
|
1036
1048
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
1037
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
1038
|
-
} else n = null, r =
|
|
1049
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = Ie(r);
|
|
1050
|
+
} else n = null, r = Ie(e), i = !1;
|
|
1039
1051
|
return {
|
|
1040
1052
|
key: n,
|
|
1041
1053
|
value: r,
|
|
@@ -1045,12 +1057,12 @@ function mt(n, r, i, l = []) {
|
|
|
1045
1057
|
};
|
|
1046
1058
|
}), C = [];
|
|
1047
1059
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1048
|
-
let i = ee[t], v =
|
|
1060
|
+
let i = ee[t], v = ht(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1049
1061
|
if (!te) {
|
|
1050
1062
|
o ? C.push(r ? y`${y.identifier(t)} IS NULL` : y`${y.identifier(t)} IS NOT NULL`) : C.push(y`${y.identifier(t)} ${y.raw(r ? "!=" : l ?? "=")} ${n}`);
|
|
1051
1063
|
continue;
|
|
1052
1064
|
}
|
|
1053
|
-
let S = v ?
|
|
1065
|
+
let S = v ? gt(i) : y`${te}`;
|
|
1054
1066
|
if (o) C.push(r ? f(te) : d(te));
|
|
1055
1067
|
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1056
1068
|
else if (r) switch (l) {
|
|
@@ -1085,7 +1097,7 @@ function mt(n, r, i, l = []) {
|
|
|
1085
1097
|
}
|
|
1086
1098
|
} else if (n) {
|
|
1087
1099
|
let t = i.includes("email") ? ee.email : void 0;
|
|
1088
|
-
if (
|
|
1100
|
+
if (ye(n) && u(t, e)) {
|
|
1089
1101
|
C.push(a(t, n.toLowerCase()));
|
|
1090
1102
|
continue;
|
|
1091
1103
|
}
|
|
@@ -1099,11 +1111,11 @@ function mt(n, r, i, l = []) {
|
|
|
1099
1111
|
}
|
|
1100
1112
|
//#endregion
|
|
1101
1113
|
//#region src/adapters/actions.ts
|
|
1102
|
-
function
|
|
1114
|
+
function vt(e) {
|
|
1103
1115
|
let t = Z(e);
|
|
1104
1116
|
return Array.isArray(t) ? t : [];
|
|
1105
1117
|
}
|
|
1106
|
-
function
|
|
1118
|
+
function yt(e) {
|
|
1107
1119
|
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;
|
|
1108
1120
|
return {
|
|
1109
1121
|
...f,
|
|
@@ -1120,11 +1132,11 @@ function gt(e) {
|
|
|
1120
1132
|
updated_at: new Date(Number(n)).toISOString()
|
|
1121
1133
|
};
|
|
1122
1134
|
}
|
|
1123
|
-
function
|
|
1135
|
+
function bt(e) {
|
|
1124
1136
|
return {
|
|
1125
1137
|
async create(t, n) {
|
|
1126
1138
|
let r = Date.now(), i = `act_${b()}`;
|
|
1127
|
-
return await e.insert(
|
|
1139
|
+
return await e.insert(Be).values({
|
|
1128
1140
|
id: i,
|
|
1129
1141
|
tenant_id: t,
|
|
1130
1142
|
name: n.name,
|
|
@@ -1155,28 +1167,28 @@ function _t(e) {
|
|
|
1155
1167
|
};
|
|
1156
1168
|
},
|
|
1157
1169
|
async get(n, r) {
|
|
1158
|
-
let i = await e.select().from(
|
|
1159
|
-
return i ?
|
|
1170
|
+
let i = await e.select().from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get();
|
|
1171
|
+
return i ? yt(i) : null;
|
|
1160
1172
|
},
|
|
1161
1173
|
async list(o, s = {}) {
|
|
1162
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1174
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Be.tenant_id, o)];
|
|
1163
1175
|
if (f) {
|
|
1164
|
-
let e =
|
|
1176
|
+
let e = _t(Be, f, ["name"]);
|
|
1165
1177
|
e && p.push(e);
|
|
1166
1178
|
}
|
|
1167
|
-
let m = t(...p), h = e.select().from(
|
|
1179
|
+
let m = t(...p), h = e.select().from(Be).where(m).$dynamic();
|
|
1168
1180
|
if (d?.sort_by) {
|
|
1169
|
-
let e =
|
|
1181
|
+
let e = Be[d.sort_by];
|
|
1170
1182
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1171
1183
|
}
|
|
1172
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1184
|
+
let g = (await h.offset(c * l).limit(l)).map(yt);
|
|
1173
1185
|
if (!u) return {
|
|
1174
1186
|
actions: g,
|
|
1175
1187
|
start: 0,
|
|
1176
1188
|
limit: 0,
|
|
1177
1189
|
length: 0
|
|
1178
1190
|
};
|
|
1179
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1191
|
+
let [_] = await e.select({ count: r() }).from(Be).where(m);
|
|
1180
1192
|
return {
|
|
1181
1193
|
actions: g,
|
|
1182
1194
|
start: c * l,
|
|
@@ -1187,7 +1199,7 @@ function _t(e) {
|
|
|
1187
1199
|
async update(n, r, i) {
|
|
1188
1200
|
let o = { updated_at_ts: Date.now() };
|
|
1189
1201
|
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) {
|
|
1190
|
-
let s = await e.select({ secrets:
|
|
1202
|
+
let s = await e.select({ secrets: Be.secrets }).from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get(), c = new Map(vt(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1191
1203
|
name: e.name,
|
|
1192
1204
|
value: c.get(e.name)?.value
|
|
1193
1205
|
} : e);
|
|
@@ -1197,21 +1209,21 @@ function _t(e) {
|
|
|
1197
1209
|
let e = new Date(i.deployed_at).getTime();
|
|
1198
1210
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1199
1211
|
}
|
|
1200
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1212
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(Be).set(o).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
|
|
1201
1213
|
},
|
|
1202
1214
|
async remove(n, r) {
|
|
1203
|
-
return (await e.delete(
|
|
1215
|
+
return (await e.delete(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
|
|
1204
1216
|
}
|
|
1205
1217
|
};
|
|
1206
1218
|
}
|
|
1207
1219
|
//#endregion
|
|
1208
1220
|
//#region src/adapters/actionExecutions.ts
|
|
1209
|
-
var
|
|
1210
|
-
function
|
|
1221
|
+
var xt = 500;
|
|
1222
|
+
function St(e) {
|
|
1211
1223
|
return {
|
|
1212
1224
|
async create(t, n) {
|
|
1213
1225
|
let r = Date.now();
|
|
1214
|
-
return await e.insert(
|
|
1226
|
+
return await e.insert(Ve).values({
|
|
1215
1227
|
id: n.id,
|
|
1216
1228
|
tenant_id: t,
|
|
1217
1229
|
trigger_id: n.trigger_id,
|
|
@@ -1232,7 +1244,7 @@ function yt(e) {
|
|
|
1232
1244
|
};
|
|
1233
1245
|
},
|
|
1234
1246
|
async get(n, r) {
|
|
1235
|
-
let i = await e.select().from(
|
|
1247
|
+
let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
|
|
1236
1248
|
return i ? {
|
|
1237
1249
|
id: i.id,
|
|
1238
1250
|
tenant_id: i.tenant_id,
|
|
@@ -1249,8 +1261,8 @@ function yt(e) {
|
|
|
1249
1261
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1250
1262
|
let r = 0;
|
|
1251
1263
|
for (;;) {
|
|
1252
|
-
let t = await e.delete(
|
|
1253
|
-
if (r += t.length, t.length <
|
|
1264
|
+
let t = await e.delete(Ve).where(y`rowid IN (SELECT rowid FROM ${Ve} WHERE ${Ve.created_at_ts} < ${n} LIMIT ${xt})`).returning({ id: Ve.id });
|
|
1265
|
+
if (r += t.length, t.length < xt) break;
|
|
1254
1266
|
}
|
|
1255
1267
|
return r;
|
|
1256
1268
|
}
|
|
@@ -1258,12 +1270,12 @@ function yt(e) {
|
|
|
1258
1270
|
}
|
|
1259
1271
|
//#endregion
|
|
1260
1272
|
//#region src/adapters/atomic.ts
|
|
1261
|
-
function
|
|
1273
|
+
function Ct(e) {
|
|
1262
1274
|
let t = e;
|
|
1263
1275
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1264
1276
|
}
|
|
1265
|
-
async function
|
|
1266
|
-
if (
|
|
1277
|
+
async function wt(e, t) {
|
|
1278
|
+
if (Ct(e)) return e.batch(t);
|
|
1267
1279
|
await e.run(y`BEGIN`);
|
|
1268
1280
|
try {
|
|
1269
1281
|
let n = [];
|
|
@@ -1280,7 +1292,7 @@ async function xt(e, t) {
|
|
|
1280
1292
|
}
|
|
1281
1293
|
//#endregion
|
|
1282
1294
|
//#region src/adapters/actionVersions.ts
|
|
1283
|
-
function
|
|
1295
|
+
function Tt(e) {
|
|
1284
1296
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1285
1297
|
return {
|
|
1286
1298
|
...c,
|
|
@@ -1293,7 +1305,7 @@ function St(e) {
|
|
|
1293
1305
|
updated_at: new Date(Number(n)).toISOString()
|
|
1294
1306
|
};
|
|
1295
1307
|
}
|
|
1296
|
-
function
|
|
1308
|
+
function Et(e) {
|
|
1297
1309
|
return {
|
|
1298
1310
|
async create(n, r) {
|
|
1299
1311
|
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: k.number }).from(k).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id))).orderBy(i(k.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(k).values({
|
|
@@ -1310,7 +1322,7 @@ function Ct(e) {
|
|
|
1310
1322
|
created_at_ts: o,
|
|
1311
1323
|
updated_at_ts: o
|
|
1312
1324
|
});
|
|
1313
|
-
return await
|
|
1325
|
+
return await wt(e, c ? [e.update(k).set({
|
|
1314
1326
|
deployed: 0,
|
|
1315
1327
|
updated_at_ts: o
|
|
1316
1328
|
}).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id), a(k.deployed, 1))), u] : [u]), {
|
|
@@ -1330,10 +1342,10 @@ function Ct(e) {
|
|
|
1330
1342
|
},
|
|
1331
1343
|
async get(n, r, i) {
|
|
1332
1344
|
let o = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.action_id, r), a(k.id, i))).get();
|
|
1333
|
-
return o ?
|
|
1345
|
+
return o ? Tt(o) : null;
|
|
1334
1346
|
},
|
|
1335
1347
|
async list(n, o, s = {}) {
|
|
1336
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(
|
|
1348
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(Tt);
|
|
1337
1349
|
if (!u) return {
|
|
1338
1350
|
versions: f,
|
|
1339
1351
|
start: 0,
|
|
@@ -1355,13 +1367,13 @@ function Ct(e) {
|
|
|
1355
1367
|
}
|
|
1356
1368
|
//#endregion
|
|
1357
1369
|
//#region src/adapters/branding.ts
|
|
1358
|
-
function
|
|
1370
|
+
function Dt(e) {
|
|
1359
1371
|
return e === "dark" || e === "light" || e === "auto";
|
|
1360
1372
|
}
|
|
1361
|
-
function
|
|
1373
|
+
function Ot(e) {
|
|
1362
1374
|
return {
|
|
1363
1375
|
async get(t) {
|
|
1364
|
-
let n = await e.select().from(
|
|
1376
|
+
let n = await e.select().from(Xe).where(a(Xe.tenant_id, t)).get();
|
|
1365
1377
|
if (!n) return null;
|
|
1366
1378
|
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;
|
|
1367
1379
|
return D({
|
|
@@ -1376,7 +1388,7 @@ function Tt(e) {
|
|
|
1376
1388
|
}
|
|
1377
1389
|
},
|
|
1378
1390
|
font: u ? { url: u } : void 0,
|
|
1379
|
-
dark_mode:
|
|
1391
|
+
dark_mode: Dt(d) ? d : void 0
|
|
1380
1392
|
});
|
|
1381
1393
|
},
|
|
1382
1394
|
async set(t, n) {
|
|
@@ -1390,11 +1402,11 @@ function Tt(e) {
|
|
|
1390
1402
|
font_url: i?.url,
|
|
1391
1403
|
dark_mode: a
|
|
1392
1404
|
};
|
|
1393
|
-
await e.insert(
|
|
1405
|
+
await e.insert(Xe).values({
|
|
1394
1406
|
tenant_id: t,
|
|
1395
1407
|
...l
|
|
1396
1408
|
}).onConflictDoUpdate({
|
|
1397
|
-
target:
|
|
1409
|
+
target: Xe.tenant_id,
|
|
1398
1410
|
set: l
|
|
1399
1411
|
});
|
|
1400
1412
|
}
|
|
@@ -1402,30 +1414,30 @@ function Tt(e) {
|
|
|
1402
1414
|
}
|
|
1403
1415
|
//#endregion
|
|
1404
1416
|
//#region src/helpers/paginate.ts
|
|
1405
|
-
function
|
|
1417
|
+
function kt(e) {
|
|
1406
1418
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1407
1419
|
}
|
|
1408
|
-
function
|
|
1420
|
+
function At(e) {
|
|
1409
1421
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1410
1422
|
return n >= 1 ? n : 50;
|
|
1411
1423
|
}
|
|
1412
|
-
function
|
|
1424
|
+
function jt(e) {
|
|
1413
1425
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1414
1426
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1415
1427
|
}
|
|
1416
|
-
function
|
|
1417
|
-
let n = e?.from ?
|
|
1428
|
+
function Mt(e, t) {
|
|
1429
|
+
let n = e?.from ? ge(e.from) : null;
|
|
1418
1430
|
if (!n) return;
|
|
1419
|
-
if (n.k !== t.sortKey) throw new
|
|
1431
|
+
if (n.k !== t.sortKey) throw new Le(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
1420
1432
|
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1421
1433
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1422
1434
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1423
1435
|
}
|
|
1424
|
-
function
|
|
1436
|
+
function Nt(e, t, n, r = "id", i) {
|
|
1425
1437
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1426
1438
|
if (a && c) {
|
|
1427
1439
|
let e = c[n];
|
|
1428
|
-
s =
|
|
1440
|
+
s = _e({
|
|
1429
1441
|
s: typeof e == "string" || typeof e == "number" || e === null ? e : String(e),
|
|
1430
1442
|
i: String(c[r]),
|
|
1431
1443
|
...i !== void 0 && { k: i }
|
|
@@ -1438,7 +1450,7 @@ function At(e, t, n, r = "id", i) {
|
|
|
1438
1450
|
}
|
|
1439
1451
|
//#endregion
|
|
1440
1452
|
//#region src/adapters/clients.ts
|
|
1441
|
-
var
|
|
1453
|
+
var Pt = [
|
|
1442
1454
|
"global",
|
|
1443
1455
|
"is_first_party",
|
|
1444
1456
|
"oidc_conformant",
|
|
@@ -1450,7 +1462,7 @@ var jt = [
|
|
|
1450
1462
|
"require_pushed_authorization_requests",
|
|
1451
1463
|
"require_proof_of_possession",
|
|
1452
1464
|
"hide_sign_up_disabled_error"
|
|
1453
|
-
],
|
|
1465
|
+
], Ft = [
|
|
1454
1466
|
"callbacks",
|
|
1455
1467
|
"allowed_origins",
|
|
1456
1468
|
"web_origins",
|
|
@@ -1459,7 +1471,7 @@ var jt = [
|
|
|
1459
1471
|
"allowed_logout_urls",
|
|
1460
1472
|
"grant_types",
|
|
1461
1473
|
"signing_keys"
|
|
1462
|
-
],
|
|
1474
|
+
], It = [
|
|
1463
1475
|
"session_transfer",
|
|
1464
1476
|
"oidc_logout",
|
|
1465
1477
|
"jwt_configuration",
|
|
@@ -1473,23 +1485,24 @@ var jt = [
|
|
|
1473
1485
|
"client_authentication_methods",
|
|
1474
1486
|
"signed_request_object",
|
|
1475
1487
|
"token_quota",
|
|
1476
|
-
"registration_metadata"
|
|
1488
|
+
"registration_metadata",
|
|
1489
|
+
"token_exchange"
|
|
1477
1490
|
];
|
|
1478
|
-
function
|
|
1491
|
+
function Lt(e) {
|
|
1479
1492
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1480
|
-
for (let e of
|
|
1481
|
-
for (let e of
|
|
1482
|
-
for (let e of
|
|
1493
|
+
for (let e of Pt) i[e] = !!r[e];
|
|
1494
|
+
for (let e of Ft) i[e] = Z(r[e], []);
|
|
1495
|
+
for (let e of It) i[e] = Z(r[e], {});
|
|
1483
1496
|
return i.connections = Z(n, []), D(i);
|
|
1484
1497
|
}
|
|
1485
|
-
function
|
|
1498
|
+
function Rt(e) {
|
|
1486
1499
|
let t = { ...e };
|
|
1487
|
-
ie(e,
|
|
1488
|
-
for (let n of
|
|
1489
|
-
for (let n of
|
|
1500
|
+
ie(e, Pt, t);
|
|
1501
|
+
for (let n of Ft) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1502
|
+
for (let n of It) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1490
1503
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
|
|
1491
1504
|
}
|
|
1492
|
-
function
|
|
1505
|
+
function zt(e) {
|
|
1493
1506
|
return {
|
|
1494
1507
|
async create(t, n) {
|
|
1495
1508
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1513,51 +1526,51 @@ function It(e) {
|
|
|
1513
1526
|
created_at: r,
|
|
1514
1527
|
updated_at: r
|
|
1515
1528
|
};
|
|
1516
|
-
for (let e of
|
|
1529
|
+
for (let e of Pt) i[e] = n[e] ?? !1;
|
|
1517
1530
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1518
|
-
for (let e of
|
|
1519
|
-
for (let e of
|
|
1531
|
+
for (let e of Ft) i[e] = n[e] || [];
|
|
1532
|
+
for (let e of It) i[e] = n[e] || {};
|
|
1520
1533
|
i.connections = n.connections || [];
|
|
1521
|
-
let a =
|
|
1534
|
+
let a = Rt(i);
|
|
1522
1535
|
try {
|
|
1523
1536
|
await e.insert(I).values({
|
|
1524
1537
|
...a,
|
|
1525
1538
|
tenant_id: t
|
|
1526
1539
|
});
|
|
1527
1540
|
} catch (e) {
|
|
1528
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1541
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Client already exists" }) : e;
|
|
1529
1542
|
}
|
|
1530
|
-
return
|
|
1543
|
+
return Lt({
|
|
1531
1544
|
...a,
|
|
1532
1545
|
tenant_id: t
|
|
1533
1546
|
});
|
|
1534
1547
|
},
|
|
1535
1548
|
async get(n, r) {
|
|
1536
1549
|
let i = await e.select().from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1537
|
-
return i ?
|
|
1550
|
+
return i ? Lt(i) : null;
|
|
1538
1551
|
},
|
|
1539
1552
|
async getByClientId(t) {
|
|
1540
1553
|
let n = await e.select().from(I).where(a(I.client_id, t)).get();
|
|
1541
1554
|
return n ? {
|
|
1542
|
-
...
|
|
1555
|
+
...Lt(n),
|
|
1543
1556
|
tenant_id: n.tenant_id
|
|
1544
1557
|
} : null;
|
|
1545
1558
|
},
|
|
1546
1559
|
async update(n, r, i) {
|
|
1547
|
-
let o =
|
|
1560
|
+
let o = Rt({
|
|
1548
1561
|
...i,
|
|
1549
1562
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1550
1563
|
});
|
|
1551
1564
|
return delete o.client_id, delete o.tenant_id, await e.update(I).set(o).where(t(a(I.tenant_id, n), a(I.client_id, r))), !0;
|
|
1552
1565
|
},
|
|
1553
1566
|
async list(o, s) {
|
|
1554
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1555
|
-
if (
|
|
1567
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
|
|
1568
|
+
if (kt(s)) {
|
|
1556
1569
|
let n = {
|
|
1557
1570
|
sortColumn: I.created_at,
|
|
1558
1571
|
idColumn: I.client_id,
|
|
1559
1572
|
sortOrder: "desc"
|
|
1560
|
-
}, r =
|
|
1573
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...jt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Lt);
|
|
1561
1574
|
return {
|
|
1562
1575
|
clients: c,
|
|
1563
1576
|
totals: {
|
|
@@ -1573,7 +1586,7 @@ function It(e) {
|
|
|
1573
1586
|
let e = I[d.sort_by];
|
|
1574
1587
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1575
1588
|
}
|
|
1576
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1589
|
+
let g = (await h.offset(c * l).limit(l)).map(Lt);
|
|
1577
1590
|
if (!u) return { clients: g };
|
|
1578
1591
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1579
1592
|
return {
|
|
@@ -1593,7 +1606,7 @@ function It(e) {
|
|
|
1593
1606
|
}
|
|
1594
1607
|
//#endregion
|
|
1595
1608
|
//#region src/adapters/clientConnections.ts
|
|
1596
|
-
function
|
|
1609
|
+
function Bt(e) {
|
|
1597
1610
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1598
1611
|
return D({
|
|
1599
1612
|
...a,
|
|
@@ -1602,14 +1615,14 @@ function Lt(e) {
|
|
|
1602
1615
|
is_system: n ? !0 : void 0
|
|
1603
1616
|
});
|
|
1604
1617
|
}
|
|
1605
|
-
function
|
|
1618
|
+
function Vt(e) {
|
|
1606
1619
|
return {
|
|
1607
1620
|
async listByClient(n, r) {
|
|
1608
1621
|
let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1609
1622
|
if (!i) return [];
|
|
1610
1623
|
let o = Z(i.connections, []) || [];
|
|
1611
1624
|
if (o.length === 0) return [];
|
|
1612
|
-
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(
|
|
1625
|
+
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(Bt);
|
|
1613
1626
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1614
1627
|
},
|
|
1615
1628
|
async updateByClient(n, r, i) {
|
|
@@ -1646,7 +1659,7 @@ function Rt(e) {
|
|
|
1646
1659
|
}
|
|
1647
1660
|
//#endregion
|
|
1648
1661
|
//#region src/adapters/clientGrants.ts
|
|
1649
|
-
function
|
|
1662
|
+
function Ht(e) {
|
|
1650
1663
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1651
1664
|
return D({
|
|
1652
1665
|
...o,
|
|
@@ -1656,7 +1669,7 @@ function zt(e) {
|
|
|
1656
1669
|
is_system: !!a
|
|
1657
1670
|
});
|
|
1658
1671
|
}
|
|
1659
|
-
function
|
|
1672
|
+
function Ut(e) {
|
|
1660
1673
|
return {
|
|
1661
1674
|
async create(t, n) {
|
|
1662
1675
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1673,14 +1686,14 @@ function Bt(e) {
|
|
|
1673
1686
|
created_at: r,
|
|
1674
1687
|
updated_at: r
|
|
1675
1688
|
};
|
|
1676
|
-
return await e.insert(R).values(i),
|
|
1689
|
+
return await e.insert(R).values(i), Ht({
|
|
1677
1690
|
...i,
|
|
1678
1691
|
tenant_id: t
|
|
1679
1692
|
});
|
|
1680
1693
|
},
|
|
1681
1694
|
async get(n, r) {
|
|
1682
1695
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1683
|
-
return i ?
|
|
1696
|
+
return i ? Ht(i) : null;
|
|
1684
1697
|
},
|
|
1685
1698
|
async update(n, r, i) {
|
|
1686
1699
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1690,13 +1703,13 @@ function Bt(e) {
|
|
|
1690
1703
|
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(R).set(d).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
1691
1704
|
},
|
|
1692
1705
|
async list(o, s) {
|
|
1693
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1694
|
-
if (
|
|
1706
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(R, f, ["client_id", "audience"]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
|
|
1707
|
+
if (kt(s)) {
|
|
1695
1708
|
let n = {
|
|
1696
1709
|
sortColumn: R.created_at,
|
|
1697
1710
|
idColumn: R.id,
|
|
1698
1711
|
sortOrder: "desc"
|
|
1699
|
-
}, r =
|
|
1712
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(R).where(r ? t(m, r) : m).orderBy(...jt(n)).limit(i + 1), i, "created_at"), c = a.map(Ht);
|
|
1700
1713
|
return {
|
|
1701
1714
|
client_grants: c,
|
|
1702
1715
|
start: 0,
|
|
@@ -1710,7 +1723,7 @@ function Bt(e) {
|
|
|
1710
1723
|
let e = R[d.sort_by];
|
|
1711
1724
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1712
1725
|
} else h = h.orderBy(i(R.created_at), i(R.id));
|
|
1713
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1726
|
+
let g = (await h.offset(c * l).limit(l)).map(Ht);
|
|
1714
1727
|
if (!u) return { client_grants: g };
|
|
1715
1728
|
let [_] = await e.select({ count: r() }).from(R).where(m);
|
|
1716
1729
|
return {
|
|
@@ -1727,36 +1740,36 @@ function Bt(e) {
|
|
|
1727
1740
|
}
|
|
1728
1741
|
//#endregion
|
|
1729
1742
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1730
|
-
function
|
|
1743
|
+
function Wt(e) {
|
|
1731
1744
|
if (!e) return;
|
|
1732
1745
|
let t = JSON.parse(e);
|
|
1733
|
-
return
|
|
1746
|
+
return be(t) ? t : void 0;
|
|
1734
1747
|
}
|
|
1735
|
-
function
|
|
1748
|
+
function Gt(e) {
|
|
1736
1749
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1737
1750
|
}
|
|
1738
|
-
function
|
|
1751
|
+
function Kt(e) {
|
|
1739
1752
|
if (!e) return null;
|
|
1740
1753
|
let t = new Date(e);
|
|
1741
1754
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1742
1755
|
}
|
|
1743
|
-
function
|
|
1744
|
-
let t =
|
|
1756
|
+
function qt(e) {
|
|
1757
|
+
let t = he.parse(e.type);
|
|
1745
1758
|
return {
|
|
1746
1759
|
id: e.id,
|
|
1747
1760
|
token_hash: e.token_hash,
|
|
1748
1761
|
type: t,
|
|
1749
1762
|
client_id: e.client_id ?? void 0,
|
|
1750
1763
|
sub: e.sub ?? void 0,
|
|
1751
|
-
constraints:
|
|
1764
|
+
constraints: Wt(e.constraints),
|
|
1752
1765
|
single_use: !!e.single_use,
|
|
1753
|
-
expires_at:
|
|
1754
|
-
used_at:
|
|
1755
|
-
revoked_at:
|
|
1766
|
+
expires_at: Gt(e.expires_at_ts),
|
|
1767
|
+
used_at: Gt(e.used_at_ts),
|
|
1768
|
+
revoked_at: Gt(e.revoked_at_ts),
|
|
1756
1769
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1757
1770
|
};
|
|
1758
1771
|
}
|
|
1759
|
-
function
|
|
1772
|
+
function Jt(e) {
|
|
1760
1773
|
return {
|
|
1761
1774
|
async create(t, n) {
|
|
1762
1775
|
let r = Date.now();
|
|
@@ -1769,7 +1782,7 @@ function Gt(e) {
|
|
|
1769
1782
|
sub: n.sub ?? null,
|
|
1770
1783
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1771
1784
|
single_use: +!!n.single_use,
|
|
1772
|
-
expires_at_ts:
|
|
1785
|
+
expires_at_ts: Kt(n.expires_at),
|
|
1773
1786
|
created_at_ts: r
|
|
1774
1787
|
}), {
|
|
1775
1788
|
id: n.id,
|
|
@@ -1785,23 +1798,23 @@ function Gt(e) {
|
|
|
1785
1798
|
},
|
|
1786
1799
|
async get(n, r) {
|
|
1787
1800
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.id, r))).get();
|
|
1788
|
-
return i ?
|
|
1801
|
+
return i ? qt(i) : null;
|
|
1789
1802
|
},
|
|
1790
1803
|
async getByHash(n, r) {
|
|
1791
1804
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.token_hash, r))).get();
|
|
1792
|
-
return i ?
|
|
1805
|
+
return i ? qt(i) : null;
|
|
1793
1806
|
},
|
|
1794
1807
|
async listByClient(n, r) {
|
|
1795
|
-
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(
|
|
1808
|
+
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(qt);
|
|
1796
1809
|
},
|
|
1797
1810
|
async markUsed(n, r, i) {
|
|
1798
|
-
return (await e.update(L).set({ used_at_ts:
|
|
1811
|
+
return (await e.update(L).set({ used_at_ts: Kt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
|
|
1799
1812
|
},
|
|
1800
1813
|
async revoke(n, r, i) {
|
|
1801
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1814
|
+
return (await e.update(L).set({ revoked_at_ts: Kt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
|
|
1802
1815
|
},
|
|
1803
1816
|
async revokeByClient(n, r, i) {
|
|
1804
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1817
|
+
return (await e.update(L).set({ revoked_at_ts: Kt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
|
|
1805
1818
|
},
|
|
1806
1819
|
async remove(n, r) {
|
|
1807
1820
|
return (await e.delete(L).where(t(a(L.tenant_id, n), a(L.id, r))).returning()).length > 0;
|
|
@@ -1810,12 +1823,12 @@ function Gt(e) {
|
|
|
1810
1823
|
}
|
|
1811
1824
|
//#endregion
|
|
1812
1825
|
//#region src/adapters/codes.ts
|
|
1813
|
-
var
|
|
1814
|
-
function
|
|
1826
|
+
var Yt = ["code_id", "login_id"], Xt = 500;
|
|
1827
|
+
function Zt(e) {
|
|
1815
1828
|
let { tenant_id: t, ...n } = e;
|
|
1816
1829
|
return D(n);
|
|
1817
1830
|
}
|
|
1818
|
-
function
|
|
1831
|
+
function Qt(e) {
|
|
1819
1832
|
return {
|
|
1820
1833
|
async create(t, n) {
|
|
1821
1834
|
let r = {
|
|
@@ -1824,18 +1837,18 @@ function Yt(e) {
|
|
|
1824
1837
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1825
1838
|
expires_at: n.expires_at
|
|
1826
1839
|
};
|
|
1827
|
-
return await e.insert(F).values(r),
|
|
1840
|
+
return await e.insert(F).values(r), Zt(r);
|
|
1828
1841
|
},
|
|
1829
1842
|
async get(n, r, i) {
|
|
1830
1843
|
let o = n ? t(a(F.tenant_id, n), a(F.code_id, r), a(F.code_type, i)) : t(a(F.code_id, r), a(F.code_type, i)), s = await e.select().from(F).where(o).get();
|
|
1831
|
-
return s ?
|
|
1844
|
+
return s ? Zt(s) : null;
|
|
1832
1845
|
},
|
|
1833
1846
|
async list(o, s) {
|
|
1834
1847
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(F.tenant_id, o)];
|
|
1835
1848
|
if (f) {
|
|
1836
|
-
let e =
|
|
1849
|
+
let e = Te(f, Yt);
|
|
1837
1850
|
if (e) {
|
|
1838
|
-
let t =
|
|
1851
|
+
let t = _t(F, e, Yt);
|
|
1839
1852
|
t && p.push(t);
|
|
1840
1853
|
}
|
|
1841
1854
|
}
|
|
@@ -1844,7 +1857,7 @@ function Yt(e) {
|
|
|
1844
1857
|
let e = F[d.sort_by];
|
|
1845
1858
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1846
1859
|
}
|
|
1847
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1860
|
+
let g = (await h.offset(c * l).limit(l)).map(Zt);
|
|
1848
1861
|
if (!u) return { codes: g };
|
|
1849
1862
|
let [_] = await e.select({ count: r() }).from(F).where(m);
|
|
1850
1863
|
return {
|
|
@@ -1866,8 +1879,8 @@ function Yt(e) {
|
|
|
1866
1879
|
async cleanup(t) {
|
|
1867
1880
|
let n = 0;
|
|
1868
1881
|
for (;;) {
|
|
1869
|
-
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${
|
|
1870
|
-
if (n += r.length, r.length <
|
|
1882
|
+
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${Xt})`).returning({ code_id: F.code_id });
|
|
1883
|
+
if (n += r.length, r.length < Xt) break;
|
|
1871
1884
|
}
|
|
1872
1885
|
return n;
|
|
1873
1886
|
}
|
|
@@ -1875,10 +1888,10 @@ function Yt(e) {
|
|
|
1875
1888
|
}
|
|
1876
1889
|
//#endregion
|
|
1877
1890
|
//#region src/adapters/connections.ts
|
|
1878
|
-
function
|
|
1891
|
+
function $t() {
|
|
1879
1892
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1880
1893
|
}
|
|
1881
|
-
function
|
|
1894
|
+
function en(e) {
|
|
1882
1895
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1883
1896
|
return D({
|
|
1884
1897
|
...a,
|
|
@@ -1887,11 +1900,11 @@ function Zt(e) {
|
|
|
1887
1900
|
is_system: n ? !0 : void 0
|
|
1888
1901
|
});
|
|
1889
1902
|
}
|
|
1890
|
-
function
|
|
1903
|
+
function tn(e) {
|
|
1891
1904
|
return {
|
|
1892
1905
|
async create(t, n) {
|
|
1893
1906
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1894
|
-
id: n.id ||
|
|
1907
|
+
id: n.id || $t(),
|
|
1895
1908
|
...n,
|
|
1896
1909
|
tenant_id: t,
|
|
1897
1910
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1903,13 +1916,13 @@ function Qt(e) {
|
|
|
1903
1916
|
try {
|
|
1904
1917
|
await e.insert(B).values(i);
|
|
1905
1918
|
} catch (e) {
|
|
1906
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1919
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Connection already exists" }) : e;
|
|
1907
1920
|
}
|
|
1908
|
-
return
|
|
1921
|
+
return en(i);
|
|
1909
1922
|
},
|
|
1910
1923
|
async get(n, r) {
|
|
1911
1924
|
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
1912
|
-
return i ?
|
|
1925
|
+
return i ? en(i) : null;
|
|
1913
1926
|
},
|
|
1914
1927
|
async update(n, r, i) {
|
|
1915
1928
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1918,15 +1931,15 @@ function Qt(e) {
|
|
|
1918
1931
|
async list(o, s) {
|
|
1919
1932
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(B.tenant_id, o);
|
|
1920
1933
|
if (f) {
|
|
1921
|
-
let e =
|
|
1934
|
+
let e = _t(B, f, ["name"]);
|
|
1922
1935
|
e && (p = t(p, e));
|
|
1923
1936
|
}
|
|
1924
|
-
if (
|
|
1937
|
+
if (kt(s)) {
|
|
1925
1938
|
let n = {
|
|
1926
1939
|
sortColumn: B.created_at,
|
|
1927
1940
|
idColumn: B.id,
|
|
1928
1941
|
sortOrder: "desc"
|
|
1929
|
-
}, r =
|
|
1942
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...jt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(en);
|
|
1930
1943
|
return {
|
|
1931
1944
|
connections: c,
|
|
1932
1945
|
start: 0,
|
|
@@ -1940,7 +1953,7 @@ function Qt(e) {
|
|
|
1940
1953
|
let e = B[d.sort_by];
|
|
1941
1954
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1942
1955
|
}
|
|
1943
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1956
|
+
let h = (await m.offset(c * l).limit(l)).map(en);
|
|
1944
1957
|
if (!u) return { connections: h };
|
|
1945
1958
|
let [g] = await e.select({ count: r() }).from(B).where(p);
|
|
1946
1959
|
return {
|
|
@@ -1957,7 +1970,7 @@ function Qt(e) {
|
|
|
1957
1970
|
}
|
|
1958
1971
|
//#endregion
|
|
1959
1972
|
//#region src/adapters/customDomains.ts
|
|
1960
|
-
function
|
|
1973
|
+
function nn(e) {
|
|
1961
1974
|
let { tenant_id: t, domain_metadata: n, verification: r, ...i } = e;
|
|
1962
1975
|
return D({
|
|
1963
1976
|
...i,
|
|
@@ -1966,7 +1979,7 @@ function $t(e) {
|
|
|
1966
1979
|
verification: Z(r)
|
|
1967
1980
|
});
|
|
1968
1981
|
}
|
|
1969
|
-
function
|
|
1982
|
+
function rn(e) {
|
|
1970
1983
|
return {
|
|
1971
1984
|
async create(t, n) {
|
|
1972
1985
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1984,24 +1997,24 @@ function en(e) {
|
|
|
1984
1997
|
created_at: r,
|
|
1985
1998
|
updated_at: r
|
|
1986
1999
|
};
|
|
1987
|
-
return await e.insert(V).values(i),
|
|
2000
|
+
return await e.insert(V).values(i), nn({
|
|
1988
2001
|
...i,
|
|
1989
2002
|
tenant_id: t
|
|
1990
2003
|
});
|
|
1991
2004
|
},
|
|
1992
2005
|
async get(n, r) {
|
|
1993
2006
|
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).get();
|
|
1994
|
-
return i ?
|
|
2007
|
+
return i ? nn(i) : null;
|
|
1995
2008
|
},
|
|
1996
2009
|
async getByDomain(t) {
|
|
1997
2010
|
let n = await e.select().from(V).where(a(V.domain, t)).get();
|
|
1998
2011
|
return n ? {
|
|
1999
|
-
|
|
2012
|
+
...nn(n),
|
|
2000
2013
|
tenant_id: n.tenant_id
|
|
2001
2014
|
} : null;
|
|
2002
2015
|
},
|
|
2003
2016
|
async list(t) {
|
|
2004
|
-
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map(
|
|
2017
|
+
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map(nn);
|
|
2005
2018
|
},
|
|
2006
2019
|
async update(n, r, i) {
|
|
2007
2020
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2014,10 +2027,10 @@ function en(e) {
|
|
|
2014
2027
|
}
|
|
2015
2028
|
//#endregion
|
|
2016
2029
|
//#region src/adapters/customText.ts
|
|
2017
|
-
function
|
|
2030
|
+
function an(e) {
|
|
2018
2031
|
return {
|
|
2019
2032
|
async get(n, r, i) {
|
|
2020
|
-
let o = await e.select().from(
|
|
2033
|
+
let o = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.prompt, r), a(st.language, i))).get();
|
|
2021
2034
|
if (!o) return null;
|
|
2022
2035
|
try {
|
|
2023
2036
|
return JSON.parse(o.custom_text);
|
|
@@ -2027,7 +2040,7 @@ function tn(e) {
|
|
|
2027
2040
|
},
|
|
2028
2041
|
async set(t, n, r, i) {
|
|
2029
2042
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2030
|
-
await e.insert(
|
|
2043
|
+
await e.insert(st).values({
|
|
2031
2044
|
tenant_id: t,
|
|
2032
2045
|
prompt: n,
|
|
2033
2046
|
language: r,
|
|
@@ -2036,9 +2049,9 @@ function tn(e) {
|
|
|
2036
2049
|
updated_at_ts: a
|
|
2037
2050
|
}).onConflictDoUpdate({
|
|
2038
2051
|
target: [
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2052
|
+
st.tenant_id,
|
|
2053
|
+
st.prompt,
|
|
2054
|
+
st.language
|
|
2042
2055
|
],
|
|
2043
2056
|
set: {
|
|
2044
2057
|
custom_text: o,
|
|
@@ -2047,23 +2060,23 @@ function tn(e) {
|
|
|
2047
2060
|
});
|
|
2048
2061
|
},
|
|
2049
2062
|
async delete(n, r, i) {
|
|
2050
|
-
await e.delete(
|
|
2063
|
+
await e.delete(st).where(t(a(st.tenant_id, n), a(st.prompt, r), a(st.language, i)));
|
|
2051
2064
|
},
|
|
2052
2065
|
async list(t) {
|
|
2053
2066
|
return await e.select({
|
|
2054
|
-
prompt:
|
|
2055
|
-
language:
|
|
2056
|
-
}).from(
|
|
2067
|
+
prompt: st.prompt,
|
|
2068
|
+
language: st.language
|
|
2069
|
+
}).from(st).where(a(st.tenant_id, t)).all();
|
|
2057
2070
|
}
|
|
2058
2071
|
};
|
|
2059
2072
|
}
|
|
2060
2073
|
//#endregion
|
|
2061
2074
|
//#region src/adapters/emailProviders.ts
|
|
2062
|
-
function
|
|
2075
|
+
function on(e) {
|
|
2063
2076
|
return {
|
|
2064
2077
|
async create(t, n) {
|
|
2065
2078
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2066
|
-
await e.insert(
|
|
2079
|
+
await e.insert(nt).values({
|
|
2067
2080
|
tenant_id: t,
|
|
2068
2081
|
name: n.name,
|
|
2069
2082
|
enabled: n.enabled,
|
|
@@ -2075,7 +2088,7 @@ function nn(e) {
|
|
|
2075
2088
|
});
|
|
2076
2089
|
},
|
|
2077
2090
|
async get(t) {
|
|
2078
|
-
let n = await e.select().from(
|
|
2091
|
+
let n = await e.select().from(nt).where(a(nt.tenant_id, t)).get();
|
|
2079
2092
|
if (!n) return null;
|
|
2080
2093
|
let { tenant_id: r, ...i } = n;
|
|
2081
2094
|
return D({
|
|
@@ -2087,16 +2100,16 @@ function nn(e) {
|
|
|
2087
2100
|
},
|
|
2088
2101
|
async update(t, n) {
|
|
2089
2102
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2090
|
-
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(
|
|
2103
|
+
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(nt).set(r).where(a(nt.tenant_id, t));
|
|
2091
2104
|
},
|
|
2092
2105
|
async remove(t) {
|
|
2093
|
-
await e.delete(
|
|
2106
|
+
await e.delete(nt).where(a(nt.tenant_id, t));
|
|
2094
2107
|
}
|
|
2095
2108
|
};
|
|
2096
2109
|
}
|
|
2097
2110
|
//#endregion
|
|
2098
2111
|
//#region src/adapters/emailTemplates.ts
|
|
2099
|
-
function
|
|
2112
|
+
function sn(e) {
|
|
2100
2113
|
return D({
|
|
2101
2114
|
template: e.template,
|
|
2102
2115
|
body: e.body,
|
|
@@ -2109,18 +2122,18 @@ function rn(e) {
|
|
|
2109
2122
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2110
2123
|
});
|
|
2111
2124
|
}
|
|
2112
|
-
function
|
|
2125
|
+
function cn(e) {
|
|
2113
2126
|
return {
|
|
2114
2127
|
async get(n, r) {
|
|
2115
|
-
let i = await e.select().from(
|
|
2116
|
-
return i ?
|
|
2128
|
+
let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.template, r))).get();
|
|
2129
|
+
return i ? sn(i) : null;
|
|
2117
2130
|
},
|
|
2118
2131
|
async list(t) {
|
|
2119
|
-
return (await e.select().from(
|
|
2132
|
+
return (await e.select().from(rt).where(a(rt.tenant_id, t)).all()).map(sn);
|
|
2120
2133
|
},
|
|
2121
2134
|
async create(t, n) {
|
|
2122
2135
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2123
|
-
return await e.insert(
|
|
2136
|
+
return await e.insert(rt).values({
|
|
2124
2137
|
tenant_id: t,
|
|
2125
2138
|
template: n.template,
|
|
2126
2139
|
body: n.body,
|
|
@@ -2138,23 +2151,23 @@ function an(e) {
|
|
|
2138
2151
|
async update(n, r, i) {
|
|
2139
2152
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2140
2153
|
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);
|
|
2141
|
-
let s = await e.update(
|
|
2154
|
+
let s = await e.update(rt).set(o).where(t(a(rt.tenant_id, n), a(rt.template, r))).run();
|
|
2142
2155
|
return Number(s.changes ?? 0) > 0;
|
|
2143
2156
|
},
|
|
2144
2157
|
async remove(n, r) {
|
|
2145
|
-
let i = await e.delete(
|
|
2158
|
+
let i = await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.template, r))).run();
|
|
2146
2159
|
return Number(i.changes ?? 0) > 0;
|
|
2147
2160
|
}
|
|
2148
2161
|
};
|
|
2149
2162
|
}
|
|
2150
2163
|
//#endregion
|
|
2151
2164
|
//#region src/adapters/flows.ts
|
|
2152
|
-
var
|
|
2153
|
-
function
|
|
2165
|
+
var ln = ["id", "name"];
|
|
2166
|
+
function un(e) {
|
|
2154
2167
|
return {
|
|
2155
2168
|
async create(t, n) {
|
|
2156
2169
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2157
|
-
return await e.insert(
|
|
2170
|
+
return await e.insert(et).values({
|
|
2158
2171
|
id: i,
|
|
2159
2172
|
tenant_id: t,
|
|
2160
2173
|
name: n.name,
|
|
@@ -2170,7 +2183,7 @@ function sn(e) {
|
|
|
2170
2183
|
};
|
|
2171
2184
|
},
|
|
2172
2185
|
async get(n, r) {
|
|
2173
|
-
let i = await e.select().from(
|
|
2186
|
+
let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.id, r))).get();
|
|
2174
2187
|
if (!i) return null;
|
|
2175
2188
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2176
2189
|
return D({
|
|
@@ -2180,20 +2193,20 @@ function sn(e) {
|
|
|
2180
2193
|
},
|
|
2181
2194
|
async update(n, r, i) {
|
|
2182
2195
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2183
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2196
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(et).set(o).where(t(a(et.tenant_id, n), a(et.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2184
2197
|
},
|
|
2185
2198
|
async list(o, s) {
|
|
2186
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2199
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(et.tenant_id, o)];
|
|
2187
2200
|
if (f) {
|
|
2188
|
-
let e =
|
|
2201
|
+
let e = Te(f, ln);
|
|
2189
2202
|
if (e) {
|
|
2190
|
-
let t =
|
|
2203
|
+
let t = _t(et, e, []);
|
|
2191
2204
|
t && p.push(t);
|
|
2192
2205
|
}
|
|
2193
2206
|
}
|
|
2194
|
-
let m = t(...p), h = e.select().from(
|
|
2207
|
+
let m = t(...p), h = e.select().from(et).where(m).$dynamic();
|
|
2195
2208
|
if (d?.sort_by) {
|
|
2196
|
-
let e =
|
|
2209
|
+
let e = et[d.sort_by];
|
|
2197
2210
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2198
2211
|
}
|
|
2199
2212
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2204,7 +2217,7 @@ function sn(e) {
|
|
|
2204
2217
|
});
|
|
2205
2218
|
});
|
|
2206
2219
|
if (!u) return { flows: g };
|
|
2207
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2220
|
+
let [_] = await e.select({ count: r() }).from(et).where(m);
|
|
2208
2221
|
return {
|
|
2209
2222
|
flows: g,
|
|
2210
2223
|
start: c * l,
|
|
@@ -2213,18 +2226,18 @@ function sn(e) {
|
|
|
2213
2226
|
};
|
|
2214
2227
|
},
|
|
2215
2228
|
async remove(n, r) {
|
|
2216
|
-
return (await e.delete(
|
|
2229
|
+
return (await e.delete(et).where(t(a(et.tenant_id, n), a(et.id, r))).returning()).length > 0;
|
|
2217
2230
|
}
|
|
2218
2231
|
};
|
|
2219
2232
|
}
|
|
2220
2233
|
//#endregion
|
|
2221
2234
|
//#region src/adapters/forms.ts
|
|
2222
|
-
var
|
|
2235
|
+
var dn = [
|
|
2223
2236
|
"nodes",
|
|
2224
2237
|
"start",
|
|
2225
2238
|
"ending"
|
|
2226
|
-
],
|
|
2227
|
-
function
|
|
2239
|
+
], fn = ["name"];
|
|
2240
|
+
function pn(e) {
|
|
2228
2241
|
return {
|
|
2229
2242
|
async create(t, n) {
|
|
2230
2243
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2238,8 +2251,8 @@ function un(e) {
|
|
|
2238
2251
|
created_at: r,
|
|
2239
2252
|
updated_at: r
|
|
2240
2253
|
};
|
|
2241
|
-
for (let e of
|
|
2242
|
-
return await e.insert(
|
|
2254
|
+
for (let e of dn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2255
|
+
return await e.insert($e).values(a), {
|
|
2243
2256
|
id: i,
|
|
2244
2257
|
...n,
|
|
2245
2258
|
created_at: r,
|
|
@@ -2247,38 +2260,38 @@ function un(e) {
|
|
|
2247
2260
|
};
|
|
2248
2261
|
},
|
|
2249
2262
|
async get(n, r) {
|
|
2250
|
-
let i = await e.select().from(
|
|
2263
|
+
let i = await e.select().from($e).where(t(a($e.tenant_id, n), a($e.id, r))).get();
|
|
2251
2264
|
if (!i) return null;
|
|
2252
2265
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2253
|
-
for (let e of
|
|
2266
|
+
for (let e of dn) c[e] = Z(s[e]);
|
|
2254
2267
|
return D(c);
|
|
2255
2268
|
},
|
|
2256
2269
|
async update(n, r, i) {
|
|
2257
2270
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2258
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2259
|
-
return (await e.update(
|
|
2271
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (dn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2272
|
+
return (await e.update($e).set(o).where(t(a($e.tenant_id, n), a($e.id, r))).returning()).length > 0;
|
|
2260
2273
|
},
|
|
2261
2274
|
async list(o, s) {
|
|
2262
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2275
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a($e.tenant_id, o)];
|
|
2263
2276
|
if (f) {
|
|
2264
|
-
let e =
|
|
2277
|
+
let e = Te(f, fn);
|
|
2265
2278
|
if (e) {
|
|
2266
|
-
let t =
|
|
2279
|
+
let t = _t($e, e, fn);
|
|
2267
2280
|
t && p.push(t);
|
|
2268
2281
|
}
|
|
2269
2282
|
}
|
|
2270
|
-
let m = t(...p), h = e.select().from(
|
|
2283
|
+
let m = t(...p), h = e.select().from($e).where(m).$dynamic();
|
|
2271
2284
|
if (d?.sort_by) {
|
|
2272
|
-
let e =
|
|
2285
|
+
let e = $e[d.sort_by];
|
|
2273
2286
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2274
2287
|
}
|
|
2275
2288
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2276
2289
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2277
|
-
for (let e of
|
|
2290
|
+
for (let e of dn) r[e] = Z(n[e]);
|
|
2278
2291
|
return D(r);
|
|
2279
2292
|
});
|
|
2280
2293
|
if (!u) return { forms: g };
|
|
2281
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2294
|
+
let [_] = await e.select({ count: r() }).from($e).where(m);
|
|
2282
2295
|
return {
|
|
2283
2296
|
forms: g,
|
|
2284
2297
|
start: c * l,
|
|
@@ -2287,13 +2300,13 @@ function un(e) {
|
|
|
2287
2300
|
};
|
|
2288
2301
|
},
|
|
2289
2302
|
async remove(n, r) {
|
|
2290
|
-
return (await e.delete(
|
|
2303
|
+
return (await e.delete($e).where(t(a($e.tenant_id, n), a($e.id, r))).returning()).length > 0;
|
|
2291
2304
|
}
|
|
2292
2305
|
};
|
|
2293
2306
|
}
|
|
2294
2307
|
//#endregion
|
|
2295
2308
|
//#region src/adapters/grants.ts
|
|
2296
|
-
function
|
|
2309
|
+
function mn(e) {
|
|
2297
2310
|
return {
|
|
2298
2311
|
id: e.id,
|
|
2299
2312
|
user_id: e.user_id,
|
|
@@ -2302,17 +2315,17 @@ function dn(e) {
|
|
|
2302
2315
|
scope: Z(e.scope, []) ?? []
|
|
2303
2316
|
};
|
|
2304
2317
|
}
|
|
2305
|
-
var
|
|
2318
|
+
var hn = {
|
|
2306
2319
|
user_id: z.user_id,
|
|
2307
2320
|
client_id: z.client_id,
|
|
2308
2321
|
audience: z.audience,
|
|
2309
2322
|
created_at: z.created_at,
|
|
2310
2323
|
updated_at: z.updated_at
|
|
2311
2324
|
};
|
|
2312
|
-
function
|
|
2313
|
-
return Object.hasOwn(
|
|
2325
|
+
function gn(e) {
|
|
2326
|
+
return Object.hasOwn(hn, e) ? hn[e] : void 0;
|
|
2314
2327
|
}
|
|
2315
|
-
function
|
|
2328
|
+
function _n(e) {
|
|
2316
2329
|
return {
|
|
2317
2330
|
async create(n, r) {
|
|
2318
2331
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r.user_id), a(z.client_id, r.clientID), a(z.audience, s))).get();
|
|
@@ -2321,7 +2334,7 @@ function mn(e) {
|
|
|
2321
2334
|
return await e.update(z).set({
|
|
2322
2335
|
scope: JSON.stringify(s),
|
|
2323
2336
|
updated_at: i
|
|
2324
|
-
}).where(t(a(z.tenant_id, n), a(z.id, c.id))),
|
|
2337
|
+
}).where(t(a(z.tenant_id, n), a(z.id, c.id))), mn({
|
|
2325
2338
|
...c,
|
|
2326
2339
|
scope: JSON.stringify(s)
|
|
2327
2340
|
});
|
|
@@ -2346,16 +2359,16 @@ function mn(e) {
|
|
|
2346
2359
|
},
|
|
2347
2360
|
async get(n, r, i, o) {
|
|
2348
2361
|
let s = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r), a(z.client_id, i), a(z.audience, o ?? ""))).get();
|
|
2349
|
-
return s ?
|
|
2362
|
+
return s ? mn(s) : null;
|
|
2350
2363
|
},
|
|
2351
2364
|
async list(o, s) {
|
|
2352
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2365
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(z, f, [
|
|
2353
2366
|
"user_id",
|
|
2354
2367
|
"client_id",
|
|
2355
2368
|
"audience"
|
|
2356
|
-
]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ?
|
|
2369
|
+
]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ? gn(d.sort_by) : void 0;
|
|
2357
2370
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(z.created_at));
|
|
2358
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2371
|
+
let _ = (await h.offset(c * l).limit(l)).map(mn);
|
|
2359
2372
|
if (!u) return {
|
|
2360
2373
|
grants: _,
|
|
2361
2374
|
start: 0,
|
|
@@ -2380,11 +2393,11 @@ function mn(e) {
|
|
|
2380
2393
|
}
|
|
2381
2394
|
//#endregion
|
|
2382
2395
|
//#region src/adapters/hookCode.ts
|
|
2383
|
-
var
|
|
2384
|
-
function
|
|
2385
|
-
return `hc_${
|
|
2396
|
+
var vn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2397
|
+
function yn() {
|
|
2398
|
+
return `hc_${vn()}`;
|
|
2386
2399
|
}
|
|
2387
|
-
function
|
|
2400
|
+
function bn(e) {
|
|
2388
2401
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2389
2402
|
created_at_ts: t,
|
|
2390
2403
|
updated_at_ts: n
|
|
@@ -2395,41 +2408,41 @@ function _n(e) {
|
|
|
2395
2408
|
secrets: r ? JSON.parse(r) : void 0
|
|
2396
2409
|
};
|
|
2397
2410
|
}
|
|
2398
|
-
function
|
|
2411
|
+
function xn(e) {
|
|
2399
2412
|
return {
|
|
2400
2413
|
async create(t, n) {
|
|
2401
2414
|
let r = Date.now(), i = {
|
|
2402
|
-
id:
|
|
2415
|
+
id: yn(),
|
|
2403
2416
|
tenant_id: t,
|
|
2404
2417
|
code: n.code,
|
|
2405
2418
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2406
2419
|
created_at_ts: r,
|
|
2407
2420
|
updated_at_ts: r
|
|
2408
2421
|
};
|
|
2409
|
-
return await e.insert(
|
|
2422
|
+
return await e.insert(at).values(i), bn({
|
|
2410
2423
|
...i,
|
|
2411
2424
|
tenant_id: t
|
|
2412
2425
|
});
|
|
2413
2426
|
},
|
|
2414
2427
|
async get(n, r) {
|
|
2415
|
-
let i = await e.select().from(
|
|
2416
|
-
return i ?
|
|
2428
|
+
let i = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.id, r))).get();
|
|
2429
|
+
return i ? bn(i) : null;
|
|
2417
2430
|
},
|
|
2418
2431
|
async update(n, r, i) {
|
|
2419
2432
|
let o = { updated_at_ts: Date.now() };
|
|
2420
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2433
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(at).set(o).where(t(a(at.tenant_id, n), a(at.id, r))).returning()).length > 0;
|
|
2421
2434
|
},
|
|
2422
2435
|
async remove(n, r) {
|
|
2423
|
-
return (await e.delete(
|
|
2436
|
+
return (await e.delete(at).where(t(a(at.tenant_id, n), a(at.id, r))).returning()).length > 0;
|
|
2424
2437
|
}
|
|
2425
2438
|
};
|
|
2426
2439
|
}
|
|
2427
2440
|
//#endregion
|
|
2428
2441
|
//#region src/adapters/hooks.ts
|
|
2429
|
-
function
|
|
2442
|
+
function Sn() {
|
|
2430
2443
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2431
2444
|
}
|
|
2432
|
-
function
|
|
2445
|
+
function Cn(e) {
|
|
2433
2446
|
if (!(typeof e != "string" || !e)) try {
|
|
2434
2447
|
let t = JSON.parse(e);
|
|
2435
2448
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2437,7 +2450,7 @@ function bn(e) {
|
|
|
2437
2450
|
return;
|
|
2438
2451
|
}
|
|
2439
2452
|
}
|
|
2440
|
-
function
|
|
2453
|
+
function wn(e) {
|
|
2441
2454
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2442
2455
|
created_at_ts: n,
|
|
2443
2456
|
updated_at_ts: r
|
|
@@ -2446,15 +2459,15 @@ function xn(e) {
|
|
|
2446
2459
|
...a,
|
|
2447
2460
|
enabled: !!a.enabled,
|
|
2448
2461
|
synchronous: !!a.synchronous,
|
|
2449
|
-
metadata:
|
|
2462
|
+
metadata: Cn(i),
|
|
2450
2463
|
...o
|
|
2451
2464
|
});
|
|
2452
2465
|
}
|
|
2453
|
-
function
|
|
2466
|
+
function Tn(e) {
|
|
2454
2467
|
return {
|
|
2455
2468
|
async create(t, n) {
|
|
2456
2469
|
let r = Date.now(), i = {
|
|
2457
|
-
hook_id: n.hook_id ||
|
|
2470
|
+
hook_id: n.hook_id || Sn(),
|
|
2458
2471
|
tenant_id: t,
|
|
2459
2472
|
trigger_id: n.trigger_id,
|
|
2460
2473
|
url: n.url,
|
|
@@ -2470,30 +2483,30 @@ function Sn(e) {
|
|
|
2470
2483
|
created_at_ts: r,
|
|
2471
2484
|
updated_at_ts: r
|
|
2472
2485
|
};
|
|
2473
|
-
return await e.insert(
|
|
2486
|
+
return await e.insert(it).values(i), wn({
|
|
2474
2487
|
...i,
|
|
2475
2488
|
tenant_id: t
|
|
2476
2489
|
});
|
|
2477
2490
|
},
|
|
2478
2491
|
async get(n, r) {
|
|
2479
|
-
let i = await e.select().from(
|
|
2480
|
-
return i ?
|
|
2492
|
+
let i = await e.select().from(it).where(t(a(it.tenant_id, n), a(it.hook_id, r))).get();
|
|
2493
|
+
return i ? wn(i) : null;
|
|
2481
2494
|
},
|
|
2482
2495
|
async update(n, r, i) {
|
|
2483
2496
|
let o = { updated_at_ts: Date.now() };
|
|
2484
|
-
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(
|
|
2497
|
+
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(it).set(o).where(t(a(it.tenant_id, n), a(it.hook_id, r))).returning()).length > 0;
|
|
2485
2498
|
},
|
|
2486
2499
|
async list(o, s) {
|
|
2487
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2500
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(it, f, [
|
|
2488
2501
|
"url",
|
|
2489
2502
|
"form_id",
|
|
2490
2503
|
"template_id",
|
|
2491
2504
|
"code_id"
|
|
2492
|
-
]) : void 0, m = p ? t(a(
|
|
2493
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2494
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2505
|
+
]) : void 0, m = p ? t(a(it.tenant_id, o), p) : a(it.tenant_id, o), h = e.select().from(it).where(m).$dynamic(), g = d?.sort_by ? it[d.sort_by] : void 0;
|
|
2506
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(it.priority), n(it.created_at_ts));
|
|
2507
|
+
let _ = (await h.offset(c * l).limit(l)).map(wn);
|
|
2495
2508
|
if (!u) return { hooks: _ };
|
|
2496
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2509
|
+
let [v] = await e.select({ count: r() }).from(it).where(m);
|
|
2497
2510
|
return {
|
|
2498
2511
|
hooks: _,
|
|
2499
2512
|
start: c * l,
|
|
@@ -2502,31 +2515,31 @@ function Sn(e) {
|
|
|
2502
2515
|
};
|
|
2503
2516
|
},
|
|
2504
2517
|
async remove(n, r) {
|
|
2505
|
-
return (await e.delete(
|
|
2518
|
+
return (await e.delete(it).where(t(a(it.tenant_id, n), a(it.hook_id, r))).returning()).length > 0;
|
|
2506
2519
|
}
|
|
2507
2520
|
};
|
|
2508
2521
|
}
|
|
2509
2522
|
//#endregion
|
|
2510
2523
|
//#region src/adapters/invites.ts
|
|
2511
|
-
function
|
|
2524
|
+
function En() {
|
|
2512
2525
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2513
2526
|
}
|
|
2514
|
-
var
|
|
2527
|
+
var Dn = [
|
|
2515
2528
|
"inviter",
|
|
2516
2529
|
"invitee",
|
|
2517
2530
|
"app_metadata",
|
|
2518
2531
|
"user_metadata",
|
|
2519
2532
|
"roles"
|
|
2520
2533
|
];
|
|
2521
|
-
function
|
|
2534
|
+
function On(e) {
|
|
2522
2535
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2523
|
-
for (let e of
|
|
2536
|
+
for (let e of Dn) i[e] = Z(r[e], e === "roles" ? [] : {});
|
|
2524
2537
|
return i.send_invitation_email = !!n, D(i);
|
|
2525
2538
|
}
|
|
2526
|
-
function
|
|
2539
|
+
function kn(e) {
|
|
2527
2540
|
return {
|
|
2528
2541
|
async create(t, n) {
|
|
2529
|
-
let r = n.id ||
|
|
2542
|
+
let r = n.id || En(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2530
2543
|
id: r,
|
|
2531
2544
|
tenant_id: t,
|
|
2532
2545
|
organization_id: n.organization_id,
|
|
@@ -2539,35 +2552,35 @@ function En(e) {
|
|
|
2539
2552
|
created_at: a.toISOString(),
|
|
2540
2553
|
expires_at: o
|
|
2541
2554
|
};
|
|
2542
|
-
for (let e of
|
|
2555
|
+
for (let e of Dn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2543
2556
|
try {
|
|
2544
|
-
await e.insert(
|
|
2557
|
+
await e.insert(qe).values(s);
|
|
2545
2558
|
} catch (e) {
|
|
2546
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
2559
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Invite already exists" }) : e;
|
|
2547
2560
|
}
|
|
2548
|
-
return
|
|
2561
|
+
return On({
|
|
2549
2562
|
...s,
|
|
2550
2563
|
tenant_id: t
|
|
2551
2564
|
});
|
|
2552
2565
|
},
|
|
2553
2566
|
async get(n, r) {
|
|
2554
|
-
let i = await e.select().from(
|
|
2555
|
-
return i ?
|
|
2567
|
+
let i = await e.select().from(qe).where(t(a(qe.tenant_id, n), a(qe.id, r))).get();
|
|
2568
|
+
return i ? On(i) : null;
|
|
2556
2569
|
},
|
|
2557
2570
|
async update(n, r, i) {
|
|
2558
2571
|
let o = {};
|
|
2559
|
-
for (let e of
|
|
2560
|
-
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(
|
|
2572
|
+
for (let e of Dn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2573
|
+
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(qe).set(o).where(t(a(qe.tenant_id, n), a(qe.id, r))).returning()).length > 0;
|
|
2561
2574
|
},
|
|
2562
2575
|
async list(t, o) {
|
|
2563
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2576
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(qe).where(a(qe.tenant_id, t)).$dynamic();
|
|
2564
2577
|
if (u?.sort_by) {
|
|
2565
|
-
let e =
|
|
2578
|
+
let e = qe[u.sort_by];
|
|
2566
2579
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2567
2580
|
}
|
|
2568
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2581
|
+
let f = (await d.offset(s * c).limit(c)).map(On);
|
|
2569
2582
|
if (!l) return { invites: f };
|
|
2570
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2583
|
+
let [p] = await e.select({ count: r() }).from(qe).where(a(qe.tenant_id, t));
|
|
2571
2584
|
return {
|
|
2572
2585
|
invites: f,
|
|
2573
2586
|
start: s * c,
|
|
@@ -2576,39 +2589,39 @@ function En(e) {
|
|
|
2576
2589
|
};
|
|
2577
2590
|
},
|
|
2578
2591
|
async remove(n, r) {
|
|
2579
|
-
return (await e.delete(
|
|
2592
|
+
return (await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.id, r))).returning()).length > 0;
|
|
2580
2593
|
}
|
|
2581
2594
|
};
|
|
2582
2595
|
}
|
|
2583
2596
|
//#endregion
|
|
2584
2597
|
//#region src/adapters/keys.ts
|
|
2585
|
-
var
|
|
2598
|
+
var An = [
|
|
2586
2599
|
"kid",
|
|
2587
2600
|
"connection",
|
|
2588
2601
|
"fingerprint",
|
|
2589
2602
|
"thumbprint",
|
|
2590
2603
|
"type"
|
|
2591
2604
|
];
|
|
2592
|
-
function
|
|
2605
|
+
function jn(e) {
|
|
2593
2606
|
return {
|
|
2594
2607
|
async create(t) {
|
|
2595
|
-
await e.insert(
|
|
2608
|
+
await e.insert(ot).values({
|
|
2596
2609
|
...t,
|
|
2597
2610
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2598
2611
|
});
|
|
2599
2612
|
},
|
|
2600
2613
|
async list(a) {
|
|
2601
|
-
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(
|
|
2614
|
+
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(ot.revoked_at, p), f(ot.revoked_at))];
|
|
2602
2615
|
if (d) {
|
|
2603
|
-
let e =
|
|
2616
|
+
let e = Te(d, An);
|
|
2604
2617
|
if (e) {
|
|
2605
|
-
let t =
|
|
2618
|
+
let t = _t(ot, e, An);
|
|
2606
2619
|
t && m.push(t);
|
|
2607
2620
|
}
|
|
2608
2621
|
}
|
|
2609
|
-
let h = t(...m), g = e.select().from(
|
|
2622
|
+
let h = t(...m), g = e.select().from(ot).where(h).$dynamic();
|
|
2610
2623
|
if (u?.sort_by) {
|
|
2611
|
-
let e =
|
|
2624
|
+
let e = ot[u.sort_by];
|
|
2612
2625
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2613
2626
|
}
|
|
2614
2627
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2616,7 +2629,7 @@ function On(e) {
|
|
|
2616
2629
|
return D(n);
|
|
2617
2630
|
});
|
|
2618
2631
|
if (!l) return { signingKeys: _ };
|
|
2619
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2632
|
+
let [y] = await e.select({ count: r() }).from(ot).where(h);
|
|
2620
2633
|
return {
|
|
2621
2634
|
signingKeys: _,
|
|
2622
2635
|
start: o * c,
|
|
@@ -2625,22 +2638,22 @@ function On(e) {
|
|
|
2625
2638
|
};
|
|
2626
2639
|
},
|
|
2627
2640
|
async update(t, n) {
|
|
2628
|
-
return (await e.update(
|
|
2641
|
+
return (await e.update(ot).set(n).where(a(ot.kid, t)).returning()).length > 0;
|
|
2629
2642
|
}
|
|
2630
2643
|
};
|
|
2631
2644
|
}
|
|
2632
2645
|
//#endregion
|
|
2633
2646
|
//#region src/adapters/loginSessions.ts
|
|
2634
|
-
var
|
|
2635
|
-
function
|
|
2647
|
+
var Mn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Nn = 32;
|
|
2648
|
+
function Pn() {
|
|
2636
2649
|
let e = Date.now(), t = "";
|
|
2637
|
-
for (let n = 10; n > 0; n--) t =
|
|
2650
|
+
for (let n = 10; n > 0; n--) t = Mn.charAt(e % Nn) + t, e = Math.floor(e / Nn);
|
|
2638
2651
|
let n = new Uint8Array(16);
|
|
2639
2652
|
crypto.getRandomValues(n);
|
|
2640
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2653
|
+
for (let e = 0; e < 16; e++) t += Mn.charAt(n[e] % Nn);
|
|
2641
2654
|
return t;
|
|
2642
2655
|
}
|
|
2643
|
-
function
|
|
2656
|
+
function Fn(e) {
|
|
2644
2657
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, state_data: a, auth_params: o, ...s } = e, c = ae({
|
|
2645
2658
|
created_at_ts: n,
|
|
2646
2659
|
updated_at_ts: r,
|
|
@@ -2652,17 +2665,17 @@ function Mn(e) {
|
|
|
2652
2665
|
]), l = {};
|
|
2653
2666
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2654
2667
|
return D({
|
|
2655
|
-
...
|
|
2668
|
+
...mt(l, ["auth_strategy"]),
|
|
2656
2669
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2657
2670
|
...c,
|
|
2658
2671
|
state_data: Z(a)
|
|
2659
2672
|
});
|
|
2660
2673
|
}
|
|
2661
|
-
function
|
|
2674
|
+
function In(e) {
|
|
2662
2675
|
return {
|
|
2663
2676
|
async create(t, n) {
|
|
2664
2677
|
let r = Date.now(), i = {
|
|
2665
|
-
id:
|
|
2678
|
+
id: Pn(),
|
|
2666
2679
|
tenant_id: t,
|
|
2667
2680
|
session_id: n.session_id,
|
|
2668
2681
|
csrf_token: n.csrf_token,
|
|
@@ -2683,14 +2696,14 @@ function Nn(e) {
|
|
|
2683
2696
|
updated_at_ts: r,
|
|
2684
2697
|
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2685
2698
|
};
|
|
2686
|
-
return await e.insert(P).values(i),
|
|
2699
|
+
return await e.insert(P).values(i), Fn({
|
|
2687
2700
|
...i,
|
|
2688
2701
|
tenant_id: t
|
|
2689
2702
|
});
|
|
2690
2703
|
},
|
|
2691
2704
|
async get(n, r) {
|
|
2692
2705
|
let i = n ? t(a(P.tenant_id, n), a(P.id, r)) : a(P.id, r), o = await e.select().from(P).where(i).get();
|
|
2693
|
-
return o ?
|
|
2706
|
+
return o ? Fn(o) : null;
|
|
2694
2707
|
},
|
|
2695
2708
|
async update(n, r, i) {
|
|
2696
2709
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2710,7 +2723,7 @@ function Nn(e) {
|
|
|
2710
2723
|
}
|
|
2711
2724
|
//#endregion
|
|
2712
2725
|
//#region src/adapters/logs.ts
|
|
2713
|
-
function
|
|
2726
|
+
function Ln(e) {
|
|
2714
2727
|
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 = {
|
|
2715
2728
|
...f,
|
|
2716
2729
|
isMobile: !!n,
|
|
@@ -2727,7 +2740,7 @@ function Pn(e) {
|
|
|
2727
2740
|
continent_code: u
|
|
2728
2741
|
})), D(p);
|
|
2729
2742
|
}
|
|
2730
|
-
function
|
|
2743
|
+
function Rn(e) {
|
|
2731
2744
|
return {
|
|
2732
2745
|
async create(t, n) {
|
|
2733
2746
|
let r = {
|
|
@@ -2753,7 +2766,7 @@ function Fn(e) {
|
|
|
2753
2766
|
hostname: n.hostname,
|
|
2754
2767
|
session_connection: n.session_connection
|
|
2755
2768
|
};
|
|
2756
|
-
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(q).values(r),
|
|
2769
|
+
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(q).values(r), Ln({
|
|
2757
2770
|
...r,
|
|
2758
2771
|
tenant_id: t
|
|
2759
2772
|
});
|
|
@@ -2761,7 +2774,7 @@ function Fn(e) {
|
|
|
2761
2774
|
async list(o, s) {
|
|
2762
2775
|
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(q.tenant_id, o)];
|
|
2763
2776
|
if (p) {
|
|
2764
|
-
let e =
|
|
2777
|
+
let e = _t(q, p, [
|
|
2765
2778
|
"user_id",
|
|
2766
2779
|
"ip",
|
|
2767
2780
|
"type",
|
|
@@ -2771,14 +2784,14 @@ function Fn(e) {
|
|
|
2771
2784
|
}
|
|
2772
2785
|
typeof h == "number" && Number.isFinite(h) && _.push(c(q.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(q.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2773
2786
|
let v = t(..._);
|
|
2774
|
-
if (
|
|
2775
|
-
if (f?.sort_by && f.sort_by !== "date") throw new
|
|
2787
|
+
if (kt(s)) {
|
|
2788
|
+
if (f?.sort_by && f.sort_by !== "date") throw new Le(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2776
2789
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2777
2790
|
sortColumn: q.date,
|
|
2778
2791
|
idColumn: q.log_id,
|
|
2779
2792
|
sortOrder: n,
|
|
2780
2793
|
sortKey: `date:${n}`
|
|
2781
|
-
}, i =
|
|
2794
|
+
}, i = Mt(s, r), a = At(s), { rows: o, next: c } = Nt(await e.select().from(q).where(i ? t(v, i) : v).orderBy(...jt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Ln);
|
|
2782
2795
|
return {
|
|
2783
2796
|
logs: l,
|
|
2784
2797
|
start: 0,
|
|
@@ -2792,7 +2805,7 @@ function Fn(e) {
|
|
|
2792
2805
|
let e = q[f.sort_by];
|
|
2793
2806
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2794
2807
|
} else y = y.orderBy(i(q.date));
|
|
2795
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2808
|
+
let ee = (await y.offset(l * u).limit(u)).map(Ln);
|
|
2796
2809
|
if (!d) return { logs: ee };
|
|
2797
2810
|
let [b] = await e.select({ count: r() }).from(q).where(v);
|
|
2798
2811
|
return {
|
|
@@ -2804,22 +2817,22 @@ function Fn(e) {
|
|
|
2804
2817
|
},
|
|
2805
2818
|
async get(n, r) {
|
|
2806
2819
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.log_id, r))).get();
|
|
2807
|
-
return i ?
|
|
2820
|
+
return i ? Ln(i) : null;
|
|
2808
2821
|
}
|
|
2809
2822
|
};
|
|
2810
2823
|
}
|
|
2811
2824
|
//#endregion
|
|
2812
2825
|
//#region src/adapters/authenticationMethods.ts
|
|
2813
|
-
var
|
|
2814
|
-
function
|
|
2826
|
+
var zn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Bn = 32;
|
|
2827
|
+
function Vn() {
|
|
2815
2828
|
let e = Date.now(), t = "";
|
|
2816
|
-
for (let n = 10; n > 0; n--) t =
|
|
2829
|
+
for (let n = 10; n > 0; n--) t = zn.charAt(e % Bn) + t, e = Math.floor(e / Bn);
|
|
2817
2830
|
let n = new Uint8Array(16);
|
|
2818
2831
|
crypto.getRandomValues(n);
|
|
2819
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2832
|
+
for (let e = 0; e < 16; e++) t += zn.charAt(n[e] % Bn);
|
|
2820
2833
|
return t;
|
|
2821
2834
|
}
|
|
2822
|
-
function
|
|
2835
|
+
function Hn(e) {
|
|
2823
2836
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2824
2837
|
return D({
|
|
2825
2838
|
...s,
|
|
@@ -2830,11 +2843,11 @@ function zn(e) {
|
|
|
2830
2843
|
updated_at: oe(r)
|
|
2831
2844
|
});
|
|
2832
2845
|
}
|
|
2833
|
-
function
|
|
2846
|
+
function Un(e) {
|
|
2834
2847
|
return {
|
|
2835
2848
|
async create(t, n) {
|
|
2836
2849
|
let r = Date.now(), i = {
|
|
2837
|
-
id: n.id ||
|
|
2850
|
+
id: n.id || Vn(),
|
|
2838
2851
|
tenant_id: t,
|
|
2839
2852
|
user_id: n.user_id,
|
|
2840
2853
|
type: n.type,
|
|
@@ -2850,41 +2863,41 @@ function Bn(e) {
|
|
|
2850
2863
|
created_at_ts: r,
|
|
2851
2864
|
updated_at_ts: r
|
|
2852
2865
|
};
|
|
2853
|
-
return await e.insert(
|
|
2866
|
+
return await e.insert(ct).values(i), Hn({
|
|
2854
2867
|
...i,
|
|
2855
2868
|
tenant_id: t
|
|
2856
2869
|
});
|
|
2857
2870
|
},
|
|
2858
2871
|
async get(n, r) {
|
|
2859
|
-
let i = await e.select().from(
|
|
2860
|
-
return i ?
|
|
2872
|
+
let i = await e.select().from(ct).where(t(a(ct.tenant_id, n), a(ct.id, r))).get();
|
|
2873
|
+
return i ? Hn(i) : null;
|
|
2861
2874
|
},
|
|
2862
2875
|
async getByCredentialId(n, r) {
|
|
2863
|
-
let i = await e.select().from(
|
|
2864
|
-
return i ?
|
|
2876
|
+
let i = await e.select().from(ct).where(t(a(ct.tenant_id, n), a(ct.credential_id, r))).get();
|
|
2877
|
+
return i ? Hn(i) : null;
|
|
2865
2878
|
},
|
|
2866
2879
|
async list(n, r) {
|
|
2867
|
-
return (await e.select().from(
|
|
2880
|
+
return (await e.select().from(ct).where(t(a(ct.tenant_id, n), a(ct.user_id, r))).all()).map(Hn);
|
|
2868
2881
|
},
|
|
2869
2882
|
async update(n, r, i) {
|
|
2870
2883
|
let o = { updated_at_ts: Date.now() };
|
|
2871
|
-
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(
|
|
2884
|
+
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(ct).set(o).where(t(a(ct.tenant_id, n), a(ct.id, r)));
|
|
2872
2885
|
let s = await this.get(n, r);
|
|
2873
2886
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2874
2887
|
return s;
|
|
2875
2888
|
},
|
|
2876
2889
|
async remove(n, r) {
|
|
2877
|
-
return (await e.delete(
|
|
2890
|
+
return (await e.delete(ct).where(t(a(ct.tenant_id, n), a(ct.id, r))).returning()).length > 0;
|
|
2878
2891
|
}
|
|
2879
2892
|
};
|
|
2880
2893
|
}
|
|
2881
2894
|
//#endregion
|
|
2882
2895
|
//#region src/adapters/organizations.ts
|
|
2883
|
-
var
|
|
2884
|
-
function
|
|
2896
|
+
var Wn = ["name", "display_name"];
|
|
2897
|
+
function Gn() {
|
|
2885
2898
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2886
2899
|
}
|
|
2887
|
-
function
|
|
2900
|
+
function Kn(e) {
|
|
2888
2901
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2889
2902
|
return D({
|
|
2890
2903
|
...o,
|
|
@@ -2894,11 +2907,11 @@ function Un(e) {
|
|
|
2894
2907
|
token_quota: Z(a, {})
|
|
2895
2908
|
});
|
|
2896
2909
|
}
|
|
2897
|
-
function
|
|
2910
|
+
function qn(e) {
|
|
2898
2911
|
return {
|
|
2899
2912
|
async create(t, n) {
|
|
2900
2913
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2901
|
-
id: n.id ||
|
|
2914
|
+
id: n.id || Gn(),
|
|
2902
2915
|
tenant_id: t,
|
|
2903
2916
|
name: n.name,
|
|
2904
2917
|
display_name: n.display_name,
|
|
@@ -2912,16 +2925,16 @@ function Wn(e) {
|
|
|
2912
2925
|
try {
|
|
2913
2926
|
await e.insert(H).values(i);
|
|
2914
2927
|
} catch (e) {
|
|
2915
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new
|
|
2928
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "Organization already exists" }) : e;
|
|
2916
2929
|
}
|
|
2917
|
-
return
|
|
2930
|
+
return Kn({
|
|
2918
2931
|
...i,
|
|
2919
2932
|
tenant_id: t
|
|
2920
2933
|
});
|
|
2921
2934
|
},
|
|
2922
2935
|
async get(n, r) {
|
|
2923
2936
|
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
2924
|
-
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ?
|
|
2937
|
+
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ? Kn(i) : null;
|
|
2925
2938
|
},
|
|
2926
2939
|
async update(n, r, i) {
|
|
2927
2940
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2930,19 +2943,19 @@ function Wn(e) {
|
|
|
2930
2943
|
async list(o, s) {
|
|
2931
2944
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(H.tenant_id, o)];
|
|
2932
2945
|
if (f) {
|
|
2933
|
-
let e =
|
|
2946
|
+
let e = Te(f, Wn);
|
|
2934
2947
|
if (e) {
|
|
2935
|
-
let t =
|
|
2948
|
+
let t = _t(H, e, Wn);
|
|
2936
2949
|
t && p.push(t);
|
|
2937
2950
|
}
|
|
2938
2951
|
}
|
|
2939
2952
|
let m = t(...p);
|
|
2940
|
-
if (
|
|
2953
|
+
if (kt(s)) {
|
|
2941
2954
|
let n = {
|
|
2942
2955
|
sortColumn: H.created_at,
|
|
2943
2956
|
idColumn: H.id,
|
|
2944
2957
|
sortOrder: "desc"
|
|
2945
|
-
}, r =
|
|
2958
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(H).where(r ? t(m, r) : m).orderBy(...jt(n)).limit(i + 1), i, "created_at"), c = a.map(Kn);
|
|
2946
2959
|
return {
|
|
2947
2960
|
organizations: c,
|
|
2948
2961
|
start: 0,
|
|
@@ -2957,7 +2970,7 @@ function Wn(e) {
|
|
|
2957
2970
|
let e = H[d.sort_by];
|
|
2958
2971
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2959
2972
|
}
|
|
2960
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2973
|
+
let g = (await h.offset(c * l).limit(l)).map(Kn);
|
|
2961
2974
|
if (!u) return { organizations: g };
|
|
2962
2975
|
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2963
2976
|
return {
|
|
@@ -2974,14 +2987,14 @@ function Wn(e) {
|
|
|
2974
2987
|
}
|
|
2975
2988
|
//#endregion
|
|
2976
2989
|
//#region src/adapters/passwords.ts
|
|
2977
|
-
function
|
|
2990
|
+
function Jn(e) {
|
|
2978
2991
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2979
2992
|
return {
|
|
2980
2993
|
...r,
|
|
2981
2994
|
is_current: !!n
|
|
2982
2995
|
};
|
|
2983
2996
|
}
|
|
2984
|
-
function
|
|
2997
|
+
function Yn(e) {
|
|
2985
2998
|
return {
|
|
2986
2999
|
async create(n, r) {
|
|
2987
3000
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2996,18 +3009,18 @@ function Kn(e) {
|
|
|
2996
3009
|
created_at: i,
|
|
2997
3010
|
updated_at: i
|
|
2998
3011
|
};
|
|
2999
|
-
return await e.insert(j).values(s),
|
|
3012
|
+
return await e.insert(j).values(s), Jn({
|
|
3000
3013
|
...s,
|
|
3001
3014
|
tenant_id: n
|
|
3002
3015
|
});
|
|
3003
3016
|
},
|
|
3004
3017
|
async get(n, r) {
|
|
3005
3018
|
let i = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r), a(j.is_current, 1))).get();
|
|
3006
|
-
return i ?
|
|
3019
|
+
return i ? Jn(i) : null;
|
|
3007
3020
|
},
|
|
3008
3021
|
async list(n, r, o) {
|
|
3009
3022
|
let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
|
|
3010
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
3023
|
+
return o && (s = s.limit(o)), (await s).map(Jn);
|
|
3011
3024
|
},
|
|
3012
3025
|
async update(n, r) {
|
|
3013
3026
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3017,10 +3030,10 @@ function Kn(e) {
|
|
|
3017
3030
|
}
|
|
3018
3031
|
//#endregion
|
|
3019
3032
|
//#region src/adapters/promptSettings.ts
|
|
3020
|
-
function
|
|
3033
|
+
function Xn(e) {
|
|
3021
3034
|
return {
|
|
3022
3035
|
async get(t) {
|
|
3023
|
-
let n = await e.select().from(
|
|
3036
|
+
let n = await e.select().from(tt).where(a(tt.tenant_id, t)).get();
|
|
3024
3037
|
return n ? {
|
|
3025
3038
|
universal_login_experience: n.universal_login_experience,
|
|
3026
3039
|
identifier_first: !!n.identifier_first,
|
|
@@ -3036,7 +3049,7 @@ function qn(e) {
|
|
|
3036
3049
|
};
|
|
3037
3050
|
},
|
|
3038
3051
|
async set(t, n) {
|
|
3039
|
-
await e.insert(
|
|
3052
|
+
await e.insert(tt).values({
|
|
3040
3053
|
tenant_id: t,
|
|
3041
3054
|
universal_login_experience: n.universal_login_experience,
|
|
3042
3055
|
identifier_first: n.identifier_first,
|
|
@@ -3044,7 +3057,7 @@ function qn(e) {
|
|
|
3044
3057
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3045
3058
|
show_last_used_connection: n.show_last_used_connection
|
|
3046
3059
|
}).onConflictDoUpdate({
|
|
3047
|
-
target:
|
|
3060
|
+
target: tt.tenant_id,
|
|
3048
3061
|
set: {
|
|
3049
3062
|
universal_login_experience: n.universal_login_experience,
|
|
3050
3063
|
identifier_first: n.identifier_first,
|
|
@@ -3058,22 +3071,22 @@ function qn(e) {
|
|
|
3058
3071
|
}
|
|
3059
3072
|
//#endregion
|
|
3060
3073
|
//#region src/adapters/proxyRoutes.ts
|
|
3061
|
-
function
|
|
3074
|
+
function Zn(e) {
|
|
3062
3075
|
if (!e) return { path: "/*" };
|
|
3063
3076
|
try {
|
|
3064
|
-
let t = JSON.parse(e), n =
|
|
3077
|
+
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
3065
3078
|
if (n.success) return n.data;
|
|
3066
3079
|
} catch {}
|
|
3067
3080
|
return { path: "/*" };
|
|
3068
3081
|
}
|
|
3069
|
-
function
|
|
3082
|
+
function Qn(e) {
|
|
3070
3083
|
if (!e) return [];
|
|
3071
3084
|
try {
|
|
3072
3085
|
let t = JSON.parse(e);
|
|
3073
3086
|
if (!Array.isArray(t)) return [];
|
|
3074
3087
|
let n = [];
|
|
3075
3088
|
for (let e of t) {
|
|
3076
|
-
let t =
|
|
3089
|
+
let t = ve.safeParse(e);
|
|
3077
3090
|
t.success && n.push(t.data);
|
|
3078
3091
|
}
|
|
3079
3092
|
return n;
|
|
@@ -3081,19 +3094,19 @@ function Yn(e) {
|
|
|
3081
3094
|
return [];
|
|
3082
3095
|
}
|
|
3083
3096
|
}
|
|
3084
|
-
function
|
|
3097
|
+
function $n(e) {
|
|
3085
3098
|
return {
|
|
3086
3099
|
id: e.id,
|
|
3087
3100
|
tenant_id: e.tenant_id,
|
|
3088
3101
|
custom_domain_id: e.custom_domain_id,
|
|
3089
3102
|
priority: e.priority,
|
|
3090
|
-
match:
|
|
3091
|
-
handlers:
|
|
3103
|
+
match: Zn(e.match),
|
|
3104
|
+
handlers: Qn(e.handlers),
|
|
3092
3105
|
created_at: e.created_at,
|
|
3093
3106
|
updated_at: e.updated_at
|
|
3094
3107
|
};
|
|
3095
3108
|
}
|
|
3096
|
-
function
|
|
3109
|
+
function er(e) {
|
|
3097
3110
|
return {
|
|
3098
3111
|
async create(t, n) {
|
|
3099
3112
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3119,14 +3132,14 @@ function Zn(e) {
|
|
|
3119
3132
|
},
|
|
3120
3133
|
async get(n, r) {
|
|
3121
3134
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.id, r))).limit(1);
|
|
3122
|
-
return i[0] ?
|
|
3135
|
+
return i[0] ? $n(i[0]) : null;
|
|
3123
3136
|
},
|
|
3124
3137
|
async list(r, i = {}) {
|
|
3125
3138
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(Y.tenant_id, r)];
|
|
3126
3139
|
i.custom_domain_id && c.push(a(Y.custom_domain_id, i.custom_domain_id));
|
|
3127
3140
|
let l = await e.select().from(Y).where(t(...c)).orderBy(n(Y.priority), n(Y.created_at)).offset(o * s).limit(s);
|
|
3128
3141
|
return {
|
|
3129
|
-
proxy_routes: l.map(
|
|
3142
|
+
proxy_routes: l.map($n),
|
|
3130
3143
|
start: o * s,
|
|
3131
3144
|
limit: s,
|
|
3132
3145
|
length: l.length
|
|
@@ -3144,15 +3157,71 @@ function Zn(e) {
|
|
|
3144
3157
|
};
|
|
3145
3158
|
}
|
|
3146
3159
|
//#endregion
|
|
3160
|
+
//#region src/adapters/tokenExchangeProfiles.ts
|
|
3161
|
+
var tr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3162
|
+
function nr(e) {
|
|
3163
|
+
if (e) try {
|
|
3164
|
+
let t = Fe.safeParse(JSON.parse(e));
|
|
3165
|
+
return t.success ? t.data : void 0;
|
|
3166
|
+
} catch {
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
function rr(e) {
|
|
3171
|
+
let t = {
|
|
3172
|
+
id: e.id,
|
|
3173
|
+
name: e.name,
|
|
3174
|
+
subject_token_type: e.subject_token_type,
|
|
3175
|
+
type: de,
|
|
3176
|
+
created_at: e.created_at,
|
|
3177
|
+
updated_at: e.updated_at
|
|
3178
|
+
};
|
|
3179
|
+
e.action_id && (t.action_id = e.action_id);
|
|
3180
|
+
let n = nr(e.jwt_verification);
|
|
3181
|
+
return n && (t.jwt_verification = n), t;
|
|
3182
|
+
}
|
|
3183
|
+
function ir(e) {
|
|
3184
|
+
return {
|
|
3185
|
+
async create(t, n, r) {
|
|
3186
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3187
|
+
id: i?.id ?? `tep_${tr()}`,
|
|
3188
|
+
tenant_id: t,
|
|
3189
|
+
name: n.name,
|
|
3190
|
+
subject_token_type: n.subject_token_type,
|
|
3191
|
+
action_id: n.action_id ?? null,
|
|
3192
|
+
type: de,
|
|
3193
|
+
jwt_verification: n.jwt_verification ? JSON.stringify(n.jwt_verification) : null,
|
|
3194
|
+
created_at: i?.created_at ?? a,
|
|
3195
|
+
updated_at: i?.updated_at ?? a
|
|
3196
|
+
};
|
|
3197
|
+
return await e.insert(dt).values(o), rr(o);
|
|
3198
|
+
},
|
|
3199
|
+
async get(n, r) {
|
|
3200
|
+
let i = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).limit(1);
|
|
3201
|
+
return i[0] ? rr(i[0]) : null;
|
|
3202
|
+
},
|
|
3203
|
+
async list(t) {
|
|
3204
|
+
return (await e.select().from(dt).where(a(dt.tenant_id, t)).orderBy(n(dt.created_at), n(dt.id))).map(rr);
|
|
3205
|
+
},
|
|
3206
|
+
async update(n, r, i) {
|
|
3207
|
+
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3208
|
+
return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(dt).set(o).where(t(a(dt.tenant_id, n), a(dt.id, r))).returning({ id: dt.id })).length > 0;
|
|
3209
|
+
},
|
|
3210
|
+
async remove(n, r) {
|
|
3211
|
+
return (await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).returning({ id: dt.id })).length > 0;
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
}
|
|
3215
|
+
//#endregion
|
|
3147
3216
|
//#region src/adapters/scim.ts
|
|
3148
|
-
function
|
|
3217
|
+
function ar(e) {
|
|
3149
3218
|
if (!e) return [];
|
|
3150
3219
|
try {
|
|
3151
3220
|
let t = JSON.parse(e);
|
|
3152
3221
|
if (!Array.isArray(t)) return [];
|
|
3153
3222
|
let n = [];
|
|
3154
3223
|
for (let e of t) {
|
|
3155
|
-
let t =
|
|
3224
|
+
let t = Ee.safeParse(e);
|
|
3156
3225
|
t.success && n.push(t.data);
|
|
3157
3226
|
}
|
|
3158
3227
|
return n;
|
|
@@ -3160,7 +3229,7 @@ function Qn(e) {
|
|
|
3160
3229
|
return [];
|
|
3161
3230
|
}
|
|
3162
3231
|
}
|
|
3163
|
-
function
|
|
3232
|
+
function or(e) {
|
|
3164
3233
|
if (!e) return [];
|
|
3165
3234
|
try {
|
|
3166
3235
|
let t = JSON.parse(e);
|
|
@@ -3169,16 +3238,16 @@ function $n(e) {
|
|
|
3169
3238
|
return [];
|
|
3170
3239
|
}
|
|
3171
3240
|
}
|
|
3172
|
-
function
|
|
3241
|
+
function sr(e) {
|
|
3173
3242
|
return {
|
|
3174
3243
|
connection_id: e.connection_id,
|
|
3175
3244
|
user_id_attribute: e.user_id_attribute,
|
|
3176
|
-
mapping:
|
|
3245
|
+
mapping: ar(e.mapping),
|
|
3177
3246
|
created_at: e.created_at,
|
|
3178
3247
|
updated_at: e.updated_at
|
|
3179
3248
|
};
|
|
3180
3249
|
}
|
|
3181
|
-
function
|
|
3250
|
+
function cr(e) {
|
|
3182
3251
|
return {
|
|
3183
3252
|
async create(t, n) {
|
|
3184
3253
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3188,7 +3257,7 @@ function tr(e) {
|
|
|
3188
3257
|
created_at: r,
|
|
3189
3258
|
updated_at: r
|
|
3190
3259
|
};
|
|
3191
|
-
return await e.insert(
|
|
3260
|
+
return await e.insert(lt).values({
|
|
3192
3261
|
connection_id: i.connection_id,
|
|
3193
3262
|
tenant_id: t,
|
|
3194
3263
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3198,31 +3267,31 @@ function tr(e) {
|
|
|
3198
3267
|
}), i;
|
|
3199
3268
|
},
|
|
3200
3269
|
async get(n, r) {
|
|
3201
|
-
let i = await e.select().from(
|
|
3202
|
-
return i[0] ?
|
|
3270
|
+
let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.connection_id, r))).limit(1);
|
|
3271
|
+
return i[0] ? sr(i[0]) : null;
|
|
3203
3272
|
},
|
|
3204
3273
|
async update(n, r, i) {
|
|
3205
|
-
if ((await e.select({ connection_id:
|
|
3274
|
+
if ((await e.select({ connection_id: lt.connection_id }).from(lt).where(t(a(lt.tenant_id, n), a(lt.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3206
3275
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3207
|
-
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(
|
|
3276
|
+
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(lt).set(o).where(t(a(lt.tenant_id, n), a(lt.connection_id, r))), !0;
|
|
3208
3277
|
},
|
|
3209
3278
|
async remove(n, r) {
|
|
3210
|
-
return (await e.select({ connection_id:
|
|
3279
|
+
return (await e.select({ connection_id: lt.connection_id }).from(lt).where(t(a(lt.tenant_id, n), a(lt.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.connection_id, r))), !0);
|
|
3211
3280
|
}
|
|
3212
3281
|
};
|
|
3213
3282
|
}
|
|
3214
|
-
function
|
|
3283
|
+
function lr(e) {
|
|
3215
3284
|
return {
|
|
3216
3285
|
token_id: e.token_id,
|
|
3217
3286
|
connection_id: e.connection_id,
|
|
3218
3287
|
token_hash: e.token_hash,
|
|
3219
|
-
scopes:
|
|
3288
|
+
scopes: or(e.scopes),
|
|
3220
3289
|
valid_until: e.valid_until ?? void 0,
|
|
3221
3290
|
created_at: e.created_at,
|
|
3222
3291
|
last_used_at: e.last_used_at ?? void 0
|
|
3223
3292
|
};
|
|
3224
3293
|
}
|
|
3225
|
-
function
|
|
3294
|
+
function ur(e) {
|
|
3226
3295
|
return {
|
|
3227
3296
|
async create(t, n) {
|
|
3228
3297
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3245,14 +3314,14 @@ function rr(e) {
|
|
|
3245
3314
|
},
|
|
3246
3315
|
async get(n, r) {
|
|
3247
3316
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1);
|
|
3248
|
-
return i[0] ?
|
|
3317
|
+
return i[0] ? lr(i[0]) : null;
|
|
3249
3318
|
},
|
|
3250
3319
|
async getByHash(n, r) {
|
|
3251
3320
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_hash, r))).limit(1);
|
|
3252
|
-
return i[0] ?
|
|
3321
|
+
return i[0] ? lr(i[0]) : null;
|
|
3253
3322
|
},
|
|
3254
3323
|
async listByConnection(n, r) {
|
|
3255
|
-
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(
|
|
3324
|
+
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(lr);
|
|
3256
3325
|
},
|
|
3257
3326
|
async markUsed(n, r, i) {
|
|
3258
3327
|
return (await e.select({ token_id: X.token_id }).from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(X).set({ last_used_at: i }).where(t(a(X.tenant_id, n), a(X.token_id, r))), !0);
|
|
@@ -3262,7 +3331,7 @@ function rr(e) {
|
|
|
3262
3331
|
}
|
|
3263
3332
|
};
|
|
3264
3333
|
}
|
|
3265
|
-
function
|
|
3334
|
+
function dr(e) {
|
|
3266
3335
|
return {
|
|
3267
3336
|
connection_id: e.connection_id,
|
|
3268
3337
|
external_id: e.external_id,
|
|
@@ -3270,7 +3339,7 @@ function ir(e) {
|
|
|
3270
3339
|
created_at: e.created_at
|
|
3271
3340
|
};
|
|
3272
3341
|
}
|
|
3273
|
-
function
|
|
3342
|
+
function fr(e) {
|
|
3274
3343
|
return {
|
|
3275
3344
|
async create(t, n) {
|
|
3276
3345
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3279,7 +3348,7 @@ function ar(e) {
|
|
|
3279
3348
|
user_id: n.user_id,
|
|
3280
3349
|
created_at: r
|
|
3281
3350
|
};
|
|
3282
|
-
return await e.insert(
|
|
3351
|
+
return await e.insert(ut).values({
|
|
3283
3352
|
tenant_id: t,
|
|
3284
3353
|
connection_id: i.connection_id,
|
|
3285
3354
|
external_id: i.external_id,
|
|
@@ -3288,21 +3357,21 @@ function ar(e) {
|
|
|
3288
3357
|
}), i;
|
|
3289
3358
|
},
|
|
3290
3359
|
async getByExternalId(n, r, i) {
|
|
3291
|
-
let o = await e.select().from(
|
|
3292
|
-
return o[0] ?
|
|
3360
|
+
let o = await e.select().from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r), a(ut.external_id, i))).limit(1);
|
|
3361
|
+
return o[0] ? dr(o[0]) : null;
|
|
3293
3362
|
},
|
|
3294
3363
|
async getByUserId(n, r, i) {
|
|
3295
|
-
let o = await e.select().from(
|
|
3296
|
-
return o[0] ?
|
|
3364
|
+
let o = await e.select().from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r), a(ut.user_id, i))).limit(1);
|
|
3365
|
+
return o[0] ? dr(o[0]) : null;
|
|
3297
3366
|
},
|
|
3298
3367
|
async remove(n, r, i) {
|
|
3299
|
-
return (await e.select({ user_id:
|
|
3368
|
+
return (await e.select({ user_id: ut.user_id }).from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r), a(ut.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r), a(ut.user_id, i))), !0);
|
|
3300
3369
|
}
|
|
3301
3370
|
};
|
|
3302
3371
|
}
|
|
3303
3372
|
//#endregion
|
|
3304
3373
|
//#region src/adapters/refreshTokens.ts
|
|
3305
|
-
function
|
|
3374
|
+
function pr(e) {
|
|
3306
3375
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: r, idle_expires_at_ts: i, last_exchanged_at_ts: a, revoked_at_ts: o, rotated_at_ts: s, device: c, resource_servers: l, rotating: u, auth_strategy_strategy: d, auth_strategy_strategy_type: f, ...p } = e, m = ae({
|
|
3307
3376
|
created_at_ts: n,
|
|
3308
3377
|
expires_at_ts: r,
|
|
@@ -3329,10 +3398,10 @@ function or(e) {
|
|
|
3329
3398
|
} } : {}
|
|
3330
3399
|
});
|
|
3331
3400
|
}
|
|
3332
|
-
function
|
|
3401
|
+
function mr(e, t) {
|
|
3333
3402
|
return Math.max(e ?? 0, t ?? 0);
|
|
3334
3403
|
}
|
|
3335
|
-
function
|
|
3404
|
+
function hr(e) {
|
|
3336
3405
|
return {
|
|
3337
3406
|
async create(n, r) {
|
|
3338
3407
|
let i = Date.now(), o = {
|
|
@@ -3358,22 +3427,22 @@ function cr(e) {
|
|
|
3358
3427
|
expires_at_ts: E(r.expires_at),
|
|
3359
3428
|
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3360
3429
|
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3361
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3430
|
+
}, s = [e.insert(N).values(o)], c = mr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3362
3431
|
return c > 0 && o.login_id && s.push(e.update(P).set({
|
|
3363
3432
|
expires_at_ts: c,
|
|
3364
3433
|
updated_at_ts: i
|
|
3365
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await
|
|
3434
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await wt(e, s), pr({
|
|
3366
3435
|
...o,
|
|
3367
3436
|
tenant_id: n
|
|
3368
3437
|
});
|
|
3369
3438
|
},
|
|
3370
3439
|
async get(n, r) {
|
|
3371
3440
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3372
|
-
return i ?
|
|
3441
|
+
return i ? pr(i) : null;
|
|
3373
3442
|
},
|
|
3374
3443
|
async getByLookup(n, r) {
|
|
3375
3444
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
|
|
3376
|
-
return i ?
|
|
3445
|
+
return i ? pr(i) : null;
|
|
3377
3446
|
},
|
|
3378
3447
|
async update(n, r, i, o) {
|
|
3379
3448
|
let s = {};
|
|
@@ -3385,17 +3454,17 @@ function cr(e) {
|
|
|
3385
3454
|
}).where(t(a(P.tenant_id, n), a(P.id, c.login_id), m(P.expires_at_ts, l))).catch(() => {}), u.length > 0;
|
|
3386
3455
|
},
|
|
3387
3456
|
async list(o, s) {
|
|
3388
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3457
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(N, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3389
3458
|
a(N.tenant_id, o),
|
|
3390
3459
|
...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
|
|
3391
3460
|
...p ? [p] : []
|
|
3392
3461
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3393
|
-
if (
|
|
3462
|
+
if (kt(s)) {
|
|
3394
3463
|
let n = {
|
|
3395
3464
|
sortColumn: N.created_at_ts,
|
|
3396
3465
|
idColumn: N.id,
|
|
3397
3466
|
sortOrder: "desc"
|
|
3398
|
-
}, r =
|
|
3467
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...jt(n)).limit(i + 1), i, "created_at_ts"), c = a.map(pr);
|
|
3399
3468
|
return {
|
|
3400
3469
|
refresh_tokens: c,
|
|
3401
3470
|
start: 0,
|
|
@@ -3409,7 +3478,7 @@ function cr(e) {
|
|
|
3409
3478
|
let e = N[d.sort_by];
|
|
3410
3479
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3411
3480
|
}
|
|
3412
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3481
|
+
let _ = (await g.offset(c * l).limit(l)).map(pr);
|
|
3413
3482
|
if (!u) return { refresh_tokens: _ };
|
|
3414
3483
|
let [v] = await e.select({ count: r() }).from(N).where(h);
|
|
3415
3484
|
return {
|
|
@@ -3438,15 +3507,15 @@ function cr(e) {
|
|
|
3438
3507
|
}
|
|
3439
3508
|
//#endregion
|
|
3440
3509
|
//#region src/adapters/resourceServers.ts
|
|
3441
|
-
var
|
|
3442
|
-
function
|
|
3510
|
+
var gr = ["name", "identifier"];
|
|
3511
|
+
function _r() {
|
|
3443
3512
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3444
3513
|
}
|
|
3445
|
-
var
|
|
3514
|
+
var vr = [
|
|
3446
3515
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3447
3516
|
"allow_offline_access",
|
|
3448
3517
|
"is_system"
|
|
3449
|
-
],
|
|
3518
|
+
], yr = new Set([
|
|
3450
3519
|
"id",
|
|
3451
3520
|
"tenant_id",
|
|
3452
3521
|
"identifier",
|
|
@@ -3465,17 +3534,17 @@ var dr = [
|
|
|
3465
3534
|
"created_at",
|
|
3466
3535
|
"updated_at"
|
|
3467
3536
|
]);
|
|
3468
|
-
function
|
|
3537
|
+
function br(e) {
|
|
3469
3538
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3470
3539
|
s.scopes = Z(r, []), s.options = Z(i, {}), s.metadata = Z(a), n !== void 0 && (s.verificationKey = n);
|
|
3471
|
-
for (let e of
|
|
3540
|
+
for (let e of vr) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3472
3541
|
return D(s);
|
|
3473
3542
|
}
|
|
3474
|
-
function
|
|
3543
|
+
function xr(e) {
|
|
3475
3544
|
return {
|
|
3476
3545
|
async create(t, n) {
|
|
3477
3546
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3478
|
-
id: n.id ||
|
|
3547
|
+
id: n.id || _r(),
|
|
3479
3548
|
tenant_id: t,
|
|
3480
3549
|
identifier: n.identifier,
|
|
3481
3550
|
name: n.name,
|
|
@@ -3490,37 +3559,37 @@ function mr(e) {
|
|
|
3490
3559
|
created_at: r,
|
|
3491
3560
|
updated_at: r
|
|
3492
3561
|
};
|
|
3493
|
-
for (let e of
|
|
3494
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i),
|
|
3562
|
+
for (let e of vr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3563
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), br({
|
|
3495
3564
|
...i,
|
|
3496
3565
|
tenant_id: t
|
|
3497
3566
|
});
|
|
3498
3567
|
},
|
|
3499
3568
|
async get(n, r) {
|
|
3500
3569
|
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3501
|
-
return i ?
|
|
3570
|
+
return i ? br(i) : null;
|
|
3502
3571
|
},
|
|
3503
3572
|
async update(n, r, i) {
|
|
3504
3573
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3505
3574
|
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);
|
|
3506
|
-
for (let e of
|
|
3575
|
+
for (let e of vr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3507
3576
|
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3508
3577
|
},
|
|
3509
3578
|
async list(o, s) {
|
|
3510
3579
|
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)];
|
|
3511
3580
|
if (f) {
|
|
3512
|
-
let e =
|
|
3581
|
+
let e = Te(f, gr);
|
|
3513
3582
|
if (e) {
|
|
3514
|
-
let t =
|
|
3583
|
+
let t = _t(K, e, gr, ["name", "identifier"]);
|
|
3515
3584
|
t && h.push(t);
|
|
3516
3585
|
}
|
|
3517
3586
|
}
|
|
3518
|
-
if (
|
|
3587
|
+
if (kt(s)) {
|
|
3519
3588
|
let n = {
|
|
3520
3589
|
sortColumn: K.created_at,
|
|
3521
3590
|
idColumn: K.id,
|
|
3522
3591
|
sortOrder: "desc"
|
|
3523
|
-
}, r =
|
|
3592
|
+
}, r = Mt(s, n), i = At(s), { rows: a, next: o } = Nt(await e.select().from(K).where(t(...h, r)).orderBy(...jt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(br);
|
|
3524
3593
|
return {
|
|
3525
3594
|
resource_servers: c,
|
|
3526
3595
|
start: 0,
|
|
@@ -3530,11 +3599,11 @@ function mr(e) {
|
|
|
3530
3599
|
};
|
|
3531
3600
|
}
|
|
3532
3601
|
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3533
|
-
if (d?.sort_by &&
|
|
3602
|
+
if (d?.sort_by && yr.has(d.sort_by)) {
|
|
3534
3603
|
let e = K[d.sort_by];
|
|
3535
3604
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3536
3605
|
}
|
|
3537
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3606
|
+
let _ = (await g.offset(p * m).limit(m)).map(br);
|
|
3538
3607
|
if (!u) return { resource_servers: _ };
|
|
3539
3608
|
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3540
3609
|
return {
|
|
@@ -3551,12 +3620,12 @@ function mr(e) {
|
|
|
3551
3620
|
}
|
|
3552
3621
|
//#endregion
|
|
3553
3622
|
//#region src/adapters/rolePermissions.ts
|
|
3554
|
-
function
|
|
3623
|
+
function Sr(e) {
|
|
3555
3624
|
return {
|
|
3556
3625
|
async assign(t, n, r) {
|
|
3557
3626
|
if (r.length === 0) return !0;
|
|
3558
3627
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3559
|
-
return await e.insert(
|
|
3628
|
+
return await e.insert(Je).values(r.map((e) => ({
|
|
3560
3629
|
tenant_id: t,
|
|
3561
3630
|
role_id: n,
|
|
3562
3631
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3566,10 +3635,10 @@ function hr(e) {
|
|
|
3566
3635
|
},
|
|
3567
3636
|
async list(n, r, i) {
|
|
3568
3637
|
let o = await e.select({
|
|
3569
|
-
resource_server_identifier:
|
|
3570
|
-
permission_name:
|
|
3571
|
-
created_at:
|
|
3572
|
-
}).from(
|
|
3638
|
+
resource_server_identifier: Je.resource_server_identifier,
|
|
3639
|
+
permission_name: Je.permission_name,
|
|
3640
|
+
created_at: Je.created_at
|
|
3641
|
+
}).from(Je).where(t(a(Je.tenant_id, n), a(Je.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3573
3642
|
if (s.length > 0) {
|
|
3574
3643
|
let r = await e.select({
|
|
3575
3644
|
identifier: K.identifier,
|
|
@@ -3584,18 +3653,18 @@ function hr(e) {
|
|
|
3584
3653
|
},
|
|
3585
3654
|
async remove(n, r, i) {
|
|
3586
3655
|
if (i.length === 0) return !0;
|
|
3587
|
-
let o = i.map((e) => t(a(
|
|
3588
|
-
return await e.delete(
|
|
3656
|
+
let o = i.map((e) => t(a(Je.resource_server_identifier, e.resource_server_identifier), a(Je.permission_name, e.permission_name)));
|
|
3657
|
+
return await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.role_id, r), v(...o))).returning(), !0;
|
|
3589
3658
|
}
|
|
3590
3659
|
};
|
|
3591
3660
|
}
|
|
3592
3661
|
//#endregion
|
|
3593
3662
|
//#region src/adapters/userPermissions.ts
|
|
3594
|
-
function
|
|
3663
|
+
function Cr(e) {
|
|
3595
3664
|
return {
|
|
3596
3665
|
async create(t, n, r, i) {
|
|
3597
3666
|
try {
|
|
3598
|
-
await e.insert(
|
|
3667
|
+
await e.insert(Ye).values({
|
|
3599
3668
|
tenant_id: t,
|
|
3600
3669
|
user_id: n,
|
|
3601
3670
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3610,9 +3679,9 @@ function gr(e) {
|
|
|
3610
3679
|
return !0;
|
|
3611
3680
|
},
|
|
3612
3681
|
async list(n, r, i, o) {
|
|
3613
|
-
let s = [a(
|
|
3614
|
-
o && s.push(a(
|
|
3615
|
-
let c = await e.select().from(
|
|
3682
|
+
let s = [a(Ye.tenant_id, n), a(Ye.user_id, r)];
|
|
3683
|
+
o && s.push(a(Ye.organization_id, o));
|
|
3684
|
+
let c = await e.select().from(Ye).where(t(...s)).all();
|
|
3616
3685
|
return await Promise.all(c.map(async (r) => {
|
|
3617
3686
|
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();
|
|
3618
3687
|
return {
|
|
@@ -3624,13 +3693,13 @@ function gr(e) {
|
|
|
3624
3693
|
}));
|
|
3625
3694
|
},
|
|
3626
3695
|
async remove(n, r, i, o) {
|
|
3627
|
-
return (await e.delete(
|
|
3696
|
+
return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.user_id, r), a(Ye.resource_server_identifier, i.resource_server_identifier), a(Ye.permission_name, i.permission_name), a(Ye.organization_id, o || ""))).returning()).length > 0;
|
|
3628
3697
|
}
|
|
3629
3698
|
};
|
|
3630
3699
|
}
|
|
3631
3700
|
//#endregion
|
|
3632
3701
|
//#region src/adapters/roles.ts
|
|
3633
|
-
function
|
|
3702
|
+
function wr(e) {
|
|
3634
3703
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3635
3704
|
return D({
|
|
3636
3705
|
...i,
|
|
@@ -3638,7 +3707,7 @@ function _r(e) {
|
|
|
3638
3707
|
metadata: Z(r)
|
|
3639
3708
|
});
|
|
3640
3709
|
}
|
|
3641
|
-
function
|
|
3710
|
+
function Tr(e) {
|
|
3642
3711
|
return {
|
|
3643
3712
|
async create(t, n) {
|
|
3644
3713
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3651,26 +3720,26 @@ function vr(e) {
|
|
|
3651
3720
|
created_at: r,
|
|
3652
3721
|
updated_at: r
|
|
3653
3722
|
};
|
|
3654
|
-
return await e.insert(W).values(i),
|
|
3723
|
+
return await e.insert(W).values(i), wr({
|
|
3655
3724
|
...i,
|
|
3656
3725
|
tenant_id: t
|
|
3657
3726
|
});
|
|
3658
3727
|
},
|
|
3659
3728
|
async get(n, r) {
|
|
3660
3729
|
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3661
|
-
return i ?
|
|
3730
|
+
return i ? wr(i) : null;
|
|
3662
3731
|
},
|
|
3663
3732
|
async update(n, r, i) {
|
|
3664
3733
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3665
3734
|
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;
|
|
3666
3735
|
},
|
|
3667
3736
|
async list(o, s) {
|
|
3668
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3737
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(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();
|
|
3669
3738
|
if (d?.sort_by) {
|
|
3670
3739
|
let e = W[d.sort_by];
|
|
3671
3740
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3672
3741
|
}
|
|
3673
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3742
|
+
let g = (await h.offset(c * l).limit(l)).map(wr);
|
|
3674
3743
|
if (!u) return { roles: g };
|
|
3675
3744
|
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3676
3745
|
return {
|
|
@@ -3687,7 +3756,7 @@ function vr(e) {
|
|
|
3687
3756
|
}
|
|
3688
3757
|
//#endregion
|
|
3689
3758
|
//#region src/adapters/sessions.ts
|
|
3690
|
-
var
|
|
3759
|
+
var Er = ["created_at_ts", "updated_at_ts"], Dr = [
|
|
3691
3760
|
"expires_at_ts",
|
|
3692
3761
|
"idle_expires_at_ts",
|
|
3693
3762
|
"authenticated_at_ts",
|
|
@@ -3695,7 +3764,7 @@ var yr = ["created_at_ts", "updated_at_ts"], br = [
|
|
|
3695
3764
|
"used_at_ts",
|
|
3696
3765
|
"revoked_at_ts"
|
|
3697
3766
|
];
|
|
3698
|
-
function
|
|
3767
|
+
function Or(e) {
|
|
3699
3768
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, p = ae({
|
|
3700
3769
|
created_at_ts: n,
|
|
3701
3770
|
updated_at_ts: r,
|
|
@@ -3705,7 +3774,7 @@ function xr(e) {
|
|
|
3705
3774
|
last_interaction_at_ts: s,
|
|
3706
3775
|
used_at_ts: c,
|
|
3707
3776
|
revoked_at_ts: l
|
|
3708
|
-
}, [...
|
|
3777
|
+
}, [...Er], [...Dr]);
|
|
3709
3778
|
return D({
|
|
3710
3779
|
...f,
|
|
3711
3780
|
...p,
|
|
@@ -3713,10 +3782,10 @@ function xr(e) {
|
|
|
3713
3782
|
clients: Z(d, [])
|
|
3714
3783
|
});
|
|
3715
3784
|
}
|
|
3716
|
-
function
|
|
3785
|
+
function kr(e, t) {
|
|
3717
3786
|
return Math.max(e ?? 0, t ?? 0);
|
|
3718
3787
|
}
|
|
3719
|
-
function
|
|
3788
|
+
function Ar(e) {
|
|
3720
3789
|
return {
|
|
3721
3790
|
async create(n, r) {
|
|
3722
3791
|
let i = Date.now(), o = {
|
|
@@ -3734,23 +3803,23 @@ function Cr(e) {
|
|
|
3734
3803
|
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
3735
3804
|
used_at_ts: E(r.used_at),
|
|
3736
3805
|
revoked_at_ts: E(r.revoked_at)
|
|
3737
|
-
}, s = [e.insert(M).values(o)], c =
|
|
3806
|
+
}, s = [e.insert(M).values(o)], c = kr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3738
3807
|
return c > 0 && o.login_session_id && s.push(e.update(P).set({
|
|
3739
3808
|
expires_at_ts: c,
|
|
3740
3809
|
updated_at_ts: i
|
|
3741
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await
|
|
3810
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await wt(e, s), Or({
|
|
3742
3811
|
...o,
|
|
3743
3812
|
tenant_id: n
|
|
3744
3813
|
});
|
|
3745
3814
|
},
|
|
3746
3815
|
async get(n, r) {
|
|
3747
3816
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
|
|
3748
|
-
return i ?
|
|
3817
|
+
return i ? Or(i) : null;
|
|
3749
3818
|
},
|
|
3750
3819
|
async update(n, r, i) {
|
|
3751
3820
|
let o = { updated_at_ts: Date.now() };
|
|
3752
3821
|
i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = E(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = E(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = E(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = E(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = E(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = E(i.revoked_at));
|
|
3753
|
-
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c =
|
|
3822
|
+
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = kr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3754
3823
|
if (c > 0 && l) {
|
|
3755
3824
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3756
3825
|
r && await e.update(P).set({
|
|
@@ -3761,12 +3830,12 @@ function Cr(e) {
|
|
|
3761
3830
|
return s.length > 0;
|
|
3762
3831
|
},
|
|
3763
3832
|
async list(o, s) {
|
|
3764
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3833
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? _t(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o), h = e.select().from(M).where(m).$dynamic();
|
|
3765
3834
|
if (d?.sort_by) {
|
|
3766
3835
|
let e = M[d.sort_by];
|
|
3767
3836
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3768
3837
|
}
|
|
3769
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3838
|
+
let g = (await h.offset(c * l).limit(l)).map(Or);
|
|
3770
3839
|
if (!u) return { sessions: g };
|
|
3771
3840
|
let [_] = await e.select({ count: r() }).from(M).where(m);
|
|
3772
3841
|
return {
|
|
@@ -3783,7 +3852,7 @@ function Cr(e) {
|
|
|
3783
3852
|
}
|
|
3784
3853
|
//#endregion
|
|
3785
3854
|
//#region src/adapters/tenants.ts
|
|
3786
|
-
var
|
|
3855
|
+
var jr = [
|
|
3787
3856
|
"session_cookie",
|
|
3788
3857
|
"enabled_locales",
|
|
3789
3858
|
"error_page",
|
|
@@ -3799,25 +3868,25 @@ var wr = [
|
|
|
3799
3868
|
"acr_values_supported",
|
|
3800
3869
|
"mtls",
|
|
3801
3870
|
"mfa"
|
|
3802
|
-
],
|
|
3871
|
+
], Mr = [
|
|
3803
3872
|
"allow_organization_name_in_authentication_api",
|
|
3804
3873
|
"customize_mfa_in_postlogin_action",
|
|
3805
3874
|
"pushed_authorization_requests_supported",
|
|
3806
3875
|
"authorization_response_iss_parameter_supported"
|
|
3807
3876
|
];
|
|
3808
|
-
function
|
|
3877
|
+
function Nr(e) {
|
|
3809
3878
|
let t = { ...e };
|
|
3810
|
-
for (let e of
|
|
3811
|
-
for (let e of
|
|
3879
|
+
for (let e of jr) typeof t[e] == "string" && (t[e] = Z(t[e]));
|
|
3880
|
+
for (let e of Mr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3812
3881
|
return D(t);
|
|
3813
3882
|
}
|
|
3814
|
-
function
|
|
3883
|
+
function Pr(e) {
|
|
3815
3884
|
let t = { ...e };
|
|
3816
|
-
le(e,
|
|
3817
|
-
for (let n of
|
|
3885
|
+
le(e, jr, t);
|
|
3886
|
+
for (let n of Mr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3818
3887
|
return ce(t);
|
|
3819
3888
|
}
|
|
3820
|
-
function
|
|
3889
|
+
function Fr(e) {
|
|
3821
3890
|
return {
|
|
3822
3891
|
async create(t) {
|
|
3823
3892
|
let n = {
|
|
@@ -3825,26 +3894,26 @@ function Or(e) {
|
|
|
3825
3894
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3826
3895
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3827
3896
|
...t
|
|
3828
|
-
}, r =
|
|
3897
|
+
}, r = Pr(n);
|
|
3829
3898
|
try {
|
|
3830
3899
|
await e.insert(O).values(r);
|
|
3831
3900
|
} catch (e) {
|
|
3832
3901
|
let t = e?.message ?? "";
|
|
3833
|
-
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
|
|
3902
|
+
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 Le(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3834
3903
|
}
|
|
3835
3904
|
return n;
|
|
3836
3905
|
},
|
|
3837
3906
|
async get(t) {
|
|
3838
3907
|
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
3839
|
-
return n ?
|
|
3908
|
+
return n ? Nr(n) : null;
|
|
3840
3909
|
},
|
|
3841
3910
|
async list(t) {
|
|
3842
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3911
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? _t(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
3843
3912
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3844
3913
|
let e = O[c.sort_by];
|
|
3845
3914
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3846
3915
|
}
|
|
3847
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3916
|
+
let f = (await d.offset(a * o).limit(o)).map(Nr);
|
|
3848
3917
|
if (!s) return { tenants: f };
|
|
3849
3918
|
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
3850
3919
|
u && (p = p.where(u));
|
|
@@ -3857,7 +3926,7 @@ function Or(e) {
|
|
|
3857
3926
|
};
|
|
3858
3927
|
},
|
|
3859
3928
|
async update(t, n) {
|
|
3860
|
-
let r =
|
|
3929
|
+
let r = Pr({
|
|
3861
3930
|
...n,
|
|
3862
3931
|
id: t,
|
|
3863
3932
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3871,62 +3940,62 @@ function Or(e) {
|
|
|
3871
3940
|
}
|
|
3872
3941
|
//#endregion
|
|
3873
3942
|
//#region src/adapters/themes.ts
|
|
3874
|
-
var
|
|
3943
|
+
var Ir = [
|
|
3875
3944
|
"colors",
|
|
3876
3945
|
"borders",
|
|
3877
3946
|
"fonts",
|
|
3878
3947
|
"page_background",
|
|
3879
3948
|
"widget"
|
|
3880
3949
|
];
|
|
3881
|
-
function
|
|
3882
|
-
let { tenant_id: t, ...n } = e, r =
|
|
3950
|
+
function Lr(e) {
|
|
3951
|
+
let { tenant_id: t, ...n } = e, r = mt(n, Ir);
|
|
3883
3952
|
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), D(r);
|
|
3884
3953
|
}
|
|
3885
|
-
function
|
|
3954
|
+
function Rr(e) {
|
|
3886
3955
|
return {
|
|
3887
3956
|
async create(t, n, r, i) {
|
|
3888
3957
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3889
|
-
...
|
|
3958
|
+
...pt(n),
|
|
3890
3959
|
tenant_id: t,
|
|
3891
3960
|
themeId: s,
|
|
3892
3961
|
created_at: a?.created_at ?? o,
|
|
3893
3962
|
updated_at: a?.updated_at ?? o
|
|
3894
3963
|
};
|
|
3895
|
-
return await e.insert(
|
|
3964
|
+
return await e.insert(Qe).values(c), Lr({
|
|
3896
3965
|
...c,
|
|
3897
3966
|
tenant_id: t
|
|
3898
3967
|
});
|
|
3899
3968
|
},
|
|
3900
3969
|
async get(n, r) {
|
|
3901
|
-
let i = await e.select().from(
|
|
3902
|
-
return i ?
|
|
3970
|
+
let i = await e.select().from(Qe).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))).get();
|
|
3971
|
+
return i ? Lr(i) : null;
|
|
3903
3972
|
},
|
|
3904
3973
|
async update(n, r, i) {
|
|
3905
|
-
let o =
|
|
3906
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3974
|
+
let o = pt(i);
|
|
3975
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Qe).set(o).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))), !0;
|
|
3907
3976
|
},
|
|
3908
3977
|
async remove(n, r) {
|
|
3909
|
-
return (await e.delete(
|
|
3978
|
+
return (await e.delete(Qe).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))).returning()).length > 0;
|
|
3910
3979
|
}
|
|
3911
3980
|
};
|
|
3912
3981
|
}
|
|
3913
3982
|
//#endregion
|
|
3914
3983
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3915
|
-
function
|
|
3984
|
+
function zr(e) {
|
|
3916
3985
|
return {
|
|
3917
3986
|
async get(t) {
|
|
3918
|
-
let n = await e.select({ body:
|
|
3987
|
+
let n = await e.select({ body: Ze.body }).from(Ze).where(a(Ze.tenant_id, t)).get();
|
|
3919
3988
|
return n ? { body: n.body } : null;
|
|
3920
3989
|
},
|
|
3921
3990
|
async set(t, n) {
|
|
3922
3991
|
let r = Date.now();
|
|
3923
|
-
await e.insert(
|
|
3992
|
+
await e.insert(Ze).values({
|
|
3924
3993
|
tenant_id: t,
|
|
3925
3994
|
body: n.body,
|
|
3926
3995
|
created_at_ts: r,
|
|
3927
3996
|
updated_at_ts: r
|
|
3928
3997
|
}).onConflictDoUpdate({
|
|
3929
|
-
target:
|
|
3998
|
+
target: Ze.tenant_id,
|
|
3930
3999
|
set: {
|
|
3931
4000
|
body: n.body,
|
|
3932
4001
|
updated_at_ts: r
|
|
@@ -3934,20 +4003,20 @@ function Mr(e) {
|
|
|
3934
4003
|
});
|
|
3935
4004
|
},
|
|
3936
4005
|
async delete(t) {
|
|
3937
|
-
await e.delete(
|
|
4006
|
+
await e.delete(Ze).where(a(Ze.tenant_id, t));
|
|
3938
4007
|
}
|
|
3939
4008
|
};
|
|
3940
4009
|
}
|
|
3941
4010
|
//#endregion
|
|
3942
4011
|
//#region src/adapters/userActivity.ts
|
|
3943
|
-
function
|
|
4012
|
+
function Br(e) {
|
|
3944
4013
|
let t = {};
|
|
3945
4014
|
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;
|
|
3946
4015
|
}
|
|
3947
|
-
function
|
|
4016
|
+
function Vr(e) {
|
|
3948
4017
|
return {
|
|
3949
4018
|
async get(n, r) {
|
|
3950
|
-
let i = await e.select().from(
|
|
4019
|
+
let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.user_id, r))).get();
|
|
3951
4020
|
return i ? {
|
|
3952
4021
|
user_id: i.user_id,
|
|
3953
4022
|
last_login: i.last_login ?? void 0,
|
|
@@ -3958,7 +4027,7 @@ function Pr(e) {
|
|
|
3958
4027
|
} : null;
|
|
3959
4028
|
},
|
|
3960
4029
|
async upsert(t, n, r) {
|
|
3961
|
-
let i =
|
|
4030
|
+
let i = Br(r), a = e.insert(He).values({
|
|
3962
4031
|
tenant_id: t,
|
|
3963
4032
|
user_id: n,
|
|
3964
4033
|
login_count: 0,
|
|
@@ -3969,7 +4038,7 @@ function Pr(e) {
|
|
|
3969
4038
|
return;
|
|
3970
4039
|
}
|
|
3971
4040
|
await a.onConflictDoUpdate({
|
|
3972
|
-
target: [
|
|
4041
|
+
target: [He.tenant_id, He.user_id],
|
|
3973
4042
|
set: i
|
|
3974
4043
|
});
|
|
3975
4044
|
}
|
|
@@ -3977,13 +4046,13 @@ function Pr(e) {
|
|
|
3977
4046
|
}
|
|
3978
4047
|
//#endregion
|
|
3979
4048
|
//#region src/adapters/outbox.ts
|
|
3980
|
-
function
|
|
4049
|
+
function Hr(e) {
|
|
3981
4050
|
return {
|
|
3982
4051
|
...e,
|
|
3983
4052
|
payload: Z(e.payload, {})
|
|
3984
4053
|
};
|
|
3985
4054
|
}
|
|
3986
|
-
function
|
|
4055
|
+
function Ur(e, t, n, r) {
|
|
3987
4056
|
return e.insert(J).values({
|
|
3988
4057
|
id: t,
|
|
3989
4058
|
tenant_id: n,
|
|
@@ -4004,18 +4073,18 @@ function Ir(e, t, n, r) {
|
|
|
4004
4073
|
claim_expires_at: null
|
|
4005
4074
|
});
|
|
4006
4075
|
}
|
|
4007
|
-
function
|
|
4076
|
+
function Wr(e) {
|
|
4008
4077
|
return {
|
|
4009
4078
|
async create(t, n) {
|
|
4010
4079
|
let r = b();
|
|
4011
|
-
return await
|
|
4080
|
+
return await Ur(e, r, t, n), r;
|
|
4012
4081
|
},
|
|
4013
4082
|
async getByIds(t) {
|
|
4014
|
-
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(
|
|
4083
|
+
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(Hr);
|
|
4015
4084
|
},
|
|
4016
4085
|
async getUnprocessed(n) {
|
|
4017
4086
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4018
|
-
return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(
|
|
4087
|
+
return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(Hr);
|
|
4019
4088
|
},
|
|
4020
4089
|
async claimEvents(n, r, i) {
|
|
4021
4090
|
if (n.length === 0) return [];
|
|
@@ -4087,10 +4156,10 @@ function Lr(e) {
|
|
|
4087
4156
|
}
|
|
4088
4157
|
//#endregion
|
|
4089
4158
|
//#region src/adapters/users.ts
|
|
4090
|
-
function
|
|
4091
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4159
|
+
function Gr(e, t, n) {
|
|
4160
|
+
return (n?.outboxEvents ?? []).map((n) => Ur(e, n.id, t, n));
|
|
4092
4161
|
}
|
|
4093
|
-
var
|
|
4162
|
+
var Kr = [
|
|
4094
4163
|
"user_id",
|
|
4095
4164
|
"email",
|
|
4096
4165
|
"email_verified",
|
|
@@ -4112,23 +4181,23 @@ var zr = [
|
|
|
4112
4181
|
"login_count",
|
|
4113
4182
|
"created_at",
|
|
4114
4183
|
"updated_at"
|
|
4115
|
-
],
|
|
4184
|
+
], qr = [
|
|
4116
4185
|
"email",
|
|
4117
4186
|
"name",
|
|
4118
4187
|
"phone_number",
|
|
4119
4188
|
"user_id"
|
|
4120
|
-
],
|
|
4189
|
+
], Jr = new Set([
|
|
4121
4190
|
"last_login",
|
|
4122
4191
|
"last_ip",
|
|
4123
4192
|
"login_count"
|
|
4124
|
-
]),
|
|
4125
|
-
coalesce:
|
|
4193
|
+
]), Yr = o(A), Xr = o(He), Zr = Object.fromEntries(Kr.map((e) => [e, e === "login_count" ? {
|
|
4194
|
+
coalesce: He.login_count,
|
|
4126
4195
|
defaultValue: 0
|
|
4127
|
-
} :
|
|
4128
|
-
function
|
|
4129
|
-
return t(a(
|
|
4196
|
+
} : Jr.has(e) ? Xr[e] : Yr[e]]));
|
|
4197
|
+
function Qr() {
|
|
4198
|
+
return t(a(He.tenant_id, A.tenant_id), a(He.user_id, A.user_id));
|
|
4130
4199
|
}
|
|
4131
|
-
function
|
|
4200
|
+
function $r(e, t) {
|
|
4132
4201
|
return {
|
|
4133
4202
|
...e,
|
|
4134
4203
|
last_login: t?.last_login,
|
|
@@ -4136,11 +4205,11 @@ function Kr(e, t) {
|
|
|
4136
4205
|
login_count: t?.login_count ?? 0
|
|
4137
4206
|
};
|
|
4138
4207
|
}
|
|
4139
|
-
function
|
|
4208
|
+
function ei(e, t) {
|
|
4140
4209
|
let n = {
|
|
4141
4210
|
connection: e.connection,
|
|
4142
4211
|
provider: e.provider,
|
|
4143
|
-
user_id:
|
|
4212
|
+
user_id: Se(e.user_id).id,
|
|
4144
4213
|
isSocial: !!e.is_social
|
|
4145
4214
|
};
|
|
4146
4215
|
return t ? n.isPrimary = !0 : n.profileData = {
|
|
@@ -4149,8 +4218,8 @@ function qr(e, t) {
|
|
|
4149
4218
|
...typeof e.profileData == "string" ? Z(e.profileData, {}) : {}
|
|
4150
4219
|
}, n;
|
|
4151
4220
|
}
|
|
4152
|
-
function
|
|
4153
|
-
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 =
|
|
4221
|
+
function ti(e, t = []) {
|
|
4222
|
+
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 = ei(e, !0), m = t.map((e) => ei(e, !1));
|
|
4154
4223
|
return D({
|
|
4155
4224
|
...f,
|
|
4156
4225
|
email: e.email || "",
|
|
@@ -4164,7 +4233,7 @@ function Jr(e, t = []) {
|
|
|
4164
4233
|
identities: [p, ...m]
|
|
4165
4234
|
});
|
|
4166
4235
|
}
|
|
4167
|
-
function
|
|
4236
|
+
function ni(e) {
|
|
4168
4237
|
let o = async (t, n, r) => {
|
|
4169
4238
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4170
4239
|
user_id: n.user_id,
|
|
@@ -4202,7 +4271,7 @@ function Yr(e) {
|
|
|
4202
4271
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4203
4272
|
try {
|
|
4204
4273
|
let c = [e.insert(A).values(a)];
|
|
4205
|
-
s && c.push(e.insert(
|
|
4274
|
+
s && c.push(e.insert(He).values({
|
|
4206
4275
|
tenant_id: t,
|
|
4207
4276
|
user_id: n.user_id,
|
|
4208
4277
|
last_login: n.last_login,
|
|
@@ -4218,12 +4287,12 @@ function Yr(e) {
|
|
|
4218
4287
|
created_at: i,
|
|
4219
4288
|
updated_at: i
|
|
4220
4289
|
}));
|
|
4221
|
-
for (let n of
|
|
4222
|
-
c.length > 1 ? await
|
|
4290
|
+
for (let n of Gr(e, t, r)) c.push(n);
|
|
4291
|
+
c.length > 1 ? await wt(e, c) : await e.insert(A).values(a);
|
|
4223
4292
|
} catch (e) {
|
|
4224
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4293
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Le(500, { message: "Internal server error" }));
|
|
4225
4294
|
}
|
|
4226
|
-
return
|
|
4295
|
+
return ti({
|
|
4227
4296
|
...a,
|
|
4228
4297
|
last_login: n.last_login,
|
|
4229
4298
|
last_ip: n.last_ip,
|
|
@@ -4234,10 +4303,10 @@ function Yr(e) {
|
|
|
4234
4303
|
create: o,
|
|
4235
4304
|
rawCreate: o,
|
|
4236
4305
|
async get(n, r) {
|
|
4237
|
-
let i = await e.select().from(A).leftJoin(
|
|
4306
|
+
let i = await e.select().from(A).leftJoin(He, Qr()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4238
4307
|
if (!i) return null;
|
|
4239
4308
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4240
|
-
return
|
|
4309
|
+
return ti($r(i.users, i.user_activity), o);
|
|
4241
4310
|
},
|
|
4242
4311
|
async update(n, r, i, o) {
|
|
4243
4312
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4264,8 +4333,8 @@ function Yr(e) {
|
|
|
4264
4333
|
"zoneinfo"
|
|
4265
4334
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4266
4335
|
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));
|
|
4267
|
-
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l =
|
|
4268
|
-
return u = l.length > 0 ? (await
|
|
4336
|
+
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = Gr(e, n, o), u;
|
|
4337
|
+
return u = l.length > 0 ? (await wt(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 Vr(e).upsert(n, r, {
|
|
4269
4338
|
last_login: i.last_login,
|
|
4270
4339
|
last_ip: i.last_ip,
|
|
4271
4340
|
login_count: i.login_count
|
|
@@ -4274,24 +4343,24 @@ function Yr(e) {
|
|
|
4274
4343
|
async list(o, s) {
|
|
4275
4344
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(A.tenant_id, o), f(A.linked_to)];
|
|
4276
4345
|
if (m) {
|
|
4277
|
-
let e =
|
|
4346
|
+
let e = Te(m, Kr);
|
|
4278
4347
|
if (e) {
|
|
4279
|
-
let t =
|
|
4348
|
+
let t = _t(Zr, e, qr);
|
|
4280
4349
|
t && h.push(t);
|
|
4281
4350
|
}
|
|
4282
4351
|
}
|
|
4283
4352
|
let g = t(...h), _ = async (n) => {
|
|
4284
4353
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(A).where(t(a(A.tenant_id, o), l(A.linked_to, r))) : [];
|
|
4285
|
-
return n.map((e) =>
|
|
4354
|
+
return n.map((e) => ti(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4286
4355
|
};
|
|
4287
|
-
if (
|
|
4288
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4356
|
+
if (kt(s)) {
|
|
4357
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Le(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4289
4358
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4290
4359
|
sortColumn: A.created_at,
|
|
4291
4360
|
idColumn: A.user_id,
|
|
4292
4361
|
sortOrder: n,
|
|
4293
4362
|
sortKey: `created_at:${n}`
|
|
4294
|
-
}, i =
|
|
4363
|
+
}, i = At(s), a = Mt(s, r), { rows: o, next: c } = Nt((await e.select().from(A).leftJoin(He, Qr()).where(a ? t(g, a) : g).orderBy(...jt(r)).limit(i + 1)).map((e) => $r(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4295
4364
|
return {
|
|
4296
4365
|
users: l,
|
|
4297
4366
|
start: 0,
|
|
@@ -4300,15 +4369,15 @@ function Yr(e) {
|
|
|
4300
4369
|
next: c
|
|
4301
4370
|
};
|
|
4302
4371
|
}
|
|
4303
|
-
let v = e.select().from(A).leftJoin(
|
|
4372
|
+
let v = e.select().from(A).leftJoin(He, Qr()).where(g).$dynamic();
|
|
4304
4373
|
if (p?.sort_by) {
|
|
4305
|
-
let e =
|
|
4374
|
+
let e = Zr[p.sort_by];
|
|
4306
4375
|
if (e) {
|
|
4307
|
-
let t =
|
|
4376
|
+
let t = ht(e) ? gt(e) : e;
|
|
4308
4377
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4309
4378
|
}
|
|
4310
4379
|
}
|
|
4311
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(
|
|
4380
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(He, Qr()).where(g) : void 0]), b = await _(y.map((e) => $r(e.users, e.user_activity)));
|
|
4312
4381
|
if (!ee) return { users: b };
|
|
4313
4382
|
let [te] = ee;
|
|
4314
4383
|
return {
|
|
@@ -4320,14 +4389,14 @@ function Yr(e) {
|
|
|
4320
4389
|
},
|
|
4321
4390
|
async remove(n, r, i) {
|
|
4322
4391
|
let o = await e.select({ user_id: A.user_id }).from(A).where(t(a(A.tenant_id, n), v(a(A.user_id, r), a(A.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
|
|
4323
|
-
e.delete(
|
|
4392
|
+
e.delete(ct).where(t(a(ct.tenant_id, n), l(ct.user_id, u))),
|
|
4324
4393
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4325
|
-
e.delete(
|
|
4394
|
+
e.delete(He).where(t(a(He.tenant_id, n), l(He.user_id, u))),
|
|
4326
4395
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4327
4396
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4328
4397
|
], f = d.length - 1;
|
|
4329
|
-
if (s) for (let t of
|
|
4330
|
-
let p = (await
|
|
4398
|
+
if (s) for (let t of Gr(e, n, i)) d.push(t);
|
|
4399
|
+
let p = (await wt(e, d))[f];
|
|
4331
4400
|
return Array.isArray(p) && p.length > 0;
|
|
4332
4401
|
},
|
|
4333
4402
|
async unlink(n, r, i, o) {
|
|
@@ -4338,7 +4407,7 @@ function Yr(e) {
|
|
|
4338
4407
|
}
|
|
4339
4408
|
//#endregion
|
|
4340
4409
|
//#region src/adapters/userRoles.ts
|
|
4341
|
-
function
|
|
4410
|
+
function ri(e) {
|
|
4342
4411
|
return {
|
|
4343
4412
|
async create(t, n, r, i) {
|
|
4344
4413
|
try {
|
|
@@ -4372,12 +4441,12 @@ function Xr(e) {
|
|
|
4372
4441
|
},
|
|
4373
4442
|
async listUsers(r, i, o) {
|
|
4374
4443
|
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4375
|
-
if (
|
|
4444
|
+
if (kt(o)) {
|
|
4376
4445
|
let n = {
|
|
4377
4446
|
sortColumn: G.user_id,
|
|
4378
4447
|
idColumn: G.user_id,
|
|
4379
4448
|
sortOrder: "asc"
|
|
4380
|
-
}, r =
|
|
4449
|
+
}, r = Mt(o, n), i = At(o), { rows: a, next: c } = Nt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...jt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4381
4450
|
return {
|
|
4382
4451
|
userIds: a.map((e) => e.user_id),
|
|
4383
4452
|
start: 0,
|
|
@@ -4401,7 +4470,7 @@ function Xr(e) {
|
|
|
4401
4470
|
}
|
|
4402
4471
|
//#endregion
|
|
4403
4472
|
//#region src/adapters/userOrganizations.ts
|
|
4404
|
-
function
|
|
4473
|
+
function ii(e) {
|
|
4405
4474
|
return {
|
|
4406
4475
|
async create(t, n) {
|
|
4407
4476
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4415,7 +4484,7 @@ function Zr(e) {
|
|
|
4415
4484
|
try {
|
|
4416
4485
|
await e.insert(U).values(i);
|
|
4417
4486
|
} catch (e) {
|
|
4418
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4487
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Le(409, { message: "User organization already exists" }) : e;
|
|
4419
4488
|
}
|
|
4420
4489
|
let { tenant_id: a, ...o } = i;
|
|
4421
4490
|
return o;
|
|
@@ -4433,19 +4502,19 @@ function Zr(e) {
|
|
|
4433
4502
|
async list(n, o) {
|
|
4434
4503
|
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4435
4504
|
if (c) {
|
|
4436
|
-
let e =
|
|
4505
|
+
let e = _t(U, c, ["user_id", "organization_id"]);
|
|
4437
4506
|
e && (u = t(l, e));
|
|
4438
4507
|
}
|
|
4439
4508
|
let d = (e) => {
|
|
4440
4509
|
let { tenant_id: t, ...n } = e;
|
|
4441
4510
|
return n;
|
|
4442
4511
|
};
|
|
4443
|
-
if (
|
|
4512
|
+
if (kt(o)) {
|
|
4444
4513
|
let n = {
|
|
4445
4514
|
sortColumn: U.created_at,
|
|
4446
4515
|
idColumn: U.id,
|
|
4447
4516
|
sortOrder: "desc"
|
|
4448
|
-
}, r =
|
|
4517
|
+
}, r = Mt(o, n), i = At(o), { rows: a, next: s } = Nt((await e.select().from(U).where(r ? t(u, r) : u).orderBy(...jt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4449
4518
|
return {
|
|
4450
4519
|
userOrganizations: a,
|
|
4451
4520
|
start: 0,
|
|
@@ -4493,19 +4562,19 @@ function Zr(e) {
|
|
|
4493
4562
|
}
|
|
4494
4563
|
//#endregion
|
|
4495
4564
|
//#region src/adapters/stats.ts
|
|
4496
|
-
var
|
|
4497
|
-
function
|
|
4565
|
+
var ai = ["s"], oi = ["pwd_leak"];
|
|
4566
|
+
function si(e) {
|
|
4498
4567
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4499
4568
|
}
|
|
4500
|
-
function
|
|
4569
|
+
function ci(e) {
|
|
4501
4570
|
return {
|
|
4502
4571
|
async getDaily(n, r) {
|
|
4503
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4572
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? si(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? si(r.to) : i.toISOString().split("T")[0];
|
|
4504
4573
|
return (await e.select({
|
|
4505
4574
|
date: y`substr(${q.date}, 1, 10)`.as("date"),
|
|
4506
|
-
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4575
|
+
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(ai.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4507
4576
|
signups: y`SUM(CASE WHEN ${q.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4508
|
-
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4577
|
+
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(oi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4509
4578
|
}).from(q).where(t(a(q.tenant_id, n), c(q.date, o), h(q.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${q.date}, 1, 10)`).orderBy(y`substr(${q.date}, 1, 10)`).all()).map((e) => ({
|
|
4510
4579
|
date: e.date,
|
|
4511
4580
|
logins: Number(e.logins) || 0,
|
|
@@ -4516,14 +4585,14 @@ function ti(e) {
|
|
|
4516
4585
|
}));
|
|
4517
4586
|
},
|
|
4518
4587
|
async getActiveUsers(n) {
|
|
4519
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(
|
|
4588
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(ai.map((e) => y`${e}`), y`, `)})`));
|
|
4520
4589
|
return Number(i?.count) || 0;
|
|
4521
4590
|
}
|
|
4522
4591
|
};
|
|
4523
4592
|
}
|
|
4524
4593
|
//#endregion
|
|
4525
4594
|
//#region src/adapters/analytics.ts
|
|
4526
|
-
var
|
|
4595
|
+
var li = {
|
|
4527
4596
|
"active-users": ["s", "seacft"],
|
|
4528
4597
|
logins: [
|
|
4529
4598
|
"s",
|
|
@@ -4553,7 +4622,7 @@ var ni = {
|
|
|
4553
4622
|
"fvr"
|
|
4554
4623
|
],
|
|
4555
4624
|
"codes-sent": ["cls", "cs"]
|
|
4556
|
-
},
|
|
4625
|
+
}, ui = {
|
|
4557
4626
|
"active-users": {
|
|
4558
4627
|
alias: "active_users",
|
|
4559
4628
|
type: "UInt64",
|
|
@@ -4610,7 +4679,7 @@ var ni = {
|
|
|
4610
4679
|
agg: "count"
|
|
4611
4680
|
}
|
|
4612
4681
|
};
|
|
4613
|
-
function
|
|
4682
|
+
function di(e) {
|
|
4614
4683
|
switch (e) {
|
|
4615
4684
|
case "hour": return y`substr(${q.date}, 1, 13)`;
|
|
4616
4685
|
case "month": return y`substr(${q.date}, 1, 7)`;
|
|
@@ -4619,10 +4688,10 @@ function ii(e) {
|
|
|
4619
4688
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4620
4689
|
}
|
|
4621
4690
|
}
|
|
4622
|
-
function
|
|
4691
|
+
function fi(e) {
|
|
4623
4692
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4624
4693
|
}
|
|
4625
|
-
function
|
|
4694
|
+
function pi(e) {
|
|
4626
4695
|
switch (e) {
|
|
4627
4696
|
case "connection": return q.connection;
|
|
4628
4697
|
case "client_id": return q.client_id;
|
|
@@ -4631,10 +4700,10 @@ function oi(e) {
|
|
|
4631
4700
|
case "time": throw Error("time dimension handled separately");
|
|
4632
4701
|
}
|
|
4633
4702
|
}
|
|
4634
|
-
function
|
|
4703
|
+
function mi(e) {
|
|
4635
4704
|
return {
|
|
4636
4705
|
async query(n, r, i) {
|
|
4637
|
-
let o = Date.now(), s =
|
|
4706
|
+
let o = Date.now(), s = li[r], u = ui[r], d = [
|
|
4638
4707
|
a(q.tenant_id, n),
|
|
4639
4708
|
c(q.date, i.from),
|
|
4640
4709
|
m(q.date, i.to),
|
|
@@ -4643,13 +4712,13 @@ function si(e) {
|
|
|
4643
4712
|
i.filters.connection?.length && d.push(l(q.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(q.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(q.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(q.user_id, i.filters.user_id));
|
|
4644
4713
|
let f = {}, p = [], h = [];
|
|
4645
4714
|
for (let e of i.group_by) if (e === "time") {
|
|
4646
|
-
let e =
|
|
4715
|
+
let e = di(i.interval);
|
|
4647
4716
|
f.time = e, p.push(e), h.push({
|
|
4648
4717
|
name: "time",
|
|
4649
4718
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4650
4719
|
});
|
|
4651
4720
|
} else {
|
|
4652
|
-
let t =
|
|
4721
|
+
let t = pi(e);
|
|
4653
4722
|
f[e] = t, p.push(t), h.push({
|
|
4654
4723
|
name: e,
|
|
4655
4724
|
type: "String"
|
|
@@ -4665,9 +4734,9 @@ function si(e) {
|
|
|
4665
4734
|
if (i.order_by) {
|
|
4666
4735
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4667
4736
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4668
|
-
let n =
|
|
4737
|
+
let n = fi(t);
|
|
4669
4738
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4670
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4739
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${fi("time")} ASC`)) : g.orderBy(y.raw(`${fi(u.alias)} DESC`));
|
|
4671
4740
|
g = g.limit(i.limit).offset(i.offset);
|
|
4672
4741
|
let v = (await g.all()).map((e) => {
|
|
4673
4742
|
let t = {};
|
|
@@ -4686,8 +4755,8 @@ function si(e) {
|
|
|
4686
4755
|
};
|
|
4687
4756
|
},
|
|
4688
4757
|
async sessionRetention(n, r) {
|
|
4689
|
-
let i = Date.now(), { sinceMs: o } =
|
|
4690
|
-
return
|
|
4758
|
+
let i = Date.now(), { sinceMs: o } = De(r.weeks, i), s = y`(${M.created_at_ts} + ${ue}) / ${fe}`, l = y`(COALESCE(${M.used_at_ts}, ${M.created_at_ts}) + ${ue}) / ${fe}`;
|
|
4759
|
+
return me((await e.select({
|
|
4691
4760
|
created_week: s,
|
|
4692
4761
|
used_week: l,
|
|
4693
4762
|
count: y`COUNT(*)`
|
|
@@ -4698,11 +4767,11 @@ function si(e) {
|
|
|
4698
4767
|
})), r.weeks, i);
|
|
4699
4768
|
},
|
|
4700
4769
|
async refreshTokenRetention(n, r) {
|
|
4701
|
-
let i = Date.now(), { sinceMs: o } =
|
|
4770
|
+
let i = Date.now(), { sinceMs: o } = De(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(N.client_id, r.client_id) : void 0, u = e.select({
|
|
4702
4771
|
min_created: y`MIN(${N.created_at_ts})`.as("min_created"),
|
|
4703
4772
|
max_used: y`MAX(COALESCE(${N.last_exchanged_at_ts}, ${N.created_at_ts}))`.as("max_used")
|
|
4704
|
-
}).from(N).where(t(a(N.tenant_id, n), s)).groupBy(y`COALESCE(${N.family_id}, ${N.id})`).as("families"), d = y`(${u.min_created} + ${ue}) / ${
|
|
4705
|
-
return
|
|
4773
|
+
}).from(N).where(t(a(N.tenant_id, n), s)).groupBy(y`COALESCE(${N.family_id}, ${N.id})`).as("families"), d = y`(${u.min_created} + ${ue}) / ${fe}`, f = y`(${u.max_used} + ${ue}) / ${fe}`;
|
|
4774
|
+
return pe((await e.select({
|
|
4706
4775
|
created_week: d,
|
|
4707
4776
|
used_week: f,
|
|
4708
4777
|
count: y`COUNT(*)`
|
|
@@ -4716,10 +4785,10 @@ function si(e) {
|
|
|
4716
4785
|
}
|
|
4717
4786
|
//#endregion
|
|
4718
4787
|
//#region src/adapters/cleanup.ts
|
|
4719
|
-
var
|
|
4720
|
-
function
|
|
4788
|
+
var hi = 10080 * 60 * 1e3;
|
|
4789
|
+
function gi(e) {
|
|
4721
4790
|
return async (n) => {
|
|
4722
|
-
let r = Date.now() -
|
|
4791
|
+
let r = Date.now() - hi;
|
|
4723
4792
|
try {
|
|
4724
4793
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
4725
4794
|
n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), await e.delete(N).where(t(...i)), i = [v(m(M.expires_at_ts, r), m(M.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(M.tenant_id, n.tenant_id)), n?.user_id && i.push(a(M.user_id, n.user_id)), await e.delete(M).where(t(...i)), i = [m(P.expires_at_ts, r)], n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i));
|
|
@@ -4754,7 +4823,7 @@ var Q = w("tenant_operations", {
|
|
|
4754
4823
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4755
4824
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4756
4825
|
x("tenant_operations_status_idx").on(e.status)
|
|
4757
|
-
]),
|
|
4826
|
+
]), _i = w("tenant_operation_events", {
|
|
4758
4827
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4759
4828
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4760
4829
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4785,7 +4854,7 @@ var Q = w("tenant_operations", {
|
|
|
4785
4854
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
4786
4855
|
}).onDelete("cascade"),
|
|
4787
4856
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
4788
|
-
]),
|
|
4857
|
+
]), vi = w("rollouts", {
|
|
4789
4858
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4790
4859
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4791
4860
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4801,7 +4870,7 @@ var Q = w("tenant_operations", {
|
|
|
4801
4870
|
});
|
|
4802
4871
|
//#endregion
|
|
4803
4872
|
//#region src/adapters/tenantOperations.ts
|
|
4804
|
-
function
|
|
4873
|
+
function yi(e) {
|
|
4805
4874
|
if (!e) return null;
|
|
4806
4875
|
try {
|
|
4807
4876
|
return JSON.parse(e);
|
|
@@ -4809,8 +4878,8 @@ function fi(e) {
|
|
|
4809
4878
|
return null;
|
|
4810
4879
|
}
|
|
4811
4880
|
}
|
|
4812
|
-
function
|
|
4813
|
-
return
|
|
4881
|
+
function bi(e) {
|
|
4882
|
+
return Pe.parse({
|
|
4814
4883
|
id: e.id,
|
|
4815
4884
|
tenant_id: e.tenant_id,
|
|
4816
4885
|
rollout_id: e.rollout_id,
|
|
@@ -4823,8 +4892,8 @@ function pi(e) {
|
|
|
4823
4892
|
target_database_version: e.target_database_version,
|
|
4824
4893
|
error: e.error,
|
|
4825
4894
|
initiated_by: e.initiated_by,
|
|
4826
|
-
input:
|
|
4827
|
-
result:
|
|
4895
|
+
input: yi(e.input),
|
|
4896
|
+
result: yi(e.result),
|
|
4828
4897
|
claimed_by: e.claimed_by,
|
|
4829
4898
|
claim_expires_at: e.claim_expires_at,
|
|
4830
4899
|
created_at: e.created_at,
|
|
@@ -4832,10 +4901,10 @@ function pi(e) {
|
|
|
4832
4901
|
finished_at: e.finished_at
|
|
4833
4902
|
});
|
|
4834
4903
|
}
|
|
4835
|
-
function
|
|
4904
|
+
function xi(e) {
|
|
4836
4905
|
return {
|
|
4837
4906
|
async create(t) {
|
|
4838
|
-
let n =
|
|
4907
|
+
let n = je.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4839
4908
|
id: `op_${b()}`,
|
|
4840
4909
|
tenant_id: n.tenant_id,
|
|
4841
4910
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4863,7 +4932,7 @@ function mi(e) {
|
|
|
4863
4932
|
},
|
|
4864
4933
|
async get(t) {
|
|
4865
4934
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
4866
|
-
return n[0] ?
|
|
4935
|
+
return n[0] ? bi(n[0]) : null;
|
|
4867
4936
|
},
|
|
4868
4937
|
async list(n = {}) {
|
|
4869
4938
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4874,7 +4943,7 @@ function mi(e) {
|
|
|
4874
4943
|
n.engine !== void 0 && s.push(a(Q.engine, n.engine)), n.updated_before !== void 0 && s.push(m(Q.updated_at, n.updated_before));
|
|
4875
4944
|
let c = await e.select().from(Q).where(s.length ? t(...s) : void 0).orderBy(i(Q.created_at), i(Q.id)).offset(r * o).limit(o);
|
|
4876
4945
|
return {
|
|
4877
|
-
operations: c.map(
|
|
4946
|
+
operations: c.map(bi),
|
|
4878
4947
|
start: r * o,
|
|
4879
4948
|
limit: o,
|
|
4880
4949
|
length: c.length
|
|
@@ -4900,7 +4969,7 @@ function mi(e) {
|
|
|
4900
4969
|
},
|
|
4901
4970
|
async listResumable(r) {
|
|
4902
4971
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
4903
|
-
return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(
|
|
4972
|
+
return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(bi);
|
|
4904
4973
|
},
|
|
4905
4974
|
async remove(t) {
|
|
4906
4975
|
return (await e.select({ id: Q.id }).from(Q).where(a(Q.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Q).where(a(Q.id, t)), !0);
|
|
@@ -4909,19 +4978,19 @@ function mi(e) {
|
|
|
4909
4978
|
}
|
|
4910
4979
|
//#endregion
|
|
4911
4980
|
//#region src/adapters/tenantOperationRows.ts
|
|
4912
|
-
var
|
|
4913
|
-
function
|
|
4981
|
+
var Si = 50, Ci = 50;
|
|
4982
|
+
function wi(e) {
|
|
4914
4983
|
try {
|
|
4915
4984
|
return JSON.parse(e);
|
|
4916
4985
|
} catch {
|
|
4917
4986
|
return {};
|
|
4918
4987
|
}
|
|
4919
4988
|
}
|
|
4920
|
-
function
|
|
4921
|
-
return
|
|
4989
|
+
function Ti(e) {
|
|
4990
|
+
return Ne.parse({
|
|
4922
4991
|
operation_id: e.operation_id,
|
|
4923
4992
|
seq: e.seq,
|
|
4924
|
-
payload:
|
|
4993
|
+
payload: wi(e.payload),
|
|
4925
4994
|
status: e.status,
|
|
4926
4995
|
error_code: e.error_code,
|
|
4927
4996
|
error_message: e.error_message,
|
|
@@ -4931,12 +5000,12 @@ function vi(e) {
|
|
|
4931
5000
|
updated_at: e.updated_at
|
|
4932
5001
|
});
|
|
4933
5002
|
}
|
|
4934
|
-
function
|
|
5003
|
+
function Ei(e, t) {
|
|
4935
5004
|
let n = [];
|
|
4936
5005
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
4937
5006
|
return n;
|
|
4938
5007
|
}
|
|
4939
|
-
function
|
|
5008
|
+
function Di(e, n, r, i) {
|
|
4940
5009
|
return e.update($).set({
|
|
4941
5010
|
status: r.status,
|
|
4942
5011
|
error_code: r.error_code ?? null,
|
|
@@ -4946,12 +5015,12 @@ function bi(e, n, r, i) {
|
|
|
4946
5015
|
updated_at: i
|
|
4947
5016
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
4948
5017
|
}
|
|
4949
|
-
function
|
|
5018
|
+
function Oi(e) {
|
|
4950
5019
|
return {
|
|
4951
5020
|
async createMany(t) {
|
|
4952
5021
|
if (t.length === 0) return 0;
|
|
4953
5022
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.map((e) => {
|
|
4954
|
-
let t =
|
|
5023
|
+
let t = Me.parse(e);
|
|
4955
5024
|
return {
|
|
4956
5025
|
operation_id: t.operation_id,
|
|
4957
5026
|
seq: t.seq,
|
|
@@ -4965,24 +5034,24 @@ function xi(e) {
|
|
|
4965
5034
|
updated_at: n
|
|
4966
5035
|
};
|
|
4967
5036
|
});
|
|
4968
|
-
for (let t of
|
|
5037
|
+
for (let t of Ei(r, Si)) await e.insert($).values(t);
|
|
4969
5038
|
return r.length;
|
|
4970
5039
|
},
|
|
4971
5040
|
async claimPending(r, i) {
|
|
4972
|
-
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(
|
|
5041
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Ti);
|
|
4973
5042
|
},
|
|
4974
5043
|
async recordOutcomes(n, r) {
|
|
4975
5044
|
if (r.length === 0) return 0;
|
|
4976
5045
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
4977
|
-
for (let r of
|
|
5046
|
+
for (let r of Ei(o, Ci)) {
|
|
4978
5047
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
4979
5048
|
for (let e of i) s.add(e.seq);
|
|
4980
5049
|
}
|
|
4981
5050
|
let c = r.filter((e) => s.has(e.seq));
|
|
4982
5051
|
if (c.length === 0) return 0;
|
|
4983
|
-
for (let t of
|
|
4984
|
-
let [r, ...a] = t.map((t) =>
|
|
4985
|
-
r && await
|
|
5052
|
+
for (let t of Ei(c, Ci)) {
|
|
5053
|
+
let [r, ...a] = t.map((t) => Di(e, n, t, i));
|
|
5054
|
+
r && await wt(e, [r, ...a]);
|
|
4986
5055
|
}
|
|
4987
5056
|
return c.length;
|
|
4988
5057
|
},
|
|
@@ -5017,7 +5086,7 @@ function xi(e) {
|
|
|
5017
5086
|
}
|
|
5018
5087
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5019
5088
|
return {
|
|
5020
|
-
rows: u.map(
|
|
5089
|
+
rows: u.map(Ti),
|
|
5021
5090
|
start: o * s,
|
|
5022
5091
|
limit: s,
|
|
5023
5092
|
length: u.length
|
|
@@ -5031,27 +5100,27 @@ function xi(e) {
|
|
|
5031
5100
|
}
|
|
5032
5101
|
//#endregion
|
|
5033
5102
|
//#region src/helpers/monotonic-id.ts
|
|
5034
|
-
var
|
|
5035
|
-
function
|
|
5103
|
+
var ki = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ai = 32, ji = 10, Mi = 4, Ni = 10;
|
|
5104
|
+
function Pi(e, t) {
|
|
5036
5105
|
let n = "";
|
|
5037
|
-
for (let r = t; r > 0; r--) n =
|
|
5106
|
+
for (let r = t; r > 0; r--) n = ki.charAt(e % Ai) + n, e = Math.floor(e / Ai);
|
|
5038
5107
|
return n;
|
|
5039
5108
|
}
|
|
5040
|
-
function
|
|
5041
|
-
let e = new Uint8Array(
|
|
5109
|
+
function Fi() {
|
|
5110
|
+
let e = new Uint8Array(Ni);
|
|
5042
5111
|
crypto.getRandomValues(e);
|
|
5043
5112
|
let t = "";
|
|
5044
|
-
for (let n = 0; n <
|
|
5113
|
+
for (let n = 0; n < Ni; n++) t += ki.charAt(e[n] % Ai);
|
|
5045
5114
|
return t;
|
|
5046
5115
|
}
|
|
5047
|
-
var
|
|
5048
|
-
function
|
|
5116
|
+
var Ii = 0, Li = 0;
|
|
5117
|
+
function Ri() {
|
|
5049
5118
|
let e = Date.now();
|
|
5050
|
-
return e ===
|
|
5119
|
+
return e === Ii ? Li++ : (Ii = e, Li = 0), Pi(e, ji) + Pi(Li, Mi) + Fi();
|
|
5051
5120
|
}
|
|
5052
5121
|
//#endregion
|
|
5053
5122
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5054
|
-
function
|
|
5123
|
+
function zi(e) {
|
|
5055
5124
|
if (!e) return null;
|
|
5056
5125
|
try {
|
|
5057
5126
|
let t = JSON.parse(e);
|
|
@@ -5059,22 +5128,22 @@ function Mi(e) {
|
|
|
5059
5128
|
} catch {}
|
|
5060
5129
|
return null;
|
|
5061
5130
|
}
|
|
5062
|
-
function
|
|
5063
|
-
return
|
|
5131
|
+
function Bi(e) {
|
|
5132
|
+
return Ae.parse({
|
|
5064
5133
|
id: e.id,
|
|
5065
5134
|
operation_id: e.operation_id,
|
|
5066
5135
|
step: e.step,
|
|
5067
5136
|
outcome: e.outcome,
|
|
5068
|
-
detail:
|
|
5137
|
+
detail: zi(e.detail),
|
|
5069
5138
|
attempt: e.attempt,
|
|
5070
5139
|
created_at: e.created_at
|
|
5071
5140
|
});
|
|
5072
5141
|
}
|
|
5073
|
-
function
|
|
5142
|
+
function Vi(e) {
|
|
5074
5143
|
return {
|
|
5075
5144
|
async create(t) {
|
|
5076
|
-
let n =
|
|
5077
|
-
id: `evt_${
|
|
5145
|
+
let n = ke.parse(t), r = {
|
|
5146
|
+
id: `evt_${Ri()}`,
|
|
5078
5147
|
operation_id: n.operation_id,
|
|
5079
5148
|
step: n.step,
|
|
5080
5149
|
outcome: n.outcome,
|
|
@@ -5082,7 +5151,7 @@ function Pi(e) {
|
|
|
5082
5151
|
attempt: n.attempt,
|
|
5083
5152
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5084
5153
|
};
|
|
5085
|
-
return await e.insert(
|
|
5154
|
+
return await e.insert(_i).values(r), Ae.parse({
|
|
5086
5155
|
id: r.id,
|
|
5087
5156
|
operation_id: r.operation_id,
|
|
5088
5157
|
step: r.step,
|
|
@@ -5093,9 +5162,9 @@ function Pi(e) {
|
|
|
5093
5162
|
});
|
|
5094
5163
|
},
|
|
5095
5164
|
async listByOperation(t, r = {}) {
|
|
5096
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5165
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(_i).where(a(_i.operation_id, t)).orderBy(n(_i.created_at), n(_i.id)).offset(i * o).limit(o);
|
|
5097
5166
|
return {
|
|
5098
|
-
events: s.map(
|
|
5167
|
+
events: s.map(Bi),
|
|
5099
5168
|
start: i * o,
|
|
5100
5169
|
limit: o,
|
|
5101
5170
|
length: s.length
|
|
@@ -5105,7 +5174,7 @@ function Pi(e) {
|
|
|
5105
5174
|
}
|
|
5106
5175
|
//#endregion
|
|
5107
5176
|
//#region src/adapters/rollouts.ts
|
|
5108
|
-
function
|
|
5177
|
+
function Hi(e) {
|
|
5109
5178
|
if (!e) return null;
|
|
5110
5179
|
try {
|
|
5111
5180
|
return JSON.parse(e);
|
|
@@ -5113,26 +5182,26 @@ function Fi(e) {
|
|
|
5113
5182
|
return null;
|
|
5114
5183
|
}
|
|
5115
5184
|
}
|
|
5116
|
-
function
|
|
5117
|
-
return
|
|
5185
|
+
function Ui(e) {
|
|
5186
|
+
return we.parse({
|
|
5118
5187
|
id: e.id,
|
|
5119
5188
|
kind: e.kind,
|
|
5120
5189
|
status: e.status,
|
|
5121
5190
|
target_worker_version: e.target_worker_version,
|
|
5122
5191
|
target_database_version: e.target_database_version,
|
|
5123
5192
|
wave_size: e.wave_size,
|
|
5124
|
-
canary_tenant_ids:
|
|
5125
|
-
filter:
|
|
5193
|
+
canary_tenant_ids: Hi(e.canary_tenant_ids),
|
|
5194
|
+
filter: Hi(e.filter),
|
|
5126
5195
|
initiated_by: e.initiated_by,
|
|
5127
5196
|
created_at: e.created_at,
|
|
5128
5197
|
updated_at: e.updated_at,
|
|
5129
5198
|
finished_at: e.finished_at
|
|
5130
5199
|
});
|
|
5131
5200
|
}
|
|
5132
|
-
function
|
|
5201
|
+
function Wi(e) {
|
|
5133
5202
|
return {
|
|
5134
5203
|
async create(t) {
|
|
5135
|
-
let n =
|
|
5204
|
+
let n = Ce.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
5136
5205
|
id: `rol_${b()}`,
|
|
5137
5206
|
kind: n.kind,
|
|
5138
5207
|
status: "pending",
|
|
@@ -5146,94 +5215,95 @@ function Li(e) {
|
|
|
5146
5215
|
updated_at: r,
|
|
5147
5216
|
finished_at: null
|
|
5148
5217
|
};
|
|
5149
|
-
await e.insert(
|
|
5218
|
+
await e.insert(vi).values(i);
|
|
5150
5219
|
let a = await this.get(i.id);
|
|
5151
5220
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5152
5221
|
return a;
|
|
5153
5222
|
},
|
|
5154
5223
|
async get(t) {
|
|
5155
|
-
let n = await e.select().from(
|
|
5156
|
-
return n[0] ?
|
|
5224
|
+
let n = await e.select().from(vi).where(a(vi.id, t)).limit(1);
|
|
5225
|
+
return n[0] ? Ui(n[0]) : null;
|
|
5157
5226
|
},
|
|
5158
5227
|
async list(t = {}) {
|
|
5159
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5228
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(vi).orderBy(i(vi.created_at), i(vi.id)).offset(n * r).limit(r);
|
|
5160
5229
|
return {
|
|
5161
|
-
rollouts: a.map(
|
|
5230
|
+
rollouts: a.map(Ui),
|
|
5162
5231
|
start: n * r,
|
|
5163
5232
|
limit: r,
|
|
5164
5233
|
length: a.length
|
|
5165
5234
|
};
|
|
5166
5235
|
},
|
|
5167
5236
|
async update(t, n) {
|
|
5168
|
-
if ((await e.select({ id:
|
|
5237
|
+
if ((await e.select({ id: vi.id }).from(vi).where(a(vi.id, t)).limit(1)).length === 0) return !1;
|
|
5169
5238
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5170
|
-
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(
|
|
5239
|
+
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(vi).set(r).where(a(vi.id, t)), !0;
|
|
5171
5240
|
},
|
|
5172
5241
|
async remove(t) {
|
|
5173
|
-
return (await e.select({ id:
|
|
5242
|
+
return (await e.select({ id: vi.id }).from(vi).where(a(vi.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(vi).where(a(vi.id, t)), !0);
|
|
5174
5243
|
}
|
|
5175
5244
|
};
|
|
5176
5245
|
}
|
|
5177
5246
|
//#endregion
|
|
5178
5247
|
//#region src/adapters/index.ts
|
|
5179
|
-
function
|
|
5248
|
+
function Gi(e, t = { useTransactions: !0 }) {
|
|
5180
5249
|
let n = {
|
|
5181
|
-
actions:
|
|
5182
|
-
actionExecutions:
|
|
5183
|
-
actionVersions:
|
|
5184
|
-
branding:
|
|
5185
|
-
clients:
|
|
5186
|
-
clientConnections:
|
|
5187
|
-
clientGrants:
|
|
5188
|
-
clientRegistrationTokens:
|
|
5189
|
-
codes:
|
|
5190
|
-
connections:
|
|
5191
|
-
customDomains:
|
|
5192
|
-
customText:
|
|
5193
|
-
emailProviders:
|
|
5194
|
-
emailTemplates:
|
|
5195
|
-
flows:
|
|
5196
|
-
forms:
|
|
5197
|
-
grants:
|
|
5198
|
-
hookCode:
|
|
5199
|
-
hooks:
|
|
5200
|
-
invites:
|
|
5201
|
-
keys:
|
|
5202
|
-
loginSessions:
|
|
5203
|
-
logs:
|
|
5204
|
-
authenticationMethods:
|
|
5205
|
-
organizations:
|
|
5206
|
-
passwords:
|
|
5207
|
-
promptSettings:
|
|
5208
|
-
proxyRoutes:
|
|
5209
|
-
scimConfigurations:
|
|
5210
|
-
scimTokens:
|
|
5211
|
-
scimExternalIds:
|
|
5212
|
-
refreshTokens:
|
|
5213
|
-
resourceServers:
|
|
5214
|
-
rolePermissions:
|
|
5215
|
-
userPermissions:
|
|
5216
|
-
roles:
|
|
5217
|
-
sessions:
|
|
5218
|
-
sessionCleanup:
|
|
5219
|
-
tenants:
|
|
5250
|
+
actions: bt(e),
|
|
5251
|
+
actionExecutions: St(e),
|
|
5252
|
+
actionVersions: Et(e),
|
|
5253
|
+
branding: Ot(e),
|
|
5254
|
+
clients: zt(e),
|
|
5255
|
+
clientConnections: Vt(e),
|
|
5256
|
+
clientGrants: Ut(e),
|
|
5257
|
+
clientRegistrationTokens: Jt(e),
|
|
5258
|
+
codes: Qt(e),
|
|
5259
|
+
connections: tn(e),
|
|
5260
|
+
customDomains: rn(e),
|
|
5261
|
+
customText: an(e),
|
|
5262
|
+
emailProviders: on(e),
|
|
5263
|
+
emailTemplates: cn(e),
|
|
5264
|
+
flows: un(e),
|
|
5265
|
+
forms: pn(e),
|
|
5266
|
+
grants: _n(e),
|
|
5267
|
+
hookCode: xn(e),
|
|
5268
|
+
hooks: Tn(e),
|
|
5269
|
+
invites: kn(e),
|
|
5270
|
+
keys: jn(e),
|
|
5271
|
+
loginSessions: In(e),
|
|
5272
|
+
logs: Rn(e),
|
|
5273
|
+
authenticationMethods: Un(e),
|
|
5274
|
+
organizations: qn(e),
|
|
5275
|
+
passwords: Yn(e),
|
|
5276
|
+
promptSettings: Xn(e),
|
|
5277
|
+
proxyRoutes: er(e),
|
|
5278
|
+
scimConfigurations: cr(e),
|
|
5279
|
+
scimTokens: ur(e),
|
|
5280
|
+
scimExternalIds: fr(e),
|
|
5281
|
+
refreshTokens: hr(e),
|
|
5282
|
+
resourceServers: xr(e),
|
|
5283
|
+
rolePermissions: Sr(e),
|
|
5284
|
+
userPermissions: Cr(e),
|
|
5285
|
+
roles: Tr(e),
|
|
5286
|
+
sessions: Ar(e),
|
|
5287
|
+
sessionCleanup: gi(e),
|
|
5288
|
+
tenants: Fr(e),
|
|
5289
|
+
tokenExchangeProfiles: ir(e),
|
|
5220
5290
|
...t.controlPlane ? {
|
|
5221
|
-
tenantOperations:
|
|
5222
|
-
tenantOperationEvents:
|
|
5223
|
-
tenantOperationRows:
|
|
5224
|
-
rollouts:
|
|
5291
|
+
tenantOperations: xi(e),
|
|
5292
|
+
tenantOperationEvents: Vi(e),
|
|
5293
|
+
tenantOperationRows: Oi(e),
|
|
5294
|
+
rollouts: Wi(e)
|
|
5225
5295
|
} : {},
|
|
5226
|
-
themes:
|
|
5227
|
-
universalLoginTemplates:
|
|
5228
|
-
users:
|
|
5229
|
-
userActivity:
|
|
5230
|
-
userRoles:
|
|
5231
|
-
userOrganizations:
|
|
5232
|
-
stats:
|
|
5233
|
-
analytics:
|
|
5234
|
-
outbox:
|
|
5296
|
+
themes: Rr(e),
|
|
5297
|
+
universalLoginTemplates: zr(e),
|
|
5298
|
+
users: ni(e),
|
|
5299
|
+
userActivity: Vr(e),
|
|
5300
|
+
userRoles: ri(e),
|
|
5301
|
+
userOrganizations: ii(e),
|
|
5302
|
+
stats: ci(e),
|
|
5303
|
+
analytics: mi(e),
|
|
5304
|
+
outbox: Wr(e),
|
|
5235
5305
|
async transaction(r) {
|
|
5236
|
-
if (t.useTransactions === !1 ||
|
|
5306
|
+
if (t.useTransactions === !1 || Ct(e)) return r(n);
|
|
5237
5307
|
await e.run(y`BEGIN`);
|
|
5238
5308
|
try {
|
|
5239
5309
|
let t = await r(n);
|
|
@@ -5247,22 +5317,22 @@ function Ri(e, t = { useTransactions: !0 }) {
|
|
|
5247
5317
|
}
|
|
5248
5318
|
//#endregion
|
|
5249
5319
|
//#region src/adapters/resolveHost.ts
|
|
5250
|
-
function
|
|
5320
|
+
function Ki(e) {
|
|
5251
5321
|
if (!e) return { path: "/*" };
|
|
5252
5322
|
try {
|
|
5253
|
-
let t = JSON.parse(e), n =
|
|
5323
|
+
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
5254
5324
|
if (n.success) return n.data;
|
|
5255
5325
|
} catch {}
|
|
5256
5326
|
return { path: "/*" };
|
|
5257
5327
|
}
|
|
5258
|
-
function
|
|
5328
|
+
function qi(e) {
|
|
5259
5329
|
if (!e) return [];
|
|
5260
5330
|
try {
|
|
5261
5331
|
let t = JSON.parse(e);
|
|
5262
5332
|
if (!Array.isArray(t)) return [];
|
|
5263
5333
|
let n = [];
|
|
5264
5334
|
for (let e of t) {
|
|
5265
|
-
let t =
|
|
5335
|
+
let t = ve.safeParse(e);
|
|
5266
5336
|
t.success && n.push(t.data);
|
|
5267
5337
|
}
|
|
5268
5338
|
return n;
|
|
@@ -5270,7 +5340,7 @@ function Bi(e) {
|
|
|
5270
5340
|
return [];
|
|
5271
5341
|
}
|
|
5272
5342
|
}
|
|
5273
|
-
async function
|
|
5343
|
+
async function Ji(e, r) {
|
|
5274
5344
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5275
5345
|
custom_domain_id: V.custom_domain_id,
|
|
5276
5346
|
tenant_id: V.tenant_id,
|
|
@@ -5282,8 +5352,8 @@ async function Vi(e, r) {
|
|
|
5282
5352
|
tenant_id: e.tenant_id,
|
|
5283
5353
|
custom_domain_id: e.custom_domain_id,
|
|
5284
5354
|
priority: e.priority,
|
|
5285
|
-
match:
|
|
5286
|
-
handlers:
|
|
5355
|
+
match: Ki(e.match),
|
|
5356
|
+
handlers: qi(e.handlers),
|
|
5287
5357
|
created_at: e.created_at,
|
|
5288
5358
|
updated_at: e.updated_at
|
|
5289
5359
|
}));
|
|
@@ -5296,11 +5366,11 @@ async function Vi(e, r) {
|
|
|
5296
5366
|
}
|
|
5297
5367
|
//#endregion
|
|
5298
5368
|
//#region src/adapters/proxyData.ts
|
|
5299
|
-
function
|
|
5369
|
+
function Yi(e) {
|
|
5300
5370
|
return {
|
|
5301
|
-
proxyRoutes:
|
|
5302
|
-
resolveHost: (t) =>
|
|
5371
|
+
proxyRoutes: er(e),
|
|
5372
|
+
resolveHost: (t) => Ji(e, t)
|
|
5303
5373
|
};
|
|
5304
5374
|
}
|
|
5305
5375
|
//#endregion
|
|
5306
|
-
export {
|
|
5376
|
+
export { Yi as createProxyDataAdapter, er as createProxyRoutesAdapter, Gi as default, ft as sqlite };
|