@authhero/drizzle 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +962 -720
- package/drizzle/0010_prompt_partials.sql +9 -0
- package/drizzle/0011_org_connections_log_streams_migration_sources.sql +39 -0
- package/drizzle/meta/0010_snapshot.json +6808 -0
- package/drizzle/meta/0011_snapshot.json +7055 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +4 -4
- package/src/schema/sqlite/branding.ts +14 -0
- package/src/schema/sqlite/index.ts +6 -0
- package/src/schema/sqlite/logStreams.ts +18 -0
- package/src/schema/sqlite/migrationSources.ts +17 -0
- package/src/schema/sqlite/organizations.ts +23 -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, 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,
|
|
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, migrationProviderTypeSchema as Se, parseUserId as Ce, rolloutInsertSchema as we, rolloutSchema as Te, sanitizeLuceneQuery as Ee, scimMappingEntrySchema as De, sessionRetentionWindow as Oe, splitLuceneOrGroups as ke, tenantOperationEventInsertSchema as Ae, tenantOperationEventSchema as je, tenantOperationInsertSchema as Me, tenantOperationRowInsertSchema as Ne, tenantOperationRowSchema as Pe, tenantOperationSchema as Fe, tokenExchangeJwtVerificationSchema as Ie, unescapeLuceneValue as Le } from "@authhero/adapter-interfaces";
|
|
6
|
+
import { HTTPException as Re } from "hono/http-exception";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var ze = Object.defineProperty, Be = (e, t) => {
|
|
9
9
|
let n = {};
|
|
10
|
-
for (var r in e)
|
|
10
|
+
for (var r in e) ze(n, r, {
|
|
11
11
|
get: e[r],
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
|
-
return t ||
|
|
14
|
+
return t || ze(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 Re = Object.defineProperty, ze = (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
|
+
}), Ve = 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 Re = Object.defineProperty, ze = (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
|
+
]), He = 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 Re = Object.defineProperty, ze = (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
|
+
}), Ue = 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 Re = Object.defineProperty, ze = (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)]), We = 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 Re = Object.defineProperty, ze = (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
|
+
}), Ge = 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 Re = Object.defineProperty, ze = (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)]), Ke = 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(),
|
|
@@ -475,7 +475,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
475
475
|
C({ columns: [e.tenant_id, e.id] }),
|
|
476
476
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
477
477
|
re("connections_id_unique").on(e.id)
|
|
478
|
-
]),
|
|
478
|
+
]), qe = w("custom_domains", {
|
|
479
479
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
480
480
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
481
481
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -489,7 +489,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
489
489
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
490
490
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
491
491
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
492
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
492
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), Je = w("domains", {
|
|
493
493
|
id: T("id", { length: 255 }).primaryKey(),
|
|
494
494
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
495
495
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -522,7 +522,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
522
522
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
523
523
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
524
524
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
525
|
-
]),
|
|
525
|
+
]), Ye = w("invites", {
|
|
526
526
|
id: T("id", { length: 21 }).primaryKey(),
|
|
527
527
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
528
528
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -544,7 +544,20 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
544
544
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
545
545
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
546
546
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
547
|
-
]),
|
|
547
|
+
]), Xe = w("organization_connections", {
|
|
548
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
549
|
+
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
550
|
+
connection_id: T("connection_id", { length: 191 }).notNull(),
|
|
551
|
+
assign_membership_on_login: S("assign_membership_on_login").notNull().default(0),
|
|
552
|
+
show_as_button: S("show_as_button").notNull().default(1),
|
|
553
|
+
is_signup_enabled: S("is_signup_enabled").notNull().default(1),
|
|
554
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
555
|
+
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
556
|
+
}, (e) => [C({ columns: [
|
|
557
|
+
e.tenant_id,
|
|
558
|
+
e.organization_id,
|
|
559
|
+
e.connection_id
|
|
560
|
+
] })]), U = w("roles", {
|
|
548
561
|
id: T("id", { length: 21 }).notNull(),
|
|
549
562
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
550
563
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -574,7 +587,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
574
587
|
}),
|
|
575
588
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
576
589
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
577
|
-
]),
|
|
590
|
+
]), Ze = w("user_permissions", {
|
|
578
591
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
579
592
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
580
593
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -635,7 +648,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
635
648
|
}, (e) => [C({
|
|
636
649
|
columns: [e.tenant_id, e.id],
|
|
637
650
|
name: "resource_servers_pk"
|
|
638
|
-
})]),
|
|
651
|
+
})]), Qe = w("branding", {
|
|
639
652
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
640
653
|
logo_url: T("logo_url", { length: 512 }),
|
|
641
654
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -646,12 +659,12 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
646
659
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
647
660
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
648
661
|
dark_mode: T("dark_mode", { length: 8 })
|
|
649
|
-
}),
|
|
662
|
+
}), $e = w("universal_login_templates", {
|
|
650
663
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
651
664
|
body: T("body").notNull(),
|
|
652
665
|
created_at_ts: S("created_at_ts").notNull(),
|
|
653
666
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
654
|
-
}),
|
|
667
|
+
}), et = w("themes", {
|
|
655
668
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
656
669
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
657
670
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -711,7 +724,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
711
724
|
}, (e) => [C({
|
|
712
725
|
columns: [e.tenant_id, e.themeId],
|
|
713
726
|
name: "themes_pkey"
|
|
714
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
727
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), tt = w("forms", {
|
|
715
728
|
id: T("id", { length: 255 }).primaryKey(),
|
|
716
729
|
name: T("name", { length: 255 }).notNull(),
|
|
717
730
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -724,21 +737,21 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
724
737
|
style: T("style", { length: 1042 }),
|
|
725
738
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
726
739
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
727
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
740
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), nt = w("flows", {
|
|
728
741
|
id: T("id", { length: 24 }).primaryKey(),
|
|
729
742
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
730
743
|
name: T("name", { length: 150 }).notNull(),
|
|
731
744
|
actions: T("actions"),
|
|
732
745
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
733
746
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
734
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
747
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), rt = w("prompt_settings", {
|
|
735
748
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
736
749
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
737
750
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
738
751
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
739
752
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
740
753
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
741
|
-
}),
|
|
754
|
+
}), it = w("email_providers", {
|
|
742
755
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
743
756
|
name: T("name", { length: 255 }).notNull(),
|
|
744
757
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -747,7 +760,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
747
760
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
748
761
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
749
762
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
750
|
-
}),
|
|
763
|
+
}), at = w("email_templates", {
|
|
751
764
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
752
765
|
template: T("template", { length: 64 }).notNull(),
|
|
753
766
|
body: T("body").notNull(),
|
|
@@ -760,7 +773,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
760
773
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
761
774
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
762
775
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
763
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
776
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), ot = w("hooks", {
|
|
764
777
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
765
778
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
766
779
|
url: T("url", { length: 512 }),
|
|
@@ -776,14 +789,14 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
776
789
|
page_id: T("page_id", { length: 64 }),
|
|
777
790
|
permission_required: T("permission_required", { length: 255 }),
|
|
778
791
|
metadata: T("metadata")
|
|
779
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
792
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), st = w("hook_code", {
|
|
780
793
|
id: T("id", { length: 21 }).primaryKey(),
|
|
781
794
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
782
795
|
code: T("code").notNull(),
|
|
783
796
|
secrets: T("secrets"),
|
|
784
797
|
created_at_ts: S("created_at_ts").notNull(),
|
|
785
798
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
786
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
799
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), ct = w("keys", {
|
|
787
800
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
788
801
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
789
802
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -796,7 +809,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
796
809
|
current_until: T("current_until", { length: 35 }),
|
|
797
810
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
798
811
|
connection: T("connection", { length: 255 }).references(() => B.id, { onDelete: "cascade" })
|
|
799
|
-
}),
|
|
812
|
+
}), lt = w("custom_text", {
|
|
800
813
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
801
814
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
802
815
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -807,7 +820,13 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
807
820
|
e.tenant_id,
|
|
808
821
|
e.prompt,
|
|
809
822
|
e.language
|
|
810
|
-
] })]),
|
|
823
|
+
] })]), ut = w("prompt_partials", {
|
|
824
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
825
|
+
prompt: T("prompt", { length: 64 }).notNull(),
|
|
826
|
+
body: T("body").notNull(),
|
|
827
|
+
created_at_ts: S("created_at_ts").notNull(),
|
|
828
|
+
updated_at_ts: S("updated_at_ts").notNull()
|
|
829
|
+
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), dt = w("authentication_methods", {
|
|
811
830
|
id: T("id", { length: 26 }).primaryKey(),
|
|
812
831
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
813
832
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -889,7 +908,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
889
908
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
890
909
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
891
910
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
892
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
911
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), ft = w("scim_configurations", {
|
|
893
912
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
894
913
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
895
914
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -909,7 +928,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
909
928
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
910
929
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
911
930
|
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
912
|
-
]),
|
|
931
|
+
]), pt = w("scim_external_ids", {
|
|
913
932
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
914
933
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
915
934
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -919,7 +938,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
919
938
|
e.tenant_id,
|
|
920
939
|
e.connection_id,
|
|
921
940
|
e.user_id
|
|
922
|
-
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
941
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), mt = w("token_exchange_profiles", {
|
|
923
942
|
id: T("id", { length: 64 }).primaryKey(),
|
|
924
943
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
925
944
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -929,54 +948,79 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
929
948
|
jwt_verification: T("jwt_verification"),
|
|
930
949
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
931
950
|
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)]),
|
|
933
|
-
|
|
951
|
+
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), ht = w("log_streams", {
|
|
952
|
+
id: T("id", { length: 64 }).primaryKey(),
|
|
953
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
954
|
+
name: T("name", { length: 255 }).notNull(),
|
|
955
|
+
type: T("type", { length: 64 }).notNull(),
|
|
956
|
+
status: T("status", { length: 32 }).notNull(),
|
|
957
|
+
sink: T("sink").notNull(),
|
|
958
|
+
filters: T("filters"),
|
|
959
|
+
is_priority: S("is_priority"),
|
|
960
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
961
|
+
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
962
|
+
}, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]), gt = w("migration_sources", {
|
|
963
|
+
id: T("id", { length: 64 }).primaryKey(),
|
|
964
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
965
|
+
name: T("name", { length: 255 }).notNull(),
|
|
966
|
+
provider: T("provider", { length: 32 }).notNull(),
|
|
967
|
+
connection: T("connection", { length: 255 }).notNull(),
|
|
968
|
+
enabled: S("enabled").notNull(),
|
|
969
|
+
credentials: T("credentials").notNull(),
|
|
970
|
+
created_at: T("created_at", { length: 35 }).notNull(),
|
|
971
|
+
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
972
|
+
}, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]), _t = /* @__PURE__ */ Be({
|
|
973
|
+
actionExecutions: () => He,
|
|
934
974
|
actionVersions: () => k,
|
|
935
|
-
actions: () =>
|
|
936
|
-
authenticationCodes: () =>
|
|
937
|
-
authenticationMethods: () =>
|
|
938
|
-
branding: () =>
|
|
975
|
+
actions: () => Ve,
|
|
976
|
+
authenticationCodes: () => We,
|
|
977
|
+
authenticationMethods: () => dt,
|
|
978
|
+
branding: () => Qe,
|
|
939
979
|
clientGrants: () => R,
|
|
940
980
|
clientRegistrationTokens: () => L,
|
|
941
981
|
clients: () => I,
|
|
942
982
|
codes: () => F,
|
|
943
983
|
connections: () => B,
|
|
944
|
-
customDomains: () =>
|
|
945
|
-
customText: () =>
|
|
946
|
-
domains: () =>
|
|
947
|
-
emailProviders: () =>
|
|
948
|
-
emailTemplates: () =>
|
|
949
|
-
flows: () =>
|
|
950
|
-
forms: () =>
|
|
984
|
+
customDomains: () => qe,
|
|
985
|
+
customText: () => lt,
|
|
986
|
+
domains: () => Je,
|
|
987
|
+
emailProviders: () => it,
|
|
988
|
+
emailTemplates: () => at,
|
|
989
|
+
flows: () => nt,
|
|
990
|
+
forms: () => tt,
|
|
951
991
|
grants: () => z,
|
|
952
|
-
hookCode: () =>
|
|
953
|
-
hooks: () =>
|
|
954
|
-
invites: () =>
|
|
955
|
-
keys: () =>
|
|
992
|
+
hookCode: () => st,
|
|
993
|
+
hooks: () => ot,
|
|
994
|
+
invites: () => Ye,
|
|
995
|
+
keys: () => ct,
|
|
996
|
+
logStreams: () => ht,
|
|
956
997
|
loginSessions: () => P,
|
|
957
998
|
logs: () => q,
|
|
999
|
+
migrationSources: () => gt,
|
|
1000
|
+
organizationConnections: () => Xe,
|
|
958
1001
|
organizations: () => V,
|
|
959
|
-
otps: () =>
|
|
1002
|
+
otps: () => Ge,
|
|
960
1003
|
outboxEvents: () => J,
|
|
961
1004
|
passwords: () => j,
|
|
962
|
-
|
|
1005
|
+
promptPartials: () => ut,
|
|
1006
|
+
promptSettings: () => rt,
|
|
963
1007
|
proxyRoutes: () => Y,
|
|
964
1008
|
refreshTokens: () => N,
|
|
965
1009
|
resourceServers: () => K,
|
|
966
1010
|
rolePermissions: () => W,
|
|
967
1011
|
roles: () => U,
|
|
968
|
-
scimConfigurations: () =>
|
|
969
|
-
scimExternalIds: () =>
|
|
1012
|
+
scimConfigurations: () => ft,
|
|
1013
|
+
scimExternalIds: () => pt,
|
|
970
1014
|
scimTokens: () => X,
|
|
971
1015
|
sessions: () => M,
|
|
972
1016
|
tenants: () => O,
|
|
973
|
-
themes: () =>
|
|
974
|
-
tickets: () =>
|
|
975
|
-
tokenExchangeProfiles: () =>
|
|
976
|
-
universalLoginTemplates: () =>
|
|
977
|
-
userActivity: () =>
|
|
1017
|
+
themes: () => et,
|
|
1018
|
+
tickets: () => Ke,
|
|
1019
|
+
tokenExchangeProfiles: () => mt,
|
|
1020
|
+
universalLoginTemplates: () => $e,
|
|
1021
|
+
userActivity: () => Ue,
|
|
978
1022
|
userOrganizations: () => H,
|
|
979
|
-
userPermissions: () =>
|
|
1023
|
+
userPermissions: () => Ze,
|
|
980
1024
|
userRoles: () => G,
|
|
981
1025
|
users: () => A
|
|
982
1026
|
});
|
|
@@ -991,14 +1035,14 @@ function Z(e, t) {
|
|
|
991
1035
|
}
|
|
992
1036
|
return e;
|
|
993
1037
|
}
|
|
994
|
-
function
|
|
1038
|
+
function vt(e, t = "", n = {}) {
|
|
995
1039
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
996
1040
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
997
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
1041
|
+
typeof a == "object" && a && !Array.isArray(a) ? vt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
998
1042
|
}
|
|
999
1043
|
return n;
|
|
1000
1044
|
}
|
|
1001
|
-
function
|
|
1045
|
+
function yt(e, t) {
|
|
1002
1046
|
let n = {};
|
|
1003
1047
|
for (let [r, i] of Object.entries(e)) {
|
|
1004
1048
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -1015,17 +1059,17 @@ function mt(e, t) {
|
|
|
1015
1059
|
}
|
|
1016
1060
|
//#endregion
|
|
1017
1061
|
//#region src/helpers/filter.ts
|
|
1018
|
-
function
|
|
1062
|
+
function bt(e) {
|
|
1019
1063
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1020
1064
|
}
|
|
1021
|
-
function
|
|
1065
|
+
function xt(e) {
|
|
1022
1066
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1023
1067
|
}
|
|
1024
|
-
function
|
|
1068
|
+
function St(n, r, i, l = []) {
|
|
1025
1069
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1026
1070
|
let t = Number(e);
|
|
1027
1071
|
return Number.isFinite(t) ? t : e;
|
|
1028
|
-
}, x =
|
|
1072
|
+
}, x = ke(r);
|
|
1029
1073
|
if (x.length > 1) {
|
|
1030
1074
|
let n = x.map((n) => {
|
|
1031
1075
|
let r = n.map((t) => {
|
|
@@ -1033,8 +1077,8 @@ function _t(n, r, i, l = []) {
|
|
|
1033
1077
|
if (!n) return null;
|
|
1034
1078
|
let [, r, i] = n;
|
|
1035
1079
|
if (!r || !i) return null;
|
|
1036
|
-
let o = r.trim(), s =
|
|
1037
|
-
return
|
|
1080
|
+
let o = r.trim(), s = Le(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1081
|
+
return bt(c) ? a(xt(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1038
1082
|
}).filter((e) => e !== null);
|
|
1039
1083
|
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1040
1084
|
}).filter((e) => e !== null);
|
|
@@ -1046,8 +1090,8 @@ function _t(n, r, i, l = []) {
|
|
|
1046
1090
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
1047
1091
|
else if (e.includes(":")) {
|
|
1048
1092
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
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 =
|
|
1050
|
-
} else n = null, r =
|
|
1093
|
+
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 = Le(r);
|
|
1094
|
+
} else n = null, r = Le(e), i = !1;
|
|
1051
1095
|
return {
|
|
1052
1096
|
key: n,
|
|
1053
1097
|
value: r,
|
|
@@ -1057,12 +1101,12 @@ function _t(n, r, i, l = []) {
|
|
|
1057
1101
|
};
|
|
1058
1102
|
}), C = [];
|
|
1059
1103
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1060
|
-
let i = ee[t], v =
|
|
1104
|
+
let i = ee[t], v = bt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1061
1105
|
if (!te) {
|
|
1062
1106
|
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}`);
|
|
1063
1107
|
continue;
|
|
1064
1108
|
}
|
|
1065
|
-
let S = v ?
|
|
1109
|
+
let S = v ? xt(i) : y`${te}`;
|
|
1066
1110
|
if (o) C.push(r ? f(te) : d(te));
|
|
1067
1111
|
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1068
1112
|
else if (r) switch (l) {
|
|
@@ -1111,11 +1155,11 @@ function _t(n, r, i, l = []) {
|
|
|
1111
1155
|
}
|
|
1112
1156
|
//#endregion
|
|
1113
1157
|
//#region src/adapters/actions.ts
|
|
1114
|
-
function
|
|
1158
|
+
function Ct(e) {
|
|
1115
1159
|
let t = Z(e);
|
|
1116
1160
|
return Array.isArray(t) ? t : [];
|
|
1117
1161
|
}
|
|
1118
|
-
function
|
|
1162
|
+
function wt(e) {
|
|
1119
1163
|
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;
|
|
1120
1164
|
return {
|
|
1121
1165
|
...f,
|
|
@@ -1132,11 +1176,11 @@ function yt(e) {
|
|
|
1132
1176
|
updated_at: new Date(Number(n)).toISOString()
|
|
1133
1177
|
};
|
|
1134
1178
|
}
|
|
1135
|
-
function
|
|
1179
|
+
function Tt(e) {
|
|
1136
1180
|
return {
|
|
1137
1181
|
async create(t, n) {
|
|
1138
1182
|
let r = Date.now(), i = `act_${b()}`;
|
|
1139
|
-
return await e.insert(
|
|
1183
|
+
return await e.insert(Ve).values({
|
|
1140
1184
|
id: i,
|
|
1141
1185
|
tenant_id: t,
|
|
1142
1186
|
name: n.name,
|
|
@@ -1167,28 +1211,28 @@ function bt(e) {
|
|
|
1167
1211
|
};
|
|
1168
1212
|
},
|
|
1169
1213
|
async get(n, r) {
|
|
1170
|
-
let i = await e.select().from(
|
|
1171
|
-
return i ?
|
|
1214
|
+
let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
|
|
1215
|
+
return i ? wt(i) : null;
|
|
1172
1216
|
},
|
|
1173
1217
|
async list(o, s = {}) {
|
|
1174
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1218
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Ve.tenant_id, o)];
|
|
1175
1219
|
if (f) {
|
|
1176
|
-
let e =
|
|
1220
|
+
let e = St(Ve, f, ["name"]);
|
|
1177
1221
|
e && p.push(e);
|
|
1178
1222
|
}
|
|
1179
|
-
let m = t(...p), h = e.select().from(
|
|
1223
|
+
let m = t(...p), h = e.select().from(Ve).where(m).$dynamic();
|
|
1180
1224
|
if (d?.sort_by) {
|
|
1181
|
-
let e =
|
|
1225
|
+
let e = Ve[d.sort_by];
|
|
1182
1226
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1183
1227
|
}
|
|
1184
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1228
|
+
let g = (await h.offset(c * l).limit(l)).map(wt);
|
|
1185
1229
|
if (!u) return {
|
|
1186
1230
|
actions: g,
|
|
1187
1231
|
start: 0,
|
|
1188
1232
|
limit: 0,
|
|
1189
1233
|
length: 0
|
|
1190
1234
|
};
|
|
1191
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1235
|
+
let [_] = await e.select({ count: r() }).from(Ve).where(m);
|
|
1192
1236
|
return {
|
|
1193
1237
|
actions: g,
|
|
1194
1238
|
start: c * l,
|
|
@@ -1199,7 +1243,7 @@ function bt(e) {
|
|
|
1199
1243
|
async update(n, r, i) {
|
|
1200
1244
|
let o = { updated_at_ts: Date.now() };
|
|
1201
1245
|
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) {
|
|
1202
|
-
let s = await e.select({ secrets:
|
|
1246
|
+
let s = await e.select({ secrets: Ve.secrets }).from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get(), c = new Map(Ct(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1203
1247
|
name: e.name,
|
|
1204
1248
|
value: c.get(e.name)?.value
|
|
1205
1249
|
} : e);
|
|
@@ -1209,21 +1253,21 @@ function bt(e) {
|
|
|
1209
1253
|
let e = new Date(i.deployed_at).getTime();
|
|
1210
1254
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1211
1255
|
}
|
|
1212
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1256
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(Ve).set(o).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
|
|
1213
1257
|
},
|
|
1214
1258
|
async remove(n, r) {
|
|
1215
|
-
return (await e.delete(
|
|
1259
|
+
return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
|
|
1216
1260
|
}
|
|
1217
1261
|
};
|
|
1218
1262
|
}
|
|
1219
1263
|
//#endregion
|
|
1220
1264
|
//#region src/adapters/actionExecutions.ts
|
|
1221
|
-
var
|
|
1222
|
-
function
|
|
1265
|
+
var Et = 500;
|
|
1266
|
+
function Dt(e) {
|
|
1223
1267
|
return {
|
|
1224
1268
|
async create(t, n) {
|
|
1225
1269
|
let r = Date.now();
|
|
1226
|
-
return await e.insert(
|
|
1270
|
+
return await e.insert(He).values({
|
|
1227
1271
|
id: n.id,
|
|
1228
1272
|
tenant_id: t,
|
|
1229
1273
|
trigger_id: n.trigger_id,
|
|
@@ -1244,7 +1288,7 @@ function St(e) {
|
|
|
1244
1288
|
};
|
|
1245
1289
|
},
|
|
1246
1290
|
async get(n, r) {
|
|
1247
|
-
let i = await e.select().from(
|
|
1291
|
+
let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.id, r))).get();
|
|
1248
1292
|
return i ? {
|
|
1249
1293
|
id: i.id,
|
|
1250
1294
|
tenant_id: i.tenant_id,
|
|
@@ -1261,8 +1305,8 @@ function St(e) {
|
|
|
1261
1305
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1262
1306
|
let r = 0;
|
|
1263
1307
|
for (;;) {
|
|
1264
|
-
let t = await e.delete(
|
|
1265
|
-
if (r += t.length, t.length <
|
|
1308
|
+
let t = await e.delete(He).where(y`rowid IN (SELECT rowid FROM ${He} WHERE ${He.created_at_ts} < ${n} LIMIT ${Et})`).returning({ id: He.id });
|
|
1309
|
+
if (r += t.length, t.length < Et) break;
|
|
1266
1310
|
}
|
|
1267
1311
|
return r;
|
|
1268
1312
|
}
|
|
@@ -1270,12 +1314,12 @@ function St(e) {
|
|
|
1270
1314
|
}
|
|
1271
1315
|
//#endregion
|
|
1272
1316
|
//#region src/adapters/atomic.ts
|
|
1273
|
-
function
|
|
1317
|
+
function Ot(e) {
|
|
1274
1318
|
let t = e;
|
|
1275
1319
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1276
1320
|
}
|
|
1277
|
-
async function
|
|
1278
|
-
if (
|
|
1321
|
+
async function kt(e, t) {
|
|
1322
|
+
if (Ot(e)) return e.batch(t);
|
|
1279
1323
|
await e.run(y`BEGIN`);
|
|
1280
1324
|
try {
|
|
1281
1325
|
let n = [];
|
|
@@ -1292,7 +1336,7 @@ async function wt(e, t) {
|
|
|
1292
1336
|
}
|
|
1293
1337
|
//#endregion
|
|
1294
1338
|
//#region src/adapters/actionVersions.ts
|
|
1295
|
-
function
|
|
1339
|
+
function At(e) {
|
|
1296
1340
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1297
1341
|
return {
|
|
1298
1342
|
...c,
|
|
@@ -1305,7 +1349,7 @@ function Tt(e) {
|
|
|
1305
1349
|
updated_at: new Date(Number(n)).toISOString()
|
|
1306
1350
|
};
|
|
1307
1351
|
}
|
|
1308
|
-
function
|
|
1352
|
+
function jt(e) {
|
|
1309
1353
|
return {
|
|
1310
1354
|
async create(n, r) {
|
|
1311
1355
|
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({
|
|
@@ -1322,7 +1366,7 @@ function Et(e) {
|
|
|
1322
1366
|
created_at_ts: o,
|
|
1323
1367
|
updated_at_ts: o
|
|
1324
1368
|
});
|
|
1325
|
-
return await
|
|
1369
|
+
return await kt(e, c ? [e.update(k).set({
|
|
1326
1370
|
deployed: 0,
|
|
1327
1371
|
updated_at_ts: o
|
|
1328
1372
|
}).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id), a(k.deployed, 1))), u] : [u]), {
|
|
@@ -1342,10 +1386,10 @@ function Et(e) {
|
|
|
1342
1386
|
},
|
|
1343
1387
|
async get(n, r, i) {
|
|
1344
1388
|
let o = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.action_id, r), a(k.id, i))).get();
|
|
1345
|
-
return o ?
|
|
1389
|
+
return o ? At(o) : null;
|
|
1346
1390
|
},
|
|
1347
1391
|
async list(n, o, s = {}) {
|
|
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(
|
|
1392
|
+
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(At);
|
|
1349
1393
|
if (!u) return {
|
|
1350
1394
|
versions: f,
|
|
1351
1395
|
start: 0,
|
|
@@ -1367,13 +1411,13 @@ function Et(e) {
|
|
|
1367
1411
|
}
|
|
1368
1412
|
//#endregion
|
|
1369
1413
|
//#region src/adapters/branding.ts
|
|
1370
|
-
function
|
|
1414
|
+
function Mt(e) {
|
|
1371
1415
|
return e === "dark" || e === "light" || e === "auto";
|
|
1372
1416
|
}
|
|
1373
|
-
function
|
|
1417
|
+
function Nt(e) {
|
|
1374
1418
|
return {
|
|
1375
1419
|
async get(t) {
|
|
1376
|
-
let n = await e.select().from(
|
|
1420
|
+
let n = await e.select().from(Qe).where(a(Qe.tenant_id, t)).get();
|
|
1377
1421
|
if (!n) return null;
|
|
1378
1422
|
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;
|
|
1379
1423
|
return D({
|
|
@@ -1388,7 +1432,7 @@ function Ot(e) {
|
|
|
1388
1432
|
}
|
|
1389
1433
|
},
|
|
1390
1434
|
font: u ? { url: u } : void 0,
|
|
1391
|
-
dark_mode:
|
|
1435
|
+
dark_mode: Mt(d) ? d : void 0
|
|
1392
1436
|
});
|
|
1393
1437
|
},
|
|
1394
1438
|
async set(t, n) {
|
|
@@ -1402,11 +1446,11 @@ function Ot(e) {
|
|
|
1402
1446
|
font_url: i?.url,
|
|
1403
1447
|
dark_mode: a
|
|
1404
1448
|
};
|
|
1405
|
-
await e.insert(
|
|
1449
|
+
await e.insert(Qe).values({
|
|
1406
1450
|
tenant_id: t,
|
|
1407
1451
|
...l
|
|
1408
1452
|
}).onConflictDoUpdate({
|
|
1409
|
-
target:
|
|
1453
|
+
target: Qe.tenant_id,
|
|
1410
1454
|
set: l
|
|
1411
1455
|
});
|
|
1412
1456
|
}
|
|
@@ -1414,26 +1458,26 @@ function Ot(e) {
|
|
|
1414
1458
|
}
|
|
1415
1459
|
//#endregion
|
|
1416
1460
|
//#region src/helpers/paginate.ts
|
|
1417
|
-
function
|
|
1461
|
+
function Pt(e) {
|
|
1418
1462
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1419
1463
|
}
|
|
1420
|
-
function
|
|
1464
|
+
function Ft(e) {
|
|
1421
1465
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1422
1466
|
return n >= 1 ? n : 50;
|
|
1423
1467
|
}
|
|
1424
|
-
function
|
|
1468
|
+
function It(e) {
|
|
1425
1469
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1426
1470
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1427
1471
|
}
|
|
1428
|
-
function
|
|
1472
|
+
function Lt(e, t) {
|
|
1429
1473
|
let n = e?.from ? ge(e.from) : null;
|
|
1430
1474
|
if (!n) return;
|
|
1431
|
-
if (n.k !== t.sortKey) throw new
|
|
1475
|
+
if (n.k !== t.sortKey) throw new Re(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
1432
1476
|
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1433
1477
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1434
1478
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1435
1479
|
}
|
|
1436
|
-
function
|
|
1480
|
+
function Rt(e, t, n, r = "id", i) {
|
|
1437
1481
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1438
1482
|
if (a && c) {
|
|
1439
1483
|
let e = c[n];
|
|
@@ -1450,7 +1494,7 @@ function Nt(e, t, n, r = "id", i) {
|
|
|
1450
1494
|
}
|
|
1451
1495
|
//#endregion
|
|
1452
1496
|
//#region src/adapters/clients.ts
|
|
1453
|
-
var
|
|
1497
|
+
var zt = [
|
|
1454
1498
|
"global",
|
|
1455
1499
|
"is_first_party",
|
|
1456
1500
|
"oidc_conformant",
|
|
@@ -1462,7 +1506,7 @@ var Pt = [
|
|
|
1462
1506
|
"require_pushed_authorization_requests",
|
|
1463
1507
|
"require_proof_of_possession",
|
|
1464
1508
|
"hide_sign_up_disabled_error"
|
|
1465
|
-
],
|
|
1509
|
+
], Bt = [
|
|
1466
1510
|
"callbacks",
|
|
1467
1511
|
"allowed_origins",
|
|
1468
1512
|
"web_origins",
|
|
@@ -1471,7 +1515,7 @@ var Pt = [
|
|
|
1471
1515
|
"allowed_logout_urls",
|
|
1472
1516
|
"grant_types",
|
|
1473
1517
|
"signing_keys"
|
|
1474
|
-
],
|
|
1518
|
+
], Vt = [
|
|
1475
1519
|
"session_transfer",
|
|
1476
1520
|
"oidc_logout",
|
|
1477
1521
|
"jwt_configuration",
|
|
@@ -1488,21 +1532,21 @@ var Pt = [
|
|
|
1488
1532
|
"registration_metadata",
|
|
1489
1533
|
"token_exchange"
|
|
1490
1534
|
];
|
|
1491
|
-
function
|
|
1535
|
+
function Ht(e) {
|
|
1492
1536
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1493
|
-
for (let e of
|
|
1494
|
-
for (let e of
|
|
1495
|
-
for (let e of
|
|
1537
|
+
for (let e of zt) i[e] = !!r[e];
|
|
1538
|
+
for (let e of Bt) i[e] = Z(r[e], []);
|
|
1539
|
+
for (let e of Vt) i[e] = Z(r[e], {});
|
|
1496
1540
|
return i.connections = Z(n, []), D(i);
|
|
1497
1541
|
}
|
|
1498
|
-
function
|
|
1542
|
+
function Ut(e) {
|
|
1499
1543
|
let t = { ...e };
|
|
1500
|
-
ie(e,
|
|
1501
|
-
for (let n of
|
|
1502
|
-
for (let n of
|
|
1544
|
+
ie(e, zt, t);
|
|
1545
|
+
for (let n of Bt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1546
|
+
for (let n of Vt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1503
1547
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
|
|
1504
1548
|
}
|
|
1505
|
-
function
|
|
1549
|
+
function Wt(e) {
|
|
1506
1550
|
return {
|
|
1507
1551
|
async create(t, n) {
|
|
1508
1552
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1526,51 +1570,51 @@ function zt(e) {
|
|
|
1526
1570
|
created_at: r,
|
|
1527
1571
|
updated_at: r
|
|
1528
1572
|
};
|
|
1529
|
-
for (let e of
|
|
1573
|
+
for (let e of zt) i[e] = n[e] ?? !1;
|
|
1530
1574
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1531
|
-
for (let e of
|
|
1532
|
-
for (let e of
|
|
1575
|
+
for (let e of Bt) i[e] = n[e] || [];
|
|
1576
|
+
for (let e of Vt) i[e] = n[e] || {};
|
|
1533
1577
|
i.connections = n.connections || [];
|
|
1534
|
-
let a =
|
|
1578
|
+
let a = Ut(i);
|
|
1535
1579
|
try {
|
|
1536
1580
|
await e.insert(I).values({
|
|
1537
1581
|
...a,
|
|
1538
1582
|
tenant_id: t
|
|
1539
1583
|
});
|
|
1540
1584
|
} catch (e) {
|
|
1541
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1585
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Client already exists" }) : e;
|
|
1542
1586
|
}
|
|
1543
|
-
return
|
|
1587
|
+
return Ht({
|
|
1544
1588
|
...a,
|
|
1545
1589
|
tenant_id: t
|
|
1546
1590
|
});
|
|
1547
1591
|
},
|
|
1548
1592
|
async get(n, r) {
|
|
1549
1593
|
let i = await e.select().from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1550
|
-
return i ?
|
|
1594
|
+
return i ? Ht(i) : null;
|
|
1551
1595
|
},
|
|
1552
1596
|
async getByClientId(t) {
|
|
1553
1597
|
let n = await e.select().from(I).where(a(I.client_id, t)).get();
|
|
1554
1598
|
return n ? {
|
|
1555
|
-
...
|
|
1599
|
+
...Ht(n),
|
|
1556
1600
|
tenant_id: n.tenant_id
|
|
1557
1601
|
} : null;
|
|
1558
1602
|
},
|
|
1559
1603
|
async update(n, r, i) {
|
|
1560
|
-
let o =
|
|
1604
|
+
let o = Ut({
|
|
1561
1605
|
...i,
|
|
1562
1606
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1563
1607
|
});
|
|
1564
1608
|
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;
|
|
1565
1609
|
},
|
|
1566
1610
|
async list(o, s) {
|
|
1567
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1568
|
-
if (
|
|
1611
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
|
|
1612
|
+
if (Pt(s)) {
|
|
1569
1613
|
let n = {
|
|
1570
1614
|
sortColumn: I.created_at,
|
|
1571
1615
|
idColumn: I.client_id,
|
|
1572
1616
|
sortOrder: "desc"
|
|
1573
|
-
}, r =
|
|
1617
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Ht);
|
|
1574
1618
|
return {
|
|
1575
1619
|
clients: c,
|
|
1576
1620
|
totals: {
|
|
@@ -1586,7 +1630,7 @@ function zt(e) {
|
|
|
1586
1630
|
let e = I[d.sort_by];
|
|
1587
1631
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1588
1632
|
}
|
|
1589
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1633
|
+
let g = (await h.offset(c * l).limit(l)).map(Ht);
|
|
1590
1634
|
if (!u) return { clients: g };
|
|
1591
1635
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1592
1636
|
return {
|
|
@@ -1606,7 +1650,7 @@ function zt(e) {
|
|
|
1606
1650
|
}
|
|
1607
1651
|
//#endregion
|
|
1608
1652
|
//#region src/adapters/clientConnections.ts
|
|
1609
|
-
function
|
|
1653
|
+
function Gt(e) {
|
|
1610
1654
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1611
1655
|
return D({
|
|
1612
1656
|
...a,
|
|
@@ -1615,14 +1659,14 @@ function Bt(e) {
|
|
|
1615
1659
|
is_system: n ? !0 : void 0
|
|
1616
1660
|
});
|
|
1617
1661
|
}
|
|
1618
|
-
function
|
|
1662
|
+
function Kt(e) {
|
|
1619
1663
|
return {
|
|
1620
1664
|
async listByClient(n, r) {
|
|
1621
1665
|
let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1622
1666
|
if (!i) return [];
|
|
1623
1667
|
let o = Z(i.connections, []) || [];
|
|
1624
1668
|
if (o.length === 0) return [];
|
|
1625
|
-
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(
|
|
1669
|
+
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(Gt);
|
|
1626
1670
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1627
1671
|
},
|
|
1628
1672
|
async updateByClient(n, r, i) {
|
|
@@ -1659,7 +1703,7 @@ function Vt(e) {
|
|
|
1659
1703
|
}
|
|
1660
1704
|
//#endregion
|
|
1661
1705
|
//#region src/adapters/clientGrants.ts
|
|
1662
|
-
function
|
|
1706
|
+
function qt(e) {
|
|
1663
1707
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1664
1708
|
return D({
|
|
1665
1709
|
...o,
|
|
@@ -1669,7 +1713,7 @@ function Ht(e) {
|
|
|
1669
1713
|
is_system: !!a
|
|
1670
1714
|
});
|
|
1671
1715
|
}
|
|
1672
|
-
function
|
|
1716
|
+
function Jt(e) {
|
|
1673
1717
|
return {
|
|
1674
1718
|
async create(t, n) {
|
|
1675
1719
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1686,14 +1730,14 @@ function Ut(e) {
|
|
|
1686
1730
|
created_at: r,
|
|
1687
1731
|
updated_at: r
|
|
1688
1732
|
};
|
|
1689
|
-
return await e.insert(R).values(i),
|
|
1733
|
+
return await e.insert(R).values(i), qt({
|
|
1690
1734
|
...i,
|
|
1691
1735
|
tenant_id: t
|
|
1692
1736
|
});
|
|
1693
1737
|
},
|
|
1694
1738
|
async get(n, r) {
|
|
1695
1739
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1696
|
-
return i ?
|
|
1740
|
+
return i ? qt(i) : null;
|
|
1697
1741
|
},
|
|
1698
1742
|
async update(n, r, i) {
|
|
1699
1743
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1703,13 +1747,13 @@ function Ut(e) {
|
|
|
1703
1747
|
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;
|
|
1704
1748
|
},
|
|
1705
1749
|
async list(o, s) {
|
|
1706
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1707
|
-
if (
|
|
1750
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(R, f, ["client_id", "audience"]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
|
|
1751
|
+
if (Pt(s)) {
|
|
1708
1752
|
let n = {
|
|
1709
1753
|
sortColumn: R.created_at,
|
|
1710
1754
|
idColumn: R.id,
|
|
1711
1755
|
sortOrder: "desc"
|
|
1712
|
-
}, r =
|
|
1756
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(R).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at"), c = a.map(qt);
|
|
1713
1757
|
return {
|
|
1714
1758
|
client_grants: c,
|
|
1715
1759
|
start: 0,
|
|
@@ -1723,7 +1767,7 @@ function Ut(e) {
|
|
|
1723
1767
|
let e = R[d.sort_by];
|
|
1724
1768
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1725
1769
|
} else h = h.orderBy(i(R.created_at), i(R.id));
|
|
1726
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1770
|
+
let g = (await h.offset(c * l).limit(l)).map(qt);
|
|
1727
1771
|
if (!u) return { client_grants: g };
|
|
1728
1772
|
let [_] = await e.select({ count: r() }).from(R).where(m);
|
|
1729
1773
|
return {
|
|
@@ -1740,20 +1784,20 @@ function Ut(e) {
|
|
|
1740
1784
|
}
|
|
1741
1785
|
//#endregion
|
|
1742
1786
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1743
|
-
function
|
|
1787
|
+
function Yt(e) {
|
|
1744
1788
|
if (!e) return;
|
|
1745
1789
|
let t = JSON.parse(e);
|
|
1746
1790
|
return be(t) ? t : void 0;
|
|
1747
1791
|
}
|
|
1748
|
-
function
|
|
1792
|
+
function Xt(e) {
|
|
1749
1793
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1750
1794
|
}
|
|
1751
|
-
function
|
|
1795
|
+
function Zt(e) {
|
|
1752
1796
|
if (!e) return null;
|
|
1753
1797
|
let t = new Date(e);
|
|
1754
1798
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1755
1799
|
}
|
|
1756
|
-
function
|
|
1800
|
+
function Qt(e) {
|
|
1757
1801
|
let t = he.parse(e.type);
|
|
1758
1802
|
return {
|
|
1759
1803
|
id: e.id,
|
|
@@ -1761,15 +1805,15 @@ function qt(e) {
|
|
|
1761
1805
|
type: t,
|
|
1762
1806
|
client_id: e.client_id ?? void 0,
|
|
1763
1807
|
sub: e.sub ?? void 0,
|
|
1764
|
-
constraints:
|
|
1808
|
+
constraints: Yt(e.constraints),
|
|
1765
1809
|
single_use: !!e.single_use,
|
|
1766
|
-
expires_at:
|
|
1767
|
-
used_at:
|
|
1768
|
-
revoked_at:
|
|
1810
|
+
expires_at: Xt(e.expires_at_ts),
|
|
1811
|
+
used_at: Xt(e.used_at_ts),
|
|
1812
|
+
revoked_at: Xt(e.revoked_at_ts),
|
|
1769
1813
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1770
1814
|
};
|
|
1771
1815
|
}
|
|
1772
|
-
function
|
|
1816
|
+
function $t(e) {
|
|
1773
1817
|
return {
|
|
1774
1818
|
async create(t, n) {
|
|
1775
1819
|
let r = Date.now();
|
|
@@ -1782,7 +1826,7 @@ function Jt(e) {
|
|
|
1782
1826
|
sub: n.sub ?? null,
|
|
1783
1827
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1784
1828
|
single_use: +!!n.single_use,
|
|
1785
|
-
expires_at_ts:
|
|
1829
|
+
expires_at_ts: Zt(n.expires_at),
|
|
1786
1830
|
created_at_ts: r
|
|
1787
1831
|
}), {
|
|
1788
1832
|
id: n.id,
|
|
@@ -1798,23 +1842,23 @@ function Jt(e) {
|
|
|
1798
1842
|
},
|
|
1799
1843
|
async get(n, r) {
|
|
1800
1844
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.id, r))).get();
|
|
1801
|
-
return i ?
|
|
1845
|
+
return i ? Qt(i) : null;
|
|
1802
1846
|
},
|
|
1803
1847
|
async getByHash(n, r) {
|
|
1804
1848
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.token_hash, r))).get();
|
|
1805
|
-
return i ?
|
|
1849
|
+
return i ? Qt(i) : null;
|
|
1806
1850
|
},
|
|
1807
1851
|
async listByClient(n, r) {
|
|
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(
|
|
1852
|
+
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);
|
|
1809
1853
|
},
|
|
1810
1854
|
async markUsed(n, r, i) {
|
|
1811
|
-
return (await e.update(L).set({ used_at_ts:
|
|
1855
|
+
return (await e.update(L).set({ used_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
|
|
1812
1856
|
},
|
|
1813
1857
|
async revoke(n, r, i) {
|
|
1814
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1858
|
+
return (await e.update(L).set({ revoked_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
|
|
1815
1859
|
},
|
|
1816
1860
|
async revokeByClient(n, r, i) {
|
|
1817
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1861
|
+
return (await e.update(L).set({ revoked_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
|
|
1818
1862
|
},
|
|
1819
1863
|
async remove(n, r) {
|
|
1820
1864
|
return (await e.delete(L).where(t(a(L.tenant_id, n), a(L.id, r))).returning()).length > 0;
|
|
@@ -1823,12 +1867,12 @@ function Jt(e) {
|
|
|
1823
1867
|
}
|
|
1824
1868
|
//#endregion
|
|
1825
1869
|
//#region src/adapters/codes.ts
|
|
1826
|
-
var
|
|
1827
|
-
function
|
|
1870
|
+
var en = ["code_id", "login_id"], tn = 500;
|
|
1871
|
+
function nn(e) {
|
|
1828
1872
|
let { tenant_id: t, ...n } = e;
|
|
1829
1873
|
return D(n);
|
|
1830
1874
|
}
|
|
1831
|
-
function
|
|
1875
|
+
function rn(e) {
|
|
1832
1876
|
return {
|
|
1833
1877
|
async create(t, n) {
|
|
1834
1878
|
let r = {
|
|
@@ -1837,18 +1881,18 @@ function Qt(e) {
|
|
|
1837
1881
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1838
1882
|
expires_at: n.expires_at
|
|
1839
1883
|
};
|
|
1840
|
-
return await e.insert(F).values(r),
|
|
1884
|
+
return await e.insert(F).values(r), nn(r);
|
|
1841
1885
|
},
|
|
1842
1886
|
async get(n, r, i) {
|
|
1843
1887
|
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();
|
|
1844
|
-
return s ?
|
|
1888
|
+
return s ? nn(s) : null;
|
|
1845
1889
|
},
|
|
1846
1890
|
async list(o, s) {
|
|
1847
1891
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(F.tenant_id, o)];
|
|
1848
1892
|
if (f) {
|
|
1849
|
-
let e =
|
|
1893
|
+
let e = Ee(f, en);
|
|
1850
1894
|
if (e) {
|
|
1851
|
-
let t =
|
|
1895
|
+
let t = St(F, e, en);
|
|
1852
1896
|
t && p.push(t);
|
|
1853
1897
|
}
|
|
1854
1898
|
}
|
|
@@ -1857,7 +1901,7 @@ function Qt(e) {
|
|
|
1857
1901
|
let e = F[d.sort_by];
|
|
1858
1902
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1859
1903
|
}
|
|
1860
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1904
|
+
let g = (await h.offset(c * l).limit(l)).map(nn);
|
|
1861
1905
|
if (!u) return { codes: g };
|
|
1862
1906
|
let [_] = await e.select({ count: r() }).from(F).where(m);
|
|
1863
1907
|
return {
|
|
@@ -1879,8 +1923,8 @@ function Qt(e) {
|
|
|
1879
1923
|
async cleanup(t) {
|
|
1880
1924
|
let n = 0;
|
|
1881
1925
|
for (;;) {
|
|
1882
|
-
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${
|
|
1883
|
-
if (n += r.length, r.length <
|
|
1926
|
+
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${tn})`).returning({ code_id: F.code_id });
|
|
1927
|
+
if (n += r.length, r.length < tn) break;
|
|
1884
1928
|
}
|
|
1885
1929
|
return n;
|
|
1886
1930
|
}
|
|
@@ -1888,10 +1932,10 @@ function Qt(e) {
|
|
|
1888
1932
|
}
|
|
1889
1933
|
//#endregion
|
|
1890
1934
|
//#region src/adapters/connections.ts
|
|
1891
|
-
function
|
|
1935
|
+
function an() {
|
|
1892
1936
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1893
1937
|
}
|
|
1894
|
-
function
|
|
1938
|
+
function on(e) {
|
|
1895
1939
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1896
1940
|
return D({
|
|
1897
1941
|
...a,
|
|
@@ -1900,11 +1944,11 @@ function en(e) {
|
|
|
1900
1944
|
is_system: n ? !0 : void 0
|
|
1901
1945
|
});
|
|
1902
1946
|
}
|
|
1903
|
-
function
|
|
1947
|
+
function sn(e) {
|
|
1904
1948
|
return {
|
|
1905
1949
|
async create(t, n) {
|
|
1906
1950
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1907
|
-
id: n.id ||
|
|
1951
|
+
id: n.id || an(),
|
|
1908
1952
|
...n,
|
|
1909
1953
|
tenant_id: t,
|
|
1910
1954
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1916,13 +1960,13 @@ function tn(e) {
|
|
|
1916
1960
|
try {
|
|
1917
1961
|
await e.insert(B).values(i);
|
|
1918
1962
|
} catch (e) {
|
|
1919
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1963
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Connection already exists" }) : e;
|
|
1920
1964
|
}
|
|
1921
|
-
return
|
|
1965
|
+
return on(i);
|
|
1922
1966
|
},
|
|
1923
1967
|
async get(n, r) {
|
|
1924
1968
|
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
1925
|
-
return i ?
|
|
1969
|
+
return i ? on(i) : null;
|
|
1926
1970
|
},
|
|
1927
1971
|
async update(n, r, i) {
|
|
1928
1972
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1931,15 +1975,15 @@ function tn(e) {
|
|
|
1931
1975
|
async list(o, s) {
|
|
1932
1976
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(B.tenant_id, o);
|
|
1933
1977
|
if (f) {
|
|
1934
|
-
let e =
|
|
1978
|
+
let e = St(B, f, ["name"]);
|
|
1935
1979
|
e && (p = t(p, e));
|
|
1936
1980
|
}
|
|
1937
|
-
if (
|
|
1981
|
+
if (Pt(s)) {
|
|
1938
1982
|
let n = {
|
|
1939
1983
|
sortColumn: B.created_at,
|
|
1940
1984
|
idColumn: B.id,
|
|
1941
1985
|
sortOrder: "desc"
|
|
1942
|
-
}, r =
|
|
1986
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...It(n)).limit(i + 1), i, "created_at", "id"), c = a.map(on);
|
|
1943
1987
|
return {
|
|
1944
1988
|
connections: c,
|
|
1945
1989
|
start: 0,
|
|
@@ -1953,7 +1997,7 @@ function tn(e) {
|
|
|
1953
1997
|
let e = B[d.sort_by];
|
|
1954
1998
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1955
1999
|
}
|
|
1956
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
2000
|
+
let h = (await m.offset(c * l).limit(l)).map(on);
|
|
1957
2001
|
if (!u) return { connections: h };
|
|
1958
2002
|
let [g] = await e.select({ count: r() }).from(B).where(p);
|
|
1959
2003
|
return {
|
|
@@ -1970,7 +2014,7 @@ function tn(e) {
|
|
|
1970
2014
|
}
|
|
1971
2015
|
//#endregion
|
|
1972
2016
|
//#region src/adapters/customDomains.ts
|
|
1973
|
-
function
|
|
2017
|
+
function cn(e) {
|
|
1974
2018
|
let { tenant_id: t, domain_metadata: n, verification: r, ...i } = e;
|
|
1975
2019
|
return D({
|
|
1976
2020
|
...i,
|
|
@@ -1979,7 +2023,7 @@ function nn(e) {
|
|
|
1979
2023
|
verification: Z(r)
|
|
1980
2024
|
});
|
|
1981
2025
|
}
|
|
1982
|
-
function
|
|
2026
|
+
function ln(e) {
|
|
1983
2027
|
return {
|
|
1984
2028
|
async create(t, n) {
|
|
1985
2029
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1997,40 +2041,40 @@ function rn(e) {
|
|
|
1997
2041
|
created_at: r,
|
|
1998
2042
|
updated_at: r
|
|
1999
2043
|
};
|
|
2000
|
-
return await e.insert(
|
|
2044
|
+
return await e.insert(qe).values(i), cn({
|
|
2001
2045
|
...i,
|
|
2002
2046
|
tenant_id: t
|
|
2003
2047
|
});
|
|
2004
2048
|
},
|
|
2005
2049
|
async get(n, r) {
|
|
2006
|
-
let i = await e.select().from(
|
|
2007
|
-
return i ?
|
|
2050
|
+
let i = await e.select().from(qe).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).get();
|
|
2051
|
+
return i ? cn(i) : null;
|
|
2008
2052
|
},
|
|
2009
2053
|
async getByDomain(t) {
|
|
2010
|
-
let n = await e.select().from(
|
|
2054
|
+
let n = await e.select().from(qe).where(a(qe.domain, t)).get();
|
|
2011
2055
|
return n ? {
|
|
2012
|
-
...
|
|
2056
|
+
...cn(n),
|
|
2013
2057
|
tenant_id: n.tenant_id
|
|
2014
2058
|
} : null;
|
|
2015
2059
|
},
|
|
2016
2060
|
async list(t) {
|
|
2017
|
-
return (await e.select().from(
|
|
2061
|
+
return (await e.select().from(qe).where(a(qe.tenant_id, t)).all()).map(cn);
|
|
2018
2062
|
},
|
|
2019
2063
|
async update(n, r, i) {
|
|
2020
2064
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2021
|
-
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(
|
|
2065
|
+
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(qe).set(o).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).returning()).length > 0;
|
|
2022
2066
|
},
|
|
2023
2067
|
async remove(n, r) {
|
|
2024
|
-
return (await e.delete(
|
|
2068
|
+
return (await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).returning()).length > 0;
|
|
2025
2069
|
}
|
|
2026
2070
|
};
|
|
2027
2071
|
}
|
|
2028
2072
|
//#endregion
|
|
2029
2073
|
//#region src/adapters/customText.ts
|
|
2030
|
-
function
|
|
2074
|
+
function un(e) {
|
|
2031
2075
|
return {
|
|
2032
2076
|
async get(n, r, i) {
|
|
2033
|
-
let o = await e.select().from(
|
|
2077
|
+
let o = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.prompt, r), a(lt.language, i))).get();
|
|
2034
2078
|
if (!o) return null;
|
|
2035
2079
|
try {
|
|
2036
2080
|
return JSON.parse(o.custom_text);
|
|
@@ -2040,7 +2084,7 @@ function an(e) {
|
|
|
2040
2084
|
},
|
|
2041
2085
|
async set(t, n, r, i) {
|
|
2042
2086
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2043
|
-
await e.insert(
|
|
2087
|
+
await e.insert(lt).values({
|
|
2044
2088
|
tenant_id: t,
|
|
2045
2089
|
prompt: n,
|
|
2046
2090
|
language: r,
|
|
@@ -2049,9 +2093,9 @@ function an(e) {
|
|
|
2049
2093
|
updated_at_ts: a
|
|
2050
2094
|
}).onConflictDoUpdate({
|
|
2051
2095
|
target: [
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2096
|
+
lt.tenant_id,
|
|
2097
|
+
lt.prompt,
|
|
2098
|
+
lt.language
|
|
2055
2099
|
],
|
|
2056
2100
|
set: {
|
|
2057
2101
|
custom_text: o,
|
|
@@ -2060,23 +2104,23 @@ function an(e) {
|
|
|
2060
2104
|
});
|
|
2061
2105
|
},
|
|
2062
2106
|
async delete(n, r, i) {
|
|
2063
|
-
await e.delete(
|
|
2107
|
+
await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.prompt, r), a(lt.language, i)));
|
|
2064
2108
|
},
|
|
2065
2109
|
async list(t) {
|
|
2066
2110
|
return await e.select({
|
|
2067
|
-
prompt:
|
|
2068
|
-
language:
|
|
2069
|
-
}).from(
|
|
2111
|
+
prompt: lt.prompt,
|
|
2112
|
+
language: lt.language
|
|
2113
|
+
}).from(lt).where(a(lt.tenant_id, t)).all();
|
|
2070
2114
|
}
|
|
2071
2115
|
};
|
|
2072
2116
|
}
|
|
2073
2117
|
//#endregion
|
|
2074
2118
|
//#region src/adapters/emailProviders.ts
|
|
2075
|
-
function
|
|
2119
|
+
function dn(e) {
|
|
2076
2120
|
return {
|
|
2077
2121
|
async create(t, n) {
|
|
2078
2122
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2079
|
-
await e.insert(
|
|
2123
|
+
await e.insert(it).values({
|
|
2080
2124
|
tenant_id: t,
|
|
2081
2125
|
name: n.name,
|
|
2082
2126
|
enabled: n.enabled,
|
|
@@ -2088,7 +2132,7 @@ function on(e) {
|
|
|
2088
2132
|
});
|
|
2089
2133
|
},
|
|
2090
2134
|
async get(t) {
|
|
2091
|
-
let n = await e.select().from(
|
|
2135
|
+
let n = await e.select().from(it).where(a(it.tenant_id, t)).get();
|
|
2092
2136
|
if (!n) return null;
|
|
2093
2137
|
let { tenant_id: r, ...i } = n;
|
|
2094
2138
|
return D({
|
|
@@ -2100,16 +2144,16 @@ function on(e) {
|
|
|
2100
2144
|
},
|
|
2101
2145
|
async update(t, n) {
|
|
2102
2146
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
2147
|
+
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(it).set(r).where(a(it.tenant_id, t));
|
|
2104
2148
|
},
|
|
2105
2149
|
async remove(t) {
|
|
2106
|
-
await e.delete(
|
|
2150
|
+
await e.delete(it).where(a(it.tenant_id, t));
|
|
2107
2151
|
}
|
|
2108
2152
|
};
|
|
2109
2153
|
}
|
|
2110
2154
|
//#endregion
|
|
2111
2155
|
//#region src/adapters/emailTemplates.ts
|
|
2112
|
-
function
|
|
2156
|
+
function fn(e) {
|
|
2113
2157
|
return D({
|
|
2114
2158
|
template: e.template,
|
|
2115
2159
|
body: e.body,
|
|
@@ -2122,18 +2166,18 @@ function sn(e) {
|
|
|
2122
2166
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2123
2167
|
});
|
|
2124
2168
|
}
|
|
2125
|
-
function
|
|
2169
|
+
function pn(e) {
|
|
2126
2170
|
return {
|
|
2127
2171
|
async get(n, r) {
|
|
2128
|
-
let i = await e.select().from(
|
|
2129
|
-
return i ?
|
|
2172
|
+
let i = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.template, r))).get();
|
|
2173
|
+
return i ? fn(i) : null;
|
|
2130
2174
|
},
|
|
2131
2175
|
async list(t) {
|
|
2132
|
-
return (await e.select().from(
|
|
2176
|
+
return (await e.select().from(at).where(a(at.tenant_id, t)).all()).map(fn);
|
|
2133
2177
|
},
|
|
2134
2178
|
async create(t, n) {
|
|
2135
2179
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2136
|
-
return await e.insert(
|
|
2180
|
+
return await e.insert(at).values({
|
|
2137
2181
|
tenant_id: t,
|
|
2138
2182
|
template: n.template,
|
|
2139
2183
|
body: n.body,
|
|
@@ -2151,23 +2195,23 @@ function cn(e) {
|
|
|
2151
2195
|
async update(n, r, i) {
|
|
2152
2196
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2153
2197
|
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);
|
|
2154
|
-
let s = await e.update(
|
|
2198
|
+
let s = await e.update(at).set(o).where(t(a(at.tenant_id, n), a(at.template, r))).run();
|
|
2155
2199
|
return Number(s.changes ?? 0) > 0;
|
|
2156
2200
|
},
|
|
2157
2201
|
async remove(n, r) {
|
|
2158
|
-
let i = await e.delete(
|
|
2202
|
+
let i = await e.delete(at).where(t(a(at.tenant_id, n), a(at.template, r))).run();
|
|
2159
2203
|
return Number(i.changes ?? 0) > 0;
|
|
2160
2204
|
}
|
|
2161
2205
|
};
|
|
2162
2206
|
}
|
|
2163
2207
|
//#endregion
|
|
2164
2208
|
//#region src/adapters/flows.ts
|
|
2165
|
-
var
|
|
2166
|
-
function
|
|
2209
|
+
var mn = ["id", "name"];
|
|
2210
|
+
function hn(e) {
|
|
2167
2211
|
return {
|
|
2168
2212
|
async create(t, n) {
|
|
2169
2213
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2170
|
-
return await e.insert(
|
|
2214
|
+
return await e.insert(nt).values({
|
|
2171
2215
|
id: i,
|
|
2172
2216
|
tenant_id: t,
|
|
2173
2217
|
name: n.name,
|
|
@@ -2183,7 +2227,7 @@ function un(e) {
|
|
|
2183
2227
|
};
|
|
2184
2228
|
},
|
|
2185
2229
|
async get(n, r) {
|
|
2186
|
-
let i = await e.select().from(
|
|
2230
|
+
let i = await e.select().from(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).get();
|
|
2187
2231
|
if (!i) return null;
|
|
2188
2232
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2189
2233
|
return D({
|
|
@@ -2193,20 +2237,20 @@ function un(e) {
|
|
|
2193
2237
|
},
|
|
2194
2238
|
async update(n, r, i) {
|
|
2195
2239
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2196
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2240
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(nt).set(o).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2197
2241
|
},
|
|
2198
2242
|
async list(o, s) {
|
|
2199
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2243
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(nt.tenant_id, o)];
|
|
2200
2244
|
if (f) {
|
|
2201
|
-
let e =
|
|
2245
|
+
let e = Ee(f, mn);
|
|
2202
2246
|
if (e) {
|
|
2203
|
-
let t =
|
|
2247
|
+
let t = St(nt, e, []);
|
|
2204
2248
|
t && p.push(t);
|
|
2205
2249
|
}
|
|
2206
2250
|
}
|
|
2207
|
-
let m = t(...p), h = e.select().from(
|
|
2251
|
+
let m = t(...p), h = e.select().from(nt).where(m).$dynamic();
|
|
2208
2252
|
if (d?.sort_by) {
|
|
2209
|
-
let e =
|
|
2253
|
+
let e = nt[d.sort_by];
|
|
2210
2254
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2211
2255
|
}
|
|
2212
2256
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
@@ -2217,7 +2261,7 @@ function un(e) {
|
|
|
2217
2261
|
});
|
|
2218
2262
|
});
|
|
2219
2263
|
if (!u) return { flows: g };
|
|
2220
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2264
|
+
let [_] = await e.select({ count: r() }).from(nt).where(m);
|
|
2221
2265
|
return {
|
|
2222
2266
|
flows: g,
|
|
2223
2267
|
start: c * l,
|
|
@@ -2226,18 +2270,18 @@ function un(e) {
|
|
|
2226
2270
|
};
|
|
2227
2271
|
},
|
|
2228
2272
|
async remove(n, r) {
|
|
2229
|
-
return (await e.delete(
|
|
2273
|
+
return (await e.delete(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length > 0;
|
|
2230
2274
|
}
|
|
2231
2275
|
};
|
|
2232
2276
|
}
|
|
2233
2277
|
//#endregion
|
|
2234
2278
|
//#region src/adapters/forms.ts
|
|
2235
|
-
var
|
|
2279
|
+
var gn = [
|
|
2236
2280
|
"nodes",
|
|
2237
2281
|
"start",
|
|
2238
2282
|
"ending"
|
|
2239
|
-
],
|
|
2240
|
-
function
|
|
2283
|
+
], _n = ["name"];
|
|
2284
|
+
function vn(e) {
|
|
2241
2285
|
return {
|
|
2242
2286
|
async create(t, n) {
|
|
2243
2287
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2251,8 +2295,8 @@ function pn(e) {
|
|
|
2251
2295
|
created_at: r,
|
|
2252
2296
|
updated_at: r
|
|
2253
2297
|
};
|
|
2254
|
-
for (let e of
|
|
2255
|
-
return await e.insert(
|
|
2298
|
+
for (let e of gn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2299
|
+
return await e.insert(tt).values(a), {
|
|
2256
2300
|
id: i,
|
|
2257
2301
|
...n,
|
|
2258
2302
|
created_at: r,
|
|
@@ -2260,38 +2304,38 @@ function pn(e) {
|
|
|
2260
2304
|
};
|
|
2261
2305
|
},
|
|
2262
2306
|
async get(n, r) {
|
|
2263
|
-
let i = await e.select().from(
|
|
2307
|
+
let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).get();
|
|
2264
2308
|
if (!i) return null;
|
|
2265
2309
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2266
|
-
for (let e of
|
|
2310
|
+
for (let e of gn) c[e] = Z(s[e]);
|
|
2267
2311
|
return D(c);
|
|
2268
2312
|
},
|
|
2269
2313
|
async update(n, r, i) {
|
|
2270
2314
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2271
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2272
|
-
return (await e.update(
|
|
2315
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (gn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2316
|
+
return (await e.update(tt).set(o).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
|
|
2273
2317
|
},
|
|
2274
2318
|
async list(o, s) {
|
|
2275
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2319
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(tt.tenant_id, o)];
|
|
2276
2320
|
if (f) {
|
|
2277
|
-
let e =
|
|
2321
|
+
let e = Ee(f, _n);
|
|
2278
2322
|
if (e) {
|
|
2279
|
-
let t =
|
|
2323
|
+
let t = St(tt, e, _n);
|
|
2280
2324
|
t && p.push(t);
|
|
2281
2325
|
}
|
|
2282
2326
|
}
|
|
2283
|
-
let m = t(...p), h = e.select().from(
|
|
2327
|
+
let m = t(...p), h = e.select().from(tt).where(m).$dynamic();
|
|
2284
2328
|
if (d?.sort_by) {
|
|
2285
|
-
let e =
|
|
2329
|
+
let e = tt[d.sort_by];
|
|
2286
2330
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2287
2331
|
}
|
|
2288
2332
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2289
2333
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2290
|
-
for (let e of
|
|
2334
|
+
for (let e of gn) r[e] = Z(n[e]);
|
|
2291
2335
|
return D(r);
|
|
2292
2336
|
});
|
|
2293
2337
|
if (!u) return { forms: g };
|
|
2294
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2338
|
+
let [_] = await e.select({ count: r() }).from(tt).where(m);
|
|
2295
2339
|
return {
|
|
2296
2340
|
forms: g,
|
|
2297
2341
|
start: c * l,
|
|
@@ -2300,13 +2344,13 @@ function pn(e) {
|
|
|
2300
2344
|
};
|
|
2301
2345
|
},
|
|
2302
2346
|
async remove(n, r) {
|
|
2303
|
-
return (await e.delete(
|
|
2347
|
+
return (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
|
|
2304
2348
|
}
|
|
2305
2349
|
};
|
|
2306
2350
|
}
|
|
2307
2351
|
//#endregion
|
|
2308
2352
|
//#region src/adapters/grants.ts
|
|
2309
|
-
function
|
|
2353
|
+
function yn(e) {
|
|
2310
2354
|
return {
|
|
2311
2355
|
id: e.id,
|
|
2312
2356
|
user_id: e.user_id,
|
|
@@ -2315,17 +2359,17 @@ function mn(e) {
|
|
|
2315
2359
|
scope: Z(e.scope, []) ?? []
|
|
2316
2360
|
};
|
|
2317
2361
|
}
|
|
2318
|
-
var
|
|
2362
|
+
var bn = {
|
|
2319
2363
|
user_id: z.user_id,
|
|
2320
2364
|
client_id: z.client_id,
|
|
2321
2365
|
audience: z.audience,
|
|
2322
2366
|
created_at: z.created_at,
|
|
2323
2367
|
updated_at: z.updated_at
|
|
2324
2368
|
};
|
|
2325
|
-
function
|
|
2326
|
-
return Object.hasOwn(
|
|
2369
|
+
function xn(e) {
|
|
2370
|
+
return Object.hasOwn(bn, e) ? bn[e] : void 0;
|
|
2327
2371
|
}
|
|
2328
|
-
function
|
|
2372
|
+
function Sn(e) {
|
|
2329
2373
|
return {
|
|
2330
2374
|
async create(n, r) {
|
|
2331
2375
|
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();
|
|
@@ -2334,7 +2378,7 @@ function _n(e) {
|
|
|
2334
2378
|
return await e.update(z).set({
|
|
2335
2379
|
scope: JSON.stringify(s),
|
|
2336
2380
|
updated_at: i
|
|
2337
|
-
}).where(t(a(z.tenant_id, n), a(z.id, c.id))),
|
|
2381
|
+
}).where(t(a(z.tenant_id, n), a(z.id, c.id))), yn({
|
|
2338
2382
|
...c,
|
|
2339
2383
|
scope: JSON.stringify(s)
|
|
2340
2384
|
});
|
|
@@ -2359,16 +2403,16 @@ function _n(e) {
|
|
|
2359
2403
|
},
|
|
2360
2404
|
async get(n, r, i, o) {
|
|
2361
2405
|
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();
|
|
2362
|
-
return s ?
|
|
2406
|
+
return s ? yn(s) : null;
|
|
2363
2407
|
},
|
|
2364
2408
|
async list(o, s) {
|
|
2365
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2409
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(z, f, [
|
|
2366
2410
|
"user_id",
|
|
2367
2411
|
"client_id",
|
|
2368
2412
|
"audience"
|
|
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 ?
|
|
2413
|
+
]) : 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 ? xn(d.sort_by) : void 0;
|
|
2370
2414
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(z.created_at));
|
|
2371
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2415
|
+
let _ = (await h.offset(c * l).limit(l)).map(yn);
|
|
2372
2416
|
if (!u) return {
|
|
2373
2417
|
grants: _,
|
|
2374
2418
|
start: 0,
|
|
@@ -2393,11 +2437,11 @@ function _n(e) {
|
|
|
2393
2437
|
}
|
|
2394
2438
|
//#endregion
|
|
2395
2439
|
//#region src/adapters/hookCode.ts
|
|
2396
|
-
var
|
|
2397
|
-
function
|
|
2398
|
-
return `hc_${
|
|
2440
|
+
var Cn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2441
|
+
function wn() {
|
|
2442
|
+
return `hc_${Cn()}`;
|
|
2399
2443
|
}
|
|
2400
|
-
function
|
|
2444
|
+
function Tn(e) {
|
|
2401
2445
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2402
2446
|
created_at_ts: t,
|
|
2403
2447
|
updated_at_ts: n
|
|
@@ -2408,41 +2452,41 @@ function bn(e) {
|
|
|
2408
2452
|
secrets: r ? JSON.parse(r) : void 0
|
|
2409
2453
|
};
|
|
2410
2454
|
}
|
|
2411
|
-
function
|
|
2455
|
+
function En(e) {
|
|
2412
2456
|
return {
|
|
2413
2457
|
async create(t, n) {
|
|
2414
2458
|
let r = Date.now(), i = {
|
|
2415
|
-
id:
|
|
2459
|
+
id: wn(),
|
|
2416
2460
|
tenant_id: t,
|
|
2417
2461
|
code: n.code,
|
|
2418
2462
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2419
2463
|
created_at_ts: r,
|
|
2420
2464
|
updated_at_ts: r
|
|
2421
2465
|
};
|
|
2422
|
-
return await e.insert(
|
|
2466
|
+
return await e.insert(st).values(i), Tn({
|
|
2423
2467
|
...i,
|
|
2424
2468
|
tenant_id: t
|
|
2425
2469
|
});
|
|
2426
2470
|
},
|
|
2427
2471
|
async get(n, r) {
|
|
2428
|
-
let i = await e.select().from(
|
|
2429
|
-
return i ?
|
|
2472
|
+
let i = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.id, r))).get();
|
|
2473
|
+
return i ? Tn(i) : null;
|
|
2430
2474
|
},
|
|
2431
2475
|
async update(n, r, i) {
|
|
2432
2476
|
let o = { updated_at_ts: Date.now() };
|
|
2433
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2477
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(st).set(o).where(t(a(st.tenant_id, n), a(st.id, r))).returning()).length > 0;
|
|
2434
2478
|
},
|
|
2435
2479
|
async remove(n, r) {
|
|
2436
|
-
return (await e.delete(
|
|
2480
|
+
return (await e.delete(st).where(t(a(st.tenant_id, n), a(st.id, r))).returning()).length > 0;
|
|
2437
2481
|
}
|
|
2438
2482
|
};
|
|
2439
2483
|
}
|
|
2440
2484
|
//#endregion
|
|
2441
2485
|
//#region src/adapters/hooks.ts
|
|
2442
|
-
function
|
|
2486
|
+
function Dn() {
|
|
2443
2487
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2444
2488
|
}
|
|
2445
|
-
function
|
|
2489
|
+
function On(e) {
|
|
2446
2490
|
if (!(typeof e != "string" || !e)) try {
|
|
2447
2491
|
let t = JSON.parse(e);
|
|
2448
2492
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2450,7 +2494,7 @@ function Cn(e) {
|
|
|
2450
2494
|
return;
|
|
2451
2495
|
}
|
|
2452
2496
|
}
|
|
2453
|
-
function
|
|
2497
|
+
function kn(e) {
|
|
2454
2498
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2455
2499
|
created_at_ts: n,
|
|
2456
2500
|
updated_at_ts: r
|
|
@@ -2459,15 +2503,15 @@ function wn(e) {
|
|
|
2459
2503
|
...a,
|
|
2460
2504
|
enabled: !!a.enabled,
|
|
2461
2505
|
synchronous: !!a.synchronous,
|
|
2462
|
-
metadata:
|
|
2506
|
+
metadata: On(i),
|
|
2463
2507
|
...o
|
|
2464
2508
|
});
|
|
2465
2509
|
}
|
|
2466
|
-
function
|
|
2510
|
+
function An(e) {
|
|
2467
2511
|
return {
|
|
2468
2512
|
async create(t, n) {
|
|
2469
2513
|
let r = Date.now(), i = {
|
|
2470
|
-
hook_id: n.hook_id ||
|
|
2514
|
+
hook_id: n.hook_id || Dn(),
|
|
2471
2515
|
tenant_id: t,
|
|
2472
2516
|
trigger_id: n.trigger_id,
|
|
2473
2517
|
url: n.url,
|
|
@@ -2483,30 +2527,30 @@ function Tn(e) {
|
|
|
2483
2527
|
created_at_ts: r,
|
|
2484
2528
|
updated_at_ts: r
|
|
2485
2529
|
};
|
|
2486
|
-
return await e.insert(
|
|
2530
|
+
return await e.insert(ot).values(i), kn({
|
|
2487
2531
|
...i,
|
|
2488
2532
|
tenant_id: t
|
|
2489
2533
|
});
|
|
2490
2534
|
},
|
|
2491
2535
|
async get(n, r) {
|
|
2492
|
-
let i = await e.select().from(
|
|
2493
|
-
return i ?
|
|
2536
|
+
let i = await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).get();
|
|
2537
|
+
return i ? kn(i) : null;
|
|
2494
2538
|
},
|
|
2495
2539
|
async update(n, r, i) {
|
|
2496
2540
|
let o = { updated_at_ts: Date.now() };
|
|
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(
|
|
2541
|
+
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(ot).set(o).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).returning()).length > 0;
|
|
2498
2542
|
},
|
|
2499
2543
|
async list(o, s) {
|
|
2500
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2544
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(ot, f, [
|
|
2501
2545
|
"url",
|
|
2502
2546
|
"form_id",
|
|
2503
2547
|
"template_id",
|
|
2504
2548
|
"code_id"
|
|
2505
|
-
]) : void 0, m = p ? t(a(
|
|
2506
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2507
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2549
|
+
]) : void 0, m = p ? t(a(ot.tenant_id, o), p) : a(ot.tenant_id, o), h = e.select().from(ot).where(m).$dynamic(), g = d?.sort_by ? ot[d.sort_by] : void 0;
|
|
2550
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(ot.priority), n(ot.created_at_ts));
|
|
2551
|
+
let _ = (await h.offset(c * l).limit(l)).map(kn);
|
|
2508
2552
|
if (!u) return { hooks: _ };
|
|
2509
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2553
|
+
let [v] = await e.select({ count: r() }).from(ot).where(m);
|
|
2510
2554
|
return {
|
|
2511
2555
|
hooks: _,
|
|
2512
2556
|
start: c * l,
|
|
@@ -2515,31 +2559,31 @@ function Tn(e) {
|
|
|
2515
2559
|
};
|
|
2516
2560
|
},
|
|
2517
2561
|
async remove(n, r) {
|
|
2518
|
-
return (await e.delete(
|
|
2562
|
+
return (await e.delete(ot).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).returning()).length > 0;
|
|
2519
2563
|
}
|
|
2520
2564
|
};
|
|
2521
2565
|
}
|
|
2522
2566
|
//#endregion
|
|
2523
2567
|
//#region src/adapters/invites.ts
|
|
2524
|
-
function
|
|
2568
|
+
function jn() {
|
|
2525
2569
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2526
2570
|
}
|
|
2527
|
-
var
|
|
2571
|
+
var Mn = [
|
|
2528
2572
|
"inviter",
|
|
2529
2573
|
"invitee",
|
|
2530
2574
|
"app_metadata",
|
|
2531
2575
|
"user_metadata",
|
|
2532
2576
|
"roles"
|
|
2533
2577
|
];
|
|
2534
|
-
function
|
|
2578
|
+
function Nn(e) {
|
|
2535
2579
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2536
|
-
for (let e of
|
|
2580
|
+
for (let e of Mn) i[e] = Z(r[e], e === "roles" ? [] : {});
|
|
2537
2581
|
return i.send_invitation_email = !!n, D(i);
|
|
2538
2582
|
}
|
|
2539
|
-
function
|
|
2583
|
+
function Pn(e) {
|
|
2540
2584
|
return {
|
|
2541
2585
|
async create(t, n) {
|
|
2542
|
-
let r = n.id ||
|
|
2586
|
+
let r = n.id || jn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2543
2587
|
id: r,
|
|
2544
2588
|
tenant_id: t,
|
|
2545
2589
|
organization_id: n.organization_id,
|
|
@@ -2552,35 +2596,35 @@ function kn(e) {
|
|
|
2552
2596
|
created_at: a.toISOString(),
|
|
2553
2597
|
expires_at: o
|
|
2554
2598
|
};
|
|
2555
|
-
for (let e of
|
|
2599
|
+
for (let e of Mn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2556
2600
|
try {
|
|
2557
|
-
await e.insert(
|
|
2601
|
+
await e.insert(Ye).values(s);
|
|
2558
2602
|
} catch (e) {
|
|
2559
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
2603
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Invite already exists" }) : e;
|
|
2560
2604
|
}
|
|
2561
|
-
return
|
|
2605
|
+
return Nn({
|
|
2562
2606
|
...s,
|
|
2563
2607
|
tenant_id: t
|
|
2564
2608
|
});
|
|
2565
2609
|
},
|
|
2566
2610
|
async get(n, r) {
|
|
2567
|
-
let i = await e.select().from(
|
|
2568
|
-
return i ?
|
|
2611
|
+
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).get();
|
|
2612
|
+
return i ? Nn(i) : null;
|
|
2569
2613
|
},
|
|
2570
2614
|
async update(n, r, i) {
|
|
2571
2615
|
let o = {};
|
|
2572
|
-
for (let e of
|
|
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(
|
|
2616
|
+
for (let e of Mn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2617
|
+
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(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
|
|
2574
2618
|
},
|
|
2575
2619
|
async list(t, o) {
|
|
2576
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2620
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Ye).where(a(Ye.tenant_id, t)).$dynamic();
|
|
2577
2621
|
if (u?.sort_by) {
|
|
2578
|
-
let e =
|
|
2622
|
+
let e = Ye[u.sort_by];
|
|
2579
2623
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2580
2624
|
}
|
|
2581
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2625
|
+
let f = (await d.offset(s * c).limit(c)).map(Nn);
|
|
2582
2626
|
if (!l) return { invites: f };
|
|
2583
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2627
|
+
let [p] = await e.select({ count: r() }).from(Ye).where(a(Ye.tenant_id, t));
|
|
2584
2628
|
return {
|
|
2585
2629
|
invites: f,
|
|
2586
2630
|
start: s * c,
|
|
@@ -2589,39 +2633,39 @@ function kn(e) {
|
|
|
2589
2633
|
};
|
|
2590
2634
|
},
|
|
2591
2635
|
async remove(n, r) {
|
|
2592
|
-
return (await e.delete(
|
|
2636
|
+
return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
|
|
2593
2637
|
}
|
|
2594
2638
|
};
|
|
2595
2639
|
}
|
|
2596
2640
|
//#endregion
|
|
2597
2641
|
//#region src/adapters/keys.ts
|
|
2598
|
-
var
|
|
2642
|
+
var Fn = [
|
|
2599
2643
|
"kid",
|
|
2600
2644
|
"connection",
|
|
2601
2645
|
"fingerprint",
|
|
2602
2646
|
"thumbprint",
|
|
2603
2647
|
"type"
|
|
2604
2648
|
];
|
|
2605
|
-
function
|
|
2649
|
+
function In(e) {
|
|
2606
2650
|
return {
|
|
2607
2651
|
async create(t) {
|
|
2608
|
-
await e.insert(
|
|
2652
|
+
await e.insert(ct).values({
|
|
2609
2653
|
...t,
|
|
2610
2654
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2611
2655
|
});
|
|
2612
2656
|
},
|
|
2613
2657
|
async list(a) {
|
|
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(
|
|
2658
|
+
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(ct.revoked_at, p), f(ct.revoked_at))];
|
|
2615
2659
|
if (d) {
|
|
2616
|
-
let e =
|
|
2660
|
+
let e = Ee(d, Fn);
|
|
2617
2661
|
if (e) {
|
|
2618
|
-
let t =
|
|
2662
|
+
let t = St(ct, e, Fn);
|
|
2619
2663
|
t && m.push(t);
|
|
2620
2664
|
}
|
|
2621
2665
|
}
|
|
2622
|
-
let h = t(...m), g = e.select().from(
|
|
2666
|
+
let h = t(...m), g = e.select().from(ct).where(h).$dynamic();
|
|
2623
2667
|
if (u?.sort_by) {
|
|
2624
|
-
let e =
|
|
2668
|
+
let e = ct[u.sort_by];
|
|
2625
2669
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2626
2670
|
}
|
|
2627
2671
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2629,7 +2673,7 @@ function jn(e) {
|
|
|
2629
2673
|
return D(n);
|
|
2630
2674
|
});
|
|
2631
2675
|
if (!l) return { signingKeys: _ };
|
|
2632
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2676
|
+
let [y] = await e.select({ count: r() }).from(ct).where(h);
|
|
2633
2677
|
return {
|
|
2634
2678
|
signingKeys: _,
|
|
2635
2679
|
start: o * c,
|
|
@@ -2638,22 +2682,22 @@ function jn(e) {
|
|
|
2638
2682
|
};
|
|
2639
2683
|
},
|
|
2640
2684
|
async update(t, n) {
|
|
2641
|
-
return (await e.update(
|
|
2685
|
+
return (await e.update(ct).set(n).where(a(ct.kid, t)).returning()).length > 0;
|
|
2642
2686
|
}
|
|
2643
2687
|
};
|
|
2644
2688
|
}
|
|
2645
2689
|
//#endregion
|
|
2646
2690
|
//#region src/adapters/loginSessions.ts
|
|
2647
|
-
var
|
|
2648
|
-
function
|
|
2691
|
+
var Ln = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Rn = 32;
|
|
2692
|
+
function zn() {
|
|
2649
2693
|
let e = Date.now(), t = "";
|
|
2650
|
-
for (let n = 10; n > 0; n--) t =
|
|
2694
|
+
for (let n = 10; n > 0; n--) t = Ln.charAt(e % Rn) + t, e = Math.floor(e / Rn);
|
|
2651
2695
|
let n = new Uint8Array(16);
|
|
2652
2696
|
crypto.getRandomValues(n);
|
|
2653
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2697
|
+
for (let e = 0; e < 16; e++) t += Ln.charAt(n[e] % Rn);
|
|
2654
2698
|
return t;
|
|
2655
2699
|
}
|
|
2656
|
-
function
|
|
2700
|
+
function Bn(e) {
|
|
2657
2701
|
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({
|
|
2658
2702
|
created_at_ts: n,
|
|
2659
2703
|
updated_at_ts: r,
|
|
@@ -2665,17 +2709,17 @@ function Fn(e) {
|
|
|
2665
2709
|
]), l = {};
|
|
2666
2710
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2667
2711
|
return D({
|
|
2668
|
-
...
|
|
2712
|
+
...yt(l, ["auth_strategy"]),
|
|
2669
2713
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2670
2714
|
...c,
|
|
2671
2715
|
state_data: Z(a)
|
|
2672
2716
|
});
|
|
2673
2717
|
}
|
|
2674
|
-
function
|
|
2718
|
+
function Vn(e) {
|
|
2675
2719
|
return {
|
|
2676
2720
|
async create(t, n) {
|
|
2677
2721
|
let r = Date.now(), i = {
|
|
2678
|
-
id:
|
|
2722
|
+
id: zn(),
|
|
2679
2723
|
tenant_id: t,
|
|
2680
2724
|
session_id: n.session_id,
|
|
2681
2725
|
csrf_token: n.csrf_token,
|
|
@@ -2696,14 +2740,14 @@ function In(e) {
|
|
|
2696
2740
|
updated_at_ts: r,
|
|
2697
2741
|
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2698
2742
|
};
|
|
2699
|
-
return await e.insert(P).values(i),
|
|
2743
|
+
return await e.insert(P).values(i), Bn({
|
|
2700
2744
|
...i,
|
|
2701
2745
|
tenant_id: t
|
|
2702
2746
|
});
|
|
2703
2747
|
},
|
|
2704
2748
|
async get(n, r) {
|
|
2705
2749
|
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();
|
|
2706
|
-
return o ?
|
|
2750
|
+
return o ? Bn(o) : null;
|
|
2707
2751
|
},
|
|
2708
2752
|
async update(n, r, i) {
|
|
2709
2753
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2723,7 +2767,7 @@ function In(e) {
|
|
|
2723
2767
|
}
|
|
2724
2768
|
//#endregion
|
|
2725
2769
|
//#region src/adapters/logs.ts
|
|
2726
|
-
function
|
|
2770
|
+
function Hn(e) {
|
|
2727
2771
|
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 = {
|
|
2728
2772
|
...f,
|
|
2729
2773
|
isMobile: !!n,
|
|
@@ -2740,7 +2784,7 @@ function Ln(e) {
|
|
|
2740
2784
|
continent_code: u
|
|
2741
2785
|
})), D(p);
|
|
2742
2786
|
}
|
|
2743
|
-
function
|
|
2787
|
+
function Un(e) {
|
|
2744
2788
|
return {
|
|
2745
2789
|
async create(t, n) {
|
|
2746
2790
|
let r = {
|
|
@@ -2766,7 +2810,7 @@ function Rn(e) {
|
|
|
2766
2810
|
hostname: n.hostname,
|
|
2767
2811
|
session_connection: n.session_connection
|
|
2768
2812
|
};
|
|
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),
|
|
2813
|
+
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), Hn({
|
|
2770
2814
|
...r,
|
|
2771
2815
|
tenant_id: t
|
|
2772
2816
|
});
|
|
@@ -2774,7 +2818,7 @@ function Rn(e) {
|
|
|
2774
2818
|
async list(o, s) {
|
|
2775
2819
|
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)];
|
|
2776
2820
|
if (p) {
|
|
2777
|
-
let e =
|
|
2821
|
+
let e = St(q, p, [
|
|
2778
2822
|
"user_id",
|
|
2779
2823
|
"ip",
|
|
2780
2824
|
"type",
|
|
@@ -2784,14 +2828,14 @@ function Rn(e) {
|
|
|
2784
2828
|
}
|
|
2785
2829
|
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()));
|
|
2786
2830
|
let v = t(..._);
|
|
2787
|
-
if (
|
|
2788
|
-
if (f?.sort_by && f.sort_by !== "date") throw new
|
|
2831
|
+
if (Pt(s)) {
|
|
2832
|
+
if (f?.sort_by && f.sort_by !== "date") throw new Re(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2789
2833
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2790
2834
|
sortColumn: q.date,
|
|
2791
2835
|
idColumn: q.log_id,
|
|
2792
2836
|
sortOrder: n,
|
|
2793
2837
|
sortKey: `date:${n}`
|
|
2794
|
-
}, i =
|
|
2838
|
+
}, i = Lt(s, r), a = Ft(s), { rows: o, next: c } = Rt(await e.select().from(q).where(i ? t(v, i) : v).orderBy(...It(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Hn);
|
|
2795
2839
|
return {
|
|
2796
2840
|
logs: l,
|
|
2797
2841
|
start: 0,
|
|
@@ -2805,7 +2849,7 @@ function Rn(e) {
|
|
|
2805
2849
|
let e = q[f.sort_by];
|
|
2806
2850
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2807
2851
|
} else y = y.orderBy(i(q.date));
|
|
2808
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2852
|
+
let ee = (await y.offset(l * u).limit(u)).map(Hn);
|
|
2809
2853
|
if (!d) return { logs: ee };
|
|
2810
2854
|
let [b] = await e.select({ count: r() }).from(q).where(v);
|
|
2811
2855
|
return {
|
|
@@ -2817,22 +2861,22 @@ function Rn(e) {
|
|
|
2817
2861
|
},
|
|
2818
2862
|
async get(n, r) {
|
|
2819
2863
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.log_id, r))).get();
|
|
2820
|
-
return i ?
|
|
2864
|
+
return i ? Hn(i) : null;
|
|
2821
2865
|
}
|
|
2822
2866
|
};
|
|
2823
2867
|
}
|
|
2824
2868
|
//#endregion
|
|
2825
2869
|
//#region src/adapters/authenticationMethods.ts
|
|
2826
|
-
var
|
|
2827
|
-
function
|
|
2870
|
+
var Wn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Gn = 32;
|
|
2871
|
+
function Kn() {
|
|
2828
2872
|
let e = Date.now(), t = "";
|
|
2829
|
-
for (let n = 10; n > 0; n--) t =
|
|
2873
|
+
for (let n = 10; n > 0; n--) t = Wn.charAt(e % Gn) + t, e = Math.floor(e / Gn);
|
|
2830
2874
|
let n = new Uint8Array(16);
|
|
2831
2875
|
crypto.getRandomValues(n);
|
|
2832
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2876
|
+
for (let e = 0; e < 16; e++) t += Wn.charAt(n[e] % Gn);
|
|
2833
2877
|
return t;
|
|
2834
2878
|
}
|
|
2835
|
-
function
|
|
2879
|
+
function qn(e) {
|
|
2836
2880
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2837
2881
|
return D({
|
|
2838
2882
|
...s,
|
|
@@ -2843,11 +2887,11 @@ function Hn(e) {
|
|
|
2843
2887
|
updated_at: oe(r)
|
|
2844
2888
|
});
|
|
2845
2889
|
}
|
|
2846
|
-
function
|
|
2890
|
+
function Jn(e) {
|
|
2847
2891
|
return {
|
|
2848
2892
|
async create(t, n) {
|
|
2849
2893
|
let r = Date.now(), i = {
|
|
2850
|
-
id: n.id ||
|
|
2894
|
+
id: n.id || Kn(),
|
|
2851
2895
|
tenant_id: t,
|
|
2852
2896
|
user_id: n.user_id,
|
|
2853
2897
|
type: n.type,
|
|
@@ -2863,41 +2907,41 @@ function Un(e) {
|
|
|
2863
2907
|
created_at_ts: r,
|
|
2864
2908
|
updated_at_ts: r
|
|
2865
2909
|
};
|
|
2866
|
-
return await e.insert(
|
|
2910
|
+
return await e.insert(dt).values(i), qn({
|
|
2867
2911
|
...i,
|
|
2868
2912
|
tenant_id: t
|
|
2869
2913
|
});
|
|
2870
2914
|
},
|
|
2871
2915
|
async get(n, r) {
|
|
2872
|
-
let i = await e.select().from(
|
|
2873
|
-
return i ?
|
|
2916
|
+
let i = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).get();
|
|
2917
|
+
return i ? qn(i) : null;
|
|
2874
2918
|
},
|
|
2875
2919
|
async getByCredentialId(n, r) {
|
|
2876
|
-
let i = await e.select().from(
|
|
2877
|
-
return i ?
|
|
2920
|
+
let i = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.credential_id, r))).get();
|
|
2921
|
+
return i ? qn(i) : null;
|
|
2878
2922
|
},
|
|
2879
2923
|
async list(n, r) {
|
|
2880
|
-
return (await e.select().from(
|
|
2924
|
+
return (await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.user_id, r))).all()).map(qn);
|
|
2881
2925
|
},
|
|
2882
2926
|
async update(n, r, i) {
|
|
2883
2927
|
let o = { updated_at_ts: Date.now() };
|
|
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(
|
|
2928
|
+
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(dt).set(o).where(t(a(dt.tenant_id, n), a(dt.id, r)));
|
|
2885
2929
|
let s = await this.get(n, r);
|
|
2886
2930
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2887
2931
|
return s;
|
|
2888
2932
|
},
|
|
2889
2933
|
async remove(n, r) {
|
|
2890
|
-
return (await e.delete(
|
|
2934
|
+
return (await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).returning()).length > 0;
|
|
2891
2935
|
}
|
|
2892
2936
|
};
|
|
2893
2937
|
}
|
|
2894
2938
|
//#endregion
|
|
2895
2939
|
//#region src/adapters/organizations.ts
|
|
2896
|
-
var
|
|
2897
|
-
function
|
|
2940
|
+
var Yn = ["name", "display_name"];
|
|
2941
|
+
function Xn() {
|
|
2898
2942
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2899
2943
|
}
|
|
2900
|
-
function
|
|
2944
|
+
function Zn(e) {
|
|
2901
2945
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2902
2946
|
return D({
|
|
2903
2947
|
...o,
|
|
@@ -2907,11 +2951,11 @@ function Kn(e) {
|
|
|
2907
2951
|
token_quota: Z(a, {})
|
|
2908
2952
|
});
|
|
2909
2953
|
}
|
|
2910
|
-
function
|
|
2954
|
+
function Qn(e) {
|
|
2911
2955
|
return {
|
|
2912
2956
|
async create(t, n) {
|
|
2913
2957
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2914
|
-
id: n.id ||
|
|
2958
|
+
id: n.id || Xn(),
|
|
2915
2959
|
tenant_id: t,
|
|
2916
2960
|
name: n.name,
|
|
2917
2961
|
display_name: n.display_name,
|
|
@@ -2925,16 +2969,16 @@ function qn(e) {
|
|
|
2925
2969
|
try {
|
|
2926
2970
|
await e.insert(V).values(i);
|
|
2927
2971
|
} catch (e) {
|
|
2928
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new
|
|
2972
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "Organization already exists" }) : e;
|
|
2929
2973
|
}
|
|
2930
|
-
return
|
|
2974
|
+
return Zn({
|
|
2931
2975
|
...i,
|
|
2932
2976
|
tenant_id: t
|
|
2933
2977
|
});
|
|
2934
2978
|
},
|
|
2935
2979
|
async get(n, r) {
|
|
2936
2980
|
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
2937
|
-
return i ||= await e.select().from(V).where(t(a(V.tenant_id, n), a(V.name, r))).get(), i ?
|
|
2981
|
+
return i ||= await e.select().from(V).where(t(a(V.tenant_id, n), a(V.name, r))).get(), i ? Zn(i) : null;
|
|
2938
2982
|
},
|
|
2939
2983
|
async update(n, r, i) {
|
|
2940
2984
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2943,19 +2987,19 @@ function qn(e) {
|
|
|
2943
2987
|
async list(o, s) {
|
|
2944
2988
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(V.tenant_id, o)];
|
|
2945
2989
|
if (f) {
|
|
2946
|
-
let e =
|
|
2990
|
+
let e = Ee(f, Yn);
|
|
2947
2991
|
if (e) {
|
|
2948
|
-
let t =
|
|
2992
|
+
let t = St(V, e, Yn);
|
|
2949
2993
|
t && p.push(t);
|
|
2950
2994
|
}
|
|
2951
2995
|
}
|
|
2952
2996
|
let m = t(...p);
|
|
2953
|
-
if (
|
|
2997
|
+
if (Pt(s)) {
|
|
2954
2998
|
let n = {
|
|
2955
2999
|
sortColumn: V.created_at,
|
|
2956
3000
|
idColumn: V.id,
|
|
2957
3001
|
sortOrder: "desc"
|
|
2958
|
-
}, r =
|
|
3002
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(V).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at"), c = a.map(Zn);
|
|
2959
3003
|
return {
|
|
2960
3004
|
organizations: c,
|
|
2961
3005
|
start: 0,
|
|
@@ -2970,7 +3014,7 @@ function qn(e) {
|
|
|
2970
3014
|
let e = V[d.sort_by];
|
|
2971
3015
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2972
3016
|
}
|
|
2973
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3017
|
+
let g = (await h.offset(c * l).limit(l)).map(Zn);
|
|
2974
3018
|
if (!u) return { organizations: g };
|
|
2975
3019
|
let [_] = await e.select({ count: r() }).from(V).where(m);
|
|
2976
3020
|
return {
|
|
@@ -2986,15 +3030,172 @@ function qn(e) {
|
|
|
2986
3030
|
};
|
|
2987
3031
|
}
|
|
2988
3032
|
//#endregion
|
|
3033
|
+
//#region src/adapters/organizationConnections.ts
|
|
3034
|
+
function $n(e, t) {
|
|
3035
|
+
return {
|
|
3036
|
+
connection_id: e.connection_id,
|
|
3037
|
+
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
3038
|
+
show_as_button: !!e.show_as_button,
|
|
3039
|
+
is_signup_enabled: !!e.is_signup_enabled,
|
|
3040
|
+
connection: t ? {
|
|
3041
|
+
name: t.name,
|
|
3042
|
+
strategy: t.strategy
|
|
3043
|
+
} : void 0,
|
|
3044
|
+
created_at: e.created_at,
|
|
3045
|
+
updated_at: e.updated_at
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
function er(e) {
|
|
3049
|
+
async function n(n, r) {
|
|
3050
|
+
let i = await e.select({
|
|
3051
|
+
name: B.name,
|
|
3052
|
+
strategy: B.strategy
|
|
3053
|
+
}).from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
3054
|
+
if (i) return {
|
|
3055
|
+
name: i.name,
|
|
3056
|
+
strategy: typeof i.strategy == "string" ? i.strategy : void 0
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
let r = (e, n, r) => t(a(Xe.tenant_id, e), a(Xe.organization_id, n), a(Xe.connection_id, r));
|
|
3060
|
+
return {
|
|
3061
|
+
async create(t, r, i, a) {
|
|
3062
|
+
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
3063
|
+
tenant_id: t,
|
|
3064
|
+
organization_id: r,
|
|
3065
|
+
connection_id: i.connection_id,
|
|
3066
|
+
assign_membership_on_login: +!!i.assign_membership_on_login,
|
|
3067
|
+
show_as_button: i.show_as_button === !1 ? 0 : 1,
|
|
3068
|
+
is_signup_enabled: i.is_signup_enabled === !1 ? 0 : 1,
|
|
3069
|
+
created_at: o?.created_at ?? s,
|
|
3070
|
+
updated_at: o?.updated_at ?? s
|
|
3071
|
+
};
|
|
3072
|
+
return await e.insert(Xe).values(c), $n(c, await n(t, i.connection_id));
|
|
3073
|
+
},
|
|
3074
|
+
async list(r, i) {
|
|
3075
|
+
let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, r), a(Xe.organization_id, i))).all(), s = [];
|
|
3076
|
+
for (let e of o) s.push($n(e, await n(r, e.connection_id)));
|
|
3077
|
+
return s;
|
|
3078
|
+
},
|
|
3079
|
+
async get(t, i, a) {
|
|
3080
|
+
let o = await e.select().from(Xe).where(r(t, i, a)).get();
|
|
3081
|
+
return o ? $n(o, await n(t, a)) : null;
|
|
3082
|
+
},
|
|
3083
|
+
async update(t, i, a, o) {
|
|
3084
|
+
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3085
|
+
o.assign_membership_on_login !== void 0 && (s.assign_membership_on_login = +!!o.assign_membership_on_login), o.show_as_button !== void 0 && (s.show_as_button = +!!o.show_as_button), o.is_signup_enabled !== void 0 && (s.is_signup_enabled = +!!o.is_signup_enabled);
|
|
3086
|
+
let c = await e.update(Xe).set(s).where(r(t, i, a)).returning();
|
|
3087
|
+
return c.length === 0 ? null : $n(c[0], await n(t, a));
|
|
3088
|
+
},
|
|
3089
|
+
async remove(t, n, i) {
|
|
3090
|
+
return (await e.delete(Xe).where(r(t, n, i)).returning({ id: Xe.connection_id })).length > 0;
|
|
3091
|
+
}
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
//#endregion
|
|
3095
|
+
//#region src/adapters/logStreams.ts
|
|
3096
|
+
function tr(e) {
|
|
3097
|
+
return {
|
|
3098
|
+
id: e.id,
|
|
3099
|
+
name: e.name,
|
|
3100
|
+
type: e.type,
|
|
3101
|
+
status: e.status,
|
|
3102
|
+
sink: JSON.parse(e.sink),
|
|
3103
|
+
filters: e.filters ? JSON.parse(e.filters) : void 0,
|
|
3104
|
+
isPriority: e.is_priority == null ? void 0 : e.is_priority === 1,
|
|
3105
|
+
created_at: e.created_at,
|
|
3106
|
+
updated_at: e.updated_at
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
function nr(e) {
|
|
3110
|
+
return {
|
|
3111
|
+
async create(t, n, r) {
|
|
3112
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3113
|
+
id: i?.id ?? `lst_${b()}`,
|
|
3114
|
+
tenant_id: t,
|
|
3115
|
+
name: n.name,
|
|
3116
|
+
type: n.type,
|
|
3117
|
+
status: n.status ?? "active",
|
|
3118
|
+
sink: JSON.stringify(n.sink),
|
|
3119
|
+
filters: n.filters ? JSON.stringify(n.filters) : null,
|
|
3120
|
+
is_priority: n.isPriority === void 0 ? null : +!!n.isPriority,
|
|
3121
|
+
created_at: i?.created_at ?? a,
|
|
3122
|
+
updated_at: i?.updated_at ?? a
|
|
3123
|
+
};
|
|
3124
|
+
return await e.insert(ht).values(o), tr(o);
|
|
3125
|
+
},
|
|
3126
|
+
async get(n, r) {
|
|
3127
|
+
let i = await e.select().from(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).get();
|
|
3128
|
+
return i ? tr(i) : null;
|
|
3129
|
+
},
|
|
3130
|
+
async list(t) {
|
|
3131
|
+
return (await e.select().from(ht).where(a(ht.tenant_id, t)).all()).map(tr);
|
|
3132
|
+
},
|
|
3133
|
+
async update(n, r, i) {
|
|
3134
|
+
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3135
|
+
return i.name !== void 0 && (o.name = i.name), i.type !== void 0 && (o.type = i.type), i.status !== void 0 && (o.status = i.status), i.sink !== void 0 && (o.sink = JSON.stringify(i.sink)), i.filters !== void 0 && (o.filters = i.filters ? JSON.stringify(i.filters) : null), i.isPriority !== void 0 && (o.is_priority = +!!i.isPriority), (await e.update(ht).set(o).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
|
|
3136
|
+
},
|
|
3137
|
+
async remove(n, r) {
|
|
3138
|
+
return (await e.delete(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
}
|
|
3142
|
+
//#endregion
|
|
3143
|
+
//#region src/adapters/migrationSources.ts
|
|
3144
|
+
function rr(e) {
|
|
3145
|
+
return {
|
|
3146
|
+
id: e.id,
|
|
3147
|
+
name: e.name,
|
|
3148
|
+
provider: Se.parse(e.provider),
|
|
3149
|
+
connection: e.connection,
|
|
3150
|
+
enabled: e.enabled === 1,
|
|
3151
|
+
credentials: JSON.parse(e.credentials),
|
|
3152
|
+
created_at: e.created_at,
|
|
3153
|
+
updated_at: e.updated_at
|
|
3154
|
+
};
|
|
3155
|
+
}
|
|
3156
|
+
function ir(e) {
|
|
3157
|
+
let n = (e, n) => t(a(gt.tenant_id, e), a(gt.id, n));
|
|
3158
|
+
return {
|
|
3159
|
+
async create(t, n, r) {
|
|
3160
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3161
|
+
id: i?.id ?? n.id ?? `mig_${b()}`,
|
|
3162
|
+
tenant_id: t,
|
|
3163
|
+
name: n.name,
|
|
3164
|
+
provider: n.provider,
|
|
3165
|
+
connection: n.connection,
|
|
3166
|
+
enabled: n.enabled ?? !0 ? 1 : 0,
|
|
3167
|
+
credentials: JSON.stringify(n.credentials),
|
|
3168
|
+
created_at: i?.created_at ?? a,
|
|
3169
|
+
updated_at: i?.updated_at ?? a
|
|
3170
|
+
};
|
|
3171
|
+
return await e.insert(gt).values(o), rr(o);
|
|
3172
|
+
},
|
|
3173
|
+
async get(t, r) {
|
|
3174
|
+
let i = await e.select().from(gt).where(n(t, r)).get();
|
|
3175
|
+
return i ? rr(i) : null;
|
|
3176
|
+
},
|
|
3177
|
+
async list(t) {
|
|
3178
|
+
return (await e.select().from(gt).where(a(gt.tenant_id, t)).all()).map(rr);
|
|
3179
|
+
},
|
|
3180
|
+
async update(t, r, i) {
|
|
3181
|
+
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3182
|
+
return i.name !== void 0 && (a.name = i.name), i.provider !== void 0 && (a.provider = i.provider), i.connection !== void 0 && (a.connection = i.connection), i.enabled !== void 0 && (a.enabled = +!!i.enabled), i.credentials !== void 0 && (a.credentials = JSON.stringify(i.credentials)), (await e.update(gt).set(a).where(n(t, r)).returning({ id: gt.id })).length > 0;
|
|
3183
|
+
},
|
|
3184
|
+
async remove(t, r) {
|
|
3185
|
+
return (await e.delete(gt).where(n(t, r)).returning({ id: gt.id })).length > 0;
|
|
3186
|
+
}
|
|
3187
|
+
};
|
|
3188
|
+
}
|
|
3189
|
+
//#endregion
|
|
2989
3190
|
//#region src/adapters/passwords.ts
|
|
2990
|
-
function
|
|
3191
|
+
function ar(e) {
|
|
2991
3192
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2992
3193
|
return {
|
|
2993
3194
|
...r,
|
|
2994
3195
|
is_current: !!n
|
|
2995
3196
|
};
|
|
2996
3197
|
}
|
|
2997
|
-
function
|
|
3198
|
+
function or(e) {
|
|
2998
3199
|
return {
|
|
2999
3200
|
async create(n, r) {
|
|
3000
3201
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -3009,18 +3210,18 @@ function Yn(e) {
|
|
|
3009
3210
|
created_at: i,
|
|
3010
3211
|
updated_at: i
|
|
3011
3212
|
};
|
|
3012
|
-
return await e.insert(j).values(s),
|
|
3213
|
+
return await e.insert(j).values(s), ar({
|
|
3013
3214
|
...s,
|
|
3014
3215
|
tenant_id: n
|
|
3015
3216
|
});
|
|
3016
3217
|
},
|
|
3017
3218
|
async get(n, r) {
|
|
3018
3219
|
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();
|
|
3019
|
-
return i ?
|
|
3220
|
+
return i ? ar(i) : null;
|
|
3020
3221
|
},
|
|
3021
3222
|
async list(n, r, o) {
|
|
3022
3223
|
let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
|
|
3023
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
3224
|
+
return o && (s = s.limit(o)), (await s).map(ar);
|
|
3024
3225
|
},
|
|
3025
3226
|
async update(n, r) {
|
|
3026
3227
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3030,10 +3231,10 @@ function Yn(e) {
|
|
|
3030
3231
|
}
|
|
3031
3232
|
//#endregion
|
|
3032
3233
|
//#region src/adapters/promptSettings.ts
|
|
3033
|
-
function
|
|
3234
|
+
function sr(e) {
|
|
3034
3235
|
return {
|
|
3035
3236
|
async get(t) {
|
|
3036
|
-
let n = await e.select().from(
|
|
3237
|
+
let n = await e.select().from(rt).where(a(rt.tenant_id, t)).get();
|
|
3037
3238
|
return n ? {
|
|
3038
3239
|
universal_login_experience: n.universal_login_experience,
|
|
3039
3240
|
identifier_first: !!n.identifier_first,
|
|
@@ -3049,7 +3250,7 @@ function Xn(e) {
|
|
|
3049
3250
|
};
|
|
3050
3251
|
},
|
|
3051
3252
|
async set(t, n) {
|
|
3052
|
-
await e.insert(
|
|
3253
|
+
await e.insert(rt).values({
|
|
3053
3254
|
tenant_id: t,
|
|
3054
3255
|
universal_login_experience: n.universal_login_experience,
|
|
3055
3256
|
identifier_first: n.identifier_first,
|
|
@@ -3057,7 +3258,7 @@ function Xn(e) {
|
|
|
3057
3258
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3058
3259
|
show_last_used_connection: n.show_last_used_connection
|
|
3059
3260
|
}).onConflictDoUpdate({
|
|
3060
|
-
target:
|
|
3261
|
+
target: rt.tenant_id,
|
|
3061
3262
|
set: {
|
|
3062
3263
|
universal_login_experience: n.universal_login_experience,
|
|
3063
3264
|
identifier_first: n.identifier_first,
|
|
@@ -3070,8 +3271,45 @@ function Xn(e) {
|
|
|
3070
3271
|
};
|
|
3071
3272
|
}
|
|
3072
3273
|
//#endregion
|
|
3274
|
+
//#region src/adapters/promptPartials.ts
|
|
3275
|
+
function cr(e) {
|
|
3276
|
+
return {
|
|
3277
|
+
async get(n, r) {
|
|
3278
|
+
let i = await e.select({ body: ut.body }).from(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r))).get();
|
|
3279
|
+
if (!i) return null;
|
|
3280
|
+
try {
|
|
3281
|
+
return JSON.parse(i.body);
|
|
3282
|
+
} catch {
|
|
3283
|
+
return null;
|
|
3284
|
+
}
|
|
3285
|
+
},
|
|
3286
|
+
async set(t, n, r, i) {
|
|
3287
|
+
let a = Date.now(), o = i?.importMetadata?.created_at, s = i?.importMetadata?.updated_at, c = o ? new Date(o).getTime() : a, l = s ? new Date(s).getTime() : c, u = JSON.stringify(r);
|
|
3288
|
+
await e.insert(ut).values({
|
|
3289
|
+
tenant_id: t,
|
|
3290
|
+
prompt: n,
|
|
3291
|
+
body: u,
|
|
3292
|
+
created_at_ts: c,
|
|
3293
|
+
updated_at_ts: l
|
|
3294
|
+
}).onConflictDoUpdate({
|
|
3295
|
+
target: [ut.tenant_id, ut.prompt],
|
|
3296
|
+
set: {
|
|
3297
|
+
body: u,
|
|
3298
|
+
updated_at_ts: s ? l : a
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
},
|
|
3302
|
+
async delete(n, r) {
|
|
3303
|
+
await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r)));
|
|
3304
|
+
},
|
|
3305
|
+
async list(t) {
|
|
3306
|
+
return (await e.select({ prompt: ut.prompt }).from(ut).where(a(ut.tenant_id, t)).all()).map(({ prompt: e }) => e);
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
}
|
|
3310
|
+
//#endregion
|
|
3073
3311
|
//#region src/adapters/proxyRoutes.ts
|
|
3074
|
-
function
|
|
3312
|
+
function lr(e) {
|
|
3075
3313
|
if (!e) return { path: "/*" };
|
|
3076
3314
|
try {
|
|
3077
3315
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -3079,7 +3317,7 @@ function Zn(e) {
|
|
|
3079
3317
|
} catch {}
|
|
3080
3318
|
return { path: "/*" };
|
|
3081
3319
|
}
|
|
3082
|
-
function
|
|
3320
|
+
function ur(e) {
|
|
3083
3321
|
if (!e) return [];
|
|
3084
3322
|
try {
|
|
3085
3323
|
let t = JSON.parse(e);
|
|
@@ -3094,19 +3332,19 @@ function Qn(e) {
|
|
|
3094
3332
|
return [];
|
|
3095
3333
|
}
|
|
3096
3334
|
}
|
|
3097
|
-
function
|
|
3335
|
+
function dr(e) {
|
|
3098
3336
|
return {
|
|
3099
3337
|
id: e.id,
|
|
3100
3338
|
tenant_id: e.tenant_id,
|
|
3101
3339
|
custom_domain_id: e.custom_domain_id,
|
|
3102
3340
|
priority: e.priority,
|
|
3103
|
-
match:
|
|
3104
|
-
handlers:
|
|
3341
|
+
match: lr(e.match),
|
|
3342
|
+
handlers: ur(e.handlers),
|
|
3105
3343
|
created_at: e.created_at,
|
|
3106
3344
|
updated_at: e.updated_at
|
|
3107
3345
|
};
|
|
3108
3346
|
}
|
|
3109
|
-
function
|
|
3347
|
+
function fr(e) {
|
|
3110
3348
|
return {
|
|
3111
3349
|
async create(t, n) {
|
|
3112
3350
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3132,14 +3370,14 @@ function er(e) {
|
|
|
3132
3370
|
},
|
|
3133
3371
|
async get(n, r) {
|
|
3134
3372
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.id, r))).limit(1);
|
|
3135
|
-
return i[0] ?
|
|
3373
|
+
return i[0] ? dr(i[0]) : null;
|
|
3136
3374
|
},
|
|
3137
3375
|
async list(r, i = {}) {
|
|
3138
3376
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(Y.tenant_id, r)];
|
|
3139
3377
|
i.custom_domain_id && c.push(a(Y.custom_domain_id, i.custom_domain_id));
|
|
3140
3378
|
let l = await e.select().from(Y).where(t(...c)).orderBy(n(Y.priority), n(Y.created_at)).offset(o * s).limit(s);
|
|
3141
3379
|
return {
|
|
3142
|
-
proxy_routes: l.map(
|
|
3380
|
+
proxy_routes: l.map(dr),
|
|
3143
3381
|
start: o * s,
|
|
3144
3382
|
limit: s,
|
|
3145
3383
|
length: l.length
|
|
@@ -3158,16 +3396,16 @@ function er(e) {
|
|
|
3158
3396
|
}
|
|
3159
3397
|
//#endregion
|
|
3160
3398
|
//#region src/adapters/tokenExchangeProfiles.ts
|
|
3161
|
-
var
|
|
3162
|
-
function
|
|
3399
|
+
var pr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3400
|
+
function mr(e) {
|
|
3163
3401
|
if (e) try {
|
|
3164
|
-
let t =
|
|
3402
|
+
let t = Ie.safeParse(JSON.parse(e));
|
|
3165
3403
|
return t.success ? t.data : void 0;
|
|
3166
3404
|
} catch {
|
|
3167
3405
|
return;
|
|
3168
3406
|
}
|
|
3169
3407
|
}
|
|
3170
|
-
function
|
|
3408
|
+
function hr(e) {
|
|
3171
3409
|
let t = {
|
|
3172
3410
|
id: e.id,
|
|
3173
3411
|
name: e.name,
|
|
@@ -3177,14 +3415,14 @@ function rr(e) {
|
|
|
3177
3415
|
updated_at: e.updated_at
|
|
3178
3416
|
};
|
|
3179
3417
|
e.action_id && (t.action_id = e.action_id);
|
|
3180
|
-
let n =
|
|
3418
|
+
let n = mr(e.jwt_verification);
|
|
3181
3419
|
return n && (t.jwt_verification = n), t;
|
|
3182
3420
|
}
|
|
3183
|
-
function
|
|
3421
|
+
function gr(e) {
|
|
3184
3422
|
return {
|
|
3185
3423
|
async create(t, n, r) {
|
|
3186
3424
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3187
|
-
id: i?.id ?? `tep_${
|
|
3425
|
+
id: i?.id ?? `tep_${pr()}`,
|
|
3188
3426
|
tenant_id: t,
|
|
3189
3427
|
name: n.name,
|
|
3190
3428
|
subject_token_type: n.subject_token_type,
|
|
@@ -3194,34 +3432,34 @@ function ir(e) {
|
|
|
3194
3432
|
created_at: i?.created_at ?? a,
|
|
3195
3433
|
updated_at: i?.updated_at ?? a
|
|
3196
3434
|
};
|
|
3197
|
-
return await e.insert(
|
|
3435
|
+
return await e.insert(mt).values(o), hr(o);
|
|
3198
3436
|
},
|
|
3199
3437
|
async get(n, r) {
|
|
3200
|
-
let i = await e.select().from(
|
|
3201
|
-
return i[0] ?
|
|
3438
|
+
let i = await e.select().from(mt).where(t(a(mt.tenant_id, n), a(mt.id, r))).limit(1);
|
|
3439
|
+
return i[0] ? hr(i[0]) : null;
|
|
3202
3440
|
},
|
|
3203
3441
|
async list(t) {
|
|
3204
|
-
return (await e.select().from(
|
|
3442
|
+
return (await e.select().from(mt).where(a(mt.tenant_id, t)).orderBy(n(mt.created_at), n(mt.id))).map(hr);
|
|
3205
3443
|
},
|
|
3206
3444
|
async update(n, r, i) {
|
|
3207
3445
|
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(
|
|
3446
|
+
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(mt).set(o).where(t(a(mt.tenant_id, n), a(mt.id, r))).returning({ id: mt.id })).length > 0;
|
|
3209
3447
|
},
|
|
3210
3448
|
async remove(n, r) {
|
|
3211
|
-
return (await e.delete(
|
|
3449
|
+
return (await e.delete(mt).where(t(a(mt.tenant_id, n), a(mt.id, r))).returning({ id: mt.id })).length > 0;
|
|
3212
3450
|
}
|
|
3213
3451
|
};
|
|
3214
3452
|
}
|
|
3215
3453
|
//#endregion
|
|
3216
3454
|
//#region src/adapters/scim.ts
|
|
3217
|
-
function
|
|
3455
|
+
function _r(e) {
|
|
3218
3456
|
if (!e) return [];
|
|
3219
3457
|
try {
|
|
3220
3458
|
let t = JSON.parse(e);
|
|
3221
3459
|
if (!Array.isArray(t)) return [];
|
|
3222
3460
|
let n = [];
|
|
3223
3461
|
for (let e of t) {
|
|
3224
|
-
let t =
|
|
3462
|
+
let t = De.safeParse(e);
|
|
3225
3463
|
t.success && n.push(t.data);
|
|
3226
3464
|
}
|
|
3227
3465
|
return n;
|
|
@@ -3229,7 +3467,7 @@ function ar(e) {
|
|
|
3229
3467
|
return [];
|
|
3230
3468
|
}
|
|
3231
3469
|
}
|
|
3232
|
-
function
|
|
3470
|
+
function vr(e) {
|
|
3233
3471
|
if (!e) return [];
|
|
3234
3472
|
try {
|
|
3235
3473
|
let t = JSON.parse(e);
|
|
@@ -3238,16 +3476,16 @@ function or(e) {
|
|
|
3238
3476
|
return [];
|
|
3239
3477
|
}
|
|
3240
3478
|
}
|
|
3241
|
-
function
|
|
3479
|
+
function yr(e) {
|
|
3242
3480
|
return {
|
|
3243
3481
|
connection_id: e.connection_id,
|
|
3244
3482
|
user_id_attribute: e.user_id_attribute,
|
|
3245
|
-
mapping:
|
|
3483
|
+
mapping: _r(e.mapping),
|
|
3246
3484
|
created_at: e.created_at,
|
|
3247
3485
|
updated_at: e.updated_at
|
|
3248
3486
|
};
|
|
3249
3487
|
}
|
|
3250
|
-
function
|
|
3488
|
+
function br(e) {
|
|
3251
3489
|
return {
|
|
3252
3490
|
async create(t, n) {
|
|
3253
3491
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3257,7 +3495,7 @@ function cr(e) {
|
|
|
3257
3495
|
created_at: r,
|
|
3258
3496
|
updated_at: r
|
|
3259
3497
|
};
|
|
3260
|
-
return await e.insert(
|
|
3498
|
+
return await e.insert(ft).values({
|
|
3261
3499
|
connection_id: i.connection_id,
|
|
3262
3500
|
tenant_id: t,
|
|
3263
3501
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3267,31 +3505,31 @@ function cr(e) {
|
|
|
3267
3505
|
}), i;
|
|
3268
3506
|
},
|
|
3269
3507
|
async get(n, r) {
|
|
3270
|
-
let i = await e.select().from(
|
|
3271
|
-
return i[0] ?
|
|
3508
|
+
let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1);
|
|
3509
|
+
return i[0] ? yr(i[0]) : null;
|
|
3272
3510
|
},
|
|
3273
3511
|
async update(n, r, i) {
|
|
3274
|
-
if ((await e.select({ connection_id:
|
|
3512
|
+
if ((await e.select({ connection_id: ft.connection_id }).from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3275
3513
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
3514
|
+
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(ft).set(o).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))), !0;
|
|
3277
3515
|
},
|
|
3278
3516
|
async remove(n, r) {
|
|
3279
|
-
return (await e.select({ connection_id:
|
|
3517
|
+
return (await e.select({ connection_id: ft.connection_id }).from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))), !0);
|
|
3280
3518
|
}
|
|
3281
3519
|
};
|
|
3282
3520
|
}
|
|
3283
|
-
function
|
|
3521
|
+
function xr(e) {
|
|
3284
3522
|
return {
|
|
3285
3523
|
token_id: e.token_id,
|
|
3286
3524
|
connection_id: e.connection_id,
|
|
3287
3525
|
token_hash: e.token_hash,
|
|
3288
|
-
scopes:
|
|
3526
|
+
scopes: vr(e.scopes),
|
|
3289
3527
|
valid_until: e.valid_until ?? void 0,
|
|
3290
3528
|
created_at: e.created_at,
|
|
3291
3529
|
last_used_at: e.last_used_at ?? void 0
|
|
3292
3530
|
};
|
|
3293
3531
|
}
|
|
3294
|
-
function
|
|
3532
|
+
function Sr(e) {
|
|
3295
3533
|
return {
|
|
3296
3534
|
async create(t, n) {
|
|
3297
3535
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3314,14 +3552,14 @@ function ur(e) {
|
|
|
3314
3552
|
},
|
|
3315
3553
|
async get(n, r) {
|
|
3316
3554
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1);
|
|
3317
|
-
return i[0] ?
|
|
3555
|
+
return i[0] ? xr(i[0]) : null;
|
|
3318
3556
|
},
|
|
3319
3557
|
async getByHash(n, r) {
|
|
3320
3558
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_hash, r))).limit(1);
|
|
3321
|
-
return i[0] ?
|
|
3559
|
+
return i[0] ? xr(i[0]) : null;
|
|
3322
3560
|
},
|
|
3323
3561
|
async listByConnection(n, r) {
|
|
3324
|
-
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(
|
|
3562
|
+
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(xr);
|
|
3325
3563
|
},
|
|
3326
3564
|
async markUsed(n, r, i) {
|
|
3327
3565
|
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);
|
|
@@ -3331,7 +3569,7 @@ function ur(e) {
|
|
|
3331
3569
|
}
|
|
3332
3570
|
};
|
|
3333
3571
|
}
|
|
3334
|
-
function
|
|
3572
|
+
function Cr(e) {
|
|
3335
3573
|
return {
|
|
3336
3574
|
connection_id: e.connection_id,
|
|
3337
3575
|
external_id: e.external_id,
|
|
@@ -3339,7 +3577,7 @@ function dr(e) {
|
|
|
3339
3577
|
created_at: e.created_at
|
|
3340
3578
|
};
|
|
3341
3579
|
}
|
|
3342
|
-
function
|
|
3580
|
+
function wr(e) {
|
|
3343
3581
|
return {
|
|
3344
3582
|
async create(t, n) {
|
|
3345
3583
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3348,7 +3586,7 @@ function fr(e) {
|
|
|
3348
3586
|
user_id: n.user_id,
|
|
3349
3587
|
created_at: r
|
|
3350
3588
|
};
|
|
3351
|
-
return await e.insert(
|
|
3589
|
+
return await e.insert(pt).values({
|
|
3352
3590
|
tenant_id: t,
|
|
3353
3591
|
connection_id: i.connection_id,
|
|
3354
3592
|
external_id: i.external_id,
|
|
@@ -3357,21 +3595,21 @@ function fr(e) {
|
|
|
3357
3595
|
}), i;
|
|
3358
3596
|
},
|
|
3359
3597
|
async getByExternalId(n, r, i) {
|
|
3360
|
-
let o = await e.select().from(
|
|
3361
|
-
return o[0] ?
|
|
3598
|
+
let o = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.external_id, i))).limit(1);
|
|
3599
|
+
return o[0] ? Cr(o[0]) : null;
|
|
3362
3600
|
},
|
|
3363
3601
|
async getByUserId(n, r, i) {
|
|
3364
|
-
let o = await e.select().from(
|
|
3365
|
-
return o[0] ?
|
|
3602
|
+
let o = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))).limit(1);
|
|
3603
|
+
return o[0] ? Cr(o[0]) : null;
|
|
3366
3604
|
},
|
|
3367
3605
|
async remove(n, r, i) {
|
|
3368
|
-
return (await e.select({ user_id:
|
|
3606
|
+
return (await e.select({ user_id: pt.user_id }).from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))), !0);
|
|
3369
3607
|
}
|
|
3370
3608
|
};
|
|
3371
3609
|
}
|
|
3372
3610
|
//#endregion
|
|
3373
3611
|
//#region src/adapters/refreshTokens.ts
|
|
3374
|
-
function
|
|
3612
|
+
function Tr(e) {
|
|
3375
3613
|
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({
|
|
3376
3614
|
created_at_ts: n,
|
|
3377
3615
|
expires_at_ts: r,
|
|
@@ -3398,10 +3636,10 @@ function pr(e) {
|
|
|
3398
3636
|
} } : {}
|
|
3399
3637
|
});
|
|
3400
3638
|
}
|
|
3401
|
-
function
|
|
3639
|
+
function Er(e, t) {
|
|
3402
3640
|
return Math.max(e ?? 0, t ?? 0);
|
|
3403
3641
|
}
|
|
3404
|
-
function
|
|
3642
|
+
function Dr(e) {
|
|
3405
3643
|
return {
|
|
3406
3644
|
async create(n, r) {
|
|
3407
3645
|
let i = Date.now(), o = {
|
|
@@ -3427,22 +3665,22 @@ function hr(e) {
|
|
|
3427
3665
|
expires_at_ts: E(r.expires_at),
|
|
3428
3666
|
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3429
3667
|
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3430
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3668
|
+
}, s = [e.insert(N).values(o)], c = Er(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3431
3669
|
return c > 0 && o.login_id && s.push(e.update(P).set({
|
|
3432
3670
|
expires_at_ts: c,
|
|
3433
3671
|
updated_at_ts: i
|
|
3434
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await
|
|
3672
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await kt(e, s), Tr({
|
|
3435
3673
|
...o,
|
|
3436
3674
|
tenant_id: n
|
|
3437
3675
|
});
|
|
3438
3676
|
},
|
|
3439
3677
|
async get(n, r) {
|
|
3440
3678
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3441
|
-
return i ?
|
|
3679
|
+
return i ? Tr(i) : null;
|
|
3442
3680
|
},
|
|
3443
3681
|
async getByLookup(n, r) {
|
|
3444
3682
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
|
|
3445
|
-
return i ?
|
|
3683
|
+
return i ? Tr(i) : null;
|
|
3446
3684
|
},
|
|
3447
3685
|
async update(n, r, i, o) {
|
|
3448
3686
|
let s = {};
|
|
@@ -3454,17 +3692,17 @@ function hr(e) {
|
|
|
3454
3692
|
}).where(t(a(P.tenant_id, n), a(P.id, c.login_id), m(P.expires_at_ts, l))).catch(() => {}), u.length > 0;
|
|
3455
3693
|
},
|
|
3456
3694
|
async list(o, s) {
|
|
3457
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3695
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(N, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3458
3696
|
a(N.tenant_id, o),
|
|
3459
3697
|
...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
|
|
3460
3698
|
...p ? [p] : []
|
|
3461
3699
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3462
|
-
if (
|
|
3700
|
+
if (Pt(s)) {
|
|
3463
3701
|
let n = {
|
|
3464
3702
|
sortColumn: N.created_at_ts,
|
|
3465
3703
|
idColumn: N.id,
|
|
3466
3704
|
sortOrder: "desc"
|
|
3467
|
-
}, r =
|
|
3705
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...It(n)).limit(i + 1), i, "created_at_ts"), c = a.map(Tr);
|
|
3468
3706
|
return {
|
|
3469
3707
|
refresh_tokens: c,
|
|
3470
3708
|
start: 0,
|
|
@@ -3478,7 +3716,7 @@ function hr(e) {
|
|
|
3478
3716
|
let e = N[d.sort_by];
|
|
3479
3717
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3480
3718
|
}
|
|
3481
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3719
|
+
let _ = (await g.offset(c * l).limit(l)).map(Tr);
|
|
3482
3720
|
if (!u) return { refresh_tokens: _ };
|
|
3483
3721
|
let [v] = await e.select({ count: r() }).from(N).where(h);
|
|
3484
3722
|
return {
|
|
@@ -3507,15 +3745,15 @@ function hr(e) {
|
|
|
3507
3745
|
}
|
|
3508
3746
|
//#endregion
|
|
3509
3747
|
//#region src/adapters/resourceServers.ts
|
|
3510
|
-
var
|
|
3511
|
-
function
|
|
3748
|
+
var Or = ["name", "identifier"];
|
|
3749
|
+
function kr() {
|
|
3512
3750
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3513
3751
|
}
|
|
3514
|
-
var
|
|
3752
|
+
var Ar = [
|
|
3515
3753
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3516
3754
|
"allow_offline_access",
|
|
3517
3755
|
"is_system"
|
|
3518
|
-
],
|
|
3756
|
+
], jr = new Set([
|
|
3519
3757
|
"id",
|
|
3520
3758
|
"tenant_id",
|
|
3521
3759
|
"identifier",
|
|
@@ -3534,17 +3772,17 @@ var vr = [
|
|
|
3534
3772
|
"created_at",
|
|
3535
3773
|
"updated_at"
|
|
3536
3774
|
]);
|
|
3537
|
-
function
|
|
3775
|
+
function Mr(e) {
|
|
3538
3776
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3539
3777
|
s.scopes = Z(r, []), s.options = Z(i, {}), s.metadata = Z(a), n !== void 0 && (s.verificationKey = n);
|
|
3540
|
-
for (let e of
|
|
3778
|
+
for (let e of Ar) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3541
3779
|
return D(s);
|
|
3542
3780
|
}
|
|
3543
|
-
function
|
|
3781
|
+
function Nr(e) {
|
|
3544
3782
|
return {
|
|
3545
3783
|
async create(t, n) {
|
|
3546
3784
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3547
|
-
id: n.id ||
|
|
3785
|
+
id: n.id || kr(),
|
|
3548
3786
|
tenant_id: t,
|
|
3549
3787
|
identifier: n.identifier,
|
|
3550
3788
|
name: n.name,
|
|
@@ -3559,37 +3797,37 @@ function xr(e) {
|
|
|
3559
3797
|
created_at: r,
|
|
3560
3798
|
updated_at: r
|
|
3561
3799
|
};
|
|
3562
|
-
for (let e of
|
|
3563
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i),
|
|
3800
|
+
for (let e of Ar) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3801
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), Mr({
|
|
3564
3802
|
...i,
|
|
3565
3803
|
tenant_id: t
|
|
3566
3804
|
});
|
|
3567
3805
|
},
|
|
3568
3806
|
async get(n, r) {
|
|
3569
3807
|
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3570
|
-
return i ?
|
|
3808
|
+
return i ? Mr(i) : null;
|
|
3571
3809
|
},
|
|
3572
3810
|
async update(n, r, i) {
|
|
3573
3811
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3574
3812
|
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);
|
|
3575
|
-
for (let e of
|
|
3813
|
+
for (let e of Ar) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3576
3814
|
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3577
3815
|
},
|
|
3578
3816
|
async list(o, s) {
|
|
3579
3817
|
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)];
|
|
3580
3818
|
if (f) {
|
|
3581
|
-
let e =
|
|
3819
|
+
let e = Ee(f, Or);
|
|
3582
3820
|
if (e) {
|
|
3583
|
-
let t =
|
|
3821
|
+
let t = St(K, e, Or, ["name", "identifier"]);
|
|
3584
3822
|
t && h.push(t);
|
|
3585
3823
|
}
|
|
3586
3824
|
}
|
|
3587
|
-
if (
|
|
3825
|
+
if (Pt(s)) {
|
|
3588
3826
|
let n = {
|
|
3589
3827
|
sortColumn: K.created_at,
|
|
3590
3828
|
idColumn: K.id,
|
|
3591
3829
|
sortOrder: "desc"
|
|
3592
|
-
}, r =
|
|
3830
|
+
}, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(K).where(t(...h, r)).orderBy(...It(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Mr);
|
|
3593
3831
|
return {
|
|
3594
3832
|
resource_servers: c,
|
|
3595
3833
|
start: 0,
|
|
@@ -3599,11 +3837,11 @@ function xr(e) {
|
|
|
3599
3837
|
};
|
|
3600
3838
|
}
|
|
3601
3839
|
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3602
|
-
if (d?.sort_by &&
|
|
3840
|
+
if (d?.sort_by && jr.has(d.sort_by)) {
|
|
3603
3841
|
let e = K[d.sort_by];
|
|
3604
3842
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3605
3843
|
}
|
|
3606
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3844
|
+
let _ = (await g.offset(p * m).limit(m)).map(Mr);
|
|
3607
3845
|
if (!u) return { resource_servers: _ };
|
|
3608
3846
|
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3609
3847
|
return {
|
|
@@ -3620,7 +3858,7 @@ function xr(e) {
|
|
|
3620
3858
|
}
|
|
3621
3859
|
//#endregion
|
|
3622
3860
|
//#region src/adapters/rolePermissions.ts
|
|
3623
|
-
function
|
|
3861
|
+
function Pr(e) {
|
|
3624
3862
|
return {
|
|
3625
3863
|
async assign(t, n, r) {
|
|
3626
3864
|
if (r.length === 0) return !0;
|
|
@@ -3634,7 +3872,7 @@ function Sr(e) {
|
|
|
3634
3872
|
}))).onConflictDoNothing(), !0;
|
|
3635
3873
|
},
|
|
3636
3874
|
async list(n, r, i) {
|
|
3637
|
-
return
|
|
3875
|
+
return Fr(e, n, await e.select({
|
|
3638
3876
|
resource_server_identifier: W.resource_server_identifier,
|
|
3639
3877
|
permission_name: W.permission_name,
|
|
3640
3878
|
created_at: W.created_at
|
|
@@ -3645,14 +3883,14 @@ function Sr(e) {
|
|
|
3645
3883
|
sortColumn: W.resource_server_identifier,
|
|
3646
3884
|
idColumn: W.permission_name,
|
|
3647
3885
|
sortOrder: "asc"
|
|
3648
|
-
}, s =
|
|
3886
|
+
}, s = Ft(i), { rows: c, next: l } = Rt(await e.select({
|
|
3649
3887
|
role_id: W.role_id,
|
|
3650
3888
|
resource_server_identifier: W.resource_server_identifier,
|
|
3651
3889
|
permission_name: W.permission_name,
|
|
3652
3890
|
created_at: W.created_at
|
|
3653
|
-
}).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r),
|
|
3891
|
+
}).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r), Lt(i, o))).orderBy(...It(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
|
|
3654
3892
|
return {
|
|
3655
|
-
permissions: await
|
|
3893
|
+
permissions: await Fr(e, n, c),
|
|
3656
3894
|
next: l
|
|
3657
3895
|
};
|
|
3658
3896
|
},
|
|
@@ -3663,7 +3901,7 @@ function Sr(e) {
|
|
|
3663
3901
|
}
|
|
3664
3902
|
};
|
|
3665
3903
|
}
|
|
3666
|
-
async function
|
|
3904
|
+
async function Fr(e, n, r) {
|
|
3667
3905
|
let i = [...new Set(r.map((e) => e.resource_server_identifier))], o = /* @__PURE__ */ new Map();
|
|
3668
3906
|
if (i.length > 0) {
|
|
3669
3907
|
let r = await e.select({
|
|
@@ -3679,11 +3917,11 @@ async function Cr(e, n, r) {
|
|
|
3679
3917
|
}
|
|
3680
3918
|
//#endregion
|
|
3681
3919
|
//#region src/adapters/userPermissions.ts
|
|
3682
|
-
function
|
|
3920
|
+
function Ir(e) {
|
|
3683
3921
|
return {
|
|
3684
3922
|
async create(t, n, r, i) {
|
|
3685
3923
|
try {
|
|
3686
|
-
await e.insert(
|
|
3924
|
+
await e.insert(Ze).values({
|
|
3687
3925
|
tenant_id: t,
|
|
3688
3926
|
user_id: n,
|
|
3689
3927
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3698,9 +3936,9 @@ function wr(e) {
|
|
|
3698
3936
|
return !0;
|
|
3699
3937
|
},
|
|
3700
3938
|
async list(n, r, i, o) {
|
|
3701
|
-
let s = [a(
|
|
3702
|
-
o && s.push(a(
|
|
3703
|
-
let c = await e.select().from(
|
|
3939
|
+
let s = [a(Ze.tenant_id, n), a(Ze.user_id, r)];
|
|
3940
|
+
o && s.push(a(Ze.organization_id, o));
|
|
3941
|
+
let c = await e.select().from(Ze).where(t(...s)).all();
|
|
3704
3942
|
return await Promise.all(c.map(async (r) => {
|
|
3705
3943
|
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();
|
|
3706
3944
|
return {
|
|
@@ -3712,13 +3950,13 @@ function wr(e) {
|
|
|
3712
3950
|
}));
|
|
3713
3951
|
},
|
|
3714
3952
|
async remove(n, r, i, o) {
|
|
3715
|
-
return (await e.delete(
|
|
3953
|
+
return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.user_id, r), a(Ze.resource_server_identifier, i.resource_server_identifier), a(Ze.permission_name, i.permission_name), a(Ze.organization_id, o || ""))).returning()).length > 0;
|
|
3716
3954
|
}
|
|
3717
3955
|
};
|
|
3718
3956
|
}
|
|
3719
3957
|
//#endregion
|
|
3720
3958
|
//#region src/adapters/roles.ts
|
|
3721
|
-
function
|
|
3959
|
+
function Lr(e) {
|
|
3722
3960
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3723
3961
|
return D({
|
|
3724
3962
|
...i,
|
|
@@ -3726,7 +3964,7 @@ function Tr(e) {
|
|
|
3726
3964
|
metadata: Z(r)
|
|
3727
3965
|
});
|
|
3728
3966
|
}
|
|
3729
|
-
function
|
|
3967
|
+
function Rr(e) {
|
|
3730
3968
|
return {
|
|
3731
3969
|
async create(t, n) {
|
|
3732
3970
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3739,29 +3977,29 @@ function Er(e) {
|
|
|
3739
3977
|
created_at: r,
|
|
3740
3978
|
updated_at: r
|
|
3741
3979
|
};
|
|
3742
|
-
return await e.insert(U).values(i),
|
|
3980
|
+
return await e.insert(U).values(i), Lr({
|
|
3743
3981
|
...i,
|
|
3744
3982
|
tenant_id: t
|
|
3745
3983
|
});
|
|
3746
3984
|
},
|
|
3747
3985
|
async get(n, r) {
|
|
3748
3986
|
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
3749
|
-
return i ?
|
|
3987
|
+
return i ? Lr(i) : null;
|
|
3750
3988
|
},
|
|
3751
3989
|
async update(n, r, i) {
|
|
3752
3990
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3753
3991
|
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(U).set(o).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
3754
3992
|
},
|
|
3755
3993
|
async list(o, s) {
|
|
3756
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3757
|
-
if (
|
|
3994
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(U, f, ["name"]) : void 0, m = p ? t(a(U.tenant_id, o), p) : a(U.tenant_id, o);
|
|
3995
|
+
if (Pt(s)) {
|
|
3758
3996
|
let n = {
|
|
3759
3997
|
sortColumn: U.created_at,
|
|
3760
3998
|
idColumn: U.id,
|
|
3761
3999
|
sortOrder: "desc"
|
|
3762
|
-
}, r =
|
|
4000
|
+
}, r = Ft(s), { rows: i, next: a } = Rt(await e.select().from(U).where(t(m, Lt(s, n))).orderBy(...It(n)).limit(r + 1), r, "created_at");
|
|
3763
4001
|
return {
|
|
3764
|
-
roles: i.map(
|
|
4002
|
+
roles: i.map(Lr),
|
|
3765
4003
|
start: 0,
|
|
3766
4004
|
limit: r,
|
|
3767
4005
|
length: i.length,
|
|
@@ -3773,7 +4011,7 @@ function Er(e) {
|
|
|
3773
4011
|
let e = U[d.sort_by];
|
|
3774
4012
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3775
4013
|
}
|
|
3776
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4014
|
+
let g = (await h.offset(c * l).limit(l)).map(Lr);
|
|
3777
4015
|
if (!u) return { roles: g };
|
|
3778
4016
|
let [_] = await e.select({ count: r() }).from(U).where(m);
|
|
3779
4017
|
return {
|
|
@@ -3790,7 +4028,7 @@ function Er(e) {
|
|
|
3790
4028
|
}
|
|
3791
4029
|
//#endregion
|
|
3792
4030
|
//#region src/adapters/sessions.ts
|
|
3793
|
-
var
|
|
4031
|
+
var zr = ["created_at_ts", "updated_at_ts"], Br = [
|
|
3794
4032
|
"expires_at_ts",
|
|
3795
4033
|
"idle_expires_at_ts",
|
|
3796
4034
|
"authenticated_at_ts",
|
|
@@ -3798,7 +4036,7 @@ var Dr = ["created_at_ts", "updated_at_ts"], Or = [
|
|
|
3798
4036
|
"used_at_ts",
|
|
3799
4037
|
"revoked_at_ts"
|
|
3800
4038
|
];
|
|
3801
|
-
function
|
|
4039
|
+
function Vr(e) {
|
|
3802
4040
|
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({
|
|
3803
4041
|
created_at_ts: n,
|
|
3804
4042
|
updated_at_ts: r,
|
|
@@ -3808,7 +4046,7 @@ function kr(e) {
|
|
|
3808
4046
|
last_interaction_at_ts: s,
|
|
3809
4047
|
used_at_ts: c,
|
|
3810
4048
|
revoked_at_ts: l
|
|
3811
|
-
}, [...
|
|
4049
|
+
}, [...zr], [...Br]);
|
|
3812
4050
|
return D({
|
|
3813
4051
|
...f,
|
|
3814
4052
|
...p,
|
|
@@ -3816,10 +4054,10 @@ function kr(e) {
|
|
|
3816
4054
|
clients: Z(d, [])
|
|
3817
4055
|
});
|
|
3818
4056
|
}
|
|
3819
|
-
function
|
|
4057
|
+
function Hr(e, t) {
|
|
3820
4058
|
return Math.max(e ?? 0, t ?? 0);
|
|
3821
4059
|
}
|
|
3822
|
-
function
|
|
4060
|
+
function Ur(e) {
|
|
3823
4061
|
return {
|
|
3824
4062
|
async create(n, r) {
|
|
3825
4063
|
let i = Date.now(), o = {
|
|
@@ -3837,23 +4075,23 @@ function jr(e) {
|
|
|
3837
4075
|
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
3838
4076
|
used_at_ts: E(r.used_at),
|
|
3839
4077
|
revoked_at_ts: E(r.revoked_at)
|
|
3840
|
-
}, s = [e.insert(M).values(o)], c =
|
|
4078
|
+
}, s = [e.insert(M).values(o)], c = Hr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3841
4079
|
return c > 0 && o.login_session_id && s.push(e.update(P).set({
|
|
3842
4080
|
expires_at_ts: c,
|
|
3843
4081
|
updated_at_ts: i
|
|
3844
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await
|
|
4082
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await kt(e, s), Vr({
|
|
3845
4083
|
...o,
|
|
3846
4084
|
tenant_id: n
|
|
3847
4085
|
});
|
|
3848
4086
|
},
|
|
3849
4087
|
async get(n, r) {
|
|
3850
4088
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
|
|
3851
|
-
return i ?
|
|
4089
|
+
return i ? Vr(i) : null;
|
|
3852
4090
|
},
|
|
3853
4091
|
async update(n, r, i) {
|
|
3854
4092
|
let o = { updated_at_ts: Date.now() };
|
|
3855
4093
|
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));
|
|
3856
|
-
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c =
|
|
4094
|
+
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Hr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3857
4095
|
if (c > 0 && l) {
|
|
3858
4096
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3859
4097
|
r && await e.update(P).set({
|
|
@@ -3864,12 +4102,12 @@ function jr(e) {
|
|
|
3864
4102
|
return s.length > 0;
|
|
3865
4103
|
},
|
|
3866
4104
|
async list(o, s) {
|
|
3867
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
4105
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(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();
|
|
3868
4106
|
if (d?.sort_by) {
|
|
3869
4107
|
let e = M[d.sort_by];
|
|
3870
4108
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3871
4109
|
}
|
|
3872
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4110
|
+
let g = (await h.offset(c * l).limit(l)).map(Vr);
|
|
3873
4111
|
if (!u) return { sessions: g };
|
|
3874
4112
|
let [_] = await e.select({ count: r() }).from(M).where(m);
|
|
3875
4113
|
return {
|
|
@@ -3886,7 +4124,7 @@ function jr(e) {
|
|
|
3886
4124
|
}
|
|
3887
4125
|
//#endregion
|
|
3888
4126
|
//#region src/adapters/tenants.ts
|
|
3889
|
-
var
|
|
4127
|
+
var Wr = [
|
|
3890
4128
|
"session_cookie",
|
|
3891
4129
|
"enabled_locales",
|
|
3892
4130
|
"error_page",
|
|
@@ -3902,25 +4140,25 @@ var Mr = [
|
|
|
3902
4140
|
"acr_values_supported",
|
|
3903
4141
|
"mtls",
|
|
3904
4142
|
"mfa"
|
|
3905
|
-
],
|
|
4143
|
+
], Gr = [
|
|
3906
4144
|
"allow_organization_name_in_authentication_api",
|
|
3907
4145
|
"customize_mfa_in_postlogin_action",
|
|
3908
4146
|
"pushed_authorization_requests_supported",
|
|
3909
4147
|
"authorization_response_iss_parameter_supported"
|
|
3910
4148
|
];
|
|
3911
|
-
function
|
|
4149
|
+
function Kr(e) {
|
|
3912
4150
|
let t = { ...e };
|
|
3913
|
-
for (let e of
|
|
3914
|
-
for (let e of
|
|
4151
|
+
for (let e of Wr) typeof t[e] == "string" && (t[e] = Z(t[e]));
|
|
4152
|
+
for (let e of Gr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3915
4153
|
return D(t);
|
|
3916
4154
|
}
|
|
3917
|
-
function
|
|
4155
|
+
function qr(e) {
|
|
3918
4156
|
let t = { ...e };
|
|
3919
|
-
le(e,
|
|
3920
|
-
for (let n of
|
|
4157
|
+
le(e, Wr, t);
|
|
4158
|
+
for (let n of Gr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3921
4159
|
return ce(t);
|
|
3922
4160
|
}
|
|
3923
|
-
function
|
|
4161
|
+
function Jr(e) {
|
|
3924
4162
|
return {
|
|
3925
4163
|
async create(t) {
|
|
3926
4164
|
let n = {
|
|
@@ -3928,26 +4166,26 @@ function Ir(e) {
|
|
|
3928
4166
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3929
4167
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3930
4168
|
...t
|
|
3931
|
-
}, r =
|
|
4169
|
+
}, r = qr(n);
|
|
3932
4170
|
try {
|
|
3933
4171
|
await e.insert(O).values(r);
|
|
3934
4172
|
} catch (e) {
|
|
3935
4173
|
let t = e?.message ?? "";
|
|
3936
|
-
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
|
|
4174
|
+
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 Re(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3937
4175
|
}
|
|
3938
4176
|
return n;
|
|
3939
4177
|
},
|
|
3940
4178
|
async get(t) {
|
|
3941
4179
|
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
3942
|
-
return n ?
|
|
4180
|
+
return n ? Kr(n) : null;
|
|
3943
4181
|
},
|
|
3944
4182
|
async list(t) {
|
|
3945
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
4183
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? St(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
3946
4184
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3947
4185
|
let e = O[c.sort_by];
|
|
3948
4186
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3949
4187
|
}
|
|
3950
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
4188
|
+
let f = (await d.offset(a * o).limit(o)).map(Kr);
|
|
3951
4189
|
if (!s) return { tenants: f };
|
|
3952
4190
|
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
3953
4191
|
u && (p = p.where(u));
|
|
@@ -3960,7 +4198,7 @@ function Ir(e) {
|
|
|
3960
4198
|
};
|
|
3961
4199
|
},
|
|
3962
4200
|
async update(t, n) {
|
|
3963
|
-
let r =
|
|
4201
|
+
let r = qr({
|
|
3964
4202
|
...n,
|
|
3965
4203
|
id: t,
|
|
3966
4204
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3974,62 +4212,62 @@ function Ir(e) {
|
|
|
3974
4212
|
}
|
|
3975
4213
|
//#endregion
|
|
3976
4214
|
//#region src/adapters/themes.ts
|
|
3977
|
-
var
|
|
4215
|
+
var Yr = [
|
|
3978
4216
|
"colors",
|
|
3979
4217
|
"borders",
|
|
3980
4218
|
"fonts",
|
|
3981
4219
|
"page_background",
|
|
3982
4220
|
"widget"
|
|
3983
4221
|
];
|
|
3984
|
-
function
|
|
3985
|
-
let { tenant_id: t, ...n } = e, r =
|
|
4222
|
+
function Xr(e) {
|
|
4223
|
+
let { tenant_id: t, ...n } = e, r = yt(n, Yr);
|
|
3986
4224
|
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);
|
|
3987
4225
|
}
|
|
3988
|
-
function
|
|
4226
|
+
function Zr(e) {
|
|
3989
4227
|
return {
|
|
3990
4228
|
async create(t, n, r, i) {
|
|
3991
4229
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3992
|
-
...
|
|
4230
|
+
...vt(n),
|
|
3993
4231
|
tenant_id: t,
|
|
3994
4232
|
themeId: s,
|
|
3995
4233
|
created_at: a?.created_at ?? o,
|
|
3996
4234
|
updated_at: a?.updated_at ?? o
|
|
3997
4235
|
};
|
|
3998
|
-
return await e.insert(
|
|
4236
|
+
return await e.insert(et).values(c), Xr({
|
|
3999
4237
|
...c,
|
|
4000
4238
|
tenant_id: t
|
|
4001
4239
|
});
|
|
4002
4240
|
},
|
|
4003
4241
|
async get(n, r) {
|
|
4004
|
-
let i = await e.select().from(
|
|
4005
|
-
return i ?
|
|
4242
|
+
let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.themeId, r))).get();
|
|
4243
|
+
return i ? Xr(i) : null;
|
|
4006
4244
|
},
|
|
4007
4245
|
async update(n, r, i) {
|
|
4008
|
-
let o =
|
|
4009
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
4246
|
+
let o = vt(i);
|
|
4247
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(et).set(o).where(t(a(et.tenant_id, n), a(et.themeId, r))), !0;
|
|
4010
4248
|
},
|
|
4011
4249
|
async remove(n, r) {
|
|
4012
|
-
return (await e.delete(
|
|
4250
|
+
return (await e.delete(et).where(t(a(et.tenant_id, n), a(et.themeId, r))).returning()).length > 0;
|
|
4013
4251
|
}
|
|
4014
4252
|
};
|
|
4015
4253
|
}
|
|
4016
4254
|
//#endregion
|
|
4017
4255
|
//#region src/adapters/universalLoginTemplates.ts
|
|
4018
|
-
function
|
|
4256
|
+
function Qr(e) {
|
|
4019
4257
|
return {
|
|
4020
4258
|
async get(t) {
|
|
4021
|
-
let n = await e.select({ body:
|
|
4259
|
+
let n = await e.select({ body: $e.body }).from($e).where(a($e.tenant_id, t)).get();
|
|
4022
4260
|
return n ? { body: n.body } : null;
|
|
4023
4261
|
},
|
|
4024
4262
|
async set(t, n) {
|
|
4025
4263
|
let r = Date.now();
|
|
4026
|
-
await e.insert(
|
|
4264
|
+
await e.insert($e).values({
|
|
4027
4265
|
tenant_id: t,
|
|
4028
4266
|
body: n.body,
|
|
4029
4267
|
created_at_ts: r,
|
|
4030
4268
|
updated_at_ts: r
|
|
4031
4269
|
}).onConflictDoUpdate({
|
|
4032
|
-
target:
|
|
4270
|
+
target: $e.tenant_id,
|
|
4033
4271
|
set: {
|
|
4034
4272
|
body: n.body,
|
|
4035
4273
|
updated_at_ts: r
|
|
@@ -4037,20 +4275,20 @@ function Br(e) {
|
|
|
4037
4275
|
});
|
|
4038
4276
|
},
|
|
4039
4277
|
async delete(t) {
|
|
4040
|
-
await e.delete(
|
|
4278
|
+
await e.delete($e).where(a($e.tenant_id, t));
|
|
4041
4279
|
}
|
|
4042
4280
|
};
|
|
4043
4281
|
}
|
|
4044
4282
|
//#endregion
|
|
4045
4283
|
//#region src/adapters/userActivity.ts
|
|
4046
|
-
function
|
|
4284
|
+
function $r(e) {
|
|
4047
4285
|
let t = {};
|
|
4048
4286
|
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;
|
|
4049
4287
|
}
|
|
4050
|
-
function
|
|
4288
|
+
function ei(e) {
|
|
4051
4289
|
return {
|
|
4052
4290
|
async get(n, r) {
|
|
4053
|
-
let i = await e.select().from(
|
|
4291
|
+
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.user_id, r))).get();
|
|
4054
4292
|
return i ? {
|
|
4055
4293
|
user_id: i.user_id,
|
|
4056
4294
|
last_login: i.last_login ?? void 0,
|
|
@@ -4061,7 +4299,7 @@ function Hr(e) {
|
|
|
4061
4299
|
} : null;
|
|
4062
4300
|
},
|
|
4063
4301
|
async upsert(t, n, r) {
|
|
4064
|
-
let i =
|
|
4302
|
+
let i = $r(r), a = e.insert(Ue).values({
|
|
4065
4303
|
tenant_id: t,
|
|
4066
4304
|
user_id: n,
|
|
4067
4305
|
login_count: 0,
|
|
@@ -4072,7 +4310,7 @@ function Hr(e) {
|
|
|
4072
4310
|
return;
|
|
4073
4311
|
}
|
|
4074
4312
|
await a.onConflictDoUpdate({
|
|
4075
|
-
target: [
|
|
4313
|
+
target: [Ue.tenant_id, Ue.user_id],
|
|
4076
4314
|
set: i
|
|
4077
4315
|
});
|
|
4078
4316
|
}
|
|
@@ -4080,13 +4318,13 @@ function Hr(e) {
|
|
|
4080
4318
|
}
|
|
4081
4319
|
//#endregion
|
|
4082
4320
|
//#region src/adapters/outbox.ts
|
|
4083
|
-
function
|
|
4321
|
+
function ti(e) {
|
|
4084
4322
|
return {
|
|
4085
4323
|
...e,
|
|
4086
4324
|
payload: Z(e.payload, {})
|
|
4087
4325
|
};
|
|
4088
4326
|
}
|
|
4089
|
-
function
|
|
4327
|
+
function ni(e, t, n, r) {
|
|
4090
4328
|
return e.insert(J).values({
|
|
4091
4329
|
id: t,
|
|
4092
4330
|
tenant_id: n,
|
|
@@ -4107,18 +4345,18 @@ function Wr(e, t, n, r) {
|
|
|
4107
4345
|
claim_expires_at: null
|
|
4108
4346
|
});
|
|
4109
4347
|
}
|
|
4110
|
-
function
|
|
4348
|
+
function ri(e) {
|
|
4111
4349
|
return {
|
|
4112
4350
|
async create(t, n) {
|
|
4113
4351
|
let r = b();
|
|
4114
|
-
return await
|
|
4352
|
+
return await ni(e, r, t, n), r;
|
|
4115
4353
|
},
|
|
4116
4354
|
async getByIds(t) {
|
|
4117
|
-
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(
|
|
4355
|
+
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(ti);
|
|
4118
4356
|
},
|
|
4119
4357
|
async getUnprocessed(n) {
|
|
4120
4358
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4121
|
-
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(
|
|
4359
|
+
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(ti);
|
|
4122
4360
|
},
|
|
4123
4361
|
async claimEvents(n, r, i) {
|
|
4124
4362
|
if (n.length === 0) return [];
|
|
@@ -4193,10 +4431,10 @@ function Gr(e) {
|
|
|
4193
4431
|
}
|
|
4194
4432
|
//#endregion
|
|
4195
4433
|
//#region src/adapters/users.ts
|
|
4196
|
-
function
|
|
4197
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4434
|
+
function ii(e, t, n) {
|
|
4435
|
+
return (n?.outboxEvents ?? []).map((n) => ni(e, n.id, t, n));
|
|
4198
4436
|
}
|
|
4199
|
-
var
|
|
4437
|
+
var ai = [
|
|
4200
4438
|
"user_id",
|
|
4201
4439
|
"email",
|
|
4202
4440
|
"email_verified",
|
|
@@ -4218,23 +4456,23 @@ var qr = [
|
|
|
4218
4456
|
"login_count",
|
|
4219
4457
|
"created_at",
|
|
4220
4458
|
"updated_at"
|
|
4221
|
-
],
|
|
4459
|
+
], oi = [
|
|
4222
4460
|
"email",
|
|
4223
4461
|
"name",
|
|
4224
4462
|
"phone_number",
|
|
4225
4463
|
"user_id"
|
|
4226
|
-
],
|
|
4464
|
+
], si = new Set([
|
|
4227
4465
|
"last_login",
|
|
4228
4466
|
"last_ip",
|
|
4229
4467
|
"login_count"
|
|
4230
|
-
]),
|
|
4231
|
-
coalesce:
|
|
4468
|
+
]), ci = o(A), li = o(Ue), ui = Object.fromEntries(ai.map((e) => [e, e === "login_count" ? {
|
|
4469
|
+
coalesce: Ue.login_count,
|
|
4232
4470
|
defaultValue: 0
|
|
4233
|
-
} :
|
|
4234
|
-
function
|
|
4235
|
-
return t(a(
|
|
4471
|
+
} : si.has(e) ? li[e] : ci[e]]));
|
|
4472
|
+
function di() {
|
|
4473
|
+
return t(a(Ue.tenant_id, A.tenant_id), a(Ue.user_id, A.user_id));
|
|
4236
4474
|
}
|
|
4237
|
-
function
|
|
4475
|
+
function fi(e, t) {
|
|
4238
4476
|
return {
|
|
4239
4477
|
...e,
|
|
4240
4478
|
last_login: t?.last_login,
|
|
@@ -4242,11 +4480,11 @@ function ei(e, t) {
|
|
|
4242
4480
|
login_count: t?.login_count ?? 0
|
|
4243
4481
|
};
|
|
4244
4482
|
}
|
|
4245
|
-
function
|
|
4483
|
+
function pi(e, t) {
|
|
4246
4484
|
let n = {
|
|
4247
4485
|
connection: e.connection,
|
|
4248
4486
|
provider: e.provider,
|
|
4249
|
-
user_id:
|
|
4487
|
+
user_id: Ce(e.user_id).id,
|
|
4250
4488
|
isSocial: !!e.is_social
|
|
4251
4489
|
};
|
|
4252
4490
|
return t ? n.isPrimary = !0 : n.profileData = {
|
|
@@ -4255,8 +4493,8 @@ function ti(e, t) {
|
|
|
4255
4493
|
...typeof e.profileData == "string" ? Z(e.profileData, {}) : {}
|
|
4256
4494
|
}, n;
|
|
4257
4495
|
}
|
|
4258
|
-
function
|
|
4259
|
-
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 =
|
|
4496
|
+
function mi(e, t = []) {
|
|
4497
|
+
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 = pi(e, !0), m = t.map((e) => pi(e, !1));
|
|
4260
4498
|
return D({
|
|
4261
4499
|
...f,
|
|
4262
4500
|
email: e.email || "",
|
|
@@ -4270,7 +4508,7 @@ function ni(e, t = []) {
|
|
|
4270
4508
|
identities: [p, ...m]
|
|
4271
4509
|
});
|
|
4272
4510
|
}
|
|
4273
|
-
function
|
|
4511
|
+
function hi(e) {
|
|
4274
4512
|
let o = async (t, n, r) => {
|
|
4275
4513
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4276
4514
|
user_id: n.user_id,
|
|
@@ -4308,7 +4546,7 @@ function ri(e) {
|
|
|
4308
4546
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4309
4547
|
try {
|
|
4310
4548
|
let c = [e.insert(A).values(a)];
|
|
4311
|
-
s && c.push(e.insert(
|
|
4549
|
+
s && c.push(e.insert(Ue).values({
|
|
4312
4550
|
tenant_id: t,
|
|
4313
4551
|
user_id: n.user_id,
|
|
4314
4552
|
last_login: n.last_login,
|
|
@@ -4324,12 +4562,12 @@ function ri(e) {
|
|
|
4324
4562
|
created_at: i,
|
|
4325
4563
|
updated_at: i
|
|
4326
4564
|
}));
|
|
4327
|
-
for (let n of
|
|
4328
|
-
c.length > 1 ? await
|
|
4565
|
+
for (let n of ii(e, t, r)) c.push(n);
|
|
4566
|
+
c.length > 1 ? await kt(e, c) : await e.insert(A).values(a);
|
|
4329
4567
|
} catch (e) {
|
|
4330
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4568
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Re(500, { message: "Internal server error" }));
|
|
4331
4569
|
}
|
|
4332
|
-
return
|
|
4570
|
+
return mi({
|
|
4333
4571
|
...a,
|
|
4334
4572
|
last_login: n.last_login,
|
|
4335
4573
|
last_ip: n.last_ip,
|
|
@@ -4340,10 +4578,10 @@ function ri(e) {
|
|
|
4340
4578
|
create: o,
|
|
4341
4579
|
rawCreate: o,
|
|
4342
4580
|
async get(n, r) {
|
|
4343
|
-
let i = await e.select().from(A).leftJoin(
|
|
4581
|
+
let i = await e.select().from(A).leftJoin(Ue, di()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4344
4582
|
if (!i) return null;
|
|
4345
4583
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4346
|
-
return
|
|
4584
|
+
return mi(fi(i.users, i.user_activity), o);
|
|
4347
4585
|
},
|
|
4348
4586
|
async update(n, r, i, o) {
|
|
4349
4587
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4370,8 +4608,8 @@ function ri(e) {
|
|
|
4370
4608
|
"zoneinfo"
|
|
4371
4609
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4372
4610
|
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));
|
|
4373
|
-
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l =
|
|
4374
|
-
return u = l.length > 0 ? (await
|
|
4611
|
+
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = ii(e, n, o), u;
|
|
4612
|
+
return u = l.length > 0 ? (await kt(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 ei(e).upsert(n, r, {
|
|
4375
4613
|
last_login: i.last_login,
|
|
4376
4614
|
last_ip: i.last_ip,
|
|
4377
4615
|
login_count: i.login_count
|
|
@@ -4380,24 +4618,24 @@ function ri(e) {
|
|
|
4380
4618
|
async list(o, s) {
|
|
4381
4619
|
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)];
|
|
4382
4620
|
if (m) {
|
|
4383
|
-
let e =
|
|
4621
|
+
let e = Ee(m, ai);
|
|
4384
4622
|
if (e) {
|
|
4385
|
-
let t =
|
|
4623
|
+
let t = St(ui, e, oi);
|
|
4386
4624
|
t && h.push(t);
|
|
4387
4625
|
}
|
|
4388
4626
|
}
|
|
4389
4627
|
let g = t(...h), _ = async (n) => {
|
|
4390
4628
|
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))) : [];
|
|
4391
|
-
return n.map((e) =>
|
|
4629
|
+
return n.map((e) => mi(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4392
4630
|
};
|
|
4393
|
-
if (
|
|
4394
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4631
|
+
if (Pt(s)) {
|
|
4632
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Re(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4395
4633
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4396
4634
|
sortColumn: A.created_at,
|
|
4397
4635
|
idColumn: A.user_id,
|
|
4398
4636
|
sortOrder: n,
|
|
4399
4637
|
sortKey: `created_at:${n}`
|
|
4400
|
-
}, i =
|
|
4638
|
+
}, i = Ft(s), a = Lt(s, r), { rows: o, next: c } = Rt((await e.select().from(A).leftJoin(Ue, di()).where(a ? t(g, a) : g).orderBy(...It(r)).limit(i + 1)).map((e) => fi(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4401
4639
|
return {
|
|
4402
4640
|
users: l,
|
|
4403
4641
|
start: 0,
|
|
@@ -4406,15 +4644,15 @@ function ri(e) {
|
|
|
4406
4644
|
next: c
|
|
4407
4645
|
};
|
|
4408
4646
|
}
|
|
4409
|
-
let v = e.select().from(A).leftJoin(
|
|
4647
|
+
let v = e.select().from(A).leftJoin(Ue, di()).where(g).$dynamic();
|
|
4410
4648
|
if (p?.sort_by) {
|
|
4411
|
-
let e =
|
|
4649
|
+
let e = ui[p.sort_by];
|
|
4412
4650
|
if (e) {
|
|
4413
|
-
let t =
|
|
4651
|
+
let t = bt(e) ? xt(e) : e;
|
|
4414
4652
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4415
4653
|
}
|
|
4416
4654
|
}
|
|
4417
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(
|
|
4655
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(Ue, di()).where(g) : void 0]), b = await _(y.map((e) => fi(e.users, e.user_activity)));
|
|
4418
4656
|
if (!ee) return { users: b };
|
|
4419
4657
|
let [te] = ee;
|
|
4420
4658
|
return {
|
|
@@ -4426,14 +4664,14 @@ function ri(e) {
|
|
|
4426
4664
|
},
|
|
4427
4665
|
async remove(n, r, i) {
|
|
4428
4666
|
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 = [
|
|
4429
|
-
e.delete(
|
|
4667
|
+
e.delete(dt).where(t(a(dt.tenant_id, n), l(dt.user_id, u))),
|
|
4430
4668
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4431
|
-
e.delete(
|
|
4669
|
+
e.delete(Ue).where(t(a(Ue.tenant_id, n), l(Ue.user_id, u))),
|
|
4432
4670
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4433
4671
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4434
4672
|
], f = d.length - 1;
|
|
4435
|
-
if (s) for (let t of
|
|
4436
|
-
let p = (await
|
|
4673
|
+
if (s) for (let t of ii(e, n, i)) d.push(t);
|
|
4674
|
+
let p = (await kt(e, d))[f];
|
|
4437
4675
|
return Array.isArray(p) && p.length > 0;
|
|
4438
4676
|
},
|
|
4439
4677
|
async unlink(n, r, i, o) {
|
|
@@ -4444,7 +4682,7 @@ function ri(e) {
|
|
|
4444
4682
|
}
|
|
4445
4683
|
//#endregion
|
|
4446
4684
|
//#region src/adapters/userRoles.ts
|
|
4447
|
-
function
|
|
4685
|
+
function gi(e) {
|
|
4448
4686
|
return {
|
|
4449
4687
|
async create(t, n, r, i) {
|
|
4450
4688
|
try {
|
|
@@ -4478,12 +4716,12 @@ function ii(e) {
|
|
|
4478
4716
|
},
|
|
4479
4717
|
async listUsers(r, i, o) {
|
|
4480
4718
|
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4481
|
-
if (
|
|
4719
|
+
if (Pt(o)) {
|
|
4482
4720
|
let n = {
|
|
4483
4721
|
sortColumn: G.user_id,
|
|
4484
4722
|
idColumn: G.user_id,
|
|
4485
4723
|
sortOrder: "asc"
|
|
4486
|
-
}, r =
|
|
4724
|
+
}, r = Lt(o, n), i = Ft(o), { rows: a, next: c } = Rt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...It(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4487
4725
|
return {
|
|
4488
4726
|
userIds: a.map((e) => e.user_id),
|
|
4489
4727
|
start: 0,
|
|
@@ -4507,7 +4745,7 @@ function ii(e) {
|
|
|
4507
4745
|
}
|
|
4508
4746
|
//#endregion
|
|
4509
4747
|
//#region src/adapters/userOrganizations.ts
|
|
4510
|
-
function
|
|
4748
|
+
function _i(e) {
|
|
4511
4749
|
return {
|
|
4512
4750
|
async create(t, n) {
|
|
4513
4751
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4521,7 +4759,7 @@ function ai(e) {
|
|
|
4521
4759
|
try {
|
|
4522
4760
|
await e.insert(H).values(i);
|
|
4523
4761
|
} catch (e) {
|
|
4524
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4762
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Re(409, { message: "User organization already exists" }) : e;
|
|
4525
4763
|
}
|
|
4526
4764
|
let { tenant_id: a, ...o } = i;
|
|
4527
4765
|
return o;
|
|
@@ -4539,19 +4777,19 @@ function ai(e) {
|
|
|
4539
4777
|
async list(n, o) {
|
|
4540
4778
|
let { include_totals: s = !1, q: c } = o || {}, l = a(H.tenant_id, n), u = l;
|
|
4541
4779
|
if (c) {
|
|
4542
|
-
let e =
|
|
4780
|
+
let e = St(H, c, ["user_id", "organization_id"]);
|
|
4543
4781
|
e && (u = t(l, e));
|
|
4544
4782
|
}
|
|
4545
4783
|
let d = (e) => {
|
|
4546
4784
|
let { tenant_id: t, ...n } = e;
|
|
4547
4785
|
return n;
|
|
4548
4786
|
};
|
|
4549
|
-
if (
|
|
4787
|
+
if (Pt(o)) {
|
|
4550
4788
|
let n = {
|
|
4551
4789
|
sortColumn: H.created_at,
|
|
4552
4790
|
idColumn: H.id,
|
|
4553
4791
|
sortOrder: "desc"
|
|
4554
|
-
}, r =
|
|
4792
|
+
}, r = Lt(o, n), i = Ft(o), { rows: a, next: s } = Rt((await e.select().from(H).where(r ? t(u, r) : u).orderBy(...It(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4555
4793
|
return {
|
|
4556
4794
|
userOrganizations: a,
|
|
4557
4795
|
start: 0,
|
|
@@ -4599,19 +4837,19 @@ function ai(e) {
|
|
|
4599
4837
|
}
|
|
4600
4838
|
//#endregion
|
|
4601
4839
|
//#region src/adapters/stats.ts
|
|
4602
|
-
var
|
|
4603
|
-
function
|
|
4840
|
+
var vi = ["s"], yi = ["pwd_leak"];
|
|
4841
|
+
function bi(e) {
|
|
4604
4842
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4605
4843
|
}
|
|
4606
|
-
function
|
|
4844
|
+
function xi(e) {
|
|
4607
4845
|
return {
|
|
4608
4846
|
async getDaily(n, r) {
|
|
4609
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4847
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? bi(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? bi(r.to) : i.toISOString().split("T")[0];
|
|
4610
4848
|
return (await e.select({
|
|
4611
4849
|
date: y`substr(${q.date}, 1, 10)`.as("date"),
|
|
4612
|
-
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4850
|
+
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(vi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4613
4851
|
signups: y`SUM(CASE WHEN ${q.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4614
|
-
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4852
|
+
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(yi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4615
4853
|
}).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) => ({
|
|
4616
4854
|
date: e.date,
|
|
4617
4855
|
logins: Number(e.logins) || 0,
|
|
@@ -4622,14 +4860,14 @@ function li(e) {
|
|
|
4622
4860
|
}));
|
|
4623
4861
|
},
|
|
4624
4862
|
async getActiveUsers(n) {
|
|
4625
|
-
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(
|
|
4863
|
+
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(vi.map((e) => y`${e}`), y`, `)})`));
|
|
4626
4864
|
return Number(i?.count) || 0;
|
|
4627
4865
|
}
|
|
4628
4866
|
};
|
|
4629
4867
|
}
|
|
4630
4868
|
//#endregion
|
|
4631
4869
|
//#region src/adapters/analytics.ts
|
|
4632
|
-
var
|
|
4870
|
+
var Si = {
|
|
4633
4871
|
"active-users": ["s", "seacft"],
|
|
4634
4872
|
logins: [
|
|
4635
4873
|
"s",
|
|
@@ -4659,7 +4897,7 @@ var ui = {
|
|
|
4659
4897
|
"fvr"
|
|
4660
4898
|
],
|
|
4661
4899
|
"codes-sent": ["cls", "cs"]
|
|
4662
|
-
},
|
|
4900
|
+
}, Ci = {
|
|
4663
4901
|
"active-users": {
|
|
4664
4902
|
alias: "active_users",
|
|
4665
4903
|
type: "UInt64",
|
|
@@ -4716,7 +4954,7 @@ var ui = {
|
|
|
4716
4954
|
agg: "count"
|
|
4717
4955
|
}
|
|
4718
4956
|
};
|
|
4719
|
-
function
|
|
4957
|
+
function wi(e) {
|
|
4720
4958
|
switch (e) {
|
|
4721
4959
|
case "hour": return y`substr(${q.date}, 1, 13)`;
|
|
4722
4960
|
case "month": return y`substr(${q.date}, 1, 7)`;
|
|
@@ -4725,10 +4963,10 @@ function fi(e) {
|
|
|
4725
4963
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4726
4964
|
}
|
|
4727
4965
|
}
|
|
4728
|
-
function
|
|
4966
|
+
function Ti(e) {
|
|
4729
4967
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4730
4968
|
}
|
|
4731
|
-
function
|
|
4969
|
+
function Ei(e) {
|
|
4732
4970
|
switch (e) {
|
|
4733
4971
|
case "connection": return q.connection;
|
|
4734
4972
|
case "client_id": return q.client_id;
|
|
@@ -4737,10 +4975,10 @@ function mi(e) {
|
|
|
4737
4975
|
case "time": throw Error("time dimension handled separately");
|
|
4738
4976
|
}
|
|
4739
4977
|
}
|
|
4740
|
-
function
|
|
4978
|
+
function Di(e) {
|
|
4741
4979
|
return {
|
|
4742
4980
|
async query(n, r, i) {
|
|
4743
|
-
let o = Date.now(), s =
|
|
4981
|
+
let o = Date.now(), s = Si[r], u = Ci[r], d = [
|
|
4744
4982
|
a(q.tenant_id, n),
|
|
4745
4983
|
c(q.date, i.from),
|
|
4746
4984
|
m(q.date, i.to),
|
|
@@ -4749,13 +4987,13 @@ function hi(e) {
|
|
|
4749
4987
|
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));
|
|
4750
4988
|
let f = {}, p = [], h = [];
|
|
4751
4989
|
for (let e of i.group_by) if (e === "time") {
|
|
4752
|
-
let e =
|
|
4990
|
+
let e = wi(i.interval);
|
|
4753
4991
|
f.time = e, p.push(e), h.push({
|
|
4754
4992
|
name: "time",
|
|
4755
4993
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4756
4994
|
});
|
|
4757
4995
|
} else {
|
|
4758
|
-
let t =
|
|
4996
|
+
let t = Ei(e);
|
|
4759
4997
|
f[e] = t, p.push(t), h.push({
|
|
4760
4998
|
name: e,
|
|
4761
4999
|
type: "String"
|
|
@@ -4771,9 +5009,9 @@ function hi(e) {
|
|
|
4771
5009
|
if (i.order_by) {
|
|
4772
5010
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4773
5011
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4774
|
-
let n =
|
|
5012
|
+
let n = Ti(t);
|
|
4775
5013
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4776
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
5014
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Ti("time")} ASC`)) : g.orderBy(y.raw(`${Ti(u.alias)} DESC`));
|
|
4777
5015
|
g = g.limit(i.limit).offset(i.offset);
|
|
4778
5016
|
let v = (await g.all()).map((e) => {
|
|
4779
5017
|
let t = {};
|
|
@@ -4792,7 +5030,7 @@ function hi(e) {
|
|
|
4792
5030
|
};
|
|
4793
5031
|
},
|
|
4794
5032
|
async sessionRetention(n, r) {
|
|
4795
|
-
let i = Date.now(), { sinceMs: o } =
|
|
5033
|
+
let i = Date.now(), { sinceMs: o } = Oe(r.weeks, i), s = y`(${M.created_at_ts} + ${ue}) / ${fe}`, l = y`(COALESCE(${M.used_at_ts}, ${M.created_at_ts}) + ${ue}) / ${fe}`;
|
|
4796
5034
|
return me((await e.select({
|
|
4797
5035
|
created_week: s,
|
|
4798
5036
|
used_week: l,
|
|
@@ -4804,7 +5042,7 @@ function hi(e) {
|
|
|
4804
5042
|
})), r.weeks, i);
|
|
4805
5043
|
},
|
|
4806
5044
|
async refreshTokenRetention(n, r) {
|
|
4807
|
-
let i = Date.now(), { sinceMs: o } =
|
|
5045
|
+
let i = Date.now(), { sinceMs: o } = Oe(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(N.client_id, r.client_id) : void 0, u = e.select({
|
|
4808
5046
|
min_created: y`MIN(${N.created_at_ts})`.as("min_created"),
|
|
4809
5047
|
max_used: y`MAX(COALESCE(${N.last_exchanged_at_ts}, ${N.created_at_ts}))`.as("max_used")
|
|
4810
5048
|
}).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}`;
|
|
@@ -4822,10 +5060,10 @@ function hi(e) {
|
|
|
4822
5060
|
}
|
|
4823
5061
|
//#endregion
|
|
4824
5062
|
//#region src/adapters/cleanup.ts
|
|
4825
|
-
var
|
|
4826
|
-
function
|
|
5063
|
+
var Oi = 10080 * 60 * 1e3;
|
|
5064
|
+
function ki(e) {
|
|
4827
5065
|
return async (n) => {
|
|
4828
|
-
let r = Date.now() -
|
|
5066
|
+
let r = Date.now() - Oi;
|
|
4829
5067
|
try {
|
|
4830
5068
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
4831
5069
|
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));
|
|
@@ -4860,7 +5098,7 @@ var Q = w("tenant_operations", {
|
|
|
4860
5098
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4861
5099
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4862
5100
|
x("tenant_operations_status_idx").on(e.status)
|
|
4863
|
-
]),
|
|
5101
|
+
]), Ai = w("tenant_operation_events", {
|
|
4864
5102
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4865
5103
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4866
5104
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4891,7 +5129,7 @@ var Q = w("tenant_operations", {
|
|
|
4891
5129
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
4892
5130
|
}).onDelete("cascade"),
|
|
4893
5131
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
4894
|
-
]),
|
|
5132
|
+
]), ji = w("rollouts", {
|
|
4895
5133
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4896
5134
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4897
5135
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4907,7 +5145,7 @@ var Q = w("tenant_operations", {
|
|
|
4907
5145
|
});
|
|
4908
5146
|
//#endregion
|
|
4909
5147
|
//#region src/adapters/tenantOperations.ts
|
|
4910
|
-
function
|
|
5148
|
+
function Mi(e) {
|
|
4911
5149
|
if (!e) return null;
|
|
4912
5150
|
try {
|
|
4913
5151
|
return JSON.parse(e);
|
|
@@ -4915,8 +5153,8 @@ function bi(e) {
|
|
|
4915
5153
|
return null;
|
|
4916
5154
|
}
|
|
4917
5155
|
}
|
|
4918
|
-
function
|
|
4919
|
-
return
|
|
5156
|
+
function Ni(e) {
|
|
5157
|
+
return Fe.parse({
|
|
4920
5158
|
id: e.id,
|
|
4921
5159
|
tenant_id: e.tenant_id,
|
|
4922
5160
|
rollout_id: e.rollout_id,
|
|
@@ -4929,8 +5167,8 @@ function xi(e) {
|
|
|
4929
5167
|
target_database_version: e.target_database_version,
|
|
4930
5168
|
error: e.error,
|
|
4931
5169
|
initiated_by: e.initiated_by,
|
|
4932
|
-
input:
|
|
4933
|
-
result:
|
|
5170
|
+
input: Mi(e.input),
|
|
5171
|
+
result: Mi(e.result),
|
|
4934
5172
|
claimed_by: e.claimed_by,
|
|
4935
5173
|
claim_expires_at: e.claim_expires_at,
|
|
4936
5174
|
created_at: e.created_at,
|
|
@@ -4938,10 +5176,10 @@ function xi(e) {
|
|
|
4938
5176
|
finished_at: e.finished_at
|
|
4939
5177
|
});
|
|
4940
5178
|
}
|
|
4941
|
-
function
|
|
5179
|
+
function Pi(e) {
|
|
4942
5180
|
return {
|
|
4943
5181
|
async create(t) {
|
|
4944
|
-
let n =
|
|
5182
|
+
let n = Me.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4945
5183
|
id: `op_${b()}`,
|
|
4946
5184
|
tenant_id: n.tenant_id,
|
|
4947
5185
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4969,7 +5207,7 @@ function Si(e) {
|
|
|
4969
5207
|
},
|
|
4970
5208
|
async get(t) {
|
|
4971
5209
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
4972
|
-
return n[0] ?
|
|
5210
|
+
return n[0] ? Ni(n[0]) : null;
|
|
4973
5211
|
},
|
|
4974
5212
|
async list(n = {}) {
|
|
4975
5213
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4980,7 +5218,7 @@ function Si(e) {
|
|
|
4980
5218
|
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));
|
|
4981
5219
|
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);
|
|
4982
5220
|
return {
|
|
4983
|
-
operations: c.map(
|
|
5221
|
+
operations: c.map(Ni),
|
|
4984
5222
|
start: r * o,
|
|
4985
5223
|
limit: o,
|
|
4986
5224
|
length: c.length
|
|
@@ -5006,7 +5244,7 @@ function Si(e) {
|
|
|
5006
5244
|
},
|
|
5007
5245
|
async listResumable(r) {
|
|
5008
5246
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
5009
|
-
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(
|
|
5247
|
+
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(Ni);
|
|
5010
5248
|
},
|
|
5011
5249
|
async remove(t) {
|
|
5012
5250
|
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);
|
|
@@ -5015,19 +5253,19 @@ function Si(e) {
|
|
|
5015
5253
|
}
|
|
5016
5254
|
//#endregion
|
|
5017
5255
|
//#region src/adapters/tenantOperationRows.ts
|
|
5018
|
-
var
|
|
5019
|
-
function
|
|
5256
|
+
var Fi = 50, Ii = 50;
|
|
5257
|
+
function Li(e) {
|
|
5020
5258
|
try {
|
|
5021
5259
|
return JSON.parse(e);
|
|
5022
5260
|
} catch {
|
|
5023
5261
|
return {};
|
|
5024
5262
|
}
|
|
5025
5263
|
}
|
|
5026
|
-
function
|
|
5027
|
-
return
|
|
5264
|
+
function Ri(e) {
|
|
5265
|
+
return Pe.parse({
|
|
5028
5266
|
operation_id: e.operation_id,
|
|
5029
5267
|
seq: e.seq,
|
|
5030
|
-
payload:
|
|
5268
|
+
payload: Li(e.payload),
|
|
5031
5269
|
status: e.status,
|
|
5032
5270
|
error_code: e.error_code,
|
|
5033
5271
|
error_message: e.error_message,
|
|
@@ -5037,12 +5275,12 @@ function Ei(e) {
|
|
|
5037
5275
|
updated_at: e.updated_at
|
|
5038
5276
|
});
|
|
5039
5277
|
}
|
|
5040
|
-
function
|
|
5278
|
+
function zi(e, t) {
|
|
5041
5279
|
let n = [];
|
|
5042
5280
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5043
5281
|
return n;
|
|
5044
5282
|
}
|
|
5045
|
-
function
|
|
5283
|
+
function Bi(e, n, r, i) {
|
|
5046
5284
|
return e.update($).set({
|
|
5047
5285
|
status: r.status,
|
|
5048
5286
|
error_code: r.error_code ?? null,
|
|
@@ -5052,12 +5290,12 @@ function Oi(e, n, r, i) {
|
|
|
5052
5290
|
updated_at: i
|
|
5053
5291
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
5054
5292
|
}
|
|
5055
|
-
function
|
|
5293
|
+
function Vi(e) {
|
|
5056
5294
|
return {
|
|
5057
5295
|
async createMany(t) {
|
|
5058
5296
|
if (t.length === 0) return 0;
|
|
5059
5297
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.map((e) => {
|
|
5060
|
-
let t =
|
|
5298
|
+
let t = Ne.parse(e);
|
|
5061
5299
|
return {
|
|
5062
5300
|
operation_id: t.operation_id,
|
|
5063
5301
|
seq: t.seq,
|
|
@@ -5071,24 +5309,24 @@ function ki(e) {
|
|
|
5071
5309
|
updated_at: n
|
|
5072
5310
|
};
|
|
5073
5311
|
});
|
|
5074
|
-
for (let t of
|
|
5312
|
+
for (let t of zi(r, Fi)) await e.insert($).values(t);
|
|
5075
5313
|
return r.length;
|
|
5076
5314
|
},
|
|
5077
5315
|
async claimPending(r, i) {
|
|
5078
|
-
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(
|
|
5316
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Ri);
|
|
5079
5317
|
},
|
|
5080
5318
|
async recordOutcomes(n, r) {
|
|
5081
5319
|
if (r.length === 0) return 0;
|
|
5082
5320
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
5083
|
-
for (let r of
|
|
5321
|
+
for (let r of zi(o, Ii)) {
|
|
5084
5322
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
5085
5323
|
for (let e of i) s.add(e.seq);
|
|
5086
5324
|
}
|
|
5087
5325
|
let c = r.filter((e) => s.has(e.seq));
|
|
5088
5326
|
if (c.length === 0) return 0;
|
|
5089
|
-
for (let t of
|
|
5090
|
-
let [r, ...a] = t.map((t) =>
|
|
5091
|
-
r && await
|
|
5327
|
+
for (let t of zi(c, Ii)) {
|
|
5328
|
+
let [r, ...a] = t.map((t) => Bi(e, n, t, i));
|
|
5329
|
+
r && await kt(e, [r, ...a]);
|
|
5092
5330
|
}
|
|
5093
5331
|
return c.length;
|
|
5094
5332
|
},
|
|
@@ -5123,7 +5361,7 @@ function ki(e) {
|
|
|
5123
5361
|
}
|
|
5124
5362
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5125
5363
|
return {
|
|
5126
|
-
rows: u.map(
|
|
5364
|
+
rows: u.map(Ri),
|
|
5127
5365
|
start: o * s,
|
|
5128
5366
|
limit: s,
|
|
5129
5367
|
length: u.length
|
|
@@ -5137,27 +5375,27 @@ function ki(e) {
|
|
|
5137
5375
|
}
|
|
5138
5376
|
//#endregion
|
|
5139
5377
|
//#region src/helpers/monotonic-id.ts
|
|
5140
|
-
var
|
|
5141
|
-
function
|
|
5378
|
+
var Hi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ui = 32, Wi = 10, Gi = 4, Ki = 10;
|
|
5379
|
+
function qi(e, t) {
|
|
5142
5380
|
let n = "";
|
|
5143
|
-
for (let r = t; r > 0; r--) n =
|
|
5381
|
+
for (let r = t; r > 0; r--) n = Hi.charAt(e % Ui) + n, e = Math.floor(e / Ui);
|
|
5144
5382
|
return n;
|
|
5145
5383
|
}
|
|
5146
|
-
function
|
|
5147
|
-
let e = new Uint8Array(
|
|
5384
|
+
function Ji() {
|
|
5385
|
+
let e = new Uint8Array(Ki);
|
|
5148
5386
|
crypto.getRandomValues(e);
|
|
5149
5387
|
let t = "";
|
|
5150
|
-
for (let n = 0; n <
|
|
5388
|
+
for (let n = 0; n < Ki; n++) t += Hi.charAt(e[n] % Ui);
|
|
5151
5389
|
return t;
|
|
5152
5390
|
}
|
|
5153
|
-
var
|
|
5154
|
-
function
|
|
5391
|
+
var Yi = 0, Xi = 0;
|
|
5392
|
+
function Zi() {
|
|
5155
5393
|
let e = Date.now();
|
|
5156
|
-
return e ===
|
|
5394
|
+
return e === Yi ? Xi++ : (Yi = e, Xi = 0), qi(e, Wi) + qi(Xi, Gi) + Ji();
|
|
5157
5395
|
}
|
|
5158
5396
|
//#endregion
|
|
5159
5397
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5160
|
-
function
|
|
5398
|
+
function Qi(e) {
|
|
5161
5399
|
if (!e) return null;
|
|
5162
5400
|
try {
|
|
5163
5401
|
let t = JSON.parse(e);
|
|
@@ -5165,22 +5403,22 @@ function Bi(e) {
|
|
|
5165
5403
|
} catch {}
|
|
5166
5404
|
return null;
|
|
5167
5405
|
}
|
|
5168
|
-
function
|
|
5169
|
-
return
|
|
5406
|
+
function $i(e) {
|
|
5407
|
+
return je.parse({
|
|
5170
5408
|
id: e.id,
|
|
5171
5409
|
operation_id: e.operation_id,
|
|
5172
5410
|
step: e.step,
|
|
5173
5411
|
outcome: e.outcome,
|
|
5174
|
-
detail:
|
|
5412
|
+
detail: Qi(e.detail),
|
|
5175
5413
|
attempt: e.attempt,
|
|
5176
5414
|
created_at: e.created_at
|
|
5177
5415
|
});
|
|
5178
5416
|
}
|
|
5179
|
-
function
|
|
5417
|
+
function ea(e) {
|
|
5180
5418
|
return {
|
|
5181
5419
|
async create(t) {
|
|
5182
|
-
let n =
|
|
5183
|
-
id: `evt_${
|
|
5420
|
+
let n = Ae.parse(t), r = {
|
|
5421
|
+
id: `evt_${Zi()}`,
|
|
5184
5422
|
operation_id: n.operation_id,
|
|
5185
5423
|
step: n.step,
|
|
5186
5424
|
outcome: n.outcome,
|
|
@@ -5188,7 +5426,7 @@ function Hi(e) {
|
|
|
5188
5426
|
attempt: n.attempt,
|
|
5189
5427
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5190
5428
|
};
|
|
5191
|
-
return await e.insert(
|
|
5429
|
+
return await e.insert(Ai).values(r), je.parse({
|
|
5192
5430
|
id: r.id,
|
|
5193
5431
|
operation_id: r.operation_id,
|
|
5194
5432
|
step: r.step,
|
|
@@ -5199,9 +5437,9 @@ function Hi(e) {
|
|
|
5199
5437
|
});
|
|
5200
5438
|
},
|
|
5201
5439
|
async listByOperation(t, r = {}) {
|
|
5202
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5440
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Ai).where(a(Ai.operation_id, t)).orderBy(n(Ai.created_at), n(Ai.id)).offset(i * o).limit(o);
|
|
5203
5441
|
return {
|
|
5204
|
-
events: s.map(
|
|
5442
|
+
events: s.map($i),
|
|
5205
5443
|
start: i * o,
|
|
5206
5444
|
limit: o,
|
|
5207
5445
|
length: s.length
|
|
@@ -5211,7 +5449,7 @@ function Hi(e) {
|
|
|
5211
5449
|
}
|
|
5212
5450
|
//#endregion
|
|
5213
5451
|
//#region src/adapters/rollouts.ts
|
|
5214
|
-
function
|
|
5452
|
+
function ta(e) {
|
|
5215
5453
|
if (!e) return null;
|
|
5216
5454
|
try {
|
|
5217
5455
|
return JSON.parse(e);
|
|
@@ -5219,26 +5457,26 @@ function Ui(e) {
|
|
|
5219
5457
|
return null;
|
|
5220
5458
|
}
|
|
5221
5459
|
}
|
|
5222
|
-
function
|
|
5223
|
-
return
|
|
5460
|
+
function na(e) {
|
|
5461
|
+
return Te.parse({
|
|
5224
5462
|
id: e.id,
|
|
5225
5463
|
kind: e.kind,
|
|
5226
5464
|
status: e.status,
|
|
5227
5465
|
target_worker_version: e.target_worker_version,
|
|
5228
5466
|
target_database_version: e.target_database_version,
|
|
5229
5467
|
wave_size: e.wave_size,
|
|
5230
|
-
canary_tenant_ids:
|
|
5231
|
-
filter:
|
|
5468
|
+
canary_tenant_ids: ta(e.canary_tenant_ids),
|
|
5469
|
+
filter: ta(e.filter),
|
|
5232
5470
|
initiated_by: e.initiated_by,
|
|
5233
5471
|
created_at: e.created_at,
|
|
5234
5472
|
updated_at: e.updated_at,
|
|
5235
5473
|
finished_at: e.finished_at
|
|
5236
5474
|
});
|
|
5237
5475
|
}
|
|
5238
|
-
function
|
|
5476
|
+
function ra(e) {
|
|
5239
5477
|
return {
|
|
5240
5478
|
async create(t) {
|
|
5241
|
-
let n =
|
|
5479
|
+
let n = we.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
5242
5480
|
id: `rol_${b()}`,
|
|
5243
5481
|
kind: n.kind,
|
|
5244
5482
|
status: "pending",
|
|
@@ -5252,95 +5490,99 @@ function Gi(e) {
|
|
|
5252
5490
|
updated_at: r,
|
|
5253
5491
|
finished_at: null
|
|
5254
5492
|
};
|
|
5255
|
-
await e.insert(
|
|
5493
|
+
await e.insert(ji).values(i);
|
|
5256
5494
|
let a = await this.get(i.id);
|
|
5257
5495
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5258
5496
|
return a;
|
|
5259
5497
|
},
|
|
5260
5498
|
async get(t) {
|
|
5261
|
-
let n = await e.select().from(
|
|
5262
|
-
return n[0] ?
|
|
5499
|
+
let n = await e.select().from(ji).where(a(ji.id, t)).limit(1);
|
|
5500
|
+
return n[0] ? na(n[0]) : null;
|
|
5263
5501
|
},
|
|
5264
5502
|
async list(t = {}) {
|
|
5265
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5503
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(ji).orderBy(i(ji.created_at), i(ji.id)).offset(n * r).limit(r);
|
|
5266
5504
|
return {
|
|
5267
|
-
rollouts: a.map(
|
|
5505
|
+
rollouts: a.map(na),
|
|
5268
5506
|
start: n * r,
|
|
5269
5507
|
limit: r,
|
|
5270
5508
|
length: a.length
|
|
5271
5509
|
};
|
|
5272
5510
|
},
|
|
5273
5511
|
async update(t, n) {
|
|
5274
|
-
if ((await e.select({ id:
|
|
5512
|
+
if ((await e.select({ id: ji.id }).from(ji).where(a(ji.id, t)).limit(1)).length === 0) return !1;
|
|
5275
5513
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5276
|
-
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(
|
|
5514
|
+
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(ji).set(r).where(a(ji.id, t)), !0;
|
|
5277
5515
|
},
|
|
5278
5516
|
async remove(t) {
|
|
5279
|
-
return (await e.select({ id:
|
|
5517
|
+
return (await e.select({ id: ji.id }).from(ji).where(a(ji.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(ji).where(a(ji.id, t)), !0);
|
|
5280
5518
|
}
|
|
5281
5519
|
};
|
|
5282
5520
|
}
|
|
5283
5521
|
//#endregion
|
|
5284
5522
|
//#region src/adapters/index.ts
|
|
5285
|
-
function
|
|
5523
|
+
function ia(e, t = { useTransactions: !0 }) {
|
|
5286
5524
|
let n = {
|
|
5287
|
-
actions:
|
|
5288
|
-
actionExecutions:
|
|
5289
|
-
actionVersions:
|
|
5290
|
-
branding:
|
|
5291
|
-
clients:
|
|
5292
|
-
clientConnections:
|
|
5293
|
-
clientGrants:
|
|
5294
|
-
clientRegistrationTokens:
|
|
5295
|
-
codes:
|
|
5296
|
-
connections:
|
|
5297
|
-
customDomains:
|
|
5298
|
-
customText:
|
|
5299
|
-
emailProviders:
|
|
5300
|
-
emailTemplates:
|
|
5301
|
-
flows:
|
|
5302
|
-
forms:
|
|
5303
|
-
grants:
|
|
5304
|
-
hookCode:
|
|
5305
|
-
hooks:
|
|
5306
|
-
invites:
|
|
5307
|
-
keys:
|
|
5308
|
-
loginSessions:
|
|
5309
|
-
logs:
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5525
|
+
actions: Tt(e),
|
|
5526
|
+
actionExecutions: Dt(e),
|
|
5527
|
+
actionVersions: jt(e),
|
|
5528
|
+
branding: Nt(e),
|
|
5529
|
+
clients: Wt(e),
|
|
5530
|
+
clientConnections: Kt(e),
|
|
5531
|
+
clientGrants: Jt(e),
|
|
5532
|
+
clientRegistrationTokens: $t(e),
|
|
5533
|
+
codes: rn(e),
|
|
5534
|
+
connections: sn(e),
|
|
5535
|
+
customDomains: ln(e),
|
|
5536
|
+
customText: un(e),
|
|
5537
|
+
emailProviders: dn(e),
|
|
5538
|
+
emailTemplates: pn(e),
|
|
5539
|
+
flows: hn(e),
|
|
5540
|
+
forms: vn(e),
|
|
5541
|
+
grants: Sn(e),
|
|
5542
|
+
hookCode: En(e),
|
|
5543
|
+
hooks: An(e),
|
|
5544
|
+
invites: Pn(e),
|
|
5545
|
+
keys: In(e),
|
|
5546
|
+
loginSessions: Vn(e),
|
|
5547
|
+
logs: Un(e),
|
|
5548
|
+
logStreams: nr(e),
|
|
5549
|
+
migrationSources: ir(e),
|
|
5550
|
+
authenticationMethods: Jn(e),
|
|
5551
|
+
organizations: Qn(e),
|
|
5552
|
+
organizationConnections: er(e),
|
|
5553
|
+
passwords: or(e),
|
|
5554
|
+
promptSettings: sr(e),
|
|
5555
|
+
promptPartials: cr(e),
|
|
5556
|
+
proxyRoutes: fr(e),
|
|
5557
|
+
scimConfigurations: br(e),
|
|
5558
|
+
scimTokens: Sr(e),
|
|
5559
|
+
scimExternalIds: wr(e),
|
|
5560
|
+
refreshTokens: Dr(e),
|
|
5561
|
+
resourceServers: Nr(e),
|
|
5562
|
+
rolePermissions: Pr(e),
|
|
5563
|
+
userPermissions: Ir(e),
|
|
5564
|
+
roles: Rr(e),
|
|
5565
|
+
sessions: Ur(e),
|
|
5566
|
+
sessionCleanup: ki(e),
|
|
5567
|
+
tenants: Jr(e),
|
|
5568
|
+
tokenExchangeProfiles: gr(e),
|
|
5327
5569
|
...t.controlPlane ? {
|
|
5328
|
-
tenantOperations:
|
|
5329
|
-
tenantOperationEvents:
|
|
5330
|
-
tenantOperationRows:
|
|
5331
|
-
rollouts:
|
|
5570
|
+
tenantOperations: Pi(e),
|
|
5571
|
+
tenantOperationEvents: ea(e),
|
|
5572
|
+
tenantOperationRows: Vi(e),
|
|
5573
|
+
rollouts: ra(e)
|
|
5332
5574
|
} : {},
|
|
5333
|
-
themes:
|
|
5334
|
-
universalLoginTemplates:
|
|
5335
|
-
users:
|
|
5336
|
-
userActivity:
|
|
5337
|
-
userRoles:
|
|
5338
|
-
userOrganizations:
|
|
5339
|
-
stats:
|
|
5340
|
-
analytics:
|
|
5341
|
-
outbox:
|
|
5575
|
+
themes: Zr(e),
|
|
5576
|
+
universalLoginTemplates: Qr(e),
|
|
5577
|
+
users: hi(e),
|
|
5578
|
+
userActivity: ei(e),
|
|
5579
|
+
userRoles: gi(e),
|
|
5580
|
+
userOrganizations: _i(e),
|
|
5581
|
+
stats: xi(e),
|
|
5582
|
+
analytics: Di(e),
|
|
5583
|
+
outbox: ri(e),
|
|
5342
5584
|
async transaction(r) {
|
|
5343
|
-
if (t.useTransactions === !1 ||
|
|
5585
|
+
if (t.useTransactions === !1 || Ot(e)) return r(n);
|
|
5344
5586
|
await e.run(y`BEGIN`);
|
|
5345
5587
|
try {
|
|
5346
5588
|
let t = await r(n);
|
|
@@ -5354,7 +5596,7 @@ function Ki(e, t = { useTransactions: !0 }) {
|
|
|
5354
5596
|
}
|
|
5355
5597
|
//#endregion
|
|
5356
5598
|
//#region src/adapters/resolveHost.ts
|
|
5357
|
-
function
|
|
5599
|
+
function aa(e) {
|
|
5358
5600
|
if (!e) return { path: "/*" };
|
|
5359
5601
|
try {
|
|
5360
5602
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -5362,7 +5604,7 @@ function qi(e) {
|
|
|
5362
5604
|
} catch {}
|
|
5363
5605
|
return { path: "/*" };
|
|
5364
5606
|
}
|
|
5365
|
-
function
|
|
5607
|
+
function oa(e) {
|
|
5366
5608
|
if (!e) return [];
|
|
5367
5609
|
try {
|
|
5368
5610
|
let t = JSON.parse(e);
|
|
@@ -5377,20 +5619,20 @@ function Ji(e) {
|
|
|
5377
5619
|
return [];
|
|
5378
5620
|
}
|
|
5379
5621
|
}
|
|
5380
|
-
async function
|
|
5622
|
+
async function sa(e, r) {
|
|
5381
5623
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5382
|
-
custom_domain_id:
|
|
5383
|
-
tenant_id:
|
|
5384
|
-
domain:
|
|
5385
|
-
}).from(
|
|
5624
|
+
custom_domain_id: qe.custom_domain_id,
|
|
5625
|
+
tenant_id: qe.tenant_id,
|
|
5626
|
+
domain: qe.domain
|
|
5627
|
+
}).from(qe).where(a(qe.domain, i)).limit(1))[0];
|
|
5386
5628
|
if (!o) return null;
|
|
5387
5629
|
let s = (await e.select().from(Y).where(t(a(Y.tenant_id, o.tenant_id), a(Y.custom_domain_id, o.custom_domain_id))).orderBy(n(Y.priority), n(Y.created_at))).map((e) => ({
|
|
5388
5630
|
id: e.id,
|
|
5389
5631
|
tenant_id: e.tenant_id,
|
|
5390
5632
|
custom_domain_id: e.custom_domain_id,
|
|
5391
5633
|
priority: e.priority,
|
|
5392
|
-
match:
|
|
5393
|
-
handlers:
|
|
5634
|
+
match: aa(e.match),
|
|
5635
|
+
handlers: oa(e.handlers),
|
|
5394
5636
|
created_at: e.created_at,
|
|
5395
5637
|
updated_at: e.updated_at
|
|
5396
5638
|
}));
|
|
@@ -5403,11 +5645,11 @@ async function Yi(e, r) {
|
|
|
5403
5645
|
}
|
|
5404
5646
|
//#endregion
|
|
5405
5647
|
//#region src/adapters/proxyData.ts
|
|
5406
|
-
function
|
|
5648
|
+
function ca(e) {
|
|
5407
5649
|
return {
|
|
5408
|
-
proxyRoutes:
|
|
5409
|
-
resolveHost: (t) =>
|
|
5650
|
+
proxyRoutes: fr(e),
|
|
5651
|
+
resolveHost: (t) => sa(e, t)
|
|
5410
5652
|
};
|
|
5411
5653
|
}
|
|
5412
5654
|
//#endregion
|
|
5413
|
-
export {
|
|
5655
|
+
export { ca as createProxyDataAdapter, fr as createProxyRoutesAdapter, ia as default, _t as sqlite };
|