@authhero/kysely-adapter 12.10.0 → 12.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -199,14 +199,14 @@ function E(e, t, n, r, i = [], a = {}) {
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/actions/list.ts
|
|
202
|
-
function
|
|
202
|
+
function Ge(e) {
|
|
203
203
|
if (e) try {
|
|
204
204
|
return JSON.parse(e);
|
|
205
205
|
} catch {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Ke(e) {
|
|
210
210
|
return async (t, n = {}) => {
|
|
211
211
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
212
212
|
c && (l = E(e, l, c, ["name"]));
|
|
@@ -222,9 +222,9 @@ function Ge(e) {
|
|
|
222
222
|
runtime: f.runtime ?? void 0,
|
|
223
223
|
status: f.status || "built",
|
|
224
224
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
225
|
-
secrets:
|
|
226
|
-
dependencies:
|
|
227
|
-
supported_triggers:
|
|
225
|
+
secrets: Ge(o),
|
|
226
|
+
dependencies: Ge(s),
|
|
227
|
+
supported_triggers: Ge(c),
|
|
228
228
|
is_system: !!l,
|
|
229
229
|
inherit: !!u
|
|
230
230
|
};
|
|
@@ -246,7 +246,7 @@ function Ge(e) {
|
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/actions/update.ts
|
|
249
|
-
function
|
|
249
|
+
function qe(e) {
|
|
250
250
|
if (!e) return [];
|
|
251
251
|
try {
|
|
252
252
|
let t = JSON.parse(e);
|
|
@@ -255,11 +255,11 @@ function Ke(e) {
|
|
|
255
255
|
return [];
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Je(e) {
|
|
259
259
|
return async (t, n, r) => {
|
|
260
260
|
let i = { updated_at_ts: Date.now() };
|
|
261
261
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
262
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
262
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(qe(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
263
263
|
name: e.name,
|
|
264
264
|
value: o.get(e.name)?.value
|
|
265
265
|
} : e);
|
|
@@ -274,23 +274,23 @@ function qe(e) {
|
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
276
|
//#region src/actions/remove.ts
|
|
277
|
-
function
|
|
277
|
+
function Ye(e) {
|
|
278
278
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
279
279
|
}
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/actions/index.ts
|
|
282
|
-
function
|
|
282
|
+
function Xe(e) {
|
|
283
283
|
return {
|
|
284
284
|
create: Ve(e),
|
|
285
285
|
get: Ue(e),
|
|
286
|
-
list:
|
|
287
|
-
update:
|
|
288
|
-
remove:
|
|
286
|
+
list: Ke(e),
|
|
287
|
+
update: Je(e),
|
|
288
|
+
remove: Ye(e)
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/actionExecutions/create.ts
|
|
293
|
-
function
|
|
293
|
+
function Ze(e) {
|
|
294
294
|
return async (t, n) => {
|
|
295
295
|
let r = Date.now();
|
|
296
296
|
return await e.insertInto("action_executions").values({
|
|
@@ -316,14 +316,14 @@ function Xe(e) {
|
|
|
316
316
|
}
|
|
317
317
|
//#endregion
|
|
318
318
|
//#region src/actionExecutions/get.ts
|
|
319
|
-
function
|
|
319
|
+
function Qe(e) {
|
|
320
320
|
if (e) try {
|
|
321
321
|
return JSON.parse(e);
|
|
322
322
|
} catch {
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function $e(e) {
|
|
327
327
|
return async (t, n) => {
|
|
328
328
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
329
329
|
return r ? {
|
|
@@ -331,8 +331,8 @@ function Qe(e) {
|
|
|
331
331
|
tenant_id: r.tenant_id,
|
|
332
332
|
trigger_id: r.trigger_id,
|
|
333
333
|
status: r.status,
|
|
334
|
-
results:
|
|
335
|
-
logs:
|
|
334
|
+
results: Qe(r.results) ?? [],
|
|
335
|
+
logs: Qe(r.logs),
|
|
336
336
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
337
337
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
338
338
|
} : null;
|
|
@@ -340,7 +340,7 @@ function Qe(e) {
|
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
342
342
|
//#region src/helpers/database-type.ts
|
|
343
|
-
async function
|
|
343
|
+
async function et(e) {
|
|
344
344
|
try {
|
|
345
345
|
return await p`SELECT VERSION()`.execute(e), "mysql";
|
|
346
346
|
} catch {
|
|
@@ -349,19 +349,19 @@ async function $e(e) {
|
|
|
349
349
|
}
|
|
350
350
|
//#endregion
|
|
351
351
|
//#region src/actionExecutions/cleanup.ts
|
|
352
|
-
var
|
|
353
|
-
function
|
|
352
|
+
var tt = 5e4;
|
|
353
|
+
function nt(e) {
|
|
354
354
|
let t;
|
|
355
355
|
return async (n) => {
|
|
356
356
|
let r = Date.parse(n);
|
|
357
357
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
358
|
-
if (t ??= await
|
|
358
|
+
if (t ??= await et(e), t === "sqlite") {
|
|
359
359
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
360
360
|
return Number(t.numDeletedRows);
|
|
361
361
|
}
|
|
362
|
-
let i = 0, a =
|
|
363
|
-
for (; a >=
|
|
364
|
-
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(
|
|
362
|
+
let i = 0, a = tt;
|
|
363
|
+
for (; a >= tt;) {
|
|
364
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(tt).executeTakeFirst();
|
|
365
365
|
a = Number(t.numDeletedRows), i += a;
|
|
366
366
|
}
|
|
367
367
|
return i;
|
|
@@ -369,36 +369,36 @@ function et(e) {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/actionExecutions/index.ts
|
|
372
|
-
function
|
|
372
|
+
function rt(e) {
|
|
373
373
|
return {
|
|
374
|
-
create:
|
|
375
|
-
get:
|
|
376
|
-
cleanup:
|
|
374
|
+
create: Ze(e),
|
|
375
|
+
get: $e(e),
|
|
376
|
+
cleanup: nt(e)
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/actionVersions/index.ts
|
|
381
|
-
function
|
|
381
|
+
function it(e) {
|
|
382
382
|
if (e) try {
|
|
383
383
|
return JSON.parse(e);
|
|
384
384
|
} catch {
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function at(e) {
|
|
389
389
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
390
390
|
return {
|
|
391
391
|
...c,
|
|
392
392
|
runtime: s ?? void 0,
|
|
393
393
|
deployed: !!o,
|
|
394
|
-
secrets:
|
|
395
|
-
dependencies:
|
|
396
|
-
supported_triggers:
|
|
394
|
+
secrets: it(r),
|
|
395
|
+
dependencies: it(i),
|
|
396
|
+
supported_triggers: it(a),
|
|
397
397
|
created_at: new Date(Number(t)).toISOString(),
|
|
398
398
|
updated_at: new Date(Number(n)).toISOString()
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function ot(e) {
|
|
402
402
|
return {
|
|
403
403
|
async create(t, n, r) {
|
|
404
404
|
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? Ie(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
@@ -438,10 +438,10 @@ function rt(e) {
|
|
|
438
438
|
},
|
|
439
439
|
async get(t, n, r) {
|
|
440
440
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
441
|
-
return i ?
|
|
441
|
+
return i ? at(i) : null;
|
|
442
442
|
},
|
|
443
443
|
async list(t, n, r = {}) {
|
|
444
|
-
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(
|
|
444
|
+
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(at);
|
|
445
445
|
if (!s) return {
|
|
446
446
|
versions: l,
|
|
447
447
|
start: 0,
|
|
@@ -464,7 +464,7 @@ function rt(e) {
|
|
|
464
464
|
}
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/outbox/create.ts
|
|
467
|
-
async function
|
|
467
|
+
async function D(e, t, n, r) {
|
|
468
468
|
await e.insertInto("outbox_events").values({
|
|
469
469
|
id: n,
|
|
470
470
|
tenant_id: t,
|
|
@@ -483,15 +483,15 @@ async function A(e, t, n, r) {
|
|
|
483
483
|
error: null
|
|
484
484
|
}).execute();
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function st(e) {
|
|
487
487
|
return async (n, r) => {
|
|
488
488
|
let i = t();
|
|
489
|
-
return await
|
|
489
|
+
return await D(e, n, i, r), i;
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/users/create.ts
|
|
494
|
-
function
|
|
494
|
+
function ct(e) {
|
|
495
495
|
return async (n, r, i) => {
|
|
496
496
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
497
497
|
...f,
|
|
@@ -526,7 +526,7 @@ function at(e) {
|
|
|
526
526
|
};
|
|
527
527
|
await e.insertInto("passwords").values(r).execute();
|
|
528
528
|
}
|
|
529
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await D(e, n, t.id, t);
|
|
530
530
|
};
|
|
531
531
|
try {
|
|
532
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
@@ -551,16 +551,16 @@ function at(e) {
|
|
|
551
551
|
}
|
|
552
552
|
//#endregion
|
|
553
553
|
//#region src/users/createMany.ts
|
|
554
|
-
var
|
|
555
|
-
function
|
|
554
|
+
var O = 500;
|
|
555
|
+
function lt(e) {
|
|
556
556
|
let t = e;
|
|
557
557
|
return t.identities !== void 0 || t.last_login !== void 0 || t.last_ip !== void 0 || t.login_count !== void 0;
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function ut(e) {
|
|
560
560
|
return async (n, r, i) => {
|
|
561
561
|
if (r.length === 0) return [];
|
|
562
562
|
if (i?.outboxEvents?.length) throw new C(400, { message: "createMany does not persist outbox events; use create for those users" });
|
|
563
|
-
if (r.find(
|
|
563
|
+
if (r.find(lt)) throw new C(400, { message: "createMany does not write identities or activity counters; use create for those users" });
|
|
564
564
|
let a = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => {
|
|
565
565
|
let { identities: r, phone_verified: i, password: o, last_login: s, last_ip: c, login_count: l, ...u } = e, d = {
|
|
566
566
|
...u,
|
|
@@ -591,8 +591,8 @@ function st(e) {
|
|
|
591
591
|
original: e
|
|
592
592
|
};
|
|
593
593
|
}), s = o.map((e) => e.sqlUser), c = o.map((e) => e.passwordRecord).filter((e) => e !== void 0), l = async (e) => {
|
|
594
|
-
for (let t = 0; t < s.length; t +=
|
|
595
|
-
for (let t = 0; t < c.length; t +=
|
|
594
|
+
for (let t = 0; t < s.length; t += O) await e.insertInto("users").values(s.slice(t, t + O)).execute();
|
|
595
|
+
for (let t = 0; t < c.length; t += O) await e.insertInto("passwords").values(c.slice(t, t + O)).execute();
|
|
596
596
|
};
|
|
597
597
|
try {
|
|
598
598
|
e.isTransaction ? await l(e) : await e.transaction().execute(l);
|
|
@@ -615,21 +615,21 @@ function st(e) {
|
|
|
615
615
|
}
|
|
616
616
|
//#endregion
|
|
617
617
|
//#region src/users/user-to-identity.ts
|
|
618
|
-
var
|
|
618
|
+
var dt = [
|
|
619
619
|
"email",
|
|
620
620
|
"email_verified",
|
|
621
621
|
"phone_number",
|
|
622
622
|
"phone_verified",
|
|
623
623
|
"username"
|
|
624
624
|
];
|
|
625
|
-
function
|
|
625
|
+
function k(e, t = !1) {
|
|
626
626
|
let n = {
|
|
627
627
|
connection: e.connection,
|
|
628
628
|
provider: e.provider,
|
|
629
629
|
user_id: fe(e.user_id).id,
|
|
630
630
|
isSocial: !!e.is_social
|
|
631
631
|
};
|
|
632
|
-
for (let t of
|
|
632
|
+
for (let t of dt) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
633
633
|
if (!t) {
|
|
634
634
|
let t = {};
|
|
635
635
|
try {
|
|
@@ -647,7 +647,7 @@ function M(e, t = !1) {
|
|
|
647
647
|
}
|
|
648
648
|
//#endregion
|
|
649
649
|
//#region src/users/get.ts
|
|
650
|
-
function
|
|
650
|
+
function ft(e) {
|
|
651
651
|
return async (t, n) => {
|
|
652
652
|
let [r, i] = await Promise.all([e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t).where("users.user_id", "=", n).selectAll("users").select([
|
|
653
653
|
"user_activity.last_login",
|
|
@@ -669,21 +669,21 @@ function lt(e) {
|
|
|
669
669
|
app_metadata: JSON.parse(r.app_metadata),
|
|
670
670
|
user_metadata: JSON.parse(r.user_metadata),
|
|
671
671
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
672
|
-
identities: [
|
|
672
|
+
identities: [k(r, !0), ...i.map((e) => k(e))]
|
|
673
673
|
});
|
|
674
674
|
};
|
|
675
675
|
}
|
|
676
676
|
//#endregion
|
|
677
677
|
//#region src/helpers/paginate.ts
|
|
678
|
-
function
|
|
678
|
+
function A(e) {
|
|
679
679
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function pt(e, t) {
|
|
682
682
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
683
683
|
return n >= 1 ? n : t;
|
|
684
684
|
}
|
|
685
|
-
async function
|
|
686
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
685
|
+
async function j(e, t, n) {
|
|
686
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = pt(t?.take, 50), s = e.orderBy(p.ref(r), i).orderBy(p.ref(a), i), c = t?.from ? re(t.from) : null;
|
|
687
687
|
if (c && c.k !== n.sortKey) throw new C(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
688
688
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(p.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
689
689
|
else {
|
|
@@ -707,7 +707,7 @@ async function P(e, t, n) {
|
|
|
707
707
|
}
|
|
708
708
|
//#endregion
|
|
709
709
|
//#region src/users/list.ts
|
|
710
|
-
var
|
|
710
|
+
var mt = [
|
|
711
711
|
"user_id",
|
|
712
712
|
"email",
|
|
713
713
|
"email_verified",
|
|
@@ -730,20 +730,20 @@ var dt = [
|
|
|
730
730
|
"login_count",
|
|
731
731
|
"created_at",
|
|
732
732
|
"updated_at"
|
|
733
|
-
],
|
|
733
|
+
], ht = new Set([
|
|
734
734
|
"last_login",
|
|
735
735
|
"last_ip",
|
|
736
736
|
"login_count"
|
|
737
|
-
]),
|
|
737
|
+
]), gt = Object.fromEntries(mt.map((e) => [e, e === "login_count" ? {
|
|
738
738
|
column: "user_activity.login_count",
|
|
739
739
|
defaultValue: 0
|
|
740
|
-
} :
|
|
740
|
+
} : ht.has(e) ? `user_activity.${e}` : `users.${e}`])), _t = [
|
|
741
741
|
"email",
|
|
742
742
|
"name",
|
|
743
743
|
"phone_number",
|
|
744
744
|
"user_id"
|
|
745
745
|
];
|
|
746
|
-
async function
|
|
746
|
+
async function vt(e, t, n) {
|
|
747
747
|
let r = n.map((e) => e.user_id), i = r.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", r).orderBy("created_at", "asc").execute() : [];
|
|
748
748
|
return n.map((e) => {
|
|
749
749
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -757,20 +757,20 @@ async function ht(e, t, n) {
|
|
|
757
757
|
app_metadata: JSON.parse(e.app_metadata),
|
|
758
758
|
user_metadata: JSON.parse(e.user_metadata),
|
|
759
759
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
760
|
-
identities: [
|
|
760
|
+
identities: [k(e, !0), ...t.map((e) => k(e))]
|
|
761
761
|
});
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
function
|
|
764
|
+
function yt(e) {
|
|
765
765
|
return async (t, n = {}) => {
|
|
766
766
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t);
|
|
767
767
|
if (c) {
|
|
768
|
-
let t = S(c,
|
|
769
|
-
t && (l = E(e, l, t,
|
|
768
|
+
let t = S(c, mt);
|
|
769
|
+
t && (l = E(e, l, t, _t, [], gt));
|
|
770
770
|
}
|
|
771
|
-
if (
|
|
771
|
+
if (A(n)) {
|
|
772
772
|
if (s?.sort_by && s.sort_by !== "created_at") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
773
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
773
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await j(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
774
774
|
"user_activity.last_login",
|
|
775
775
|
"user_activity.last_ip",
|
|
776
776
|
"user_activity.login_count"
|
|
@@ -779,7 +779,7 @@ function gt(e) {
|
|
|
779
779
|
sortOrder: r,
|
|
780
780
|
idColumn: "users.user_id",
|
|
781
781
|
sortKey: `created_at:${r}`
|
|
782
|
-
}), c = await
|
|
782
|
+
}), c = await vt(e, t, i);
|
|
783
783
|
return {
|
|
784
784
|
users: c,
|
|
785
785
|
start: 0,
|
|
@@ -789,7 +789,7 @@ function gt(e) {
|
|
|
789
789
|
};
|
|
790
790
|
}
|
|
791
791
|
if (s && s.sort_by) {
|
|
792
|
-
let t =
|
|
792
|
+
let t = gt[s.sort_by];
|
|
793
793
|
if (t) {
|
|
794
794
|
let { ref: n } = e.dynamic;
|
|
795
795
|
l = l.orderBy(typeof t == "string" ? n(t) : We(t), s.sort_order);
|
|
@@ -799,7 +799,7 @@ function gt(e) {
|
|
|
799
799
|
"user_activity.last_login",
|
|
800
800
|
"user_activity.last_ip",
|
|
801
801
|
"user_activity.login_count"
|
|
802
|
-
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await
|
|
802
|
+
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await vt(e, t, d);
|
|
803
803
|
if (!f) return {
|
|
804
804
|
users: p,
|
|
805
805
|
start: 0,
|
|
@@ -817,12 +817,12 @@ function gt(e) {
|
|
|
817
817
|
}
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region src/users/remove.ts
|
|
820
|
-
function
|
|
820
|
+
function bt(e) {
|
|
821
821
|
return async (t, n, r) => {
|
|
822
822
|
let i = async (e) => {
|
|
823
823
|
await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "in", (e) => e.selectFrom("users").select("users.user_id").where("users.tenant_id", "=", t).where((e) => e.or([e("users.user_id", "=", n), e("users.linked_to", "=", n)]))).execute(), await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.linked_to", "=", n).execute();
|
|
824
824
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
825
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
825
|
+
for (let n of r?.outboxEvents ?? []) await D(e, t, n.id, n);
|
|
826
826
|
return i.length === 1;
|
|
827
827
|
};
|
|
828
828
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -830,14 +830,14 @@ function _t(e) {
|
|
|
830
830
|
}
|
|
831
831
|
//#endregion
|
|
832
832
|
//#region src/utils/flatten.ts
|
|
833
|
-
function
|
|
833
|
+
function M(e, t = "", n = {}) {
|
|
834
834
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
835
835
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
836
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
836
|
+
typeof a == "object" && a && !Array.isArray(a) ? M(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
837
837
|
}
|
|
838
838
|
return n;
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function xt(e, t) {
|
|
841
841
|
let n = {};
|
|
842
842
|
for (let [r, i] of Object.entries(e)) {
|
|
843
843
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -854,7 +854,7 @@ function vt(e, t) {
|
|
|
854
854
|
}
|
|
855
855
|
//#endregion
|
|
856
856
|
//#region src/userActivity/index.ts
|
|
857
|
-
function
|
|
857
|
+
function St(e) {
|
|
858
858
|
return {
|
|
859
859
|
user_id: e.user_id,
|
|
860
860
|
last_login: e.last_login ?? void 0,
|
|
@@ -864,18 +864,18 @@ function yt(e) {
|
|
|
864
864
|
last_password_reset: e.last_password_reset ?? void 0
|
|
865
865
|
};
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function Ct(e) {
|
|
868
868
|
let t = {};
|
|
869
869
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
870
870
|
}
|
|
871
|
-
function
|
|
871
|
+
function wt(e) {
|
|
872
872
|
return {
|
|
873
873
|
async get(t, n) {
|
|
874
874
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
875
|
-
return r ?
|
|
875
|
+
return r ? St(r) : null;
|
|
876
876
|
},
|
|
877
877
|
async upsert(t, n, r) {
|
|
878
|
-
let i =
|
|
878
|
+
let i = Ct(r);
|
|
879
879
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
880
880
|
if (Object.keys(i).length === 0) return;
|
|
881
881
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -897,9 +897,9 @@ function xt(e) {
|
|
|
897
897
|
}
|
|
898
898
|
//#endregion
|
|
899
899
|
//#region src/users/update.ts
|
|
900
|
-
function
|
|
900
|
+
function Tt(e) {
|
|
901
901
|
return async (t, n, r, i) => {
|
|
902
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
902
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = M({
|
|
903
903
|
...c,
|
|
904
904
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
905
905
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -910,12 +910,12 @@ function St(e) {
|
|
|
910
910
|
}), u = async (e) => {
|
|
911
911
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
912
912
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
913
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
913
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await wt(e).upsert(t, n, {
|
|
914
914
|
last_login: a,
|
|
915
915
|
last_ip: o,
|
|
916
916
|
login_count: s
|
|
917
917
|
});
|
|
918
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
918
|
+
for (let n of i?.outboxEvents ?? []) await D(e, t, n.id, n);
|
|
919
919
|
return !0;
|
|
920
920
|
};
|
|
921
921
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -923,27 +923,27 @@ function St(e) {
|
|
|
923
923
|
}
|
|
924
924
|
//#endregion
|
|
925
925
|
//#region src/users/unlink.ts
|
|
926
|
-
function
|
|
926
|
+
function Et(e) {
|
|
927
927
|
return async (t, n, r, i) => (await e.updateTable("users").set({ linked_to: null }).where("users.tenant_id", "=", t).where("users.user_id", "=", `${r}|${i}`).where("users.linked_to", "=", `${n}`).execute()).length === 1;
|
|
928
928
|
}
|
|
929
929
|
//#endregion
|
|
930
930
|
//#region src/users/index.ts
|
|
931
|
-
function
|
|
932
|
-
let t =
|
|
931
|
+
function Dt(e) {
|
|
932
|
+
let t = ct(e);
|
|
933
933
|
return {
|
|
934
934
|
create: t,
|
|
935
935
|
rawCreate: t,
|
|
936
|
-
createMany:
|
|
937
|
-
remove:
|
|
938
|
-
get:
|
|
939
|
-
list:
|
|
940
|
-
update:
|
|
941
|
-
unlink:
|
|
936
|
+
createMany: ut(e),
|
|
937
|
+
remove: bt(e),
|
|
938
|
+
get: ft(e),
|
|
939
|
+
list: yt(e),
|
|
940
|
+
update: Tt(e),
|
|
941
|
+
unlink: Et(e)
|
|
942
942
|
};
|
|
943
943
|
}
|
|
944
944
|
//#endregion
|
|
945
945
|
//#region src/flows/create.ts
|
|
946
|
-
function
|
|
946
|
+
function Ot(e) {
|
|
947
947
|
return async (n, r, i) => {
|
|
948
948
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
949
949
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -961,7 +961,7 @@ function Tt(e) {
|
|
|
961
961
|
}
|
|
962
962
|
//#endregion
|
|
963
963
|
//#region src/helpers/parse.ts
|
|
964
|
-
function
|
|
964
|
+
function N(e, t) {
|
|
965
965
|
if (!e) return t;
|
|
966
966
|
try {
|
|
967
967
|
return JSON.parse(e);
|
|
@@ -969,7 +969,7 @@ function I(e, t) {
|
|
|
969
969
|
return t;
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function kt(e) {
|
|
973
973
|
if (e) try {
|
|
974
974
|
let t = JSON.parse(e);
|
|
975
975
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -977,33 +977,33 @@ function Et(e) {
|
|
|
977
977
|
return;
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
function
|
|
981
|
-
for (let r in t) r in e && (n[r] =
|
|
980
|
+
function At(e, t, n = { ...e }) {
|
|
981
|
+
for (let r in t) r in e && (n[r] = N(e[r], t[r]));
|
|
982
982
|
return n;
|
|
983
983
|
}
|
|
984
984
|
//#endregion
|
|
985
985
|
//#region src/flows/get.ts
|
|
986
|
-
function
|
|
986
|
+
function jt(e) {
|
|
987
987
|
return async (t, n) => {
|
|
988
988
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
989
989
|
if (!r) return null;
|
|
990
990
|
let i = {
|
|
991
991
|
...r,
|
|
992
|
-
actions:
|
|
992
|
+
actions: N(r.actions, [])
|
|
993
993
|
};
|
|
994
994
|
return b.parse(l(i));
|
|
995
995
|
};
|
|
996
996
|
}
|
|
997
997
|
//#endregion
|
|
998
998
|
//#region src/flows/list.ts
|
|
999
|
-
function
|
|
999
|
+
function Mt(e) {
|
|
1000
1000
|
return async (t, n = {}) => {
|
|
1001
1001
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
1002
1002
|
s && (c = E(e, c, s, []));
|
|
1003
1003
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1004
1004
|
let t = {
|
|
1005
1005
|
...e,
|
|
1006
|
-
actions:
|
|
1006
|
+
actions: N(e.actions, [])
|
|
1007
1007
|
};
|
|
1008
1008
|
return b.parse(l(t));
|
|
1009
1009
|
});
|
|
@@ -1024,7 +1024,7 @@ function kt(e) {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
//#endregion
|
|
1026
1026
|
//#region src/flows/update.ts
|
|
1027
|
-
function
|
|
1027
|
+
function Nt(e) {
|
|
1028
1028
|
return async (t, n, r) => {
|
|
1029
1029
|
let i = {
|
|
1030
1030
|
...r,
|
|
@@ -1042,27 +1042,27 @@ function At(e) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
//#endregion
|
|
1044
1044
|
//#region src/flows/remove.ts
|
|
1045
|
-
function
|
|
1045
|
+
function Pt(e) {
|
|
1046
1046
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
1047
1047
|
}
|
|
1048
1048
|
//#endregion
|
|
1049
1049
|
//#region src/flows/index.ts
|
|
1050
|
-
function
|
|
1050
|
+
function Ft(e) {
|
|
1051
1051
|
return {
|
|
1052
|
-
create:
|
|
1053
|
-
get:
|
|
1054
|
-
list:
|
|
1055
|
-
update:
|
|
1056
|
-
remove:
|
|
1052
|
+
create: Ot(e),
|
|
1053
|
+
get: jt(e),
|
|
1054
|
+
list: Mt(e),
|
|
1055
|
+
update: Nt(e),
|
|
1056
|
+
remove: Pt(e)
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
//#endregion
|
|
1060
1060
|
//#region src/tenants/utils.ts
|
|
1061
|
-
function
|
|
1061
|
+
function It(e) {
|
|
1062
1062
|
let t = { ...e };
|
|
1063
1063
|
return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(e.sandbox_versions_available)), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.attack_protection && typeof e.attack_protection == "string" && (t.attack_protection = JSON.parse(e.attack_protection)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), l(t);
|
|
1064
1064
|
}
|
|
1065
|
-
function
|
|
1065
|
+
function Lt(e) {
|
|
1066
1066
|
let t = { ...e };
|
|
1067
1067
|
return d(e, [
|
|
1068
1068
|
"session_cookie",
|
|
@@ -1085,14 +1085,14 @@ function Pt(e) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
//#endregion
|
|
1087
1087
|
//#region src/tenants/create.ts
|
|
1088
|
-
function
|
|
1088
|
+
function Rt(e) {
|
|
1089
1089
|
return async (n, r) => {
|
|
1090
1090
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
1091
1091
|
...n,
|
|
1092
1092
|
id: i?.id ?? n.id ?? t(),
|
|
1093
1093
|
created_at: i?.created_at ?? a,
|
|
1094
1094
|
updated_at: i?.updated_at ?? a
|
|
1095
|
-
}, s =
|
|
1095
|
+
}, s = Lt(o);
|
|
1096
1096
|
try {
|
|
1097
1097
|
await e.insertInto("tenants").values(s).execute();
|
|
1098
1098
|
} catch (e) {
|
|
@@ -1104,15 +1104,15 @@ function Ft(e) {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
//#endregion
|
|
1106
1106
|
//#region src/tenants/get.ts
|
|
1107
|
-
function
|
|
1107
|
+
function zt(e) {
|
|
1108
1108
|
return async (t) => {
|
|
1109
1109
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1110
|
-
return n ?
|
|
1110
|
+
return n ? It(n) : null;
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
1113
|
//#endregion
|
|
1114
1114
|
//#region src/tenants/list.ts
|
|
1115
|
-
function
|
|
1115
|
+
function Bt(e) {
|
|
1116
1116
|
return async (t) => {
|
|
1117
1117
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1118
1118
|
if (s && s.sort_by) {
|
|
@@ -1120,7 +1120,7 @@ function Lt(e) {
|
|
|
1120
1120
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1121
1121
|
}
|
|
1122
1122
|
c && (n = E(e, n, c, ["friendly_name"]));
|
|
1123
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1123
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(It);
|
|
1124
1124
|
if (!a) return { tenants: l };
|
|
1125
1125
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1126
1126
|
return {
|
|
@@ -1133,10 +1133,10 @@ function Lt(e) {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
//#endregion
|
|
1135
1135
|
//#region src/tenants/update.ts
|
|
1136
|
-
function
|
|
1136
|
+
function Vt(e) {
|
|
1137
1137
|
return async (t, n) => {
|
|
1138
1138
|
let r = {
|
|
1139
|
-
...
|
|
1139
|
+
...Lt(n),
|
|
1140
1140
|
id: t,
|
|
1141
1141
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1142
1142
|
};
|
|
@@ -1145,29 +1145,29 @@ function Rt(e) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
//#endregion
|
|
1147
1147
|
//#region src/tenants/remove.ts
|
|
1148
|
-
function
|
|
1148
|
+
function Ht(e) {
|
|
1149
1149
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1150
1150
|
}
|
|
1151
1151
|
//#endregion
|
|
1152
1152
|
//#region src/tenants/index.ts
|
|
1153
|
-
function
|
|
1153
|
+
function Ut(e) {
|
|
1154
1154
|
return {
|
|
1155
|
-
create:
|
|
1156
|
-
get:
|
|
1157
|
-
list:
|
|
1158
|
-
update:
|
|
1159
|
-
remove:
|
|
1155
|
+
create: Rt(e),
|
|
1156
|
+
get: zt(e),
|
|
1157
|
+
list: Bt(e),
|
|
1158
|
+
update: Vt(e),
|
|
1159
|
+
remove: Ht(e)
|
|
1160
1160
|
};
|
|
1161
1161
|
}
|
|
1162
1162
|
//#endregion
|
|
1163
1163
|
//#region src/logs/create.ts
|
|
1164
|
-
function
|
|
1164
|
+
function Wt(e) {
|
|
1165
1165
|
return e ? JSON.stringify(e) : void 0;
|
|
1166
1166
|
}
|
|
1167
|
-
var
|
|
1168
|
-
function
|
|
1167
|
+
var Gt = 256;
|
|
1168
|
+
function Kt(e) {
|
|
1169
1169
|
return async (n, r) => {
|
|
1170
|
-
let i = r.user_agent?.slice(0,
|
|
1170
|
+
let i = r.user_agent?.slice(0, Gt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1171
1171
|
return await e.insertInto("logs").values({
|
|
1172
1172
|
...s,
|
|
1173
1173
|
log_id: a,
|
|
@@ -1176,8 +1176,8 @@ function Ut(e) {
|
|
|
1176
1176
|
description: r.description?.substring(0, 256),
|
|
1177
1177
|
isMobile: +!!r.isMobile,
|
|
1178
1178
|
scope: r.scope,
|
|
1179
|
-
auth0_client:
|
|
1180
|
-
details:
|
|
1179
|
+
auth0_client: Wt(r.auth0_client),
|
|
1180
|
+
details: Wt(r.details)?.substring(0, 8192),
|
|
1181
1181
|
country_code: o?.country_code,
|
|
1182
1182
|
city_name: o?.city_name,
|
|
1183
1183
|
latitude: o?.latitude,
|
|
@@ -1193,7 +1193,7 @@ function Ut(e) {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
//#endregion
|
|
1195
1195
|
//#region src/logs/logs.ts
|
|
1196
|
-
function
|
|
1196
|
+
function qt(e) {
|
|
1197
1197
|
if (!e) return "";
|
|
1198
1198
|
try {
|
|
1199
1199
|
return JSON.parse(e);
|
|
@@ -1201,13 +1201,13 @@ function Wt(e) {
|
|
|
1201
1201
|
return e;
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
|
-
function
|
|
1204
|
+
function P(e) {
|
|
1205
1205
|
return {
|
|
1206
1206
|
...e,
|
|
1207
1207
|
client_id: e.client_id,
|
|
1208
1208
|
client_name: e.client_name || "",
|
|
1209
|
-
auth0_client:
|
|
1210
|
-
details:
|
|
1209
|
+
auth0_client: qt(e.auth0_client),
|
|
1210
|
+
details: qt(e.details),
|
|
1211
1211
|
isMobile: !!e.isMobile,
|
|
1212
1212
|
scope: e.scope || void 0,
|
|
1213
1213
|
log_id: e.log_id,
|
|
@@ -1223,7 +1223,7 @@ function Gt(e) {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
//#endregion
|
|
1225
1225
|
//#region src/logs/list.ts
|
|
1226
|
-
var
|
|
1226
|
+
var Jt = [
|
|
1227
1227
|
"user_id",
|
|
1228
1228
|
"ip",
|
|
1229
1229
|
"type",
|
|
@@ -1249,25 +1249,25 @@ var Kt = [
|
|
|
1249
1249
|
"time_zone",
|
|
1250
1250
|
"continent_code"
|
|
1251
1251
|
];
|
|
1252
|
-
function
|
|
1252
|
+
function Yt(e) {
|
|
1253
1253
|
return async (t, n = {}) => {
|
|
1254
1254
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, from_date: l, to_date: u } = n, d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
1255
1255
|
if (c) {
|
|
1256
|
-
let t = S(c,
|
|
1256
|
+
let t = S(c, Jt);
|
|
1257
1257
|
t && (d = E(e, d, t, [
|
|
1258
1258
|
"user_id",
|
|
1259
1259
|
"ip",
|
|
1260
1260
|
"description"
|
|
1261
1261
|
], ["description"]));
|
|
1262
1262
|
}
|
|
1263
|
-
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())),
|
|
1263
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), A(n)) {
|
|
1264
1264
|
if (s?.sort_by && s.sort_by !== "date") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1265
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1265
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await j(d.selectAll(), n, {
|
|
1266
1266
|
sortColumn: "date",
|
|
1267
1267
|
sortOrder: e,
|
|
1268
1268
|
idColumn: "log_id",
|
|
1269
1269
|
sortKey: `date:${e}`
|
|
1270
|
-
}), a = t.map(
|
|
1270
|
+
}), a = t.map(P);
|
|
1271
1271
|
return {
|
|
1272
1272
|
logs: a,
|
|
1273
1273
|
start: 0,
|
|
@@ -1282,7 +1282,7 @@ function qt(e) {
|
|
|
1282
1282
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1283
1283
|
}
|
|
1284
1284
|
f = f.offset(r * i).limit(i);
|
|
1285
|
-
let p = (await f.selectAll().execute()).map(
|
|
1285
|
+
let p = (await f.selectAll().execute()).map(P);
|
|
1286
1286
|
if (!a) return {
|
|
1287
1287
|
logs: p,
|
|
1288
1288
|
start: 0,
|
|
@@ -1300,24 +1300,24 @@ function qt(e) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
//#endregion
|
|
1302
1302
|
//#region src/logs/get.ts
|
|
1303
|
-
function
|
|
1303
|
+
function Xt(e) {
|
|
1304
1304
|
return async (t, n) => {
|
|
1305
1305
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1306
|
-
return r ?
|
|
1306
|
+
return r ? P(r) : null;
|
|
1307
1307
|
};
|
|
1308
1308
|
}
|
|
1309
1309
|
//#endregion
|
|
1310
1310
|
//#region src/logs/index.ts
|
|
1311
|
-
function
|
|
1311
|
+
function Zt(e) {
|
|
1312
1312
|
return {
|
|
1313
|
-
create:
|
|
1314
|
-
list:
|
|
1315
|
-
get:
|
|
1313
|
+
create: Kt(e),
|
|
1314
|
+
list: Yt(e),
|
|
1315
|
+
get: Xt(e)
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
1318
|
//#endregion
|
|
1319
1319
|
//#region src/sessions/get.ts
|
|
1320
|
-
function
|
|
1320
|
+
function Qt(e) {
|
|
1321
1321
|
return async (t, n) => {
|
|
1322
1322
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1323
1323
|
if (!i) return null;
|
|
@@ -1351,7 +1351,7 @@ function Xt(e) {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
//#endregion
|
|
1353
1353
|
//#region src/sessions/create.ts
|
|
1354
|
-
function
|
|
1354
|
+
function $t(e) {
|
|
1355
1355
|
return async (t, n) => {
|
|
1356
1356
|
let r = Date.now(), i = c(), a = {
|
|
1357
1357
|
...n,
|
|
@@ -1383,12 +1383,12 @@ function Zt(e) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
//#endregion
|
|
1385
1385
|
//#region src/sessions/remove.ts
|
|
1386
|
-
function
|
|
1386
|
+
function en(e) {
|
|
1387
1387
|
return async (t, n) => ((await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
1388
1388
|
}
|
|
1389
1389
|
//#endregion
|
|
1390
1390
|
//#region src/sessions/update.ts
|
|
1391
|
-
function
|
|
1391
|
+
function tn(e) {
|
|
1392
1392
|
return async (t, n, r) => {
|
|
1393
1393
|
let i = Date.now(), a = {
|
|
1394
1394
|
updated_at_ts: i,
|
|
@@ -1409,7 +1409,7 @@ function $t(e) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
//#endregion
|
|
1411
1411
|
//#region src/sessions/list.ts
|
|
1412
|
-
function
|
|
1412
|
+
function nn(e) {
|
|
1413
1413
|
return async (t, n = {}) => {
|
|
1414
1414
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
1415
1415
|
l && (u = E(e, u, l, ["user_id", "session_id"]));
|
|
@@ -1464,18 +1464,18 @@ function en(e) {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
//#endregion
|
|
1466
1466
|
//#region src/sessions/index.ts
|
|
1467
|
-
function
|
|
1467
|
+
function rn(e) {
|
|
1468
1468
|
return {
|
|
1469
|
-
create:
|
|
1470
|
-
get:
|
|
1471
|
-
list:
|
|
1472
|
-
remove:
|
|
1473
|
-
update:
|
|
1469
|
+
create: $t(e),
|
|
1470
|
+
get: Qt(e),
|
|
1471
|
+
list: nn(e),
|
|
1472
|
+
remove: en(e),
|
|
1473
|
+
update: tn(e)
|
|
1474
1474
|
};
|
|
1475
1475
|
}
|
|
1476
1476
|
//#endregion
|
|
1477
1477
|
//#region src/passwords/get.ts
|
|
1478
|
-
function
|
|
1478
|
+
function an(e) {
|
|
1479
1479
|
return async (t, n) => {
|
|
1480
1480
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1481
1481
|
if (!r) return null;
|
|
@@ -1488,7 +1488,7 @@ function nn(e) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
//#endregion
|
|
1490
1490
|
//#region src/passwords/create.ts
|
|
1491
|
-
function
|
|
1491
|
+
function on(e) {
|
|
1492
1492
|
return async (n, r, i) => {
|
|
1493
1493
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1494
1494
|
...r,
|
|
@@ -1506,7 +1506,7 @@ function rn(e) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
//#endregion
|
|
1508
1508
|
//#region src/passwords/update.ts
|
|
1509
|
-
function
|
|
1509
|
+
function sn(e) {
|
|
1510
1510
|
return async (t, n) => {
|
|
1511
1511
|
let r = e.updateTable("passwords").set({
|
|
1512
1512
|
password: n.password,
|
|
@@ -1519,7 +1519,7 @@ function an(e) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/passwords/list.ts
|
|
1522
|
-
function
|
|
1522
|
+
function cn(e) {
|
|
1523
1523
|
return async (t, n, r) => {
|
|
1524
1524
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1525
1525
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1530,17 +1530,17 @@ function on(e) {
|
|
|
1530
1530
|
}
|
|
1531
1531
|
//#endregion
|
|
1532
1532
|
//#region src/passwords/index.ts
|
|
1533
|
-
function
|
|
1533
|
+
function ln(e) {
|
|
1534
1534
|
return {
|
|
1535
|
-
create:
|
|
1536
|
-
update:
|
|
1537
|
-
get:
|
|
1538
|
-
list:
|
|
1535
|
+
create: on(e),
|
|
1536
|
+
update: sn(e),
|
|
1537
|
+
get: an(e),
|
|
1538
|
+
list: cn(e)
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
1541
|
//#endregion
|
|
1542
1542
|
//#region src/codes/list.ts
|
|
1543
|
-
function
|
|
1543
|
+
function un(e) {
|
|
1544
1544
|
return async (t, n = {}) => {
|
|
1545
1545
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1546
1546
|
s && (c = E(e, c, s, ["code", "login_id"]));
|
|
@@ -1565,13 +1565,13 @@ function cn(e) {
|
|
|
1565
1565
|
}
|
|
1566
1566
|
//#endregion
|
|
1567
1567
|
//#region src/codes/expires-at-ts.ts
|
|
1568
|
-
function
|
|
1568
|
+
function dn(e) {
|
|
1569
1569
|
let t = new Date(e).getTime();
|
|
1570
1570
|
return Number.isNaN(t) ? 0 : t;
|
|
1571
1571
|
}
|
|
1572
1572
|
//#endregion
|
|
1573
1573
|
//#region src/codes/create.ts
|
|
1574
|
-
function
|
|
1574
|
+
function fn(e) {
|
|
1575
1575
|
return async (t, n) => {
|
|
1576
1576
|
let r = {
|
|
1577
1577
|
...n,
|
|
@@ -1580,18 +1580,18 @@ function un(e) {
|
|
|
1580
1580
|
return await e.insertInto("codes").values({
|
|
1581
1581
|
...r,
|
|
1582
1582
|
tenant_id: t,
|
|
1583
|
-
expires_at_ts:
|
|
1583
|
+
expires_at_ts: dn(r.expires_at)
|
|
1584
1584
|
}).execute(), r;
|
|
1585
1585
|
};
|
|
1586
1586
|
}
|
|
1587
1587
|
//#endregion
|
|
1588
1588
|
//#region src/codes/remove.ts
|
|
1589
|
-
function
|
|
1589
|
+
function pn(e) {
|
|
1590
1590
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1591
1591
|
}
|
|
1592
1592
|
//#endregion
|
|
1593
1593
|
//#region src/codes/get.ts
|
|
1594
|
-
function
|
|
1594
|
+
function mn(e) {
|
|
1595
1595
|
return async (t, n, r) => {
|
|
1596
1596
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1597
1597
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1601,34 +1601,34 @@ function fn(e) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
1603
|
//#region src/codes/used.ts
|
|
1604
|
-
function
|
|
1604
|
+
function hn(e) {
|
|
1605
1605
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numUpdatedRows > 0;
|
|
1606
1606
|
}
|
|
1607
1607
|
//#endregion
|
|
1608
1608
|
//#region src/codes/consume.ts
|
|
1609
|
-
function
|
|
1609
|
+
function gn(e) {
|
|
1610
1610
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).where("codes.used_at", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
1611
1611
|
}
|
|
1612
1612
|
//#endregion
|
|
1613
1613
|
//#region src/codes/cleanup.ts
|
|
1614
|
-
var
|
|
1615
|
-
async function
|
|
1614
|
+
var F = 5e4;
|
|
1615
|
+
async function _n(e, t) {
|
|
1616
1616
|
if (!t) return e();
|
|
1617
|
-
let n = 0, r =
|
|
1618
|
-
for (; r >=
|
|
1617
|
+
let n = 0, r = F;
|
|
1618
|
+
for (; r >= F;) r = await e(F), n += r;
|
|
1619
1619
|
return n;
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1621
|
+
function vn(e) {
|
|
1622
1622
|
let t;
|
|
1623
1623
|
return async (n) => {
|
|
1624
|
-
t ??= await
|
|
1624
|
+
t ??= await et(e);
|
|
1625
1625
|
let r = t === "mysql";
|
|
1626
|
-
return await
|
|
1627
|
-
let r = e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1626
|
+
return await _n(async (t) => {
|
|
1627
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "<", dn(n));
|
|
1628
1628
|
t !== void 0 && (r = r.limit(t));
|
|
1629
1629
|
let i = await r.executeTakeFirst();
|
|
1630
1630
|
return Number(i.numDeletedRows);
|
|
1631
|
-
}, r) + await
|
|
1631
|
+
}, r) + await _n(async (t) => {
|
|
1632
1632
|
let r = e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", n);
|
|
1633
1633
|
t !== void 0 && (r = r.limit(t));
|
|
1634
1634
|
let i = await r.executeTakeFirst();
|
|
@@ -1638,20 +1638,20 @@ function _n(e) {
|
|
|
1638
1638
|
}
|
|
1639
1639
|
//#endregion
|
|
1640
1640
|
//#region src/codes/index.ts
|
|
1641
|
-
function
|
|
1641
|
+
function yn(e) {
|
|
1642
1642
|
return {
|
|
1643
|
-
create:
|
|
1644
|
-
list:
|
|
1645
|
-
remove:
|
|
1646
|
-
used:
|
|
1647
|
-
consume:
|
|
1648
|
-
get:
|
|
1649
|
-
cleanup:
|
|
1643
|
+
create: fn(e),
|
|
1644
|
+
list: un(e),
|
|
1645
|
+
remove: pn(e),
|
|
1646
|
+
used: hn(e),
|
|
1647
|
+
consume: gn(e),
|
|
1648
|
+
get: mn(e),
|
|
1649
|
+
cleanup: vn(e)
|
|
1650
1650
|
};
|
|
1651
1651
|
}
|
|
1652
1652
|
//#endregion
|
|
1653
1653
|
//#region src/connections/create.ts
|
|
1654
|
-
function
|
|
1654
|
+
function bn(e) {
|
|
1655
1655
|
return async (t, n, r) => {
|
|
1656
1656
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1657
1657
|
delete o.enabled_clients;
|
|
@@ -1672,7 +1672,7 @@ function yn(e) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
//#endregion
|
|
1674
1674
|
//#region src/connections/transform.ts
|
|
1675
|
-
function
|
|
1675
|
+
function I(e) {
|
|
1676
1676
|
let { is_system: t, ...n } = e;
|
|
1677
1677
|
return l({
|
|
1678
1678
|
...n,
|
|
@@ -1681,15 +1681,15 @@ function bn(e) {
|
|
|
1681
1681
|
});
|
|
1682
1682
|
}
|
|
1683
1683
|
function xn(e) {
|
|
1684
|
-
return e.map(
|
|
1684
|
+
return e.map(I);
|
|
1685
1685
|
}
|
|
1686
1686
|
//#endregion
|
|
1687
1687
|
//#region src/connections/list.ts
|
|
1688
1688
|
function Sn(e) {
|
|
1689
1689
|
return async (t, n = {}) => {
|
|
1690
1690
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1691
|
-
if (s && (c = E(e, c, s, ["user_id", "ip"])),
|
|
1692
|
-
let { rows: e, limit: t, next: r } = await
|
|
1691
|
+
if (s && (c = E(e, c, s, ["user_id", "ip"])), A(n)) {
|
|
1692
|
+
let { rows: e, limit: t, next: r } = await j(c.selectAll(), n, {
|
|
1693
1693
|
sortColumn: "created_at",
|
|
1694
1694
|
sortOrder: "desc",
|
|
1695
1695
|
idColumn: "id"
|
|
@@ -1728,7 +1728,7 @@ function Cn(e) {
|
|
|
1728
1728
|
function wn(e) {
|
|
1729
1729
|
return async (t, n) => {
|
|
1730
1730
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1731
|
-
return r ?
|
|
1731
|
+
return r ? I(r) : null;
|
|
1732
1732
|
};
|
|
1733
1733
|
}
|
|
1734
1734
|
//#endregion
|
|
@@ -1752,7 +1752,7 @@ function Tn(e) {
|
|
|
1752
1752
|
//#region src/connections/index.ts
|
|
1753
1753
|
function En(e) {
|
|
1754
1754
|
return {
|
|
1755
|
-
create:
|
|
1755
|
+
create: bn(e),
|
|
1756
1756
|
get: wn(e),
|
|
1757
1757
|
list: Sn(e),
|
|
1758
1758
|
remove: Cn(e),
|
|
@@ -1980,8 +1980,8 @@ function Mn(e) {
|
|
|
1980
1980
|
r = r.where(t, "=", e.value);
|
|
1981
1981
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1982
1982
|
}
|
|
1983
|
-
if (
|
|
1984
|
-
let { rows: e, limit: t, next: i } = await
|
|
1983
|
+
if (A(n)) {
|
|
1984
|
+
let { rows: e, limit: t, next: i } = await j(r.selectAll(), n, {
|
|
1985
1985
|
sortColumn: "created_at",
|
|
1986
1986
|
sortOrder: "desc",
|
|
1987
1987
|
idColumn: "client_id"
|
|
@@ -2103,7 +2103,7 @@ function In(e) {
|
|
|
2103
2103
|
if (!r) return [];
|
|
2104
2104
|
let i = JSON.parse(r.connections || "[]");
|
|
2105
2105
|
if (i.length === 0) return [];
|
|
2106
|
-
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id,
|
|
2106
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, I(e)]));
|
|
2107
2107
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2108
2108
|
};
|
|
2109
2109
|
}
|
|
@@ -2233,8 +2233,8 @@ function Gn(e) {
|
|
|
2233
2233
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2234
2234
|
} else l = E(e, l, t, []);
|
|
2235
2235
|
}
|
|
2236
|
-
if (
|
|
2237
|
-
let { rows: e, limit: t, next: r } = await
|
|
2236
|
+
if (A(n)) {
|
|
2237
|
+
let { rows: e, limit: t, next: r } = await j(l.selectAll(), n, {
|
|
2238
2238
|
sortColumn: "created_at",
|
|
2239
2239
|
sortOrder: "desc"
|
|
2240
2240
|
}), i = e.map(Wn);
|
|
@@ -2342,7 +2342,7 @@ function Zn(e) {
|
|
|
2342
2342
|
}
|
|
2343
2343
|
return ce(t) ? t : void 0;
|
|
2344
2344
|
}
|
|
2345
|
-
function
|
|
2345
|
+
function L(e) {
|
|
2346
2346
|
return {
|
|
2347
2347
|
id: e.id,
|
|
2348
2348
|
token_hash: e.token_hash,
|
|
@@ -2359,38 +2359,38 @@ function Qn(e) {
|
|
|
2359
2359
|
}
|
|
2360
2360
|
//#endregion
|
|
2361
2361
|
//#region src/clientRegistrationTokens/get.ts
|
|
2362
|
-
function
|
|
2362
|
+
function Qn(e) {
|
|
2363
2363
|
return async (t, n) => {
|
|
2364
2364
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2365
|
-
return r ?
|
|
2365
|
+
return r ? L(r) : null;
|
|
2366
2366
|
};
|
|
2367
2367
|
}
|
|
2368
2368
|
//#endregion
|
|
2369
2369
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2370
|
-
function
|
|
2370
|
+
function $n(e) {
|
|
2371
2371
|
return async (t, n) => {
|
|
2372
2372
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2373
|
-
return r ?
|
|
2373
|
+
return r ? L(r) : null;
|
|
2374
2374
|
};
|
|
2375
2375
|
}
|
|
2376
2376
|
//#endregion
|
|
2377
2377
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2378
|
-
function
|
|
2379
|
-
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(
|
|
2378
|
+
function er(e) {
|
|
2379
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(L);
|
|
2380
2380
|
}
|
|
2381
2381
|
//#endregion
|
|
2382
2382
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2383
|
-
function
|
|
2383
|
+
function tr(e) {
|
|
2384
2384
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ used_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("used_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2385
2385
|
}
|
|
2386
2386
|
//#endregion
|
|
2387
2387
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2388
|
-
function
|
|
2388
|
+
function nr(e) {
|
|
2389
2389
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2390
2390
|
}
|
|
2391
2391
|
//#endregion
|
|
2392
2392
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2393
|
-
function
|
|
2393
|
+
function rr(e) {
|
|
2394
2394
|
return async (t, n, r) => {
|
|
2395
2395
|
let i = await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("client_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
2396
2396
|
return Number(i.numUpdatedRows);
|
|
@@ -2398,26 +2398,26 @@ function ir(e) {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
//#endregion
|
|
2400
2400
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2401
|
-
function
|
|
2401
|
+
function ir(e) {
|
|
2402
2402
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2403
2403
|
}
|
|
2404
2404
|
//#endregion
|
|
2405
2405
|
//#region src/clientRegistrationTokens/index.ts
|
|
2406
|
-
function
|
|
2406
|
+
function ar(e) {
|
|
2407
2407
|
return {
|
|
2408
2408
|
create: Yn(e),
|
|
2409
|
-
get:
|
|
2410
|
-
getByHash:
|
|
2411
|
-
listByClient:
|
|
2412
|
-
markUsed:
|
|
2413
|
-
revoke:
|
|
2414
|
-
revokeByClient:
|
|
2415
|
-
remove:
|
|
2409
|
+
get: Qn(e),
|
|
2410
|
+
getByHash: $n(e),
|
|
2411
|
+
listByClient: er(e),
|
|
2412
|
+
markUsed: tr(e),
|
|
2413
|
+
revoke: nr(e),
|
|
2414
|
+
revokeByClient: rr(e),
|
|
2415
|
+
remove: ir(e)
|
|
2416
2416
|
};
|
|
2417
2417
|
}
|
|
2418
2418
|
//#endregion
|
|
2419
2419
|
//#region src/keys/list.ts
|
|
2420
|
-
function
|
|
2420
|
+
function or(e) {
|
|
2421
2421
|
return async (t = {}) => {
|
|
2422
2422
|
let { page: n = 0, per_page: r = 100, include_totals: i = !1, sort: a, q: s } = t, c = e.selectFrom("keys").where((e) => e.or([e("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()), e("revoked_at", "is", null)]));
|
|
2423
2423
|
s && (c = E(e, c, s, [
|
|
@@ -2446,7 +2446,7 @@ function sr(e) {
|
|
|
2446
2446
|
}
|
|
2447
2447
|
//#endregion
|
|
2448
2448
|
//#region src/keys/create.ts
|
|
2449
|
-
function
|
|
2449
|
+
function sr(e) {
|
|
2450
2450
|
return async (t, n) => {
|
|
2451
2451
|
let r = n?.importMetadata;
|
|
2452
2452
|
await e.insertInto("keys").values({
|
|
@@ -2458,21 +2458,21 @@ function cr(e) {
|
|
|
2458
2458
|
}
|
|
2459
2459
|
//#endregion
|
|
2460
2460
|
//#region src/keys/update.ts
|
|
2461
|
-
function
|
|
2461
|
+
function cr(e) {
|
|
2462
2462
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2463
2463
|
}
|
|
2464
2464
|
//#endregion
|
|
2465
2465
|
//#region src/keys/index.ts
|
|
2466
|
-
function
|
|
2466
|
+
function lr(e) {
|
|
2467
2467
|
return {
|
|
2468
|
-
create:
|
|
2469
|
-
list:
|
|
2470
|
-
update:
|
|
2468
|
+
create: sr(e),
|
|
2469
|
+
list: or(e),
|
|
2470
|
+
update: cr(e)
|
|
2471
2471
|
};
|
|
2472
2472
|
}
|
|
2473
2473
|
//#endregion
|
|
2474
2474
|
//#region src/customDomains/create.ts
|
|
2475
|
-
function
|
|
2475
|
+
function ur(e) {
|
|
2476
2476
|
return async (n, r, i) => {
|
|
2477
2477
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2478
2478
|
status: "pending",
|
|
@@ -2493,35 +2493,35 @@ function dr(e) {
|
|
|
2493
2493
|
}
|
|
2494
2494
|
//#endregion
|
|
2495
2495
|
//#region src/customDomains/list.ts
|
|
2496
|
-
function
|
|
2496
|
+
function dr(e) {
|
|
2497
2497
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2498
2498
|
...e,
|
|
2499
2499
|
primary: e.primary === 1,
|
|
2500
|
-
domain_metadata:
|
|
2501
|
-
verification:
|
|
2500
|
+
domain_metadata: N(e.domain_metadata, void 0),
|
|
2501
|
+
verification: N(e.verification, void 0)
|
|
2502
2502
|
}));
|
|
2503
2503
|
}
|
|
2504
2504
|
//#endregion
|
|
2505
2505
|
//#region src/customDomains/remove.ts
|
|
2506
|
-
function
|
|
2506
|
+
function fr(e) {
|
|
2507
2507
|
return async (t, n) => (await e.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).execute()).length > 0;
|
|
2508
2508
|
}
|
|
2509
2509
|
//#endregion
|
|
2510
2510
|
//#region src/customDomains/get.ts
|
|
2511
|
-
function
|
|
2511
|
+
function pr(e) {
|
|
2512
2512
|
return async (t, n) => {
|
|
2513
2513
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2514
2514
|
return r ? {
|
|
2515
2515
|
...r,
|
|
2516
2516
|
primary: r.primary === 1,
|
|
2517
|
-
domain_metadata:
|
|
2518
|
-
verification:
|
|
2517
|
+
domain_metadata: N(r.domain_metadata, void 0),
|
|
2518
|
+
verification: N(r.verification, void 0)
|
|
2519
2519
|
} : null;
|
|
2520
2520
|
};
|
|
2521
2521
|
}
|
|
2522
2522
|
//#endregion
|
|
2523
2523
|
//#region src/customDomains/update.ts
|
|
2524
|
-
function
|
|
2524
|
+
function mr(e) {
|
|
2525
2525
|
return async (t, n, r) => {
|
|
2526
2526
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2527
2527
|
...s,
|
|
@@ -2535,32 +2535,32 @@ function hr(e) {
|
|
|
2535
2535
|
}
|
|
2536
2536
|
//#endregion
|
|
2537
2537
|
//#region src/customDomains/getByDomain.ts
|
|
2538
|
-
function
|
|
2538
|
+
function hr(e) {
|
|
2539
2539
|
return async (t) => {
|
|
2540
2540
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2541
2541
|
return n ? {
|
|
2542
2542
|
...n,
|
|
2543
2543
|
primary: n.primary === 1,
|
|
2544
|
-
domain_metadata:
|
|
2545
|
-
verification:
|
|
2544
|
+
domain_metadata: N(n.domain_metadata, void 0),
|
|
2545
|
+
verification: N(n.verification, void 0)
|
|
2546
2546
|
} : null;
|
|
2547
2547
|
};
|
|
2548
2548
|
}
|
|
2549
2549
|
//#endregion
|
|
2550
2550
|
//#region src/customDomains/index.ts
|
|
2551
|
-
function
|
|
2551
|
+
function gr(e) {
|
|
2552
2552
|
return {
|
|
2553
|
-
create:
|
|
2554
|
-
get:
|
|
2555
|
-
getByDomain:
|
|
2556
|
-
list:
|
|
2557
|
-
remove:
|
|
2558
|
-
update:
|
|
2553
|
+
create: ur(e),
|
|
2554
|
+
get: pr(e),
|
|
2555
|
+
getByDomain: hr(e),
|
|
2556
|
+
list: dr(e),
|
|
2557
|
+
remove: fr(e),
|
|
2558
|
+
update: mr(e)
|
|
2559
2559
|
};
|
|
2560
2560
|
}
|
|
2561
2561
|
//#endregion
|
|
2562
2562
|
//#region src/branding/get.ts
|
|
2563
|
-
function
|
|
2563
|
+
function _r(e) {
|
|
2564
2564
|
return async (t) => {
|
|
2565
2565
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2566
2566
|
if (!n) return null;
|
|
@@ -2582,7 +2582,7 @@ function vr(e) {
|
|
|
2582
2582
|
}
|
|
2583
2583
|
//#endregion
|
|
2584
2584
|
//#region src/branding/set.ts
|
|
2585
|
-
function
|
|
2585
|
+
function vr(e) {
|
|
2586
2586
|
return async (t, n) => {
|
|
2587
2587
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2588
2588
|
try {
|
|
@@ -2611,15 +2611,15 @@ function yr(e) {
|
|
|
2611
2611
|
}
|
|
2612
2612
|
//#endregion
|
|
2613
2613
|
//#region src/branding/index.ts
|
|
2614
|
-
function
|
|
2614
|
+
function yr(e) {
|
|
2615
2615
|
return {
|
|
2616
|
-
get:
|
|
2617
|
-
set:
|
|
2616
|
+
get: _r(e),
|
|
2617
|
+
set: vr(e)
|
|
2618
2618
|
};
|
|
2619
2619
|
}
|
|
2620
2620
|
//#endregion
|
|
2621
2621
|
//#region src/universalLoginTemplates/get.ts
|
|
2622
|
-
function
|
|
2622
|
+
function br(e) {
|
|
2623
2623
|
return async (t) => {
|
|
2624
2624
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2625
2625
|
return n ? { body: n.body } : null;
|
|
@@ -2627,7 +2627,7 @@ function xr(e) {
|
|
|
2627
2627
|
}
|
|
2628
2628
|
//#endregion
|
|
2629
2629
|
//#region src/universalLoginTemplates/set.ts
|
|
2630
|
-
function
|
|
2630
|
+
function xr(e) {
|
|
2631
2631
|
return async (t, n, r) => {
|
|
2632
2632
|
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : a;
|
|
2633
2633
|
try {
|
|
@@ -2648,23 +2648,23 @@ function Sr(e) {
|
|
|
2648
2648
|
}
|
|
2649
2649
|
//#endregion
|
|
2650
2650
|
//#region src/universalLoginTemplates/delete.ts
|
|
2651
|
-
function
|
|
2651
|
+
function Sr(e) {
|
|
2652
2652
|
return async (t) => {
|
|
2653
2653
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2654
2654
|
};
|
|
2655
2655
|
}
|
|
2656
2656
|
//#endregion
|
|
2657
2657
|
//#region src/universalLoginTemplates/index.ts
|
|
2658
|
-
function
|
|
2658
|
+
function Cr(e) {
|
|
2659
2659
|
return {
|
|
2660
|
-
get:
|
|
2661
|
-
set:
|
|
2662
|
-
delete:
|
|
2660
|
+
get: br(e),
|
|
2661
|
+
set: xr(e),
|
|
2662
|
+
delete: Sr(e)
|
|
2663
2663
|
};
|
|
2664
2664
|
}
|
|
2665
2665
|
//#endregion
|
|
2666
2666
|
//#region src/hooks/list.ts
|
|
2667
|
-
function
|
|
2667
|
+
function wr(e) {
|
|
2668
2668
|
return async (t, n = {}) => {
|
|
2669
2669
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: u } = n, d = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
|
|
2670
2670
|
if (u && (d = E(e, d, u, [
|
|
@@ -2686,7 +2686,7 @@ function Tr(e) {
|
|
|
2686
2686
|
...u,
|
|
2687
2687
|
enabled: !!n,
|
|
2688
2688
|
synchronous: !!i,
|
|
2689
|
-
metadata:
|
|
2689
|
+
metadata: kt(s)
|
|
2690
2690
|
});
|
|
2691
2691
|
});
|
|
2692
2692
|
if (!s) return {
|
|
@@ -2706,7 +2706,7 @@ function Tr(e) {
|
|
|
2706
2706
|
}
|
|
2707
2707
|
//#endregion
|
|
2708
2708
|
//#region src/hooks/get.ts
|
|
2709
|
-
function
|
|
2709
|
+
function Tr(e) {
|
|
2710
2710
|
return async (t, n) => {
|
|
2711
2711
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2712
2712
|
if (!i) return null;
|
|
@@ -2719,18 +2719,18 @@ function Er(e) {
|
|
|
2719
2719
|
...d,
|
|
2720
2720
|
enabled: !!u.enabled,
|
|
2721
2721
|
synchronous: !!u.synchronous,
|
|
2722
|
-
metadata:
|
|
2722
|
+
metadata: kt(c)
|
|
2723
2723
|
});
|
|
2724
2724
|
};
|
|
2725
2725
|
}
|
|
2726
2726
|
//#endregion
|
|
2727
2727
|
//#region src/hooks/remove.ts
|
|
2728
|
-
function
|
|
2728
|
+
function Er(e) {
|
|
2729
2729
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2730
2730
|
}
|
|
2731
2731
|
//#endregion
|
|
2732
2732
|
//#region src/hooks/create.ts
|
|
2733
|
-
function
|
|
2733
|
+
function Dr(e) {
|
|
2734
2734
|
return async (t, n, r) => {
|
|
2735
2735
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Le()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2736
2736
|
return await e.insertInto("hooks").values({
|
|
@@ -2755,7 +2755,7 @@ function Or(e) {
|
|
|
2755
2755
|
}
|
|
2756
2756
|
//#endregion
|
|
2757
2757
|
//#region src/hooks/update.ts
|
|
2758
|
-
function
|
|
2758
|
+
function Or(e) {
|
|
2759
2759
|
return async (t, n, r) => {
|
|
2760
2760
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2761
2761
|
...o,
|
|
@@ -2769,18 +2769,18 @@ function kr(e) {
|
|
|
2769
2769
|
}
|
|
2770
2770
|
//#endregion
|
|
2771
2771
|
//#region src/hooks/index.ts
|
|
2772
|
-
function
|
|
2772
|
+
function kr(e) {
|
|
2773
2773
|
return {
|
|
2774
|
-
create:
|
|
2775
|
-
get:
|
|
2776
|
-
list:
|
|
2777
|
-
update:
|
|
2778
|
-
remove:
|
|
2774
|
+
create: Dr(e),
|
|
2775
|
+
get: Tr(e),
|
|
2776
|
+
list: wr(e),
|
|
2777
|
+
update: Or(e),
|
|
2778
|
+
remove: Er(e)
|
|
2779
2779
|
};
|
|
2780
2780
|
}
|
|
2781
2781
|
//#endregion
|
|
2782
2782
|
//#region src/hook-code/create.ts
|
|
2783
|
-
function
|
|
2783
|
+
function Ar(e) {
|
|
2784
2784
|
return async (t, n, r) => {
|
|
2785
2785
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? ze();
|
|
2786
2786
|
return await e.insertInto("hook_code").values({
|
|
@@ -2802,7 +2802,7 @@ function jr(e) {
|
|
|
2802
2802
|
}
|
|
2803
2803
|
//#endregion
|
|
2804
2804
|
//#region src/hook-code/get.ts
|
|
2805
|
-
function
|
|
2805
|
+
function jr(e) {
|
|
2806
2806
|
return async (t, n) => {
|
|
2807
2807
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2808
2808
|
if (!i) return null;
|
|
@@ -2826,7 +2826,7 @@ function Mr(e) {
|
|
|
2826
2826
|
}
|
|
2827
2827
|
//#endregion
|
|
2828
2828
|
//#region src/hook-code/update.ts
|
|
2829
|
-
function
|
|
2829
|
+
function Mr(e) {
|
|
2830
2830
|
return async (t, n, r) => {
|
|
2831
2831
|
let i = { updated_at_ts: Date.now() };
|
|
2832
2832
|
return r.code !== void 0 && (i.code = r.code), r.secrets !== void 0 && (i.secrets = JSON.stringify(r.secrets)), (await e.updateTable("hook_code").set(i).where("hook_code.id", "=", n).where("hook_code.tenant_id", "=", t).executeTakeFirst()).numUpdatedRows > 0;
|
|
@@ -2834,22 +2834,22 @@ function Nr(e) {
|
|
|
2834
2834
|
}
|
|
2835
2835
|
//#endregion
|
|
2836
2836
|
//#region src/hook-code/remove.ts
|
|
2837
|
-
function
|
|
2837
|
+
function Nr(e) {
|
|
2838
2838
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2839
2839
|
}
|
|
2840
2840
|
//#endregion
|
|
2841
2841
|
//#region src/hook-code/index.ts
|
|
2842
|
-
function
|
|
2842
|
+
function Pr(e) {
|
|
2843
2843
|
return {
|
|
2844
|
-
create:
|
|
2845
|
-
get:
|
|
2846
|
-
update:
|
|
2847
|
-
remove:
|
|
2844
|
+
create: Ar(e),
|
|
2845
|
+
get: jr(e),
|
|
2846
|
+
update: Mr(e),
|
|
2847
|
+
remove: Nr(e)
|
|
2848
2848
|
};
|
|
2849
2849
|
}
|
|
2850
2850
|
//#endregion
|
|
2851
2851
|
//#region src/themes/create.ts
|
|
2852
|
-
function
|
|
2852
|
+
function Fr(e) {
|
|
2853
2853
|
return async (n, r, i, a) => {
|
|
2854
2854
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2855
2855
|
themeId: o?.id || i || t(),
|
|
@@ -2860,20 +2860,20 @@ function Ir(e) {
|
|
|
2860
2860
|
...c,
|
|
2861
2861
|
tenant_id: n
|
|
2862
2862
|
};
|
|
2863
|
-
return await e.insertInto("themes").values(
|
|
2863
|
+
return await e.insertInto("themes").values(M(l)).execute(), c;
|
|
2864
2864
|
};
|
|
2865
2865
|
}
|
|
2866
2866
|
//#endregion
|
|
2867
2867
|
//#region src/themes/remove.ts
|
|
2868
|
-
function
|
|
2868
|
+
function Ir(e) {
|
|
2869
2869
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2870
2870
|
}
|
|
2871
2871
|
//#endregion
|
|
2872
2872
|
//#region src/themes/get.ts
|
|
2873
|
-
function
|
|
2873
|
+
function Lr(e) {
|
|
2874
2874
|
return async (t, n) => {
|
|
2875
2875
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2876
|
-
return r ? l(
|
|
2876
|
+
return r ? l(xt({
|
|
2877
2877
|
...r,
|
|
2878
2878
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2879
2879
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2893,9 +2893,9 @@ function Rr(e) {
|
|
|
2893
2893
|
}
|
|
2894
2894
|
//#endregion
|
|
2895
2895
|
//#region src/themes/update.ts
|
|
2896
|
-
function
|
|
2896
|
+
function Rr(e) {
|
|
2897
2897
|
return async (t, n, r) => {
|
|
2898
|
-
let { themeId: i, ...a } = r, o =
|
|
2898
|
+
let { themeId: i, ...a } = r, o = M({
|
|
2899
2899
|
...a,
|
|
2900
2900
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2901
2901
|
});
|
|
@@ -2904,17 +2904,17 @@ function zr(e) {
|
|
|
2904
2904
|
}
|
|
2905
2905
|
//#endregion
|
|
2906
2906
|
//#region src/themes/index.ts
|
|
2907
|
-
function
|
|
2907
|
+
function zr(e) {
|
|
2908
2908
|
return {
|
|
2909
|
-
create:
|
|
2910
|
-
get:
|
|
2911
|
-
remove:
|
|
2912
|
-
update:
|
|
2909
|
+
create: Fr(e),
|
|
2910
|
+
get: Lr(e),
|
|
2911
|
+
remove: Ir(e),
|
|
2912
|
+
update: Rr(e)
|
|
2913
2913
|
};
|
|
2914
2914
|
}
|
|
2915
2915
|
//#endregion
|
|
2916
2916
|
//#region src/loginSessions/get.ts
|
|
2917
|
-
function
|
|
2917
|
+
function Br(e) {
|
|
2918
2918
|
return async (t, n) => {
|
|
2919
2919
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2920
2920
|
if (!i) return null;
|
|
@@ -2926,7 +2926,7 @@ function Vr(e) {
|
|
|
2926
2926
|
"created_at_ts",
|
|
2927
2927
|
"updated_at_ts",
|
|
2928
2928
|
"expires_at_ts"
|
|
2929
|
-
]), f =
|
|
2929
|
+
]), f = xt(l({
|
|
2930
2930
|
...u,
|
|
2931
2931
|
...d,
|
|
2932
2932
|
state: i.state || m.PENDING,
|
|
@@ -2938,36 +2938,35 @@ function Vr(e) {
|
|
|
2938
2938
|
}
|
|
2939
2939
|
//#endregion
|
|
2940
2940
|
//#region src/utils/ulid.ts
|
|
2941
|
-
var
|
|
2942
|
-
function
|
|
2941
|
+
var Vr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", R = 32, Hr = 10, Ur = 16;
|
|
2942
|
+
function Wr(e) {
|
|
2943
2943
|
let t = "";
|
|
2944
|
-
for (let n =
|
|
2944
|
+
for (let n = Hr; n > 0; n--) t = Vr.charAt(e % R) + t, e = Math.floor(e / R);
|
|
2945
2945
|
return t;
|
|
2946
2946
|
}
|
|
2947
|
-
function
|
|
2948
|
-
let e = new Uint8Array(
|
|
2947
|
+
function Gr() {
|
|
2948
|
+
let e = new Uint8Array(Ur);
|
|
2949
2949
|
crypto.getRandomValues(e);
|
|
2950
2950
|
let t = "";
|
|
2951
|
-
for (let n = 0; n <
|
|
2951
|
+
for (let n = 0; n < Ur; n++) t += Vr.charAt(e[n] % R);
|
|
2952
2952
|
return t;
|
|
2953
2953
|
}
|
|
2954
|
-
function
|
|
2955
|
-
return
|
|
2954
|
+
function Kr() {
|
|
2955
|
+
return Wr(Date.now()) + Gr();
|
|
2956
2956
|
}
|
|
2957
2957
|
//#endregion
|
|
2958
2958
|
//#region src/loginSessions/create.ts
|
|
2959
|
-
function
|
|
2959
|
+
function qr(e) {
|
|
2960
2960
|
return async (t, n) => {
|
|
2961
2961
|
let r = c(), i = {
|
|
2962
|
-
id:
|
|
2962
|
+
id: Kr(),
|
|
2963
2963
|
...n,
|
|
2964
|
-
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2965
2964
|
created_at: r,
|
|
2966
2965
|
updated_at: r,
|
|
2967
2966
|
state: n.state || m.PENDING,
|
|
2968
2967
|
state_data: n.state_data,
|
|
2969
2968
|
failure_reason: n.failure_reason
|
|
2970
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2969
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = M(o);
|
|
2971
2970
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2972
2971
|
...l,
|
|
2973
2972
|
tenant_id: t,
|
|
@@ -2980,7 +2979,7 @@ function Yr(e) {
|
|
|
2980
2979
|
}
|
|
2981
2980
|
//#endregion
|
|
2982
2981
|
//#region src/loginSessions/update.ts
|
|
2983
|
-
function
|
|
2982
|
+
function Jr(e) {
|
|
2984
2983
|
return async (t, n, r) => {
|
|
2985
2984
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2986
2985
|
if (c !== void 0) {
|
|
@@ -2990,7 +2989,7 @@ function Xr(e) {
|
|
|
2990
2989
|
...c
|
|
2991
2990
|
}) };
|
|
2992
2991
|
}
|
|
2993
|
-
let d =
|
|
2992
|
+
let d = M(l);
|
|
2994
2993
|
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2995
2994
|
...d,
|
|
2996
2995
|
...u,
|
|
@@ -3001,22 +3000,22 @@ function Xr(e) {
|
|
|
3001
3000
|
}
|
|
3002
3001
|
//#endregion
|
|
3003
3002
|
//#region src/loginSessions/remove.ts
|
|
3004
|
-
function
|
|
3003
|
+
function Yr(e) {
|
|
3005
3004
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
3006
3005
|
}
|
|
3007
3006
|
//#endregion
|
|
3008
3007
|
//#region src/loginSessions/index.ts
|
|
3009
|
-
function
|
|
3008
|
+
function Xr(e) {
|
|
3010
3009
|
return {
|
|
3011
|
-
create:
|
|
3012
|
-
get:
|
|
3013
|
-
update:
|
|
3014
|
-
remove:
|
|
3010
|
+
create: qr(e),
|
|
3011
|
+
get: Br(e),
|
|
3012
|
+
update: Jr(e),
|
|
3013
|
+
remove: Yr(e)
|
|
3015
3014
|
};
|
|
3016
3015
|
}
|
|
3017
3016
|
//#endregion
|
|
3018
3017
|
//#region src/promptSettings/get.ts
|
|
3019
|
-
function
|
|
3018
|
+
function Zr(e) {
|
|
3020
3019
|
return async (t) => {
|
|
3021
3020
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
3022
3021
|
return l({
|
|
@@ -3030,13 +3029,13 @@ function $r(e) {
|
|
|
3030
3029
|
}
|
|
3031
3030
|
//#endregion
|
|
3032
3031
|
//#region src/promptSettings/set.ts
|
|
3033
|
-
function
|
|
3032
|
+
function Qr(e) {
|
|
3034
3033
|
let t = {};
|
|
3035
3034
|
return typeof e.identifier_first == "boolean" && (t.identifier_first = +!!e.identifier_first), typeof e.password_first == "boolean" && (t.password_first = +!!e.password_first), typeof e.webauthn_platform_first_factor == "boolean" && (t.webauthn_platform_first_factor = +!!e.webauthn_platform_first_factor), typeof e.show_last_used_connection == "boolean" && (t.show_last_used_connection = +!!e.show_last_used_connection), e.universal_login_experience && (t.universal_login_experience = e.universal_login_experience), t;
|
|
3036
3035
|
}
|
|
3037
|
-
function
|
|
3036
|
+
function $r(e) {
|
|
3038
3037
|
return async (t, n) => {
|
|
3039
|
-
let r =
|
|
3038
|
+
let r = Qr(n);
|
|
3040
3039
|
try {
|
|
3041
3040
|
await e.insertInto("prompt_settings").values({
|
|
3042
3041
|
tenant_id: t,
|
|
@@ -3054,15 +3053,15 @@ function ti(e) {
|
|
|
3054
3053
|
}
|
|
3055
3054
|
//#endregion
|
|
3056
3055
|
//#region src/promptSettings/index.ts
|
|
3057
|
-
function
|
|
3056
|
+
function ei(e) {
|
|
3058
3057
|
return {
|
|
3059
|
-
get:
|
|
3060
|
-
set:
|
|
3058
|
+
get: Zr(e),
|
|
3059
|
+
set: $r(e)
|
|
3061
3060
|
};
|
|
3062
3061
|
}
|
|
3063
3062
|
//#endregion
|
|
3064
3063
|
//#region src/emailProvideres/get.ts
|
|
3065
|
-
function
|
|
3064
|
+
function ti(e) {
|
|
3066
3065
|
return async (t) => {
|
|
3067
3066
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
3068
3067
|
if (!n) return null;
|
|
@@ -3077,7 +3076,7 @@ function ri(e) {
|
|
|
3077
3076
|
}
|
|
3078
3077
|
//#endregion
|
|
3079
3078
|
//#region src/emailProvideres/update.ts
|
|
3080
|
-
function
|
|
3079
|
+
function ni(e) {
|
|
3081
3080
|
return async (t, n) => {
|
|
3082
3081
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
3083
3082
|
await e.updateTable("email_providers").set({
|
|
@@ -3090,7 +3089,7 @@ function ii(e) {
|
|
|
3090
3089
|
}
|
|
3091
3090
|
//#endregion
|
|
3092
3091
|
//#region src/emailProvideres/create.ts
|
|
3093
|
-
function
|
|
3092
|
+
function ri(e) {
|
|
3094
3093
|
return async (t, n, r) => {
|
|
3095
3094
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
3096
3095
|
await e.insertInto("email_providers").values({
|
|
@@ -3106,24 +3105,24 @@ function ai(e) {
|
|
|
3106
3105
|
}
|
|
3107
3106
|
//#endregion
|
|
3108
3107
|
//#region src/emailProvideres/remove.ts
|
|
3109
|
-
function
|
|
3108
|
+
function ii(e) {
|
|
3110
3109
|
return async (t) => {
|
|
3111
3110
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3112
3111
|
};
|
|
3113
3112
|
}
|
|
3114
3113
|
//#endregion
|
|
3115
3114
|
//#region src/emailProvideres/index.ts
|
|
3116
|
-
function
|
|
3115
|
+
function ai(e) {
|
|
3117
3116
|
return {
|
|
3118
|
-
get:
|
|
3119
|
-
create:
|
|
3120
|
-
update:
|
|
3121
|
-
remove:
|
|
3117
|
+
get: ti(e),
|
|
3118
|
+
create: ri(e),
|
|
3119
|
+
update: ni(e),
|
|
3120
|
+
remove: ii(e)
|
|
3122
3121
|
};
|
|
3123
3122
|
}
|
|
3124
3123
|
//#endregion
|
|
3125
3124
|
//#region src/emailTemplates/row.ts
|
|
3126
|
-
function
|
|
3125
|
+
function oi(e) {
|
|
3127
3126
|
let t = {
|
|
3128
3127
|
template: e.template,
|
|
3129
3128
|
body: e.body,
|
|
@@ -3137,20 +3136,20 @@ function ci(e) {
|
|
|
3137
3136
|
}
|
|
3138
3137
|
//#endregion
|
|
3139
3138
|
//#region src/emailTemplates/get.ts
|
|
3140
|
-
function
|
|
3139
|
+
function si(e) {
|
|
3141
3140
|
return async (t, n) => {
|
|
3142
3141
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3143
|
-
return r ? ie.parse(
|
|
3142
|
+
return r ? ie.parse(oi(r)) : null;
|
|
3144
3143
|
};
|
|
3145
3144
|
}
|
|
3146
3145
|
//#endregion
|
|
3147
3146
|
//#region src/emailTemplates/list.ts
|
|
3148
|
-
function
|
|
3149
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ie.parse(
|
|
3147
|
+
function ci(e) {
|
|
3148
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ie.parse(oi(e)));
|
|
3150
3149
|
}
|
|
3151
3150
|
//#endregion
|
|
3152
3151
|
//#region src/emailTemplates/create.ts
|
|
3153
|
-
function
|
|
3152
|
+
function li(e) {
|
|
3154
3153
|
return async (t, n, r) => {
|
|
3155
3154
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3156
3155
|
return await e.insertInto("email_templates").values({
|
|
@@ -3171,7 +3170,7 @@ function di(e) {
|
|
|
3171
3170
|
}
|
|
3172
3171
|
//#endregion
|
|
3173
3172
|
//#region src/emailTemplates/update.ts
|
|
3174
|
-
function
|
|
3173
|
+
function ui(e) {
|
|
3175
3174
|
return async (t, n, r) => {
|
|
3176
3175
|
let i = {};
|
|
3177
3176
|
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;
|
|
@@ -3182,7 +3181,7 @@ function fi(e) {
|
|
|
3182
3181
|
}
|
|
3183
3182
|
//#endregion
|
|
3184
3183
|
//#region src/emailTemplates/remove.ts
|
|
3185
|
-
function
|
|
3184
|
+
function di(e) {
|
|
3186
3185
|
return async (t, n) => {
|
|
3187
3186
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3188
3187
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3190,18 +3189,18 @@ function pi(e) {
|
|
|
3190
3189
|
}
|
|
3191
3190
|
//#endregion
|
|
3192
3191
|
//#region src/emailTemplates/index.ts
|
|
3193
|
-
function
|
|
3192
|
+
function fi(e) {
|
|
3194
3193
|
return {
|
|
3195
|
-
get:
|
|
3196
|
-
list:
|
|
3197
|
-
create:
|
|
3198
|
-
update:
|
|
3199
|
-
remove:
|
|
3194
|
+
get: si(e),
|
|
3195
|
+
list: ci(e),
|
|
3196
|
+
create: li(e),
|
|
3197
|
+
update: ui(e),
|
|
3198
|
+
remove: di(e)
|
|
3200
3199
|
};
|
|
3201
3200
|
}
|
|
3202
3201
|
//#endregion
|
|
3203
3202
|
//#region src/refreshTokens/to-refresh-token.ts
|
|
3204
|
-
function
|
|
3203
|
+
function z(e) {
|
|
3205
3204
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: i, idle_expires_at_ts: a, last_exchanged_at_ts: o, revoked_at_ts: s, rotated_at_ts: c, auth_strategy_strategy: u, auth_strategy_strategy_type: d, ...f } = e, p = r({
|
|
3206
3205
|
created_at_ts: n,
|
|
3207
3206
|
expires_at_ts: i,
|
|
@@ -3230,23 +3229,23 @@ function L(e) {
|
|
|
3230
3229
|
}
|
|
3231
3230
|
//#endregion
|
|
3232
3231
|
//#region src/refreshTokens/get.ts
|
|
3233
|
-
function
|
|
3232
|
+
function pi(e) {
|
|
3234
3233
|
return async (t, n) => {
|
|
3235
3234
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3236
|
-
return r ?
|
|
3235
|
+
return r ? z(r) : null;
|
|
3237
3236
|
};
|
|
3238
3237
|
}
|
|
3239
3238
|
//#endregion
|
|
3240
3239
|
//#region src/refreshTokens/getByLookup.ts
|
|
3241
|
-
function
|
|
3240
|
+
function mi(e) {
|
|
3242
3241
|
return async (t, n) => {
|
|
3243
3242
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3244
|
-
return r ?
|
|
3243
|
+
return r ? z(r) : null;
|
|
3245
3244
|
};
|
|
3246
3245
|
}
|
|
3247
3246
|
//#endregion
|
|
3248
3247
|
//#region src/refreshTokens/create.ts
|
|
3249
|
-
function
|
|
3248
|
+
function hi(e) {
|
|
3250
3249
|
return async (t, n) => {
|
|
3251
3250
|
let r = c(), i = {
|
|
3252
3251
|
...n,
|
|
@@ -3278,12 +3277,12 @@ function _i(e) {
|
|
|
3278
3277
|
}
|
|
3279
3278
|
//#endregion
|
|
3280
3279
|
//#region src/refreshTokens/remove.ts
|
|
3281
|
-
function
|
|
3280
|
+
function gi(e) {
|
|
3282
3281
|
return async (t, n) => ((await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
3283
3282
|
}
|
|
3284
3283
|
//#endregion
|
|
3285
3284
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3286
|
-
function
|
|
3285
|
+
function _i(e) {
|
|
3287
3286
|
return async (t, n, r) => {
|
|
3288
3287
|
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();
|
|
3289
3288
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3291,7 +3290,7 @@ function yi(e) {
|
|
|
3291
3290
|
}
|
|
3292
3291
|
//#endregion
|
|
3293
3292
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3294
|
-
function
|
|
3293
|
+
function vi(e) {
|
|
3295
3294
|
return async (t, n, r) => {
|
|
3296
3295
|
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();
|
|
3297
3296
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3299,7 +3298,7 @@ function bi(e) {
|
|
|
3299
3298
|
}
|
|
3300
3299
|
//#endregion
|
|
3301
3300
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3302
|
-
function
|
|
3301
|
+
function yi(e) {
|
|
3303
3302
|
return async (t, n, r) => {
|
|
3304
3303
|
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();
|
|
3305
3304
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3307,7 +3306,7 @@ function xi(e) {
|
|
|
3307
3306
|
}
|
|
3308
3307
|
//#endregion
|
|
3309
3308
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3310
|
-
function
|
|
3309
|
+
function bi(e) {
|
|
3311
3310
|
return async (t, n, r) => {
|
|
3312
3311
|
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();
|
|
3313
3312
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3315,7 +3314,7 @@ function Si(e) {
|
|
|
3315
3314
|
}
|
|
3316
3315
|
//#endregion
|
|
3317
3316
|
//#region src/refreshTokens/update.ts
|
|
3318
|
-
function
|
|
3317
|
+
function xi(e) {
|
|
3319
3318
|
return async (t, n, r, i) => {
|
|
3320
3319
|
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 = {
|
|
3321
3320
|
...h,
|
|
@@ -3336,14 +3335,14 @@ function Ci(e) {
|
|
|
3336
3335
|
}
|
|
3337
3336
|
//#endregion
|
|
3338
3337
|
//#region src/refreshTokens/list.ts
|
|
3339
|
-
function
|
|
3338
|
+
function Si(e) {
|
|
3340
3339
|
return async (t, n = {}) => {
|
|
3341
3340
|
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);
|
|
3342
|
-
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = E(e, u, c, ["token", "login_id"])),
|
|
3343
|
-
let { rows: e, limit: t, next: r } = await
|
|
3341
|
+
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = E(e, u, c, ["token", "login_id"])), A(n)) {
|
|
3342
|
+
let { rows: e, limit: t, next: r } = await j(u.selectAll(), n, {
|
|
3344
3343
|
sortColumn: "created_at_ts",
|
|
3345
3344
|
sortOrder: "desc"
|
|
3346
|
-
}), i = e.map(
|
|
3345
|
+
}), i = e.map(z);
|
|
3347
3346
|
return {
|
|
3348
3347
|
refresh_tokens: i,
|
|
3349
3348
|
start: 0,
|
|
@@ -3358,7 +3357,7 @@ function wi(e) {
|
|
|
3358
3357
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3359
3358
|
}
|
|
3360
3359
|
d = d.offset(r * i).limit(i);
|
|
3361
|
-
let f = (await d.selectAll().execute()).map(
|
|
3360
|
+
let f = (await d.selectAll().execute()).map(z);
|
|
3362
3361
|
if (!a) return {
|
|
3363
3362
|
refresh_tokens: f,
|
|
3364
3363
|
start: 0,
|
|
@@ -3376,34 +3375,34 @@ function wi(e) {
|
|
|
3376
3375
|
}
|
|
3377
3376
|
//#endregion
|
|
3378
3377
|
//#region src/refreshTokens/index.ts
|
|
3379
|
-
function
|
|
3378
|
+
function Ci(e) {
|
|
3380
3379
|
return {
|
|
3381
|
-
create:
|
|
3382
|
-
get:
|
|
3383
|
-
getByLookup:
|
|
3384
|
-
list:
|
|
3385
|
-
remove:
|
|
3386
|
-
revokeByLoginSession:
|
|
3387
|
-
revokeBySession:
|
|
3388
|
-
revokeByUser:
|
|
3389
|
-
revokeFamily:
|
|
3390
|
-
update:
|
|
3380
|
+
create: hi(e),
|
|
3381
|
+
get: pi(e),
|
|
3382
|
+
getByLookup: mi(e),
|
|
3383
|
+
list: Si(e),
|
|
3384
|
+
remove: gi(e),
|
|
3385
|
+
revokeByLoginSession: _i(e),
|
|
3386
|
+
revokeBySession: vi(e),
|
|
3387
|
+
revokeByUser: yi(e),
|
|
3388
|
+
revokeFamily: bi(e),
|
|
3389
|
+
update: xi(e)
|
|
3391
3390
|
};
|
|
3392
3391
|
}
|
|
3393
3392
|
//#endregion
|
|
3394
3393
|
//#region src/cleanup.ts
|
|
3395
|
-
var
|
|
3396
|
-
function
|
|
3394
|
+
var wi = 10080 * 60 * 1e3, B = 1e3;
|
|
3395
|
+
function Ti(e) {
|
|
3397
3396
|
return async (t) => {
|
|
3398
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3397
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - wi, a = (t) => async () => {
|
|
3399
3398
|
let a = e.deleteFrom("refresh_tokens").where(t, "<", i);
|
|
3400
3399
|
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3401
|
-
let o = await a.limit(
|
|
3400
|
+
let o = await a.limit(B).execute();
|
|
3402
3401
|
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3403
3402
|
}, o = (t) => async () => {
|
|
3404
3403
|
let a = e.deleteFrom("sessions").where(t, "<", i);
|
|
3405
3404
|
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3406
|
-
let o = await a.limit(
|
|
3405
|
+
let o = await a.limit(B).execute();
|
|
3407
3406
|
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3408
3407
|
}, s = [
|
|
3409
3408
|
{
|
|
@@ -3412,7 +3411,7 @@ function Di(e) {
|
|
|
3412
3411
|
deleteBatch: async () => {
|
|
3413
3412
|
let t = e.deleteFrom("login_sessions").where("expires_at_ts", "<", i);
|
|
3414
3413
|
n && (t = t.where("tenant_id", "=", n)), r && (t = t.where("user_id", "=", r));
|
|
3415
|
-
let a = await t.limit(
|
|
3414
|
+
let a = await t.limit(B).execute();
|
|
3416
3415
|
return Number(a[0]?.numDeletedRows ?? 0);
|
|
3417
3416
|
}
|
|
3418
3417
|
},
|
|
@@ -3446,7 +3445,7 @@ function Di(e) {
|
|
|
3446
3445
|
c += 1;
|
|
3447
3446
|
try {
|
|
3448
3447
|
let t = await e.deleteBatch();
|
|
3449
|
-
e.deleted += t, t <
|
|
3448
|
+
e.deleted += t, t < B && (e.drained = !0);
|
|
3450
3449
|
} catch (t) {
|
|
3451
3450
|
e.failed = !0, e.drained = !0, console.error(`Error during session cleanup (${e.label}):`, t);
|
|
3452
3451
|
}
|
|
@@ -3459,7 +3458,7 @@ function Di(e) {
|
|
|
3459
3458
|
}
|
|
3460
3459
|
//#endregion
|
|
3461
3460
|
//#region src/forms/create.ts
|
|
3462
|
-
function
|
|
3461
|
+
function Ei(e) {
|
|
3463
3462
|
return async (n, r, i) => {
|
|
3464
3463
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3465
3464
|
id: a?.id ?? t(),
|
|
@@ -3478,7 +3477,7 @@ function Oi(e) {
|
|
|
3478
3477
|
}
|
|
3479
3478
|
//#endregion
|
|
3480
3479
|
//#region src/forms/list.ts
|
|
3481
|
-
function
|
|
3480
|
+
function Di(e) {
|
|
3482
3481
|
return async (t, n = {}) => {
|
|
3483
3482
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3484
3483
|
s && (c = E(e, c, s, []));
|
|
@@ -3512,7 +3511,7 @@ function ki(e) {
|
|
|
3512
3511
|
}
|
|
3513
3512
|
//#endregion
|
|
3514
3513
|
//#region src/forms/remove.ts
|
|
3515
|
-
function
|
|
3514
|
+
function Oi(e) {
|
|
3516
3515
|
return async (t, n) => {
|
|
3517
3516
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3518
3517
|
return r > 0;
|
|
@@ -3520,7 +3519,7 @@ function Ai(e) {
|
|
|
3520
3519
|
}
|
|
3521
3520
|
//#endregion
|
|
3522
3521
|
//#region src/forms/get.ts
|
|
3523
|
-
function
|
|
3522
|
+
function ki(e) {
|
|
3524
3523
|
return async (t, n) => {
|
|
3525
3524
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3526
3525
|
if (!r) return null;
|
|
@@ -3539,7 +3538,7 @@ function ji(e) {
|
|
|
3539
3538
|
}
|
|
3540
3539
|
//#endregion
|
|
3541
3540
|
//#region src/forms/update.ts
|
|
3542
|
-
function
|
|
3541
|
+
function Ai(e) {
|
|
3543
3542
|
return async (t, n, r) => {
|
|
3544
3543
|
let i = {
|
|
3545
3544
|
...r,
|
|
@@ -3556,18 +3555,18 @@ function Mi(e) {
|
|
|
3556
3555
|
}
|
|
3557
3556
|
//#endregion
|
|
3558
3557
|
//#region src/forms/index.ts
|
|
3559
|
-
function
|
|
3558
|
+
function ji(e) {
|
|
3560
3559
|
return {
|
|
3561
|
-
create:
|
|
3562
|
-
get:
|
|
3563
|
-
list:
|
|
3564
|
-
remove:
|
|
3565
|
-
update:
|
|
3560
|
+
create: Ei(e),
|
|
3561
|
+
get: ki(e),
|
|
3562
|
+
list: Di(e),
|
|
3563
|
+
remove: Oi(e),
|
|
3564
|
+
update: Ai(e)
|
|
3566
3565
|
};
|
|
3567
3566
|
}
|
|
3568
3567
|
//#endregion
|
|
3569
3568
|
//#region src/resourceServers/create.ts
|
|
3570
|
-
function
|
|
3569
|
+
function Mi(e) {
|
|
3571
3570
|
return async (t, n, r) => {
|
|
3572
3571
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3573
3572
|
...n,
|
|
@@ -3592,7 +3591,7 @@ function Pi(e) {
|
|
|
3592
3591
|
}
|
|
3593
3592
|
//#endregion
|
|
3594
3593
|
//#region src/resourceServers/get.ts
|
|
3595
|
-
function
|
|
3594
|
+
function Ni(e) {
|
|
3596
3595
|
return async (t, n) => {
|
|
3597
3596
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3598
3597
|
if (!r) return null;
|
|
@@ -3611,7 +3610,7 @@ function Fi(e) {
|
|
|
3611
3610
|
}
|
|
3612
3611
|
//#endregion
|
|
3613
3612
|
//#region src/resourceServers/list.ts
|
|
3614
|
-
function
|
|
3613
|
+
function Pi(e) {
|
|
3615
3614
|
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({
|
|
3616
3615
|
...c,
|
|
3617
3616
|
scopes: n ? JSON.parse(n) : [],
|
|
@@ -3624,7 +3623,7 @@ function Ii(e) {
|
|
|
3624
3623
|
});
|
|
3625
3624
|
return u.token_lifetime ??= 86400, u.token_lifetime_for_web ??= 7200, u;
|
|
3626
3625
|
}
|
|
3627
|
-
function
|
|
3626
|
+
function Fi(e) {
|
|
3628
3627
|
return async (t, n = {}) => {
|
|
3629
3628
|
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);
|
|
3630
3629
|
if (s) {
|
|
@@ -3634,12 +3633,12 @@ function Li(e) {
|
|
|
3634
3633
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3635
3634
|
} else c = E(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3636
3635
|
}
|
|
3637
|
-
if (
|
|
3638
|
-
let { rows: e, limit: t, next: r } = await
|
|
3636
|
+
if (A(n)) {
|
|
3637
|
+
let { rows: e, limit: t, next: r } = await j(c.selectAll(), n, {
|
|
3639
3638
|
sortColumn: "created_at",
|
|
3640
3639
|
sortOrder: "desc",
|
|
3641
3640
|
idColumn: "id"
|
|
3642
|
-
}), i = e.map(
|
|
3641
|
+
}), i = e.map(Pi);
|
|
3643
3642
|
return {
|
|
3644
3643
|
resource_servers: i,
|
|
3645
3644
|
start: 0,
|
|
@@ -3648,7 +3647,7 @@ function Li(e) {
|
|
|
3648
3647
|
next: r
|
|
3649
3648
|
};
|
|
3650
3649
|
}
|
|
3651
|
-
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(
|
|
3650
|
+
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(Pi);
|
|
3652
3651
|
if (!a) return {
|
|
3653
3652
|
resource_servers: l,
|
|
3654
3653
|
start: 0,
|
|
@@ -3666,7 +3665,7 @@ function Li(e) {
|
|
|
3666
3665
|
}
|
|
3667
3666
|
//#endregion
|
|
3668
3667
|
//#region src/resourceServers/remove.ts
|
|
3669
|
-
function
|
|
3668
|
+
function Ii(e) {
|
|
3670
3669
|
return async (t, n) => {
|
|
3671
3670
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3672
3671
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3674,7 +3673,7 @@ function Ri(e) {
|
|
|
3674
3673
|
}
|
|
3675
3674
|
//#endregion
|
|
3676
3675
|
//#region src/resourceServers/update.ts
|
|
3677
|
-
function
|
|
3676
|
+
function Li(e) {
|
|
3678
3677
|
return async (t, n, r) => {
|
|
3679
3678
|
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 = {
|
|
3680
3679
|
...d,
|
|
@@ -3694,18 +3693,18 @@ function zi(e) {
|
|
|
3694
3693
|
}
|
|
3695
3694
|
//#endregion
|
|
3696
3695
|
//#region src/resourceServers/index.ts
|
|
3697
|
-
function
|
|
3696
|
+
function Ri(e) {
|
|
3698
3697
|
return {
|
|
3699
|
-
create:
|
|
3700
|
-
get:
|
|
3701
|
-
list:
|
|
3702
|
-
remove:
|
|
3703
|
-
update:
|
|
3698
|
+
create: Mi(e),
|
|
3699
|
+
get: Ni(e),
|
|
3700
|
+
list: Fi(e),
|
|
3701
|
+
remove: Ii(e),
|
|
3702
|
+
update: Li(e)
|
|
3704
3703
|
};
|
|
3705
3704
|
}
|
|
3706
3705
|
//#endregion
|
|
3707
3706
|
//#region src/roles/create.ts
|
|
3708
|
-
function
|
|
3707
|
+
function zi(e) {
|
|
3709
3708
|
return async (n, r, i) => {
|
|
3710
3709
|
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 = {
|
|
3711
3710
|
id: l,
|
|
@@ -3728,7 +3727,7 @@ function Vi(e) {
|
|
|
3728
3727
|
}
|
|
3729
3728
|
//#endregion
|
|
3730
3729
|
//#region src/roles/get.ts
|
|
3731
|
-
function
|
|
3730
|
+
function Bi(e) {
|
|
3732
3731
|
return async (t, n) => {
|
|
3733
3732
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3734
3733
|
if (!r) return null;
|
|
@@ -3742,18 +3741,24 @@ function Hi(e) {
|
|
|
3742
3741
|
}
|
|
3743
3742
|
//#endregion
|
|
3744
3743
|
//#region src/roles/list.ts
|
|
3745
|
-
function
|
|
3746
|
-
return async (t, n) => {
|
|
3744
|
+
function Vi(e) {
|
|
3745
|
+
return async (t, n = {}) => {
|
|
3747
3746
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3748
|
-
n.q && (r = E(e, r, n.q, ["name"]))
|
|
3749
|
-
|
|
3750
|
-
|
|
3747
|
+
if (n.q && (r = E(e, r, n.q, ["name"])), A(n)) {
|
|
3748
|
+
let { rows: e, limit: t, next: i } = await j(r.selectAll(), n, {
|
|
3749
|
+
sortColumn: "created_at",
|
|
3750
|
+
sortOrder: "desc",
|
|
3751
|
+
idColumn: "id"
|
|
3752
|
+
}), a = e.map(Hi);
|
|
3751
3753
|
return {
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3754
|
+
roles: a,
|
|
3755
|
+
start: 0,
|
|
3756
|
+
limit: t,
|
|
3757
|
+
length: a.length,
|
|
3758
|
+
next: i
|
|
3755
3759
|
};
|
|
3756
|
-
}
|
|
3760
|
+
}
|
|
3761
|
+
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map(Hi);
|
|
3757
3762
|
if (!s) return {
|
|
3758
3763
|
roles: c,
|
|
3759
3764
|
start: i * a,
|
|
@@ -3769,9 +3774,17 @@ function Ui(e) {
|
|
|
3769
3774
|
};
|
|
3770
3775
|
};
|
|
3771
3776
|
}
|
|
3777
|
+
function Hi(e) {
|
|
3778
|
+
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3779
|
+
return {
|
|
3780
|
+
...i,
|
|
3781
|
+
is_system: t ? !0 : void 0,
|
|
3782
|
+
metadata: r ? JSON.parse(r) : void 0
|
|
3783
|
+
};
|
|
3784
|
+
}
|
|
3772
3785
|
//#endregion
|
|
3773
3786
|
//#region src/roles/update.ts
|
|
3774
|
-
function
|
|
3787
|
+
function Ui(e) {
|
|
3775
3788
|
return async (t, n, r) => {
|
|
3776
3789
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3777
3790
|
...o,
|
|
@@ -3784,7 +3797,7 @@ function Wi(e) {
|
|
|
3784
3797
|
}
|
|
3785
3798
|
//#endregion
|
|
3786
3799
|
//#region src/roles/remove.ts
|
|
3787
|
-
function
|
|
3800
|
+
function Wi(e) {
|
|
3788
3801
|
return async (t, n) => {
|
|
3789
3802
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3790
3803
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3792,23 +3805,23 @@ function Gi(e) {
|
|
|
3792
3805
|
}
|
|
3793
3806
|
//#endregion
|
|
3794
3807
|
//#region src/roles/index.ts
|
|
3795
|
-
function
|
|
3808
|
+
function Gi(e) {
|
|
3796
3809
|
return {
|
|
3797
|
-
create:
|
|
3798
|
-
get:
|
|
3799
|
-
list:
|
|
3800
|
-
update:
|
|
3801
|
-
remove:
|
|
3810
|
+
create: zi(e),
|
|
3811
|
+
get: Bi(e),
|
|
3812
|
+
list: Vi(e),
|
|
3813
|
+
update: Ui(e),
|
|
3814
|
+
remove: Wi(e)
|
|
3802
3815
|
};
|
|
3803
3816
|
}
|
|
3804
3817
|
//#endregion
|
|
3805
3818
|
//#region src/role-permissions/assign.ts
|
|
3806
|
-
function
|
|
3819
|
+
function Ki(e) {
|
|
3807
3820
|
if (typeof e != "object" || !e) return !1;
|
|
3808
3821
|
let { code: t, message: n } = e;
|
|
3809
3822
|
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"));
|
|
3810
3823
|
}
|
|
3811
|
-
function
|
|
3824
|
+
function qi(e) {
|
|
3812
3825
|
return async (t, n, r, i) => {
|
|
3813
3826
|
if (r.length === 0) return !0;
|
|
3814
3827
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3825,7 +3838,7 @@ function Ji(e) {
|
|
|
3825
3838
|
try {
|
|
3826
3839
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3827
3840
|
} catch (e) {
|
|
3828
|
-
if (
|
|
3841
|
+
if (Ki(e)) continue;
|
|
3829
3842
|
throw e;
|
|
3830
3843
|
}
|
|
3831
3844
|
}
|
|
@@ -3837,7 +3850,7 @@ function Ji(e) {
|
|
|
3837
3850
|
}
|
|
3838
3851
|
//#endregion
|
|
3839
3852
|
//#region src/role-permissions/remove.ts
|
|
3840
|
-
function
|
|
3853
|
+
function Ji(e) {
|
|
3841
3854
|
return async (t, n, r) => {
|
|
3842
3855
|
if (r.length === 0) return !0;
|
|
3843
3856
|
try {
|
|
@@ -3849,7 +3862,7 @@ function Yi(e) {
|
|
|
3849
3862
|
}
|
|
3850
3863
|
//#endregion
|
|
3851
3864
|
//#region src/role-permissions/list.ts
|
|
3852
|
-
function
|
|
3865
|
+
function Yi(e) {
|
|
3853
3866
|
return async (t, n, r = {}) => {
|
|
3854
3867
|
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s = e.selectFrom("role_permissions").leftJoin("resource_servers", (e) => e.onRef("role_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("role_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3855
3868
|
"role_permissions.role_id",
|
|
@@ -3870,16 +3883,16 @@ function Xi(e) {
|
|
|
3870
3883
|
}
|
|
3871
3884
|
//#endregion
|
|
3872
3885
|
//#region src/role-permissions/index.ts
|
|
3873
|
-
function
|
|
3886
|
+
function Xi(e) {
|
|
3874
3887
|
return {
|
|
3875
|
-
assign:
|
|
3876
|
-
remove:
|
|
3877
|
-
list:
|
|
3888
|
+
assign: qi(e),
|
|
3889
|
+
remove: Ji(e),
|
|
3890
|
+
list: Yi(e)
|
|
3878
3891
|
};
|
|
3879
3892
|
}
|
|
3880
3893
|
//#endregion
|
|
3881
3894
|
//#region src/grants/create.ts
|
|
3882
|
-
function
|
|
3895
|
+
function Zi(e) {
|
|
3883
3896
|
return async (n, r) => {
|
|
3884
3897
|
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();
|
|
3885
3898
|
if (s) {
|
|
@@ -3916,7 +3929,7 @@ function Qi(e) {
|
|
|
3916
3929
|
}
|
|
3917
3930
|
//#endregion
|
|
3918
3931
|
//#region src/grants/get.ts
|
|
3919
|
-
function
|
|
3932
|
+
function Qi(e) {
|
|
3920
3933
|
return async (t, n, r, i) => {
|
|
3921
3934
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3922
3935
|
return a ? {
|
|
@@ -3930,7 +3943,7 @@ function $i(e) {
|
|
|
3930
3943
|
}
|
|
3931
3944
|
//#endregion
|
|
3932
3945
|
//#region src/grants/list.ts
|
|
3933
|
-
function
|
|
3946
|
+
function $i(e) {
|
|
3934
3947
|
return async (t, n = {}) => {
|
|
3935
3948
|
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);
|
|
3936
3949
|
c && (l = E(e, l, c, [
|
|
@@ -3968,26 +3981,26 @@ function ea(e) {
|
|
|
3968
3981
|
}
|
|
3969
3982
|
//#endregion
|
|
3970
3983
|
//#region src/grants/remove.ts
|
|
3971
|
-
function
|
|
3984
|
+
function ea(e) {
|
|
3972
3985
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3973
3986
|
}
|
|
3974
|
-
function
|
|
3987
|
+
function ta(e) {
|
|
3975
3988
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3976
3989
|
}
|
|
3977
3990
|
//#endregion
|
|
3978
3991
|
//#region src/grants/index.ts
|
|
3979
|
-
function
|
|
3992
|
+
function na(e) {
|
|
3980
3993
|
return {
|
|
3981
|
-
create:
|
|
3982
|
-
get:
|
|
3983
|
-
list:
|
|
3984
|
-
remove:
|
|
3985
|
-
removeByUser:
|
|
3994
|
+
create: Zi(e),
|
|
3995
|
+
get: Qi(e),
|
|
3996
|
+
list: $i(e),
|
|
3997
|
+
remove: ea(e),
|
|
3998
|
+
removeByUser: ta(e)
|
|
3986
3999
|
};
|
|
3987
4000
|
}
|
|
3988
4001
|
//#endregion
|
|
3989
4002
|
//#region src/user-permissions/create.ts
|
|
3990
|
-
function
|
|
4003
|
+
function ra(e) {
|
|
3991
4004
|
return async (t, n, r, i, a) => {
|
|
3992
4005
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3993
4006
|
try {
|
|
@@ -4007,7 +4020,7 @@ function ia(e) {
|
|
|
4007
4020
|
}
|
|
4008
4021
|
//#endregion
|
|
4009
4022
|
//#region src/user-permissions/remove.ts
|
|
4010
|
-
function
|
|
4023
|
+
function ia(e) {
|
|
4011
4024
|
return async (t, n, r, i) => {
|
|
4012
4025
|
try {
|
|
4013
4026
|
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);
|
|
@@ -4019,7 +4032,7 @@ function aa(e) {
|
|
|
4019
4032
|
}
|
|
4020
4033
|
//#endregion
|
|
4021
4034
|
//#region src/user-permissions/list.ts
|
|
4022
|
-
function
|
|
4035
|
+
function aa(e) {
|
|
4023
4036
|
return async (t, n, r, i) => {
|
|
4024
4037
|
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([
|
|
4025
4038
|
"user_permissions.resource_server_identifier",
|
|
@@ -4042,17 +4055,17 @@ function oa(e) {
|
|
|
4042
4055
|
}
|
|
4043
4056
|
//#endregion
|
|
4044
4057
|
//#region src/user-permissions/index.ts
|
|
4045
|
-
function
|
|
4058
|
+
function oa(e) {
|
|
4046
4059
|
return {
|
|
4047
|
-
create:
|
|
4048
|
-
remove:
|
|
4049
|
-
list:
|
|
4060
|
+
create: ra(e),
|
|
4061
|
+
remove: ia(e),
|
|
4062
|
+
list: aa(e)
|
|
4050
4063
|
};
|
|
4051
4064
|
}
|
|
4052
4065
|
//#endregion
|
|
4053
4066
|
//#region src/user-permissions/adapter.ts
|
|
4054
|
-
function
|
|
4055
|
-
let t =
|
|
4067
|
+
function sa(e) {
|
|
4068
|
+
let t = oa(e);
|
|
4056
4069
|
return {
|
|
4057
4070
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
4058
4071
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -4061,7 +4074,7 @@ function ca(e) {
|
|
|
4061
4074
|
}
|
|
4062
4075
|
//#endregion
|
|
4063
4076
|
//#region src/user-roles/list.ts
|
|
4064
|
-
function
|
|
4077
|
+
function ca(e) {
|
|
4065
4078
|
return async (t, n, r, i) => {
|
|
4066
4079
|
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([
|
|
4067
4080
|
"r.id",
|
|
@@ -4075,11 +4088,11 @@ function la(e) {
|
|
|
4075
4088
|
}
|
|
4076
4089
|
//#endregion
|
|
4077
4090
|
//#region src/user-roles/list-users.ts
|
|
4078
|
-
function
|
|
4091
|
+
function la(e) {
|
|
4079
4092
|
return async (t, n, r) => {
|
|
4080
4093
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
4081
|
-
if (
|
|
4082
|
-
let { rows: e, limit: t, next: n } = await
|
|
4094
|
+
if (A(r)) {
|
|
4095
|
+
let { rows: e, limit: t, next: n } = await j(i, r, {
|
|
4083
4096
|
sortColumn: "user_id",
|
|
4084
4097
|
sortOrder: "asc",
|
|
4085
4098
|
idColumn: "user_id"
|
|
@@ -4103,7 +4116,7 @@ function ua(e) {
|
|
|
4103
4116
|
}
|
|
4104
4117
|
//#endregion
|
|
4105
4118
|
//#region src/user-roles/create.ts
|
|
4106
|
-
function
|
|
4119
|
+
function ua(e) {
|
|
4107
4120
|
return async (t, n, r, i, a) => {
|
|
4108
4121
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
4109
4122
|
try {
|
|
@@ -4121,7 +4134,7 @@ function da(e) {
|
|
|
4121
4134
|
}
|
|
4122
4135
|
//#endregion
|
|
4123
4136
|
//#region src/user-roles/remove.ts
|
|
4124
|
-
function
|
|
4137
|
+
function da(e) {
|
|
4125
4138
|
return async (t, n, r, i) => {
|
|
4126
4139
|
try {
|
|
4127
4140
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -4133,18 +4146,18 @@ function fa(e) {
|
|
|
4133
4146
|
}
|
|
4134
4147
|
//#endregion
|
|
4135
4148
|
//#region src/user-roles/index.ts
|
|
4136
|
-
function
|
|
4149
|
+
function fa(e) {
|
|
4137
4150
|
return {
|
|
4138
|
-
list:
|
|
4139
|
-
listUsers:
|
|
4140
|
-
create:
|
|
4141
|
-
remove:
|
|
4151
|
+
list: ca(e),
|
|
4152
|
+
listUsers: la(e),
|
|
4153
|
+
create: ua(e),
|
|
4154
|
+
remove: da(e)
|
|
4142
4155
|
};
|
|
4143
4156
|
}
|
|
4144
4157
|
//#endregion
|
|
4145
4158
|
//#region src/user-roles/adapter.ts
|
|
4146
|
-
function
|
|
4147
|
-
let t =
|
|
4159
|
+
function pa(e) {
|
|
4160
|
+
let t = fa(e);
|
|
4148
4161
|
return {
|
|
4149
4162
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
4150
4163
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4154,7 +4167,7 @@ function ma(e) {
|
|
|
4154
4167
|
}
|
|
4155
4168
|
//#endregion
|
|
4156
4169
|
//#region src/organizations/create.ts
|
|
4157
|
-
function
|
|
4170
|
+
function ma(e) {
|
|
4158
4171
|
return async (t, n, r) => {
|
|
4159
4172
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4160
4173
|
...n,
|
|
@@ -4182,7 +4195,7 @@ function ha(e) {
|
|
|
4182
4195
|
}
|
|
4183
4196
|
//#endregion
|
|
4184
4197
|
//#region src/organizations/get.ts
|
|
4185
|
-
function
|
|
4198
|
+
function ha(e) {
|
|
4186
4199
|
return async (t, n) => {
|
|
4187
4200
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4188
4201
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4196,16 +4209,16 @@ function ga(e) {
|
|
|
4196
4209
|
}
|
|
4197
4210
|
//#endregion
|
|
4198
4211
|
//#region src/organizations/list.ts
|
|
4199
|
-
var
|
|
4200
|
-
function
|
|
4212
|
+
var V = ["name", "display_name"];
|
|
4213
|
+
function ga(e) {
|
|
4201
4214
|
return async (t, n) => {
|
|
4202
4215
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4203
4216
|
if (n?.q) {
|
|
4204
|
-
let t = S(n.q,
|
|
4205
|
-
t && (r = E(e, r, t,
|
|
4217
|
+
let t = S(n.q, V);
|
|
4218
|
+
t && (r = E(e, r, t, V));
|
|
4206
4219
|
}
|
|
4207
|
-
if (
|
|
4208
|
-
let { rows: e, limit: t, next: i } = await
|
|
4220
|
+
if (A(n)) {
|
|
4221
|
+
let { rows: e, limit: t, next: i } = await j(r.selectAll(), n, {
|
|
4209
4222
|
sortColumn: "created_at",
|
|
4210
4223
|
sortOrder: "desc"
|
|
4211
4224
|
}), a = e.map((e) => l({
|
|
@@ -4238,8 +4251,8 @@ function _a(e) {
|
|
|
4238
4251
|
if (n?.include_totals) {
|
|
4239
4252
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4240
4253
|
if (n?.q) {
|
|
4241
|
-
let t = S(n.q,
|
|
4242
|
-
t && (r = E(e, r, t,
|
|
4254
|
+
let t = S(n.q, V);
|
|
4255
|
+
t && (r = E(e, r, t, V));
|
|
4243
4256
|
}
|
|
4244
4257
|
let i = await r.select(p`count(*)`.as("count")).executeTakeFirst();
|
|
4245
4258
|
u = Number(i?.count || 0);
|
|
@@ -4262,7 +4275,7 @@ function _a(e) {
|
|
|
4262
4275
|
}
|
|
4263
4276
|
//#endregion
|
|
4264
4277
|
//#region src/organizations/remove.ts
|
|
4265
|
-
function
|
|
4278
|
+
function _a(e) {
|
|
4266
4279
|
return async (t, n) => {
|
|
4267
4280
|
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4268
4281
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -4270,7 +4283,7 @@ function va(e) {
|
|
|
4270
4283
|
}
|
|
4271
4284
|
//#endregion
|
|
4272
4285
|
//#region src/organizations/update.ts
|
|
4273
|
-
function
|
|
4286
|
+
function va(e) {
|
|
4274
4287
|
return async (t, n, r) => {
|
|
4275
4288
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4276
4289
|
...c,
|
|
@@ -4286,18 +4299,18 @@ function ya(e) {
|
|
|
4286
4299
|
}
|
|
4287
4300
|
//#endregion
|
|
4288
4301
|
//#region src/organizations/index.ts
|
|
4289
|
-
function
|
|
4302
|
+
function ya(e) {
|
|
4290
4303
|
return {
|
|
4291
|
-
create:
|
|
4292
|
-
get:
|
|
4293
|
-
list:
|
|
4294
|
-
remove:
|
|
4295
|
-
update:
|
|
4304
|
+
create: ma(e),
|
|
4305
|
+
get: ha(e),
|
|
4306
|
+
list: ga(e),
|
|
4307
|
+
remove: _a(e),
|
|
4308
|
+
update: va(e)
|
|
4296
4309
|
};
|
|
4297
4310
|
}
|
|
4298
4311
|
//#endregion
|
|
4299
4312
|
//#region src/organization-connections/index.ts
|
|
4300
|
-
function
|
|
4313
|
+
function H(e, t) {
|
|
4301
4314
|
return {
|
|
4302
4315
|
connection_id: e.connection_id,
|
|
4303
4316
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4311,14 +4324,14 @@ function B(e, t) {
|
|
|
4311
4324
|
updated_at: e.updated_at
|
|
4312
4325
|
};
|
|
4313
4326
|
}
|
|
4314
|
-
async function
|
|
4327
|
+
async function U(e, t, n) {
|
|
4315
4328
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4316
4329
|
if (r) return {
|
|
4317
4330
|
name: r.name,
|
|
4318
4331
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4319
4332
|
};
|
|
4320
4333
|
}
|
|
4321
|
-
function
|
|
4334
|
+
function ba(e) {
|
|
4322
4335
|
return {
|
|
4323
4336
|
async create(t, n, r, i) {
|
|
4324
4337
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4331,19 +4344,19 @@ function xa(e) {
|
|
|
4331
4344
|
created_at: a?.created_at ?? o,
|
|
4332
4345
|
updated_at: a?.updated_at ?? o
|
|
4333
4346
|
};
|
|
4334
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4347
|
+
return await e.insertInto("organization_connections").values(s).execute(), H(s, await U(e, t, r.connection_id));
|
|
4335
4348
|
},
|
|
4336
4349
|
async list(t, n) {
|
|
4337
4350
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4338
4351
|
for (let n of r) {
|
|
4339
|
-
let r = await
|
|
4340
|
-
i.push(
|
|
4352
|
+
let r = await U(e, t, n.connection_id);
|
|
4353
|
+
i.push(H(n, r));
|
|
4341
4354
|
}
|
|
4342
4355
|
return i;
|
|
4343
4356
|
},
|
|
4344
4357
|
async get(t, n, r) {
|
|
4345
4358
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4346
|
-
return i ?
|
|
4359
|
+
return i ? H(i, await U(e, t, r)) : null;
|
|
4347
4360
|
},
|
|
4348
4361
|
async update(t, n, r, i) {
|
|
4349
4362
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4351,7 +4364,7 @@ function xa(e) {
|
|
|
4351
4364
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4352
4365
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4353
4366
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4354
|
-
return s ?
|
|
4367
|
+
return s ? H(s, await U(e, t, r)) : null;
|
|
4355
4368
|
},
|
|
4356
4369
|
async remove(t, n, r) {
|
|
4357
4370
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4361,7 +4374,7 @@ function xa(e) {
|
|
|
4361
4374
|
}
|
|
4362
4375
|
//#endregion
|
|
4363
4376
|
//#region src/user-organizations/create.ts
|
|
4364
|
-
function
|
|
4377
|
+
function xa(e) {
|
|
4365
4378
|
return async (n, r, i) => {
|
|
4366
4379
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4367
4380
|
id: a?.id ?? t(),
|
|
@@ -4381,7 +4394,7 @@ function Sa(e) {
|
|
|
4381
4394
|
}
|
|
4382
4395
|
//#endregion
|
|
4383
4396
|
//#region src/user-organizations/get.ts
|
|
4384
|
-
function
|
|
4397
|
+
function Sa(e) {
|
|
4385
4398
|
return async (t, n) => {
|
|
4386
4399
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4387
4400
|
return r ? {
|
|
@@ -4395,13 +4408,13 @@ function Ca(e) {
|
|
|
4395
4408
|
}
|
|
4396
4409
|
//#endregion
|
|
4397
4410
|
//#region src/user-organizations/list.ts
|
|
4398
|
-
function
|
|
4411
|
+
function W(e, t) {
|
|
4399
4412
|
return Oe(e.slice(t.length + 1));
|
|
4400
4413
|
}
|
|
4401
|
-
function
|
|
4414
|
+
function Ca(e) {
|
|
4402
4415
|
return async (t, n) => {
|
|
4403
4416
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4404
|
-
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=",
|
|
4417
|
+
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", W(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", W(n.q, "organization_id"))));
|
|
4405
4418
|
let i = (e) => ({
|
|
4406
4419
|
id: e.id,
|
|
4407
4420
|
user_id: e.user_id,
|
|
@@ -4409,8 +4422,8 @@ function wa(e) {
|
|
|
4409
4422
|
created_at: e.created_at,
|
|
4410
4423
|
updated_at: e.updated_at
|
|
4411
4424
|
});
|
|
4412
|
-
if (
|
|
4413
|
-
let { rows: e, limit: t, next: a } = await
|
|
4425
|
+
if (A(n)) {
|
|
4426
|
+
let { rows: e, limit: t, next: a } = await j(r, n, {
|
|
4414
4427
|
sortColumn: "created_at",
|
|
4415
4428
|
sortOrder: "desc"
|
|
4416
4429
|
});
|
|
@@ -4423,7 +4436,7 @@ function wa(e) {
|
|
|
4423
4436
|
};
|
|
4424
4437
|
}
|
|
4425
4438
|
let a = n?.page || 0, o = n?.per_page || 50, s = a * o, c = await r.orderBy("created_at", "desc").limit(o).offset(s).execute(), l = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
|
|
4426
|
-
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=",
|
|
4439
|
+
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=", W(n.q, "user_id")) : n.q.startsWith("organization_id:") && (l = l.where("organization_id", "=", W(n.q, "organization_id"))));
|
|
4427
4440
|
let u = await l.executeTakeFirst();
|
|
4428
4441
|
return {
|
|
4429
4442
|
userOrganizations: c.map(i),
|
|
@@ -4435,7 +4448,7 @@ function wa(e) {
|
|
|
4435
4448
|
}
|
|
4436
4449
|
//#endregion
|
|
4437
4450
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4438
|
-
function
|
|
4451
|
+
function wa(e) {
|
|
4439
4452
|
return async (t, n, r) => {
|
|
4440
4453
|
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([
|
|
4441
4454
|
"organizations.id",
|
|
@@ -4472,12 +4485,12 @@ function Ta(e) {
|
|
|
4472
4485
|
}
|
|
4473
4486
|
//#endregion
|
|
4474
4487
|
//#region src/user-organizations/remove.ts
|
|
4475
|
-
function
|
|
4488
|
+
function Ta(e) {
|
|
4476
4489
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4477
4490
|
}
|
|
4478
4491
|
//#endregion
|
|
4479
4492
|
//#region src/user-organizations/update.ts
|
|
4480
|
-
function
|
|
4493
|
+
function Ea(e) {
|
|
4481
4494
|
return async (t, n, r) => {
|
|
4482
4495
|
let i = {
|
|
4483
4496
|
...r,
|
|
@@ -4488,19 +4501,19 @@ function Da(e) {
|
|
|
4488
4501
|
}
|
|
4489
4502
|
//#endregion
|
|
4490
4503
|
//#region src/user-organizations/index.ts
|
|
4491
|
-
function
|
|
4504
|
+
function Da(e) {
|
|
4492
4505
|
return {
|
|
4493
|
-
create:
|
|
4494
|
-
get:
|
|
4495
|
-
list:
|
|
4496
|
-
listUserOrganizations:
|
|
4497
|
-
remove:
|
|
4498
|
-
update:
|
|
4506
|
+
create: xa(e),
|
|
4507
|
+
get: Sa(e),
|
|
4508
|
+
list: Ca(e),
|
|
4509
|
+
listUserOrganizations: wa(e),
|
|
4510
|
+
remove: Ta(e),
|
|
4511
|
+
update: Ea(e)
|
|
4499
4512
|
};
|
|
4500
4513
|
}
|
|
4501
4514
|
//#endregion
|
|
4502
4515
|
//#region src/invites/create.ts
|
|
4503
|
-
function
|
|
4516
|
+
function Oa(e) {
|
|
4504
4517
|
return async (t, n, r) => {
|
|
4505
4518
|
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 = {
|
|
4506
4519
|
id: a,
|
|
@@ -4546,11 +4559,11 @@ function ka(e) {
|
|
|
4546
4559
|
}
|
|
4547
4560
|
//#endregion
|
|
4548
4561
|
//#region src/invites/get.ts
|
|
4549
|
-
function
|
|
4562
|
+
function ka(e) {
|
|
4550
4563
|
return async (t, n) => {
|
|
4551
4564
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4552
4565
|
return r ? l({
|
|
4553
|
-
...
|
|
4566
|
+
...At(r, {
|
|
4554
4567
|
inviter: {},
|
|
4555
4568
|
invitee: {},
|
|
4556
4569
|
app_metadata: {},
|
|
@@ -4563,7 +4576,7 @@ function Aa(e) {
|
|
|
4563
4576
|
}
|
|
4564
4577
|
//#endregion
|
|
4565
4578
|
//#region src/invites/list.ts
|
|
4566
|
-
function
|
|
4579
|
+
function Aa(e) {
|
|
4567
4580
|
return async (t, n) => {
|
|
4568
4581
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4569
4582
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4571,7 +4584,7 @@ function ja(e) {
|
|
|
4571
4584
|
r = r.offset(e);
|
|
4572
4585
|
}
|
|
4573
4586
|
let i = (await r.execute()).map((e) => l({
|
|
4574
|
-
...
|
|
4587
|
+
...At(e, {
|
|
4575
4588
|
inviter: {},
|
|
4576
4589
|
invitee: {},
|
|
4577
4590
|
app_metadata: {},
|
|
@@ -4590,12 +4603,12 @@ function ja(e) {
|
|
|
4590
4603
|
}
|
|
4591
4604
|
//#endregion
|
|
4592
4605
|
//#region src/invites/remove.ts
|
|
4593
|
-
function
|
|
4606
|
+
function ja(e) {
|
|
4594
4607
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4595
4608
|
}
|
|
4596
4609
|
//#endregion
|
|
4597
4610
|
//#region src/invites/update.ts
|
|
4598
|
-
function
|
|
4611
|
+
function Ma(e) {
|
|
4599
4612
|
return async (t, n, r) => {
|
|
4600
4613
|
let i = {};
|
|
4601
4614
|
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;
|
|
@@ -4603,35 +4616,35 @@ function Na(e) {
|
|
|
4603
4616
|
}
|
|
4604
4617
|
//#endregion
|
|
4605
4618
|
//#region src/invites/index.ts
|
|
4606
|
-
function
|
|
4619
|
+
function Na(e) {
|
|
4607
4620
|
return {
|
|
4608
|
-
create:
|
|
4609
|
-
get:
|
|
4610
|
-
list:
|
|
4611
|
-
remove:
|
|
4612
|
-
update:
|
|
4621
|
+
create: Oa(e),
|
|
4622
|
+
get: ka(e),
|
|
4623
|
+
list: Aa(e),
|
|
4624
|
+
remove: ja(e),
|
|
4625
|
+
update: Ma(e)
|
|
4613
4626
|
};
|
|
4614
4627
|
}
|
|
4615
4628
|
//#endregion
|
|
4616
4629
|
//#region src/stats/index.ts
|
|
4617
|
-
var
|
|
4618
|
-
function
|
|
4630
|
+
var Pa = ["s"], Fa = ["pwd_leak"];
|
|
4631
|
+
function Ia(e) {
|
|
4619
4632
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4620
4633
|
}
|
|
4621
|
-
function
|
|
4634
|
+
function La(e) {
|
|
4622
4635
|
return e.toISOString().split("T")[0];
|
|
4623
4636
|
}
|
|
4624
|
-
function
|
|
4637
|
+
function Ra(e) {
|
|
4625
4638
|
return {
|
|
4626
4639
|
async getDaily(t, n = {}) {
|
|
4627
4640
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4628
4641
|
o.setDate(o.getDate() - 30);
|
|
4629
|
-
let s = r ?
|
|
4642
|
+
let s = r ? Ia(r) : La(o), c = i ? Ia(i) : La(a), l = p`DATE(logs.date)`;
|
|
4630
4643
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4631
4644
|
l.as("date"),
|
|
4632
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4645
|
+
e.fn.sum(e.case().when("type", "in", Pa).then(1).else(0).end()).as("logins"),
|
|
4633
4646
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4634
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4647
|
+
e.fn.sum(e.case().when("type", "in", Fa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4635
4648
|
e.fn.min("date").as("first_event"),
|
|
4636
4649
|
e.fn.max("date").as("last_event")
|
|
4637
4650
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4645,13 +4658,13 @@ function za(e) {
|
|
|
4645
4658
|
},
|
|
4646
4659
|
async getActiveUsers(t) {
|
|
4647
4660
|
let n = /* @__PURE__ */ new Date();
|
|
4648
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4661
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", Pa).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4649
4662
|
}
|
|
4650
4663
|
};
|
|
4651
4664
|
}
|
|
4652
4665
|
//#endregion
|
|
4653
4666
|
//#region src/analytics/index.ts
|
|
4654
|
-
var
|
|
4667
|
+
var za = {
|
|
4655
4668
|
"active-users": ["s", "seacft"],
|
|
4656
4669
|
logins: [
|
|
4657
4670
|
"s",
|
|
@@ -4681,7 +4694,7 @@ var Ba = {
|
|
|
4681
4694
|
"fvr"
|
|
4682
4695
|
],
|
|
4683
4696
|
"codes-sent": ["cls", "cs"]
|
|
4684
|
-
},
|
|
4697
|
+
}, Ba = {
|
|
4685
4698
|
"active-users": {
|
|
4686
4699
|
alias: "active_users",
|
|
4687
4700
|
type: "UInt64",
|
|
@@ -4738,14 +4751,14 @@ var Ba = {
|
|
|
4738
4751
|
agg: "count"
|
|
4739
4752
|
}
|
|
4740
4753
|
};
|
|
4741
|
-
async function
|
|
4754
|
+
async function Va(e) {
|
|
4742
4755
|
try {
|
|
4743
4756
|
return await p`SELECT @@version_comment`.execute(e), "mysql";
|
|
4744
4757
|
} catch {
|
|
4745
4758
|
return "sqlite";
|
|
4746
4759
|
}
|
|
4747
4760
|
}
|
|
4748
|
-
function
|
|
4761
|
+
function Ha(e, t) {
|
|
4749
4762
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4750
4763
|
timeZone: e,
|
|
4751
4764
|
year: "numeric",
|
|
@@ -4775,9 +4788,9 @@ var Ua = [
|
|
|
4775
4788
|
"December"
|
|
4776
4789
|
];
|
|
4777
4790
|
function Wa(e, t) {
|
|
4778
|
-
let n = t.getUTCFullYear(), r =
|
|
4791
|
+
let n = t.getUTCFullYear(), r = Ha(e, new Date(Date.UTC(n, 0, 1)));
|
|
4779
4792
|
for (let t = 1; t < 12; t++) {
|
|
4780
|
-
let i =
|
|
4793
|
+
let i = Ha(e, new Date(Date.UTC(n, t, 1)));
|
|
4781
4794
|
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ua[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').`);
|
|
4782
4795
|
}
|
|
4783
4796
|
}
|
|
@@ -4822,7 +4835,7 @@ function qa(e, t) {
|
|
|
4822
4835
|
}
|
|
4823
4836
|
function Ja(e, t, n, r) {
|
|
4824
4837
|
Wa(t, n);
|
|
4825
|
-
let i =
|
|
4838
|
+
let i = Ha(t, n);
|
|
4826
4839
|
return r === "mysql" ? qa(e, i) : Ka(e, i);
|
|
4827
4840
|
}
|
|
4828
4841
|
function Ya(e) {
|
|
@@ -4835,10 +4848,10 @@ function Ya(e) {
|
|
|
4835
4848
|
}
|
|
4836
4849
|
}
|
|
4837
4850
|
function Xa(e) {
|
|
4838
|
-
let t = null, n = () => (t ||=
|
|
4851
|
+
let t = null, n = () => (t ||= Va(e), t);
|
|
4839
4852
|
return {
|
|
4840
4853
|
async query(t, r, i) {
|
|
4841
|
-
let a = Date.now(), o =
|
|
4854
|
+
let a = Date.now(), o = za[r], s = Ba[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4842
4855
|
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));
|
|
4843
4856
|
let d = [], f = [];
|
|
4844
4857
|
for (let e of i.group_by) if (e === "time") {
|
|
@@ -4967,7 +4980,7 @@ function Za(e) {
|
|
|
4967
4980
|
//#region src/authenticationMethods/create.ts
|
|
4968
4981
|
function Qa(e) {
|
|
4969
4982
|
return async (t, n, r) => {
|
|
4970
|
-
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 ??
|
|
4983
|
+
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 ?? Kr();
|
|
4971
4984
|
return await e.insertInto("authentication_methods").values({
|
|
4972
4985
|
id: s,
|
|
4973
4986
|
tenant_id: t,
|
|
@@ -5235,7 +5248,7 @@ function mo(e) {
|
|
|
5235
5248
|
//#region src/outbox/index.ts
|
|
5236
5249
|
function ho(e) {
|
|
5237
5250
|
return {
|
|
5238
|
-
create:
|
|
5251
|
+
create: st(e),
|
|
5239
5252
|
getByIds: ao(e),
|
|
5240
5253
|
getUnprocessed: oo(e),
|
|
5241
5254
|
claimEvents: so(e),
|
|
@@ -5249,7 +5262,7 @@ function ho(e) {
|
|
|
5249
5262
|
}
|
|
5250
5263
|
//#endregion
|
|
5251
5264
|
//#region src/log-streams/index.ts
|
|
5252
|
-
function
|
|
5265
|
+
function go(e) {
|
|
5253
5266
|
return {
|
|
5254
5267
|
id: e.id,
|
|
5255
5268
|
name: e.name,
|
|
@@ -5262,7 +5275,7 @@ function W(e) {
|
|
|
5262
5275
|
updated_at: e.updated_at
|
|
5263
5276
|
};
|
|
5264
5277
|
}
|
|
5265
|
-
function
|
|
5278
|
+
function _o(e) {
|
|
5266
5279
|
return {
|
|
5267
5280
|
async create(n, r, i) {
|
|
5268
5281
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5277,14 +5290,14 @@ function go(e) {
|
|
|
5277
5290
|
created_at: a?.created_at ?? o,
|
|
5278
5291
|
updated_at: a?.updated_at ?? o
|
|
5279
5292
|
};
|
|
5280
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5293
|
+
return await e.insertInto("log_streams").values(s).execute(), go(s);
|
|
5281
5294
|
},
|
|
5282
5295
|
async get(t, n) {
|
|
5283
5296
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5284
|
-
return r ?
|
|
5297
|
+
return r ? go(r) : null;
|
|
5285
5298
|
},
|
|
5286
5299
|
async list(t) {
|
|
5287
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5300
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(go);
|
|
5288
5301
|
},
|
|
5289
5302
|
async update(t, n, r) {
|
|
5290
5303
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5297,7 +5310,7 @@ function go(e) {
|
|
|
5297
5310
|
}
|
|
5298
5311
|
//#endregion
|
|
5299
5312
|
//#region src/migrationSources/index.ts
|
|
5300
|
-
function
|
|
5313
|
+
function vo(e) {
|
|
5301
5314
|
return {
|
|
5302
5315
|
id: e.id,
|
|
5303
5316
|
name: e.name,
|
|
@@ -5309,7 +5322,7 @@ function G(e) {
|
|
|
5309
5322
|
updated_at: e.updated_at
|
|
5310
5323
|
};
|
|
5311
5324
|
}
|
|
5312
|
-
function
|
|
5325
|
+
function yo(e) {
|
|
5313
5326
|
return {
|
|
5314
5327
|
async create(n, r, i) {
|
|
5315
5328
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5323,14 +5336,14 @@ function _o(e) {
|
|
|
5323
5336
|
created_at: a?.created_at ?? o,
|
|
5324
5337
|
updated_at: a?.updated_at ?? o
|
|
5325
5338
|
};
|
|
5326
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5339
|
+
return await e.insertInto("migration_sources").values(l).execute(), vo(l);
|
|
5327
5340
|
},
|
|
5328
5341
|
async get(t, n) {
|
|
5329
5342
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5330
|
-
return r ?
|
|
5343
|
+
return r ? vo(r) : null;
|
|
5331
5344
|
},
|
|
5332
5345
|
async list(t) {
|
|
5333
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5346
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(vo);
|
|
5334
5347
|
},
|
|
5335
5348
|
async update(t, n, r) {
|
|
5336
5349
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5343,19 +5356,19 @@ function _o(e) {
|
|
|
5343
5356
|
}
|
|
5344
5357
|
//#endregion
|
|
5345
5358
|
//#region src/proxyRoutes/serialize.ts
|
|
5346
|
-
function
|
|
5359
|
+
function bo(e) {
|
|
5347
5360
|
return {
|
|
5348
5361
|
id: e.id,
|
|
5349
5362
|
tenant_id: e.tenant_id,
|
|
5350
5363
|
custom_domain_id: e.custom_domain_id,
|
|
5351
5364
|
priority: e.priority,
|
|
5352
|
-
match:
|
|
5353
|
-
handlers:
|
|
5365
|
+
match: xo(e.match),
|
|
5366
|
+
handlers: So(e.handlers),
|
|
5354
5367
|
created_at: e.created_at,
|
|
5355
5368
|
updated_at: e.updated_at
|
|
5356
5369
|
};
|
|
5357
5370
|
}
|
|
5358
|
-
function
|
|
5371
|
+
function xo(e) {
|
|
5359
5372
|
if (!e) return { path: "/*" };
|
|
5360
5373
|
try {
|
|
5361
5374
|
let t = JSON.parse(e), n = ue.safeParse(t);
|
|
@@ -5363,7 +5376,7 @@ function yo(e) {
|
|
|
5363
5376
|
} catch {}
|
|
5364
5377
|
return { path: "/*" };
|
|
5365
5378
|
}
|
|
5366
|
-
function
|
|
5379
|
+
function So(e) {
|
|
5367
5380
|
if (!e) return [];
|
|
5368
5381
|
try {
|
|
5369
5382
|
let t = JSON.parse(e);
|
|
@@ -5380,7 +5393,7 @@ function bo(e) {
|
|
|
5380
5393
|
}
|
|
5381
5394
|
//#endregion
|
|
5382
5395
|
//#region src/proxyRoutes/adapter.ts
|
|
5383
|
-
function
|
|
5396
|
+
function Co(e) {
|
|
5384
5397
|
return {
|
|
5385
5398
|
async create(n, r, i) {
|
|
5386
5399
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5406,14 +5419,14 @@ function xo(e) {
|
|
|
5406
5419
|
},
|
|
5407
5420
|
async get(t, n) {
|
|
5408
5421
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5409
|
-
return r ?
|
|
5422
|
+
return r ? bo(r) : null;
|
|
5410
5423
|
},
|
|
5411
5424
|
async list(t, n = {}) {
|
|
5412
5425
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5413
5426
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5414
5427
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5415
5428
|
return {
|
|
5416
|
-
proxy_routes: o.map(
|
|
5429
|
+
proxy_routes: o.map(bo),
|
|
5417
5430
|
start: r * i,
|
|
5418
5431
|
limit: i,
|
|
5419
5432
|
length: o.length
|
|
@@ -5433,7 +5446,7 @@ function xo(e) {
|
|
|
5433
5446
|
}
|
|
5434
5447
|
//#endregion
|
|
5435
5448
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5436
|
-
async function
|
|
5449
|
+
async function wo(e, t) {
|
|
5437
5450
|
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([
|
|
5438
5451
|
"custom_domain_id",
|
|
5439
5452
|
"tenant_id",
|
|
@@ -5445,20 +5458,20 @@ async function So(e, t) {
|
|
|
5445
5458
|
tenant_id: a.tenant_id,
|
|
5446
5459
|
custom_domain_id: a.custom_domain_id,
|
|
5447
5460
|
domain: a.domain,
|
|
5448
|
-
routes: o.map(
|
|
5461
|
+
routes: o.map(bo)
|
|
5449
5462
|
};
|
|
5450
5463
|
}
|
|
5451
5464
|
//#endregion
|
|
5452
5465
|
//#region src/proxyRoutes/index.ts
|
|
5453
|
-
function
|
|
5466
|
+
function To(e) {
|
|
5454
5467
|
return {
|
|
5455
|
-
proxyRoutes:
|
|
5456
|
-
resolveHost: (t) =>
|
|
5468
|
+
proxyRoutes: Co(e),
|
|
5469
|
+
resolveHost: (t) => wo(e, t)
|
|
5457
5470
|
};
|
|
5458
5471
|
}
|
|
5459
5472
|
//#endregion
|
|
5460
5473
|
//#region src/tokenExchangeProfiles/serialize.ts
|
|
5461
|
-
function
|
|
5474
|
+
function Eo(e) {
|
|
5462
5475
|
let t = {
|
|
5463
5476
|
id: e.id,
|
|
5464
5477
|
name: e.name,
|
|
@@ -5468,10 +5481,10 @@ function wo(e) {
|
|
|
5468
5481
|
updated_at: e.updated_at
|
|
5469
5482
|
};
|
|
5470
5483
|
e.action_id && (t.action_id = e.action_id);
|
|
5471
|
-
let n =
|
|
5484
|
+
let n = Do(e.jwt_verification);
|
|
5472
5485
|
return n && (t.jwt_verification = n), t;
|
|
5473
5486
|
}
|
|
5474
|
-
function
|
|
5487
|
+
function Do(e) {
|
|
5475
5488
|
if (e) try {
|
|
5476
5489
|
let t = Te.safeParse(JSON.parse(e));
|
|
5477
5490
|
return t.success ? t.data : void 0;
|
|
@@ -5481,12 +5494,12 @@ function To(e) {
|
|
|
5481
5494
|
}
|
|
5482
5495
|
//#endregion
|
|
5483
5496
|
//#region src/tokenExchangeProfiles/adapter.ts
|
|
5484
|
-
var
|
|
5485
|
-
function
|
|
5497
|
+
var Oo = e("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
5498
|
+
function ko(e) {
|
|
5486
5499
|
return {
|
|
5487
5500
|
async create(t, n, r) {
|
|
5488
5501
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5489
|
-
id: i?.id ?? `tep_${
|
|
5502
|
+
id: i?.id ?? `tep_${Oo()}`,
|
|
5490
5503
|
tenant_id: t,
|
|
5491
5504
|
name: n.name,
|
|
5492
5505
|
subject_token_type: n.subject_token_type,
|
|
@@ -5496,14 +5509,14 @@ function Do(e) {
|
|
|
5496
5509
|
created_at: i?.created_at ?? a,
|
|
5497
5510
|
updated_at: i?.updated_at ?? a
|
|
5498
5511
|
};
|
|
5499
|
-
return await e.insertInto("token_exchange_profiles").values(o).execute(),
|
|
5512
|
+
return await e.insertInto("token_exchange_profiles").values(o).execute(), Eo(o);
|
|
5500
5513
|
},
|
|
5501
5514
|
async get(t, n) {
|
|
5502
5515
|
let r = await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5503
|
-
return r ?
|
|
5516
|
+
return r ? Eo(r) : null;
|
|
5504
5517
|
},
|
|
5505
5518
|
async list(t) {
|
|
5506
|
-
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(
|
|
5519
|
+
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(Eo);
|
|
5507
5520
|
},
|
|
5508
5521
|
async update(t, n, r) {
|
|
5509
5522
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5519,7 +5532,7 @@ function Do(e) {
|
|
|
5519
5532
|
}
|
|
5520
5533
|
//#endregion
|
|
5521
5534
|
//#region src/scim/adapter.ts
|
|
5522
|
-
function
|
|
5535
|
+
function Ao(e) {
|
|
5523
5536
|
if (!e) return [];
|
|
5524
5537
|
try {
|
|
5525
5538
|
let t = JSON.parse(e);
|
|
@@ -5534,7 +5547,7 @@ function Oo(e) {
|
|
|
5534
5547
|
return [];
|
|
5535
5548
|
}
|
|
5536
5549
|
}
|
|
5537
|
-
function
|
|
5550
|
+
function jo(e) {
|
|
5538
5551
|
if (!e) return [];
|
|
5539
5552
|
try {
|
|
5540
5553
|
let t = JSON.parse(e);
|
|
@@ -5543,16 +5556,16 @@ function ko(e) {
|
|
|
5543
5556
|
return [];
|
|
5544
5557
|
}
|
|
5545
5558
|
}
|
|
5546
|
-
function
|
|
5559
|
+
function Mo(e) {
|
|
5547
5560
|
return {
|
|
5548
5561
|
connection_id: e.connection_id,
|
|
5549
5562
|
user_id_attribute: e.user_id_attribute,
|
|
5550
|
-
mapping:
|
|
5563
|
+
mapping: Ao(e.mapping),
|
|
5551
5564
|
created_at: e.created_at,
|
|
5552
5565
|
updated_at: e.updated_at
|
|
5553
5566
|
};
|
|
5554
5567
|
}
|
|
5555
|
-
function
|
|
5568
|
+
function No(e) {
|
|
5556
5569
|
return {
|
|
5557
5570
|
async create(t, n) {
|
|
5558
5571
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5573,7 +5586,7 @@ function jo(e) {
|
|
|
5573
5586
|
},
|
|
5574
5587
|
async get(t, n) {
|
|
5575
5588
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5576
|
-
return r ?
|
|
5589
|
+
return r ? Mo(r) : null;
|
|
5577
5590
|
},
|
|
5578
5591
|
async update(t, n, r) {
|
|
5579
5592
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5587,18 +5600,18 @@ function jo(e) {
|
|
|
5587
5600
|
}
|
|
5588
5601
|
};
|
|
5589
5602
|
}
|
|
5590
|
-
function
|
|
5603
|
+
function Po(e) {
|
|
5591
5604
|
return {
|
|
5592
5605
|
token_id: e.token_id,
|
|
5593
5606
|
connection_id: e.connection_id,
|
|
5594
5607
|
token_hash: e.token_hash,
|
|
5595
|
-
scopes:
|
|
5608
|
+
scopes: jo(e.scopes),
|
|
5596
5609
|
valid_until: e.valid_until ?? void 0,
|
|
5597
5610
|
created_at: e.created_at,
|
|
5598
5611
|
last_used_at: e.last_used_at ?? void 0
|
|
5599
5612
|
};
|
|
5600
5613
|
}
|
|
5601
|
-
function
|
|
5614
|
+
function Fo(e) {
|
|
5602
5615
|
return {
|
|
5603
5616
|
async create(t, n) {
|
|
5604
5617
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5622,14 +5635,14 @@ function No(e) {
|
|
|
5622
5635
|
},
|
|
5623
5636
|
async get(t, n) {
|
|
5624
5637
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5625
|
-
return r ?
|
|
5638
|
+
return r ? Po(r) : null;
|
|
5626
5639
|
},
|
|
5627
5640
|
async getByHash(t, n) {
|
|
5628
5641
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5629
|
-
return r ?
|
|
5642
|
+
return r ? Po(r) : null;
|
|
5630
5643
|
},
|
|
5631
5644
|
async listByConnection(t, n) {
|
|
5632
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5645
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Po);
|
|
5633
5646
|
},
|
|
5634
5647
|
async markUsed(t, n, r) {
|
|
5635
5648
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5641,7 +5654,7 @@ function No(e) {
|
|
|
5641
5654
|
}
|
|
5642
5655
|
};
|
|
5643
5656
|
}
|
|
5644
|
-
function
|
|
5657
|
+
function Io(e) {
|
|
5645
5658
|
return {
|
|
5646
5659
|
connection_id: e.connection_id,
|
|
5647
5660
|
external_id: e.external_id,
|
|
@@ -5649,7 +5662,7 @@ function Po(e) {
|
|
|
5649
5662
|
created_at: e.created_at
|
|
5650
5663
|
};
|
|
5651
5664
|
}
|
|
5652
|
-
function
|
|
5665
|
+
function Lo(e) {
|
|
5653
5666
|
return {
|
|
5654
5667
|
async create(t, n) {
|
|
5655
5668
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5668,11 +5681,11 @@ function Fo(e) {
|
|
|
5668
5681
|
},
|
|
5669
5682
|
async getByExternalId(t, n, r) {
|
|
5670
5683
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5671
|
-
return i ?
|
|
5684
|
+
return i ? Io(i) : null;
|
|
5672
5685
|
},
|
|
5673
5686
|
async getByUserId(t, n, r) {
|
|
5674
5687
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5675
|
-
return i ?
|
|
5688
|
+
return i ? Io(i) : null;
|
|
5676
5689
|
},
|
|
5677
5690
|
async remove(t, n, r) {
|
|
5678
5691
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5682,7 +5695,7 @@ function Fo(e) {
|
|
|
5682
5695
|
}
|
|
5683
5696
|
//#endregion
|
|
5684
5697
|
//#region src/tenantOperations/index.ts
|
|
5685
|
-
function
|
|
5698
|
+
function Ro(e) {
|
|
5686
5699
|
if (!e) return null;
|
|
5687
5700
|
try {
|
|
5688
5701
|
let t = JSON.parse(e);
|
|
@@ -5690,7 +5703,7 @@ function Io(e) {
|
|
|
5690
5703
|
} catch {}
|
|
5691
5704
|
return null;
|
|
5692
5705
|
}
|
|
5693
|
-
function
|
|
5706
|
+
function G(e) {
|
|
5694
5707
|
return we.parse({
|
|
5695
5708
|
id: e.id,
|
|
5696
5709
|
tenant_id: e.tenant_id,
|
|
@@ -5704,8 +5717,8 @@ function K(e) {
|
|
|
5704
5717
|
target_database_version: e.target_database_version,
|
|
5705
5718
|
error: e.error,
|
|
5706
5719
|
initiated_by: e.initiated_by,
|
|
5707
|
-
input:
|
|
5708
|
-
result:
|
|
5720
|
+
input: Ro(e.input),
|
|
5721
|
+
result: Ro(e.result),
|
|
5709
5722
|
claimed_by: e.claimed_by,
|
|
5710
5723
|
claim_expires_at: e.claim_expires_at,
|
|
5711
5724
|
created_at: e.created_at,
|
|
@@ -5713,7 +5726,7 @@ function K(e) {
|
|
|
5713
5726
|
finished_at: e.finished_at
|
|
5714
5727
|
});
|
|
5715
5728
|
}
|
|
5716
|
-
function
|
|
5729
|
+
function zo(e) {
|
|
5717
5730
|
return {
|
|
5718
5731
|
async create(n) {
|
|
5719
5732
|
let r = xe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5737,11 +5750,11 @@ function Lo(e) {
|
|
|
5737
5750
|
updated_at: i,
|
|
5738
5751
|
finished_at: null
|
|
5739
5752
|
};
|
|
5740
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5753
|
+
return await e.insertInto("tenant_operations").values(a).execute(), G(a);
|
|
5741
5754
|
},
|
|
5742
5755
|
async get(t) {
|
|
5743
5756
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5744
|
-
return n ?
|
|
5757
|
+
return n ? G(n) : null;
|
|
5745
5758
|
},
|
|
5746
5759
|
async list(t = {}) {
|
|
5747
5760
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5752,7 +5765,7 @@ function Lo(e) {
|
|
|
5752
5765
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5753
5766
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5754
5767
|
return {
|
|
5755
|
-
operations: a.map(
|
|
5768
|
+
operations: a.map(G),
|
|
5756
5769
|
start: n * r,
|
|
5757
5770
|
limit: r,
|
|
5758
5771
|
length: a.length
|
|
@@ -5786,7 +5799,7 @@ function Lo(e) {
|
|
|
5786
5799
|
},
|
|
5787
5800
|
async listResumable(t) {
|
|
5788
5801
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
5789
|
-
return (await e.selectFrom("tenant_operations").where("kind", "=", t.kind).where("status", "in", ["pending", "running"]).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").limit(t.limit).execute()).map(
|
|
5802
|
+
return (await e.selectFrom("tenant_operations").where("kind", "=", t.kind).where("status", "in", ["pending", "running"]).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").limit(t.limit).execute()).map(G);
|
|
5790
5803
|
},
|
|
5791
5804
|
async remove(t) {
|
|
5792
5805
|
let n = await e.deleteFrom("tenant_operations").where("id", "=", t).executeTakeFirst();
|
|
@@ -5796,27 +5809,27 @@ function Lo(e) {
|
|
|
5796
5809
|
}
|
|
5797
5810
|
//#endregion
|
|
5798
5811
|
//#region src/utils/monotonic-id.ts
|
|
5799
|
-
var
|
|
5800
|
-
function
|
|
5812
|
+
var Bo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Vo = 32, Ho = 10, Uo = 4, Wo = 10;
|
|
5813
|
+
function Go(e, t) {
|
|
5801
5814
|
let n = "";
|
|
5802
|
-
for (let r = t; r > 0; r--) n =
|
|
5815
|
+
for (let r = t; r > 0; r--) n = Bo.charAt(e % Vo) + n, e = Math.floor(e / Vo);
|
|
5803
5816
|
return n;
|
|
5804
5817
|
}
|
|
5805
|
-
function
|
|
5806
|
-
let e = new Uint8Array(
|
|
5818
|
+
function Ko() {
|
|
5819
|
+
let e = new Uint8Array(Wo);
|
|
5807
5820
|
crypto.getRandomValues(e);
|
|
5808
5821
|
let t = "";
|
|
5809
|
-
for (let n = 0; n <
|
|
5822
|
+
for (let n = 0; n < Wo; n++) t += Bo.charAt(e[n] % Vo);
|
|
5810
5823
|
return t;
|
|
5811
5824
|
}
|
|
5812
|
-
var
|
|
5813
|
-
function
|
|
5825
|
+
var qo = 0, Jo = 0;
|
|
5826
|
+
function Yo() {
|
|
5814
5827
|
let e = Date.now();
|
|
5815
|
-
return e ===
|
|
5828
|
+
return e === qo ? Jo++ : (qo = e, Jo = 0), Go(e, Ho) + Go(Jo, Uo) + Ko();
|
|
5816
5829
|
}
|
|
5817
5830
|
//#endregion
|
|
5818
5831
|
//#region src/tenantOperationEvents/index.ts
|
|
5819
|
-
function
|
|
5832
|
+
function Xo(e) {
|
|
5820
5833
|
if (!e) return null;
|
|
5821
5834
|
try {
|
|
5822
5835
|
let t = JSON.parse(e);
|
|
@@ -5824,22 +5837,22 @@ function Jo(e) {
|
|
|
5824
5837
|
} catch {}
|
|
5825
5838
|
return null;
|
|
5826
5839
|
}
|
|
5827
|
-
function
|
|
5840
|
+
function Zo(e) {
|
|
5828
5841
|
return be.parse({
|
|
5829
5842
|
id: e.id,
|
|
5830
5843
|
operation_id: e.operation_id,
|
|
5831
5844
|
step: e.step,
|
|
5832
5845
|
outcome: e.outcome,
|
|
5833
|
-
detail:
|
|
5846
|
+
detail: Xo(e.detail),
|
|
5834
5847
|
attempt: e.attempt,
|
|
5835
5848
|
created_at: e.created_at
|
|
5836
5849
|
});
|
|
5837
5850
|
}
|
|
5838
|
-
function
|
|
5851
|
+
function Qo(e) {
|
|
5839
5852
|
return {
|
|
5840
5853
|
async create(t) {
|
|
5841
5854
|
let n = ye.parse(t), r = {
|
|
5842
|
-
id: `evt_${
|
|
5855
|
+
id: `evt_${Yo()}`,
|
|
5843
5856
|
operation_id: n.operation_id,
|
|
5844
5857
|
step: n.step,
|
|
5845
5858
|
outcome: n.outcome,
|
|
@@ -5847,12 +5860,12 @@ function Xo(e) {
|
|
|
5847
5860
|
attempt: n.attempt,
|
|
5848
5861
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5849
5862
|
};
|
|
5850
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5863
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Zo(r);
|
|
5851
5864
|
},
|
|
5852
5865
|
async listByOperation(t, n = {}) {
|
|
5853
5866
|
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();
|
|
5854
5867
|
return {
|
|
5855
|
-
events: a.map(
|
|
5868
|
+
events: a.map(Zo),
|
|
5856
5869
|
start: r * i,
|
|
5857
5870
|
limit: i,
|
|
5858
5871
|
length: a.length
|
|
@@ -5862,16 +5875,16 @@ function Xo(e) {
|
|
|
5862
5875
|
}
|
|
5863
5876
|
//#endregion
|
|
5864
5877
|
//#region src/tenantOperationRows/index.ts
|
|
5865
|
-
var
|
|
5866
|
-
function
|
|
5878
|
+
var $o = 50;
|
|
5879
|
+
function es(e) {
|
|
5867
5880
|
let t = JSON.parse(e);
|
|
5868
5881
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5869
5882
|
}
|
|
5870
|
-
function
|
|
5883
|
+
function ts(e) {
|
|
5871
5884
|
return Ce.parse({
|
|
5872
5885
|
operation_id: e.operation_id,
|
|
5873
5886
|
seq: e.seq,
|
|
5874
|
-
payload:
|
|
5887
|
+
payload: es(e.payload),
|
|
5875
5888
|
status: e.status,
|
|
5876
5889
|
error_code: e.error_code,
|
|
5877
5890
|
error_message: e.error_message,
|
|
@@ -5881,7 +5894,7 @@ function $o(e) {
|
|
|
5881
5894
|
updated_at: e.updated_at
|
|
5882
5895
|
});
|
|
5883
5896
|
}
|
|
5884
|
-
function
|
|
5897
|
+
function ns(e) {
|
|
5885
5898
|
return {
|
|
5886
5899
|
async createMany(t) {
|
|
5887
5900
|
if (t.length === 0) return 0;
|
|
@@ -5900,11 +5913,11 @@ function es(e) {
|
|
|
5900
5913
|
updated_at: n
|
|
5901
5914
|
};
|
|
5902
5915
|
});
|
|
5903
|
-
for (let t = 0; t < r.length; t +=
|
|
5916
|
+
for (let t = 0; t < r.length; t += $o) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + $o)).execute();
|
|
5904
5917
|
return r.length;
|
|
5905
5918
|
},
|
|
5906
5919
|
async claimPending(t, n) {
|
|
5907
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5920
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(ts);
|
|
5908
5921
|
},
|
|
5909
5922
|
async recordOutcomes(t, n) {
|
|
5910
5923
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5953,7 +5966,7 @@ function es(e) {
|
|
|
5953
5966
|
}
|
|
5954
5967
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5955
5968
|
return {
|
|
5956
|
-
rows: o.map(
|
|
5969
|
+
rows: o.map(ts),
|
|
5957
5970
|
start: r * i,
|
|
5958
5971
|
limit: i,
|
|
5959
5972
|
length: o.length
|
|
@@ -5967,7 +5980,7 @@ function es(e) {
|
|
|
5967
5980
|
}
|
|
5968
5981
|
//#endregion
|
|
5969
5982
|
//#region src/rollouts/index.ts
|
|
5970
|
-
function
|
|
5983
|
+
function rs(e) {
|
|
5971
5984
|
if (!e) return null;
|
|
5972
5985
|
try {
|
|
5973
5986
|
return JSON.parse(e);
|
|
@@ -5975,7 +5988,7 @@ function ts(e) {
|
|
|
5975
5988
|
return null;
|
|
5976
5989
|
}
|
|
5977
5990
|
}
|
|
5978
|
-
function
|
|
5991
|
+
function is(e) {
|
|
5979
5992
|
return he.parse({
|
|
5980
5993
|
id: e.id,
|
|
5981
5994
|
kind: e.kind,
|
|
@@ -5983,15 +5996,15 @@ function ns(e) {
|
|
|
5983
5996
|
target_worker_version: e.target_worker_version,
|
|
5984
5997
|
target_database_version: e.target_database_version,
|
|
5985
5998
|
wave_size: e.wave_size,
|
|
5986
|
-
canary_tenant_ids:
|
|
5987
|
-
filter:
|
|
5999
|
+
canary_tenant_ids: rs(e.canary_tenant_ids),
|
|
6000
|
+
filter: rs(e.filter),
|
|
5988
6001
|
initiated_by: e.initiated_by,
|
|
5989
6002
|
created_at: e.created_at,
|
|
5990
6003
|
updated_at: e.updated_at,
|
|
5991
6004
|
finished_at: e.finished_at
|
|
5992
6005
|
});
|
|
5993
6006
|
}
|
|
5994
|
-
function
|
|
6007
|
+
function as(e) {
|
|
5995
6008
|
return {
|
|
5996
6009
|
async create(n) {
|
|
5997
6010
|
let r = me.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -6008,16 +6021,16 @@ function rs(e) {
|
|
|
6008
6021
|
updated_at: i,
|
|
6009
6022
|
finished_at: null
|
|
6010
6023
|
};
|
|
6011
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
6024
|
+
return await e.insertInto("rollouts").values(a).execute(), is(a);
|
|
6012
6025
|
},
|
|
6013
6026
|
async get(t) {
|
|
6014
6027
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
6015
|
-
return n ?
|
|
6028
|
+
return n ? is(n) : null;
|
|
6016
6029
|
},
|
|
6017
6030
|
async list(t = {}) {
|
|
6018
6031
|
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();
|
|
6019
6032
|
return {
|
|
6020
|
-
rollouts: i.map(
|
|
6033
|
+
rollouts: i.map(is),
|
|
6021
6034
|
start: n * r,
|
|
6022
6035
|
limit: r,
|
|
6023
6036
|
length: i.length
|
|
@@ -6037,7 +6050,7 @@ function rs(e) {
|
|
|
6037
6050
|
}
|
|
6038
6051
|
//#endregion
|
|
6039
6052
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
6040
|
-
var
|
|
6053
|
+
var os = class {
|
|
6041
6054
|
migrations;
|
|
6042
6055
|
constructor(e) {
|
|
6043
6056
|
this.migrations = e;
|
|
@@ -6045,10 +6058,10 @@ var is = class {
|
|
|
6045
6058
|
async getMigrations() {
|
|
6046
6059
|
return this.migrations;
|
|
6047
6060
|
}
|
|
6048
|
-
},
|
|
6049
|
-
down: () =>
|
|
6050
|
-
up: () =>
|
|
6051
|
-
}),
|
|
6061
|
+
}, ss = /* @__PURE__ */ w({
|
|
6062
|
+
down: () => ds,
|
|
6063
|
+
up: () => us
|
|
6064
|
+
}), cs = [
|
|
6052
6065
|
{
|
|
6053
6066
|
table: "authentication_methods",
|
|
6054
6067
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6314,47 +6327,47 @@ var is = class {
|
|
|
6314
6327
|
onDelete: "cascade"
|
|
6315
6328
|
}
|
|
6316
6329
|
];
|
|
6317
|
-
async function
|
|
6330
|
+
async function ls(e) {
|
|
6318
6331
|
try {
|
|
6319
6332
|
return await p`select sqlite_version()`.execute(e), !0;
|
|
6320
6333
|
} catch {
|
|
6321
6334
|
return !1;
|
|
6322
6335
|
}
|
|
6323
6336
|
}
|
|
6324
|
-
function
|
|
6337
|
+
function K(e, t) {
|
|
6325
6338
|
let n = e;
|
|
6326
|
-
for (let e of
|
|
6339
|
+
for (let e of cs) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6327
6340
|
let n = t;
|
|
6328
6341
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6329
6342
|
}));
|
|
6330
6343
|
return n;
|
|
6331
6344
|
}
|
|
6332
|
-
async function
|
|
6333
|
-
let t = await
|
|
6345
|
+
async function us(e) {
|
|
6346
|
+
let t = await ls(e);
|
|
6334
6347
|
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();
|
|
6335
6348
|
{
|
|
6336
6349
|
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"]);
|
|
6337
|
-
t && (n =
|
|
6350
|
+
t && (n = K(n, "authentication_methods")), await n.execute();
|
|
6338
6351
|
}
|
|
6339
6352
|
{
|
|
6340
6353
|
let n = e.schema.createTable("branding").addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("logo_url", p`varchar(512)`).addColumn("favicon_url", p`varchar(512)`).addColumn("font_url", p`varchar(512)`).addColumn("colors_primary", p`varchar(8)`).addColumn("colors_page_background_type", p`varchar(32)`).addColumn("colors_page_background_start", p`varchar(8)`).addColumn("colors_page_background_end", p`varchar(8)`).addColumn("colors_page_background_angle_dev", p`int`).addColumn("dark_mode", p`varchar(8)`).addPrimaryKeyConstraint("branding_pk", ["tenant_id"]);
|
|
6341
|
-
t && (n =
|
|
6354
|
+
t && (n = K(n, "branding")), await n.execute();
|
|
6342
6355
|
}
|
|
6343
6356
|
{
|
|
6344
6357
|
let n = e.schema.createTable("clients").addColumn("client_id", p`varchar(191)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("description", p`varchar(140)`).addColumn("global", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("client_secret", p`varchar(255)`).addColumn("app_type", p`varchar(64)`, (e) => e.defaultTo("regular_web")).addColumn("logo_uri", p`varchar(2083)`).addColumn("is_first_party", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("oidc_conformant", p`int`, (e) => e.notNull().defaultTo(1)).addColumn("callbacks", p`text`, (e) => e.notNull()).addColumn("allowed_origins", p`text`, (e) => e.notNull()).addColumn("web_origins", p`text`, (e) => e.notNull()).addColumn("client_aliases", p`text`, (e) => e.notNull()).addColumn("allowed_clients", p`text`, (e) => e.notNull()).addColumn("allowed_logout_urls", p`text`, (e) => e.notNull()).addColumn("session_transfer", p`text`, (e) => e.notNull()).addColumn("oidc_logout", p`text`, (e) => e.notNull()).addColumn("grant_types", p`text`, (e) => e.notNull()).addColumn("jwt_configuration", p`text`, (e) => e.notNull()).addColumn("signing_keys", p`text`, (e) => e.notNull()).addColumn("encryption_key", p`text`, (e) => e.notNull()).addColumn("sso", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("sso_disabled", p`int`, (e) => e.notNull().defaultTo(1)).addColumn("cross_origin_authentication", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("cross_origin_loc", p`varchar(2083)`).addColumn("custom_login_page_on", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("custom_login_page", p`text`).addColumn("custom_login_page_preview", p`text`).addColumn("form_template", p`text`).addColumn("addons", p`text`, (e) => e.notNull()).addColumn("token_endpoint_auth_method", p`varchar(64)`, (e) => e.defaultTo("client_secret_basic")).addColumn("client_metadata", p`text`, (e) => e.notNull()).addColumn("mobile", p`text`, (e) => e.notNull()).addColumn("initiate_login_uri", p`varchar(2083)`).addColumn("native_social_login", p`text`, (e) => e.notNull()).addColumn("refresh_token", p`text`, (e) => e.notNull()).addColumn("default_organization", p`text`, (e) => e.notNull()).addColumn("organization_usage", p`varchar(32)`, (e) => e.defaultTo("deny")).addColumn("organization_require_behavior", p`varchar(32)`, (e) => e.defaultTo("no_prompt")).addColumn("client_authentication_methods", p`text`, (e) => e.notNull()).addColumn("require_pushed_authorization_requests", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("require_proof_of_possession", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("signed_request_object", p`text`, (e) => e.notNull()).addColumn("compliance_level", p`varchar(64)`).addColumn("par_request_expiry", p`int`).addColumn("token_quota", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("connections", p`text`).addColumn("auth0_conformant", p`int`, (e) => e.defaultTo(1)).addColumn("owner_user_id", p`varchar(255)`).addColumn("registration_type", p`varchar(32)`).addColumn("registration_metadata", p`text`).addColumn("user_linking_mode", p`varchar(16)`).addColumn("hide_sign_up_disabled_error", p`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("clients_pk", ["tenant_id", "client_id"]);
|
|
6345
|
-
t && (n =
|
|
6358
|
+
t && (n = K(n, "clients")), await n.execute();
|
|
6346
6359
|
}
|
|
6347
6360
|
{
|
|
6348
6361
|
let n = e.schema.createTable("client_grants").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("client_id", p`varchar(191)`, (e) => e.notNull()).addColumn("audience", p`varchar(191)`, (e) => e.notNull()).addColumn("scope", p`text`).addColumn("organization_usage", p`varchar(32)`).addColumn("allow_any_organization", p`int`, (e) => e.defaultTo(0)).addColumn("is_system", p`int`, (e) => e.defaultTo(0)).addColumn("subject_type", p`varchar(32)`).addColumn("authorization_details_types", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("client_grants_pk", ["tenant_id", "id"]);
|
|
6349
|
-
t && (n =
|
|
6362
|
+
t && (n = K(n, "client_grants")), await n.execute();
|
|
6350
6363
|
}
|
|
6351
6364
|
{
|
|
6352
6365
|
let n = e.schema.createTable("client_registration_tokens").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("token_hash", p`varchar(64)`, (e) => e.notNull()).addColumn("type", p`varchar(8)`, (e) => e.notNull()).addColumn("client_id", p`varchar(191)`).addColumn("sub", p`varchar(255)`).addColumn("constraints", p`text`).addColumn("single_use", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("used_at_ts", p`bigint`).addColumn("expires_at_ts", p`bigint`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("revoked_at_ts", p`bigint`).addPrimaryKeyConstraint("client_registration_tokens_pk", ["id"]);
|
|
6353
|
-
t && (n =
|
|
6366
|
+
t && (n = K(n, "client_registration_tokens")), await n.execute();
|
|
6354
6367
|
}
|
|
6355
6368
|
{
|
|
6356
6369
|
let n = e.schema.createTable("users").addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("email", p`varchar(255)`).addColumn("given_name", p`varchar(255)`).addColumn("family_name", p`varchar(255)`).addColumn("nickname", p`varchar(255)`).addColumn("name", p`varchar(255)`).addColumn("picture", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("linked_to", p`varchar(255)`).addColumn("provider", p`varchar(255)`, (e) => e.notNull()).addColumn("connection", p`varchar(255)`, (e) => e.notNull()).addColumn("email_verified", p`tinyint(1)`, (e) => e.notNull()).addColumn("is_social", p`tinyint(1)`, (e) => e.notNull()).addColumn("app_metadata", p`text`, (e) => e.notNull().defaultTo(p`('{}')`)).addColumn("profileData", p`text`).addColumn("locale", p`varchar(64)`).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("phone_number", p`varchar(17)`).addColumn("phone_verified", p`tinyint(1)`).addColumn("username", p`varchar(128)`).addColumn("user_metadata", p`text`).addColumn("middle_name", p`varchar(100)`).addColumn("profile", p`text`).addColumn("website", p`text`).addColumn("gender", p`varchar(50)`).addColumn("birthdate", p`varchar(10)`).addColumn("zoneinfo", p`varchar(100)`).addColumn("preferred_username", p`varchar(255)`).addColumn("address", p`text`).addColumn("registration_completed_at", p`varchar(35)`).addPrimaryKeyConstraint("users_pk", ["tenant_id", "user_id"]);
|
|
6357
|
-
t && (n =
|
|
6370
|
+
t && (n = K(n, "users")), await n.execute();
|
|
6358
6371
|
}
|
|
6359
6372
|
{
|
|
6360
6373
|
let n = e.schema.createTable("codes").addColumn("code_id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`).addColumn("login_id", p`varchar(255)`).addColumn("connection_id", p`varchar(255)`).addColumn("code_type", p`varchar(255)`, (e) => e.notNull()).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("expires_at", p`varchar(255)`, (e) => e.notNull()).addColumn("used_at", p`varchar(255)`).addColumn("code_verifier", p`varchar(128)`).addColumn("code_challenge", p`varchar(128)`).addColumn("code_challenge_method", p`varchar(5)`).addColumn("redirect_uri", p`varchar(1024)`).addColumn("nonce", p`varchar(1024)`).addColumn("state", p`varchar(2048)`).addColumn("otp", p`varchar(32)`).addPrimaryKeyConstraint("codes_pk", [
|
|
@@ -6362,16 +6375,16 @@ async function cs(e) {
|
|
|
6362
6375
|
"code_type",
|
|
6363
6376
|
"tenant_id"
|
|
6364
6377
|
]);
|
|
6365
|
-
t && (n =
|
|
6378
|
+
t && (n = K(n, "codes")), await n.execute();
|
|
6366
6379
|
}
|
|
6367
6380
|
{
|
|
6368
6381
|
let n = e.schema.createTable("connections").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("response_type", p`varchar(255)`).addColumn("response_mode", p`varchar(255)`).addColumn("strategy", p`varchar(64)`).addColumn("options", p`varchar(8192)`, (e) => e.notNull().defaultTo("{}")).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(255)`, (e) => e.notNull()).addColumn("display_name", p`varchar(255)`).addColumn("is_domain_connection", p`int`).addColumn("show_as_button", p`int`).addColumn("metadata", p`varchar(4096)`).addColumn("is_system", p`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("connections_pk", ["tenant_id", "id"]);
|
|
6369
|
-
t && (n =
|
|
6382
|
+
t && (n = K(n, "connections")), await n.execute();
|
|
6370
6383
|
}
|
|
6371
6384
|
await e.schema.createTable("control_plane_comm_keys").addColumn("kid", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("public_jwk", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("revoked_at", p`varchar(35)`).addPrimaryKeyConstraint("control_plane_comm_keys_pk", ["kid"]).execute();
|
|
6372
6385
|
{
|
|
6373
6386
|
let n = e.schema.createTable("custom_domains").addColumn("custom_domain_id", p`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("domain", p`varchar(255)`, (e) => e.notNull()).addColumn("primary", p`tinyint(1)`, (e) => e.notNull()).addColumn("status", p`varchar(50)`, (e) => e.notNull()).addColumn("type", p`varchar(50)`, (e) => e.notNull()).addColumn("origin_domain_name", p`varchar(255)`).addColumn("verification", p`varchar(2048)`).addColumn("custom_client_ip_header", p`varchar(50)`).addColumn("tls_policy", p`varchar(50)`).addColumn("domain_metadata", p`varchar(2048)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("custom_domains_pk", ["custom_domain_id"]);
|
|
6374
|
-
t && (n =
|
|
6387
|
+
t && (n = K(n, "custom_domains")), await n.execute();
|
|
6375
6388
|
}
|
|
6376
6389
|
{
|
|
6377
6390
|
let n = e.schema.createTable("custom_text").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("prompt", p`varchar(64)`, (e) => e.notNull()).addColumn("language", p`varchar(16)`, (e) => e.notNull()).addColumn("custom_text", p`text`, (e) => e.notNull()).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("custom_text_pk", [
|
|
@@ -6379,56 +6392,56 @@ async function cs(e) {
|
|
|
6379
6392
|
"prompt",
|
|
6380
6393
|
"language"
|
|
6381
6394
|
]);
|
|
6382
|
-
t && (n =
|
|
6395
|
+
t && (n = K(n, "custom_text")), await n.execute();
|
|
6383
6396
|
}
|
|
6384
6397
|
await e.schema.createTable("email_providers").addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("enabled", p`tinyint(1)`, (e) => e.notNull()).addColumn("default_from_address", p`varchar(255)`).addColumn("credentials", p`varchar(2048)`, (e) => e.notNull().defaultTo("{}")).addColumn("settings", p`varchar(2048)`, (e) => e.notNull().defaultTo("{}")).addColumn("created_at", p`varchar(29)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(29)`, (e) => e.notNull()).addPrimaryKeyConstraint("email_providers_pk", ["tenant_id"]).execute();
|
|
6385
6398
|
{
|
|
6386
6399
|
let n = e.schema.createTable("email_templates").addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("template", p`varchar(64)`, (e) => e.notNull()).addColumn("body", p`text`, (e) => e.notNull()).addColumn("from", p`varchar(255)`, (e) => e.notNull()).addColumn("subject", p`varchar(255)`, (e) => e.notNull()).addColumn("syntax", p`varchar(16)`, (e) => e.notNull().defaultTo("liquid")).addColumn("result_url", p`varchar(2048)`).addColumn("url_lifetime_in_seconds", p`int`).addColumn("include_email_in_redirect", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("enabled", p`int`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("email_templates_pk", ["tenant_id", "template"]);
|
|
6387
|
-
t && (n =
|
|
6400
|
+
t && (n = K(n, "email_templates")), await n.execute();
|
|
6388
6401
|
}
|
|
6389
6402
|
await e.schema.createTable("flows").addColumn("id", p`varchar(24)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(150)`, (e) => e.notNull()).addColumn("actions", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("flows_pk", ["id"]).execute(), await e.schema.createTable("forms").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("messages", p`varchar(255)`).addColumn("languages", p`varchar(255)`).addColumn("translations", p`varchar(4096)`).addColumn("nodes", p`varchar(4096)`).addColumn("start", p`varchar(255)`).addColumn("ending", p`varchar(255)`).addColumn("style", p`varchar(1042)`).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(255)`, (e) => e.notNull()).addPrimaryKeyConstraint("forms_pk", ["id"]).execute();
|
|
6390
6403
|
{
|
|
6391
6404
|
let n = e.schema.createTable("grants").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(191)`, (e) => e.notNull()).addColumn("client_id", p`varchar(191)`, (e) => e.notNull()).addColumn("audience", p`varchar(100)`, (e) => e.notNull().defaultTo("")).addColumn("scope", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("grants_pk", ["id"]);
|
|
6392
|
-
t && (n =
|
|
6405
|
+
t && (n = K(n, "grants")), await n.execute();
|
|
6393
6406
|
}
|
|
6394
6407
|
await e.schema.createTable("hook_code").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("code", p`text`, (e) => e.notNull()).addColumn("secrets", p`text`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("hook_code_pk", ["id"]).execute();
|
|
6395
6408
|
{
|
|
6396
6409
|
let n = e.schema.createTable("hooks").addColumn("hook_id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("trigger_id", p`varchar(255)`, (e) => e.notNull()).addColumn("enabled", p`tinyint(1)`, (e) => e.notNull()).addColumn("synchronous", p`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("priority", p`int`).addColumn("form_id", p`varchar(128)`).addColumn("url", p`varchar(512)`).addColumn("template_id", p`varchar(64)`).addColumn("created_at_ts", p`bigint`).addColumn("updated_at_ts", p`bigint`).addColumn("code_id", p`varchar(21)`).addColumn("metadata", p`text`).addPrimaryKeyConstraint("hooks_pk", ["hook_id"]);
|
|
6397
|
-
t && (n =
|
|
6410
|
+
t && (n = K(n, "hooks")), await n.execute();
|
|
6398
6411
|
}
|
|
6399
6412
|
await e.schema.createTable("invites").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", p`varchar(21)`, (e) => e.notNull()).addColumn("inviter", p`text`, (e) => e.notNull()).addColumn("invitee", p`text`, (e) => e.notNull()).addColumn("client_id", p`varchar(191)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(21)`).addColumn("invitation_url", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("expires_at", p`varchar(35)`, (e) => e.notNull()).addColumn("app_metadata", p`text`).addColumn("user_metadata", p`text`).addColumn("roles", p`text`).addColumn("ticket_id", p`varchar(191)`).addColumn("ttl_sec", p`int`).addColumn("send_invitation_email", p`int`).addPrimaryKeyConstraint("invites_pk", ["id"]).execute();
|
|
6400
6413
|
{
|
|
6401
6414
|
let n = e.schema.createTable("keys").addColumn("kid", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("revoked_at", p`varchar(255)`).addColumn("cert", p`varchar(4096)`).addColumn("pkcs7", p`varchar(4096)`).addColumn("fingerprint", p`varchar(256)`).addColumn("thumbprint", p`varchar(256)`).addColumn("current_since", p`varchar(256)`).addColumn("current_until", p`varchar(256)`).addColumn("type", p`varchar(50)`, (e) => e.notNull().defaultTo("jwt_signing")).addColumn("connection", p`varchar(255)`).addPrimaryKeyConstraint("keys_pk", ["kid"]);
|
|
6402
|
-
t && (n =
|
|
6415
|
+
t && (n = K(n, "keys")), await n.execute();
|
|
6403
6416
|
}
|
|
6404
6417
|
await e.schema.createTable("log_streams").addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("type", p`varchar(64)`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("sink", p`text`, (e) => e.notNull()).addColumn("filters", p`text`).addColumn("is_priority", p`tinyint(1)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("log_streams_pk", ["id"]).execute();
|
|
6405
6418
|
{
|
|
6406
6419
|
let n = e.schema.createTable("sessions").addColumn("id", p`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`).addColumn("device", p`text`, (e) => e.notNull()).addColumn("clients", p`text`, (e) => e.notNull()).addColumn("login_session_id", p`varchar(26)`).addColumn("created_at_ts", p`bigint`).addColumn("updated_at_ts", p`bigint`).addColumn("expires_at_ts", p`bigint`).addColumn("idle_expires_at_ts", p`bigint`).addColumn("authenticated_at_ts", p`bigint`).addColumn("last_interaction_at_ts", p`bigint`).addColumn("used_at_ts", p`bigint`).addColumn("revoked_at_ts", p`bigint`).addPrimaryKeyConstraint("sessions_pk", ["tenant_id", "id"]);
|
|
6407
|
-
t && (n =
|
|
6420
|
+
t && (n = K(n, "sessions")), await n.execute();
|
|
6408
6421
|
}
|
|
6409
6422
|
{
|
|
6410
6423
|
let n = e.schema.createTable("login_sessions").addColumn("id", p`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("session_id", p`varchar(26)`).addColumn("csrf_token", p`varchar(26)`).addColumn("authorization_url", p`text`).addColumn("ip", p`varchar(39)`).addColumn("useragent", p`text`).addColumn("auth0Client", p`varchar(255)`).addColumn("state", p`varchar(50)`, (e) => e.defaultTo("pending")).addColumn("state_data", p`text`).addColumn("failure_reason", p`text`).addColumn("user_id", p`varchar(255)`).addColumn("created_at_ts", p`bigint`).addColumn("updated_at_ts", p`bigint`).addColumn("expires_at_ts", p`bigint`).addColumn("auth_connection", p`varchar(255)`).addColumn("auth_strategy_strategy", p`varchar(64)`).addColumn("auth_strategy_strategy_type", p`varchar(64)`).addColumn("authenticated_at", p`varchar(35)`).addColumn("auth_params", p`text`).addPrimaryKeyConstraint("login_sessions_pk", ["tenant_id", "id"]);
|
|
6411
|
-
t && (n =
|
|
6424
|
+
t && (n = K(n, "login_sessions")), await n.execute();
|
|
6412
6425
|
}
|
|
6413
6426
|
await e.schema.createTable("logs").addColumn("log_id", p`varchar(21)`, (e) => e.notNull()).addColumn("category", p`varchar(255)`).addColumn("tenant_id", p`varchar(64)`).addColumn("user_id", p`varchar(64)`).addColumn("ip", p`varchar(255)`).addColumn("type", p`varchar(8)`, (e) => e.notNull()).addColumn("date", p`varchar(25)`, (e) => e.notNull()).addColumn("client_id", p`varchar(255)`).addColumn("client_name", p`varchar(255)`).addColumn("user_agent", p`varchar(255)`).addColumn("description", p`varchar(255)`).addColumn("details", p`varchar(2048)`).addColumn("isMobile", p`int`).addColumn("user_name", p`varchar(255)`).addColumn("connection", p`varchar(255)`).addColumn("connection_id", p`varchar(255)`).addColumn("audience", p`varchar(255)`).addColumn("scope", p`varchar(255)`).addColumn("strategy", p`varchar(255)`).addColumn("strategy_type", p`varchar(255)`).addColumn("hostname", p`varchar(255)`).addColumn("auth0_client", p`varchar(8192)`).addColumn("session_connection", p`varchar(255)`).addColumn("country_code", p`varchar(2)`).addColumn("country_code3", p`varchar(3)`).addColumn("country_name", p`varchar(255)`).addColumn("city_name", p`varchar(255)`).addColumn("latitude", p`varchar(255)`).addColumn("longitude", p`varchar(255)`).addColumn("time_zone", p`varchar(255)`).addColumn("continent_code", p`varchar(2)`).addPrimaryKeyConstraint("logs_pk", ["log_id"]).execute(), await e.schema.createTable("migration_sources").addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("provider", p`varchar(32)`, (e) => e.notNull()).addColumn("connection", p`varchar(255)`, (e) => e.notNull()).addColumn("enabled", p`tinyint(1)`, (e) => e.notNull()).addColumn("credentials", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("migration_sources_pk", ["id"]).execute();
|
|
6414
6427
|
{
|
|
6415
6428
|
let n = e.schema.createTable("migrations").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("provider", p`varchar(255)`).addColumn("client_id", p`varchar(255)`).addColumn("origin", p`varchar(255)`).addColumn("domain", p`varchar(255)`).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(255)`, (e) => e.notNull()).addPrimaryKeyConstraint("migrations_pk", ["id"]);
|
|
6416
|
-
t && (n =
|
|
6429
|
+
t && (n = K(n, "migrations")), await n.execute();
|
|
6417
6430
|
}
|
|
6418
6431
|
await e.schema.createTable("organizations").addColumn("id", p`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(256)`, (e) => e.notNull()).addColumn("name", p`varchar(256)`, (e) => e.notNull()).addColumn("display_name", p`varchar(256)`).addColumn("branding", p`text`).addColumn("metadata", p`text`).addColumn("enabled_connections", p`text`).addColumn("token_quota", p`text`).addColumn("created_at", p`varchar(256)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(256)`, (e) => e.notNull()).addPrimaryKeyConstraint("organizations_pk", ["id"]).execute();
|
|
6419
6432
|
{
|
|
6420
6433
|
let n = e.schema.createTable("organization_connections").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", p`varchar(21)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(191)`, (e) => e.notNull()).addColumn("assign_membership_on_login", p`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("show_as_button", p`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("is_signup_enabled", p`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull());
|
|
6421
|
-
t && (n =
|
|
6434
|
+
t && (n = K(n, "organization_connections")), await n.execute();
|
|
6422
6435
|
}
|
|
6423
6436
|
await e.schema.createTable("outbox_events").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("event_type", p`varchar(255)`, (e) => e.notNull()).addColumn("log_type", p`varchar(64)`, (e) => e.notNull()).addColumn("aggregate_type", p`varchar(64)`, (e) => e.notNull()).addColumn("aggregate_id", p`varchar(255)`, (e) => e.notNull()).addColumn("payload", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("processed_at", p`varchar(35)`).addColumn("retry_count", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("next_retry_at", p`varchar(35)`).addColumn("error", p`text`).addColumn("claimed_by", p`varchar(64)`).addColumn("claim_expires_at", p`varchar(35)`).addColumn("dead_lettered_at", p`varchar(35)`).addColumn("final_error", p`text`).addPrimaryKeyConstraint("outbox_events_pk", ["id"]).execute();
|
|
6424
6437
|
{
|
|
6425
6438
|
let n = e.schema.createTable("passwords").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("user_id", p`varchar(191)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("password", p`varchar(255)`, (e) => e.notNull()).addColumn("algorithm", p`varchar(255)`, (e) => e.notNull().defaultTo("bcrypt")).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("is_current", p`int`, (e) => e.notNull().defaultTo(1)).addPrimaryKeyConstraint("passwords_pk", ["id"]);
|
|
6426
|
-
t && (n =
|
|
6439
|
+
t && (n = K(n, "passwords")), await n.execute();
|
|
6427
6440
|
}
|
|
6428
6441
|
await e.schema.createTable("prompt_settings").addColumn("tenant_id", p`varchar(64)`, (e) => e.notNull()).addColumn("universal_login_experience", p`varchar(16)`, (e) => e.notNull().defaultTo("new")).addColumn("identifier_first", p`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("password_first", p`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("webauthn_platform_first_factor", p`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("prompt_settings_pk", ["tenant_id"]).execute(), await e.schema.createTable("proxy_routes").addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("custom_domain_id", p`varchar(256)`, (e) => e.notNull()).addColumn("priority", p`int`, (e) => e.notNull().defaultTo(100)).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("match", p`varchar(2048)`, (e) => e.notNull().defaultTo("{\"path\":\"/*\"}")).addColumn("handlers", p`text`, (e) => e.notNull()).addPrimaryKeyConstraint("proxy_routes_pk", ["id"]).execute();
|
|
6429
6442
|
{
|
|
6430
6443
|
let n = e.schema.createTable("refresh_tokens").addColumn("id", p`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("client_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`).addColumn("resource_servers", p`text`, (e) => e.notNull()).addColumn("device", p`text`, (e) => e.notNull()).addColumn("rotating", p`tinyint(1)`, (e) => e.notNull()).addColumn("created_at_ts", p`bigint`).addColumn("expires_at_ts", p`bigint`).addColumn("idle_expires_at_ts", p`bigint`).addColumn("last_exchanged_at_ts", p`bigint`).addColumn("login_id", p`varchar(26)`, (e) => e.notNull()).addColumn("revoked_at_ts", p`bigint`).addColumn("token_lookup", p`varchar(16)`).addColumn("token_hash", p`varchar(64)`).addColumn("family_id", p`varchar(26)`).addColumn("rotated_to", p`varchar(26)`).addColumn("rotated_at_ts", p`bigint`).addPrimaryKeyConstraint("refresh_tokens_pk", ["tenant_id", "id"]);
|
|
6431
|
-
t && (n =
|
|
6444
|
+
t && (n = K(n, "refresh_tokens")), await n.execute();
|
|
6432
6445
|
}
|
|
6433
6446
|
await e.schema.createTable("resource_servers").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("identifier", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("scopes", p`text`).addColumn("signing_alg", p`varchar(64)`).addColumn("signing_secret", p`varchar(2048)`).addColumn("token_lifetime", p`int`).addColumn("token_lifetime_for_web", p`int`).addColumn("skip_consent_for_verifiable_first_party_clients", p`int`).addColumn("allow_offline_access", p`int`).addColumn("verification_key", p`varchar(4096)`).addColumn("options", p`varchar(4096)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("is_system", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("metadata", p`varchar(4096)`).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await e.schema.createTable("role_permissions").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("role_id", p`varchar(21)`, (e) => e.notNull()).addColumn("resource_server_identifier", p`varchar(191)`, (e) => e.notNull()).addColumn("permission_name", p`varchar(191)`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("role_permissions_pk", [
|
|
6434
6447
|
"tenant_id",
|
|
@@ -6438,23 +6451,23 @@ async function cs(e) {
|
|
|
6438
6451
|
]).execute(), await e.schema.createTable("roles").addColumn("id", p`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(50)`, (e) => e.notNull()).addColumn("description", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("is_system", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("metadata", p`varchar(4096)`).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await e.schema.createTable("rollouts").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("kind", p`varchar(32)`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("target_worker_version", p`varchar(255)`).addColumn("target_database_version", p`varchar(255)`).addColumn("wave_size", p`int`, (e) => e.notNull().defaultTo(10)).addColumn("canary_tenant_ids", p`text`).addColumn("filter", p`text`).addColumn("initiated_by", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("finished_at", p`varchar(35)`).addPrimaryKeyConstraint("rollouts_pk", ["id"]).execute(), await e.schema.createTable("tenant_operations").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`).addColumn("rollout_id", p`varchar(255)`).addColumn("kind", p`varchar(32)`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("current_step", p`varchar(255)`).addColumn("engine", p`varchar(64)`, (e) => e.notNull()).addColumn("engine_instance_id", p`varchar(100)`).addColumn("target_worker_version", p`varchar(255)`).addColumn("target_database_version", p`varchar(255)`).addColumn("error", p`text`).addColumn("initiated_by", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addColumn("finished_at", p`varchar(35)`).addPrimaryKeyConstraint("tenant_operations_pk", ["id"]).execute();
|
|
6439
6452
|
{
|
|
6440
6453
|
let n = e.schema.createTable("tenant_operation_events").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("operation_id", p`varchar(255)`, (e) => e.notNull()).addColumn("step", p`varchar(255)`, (e) => e.notNull()).addColumn("outcome", p`varchar(32)`, (e) => e.notNull()).addColumn("detail", p`text`).addColumn("attempt", p`int`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_events_pk", ["id"]);
|
|
6441
|
-
t && (n =
|
|
6454
|
+
t && (n = K(n, "tenant_operation_events")), await n.execute();
|
|
6442
6455
|
}
|
|
6443
6456
|
{
|
|
6444
6457
|
let n = e.schema.createTable("themes").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("themeId", p`varchar(21)`, (e) => e.notNull()).addColumn("displayName", p`varchar(255)`, (e) => e.notNull()).addColumn("colors_primary_button_label", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_primary_button", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_secondary_button_border", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_secondary_button_label", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_base_focus_color", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_base_hover_color", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_body_text", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_captcha_widget_theme", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_error", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_header", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_icons", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_background", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_border", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_filled_text", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_labels_placeholders", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_links_focused_components", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_success", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_widget_background", p`varchar(24)`, (e) => e.notNull()).addColumn("colors_widget_border", p`varchar(24)`, (e) => e.notNull()).addColumn("borders_button_border_radius", p`int`, (e) => e.notNull()).addColumn("borders_button_border_weight", p`int`, (e) => e.notNull()).addColumn("borders_buttons_style", p`varchar(24)`, (e) => e.notNull()).addColumn("borders_input_border_radius", p`int`, (e) => e.notNull()).addColumn("borders_input_border_weight", p`int`, (e) => e.notNull()).addColumn("borders_inputs_style", p`varchar(24)`, (e) => e.notNull()).addColumn("borders_show_widget_shadow", p`tinyint(1)`, (e) => e.notNull()).addColumn("borders_widget_border_weight", p`int`, (e) => e.notNull()).addColumn("borders_widget_corner_radius", p`int`, (e) => e.notNull()).addColumn("fonts_body_text_bold", p`int`, (e) => e.notNull()).addColumn("fonts_body_text_size", p`int`, (e) => e.notNull()).addColumn("fonts_buttons_text_bold", p`int`, (e) => e.notNull()).addColumn("fonts_buttons_text_size", p`int`, (e) => e.notNull()).addColumn("fonts_font_url", p`varchar(255)`, (e) => e.notNull()).addColumn("fonts_input_labels_bold", p`int`, (e) => e.notNull()).addColumn("fonts_input_labels_size", p`int`, (e) => e.notNull()).addColumn("fonts_links_bold", p`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_links_size", p`int`, (e) => e.notNull()).addColumn("fonts_links_style", p`varchar(24)`, (e) => e.notNull()).addColumn("fonts_reference_text_size", p`int`, (e) => e.notNull()).addColumn("fonts_subtitle_bold", p`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_subtitle_size", p`int`, (e) => e.notNull()).addColumn("fonts_title_bold", p`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_title_size", p`int`, (e) => e.notNull()).addColumn("page_background_background_color", p`varchar(24)`, (e) => e.notNull()).addColumn("page_background_background_image_url", p`varchar(255)`, (e) => e.notNull()).addColumn("page_background_page_layout", p`varchar(24)`, (e) => e.notNull()).addColumn("widget_header_text_alignment", p`varchar(24)`, (e) => e.notNull()).addColumn("widget_logo_height", p`int`, (e) => e.notNull()).addColumn("widget_logo_position", p`varchar(24)`, (e) => e.notNull()).addColumn("widget_logo_url", p`varchar(255)`, (e) => e.notNull()).addColumn("widget_social_buttons_layout", p`varchar(24)`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("themes_pk", ["tenant_id", "themeId"]);
|
|
6445
|
-
t && (n =
|
|
6458
|
+
t && (n = K(n, "themes")), await n.execute();
|
|
6446
6459
|
}
|
|
6447
6460
|
{
|
|
6448
6461
|
let n = e.schema.createTable("universal_login_templates").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("body", p`text`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("universal_login_templates_pk", ["tenant_id"]);
|
|
6449
|
-
t && (n =
|
|
6462
|
+
t && (n = K(n, "universal_login_templates")), await n.execute();
|
|
6450
6463
|
}
|
|
6451
6464
|
{
|
|
6452
6465
|
let n = e.schema.createTable("user_activity").addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("last_login", p`varchar(35)`).addColumn("last_ip", p`varchar(45)`).addColumn("login_count", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("failed_logins", p`text`).addColumn("last_password_reset", p`varchar(35)`).addPrimaryKeyConstraint("user_activity_pk", ["tenant_id", "user_id"]);
|
|
6453
|
-
t && (n =
|
|
6466
|
+
t && (n = K(n, "user_activity")), await n.execute();
|
|
6454
6467
|
}
|
|
6455
6468
|
{
|
|
6456
6469
|
let n = e.schema.createTable("user_organizations").addColumn("id", p`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(256)`, (e) => e.notNull()).addColumn("user_id", p`varchar(256)`, (e) => e.notNull()).addColumn("organization_id", p`varchar(256)`, (e) => e.notNull()).addColumn("created_at", p`varchar(256)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(256)`, (e) => e.notNull()).addPrimaryKeyConstraint("user_organizations_pk", ["id"]);
|
|
6457
|
-
t && (n =
|
|
6470
|
+
t && (n = K(n, "user_organizations")), await n.execute();
|
|
6458
6471
|
}
|
|
6459
6472
|
if (await e.schema.createTable("user_permissions").addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(191)`, (e) => e.notNull()).addColumn("resource_server_identifier", p`varchar(100)`, (e) => e.notNull()).addColumn("permission_name", p`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", p`varchar(21)`, (e) => e.notNull().defaultTo("")).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("user_permissions_pk", [
|
|
6460
6473
|
"tenant_id",
|
|
@@ -6517,40 +6530,40 @@ async function cs(e) {
|
|
|
6517
6530
|
"tenant_id",
|
|
6518
6531
|
"phone_number",
|
|
6519
6532
|
"provider"
|
|
6520
|
-
]).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
|
|
6533
|
+
]).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 cs) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6521
6534
|
let n = e;
|
|
6522
6535
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6523
6536
|
}).execute();
|
|
6524
6537
|
}
|
|
6525
|
-
async function
|
|
6538
|
+
async function ds(e) {
|
|
6526
6539
|
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();
|
|
6527
6540
|
}
|
|
6528
6541
|
//#endregion
|
|
6529
6542
|
//#region migrate/log.ts
|
|
6530
|
-
var
|
|
6531
|
-
function
|
|
6532
|
-
|
|
6543
|
+
var fs = !1;
|
|
6544
|
+
function q(e) {
|
|
6545
|
+
fs = e;
|
|
6533
6546
|
}
|
|
6534
6547
|
function J(...e) {
|
|
6535
|
-
|
|
6548
|
+
fs && console.log(...e);
|
|
6536
6549
|
}
|
|
6537
6550
|
function Y(...e) {
|
|
6538
6551
|
console.warn(...e);
|
|
6539
6552
|
}
|
|
6540
6553
|
//#endregion
|
|
6541
6554
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6542
|
-
var
|
|
6543
|
-
down: () =>
|
|
6544
|
-
up: () =>
|
|
6545
|
-
}),
|
|
6546
|
-
async function
|
|
6555
|
+
var ps = /* @__PURE__ */ w({
|
|
6556
|
+
down: () => ws,
|
|
6557
|
+
up: () => xs
|
|
6558
|
+
}), ms = 5e4, hs = 500;
|
|
6559
|
+
async function gs(e) {
|
|
6547
6560
|
try {
|
|
6548
6561
|
return await p`SELECT VERSION()`.execute(e), "mysql";
|
|
6549
6562
|
} catch {
|
|
6550
6563
|
return "sqlite";
|
|
6551
6564
|
}
|
|
6552
6565
|
}
|
|
6553
|
-
async function
|
|
6566
|
+
async function _s(e, t, n) {
|
|
6554
6567
|
try {
|
|
6555
6568
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6556
6569
|
} catch (e) {
|
|
@@ -6561,7 +6574,7 @@ async function gs(e, t, n) {
|
|
|
6561
6574
|
throw e;
|
|
6562
6575
|
}
|
|
6563
6576
|
}
|
|
6564
|
-
async function
|
|
6577
|
+
async function vs(e, t, n, r) {
|
|
6565
6578
|
try {
|
|
6566
6579
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6567
6580
|
} catch (e) {
|
|
@@ -6572,21 +6585,21 @@ async function _s(e, t, n, r) {
|
|
|
6572
6585
|
throw e;
|
|
6573
6586
|
}
|
|
6574
6587
|
}
|
|
6575
|
-
async function
|
|
6588
|
+
async function ys(e, t) {
|
|
6576
6589
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6577
6590
|
if (t === "sqlite") {
|
|
6578
6591
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6579
6592
|
r = Number(t.numDeletedRows);
|
|
6580
6593
|
} else {
|
|
6581
|
-
let t =
|
|
6582
|
-
for (; t >=
|
|
6583
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6594
|
+
let t = ms;
|
|
6595
|
+
for (; t >= ms;) {
|
|
6596
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(ms).executeTakeFirst();
|
|
6584
6597
|
t = Number(i.numDeletedRows), r += t, t > 0 && J(` Pruned ${r} expired codes row(s)...`);
|
|
6585
6598
|
}
|
|
6586
6599
|
}
|
|
6587
6600
|
return r;
|
|
6588
6601
|
}
|
|
6589
|
-
async function
|
|
6602
|
+
async function bs(e) {
|
|
6590
6603
|
let t = 0;
|
|
6591
6604
|
for (;;) {
|
|
6592
6605
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6594,33 +6607,33 @@ async function ys(e) {
|
|
|
6594
6607
|
"code_type",
|
|
6595
6608
|
"tenant_id",
|
|
6596
6609
|
"expires_at"
|
|
6597
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6610
|
+
]).where("expires_at_ts", "is", null).limit(hs).execute();
|
|
6598
6611
|
if (n.length === 0) break;
|
|
6599
6612
|
for (let t of n) {
|
|
6600
6613
|
let n = Date.parse(t.expires_at);
|
|
6601
6614
|
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();
|
|
6602
6615
|
}
|
|
6603
|
-
if (t += n.length, n.length <
|
|
6616
|
+
if (t += n.length, n.length < hs) break;
|
|
6604
6617
|
}
|
|
6605
6618
|
return t;
|
|
6606
6619
|
}
|
|
6607
|
-
async function
|
|
6608
|
-
let t = await
|
|
6620
|
+
async function xs(e) {
|
|
6621
|
+
let t = await gs(e);
|
|
6609
6622
|
try {
|
|
6610
|
-
let n = await
|
|
6623
|
+
let n = await ys(e, t);
|
|
6611
6624
|
J(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6612
6625
|
} catch (e) {
|
|
6613
6626
|
Y(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6614
6627
|
}
|
|
6615
|
-
await
|
|
6628
|
+
await _s(e, "codes", "expires_at_ts"), await vs(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6616
6629
|
try {
|
|
6617
|
-
let t = await
|
|
6630
|
+
let t = await bs(e);
|
|
6618
6631
|
J(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6619
6632
|
} catch (e) {
|
|
6620
6633
|
Y(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6621
6634
|
}
|
|
6622
6635
|
}
|
|
6623
|
-
async function
|
|
6636
|
+
async function Ss(e, t, n) {
|
|
6624
6637
|
try {
|
|
6625
6638
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6626
6639
|
} catch (e) {
|
|
@@ -6628,7 +6641,7 @@ async function xs(e, t, n) {
|
|
|
6628
6641
|
throw e;
|
|
6629
6642
|
}
|
|
6630
6643
|
}
|
|
6631
|
-
async function
|
|
6644
|
+
async function Cs(e, t, n) {
|
|
6632
6645
|
try {
|
|
6633
6646
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6634
6647
|
} catch (e) {
|
|
@@ -6636,16 +6649,16 @@ async function Ss(e, t, n) {
|
|
|
6636
6649
|
throw e;
|
|
6637
6650
|
}
|
|
6638
6651
|
}
|
|
6639
|
-
async function
|
|
6640
|
-
await
|
|
6652
|
+
async function ws(e) {
|
|
6653
|
+
await Ss(e, "idx_codes_expires_at_ts", "codes"), await Cs(e, "codes", "expires_at_ts");
|
|
6641
6654
|
}
|
|
6642
6655
|
//#endregion
|
|
6643
6656
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6644
|
-
var
|
|
6645
|
-
down: () =>
|
|
6646
|
-
up: () =>
|
|
6657
|
+
var Ts = /* @__PURE__ */ w({
|
|
6658
|
+
down: () => Ds,
|
|
6659
|
+
up: () => Es
|
|
6647
6660
|
});
|
|
6648
|
-
async function
|
|
6661
|
+
async function Es(e) {
|
|
6649
6662
|
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", [
|
|
6650
6663
|
"tenant_id",
|
|
6651
6664
|
"connection_id",
|
|
@@ -6656,16 +6669,16 @@ async function Ts(e) {
|
|
|
6656
6669
|
"external_id"
|
|
6657
6670
|
]).unique().execute();
|
|
6658
6671
|
}
|
|
6659
|
-
async function
|
|
6672
|
+
async function Ds(e) {
|
|
6660
6673
|
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();
|
|
6661
6674
|
}
|
|
6662
6675
|
//#endregion
|
|
6663
6676
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6664
|
-
var
|
|
6665
|
-
down: () =>
|
|
6666
|
-
up: () =>
|
|
6677
|
+
var Os = /* @__PURE__ */ w({
|
|
6678
|
+
down: () => Ms,
|
|
6679
|
+
up: () => As
|
|
6667
6680
|
});
|
|
6668
|
-
async function
|
|
6681
|
+
async function ks(e, t, n) {
|
|
6669
6682
|
try {
|
|
6670
6683
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6671
6684
|
} catch (e) {
|
|
@@ -6673,10 +6686,10 @@ async function Os(e, t, n) {
|
|
|
6673
6686
|
throw e;
|
|
6674
6687
|
}
|
|
6675
6688
|
}
|
|
6676
|
-
async function
|
|
6677
|
-
await
|
|
6689
|
+
async function As(e) {
|
|
6690
|
+
await ks(e, "users", "blocked");
|
|
6678
6691
|
}
|
|
6679
|
-
async function
|
|
6692
|
+
async function js(e, t, n) {
|
|
6680
6693
|
try {
|
|
6681
6694
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6682
6695
|
} catch (e) {
|
|
@@ -6684,16 +6697,16 @@ async function As(e, t, n) {
|
|
|
6684
6697
|
throw e;
|
|
6685
6698
|
}
|
|
6686
6699
|
}
|
|
6687
|
-
async function
|
|
6688
|
-
await
|
|
6700
|
+
async function Ms(e) {
|
|
6701
|
+
await js(e, "users", "blocked");
|
|
6689
6702
|
}
|
|
6690
6703
|
//#endregion
|
|
6691
6704
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6692
|
-
var
|
|
6693
|
-
down: () =>
|
|
6694
|
-
up: () =>
|
|
6705
|
+
var Ns = /* @__PURE__ */ w({
|
|
6706
|
+
down: () => Ls,
|
|
6707
|
+
up: () => Fs
|
|
6695
6708
|
});
|
|
6696
|
-
async function
|
|
6709
|
+
async function Ps(e, t, n) {
|
|
6697
6710
|
try {
|
|
6698
6711
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6699
6712
|
} catch (e) {
|
|
@@ -6701,10 +6714,10 @@ async function Ns(e, t, n) {
|
|
|
6701
6714
|
throw e;
|
|
6702
6715
|
}
|
|
6703
6716
|
}
|
|
6704
|
-
async function
|
|
6705
|
-
await
|
|
6717
|
+
async function Fs(e) {
|
|
6718
|
+
await Ps(e, "prompt_settings", "show_last_used_connection");
|
|
6706
6719
|
}
|
|
6707
|
-
async function
|
|
6720
|
+
async function Is(e, t, n) {
|
|
6708
6721
|
try {
|
|
6709
6722
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6710
6723
|
} catch (e) {
|
|
@@ -6712,16 +6725,16 @@ async function Fs(e, t, n) {
|
|
|
6712
6725
|
throw e;
|
|
6713
6726
|
}
|
|
6714
6727
|
}
|
|
6715
|
-
async function
|
|
6716
|
-
await
|
|
6728
|
+
async function Ls(e) {
|
|
6729
|
+
await Is(e, "prompt_settings", "show_last_used_connection");
|
|
6717
6730
|
}
|
|
6718
6731
|
//#endregion
|
|
6719
6732
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6720
|
-
var
|
|
6721
|
-
down: () =>
|
|
6722
|
-
up: () =>
|
|
6733
|
+
var Rs = /* @__PURE__ */ w({
|
|
6734
|
+
down: () => Vs,
|
|
6735
|
+
up: () => Bs
|
|
6723
6736
|
});
|
|
6724
|
-
async function
|
|
6737
|
+
async function zs(e, t, n, r) {
|
|
6725
6738
|
try {
|
|
6726
6739
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6727
6740
|
} catch (e) {
|
|
@@ -6732,10 +6745,10 @@ async function Rs(e, t, n, r) {
|
|
|
6732
6745
|
throw e;
|
|
6733
6746
|
}
|
|
6734
6747
|
}
|
|
6735
|
-
async function zs(e) {
|
|
6736
|
-
await Rs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6737
|
-
}
|
|
6738
6748
|
async function Bs(e) {
|
|
6749
|
+
await zs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6750
|
+
}
|
|
6751
|
+
async function Vs(e) {
|
|
6739
6752
|
try {
|
|
6740
6753
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6741
6754
|
} catch (e) {
|
|
@@ -6745,11 +6758,11 @@ async function Bs(e) {
|
|
|
6745
6758
|
}
|
|
6746
6759
|
//#endregion
|
|
6747
6760
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6748
|
-
var
|
|
6749
|
-
down: () =>
|
|
6750
|
-
up: () =>
|
|
6761
|
+
var Hs = /* @__PURE__ */ w({
|
|
6762
|
+
down: () => Ks,
|
|
6763
|
+
up: () => Ws
|
|
6751
6764
|
});
|
|
6752
|
-
async function
|
|
6765
|
+
async function Us(e, t, n, r) {
|
|
6753
6766
|
try {
|
|
6754
6767
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6755
6768
|
} catch (e) {
|
|
@@ -6757,10 +6770,10 @@ async function Hs(e, t, n, r) {
|
|
|
6757
6770
|
throw e;
|
|
6758
6771
|
}
|
|
6759
6772
|
}
|
|
6760
|
-
async function
|
|
6761
|
-
await
|
|
6773
|
+
async function Ws(e) {
|
|
6774
|
+
await Us(e, "hooks", "page_id", p`varchar(64)`), await Us(e, "hooks", "permission_required", p`varchar(255)`);
|
|
6762
6775
|
}
|
|
6763
|
-
async function
|
|
6776
|
+
async function Gs(e, t, n) {
|
|
6764
6777
|
try {
|
|
6765
6778
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6766
6779
|
} catch (e) {
|
|
@@ -6768,22 +6781,22 @@ async function Ws(e, t, n) {
|
|
|
6768
6781
|
throw e;
|
|
6769
6782
|
}
|
|
6770
6783
|
}
|
|
6771
|
-
async function
|
|
6772
|
-
await
|
|
6784
|
+
async function Ks(e) {
|
|
6785
|
+
await Gs(e, "hooks", "permission_required"), await Gs(e, "hooks", "page_id");
|
|
6773
6786
|
}
|
|
6774
6787
|
//#endregion
|
|
6775
6788
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6776
|
-
var
|
|
6777
|
-
down: () =>
|
|
6778
|
-
up: () =>
|
|
6779
|
-
}),
|
|
6789
|
+
var qs = /* @__PURE__ */ w({
|
|
6790
|
+
down: () => $s,
|
|
6791
|
+
up: () => Zs
|
|
6792
|
+
}), Js = [
|
|
6780
6793
|
["session_id", p`varchar(26)`],
|
|
6781
6794
|
["organization", p`varchar(191)`],
|
|
6782
6795
|
["auth_connection", p`varchar(255)`],
|
|
6783
6796
|
["auth_strategy_strategy", p`varchar(64)`],
|
|
6784
6797
|
["auth_strategy_strategy_type", p`varchar(64)`]
|
|
6785
6798
|
];
|
|
6786
|
-
async function
|
|
6799
|
+
async function Ys(e, t, n, r) {
|
|
6787
6800
|
try {
|
|
6788
6801
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6789
6802
|
} catch (e) {
|
|
@@ -6791,7 +6804,7 @@ async function Js(e, t, n, r) {
|
|
|
6791
6804
|
throw e;
|
|
6792
6805
|
}
|
|
6793
6806
|
}
|
|
6794
|
-
async function
|
|
6807
|
+
async function Xs(e) {
|
|
6795
6808
|
try {
|
|
6796
6809
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6797
6810
|
} catch (e) {
|
|
@@ -6799,11 +6812,11 @@ async function Ys(e) {
|
|
|
6799
6812
|
throw e;
|
|
6800
6813
|
}
|
|
6801
6814
|
}
|
|
6802
|
-
async function
|
|
6803
|
-
for (let [t, n] of
|
|
6804
|
-
await
|
|
6815
|
+
async function Zs(e) {
|
|
6816
|
+
for (let [t, n] of Js) await Ys(e, "refresh_tokens", t, n);
|
|
6817
|
+
await Xs(e);
|
|
6805
6818
|
}
|
|
6806
|
-
async function
|
|
6819
|
+
async function Qs(e, t, n) {
|
|
6807
6820
|
try {
|
|
6808
6821
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6809
6822
|
} catch (e) {
|
|
@@ -6811,23 +6824,23 @@ async function Zs(e, t, n) {
|
|
|
6811
6824
|
throw e;
|
|
6812
6825
|
}
|
|
6813
6826
|
}
|
|
6814
|
-
async function
|
|
6827
|
+
async function $s(e) {
|
|
6815
6828
|
try {
|
|
6816
6829
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6817
6830
|
} catch {}
|
|
6818
|
-
for (let [t] of
|
|
6831
|
+
for (let [t] of Js) await Qs(e, "refresh_tokens", t);
|
|
6819
6832
|
}
|
|
6820
6833
|
//#endregion
|
|
6821
6834
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6822
|
-
var
|
|
6823
|
-
down: () =>
|
|
6824
|
-
up: () =>
|
|
6825
|
-
}),
|
|
6826
|
-
async function
|
|
6835
|
+
var ec = /* @__PURE__ */ w({
|
|
6836
|
+
down: () => oc,
|
|
6837
|
+
up: () => ac
|
|
6838
|
+
}), tc = 500, nc = 20, rc = 500, ic = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6839
|
+
async function ac(e) {
|
|
6827
6840
|
try {
|
|
6828
6841
|
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);
|
|
6829
|
-
if (n >
|
|
6830
|
-
Y(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6842
|
+
if (n > rc) {
|
|
6843
|
+
Y(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${rc}. SKIPPING — run the bulk path instead: ${ic}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6831
6844
|
return;
|
|
6832
6845
|
}
|
|
6833
6846
|
if (n === 0) {
|
|
@@ -6844,10 +6857,10 @@ async function ic(e) {
|
|
|
6844
6857
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6845
6858
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6846
6859
|
"login_sessions.auth_params as ls_auth_params"
|
|
6847
|
-
]).limit(
|
|
6860
|
+
]).limit(tc).execute();
|
|
6848
6861
|
if (t.length === 0) break;
|
|
6849
|
-
for (let n = 0; n < t.length; n +=
|
|
6850
|
-
let r = t.slice(n, n +
|
|
6862
|
+
for (let n = 0; n < t.length; n += nc) {
|
|
6863
|
+
let r = t.slice(n, n + nc);
|
|
6851
6864
|
await Promise.all(r.map(async (t) => {
|
|
6852
6865
|
let n = null;
|
|
6853
6866
|
if (t.ls_auth_params) try {
|
|
@@ -6864,19 +6877,19 @@ async function ic(e) {
|
|
|
6864
6877
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6865
6878
|
}));
|
|
6866
6879
|
}
|
|
6867
|
-
if (r += t.length, J(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6880
|
+
if (r += t.length, J(`refresh_tokens backfill: ${r} rows populated so far`), t.length < tc) break;
|
|
6868
6881
|
}
|
|
6869
6882
|
J(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6870
6883
|
} catch (e) {
|
|
6871
6884
|
throw Y("refresh_tokens backfill failed:", e), e;
|
|
6872
6885
|
}
|
|
6873
6886
|
}
|
|
6874
|
-
async function
|
|
6887
|
+
async function oc() {}
|
|
6875
6888
|
//#endregion
|
|
6876
6889
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6877
|
-
var
|
|
6878
|
-
down: () =>
|
|
6879
|
-
up: () =>
|
|
6890
|
+
var sc = /* @__PURE__ */ w({
|
|
6891
|
+
down: () => uc,
|
|
6892
|
+
up: () => lc
|
|
6880
6893
|
});
|
|
6881
6894
|
async function X(e, t, n, r) {
|
|
6882
6895
|
try {
|
|
@@ -6886,7 +6899,7 @@ async function X(e, t, n, r) {
|
|
|
6886
6899
|
throw e;
|
|
6887
6900
|
}
|
|
6888
6901
|
}
|
|
6889
|
-
async function
|
|
6902
|
+
async function cc(e, t, n, r) {
|
|
6890
6903
|
try {
|
|
6891
6904
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6892
6905
|
} catch (e) {
|
|
@@ -6894,12 +6907,12 @@ async function sc(e, t, n, r) {
|
|
|
6894
6907
|
throw e;
|
|
6895
6908
|
}
|
|
6896
6909
|
}
|
|
6897
|
-
async function
|
|
6898
|
-
await X(e, "tenant_operations", "input", p`text`), await X(e, "tenant_operations", "result", p`text`), await X(e, "tenant_operations", "claimed_by", p`varchar(255)`), await X(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
|
|
6910
|
+
async function lc(e) {
|
|
6911
|
+
await X(e, "tenant_operations", "input", p`text`), await X(e, "tenant_operations", "result", p`text`), await X(e, "tenant_operations", "claimed_by", p`varchar(255)`), await X(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 cc(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6899
6912
|
"operation_id",
|
|
6900
6913
|
"status",
|
|
6901
6914
|
"seq"
|
|
6902
|
-
]), await
|
|
6915
|
+
]), await cc(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6903
6916
|
"kind",
|
|
6904
6917
|
"status",
|
|
6905
6918
|
"created_at"
|
|
@@ -6913,7 +6926,7 @@ async function Z(e, t, n) {
|
|
|
6913
6926
|
throw e;
|
|
6914
6927
|
}
|
|
6915
6928
|
}
|
|
6916
|
-
async function
|
|
6929
|
+
async function uc(e) {
|
|
6917
6930
|
try {
|
|
6918
6931
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6919
6932
|
} catch {}
|
|
@@ -6921,11 +6934,11 @@ async function lc(e) {
|
|
|
6921
6934
|
}
|
|
6922
6935
|
//#endregion
|
|
6923
6936
|
//#region migrate/migrations/2026-09-25T12:00:00_token_exchange_profiles.ts
|
|
6924
|
-
var
|
|
6925
|
-
down: () =>
|
|
6926
|
-
up: () =>
|
|
6937
|
+
var dc = /* @__PURE__ */ w({
|
|
6938
|
+
down: () => hc,
|
|
6939
|
+
up: () => mc
|
|
6927
6940
|
});
|
|
6928
|
-
async function
|
|
6941
|
+
async function fc(e, t, n, r) {
|
|
6929
6942
|
try {
|
|
6930
6943
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6931
6944
|
} catch (e) {
|
|
@@ -6933,7 +6946,7 @@ async function dc(e, t, n, r) {
|
|
|
6933
6946
|
throw e;
|
|
6934
6947
|
}
|
|
6935
6948
|
}
|
|
6936
|
-
async function
|
|
6949
|
+
async function pc(e, t, n, r) {
|
|
6937
6950
|
try {
|
|
6938
6951
|
await e.schema.createIndex(t).on(n).columns(r).unique().execute();
|
|
6939
6952
|
} catch (e) {
|
|
@@ -6941,10 +6954,10 @@ async function fc(e, t, n, r) {
|
|
|
6941
6954
|
throw e;
|
|
6942
6955
|
}
|
|
6943
6956
|
}
|
|
6944
|
-
async function pc(e) {
|
|
6945
|
-
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 fc(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await dc(e, "clients", "token_exchange", p`text`);
|
|
6946
|
-
}
|
|
6947
6957
|
async function mc(e) {
|
|
6958
|
+
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 pc(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await fc(e, "clients", "token_exchange", p`text`);
|
|
6959
|
+
}
|
|
6960
|
+
async function hc(e) {
|
|
6948
6961
|
await e.schema.dropTable("token_exchange_profiles").ifExists().execute();
|
|
6949
6962
|
try {
|
|
6950
6963
|
await e.schema.alterTable("clients").dropColumn("token_exchange").execute();
|
|
@@ -6956,35 +6969,35 @@ async function mc(e) {
|
|
|
6956
6969
|
//#endregion
|
|
6957
6970
|
//#region migrate/migrations/index.ts
|
|
6958
6971
|
var Q = {
|
|
6959
|
-
"2026-07-16T14:00:00_baseline":
|
|
6960
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6961
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6962
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6963
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6964
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6965
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6966
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6967
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6968
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
6969
|
-
"2026-09-25T12:00:00_token_exchange_profiles":
|
|
6972
|
+
"2026-07-16T14:00:00_baseline": ss,
|
|
6973
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": ps,
|
|
6974
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Ts,
|
|
6975
|
+
"2026-08-05T12:00:00_user_blocked": Os,
|
|
6976
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Ns,
|
|
6977
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Rs,
|
|
6978
|
+
"2026-08-11T12:00:00_page_hooks": Hs,
|
|
6979
|
+
"2026-08-20T12:00:00_refresh_token_session_id": qs,
|
|
6980
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": ec,
|
|
6981
|
+
"2026-09-01T12:00:00_tenant_operation_rows": sc,
|
|
6982
|
+
"2026-09-25T12:00:00_token_exchange_profiles": dc
|
|
6970
6983
|
};
|
|
6971
6984
|
//#endregion
|
|
6972
6985
|
//#region migrate/migrate.ts
|
|
6973
|
-
async function
|
|
6974
|
-
|
|
6986
|
+
async function gc(e, t = !1) {
|
|
6987
|
+
q(t), t && console.log("migrating...");
|
|
6975
6988
|
let { error: n, results: r } = await new ke({
|
|
6976
6989
|
db: e,
|
|
6977
|
-
provider: new
|
|
6990
|
+
provider: new os(Q)
|
|
6978
6991
|
}).migrateToLatest();
|
|
6979
6992
|
if (r?.forEach((e) => {
|
|
6980
6993
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6981
6994
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6982
6995
|
}
|
|
6983
|
-
async function
|
|
6984
|
-
|
|
6996
|
+
async function _c(e, t = !1) {
|
|
6997
|
+
q(t), t && console.log("migrating...");
|
|
6985
6998
|
let { error: n, results: r } = await new ke({
|
|
6986
6999
|
db: e,
|
|
6987
|
-
provider: new
|
|
7000
|
+
provider: new os(Q)
|
|
6988
7001
|
}).migrateDown();
|
|
6989
7002
|
if (r?.forEach((e) => {
|
|
6990
7003
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6992,22 +7005,22 @@ async function gc(e, t = !1) {
|
|
|
6992
7005
|
}
|
|
6993
7006
|
//#endregion
|
|
6994
7007
|
//#region migrate/plan.ts
|
|
6995
|
-
var
|
|
6996
|
-
function
|
|
7008
|
+
var vc = 5e3, yc = class extends Error {};
|
|
7009
|
+
function bc(e) {
|
|
6997
7010
|
if (e.query.kind === "SelectQueryNode") return !0;
|
|
6998
7011
|
if (e.query.kind !== "RawNode") return !1;
|
|
6999
7012
|
let t = e.sql.trimStart();
|
|
7000
7013
|
return /^(select|show|explain|describe|desc)\b/i.test(t) ? !0 : /^pragma\b/i.test(t) && !t.includes("=");
|
|
7001
7014
|
}
|
|
7002
|
-
var
|
|
7015
|
+
var xc = class {
|
|
7003
7016
|
inner;
|
|
7004
7017
|
captured;
|
|
7005
7018
|
constructor(e, t) {
|
|
7006
7019
|
this.inner = e, this.captured = t;
|
|
7007
7020
|
}
|
|
7008
7021
|
async executeQuery(e) {
|
|
7009
|
-
if (
|
|
7010
|
-
if (this.captured.length >=
|
|
7022
|
+
if (bc(e)) return this.inner.executeQuery(e);
|
|
7023
|
+
if (this.captured.length >= vc) throw new yc(`stopped after ${vc} statements`);
|
|
7011
7024
|
return this.captured.push({
|
|
7012
7025
|
sql: e.sql,
|
|
7013
7026
|
parameters: e.parameters
|
|
@@ -7023,7 +7036,7 @@ var bc = class {
|
|
|
7023
7036
|
function $() {
|
|
7024
7037
|
throw Error("not available in a migration dry run");
|
|
7025
7038
|
}
|
|
7026
|
-
var
|
|
7039
|
+
var Sc = {
|
|
7027
7040
|
init: async () => {},
|
|
7028
7041
|
acquireConnection: $,
|
|
7029
7042
|
beginTransaction: $,
|
|
@@ -7032,25 +7045,25 @@ var xc = {
|
|
|
7032
7045
|
releaseConnection: $,
|
|
7033
7046
|
destroy: async () => {}
|
|
7034
7047
|
};
|
|
7035
|
-
function
|
|
7036
|
-
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new
|
|
7048
|
+
function Cc(e, t) {
|
|
7049
|
+
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new xc(n, t))) }), i = {
|
|
7037
7050
|
createAdapter: () => n.adapter,
|
|
7038
|
-
createDriver: () =>
|
|
7051
|
+
createDriver: () => Sc,
|
|
7039
7052
|
createQueryCompiler: () => $(),
|
|
7040
7053
|
createIntrospector: () => $()
|
|
7041
7054
|
};
|
|
7042
7055
|
return new f({
|
|
7043
7056
|
config: { dialect: i },
|
|
7044
7057
|
dialect: i,
|
|
7045
|
-
driver:
|
|
7058
|
+
driver: Sc,
|
|
7046
7059
|
executor: r
|
|
7047
7060
|
});
|
|
7048
7061
|
}
|
|
7049
|
-
async function
|
|
7050
|
-
|
|
7062
|
+
async function wc(e) {
|
|
7063
|
+
q(!1);
|
|
7051
7064
|
let t = await new ke({
|
|
7052
7065
|
db: e,
|
|
7053
|
-
provider: new
|
|
7066
|
+
provider: new os(Q)
|
|
7054
7067
|
}).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;
|
|
7055
7068
|
if (a) throw Error(`pending migration "${a.name}" sorts before already-executed "${i}"; migrateToLatest would refuse to run`);
|
|
7056
7069
|
let o = [];
|
|
@@ -7060,9 +7073,9 @@ async function Cc(e) {
|
|
|
7060
7073
|
statements: n
|
|
7061
7074
|
};
|
|
7062
7075
|
try {
|
|
7063
|
-
await t.migration.up(
|
|
7076
|
+
await t.migration.up(Cc(e, n));
|
|
7064
7077
|
} catch (e) {
|
|
7065
|
-
r.error = e instanceof Error ? e.message : String(e), e instanceof
|
|
7078
|
+
r.error = e instanceof Error ? e.message : String(e), e instanceof yc && (r.truncated = !0);
|
|
7066
7079
|
}
|
|
7067
7080
|
o.push(r);
|
|
7068
7081
|
}
|
|
@@ -7071,7 +7084,7 @@ async function Cc(e) {
|
|
|
7071
7084
|
pending: o
|
|
7072
7085
|
};
|
|
7073
7086
|
}
|
|
7074
|
-
function
|
|
7087
|
+
function Tc(e) {
|
|
7075
7088
|
if (e.pending.length === 0) return `-- Database is up to date (${e.executed.length} migrations executed).`;
|
|
7076
7089
|
let t = [`-- ${e.pending.length} pending migration(s); ${e.executed.length} already executed.`];
|
|
7077
7090
|
for (let n of e.pending) {
|
|
@@ -7086,66 +7099,66 @@ function wc(e) {
|
|
|
7086
7099
|
}
|
|
7087
7100
|
//#endregion
|
|
7088
7101
|
//#region src/index.ts
|
|
7089
|
-
function
|
|
7102
|
+
function Ec(e, t = { useTransactions: !0 }) {
|
|
7090
7103
|
let n = {
|
|
7091
|
-
actions:
|
|
7092
|
-
actionExecutions:
|
|
7093
|
-
actionVersions:
|
|
7094
|
-
branding:
|
|
7104
|
+
actions: Xe(e),
|
|
7105
|
+
actionExecutions: rt(e),
|
|
7106
|
+
actionVersions: ot(e),
|
|
7107
|
+
branding: yr(e),
|
|
7095
7108
|
clients: Fn(e),
|
|
7096
7109
|
clientConnections: Vn(e),
|
|
7097
7110
|
clientGrants: Jn(e),
|
|
7098
|
-
clientRegistrationTokens:
|
|
7099
|
-
codes:
|
|
7111
|
+
clientRegistrationTokens: ar(e),
|
|
7112
|
+
codes: yn(e),
|
|
7100
7113
|
connections: En(e),
|
|
7101
|
-
emailProviders:
|
|
7102
|
-
emailTemplates:
|
|
7103
|
-
customDomains:
|
|
7104
|
-
flows:
|
|
7105
|
-
forms:
|
|
7106
|
-
hookCode:
|
|
7107
|
-
hooks:
|
|
7108
|
-
invites:
|
|
7109
|
-
keys:
|
|
7110
|
-
loginSessions:
|
|
7111
|
-
logs:
|
|
7112
|
-
logStreams:
|
|
7113
|
-
migrationSources:
|
|
7114
|
+
emailProviders: ai(e),
|
|
7115
|
+
emailTemplates: fi(e),
|
|
7116
|
+
customDomains: gr(e),
|
|
7117
|
+
flows: Ft(e),
|
|
7118
|
+
forms: ji(e),
|
|
7119
|
+
hookCode: Pr(e),
|
|
7120
|
+
hooks: kr(e),
|
|
7121
|
+
invites: Na(e),
|
|
7122
|
+
keys: lr(e),
|
|
7123
|
+
loginSessions: Xr(e),
|
|
7124
|
+
logs: Zt(e),
|
|
7125
|
+
logStreams: _o(e),
|
|
7126
|
+
migrationSources: yo(e),
|
|
7114
7127
|
authenticationMethods: io(e),
|
|
7115
|
-
passwords:
|
|
7116
|
-
promptSettings:
|
|
7117
|
-
proxyRoutes:
|
|
7118
|
-
scimConfigurations:
|
|
7119
|
-
scimTokens:
|
|
7120
|
-
scimExternalIds:
|
|
7121
|
-
refreshTokens:
|
|
7122
|
-
resourceServers:
|
|
7123
|
-
rolePermissions:
|
|
7124
|
-
grants:
|
|
7125
|
-
userPermissions:
|
|
7126
|
-
userRoles:
|
|
7127
|
-
roles:
|
|
7128
|
-
sessions:
|
|
7129
|
-
sessionCleanup:
|
|
7130
|
-
tenants:
|
|
7131
|
-
tenantOperations:
|
|
7132
|
-
tenantOperationEvents:
|
|
7133
|
-
tenantOperationRows:
|
|
7134
|
-
tokenExchangeProfiles:
|
|
7135
|
-
rollouts:
|
|
7136
|
-
themes:
|
|
7137
|
-
universalLoginTemplates:
|
|
7128
|
+
passwords: ln(e),
|
|
7129
|
+
promptSettings: ei(e),
|
|
7130
|
+
proxyRoutes: Co(e),
|
|
7131
|
+
scimConfigurations: No(e),
|
|
7132
|
+
scimTokens: Fo(e),
|
|
7133
|
+
scimExternalIds: Lo(e),
|
|
7134
|
+
refreshTokens: Ci(e),
|
|
7135
|
+
resourceServers: Ri(e),
|
|
7136
|
+
rolePermissions: Xi(e),
|
|
7137
|
+
grants: na(e),
|
|
7138
|
+
userPermissions: sa(e),
|
|
7139
|
+
userRoles: pa(e),
|
|
7140
|
+
roles: Gi(e),
|
|
7141
|
+
sessions: rn(e),
|
|
7142
|
+
sessionCleanup: Ti(e),
|
|
7143
|
+
tenants: Ut(e),
|
|
7144
|
+
tenantOperations: zo(e),
|
|
7145
|
+
tenantOperationEvents: Qo(e),
|
|
7146
|
+
tenantOperationRows: ns(e),
|
|
7147
|
+
tokenExchangeProfiles: ko(e),
|
|
7148
|
+
rollouts: as(e),
|
|
7149
|
+
themes: zr(e),
|
|
7150
|
+
universalLoginTemplates: Cr(e),
|
|
7138
7151
|
customText: Za(e),
|
|
7139
|
-
users:
|
|
7140
|
-
userActivity:
|
|
7141
|
-
organizations:
|
|
7142
|
-
organizationConnections:
|
|
7143
|
-
userOrganizations:
|
|
7144
|
-
stats:
|
|
7152
|
+
users: Dt(e),
|
|
7153
|
+
userActivity: wt(e),
|
|
7154
|
+
organizations: ya(e),
|
|
7155
|
+
organizationConnections: ba(e),
|
|
7156
|
+
userOrganizations: Da(e),
|
|
7157
|
+
stats: Ra(e),
|
|
7145
7158
|
analytics: Xa(e),
|
|
7146
7159
|
outbox: ho(e),
|
|
7147
7160
|
async transaction(r) {
|
|
7148
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
7161
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Ec(e, {
|
|
7149
7162
|
...t,
|
|
7150
7163
|
useTransactions: !1
|
|
7151
7164
|
})));
|
|
@@ -7154,4 +7167,4 @@ function Tc(e, t = { useTransactions: !0 }) {
|
|
|
7154
7167
|
return n;
|
|
7155
7168
|
}
|
|
7156
7169
|
//#endregion
|
|
7157
|
-
export {
|
|
7170
|
+
export { To as createProxyDataAdapter, Co as createProxyRoutesAdapter, Ec as default, Tc as formatMigrationPlan, _c as migrateDown, gc as migrateToLatest, wc as planMigrations };
|