@authhero/kysely-adapter 12.13.0 → 12.14.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.cjs +2 -2
- package/dist/kysely-adapter.d.ts +8 -0
- package/dist/kysely-adapter.mjs +543 -494
- package/dist/types/migrate/migrations/2026-10-13T12:00:00_prompt_partials.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +2 -0
- package/dist/types/src/db.d.ts +8 -0
- package/dist/types/src/promptPartials/index.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -3060,8 +3060,43 @@ function ti(e) {
|
|
|
3060
3060
|
};
|
|
3061
3061
|
}
|
|
3062
3062
|
//#endregion
|
|
3063
|
-
//#region src/
|
|
3063
|
+
//#region src/promptPartials/index.ts
|
|
3064
3064
|
function ni(e) {
|
|
3065
|
+
return {
|
|
3066
|
+
async get(t, n) {
|
|
3067
|
+
let r = await e.selectFrom("prompt_partials").select("body").where("tenant_id", "=", t).where("prompt", "=", n).executeTakeFirst();
|
|
3068
|
+
if (!r) return null;
|
|
3069
|
+
try {
|
|
3070
|
+
return JSON.parse(r.body);
|
|
3071
|
+
} catch {
|
|
3072
|
+
return null;
|
|
3073
|
+
}
|
|
3074
|
+
},
|
|
3075
|
+
async set(t, n, r, i) {
|
|
3076
|
+
let a = Date.now(), o = i?.importMetadata?.created_at, s = i?.importMetadata?.updated_at, c = o ? new Date(o).getTime() : a, l = s ? new Date(s).getTime() : c, u = JSON.stringify(r);
|
|
3077
|
+
await e.selectFrom("prompt_partials").select("tenant_id").where("tenant_id", "=", t).where("prompt", "=", n).executeTakeFirst() ? await e.updateTable("prompt_partials").set({
|
|
3078
|
+
body: u,
|
|
3079
|
+
...o ? { created_at_ts: c } : void 0,
|
|
3080
|
+
updated_at_ts: s ? l : a
|
|
3081
|
+
}).where("tenant_id", "=", t).where("prompt", "=", n).execute() : await e.insertInto("prompt_partials").values({
|
|
3082
|
+
tenant_id: t,
|
|
3083
|
+
prompt: n,
|
|
3084
|
+
body: u,
|
|
3085
|
+
created_at_ts: c,
|
|
3086
|
+
updated_at_ts: l
|
|
3087
|
+
}).execute();
|
|
3088
|
+
},
|
|
3089
|
+
async delete(t, n) {
|
|
3090
|
+
await e.deleteFrom("prompt_partials").where("tenant_id", "=", t).where("prompt", "=", n).execute();
|
|
3091
|
+
},
|
|
3092
|
+
async list(t) {
|
|
3093
|
+
return (await e.selectFrom("prompt_partials").select("prompt").where("tenant_id", "=", t).execute()).map(({ prompt: e }) => e);
|
|
3094
|
+
}
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/emailProvideres/get.ts
|
|
3099
|
+
function ri(e) {
|
|
3065
3100
|
return async (t) => {
|
|
3066
3101
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
3067
3102
|
if (!n) return null;
|
|
@@ -3076,7 +3111,7 @@ function ni(e) {
|
|
|
3076
3111
|
}
|
|
3077
3112
|
//#endregion
|
|
3078
3113
|
//#region src/emailProvideres/update.ts
|
|
3079
|
-
function
|
|
3114
|
+
function ii(e) {
|
|
3080
3115
|
return async (t, n) => {
|
|
3081
3116
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
3082
3117
|
await e.updateTable("email_providers").set({
|
|
@@ -3089,7 +3124,7 @@ function ri(e) {
|
|
|
3089
3124
|
}
|
|
3090
3125
|
//#endregion
|
|
3091
3126
|
//#region src/emailProvideres/create.ts
|
|
3092
|
-
function
|
|
3127
|
+
function ai(e) {
|
|
3093
3128
|
return async (t, n, r) => {
|
|
3094
3129
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
3095
3130
|
await e.insertInto("email_providers").values({
|
|
@@ -3105,24 +3140,24 @@ function ii(e) {
|
|
|
3105
3140
|
}
|
|
3106
3141
|
//#endregion
|
|
3107
3142
|
//#region src/emailProvideres/remove.ts
|
|
3108
|
-
function
|
|
3143
|
+
function oi(e) {
|
|
3109
3144
|
return async (t) => {
|
|
3110
3145
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3111
3146
|
};
|
|
3112
3147
|
}
|
|
3113
3148
|
//#endregion
|
|
3114
3149
|
//#region src/emailProvideres/index.ts
|
|
3115
|
-
function
|
|
3150
|
+
function si(e) {
|
|
3116
3151
|
return {
|
|
3117
|
-
get:
|
|
3118
|
-
create:
|
|
3119
|
-
update:
|
|
3120
|
-
remove:
|
|
3152
|
+
get: ri(e),
|
|
3153
|
+
create: ai(e),
|
|
3154
|
+
update: ii(e),
|
|
3155
|
+
remove: oi(e)
|
|
3121
3156
|
};
|
|
3122
3157
|
}
|
|
3123
3158
|
//#endregion
|
|
3124
3159
|
//#region src/emailTemplates/row.ts
|
|
3125
|
-
function
|
|
3160
|
+
function ci(e) {
|
|
3126
3161
|
let t = {
|
|
3127
3162
|
template: e.template,
|
|
3128
3163
|
body: e.body,
|
|
@@ -3136,20 +3171,20 @@ function si(e) {
|
|
|
3136
3171
|
}
|
|
3137
3172
|
//#endregion
|
|
3138
3173
|
//#region src/emailTemplates/get.ts
|
|
3139
|
-
function
|
|
3174
|
+
function li(e) {
|
|
3140
3175
|
return async (t, n) => {
|
|
3141
3176
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3142
|
-
return r ? ie.parse(
|
|
3177
|
+
return r ? ie.parse(ci(r)) : null;
|
|
3143
3178
|
};
|
|
3144
3179
|
}
|
|
3145
3180
|
//#endregion
|
|
3146
3181
|
//#region src/emailTemplates/list.ts
|
|
3147
|
-
function
|
|
3148
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ie.parse(
|
|
3182
|
+
function ui(e) {
|
|
3183
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ie.parse(ci(e)));
|
|
3149
3184
|
}
|
|
3150
3185
|
//#endregion
|
|
3151
3186
|
//#region src/emailTemplates/create.ts
|
|
3152
|
-
function
|
|
3187
|
+
function di(e) {
|
|
3153
3188
|
return async (t, n, r) => {
|
|
3154
3189
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3155
3190
|
return await e.insertInto("email_templates").values({
|
|
@@ -3170,7 +3205,7 @@ function ui(e) {
|
|
|
3170
3205
|
}
|
|
3171
3206
|
//#endregion
|
|
3172
3207
|
//#region src/emailTemplates/update.ts
|
|
3173
|
-
function
|
|
3208
|
+
function fi(e) {
|
|
3174
3209
|
return async (t, n, r) => {
|
|
3175
3210
|
let i = {};
|
|
3176
3211
|
if (r.body !== void 0 && (i.body = r.body), r.from !== void 0 && (i.from = r.from), r.subject !== void 0 && (i.subject = r.subject), r.syntax !== void 0 && (i.syntax = r.syntax), r.resultUrl !== void 0 && (i.result_url = r.resultUrl), r.urlLifetimeInSeconds !== void 0 && (i.url_lifetime_in_seconds = r.urlLifetimeInSeconds), r.includeEmailInRedirect !== void 0 && (i.include_email_in_redirect = +!!r.includeEmailInRedirect), r.enabled !== void 0 && (i.enabled = +!!r.enabled), Object.keys(i).length === 0) return await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).select("template").executeTakeFirst() !== void 0;
|
|
@@ -3181,7 +3216,7 @@ function di(e) {
|
|
|
3181
3216
|
}
|
|
3182
3217
|
//#endregion
|
|
3183
3218
|
//#region src/emailTemplates/remove.ts
|
|
3184
|
-
function
|
|
3219
|
+
function pi(e) {
|
|
3185
3220
|
return async (t, n) => {
|
|
3186
3221
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3187
3222
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3189,13 +3224,13 @@ function fi(e) {
|
|
|
3189
3224
|
}
|
|
3190
3225
|
//#endregion
|
|
3191
3226
|
//#region src/emailTemplates/index.ts
|
|
3192
|
-
function
|
|
3227
|
+
function mi(e) {
|
|
3193
3228
|
return {
|
|
3194
|
-
get:
|
|
3195
|
-
list:
|
|
3196
|
-
create:
|
|
3197
|
-
update:
|
|
3198
|
-
remove:
|
|
3229
|
+
get: li(e),
|
|
3230
|
+
list: ui(e),
|
|
3231
|
+
create: di(e),
|
|
3232
|
+
update: fi(e),
|
|
3233
|
+
remove: pi(e)
|
|
3199
3234
|
};
|
|
3200
3235
|
}
|
|
3201
3236
|
//#endregion
|
|
@@ -3229,7 +3264,7 @@ function R(e) {
|
|
|
3229
3264
|
}
|
|
3230
3265
|
//#endregion
|
|
3231
3266
|
//#region src/refreshTokens/get.ts
|
|
3232
|
-
function
|
|
3267
|
+
function hi(e) {
|
|
3233
3268
|
return async (t, n) => {
|
|
3234
3269
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3235
3270
|
return r ? R(r) : null;
|
|
@@ -3237,7 +3272,7 @@ function mi(e) {
|
|
|
3237
3272
|
}
|
|
3238
3273
|
//#endregion
|
|
3239
3274
|
//#region src/refreshTokens/getByLookup.ts
|
|
3240
|
-
function
|
|
3275
|
+
function gi(e) {
|
|
3241
3276
|
return async (t, n) => {
|
|
3242
3277
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3243
3278
|
return r ? R(r) : null;
|
|
@@ -3245,7 +3280,7 @@ function hi(e) {
|
|
|
3245
3280
|
}
|
|
3246
3281
|
//#endregion
|
|
3247
3282
|
//#region src/refreshTokens/create.ts
|
|
3248
|
-
function
|
|
3283
|
+
function _i(e) {
|
|
3249
3284
|
return async (t, n) => {
|
|
3250
3285
|
let r = c(), i = {
|
|
3251
3286
|
...n,
|
|
@@ -3277,12 +3312,12 @@ function gi(e) {
|
|
|
3277
3312
|
}
|
|
3278
3313
|
//#endregion
|
|
3279
3314
|
//#region src/refreshTokens/remove.ts
|
|
3280
|
-
function
|
|
3315
|
+
function vi(e) {
|
|
3281
3316
|
return async (t, n) => ((await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
3282
3317
|
}
|
|
3283
3318
|
//#endregion
|
|
3284
3319
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3285
|
-
function
|
|
3320
|
+
function yi(e) {
|
|
3286
3321
|
return async (t, n, r) => {
|
|
3287
3322
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("login_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3288
3323
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3290,7 +3325,7 @@ function vi(e) {
|
|
|
3290
3325
|
}
|
|
3291
3326
|
//#endregion
|
|
3292
3327
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3293
|
-
function
|
|
3328
|
+
function bi(e) {
|
|
3294
3329
|
return async (t, n, r) => {
|
|
3295
3330
|
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();
|
|
3296
3331
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3298,7 +3333,7 @@ function yi(e) {
|
|
|
3298
3333
|
}
|
|
3299
3334
|
//#endregion
|
|
3300
3335
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3301
|
-
function
|
|
3336
|
+
function xi(e) {
|
|
3302
3337
|
return async (t, n, r) => {
|
|
3303
3338
|
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();
|
|
3304
3339
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3306,7 +3341,7 @@ function bi(e) {
|
|
|
3306
3341
|
}
|
|
3307
3342
|
//#endregion
|
|
3308
3343
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3309
|
-
function
|
|
3344
|
+
function Si(e) {
|
|
3310
3345
|
return async (t, n, r) => {
|
|
3311
3346
|
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();
|
|
3312
3347
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3314,7 +3349,7 @@ function xi(e) {
|
|
|
3314
3349
|
}
|
|
3315
3350
|
//#endregion
|
|
3316
3351
|
//#region src/refreshTokens/update.ts
|
|
3317
|
-
function
|
|
3352
|
+
function Ci(e) {
|
|
3318
3353
|
return async (t, n, r, i) => {
|
|
3319
3354
|
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 = {
|
|
3320
3355
|
...h,
|
|
@@ -3335,7 +3370,7 @@ function Si(e) {
|
|
|
3335
3370
|
}
|
|
3336
3371
|
//#endregion
|
|
3337
3372
|
//#region src/refreshTokens/list.ts
|
|
3338
|
-
function
|
|
3373
|
+
function wi(e) {
|
|
3339
3374
|
return async (t, n = {}) => {
|
|
3340
3375
|
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);
|
|
3341
3376
|
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = E(e, u, c, ["token", "login_id"])), A(n)) {
|
|
@@ -3375,26 +3410,26 @@ function Ci(e) {
|
|
|
3375
3410
|
}
|
|
3376
3411
|
//#endregion
|
|
3377
3412
|
//#region src/refreshTokens/index.ts
|
|
3378
|
-
function
|
|
3413
|
+
function Ti(e) {
|
|
3379
3414
|
return {
|
|
3380
|
-
create:
|
|
3381
|
-
get:
|
|
3382
|
-
getByLookup:
|
|
3383
|
-
list:
|
|
3384
|
-
remove:
|
|
3385
|
-
revokeByLoginSession:
|
|
3386
|
-
revokeBySession:
|
|
3387
|
-
revokeByUser:
|
|
3388
|
-
revokeFamily:
|
|
3389
|
-
update:
|
|
3415
|
+
create: _i(e),
|
|
3416
|
+
get: hi(e),
|
|
3417
|
+
getByLookup: gi(e),
|
|
3418
|
+
list: wi(e),
|
|
3419
|
+
remove: vi(e),
|
|
3420
|
+
revokeByLoginSession: yi(e),
|
|
3421
|
+
revokeBySession: bi(e),
|
|
3422
|
+
revokeByUser: xi(e),
|
|
3423
|
+
revokeFamily: Si(e),
|
|
3424
|
+
update: Ci(e)
|
|
3390
3425
|
};
|
|
3391
3426
|
}
|
|
3392
3427
|
//#endregion
|
|
3393
3428
|
//#region src/cleanup.ts
|
|
3394
|
-
var
|
|
3395
|
-
function
|
|
3429
|
+
var Ei = 10080 * 60 * 1e3, z = 1e3;
|
|
3430
|
+
function Di(e) {
|
|
3396
3431
|
return async (t) => {
|
|
3397
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3432
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - Ei, a = (t) => async () => {
|
|
3398
3433
|
let a = e.deleteFrom("refresh_tokens").where(t, "<", i);
|
|
3399
3434
|
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3400
3435
|
let o = await a.limit(z).execute();
|
|
@@ -3458,7 +3493,7 @@ function Ei(e) {
|
|
|
3458
3493
|
}
|
|
3459
3494
|
//#endregion
|
|
3460
3495
|
//#region src/forms/create.ts
|
|
3461
|
-
function
|
|
3496
|
+
function Oi(e) {
|
|
3462
3497
|
return async (n, r, i) => {
|
|
3463
3498
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3464
3499
|
id: a?.id ?? t(),
|
|
@@ -3477,7 +3512,7 @@ function Di(e) {
|
|
|
3477
3512
|
}
|
|
3478
3513
|
//#endregion
|
|
3479
3514
|
//#region src/forms/list.ts
|
|
3480
|
-
function
|
|
3515
|
+
function ki(e) {
|
|
3481
3516
|
return async (t, n = {}) => {
|
|
3482
3517
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3483
3518
|
s && (c = E(e, c, s, []));
|
|
@@ -3511,7 +3546,7 @@ function Oi(e) {
|
|
|
3511
3546
|
}
|
|
3512
3547
|
//#endregion
|
|
3513
3548
|
//#region src/forms/remove.ts
|
|
3514
|
-
function
|
|
3549
|
+
function Ai(e) {
|
|
3515
3550
|
return async (t, n) => {
|
|
3516
3551
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3517
3552
|
return r > 0;
|
|
@@ -3519,7 +3554,7 @@ function ki(e) {
|
|
|
3519
3554
|
}
|
|
3520
3555
|
//#endregion
|
|
3521
3556
|
//#region src/forms/get.ts
|
|
3522
|
-
function
|
|
3557
|
+
function ji(e) {
|
|
3523
3558
|
return async (t, n) => {
|
|
3524
3559
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3525
3560
|
if (!r) return null;
|
|
@@ -3538,7 +3573,7 @@ function Ai(e) {
|
|
|
3538
3573
|
}
|
|
3539
3574
|
//#endregion
|
|
3540
3575
|
//#region src/forms/update.ts
|
|
3541
|
-
function
|
|
3576
|
+
function Mi(e) {
|
|
3542
3577
|
return async (t, n, r) => {
|
|
3543
3578
|
let i = {
|
|
3544
3579
|
...r,
|
|
@@ -3555,18 +3590,18 @@ function ji(e) {
|
|
|
3555
3590
|
}
|
|
3556
3591
|
//#endregion
|
|
3557
3592
|
//#region src/forms/index.ts
|
|
3558
|
-
function
|
|
3593
|
+
function Ni(e) {
|
|
3559
3594
|
return {
|
|
3560
|
-
create:
|
|
3561
|
-
get:
|
|
3562
|
-
list:
|
|
3563
|
-
remove:
|
|
3564
|
-
update:
|
|
3595
|
+
create: Oi(e),
|
|
3596
|
+
get: ji(e),
|
|
3597
|
+
list: ki(e),
|
|
3598
|
+
remove: Ai(e),
|
|
3599
|
+
update: Mi(e)
|
|
3565
3600
|
};
|
|
3566
3601
|
}
|
|
3567
3602
|
//#endregion
|
|
3568
3603
|
//#region src/resourceServers/create.ts
|
|
3569
|
-
function
|
|
3604
|
+
function Pi(e) {
|
|
3570
3605
|
return async (t, n, r) => {
|
|
3571
3606
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3572
3607
|
...n,
|
|
@@ -3591,7 +3626,7 @@ function Ni(e) {
|
|
|
3591
3626
|
}
|
|
3592
3627
|
//#endregion
|
|
3593
3628
|
//#region src/resourceServers/get.ts
|
|
3594
|
-
function
|
|
3629
|
+
function Fi(e) {
|
|
3595
3630
|
return async (t, n) => {
|
|
3596
3631
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3597
3632
|
if (!r) return null;
|
|
@@ -3610,7 +3645,7 @@ function Pi(e) {
|
|
|
3610
3645
|
}
|
|
3611
3646
|
//#endregion
|
|
3612
3647
|
//#region src/resourceServers/list.ts
|
|
3613
|
-
function
|
|
3648
|
+
function Ii(e) {
|
|
3614
3649
|
let { verification_key: t, scopes: n, options: r, skip_consent_for_verifiable_first_party_clients: i, allow_offline_access: a, is_system: o, metadata: s, ...c } = e, u = l({
|
|
3615
3650
|
...c,
|
|
3616
3651
|
scopes: n ? JSON.parse(n) : [],
|
|
@@ -3623,7 +3658,7 @@ function Fi(e) {
|
|
|
3623
3658
|
});
|
|
3624
3659
|
return u.token_lifetime ??= 86400, u.token_lifetime_for_web ??= 7200, u;
|
|
3625
3660
|
}
|
|
3626
|
-
function
|
|
3661
|
+
function Li(e) {
|
|
3627
3662
|
return async (t, n = {}) => {
|
|
3628
3663
|
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);
|
|
3629
3664
|
if (s) {
|
|
@@ -3638,7 +3673,7 @@ function Ii(e) {
|
|
|
3638
3673
|
sortColumn: "created_at",
|
|
3639
3674
|
sortOrder: "desc",
|
|
3640
3675
|
idColumn: "id"
|
|
3641
|
-
}), i = e.map(
|
|
3676
|
+
}), i = e.map(Ii);
|
|
3642
3677
|
return {
|
|
3643
3678
|
resource_servers: i,
|
|
3644
3679
|
start: 0,
|
|
@@ -3647,7 +3682,7 @@ function Ii(e) {
|
|
|
3647
3682
|
next: r
|
|
3648
3683
|
};
|
|
3649
3684
|
}
|
|
3650
|
-
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(
|
|
3685
|
+
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(Ii);
|
|
3651
3686
|
if (!a) return {
|
|
3652
3687
|
resource_servers: l,
|
|
3653
3688
|
start: 0,
|
|
@@ -3665,7 +3700,7 @@ function Ii(e) {
|
|
|
3665
3700
|
}
|
|
3666
3701
|
//#endregion
|
|
3667
3702
|
//#region src/resourceServers/remove.ts
|
|
3668
|
-
function
|
|
3703
|
+
function Ri(e) {
|
|
3669
3704
|
return async (t, n) => {
|
|
3670
3705
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3671
3706
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3673,7 +3708,7 @@ function Li(e) {
|
|
|
3673
3708
|
}
|
|
3674
3709
|
//#endregion
|
|
3675
3710
|
//#region src/resourceServers/update.ts
|
|
3676
|
-
function
|
|
3711
|
+
function zi(e) {
|
|
3677
3712
|
return async (t, n, r) => {
|
|
3678
3713
|
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 = {
|
|
3679
3714
|
...d,
|
|
@@ -3693,18 +3728,18 @@ function Ri(e) {
|
|
|
3693
3728
|
}
|
|
3694
3729
|
//#endregion
|
|
3695
3730
|
//#region src/resourceServers/index.ts
|
|
3696
|
-
function
|
|
3731
|
+
function Bi(e) {
|
|
3697
3732
|
return {
|
|
3698
|
-
create:
|
|
3699
|
-
get:
|
|
3700
|
-
list:
|
|
3701
|
-
remove:
|
|
3702
|
-
update:
|
|
3733
|
+
create: Pi(e),
|
|
3734
|
+
get: Fi(e),
|
|
3735
|
+
list: Li(e),
|
|
3736
|
+
remove: Ri(e),
|
|
3737
|
+
update: zi(e)
|
|
3703
3738
|
};
|
|
3704
3739
|
}
|
|
3705
3740
|
//#endregion
|
|
3706
3741
|
//#region src/roles/create.ts
|
|
3707
|
-
function
|
|
3742
|
+
function Vi(e) {
|
|
3708
3743
|
return async (n, r, i) => {
|
|
3709
3744
|
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 = {
|
|
3710
3745
|
id: l,
|
|
@@ -3727,7 +3762,7 @@ function Bi(e) {
|
|
|
3727
3762
|
}
|
|
3728
3763
|
//#endregion
|
|
3729
3764
|
//#region src/roles/get.ts
|
|
3730
|
-
function
|
|
3765
|
+
function Hi(e) {
|
|
3731
3766
|
return async (t, n) => {
|
|
3732
3767
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3733
3768
|
if (!r) return null;
|
|
@@ -3741,7 +3776,7 @@ function Vi(e) {
|
|
|
3741
3776
|
}
|
|
3742
3777
|
//#endregion
|
|
3743
3778
|
//#region src/roles/list.ts
|
|
3744
|
-
function
|
|
3779
|
+
function Ui(e) {
|
|
3745
3780
|
return async (t, n = {}) => {
|
|
3746
3781
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3747
3782
|
if (n.q && (r = E(e, r, n.q, ["name"])), A(n)) {
|
|
@@ -3749,7 +3784,7 @@ function Hi(e) {
|
|
|
3749
3784
|
sortColumn: "created_at",
|
|
3750
3785
|
sortOrder: "desc",
|
|
3751
3786
|
idColumn: "id"
|
|
3752
|
-
}), a = e.map(
|
|
3787
|
+
}), a = e.map(Wi);
|
|
3753
3788
|
return {
|
|
3754
3789
|
roles: a,
|
|
3755
3790
|
start: 0,
|
|
@@ -3758,7 +3793,7 @@ function Hi(e) {
|
|
|
3758
3793
|
next: i
|
|
3759
3794
|
};
|
|
3760
3795
|
}
|
|
3761
|
-
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map(
|
|
3796
|
+
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map(Wi);
|
|
3762
3797
|
if (!s) return {
|
|
3763
3798
|
roles: c,
|
|
3764
3799
|
start: i * a,
|
|
@@ -3774,7 +3809,7 @@ function Hi(e) {
|
|
|
3774
3809
|
};
|
|
3775
3810
|
};
|
|
3776
3811
|
}
|
|
3777
|
-
function
|
|
3812
|
+
function Wi(e) {
|
|
3778
3813
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3779
3814
|
return {
|
|
3780
3815
|
...i,
|
|
@@ -3784,7 +3819,7 @@ function Ui(e) {
|
|
|
3784
3819
|
}
|
|
3785
3820
|
//#endregion
|
|
3786
3821
|
//#region src/roles/update.ts
|
|
3787
|
-
function
|
|
3822
|
+
function Gi(e) {
|
|
3788
3823
|
return async (t, n, r) => {
|
|
3789
3824
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3790
3825
|
...o,
|
|
@@ -3797,7 +3832,7 @@ function Wi(e) {
|
|
|
3797
3832
|
}
|
|
3798
3833
|
//#endregion
|
|
3799
3834
|
//#region src/roles/remove.ts
|
|
3800
|
-
function
|
|
3835
|
+
function Ki(e) {
|
|
3801
3836
|
return async (t, n) => {
|
|
3802
3837
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3803
3838
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3805,23 +3840,23 @@ function Gi(e) {
|
|
|
3805
3840
|
}
|
|
3806
3841
|
//#endregion
|
|
3807
3842
|
//#region src/roles/index.ts
|
|
3808
|
-
function
|
|
3843
|
+
function qi(e) {
|
|
3809
3844
|
return {
|
|
3810
|
-
create:
|
|
3811
|
-
get:
|
|
3812
|
-
list:
|
|
3813
|
-
update:
|
|
3814
|
-
remove:
|
|
3845
|
+
create: Vi(e),
|
|
3846
|
+
get: Hi(e),
|
|
3847
|
+
list: Ui(e),
|
|
3848
|
+
update: Gi(e),
|
|
3849
|
+
remove: Ki(e)
|
|
3815
3850
|
};
|
|
3816
3851
|
}
|
|
3817
3852
|
//#endregion
|
|
3818
3853
|
//#region src/role-permissions/assign.ts
|
|
3819
|
-
function
|
|
3854
|
+
function Ji(e) {
|
|
3820
3855
|
if (typeof e != "object" || !e) return !1;
|
|
3821
3856
|
let { code: t, message: n } = e;
|
|
3822
3857
|
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"));
|
|
3823
3858
|
}
|
|
3824
|
-
function
|
|
3859
|
+
function Yi(e) {
|
|
3825
3860
|
return async (t, n, r, i) => {
|
|
3826
3861
|
if (r.length === 0) return !0;
|
|
3827
3862
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3838,7 +3873,7 @@ function Ji(e) {
|
|
|
3838
3873
|
try {
|
|
3839
3874
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3840
3875
|
} catch (e) {
|
|
3841
|
-
if (
|
|
3876
|
+
if (Ji(e)) continue;
|
|
3842
3877
|
throw e;
|
|
3843
3878
|
}
|
|
3844
3879
|
}
|
|
@@ -3850,7 +3885,7 @@ function Ji(e) {
|
|
|
3850
3885
|
}
|
|
3851
3886
|
//#endregion
|
|
3852
3887
|
//#region src/role-permissions/remove.ts
|
|
3853
|
-
function
|
|
3888
|
+
function Xi(e) {
|
|
3854
3889
|
return async (t, n, r) => {
|
|
3855
3890
|
if (r.length === 0) return !0;
|
|
3856
3891
|
try {
|
|
@@ -3862,13 +3897,13 @@ function Yi(e) {
|
|
|
3862
3897
|
}
|
|
3863
3898
|
//#endregion
|
|
3864
3899
|
//#region src/role-permissions/list.ts
|
|
3865
|
-
function
|
|
3900
|
+
function Zi(e) {
|
|
3866
3901
|
return async (t, n, r = {}) => {
|
|
3867
|
-
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s =
|
|
3902
|
+
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s = Qi(e, t, n), c = (await s.offset(i * a).limit(a).execute()).map($i);
|
|
3868
3903
|
return o && await s.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), c;
|
|
3869
3904
|
};
|
|
3870
3905
|
}
|
|
3871
|
-
function
|
|
3906
|
+
function Qi(e, t, n) {
|
|
3872
3907
|
return 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([
|
|
3873
3908
|
"role_permissions.role_id",
|
|
3874
3909
|
"role_permissions.resource_server_identifier",
|
|
@@ -3877,7 +3912,7 @@ function Zi(e, t, n) {
|
|
|
3877
3912
|
"resource_servers.name as resource_server_name"
|
|
3878
3913
|
]).where("role_permissions.tenant_id", "=", t).where("role_permissions.role_id", "=", n);
|
|
3879
3914
|
}
|
|
3880
|
-
function
|
|
3915
|
+
function $i(e) {
|
|
3881
3916
|
return {
|
|
3882
3917
|
role_id: e.role_id,
|
|
3883
3918
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3887,32 +3922,32 @@ function Qi(e) {
|
|
|
3887
3922
|
created_at: e.created_at
|
|
3888
3923
|
};
|
|
3889
3924
|
}
|
|
3890
|
-
function
|
|
3925
|
+
function ea(e) {
|
|
3891
3926
|
return async (t, n, r = {}) => {
|
|
3892
|
-
let { rows: i, next: a } = await j(
|
|
3927
|
+
let { rows: i, next: a } = await j(Qi(e, t, n), r, {
|
|
3893
3928
|
sortColumn: "role_permissions.resource_server_identifier",
|
|
3894
3929
|
idColumn: "role_permissions.permission_name",
|
|
3895
3930
|
sortOrder: "asc"
|
|
3896
3931
|
});
|
|
3897
3932
|
return {
|
|
3898
|
-
permissions: i.map(
|
|
3933
|
+
permissions: i.map($i),
|
|
3899
3934
|
next: a
|
|
3900
3935
|
};
|
|
3901
3936
|
};
|
|
3902
3937
|
}
|
|
3903
3938
|
//#endregion
|
|
3904
3939
|
//#region src/role-permissions/index.ts
|
|
3905
|
-
function
|
|
3940
|
+
function ta(e) {
|
|
3906
3941
|
return {
|
|
3907
|
-
assign:
|
|
3908
|
-
remove:
|
|
3909
|
-
list:
|
|
3910
|
-
listCheckpoint:
|
|
3942
|
+
assign: Yi(e),
|
|
3943
|
+
remove: Xi(e),
|
|
3944
|
+
list: Zi(e),
|
|
3945
|
+
listCheckpoint: ea(e)
|
|
3911
3946
|
};
|
|
3912
3947
|
}
|
|
3913
3948
|
//#endregion
|
|
3914
3949
|
//#region src/grants/create.ts
|
|
3915
|
-
function
|
|
3950
|
+
function na(e) {
|
|
3916
3951
|
return async (n, r) => {
|
|
3917
3952
|
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();
|
|
3918
3953
|
if (s) {
|
|
@@ -3949,7 +3984,7 @@ function ta(e) {
|
|
|
3949
3984
|
}
|
|
3950
3985
|
//#endregion
|
|
3951
3986
|
//#region src/grants/get.ts
|
|
3952
|
-
function
|
|
3987
|
+
function ra(e) {
|
|
3953
3988
|
return async (t, n, r, i) => {
|
|
3954
3989
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3955
3990
|
return a ? {
|
|
@@ -3963,7 +3998,7 @@ function na(e) {
|
|
|
3963
3998
|
}
|
|
3964
3999
|
//#endregion
|
|
3965
4000
|
//#region src/grants/list.ts
|
|
3966
|
-
function
|
|
4001
|
+
function ia(e) {
|
|
3967
4002
|
return async (t, n = {}) => {
|
|
3968
4003
|
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);
|
|
3969
4004
|
c && (l = E(e, l, c, [
|
|
@@ -4001,26 +4036,26 @@ function ra(e) {
|
|
|
4001
4036
|
}
|
|
4002
4037
|
//#endregion
|
|
4003
4038
|
//#region src/grants/remove.ts
|
|
4004
|
-
function
|
|
4039
|
+
function aa(e) {
|
|
4005
4040
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4006
4041
|
}
|
|
4007
|
-
function
|
|
4042
|
+
function oa(e) {
|
|
4008
4043
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4009
4044
|
}
|
|
4010
4045
|
//#endregion
|
|
4011
4046
|
//#region src/grants/index.ts
|
|
4012
|
-
function
|
|
4047
|
+
function sa(e) {
|
|
4013
4048
|
return {
|
|
4014
|
-
create:
|
|
4015
|
-
get:
|
|
4016
|
-
list:
|
|
4017
|
-
remove:
|
|
4018
|
-
removeByUser:
|
|
4049
|
+
create: na(e),
|
|
4050
|
+
get: ra(e),
|
|
4051
|
+
list: ia(e),
|
|
4052
|
+
remove: aa(e),
|
|
4053
|
+
removeByUser: oa(e)
|
|
4019
4054
|
};
|
|
4020
4055
|
}
|
|
4021
4056
|
//#endregion
|
|
4022
4057
|
//#region src/user-permissions/create.ts
|
|
4023
|
-
function
|
|
4058
|
+
function ca(e) {
|
|
4024
4059
|
return async (t, n, r, i, a) => {
|
|
4025
4060
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
4026
4061
|
try {
|
|
@@ -4040,7 +4075,7 @@ function sa(e) {
|
|
|
4040
4075
|
}
|
|
4041
4076
|
//#endregion
|
|
4042
4077
|
//#region src/user-permissions/remove.ts
|
|
4043
|
-
function
|
|
4078
|
+
function la(e) {
|
|
4044
4079
|
return async (t, n, r, i) => {
|
|
4045
4080
|
try {
|
|
4046
4081
|
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);
|
|
@@ -4052,7 +4087,7 @@ function ca(e) {
|
|
|
4052
4087
|
}
|
|
4053
4088
|
//#endregion
|
|
4054
4089
|
//#region src/user-permissions/list.ts
|
|
4055
|
-
function
|
|
4090
|
+
function ua(e) {
|
|
4056
4091
|
return async (t, n, r, i) => {
|
|
4057
4092
|
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([
|
|
4058
4093
|
"user_permissions.resource_server_identifier",
|
|
@@ -4075,17 +4110,17 @@ function la(e) {
|
|
|
4075
4110
|
}
|
|
4076
4111
|
//#endregion
|
|
4077
4112
|
//#region src/user-permissions/index.ts
|
|
4078
|
-
function
|
|
4113
|
+
function da(e) {
|
|
4079
4114
|
return {
|
|
4080
|
-
create:
|
|
4081
|
-
remove:
|
|
4082
|
-
list:
|
|
4115
|
+
create: ca(e),
|
|
4116
|
+
remove: la(e),
|
|
4117
|
+
list: ua(e)
|
|
4083
4118
|
};
|
|
4084
4119
|
}
|
|
4085
4120
|
//#endregion
|
|
4086
4121
|
//#region src/user-permissions/adapter.ts
|
|
4087
|
-
function
|
|
4088
|
-
let t =
|
|
4122
|
+
function fa(e) {
|
|
4123
|
+
let t = da(e);
|
|
4089
4124
|
return {
|
|
4090
4125
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
4091
4126
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -4094,7 +4129,7 @@ function da(e) {
|
|
|
4094
4129
|
}
|
|
4095
4130
|
//#endregion
|
|
4096
4131
|
//#region src/user-roles/list.ts
|
|
4097
|
-
function
|
|
4132
|
+
function pa(e) {
|
|
4098
4133
|
return async (t, n, r, i) => {
|
|
4099
4134
|
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([
|
|
4100
4135
|
"r.id",
|
|
@@ -4108,7 +4143,7 @@ function fa(e) {
|
|
|
4108
4143
|
}
|
|
4109
4144
|
//#endregion
|
|
4110
4145
|
//#region src/user-roles/list-users.ts
|
|
4111
|
-
function
|
|
4146
|
+
function ma(e) {
|
|
4112
4147
|
return async (t, n, r) => {
|
|
4113
4148
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
4114
4149
|
if (A(r)) {
|
|
@@ -4136,7 +4171,7 @@ function pa(e) {
|
|
|
4136
4171
|
}
|
|
4137
4172
|
//#endregion
|
|
4138
4173
|
//#region src/user-roles/create.ts
|
|
4139
|
-
function
|
|
4174
|
+
function ha(e) {
|
|
4140
4175
|
return async (t, n, r, i, a) => {
|
|
4141
4176
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
4142
4177
|
try {
|
|
@@ -4154,7 +4189,7 @@ function ma(e) {
|
|
|
4154
4189
|
}
|
|
4155
4190
|
//#endregion
|
|
4156
4191
|
//#region src/user-roles/remove.ts
|
|
4157
|
-
function
|
|
4192
|
+
function ga(e) {
|
|
4158
4193
|
return async (t, n, r, i) => {
|
|
4159
4194
|
try {
|
|
4160
4195
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -4166,18 +4201,18 @@ function ha(e) {
|
|
|
4166
4201
|
}
|
|
4167
4202
|
//#endregion
|
|
4168
4203
|
//#region src/user-roles/index.ts
|
|
4169
|
-
function
|
|
4204
|
+
function _a(e) {
|
|
4170
4205
|
return {
|
|
4171
|
-
list:
|
|
4172
|
-
listUsers:
|
|
4173
|
-
create:
|
|
4174
|
-
remove:
|
|
4206
|
+
list: pa(e),
|
|
4207
|
+
listUsers: ma(e),
|
|
4208
|
+
create: ha(e),
|
|
4209
|
+
remove: ga(e)
|
|
4175
4210
|
};
|
|
4176
4211
|
}
|
|
4177
4212
|
//#endregion
|
|
4178
4213
|
//#region src/user-roles/adapter.ts
|
|
4179
|
-
function
|
|
4180
|
-
let t =
|
|
4214
|
+
function va(e) {
|
|
4215
|
+
let t = _a(e);
|
|
4181
4216
|
return {
|
|
4182
4217
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
4183
4218
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4187,7 +4222,7 @@ function _a(e) {
|
|
|
4187
4222
|
}
|
|
4188
4223
|
//#endregion
|
|
4189
4224
|
//#region src/organizations/create.ts
|
|
4190
|
-
function
|
|
4225
|
+
function ya(e) {
|
|
4191
4226
|
return async (t, n, r) => {
|
|
4192
4227
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4193
4228
|
...n,
|
|
@@ -4215,7 +4250,7 @@ function va(e) {
|
|
|
4215
4250
|
}
|
|
4216
4251
|
//#endregion
|
|
4217
4252
|
//#region src/organizations/get.ts
|
|
4218
|
-
function
|
|
4253
|
+
function ba(e) {
|
|
4219
4254
|
return async (t, n) => {
|
|
4220
4255
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4221
4256
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4230,7 +4265,7 @@ function ya(e) {
|
|
|
4230
4265
|
//#endregion
|
|
4231
4266
|
//#region src/organizations/list.ts
|
|
4232
4267
|
var B = ["name", "display_name"];
|
|
4233
|
-
function
|
|
4268
|
+
function xa(e) {
|
|
4234
4269
|
return async (t, n) => {
|
|
4235
4270
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4236
4271
|
if (n?.q) {
|
|
@@ -4295,7 +4330,7 @@ function ba(e) {
|
|
|
4295
4330
|
}
|
|
4296
4331
|
//#endregion
|
|
4297
4332
|
//#region src/organizations/remove.ts
|
|
4298
|
-
function
|
|
4333
|
+
function Sa(e) {
|
|
4299
4334
|
return async (t, n) => {
|
|
4300
4335
|
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4301
4336
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -4303,7 +4338,7 @@ function xa(e) {
|
|
|
4303
4338
|
}
|
|
4304
4339
|
//#endregion
|
|
4305
4340
|
//#region src/organizations/update.ts
|
|
4306
|
-
function
|
|
4341
|
+
function Ca(e) {
|
|
4307
4342
|
return async (t, n, r) => {
|
|
4308
4343
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4309
4344
|
...c,
|
|
@@ -4319,13 +4354,13 @@ function Sa(e) {
|
|
|
4319
4354
|
}
|
|
4320
4355
|
//#endregion
|
|
4321
4356
|
//#region src/organizations/index.ts
|
|
4322
|
-
function
|
|
4357
|
+
function wa(e) {
|
|
4323
4358
|
return {
|
|
4324
|
-
create:
|
|
4325
|
-
get:
|
|
4326
|
-
list:
|
|
4327
|
-
remove:
|
|
4328
|
-
update:
|
|
4359
|
+
create: ya(e),
|
|
4360
|
+
get: ba(e),
|
|
4361
|
+
list: xa(e),
|
|
4362
|
+
remove: Sa(e),
|
|
4363
|
+
update: Ca(e)
|
|
4329
4364
|
};
|
|
4330
4365
|
}
|
|
4331
4366
|
//#endregion
|
|
@@ -4351,7 +4386,7 @@ async function H(e, t, n) {
|
|
|
4351
4386
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4352
4387
|
};
|
|
4353
4388
|
}
|
|
4354
|
-
function
|
|
4389
|
+
function Ta(e) {
|
|
4355
4390
|
return {
|
|
4356
4391
|
async create(t, n, r, i) {
|
|
4357
4392
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4394,7 +4429,7 @@ function wa(e) {
|
|
|
4394
4429
|
}
|
|
4395
4430
|
//#endregion
|
|
4396
4431
|
//#region src/user-organizations/create.ts
|
|
4397
|
-
function
|
|
4432
|
+
function Ea(e) {
|
|
4398
4433
|
return async (n, r, i) => {
|
|
4399
4434
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4400
4435
|
id: a?.id ?? t(),
|
|
@@ -4414,7 +4449,7 @@ function Ta(e) {
|
|
|
4414
4449
|
}
|
|
4415
4450
|
//#endregion
|
|
4416
4451
|
//#region src/user-organizations/get.ts
|
|
4417
|
-
function
|
|
4452
|
+
function Da(e) {
|
|
4418
4453
|
return async (t, n) => {
|
|
4419
4454
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4420
4455
|
return r ? {
|
|
@@ -4431,7 +4466,7 @@ function Ea(e) {
|
|
|
4431
4466
|
function U(e, t) {
|
|
4432
4467
|
return Oe(e.slice(t.length + 1));
|
|
4433
4468
|
}
|
|
4434
|
-
function
|
|
4469
|
+
function Oa(e) {
|
|
4435
4470
|
return async (t, n) => {
|
|
4436
4471
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4437
4472
|
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", U(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", U(n.q, "organization_id"))));
|
|
@@ -4468,7 +4503,7 @@ function Da(e) {
|
|
|
4468
4503
|
}
|
|
4469
4504
|
//#endregion
|
|
4470
4505
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4471
|
-
function
|
|
4506
|
+
function ka(e) {
|
|
4472
4507
|
return async (t, n, r) => {
|
|
4473
4508
|
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([
|
|
4474
4509
|
"organizations.id",
|
|
@@ -4505,12 +4540,12 @@ function Oa(e) {
|
|
|
4505
4540
|
}
|
|
4506
4541
|
//#endregion
|
|
4507
4542
|
//#region src/user-organizations/remove.ts
|
|
4508
|
-
function
|
|
4543
|
+
function Aa(e) {
|
|
4509
4544
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4510
4545
|
}
|
|
4511
4546
|
//#endregion
|
|
4512
4547
|
//#region src/user-organizations/update.ts
|
|
4513
|
-
function
|
|
4548
|
+
function ja(e) {
|
|
4514
4549
|
return async (t, n, r) => {
|
|
4515
4550
|
let i = {
|
|
4516
4551
|
...r,
|
|
@@ -4521,19 +4556,19 @@ function Aa(e) {
|
|
|
4521
4556
|
}
|
|
4522
4557
|
//#endregion
|
|
4523
4558
|
//#region src/user-organizations/index.ts
|
|
4524
|
-
function
|
|
4559
|
+
function Ma(e) {
|
|
4525
4560
|
return {
|
|
4526
|
-
create:
|
|
4527
|
-
get:
|
|
4528
|
-
list:
|
|
4529
|
-
listUserOrganizations:
|
|
4530
|
-
remove:
|
|
4531
|
-
update:
|
|
4561
|
+
create: Ea(e),
|
|
4562
|
+
get: Da(e),
|
|
4563
|
+
list: Oa(e),
|
|
4564
|
+
listUserOrganizations: ka(e),
|
|
4565
|
+
remove: Aa(e),
|
|
4566
|
+
update: ja(e)
|
|
4532
4567
|
};
|
|
4533
4568
|
}
|
|
4534
4569
|
//#endregion
|
|
4535
4570
|
//#region src/invites/create.ts
|
|
4536
|
-
function
|
|
4571
|
+
function Na(e) {
|
|
4537
4572
|
return async (t, n, r) => {
|
|
4538
4573
|
let i = r?.importMetadata, a = i?.id ?? n.id ?? Be(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4539
4574
|
id: a,
|
|
@@ -4579,7 +4614,7 @@ function Ma(e) {
|
|
|
4579
4614
|
}
|
|
4580
4615
|
//#endregion
|
|
4581
4616
|
//#region src/invites/get.ts
|
|
4582
|
-
function
|
|
4617
|
+
function Pa(e) {
|
|
4583
4618
|
return async (t, n) => {
|
|
4584
4619
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4585
4620
|
return r ? l({
|
|
@@ -4596,7 +4631,7 @@ function Na(e) {
|
|
|
4596
4631
|
}
|
|
4597
4632
|
//#endregion
|
|
4598
4633
|
//#region src/invites/list.ts
|
|
4599
|
-
function
|
|
4634
|
+
function Fa(e) {
|
|
4600
4635
|
return async (t, n) => {
|
|
4601
4636
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4602
4637
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4623,12 +4658,12 @@ function Pa(e) {
|
|
|
4623
4658
|
}
|
|
4624
4659
|
//#endregion
|
|
4625
4660
|
//#region src/invites/remove.ts
|
|
4626
|
-
function
|
|
4661
|
+
function Ia(e) {
|
|
4627
4662
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4628
4663
|
}
|
|
4629
4664
|
//#endregion
|
|
4630
4665
|
//#region src/invites/update.ts
|
|
4631
|
-
function
|
|
4666
|
+
function La(e) {
|
|
4632
4667
|
return async (t, n, r) => {
|
|
4633
4668
|
let i = {};
|
|
4634
4669
|
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;
|
|
@@ -4636,35 +4671,35 @@ function Ia(e) {
|
|
|
4636
4671
|
}
|
|
4637
4672
|
//#endregion
|
|
4638
4673
|
//#region src/invites/index.ts
|
|
4639
|
-
function
|
|
4674
|
+
function Ra(e) {
|
|
4640
4675
|
return {
|
|
4641
|
-
create:
|
|
4642
|
-
get:
|
|
4643
|
-
list:
|
|
4644
|
-
remove:
|
|
4645
|
-
update:
|
|
4676
|
+
create: Na(e),
|
|
4677
|
+
get: Pa(e),
|
|
4678
|
+
list: Fa(e),
|
|
4679
|
+
remove: Ia(e),
|
|
4680
|
+
update: La(e)
|
|
4646
4681
|
};
|
|
4647
4682
|
}
|
|
4648
4683
|
//#endregion
|
|
4649
4684
|
//#region src/stats/index.ts
|
|
4650
|
-
var
|
|
4651
|
-
function
|
|
4685
|
+
var za = ["s"], Ba = ["pwd_leak"];
|
|
4686
|
+
function Va(e) {
|
|
4652
4687
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4653
4688
|
}
|
|
4654
|
-
function
|
|
4689
|
+
function Ha(e) {
|
|
4655
4690
|
return e.toISOString().split("T")[0];
|
|
4656
4691
|
}
|
|
4657
|
-
function
|
|
4692
|
+
function Ua(e) {
|
|
4658
4693
|
return {
|
|
4659
4694
|
async getDaily(t, n = {}) {
|
|
4660
4695
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4661
4696
|
o.setDate(o.getDate() - 30);
|
|
4662
|
-
let s = r ?
|
|
4697
|
+
let s = r ? Va(r) : Ha(o), c = i ? Va(i) : Ha(a), l = p`DATE(logs.date)`;
|
|
4663
4698
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4664
4699
|
l.as("date"),
|
|
4665
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4700
|
+
e.fn.sum(e.case().when("type", "in", za).then(1).else(0).end()).as("logins"),
|
|
4666
4701
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4667
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4702
|
+
e.fn.sum(e.case().when("type", "in", Ba).then(1).else(0).end()).as("leaked_passwords"),
|
|
4668
4703
|
e.fn.min("date").as("first_event"),
|
|
4669
4704
|
e.fn.max("date").as("last_event")
|
|
4670
4705
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4678,13 +4713,13 @@ function Ha(e) {
|
|
|
4678
4713
|
},
|
|
4679
4714
|
async getActiveUsers(t) {
|
|
4680
4715
|
let n = /* @__PURE__ */ new Date();
|
|
4681
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4716
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", za).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4682
4717
|
}
|
|
4683
4718
|
};
|
|
4684
4719
|
}
|
|
4685
4720
|
//#endregion
|
|
4686
4721
|
//#region src/analytics/index.ts
|
|
4687
|
-
var
|
|
4722
|
+
var Wa = {
|
|
4688
4723
|
"active-users": ["s", "seacft"],
|
|
4689
4724
|
logins: [
|
|
4690
4725
|
"s",
|
|
@@ -4714,7 +4749,7 @@ var Ua = {
|
|
|
4714
4749
|
"fvr"
|
|
4715
4750
|
],
|
|
4716
4751
|
"codes-sent": ["cls", "cs"]
|
|
4717
|
-
},
|
|
4752
|
+
}, Ga = {
|
|
4718
4753
|
"active-users": {
|
|
4719
4754
|
alias: "active_users",
|
|
4720
4755
|
type: "UInt64",
|
|
@@ -4771,7 +4806,7 @@ var Ua = {
|
|
|
4771
4806
|
agg: "count"
|
|
4772
4807
|
}
|
|
4773
4808
|
};
|
|
4774
|
-
async function
|
|
4809
|
+
async function Ka(e) {
|
|
4775
4810
|
try {
|
|
4776
4811
|
return await p`SELECT @@version_comment`.execute(e), "mysql";
|
|
4777
4812
|
} catch {
|
|
@@ -4793,7 +4828,7 @@ function W(e, t) {
|
|
|
4793
4828
|
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);
|
|
4794
4829
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4795
4830
|
}
|
|
4796
|
-
var
|
|
4831
|
+
var qa = [
|
|
4797
4832
|
"January",
|
|
4798
4833
|
"February",
|
|
4799
4834
|
"March",
|
|
@@ -4807,22 +4842,22 @@ var Ka = [
|
|
|
4807
4842
|
"November",
|
|
4808
4843
|
"December"
|
|
4809
4844
|
];
|
|
4810
|
-
function
|
|
4845
|
+
function Ja(e, t) {
|
|
4811
4846
|
let n = t.getUTCFullYear(), r = W(e, new Date(Date.UTC(n, 0, 1)));
|
|
4812
4847
|
for (let t = 1; t < 12; t++) {
|
|
4813
4848
|
let i = W(e, new Date(Date.UTC(n, t, 1)));
|
|
4814
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4849
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${qa[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').`);
|
|
4815
4850
|
}
|
|
4816
4851
|
}
|
|
4817
|
-
function
|
|
4852
|
+
function Ya(e) {
|
|
4818
4853
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4819
4854
|
return t * (Number(n) * 60 + Number(r));
|
|
4820
4855
|
}
|
|
4821
|
-
function
|
|
4856
|
+
function Xa(e, t) {
|
|
4822
4857
|
let n;
|
|
4823
4858
|
if (t === "+00:00") n = p`${p.ref("logs.date")}`;
|
|
4824
4859
|
else {
|
|
4825
|
-
let e =
|
|
4860
|
+
let e = Ya(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4826
4861
|
n = p`datetime(${p.ref("logs.date")}, ${r})`;
|
|
4827
4862
|
}
|
|
4828
4863
|
switch (e) {
|
|
@@ -4833,7 +4868,7 @@ function Ya(e, t) {
|
|
|
4833
4868
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4834
4869
|
}
|
|
4835
4870
|
}
|
|
4836
|
-
function
|
|
4871
|
+
function Za(e, t) {
|
|
4837
4872
|
if (t === "+00:00") switch (e) {
|
|
4838
4873
|
case "hour": return p`substring(${p.ref("logs.date")}, 1, 13)`;
|
|
4839
4874
|
case "day": return p`substring(${p.ref("logs.date")}, 1, 10)`;
|
|
@@ -4844,7 +4879,7 @@ function Xa(e, t) {
|
|
|
4844
4879
|
}
|
|
4845
4880
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4846
4881
|
}
|
|
4847
|
-
let n =
|
|
4882
|
+
let n = Ya(t), r = p`date_add(str_to_date(substring(${p.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${p.lit(n)} minute)`;
|
|
4848
4883
|
switch (e) {
|
|
4849
4884
|
case "hour": return p`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4850
4885
|
case "day": return p`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4853,12 +4888,12 @@ function Xa(e, t) {
|
|
|
4853
4888
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4854
4889
|
}
|
|
4855
4890
|
}
|
|
4856
|
-
function
|
|
4857
|
-
|
|
4891
|
+
function Qa(e, t, n, r) {
|
|
4892
|
+
Ja(t, n);
|
|
4858
4893
|
let i = W(t, n);
|
|
4859
|
-
return r === "mysql" ?
|
|
4894
|
+
return r === "mysql" ? Za(e, i) : Xa(e, i);
|
|
4860
4895
|
}
|
|
4861
|
-
function
|
|
4896
|
+
function $a(e) {
|
|
4862
4897
|
switch (e) {
|
|
4863
4898
|
case "connection": return "logs.connection";
|
|
4864
4899
|
case "client_id": return "logs.client_id";
|
|
@@ -4867,15 +4902,15 @@ function Qa(e) {
|
|
|
4867
4902
|
case "time": throw Error("time dimension is handled separately");
|
|
4868
4903
|
}
|
|
4869
4904
|
}
|
|
4870
|
-
function
|
|
4871
|
-
let t = null, n = () => (t ||=
|
|
4905
|
+
function eo(e) {
|
|
4906
|
+
let t = null, n = () => (t ||= Ka(e), t);
|
|
4872
4907
|
return {
|
|
4873
4908
|
async query(t, r, i) {
|
|
4874
|
-
let a = Date.now(), o =
|
|
4909
|
+
let a = Date.now(), o = Wa[r], s = Ga[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4875
4910
|
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));
|
|
4876
4911
|
let d = [], f = [];
|
|
4877
4912
|
for (let e of i.group_by) if (e === "time") {
|
|
4878
|
-
let e =
|
|
4913
|
+
let e = Qa(i.interval, i.tz, new Date(i.from), c);
|
|
4879
4914
|
f.push({
|
|
4880
4915
|
alias: "time",
|
|
4881
4916
|
expr: e
|
|
@@ -4884,7 +4919,7 @@ function $a(e) {
|
|
|
4884
4919
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4885
4920
|
});
|
|
4886
4921
|
} else {
|
|
4887
|
-
let t =
|
|
4922
|
+
let t = $a(e);
|
|
4888
4923
|
f.push({
|
|
4889
4924
|
alias: e,
|
|
4890
4925
|
expr: p`${p.ref(t)}`
|
|
@@ -4959,7 +4994,7 @@ function $a(e) {
|
|
|
4959
4994
|
}
|
|
4960
4995
|
//#endregion
|
|
4961
4996
|
//#region src/customText/index.ts
|
|
4962
|
-
function
|
|
4997
|
+
function to(e) {
|
|
4963
4998
|
return {
|
|
4964
4999
|
async get(t, n, r) {
|
|
4965
5000
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4998,7 +5033,7 @@ function eo(e) {
|
|
|
4998
5033
|
}
|
|
4999
5034
|
//#endregion
|
|
5000
5035
|
//#region src/authenticationMethods/create.ts
|
|
5001
|
-
function
|
|
5036
|
+
function no(e) {
|
|
5002
5037
|
return async (t, n, r) => {
|
|
5003
5038
|
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 ?? qr();
|
|
5004
5039
|
return await e.insertInto("authentication_methods").values({
|
|
@@ -5037,7 +5072,7 @@ function to(e) {
|
|
|
5037
5072
|
}
|
|
5038
5073
|
//#endregion
|
|
5039
5074
|
//#region src/authenticationMethods/get.ts
|
|
5040
|
-
function
|
|
5075
|
+
function ro(e) {
|
|
5041
5076
|
return async (t, n) => {
|
|
5042
5077
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
5043
5078
|
return r ? {
|
|
@@ -5060,7 +5095,7 @@ function no(e) {
|
|
|
5060
5095
|
}
|
|
5061
5096
|
//#endregion
|
|
5062
5097
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
5063
|
-
function
|
|
5098
|
+
function io(e) {
|
|
5064
5099
|
return async (t, n) => {
|
|
5065
5100
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
5066
5101
|
return r ? {
|
|
@@ -5083,7 +5118,7 @@ function ro(e) {
|
|
|
5083
5118
|
}
|
|
5084
5119
|
//#endregion
|
|
5085
5120
|
//#region src/authenticationMethods/list.ts
|
|
5086
|
-
function
|
|
5121
|
+
function ao(e) {
|
|
5087
5122
|
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) => ({
|
|
5088
5123
|
id: e.id,
|
|
5089
5124
|
user_id: e.user_id,
|
|
@@ -5103,35 +5138,35 @@ function io(e) {
|
|
|
5103
5138
|
}
|
|
5104
5139
|
//#endregion
|
|
5105
5140
|
//#region src/authenticationMethods/update.ts
|
|
5106
|
-
function
|
|
5141
|
+
function oo(e) {
|
|
5107
5142
|
return async (t, n, r) => {
|
|
5108
5143
|
let i = { updated_at_ts: Date.now() };
|
|
5109
5144
|
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();
|
|
5110
|
-
let a = await
|
|
5145
|
+
let a = await ro(e)(t, n);
|
|
5111
5146
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
5112
5147
|
return a;
|
|
5113
5148
|
};
|
|
5114
5149
|
}
|
|
5115
5150
|
//#endregion
|
|
5116
5151
|
//#region src/authenticationMethods/remove.ts
|
|
5117
|
-
function
|
|
5152
|
+
function so(e) {
|
|
5118
5153
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
5119
5154
|
}
|
|
5120
5155
|
//#endregion
|
|
5121
5156
|
//#region src/authenticationMethods/index.ts
|
|
5122
|
-
function
|
|
5157
|
+
function co(e) {
|
|
5123
5158
|
return {
|
|
5124
|
-
create:
|
|
5125
|
-
get:
|
|
5126
|
-
getByCredentialId:
|
|
5127
|
-
list:
|
|
5128
|
-
update:
|
|
5129
|
-
remove:
|
|
5159
|
+
create: no(e),
|
|
5160
|
+
get: ro(e),
|
|
5161
|
+
getByCredentialId: io(e),
|
|
5162
|
+
list: ao(e),
|
|
5163
|
+
update: oo(e),
|
|
5164
|
+
remove: so(e)
|
|
5130
5165
|
};
|
|
5131
5166
|
}
|
|
5132
5167
|
//#endregion
|
|
5133
5168
|
//#region src/outbox/getByIds.ts
|
|
5134
|
-
function
|
|
5169
|
+
function lo(e) {
|
|
5135
5170
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
5136
5171
|
...JSON.parse(e.payload),
|
|
5137
5172
|
id: e.id,
|
|
@@ -5144,7 +5179,7 @@ function co(e) {
|
|
|
5144
5179
|
}
|
|
5145
5180
|
//#endregion
|
|
5146
5181
|
//#region src/outbox/getUnprocessed.ts
|
|
5147
|
-
function
|
|
5182
|
+
function uo(e) {
|
|
5148
5183
|
return async (t) => {
|
|
5149
5184
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
5150
5185
|
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) => ({
|
|
@@ -5160,7 +5195,7 @@ function lo(e) {
|
|
|
5160
5195
|
}
|
|
5161
5196
|
//#endregion
|
|
5162
5197
|
//#region src/outbox/claimEvents.ts
|
|
5163
|
-
function
|
|
5198
|
+
function fo(e) {
|
|
5164
5199
|
return async (t, n, r) => {
|
|
5165
5200
|
if (t.length === 0) return [];
|
|
5166
5201
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -5172,7 +5207,7 @@ function uo(e) {
|
|
|
5172
5207
|
}
|
|
5173
5208
|
//#endregion
|
|
5174
5209
|
//#region src/outbox/markProcessed.ts
|
|
5175
|
-
function
|
|
5210
|
+
function po(e) {
|
|
5176
5211
|
return async (t) => {
|
|
5177
5212
|
if (t.length === 0) return;
|
|
5178
5213
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5181,7 +5216,7 @@ function fo(e) {
|
|
|
5181
5216
|
}
|
|
5182
5217
|
//#endregion
|
|
5183
5218
|
//#region src/outbox/markRetry.ts
|
|
5184
|
-
function
|
|
5219
|
+
function mo(e) {
|
|
5185
5220
|
return async (t, n, r) => {
|
|
5186
5221
|
await e.updateTable("outbox_events").set({
|
|
5187
5222
|
error: n,
|
|
@@ -5194,7 +5229,7 @@ function po(e) {
|
|
|
5194
5229
|
}
|
|
5195
5230
|
//#endregion
|
|
5196
5231
|
//#region src/outbox/deadLetter.ts
|
|
5197
|
-
function
|
|
5232
|
+
function ho(e) {
|
|
5198
5233
|
return async (t, n) => {
|
|
5199
5234
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5200
5235
|
await e.updateTable("outbox_events").set({
|
|
@@ -5206,7 +5241,7 @@ function mo(e) {
|
|
|
5206
5241
|
}
|
|
5207
5242
|
//#endregion
|
|
5208
5243
|
//#region src/outbox/listFailed.ts
|
|
5209
|
-
function
|
|
5244
|
+
function go(e) {
|
|
5210
5245
|
return async (t, n = {}) => {
|
|
5211
5246
|
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) => {
|
|
5212
5247
|
let t;
|
|
@@ -5241,7 +5276,7 @@ function ho(e) {
|
|
|
5241
5276
|
}
|
|
5242
5277
|
//#endregion
|
|
5243
5278
|
//#region src/outbox/replay.ts
|
|
5244
|
-
function
|
|
5279
|
+
function _o(e) {
|
|
5245
5280
|
return async (t, n) => {
|
|
5246
5281
|
let r = await e.updateTable("outbox_events").set({
|
|
5247
5282
|
processed_at: null,
|
|
@@ -5258,7 +5293,7 @@ function go(e) {
|
|
|
5258
5293
|
}
|
|
5259
5294
|
//#endregion
|
|
5260
5295
|
//#region src/outbox/discard.ts
|
|
5261
|
-
function
|
|
5296
|
+
function vo(e) {
|
|
5262
5297
|
return async (t, n) => {
|
|
5263
5298
|
let r = await e.deleteFrom("outbox_events").where("id", "=", t).where("tenant_id", "=", n).where("dead_lettered_at", "is not", null).executeTakeFirst();
|
|
5264
5299
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -5266,7 +5301,7 @@ function _o(e) {
|
|
|
5266
5301
|
}
|
|
5267
5302
|
//#endregion
|
|
5268
5303
|
//#region src/outbox/cleanup.ts
|
|
5269
|
-
function
|
|
5304
|
+
function yo(e) {
|
|
5270
5305
|
return async (t) => {
|
|
5271
5306
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5272
5307
|
return Number(n.numDeletedRows);
|
|
@@ -5274,19 +5309,19 @@ function vo(e) {
|
|
|
5274
5309
|
}
|
|
5275
5310
|
//#endregion
|
|
5276
5311
|
//#region src/outbox/index.ts
|
|
5277
|
-
function
|
|
5312
|
+
function bo(e) {
|
|
5278
5313
|
return {
|
|
5279
5314
|
create: st(e),
|
|
5280
|
-
getByIds:
|
|
5281
|
-
getUnprocessed:
|
|
5282
|
-
claimEvents:
|
|
5283
|
-
markProcessed:
|
|
5284
|
-
markRetry:
|
|
5285
|
-
deadLetter:
|
|
5286
|
-
listFailed:
|
|
5287
|
-
replay:
|
|
5288
|
-
discard:
|
|
5289
|
-
cleanup:
|
|
5315
|
+
getByIds: lo(e),
|
|
5316
|
+
getUnprocessed: uo(e),
|
|
5317
|
+
claimEvents: fo(e),
|
|
5318
|
+
markProcessed: po(e),
|
|
5319
|
+
markRetry: mo(e),
|
|
5320
|
+
deadLetter: ho(e),
|
|
5321
|
+
listFailed: go(e),
|
|
5322
|
+
replay: _o(e),
|
|
5323
|
+
discard: vo(e),
|
|
5324
|
+
cleanup: yo(e)
|
|
5290
5325
|
};
|
|
5291
5326
|
}
|
|
5292
5327
|
//#endregion
|
|
@@ -5304,7 +5339,7 @@ function G(e) {
|
|
|
5304
5339
|
updated_at: e.updated_at
|
|
5305
5340
|
};
|
|
5306
5341
|
}
|
|
5307
|
-
function
|
|
5342
|
+
function xo(e) {
|
|
5308
5343
|
return {
|
|
5309
5344
|
async create(n, r, i) {
|
|
5310
5345
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5351,7 +5386,7 @@ function K(e) {
|
|
|
5351
5386
|
updated_at: e.updated_at
|
|
5352
5387
|
};
|
|
5353
5388
|
}
|
|
5354
|
-
function
|
|
5389
|
+
function So(e) {
|
|
5355
5390
|
return {
|
|
5356
5391
|
async create(n, r, i) {
|
|
5357
5392
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5385,19 +5420,19 @@ function xo(e) {
|
|
|
5385
5420
|
}
|
|
5386
5421
|
//#endregion
|
|
5387
5422
|
//#region src/proxyRoutes/serialize.ts
|
|
5388
|
-
function
|
|
5423
|
+
function Co(e) {
|
|
5389
5424
|
return {
|
|
5390
5425
|
id: e.id,
|
|
5391
5426
|
tenant_id: e.tenant_id,
|
|
5392
5427
|
custom_domain_id: e.custom_domain_id,
|
|
5393
5428
|
priority: e.priority,
|
|
5394
|
-
match:
|
|
5395
|
-
handlers:
|
|
5429
|
+
match: wo(e.match),
|
|
5430
|
+
handlers: To(e.handlers),
|
|
5396
5431
|
created_at: e.created_at,
|
|
5397
5432
|
updated_at: e.updated_at
|
|
5398
5433
|
};
|
|
5399
5434
|
}
|
|
5400
|
-
function
|
|
5435
|
+
function wo(e) {
|
|
5401
5436
|
if (!e) return { path: "/*" };
|
|
5402
5437
|
try {
|
|
5403
5438
|
let t = JSON.parse(e), n = ue.safeParse(t);
|
|
@@ -5405,7 +5440,7 @@ function Co(e) {
|
|
|
5405
5440
|
} catch {}
|
|
5406
5441
|
return { path: "/*" };
|
|
5407
5442
|
}
|
|
5408
|
-
function
|
|
5443
|
+
function To(e) {
|
|
5409
5444
|
if (!e) return [];
|
|
5410
5445
|
try {
|
|
5411
5446
|
let t = JSON.parse(e);
|
|
@@ -5422,7 +5457,7 @@ function wo(e) {
|
|
|
5422
5457
|
}
|
|
5423
5458
|
//#endregion
|
|
5424
5459
|
//#region src/proxyRoutes/adapter.ts
|
|
5425
|
-
function
|
|
5460
|
+
function Eo(e) {
|
|
5426
5461
|
return {
|
|
5427
5462
|
async create(n, r, i) {
|
|
5428
5463
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5448,14 +5483,14 @@ function To(e) {
|
|
|
5448
5483
|
},
|
|
5449
5484
|
async get(t, n) {
|
|
5450
5485
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5451
|
-
return r ?
|
|
5486
|
+
return r ? Co(r) : null;
|
|
5452
5487
|
},
|
|
5453
5488
|
async list(t, n = {}) {
|
|
5454
5489
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5455
5490
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5456
5491
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5457
5492
|
return {
|
|
5458
|
-
proxy_routes: o.map(
|
|
5493
|
+
proxy_routes: o.map(Co),
|
|
5459
5494
|
start: r * i,
|
|
5460
5495
|
limit: i,
|
|
5461
5496
|
length: o.length
|
|
@@ -5475,7 +5510,7 @@ function To(e) {
|
|
|
5475
5510
|
}
|
|
5476
5511
|
//#endregion
|
|
5477
5512
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5478
|
-
async function
|
|
5513
|
+
async function Do(e, t) {
|
|
5479
5514
|
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([
|
|
5480
5515
|
"custom_domain_id",
|
|
5481
5516
|
"tenant_id",
|
|
@@ -5487,20 +5522,20 @@ async function Eo(e, t) {
|
|
|
5487
5522
|
tenant_id: a.tenant_id,
|
|
5488
5523
|
custom_domain_id: a.custom_domain_id,
|
|
5489
5524
|
domain: a.domain,
|
|
5490
|
-
routes: o.map(
|
|
5525
|
+
routes: o.map(Co)
|
|
5491
5526
|
};
|
|
5492
5527
|
}
|
|
5493
5528
|
//#endregion
|
|
5494
5529
|
//#region src/proxyRoutes/index.ts
|
|
5495
|
-
function
|
|
5530
|
+
function Oo(e) {
|
|
5496
5531
|
return {
|
|
5497
|
-
proxyRoutes:
|
|
5498
|
-
resolveHost: (t) =>
|
|
5532
|
+
proxyRoutes: Eo(e),
|
|
5533
|
+
resolveHost: (t) => Do(e, t)
|
|
5499
5534
|
};
|
|
5500
5535
|
}
|
|
5501
5536
|
//#endregion
|
|
5502
5537
|
//#region src/tokenExchangeProfiles/serialize.ts
|
|
5503
|
-
function
|
|
5538
|
+
function ko(e) {
|
|
5504
5539
|
let t = {
|
|
5505
5540
|
id: e.id,
|
|
5506
5541
|
name: e.name,
|
|
@@ -5510,10 +5545,10 @@ function Oo(e) {
|
|
|
5510
5545
|
updated_at: e.updated_at
|
|
5511
5546
|
};
|
|
5512
5547
|
e.action_id && (t.action_id = e.action_id);
|
|
5513
|
-
let n =
|
|
5548
|
+
let n = Ao(e.jwt_verification);
|
|
5514
5549
|
return n && (t.jwt_verification = n), t;
|
|
5515
5550
|
}
|
|
5516
|
-
function
|
|
5551
|
+
function Ao(e) {
|
|
5517
5552
|
if (e) try {
|
|
5518
5553
|
let t = Te.safeParse(JSON.parse(e));
|
|
5519
5554
|
return t.success ? t.data : void 0;
|
|
@@ -5523,12 +5558,12 @@ function ko(e) {
|
|
|
5523
5558
|
}
|
|
5524
5559
|
//#endregion
|
|
5525
5560
|
//#region src/tokenExchangeProfiles/adapter.ts
|
|
5526
|
-
var
|
|
5527
|
-
function
|
|
5561
|
+
var jo = e("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
5562
|
+
function Mo(e) {
|
|
5528
5563
|
return {
|
|
5529
5564
|
async create(t, n, r) {
|
|
5530
5565
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5531
|
-
id: i?.id ?? `tep_${
|
|
5566
|
+
id: i?.id ?? `tep_${jo()}`,
|
|
5532
5567
|
tenant_id: t,
|
|
5533
5568
|
name: n.name,
|
|
5534
5569
|
subject_token_type: n.subject_token_type,
|
|
@@ -5538,14 +5573,14 @@ function jo(e) {
|
|
|
5538
5573
|
created_at: i?.created_at ?? a,
|
|
5539
5574
|
updated_at: i?.updated_at ?? a
|
|
5540
5575
|
};
|
|
5541
|
-
return await e.insertInto("token_exchange_profiles").values(o).execute(),
|
|
5576
|
+
return await e.insertInto("token_exchange_profiles").values(o).execute(), ko(o);
|
|
5542
5577
|
},
|
|
5543
5578
|
async get(t, n) {
|
|
5544
5579
|
let r = await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5545
|
-
return r ?
|
|
5580
|
+
return r ? ko(r) : null;
|
|
5546
5581
|
},
|
|
5547
5582
|
async list(t) {
|
|
5548
|
-
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(
|
|
5583
|
+
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(ko);
|
|
5549
5584
|
},
|
|
5550
5585
|
async update(t, n, r) {
|
|
5551
5586
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5561,7 +5596,7 @@ function jo(e) {
|
|
|
5561
5596
|
}
|
|
5562
5597
|
//#endregion
|
|
5563
5598
|
//#region src/scim/adapter.ts
|
|
5564
|
-
function
|
|
5599
|
+
function No(e) {
|
|
5565
5600
|
if (!e) return [];
|
|
5566
5601
|
try {
|
|
5567
5602
|
let t = JSON.parse(e);
|
|
@@ -5576,7 +5611,7 @@ function Mo(e) {
|
|
|
5576
5611
|
return [];
|
|
5577
5612
|
}
|
|
5578
5613
|
}
|
|
5579
|
-
function
|
|
5614
|
+
function Po(e) {
|
|
5580
5615
|
if (!e) return [];
|
|
5581
5616
|
try {
|
|
5582
5617
|
let t = JSON.parse(e);
|
|
@@ -5585,16 +5620,16 @@ function No(e) {
|
|
|
5585
5620
|
return [];
|
|
5586
5621
|
}
|
|
5587
5622
|
}
|
|
5588
|
-
function
|
|
5623
|
+
function Fo(e) {
|
|
5589
5624
|
return {
|
|
5590
5625
|
connection_id: e.connection_id,
|
|
5591
5626
|
user_id_attribute: e.user_id_attribute,
|
|
5592
|
-
mapping:
|
|
5627
|
+
mapping: No(e.mapping),
|
|
5593
5628
|
created_at: e.created_at,
|
|
5594
5629
|
updated_at: e.updated_at
|
|
5595
5630
|
};
|
|
5596
5631
|
}
|
|
5597
|
-
function
|
|
5632
|
+
function Io(e) {
|
|
5598
5633
|
return {
|
|
5599
5634
|
async create(t, n) {
|
|
5600
5635
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5615,7 +5650,7 @@ function Fo(e) {
|
|
|
5615
5650
|
},
|
|
5616
5651
|
async get(t, n) {
|
|
5617
5652
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5618
|
-
return r ?
|
|
5653
|
+
return r ? Fo(r) : null;
|
|
5619
5654
|
},
|
|
5620
5655
|
async update(t, n, r) {
|
|
5621
5656
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5629,18 +5664,18 @@ function Fo(e) {
|
|
|
5629
5664
|
}
|
|
5630
5665
|
};
|
|
5631
5666
|
}
|
|
5632
|
-
function
|
|
5667
|
+
function Lo(e) {
|
|
5633
5668
|
return {
|
|
5634
5669
|
token_id: e.token_id,
|
|
5635
5670
|
connection_id: e.connection_id,
|
|
5636
5671
|
token_hash: e.token_hash,
|
|
5637
|
-
scopes:
|
|
5672
|
+
scopes: Po(e.scopes),
|
|
5638
5673
|
valid_until: e.valid_until ?? void 0,
|
|
5639
5674
|
created_at: e.created_at,
|
|
5640
5675
|
last_used_at: e.last_used_at ?? void 0
|
|
5641
5676
|
};
|
|
5642
5677
|
}
|
|
5643
|
-
function
|
|
5678
|
+
function Ro(e) {
|
|
5644
5679
|
return {
|
|
5645
5680
|
async create(t, n) {
|
|
5646
5681
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5664,14 +5699,14 @@ function Lo(e) {
|
|
|
5664
5699
|
},
|
|
5665
5700
|
async get(t, n) {
|
|
5666
5701
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5667
|
-
return r ?
|
|
5702
|
+
return r ? Lo(r) : null;
|
|
5668
5703
|
},
|
|
5669
5704
|
async getByHash(t, n) {
|
|
5670
5705
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5671
|
-
return r ?
|
|
5706
|
+
return r ? Lo(r) : null;
|
|
5672
5707
|
},
|
|
5673
5708
|
async listByConnection(t, n) {
|
|
5674
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5709
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Lo);
|
|
5675
5710
|
},
|
|
5676
5711
|
async markUsed(t, n, r) {
|
|
5677
5712
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5683,7 +5718,7 @@ function Lo(e) {
|
|
|
5683
5718
|
}
|
|
5684
5719
|
};
|
|
5685
5720
|
}
|
|
5686
|
-
function
|
|
5721
|
+
function zo(e) {
|
|
5687
5722
|
return {
|
|
5688
5723
|
connection_id: e.connection_id,
|
|
5689
5724
|
external_id: e.external_id,
|
|
@@ -5691,7 +5726,7 @@ function Ro(e) {
|
|
|
5691
5726
|
created_at: e.created_at
|
|
5692
5727
|
};
|
|
5693
5728
|
}
|
|
5694
|
-
function
|
|
5729
|
+
function Bo(e) {
|
|
5695
5730
|
return {
|
|
5696
5731
|
async create(t, n) {
|
|
5697
5732
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5710,11 +5745,11 @@ function zo(e) {
|
|
|
5710
5745
|
},
|
|
5711
5746
|
async getByExternalId(t, n, r) {
|
|
5712
5747
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5713
|
-
return i ?
|
|
5748
|
+
return i ? zo(i) : null;
|
|
5714
5749
|
},
|
|
5715
5750
|
async getByUserId(t, n, r) {
|
|
5716
5751
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5717
|
-
return i ?
|
|
5752
|
+
return i ? zo(i) : null;
|
|
5718
5753
|
},
|
|
5719
5754
|
async remove(t, n, r) {
|
|
5720
5755
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5724,7 +5759,7 @@ function zo(e) {
|
|
|
5724
5759
|
}
|
|
5725
5760
|
//#endregion
|
|
5726
5761
|
//#region src/tenantOperations/index.ts
|
|
5727
|
-
function
|
|
5762
|
+
function Vo(e) {
|
|
5728
5763
|
if (!e) return null;
|
|
5729
5764
|
try {
|
|
5730
5765
|
let t = JSON.parse(e);
|
|
@@ -5746,8 +5781,8 @@ function q(e) {
|
|
|
5746
5781
|
target_database_version: e.target_database_version,
|
|
5747
5782
|
error: e.error,
|
|
5748
5783
|
initiated_by: e.initiated_by,
|
|
5749
|
-
input:
|
|
5750
|
-
result:
|
|
5784
|
+
input: Vo(e.input),
|
|
5785
|
+
result: Vo(e.result),
|
|
5751
5786
|
claimed_by: e.claimed_by,
|
|
5752
5787
|
claim_expires_at: e.claim_expires_at,
|
|
5753
5788
|
created_at: e.created_at,
|
|
@@ -5755,7 +5790,7 @@ function q(e) {
|
|
|
5755
5790
|
finished_at: e.finished_at
|
|
5756
5791
|
});
|
|
5757
5792
|
}
|
|
5758
|
-
function
|
|
5793
|
+
function Ho(e) {
|
|
5759
5794
|
return {
|
|
5760
5795
|
async create(n) {
|
|
5761
5796
|
let r = xe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5838,27 +5873,27 @@ function Vo(e) {
|
|
|
5838
5873
|
}
|
|
5839
5874
|
//#endregion
|
|
5840
5875
|
//#region src/utils/monotonic-id.ts
|
|
5841
|
-
var
|
|
5842
|
-
function
|
|
5876
|
+
var Uo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Wo = 32, Go = 10, Ko = 4, qo = 10;
|
|
5877
|
+
function Jo(e, t) {
|
|
5843
5878
|
let n = "";
|
|
5844
|
-
for (let r = t; r > 0; r--) n =
|
|
5879
|
+
for (let r = t; r > 0; r--) n = Uo.charAt(e % Wo) + n, e = Math.floor(e / Wo);
|
|
5845
5880
|
return n;
|
|
5846
5881
|
}
|
|
5847
|
-
function
|
|
5848
|
-
let e = new Uint8Array(
|
|
5882
|
+
function Yo() {
|
|
5883
|
+
let e = new Uint8Array(qo);
|
|
5849
5884
|
crypto.getRandomValues(e);
|
|
5850
5885
|
let t = "";
|
|
5851
|
-
for (let n = 0; n <
|
|
5886
|
+
for (let n = 0; n < qo; n++) t += Uo.charAt(e[n] % Wo);
|
|
5852
5887
|
return t;
|
|
5853
5888
|
}
|
|
5854
|
-
var
|
|
5855
|
-
function
|
|
5889
|
+
var Xo = 0, Zo = 0;
|
|
5890
|
+
function Qo() {
|
|
5856
5891
|
let e = Date.now();
|
|
5857
|
-
return e ===
|
|
5892
|
+
return e === Xo ? Zo++ : (Xo = e, Zo = 0), Jo(e, Go) + Jo(Zo, Ko) + Yo();
|
|
5858
5893
|
}
|
|
5859
5894
|
//#endregion
|
|
5860
5895
|
//#region src/tenantOperationEvents/index.ts
|
|
5861
|
-
function
|
|
5896
|
+
function $o(e) {
|
|
5862
5897
|
if (!e) return null;
|
|
5863
5898
|
try {
|
|
5864
5899
|
let t = JSON.parse(e);
|
|
@@ -5866,22 +5901,22 @@ function Qo(e) {
|
|
|
5866
5901
|
} catch {}
|
|
5867
5902
|
return null;
|
|
5868
5903
|
}
|
|
5869
|
-
function
|
|
5904
|
+
function es(e) {
|
|
5870
5905
|
return be.parse({
|
|
5871
5906
|
id: e.id,
|
|
5872
5907
|
operation_id: e.operation_id,
|
|
5873
5908
|
step: e.step,
|
|
5874
5909
|
outcome: e.outcome,
|
|
5875
|
-
detail:
|
|
5910
|
+
detail: $o(e.detail),
|
|
5876
5911
|
attempt: e.attempt,
|
|
5877
5912
|
created_at: e.created_at
|
|
5878
5913
|
});
|
|
5879
5914
|
}
|
|
5880
|
-
function
|
|
5915
|
+
function ts(e) {
|
|
5881
5916
|
return {
|
|
5882
5917
|
async create(t) {
|
|
5883
5918
|
let n = ye.parse(t), r = {
|
|
5884
|
-
id: `evt_${
|
|
5919
|
+
id: `evt_${Qo()}`,
|
|
5885
5920
|
operation_id: n.operation_id,
|
|
5886
5921
|
step: n.step,
|
|
5887
5922
|
outcome: n.outcome,
|
|
@@ -5889,12 +5924,12 @@ function es(e) {
|
|
|
5889
5924
|
attempt: n.attempt,
|
|
5890
5925
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5891
5926
|
};
|
|
5892
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5927
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), es(r);
|
|
5893
5928
|
},
|
|
5894
5929
|
async listByOperation(t, n = {}) {
|
|
5895
5930
|
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();
|
|
5896
5931
|
return {
|
|
5897
|
-
events: a.map(
|
|
5932
|
+
events: a.map(es),
|
|
5898
5933
|
start: r * i,
|
|
5899
5934
|
limit: i,
|
|
5900
5935
|
length: a.length
|
|
@@ -5904,16 +5939,16 @@ function es(e) {
|
|
|
5904
5939
|
}
|
|
5905
5940
|
//#endregion
|
|
5906
5941
|
//#region src/tenantOperationRows/index.ts
|
|
5907
|
-
var
|
|
5908
|
-
function
|
|
5942
|
+
var ns = 50;
|
|
5943
|
+
function rs(e) {
|
|
5909
5944
|
let t = JSON.parse(e);
|
|
5910
5945
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5911
5946
|
}
|
|
5912
|
-
function
|
|
5947
|
+
function is(e) {
|
|
5913
5948
|
return Ce.parse({
|
|
5914
5949
|
operation_id: e.operation_id,
|
|
5915
5950
|
seq: e.seq,
|
|
5916
|
-
payload:
|
|
5951
|
+
payload: rs(e.payload),
|
|
5917
5952
|
status: e.status,
|
|
5918
5953
|
error_code: e.error_code,
|
|
5919
5954
|
error_message: e.error_message,
|
|
@@ -5923,7 +5958,7 @@ function rs(e) {
|
|
|
5923
5958
|
updated_at: e.updated_at
|
|
5924
5959
|
});
|
|
5925
5960
|
}
|
|
5926
|
-
function
|
|
5961
|
+
function as(e) {
|
|
5927
5962
|
return {
|
|
5928
5963
|
async createMany(t) {
|
|
5929
5964
|
if (t.length === 0) return 0;
|
|
@@ -5942,11 +5977,11 @@ function is(e) {
|
|
|
5942
5977
|
updated_at: n
|
|
5943
5978
|
};
|
|
5944
5979
|
});
|
|
5945
|
-
for (let t = 0; t < r.length; t +=
|
|
5980
|
+
for (let t = 0; t < r.length; t += ns) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + ns)).execute();
|
|
5946
5981
|
return r.length;
|
|
5947
5982
|
},
|
|
5948
5983
|
async claimPending(t, n) {
|
|
5949
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5984
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(is);
|
|
5950
5985
|
},
|
|
5951
5986
|
async recordOutcomes(t, n) {
|
|
5952
5987
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5995,7 +6030,7 @@ function is(e) {
|
|
|
5995
6030
|
}
|
|
5996
6031
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5997
6032
|
return {
|
|
5998
|
-
rows: o.map(
|
|
6033
|
+
rows: o.map(is),
|
|
5999
6034
|
start: r * i,
|
|
6000
6035
|
limit: i,
|
|
6001
6036
|
length: o.length
|
|
@@ -6009,7 +6044,7 @@ function is(e) {
|
|
|
6009
6044
|
}
|
|
6010
6045
|
//#endregion
|
|
6011
6046
|
//#region src/rollouts/index.ts
|
|
6012
|
-
function
|
|
6047
|
+
function os(e) {
|
|
6013
6048
|
if (!e) return null;
|
|
6014
6049
|
try {
|
|
6015
6050
|
return JSON.parse(e);
|
|
@@ -6017,7 +6052,7 @@ function as(e) {
|
|
|
6017
6052
|
return null;
|
|
6018
6053
|
}
|
|
6019
6054
|
}
|
|
6020
|
-
function
|
|
6055
|
+
function ss(e) {
|
|
6021
6056
|
return he.parse({
|
|
6022
6057
|
id: e.id,
|
|
6023
6058
|
kind: e.kind,
|
|
@@ -6025,15 +6060,15 @@ function os(e) {
|
|
|
6025
6060
|
target_worker_version: e.target_worker_version,
|
|
6026
6061
|
target_database_version: e.target_database_version,
|
|
6027
6062
|
wave_size: e.wave_size,
|
|
6028
|
-
canary_tenant_ids:
|
|
6029
|
-
filter:
|
|
6063
|
+
canary_tenant_ids: os(e.canary_tenant_ids),
|
|
6064
|
+
filter: os(e.filter),
|
|
6030
6065
|
initiated_by: e.initiated_by,
|
|
6031
6066
|
created_at: e.created_at,
|
|
6032
6067
|
updated_at: e.updated_at,
|
|
6033
6068
|
finished_at: e.finished_at
|
|
6034
6069
|
});
|
|
6035
6070
|
}
|
|
6036
|
-
function
|
|
6071
|
+
function cs(e) {
|
|
6037
6072
|
return {
|
|
6038
6073
|
async create(n) {
|
|
6039
6074
|
let r = me.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -6050,16 +6085,16 @@ function ss(e) {
|
|
|
6050
6085
|
updated_at: i,
|
|
6051
6086
|
finished_at: null
|
|
6052
6087
|
};
|
|
6053
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
6088
|
+
return await e.insertInto("rollouts").values(a).execute(), ss(a);
|
|
6054
6089
|
},
|
|
6055
6090
|
async get(t) {
|
|
6056
6091
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
6057
|
-
return n ?
|
|
6092
|
+
return n ? ss(n) : null;
|
|
6058
6093
|
},
|
|
6059
6094
|
async list(t = {}) {
|
|
6060
6095
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = await e.selectFrom("rollouts").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
6061
6096
|
return {
|
|
6062
|
-
rollouts: i.map(
|
|
6097
|
+
rollouts: i.map(ss),
|
|
6063
6098
|
start: n * r,
|
|
6064
6099
|
limit: r,
|
|
6065
6100
|
length: i.length
|
|
@@ -6079,7 +6114,7 @@ function ss(e) {
|
|
|
6079
6114
|
}
|
|
6080
6115
|
//#endregion
|
|
6081
6116
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
6082
|
-
var
|
|
6117
|
+
var ls = class {
|
|
6083
6118
|
migrations;
|
|
6084
6119
|
constructor(e) {
|
|
6085
6120
|
this.migrations = e;
|
|
@@ -6087,10 +6122,10 @@ var cs = class {
|
|
|
6087
6122
|
async getMigrations() {
|
|
6088
6123
|
return this.migrations;
|
|
6089
6124
|
}
|
|
6090
|
-
},
|
|
6091
|
-
down: () =>
|
|
6092
|
-
up: () =>
|
|
6093
|
-
}),
|
|
6125
|
+
}, us = /* @__PURE__ */ w({
|
|
6126
|
+
down: () => ms,
|
|
6127
|
+
up: () => ps
|
|
6128
|
+
}), ds = [
|
|
6094
6129
|
{
|
|
6095
6130
|
table: "authentication_methods",
|
|
6096
6131
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6356,7 +6391,7 @@ var cs = class {
|
|
|
6356
6391
|
onDelete: "cascade"
|
|
6357
6392
|
}
|
|
6358
6393
|
];
|
|
6359
|
-
async function
|
|
6394
|
+
async function fs(e) {
|
|
6360
6395
|
try {
|
|
6361
6396
|
return await p`select sqlite_version()`.execute(e), !0;
|
|
6362
6397
|
} catch {
|
|
@@ -6365,14 +6400,14 @@ async function ds(e) {
|
|
|
6365
6400
|
}
|
|
6366
6401
|
function J(e, t) {
|
|
6367
6402
|
let n = e;
|
|
6368
|
-
for (let e of
|
|
6403
|
+
for (let e of ds) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6369
6404
|
let n = t;
|
|
6370
6405
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6371
6406
|
}));
|
|
6372
6407
|
return n;
|
|
6373
6408
|
}
|
|
6374
|
-
async function
|
|
6375
|
-
let t = await
|
|
6409
|
+
async function ps(e) {
|
|
6410
|
+
let t = await fs(e);
|
|
6376
6411
|
await e.schema.createTable("tenants").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("audience", p`varchar(255)`).addColumn("sender_email", p`varchar(255)`).addColumn("sender_name", p`varchar(255)`).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(255)`, (e) => e.notNull()).addColumn("support_url", p`varchar(255)`).addColumn("idle_session_lifetime", p`int`).addColumn("session_lifetime", p`int`).addColumn("session_cookie", p`text`).addColumn("allowed_logout_urls", p`text`).addColumn("ephemeral_session_lifetime", p`int`).addColumn("idle_ephemeral_session_lifetime", p`int`).addColumn("default_redirection_uri", p`text`).addColumn("enabled_locales", p`text`).addColumn("default_directory", p`varchar(255)`).addColumn("error_page", p`text`).addColumn("flags", p`text`).addColumn("friendly_name", p`varchar(255)`).addColumn("picture_url", p`text`).addColumn("support_email", p`varchar(255)`).addColumn("sandbox_version", p`varchar(50)`).addColumn("sandbox_versions_available", p`text`).addColumn("legacy_sandbox_version", p`varchar(50)`).addColumn("change_password", p`text`).addColumn("guardian_mfa_page", p`text`).addColumn("device_flow", p`text`).addColumn("default_token_quota", p`text`).addColumn("default_audience", p`varchar(255)`).addColumn("default_organization", p`varchar(255)`).addColumn("sessions", p`text`).addColumn("oidc_logout", p`text`).addColumn("allow_organization_name_in_authentication_api", p`int`).addColumn("customize_mfa_in_postlogin_action", p`int`).addColumn("acr_values_supported", p`text`).addColumn("mtls", p`text`).addColumn("pushed_authorization_requests_supported", p`int`).addColumn("authorization_response_iss_parameter_supported", p`int`).addColumn("mfa", p`text`).addColumn("attack_protection", p`text`).addColumn("default_client_id", p`varchar(255)`).addColumn("deployment_type", p`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", p`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", p`varchar(2048)`).addColumn("provisioning_state_changed_at", p`varchar(35)`).addColumn("bundle_configuration", p`varchar(64)`).addColumn("worker_version", p`varchar(64)`).addColumn("worker_script_name", p`varchar(255)`).addColumn("storage_kind", p`varchar(32)`).addColumn("d1_database_id", p`varchar(64)`).addColumn("database_version", p`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", p`varchar(64)`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("results", p`text`, (e) => e.notNull()).addColumn("logs", p`text`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`, (e) => e.notNull()).addColumn("number", p`int`, (e) => e.notNull()).addColumn("code", p`text`, (e) => e.notNull()).addColumn("runtime", p`varchar(50)`).addColumn("secrets", p`text`).addColumn("dependencies", p`text`).addColumn("supported_triggers", p`text`).addColumn("deployed", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("code", p`text`, (e) => e.notNull()).addColumn("runtime", p`varchar(50)`).addColumn("status", p`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", p`text`).addColumn("dependencies", p`text`).addColumn("supported_triggers", p`text`).addColumn("deployed_at_ts", p`bigint`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addColumn("is_system", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", p`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
6377
6412
|
{
|
|
6378
6413
|
let n = e.schema.createTable("authentication_methods").addColumn("id", p`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("type", p`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", p`varchar(32)`).addColumn("totp_secret", p`varchar(255)`).addColumn("confirmed", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addColumn("credential_id", p`varchar(512)`).addColumn("public_key", p`text`).addColumn("sign_count", p`int`).addColumn("credential_backed_up", p`int`).addColumn("transports", p`varchar(512)`).addColumn("friendly_name", p`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
@@ -6559,40 +6594,40 @@ async function fs(e) {
|
|
|
6559
6594
|
"tenant_id",
|
|
6560
6595
|
"phone_number",
|
|
6561
6596
|
"provider"
|
|
6562
|
-
]).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
|
|
6597
|
+
]).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 ds) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6563
6598
|
let n = e;
|
|
6564
6599
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6565
6600
|
}).execute();
|
|
6566
6601
|
}
|
|
6567
|
-
async function
|
|
6602
|
+
async function ms(e) {
|
|
6568
6603
|
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();
|
|
6569
6604
|
}
|
|
6570
6605
|
//#endregion
|
|
6571
6606
|
//#region migrate/log.ts
|
|
6572
|
-
var
|
|
6573
|
-
function
|
|
6574
|
-
|
|
6607
|
+
var hs = !1;
|
|
6608
|
+
function gs(e) {
|
|
6609
|
+
hs = e;
|
|
6575
6610
|
}
|
|
6576
6611
|
function Y(...e) {
|
|
6577
|
-
|
|
6612
|
+
hs && console.log(...e);
|
|
6578
6613
|
}
|
|
6579
6614
|
function X(...e) {
|
|
6580
6615
|
console.warn(...e);
|
|
6581
6616
|
}
|
|
6582
6617
|
//#endregion
|
|
6583
6618
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6584
|
-
var
|
|
6585
|
-
down: () =>
|
|
6586
|
-
up: () =>
|
|
6587
|
-
}),
|
|
6588
|
-
async function
|
|
6619
|
+
var _s = /* @__PURE__ */ w({
|
|
6620
|
+
down: () => Os,
|
|
6621
|
+
up: () => Ts
|
|
6622
|
+
}), vs = 5e4, ys = 500;
|
|
6623
|
+
async function bs(e) {
|
|
6589
6624
|
try {
|
|
6590
6625
|
return await p`SELECT VERSION()`.execute(e), "mysql";
|
|
6591
6626
|
} catch {
|
|
6592
6627
|
return "sqlite";
|
|
6593
6628
|
}
|
|
6594
6629
|
}
|
|
6595
|
-
async function
|
|
6630
|
+
async function xs(e, t, n) {
|
|
6596
6631
|
try {
|
|
6597
6632
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6598
6633
|
} catch (e) {
|
|
@@ -6603,7 +6638,7 @@ async function bs(e, t, n) {
|
|
|
6603
6638
|
throw e;
|
|
6604
6639
|
}
|
|
6605
6640
|
}
|
|
6606
|
-
async function
|
|
6641
|
+
async function Ss(e, t, n, r) {
|
|
6607
6642
|
try {
|
|
6608
6643
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6609
6644
|
} catch (e) {
|
|
@@ -6614,21 +6649,21 @@ async function xs(e, t, n, r) {
|
|
|
6614
6649
|
throw e;
|
|
6615
6650
|
}
|
|
6616
6651
|
}
|
|
6617
|
-
async function
|
|
6652
|
+
async function Cs(e, t) {
|
|
6618
6653
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6619
6654
|
if (t === "sqlite") {
|
|
6620
6655
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6621
6656
|
r = Number(t.numDeletedRows);
|
|
6622
6657
|
} else {
|
|
6623
|
-
let t =
|
|
6624
|
-
for (; t >=
|
|
6625
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6658
|
+
let t = vs;
|
|
6659
|
+
for (; t >= vs;) {
|
|
6660
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(vs).executeTakeFirst();
|
|
6626
6661
|
t = Number(i.numDeletedRows), r += t, t > 0 && Y(` Pruned ${r} expired codes row(s)...`);
|
|
6627
6662
|
}
|
|
6628
6663
|
}
|
|
6629
6664
|
return r;
|
|
6630
6665
|
}
|
|
6631
|
-
async function
|
|
6666
|
+
async function ws(e) {
|
|
6632
6667
|
let t = 0;
|
|
6633
6668
|
for (;;) {
|
|
6634
6669
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6636,33 +6671,33 @@ async function Cs(e) {
|
|
|
6636
6671
|
"code_type",
|
|
6637
6672
|
"tenant_id",
|
|
6638
6673
|
"expires_at"
|
|
6639
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6674
|
+
]).where("expires_at_ts", "is", null).limit(ys).execute();
|
|
6640
6675
|
if (n.length === 0) break;
|
|
6641
6676
|
for (let t of n) {
|
|
6642
6677
|
let n = Date.parse(t.expires_at);
|
|
6643
6678
|
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();
|
|
6644
6679
|
}
|
|
6645
|
-
if (t += n.length, n.length <
|
|
6680
|
+
if (t += n.length, n.length < ys) break;
|
|
6646
6681
|
}
|
|
6647
6682
|
return t;
|
|
6648
6683
|
}
|
|
6649
|
-
async function
|
|
6650
|
-
let t = await
|
|
6684
|
+
async function Ts(e) {
|
|
6685
|
+
let t = await bs(e);
|
|
6651
6686
|
try {
|
|
6652
|
-
let n = await
|
|
6687
|
+
let n = await Cs(e, t);
|
|
6653
6688
|
Y(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6654
6689
|
} catch (e) {
|
|
6655
6690
|
X(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6656
6691
|
}
|
|
6657
|
-
await
|
|
6692
|
+
await xs(e, "codes", "expires_at_ts"), await Ss(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6658
6693
|
try {
|
|
6659
|
-
let t = await
|
|
6694
|
+
let t = await ws(e);
|
|
6660
6695
|
Y(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6661
6696
|
} catch (e) {
|
|
6662
6697
|
X(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6663
6698
|
}
|
|
6664
6699
|
}
|
|
6665
|
-
async function
|
|
6700
|
+
async function Es(e, t, n) {
|
|
6666
6701
|
try {
|
|
6667
6702
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6668
6703
|
} catch (e) {
|
|
@@ -6670,7 +6705,7 @@ async function Ts(e, t, n) {
|
|
|
6670
6705
|
throw e;
|
|
6671
6706
|
}
|
|
6672
6707
|
}
|
|
6673
|
-
async function
|
|
6708
|
+
async function Ds(e, t, n) {
|
|
6674
6709
|
try {
|
|
6675
6710
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6676
6711
|
} catch (e) {
|
|
@@ -6678,16 +6713,16 @@ async function Es(e, t, n) {
|
|
|
6678
6713
|
throw e;
|
|
6679
6714
|
}
|
|
6680
6715
|
}
|
|
6681
|
-
async function
|
|
6682
|
-
await
|
|
6716
|
+
async function Os(e) {
|
|
6717
|
+
await Es(e, "idx_codes_expires_at_ts", "codes"), await Ds(e, "codes", "expires_at_ts");
|
|
6683
6718
|
}
|
|
6684
6719
|
//#endregion
|
|
6685
6720
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6686
|
-
var
|
|
6687
|
-
down: () =>
|
|
6688
|
-
up: () =>
|
|
6721
|
+
var ks = /* @__PURE__ */ w({
|
|
6722
|
+
down: () => js,
|
|
6723
|
+
up: () => As
|
|
6689
6724
|
});
|
|
6690
|
-
async function
|
|
6725
|
+
async function As(e) {
|
|
6691
6726
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", p`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", p`varchar(128)`, (e) => e.notNull()).addColumn("scopes", p`text`, (e) => e.notNull()).addColumn("valid_until", p`varchar(35)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", p`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", p`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("external_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6692
6727
|
"tenant_id",
|
|
6693
6728
|
"connection_id",
|
|
@@ -6698,16 +6733,16 @@ async function ks(e) {
|
|
|
6698
6733
|
"external_id"
|
|
6699
6734
|
]).unique().execute();
|
|
6700
6735
|
}
|
|
6701
|
-
async function
|
|
6736
|
+
async function js(e) {
|
|
6702
6737
|
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();
|
|
6703
6738
|
}
|
|
6704
6739
|
//#endregion
|
|
6705
6740
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6706
|
-
var
|
|
6707
|
-
down: () =>
|
|
6708
|
-
up: () =>
|
|
6741
|
+
var Ms = /* @__PURE__ */ w({
|
|
6742
|
+
down: () => Is,
|
|
6743
|
+
up: () => Ps
|
|
6709
6744
|
});
|
|
6710
|
-
async function
|
|
6745
|
+
async function Ns(e, t, n) {
|
|
6711
6746
|
try {
|
|
6712
6747
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6713
6748
|
} catch (e) {
|
|
@@ -6715,10 +6750,10 @@ async function Ms(e, t, n) {
|
|
|
6715
6750
|
throw e;
|
|
6716
6751
|
}
|
|
6717
6752
|
}
|
|
6718
|
-
async function
|
|
6719
|
-
await
|
|
6753
|
+
async function Ps(e) {
|
|
6754
|
+
await Ns(e, "users", "blocked");
|
|
6720
6755
|
}
|
|
6721
|
-
async function
|
|
6756
|
+
async function Fs(e, t, n) {
|
|
6722
6757
|
try {
|
|
6723
6758
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6724
6759
|
} catch (e) {
|
|
@@ -6726,16 +6761,16 @@ async function Ps(e, t, n) {
|
|
|
6726
6761
|
throw e;
|
|
6727
6762
|
}
|
|
6728
6763
|
}
|
|
6729
|
-
async function
|
|
6730
|
-
await
|
|
6764
|
+
async function Is(e) {
|
|
6765
|
+
await Fs(e, "users", "blocked");
|
|
6731
6766
|
}
|
|
6732
6767
|
//#endregion
|
|
6733
6768
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6734
|
-
var
|
|
6735
|
-
down: () =>
|
|
6736
|
-
up: () =>
|
|
6769
|
+
var Ls = /* @__PURE__ */ w({
|
|
6770
|
+
down: () => Vs,
|
|
6771
|
+
up: () => zs
|
|
6737
6772
|
});
|
|
6738
|
-
async function
|
|
6773
|
+
async function Rs(e, t, n) {
|
|
6739
6774
|
try {
|
|
6740
6775
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6741
6776
|
} catch (e) {
|
|
@@ -6743,10 +6778,10 @@ async function Ls(e, t, n) {
|
|
|
6743
6778
|
throw e;
|
|
6744
6779
|
}
|
|
6745
6780
|
}
|
|
6746
|
-
async function
|
|
6747
|
-
await
|
|
6781
|
+
async function zs(e) {
|
|
6782
|
+
await Rs(e, "prompt_settings", "show_last_used_connection");
|
|
6748
6783
|
}
|
|
6749
|
-
async function
|
|
6784
|
+
async function Bs(e, t, n) {
|
|
6750
6785
|
try {
|
|
6751
6786
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6752
6787
|
} catch (e) {
|
|
@@ -6754,16 +6789,16 @@ async function zs(e, t, n) {
|
|
|
6754
6789
|
throw e;
|
|
6755
6790
|
}
|
|
6756
6791
|
}
|
|
6757
|
-
async function
|
|
6758
|
-
await
|
|
6792
|
+
async function Vs(e) {
|
|
6793
|
+
await Bs(e, "prompt_settings", "show_last_used_connection");
|
|
6759
6794
|
}
|
|
6760
6795
|
//#endregion
|
|
6761
6796
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6762
|
-
var
|
|
6763
|
-
down: () =>
|
|
6764
|
-
up: () =>
|
|
6797
|
+
var Hs = /* @__PURE__ */ w({
|
|
6798
|
+
down: () => Gs,
|
|
6799
|
+
up: () => Ws
|
|
6765
6800
|
});
|
|
6766
|
-
async function
|
|
6801
|
+
async function Us(e, t, n, r) {
|
|
6767
6802
|
try {
|
|
6768
6803
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6769
6804
|
} catch (e) {
|
|
@@ -6774,10 +6809,10 @@ async function Hs(e, t, n, r) {
|
|
|
6774
6809
|
throw e;
|
|
6775
6810
|
}
|
|
6776
6811
|
}
|
|
6777
|
-
async function Us(e) {
|
|
6778
|
-
await Hs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6779
|
-
}
|
|
6780
6812
|
async function Ws(e) {
|
|
6813
|
+
await Us(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6814
|
+
}
|
|
6815
|
+
async function Gs(e) {
|
|
6781
6816
|
try {
|
|
6782
6817
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6783
6818
|
} catch (e) {
|
|
@@ -6787,11 +6822,11 @@ async function Ws(e) {
|
|
|
6787
6822
|
}
|
|
6788
6823
|
//#endregion
|
|
6789
6824
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6790
|
-
var
|
|
6791
|
-
down: () =>
|
|
6792
|
-
up: () =>
|
|
6825
|
+
var Ks = /* @__PURE__ */ w({
|
|
6826
|
+
down: () => Xs,
|
|
6827
|
+
up: () => Js
|
|
6793
6828
|
});
|
|
6794
|
-
async function
|
|
6829
|
+
async function qs(e, t, n, r) {
|
|
6795
6830
|
try {
|
|
6796
6831
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6797
6832
|
} catch (e) {
|
|
@@ -6799,10 +6834,10 @@ async function Ks(e, t, n, r) {
|
|
|
6799
6834
|
throw e;
|
|
6800
6835
|
}
|
|
6801
6836
|
}
|
|
6802
|
-
async function
|
|
6803
|
-
await
|
|
6837
|
+
async function Js(e) {
|
|
6838
|
+
await qs(e, "hooks", "page_id", p`varchar(64)`), await qs(e, "hooks", "permission_required", p`varchar(255)`);
|
|
6804
6839
|
}
|
|
6805
|
-
async function
|
|
6840
|
+
async function Ys(e, t, n) {
|
|
6806
6841
|
try {
|
|
6807
6842
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6808
6843
|
} catch (e) {
|
|
@@ -6810,22 +6845,22 @@ async function Js(e, t, n) {
|
|
|
6810
6845
|
throw e;
|
|
6811
6846
|
}
|
|
6812
6847
|
}
|
|
6813
|
-
async function
|
|
6814
|
-
await
|
|
6848
|
+
async function Xs(e) {
|
|
6849
|
+
await Ys(e, "hooks", "permission_required"), await Ys(e, "hooks", "page_id");
|
|
6815
6850
|
}
|
|
6816
6851
|
//#endregion
|
|
6817
6852
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6818
|
-
var
|
|
6819
|
-
down: () =>
|
|
6820
|
-
up: () =>
|
|
6821
|
-
}),
|
|
6853
|
+
var Zs = /* @__PURE__ */ w({
|
|
6854
|
+
down: () => rc,
|
|
6855
|
+
up: () => tc
|
|
6856
|
+
}), Qs = [
|
|
6822
6857
|
["session_id", p`varchar(26)`],
|
|
6823
6858
|
["organization", p`varchar(191)`],
|
|
6824
6859
|
["auth_connection", p`varchar(255)`],
|
|
6825
6860
|
["auth_strategy_strategy", p`varchar(64)`],
|
|
6826
6861
|
["auth_strategy_strategy_type", p`varchar(64)`]
|
|
6827
6862
|
];
|
|
6828
|
-
async function
|
|
6863
|
+
async function $s(e, t, n, r) {
|
|
6829
6864
|
try {
|
|
6830
6865
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6831
6866
|
} catch (e) {
|
|
@@ -6833,7 +6868,7 @@ async function Qs(e, t, n, r) {
|
|
|
6833
6868
|
throw e;
|
|
6834
6869
|
}
|
|
6835
6870
|
}
|
|
6836
|
-
async function
|
|
6871
|
+
async function ec(e) {
|
|
6837
6872
|
try {
|
|
6838
6873
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6839
6874
|
} catch (e) {
|
|
@@ -6841,11 +6876,11 @@ async function $s(e) {
|
|
|
6841
6876
|
throw e;
|
|
6842
6877
|
}
|
|
6843
6878
|
}
|
|
6844
|
-
async function
|
|
6845
|
-
for (let [t, n] of
|
|
6846
|
-
await
|
|
6879
|
+
async function tc(e) {
|
|
6880
|
+
for (let [t, n] of Qs) await $s(e, "refresh_tokens", t, n);
|
|
6881
|
+
await ec(e);
|
|
6847
6882
|
}
|
|
6848
|
-
async function
|
|
6883
|
+
async function nc(e, t, n) {
|
|
6849
6884
|
try {
|
|
6850
6885
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6851
6886
|
} catch (e) {
|
|
@@ -6853,23 +6888,23 @@ async function tc(e, t, n) {
|
|
|
6853
6888
|
throw e;
|
|
6854
6889
|
}
|
|
6855
6890
|
}
|
|
6856
|
-
async function
|
|
6891
|
+
async function rc(e) {
|
|
6857
6892
|
try {
|
|
6858
6893
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6859
6894
|
} catch {}
|
|
6860
|
-
for (let [t] of
|
|
6895
|
+
for (let [t] of Qs) await nc(e, "refresh_tokens", t);
|
|
6861
6896
|
}
|
|
6862
6897
|
//#endregion
|
|
6863
6898
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6864
|
-
var
|
|
6865
|
-
down: () =>
|
|
6866
|
-
up: () =>
|
|
6867
|
-
}),
|
|
6868
|
-
async function
|
|
6899
|
+
var ic = /* @__PURE__ */ w({
|
|
6900
|
+
down: () => uc,
|
|
6901
|
+
up: () => lc
|
|
6902
|
+
}), ac = 500, oc = 20, sc = 500, cc = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6903
|
+
async function lc(e) {
|
|
6869
6904
|
try {
|
|
6870
6905
|
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);
|
|
6871
|
-
if (n >
|
|
6872
|
-
X(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6906
|
+
if (n > sc) {
|
|
6907
|
+
X(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${sc}. SKIPPING — run the bulk path instead: ${cc}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6873
6908
|
return;
|
|
6874
6909
|
}
|
|
6875
6910
|
if (n === 0) {
|
|
@@ -6886,10 +6921,10 @@ async function cc(e) {
|
|
|
6886
6921
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6887
6922
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6888
6923
|
"login_sessions.auth_params as ls_auth_params"
|
|
6889
|
-
]).limit(
|
|
6924
|
+
]).limit(ac).execute();
|
|
6890
6925
|
if (t.length === 0) break;
|
|
6891
|
-
for (let n = 0; n < t.length; n +=
|
|
6892
|
-
let r = t.slice(n, n +
|
|
6926
|
+
for (let n = 0; n < t.length; n += oc) {
|
|
6927
|
+
let r = t.slice(n, n + oc);
|
|
6893
6928
|
await Promise.all(r.map(async (t) => {
|
|
6894
6929
|
let n = null;
|
|
6895
6930
|
if (t.ls_auth_params) try {
|
|
@@ -6906,19 +6941,19 @@ async function cc(e) {
|
|
|
6906
6941
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6907
6942
|
}));
|
|
6908
6943
|
}
|
|
6909
|
-
if (r += t.length, Y(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6944
|
+
if (r += t.length, Y(`refresh_tokens backfill: ${r} rows populated so far`), t.length < ac) break;
|
|
6910
6945
|
}
|
|
6911
6946
|
Y(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6912
6947
|
} catch (e) {
|
|
6913
6948
|
throw X("refresh_tokens backfill failed:", e), e;
|
|
6914
6949
|
}
|
|
6915
6950
|
}
|
|
6916
|
-
async function
|
|
6951
|
+
async function uc() {}
|
|
6917
6952
|
//#endregion
|
|
6918
6953
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6919
|
-
var
|
|
6920
|
-
down: () =>
|
|
6921
|
-
up: () =>
|
|
6954
|
+
var dc = /* @__PURE__ */ w({
|
|
6955
|
+
down: () => mc,
|
|
6956
|
+
up: () => pc
|
|
6922
6957
|
});
|
|
6923
6958
|
async function Z(e, t, n, r) {
|
|
6924
6959
|
try {
|
|
@@ -6928,7 +6963,7 @@ async function Z(e, t, n, r) {
|
|
|
6928
6963
|
throw e;
|
|
6929
6964
|
}
|
|
6930
6965
|
}
|
|
6931
|
-
async function
|
|
6966
|
+
async function fc(e, t, n, r) {
|
|
6932
6967
|
try {
|
|
6933
6968
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6934
6969
|
} catch (e) {
|
|
@@ -6936,12 +6971,12 @@ async function dc(e, t, n, r) {
|
|
|
6936
6971
|
throw e;
|
|
6937
6972
|
}
|
|
6938
6973
|
}
|
|
6939
|
-
async function
|
|
6940
|
-
await Z(e, "tenant_operations", "input", p`text`), await Z(e, "tenant_operations", "result", p`text`), await Z(e, "tenant_operations", "claimed_by", p`varchar(255)`), await Z(e, "tenant_operations", "claim_expires_at", p`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", p`varchar(255)`, (e) => e.notNull()).addColumn("seq", p`int`, (e) => e.notNull()).addColumn("payload", p`text`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("error_code", p`varchar(64)`).addColumn("error_message", p`text`).addColumn("error_path", p`varchar(255)`).addColumn("entity_id", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await
|
|
6974
|
+
async function pc(e) {
|
|
6975
|
+
await Z(e, "tenant_operations", "input", p`text`), await Z(e, "tenant_operations", "result", p`text`), await Z(e, "tenant_operations", "claimed_by", p`varchar(255)`), await Z(e, "tenant_operations", "claim_expires_at", p`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", p`varchar(255)`, (e) => e.notNull()).addColumn("seq", p`int`, (e) => e.notNull()).addColumn("payload", p`text`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("error_code", p`varchar(64)`).addColumn("error_message", p`text`).addColumn("error_path", p`varchar(255)`).addColumn("entity_id", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await fc(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6941
6976
|
"operation_id",
|
|
6942
6977
|
"status",
|
|
6943
6978
|
"seq"
|
|
6944
|
-
]), await
|
|
6979
|
+
]), await fc(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6945
6980
|
"kind",
|
|
6946
6981
|
"status",
|
|
6947
6982
|
"created_at"
|
|
@@ -6955,7 +6990,7 @@ async function Q(e, t, n) {
|
|
|
6955
6990
|
throw e;
|
|
6956
6991
|
}
|
|
6957
6992
|
}
|
|
6958
|
-
async function
|
|
6993
|
+
async function mc(e) {
|
|
6959
6994
|
try {
|
|
6960
6995
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6961
6996
|
} catch {}
|
|
@@ -6963,11 +6998,11 @@ async function pc(e) {
|
|
|
6963
6998
|
}
|
|
6964
6999
|
//#endregion
|
|
6965
7000
|
//#region migrate/migrations/2026-09-25T12:00:00_token_exchange_profiles.ts
|
|
6966
|
-
var
|
|
6967
|
-
down: () =>
|
|
6968
|
-
up: () =>
|
|
7001
|
+
var hc = /* @__PURE__ */ w({
|
|
7002
|
+
down: () => yc,
|
|
7003
|
+
up: () => vc
|
|
6969
7004
|
});
|
|
6970
|
-
async function
|
|
7005
|
+
async function gc(e, t, n, r) {
|
|
6971
7006
|
try {
|
|
6972
7007
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6973
7008
|
} catch (e) {
|
|
@@ -6975,7 +7010,7 @@ async function hc(e, t, n, r) {
|
|
|
6975
7010
|
throw e;
|
|
6976
7011
|
}
|
|
6977
7012
|
}
|
|
6978
|
-
async function
|
|
7013
|
+
async function _c(e, t, n, r) {
|
|
6979
7014
|
try {
|
|
6980
7015
|
await e.schema.createIndex(t).on(n).columns(r).unique().execute();
|
|
6981
7016
|
} catch (e) {
|
|
@@ -6983,10 +7018,10 @@ async function gc(e, t, n, r) {
|
|
|
6983
7018
|
throw e;
|
|
6984
7019
|
}
|
|
6985
7020
|
}
|
|
6986
|
-
async function _c(e) {
|
|
6987
|
-
await e.schema.createTable("token_exchange_profiles").ifNotExists().addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("subject_token_type", p`varchar(255)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`).addColumn("type", p`varchar(64)`, (e) => e.notNull()).addColumn("jwt_verification", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("token_exchange_profiles_pk", ["id"]).execute(), await gc(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await hc(e, "clients", "token_exchange", p`text`);
|
|
6988
|
-
}
|
|
6989
7021
|
async function vc(e) {
|
|
7022
|
+
await e.schema.createTable("token_exchange_profiles").ifNotExists().addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("subject_token_type", p`varchar(255)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`).addColumn("type", p`varchar(64)`, (e) => e.notNull()).addColumn("jwt_verification", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("token_exchange_profiles_pk", ["id"]).execute(), await _c(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await gc(e, "clients", "token_exchange", p`text`);
|
|
7023
|
+
}
|
|
7024
|
+
async function yc(e) {
|
|
6990
7025
|
await e.schema.dropTable("token_exchange_profiles").ifExists().execute();
|
|
6991
7026
|
try {
|
|
6992
7027
|
await e.schema.alterTable("clients").dropColumn("token_exchange").execute();
|
|
@@ -6996,37 +7031,50 @@ async function vc(e) {
|
|
|
6996
7031
|
}
|
|
6997
7032
|
}
|
|
6998
7033
|
//#endregion
|
|
7034
|
+
//#region migrate/migrations/2026-10-13T12:00:00_prompt_partials.ts
|
|
7035
|
+
var bc = /* @__PURE__ */ w({
|
|
7036
|
+
down: () => Sc,
|
|
7037
|
+
up: () => xc
|
|
7038
|
+
});
|
|
7039
|
+
async function xc(e) {
|
|
7040
|
+
await e.schema.createTable("prompt_partials").ifNotExists().addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("prompt", p`varchar(64)`, (e) => e.notNull()).addColumn("body", p`text`, (e) => e.notNull()).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("prompt_partials_pk", ["tenant_id", "prompt"]).execute();
|
|
7041
|
+
}
|
|
7042
|
+
async function Sc(e) {
|
|
7043
|
+
await e.schema.dropTable("prompt_partials").ifExists().execute();
|
|
7044
|
+
}
|
|
7045
|
+
//#endregion
|
|
6999
7046
|
//#region migrate/migrations/index.ts
|
|
7000
|
-
var
|
|
7001
|
-
"2026-07-16T14:00:00_baseline":
|
|
7002
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
7003
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
7004
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
7005
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
7006
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
7007
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
7008
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
7009
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
7010
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
7011
|
-
"2026-09-25T12:00:00_token_exchange_profiles":
|
|
7047
|
+
var Cc = {
|
|
7048
|
+
"2026-07-16T14:00:00_baseline": us,
|
|
7049
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": _s,
|
|
7050
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": ks,
|
|
7051
|
+
"2026-08-05T12:00:00_user_blocked": Ms,
|
|
7052
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Ls,
|
|
7053
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Hs,
|
|
7054
|
+
"2026-08-11T12:00:00_page_hooks": Ks,
|
|
7055
|
+
"2026-08-20T12:00:00_refresh_token_session_id": Zs,
|
|
7056
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": ic,
|
|
7057
|
+
"2026-09-01T12:00:00_tenant_operation_rows": dc,
|
|
7058
|
+
"2026-09-25T12:00:00_token_exchange_profiles": hc,
|
|
7059
|
+
"2026-10-13T12:00:00_prompt_partials": bc
|
|
7012
7060
|
};
|
|
7013
7061
|
//#endregion
|
|
7014
7062
|
//#region migrate/migrate.ts
|
|
7015
|
-
async function
|
|
7016
|
-
|
|
7063
|
+
async function wc(e, t = !1) {
|
|
7064
|
+
gs(t), t && console.log("migrating...");
|
|
7017
7065
|
let { error: n, results: r } = await new ke({
|
|
7018
7066
|
db: e,
|
|
7019
|
-
provider: new
|
|
7067
|
+
provider: new ls(Cc)
|
|
7020
7068
|
}).migrateToLatest();
|
|
7021
7069
|
if (r?.forEach((e) => {
|
|
7022
7070
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
7023
7071
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
7024
7072
|
}
|
|
7025
|
-
async function
|
|
7026
|
-
|
|
7073
|
+
async function Tc(e, t = !1) {
|
|
7074
|
+
gs(t), t && console.log("migrating...");
|
|
7027
7075
|
let { error: n, results: r } = await new ke({
|
|
7028
7076
|
db: e,
|
|
7029
|
-
provider: new
|
|
7077
|
+
provider: new ls(Cc)
|
|
7030
7078
|
}).migrateDown();
|
|
7031
7079
|
if (r?.forEach((e) => {
|
|
7032
7080
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -7034,22 +7082,22 @@ async function xc(e, t = !1) {
|
|
|
7034
7082
|
}
|
|
7035
7083
|
//#endregion
|
|
7036
7084
|
//#region migrate/plan.ts
|
|
7037
|
-
var
|
|
7038
|
-
function
|
|
7085
|
+
var Ec = 5e3, Dc = class extends Error {};
|
|
7086
|
+
function Oc(e) {
|
|
7039
7087
|
if (e.query.kind === "SelectQueryNode") return !0;
|
|
7040
7088
|
if (e.query.kind !== "RawNode") return !1;
|
|
7041
7089
|
let t = e.sql.trimStart();
|
|
7042
7090
|
return /^(select|show|explain|describe|desc)\b/i.test(t) ? !0 : /^pragma\b/i.test(t) && !t.includes("=");
|
|
7043
7091
|
}
|
|
7044
|
-
var
|
|
7092
|
+
var kc = class {
|
|
7045
7093
|
inner;
|
|
7046
7094
|
captured;
|
|
7047
7095
|
constructor(e, t) {
|
|
7048
7096
|
this.inner = e, this.captured = t;
|
|
7049
7097
|
}
|
|
7050
7098
|
async executeQuery(e) {
|
|
7051
|
-
if (
|
|
7052
|
-
if (this.captured.length >=
|
|
7099
|
+
if (Oc(e)) return this.inner.executeQuery(e);
|
|
7100
|
+
if (this.captured.length >= Ec) throw new Dc(`stopped after ${Ec} statements`);
|
|
7053
7101
|
return this.captured.push({
|
|
7054
7102
|
sql: e.sql,
|
|
7055
7103
|
parameters: e.parameters
|
|
@@ -7065,7 +7113,7 @@ var Tc = class {
|
|
|
7065
7113
|
function $() {
|
|
7066
7114
|
throw Error("not available in a migration dry run");
|
|
7067
7115
|
}
|
|
7068
|
-
var
|
|
7116
|
+
var Ac = {
|
|
7069
7117
|
init: async () => {},
|
|
7070
7118
|
acquireConnection: $,
|
|
7071
7119
|
beginTransaction: $,
|
|
@@ -7074,25 +7122,25 @@ var Ec = {
|
|
|
7074
7122
|
releaseConnection: $,
|
|
7075
7123
|
destroy: async () => {}
|
|
7076
7124
|
};
|
|
7077
|
-
function
|
|
7078
|
-
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new
|
|
7125
|
+
function jc(e, t) {
|
|
7126
|
+
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new kc(n, t))) }), i = {
|
|
7079
7127
|
createAdapter: () => n.adapter,
|
|
7080
|
-
createDriver: () =>
|
|
7128
|
+
createDriver: () => Ac,
|
|
7081
7129
|
createQueryCompiler: () => $(),
|
|
7082
7130
|
createIntrospector: () => $()
|
|
7083
7131
|
};
|
|
7084
7132
|
return new f({
|
|
7085
7133
|
config: { dialect: i },
|
|
7086
7134
|
dialect: i,
|
|
7087
|
-
driver:
|
|
7135
|
+
driver: Ac,
|
|
7088
7136
|
executor: r
|
|
7089
7137
|
});
|
|
7090
7138
|
}
|
|
7091
|
-
async function
|
|
7092
|
-
|
|
7139
|
+
async function Mc(e) {
|
|
7140
|
+
gs(!1);
|
|
7093
7141
|
let t = await new ke({
|
|
7094
7142
|
db: e,
|
|
7095
|
-
provider: new
|
|
7143
|
+
provider: new ls(Cc)
|
|
7096
7144
|
}).getMigrations(), n = t.filter((e) => e.executedAt).map((e) => e.name), r = t.filter((e) => !e.executedAt), i = n[n.length - 1], a = i ? r.find((e) => e.name < i) : void 0;
|
|
7097
7145
|
if (a) throw Error(`pending migration "${a.name}" sorts before already-executed "${i}"; migrateToLatest would refuse to run`);
|
|
7098
7146
|
let o = [];
|
|
@@ -7102,9 +7150,9 @@ async function Oc(e) {
|
|
|
7102
7150
|
statements: n
|
|
7103
7151
|
};
|
|
7104
7152
|
try {
|
|
7105
|
-
await t.migration.up(
|
|
7153
|
+
await t.migration.up(jc(e, n));
|
|
7106
7154
|
} catch (e) {
|
|
7107
|
-
r.error = e instanceof Error ? e.message : String(e), e instanceof
|
|
7155
|
+
r.error = e instanceof Error ? e.message : String(e), e instanceof Dc && (r.truncated = !0);
|
|
7108
7156
|
}
|
|
7109
7157
|
o.push(r);
|
|
7110
7158
|
}
|
|
@@ -7113,7 +7161,7 @@ async function Oc(e) {
|
|
|
7113
7161
|
pending: o
|
|
7114
7162
|
};
|
|
7115
7163
|
}
|
|
7116
|
-
function
|
|
7164
|
+
function Nc(e) {
|
|
7117
7165
|
if (e.pending.length === 0) return `-- Database is up to date (${e.executed.length} migrations executed).`;
|
|
7118
7166
|
let t = [`-- ${e.pending.length} pending migration(s); ${e.executed.length} already executed.`];
|
|
7119
7167
|
for (let n of e.pending) {
|
|
@@ -7128,7 +7176,7 @@ function kc(e) {
|
|
|
7128
7176
|
}
|
|
7129
7177
|
//#endregion
|
|
7130
7178
|
//#region src/index.ts
|
|
7131
|
-
function
|
|
7179
|
+
function Pc(e, t = { useTransactions: !0 }) {
|
|
7132
7180
|
let n = {
|
|
7133
7181
|
actions: Xe(e),
|
|
7134
7182
|
actionExecutions: rt(e),
|
|
@@ -7140,54 +7188,55 @@ function Ac(e, t = { useTransactions: !0 }) {
|
|
|
7140
7188
|
clientRegistrationTokens: or(e),
|
|
7141
7189
|
codes: bn(e),
|
|
7142
7190
|
connections: Dn(e),
|
|
7143
|
-
emailProviders:
|
|
7144
|
-
emailTemplates:
|
|
7191
|
+
emailProviders: si(e),
|
|
7192
|
+
emailTemplates: mi(e),
|
|
7145
7193
|
customDomains: _r(e),
|
|
7146
7194
|
flows: Ft(e),
|
|
7147
|
-
forms:
|
|
7195
|
+
forms: Ni(e),
|
|
7148
7196
|
hookCode: Fr(e),
|
|
7149
7197
|
hooks: Ar(e),
|
|
7150
|
-
invites:
|
|
7198
|
+
invites: Ra(e),
|
|
7151
7199
|
keys: ur(e),
|
|
7152
7200
|
loginSessions: Zr(e),
|
|
7153
7201
|
logs: Qt(e),
|
|
7154
|
-
logStreams:
|
|
7155
|
-
migrationSources:
|
|
7156
|
-
authenticationMethods:
|
|
7202
|
+
logStreams: xo(e),
|
|
7203
|
+
migrationSources: So(e),
|
|
7204
|
+
authenticationMethods: co(e),
|
|
7157
7205
|
passwords: un(e),
|
|
7158
7206
|
promptSettings: ti(e),
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7207
|
+
promptPartials: ni(e),
|
|
7208
|
+
proxyRoutes: Eo(e),
|
|
7209
|
+
scimConfigurations: Io(e),
|
|
7210
|
+
scimTokens: Ro(e),
|
|
7211
|
+
scimExternalIds: Bo(e),
|
|
7212
|
+
refreshTokens: Ti(e),
|
|
7213
|
+
resourceServers: Bi(e),
|
|
7214
|
+
rolePermissions: ta(e),
|
|
7215
|
+
grants: sa(e),
|
|
7216
|
+
userPermissions: fa(e),
|
|
7217
|
+
userRoles: va(e),
|
|
7218
|
+
roles: qi(e),
|
|
7170
7219
|
sessions: an(e),
|
|
7171
|
-
sessionCleanup:
|
|
7220
|
+
sessionCleanup: Di(e),
|
|
7172
7221
|
tenants: Ut(e),
|
|
7173
|
-
tenantOperations:
|
|
7174
|
-
tenantOperationEvents:
|
|
7175
|
-
tenantOperationRows:
|
|
7176
|
-
tokenExchangeProfiles:
|
|
7177
|
-
rollouts:
|
|
7222
|
+
tenantOperations: Ho(e),
|
|
7223
|
+
tenantOperationEvents: ts(e),
|
|
7224
|
+
tenantOperationRows: as(e),
|
|
7225
|
+
tokenExchangeProfiles: Mo(e),
|
|
7226
|
+
rollouts: cs(e),
|
|
7178
7227
|
themes: Br(e),
|
|
7179
7228
|
universalLoginTemplates: wr(e),
|
|
7180
|
-
customText:
|
|
7229
|
+
customText: to(e),
|
|
7181
7230
|
users: Dt(e),
|
|
7182
7231
|
userActivity: wt(e),
|
|
7183
|
-
organizations:
|
|
7184
|
-
organizationConnections:
|
|
7185
|
-
userOrganizations:
|
|
7186
|
-
stats:
|
|
7187
|
-
analytics:
|
|
7188
|
-
outbox:
|
|
7232
|
+
organizations: wa(e),
|
|
7233
|
+
organizationConnections: Ta(e),
|
|
7234
|
+
userOrganizations: Ma(e),
|
|
7235
|
+
stats: Ua(e),
|
|
7236
|
+
analytics: eo(e),
|
|
7237
|
+
outbox: bo(e),
|
|
7189
7238
|
async transaction(r) {
|
|
7190
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
7239
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Pc(e, {
|
|
7191
7240
|
...t,
|
|
7192
7241
|
useTransactions: !1
|
|
7193
7242
|
})));
|
|
@@ -7196,4 +7245,4 @@ function Ac(e, t = { useTransactions: !0 }) {
|
|
|
7196
7245
|
return n;
|
|
7197
7246
|
}
|
|
7198
7247
|
//#endregion
|
|
7199
|
-
export {
|
|
7248
|
+
export { Oo as createProxyDataAdapter, Eo as createProxyRoutesAdapter, Pc as default, Nc as formatMigrationPlan, Tc as migrateDown, wc as migrateToLatest, Mc as planMigrations };
|