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