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