@authhero/kysely-adapter 12.5.0 → 12.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/kysely-adapter.mjs
CHANGED
|
@@ -3181,8 +3181,16 @@ function ni(e) {
|
|
|
3181
3181
|
};
|
|
3182
3182
|
}
|
|
3183
3183
|
//#endregion
|
|
3184
|
-
//#region src/refreshTokens/
|
|
3184
|
+
//#region src/refreshTokens/revokeBySession.ts
|
|
3185
3185
|
function ri(e) {
|
|
3186
|
+
return async (t, n, r) => {
|
|
3187
|
+
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("session_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3188
|
+
return Number(i.numUpdatedRows ?? 0);
|
|
3189
|
+
};
|
|
3190
|
+
}
|
|
3191
|
+
//#endregion
|
|
3192
|
+
//#region src/refreshTokens/revokeByUser.ts
|
|
3193
|
+
function ii(e) {
|
|
3186
3194
|
return async (t, n, r) => {
|
|
3187
3195
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("user_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3188
3196
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3190,7 +3198,7 @@ function ri(e) {
|
|
|
3190
3198
|
}
|
|
3191
3199
|
//#endregion
|
|
3192
3200
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3193
|
-
function
|
|
3201
|
+
function ai(e) {
|
|
3194
3202
|
return async (t, n, r) => {
|
|
3195
3203
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("family_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3196
3204
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3198,7 +3206,7 @@ function ii(e) {
|
|
|
3198
3206
|
}
|
|
3199
3207
|
//#endregion
|
|
3200
3208
|
//#region src/refreshTokens/update.ts
|
|
3201
|
-
function
|
|
3209
|
+
function oi(e) {
|
|
3202
3210
|
return async (t, n, r, i) => {
|
|
3203
3211
|
let { created_at: a, expires_at: o, idle_expires_at: c, last_exchanged_at: l, revoked_at: u, rotated_at: d, device: f, resource_servers: p, rotating: m, ...h } = r, g = {
|
|
3204
3212
|
...h,
|
|
@@ -3219,7 +3227,7 @@ function ai(e) {
|
|
|
3219
3227
|
}
|
|
3220
3228
|
//#endregion
|
|
3221
3229
|
//#region src/refreshTokens/list.ts
|
|
3222
|
-
function
|
|
3230
|
+
function si(e) {
|
|
3223
3231
|
return async (t, n = {}) => {
|
|
3224
3232
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, user_id: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3225
3233
|
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = D(e, u, c, ["token", "login_id"])), M(n)) {
|
|
@@ -3259,25 +3267,26 @@ function oi(e) {
|
|
|
3259
3267
|
}
|
|
3260
3268
|
//#endregion
|
|
3261
3269
|
//#region src/refreshTokens/index.ts
|
|
3262
|
-
function
|
|
3270
|
+
function ci(e) {
|
|
3263
3271
|
return {
|
|
3264
3272
|
create: ei(e),
|
|
3265
3273
|
get: Qr(e),
|
|
3266
3274
|
getByLookup: $r(e),
|
|
3267
|
-
list:
|
|
3275
|
+
list: si(e),
|
|
3268
3276
|
remove: ti(e),
|
|
3269
3277
|
revokeByLoginSession: ni(e),
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3278
|
+
revokeBySession: ri(e),
|
|
3279
|
+
revokeByUser: ii(e),
|
|
3280
|
+
revokeFamily: ai(e),
|
|
3281
|
+
update: oi(e)
|
|
3273
3282
|
};
|
|
3274
3283
|
}
|
|
3275
3284
|
//#endregion
|
|
3276
3285
|
//#region src/cleanup.ts
|
|
3277
|
-
var
|
|
3278
|
-
function
|
|
3286
|
+
var li = 10080 * 60 * 1e3;
|
|
3287
|
+
function ui(e) {
|
|
3279
3288
|
return async (t) => {
|
|
3280
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3289
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - li, a = 1e3;
|
|
3281
3290
|
try {
|
|
3282
3291
|
let t = 0;
|
|
3283
3292
|
for (;;) {
|
|
@@ -3308,7 +3317,7 @@ function li(e) {
|
|
|
3308
3317
|
}
|
|
3309
3318
|
//#endregion
|
|
3310
3319
|
//#region src/forms/create.ts
|
|
3311
|
-
function
|
|
3320
|
+
function di(e) {
|
|
3312
3321
|
return async (n, r, i) => {
|
|
3313
3322
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3314
3323
|
id: a?.id ?? t(),
|
|
@@ -3327,7 +3336,7 @@ function ui(e) {
|
|
|
3327
3336
|
}
|
|
3328
3337
|
//#endregion
|
|
3329
3338
|
//#region src/forms/list.ts
|
|
3330
|
-
function
|
|
3339
|
+
function fi(e) {
|
|
3331
3340
|
return async (t, n = {}) => {
|
|
3332
3341
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3333
3342
|
s && (c = D(e, c, s, []));
|
|
@@ -3361,7 +3370,7 @@ function di(e) {
|
|
|
3361
3370
|
}
|
|
3362
3371
|
//#endregion
|
|
3363
3372
|
//#region src/forms/remove.ts
|
|
3364
|
-
function
|
|
3373
|
+
function pi(e) {
|
|
3365
3374
|
return async (t, n) => {
|
|
3366
3375
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3367
3376
|
return r > 0;
|
|
@@ -3369,7 +3378,7 @@ function fi(e) {
|
|
|
3369
3378
|
}
|
|
3370
3379
|
//#endregion
|
|
3371
3380
|
//#region src/forms/get.ts
|
|
3372
|
-
function
|
|
3381
|
+
function mi(e) {
|
|
3373
3382
|
return async (t, n) => {
|
|
3374
3383
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3375
3384
|
if (!r) return null;
|
|
@@ -3388,7 +3397,7 @@ function pi(e) {
|
|
|
3388
3397
|
}
|
|
3389
3398
|
//#endregion
|
|
3390
3399
|
//#region src/forms/update.ts
|
|
3391
|
-
function
|
|
3400
|
+
function hi(e) {
|
|
3392
3401
|
return async (t, n, r) => {
|
|
3393
3402
|
let i = {
|
|
3394
3403
|
...r,
|
|
@@ -3405,18 +3414,18 @@ function mi(e) {
|
|
|
3405
3414
|
}
|
|
3406
3415
|
//#endregion
|
|
3407
3416
|
//#region src/forms/index.ts
|
|
3408
|
-
function
|
|
3417
|
+
function gi(e) {
|
|
3409
3418
|
return {
|
|
3410
|
-
create:
|
|
3411
|
-
get:
|
|
3412
|
-
list:
|
|
3413
|
-
remove:
|
|
3414
|
-
update:
|
|
3419
|
+
create: di(e),
|
|
3420
|
+
get: mi(e),
|
|
3421
|
+
list: fi(e),
|
|
3422
|
+
remove: pi(e),
|
|
3423
|
+
update: hi(e)
|
|
3415
3424
|
};
|
|
3416
3425
|
}
|
|
3417
3426
|
//#endregion
|
|
3418
3427
|
//#region src/resourceServers/create.ts
|
|
3419
|
-
function
|
|
3428
|
+
function _i(e) {
|
|
3420
3429
|
return async (t, n, r) => {
|
|
3421
3430
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3422
3431
|
...n,
|
|
@@ -3441,7 +3450,7 @@ function gi(e) {
|
|
|
3441
3450
|
}
|
|
3442
3451
|
//#endregion
|
|
3443
3452
|
//#region src/resourceServers/get.ts
|
|
3444
|
-
function
|
|
3453
|
+
function vi(e) {
|
|
3445
3454
|
return async (t, n) => {
|
|
3446
3455
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3447
3456
|
if (!r) return null;
|
|
@@ -3460,7 +3469,7 @@ function _i(e) {
|
|
|
3460
3469
|
}
|
|
3461
3470
|
//#endregion
|
|
3462
3471
|
//#region src/resourceServers/list.ts
|
|
3463
|
-
function
|
|
3472
|
+
function yi(e) {
|
|
3464
3473
|
return async (t, n = {}) => {
|
|
3465
3474
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
|
|
3466
3475
|
if (s) {
|
|
@@ -3500,7 +3509,7 @@ function vi(e) {
|
|
|
3500
3509
|
}
|
|
3501
3510
|
//#endregion
|
|
3502
3511
|
//#region src/resourceServers/remove.ts
|
|
3503
|
-
function
|
|
3512
|
+
function bi(e) {
|
|
3504
3513
|
return async (t, n) => {
|
|
3505
3514
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3506
3515
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3508,7 +3517,7 @@ function yi(e) {
|
|
|
3508
3517
|
}
|
|
3509
3518
|
//#endregion
|
|
3510
3519
|
//#region src/resourceServers/update.ts
|
|
3511
|
-
function
|
|
3520
|
+
function xi(e) {
|
|
3512
3521
|
return async (t, n, r) => {
|
|
3513
3522
|
let { verificationKey: i, scopes: a, options: o, skip_consent_for_verifiable_first_party_clients: s, allow_offline_access: c, is_system: l, metadata: u, ...d } = r, f = {
|
|
3514
3523
|
...d,
|
|
@@ -3528,18 +3537,18 @@ function bi(e) {
|
|
|
3528
3537
|
}
|
|
3529
3538
|
//#endregion
|
|
3530
3539
|
//#region src/resourceServers/index.ts
|
|
3531
|
-
function
|
|
3540
|
+
function Si(e) {
|
|
3532
3541
|
return {
|
|
3533
|
-
create:
|
|
3534
|
-
get:
|
|
3535
|
-
list:
|
|
3536
|
-
remove:
|
|
3537
|
-
update:
|
|
3542
|
+
create: _i(e),
|
|
3543
|
+
get: vi(e),
|
|
3544
|
+
list: yi(e),
|
|
3545
|
+
remove: bi(e),
|
|
3546
|
+
update: xi(e)
|
|
3538
3547
|
};
|
|
3539
3548
|
}
|
|
3540
3549
|
//#endregion
|
|
3541
3550
|
//#region src/roles/create.ts
|
|
3542
|
-
function
|
|
3551
|
+
function Ci(e) {
|
|
3543
3552
|
return async (n, r, i) => {
|
|
3544
3553
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.created_at ?? o, c = a?.updated_at ?? o, l = a?.id || r.id || t(), { is_system: u, id: d, metadata: f, ...p } = r, m = {
|
|
3545
3554
|
id: l,
|
|
@@ -3562,7 +3571,7 @@ function Si(e) {
|
|
|
3562
3571
|
}
|
|
3563
3572
|
//#endregion
|
|
3564
3573
|
//#region src/roles/get.ts
|
|
3565
|
-
function
|
|
3574
|
+
function wi(e) {
|
|
3566
3575
|
return async (t, n) => {
|
|
3567
3576
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3568
3577
|
if (!r) return null;
|
|
@@ -3576,7 +3585,7 @@ function Ci(e) {
|
|
|
3576
3585
|
}
|
|
3577
3586
|
//#endregion
|
|
3578
3587
|
//#region src/roles/list.ts
|
|
3579
|
-
function
|
|
3588
|
+
function Ti(e) {
|
|
3580
3589
|
return async (t, n) => {
|
|
3581
3590
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3582
3591
|
n.q && (r = D(e, r, n.q, ["name"]));
|
|
@@ -3605,7 +3614,7 @@ function wi(e) {
|
|
|
3605
3614
|
}
|
|
3606
3615
|
//#endregion
|
|
3607
3616
|
//#region src/roles/update.ts
|
|
3608
|
-
function
|
|
3617
|
+
function Ei(e) {
|
|
3609
3618
|
return async (t, n, r) => {
|
|
3610
3619
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3611
3620
|
...o,
|
|
@@ -3618,7 +3627,7 @@ function Ti(e) {
|
|
|
3618
3627
|
}
|
|
3619
3628
|
//#endregion
|
|
3620
3629
|
//#region src/roles/remove.ts
|
|
3621
|
-
function
|
|
3630
|
+
function Di(e) {
|
|
3622
3631
|
return async (t, n) => {
|
|
3623
3632
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3624
3633
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3626,23 +3635,23 @@ function Ei(e) {
|
|
|
3626
3635
|
}
|
|
3627
3636
|
//#endregion
|
|
3628
3637
|
//#region src/roles/index.ts
|
|
3629
|
-
function
|
|
3638
|
+
function Oi(e) {
|
|
3630
3639
|
return {
|
|
3631
|
-
create:
|
|
3632
|
-
get:
|
|
3633
|
-
list:
|
|
3634
|
-
update:
|
|
3635
|
-
remove:
|
|
3640
|
+
create: Ci(e),
|
|
3641
|
+
get: wi(e),
|
|
3642
|
+
list: Ti(e),
|
|
3643
|
+
update: Ei(e),
|
|
3644
|
+
remove: Di(e)
|
|
3636
3645
|
};
|
|
3637
3646
|
}
|
|
3638
3647
|
//#endregion
|
|
3639
3648
|
//#region src/role-permissions/assign.ts
|
|
3640
|
-
function
|
|
3649
|
+
function ki(e) {
|
|
3641
3650
|
if (typeof e != "object" || !e) return !1;
|
|
3642
3651
|
let { code: t, message: n } = e;
|
|
3643
3652
|
return t === "SQLITE_CONSTRAINT" || t === "SQLITE_CONSTRAINT_PRIMARYKEY" || t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || t === "23505" ? !0 : typeof n == "string" && (n.includes("UNIQUE constraint failed") || n.includes("Duplicate entry") || n.includes("duplicate key") || n.includes("AlreadyExists"));
|
|
3644
3653
|
}
|
|
3645
|
-
function
|
|
3654
|
+
function Ai(e) {
|
|
3646
3655
|
return async (t, n, r, i) => {
|
|
3647
3656
|
if (r.length === 0) return !0;
|
|
3648
3657
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3659,7 +3668,7 @@ function ki(e) {
|
|
|
3659
3668
|
try {
|
|
3660
3669
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3661
3670
|
} catch (e) {
|
|
3662
|
-
if (
|
|
3671
|
+
if (ki(e)) continue;
|
|
3663
3672
|
throw e;
|
|
3664
3673
|
}
|
|
3665
3674
|
}
|
|
@@ -3671,7 +3680,7 @@ function ki(e) {
|
|
|
3671
3680
|
}
|
|
3672
3681
|
//#endregion
|
|
3673
3682
|
//#region src/role-permissions/remove.ts
|
|
3674
|
-
function
|
|
3683
|
+
function ji(e) {
|
|
3675
3684
|
return async (t, n, r) => {
|
|
3676
3685
|
if (r.length === 0) return !0;
|
|
3677
3686
|
try {
|
|
@@ -3683,7 +3692,7 @@ function Ai(e) {
|
|
|
3683
3692
|
}
|
|
3684
3693
|
//#endregion
|
|
3685
3694
|
//#region src/role-permissions/list.ts
|
|
3686
|
-
function
|
|
3695
|
+
function Mi(e) {
|
|
3687
3696
|
return async (t, n, r = {}) => {
|
|
3688
3697
|
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s = e.selectFrom("role_permissions").leftJoin("resource_servers", (e) => e.onRef("role_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("role_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3689
3698
|
"role_permissions.role_id",
|
|
@@ -3704,16 +3713,16 @@ function ji(e) {
|
|
|
3704
3713
|
}
|
|
3705
3714
|
//#endregion
|
|
3706
3715
|
//#region src/role-permissions/index.ts
|
|
3707
|
-
function
|
|
3716
|
+
function Ni(e) {
|
|
3708
3717
|
return {
|
|
3709
|
-
assign:
|
|
3710
|
-
remove:
|
|
3711
|
-
list:
|
|
3718
|
+
assign: Ai(e),
|
|
3719
|
+
remove: ji(e),
|
|
3720
|
+
list: Mi(e)
|
|
3712
3721
|
};
|
|
3713
3722
|
}
|
|
3714
3723
|
//#endregion
|
|
3715
3724
|
//#region src/grants/create.ts
|
|
3716
|
-
function
|
|
3725
|
+
function Pi(e) {
|
|
3717
3726
|
return async (n, r) => {
|
|
3718
3727
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = r.scope ?? [], o = r.audience ?? "", s = await e.selectFrom("grants").where("tenant_id", "=", n).where("user_id", "=", r.user_id).where("client_id", "=", r.clientID).where("audience", "=", o).selectAll().executeTakeFirst();
|
|
3719
3728
|
if (s) {
|
|
@@ -3750,7 +3759,7 @@ function Ni(e) {
|
|
|
3750
3759
|
}
|
|
3751
3760
|
//#endregion
|
|
3752
3761
|
//#region src/grants/get.ts
|
|
3753
|
-
function
|
|
3762
|
+
function Fi(e) {
|
|
3754
3763
|
return async (t, n, r, i) => {
|
|
3755
3764
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3756
3765
|
return a ? {
|
|
@@ -3764,7 +3773,7 @@ function Pi(e) {
|
|
|
3764
3773
|
}
|
|
3765
3774
|
//#endregion
|
|
3766
3775
|
//#region src/grants/list.ts
|
|
3767
|
-
function
|
|
3776
|
+
function Ii(e) {
|
|
3768
3777
|
return async (t, n = {}) => {
|
|
3769
3778
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("grants").where("grants.tenant_id", "=", t);
|
|
3770
3779
|
c && (l = D(e, l, c, [
|
|
@@ -3802,26 +3811,26 @@ function Fi(e) {
|
|
|
3802
3811
|
}
|
|
3803
3812
|
//#endregion
|
|
3804
3813
|
//#region src/grants/remove.ts
|
|
3805
|
-
function
|
|
3814
|
+
function Li(e) {
|
|
3806
3815
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3807
3816
|
}
|
|
3808
|
-
function
|
|
3817
|
+
function Ri(e) {
|
|
3809
3818
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3810
3819
|
}
|
|
3811
3820
|
//#endregion
|
|
3812
3821
|
//#region src/grants/index.ts
|
|
3813
|
-
function
|
|
3822
|
+
function zi(e) {
|
|
3814
3823
|
return {
|
|
3815
|
-
create:
|
|
3816
|
-
get:
|
|
3817
|
-
list:
|
|
3818
|
-
remove:
|
|
3819
|
-
removeByUser:
|
|
3824
|
+
create: Pi(e),
|
|
3825
|
+
get: Fi(e),
|
|
3826
|
+
list: Ii(e),
|
|
3827
|
+
remove: Li(e),
|
|
3828
|
+
removeByUser: Ri(e)
|
|
3820
3829
|
};
|
|
3821
3830
|
}
|
|
3822
3831
|
//#endregion
|
|
3823
3832
|
//#region src/user-permissions/create.ts
|
|
3824
|
-
function
|
|
3833
|
+
function Bi(e) {
|
|
3825
3834
|
return async (t, n, r, i, a) => {
|
|
3826
3835
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3827
3836
|
try {
|
|
@@ -3841,7 +3850,7 @@ function zi(e) {
|
|
|
3841
3850
|
}
|
|
3842
3851
|
//#endregion
|
|
3843
3852
|
//#region src/user-permissions/remove.ts
|
|
3844
|
-
function
|
|
3853
|
+
function Vi(e) {
|
|
3845
3854
|
return async (t, n, r, i) => {
|
|
3846
3855
|
try {
|
|
3847
3856
|
let a = e.deleteFrom("user_permissions").where("tenant_id", "=", t).where("user_id", "=", n).where("resource_server_identifier", "=", r.resource_server_identifier).where("permission_name", "=", r.permission_name);
|
|
@@ -3853,7 +3862,7 @@ function Bi(e) {
|
|
|
3853
3862
|
}
|
|
3854
3863
|
//#endregion
|
|
3855
3864
|
//#region src/user-permissions/list.ts
|
|
3856
|
-
function
|
|
3865
|
+
function Hi(e) {
|
|
3857
3866
|
return async (t, n, r, i) => {
|
|
3858
3867
|
let a = e.selectFrom("user_permissions").leftJoin("resource_servers", (e) => e.onRef("user_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("user_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3859
3868
|
"user_permissions.resource_server_identifier",
|
|
@@ -3876,17 +3885,17 @@ function Vi(e) {
|
|
|
3876
3885
|
}
|
|
3877
3886
|
//#endregion
|
|
3878
3887
|
//#region src/user-permissions/index.ts
|
|
3879
|
-
function
|
|
3888
|
+
function Ui(e) {
|
|
3880
3889
|
return {
|
|
3881
|
-
create:
|
|
3882
|
-
remove:
|
|
3883
|
-
list:
|
|
3890
|
+
create: Bi(e),
|
|
3891
|
+
remove: Vi(e),
|
|
3892
|
+
list: Hi(e)
|
|
3884
3893
|
};
|
|
3885
3894
|
}
|
|
3886
3895
|
//#endregion
|
|
3887
3896
|
//#region src/user-permissions/adapter.ts
|
|
3888
|
-
function
|
|
3889
|
-
let t =
|
|
3897
|
+
function Wi(e) {
|
|
3898
|
+
let t = Ui(e);
|
|
3890
3899
|
return {
|
|
3891
3900
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3892
3901
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3895,7 +3904,7 @@ function Ui(e) {
|
|
|
3895
3904
|
}
|
|
3896
3905
|
//#endregion
|
|
3897
3906
|
//#region src/user-roles/list.ts
|
|
3898
|
-
function
|
|
3907
|
+
function Gi(e) {
|
|
3899
3908
|
return async (t, n, r, i) => {
|
|
3900
3909
|
let a = e.selectFrom("user_roles as ur").innerJoin("roles as r", (e) => e.onRef("ur.role_id", "=", "r.id").onRef("ur.tenant_id", "=", "r.tenant_id")).select([
|
|
3901
3910
|
"r.id",
|
|
@@ -3909,7 +3918,7 @@ function Wi(e) {
|
|
|
3909
3918
|
}
|
|
3910
3919
|
//#endregion
|
|
3911
3920
|
//#region src/user-roles/list-users.ts
|
|
3912
|
-
function
|
|
3921
|
+
function Ki(e) {
|
|
3913
3922
|
return async (t, n, r) => {
|
|
3914
3923
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3915
3924
|
if (M(r)) {
|
|
@@ -3937,7 +3946,7 @@ function Gi(e) {
|
|
|
3937
3946
|
}
|
|
3938
3947
|
//#endregion
|
|
3939
3948
|
//#region src/user-roles/create.ts
|
|
3940
|
-
function
|
|
3949
|
+
function qi(e) {
|
|
3941
3950
|
return async (t, n, r, i, a) => {
|
|
3942
3951
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3943
3952
|
try {
|
|
@@ -3955,7 +3964,7 @@ function Ki(e) {
|
|
|
3955
3964
|
}
|
|
3956
3965
|
//#endregion
|
|
3957
3966
|
//#region src/user-roles/remove.ts
|
|
3958
|
-
function
|
|
3967
|
+
function Ji(e) {
|
|
3959
3968
|
return async (t, n, r, i) => {
|
|
3960
3969
|
try {
|
|
3961
3970
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3967,18 +3976,18 @@ function qi(e) {
|
|
|
3967
3976
|
}
|
|
3968
3977
|
//#endregion
|
|
3969
3978
|
//#region src/user-roles/index.ts
|
|
3970
|
-
function
|
|
3979
|
+
function Yi(e) {
|
|
3971
3980
|
return {
|
|
3972
|
-
list:
|
|
3973
|
-
listUsers:
|
|
3974
|
-
create:
|
|
3975
|
-
remove:
|
|
3981
|
+
list: Gi(e),
|
|
3982
|
+
listUsers: Ki(e),
|
|
3983
|
+
create: qi(e),
|
|
3984
|
+
remove: Ji(e)
|
|
3976
3985
|
};
|
|
3977
3986
|
}
|
|
3978
3987
|
//#endregion
|
|
3979
3988
|
//#region src/user-roles/adapter.ts
|
|
3980
|
-
function
|
|
3981
|
-
let t =
|
|
3989
|
+
function Xi(e) {
|
|
3990
|
+
let t = Yi(e);
|
|
3982
3991
|
return {
|
|
3983
3992
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3984
3993
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3988,7 +3997,7 @@ function Yi(e) {
|
|
|
3988
3997
|
}
|
|
3989
3998
|
//#endregion
|
|
3990
3999
|
//#region src/organizations/create.ts
|
|
3991
|
-
function
|
|
4000
|
+
function Zi(e) {
|
|
3992
4001
|
return async (t, n, r) => {
|
|
3993
4002
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3994
4003
|
...n,
|
|
@@ -4016,7 +4025,7 @@ function Xi(e) {
|
|
|
4016
4025
|
}
|
|
4017
4026
|
//#endregion
|
|
4018
4027
|
//#region src/organizations/get.ts
|
|
4019
|
-
function
|
|
4028
|
+
function Qi(e) {
|
|
4020
4029
|
return async (t, n) => {
|
|
4021
4030
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4022
4031
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4031,7 +4040,7 @@ function Zi(e) {
|
|
|
4031
4040
|
//#endregion
|
|
4032
4041
|
//#region src/organizations/list.ts
|
|
4033
4042
|
var V = ["name", "display_name"];
|
|
4034
|
-
function
|
|
4043
|
+
function $i(e) {
|
|
4035
4044
|
return async (t, n) => {
|
|
4036
4045
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4037
4046
|
if (n?.q) {
|
|
@@ -4096,12 +4105,12 @@ function Qi(e) {
|
|
|
4096
4105
|
}
|
|
4097
4106
|
//#endregion
|
|
4098
4107
|
//#region src/organizations/remove.ts
|
|
4099
|
-
function
|
|
4108
|
+
function ea(e) {
|
|
4100
4109
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4101
4110
|
}
|
|
4102
4111
|
//#endregion
|
|
4103
4112
|
//#region src/organizations/update.ts
|
|
4104
|
-
function
|
|
4113
|
+
function ta(e) {
|
|
4105
4114
|
return async (t, n, r) => {
|
|
4106
4115
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4107
4116
|
...c,
|
|
@@ -4117,13 +4126,13 @@ function ea(e) {
|
|
|
4117
4126
|
}
|
|
4118
4127
|
//#endregion
|
|
4119
4128
|
//#region src/organizations/index.ts
|
|
4120
|
-
function
|
|
4129
|
+
function na(e) {
|
|
4121
4130
|
return {
|
|
4122
|
-
create:
|
|
4123
|
-
get:
|
|
4124
|
-
list:
|
|
4125
|
-
remove:
|
|
4126
|
-
update:
|
|
4131
|
+
create: Zi(e),
|
|
4132
|
+
get: Qi(e),
|
|
4133
|
+
list: $i(e),
|
|
4134
|
+
remove: ea(e),
|
|
4135
|
+
update: ta(e)
|
|
4127
4136
|
};
|
|
4128
4137
|
}
|
|
4129
4138
|
//#endregion
|
|
@@ -4149,7 +4158,7 @@ async function U(e, t, n) {
|
|
|
4149
4158
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4150
4159
|
};
|
|
4151
4160
|
}
|
|
4152
|
-
function
|
|
4161
|
+
function ra(e) {
|
|
4153
4162
|
return {
|
|
4154
4163
|
async create(t, n, r, i) {
|
|
4155
4164
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4192,7 +4201,7 @@ function na(e) {
|
|
|
4192
4201
|
}
|
|
4193
4202
|
//#endregion
|
|
4194
4203
|
//#region src/user-organizations/create.ts
|
|
4195
|
-
function
|
|
4204
|
+
function ia(e) {
|
|
4196
4205
|
return async (n, r, i) => {
|
|
4197
4206
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4198
4207
|
id: a?.id ?? t(),
|
|
@@ -4212,7 +4221,7 @@ function ra(e) {
|
|
|
4212
4221
|
}
|
|
4213
4222
|
//#endregion
|
|
4214
4223
|
//#region src/user-organizations/get.ts
|
|
4215
|
-
function
|
|
4224
|
+
function aa(e) {
|
|
4216
4225
|
return async (t, n) => {
|
|
4217
4226
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4218
4227
|
return r ? {
|
|
@@ -4226,7 +4235,7 @@ function ia(e) {
|
|
|
4226
4235
|
}
|
|
4227
4236
|
//#endregion
|
|
4228
4237
|
//#region src/user-organizations/list.ts
|
|
4229
|
-
function
|
|
4238
|
+
function oa(e) {
|
|
4230
4239
|
return async (t, n) => {
|
|
4231
4240
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4232
4241
|
if (n?.q) {
|
|
@@ -4279,7 +4288,7 @@ function aa(e) {
|
|
|
4279
4288
|
}
|
|
4280
4289
|
//#endregion
|
|
4281
4290
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4282
|
-
function
|
|
4291
|
+
function sa(e) {
|
|
4283
4292
|
return async (t, n, r) => {
|
|
4284
4293
|
let i = r?.page || 0, a = r?.per_page || 50, o = i * a, s = e.selectFrom("user_organizations").innerJoin("organizations", (e) => e.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)).select([
|
|
4285
4294
|
"organizations.id",
|
|
@@ -4316,12 +4325,12 @@ function oa(e) {
|
|
|
4316
4325
|
}
|
|
4317
4326
|
//#endregion
|
|
4318
4327
|
//#region src/user-organizations/remove.ts
|
|
4319
|
-
function
|
|
4328
|
+
function ca(e) {
|
|
4320
4329
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4321
4330
|
}
|
|
4322
4331
|
//#endregion
|
|
4323
4332
|
//#region src/user-organizations/update.ts
|
|
4324
|
-
function
|
|
4333
|
+
function la(e) {
|
|
4325
4334
|
return async (t, n, r) => {
|
|
4326
4335
|
let i = {
|
|
4327
4336
|
...r,
|
|
@@ -4332,19 +4341,19 @@ function ca(e) {
|
|
|
4332
4341
|
}
|
|
4333
4342
|
//#endregion
|
|
4334
4343
|
//#region src/user-organizations/index.ts
|
|
4335
|
-
function
|
|
4344
|
+
function ua(e) {
|
|
4336
4345
|
return {
|
|
4337
|
-
create:
|
|
4338
|
-
get:
|
|
4339
|
-
list:
|
|
4340
|
-
listUserOrganizations:
|
|
4341
|
-
remove:
|
|
4342
|
-
update:
|
|
4346
|
+
create: ia(e),
|
|
4347
|
+
get: aa(e),
|
|
4348
|
+
list: oa(e),
|
|
4349
|
+
listUserOrganizations: sa(e),
|
|
4350
|
+
remove: ca(e),
|
|
4351
|
+
update: la(e)
|
|
4343
4352
|
};
|
|
4344
4353
|
}
|
|
4345
4354
|
//#endregion
|
|
4346
4355
|
//#region src/invites/create.ts
|
|
4347
|
-
function
|
|
4356
|
+
function da(e) {
|
|
4348
4357
|
return async (t, n, r) => {
|
|
4349
4358
|
let i = r?.importMetadata, a = i?.id ?? n.id ?? je(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4350
4359
|
id: a,
|
|
@@ -4390,7 +4399,7 @@ function ua(e) {
|
|
|
4390
4399
|
}
|
|
4391
4400
|
//#endregion
|
|
4392
4401
|
//#region src/invites/get.ts
|
|
4393
|
-
function
|
|
4402
|
+
function fa(e) {
|
|
4394
4403
|
return async (t, n) => {
|
|
4395
4404
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4396
4405
|
return r ? l({
|
|
@@ -4407,7 +4416,7 @@ function da(e) {
|
|
|
4407
4416
|
}
|
|
4408
4417
|
//#endregion
|
|
4409
4418
|
//#region src/invites/list.ts
|
|
4410
|
-
function
|
|
4419
|
+
function pa(e) {
|
|
4411
4420
|
return async (t, n) => {
|
|
4412
4421
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4413
4422
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4434,12 +4443,12 @@ function fa(e) {
|
|
|
4434
4443
|
}
|
|
4435
4444
|
//#endregion
|
|
4436
4445
|
//#region src/invites/remove.ts
|
|
4437
|
-
function
|
|
4446
|
+
function ma(e) {
|
|
4438
4447
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4439
4448
|
}
|
|
4440
4449
|
//#endregion
|
|
4441
4450
|
//#region src/invites/update.ts
|
|
4442
|
-
function
|
|
4451
|
+
function ha(e) {
|
|
4443
4452
|
return async (t, n, r) => {
|
|
4444
4453
|
let i = {};
|
|
4445
4454
|
return r.inviter !== void 0 && (i.inviter = JSON.stringify(r.inviter)), r.invitee !== void 0 && (i.invitee = JSON.stringify(r.invitee)), r.client_id !== void 0 && (i.client_id = r.client_id), r.connection_id !== void 0 && (i.connection_id = r.connection_id), r.app_metadata !== void 0 && (i.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (i.user_metadata = JSON.stringify(r.user_metadata)), r.roles !== void 0 && (i.roles = JSON.stringify(r.roles)), r.ttl_sec !== void 0 && (i.ttl_sec = r.ttl_sec, i.expires_at = new Date(Date.now() + r.ttl_sec * 1e3).toISOString()), r.send_invitation_email !== void 0 && (i.send_invitation_email = +!!r.send_invitation_email), Object.keys(i).length === 0 ? !0 : (await e.updateTable("invites").set(i).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numUpdatedRows > 0n;
|
|
@@ -4447,35 +4456,35 @@ function ma(e) {
|
|
|
4447
4456
|
}
|
|
4448
4457
|
//#endregion
|
|
4449
4458
|
//#region src/invites/index.ts
|
|
4450
|
-
function
|
|
4459
|
+
function ga(e) {
|
|
4451
4460
|
return {
|
|
4452
|
-
create:
|
|
4453
|
-
get:
|
|
4454
|
-
list:
|
|
4455
|
-
remove:
|
|
4456
|
-
update:
|
|
4461
|
+
create: da(e),
|
|
4462
|
+
get: fa(e),
|
|
4463
|
+
list: pa(e),
|
|
4464
|
+
remove: ma(e),
|
|
4465
|
+
update: ha(e)
|
|
4457
4466
|
};
|
|
4458
4467
|
}
|
|
4459
4468
|
//#endregion
|
|
4460
4469
|
//#region src/stats/index.ts
|
|
4461
|
-
var
|
|
4462
|
-
function
|
|
4470
|
+
var _a = ["s"], va = ["pwd_leak"];
|
|
4471
|
+
function ya(e) {
|
|
4463
4472
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4464
4473
|
}
|
|
4465
|
-
function
|
|
4474
|
+
function ba(e) {
|
|
4466
4475
|
return e.toISOString().split("T")[0];
|
|
4467
4476
|
}
|
|
4468
|
-
function
|
|
4477
|
+
function xa(e) {
|
|
4469
4478
|
return {
|
|
4470
4479
|
async getDaily(t, n = {}) {
|
|
4471
4480
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4472
4481
|
o.setDate(o.getDate() - 30);
|
|
4473
|
-
let s = r ?
|
|
4482
|
+
let s = r ? ya(r) : ba(o), c = i ? ya(i) : ba(a), l = f`DATE(logs.date)`;
|
|
4474
4483
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4475
4484
|
l.as("date"),
|
|
4476
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4485
|
+
e.fn.sum(e.case().when("type", "in", _a).then(1).else(0).end()).as("logins"),
|
|
4477
4486
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4478
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4487
|
+
e.fn.sum(e.case().when("type", "in", va).then(1).else(0).end()).as("leaked_passwords"),
|
|
4479
4488
|
e.fn.min("date").as("first_event"),
|
|
4480
4489
|
e.fn.max("date").as("last_event")
|
|
4481
4490
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4489,13 +4498,13 @@ function ba(e) {
|
|
|
4489
4498
|
},
|
|
4490
4499
|
async getActiveUsers(t) {
|
|
4491
4500
|
let n = /* @__PURE__ */ new Date();
|
|
4492
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4501
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", _a).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4493
4502
|
}
|
|
4494
4503
|
};
|
|
4495
4504
|
}
|
|
4496
4505
|
//#endregion
|
|
4497
4506
|
//#region src/analytics/index.ts
|
|
4498
|
-
var
|
|
4507
|
+
var Sa = {
|
|
4499
4508
|
"active-users": ["s", "seacft"],
|
|
4500
4509
|
logins: [
|
|
4501
4510
|
"s",
|
|
@@ -4525,7 +4534,7 @@ var xa = {
|
|
|
4525
4534
|
"fvr"
|
|
4526
4535
|
],
|
|
4527
4536
|
"codes-sent": ["cls", "cs"]
|
|
4528
|
-
},
|
|
4537
|
+
}, Ca = {
|
|
4529
4538
|
"active-users": {
|
|
4530
4539
|
alias: "active_users",
|
|
4531
4540
|
type: "UInt64",
|
|
@@ -4582,7 +4591,7 @@ var xa = {
|
|
|
4582
4591
|
agg: "count"
|
|
4583
4592
|
}
|
|
4584
4593
|
};
|
|
4585
|
-
async function
|
|
4594
|
+
async function wa(e) {
|
|
4586
4595
|
try {
|
|
4587
4596
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4588
4597
|
} catch {
|
|
@@ -4604,7 +4613,7 @@ function W(e, t) {
|
|
|
4604
4613
|
let i = r.hour === "24" ? "00" : r.hour, a = Date.UTC(Number(r.year), Number(r.month) - 1, Number(r.day), Number(i), Number(r.minute), Number(r.second)), o = Math.round((a - t.getTime()) / 6e4), s = o >= 0 ? "+" : "-", c = Math.abs(o);
|
|
4605
4614
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4606
4615
|
}
|
|
4607
|
-
var
|
|
4616
|
+
var Ta = [
|
|
4608
4617
|
"January",
|
|
4609
4618
|
"February",
|
|
4610
4619
|
"March",
|
|
@@ -4618,22 +4627,22 @@ var wa = [
|
|
|
4618
4627
|
"November",
|
|
4619
4628
|
"December"
|
|
4620
4629
|
];
|
|
4621
|
-
function
|
|
4630
|
+
function Ea(e, t) {
|
|
4622
4631
|
let n = t.getUTCFullYear(), r = W(e, new Date(Date.UTC(n, 0, 1)));
|
|
4623
4632
|
for (let t = 1; t < 12; t++) {
|
|
4624
4633
|
let i = W(e, new Date(Date.UTC(n, t, 1)));
|
|
4625
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4634
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ta[t]}) and cannot be bucketed with a single fixed offset by the SQL analytics adapter. Use a fixed-offset zone (e.g. 'UTC' or '+02:00').`);
|
|
4626
4635
|
}
|
|
4627
4636
|
}
|
|
4628
|
-
function
|
|
4637
|
+
function Da(e) {
|
|
4629
4638
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4630
4639
|
return t * (Number(n) * 60 + Number(r));
|
|
4631
4640
|
}
|
|
4632
|
-
function
|
|
4641
|
+
function Oa(e, t) {
|
|
4633
4642
|
let n;
|
|
4634
4643
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4635
4644
|
else {
|
|
4636
|
-
let e =
|
|
4645
|
+
let e = Da(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4637
4646
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4638
4647
|
}
|
|
4639
4648
|
switch (e) {
|
|
@@ -4644,7 +4653,7 @@ function Da(e, t) {
|
|
|
4644
4653
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4645
4654
|
}
|
|
4646
4655
|
}
|
|
4647
|
-
function
|
|
4656
|
+
function ka(e, t) {
|
|
4648
4657
|
if (t === "+00:00") switch (e) {
|
|
4649
4658
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4650
4659
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4655,7 +4664,7 @@ function Oa(e, t) {
|
|
|
4655
4664
|
}
|
|
4656
4665
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4657
4666
|
}
|
|
4658
|
-
let n =
|
|
4667
|
+
let n = Da(t), r = f`date_add(str_to_date(substring(${f.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${f.lit(n)} minute)`;
|
|
4659
4668
|
switch (e) {
|
|
4660
4669
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4661
4670
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4664,12 +4673,12 @@ function Oa(e, t) {
|
|
|
4664
4673
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4665
4674
|
}
|
|
4666
4675
|
}
|
|
4667
|
-
function
|
|
4668
|
-
|
|
4676
|
+
function Aa(e, t, n, r) {
|
|
4677
|
+
Ea(t, n);
|
|
4669
4678
|
let i = W(t, n);
|
|
4670
|
-
return r === "mysql" ?
|
|
4679
|
+
return r === "mysql" ? ka(e, i) : Oa(e, i);
|
|
4671
4680
|
}
|
|
4672
|
-
function
|
|
4681
|
+
function ja(e) {
|
|
4673
4682
|
switch (e) {
|
|
4674
4683
|
case "connection": return "logs.connection";
|
|
4675
4684
|
case "client_id": return "logs.client_id";
|
|
@@ -4678,15 +4687,15 @@ function Aa(e) {
|
|
|
4678
4687
|
case "time": throw Error("time dimension is handled separately");
|
|
4679
4688
|
}
|
|
4680
4689
|
}
|
|
4681
|
-
function
|
|
4682
|
-
let t = null, n = () => (t ||=
|
|
4690
|
+
function Ma(e) {
|
|
4691
|
+
let t = null, n = () => (t ||= wa(e), t);
|
|
4683
4692
|
return {
|
|
4684
4693
|
async query(t, r, i) {
|
|
4685
|
-
let a = Date.now(), o =
|
|
4694
|
+
let a = Date.now(), o = Sa[r], s = Ca[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4686
4695
|
u = u.where("date", ">=", i.from).where("date", "<", i.to), u = u.where("type", "in", o), i.filters.connection?.length && (u = u.where("connection", "in", i.filters.connection)), i.filters.client_id?.length && (u = u.where("client_id", "in", i.filters.client_id)), i.filters.user_type?.length && (u = u.where("strategy_type", "in", i.filters.user_type)), i.filters.user_id?.length && (u = u.where("user_id", "in", i.filters.user_id));
|
|
4687
4696
|
let d = [], p = [];
|
|
4688
4697
|
for (let e of i.group_by) if (e === "time") {
|
|
4689
|
-
let e =
|
|
4698
|
+
let e = Aa(i.interval, i.tz, new Date(i.from), c);
|
|
4690
4699
|
p.push({
|
|
4691
4700
|
alias: "time",
|
|
4692
4701
|
expr: e
|
|
@@ -4695,7 +4704,7 @@ function ja(e) {
|
|
|
4695
4704
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4696
4705
|
});
|
|
4697
4706
|
} else {
|
|
4698
|
-
let t =
|
|
4707
|
+
let t = ja(e);
|
|
4699
4708
|
p.push({
|
|
4700
4709
|
alias: e,
|
|
4701
4710
|
expr: f`${f.ref(t)}`
|
|
@@ -4770,7 +4779,7 @@ function ja(e) {
|
|
|
4770
4779
|
}
|
|
4771
4780
|
//#endregion
|
|
4772
4781
|
//#region src/customText/index.ts
|
|
4773
|
-
function
|
|
4782
|
+
function Na(e) {
|
|
4774
4783
|
return {
|
|
4775
4784
|
async get(t, n, r) {
|
|
4776
4785
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4809,7 +4818,7 @@ function Ma(e) {
|
|
|
4809
4818
|
}
|
|
4810
4819
|
//#endregion
|
|
4811
4820
|
//#region src/authenticationMethods/create.ts
|
|
4812
|
-
function
|
|
4821
|
+
function Pa(e) {
|
|
4813
4822
|
return async (t, n, r) => {
|
|
4814
4823
|
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ?? jr();
|
|
4815
4824
|
return await e.insertInto("authentication_methods").values({
|
|
@@ -4848,7 +4857,7 @@ function Na(e) {
|
|
|
4848
4857
|
}
|
|
4849
4858
|
//#endregion
|
|
4850
4859
|
//#region src/authenticationMethods/get.ts
|
|
4851
|
-
function
|
|
4860
|
+
function Fa(e) {
|
|
4852
4861
|
return async (t, n) => {
|
|
4853
4862
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4854
4863
|
return r ? {
|
|
@@ -4871,7 +4880,7 @@ function Pa(e) {
|
|
|
4871
4880
|
}
|
|
4872
4881
|
//#endregion
|
|
4873
4882
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4874
|
-
function
|
|
4883
|
+
function Ia(e) {
|
|
4875
4884
|
return async (t, n) => {
|
|
4876
4885
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4877
4886
|
return r ? {
|
|
@@ -4894,7 +4903,7 @@ function Fa(e) {
|
|
|
4894
4903
|
}
|
|
4895
4904
|
//#endregion
|
|
4896
4905
|
//#region src/authenticationMethods/list.ts
|
|
4897
|
-
function
|
|
4906
|
+
function La(e) {
|
|
4898
4907
|
return async (t, n) => (await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "=", n).selectAll().execute()).map((e) => ({
|
|
4899
4908
|
id: e.id,
|
|
4900
4909
|
user_id: e.user_id,
|
|
@@ -4914,35 +4923,35 @@ function Ia(e) {
|
|
|
4914
4923
|
}
|
|
4915
4924
|
//#endregion
|
|
4916
4925
|
//#region src/authenticationMethods/update.ts
|
|
4917
|
-
function
|
|
4926
|
+
function Ra(e) {
|
|
4918
4927
|
return async (t, n, r) => {
|
|
4919
4928
|
let i = { updated_at_ts: Date.now() };
|
|
4920
4929
|
r.phone_number !== void 0 && (i.phone_number = r.phone_number), r.totp_secret !== void 0 && (i.totp_secret = r.totp_secret), r.credential_id !== void 0 && (i.credential_id = r.credential_id), r.public_key !== void 0 && (i.public_key = r.public_key), r.sign_count !== void 0 && (i.sign_count = r.sign_count), r.credential_backed_up !== void 0 && (i.credential_backed_up = +!!r.credential_backed_up), r.transports !== void 0 && (i.transports = JSON.stringify(r.transports)), r.friendly_name !== void 0 && (i.friendly_name = r.friendly_name), r.confirmed !== void 0 && (i.confirmed = +!!r.confirmed), await e.updateTable("authentication_methods").set(i).where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).execute();
|
|
4921
|
-
let a = await
|
|
4930
|
+
let a = await Fa(e)(t, n);
|
|
4922
4931
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4923
4932
|
return a;
|
|
4924
4933
|
};
|
|
4925
4934
|
}
|
|
4926
4935
|
//#endregion
|
|
4927
4936
|
//#region src/authenticationMethods/remove.ts
|
|
4928
|
-
function
|
|
4937
|
+
function za(e) {
|
|
4929
4938
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4930
4939
|
}
|
|
4931
4940
|
//#endregion
|
|
4932
4941
|
//#region src/authenticationMethods/index.ts
|
|
4933
|
-
function
|
|
4942
|
+
function Ba(e) {
|
|
4934
4943
|
return {
|
|
4935
|
-
create:
|
|
4936
|
-
get:
|
|
4937
|
-
getByCredentialId:
|
|
4938
|
-
list:
|
|
4939
|
-
update:
|
|
4940
|
-
remove:
|
|
4944
|
+
create: Pa(e),
|
|
4945
|
+
get: Fa(e),
|
|
4946
|
+
getByCredentialId: Ia(e),
|
|
4947
|
+
list: La(e),
|
|
4948
|
+
update: Ra(e),
|
|
4949
|
+
remove: za(e)
|
|
4941
4950
|
};
|
|
4942
4951
|
}
|
|
4943
4952
|
//#endregion
|
|
4944
4953
|
//#region src/outbox/getByIds.ts
|
|
4945
|
-
function
|
|
4954
|
+
function Va(e) {
|
|
4946
4955
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4947
4956
|
...JSON.parse(e.payload),
|
|
4948
4957
|
id: e.id,
|
|
@@ -4955,7 +4964,7 @@ function Ba(e) {
|
|
|
4955
4964
|
}
|
|
4956
4965
|
//#endregion
|
|
4957
4966
|
//#region src/outbox/getUnprocessed.ts
|
|
4958
|
-
function
|
|
4967
|
+
function Ha(e) {
|
|
4959
4968
|
return async (t) => {
|
|
4960
4969
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4961
4970
|
return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where((e) => e.or([e("next_retry_at", "is", null), e("next_retry_at", "<=", n)])).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).orderBy("created_at", "asc").orderBy("id", "asc").limit(t).execute()).map((e) => ({
|
|
@@ -4971,7 +4980,7 @@ function Va(e) {
|
|
|
4971
4980
|
}
|
|
4972
4981
|
//#endregion
|
|
4973
4982
|
//#region src/outbox/claimEvents.ts
|
|
4974
|
-
function
|
|
4983
|
+
function Ua(e) {
|
|
4975
4984
|
return async (t, n, r) => {
|
|
4976
4985
|
if (t.length === 0) return [];
|
|
4977
4986
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4983,7 +4992,7 @@ function Ha(e) {
|
|
|
4983
4992
|
}
|
|
4984
4993
|
//#endregion
|
|
4985
4994
|
//#region src/outbox/markProcessed.ts
|
|
4986
|
-
function
|
|
4995
|
+
function Wa(e) {
|
|
4987
4996
|
return async (t) => {
|
|
4988
4997
|
if (t.length === 0) return;
|
|
4989
4998
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4992,7 +5001,7 @@ function Ua(e) {
|
|
|
4992
5001
|
}
|
|
4993
5002
|
//#endregion
|
|
4994
5003
|
//#region src/outbox/markRetry.ts
|
|
4995
|
-
function
|
|
5004
|
+
function Ga(e) {
|
|
4996
5005
|
return async (t, n, r) => {
|
|
4997
5006
|
await e.updateTable("outbox_events").set({
|
|
4998
5007
|
error: n,
|
|
@@ -5005,7 +5014,7 @@ function Wa(e) {
|
|
|
5005
5014
|
}
|
|
5006
5015
|
//#endregion
|
|
5007
5016
|
//#region src/outbox/deadLetter.ts
|
|
5008
|
-
function
|
|
5017
|
+
function Ka(e) {
|
|
5009
5018
|
return async (t, n) => {
|
|
5010
5019
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5011
5020
|
await e.updateTable("outbox_events").set({
|
|
@@ -5017,7 +5026,7 @@ function Ga(e) {
|
|
|
5017
5026
|
}
|
|
5018
5027
|
//#endregion
|
|
5019
5028
|
//#region src/outbox/listFailed.ts
|
|
5020
|
-
function
|
|
5029
|
+
function qa(e) {
|
|
5021
5030
|
return async (t, n = {}) => {
|
|
5022
5031
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1 } = n, o = (await e.selectFrom("outbox_events").selectAll().where("tenant_id", "=", t).where("dead_lettered_at", "is not", null).orderBy("dead_lettered_at", "desc").orderBy("id", "asc").offset(r * i).limit(i).execute()).flatMap((e) => {
|
|
5023
5032
|
let t;
|
|
@@ -5052,7 +5061,7 @@ function Ka(e) {
|
|
|
5052
5061
|
}
|
|
5053
5062
|
//#endregion
|
|
5054
5063
|
//#region src/outbox/replay.ts
|
|
5055
|
-
function
|
|
5064
|
+
function Ja(e) {
|
|
5056
5065
|
return async (t, n) => {
|
|
5057
5066
|
let r = await e.updateTable("outbox_events").set({
|
|
5058
5067
|
processed_at: null,
|
|
@@ -5067,7 +5076,7 @@ function qa(e) {
|
|
|
5067
5076
|
}
|
|
5068
5077
|
//#endregion
|
|
5069
5078
|
//#region src/outbox/cleanup.ts
|
|
5070
|
-
function
|
|
5079
|
+
function Ya(e) {
|
|
5071
5080
|
return async (t) => {
|
|
5072
5081
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5073
5082
|
return Number(n.numDeletedRows);
|
|
@@ -5075,18 +5084,18 @@ function Ja(e) {
|
|
|
5075
5084
|
}
|
|
5076
5085
|
//#endregion
|
|
5077
5086
|
//#region src/outbox/index.ts
|
|
5078
|
-
function
|
|
5087
|
+
function Xa(e) {
|
|
5079
5088
|
return {
|
|
5080
5089
|
create: Xe(e),
|
|
5081
|
-
getByIds:
|
|
5082
|
-
getUnprocessed:
|
|
5083
|
-
claimEvents:
|
|
5084
|
-
markProcessed:
|
|
5085
|
-
markRetry:
|
|
5086
|
-
deadLetter:
|
|
5087
|
-
listFailed:
|
|
5088
|
-
replay:
|
|
5089
|
-
cleanup:
|
|
5090
|
+
getByIds: Va(e),
|
|
5091
|
+
getUnprocessed: Ha(e),
|
|
5092
|
+
claimEvents: Ua(e),
|
|
5093
|
+
markProcessed: Wa(e),
|
|
5094
|
+
markRetry: Ga(e),
|
|
5095
|
+
deadLetter: Ka(e),
|
|
5096
|
+
listFailed: qa(e),
|
|
5097
|
+
replay: Ja(e),
|
|
5098
|
+
cleanup: Ya(e)
|
|
5090
5099
|
};
|
|
5091
5100
|
}
|
|
5092
5101
|
//#endregion
|
|
@@ -5104,7 +5113,7 @@ function G(e) {
|
|
|
5104
5113
|
updated_at: e.updated_at
|
|
5105
5114
|
};
|
|
5106
5115
|
}
|
|
5107
|
-
function
|
|
5116
|
+
function Za(e) {
|
|
5108
5117
|
return {
|
|
5109
5118
|
async create(n, r, i) {
|
|
5110
5119
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5151,7 +5160,7 @@ function K(e) {
|
|
|
5151
5160
|
updated_at: e.updated_at
|
|
5152
5161
|
};
|
|
5153
5162
|
}
|
|
5154
|
-
function
|
|
5163
|
+
function Qa(e) {
|
|
5155
5164
|
return {
|
|
5156
5165
|
async create(n, r, i) {
|
|
5157
5166
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5191,13 +5200,13 @@ function q(e) {
|
|
|
5191
5200
|
tenant_id: e.tenant_id,
|
|
5192
5201
|
custom_domain_id: e.custom_domain_id,
|
|
5193
5202
|
priority: e.priority,
|
|
5194
|
-
match:
|
|
5195
|
-
handlers:
|
|
5203
|
+
match: $a(e.match),
|
|
5204
|
+
handlers: eo(e.handlers),
|
|
5196
5205
|
created_at: e.created_at,
|
|
5197
5206
|
updated_at: e.updated_at
|
|
5198
5207
|
};
|
|
5199
5208
|
}
|
|
5200
|
-
function
|
|
5209
|
+
function $a(e) {
|
|
5201
5210
|
if (!e) return { path: "/*" };
|
|
5202
5211
|
try {
|
|
5203
5212
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5205,7 +5214,7 @@ function Qa(e) {
|
|
|
5205
5214
|
} catch {}
|
|
5206
5215
|
return { path: "/*" };
|
|
5207
5216
|
}
|
|
5208
|
-
function
|
|
5217
|
+
function eo(e) {
|
|
5209
5218
|
if (!e) return [];
|
|
5210
5219
|
try {
|
|
5211
5220
|
let t = JSON.parse(e);
|
|
@@ -5275,7 +5284,7 @@ function J(e) {
|
|
|
5275
5284
|
}
|
|
5276
5285
|
//#endregion
|
|
5277
5286
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5278
|
-
async function
|
|
5287
|
+
async function to(e, t) {
|
|
5279
5288
|
let n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n), i = (r.endsWith(".") ? r.slice(0, -1) : r).toLowerCase(), a = await e.selectFrom("custom_domains").where("domain", "=", i).select([
|
|
5280
5289
|
"custom_domain_id",
|
|
5281
5290
|
"tenant_id",
|
|
@@ -5292,15 +5301,15 @@ async function eo(e, t) {
|
|
|
5292
5301
|
}
|
|
5293
5302
|
//#endregion
|
|
5294
5303
|
//#region src/proxyRoutes/index.ts
|
|
5295
|
-
function
|
|
5304
|
+
function no(e) {
|
|
5296
5305
|
return {
|
|
5297
5306
|
proxyRoutes: J(e),
|
|
5298
|
-
resolveHost: (t) =>
|
|
5307
|
+
resolveHost: (t) => to(e, t)
|
|
5299
5308
|
};
|
|
5300
5309
|
}
|
|
5301
5310
|
//#endregion
|
|
5302
5311
|
//#region src/scim/adapter.ts
|
|
5303
|
-
function
|
|
5312
|
+
function ro(e) {
|
|
5304
5313
|
if (!e) return [];
|
|
5305
5314
|
try {
|
|
5306
5315
|
let t = JSON.parse(e);
|
|
@@ -5315,7 +5324,7 @@ function no(e) {
|
|
|
5315
5324
|
return [];
|
|
5316
5325
|
}
|
|
5317
5326
|
}
|
|
5318
|
-
function
|
|
5327
|
+
function io(e) {
|
|
5319
5328
|
if (!e) return [];
|
|
5320
5329
|
try {
|
|
5321
5330
|
let t = JSON.parse(e);
|
|
@@ -5324,16 +5333,16 @@ function ro(e) {
|
|
|
5324
5333
|
return [];
|
|
5325
5334
|
}
|
|
5326
5335
|
}
|
|
5327
|
-
function
|
|
5336
|
+
function ao(e) {
|
|
5328
5337
|
return {
|
|
5329
5338
|
connection_id: e.connection_id,
|
|
5330
5339
|
user_id_attribute: e.user_id_attribute,
|
|
5331
|
-
mapping:
|
|
5340
|
+
mapping: ro(e.mapping),
|
|
5332
5341
|
created_at: e.created_at,
|
|
5333
5342
|
updated_at: e.updated_at
|
|
5334
5343
|
};
|
|
5335
5344
|
}
|
|
5336
|
-
function
|
|
5345
|
+
function oo(e) {
|
|
5337
5346
|
return {
|
|
5338
5347
|
async create(t, n) {
|
|
5339
5348
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5354,7 +5363,7 @@ function ao(e) {
|
|
|
5354
5363
|
},
|
|
5355
5364
|
async get(t, n) {
|
|
5356
5365
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5357
|
-
return r ?
|
|
5366
|
+
return r ? ao(r) : null;
|
|
5358
5367
|
},
|
|
5359
5368
|
async update(t, n, r) {
|
|
5360
5369
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5368,18 +5377,18 @@ function ao(e) {
|
|
|
5368
5377
|
}
|
|
5369
5378
|
};
|
|
5370
5379
|
}
|
|
5371
|
-
function
|
|
5380
|
+
function so(e) {
|
|
5372
5381
|
return {
|
|
5373
5382
|
token_id: e.token_id,
|
|
5374
5383
|
connection_id: e.connection_id,
|
|
5375
5384
|
token_hash: e.token_hash,
|
|
5376
|
-
scopes:
|
|
5385
|
+
scopes: io(e.scopes),
|
|
5377
5386
|
valid_until: e.valid_until ?? void 0,
|
|
5378
5387
|
created_at: e.created_at,
|
|
5379
5388
|
last_used_at: e.last_used_at ?? void 0
|
|
5380
5389
|
};
|
|
5381
5390
|
}
|
|
5382
|
-
function
|
|
5391
|
+
function co(e) {
|
|
5383
5392
|
return {
|
|
5384
5393
|
async create(t, n) {
|
|
5385
5394
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5403,14 +5412,14 @@ function so(e) {
|
|
|
5403
5412
|
},
|
|
5404
5413
|
async get(t, n) {
|
|
5405
5414
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5406
|
-
return r ?
|
|
5415
|
+
return r ? so(r) : null;
|
|
5407
5416
|
},
|
|
5408
5417
|
async getByHash(t, n) {
|
|
5409
5418
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5410
|
-
return r ?
|
|
5419
|
+
return r ? so(r) : null;
|
|
5411
5420
|
},
|
|
5412
5421
|
async listByConnection(t, n) {
|
|
5413
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5422
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(so);
|
|
5414
5423
|
},
|
|
5415
5424
|
async markUsed(t, n, r) {
|
|
5416
5425
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5422,7 +5431,7 @@ function so(e) {
|
|
|
5422
5431
|
}
|
|
5423
5432
|
};
|
|
5424
5433
|
}
|
|
5425
|
-
function
|
|
5434
|
+
function lo(e) {
|
|
5426
5435
|
return {
|
|
5427
5436
|
connection_id: e.connection_id,
|
|
5428
5437
|
external_id: e.external_id,
|
|
@@ -5430,7 +5439,7 @@ function co(e) {
|
|
|
5430
5439
|
created_at: e.created_at
|
|
5431
5440
|
};
|
|
5432
5441
|
}
|
|
5433
|
-
function
|
|
5442
|
+
function uo(e) {
|
|
5434
5443
|
return {
|
|
5435
5444
|
async create(t, n) {
|
|
5436
5445
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5449,11 +5458,11 @@ function lo(e) {
|
|
|
5449
5458
|
},
|
|
5450
5459
|
async getByExternalId(t, n, r) {
|
|
5451
5460
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5452
|
-
return i ?
|
|
5461
|
+
return i ? lo(i) : null;
|
|
5453
5462
|
},
|
|
5454
5463
|
async getByUserId(t, n, r) {
|
|
5455
5464
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5456
|
-
return i ?
|
|
5465
|
+
return i ? lo(i) : null;
|
|
5457
5466
|
},
|
|
5458
5467
|
async remove(t, n, r) {
|
|
5459
5468
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5463,7 +5472,7 @@ function lo(e) {
|
|
|
5463
5472
|
}
|
|
5464
5473
|
//#endregion
|
|
5465
5474
|
//#region src/tenantOperations/index.ts
|
|
5466
|
-
function
|
|
5475
|
+
function fo(e) {
|
|
5467
5476
|
return ye.parse({
|
|
5468
5477
|
id: e.id,
|
|
5469
5478
|
tenant_id: e.tenant_id,
|
|
@@ -5482,7 +5491,7 @@ function uo(e) {
|
|
|
5482
5491
|
finished_at: e.finished_at
|
|
5483
5492
|
});
|
|
5484
5493
|
}
|
|
5485
|
-
function
|
|
5494
|
+
function po(e) {
|
|
5486
5495
|
return {
|
|
5487
5496
|
async create(n) {
|
|
5488
5497
|
let r = ve.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5502,11 +5511,11 @@ function fo(e) {
|
|
|
5502
5511
|
updated_at: i,
|
|
5503
5512
|
finished_at: null
|
|
5504
5513
|
};
|
|
5505
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5514
|
+
return await e.insertInto("tenant_operations").values(a).execute(), fo(a);
|
|
5506
5515
|
},
|
|
5507
5516
|
async get(t) {
|
|
5508
5517
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5509
|
-
return n ?
|
|
5518
|
+
return n ? fo(n) : null;
|
|
5510
5519
|
},
|
|
5511
5520
|
async list(t = {}) {
|
|
5512
5521
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5517,7 +5526,7 @@ function fo(e) {
|
|
|
5517
5526
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5518
5527
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5519
5528
|
return {
|
|
5520
|
-
operations: a.map(
|
|
5529
|
+
operations: a.map(fo),
|
|
5521
5530
|
start: n * r,
|
|
5522
5531
|
limit: r,
|
|
5523
5532
|
length: a.length
|
|
@@ -5537,27 +5546,27 @@ function fo(e) {
|
|
|
5537
5546
|
}
|
|
5538
5547
|
//#endregion
|
|
5539
5548
|
//#region src/utils/monotonic-id.ts
|
|
5540
|
-
var
|
|
5541
|
-
function
|
|
5549
|
+
var mo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ho = 32, go = 10, _o = 4, vo = 10;
|
|
5550
|
+
function yo(e, t) {
|
|
5542
5551
|
let n = "";
|
|
5543
|
-
for (let r = t; r > 0; r--) n =
|
|
5552
|
+
for (let r = t; r > 0; r--) n = mo.charAt(e % ho) + n, e = Math.floor(e / ho);
|
|
5544
5553
|
return n;
|
|
5545
5554
|
}
|
|
5546
|
-
function
|
|
5547
|
-
let e = new Uint8Array(
|
|
5555
|
+
function bo() {
|
|
5556
|
+
let e = new Uint8Array(vo);
|
|
5548
5557
|
crypto.getRandomValues(e);
|
|
5549
5558
|
let t = "";
|
|
5550
|
-
for (let n = 0; n <
|
|
5559
|
+
for (let n = 0; n < vo; n++) t += mo.charAt(e[n] % ho);
|
|
5551
5560
|
return t;
|
|
5552
5561
|
}
|
|
5553
|
-
var
|
|
5554
|
-
function
|
|
5562
|
+
var xo = 0, So = 0;
|
|
5563
|
+
function Co() {
|
|
5555
5564
|
let e = Date.now();
|
|
5556
|
-
return e ===
|
|
5565
|
+
return e === xo ? So++ : (xo = e, So = 0), yo(e, go) + yo(So, _o) + bo();
|
|
5557
5566
|
}
|
|
5558
5567
|
//#endregion
|
|
5559
5568
|
//#region src/tenantOperationEvents/index.ts
|
|
5560
|
-
function
|
|
5569
|
+
function wo(e) {
|
|
5561
5570
|
if (!e) return null;
|
|
5562
5571
|
try {
|
|
5563
5572
|
let t = JSON.parse(e);
|
|
@@ -5565,22 +5574,22 @@ function Co(e) {
|
|
|
5565
5574
|
} catch {}
|
|
5566
5575
|
return null;
|
|
5567
5576
|
}
|
|
5568
|
-
function
|
|
5577
|
+
function To(e) {
|
|
5569
5578
|
return _e.parse({
|
|
5570
5579
|
id: e.id,
|
|
5571
5580
|
operation_id: e.operation_id,
|
|
5572
5581
|
step: e.step,
|
|
5573
5582
|
outcome: e.outcome,
|
|
5574
|
-
detail:
|
|
5583
|
+
detail: wo(e.detail),
|
|
5575
5584
|
attempt: e.attempt,
|
|
5576
5585
|
created_at: e.created_at
|
|
5577
5586
|
});
|
|
5578
5587
|
}
|
|
5579
|
-
function
|
|
5588
|
+
function Eo(e) {
|
|
5580
5589
|
return {
|
|
5581
5590
|
async create(t) {
|
|
5582
5591
|
let n = ge.parse(t), r = {
|
|
5583
|
-
id: `evt_${
|
|
5592
|
+
id: `evt_${Co()}`,
|
|
5584
5593
|
operation_id: n.operation_id,
|
|
5585
5594
|
step: n.step,
|
|
5586
5595
|
outcome: n.outcome,
|
|
@@ -5588,12 +5597,12 @@ function To(e) {
|
|
|
5588
5597
|
attempt: n.attempt,
|
|
5589
5598
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5590
5599
|
};
|
|
5591
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5600
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), To(r);
|
|
5592
5601
|
},
|
|
5593
5602
|
async listByOperation(t, n = {}) {
|
|
5594
5603
|
let r = n.page ?? 0, i = n.per_page ?? 100, a = await e.selectFrom("tenant_operation_events").where("operation_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").offset(r * i).limit(i).execute();
|
|
5595
5604
|
return {
|
|
5596
|
-
events: a.map(
|
|
5605
|
+
events: a.map(To),
|
|
5597
5606
|
start: r * i,
|
|
5598
5607
|
limit: i,
|
|
5599
5608
|
length: a.length
|
|
@@ -5603,7 +5612,7 @@ function To(e) {
|
|
|
5603
5612
|
}
|
|
5604
5613
|
//#endregion
|
|
5605
5614
|
//#region src/rollouts/index.ts
|
|
5606
|
-
function
|
|
5615
|
+
function Do(e) {
|
|
5607
5616
|
if (!e) return null;
|
|
5608
5617
|
try {
|
|
5609
5618
|
return JSON.parse(e);
|
|
@@ -5619,15 +5628,15 @@ function Y(e) {
|
|
|
5619
5628
|
target_worker_version: e.target_worker_version,
|
|
5620
5629
|
target_database_version: e.target_database_version,
|
|
5621
5630
|
wave_size: e.wave_size,
|
|
5622
|
-
canary_tenant_ids:
|
|
5623
|
-
filter:
|
|
5631
|
+
canary_tenant_ids: Do(e.canary_tenant_ids),
|
|
5632
|
+
filter: Do(e.filter),
|
|
5624
5633
|
initiated_by: e.initiated_by,
|
|
5625
5634
|
created_at: e.created_at,
|
|
5626
5635
|
updated_at: e.updated_at,
|
|
5627
5636
|
finished_at: e.finished_at
|
|
5628
5637
|
});
|
|
5629
5638
|
}
|
|
5630
|
-
function
|
|
5639
|
+
function Oo(e) {
|
|
5631
5640
|
return {
|
|
5632
5641
|
async create(n) {
|
|
5633
5642
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5673,7 +5682,7 @@ function Do(e) {
|
|
|
5673
5682
|
}
|
|
5674
5683
|
//#endregion
|
|
5675
5684
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5676
|
-
var
|
|
5685
|
+
var ko = class {
|
|
5677
5686
|
migrations;
|
|
5678
5687
|
constructor(e) {
|
|
5679
5688
|
this.migrations = e;
|
|
@@ -5681,10 +5690,10 @@ var Oo = class {
|
|
|
5681
5690
|
async getMigrations() {
|
|
5682
5691
|
return this.migrations;
|
|
5683
5692
|
}
|
|
5684
|
-
},
|
|
5685
|
-
down: () =>
|
|
5686
|
-
up: () =>
|
|
5687
|
-
}),
|
|
5693
|
+
}, Ao = /* @__PURE__ */ w({
|
|
5694
|
+
down: () => Po,
|
|
5695
|
+
up: () => No
|
|
5696
|
+
}), jo = [
|
|
5688
5697
|
{
|
|
5689
5698
|
table: "authentication_methods",
|
|
5690
5699
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5950,7 +5959,7 @@ var Oo = class {
|
|
|
5950
5959
|
onDelete: "cascade"
|
|
5951
5960
|
}
|
|
5952
5961
|
];
|
|
5953
|
-
async function
|
|
5962
|
+
async function Mo(e) {
|
|
5954
5963
|
try {
|
|
5955
5964
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5956
5965
|
} catch {
|
|
@@ -5959,14 +5968,14 @@ async function jo(e) {
|
|
|
5959
5968
|
}
|
|
5960
5969
|
function X(e, t) {
|
|
5961
5970
|
let n = e;
|
|
5962
|
-
for (let e of
|
|
5971
|
+
for (let e of jo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5963
5972
|
let n = t;
|
|
5964
5973
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5965
5974
|
}));
|
|
5966
5975
|
return n;
|
|
5967
5976
|
}
|
|
5968
|
-
async function
|
|
5969
|
-
let t = await
|
|
5977
|
+
async function No(e) {
|
|
5978
|
+
let t = await Mo(e);
|
|
5970
5979
|
await e.schema.createTable("tenants").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("audience", f`varchar(255)`).addColumn("sender_email", f`varchar(255)`).addColumn("sender_name", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addColumn("support_url", f`varchar(255)`).addColumn("idle_session_lifetime", f`int`).addColumn("session_lifetime", f`int`).addColumn("session_cookie", f`text`).addColumn("allowed_logout_urls", f`text`).addColumn("ephemeral_session_lifetime", f`int`).addColumn("idle_ephemeral_session_lifetime", f`int`).addColumn("default_redirection_uri", f`text`).addColumn("enabled_locales", f`text`).addColumn("default_directory", f`varchar(255)`).addColumn("error_page", f`text`).addColumn("flags", f`text`).addColumn("friendly_name", f`varchar(255)`).addColumn("picture_url", f`text`).addColumn("support_email", f`varchar(255)`).addColumn("sandbox_version", f`varchar(50)`).addColumn("sandbox_versions_available", f`text`).addColumn("legacy_sandbox_version", f`varchar(50)`).addColumn("change_password", f`text`).addColumn("guardian_mfa_page", f`text`).addColumn("device_flow", f`text`).addColumn("default_token_quota", f`text`).addColumn("default_audience", f`varchar(255)`).addColumn("default_organization", f`varchar(255)`).addColumn("sessions", f`text`).addColumn("oidc_logout", f`text`).addColumn("allow_organization_name_in_authentication_api", f`int`).addColumn("customize_mfa_in_postlogin_action", f`int`).addColumn("acr_values_supported", f`text`).addColumn("mtls", f`text`).addColumn("pushed_authorization_requests_supported", f`int`).addColumn("authorization_response_iss_parameter_supported", f`int`).addColumn("mfa", f`text`).addColumn("attack_protection", f`text`).addColumn("default_client_id", f`varchar(255)`).addColumn("deployment_type", f`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", f`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", f`varchar(2048)`).addColumn("provisioning_state_changed_at", f`varchar(35)`).addColumn("bundle_configuration", f`varchar(64)`).addColumn("worker_version", f`varchar(64)`).addColumn("worker_script_name", f`varchar(255)`).addColumn("storage_kind", f`varchar(32)`).addColumn("d1_database_id", f`varchar(64)`).addColumn("database_version", f`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", f`varchar(64)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("results", f`text`, (e) => e.notNull()).addColumn("logs", f`text`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("action_id", f`varchar(255)`, (e) => e.notNull()).addColumn("number", f`int`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("status", f`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed_at_ts", f`bigint`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
5971
5980
|
{
|
|
5972
5981
|
let n = e.schema.createTable("authentication_methods").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("type", f`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", f`varchar(32)`).addColumn("totp_secret", f`varchar(255)`).addColumn("confirmed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("credential_id", f`varchar(512)`).addColumn("public_key", f`text`).addColumn("sign_count", f`int`).addColumn("credential_backed_up", f`int`).addColumn("transports", f`varchar(512)`).addColumn("friendly_name", f`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
@@ -6153,40 +6162,40 @@ async function Mo(e) {
|
|
|
6153
6162
|
"tenant_id",
|
|
6154
6163
|
"phone_number",
|
|
6155
6164
|
"provider"
|
|
6156
|
-
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of
|
|
6165
|
+
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of jo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6157
6166
|
let n = e;
|
|
6158
6167
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6159
6168
|
}).execute();
|
|
6160
6169
|
}
|
|
6161
|
-
async function
|
|
6170
|
+
async function Po(e) {
|
|
6162
6171
|
await e.schema.dropTable("user_roles").ifExists().execute(), await e.schema.dropTable("user_permissions").ifExists().execute(), await e.schema.dropTable("user_organizations").ifExists().execute(), await e.schema.dropTable("user_activity").ifExists().execute(), await e.schema.dropTable("universal_login_templates").ifExists().execute(), await e.schema.dropTable("themes").ifExists().execute(), await e.schema.dropTable("tenant_operation_events").ifExists().execute(), await e.schema.dropTable("tenant_operations").ifExists().execute(), await e.schema.dropTable("rollouts").ifExists().execute(), await e.schema.dropTable("roles").ifExists().execute(), await e.schema.dropTable("role_permissions").ifExists().execute(), await e.schema.dropTable("resource_servers").ifExists().execute(), await e.schema.dropTable("refresh_tokens").ifExists().execute(), await e.schema.dropTable("proxy_routes").ifExists().execute(), await e.schema.dropTable("prompt_settings").ifExists().execute(), await e.schema.dropTable("passwords").ifExists().execute(), await e.schema.dropTable("outbox_events").ifExists().execute(), await e.schema.dropTable("organization_connections").ifExists().execute(), await e.schema.dropTable("organizations").ifExists().execute(), await e.schema.dropTable("migrations").ifExists().execute(), await e.schema.dropTable("migration_sources").ifExists().execute(), await e.schema.dropTable("logs").ifExists().execute(), await e.schema.dropTable("login_sessions").ifExists().execute(), await e.schema.dropTable("sessions").ifExists().execute(), await e.schema.dropTable("log_streams").ifExists().execute(), await e.schema.dropTable("keys").ifExists().execute(), await e.schema.dropTable("invites").ifExists().execute(), await e.schema.dropTable("hooks").ifExists().execute(), await e.schema.dropTable("hook_code").ifExists().execute(), await e.schema.dropTable("grants").ifExists().execute(), await e.schema.dropTable("forms").ifExists().execute(), await e.schema.dropTable("flows").ifExists().execute(), await e.schema.dropTable("email_templates").ifExists().execute(), await e.schema.dropTable("email_providers").ifExists().execute(), await e.schema.dropTable("custom_text").ifExists().execute(), await e.schema.dropTable("custom_domains").ifExists().execute(), await e.schema.dropTable("control_plane_comm_keys").ifExists().execute(), await e.schema.dropTable("connections").ifExists().execute(), await e.schema.dropTable("codes").ifExists().execute(), await e.schema.dropTable("users").ifExists().execute(), await e.schema.dropTable("client_registration_tokens").ifExists().execute(), await e.schema.dropTable("client_grants").ifExists().execute(), await e.schema.dropTable("clients").ifExists().execute(), await e.schema.dropTable("branding").ifExists().execute(), await e.schema.dropTable("authentication_methods").ifExists().execute(), await e.schema.dropTable("actions").ifExists().execute(), await e.schema.dropTable("action_versions").ifExists().execute(), await e.schema.dropTable("action_executions").ifExists().execute(), await e.schema.dropTable("tenants").ifExists().execute();
|
|
6163
6172
|
}
|
|
6164
6173
|
//#endregion
|
|
6165
6174
|
//#region migrate/log.ts
|
|
6166
|
-
var
|
|
6167
|
-
function
|
|
6168
|
-
|
|
6175
|
+
var Fo = !1;
|
|
6176
|
+
function Io(e) {
|
|
6177
|
+
Fo = e;
|
|
6169
6178
|
}
|
|
6170
6179
|
function Z(...e) {
|
|
6171
|
-
|
|
6180
|
+
Fo && console.log(...e);
|
|
6172
6181
|
}
|
|
6173
6182
|
function Q(...e) {
|
|
6174
6183
|
console.warn(...e);
|
|
6175
6184
|
}
|
|
6176
6185
|
//#endregion
|
|
6177
6186
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6178
|
-
var
|
|
6179
|
-
down: () =>
|
|
6180
|
-
up: () =>
|
|
6181
|
-
}), $ = 5e4,
|
|
6182
|
-
async function
|
|
6187
|
+
var Lo = /* @__PURE__ */ w({
|
|
6188
|
+
down: () => qo,
|
|
6189
|
+
up: () => Wo
|
|
6190
|
+
}), $ = 5e4, Ro = 500;
|
|
6191
|
+
async function zo(e) {
|
|
6183
6192
|
try {
|
|
6184
6193
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6185
6194
|
} catch {
|
|
6186
6195
|
return "sqlite";
|
|
6187
6196
|
}
|
|
6188
6197
|
}
|
|
6189
|
-
async function
|
|
6198
|
+
async function Bo(e, t, n) {
|
|
6190
6199
|
try {
|
|
6191
6200
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6192
6201
|
} catch (e) {
|
|
@@ -6197,7 +6206,7 @@ async function zo(e, t, n) {
|
|
|
6197
6206
|
throw e;
|
|
6198
6207
|
}
|
|
6199
6208
|
}
|
|
6200
|
-
async function
|
|
6209
|
+
async function Vo(e, t, n, r) {
|
|
6201
6210
|
try {
|
|
6202
6211
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6203
6212
|
} catch (e) {
|
|
@@ -6208,7 +6217,7 @@ async function Bo(e, t, n, r) {
|
|
|
6208
6217
|
throw e;
|
|
6209
6218
|
}
|
|
6210
6219
|
}
|
|
6211
|
-
async function
|
|
6220
|
+
async function Ho(e, t) {
|
|
6212
6221
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6213
6222
|
if (t === "sqlite") {
|
|
6214
6223
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
@@ -6222,7 +6231,7 @@ async function Vo(e, t) {
|
|
|
6222
6231
|
}
|
|
6223
6232
|
return r;
|
|
6224
6233
|
}
|
|
6225
|
-
async function
|
|
6234
|
+
async function Uo(e) {
|
|
6226
6235
|
let t = 0;
|
|
6227
6236
|
for (;;) {
|
|
6228
6237
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6230,33 +6239,33 @@ async function Ho(e) {
|
|
|
6230
6239
|
"code_type",
|
|
6231
6240
|
"tenant_id",
|
|
6232
6241
|
"expires_at"
|
|
6233
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6242
|
+
]).where("expires_at_ts", "is", null).limit(Ro).execute();
|
|
6234
6243
|
if (n.length === 0) break;
|
|
6235
6244
|
for (let t of n) {
|
|
6236
6245
|
let n = Date.parse(t.expires_at);
|
|
6237
6246
|
await e.updateTable("codes").set({ expires_at_ts: Number.isNaN(n) ? 0 : n }).where("code_id", "=", t.code_id).where("code_type", "=", t.code_type).where("tenant_id", "=", t.tenant_id).execute();
|
|
6238
6247
|
}
|
|
6239
|
-
if (t += n.length, n.length <
|
|
6248
|
+
if (t += n.length, n.length < Ro) break;
|
|
6240
6249
|
}
|
|
6241
6250
|
return t;
|
|
6242
6251
|
}
|
|
6243
|
-
async function
|
|
6244
|
-
let t = await
|
|
6252
|
+
async function Wo(e) {
|
|
6253
|
+
let t = await zo(e);
|
|
6245
6254
|
try {
|
|
6246
|
-
let n = await
|
|
6255
|
+
let n = await Ho(e, t);
|
|
6247
6256
|
Z(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6248
6257
|
} catch (e) {
|
|
6249
6258
|
Q(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6250
6259
|
}
|
|
6251
|
-
await
|
|
6260
|
+
await Bo(e, "codes", "expires_at_ts"), await Vo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6252
6261
|
try {
|
|
6253
|
-
let t = await
|
|
6262
|
+
let t = await Uo(e);
|
|
6254
6263
|
Z(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6255
6264
|
} catch (e) {
|
|
6256
6265
|
Q(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6257
6266
|
}
|
|
6258
6267
|
}
|
|
6259
|
-
async function
|
|
6268
|
+
async function Go(e, t, n) {
|
|
6260
6269
|
try {
|
|
6261
6270
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6262
6271
|
} catch (e) {
|
|
@@ -6264,7 +6273,7 @@ async function Wo(e, t, n) {
|
|
|
6264
6273
|
throw e;
|
|
6265
6274
|
}
|
|
6266
6275
|
}
|
|
6267
|
-
async function
|
|
6276
|
+
async function Ko(e, t, n) {
|
|
6268
6277
|
try {
|
|
6269
6278
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6270
6279
|
} catch (e) {
|
|
@@ -6272,16 +6281,16 @@ async function Go(e, t, n) {
|
|
|
6272
6281
|
throw e;
|
|
6273
6282
|
}
|
|
6274
6283
|
}
|
|
6275
|
-
async function
|
|
6276
|
-
await
|
|
6284
|
+
async function qo(e) {
|
|
6285
|
+
await Go(e, "idx_codes_expires_at_ts", "codes"), await Ko(e, "codes", "expires_at_ts");
|
|
6277
6286
|
}
|
|
6278
6287
|
//#endregion
|
|
6279
6288
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6280
|
-
var
|
|
6281
|
-
down: () =>
|
|
6282
|
-
up: () =>
|
|
6289
|
+
var Jo = /* @__PURE__ */ w({
|
|
6290
|
+
down: () => Xo,
|
|
6291
|
+
up: () => Yo
|
|
6283
6292
|
});
|
|
6284
|
-
async function
|
|
6293
|
+
async function Yo(e) {
|
|
6285
6294
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", f`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(128)`, (e) => e.notNull()).addColumn("scopes", f`text`, (e) => e.notNull()).addColumn("valid_until", f`varchar(35)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", f`varchar(35)`).addPrimaryKeyConstraint("scim_tokens_pk", ["tenant_id", "token_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_connection_idx").on("scim_tokens").columns(["tenant_id", "connection_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_hash_idx").on("scim_tokens").columns(["tenant_id", "token_hash"]).unique().execute(), await e.schema.createTable("scim_external_ids").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("external_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6286
6295
|
"tenant_id",
|
|
6287
6296
|
"connection_id",
|
|
@@ -6292,16 +6301,16 @@ async function Jo(e) {
|
|
|
6292
6301
|
"external_id"
|
|
6293
6302
|
]).unique().execute();
|
|
6294
6303
|
}
|
|
6295
|
-
async function
|
|
6304
|
+
async function Xo(e) {
|
|
6296
6305
|
await e.schema.dropTable("scim_external_ids").ifExists().execute(), await e.schema.dropTable("scim_tokens").ifExists().execute(), await e.schema.dropTable("scim_configurations").ifExists().execute();
|
|
6297
6306
|
}
|
|
6298
6307
|
//#endregion
|
|
6299
6308
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6300
|
-
var
|
|
6301
|
-
down: () =>
|
|
6302
|
-
up: () =>
|
|
6309
|
+
var Zo = /* @__PURE__ */ w({
|
|
6310
|
+
down: () => ts,
|
|
6311
|
+
up: () => $o
|
|
6303
6312
|
});
|
|
6304
|
-
async function
|
|
6313
|
+
async function Qo(e, t, n) {
|
|
6305
6314
|
try {
|
|
6306
6315
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6307
6316
|
} catch (e) {
|
|
@@ -6309,10 +6318,10 @@ async function Zo(e, t, n) {
|
|
|
6309
6318
|
throw e;
|
|
6310
6319
|
}
|
|
6311
6320
|
}
|
|
6312
|
-
async function
|
|
6313
|
-
await
|
|
6321
|
+
async function $o(e) {
|
|
6322
|
+
await Qo(e, "users", "blocked");
|
|
6314
6323
|
}
|
|
6315
|
-
async function
|
|
6324
|
+
async function es(e, t, n) {
|
|
6316
6325
|
try {
|
|
6317
6326
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6318
6327
|
} catch (e) {
|
|
@@ -6320,16 +6329,16 @@ async function $o(e, t, n) {
|
|
|
6320
6329
|
throw e;
|
|
6321
6330
|
}
|
|
6322
6331
|
}
|
|
6323
|
-
async function
|
|
6324
|
-
await
|
|
6332
|
+
async function ts(e) {
|
|
6333
|
+
await es(e, "users", "blocked");
|
|
6325
6334
|
}
|
|
6326
6335
|
//#endregion
|
|
6327
6336
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6328
|
-
var
|
|
6329
|
-
down: () =>
|
|
6330
|
-
up: () =>
|
|
6337
|
+
var ns = /* @__PURE__ */ w({
|
|
6338
|
+
down: () => os,
|
|
6339
|
+
up: () => is
|
|
6331
6340
|
});
|
|
6332
|
-
async function
|
|
6341
|
+
async function rs(e, t, n) {
|
|
6333
6342
|
try {
|
|
6334
6343
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6335
6344
|
} catch (e) {
|
|
@@ -6337,10 +6346,10 @@ async function ns(e, t, n) {
|
|
|
6337
6346
|
throw e;
|
|
6338
6347
|
}
|
|
6339
6348
|
}
|
|
6340
|
-
async function
|
|
6341
|
-
await
|
|
6349
|
+
async function is(e) {
|
|
6350
|
+
await rs(e, "prompt_settings", "show_last_used_connection");
|
|
6342
6351
|
}
|
|
6343
|
-
async function
|
|
6352
|
+
async function as(e, t, n) {
|
|
6344
6353
|
try {
|
|
6345
6354
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6346
6355
|
} catch (e) {
|
|
@@ -6348,16 +6357,16 @@ async function is(e, t, n) {
|
|
|
6348
6357
|
throw e;
|
|
6349
6358
|
}
|
|
6350
6359
|
}
|
|
6351
|
-
async function
|
|
6352
|
-
await
|
|
6360
|
+
async function os(e) {
|
|
6361
|
+
await as(e, "prompt_settings", "show_last_used_connection");
|
|
6353
6362
|
}
|
|
6354
6363
|
//#endregion
|
|
6355
6364
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6356
|
-
var
|
|
6357
|
-
down: () =>
|
|
6358
|
-
up: () =>
|
|
6365
|
+
var ss = /* @__PURE__ */ w({
|
|
6366
|
+
down: () => us,
|
|
6367
|
+
up: () => ls
|
|
6359
6368
|
});
|
|
6360
|
-
async function
|
|
6369
|
+
async function cs(e, t, n, r) {
|
|
6361
6370
|
try {
|
|
6362
6371
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6363
6372
|
} catch (e) {
|
|
@@ -6368,10 +6377,10 @@ async function ss(e, t, n, r) {
|
|
|
6368
6377
|
throw e;
|
|
6369
6378
|
}
|
|
6370
6379
|
}
|
|
6371
|
-
async function cs(e) {
|
|
6372
|
-
await ss(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6373
|
-
}
|
|
6374
6380
|
async function ls(e) {
|
|
6381
|
+
await cs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6382
|
+
}
|
|
6383
|
+
async function us(e) {
|
|
6375
6384
|
try {
|
|
6376
6385
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6377
6386
|
} catch (e) {
|
|
@@ -6381,11 +6390,11 @@ async function ls(e) {
|
|
|
6381
6390
|
}
|
|
6382
6391
|
//#endregion
|
|
6383
6392
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6384
|
-
var
|
|
6385
|
-
down: () =>
|
|
6386
|
-
up: () =>
|
|
6393
|
+
var ds = /* @__PURE__ */ w({
|
|
6394
|
+
down: () => hs,
|
|
6395
|
+
up: () => ps
|
|
6387
6396
|
});
|
|
6388
|
-
async function
|
|
6397
|
+
async function fs(e, t, n, r) {
|
|
6389
6398
|
try {
|
|
6390
6399
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6391
6400
|
} catch (e) {
|
|
@@ -6393,10 +6402,10 @@ async function ds(e, t, n, r) {
|
|
|
6393
6402
|
throw e;
|
|
6394
6403
|
}
|
|
6395
6404
|
}
|
|
6396
|
-
async function
|
|
6397
|
-
await
|
|
6405
|
+
async function ps(e) {
|
|
6406
|
+
await fs(e, "hooks", "page_id", f`varchar(64)`), await fs(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6398
6407
|
}
|
|
6399
|
-
async function
|
|
6408
|
+
async function ms(e, t, n) {
|
|
6400
6409
|
try {
|
|
6401
6410
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6402
6411
|
} catch (e) {
|
|
@@ -6404,22 +6413,22 @@ async function ps(e, t, n) {
|
|
|
6404
6413
|
throw e;
|
|
6405
6414
|
}
|
|
6406
6415
|
}
|
|
6407
|
-
async function
|
|
6408
|
-
await
|
|
6416
|
+
async function hs(e) {
|
|
6417
|
+
await ms(e, "hooks", "permission_required"), await ms(e, "hooks", "page_id");
|
|
6409
6418
|
}
|
|
6410
6419
|
//#endregion
|
|
6411
6420
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6412
|
-
var
|
|
6413
|
-
down: () =>
|
|
6414
|
-
up: () =>
|
|
6415
|
-
}),
|
|
6421
|
+
var gs = /* @__PURE__ */ w({
|
|
6422
|
+
down: () => Ss,
|
|
6423
|
+
up: () => bs
|
|
6424
|
+
}), _s = [
|
|
6416
6425
|
["session_id", f`varchar(26)`],
|
|
6417
6426
|
["organization", f`varchar(191)`],
|
|
6418
6427
|
["auth_connection", f`varchar(255)`],
|
|
6419
6428
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6420
6429
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6421
6430
|
];
|
|
6422
|
-
async function
|
|
6431
|
+
async function vs(e, t, n, r) {
|
|
6423
6432
|
try {
|
|
6424
6433
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6425
6434
|
} catch (e) {
|
|
@@ -6427,7 +6436,7 @@ async function _s(e, t, n, r) {
|
|
|
6427
6436
|
throw e;
|
|
6428
6437
|
}
|
|
6429
6438
|
}
|
|
6430
|
-
async function
|
|
6439
|
+
async function ys(e) {
|
|
6431
6440
|
try {
|
|
6432
6441
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6433
6442
|
} catch (e) {
|
|
@@ -6435,11 +6444,11 @@ async function vs(e) {
|
|
|
6435
6444
|
throw e;
|
|
6436
6445
|
}
|
|
6437
6446
|
}
|
|
6438
|
-
async function
|
|
6439
|
-
for (let [t, n] of
|
|
6440
|
-
await
|
|
6447
|
+
async function bs(e) {
|
|
6448
|
+
for (let [t, n] of _s) await vs(e, "refresh_tokens", t, n);
|
|
6449
|
+
await ys(e);
|
|
6441
6450
|
}
|
|
6442
|
-
async function
|
|
6451
|
+
async function xs(e, t, n) {
|
|
6443
6452
|
try {
|
|
6444
6453
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6445
6454
|
} catch (e) {
|
|
@@ -6447,23 +6456,32 @@ async function bs(e, t, n) {
|
|
|
6447
6456
|
throw e;
|
|
6448
6457
|
}
|
|
6449
6458
|
}
|
|
6450
|
-
async function
|
|
6459
|
+
async function Ss(e) {
|
|
6451
6460
|
try {
|
|
6452
6461
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6453
6462
|
} catch {}
|
|
6454
|
-
for (let [t] of
|
|
6463
|
+
for (let [t] of _s) await xs(e, "refresh_tokens", t);
|
|
6455
6464
|
}
|
|
6456
6465
|
//#endregion
|
|
6457
6466
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6458
|
-
var
|
|
6459
|
-
down: () =>
|
|
6460
|
-
up: () =>
|
|
6461
|
-
}),
|
|
6462
|
-
async function
|
|
6467
|
+
var Cs = /* @__PURE__ */ w({
|
|
6468
|
+
down: () => ks,
|
|
6469
|
+
up: () => Os
|
|
6470
|
+
}), ws = 500, Ts = 20, Es = 500, Ds = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6471
|
+
async function Os(e) {
|
|
6463
6472
|
try {
|
|
6464
|
-
let t = 0;
|
|
6473
|
+
let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select((e) => e.fn.countAll().as("count")).executeTakeFirst(), n = Number(t?.count ?? 0);
|
|
6474
|
+
if (n > Es) {
|
|
6475
|
+
Q(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${Es}. SKIPPING — run the bulk path instead: ${Ds}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6476
|
+
return;
|
|
6477
|
+
}
|
|
6478
|
+
if (n === 0) {
|
|
6479
|
+
Z("refresh_tokens backfill: nothing to do");
|
|
6480
|
+
return;
|
|
6481
|
+
}
|
|
6482
|
+
let r = 0;
|
|
6465
6483
|
for (;;) {
|
|
6466
|
-
let
|
|
6484
|
+
let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select([
|
|
6467
6485
|
"refresh_tokens.id as id",
|
|
6468
6486
|
"refresh_tokens.tenant_id as tenant_id",
|
|
6469
6487
|
"login_sessions.session_id as ls_session_id",
|
|
@@ -6471,10 +6489,10 @@ async function Ts(e) {
|
|
|
6471
6489
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6472
6490
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6473
6491
|
"login_sessions.auth_params as ls_auth_params"
|
|
6474
|
-
]).limit(
|
|
6475
|
-
if (
|
|
6476
|
-
for (let
|
|
6477
|
-
let r =
|
|
6492
|
+
]).limit(ws).execute();
|
|
6493
|
+
if (t.length === 0) break;
|
|
6494
|
+
for (let n = 0; n < t.length; n += Ts) {
|
|
6495
|
+
let r = t.slice(n, n + Ts);
|
|
6478
6496
|
await Promise.all(r.map(async (t) => {
|
|
6479
6497
|
let n = null;
|
|
6480
6498
|
if (t.ls_auth_params) try {
|
|
@@ -6491,44 +6509,44 @@ async function Ts(e) {
|
|
|
6491
6509
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6492
6510
|
}));
|
|
6493
6511
|
}
|
|
6494
|
-
if (
|
|
6512
|
+
if (r += t.length, Z(`refresh_tokens backfill: ${r} rows populated so far`), t.length < ws) break;
|
|
6495
6513
|
}
|
|
6496
|
-
Z(`refresh_tokens backfill: done, ${
|
|
6514
|
+
Z(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6497
6515
|
} catch (e) {
|
|
6498
6516
|
throw Q("refresh_tokens backfill failed:", e), e;
|
|
6499
6517
|
}
|
|
6500
6518
|
}
|
|
6501
|
-
async function
|
|
6519
|
+
async function ks() {}
|
|
6502
6520
|
//#endregion
|
|
6503
6521
|
//#region migrate/migrations/index.ts
|
|
6504
|
-
var
|
|
6505
|
-
"2026-07-16T14:00:00_baseline":
|
|
6506
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6507
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6508
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6509
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6510
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6511
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6512
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6513
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6522
|
+
var As = {
|
|
6523
|
+
"2026-07-16T14:00:00_baseline": Ao,
|
|
6524
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Lo,
|
|
6525
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Jo,
|
|
6526
|
+
"2026-08-05T12:00:00_user_blocked": Zo,
|
|
6527
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": ns,
|
|
6528
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": ss,
|
|
6529
|
+
"2026-08-11T12:00:00_page_hooks": ds,
|
|
6530
|
+
"2026-08-20T12:00:00_refresh_token_session_id": gs,
|
|
6531
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Cs
|
|
6514
6532
|
};
|
|
6515
6533
|
//#endregion
|
|
6516
6534
|
//#region migrate/migrate.ts
|
|
6517
|
-
async function
|
|
6518
|
-
|
|
6535
|
+
async function js(e, t = !1) {
|
|
6536
|
+
Io(t), t && console.log("migrating...");
|
|
6519
6537
|
let { error: n, results: r } = await new be({
|
|
6520
6538
|
db: e,
|
|
6521
|
-
provider: new
|
|
6539
|
+
provider: new ko(As)
|
|
6522
6540
|
}).migrateToLatest();
|
|
6523
6541
|
if (r?.forEach((e) => {
|
|
6524
6542
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6525
6543
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6526
6544
|
}
|
|
6527
|
-
async function
|
|
6528
|
-
|
|
6545
|
+
async function Ms(e, t = !1) {
|
|
6546
|
+
Io(t), t && console.log("migrating...");
|
|
6529
6547
|
let { error: n, results: r } = await new be({
|
|
6530
6548
|
db: e,
|
|
6531
|
-
provider: new
|
|
6549
|
+
provider: new ko(As)
|
|
6532
6550
|
}).migrateDown();
|
|
6533
6551
|
if (r?.forEach((e) => {
|
|
6534
6552
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6536,7 +6554,7 @@ async function ks(e, t = !1) {
|
|
|
6536
6554
|
}
|
|
6537
6555
|
//#endregion
|
|
6538
6556
|
//#region src/index.ts
|
|
6539
|
-
function
|
|
6557
|
+
function Ns(e, t = { useTransactions: !0 }) {
|
|
6540
6558
|
let n = {
|
|
6541
6559
|
actions: Be(e),
|
|
6542
6560
|
actionExecutions: Ke(e),
|
|
@@ -6552,48 +6570,48 @@ function As(e, t = { useTransactions: !0 }) {
|
|
|
6552
6570
|
emailTemplates: Zr(e),
|
|
6553
6571
|
customDomains: tr(e),
|
|
6554
6572
|
flows: St(e),
|
|
6555
|
-
forms:
|
|
6573
|
+
forms: gi(e),
|
|
6556
6574
|
hookCode: yr(e),
|
|
6557
6575
|
hooks: mr(e),
|
|
6558
|
-
invites:
|
|
6576
|
+
invites: ga(e),
|
|
6559
6577
|
keys: Jn(e),
|
|
6560
6578
|
loginSessions: Fr(e),
|
|
6561
6579
|
logs: Rt(e),
|
|
6562
|
-
logStreams:
|
|
6563
|
-
migrationSources:
|
|
6564
|
-
authenticationMethods:
|
|
6580
|
+
logStreams: Za(e),
|
|
6581
|
+
migrationSources: Qa(e),
|
|
6582
|
+
authenticationMethods: Ba(e),
|
|
6565
6583
|
passwords: Yt(e),
|
|
6566
6584
|
promptSettings: zr(e),
|
|
6567
6585
|
proxyRoutes: J(e),
|
|
6568
|
-
scimConfigurations:
|
|
6569
|
-
scimTokens:
|
|
6570
|
-
scimExternalIds:
|
|
6571
|
-
refreshTokens:
|
|
6572
|
-
resourceServers:
|
|
6573
|
-
rolePermissions:
|
|
6574
|
-
grants:
|
|
6575
|
-
userPermissions:
|
|
6576
|
-
userRoles:
|
|
6577
|
-
roles:
|
|
6586
|
+
scimConfigurations: oo(e),
|
|
6587
|
+
scimTokens: co(e),
|
|
6588
|
+
scimExternalIds: uo(e),
|
|
6589
|
+
refreshTokens: ci(e),
|
|
6590
|
+
resourceServers: Si(e),
|
|
6591
|
+
rolePermissions: Ni(e),
|
|
6592
|
+
grants: zi(e),
|
|
6593
|
+
userPermissions: Wi(e),
|
|
6594
|
+
userRoles: Xi(e),
|
|
6595
|
+
roles: Oi(e),
|
|
6578
6596
|
sessions: Wt(e),
|
|
6579
|
-
sessionCleanup:
|
|
6597
|
+
sessionCleanup: ui(e),
|
|
6580
6598
|
tenants: At(e),
|
|
6581
|
-
tenantOperations:
|
|
6582
|
-
tenantOperationEvents:
|
|
6583
|
-
rollouts:
|
|
6599
|
+
tenantOperations: po(e),
|
|
6600
|
+
tenantOperationEvents: Eo(e),
|
|
6601
|
+
rollouts: Oo(e),
|
|
6584
6602
|
themes: wr(e),
|
|
6585
6603
|
universalLoginTemplates: cr(e),
|
|
6586
|
-
customText:
|
|
6604
|
+
customText: Na(e),
|
|
6587
6605
|
users: mt(e),
|
|
6588
6606
|
userActivity: dt(e),
|
|
6589
|
-
organizations:
|
|
6590
|
-
organizationConnections:
|
|
6591
|
-
userOrganizations:
|
|
6592
|
-
stats:
|
|
6593
|
-
analytics:
|
|
6594
|
-
outbox:
|
|
6607
|
+
organizations: na(e),
|
|
6608
|
+
organizationConnections: ra(e),
|
|
6609
|
+
userOrganizations: ua(e),
|
|
6610
|
+
stats: xa(e),
|
|
6611
|
+
analytics: Ma(e),
|
|
6612
|
+
outbox: Xa(e),
|
|
6595
6613
|
async transaction(r) {
|
|
6596
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6614
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Ns(e, {
|
|
6597
6615
|
...t,
|
|
6598
6616
|
useTransactions: !1
|
|
6599
6617
|
})));
|
|
@@ -6602,4 +6620,4 @@ function As(e, t = { useTransactions: !0 }) {
|
|
|
6602
6620
|
return n;
|
|
6603
6621
|
}
|
|
6604
6622
|
//#endregion
|
|
6605
|
-
export {
|
|
6623
|
+
export { no as createProxyDataAdapter, J as createProxyRoutesAdapter, Ns as default, Ms as migrateDown, js as migrateToLatest };
|