@authhero/kysely-adapter 12.8.0 → 12.8.1
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
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { customAlphabet as e, nanoid as t } from "nanoid";
|
|
2
2
|
import { booleanToInt as n, convertDatesToAdapter as r, dbDateToIso as i, dbDateToIsoRequired as a, getCountAsInt as o, isoToDbDate as s, nowIso as c, removeNullProperties as l, removeUndefinedAndNull as u, stringifyProperties as d } from "@authhero/adapter-interfaces/sql";
|
|
3
3
|
import { sql as f } from "kysely";
|
|
4
|
-
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he, splitLuceneOrGroups as ge, tenantOperationEventInsertSchema as _e, tenantOperationEventSchema as ve, tenantOperationInsertSchema as ye, tenantOperationRowInsertSchema as be, tenantOperationRowSchema as xe, tenantOperationSchema as Se, tokenizeLuceneQuery as Ce, unescapeLuceneValue as
|
|
5
|
-
import { HTTPException as
|
|
4
|
+
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he, splitLuceneOrGroups as ge, tenantOperationEventInsertSchema as _e, tenantOperationEventSchema as ve, tenantOperationInsertSchema as ye, tenantOperationRowInsertSchema as be, tenantOperationRowSchema as xe, tenantOperationSchema as Se, tokenizeLuceneQuery as Ce, unescapeLuceneValue as we, unquoteLuceneValue as C } from "@authhero/adapter-interfaces";
|
|
5
|
+
import { HTTPException as w } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as Te } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var Ee = Object.defineProperty, T = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) Ee(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || Ee(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, De = 17, Oe = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -25,39 +25,39 @@ var Te = Object.defineProperty, E = (e, t) => {
|
|
|
25
25
|
guardian_factor: "gfa_",
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
31
|
-
}
|
|
32
|
-
function Oe() {
|
|
33
|
-
return D("organization");
|
|
28
|
+
function E(t) {
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", De)();
|
|
30
|
+
return `${Oe[t]}${n}`;
|
|
34
31
|
}
|
|
35
32
|
function ke() {
|
|
36
|
-
return
|
|
33
|
+
return E("organization");
|
|
37
34
|
}
|
|
38
35
|
function Ae() {
|
|
39
|
-
return
|
|
36
|
+
return E("connection");
|
|
40
37
|
}
|
|
41
38
|
function je() {
|
|
42
|
-
return
|
|
39
|
+
return E("action");
|
|
43
40
|
}
|
|
44
41
|
function Me() {
|
|
45
|
-
return
|
|
42
|
+
return E("action_version");
|
|
46
43
|
}
|
|
47
44
|
function Ne() {
|
|
48
|
-
return
|
|
45
|
+
return E("hook");
|
|
49
46
|
}
|
|
50
47
|
function Pe() {
|
|
51
|
-
return
|
|
48
|
+
return E("resource_server");
|
|
52
49
|
}
|
|
53
50
|
function Fe() {
|
|
54
|
-
return
|
|
51
|
+
return E("hook_code");
|
|
52
|
+
}
|
|
53
|
+
function Ie() {
|
|
54
|
+
return E("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Le(e) {
|
|
59
59
|
return async (t, n, r) => {
|
|
60
|
-
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() : o, c = i?.id ??
|
|
60
|
+
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() : o, c = i?.id ?? je();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,7 +91,7 @@ function Ie(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function D(e) {
|
|
95
95
|
if (e) try {
|
|
96
96
|
return JSON.parse(e);
|
|
97
97
|
} catch {
|
|
@@ -113,9 +113,9 @@ function Re(e) {
|
|
|
113
113
|
runtime: m.runtime ?? void 0,
|
|
114
114
|
status: m.status || "built",
|
|
115
115
|
deployed_at: s ? new Date(Number(s)).toISOString() : void 0,
|
|
116
|
-
secrets:
|
|
117
|
-
dependencies:
|
|
118
|
-
supported_triggers:
|
|
116
|
+
secrets: D(c),
|
|
117
|
+
dependencies: D(l),
|
|
118
|
+
supported_triggers: D(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -146,7 +146,7 @@ function O(e, t, n, r, i = [], a = {}) {
|
|
|
146
146
|
if (!n) return null;
|
|
147
147
|
let [, r, i] = n;
|
|
148
148
|
if (!r || !i) return null;
|
|
149
|
-
let a = r.trim(), d =
|
|
149
|
+
let a = r.trim(), d = we(i.replace(/^"(.*)"$/, "$1").trim());
|
|
150
150
|
return o.has(a) ? e(s(c(a)), "like", `%${d}%`) : e(l(a), "=", u(a, d));
|
|
151
151
|
}).filter((e) => e !== null);
|
|
152
152
|
return n.length === 0 ? null : n.length === 1 ? n[0] : e.and(n);
|
|
@@ -158,8 +158,8 @@ function O(e, t, n, r, i = [], a = {}) {
|
|
|
158
158
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
159
159
|
else if (e.includes(":")) {
|
|
160
160
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
161
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
162
|
-
} else n = null, r =
|
|
161
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = we(r);
|
|
162
|
+
} else n = null, r = we(e), i = !1;
|
|
163
163
|
return {
|
|
164
164
|
key: n,
|
|
165
165
|
value: r,
|
|
@@ -281,7 +281,7 @@ function Ue(e) {
|
|
|
281
281
|
//#region src/actions/index.ts
|
|
282
282
|
function We(e) {
|
|
283
283
|
return {
|
|
284
|
-
create:
|
|
284
|
+
create: Le(e),
|
|
285
285
|
get: Re(e),
|
|
286
286
|
list: Be(e),
|
|
287
287
|
update: He(e),
|
|
@@ -349,8 +349,8 @@ async function Je(e) {
|
|
|
349
349
|
}
|
|
350
350
|
//#endregion
|
|
351
351
|
//#region src/actionExecutions/cleanup.ts
|
|
352
|
-
var
|
|
353
|
-
function
|
|
352
|
+
var Ye = 5e4;
|
|
353
|
+
function Xe(e) {
|
|
354
354
|
let t;
|
|
355
355
|
return async (n) => {
|
|
356
356
|
let r = Date.parse(n);
|
|
@@ -359,9 +359,9 @@ function Ye(e) {
|
|
|
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 = Ye;
|
|
363
|
+
for (; a >= Ye;) {
|
|
364
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(Ye).executeTakeFirst();
|
|
365
365
|
a = Number(t.numDeletedRows), i += a;
|
|
366
366
|
}
|
|
367
367
|
return i;
|
|
@@ -369,39 +369,39 @@ function Ye(e) {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/actionExecutions/index.ts
|
|
372
|
-
function
|
|
372
|
+
function Ze(e) {
|
|
373
373
|
return {
|
|
374
374
|
create: Ge(e),
|
|
375
375
|
get: qe(e),
|
|
376
|
-
cleanup:
|
|
376
|
+
cleanup: Xe(e)
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/actionVersions/index.ts
|
|
381
|
-
function
|
|
381
|
+
function Qe(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 $e(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: Qe(r),
|
|
395
|
+
dependencies: Qe(i),
|
|
396
|
+
supported_triggers: Qe(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 et(e) {
|
|
402
402
|
return {
|
|
403
403
|
async create(t, n, r) {
|
|
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 ??
|
|
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 ?? Me(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
405
405
|
let r = ((await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n.action_id).select("number").orderBy("number", "desc").limit(1).executeTakeFirst())?.number ?? 0) + 1;
|
|
406
406
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
407
407
|
deployed: 0,
|
|
@@ -438,10 +438,10 @@ function $e(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 ? $e(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($e);
|
|
445
445
|
if (!s) return {
|
|
446
446
|
versions: l,
|
|
447
447
|
start: 0,
|
|
@@ -464,7 +464,7 @@ function $e(e) {
|
|
|
464
464
|
}
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/outbox/create.ts
|
|
467
|
-
async function
|
|
467
|
+
async function A(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 j(e, t, n, r) {
|
|
|
483
483
|
error: null
|
|
484
484
|
}).execute();
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function tt(e) {
|
|
487
487
|
return async (n, r) => {
|
|
488
488
|
let i = t();
|
|
489
|
-
return await
|
|
489
|
+
return await A(e, n, i, r), i;
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/users/create.ts
|
|
494
|
-
function
|
|
494
|
+
function nt(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,12 +526,12 @@ function tt(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 A(e, n, t.id, t);
|
|
530
530
|
};
|
|
531
531
|
try {
|
|
532
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
533
533
|
} catch (e) {
|
|
534
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
534
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new w(409, { message: "User already exists" }) : new w(500, { message: `${e.code}, ${e.message}` });
|
|
535
535
|
}
|
|
536
536
|
return {
|
|
537
537
|
...m,
|
|
@@ -551,16 +551,16 @@ function tt(e) {
|
|
|
551
551
|
}
|
|
552
552
|
//#endregion
|
|
553
553
|
//#region src/users/createMany.ts
|
|
554
|
-
var
|
|
555
|
-
function
|
|
554
|
+
var j = 500;
|
|
555
|
+
function rt(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 it(e) {
|
|
560
560
|
return async (n, r, i) => {
|
|
561
561
|
if (r.length === 0) return [];
|
|
562
|
-
if (i?.outboxEvents?.length) throw new
|
|
563
|
-
if (r.find(
|
|
562
|
+
if (i?.outboxEvents?.length) throw new w(400, { message: "createMany does not persist outbox events; use create for those users" });
|
|
563
|
+
if (r.find(rt)) throw new w(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,14 +591,14 @@ function rt(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 += j) await e.insertInto("users").values(s.slice(t, t + j)).execute();
|
|
595
|
+
for (let t = 0; t < c.length; t += j) await e.insertInto("passwords").values(c.slice(t, t + j)).execute();
|
|
596
596
|
};
|
|
597
597
|
try {
|
|
598
598
|
e.isTransaction ? await l(e) : await e.transaction().execute(l);
|
|
599
599
|
} catch (e) {
|
|
600
600
|
let t = e?.code, n = e instanceof Error ? e.message : String(e);
|
|
601
|
-
throw t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || n.includes("AlreadyExists") ? new
|
|
601
|
+
throw t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || n.includes("AlreadyExists") ? new w(409, { message: "User already exists" }) : new w(500, { message: `${String(t)}, ${n}` });
|
|
602
602
|
}
|
|
603
603
|
return o.map(({ sqlUser: e, original: t }) => ({
|
|
604
604
|
...e,
|
|
@@ -615,21 +615,21 @@ function rt(e) {
|
|
|
615
615
|
}
|
|
616
616
|
//#endregion
|
|
617
617
|
//#region src/users/user-to-identity.ts
|
|
618
|
-
var
|
|
618
|
+
var at = [
|
|
619
619
|
"email",
|
|
620
620
|
"email_verified",
|
|
621
621
|
"phone_number",
|
|
622
622
|
"phone_verified",
|
|
623
623
|
"username"
|
|
624
624
|
];
|
|
625
|
-
function
|
|
625
|
+
function M(e, t = !1) {
|
|
626
626
|
let n = {
|
|
627
627
|
connection: e.connection,
|
|
628
628
|
provider: e.provider,
|
|
629
629
|
user_id: ue(e.user_id).id,
|
|
630
630
|
isSocial: !!e.is_social
|
|
631
631
|
};
|
|
632
|
-
for (let t of
|
|
632
|
+
for (let t of at) 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 N(e, t = !1) {
|
|
|
647
647
|
}
|
|
648
648
|
//#endregion
|
|
649
649
|
//#region src/users/get.ts
|
|
650
|
-
function
|
|
650
|
+
function ot(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,22 +669,22 @@ function at(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: [M(r, !0), ...i.map((e) => M(e))]
|
|
673
673
|
});
|
|
674
674
|
};
|
|
675
675
|
}
|
|
676
676
|
//#endregion
|
|
677
677
|
//#region src/helpers/paginate.ts
|
|
678
|
-
function
|
|
678
|
+
function N(e) {
|
|
679
679
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function st(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 =
|
|
687
|
-
if (c && c.k !== n.sortKey) throw new
|
|
685
|
+
async function P(e, t, n) {
|
|
686
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = st(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
687
|
+
if (c && c.k !== n.sortKey) throw new w(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(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
689
689
|
else {
|
|
690
690
|
let e = i === "asc" ? f.raw(">") : f.raw("<");
|
|
@@ -707,7 +707,7 @@ async function F(e, t, n) {
|
|
|
707
707
|
}
|
|
708
708
|
//#endregion
|
|
709
709
|
//#region src/users/list.ts
|
|
710
|
-
var
|
|
710
|
+
var ct = [
|
|
711
711
|
"user_id",
|
|
712
712
|
"email",
|
|
713
713
|
"email_verified",
|
|
@@ -730,20 +730,20 @@ var st = [
|
|
|
730
730
|
"login_count",
|
|
731
731
|
"created_at",
|
|
732
732
|
"updated_at"
|
|
733
|
-
],
|
|
733
|
+
], lt = new Set([
|
|
734
734
|
"last_login",
|
|
735
735
|
"last_ip",
|
|
736
736
|
"login_count"
|
|
737
|
-
]),
|
|
737
|
+
]), ut = Object.fromEntries(ct.map((e) => [e, e === "login_count" ? {
|
|
738
738
|
column: "user_activity.login_count",
|
|
739
739
|
defaultValue: 0
|
|
740
|
-
} :
|
|
740
|
+
} : lt.has(e) ? `user_activity.${e}` : `users.${e}`])), dt = [
|
|
741
741
|
"email",
|
|
742
742
|
"name",
|
|
743
743
|
"phone_number",
|
|
744
744
|
"user_id"
|
|
745
745
|
];
|
|
746
|
-
async function
|
|
746
|
+
async function ft(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 dt(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: [M(e, !0), ...t.map((e) => M(e))]
|
|
761
761
|
});
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
function
|
|
764
|
+
function pt(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 = O(e, l, t,
|
|
768
|
+
let t = S(c, ct);
|
|
769
|
+
t && (l = O(e, l, t, dt, [], ut));
|
|
770
770
|
}
|
|
771
|
-
if (
|
|
772
|
-
if (s?.sort_by && s.sort_by !== "created_at") throw new
|
|
773
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
771
|
+
if (N(n)) {
|
|
772
|
+
if (s?.sort_by && s.sort_by !== "created_at") throw new w(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 P(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 ft(e) {
|
|
|
779
779
|
sortOrder: r,
|
|
780
780
|
idColumn: "users.user_id",
|
|
781
781
|
sortKey: `created_at:${r}`
|
|
782
|
-
}), c = await
|
|
782
|
+
}), c = await ft(e, t, i);
|
|
783
783
|
return {
|
|
784
784
|
users: c,
|
|
785
785
|
start: 0,
|
|
@@ -789,7 +789,7 @@ function ft(e) {
|
|
|
789
789
|
};
|
|
790
790
|
}
|
|
791
791
|
if (s && s.sort_by) {
|
|
792
|
-
let t =
|
|
792
|
+
let t = ut[s.sort_by];
|
|
793
793
|
if (t) {
|
|
794
794
|
let { ref: n } = e.dynamic;
|
|
795
795
|
l = l.orderBy(typeof t == "string" ? n(t) : ze(t), s.sort_order);
|
|
@@ -799,7 +799,7 @@ function ft(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 ft(e, t, d);
|
|
803
803
|
if (!f) return {
|
|
804
804
|
users: p,
|
|
805
805
|
start: 0,
|
|
@@ -817,12 +817,12 @@ function ft(e) {
|
|
|
817
817
|
}
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region src/users/remove.ts
|
|
820
|
-
function
|
|
820
|
+
function mt(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 A(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 pt(e) {
|
|
|
830
830
|
}
|
|
831
831
|
//#endregion
|
|
832
832
|
//#region src/utils/flatten.ts
|
|
833
|
-
function
|
|
833
|
+
function F(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) ? F(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
837
837
|
}
|
|
838
838
|
return n;
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function ht(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 mt(e, t) {
|
|
|
854
854
|
}
|
|
855
855
|
//#endregion
|
|
856
856
|
//#region src/userActivity/index.ts
|
|
857
|
-
function
|
|
857
|
+
function gt(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 ht(e) {
|
|
|
864
864
|
last_password_reset: e.last_password_reset ?? void 0
|
|
865
865
|
};
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function _t(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 vt(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 ? gt(r) : null;
|
|
876
876
|
},
|
|
877
877
|
async upsert(t, n, r) {
|
|
878
|
-
let i =
|
|
878
|
+
let i = _t(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 _t(e) {
|
|
|
897
897
|
}
|
|
898
898
|
//#endregion
|
|
899
899
|
//#region src/users/update.ts
|
|
900
|
-
function
|
|
900
|
+
function yt(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 = F({
|
|
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 vt(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 vt(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 A(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 vt(e) {
|
|
|
923
923
|
}
|
|
924
924
|
//#endregion
|
|
925
925
|
//#region src/users/unlink.ts
|
|
926
|
-
function
|
|
926
|
+
function bt(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 xt(e) {
|
|
932
|
+
let t = nt(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: it(e),
|
|
937
|
+
remove: mt(e),
|
|
938
|
+
get: ot(e),
|
|
939
|
+
list: pt(e),
|
|
940
|
+
update: yt(e),
|
|
941
|
+
unlink: bt(e)
|
|
942
942
|
};
|
|
943
943
|
}
|
|
944
944
|
//#endregion
|
|
945
945
|
//#region src/flows/create.ts
|
|
946
|
-
function
|
|
946
|
+
function St(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 xt(e) {
|
|
|
961
961
|
}
|
|
962
962
|
//#endregion
|
|
963
963
|
//#region src/helpers/parse.ts
|
|
964
|
-
function
|
|
964
|
+
function I(e, t) {
|
|
965
965
|
if (!e) return t;
|
|
966
966
|
try {
|
|
967
967
|
return JSON.parse(e);
|
|
@@ -969,7 +969,7 @@ function L(e, t) {
|
|
|
969
969
|
return t;
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function Ct(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 St(e) {
|
|
|
977
977
|
return;
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
function
|
|
981
|
-
for (let r in t) r in e && (n[r] =
|
|
980
|
+
function wt(e, t, n = { ...e }) {
|
|
981
|
+
for (let r in t) r in e && (n[r] = I(e[r], t[r]));
|
|
982
982
|
return n;
|
|
983
983
|
}
|
|
984
984
|
//#endregion
|
|
985
985
|
//#region src/flows/get.ts
|
|
986
|
-
function
|
|
986
|
+
function Tt(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: I(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 Et(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 = O(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: I(e.actions, [])
|
|
1007
1007
|
};
|
|
1008
1008
|
return b.parse(l(t));
|
|
1009
1009
|
});
|
|
@@ -1024,7 +1024,7 @@ function Tt(e) {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
//#endregion
|
|
1026
1026
|
//#region src/flows/update.ts
|
|
1027
|
-
function
|
|
1027
|
+
function Dt(e) {
|
|
1028
1028
|
return async (t, n, r) => {
|
|
1029
1029
|
let i = {
|
|
1030
1030
|
...r,
|
|
@@ -1042,27 +1042,27 @@ function Et(e) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
//#endregion
|
|
1044
1044
|
//#region src/flows/remove.ts
|
|
1045
|
-
function
|
|
1045
|
+
function Ot(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 kt(e) {
|
|
1051
1051
|
return {
|
|
1052
|
-
create:
|
|
1053
|
-
get:
|
|
1054
|
-
list:
|
|
1055
|
-
update:
|
|
1056
|
-
remove:
|
|
1052
|
+
create: St(e),
|
|
1053
|
+
get: Tt(e),
|
|
1054
|
+
list: Et(e),
|
|
1055
|
+
update: Dt(e),
|
|
1056
|
+
remove: Ot(e)
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
//#endregion
|
|
1060
1060
|
//#region src/tenants/utils.ts
|
|
1061
|
-
function
|
|
1061
|
+
function At(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 jt(e) {
|
|
1066
1066
|
let t = { ...e };
|
|
1067
1067
|
return d(e, [
|
|
1068
1068
|
"session_cookie",
|
|
@@ -1085,34 +1085,34 @@ function At(e) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
//#endregion
|
|
1087
1087
|
//#region src/tenants/create.ts
|
|
1088
|
-
function
|
|
1088
|
+
function Mt(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 = jt(o);
|
|
1096
1096
|
try {
|
|
1097
1097
|
await e.insertInto("tenants").values(s).execute();
|
|
1098
1098
|
} catch (e) {
|
|
1099
1099
|
let t = e?.message ?? "";
|
|
1100
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
1100
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new w(409, { message: `Tenant with ID '${o.id}' already exists` }) : e;
|
|
1101
1101
|
}
|
|
1102
1102
|
return o;
|
|
1103
1103
|
};
|
|
1104
1104
|
}
|
|
1105
1105
|
//#endregion
|
|
1106
1106
|
//#region src/tenants/get.ts
|
|
1107
|
-
function
|
|
1107
|
+
function Nt(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 ? At(n) : null;
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
1113
|
//#endregion
|
|
1114
1114
|
//#region src/tenants/list.ts
|
|
1115
|
-
function
|
|
1115
|
+
function Pt(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 Nt(e) {
|
|
|
1120
1120
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1121
1121
|
}
|
|
1122
1122
|
c && (n = O(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(At);
|
|
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 Nt(e) {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
//#endregion
|
|
1135
1135
|
//#region src/tenants/update.ts
|
|
1136
|
-
function
|
|
1136
|
+
function Ft(e) {
|
|
1137
1137
|
return async (t, n) => {
|
|
1138
1138
|
let r = {
|
|
1139
|
-
...
|
|
1139
|
+
...jt(n),
|
|
1140
1140
|
id: t,
|
|
1141
1141
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1142
1142
|
};
|
|
@@ -1145,29 +1145,29 @@ function Pt(e) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
//#endregion
|
|
1147
1147
|
//#region src/tenants/remove.ts
|
|
1148
|
-
function
|
|
1148
|
+
function It(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 Lt(e) {
|
|
1154
1154
|
return {
|
|
1155
|
-
create:
|
|
1156
|
-
get:
|
|
1157
|
-
list:
|
|
1158
|
-
update:
|
|
1159
|
-
remove:
|
|
1155
|
+
create: Mt(e),
|
|
1156
|
+
get: Nt(e),
|
|
1157
|
+
list: Pt(e),
|
|
1158
|
+
update: Ft(e),
|
|
1159
|
+
remove: It(e)
|
|
1160
1160
|
};
|
|
1161
1161
|
}
|
|
1162
1162
|
//#endregion
|
|
1163
1163
|
//#region src/logs/create.ts
|
|
1164
|
-
function
|
|
1164
|
+
function Rt(e) {
|
|
1165
1165
|
return e ? JSON.stringify(e) : void 0;
|
|
1166
1166
|
}
|
|
1167
|
-
var
|
|
1168
|
-
function
|
|
1167
|
+
var zt = 256;
|
|
1168
|
+
function Bt(e) {
|
|
1169
1169
|
return async (n, r) => {
|
|
1170
|
-
let i = r.user_agent?.slice(0,
|
|
1170
|
+
let i = r.user_agent?.slice(0, zt), 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 zt(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: Rt(r.auth0_client),
|
|
1180
|
+
details: Rt(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 zt(e) {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
//#endregion
|
|
1195
1195
|
//#region src/logs/logs.ts
|
|
1196
|
-
function
|
|
1196
|
+
function Vt(e) {
|
|
1197
1197
|
if (!e) return "";
|
|
1198
1198
|
try {
|
|
1199
1199
|
return JSON.parse(e);
|
|
@@ -1201,13 +1201,13 @@ function Bt(e) {
|
|
|
1201
1201
|
return e;
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
|
-
function
|
|
1204
|
+
function L(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: Vt(e.auth0_client),
|
|
1210
|
+
details: Vt(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 R(e) {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
//#endregion
|
|
1225
1225
|
//#region src/logs/list.ts
|
|
1226
|
-
var
|
|
1226
|
+
var Ht = [
|
|
1227
1227
|
"user_id",
|
|
1228
1228
|
"ip",
|
|
1229
1229
|
"type",
|
|
@@ -1249,25 +1249,25 @@ var Vt = [
|
|
|
1249
1249
|
"time_zone",
|
|
1250
1250
|
"continent_code"
|
|
1251
1251
|
];
|
|
1252
|
-
function
|
|
1252
|
+
function Ut(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, Ht);
|
|
1257
1257
|
t && (d = O(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())),
|
|
1264
|
-
if (s?.sort_by && s.sort_by !== "date") throw new
|
|
1265
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
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())), N(n)) {
|
|
1264
|
+
if (s?.sort_by && s.sort_by !== "date") throw new w(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 P(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(L);
|
|
1271
1271
|
return {
|
|
1272
1272
|
logs: a,
|
|
1273
1273
|
start: 0,
|
|
@@ -1282,7 +1282,7 @@ function Ht(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(L);
|
|
1286
1286
|
if (!a) return {
|
|
1287
1287
|
logs: p,
|
|
1288
1288
|
start: 0,
|
|
@@ -1300,24 +1300,24 @@ function Ht(e) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
//#endregion
|
|
1302
1302
|
//#region src/logs/get.ts
|
|
1303
|
-
function
|
|
1303
|
+
function Wt(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 ? L(r) : null;
|
|
1307
1307
|
};
|
|
1308
1308
|
}
|
|
1309
1309
|
//#endregion
|
|
1310
1310
|
//#region src/logs/index.ts
|
|
1311
|
-
function
|
|
1311
|
+
function Gt(e) {
|
|
1312
1312
|
return {
|
|
1313
|
-
create:
|
|
1314
|
-
list:
|
|
1315
|
-
get:
|
|
1313
|
+
create: Bt(e),
|
|
1314
|
+
list: Ut(e),
|
|
1315
|
+
get: Wt(e)
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
1318
|
//#endregion
|
|
1319
1319
|
//#region src/sessions/get.ts
|
|
1320
|
-
function
|
|
1320
|
+
function Kt(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 Gt(e) {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
//#endregion
|
|
1353
1353
|
//#region src/sessions/create.ts
|
|
1354
|
-
function
|
|
1354
|
+
function qt(e) {
|
|
1355
1355
|
return async (t, n) => {
|
|
1356
1356
|
let r = Date.now(), i = c(), a = {
|
|
1357
1357
|
...n,
|
|
@@ -1383,12 +1383,12 @@ function Kt(e) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
//#endregion
|
|
1385
1385
|
//#region src/sessions/remove.ts
|
|
1386
|
-
function
|
|
1386
|
+
function Jt(e) {
|
|
1387
1387
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1388
1388
|
}
|
|
1389
1389
|
//#endregion
|
|
1390
1390
|
//#region src/sessions/update.ts
|
|
1391
|
-
function
|
|
1391
|
+
function Yt(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 Jt(e) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
//#endregion
|
|
1411
1411
|
//#region src/sessions/list.ts
|
|
1412
|
-
function
|
|
1412
|
+
function Xt(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 = O(e, u, l, ["user_id", "session_id"]));
|
|
@@ -1464,18 +1464,18 @@ function Yt(e) {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
//#endregion
|
|
1466
1466
|
//#region src/sessions/index.ts
|
|
1467
|
-
function
|
|
1467
|
+
function Zt(e) {
|
|
1468
1468
|
return {
|
|
1469
|
-
create:
|
|
1470
|
-
get:
|
|
1471
|
-
list:
|
|
1472
|
-
remove:
|
|
1473
|
-
update:
|
|
1469
|
+
create: qt(e),
|
|
1470
|
+
get: Kt(e),
|
|
1471
|
+
list: Xt(e),
|
|
1472
|
+
remove: Jt(e),
|
|
1473
|
+
update: Yt(e)
|
|
1474
1474
|
};
|
|
1475
1475
|
}
|
|
1476
1476
|
//#endregion
|
|
1477
1477
|
//#region src/passwords/get.ts
|
|
1478
|
-
function
|
|
1478
|
+
function Qt(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 Zt(e) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
//#endregion
|
|
1490
1490
|
//#region src/passwords/create.ts
|
|
1491
|
-
function
|
|
1491
|
+
function $t(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 Qt(e) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
//#endregion
|
|
1508
1508
|
//#region src/passwords/update.ts
|
|
1509
|
-
function
|
|
1509
|
+
function en(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 $t(e) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/passwords/list.ts
|
|
1522
|
-
function
|
|
1522
|
+
function tn(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 en(e) {
|
|
|
1530
1530
|
}
|
|
1531
1531
|
//#endregion
|
|
1532
1532
|
//#region src/passwords/index.ts
|
|
1533
|
-
function
|
|
1533
|
+
function nn(e) {
|
|
1534
1534
|
return {
|
|
1535
|
-
create:
|
|
1536
|
-
update:
|
|
1537
|
-
get:
|
|
1538
|
-
list:
|
|
1535
|
+
create: $t(e),
|
|
1536
|
+
update: en(e),
|
|
1537
|
+
get: Qt(e),
|
|
1538
|
+
list: tn(e)
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
1541
|
//#endregion
|
|
1542
1542
|
//#region src/codes/list.ts
|
|
1543
|
-
function
|
|
1543
|
+
function rn(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 = O(e, c, s, ["code", "login_id"]));
|
|
@@ -1565,13 +1565,13 @@ function nn(e) {
|
|
|
1565
1565
|
}
|
|
1566
1566
|
//#endregion
|
|
1567
1567
|
//#region src/codes/expires-at-ts.ts
|
|
1568
|
-
function
|
|
1568
|
+
function an(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 on(e) {
|
|
1575
1575
|
return async (t, n) => {
|
|
1576
1576
|
let r = {
|
|
1577
1577
|
...n,
|
|
@@ -1580,18 +1580,18 @@ function an(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: an(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 sn(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 cn(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 sn(e) {
|
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
1603
|
//#region src/codes/used.ts
|
|
1604
|
-
function
|
|
1604
|
+
function ln(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 un(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 R = 5e4;
|
|
1615
|
+
async function dn(e, t) {
|
|
1616
1616
|
if (!t) return e();
|
|
1617
|
-
let n = 0, r =
|
|
1618
|
-
for (; r >=
|
|
1617
|
+
let n = 0, r = R;
|
|
1618
|
+
for (; r >= R;) r = await e(R), n += r;
|
|
1619
1619
|
return n;
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1621
|
+
function fn(e) {
|
|
1622
1622
|
let t;
|
|
1623
1623
|
return async (n) => {
|
|
1624
1624
|
t ??= await Je(e);
|
|
1625
1625
|
let r = t === "mysql";
|
|
1626
|
-
return await
|
|
1627
|
-
let r = e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1626
|
+
return await dn(async (t) => {
|
|
1627
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "<", an(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 dn(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,26 +1638,26 @@ function dn(e) {
|
|
|
1638
1638
|
}
|
|
1639
1639
|
//#endregion
|
|
1640
1640
|
//#region src/codes/index.ts
|
|
1641
|
-
function
|
|
1641
|
+
function pn(e) {
|
|
1642
1642
|
return {
|
|
1643
|
-
create:
|
|
1644
|
-
list:
|
|
1645
|
-
remove:
|
|
1646
|
-
used:
|
|
1647
|
-
consume:
|
|
1648
|
-
get:
|
|
1649
|
-
cleanup:
|
|
1643
|
+
create: on(e),
|
|
1644
|
+
list: rn(e),
|
|
1645
|
+
remove: sn(e),
|
|
1646
|
+
used: ln(e),
|
|
1647
|
+
consume: un(e),
|
|
1648
|
+
get: cn(e),
|
|
1649
|
+
cleanup: fn(e)
|
|
1650
1650
|
};
|
|
1651
1651
|
}
|
|
1652
1652
|
//#endregion
|
|
1653
1653
|
//#region src/connections/create.ts
|
|
1654
|
-
function
|
|
1654
|
+
function mn(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;
|
|
1658
1658
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1659
1659
|
...o,
|
|
1660
|
-
id: i?.id ?? o.id ??
|
|
1660
|
+
id: i?.id ?? o.id ?? Ae(),
|
|
1661
1661
|
is_system: a ? !0 : void 0,
|
|
1662
1662
|
created_at: i?.created_at ?? s,
|
|
1663
1663
|
updated_at: i?.updated_at ?? s
|
|
@@ -1672,7 +1672,7 @@ function pn(e) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
//#endregion
|
|
1674
1674
|
//#region src/connections/transform.ts
|
|
1675
|
-
function
|
|
1675
|
+
function z(e) {
|
|
1676
1676
|
let { is_system: t, ...n } = e;
|
|
1677
1677
|
return l({
|
|
1678
1678
|
...n,
|
|
@@ -1681,14 +1681,27 @@ function mn(e) {
|
|
|
1681
1681
|
});
|
|
1682
1682
|
}
|
|
1683
1683
|
function hn(e) {
|
|
1684
|
-
return e.map(
|
|
1684
|
+
return e.map(z);
|
|
1685
1685
|
}
|
|
1686
1686
|
//#endregion
|
|
1687
1687
|
//#region src/connections/list.ts
|
|
1688
1688
|
function gn(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
|
-
s && (c = O(e, c, s, ["user_id", "ip"]))
|
|
1691
|
+
if (s && (c = O(e, c, s, ["user_id", "ip"])), N(n)) {
|
|
1692
|
+
let { rows: e, limit: t, next: r } = await P(c.selectAll(), n, {
|
|
1693
|
+
sortColumn: "created_at",
|
|
1694
|
+
sortOrder: "desc",
|
|
1695
|
+
idColumn: "id"
|
|
1696
|
+
}), i = hn(e);
|
|
1697
|
+
return {
|
|
1698
|
+
connections: i,
|
|
1699
|
+
start: 0,
|
|
1700
|
+
limit: t,
|
|
1701
|
+
length: i.length,
|
|
1702
|
+
next: r
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1692
1705
|
let l = hn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1693
1706
|
if (!a) return {
|
|
1694
1707
|
connections: l,
|
|
@@ -1715,7 +1728,7 @@ function _n(e) {
|
|
|
1715
1728
|
function vn(e) {
|
|
1716
1729
|
return async (t, n) => {
|
|
1717
1730
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1718
|
-
return r ?
|
|
1731
|
+
return r ? z(r) : null;
|
|
1719
1732
|
};
|
|
1720
1733
|
}
|
|
1721
1734
|
//#endregion
|
|
@@ -1739,7 +1752,7 @@ function yn(e) {
|
|
|
1739
1752
|
//#region src/connections/index.ts
|
|
1740
1753
|
function bn(e) {
|
|
1741
1754
|
return {
|
|
1742
|
-
create:
|
|
1755
|
+
create: mn(e),
|
|
1743
1756
|
get: vn(e),
|
|
1744
1757
|
list: gn(e),
|
|
1745
1758
|
remove: _n(e),
|
|
@@ -1947,7 +1960,7 @@ function Tn(e) {
|
|
|
1947
1960
|
if (t.length !== 1) return null;
|
|
1948
1961
|
let n = t[0].match(/^([a-zA-Z_][a-zA-Z0-9_]*):(.+)$/);
|
|
1949
1962
|
if (!n) return null;
|
|
1950
|
-
let r =
|
|
1963
|
+
let r = C(n[2]);
|
|
1951
1964
|
return r ? {
|
|
1952
1965
|
field: n[1],
|
|
1953
1966
|
value: r
|
|
@@ -1963,8 +1976,8 @@ function En(e) {
|
|
|
1963
1976
|
r = r.where(t, "=", e.value);
|
|
1964
1977
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1965
1978
|
}
|
|
1966
|
-
if (
|
|
1967
|
-
let { rows: e, limit: t, next: i } = await
|
|
1979
|
+
if (N(n)) {
|
|
1980
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
1968
1981
|
sortColumn: "created_at",
|
|
1969
1982
|
sortOrder: "desc",
|
|
1970
1983
|
idColumn: "client_id"
|
|
@@ -2085,7 +2098,7 @@ function An(e) {
|
|
|
2085
2098
|
if (!r) return [];
|
|
2086
2099
|
let i = JSON.parse(r.connections || "[]");
|
|
2087
2100
|
if (i.length === 0) return [];
|
|
2088
|
-
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,
|
|
2101
|
+
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, z(e)]));
|
|
2089
2102
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2090
2103
|
};
|
|
2091
2104
|
}
|
|
@@ -2215,8 +2228,8 @@ function zn(e) {
|
|
|
2215
2228
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2216
2229
|
} else l = O(e, l, t, []);
|
|
2217
2230
|
}
|
|
2218
|
-
if (
|
|
2219
|
-
let { rows: e, limit: t, next: r } = await
|
|
2231
|
+
if (N(n)) {
|
|
2232
|
+
let { rows: e, limit: t, next: r } = await P(l.selectAll(), n, {
|
|
2220
2233
|
sortColumn: "created_at",
|
|
2221
2234
|
sortOrder: "desc"
|
|
2222
2235
|
}), i = e.map(Rn);
|
|
@@ -2324,7 +2337,7 @@ function Gn(e) {
|
|
|
2324
2337
|
}
|
|
2325
2338
|
return oe(t) ? t : void 0;
|
|
2326
2339
|
}
|
|
2327
|
-
function
|
|
2340
|
+
function B(e) {
|
|
2328
2341
|
return {
|
|
2329
2342
|
id: e.id,
|
|
2330
2343
|
token_hash: e.token_hash,
|
|
@@ -2341,38 +2354,38 @@ function Kn(e) {
|
|
|
2341
2354
|
}
|
|
2342
2355
|
//#endregion
|
|
2343
2356
|
//#region src/clientRegistrationTokens/get.ts
|
|
2344
|
-
function
|
|
2357
|
+
function Kn(e) {
|
|
2345
2358
|
return async (t, n) => {
|
|
2346
2359
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2347
|
-
return r ?
|
|
2360
|
+
return r ? B(r) : null;
|
|
2348
2361
|
};
|
|
2349
2362
|
}
|
|
2350
2363
|
//#endregion
|
|
2351
2364
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2352
|
-
function
|
|
2365
|
+
function qn(e) {
|
|
2353
2366
|
return async (t, n) => {
|
|
2354
2367
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2355
|
-
return r ?
|
|
2368
|
+
return r ? B(r) : null;
|
|
2356
2369
|
};
|
|
2357
2370
|
}
|
|
2358
2371
|
//#endregion
|
|
2359
2372
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2360
|
-
function
|
|
2361
|
-
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(
|
|
2373
|
+
function Jn(e) {
|
|
2374
|
+
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(B);
|
|
2362
2375
|
}
|
|
2363
2376
|
//#endregion
|
|
2364
2377
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2365
|
-
function
|
|
2378
|
+
function Yn(e) {
|
|
2366
2379
|
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;
|
|
2367
2380
|
}
|
|
2368
2381
|
//#endregion
|
|
2369
2382
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2370
|
-
function
|
|
2383
|
+
function Xn(e) {
|
|
2371
2384
|
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;
|
|
2372
2385
|
}
|
|
2373
2386
|
//#endregion
|
|
2374
2387
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2375
|
-
function
|
|
2388
|
+
function Zn(e) {
|
|
2376
2389
|
return async (t, n, r) => {
|
|
2377
2390
|
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();
|
|
2378
2391
|
return Number(i.numUpdatedRows);
|
|
@@ -2380,26 +2393,26 @@ function Qn(e) {
|
|
|
2380
2393
|
}
|
|
2381
2394
|
//#endregion
|
|
2382
2395
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2383
|
-
function
|
|
2396
|
+
function Qn(e) {
|
|
2384
2397
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2385
2398
|
}
|
|
2386
2399
|
//#endregion
|
|
2387
2400
|
//#region src/clientRegistrationTokens/index.ts
|
|
2388
|
-
function
|
|
2401
|
+
function $n(e) {
|
|
2389
2402
|
return {
|
|
2390
2403
|
create: Un(e),
|
|
2391
|
-
get:
|
|
2392
|
-
getByHash:
|
|
2393
|
-
listByClient:
|
|
2394
|
-
markUsed:
|
|
2395
|
-
revoke:
|
|
2396
|
-
revokeByClient:
|
|
2397
|
-
remove:
|
|
2404
|
+
get: Kn(e),
|
|
2405
|
+
getByHash: qn(e),
|
|
2406
|
+
listByClient: Jn(e),
|
|
2407
|
+
markUsed: Yn(e),
|
|
2408
|
+
revoke: Xn(e),
|
|
2409
|
+
revokeByClient: Zn(e),
|
|
2410
|
+
remove: Qn(e)
|
|
2398
2411
|
};
|
|
2399
2412
|
}
|
|
2400
2413
|
//#endregion
|
|
2401
2414
|
//#region src/keys/list.ts
|
|
2402
|
-
function
|
|
2415
|
+
function er(e) {
|
|
2403
2416
|
return async (t = {}) => {
|
|
2404
2417
|
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)]));
|
|
2405
2418
|
s && (c = O(e, c, s, [
|
|
@@ -2428,7 +2441,7 @@ function tr(e) {
|
|
|
2428
2441
|
}
|
|
2429
2442
|
//#endregion
|
|
2430
2443
|
//#region src/keys/create.ts
|
|
2431
|
-
function
|
|
2444
|
+
function tr(e) {
|
|
2432
2445
|
return async (t, n) => {
|
|
2433
2446
|
let r = n?.importMetadata;
|
|
2434
2447
|
await e.insertInto("keys").values({
|
|
@@ -2440,21 +2453,21 @@ function nr(e) {
|
|
|
2440
2453
|
}
|
|
2441
2454
|
//#endregion
|
|
2442
2455
|
//#region src/keys/update.ts
|
|
2443
|
-
function
|
|
2456
|
+
function nr(e) {
|
|
2444
2457
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2445
2458
|
}
|
|
2446
2459
|
//#endregion
|
|
2447
2460
|
//#region src/keys/index.ts
|
|
2448
|
-
function
|
|
2461
|
+
function rr(e) {
|
|
2449
2462
|
return {
|
|
2450
|
-
create:
|
|
2451
|
-
list:
|
|
2452
|
-
update:
|
|
2463
|
+
create: tr(e),
|
|
2464
|
+
list: er(e),
|
|
2465
|
+
update: nr(e)
|
|
2453
2466
|
};
|
|
2454
2467
|
}
|
|
2455
2468
|
//#endregion
|
|
2456
2469
|
//#region src/customDomains/create.ts
|
|
2457
|
-
function
|
|
2470
|
+
function ir(e) {
|
|
2458
2471
|
return async (n, r, i) => {
|
|
2459
2472
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2460
2473
|
status: "pending",
|
|
@@ -2475,35 +2488,35 @@ function ar(e) {
|
|
|
2475
2488
|
}
|
|
2476
2489
|
//#endregion
|
|
2477
2490
|
//#region src/customDomains/list.ts
|
|
2478
|
-
function
|
|
2491
|
+
function ar(e) {
|
|
2479
2492
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2480
2493
|
...e,
|
|
2481
2494
|
primary: e.primary === 1,
|
|
2482
|
-
domain_metadata:
|
|
2483
|
-
verification:
|
|
2495
|
+
domain_metadata: I(e.domain_metadata, void 0),
|
|
2496
|
+
verification: I(e.verification, void 0)
|
|
2484
2497
|
}));
|
|
2485
2498
|
}
|
|
2486
2499
|
//#endregion
|
|
2487
2500
|
//#region src/customDomains/remove.ts
|
|
2488
|
-
function
|
|
2501
|
+
function or(e) {
|
|
2489
2502
|
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;
|
|
2490
2503
|
}
|
|
2491
2504
|
//#endregion
|
|
2492
2505
|
//#region src/customDomains/get.ts
|
|
2493
|
-
function
|
|
2506
|
+
function sr(e) {
|
|
2494
2507
|
return async (t, n) => {
|
|
2495
2508
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2496
2509
|
return r ? {
|
|
2497
2510
|
...r,
|
|
2498
2511
|
primary: r.primary === 1,
|
|
2499
|
-
domain_metadata:
|
|
2500
|
-
verification:
|
|
2512
|
+
domain_metadata: I(r.domain_metadata, void 0),
|
|
2513
|
+
verification: I(r.verification, void 0)
|
|
2501
2514
|
} : null;
|
|
2502
2515
|
};
|
|
2503
2516
|
}
|
|
2504
2517
|
//#endregion
|
|
2505
2518
|
//#region src/customDomains/update.ts
|
|
2506
|
-
function
|
|
2519
|
+
function cr(e) {
|
|
2507
2520
|
return async (t, n, r) => {
|
|
2508
2521
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2509
2522
|
...s,
|
|
@@ -2517,32 +2530,32 @@ function lr(e) {
|
|
|
2517
2530
|
}
|
|
2518
2531
|
//#endregion
|
|
2519
2532
|
//#region src/customDomains/getByDomain.ts
|
|
2520
|
-
function
|
|
2533
|
+
function lr(e) {
|
|
2521
2534
|
return async (t) => {
|
|
2522
2535
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2523
2536
|
return n ? {
|
|
2524
2537
|
...n,
|
|
2525
2538
|
primary: n.primary === 1,
|
|
2526
|
-
domain_metadata:
|
|
2527
|
-
verification:
|
|
2539
|
+
domain_metadata: I(n.domain_metadata, void 0),
|
|
2540
|
+
verification: I(n.verification, void 0)
|
|
2528
2541
|
} : null;
|
|
2529
2542
|
};
|
|
2530
2543
|
}
|
|
2531
2544
|
//#endregion
|
|
2532
2545
|
//#region src/customDomains/index.ts
|
|
2533
|
-
function
|
|
2546
|
+
function ur(e) {
|
|
2534
2547
|
return {
|
|
2535
|
-
create:
|
|
2536
|
-
get:
|
|
2537
|
-
getByDomain:
|
|
2538
|
-
list:
|
|
2539
|
-
remove:
|
|
2540
|
-
update:
|
|
2548
|
+
create: ir(e),
|
|
2549
|
+
get: sr(e),
|
|
2550
|
+
getByDomain: lr(e),
|
|
2551
|
+
list: ar(e),
|
|
2552
|
+
remove: or(e),
|
|
2553
|
+
update: cr(e)
|
|
2541
2554
|
};
|
|
2542
2555
|
}
|
|
2543
2556
|
//#endregion
|
|
2544
2557
|
//#region src/branding/get.ts
|
|
2545
|
-
function
|
|
2558
|
+
function dr(e) {
|
|
2546
2559
|
return async (t) => {
|
|
2547
2560
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2548
2561
|
if (!n) return null;
|
|
@@ -2564,7 +2577,7 @@ function fr(e) {
|
|
|
2564
2577
|
}
|
|
2565
2578
|
//#endregion
|
|
2566
2579
|
//#region src/branding/set.ts
|
|
2567
|
-
function
|
|
2580
|
+
function fr(e) {
|
|
2568
2581
|
return async (t, n) => {
|
|
2569
2582
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2570
2583
|
try {
|
|
@@ -2593,15 +2606,15 @@ function pr(e) {
|
|
|
2593
2606
|
}
|
|
2594
2607
|
//#endregion
|
|
2595
2608
|
//#region src/branding/index.ts
|
|
2596
|
-
function
|
|
2609
|
+
function pr(e) {
|
|
2597
2610
|
return {
|
|
2598
|
-
get:
|
|
2599
|
-
set:
|
|
2611
|
+
get: dr(e),
|
|
2612
|
+
set: fr(e)
|
|
2600
2613
|
};
|
|
2601
2614
|
}
|
|
2602
2615
|
//#endregion
|
|
2603
2616
|
//#region src/universalLoginTemplates/get.ts
|
|
2604
|
-
function
|
|
2617
|
+
function mr(e) {
|
|
2605
2618
|
return async (t) => {
|
|
2606
2619
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2607
2620
|
return n ? { body: n.body } : null;
|
|
@@ -2609,7 +2622,7 @@ function hr(e) {
|
|
|
2609
2622
|
}
|
|
2610
2623
|
//#endregion
|
|
2611
2624
|
//#region src/universalLoginTemplates/set.ts
|
|
2612
|
-
function
|
|
2625
|
+
function hr(e) {
|
|
2613
2626
|
return async (t, n, r) => {
|
|
2614
2627
|
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;
|
|
2615
2628
|
try {
|
|
@@ -2630,23 +2643,23 @@ function gr(e) {
|
|
|
2630
2643
|
}
|
|
2631
2644
|
//#endregion
|
|
2632
2645
|
//#region src/universalLoginTemplates/delete.ts
|
|
2633
|
-
function
|
|
2646
|
+
function gr(e) {
|
|
2634
2647
|
return async (t) => {
|
|
2635
2648
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2636
2649
|
};
|
|
2637
2650
|
}
|
|
2638
2651
|
//#endregion
|
|
2639
2652
|
//#region src/universalLoginTemplates/index.ts
|
|
2640
|
-
function
|
|
2653
|
+
function _r(e) {
|
|
2641
2654
|
return {
|
|
2642
|
-
get:
|
|
2643
|
-
set:
|
|
2644
|
-
delete:
|
|
2655
|
+
get: mr(e),
|
|
2656
|
+
set: hr(e),
|
|
2657
|
+
delete: gr(e)
|
|
2645
2658
|
};
|
|
2646
2659
|
}
|
|
2647
2660
|
//#endregion
|
|
2648
2661
|
//#region src/hooks/list.ts
|
|
2649
|
-
function
|
|
2662
|
+
function vr(e) {
|
|
2650
2663
|
return async (t, n = {}) => {
|
|
2651
2664
|
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);
|
|
2652
2665
|
if (u && (d = O(e, d, u, [
|
|
@@ -2668,7 +2681,7 @@ function yr(e) {
|
|
|
2668
2681
|
...u,
|
|
2669
2682
|
enabled: !!n,
|
|
2670
2683
|
synchronous: !!i,
|
|
2671
|
-
metadata:
|
|
2684
|
+
metadata: Ct(s)
|
|
2672
2685
|
});
|
|
2673
2686
|
});
|
|
2674
2687
|
if (!s) return {
|
|
@@ -2688,7 +2701,7 @@ function yr(e) {
|
|
|
2688
2701
|
}
|
|
2689
2702
|
//#endregion
|
|
2690
2703
|
//#region src/hooks/get.ts
|
|
2691
|
-
function
|
|
2704
|
+
function yr(e) {
|
|
2692
2705
|
return async (t, n) => {
|
|
2693
2706
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2694
2707
|
if (!i) return null;
|
|
@@ -2701,20 +2714,20 @@ function br(e) {
|
|
|
2701
2714
|
...d,
|
|
2702
2715
|
enabled: !!u.enabled,
|
|
2703
2716
|
synchronous: !!u.synchronous,
|
|
2704
|
-
metadata:
|
|
2717
|
+
metadata: Ct(c)
|
|
2705
2718
|
});
|
|
2706
2719
|
};
|
|
2707
2720
|
}
|
|
2708
2721
|
//#endregion
|
|
2709
2722
|
//#region src/hooks/remove.ts
|
|
2710
|
-
function
|
|
2723
|
+
function br(e) {
|
|
2711
2724
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2712
2725
|
}
|
|
2713
2726
|
//#endregion
|
|
2714
2727
|
//#region src/hooks/create.ts
|
|
2715
|
-
function
|
|
2728
|
+
function xr(e) {
|
|
2716
2729
|
return async (t, n, r) => {
|
|
2717
|
-
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 ||
|
|
2730
|
+
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 || Ne()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2718
2731
|
return await e.insertInto("hooks").values({
|
|
2719
2732
|
...p,
|
|
2720
2733
|
hook_id: c,
|
|
@@ -2737,7 +2750,7 @@ function Sr(e) {
|
|
|
2737
2750
|
}
|
|
2738
2751
|
//#endregion
|
|
2739
2752
|
//#region src/hooks/update.ts
|
|
2740
|
-
function
|
|
2753
|
+
function Sr(e) {
|
|
2741
2754
|
return async (t, n, r) => {
|
|
2742
2755
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2743
2756
|
...o,
|
|
@@ -2751,20 +2764,20 @@ function Cr(e) {
|
|
|
2751
2764
|
}
|
|
2752
2765
|
//#endregion
|
|
2753
2766
|
//#region src/hooks/index.ts
|
|
2754
|
-
function
|
|
2767
|
+
function Cr(e) {
|
|
2755
2768
|
return {
|
|
2756
|
-
create:
|
|
2757
|
-
get:
|
|
2758
|
-
list:
|
|
2759
|
-
update:
|
|
2760
|
-
remove:
|
|
2769
|
+
create: xr(e),
|
|
2770
|
+
get: yr(e),
|
|
2771
|
+
list: vr(e),
|
|
2772
|
+
update: Sr(e),
|
|
2773
|
+
remove: br(e)
|
|
2761
2774
|
};
|
|
2762
2775
|
}
|
|
2763
2776
|
//#endregion
|
|
2764
2777
|
//#region src/hook-code/create.ts
|
|
2765
|
-
function
|
|
2778
|
+
function wr(e) {
|
|
2766
2779
|
return async (t, n, r) => {
|
|
2767
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2780
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Fe();
|
|
2768
2781
|
return await e.insertInto("hook_code").values({
|
|
2769
2782
|
id: c,
|
|
2770
2783
|
tenant_id: t,
|
|
@@ -2784,7 +2797,7 @@ function Tr(e) {
|
|
|
2784
2797
|
}
|
|
2785
2798
|
//#endregion
|
|
2786
2799
|
//#region src/hook-code/get.ts
|
|
2787
|
-
function
|
|
2800
|
+
function Tr(e) {
|
|
2788
2801
|
return async (t, n) => {
|
|
2789
2802
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2790
2803
|
if (!i) return null;
|
|
@@ -2808,7 +2821,7 @@ function Er(e) {
|
|
|
2808
2821
|
}
|
|
2809
2822
|
//#endregion
|
|
2810
2823
|
//#region src/hook-code/update.ts
|
|
2811
|
-
function
|
|
2824
|
+
function Er(e) {
|
|
2812
2825
|
return async (t, n, r) => {
|
|
2813
2826
|
let i = { updated_at_ts: Date.now() };
|
|
2814
2827
|
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;
|
|
@@ -2816,22 +2829,22 @@ function Dr(e) {
|
|
|
2816
2829
|
}
|
|
2817
2830
|
//#endregion
|
|
2818
2831
|
//#region src/hook-code/remove.ts
|
|
2819
|
-
function
|
|
2832
|
+
function Dr(e) {
|
|
2820
2833
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2821
2834
|
}
|
|
2822
2835
|
//#endregion
|
|
2823
2836
|
//#region src/hook-code/index.ts
|
|
2824
|
-
function
|
|
2837
|
+
function Or(e) {
|
|
2825
2838
|
return {
|
|
2826
|
-
create:
|
|
2827
|
-
get:
|
|
2828
|
-
update:
|
|
2829
|
-
remove:
|
|
2839
|
+
create: wr(e),
|
|
2840
|
+
get: Tr(e),
|
|
2841
|
+
update: Er(e),
|
|
2842
|
+
remove: Dr(e)
|
|
2830
2843
|
};
|
|
2831
2844
|
}
|
|
2832
2845
|
//#endregion
|
|
2833
2846
|
//#region src/themes/create.ts
|
|
2834
|
-
function
|
|
2847
|
+
function kr(e) {
|
|
2835
2848
|
return async (n, r, i, a) => {
|
|
2836
2849
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2837
2850
|
themeId: o?.id || i || t(),
|
|
@@ -2842,20 +2855,20 @@ function Ar(e) {
|
|
|
2842
2855
|
...c,
|
|
2843
2856
|
tenant_id: n
|
|
2844
2857
|
};
|
|
2845
|
-
return await e.insertInto("themes").values(
|
|
2858
|
+
return await e.insertInto("themes").values(F(l)).execute(), c;
|
|
2846
2859
|
};
|
|
2847
2860
|
}
|
|
2848
2861
|
//#endregion
|
|
2849
2862
|
//#region src/themes/remove.ts
|
|
2850
|
-
function
|
|
2863
|
+
function Ar(e) {
|
|
2851
2864
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2852
2865
|
}
|
|
2853
2866
|
//#endregion
|
|
2854
2867
|
//#region src/themes/get.ts
|
|
2855
|
-
function
|
|
2868
|
+
function jr(e) {
|
|
2856
2869
|
return async (t, n) => {
|
|
2857
2870
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2858
|
-
return r ? l(
|
|
2871
|
+
return r ? l(ht({
|
|
2859
2872
|
...r,
|
|
2860
2873
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2861
2874
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2875,9 +2888,9 @@ function Mr(e) {
|
|
|
2875
2888
|
}
|
|
2876
2889
|
//#endregion
|
|
2877
2890
|
//#region src/themes/update.ts
|
|
2878
|
-
function
|
|
2891
|
+
function Mr(e) {
|
|
2879
2892
|
return async (t, n, r) => {
|
|
2880
|
-
let { themeId: i, ...a } = r, o =
|
|
2893
|
+
let { themeId: i, ...a } = r, o = F({
|
|
2881
2894
|
...a,
|
|
2882
2895
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2883
2896
|
});
|
|
@@ -2886,17 +2899,17 @@ function Nr(e) {
|
|
|
2886
2899
|
}
|
|
2887
2900
|
//#endregion
|
|
2888
2901
|
//#region src/themes/index.ts
|
|
2889
|
-
function
|
|
2902
|
+
function Nr(e) {
|
|
2890
2903
|
return {
|
|
2891
|
-
create:
|
|
2892
|
-
get:
|
|
2893
|
-
remove:
|
|
2894
|
-
update:
|
|
2904
|
+
create: kr(e),
|
|
2905
|
+
get: jr(e),
|
|
2906
|
+
remove: Ar(e),
|
|
2907
|
+
update: Mr(e)
|
|
2895
2908
|
};
|
|
2896
2909
|
}
|
|
2897
2910
|
//#endregion
|
|
2898
2911
|
//#region src/loginSessions/get.ts
|
|
2899
|
-
function
|
|
2912
|
+
function Pr(e) {
|
|
2900
2913
|
return async (t, n) => {
|
|
2901
2914
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2902
2915
|
if (!i) return null;
|
|
@@ -2908,7 +2921,7 @@ function Fr(e) {
|
|
|
2908
2921
|
"created_at_ts",
|
|
2909
2922
|
"updated_at_ts",
|
|
2910
2923
|
"expires_at_ts"
|
|
2911
|
-
]), f =
|
|
2924
|
+
]), f = ht(l({
|
|
2912
2925
|
...u,
|
|
2913
2926
|
...d,
|
|
2914
2927
|
state: i.state || p.PENDING,
|
|
@@ -2920,28 +2933,28 @@ function Fr(e) {
|
|
|
2920
2933
|
}
|
|
2921
2934
|
//#endregion
|
|
2922
2935
|
//#region src/utils/ulid.ts
|
|
2923
|
-
var
|
|
2924
|
-
function
|
|
2936
|
+
var Fr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", V = 32, Ir = 10, Lr = 16;
|
|
2937
|
+
function Rr(e) {
|
|
2925
2938
|
let t = "";
|
|
2926
|
-
for (let n =
|
|
2939
|
+
for (let n = Ir; n > 0; n--) t = Fr.charAt(e % V) + t, e = Math.floor(e / V);
|
|
2927
2940
|
return t;
|
|
2928
2941
|
}
|
|
2929
|
-
function
|
|
2930
|
-
let e = new Uint8Array(
|
|
2942
|
+
function zr() {
|
|
2943
|
+
let e = new Uint8Array(Lr);
|
|
2931
2944
|
crypto.getRandomValues(e);
|
|
2932
2945
|
let t = "";
|
|
2933
|
-
for (let n = 0; n <
|
|
2946
|
+
for (let n = 0; n < Lr; n++) t += Fr.charAt(e[n] % V);
|
|
2934
2947
|
return t;
|
|
2935
2948
|
}
|
|
2936
|
-
function
|
|
2937
|
-
return
|
|
2949
|
+
function Br() {
|
|
2950
|
+
return Rr(Date.now()) + zr();
|
|
2938
2951
|
}
|
|
2939
2952
|
//#endregion
|
|
2940
2953
|
//#region src/loginSessions/create.ts
|
|
2941
|
-
function
|
|
2954
|
+
function Vr(e) {
|
|
2942
2955
|
return async (t, n) => {
|
|
2943
2956
|
let r = c(), i = {
|
|
2944
|
-
id:
|
|
2957
|
+
id: Br(),
|
|
2945
2958
|
...n,
|
|
2946
2959
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2947
2960
|
created_at: r,
|
|
@@ -2949,7 +2962,7 @@ function Ur(e) {
|
|
|
2949
2962
|
state: n.state || p.PENDING,
|
|
2950
2963
|
state_data: n.state_data,
|
|
2951
2964
|
failure_reason: n.failure_reason
|
|
2952
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2965
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = F(o);
|
|
2953
2966
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2954
2967
|
...l,
|
|
2955
2968
|
tenant_id: t,
|
|
@@ -2962,7 +2975,7 @@ function Ur(e) {
|
|
|
2962
2975
|
}
|
|
2963
2976
|
//#endregion
|
|
2964
2977
|
//#region src/loginSessions/update.ts
|
|
2965
|
-
function
|
|
2978
|
+
function Hr(e) {
|
|
2966
2979
|
return async (t, n, r) => {
|
|
2967
2980
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2968
2981
|
if (c !== void 0) {
|
|
@@ -2972,7 +2985,7 @@ function Wr(e) {
|
|
|
2972
2985
|
...c
|
|
2973
2986
|
}) };
|
|
2974
2987
|
}
|
|
2975
|
-
let d =
|
|
2988
|
+
let d = F(l);
|
|
2976
2989
|
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({
|
|
2977
2990
|
...d,
|
|
2978
2991
|
...u,
|
|
@@ -2983,22 +2996,22 @@ function Wr(e) {
|
|
|
2983
2996
|
}
|
|
2984
2997
|
//#endregion
|
|
2985
2998
|
//#region src/loginSessions/remove.ts
|
|
2986
|
-
function
|
|
2999
|
+
function Ur(e) {
|
|
2987
3000
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2988
3001
|
}
|
|
2989
3002
|
//#endregion
|
|
2990
3003
|
//#region src/loginSessions/index.ts
|
|
2991
|
-
function
|
|
3004
|
+
function Wr(e) {
|
|
2992
3005
|
return {
|
|
2993
|
-
create:
|
|
2994
|
-
get:
|
|
2995
|
-
update:
|
|
2996
|
-
remove:
|
|
3006
|
+
create: Vr(e),
|
|
3007
|
+
get: Pr(e),
|
|
3008
|
+
update: Hr(e),
|
|
3009
|
+
remove: Ur(e)
|
|
2997
3010
|
};
|
|
2998
3011
|
}
|
|
2999
3012
|
//#endregion
|
|
3000
3013
|
//#region src/promptSettings/get.ts
|
|
3001
|
-
function
|
|
3014
|
+
function Gr(e) {
|
|
3002
3015
|
return async (t) => {
|
|
3003
3016
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
3004
3017
|
return l({
|
|
@@ -3012,13 +3025,13 @@ function qr(e) {
|
|
|
3012
3025
|
}
|
|
3013
3026
|
//#endregion
|
|
3014
3027
|
//#region src/promptSettings/set.ts
|
|
3015
|
-
function
|
|
3028
|
+
function Kr(e) {
|
|
3016
3029
|
let t = {};
|
|
3017
3030
|
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;
|
|
3018
3031
|
}
|
|
3019
|
-
function
|
|
3032
|
+
function qr(e) {
|
|
3020
3033
|
return async (t, n) => {
|
|
3021
|
-
let r =
|
|
3034
|
+
let r = Kr(n);
|
|
3022
3035
|
try {
|
|
3023
3036
|
await e.insertInto("prompt_settings").values({
|
|
3024
3037
|
tenant_id: t,
|
|
@@ -3036,15 +3049,15 @@ function Yr(e) {
|
|
|
3036
3049
|
}
|
|
3037
3050
|
//#endregion
|
|
3038
3051
|
//#region src/promptSettings/index.ts
|
|
3039
|
-
function
|
|
3052
|
+
function Jr(e) {
|
|
3040
3053
|
return {
|
|
3041
|
-
get:
|
|
3042
|
-
set:
|
|
3054
|
+
get: Gr(e),
|
|
3055
|
+
set: qr(e)
|
|
3043
3056
|
};
|
|
3044
3057
|
}
|
|
3045
3058
|
//#endregion
|
|
3046
3059
|
//#region src/emailProvideres/get.ts
|
|
3047
|
-
function
|
|
3060
|
+
function Yr(e) {
|
|
3048
3061
|
return async (t) => {
|
|
3049
3062
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
3050
3063
|
if (!n) return null;
|
|
@@ -3059,7 +3072,7 @@ function Zr(e) {
|
|
|
3059
3072
|
}
|
|
3060
3073
|
//#endregion
|
|
3061
3074
|
//#region src/emailProvideres/update.ts
|
|
3062
|
-
function
|
|
3075
|
+
function Xr(e) {
|
|
3063
3076
|
return async (t, n) => {
|
|
3064
3077
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
3065
3078
|
await e.updateTable("email_providers").set({
|
|
@@ -3072,7 +3085,7 @@ function Qr(e) {
|
|
|
3072
3085
|
}
|
|
3073
3086
|
//#endregion
|
|
3074
3087
|
//#region src/emailProvideres/create.ts
|
|
3075
|
-
function
|
|
3088
|
+
function Zr(e) {
|
|
3076
3089
|
return async (t, n, r) => {
|
|
3077
3090
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
3078
3091
|
await e.insertInto("email_providers").values({
|
|
@@ -3088,24 +3101,24 @@ function $r(e) {
|
|
|
3088
3101
|
}
|
|
3089
3102
|
//#endregion
|
|
3090
3103
|
//#region src/emailProvideres/remove.ts
|
|
3091
|
-
function
|
|
3104
|
+
function Qr(e) {
|
|
3092
3105
|
return async (t) => {
|
|
3093
3106
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3094
3107
|
};
|
|
3095
3108
|
}
|
|
3096
3109
|
//#endregion
|
|
3097
3110
|
//#region src/emailProvideres/index.ts
|
|
3098
|
-
function
|
|
3111
|
+
function $r(e) {
|
|
3099
3112
|
return {
|
|
3100
|
-
get:
|
|
3101
|
-
create:
|
|
3102
|
-
update:
|
|
3103
|
-
remove:
|
|
3113
|
+
get: Yr(e),
|
|
3114
|
+
create: Zr(e),
|
|
3115
|
+
update: Xr(e),
|
|
3116
|
+
remove: Qr(e)
|
|
3104
3117
|
};
|
|
3105
3118
|
}
|
|
3106
3119
|
//#endregion
|
|
3107
3120
|
//#region src/emailTemplates/row.ts
|
|
3108
|
-
function
|
|
3121
|
+
function ei(e) {
|
|
3109
3122
|
let t = {
|
|
3110
3123
|
template: e.template,
|
|
3111
3124
|
body: e.body,
|
|
@@ -3119,20 +3132,20 @@ function ni(e) {
|
|
|
3119
3132
|
}
|
|
3120
3133
|
//#endregion
|
|
3121
3134
|
//#region src/emailTemplates/get.ts
|
|
3122
|
-
function
|
|
3135
|
+
function ti(e) {
|
|
3123
3136
|
return async (t, n) => {
|
|
3124
3137
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3125
|
-
return r ? ne.parse(
|
|
3138
|
+
return r ? ne.parse(ei(r)) : null;
|
|
3126
3139
|
};
|
|
3127
3140
|
}
|
|
3128
3141
|
//#endregion
|
|
3129
3142
|
//#region src/emailTemplates/list.ts
|
|
3130
|
-
function
|
|
3131
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(
|
|
3143
|
+
function ni(e) {
|
|
3144
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(ei(e)));
|
|
3132
3145
|
}
|
|
3133
3146
|
//#endregion
|
|
3134
3147
|
//#region src/emailTemplates/create.ts
|
|
3135
|
-
function
|
|
3148
|
+
function ri(e) {
|
|
3136
3149
|
return async (t, n, r) => {
|
|
3137
3150
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3138
3151
|
return await e.insertInto("email_templates").values({
|
|
@@ -3153,7 +3166,7 @@ function ai(e) {
|
|
|
3153
3166
|
}
|
|
3154
3167
|
//#endregion
|
|
3155
3168
|
//#region src/emailTemplates/update.ts
|
|
3156
|
-
function
|
|
3169
|
+
function ii(e) {
|
|
3157
3170
|
return async (t, n, r) => {
|
|
3158
3171
|
let i = {};
|
|
3159
3172
|
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;
|
|
@@ -3164,7 +3177,7 @@ function oi(e) {
|
|
|
3164
3177
|
}
|
|
3165
3178
|
//#endregion
|
|
3166
3179
|
//#region src/emailTemplates/remove.ts
|
|
3167
|
-
function
|
|
3180
|
+
function ai(e) {
|
|
3168
3181
|
return async (t, n) => {
|
|
3169
3182
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3170
3183
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3172,18 +3185,18 @@ function si(e) {
|
|
|
3172
3185
|
}
|
|
3173
3186
|
//#endregion
|
|
3174
3187
|
//#region src/emailTemplates/index.ts
|
|
3175
|
-
function
|
|
3188
|
+
function oi(e) {
|
|
3176
3189
|
return {
|
|
3177
|
-
get:
|
|
3178
|
-
list:
|
|
3179
|
-
create:
|
|
3180
|
-
update:
|
|
3181
|
-
remove:
|
|
3190
|
+
get: ti(e),
|
|
3191
|
+
list: ni(e),
|
|
3192
|
+
create: ri(e),
|
|
3193
|
+
update: ii(e),
|
|
3194
|
+
remove: ai(e)
|
|
3182
3195
|
};
|
|
3183
3196
|
}
|
|
3184
3197
|
//#endregion
|
|
3185
3198
|
//#region src/refreshTokens/to-refresh-token.ts
|
|
3186
|
-
function
|
|
3199
|
+
function H(e) {
|
|
3187
3200
|
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({
|
|
3188
3201
|
created_at_ts: n,
|
|
3189
3202
|
expires_at_ts: i,
|
|
@@ -3212,23 +3225,23 @@ function B(e) {
|
|
|
3212
3225
|
}
|
|
3213
3226
|
//#endregion
|
|
3214
3227
|
//#region src/refreshTokens/get.ts
|
|
3215
|
-
function
|
|
3228
|
+
function si(e) {
|
|
3216
3229
|
return async (t, n) => {
|
|
3217
3230
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3218
|
-
return r ?
|
|
3231
|
+
return r ? H(r) : null;
|
|
3219
3232
|
};
|
|
3220
3233
|
}
|
|
3221
3234
|
//#endregion
|
|
3222
3235
|
//#region src/refreshTokens/getByLookup.ts
|
|
3223
|
-
function
|
|
3236
|
+
function ci(e) {
|
|
3224
3237
|
return async (t, n) => {
|
|
3225
3238
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3226
|
-
return r ?
|
|
3239
|
+
return r ? H(r) : null;
|
|
3227
3240
|
};
|
|
3228
3241
|
}
|
|
3229
3242
|
//#endregion
|
|
3230
3243
|
//#region src/refreshTokens/create.ts
|
|
3231
|
-
function
|
|
3244
|
+
function li(e) {
|
|
3232
3245
|
return async (t, n) => {
|
|
3233
3246
|
let r = c(), i = {
|
|
3234
3247
|
...n,
|
|
@@ -3260,12 +3273,12 @@ function di(e) {
|
|
|
3260
3273
|
}
|
|
3261
3274
|
//#endregion
|
|
3262
3275
|
//#region src/refreshTokens/remove.ts
|
|
3263
|
-
function
|
|
3276
|
+
function ui(e) {
|
|
3264
3277
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3265
3278
|
}
|
|
3266
3279
|
//#endregion
|
|
3267
3280
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3268
|
-
function
|
|
3281
|
+
function di(e) {
|
|
3269
3282
|
return async (t, n, r) => {
|
|
3270
3283
|
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();
|
|
3271
3284
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3273,7 +3286,7 @@ function pi(e) {
|
|
|
3273
3286
|
}
|
|
3274
3287
|
//#endregion
|
|
3275
3288
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3276
|
-
function
|
|
3289
|
+
function fi(e) {
|
|
3277
3290
|
return async (t, n, r) => {
|
|
3278
3291
|
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();
|
|
3279
3292
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3281,7 +3294,7 @@ function mi(e) {
|
|
|
3281
3294
|
}
|
|
3282
3295
|
//#endregion
|
|
3283
3296
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3284
|
-
function
|
|
3297
|
+
function pi(e) {
|
|
3285
3298
|
return async (t, n, r) => {
|
|
3286
3299
|
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();
|
|
3287
3300
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3289,7 +3302,7 @@ function hi(e) {
|
|
|
3289
3302
|
}
|
|
3290
3303
|
//#endregion
|
|
3291
3304
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3292
|
-
function
|
|
3305
|
+
function mi(e) {
|
|
3293
3306
|
return async (t, n, r) => {
|
|
3294
3307
|
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();
|
|
3295
3308
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3297,7 +3310,7 @@ function gi(e) {
|
|
|
3297
3310
|
}
|
|
3298
3311
|
//#endregion
|
|
3299
3312
|
//#region src/refreshTokens/update.ts
|
|
3300
|
-
function
|
|
3313
|
+
function hi(e) {
|
|
3301
3314
|
return async (t, n, r, i) => {
|
|
3302
3315
|
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 = {
|
|
3303
3316
|
...h,
|
|
@@ -3318,14 +3331,14 @@ function _i(e) {
|
|
|
3318
3331
|
}
|
|
3319
3332
|
//#endregion
|
|
3320
3333
|
//#region src/refreshTokens/list.ts
|
|
3321
|
-
function
|
|
3334
|
+
function gi(e) {
|
|
3322
3335
|
return async (t, n = {}) => {
|
|
3323
3336
|
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);
|
|
3324
|
-
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = O(e, u, c, ["token", "login_id"])),
|
|
3325
|
-
let { rows: e, limit: t, next: r } = await
|
|
3337
|
+
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = O(e, u, c, ["token", "login_id"])), N(n)) {
|
|
3338
|
+
let { rows: e, limit: t, next: r } = await P(u.selectAll(), n, {
|
|
3326
3339
|
sortColumn: "created_at_ts",
|
|
3327
3340
|
sortOrder: "desc"
|
|
3328
|
-
}), i = e.map(
|
|
3341
|
+
}), i = e.map(H);
|
|
3329
3342
|
return {
|
|
3330
3343
|
refresh_tokens: i,
|
|
3331
3344
|
start: 0,
|
|
@@ -3340,7 +3353,7 @@ function vi(e) {
|
|
|
3340
3353
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3341
3354
|
}
|
|
3342
3355
|
d = d.offset(r * i).limit(i);
|
|
3343
|
-
let f = (await d.selectAll().execute()).map(
|
|
3356
|
+
let f = (await d.selectAll().execute()).map(H);
|
|
3344
3357
|
if (!a) return {
|
|
3345
3358
|
refresh_tokens: f,
|
|
3346
3359
|
start: 0,
|
|
@@ -3358,34 +3371,34 @@ function vi(e) {
|
|
|
3358
3371
|
}
|
|
3359
3372
|
//#endregion
|
|
3360
3373
|
//#region src/refreshTokens/index.ts
|
|
3361
|
-
function
|
|
3374
|
+
function _i(e) {
|
|
3362
3375
|
return {
|
|
3363
|
-
create:
|
|
3364
|
-
get:
|
|
3365
|
-
getByLookup:
|
|
3366
|
-
list:
|
|
3367
|
-
remove:
|
|
3368
|
-
revokeByLoginSession:
|
|
3369
|
-
revokeBySession:
|
|
3370
|
-
revokeByUser:
|
|
3371
|
-
revokeFamily:
|
|
3372
|
-
update:
|
|
3376
|
+
create: li(e),
|
|
3377
|
+
get: si(e),
|
|
3378
|
+
getByLookup: ci(e),
|
|
3379
|
+
list: gi(e),
|
|
3380
|
+
remove: ui(e),
|
|
3381
|
+
revokeByLoginSession: di(e),
|
|
3382
|
+
revokeBySession: fi(e),
|
|
3383
|
+
revokeByUser: pi(e),
|
|
3384
|
+
revokeFamily: mi(e),
|
|
3385
|
+
update: hi(e)
|
|
3373
3386
|
};
|
|
3374
3387
|
}
|
|
3375
3388
|
//#endregion
|
|
3376
3389
|
//#region src/cleanup.ts
|
|
3377
|
-
var
|
|
3378
|
-
function
|
|
3390
|
+
var vi = 10080 * 60 * 1e3, U = 1e3;
|
|
3391
|
+
function yi(e) {
|
|
3379
3392
|
return async (t) => {
|
|
3380
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3393
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - vi, a = (t) => async () => {
|
|
3381
3394
|
let a = e.deleteFrom("refresh_tokens").where(t, "<", i);
|
|
3382
3395
|
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3383
|
-
let o = await a.limit(
|
|
3396
|
+
let o = await a.limit(U).execute();
|
|
3384
3397
|
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3385
3398
|
}, o = (t) => async () => {
|
|
3386
3399
|
let a = e.deleteFrom("sessions").where(t, "<", i);
|
|
3387
3400
|
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3388
|
-
let o = await a.limit(
|
|
3401
|
+
let o = await a.limit(U).execute();
|
|
3389
3402
|
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3390
3403
|
}, s = [
|
|
3391
3404
|
{
|
|
@@ -3394,7 +3407,7 @@ function xi(e) {
|
|
|
3394
3407
|
deleteBatch: async () => {
|
|
3395
3408
|
let t = e.deleteFrom("login_sessions").where("expires_at_ts", "<", i);
|
|
3396
3409
|
n && (t = t.where("tenant_id", "=", n)), r && (t = t.where("user_id", "=", r));
|
|
3397
|
-
let a = await t.limit(
|
|
3410
|
+
let a = await t.limit(U).execute();
|
|
3398
3411
|
return Number(a[0]?.numDeletedRows ?? 0);
|
|
3399
3412
|
}
|
|
3400
3413
|
},
|
|
@@ -3428,7 +3441,7 @@ function xi(e) {
|
|
|
3428
3441
|
c += 1;
|
|
3429
3442
|
try {
|
|
3430
3443
|
let t = await e.deleteBatch();
|
|
3431
|
-
e.deleted += t, t <
|
|
3444
|
+
e.deleted += t, t < U && (e.drained = !0);
|
|
3432
3445
|
} catch (t) {
|
|
3433
3446
|
e.failed = !0, e.drained = !0, console.error(`Error during session cleanup (${e.label}):`, t);
|
|
3434
3447
|
}
|
|
@@ -3441,7 +3454,7 @@ function xi(e) {
|
|
|
3441
3454
|
}
|
|
3442
3455
|
//#endregion
|
|
3443
3456
|
//#region src/forms/create.ts
|
|
3444
|
-
function
|
|
3457
|
+
function bi(e) {
|
|
3445
3458
|
return async (n, r, i) => {
|
|
3446
3459
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3447
3460
|
id: a?.id ?? t(),
|
|
@@ -3460,7 +3473,7 @@ function Si(e) {
|
|
|
3460
3473
|
}
|
|
3461
3474
|
//#endregion
|
|
3462
3475
|
//#region src/forms/list.ts
|
|
3463
|
-
function
|
|
3476
|
+
function xi(e) {
|
|
3464
3477
|
return async (t, n = {}) => {
|
|
3465
3478
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3466
3479
|
s && (c = O(e, c, s, []));
|
|
@@ -3494,7 +3507,7 @@ function Ci(e) {
|
|
|
3494
3507
|
}
|
|
3495
3508
|
//#endregion
|
|
3496
3509
|
//#region src/forms/remove.ts
|
|
3497
|
-
function
|
|
3510
|
+
function Si(e) {
|
|
3498
3511
|
return async (t, n) => {
|
|
3499
3512
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3500
3513
|
return r > 0;
|
|
@@ -3502,7 +3515,7 @@ function wi(e) {
|
|
|
3502
3515
|
}
|
|
3503
3516
|
//#endregion
|
|
3504
3517
|
//#region src/forms/get.ts
|
|
3505
|
-
function
|
|
3518
|
+
function Ci(e) {
|
|
3506
3519
|
return async (t, n) => {
|
|
3507
3520
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3508
3521
|
if (!r) return null;
|
|
@@ -3521,7 +3534,7 @@ function Ti(e) {
|
|
|
3521
3534
|
}
|
|
3522
3535
|
//#endregion
|
|
3523
3536
|
//#region src/forms/update.ts
|
|
3524
|
-
function
|
|
3537
|
+
function wi(e) {
|
|
3525
3538
|
return async (t, n, r) => {
|
|
3526
3539
|
let i = {
|
|
3527
3540
|
...r,
|
|
@@ -3538,22 +3551,22 @@ function Ei(e) {
|
|
|
3538
3551
|
}
|
|
3539
3552
|
//#endregion
|
|
3540
3553
|
//#region src/forms/index.ts
|
|
3541
|
-
function
|
|
3554
|
+
function Ti(e) {
|
|
3542
3555
|
return {
|
|
3543
|
-
create:
|
|
3544
|
-
get:
|
|
3545
|
-
list:
|
|
3546
|
-
remove:
|
|
3547
|
-
update:
|
|
3556
|
+
create: bi(e),
|
|
3557
|
+
get: Ci(e),
|
|
3558
|
+
list: xi(e),
|
|
3559
|
+
remove: Si(e),
|
|
3560
|
+
update: wi(e)
|
|
3548
3561
|
};
|
|
3549
3562
|
}
|
|
3550
3563
|
//#endregion
|
|
3551
3564
|
//#region src/resourceServers/create.ts
|
|
3552
|
-
function
|
|
3565
|
+
function Ei(e) {
|
|
3553
3566
|
return async (t, n, r) => {
|
|
3554
3567
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3555
3568
|
...n,
|
|
3556
|
-
id: i?.id ?? n.id ??
|
|
3569
|
+
id: i?.id ?? n.id ?? Pe(),
|
|
3557
3570
|
created_at: o,
|
|
3558
3571
|
updated_at: s
|
|
3559
3572
|
}, u = de.parse(c), { verificationKey: d, scopes: f, options: p, skip_consent_for_verifiable_first_party_clients: m, allow_offline_access: h, is_system: g, metadata: _, ...v } = u, y = {
|
|
@@ -3574,7 +3587,7 @@ function Oi(e) {
|
|
|
3574
3587
|
}
|
|
3575
3588
|
//#endregion
|
|
3576
3589
|
//#region src/resourceServers/get.ts
|
|
3577
|
-
function
|
|
3590
|
+
function Di(e) {
|
|
3578
3591
|
return async (t, n) => {
|
|
3579
3592
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3580
3593
|
if (!r) return null;
|
|
@@ -3593,47 +3606,62 @@ function ki(e) {
|
|
|
3593
3606
|
}
|
|
3594
3607
|
//#endregion
|
|
3595
3608
|
//#region src/resourceServers/list.ts
|
|
3596
|
-
function
|
|
3609
|
+
function Oi(e) {
|
|
3610
|
+
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({
|
|
3611
|
+
...c,
|
|
3612
|
+
scopes: n ? JSON.parse(n) : [],
|
|
3613
|
+
options: r ? JSON.parse(r) : {},
|
|
3614
|
+
skip_consent_for_verifiable_first_party_clients: !!i,
|
|
3615
|
+
allow_offline_access: !!a,
|
|
3616
|
+
is_system: o ? !0 : void 0,
|
|
3617
|
+
metadata: s ? JSON.parse(s) : void 0,
|
|
3618
|
+
verificationKey: t
|
|
3619
|
+
});
|
|
3620
|
+
return u.token_lifetime ??= 86400, u.token_lifetime_for_web ??= 7200, u;
|
|
3621
|
+
}
|
|
3622
|
+
function ki(e) {
|
|
3597
3623
|
return async (t, n = {}) => {
|
|
3598
3624
|
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);
|
|
3599
3625
|
if (s) {
|
|
3600
|
-
let t = s.trim(), n = t.split(/\s+/), r = n.length === 1 ? n[0] : void 0, i = r ? r.match(/^(-)?(name|identifier):(.*)$/) : null, a = i ?
|
|
3626
|
+
let t = s.trim(), n = t.split(/\s+/), r = n.length === 1 ? n[0] : void 0, i = r ? r.match(/^(-)?(name|identifier):(.*)$/) : null, a = i ? C(i[3]) : "", o = /^(>=|>|<=|<)/.test(a || "");
|
|
3601
3627
|
if (i && !o) {
|
|
3602
3628
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3603
3629
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3604
3630
|
} else c = O(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3605
3631
|
}
|
|
3606
|
-
|
|
3607
|
-
let {
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3632
|
+
if (N(n)) {
|
|
3633
|
+
let { rows: e, limit: t, next: r } = await P(c.selectAll(), n, {
|
|
3634
|
+
sortColumn: "created_at",
|
|
3635
|
+
sortOrder: "desc",
|
|
3636
|
+
idColumn: "id"
|
|
3637
|
+
}), i = e.map(Oi);
|
|
3638
|
+
return {
|
|
3639
|
+
resource_servers: i,
|
|
3640
|
+
start: 0,
|
|
3641
|
+
limit: t,
|
|
3642
|
+
length: i.length,
|
|
3643
|
+
next: r
|
|
3644
|
+
};
|
|
3645
|
+
}
|
|
3646
|
+
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(Oi);
|
|
3619
3647
|
if (!a) return {
|
|
3620
|
-
resource_servers:
|
|
3648
|
+
resource_servers: l,
|
|
3621
3649
|
start: 0,
|
|
3622
3650
|
limit: 0,
|
|
3623
3651
|
length: 0
|
|
3624
3652
|
};
|
|
3625
|
-
let { count:
|
|
3653
|
+
let { count: u } = await c.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
3626
3654
|
return {
|
|
3627
|
-
resource_servers:
|
|
3655
|
+
resource_servers: l,
|
|
3628
3656
|
start: r * i,
|
|
3629
3657
|
limit: i,
|
|
3630
|
-
length: o(
|
|
3658
|
+
length: o(u)
|
|
3631
3659
|
};
|
|
3632
3660
|
};
|
|
3633
3661
|
}
|
|
3634
3662
|
//#endregion
|
|
3635
3663
|
//#region src/resourceServers/remove.ts
|
|
3636
|
-
function
|
|
3664
|
+
function Ai(e) {
|
|
3637
3665
|
return async (t, n) => {
|
|
3638
3666
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3639
3667
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3641,7 +3669,7 @@ function ji(e) {
|
|
|
3641
3669
|
}
|
|
3642
3670
|
//#endregion
|
|
3643
3671
|
//#region src/resourceServers/update.ts
|
|
3644
|
-
function
|
|
3672
|
+
function ji(e) {
|
|
3645
3673
|
return async (t, n, r) => {
|
|
3646
3674
|
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 = {
|
|
3647
3675
|
...d,
|
|
@@ -3661,18 +3689,18 @@ function Mi(e) {
|
|
|
3661
3689
|
}
|
|
3662
3690
|
//#endregion
|
|
3663
3691
|
//#region src/resourceServers/index.ts
|
|
3664
|
-
function
|
|
3692
|
+
function Mi(e) {
|
|
3665
3693
|
return {
|
|
3666
|
-
create:
|
|
3667
|
-
get:
|
|
3668
|
-
list:
|
|
3669
|
-
remove:
|
|
3670
|
-
update:
|
|
3694
|
+
create: Ei(e),
|
|
3695
|
+
get: Di(e),
|
|
3696
|
+
list: ki(e),
|
|
3697
|
+
remove: Ai(e),
|
|
3698
|
+
update: ji(e)
|
|
3671
3699
|
};
|
|
3672
3700
|
}
|
|
3673
3701
|
//#endregion
|
|
3674
3702
|
//#region src/roles/create.ts
|
|
3675
|
-
function
|
|
3703
|
+
function Ni(e) {
|
|
3676
3704
|
return async (n, r, i) => {
|
|
3677
3705
|
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 = {
|
|
3678
3706
|
id: l,
|
|
@@ -3695,7 +3723,7 @@ function Pi(e) {
|
|
|
3695
3723
|
}
|
|
3696
3724
|
//#endregion
|
|
3697
3725
|
//#region src/roles/get.ts
|
|
3698
|
-
function
|
|
3726
|
+
function Pi(e) {
|
|
3699
3727
|
return async (t, n) => {
|
|
3700
3728
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3701
3729
|
if (!r) return null;
|
|
@@ -3709,7 +3737,7 @@ function Fi(e) {
|
|
|
3709
3737
|
}
|
|
3710
3738
|
//#endregion
|
|
3711
3739
|
//#region src/roles/list.ts
|
|
3712
|
-
function
|
|
3740
|
+
function Fi(e) {
|
|
3713
3741
|
return async (t, n) => {
|
|
3714
3742
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3715
3743
|
n.q && (r = O(e, r, n.q, ["name"]));
|
|
@@ -3738,7 +3766,7 @@ function Ii(e) {
|
|
|
3738
3766
|
}
|
|
3739
3767
|
//#endregion
|
|
3740
3768
|
//#region src/roles/update.ts
|
|
3741
|
-
function
|
|
3769
|
+
function Ii(e) {
|
|
3742
3770
|
return async (t, n, r) => {
|
|
3743
3771
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3744
3772
|
...o,
|
|
@@ -3751,7 +3779,7 @@ function Li(e) {
|
|
|
3751
3779
|
}
|
|
3752
3780
|
//#endregion
|
|
3753
3781
|
//#region src/roles/remove.ts
|
|
3754
|
-
function
|
|
3782
|
+
function Li(e) {
|
|
3755
3783
|
return async (t, n) => {
|
|
3756
3784
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3757
3785
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3759,23 +3787,23 @@ function Ri(e) {
|
|
|
3759
3787
|
}
|
|
3760
3788
|
//#endregion
|
|
3761
3789
|
//#region src/roles/index.ts
|
|
3762
|
-
function
|
|
3790
|
+
function Ri(e) {
|
|
3763
3791
|
return {
|
|
3764
|
-
create:
|
|
3765
|
-
get:
|
|
3766
|
-
list:
|
|
3767
|
-
update:
|
|
3768
|
-
remove:
|
|
3792
|
+
create: Ni(e),
|
|
3793
|
+
get: Pi(e),
|
|
3794
|
+
list: Fi(e),
|
|
3795
|
+
update: Ii(e),
|
|
3796
|
+
remove: Li(e)
|
|
3769
3797
|
};
|
|
3770
3798
|
}
|
|
3771
3799
|
//#endregion
|
|
3772
3800
|
//#region src/role-permissions/assign.ts
|
|
3773
|
-
function
|
|
3801
|
+
function zi(e) {
|
|
3774
3802
|
if (typeof e != "object" || !e) return !1;
|
|
3775
3803
|
let { code: t, message: n } = e;
|
|
3776
3804
|
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"));
|
|
3777
3805
|
}
|
|
3778
|
-
function
|
|
3806
|
+
function Bi(e) {
|
|
3779
3807
|
return async (t, n, r, i) => {
|
|
3780
3808
|
if (r.length === 0) return !0;
|
|
3781
3809
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3792,7 +3820,7 @@ function Vi(e) {
|
|
|
3792
3820
|
try {
|
|
3793
3821
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3794
3822
|
} catch (e) {
|
|
3795
|
-
if (
|
|
3823
|
+
if (zi(e)) continue;
|
|
3796
3824
|
throw e;
|
|
3797
3825
|
}
|
|
3798
3826
|
}
|
|
@@ -3804,7 +3832,7 @@ function Vi(e) {
|
|
|
3804
3832
|
}
|
|
3805
3833
|
//#endregion
|
|
3806
3834
|
//#region src/role-permissions/remove.ts
|
|
3807
|
-
function
|
|
3835
|
+
function Vi(e) {
|
|
3808
3836
|
return async (t, n, r) => {
|
|
3809
3837
|
if (r.length === 0) return !0;
|
|
3810
3838
|
try {
|
|
@@ -3816,7 +3844,7 @@ function Hi(e) {
|
|
|
3816
3844
|
}
|
|
3817
3845
|
//#endregion
|
|
3818
3846
|
//#region src/role-permissions/list.ts
|
|
3819
|
-
function
|
|
3847
|
+
function Hi(e) {
|
|
3820
3848
|
return async (t, n, r = {}) => {
|
|
3821
3849
|
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([
|
|
3822
3850
|
"role_permissions.role_id",
|
|
@@ -3837,16 +3865,16 @@ function Ui(e) {
|
|
|
3837
3865
|
}
|
|
3838
3866
|
//#endregion
|
|
3839
3867
|
//#region src/role-permissions/index.ts
|
|
3840
|
-
function
|
|
3868
|
+
function Ui(e) {
|
|
3841
3869
|
return {
|
|
3842
|
-
assign:
|
|
3843
|
-
remove:
|
|
3844
|
-
list:
|
|
3870
|
+
assign: Bi(e),
|
|
3871
|
+
remove: Vi(e),
|
|
3872
|
+
list: Hi(e)
|
|
3845
3873
|
};
|
|
3846
3874
|
}
|
|
3847
3875
|
//#endregion
|
|
3848
3876
|
//#region src/grants/create.ts
|
|
3849
|
-
function
|
|
3877
|
+
function Wi(e) {
|
|
3850
3878
|
return async (n, r) => {
|
|
3851
3879
|
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();
|
|
3852
3880
|
if (s) {
|
|
@@ -3883,7 +3911,7 @@ function Gi(e) {
|
|
|
3883
3911
|
}
|
|
3884
3912
|
//#endregion
|
|
3885
3913
|
//#region src/grants/get.ts
|
|
3886
|
-
function
|
|
3914
|
+
function Gi(e) {
|
|
3887
3915
|
return async (t, n, r, i) => {
|
|
3888
3916
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3889
3917
|
return a ? {
|
|
@@ -3897,7 +3925,7 @@ function Ki(e) {
|
|
|
3897
3925
|
}
|
|
3898
3926
|
//#endregion
|
|
3899
3927
|
//#region src/grants/list.ts
|
|
3900
|
-
function
|
|
3928
|
+
function Ki(e) {
|
|
3901
3929
|
return async (t, n = {}) => {
|
|
3902
3930
|
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);
|
|
3903
3931
|
c && (l = O(e, l, c, [
|
|
@@ -3935,26 +3963,26 @@ function qi(e) {
|
|
|
3935
3963
|
}
|
|
3936
3964
|
//#endregion
|
|
3937
3965
|
//#region src/grants/remove.ts
|
|
3938
|
-
function
|
|
3966
|
+
function qi(e) {
|
|
3939
3967
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3940
3968
|
}
|
|
3941
|
-
function
|
|
3969
|
+
function Ji(e) {
|
|
3942
3970
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3943
3971
|
}
|
|
3944
3972
|
//#endregion
|
|
3945
3973
|
//#region src/grants/index.ts
|
|
3946
|
-
function
|
|
3974
|
+
function Yi(e) {
|
|
3947
3975
|
return {
|
|
3948
|
-
create:
|
|
3949
|
-
get:
|
|
3950
|
-
list:
|
|
3951
|
-
remove:
|
|
3952
|
-
removeByUser:
|
|
3976
|
+
create: Wi(e),
|
|
3977
|
+
get: Gi(e),
|
|
3978
|
+
list: Ki(e),
|
|
3979
|
+
remove: qi(e),
|
|
3980
|
+
removeByUser: Ji(e)
|
|
3953
3981
|
};
|
|
3954
3982
|
}
|
|
3955
3983
|
//#endregion
|
|
3956
3984
|
//#region src/user-permissions/create.ts
|
|
3957
|
-
function
|
|
3985
|
+
function Xi(e) {
|
|
3958
3986
|
return async (t, n, r, i, a) => {
|
|
3959
3987
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3960
3988
|
try {
|
|
@@ -3974,7 +4002,7 @@ function Zi(e) {
|
|
|
3974
4002
|
}
|
|
3975
4003
|
//#endregion
|
|
3976
4004
|
//#region src/user-permissions/remove.ts
|
|
3977
|
-
function
|
|
4005
|
+
function Zi(e) {
|
|
3978
4006
|
return async (t, n, r, i) => {
|
|
3979
4007
|
try {
|
|
3980
4008
|
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);
|
|
@@ -3986,7 +4014,7 @@ function Qi(e) {
|
|
|
3986
4014
|
}
|
|
3987
4015
|
//#endregion
|
|
3988
4016
|
//#region src/user-permissions/list.ts
|
|
3989
|
-
function
|
|
4017
|
+
function Qi(e) {
|
|
3990
4018
|
return async (t, n, r, i) => {
|
|
3991
4019
|
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([
|
|
3992
4020
|
"user_permissions.resource_server_identifier",
|
|
@@ -4009,17 +4037,17 @@ function $i(e) {
|
|
|
4009
4037
|
}
|
|
4010
4038
|
//#endregion
|
|
4011
4039
|
//#region src/user-permissions/index.ts
|
|
4012
|
-
function
|
|
4040
|
+
function $i(e) {
|
|
4013
4041
|
return {
|
|
4014
|
-
create:
|
|
4015
|
-
remove:
|
|
4016
|
-
list:
|
|
4042
|
+
create: Xi(e),
|
|
4043
|
+
remove: Zi(e),
|
|
4044
|
+
list: Qi(e)
|
|
4017
4045
|
};
|
|
4018
4046
|
}
|
|
4019
4047
|
//#endregion
|
|
4020
4048
|
//#region src/user-permissions/adapter.ts
|
|
4021
|
-
function
|
|
4022
|
-
let t =
|
|
4049
|
+
function ea(e) {
|
|
4050
|
+
let t = $i(e);
|
|
4023
4051
|
return {
|
|
4024
4052
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
4025
4053
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -4028,7 +4056,7 @@ function ta(e) {
|
|
|
4028
4056
|
}
|
|
4029
4057
|
//#endregion
|
|
4030
4058
|
//#region src/user-roles/list.ts
|
|
4031
|
-
function
|
|
4059
|
+
function ta(e) {
|
|
4032
4060
|
return async (t, n, r, i) => {
|
|
4033
4061
|
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([
|
|
4034
4062
|
"r.id",
|
|
@@ -4042,11 +4070,11 @@ function na(e) {
|
|
|
4042
4070
|
}
|
|
4043
4071
|
//#endregion
|
|
4044
4072
|
//#region src/user-roles/list-users.ts
|
|
4045
|
-
function
|
|
4073
|
+
function na(e) {
|
|
4046
4074
|
return async (t, n, r) => {
|
|
4047
4075
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
4048
|
-
if (
|
|
4049
|
-
let { rows: e, limit: t, next: n } = await
|
|
4076
|
+
if (N(r)) {
|
|
4077
|
+
let { rows: e, limit: t, next: n } = await P(i, r, {
|
|
4050
4078
|
sortColumn: "user_id",
|
|
4051
4079
|
sortOrder: "asc",
|
|
4052
4080
|
idColumn: "user_id"
|
|
@@ -4070,7 +4098,7 @@ function ra(e) {
|
|
|
4070
4098
|
}
|
|
4071
4099
|
//#endregion
|
|
4072
4100
|
//#region src/user-roles/create.ts
|
|
4073
|
-
function
|
|
4101
|
+
function ra(e) {
|
|
4074
4102
|
return async (t, n, r, i, a) => {
|
|
4075
4103
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
4076
4104
|
try {
|
|
@@ -4088,7 +4116,7 @@ function ia(e) {
|
|
|
4088
4116
|
}
|
|
4089
4117
|
//#endregion
|
|
4090
4118
|
//#region src/user-roles/remove.ts
|
|
4091
|
-
function
|
|
4119
|
+
function ia(e) {
|
|
4092
4120
|
return async (t, n, r, i) => {
|
|
4093
4121
|
try {
|
|
4094
4122
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -4100,18 +4128,18 @@ function aa(e) {
|
|
|
4100
4128
|
}
|
|
4101
4129
|
//#endregion
|
|
4102
4130
|
//#region src/user-roles/index.ts
|
|
4103
|
-
function
|
|
4131
|
+
function aa(e) {
|
|
4104
4132
|
return {
|
|
4105
|
-
list:
|
|
4106
|
-
listUsers:
|
|
4107
|
-
create:
|
|
4108
|
-
remove:
|
|
4133
|
+
list: ta(e),
|
|
4134
|
+
listUsers: na(e),
|
|
4135
|
+
create: ra(e),
|
|
4136
|
+
remove: ia(e)
|
|
4109
4137
|
};
|
|
4110
4138
|
}
|
|
4111
4139
|
//#endregion
|
|
4112
4140
|
//#region src/user-roles/adapter.ts
|
|
4113
|
-
function
|
|
4114
|
-
let t =
|
|
4141
|
+
function oa(e) {
|
|
4142
|
+
let t = aa(e);
|
|
4115
4143
|
return {
|
|
4116
4144
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
4117
4145
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4121,11 +4149,11 @@ function sa(e) {
|
|
|
4121
4149
|
}
|
|
4122
4150
|
//#endregion
|
|
4123
4151
|
//#region src/organizations/create.ts
|
|
4124
|
-
function
|
|
4152
|
+
function sa(e) {
|
|
4125
4153
|
return async (t, n, r) => {
|
|
4126
4154
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4127
4155
|
...n,
|
|
4128
|
-
id: i?.id || n.id ||
|
|
4156
|
+
id: i?.id || n.id || ke(),
|
|
4129
4157
|
tenant_id: t,
|
|
4130
4158
|
created_at: i?.created_at ?? a,
|
|
4131
4159
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4137,7 +4165,7 @@ function ca(e) {
|
|
|
4137
4165
|
try {
|
|
4138
4166
|
await e.insertInto("organizations").values(o).execute();
|
|
4139
4167
|
} catch (e) {
|
|
4140
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4168
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new w(409, { message: "Organization already exists" }) : e;
|
|
4141
4169
|
}
|
|
4142
4170
|
return {
|
|
4143
4171
|
...n,
|
|
@@ -4149,7 +4177,7 @@ function ca(e) {
|
|
|
4149
4177
|
}
|
|
4150
4178
|
//#endregion
|
|
4151
4179
|
//#region src/organizations/get.ts
|
|
4152
|
-
function
|
|
4180
|
+
function ca(e) {
|
|
4153
4181
|
return async (t, n) => {
|
|
4154
4182
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4155
4183
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4163,16 +4191,16 @@ function la(e) {
|
|
|
4163
4191
|
}
|
|
4164
4192
|
//#endregion
|
|
4165
4193
|
//#region src/organizations/list.ts
|
|
4166
|
-
var
|
|
4167
|
-
function
|
|
4194
|
+
var W = ["name", "display_name"];
|
|
4195
|
+
function la(e) {
|
|
4168
4196
|
return async (t, n) => {
|
|
4169
4197
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4170
4198
|
if (n?.q) {
|
|
4171
|
-
let t = S(n.q,
|
|
4172
|
-
t && (r = O(e, r, t,
|
|
4199
|
+
let t = S(n.q, W);
|
|
4200
|
+
t && (r = O(e, r, t, W));
|
|
4173
4201
|
}
|
|
4174
|
-
if (
|
|
4175
|
-
let { rows: e, limit: t, next: i } = await
|
|
4202
|
+
if (N(n)) {
|
|
4203
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
4176
4204
|
sortColumn: "created_at",
|
|
4177
4205
|
sortOrder: "desc"
|
|
4178
4206
|
}), a = e.map((e) => l({
|
|
@@ -4205,8 +4233,8 @@ function ua(e) {
|
|
|
4205
4233
|
if (n?.include_totals) {
|
|
4206
4234
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4207
4235
|
if (n?.q) {
|
|
4208
|
-
let t = S(n.q,
|
|
4209
|
-
t && (r = O(e, r, t,
|
|
4236
|
+
let t = S(n.q, W);
|
|
4237
|
+
t && (r = O(e, r, t, W));
|
|
4210
4238
|
}
|
|
4211
4239
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4212
4240
|
u = Number(i?.count || 0);
|
|
@@ -4229,7 +4257,7 @@ function ua(e) {
|
|
|
4229
4257
|
}
|
|
4230
4258
|
//#endregion
|
|
4231
4259
|
//#region src/organizations/remove.ts
|
|
4232
|
-
function
|
|
4260
|
+
function ua(e) {
|
|
4233
4261
|
return async (t, n) => {
|
|
4234
4262
|
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4235
4263
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -4237,7 +4265,7 @@ function da(e) {
|
|
|
4237
4265
|
}
|
|
4238
4266
|
//#endregion
|
|
4239
4267
|
//#region src/organizations/update.ts
|
|
4240
|
-
function
|
|
4268
|
+
function da(e) {
|
|
4241
4269
|
return async (t, n, r) => {
|
|
4242
4270
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4243
4271
|
...c,
|
|
@@ -4253,18 +4281,18 @@ function fa(e) {
|
|
|
4253
4281
|
}
|
|
4254
4282
|
//#endregion
|
|
4255
4283
|
//#region src/organizations/index.ts
|
|
4256
|
-
function
|
|
4284
|
+
function fa(e) {
|
|
4257
4285
|
return {
|
|
4258
|
-
create:
|
|
4259
|
-
get:
|
|
4260
|
-
list:
|
|
4261
|
-
remove:
|
|
4262
|
-
update:
|
|
4286
|
+
create: sa(e),
|
|
4287
|
+
get: ca(e),
|
|
4288
|
+
list: la(e),
|
|
4289
|
+
remove: ua(e),
|
|
4290
|
+
update: da(e)
|
|
4263
4291
|
};
|
|
4264
4292
|
}
|
|
4265
4293
|
//#endregion
|
|
4266
4294
|
//#region src/organization-connections/index.ts
|
|
4267
|
-
function
|
|
4295
|
+
function G(e, t) {
|
|
4268
4296
|
return {
|
|
4269
4297
|
connection_id: e.connection_id,
|
|
4270
4298
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4278,14 +4306,14 @@ function U(e, t) {
|
|
|
4278
4306
|
updated_at: e.updated_at
|
|
4279
4307
|
};
|
|
4280
4308
|
}
|
|
4281
|
-
async function
|
|
4309
|
+
async function K(e, t, n) {
|
|
4282
4310
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4283
4311
|
if (r) return {
|
|
4284
4312
|
name: r.name,
|
|
4285
4313
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4286
4314
|
};
|
|
4287
4315
|
}
|
|
4288
|
-
function
|
|
4316
|
+
function pa(e) {
|
|
4289
4317
|
return {
|
|
4290
4318
|
async create(t, n, r, i) {
|
|
4291
4319
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4298,19 +4326,19 @@ function ma(e) {
|
|
|
4298
4326
|
created_at: a?.created_at ?? o,
|
|
4299
4327
|
updated_at: a?.updated_at ?? o
|
|
4300
4328
|
};
|
|
4301
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4329
|
+
return await e.insertInto("organization_connections").values(s).execute(), G(s, await K(e, t, r.connection_id));
|
|
4302
4330
|
},
|
|
4303
4331
|
async list(t, n) {
|
|
4304
4332
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4305
4333
|
for (let n of r) {
|
|
4306
|
-
let r = await
|
|
4307
|
-
i.push(
|
|
4334
|
+
let r = await K(e, t, n.connection_id);
|
|
4335
|
+
i.push(G(n, r));
|
|
4308
4336
|
}
|
|
4309
4337
|
return i;
|
|
4310
4338
|
},
|
|
4311
4339
|
async get(t, n, r) {
|
|
4312
4340
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4313
|
-
return i ?
|
|
4341
|
+
return i ? G(i, await K(e, t, r)) : null;
|
|
4314
4342
|
},
|
|
4315
4343
|
async update(t, n, r, i) {
|
|
4316
4344
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4318,7 +4346,7 @@ function ma(e) {
|
|
|
4318
4346
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4319
4347
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4320
4348
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4321
|
-
return s ?
|
|
4349
|
+
return s ? G(s, await K(e, t, r)) : null;
|
|
4322
4350
|
},
|
|
4323
4351
|
async remove(t, n, r) {
|
|
4324
4352
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4328,7 +4356,7 @@ function ma(e) {
|
|
|
4328
4356
|
}
|
|
4329
4357
|
//#endregion
|
|
4330
4358
|
//#region src/user-organizations/create.ts
|
|
4331
|
-
function
|
|
4359
|
+
function ma(e) {
|
|
4332
4360
|
return async (n, r, i) => {
|
|
4333
4361
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4334
4362
|
id: a?.id ?? t(),
|
|
@@ -4341,14 +4369,14 @@ function ha(e) {
|
|
|
4341
4369
|
try {
|
|
4342
4370
|
await e.insertInto("user_organizations").values(s).execute();
|
|
4343
4371
|
} catch (e) {
|
|
4344
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new
|
|
4372
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new w(409, { message: "User is already a member of this organization" }) : e;
|
|
4345
4373
|
}
|
|
4346
4374
|
return { ...s };
|
|
4347
4375
|
};
|
|
4348
4376
|
}
|
|
4349
4377
|
//#endregion
|
|
4350
4378
|
//#region src/user-organizations/get.ts
|
|
4351
|
-
function
|
|
4379
|
+
function ha(e) {
|
|
4352
4380
|
return async (t, n) => {
|
|
4353
4381
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4354
4382
|
return r ? {
|
|
@@ -4362,13 +4390,13 @@ function ga(e) {
|
|
|
4362
4390
|
}
|
|
4363
4391
|
//#endregion
|
|
4364
4392
|
//#region src/user-organizations/list.ts
|
|
4365
|
-
function
|
|
4366
|
-
return
|
|
4393
|
+
function q(e, t) {
|
|
4394
|
+
return C(e.slice(t.length + 1));
|
|
4367
4395
|
}
|
|
4368
|
-
function
|
|
4396
|
+
function ga(e) {
|
|
4369
4397
|
return async (t, n) => {
|
|
4370
4398
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4371
|
-
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=",
|
|
4399
|
+
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", q(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", q(n.q, "organization_id"))));
|
|
4372
4400
|
let i = (e) => ({
|
|
4373
4401
|
id: e.id,
|
|
4374
4402
|
user_id: e.user_id,
|
|
@@ -4376,8 +4404,8 @@ function _a(e) {
|
|
|
4376
4404
|
created_at: e.created_at,
|
|
4377
4405
|
updated_at: e.updated_at
|
|
4378
4406
|
});
|
|
4379
|
-
if (
|
|
4380
|
-
let { rows: e, limit: t, next: a } = await
|
|
4407
|
+
if (N(n)) {
|
|
4408
|
+
let { rows: e, limit: t, next: a } = await P(r, n, {
|
|
4381
4409
|
sortColumn: "created_at",
|
|
4382
4410
|
sortOrder: "desc"
|
|
4383
4411
|
});
|
|
@@ -4390,7 +4418,7 @@ function _a(e) {
|
|
|
4390
4418
|
};
|
|
4391
4419
|
}
|
|
4392
4420
|
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);
|
|
4393
|
-
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=",
|
|
4421
|
+
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=", q(n.q, "user_id")) : n.q.startsWith("organization_id:") && (l = l.where("organization_id", "=", q(n.q, "organization_id"))));
|
|
4394
4422
|
let u = await l.executeTakeFirst();
|
|
4395
4423
|
return {
|
|
4396
4424
|
userOrganizations: c.map(i),
|
|
@@ -4402,7 +4430,7 @@ function _a(e) {
|
|
|
4402
4430
|
}
|
|
4403
4431
|
//#endregion
|
|
4404
4432
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4405
|
-
function
|
|
4433
|
+
function _a(e) {
|
|
4406
4434
|
return async (t, n, r) => {
|
|
4407
4435
|
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([
|
|
4408
4436
|
"organizations.id",
|
|
@@ -4439,12 +4467,12 @@ function va(e) {
|
|
|
4439
4467
|
}
|
|
4440
4468
|
//#endregion
|
|
4441
4469
|
//#region src/user-organizations/remove.ts
|
|
4442
|
-
function
|
|
4470
|
+
function va(e) {
|
|
4443
4471
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4444
4472
|
}
|
|
4445
4473
|
//#endregion
|
|
4446
4474
|
//#region src/user-organizations/update.ts
|
|
4447
|
-
function
|
|
4475
|
+
function ya(e) {
|
|
4448
4476
|
return async (t, n, r) => {
|
|
4449
4477
|
let i = {
|
|
4450
4478
|
...r,
|
|
@@ -4455,21 +4483,21 @@ function ba(e) {
|
|
|
4455
4483
|
}
|
|
4456
4484
|
//#endregion
|
|
4457
4485
|
//#region src/user-organizations/index.ts
|
|
4458
|
-
function
|
|
4486
|
+
function ba(e) {
|
|
4459
4487
|
return {
|
|
4460
|
-
create:
|
|
4461
|
-
get:
|
|
4462
|
-
list:
|
|
4463
|
-
listUserOrganizations:
|
|
4464
|
-
remove:
|
|
4465
|
-
update:
|
|
4488
|
+
create: ma(e),
|
|
4489
|
+
get: ha(e),
|
|
4490
|
+
list: ga(e),
|
|
4491
|
+
listUserOrganizations: _a(e),
|
|
4492
|
+
remove: va(e),
|
|
4493
|
+
update: ya(e)
|
|
4466
4494
|
};
|
|
4467
4495
|
}
|
|
4468
4496
|
//#endregion
|
|
4469
4497
|
//#region src/invites/create.ts
|
|
4470
|
-
function
|
|
4498
|
+
function xa(e) {
|
|
4471
4499
|
return async (t, n, r) => {
|
|
4472
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4500
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Ie(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4473
4501
|
id: a,
|
|
4474
4502
|
tenant_id: t,
|
|
4475
4503
|
organization_id: n.organization_id,
|
|
@@ -4490,7 +4518,7 @@ function Sa(e) {
|
|
|
4490
4518
|
try {
|
|
4491
4519
|
await e.insertInto("invites").values(l).execute();
|
|
4492
4520
|
} catch (e) {
|
|
4493
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4521
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new w(409, { message: "Invite already exists" }) : e;
|
|
4494
4522
|
}
|
|
4495
4523
|
return {
|
|
4496
4524
|
id: a,
|
|
@@ -4513,11 +4541,11 @@ function Sa(e) {
|
|
|
4513
4541
|
}
|
|
4514
4542
|
//#endregion
|
|
4515
4543
|
//#region src/invites/get.ts
|
|
4516
|
-
function
|
|
4544
|
+
function Sa(e) {
|
|
4517
4545
|
return async (t, n) => {
|
|
4518
4546
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4519
4547
|
return r ? l({
|
|
4520
|
-
...
|
|
4548
|
+
...wt(r, {
|
|
4521
4549
|
inviter: {},
|
|
4522
4550
|
invitee: {},
|
|
4523
4551
|
app_metadata: {},
|
|
@@ -4530,7 +4558,7 @@ function Ca(e) {
|
|
|
4530
4558
|
}
|
|
4531
4559
|
//#endregion
|
|
4532
4560
|
//#region src/invites/list.ts
|
|
4533
|
-
function
|
|
4561
|
+
function Ca(e) {
|
|
4534
4562
|
return async (t, n) => {
|
|
4535
4563
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4536
4564
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4538,7 +4566,7 @@ function wa(e) {
|
|
|
4538
4566
|
r = r.offset(e);
|
|
4539
4567
|
}
|
|
4540
4568
|
let i = (await r.execute()).map((e) => l({
|
|
4541
|
-
...
|
|
4569
|
+
...wt(e, {
|
|
4542
4570
|
inviter: {},
|
|
4543
4571
|
invitee: {},
|
|
4544
4572
|
app_metadata: {},
|
|
@@ -4557,12 +4585,12 @@ function wa(e) {
|
|
|
4557
4585
|
}
|
|
4558
4586
|
//#endregion
|
|
4559
4587
|
//#region src/invites/remove.ts
|
|
4560
|
-
function
|
|
4588
|
+
function wa(e) {
|
|
4561
4589
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4562
4590
|
}
|
|
4563
4591
|
//#endregion
|
|
4564
4592
|
//#region src/invites/update.ts
|
|
4565
|
-
function
|
|
4593
|
+
function Ta(e) {
|
|
4566
4594
|
return async (t, n, r) => {
|
|
4567
4595
|
let i = {};
|
|
4568
4596
|
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;
|
|
@@ -4570,35 +4598,35 @@ function Ea(e) {
|
|
|
4570
4598
|
}
|
|
4571
4599
|
//#endregion
|
|
4572
4600
|
//#region src/invites/index.ts
|
|
4573
|
-
function
|
|
4601
|
+
function Ea(e) {
|
|
4574
4602
|
return {
|
|
4575
|
-
create:
|
|
4576
|
-
get:
|
|
4577
|
-
list:
|
|
4578
|
-
remove:
|
|
4579
|
-
update:
|
|
4603
|
+
create: xa(e),
|
|
4604
|
+
get: Sa(e),
|
|
4605
|
+
list: Ca(e),
|
|
4606
|
+
remove: wa(e),
|
|
4607
|
+
update: Ta(e)
|
|
4580
4608
|
};
|
|
4581
4609
|
}
|
|
4582
4610
|
//#endregion
|
|
4583
4611
|
//#region src/stats/index.ts
|
|
4584
|
-
var
|
|
4585
|
-
function
|
|
4612
|
+
var Da = ["s"], Oa = ["pwd_leak"];
|
|
4613
|
+
function ka(e) {
|
|
4586
4614
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4587
4615
|
}
|
|
4588
|
-
function
|
|
4616
|
+
function Aa(e) {
|
|
4589
4617
|
return e.toISOString().split("T")[0];
|
|
4590
4618
|
}
|
|
4591
|
-
function
|
|
4619
|
+
function ja(e) {
|
|
4592
4620
|
return {
|
|
4593
4621
|
async getDaily(t, n = {}) {
|
|
4594
4622
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4595
4623
|
o.setDate(o.getDate() - 30);
|
|
4596
|
-
let s = r ?
|
|
4624
|
+
let s = r ? ka(r) : Aa(o), c = i ? ka(i) : Aa(a), l = f`DATE(logs.date)`;
|
|
4597
4625
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4598
4626
|
l.as("date"),
|
|
4599
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4627
|
+
e.fn.sum(e.case().when("type", "in", Da).then(1).else(0).end()).as("logins"),
|
|
4600
4628
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4601
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4629
|
+
e.fn.sum(e.case().when("type", "in", Oa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4602
4630
|
e.fn.min("date").as("first_event"),
|
|
4603
4631
|
e.fn.max("date").as("last_event")
|
|
4604
4632
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4612,13 +4640,13 @@ function Ma(e) {
|
|
|
4612
4640
|
},
|
|
4613
4641
|
async getActiveUsers(t) {
|
|
4614
4642
|
let n = /* @__PURE__ */ new Date();
|
|
4615
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4643
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", Da).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4616
4644
|
}
|
|
4617
4645
|
};
|
|
4618
4646
|
}
|
|
4619
4647
|
//#endregion
|
|
4620
4648
|
//#region src/analytics/index.ts
|
|
4621
|
-
var
|
|
4649
|
+
var Ma = {
|
|
4622
4650
|
"active-users": ["s", "seacft"],
|
|
4623
4651
|
logins: [
|
|
4624
4652
|
"s",
|
|
@@ -4648,7 +4676,7 @@ var Na = {
|
|
|
4648
4676
|
"fvr"
|
|
4649
4677
|
],
|
|
4650
4678
|
"codes-sent": ["cls", "cs"]
|
|
4651
|
-
},
|
|
4679
|
+
}, Na = {
|
|
4652
4680
|
"active-users": {
|
|
4653
4681
|
alias: "active_users",
|
|
4654
4682
|
type: "UInt64",
|
|
@@ -4705,14 +4733,14 @@ var Na = {
|
|
|
4705
4733
|
agg: "count"
|
|
4706
4734
|
}
|
|
4707
4735
|
};
|
|
4708
|
-
async function
|
|
4736
|
+
async function Pa(e) {
|
|
4709
4737
|
try {
|
|
4710
4738
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4711
4739
|
} catch {
|
|
4712
4740
|
return "sqlite";
|
|
4713
4741
|
}
|
|
4714
4742
|
}
|
|
4715
|
-
function
|
|
4743
|
+
function Fa(e, t) {
|
|
4716
4744
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4717
4745
|
timeZone: e,
|
|
4718
4746
|
year: "numeric",
|
|
@@ -4742,9 +4770,9 @@ var Ia = [
|
|
|
4742
4770
|
"December"
|
|
4743
4771
|
];
|
|
4744
4772
|
function La(e, t) {
|
|
4745
|
-
let n = t.getUTCFullYear(), r =
|
|
4773
|
+
let n = t.getUTCFullYear(), r = Fa(e, new Date(Date.UTC(n, 0, 1)));
|
|
4746
4774
|
for (let t = 1; t < 12; t++) {
|
|
4747
|
-
let i =
|
|
4775
|
+
let i = Fa(e, new Date(Date.UTC(n, t, 1)));
|
|
4748
4776
|
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ia[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').`);
|
|
4749
4777
|
}
|
|
4750
4778
|
}
|
|
@@ -4789,7 +4817,7 @@ function Ba(e, t) {
|
|
|
4789
4817
|
}
|
|
4790
4818
|
function Va(e, t, n, r) {
|
|
4791
4819
|
La(t, n);
|
|
4792
|
-
let i =
|
|
4820
|
+
let i = Fa(t, n);
|
|
4793
4821
|
return r === "mysql" ? Ba(e, i) : za(e, i);
|
|
4794
4822
|
}
|
|
4795
4823
|
function Ha(e) {
|
|
@@ -4802,10 +4830,10 @@ function Ha(e) {
|
|
|
4802
4830
|
}
|
|
4803
4831
|
}
|
|
4804
4832
|
function Ua(e) {
|
|
4805
|
-
let t = null, n = () => (t ||=
|
|
4833
|
+
let t = null, n = () => (t ||= Pa(e), t);
|
|
4806
4834
|
return {
|
|
4807
4835
|
async query(t, r, i) {
|
|
4808
|
-
let a = Date.now(), o =
|
|
4836
|
+
let a = Date.now(), o = Ma[r], s = Na[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4809
4837
|
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));
|
|
4810
4838
|
let d = [], p = [];
|
|
4811
4839
|
for (let e of i.group_by) if (e === "time") {
|
|
@@ -4934,7 +4962,7 @@ function Wa(e) {
|
|
|
4934
4962
|
//#region src/authenticationMethods/create.ts
|
|
4935
4963
|
function Ga(e) {
|
|
4936
4964
|
return async (t, n, r) => {
|
|
4937
|
-
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 ??
|
|
4965
|
+
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 ?? Br();
|
|
4938
4966
|
return await e.insertInto("authentication_methods").values({
|
|
4939
4967
|
id: s,
|
|
4940
4968
|
tenant_id: t,
|
|
@@ -5202,7 +5230,7 @@ function oo(e) {
|
|
|
5202
5230
|
//#region src/outbox/index.ts
|
|
5203
5231
|
function so(e) {
|
|
5204
5232
|
return {
|
|
5205
|
-
create:
|
|
5233
|
+
create: tt(e),
|
|
5206
5234
|
getByIds: Qa(e),
|
|
5207
5235
|
getUnprocessed: $a(e),
|
|
5208
5236
|
claimEvents: eo(e),
|
|
@@ -5216,7 +5244,7 @@ function so(e) {
|
|
|
5216
5244
|
}
|
|
5217
5245
|
//#endregion
|
|
5218
5246
|
//#region src/log-streams/index.ts
|
|
5219
|
-
function
|
|
5247
|
+
function co(e) {
|
|
5220
5248
|
return {
|
|
5221
5249
|
id: e.id,
|
|
5222
5250
|
name: e.name,
|
|
@@ -5229,7 +5257,7 @@ function q(e) {
|
|
|
5229
5257
|
updated_at: e.updated_at
|
|
5230
5258
|
};
|
|
5231
5259
|
}
|
|
5232
|
-
function
|
|
5260
|
+
function lo(e) {
|
|
5233
5261
|
return {
|
|
5234
5262
|
async create(n, r, i) {
|
|
5235
5263
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5244,14 +5272,14 @@ function co(e) {
|
|
|
5244
5272
|
created_at: a?.created_at ?? o,
|
|
5245
5273
|
updated_at: a?.updated_at ?? o
|
|
5246
5274
|
};
|
|
5247
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5275
|
+
return await e.insertInto("log_streams").values(s).execute(), co(s);
|
|
5248
5276
|
},
|
|
5249
5277
|
async get(t, n) {
|
|
5250
5278
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5251
|
-
return r ?
|
|
5279
|
+
return r ? co(r) : null;
|
|
5252
5280
|
},
|
|
5253
5281
|
async list(t) {
|
|
5254
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5282
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(co);
|
|
5255
5283
|
},
|
|
5256
5284
|
async update(t, n, r) {
|
|
5257
5285
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5264,7 +5292,7 @@ function co(e) {
|
|
|
5264
5292
|
}
|
|
5265
5293
|
//#endregion
|
|
5266
5294
|
//#region src/migrationSources/index.ts
|
|
5267
|
-
function
|
|
5295
|
+
function uo(e) {
|
|
5268
5296
|
return {
|
|
5269
5297
|
id: e.id,
|
|
5270
5298
|
name: e.name,
|
|
@@ -5276,7 +5304,7 @@ function lo(e) {
|
|
|
5276
5304
|
updated_at: e.updated_at
|
|
5277
5305
|
};
|
|
5278
5306
|
}
|
|
5279
|
-
function
|
|
5307
|
+
function fo(e) {
|
|
5280
5308
|
return {
|
|
5281
5309
|
async create(n, r, i) {
|
|
5282
5310
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5290,14 +5318,14 @@ function uo(e) {
|
|
|
5290
5318
|
created_at: a?.created_at ?? o,
|
|
5291
5319
|
updated_at: a?.updated_at ?? o
|
|
5292
5320
|
};
|
|
5293
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5321
|
+
return await e.insertInto("migration_sources").values(l).execute(), uo(l);
|
|
5294
5322
|
},
|
|
5295
5323
|
async get(t, n) {
|
|
5296
5324
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5297
|
-
return r ?
|
|
5325
|
+
return r ? uo(r) : null;
|
|
5298
5326
|
},
|
|
5299
5327
|
async list(t) {
|
|
5300
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5328
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(uo);
|
|
5301
5329
|
},
|
|
5302
5330
|
async update(t, n, r) {
|
|
5303
5331
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5310,19 +5338,19 @@ function uo(e) {
|
|
|
5310
5338
|
}
|
|
5311
5339
|
//#endregion
|
|
5312
5340
|
//#region src/proxyRoutes/serialize.ts
|
|
5313
|
-
function
|
|
5341
|
+
function po(e) {
|
|
5314
5342
|
return {
|
|
5315
5343
|
id: e.id,
|
|
5316
5344
|
tenant_id: e.tenant_id,
|
|
5317
5345
|
custom_domain_id: e.custom_domain_id,
|
|
5318
5346
|
priority: e.priority,
|
|
5319
|
-
match:
|
|
5320
|
-
handlers:
|
|
5347
|
+
match: mo(e.match),
|
|
5348
|
+
handlers: ho(e.handlers),
|
|
5321
5349
|
created_at: e.created_at,
|
|
5322
5350
|
updated_at: e.updated_at
|
|
5323
5351
|
};
|
|
5324
5352
|
}
|
|
5325
|
-
function
|
|
5353
|
+
function mo(e) {
|
|
5326
5354
|
if (!e) return { path: "/*" };
|
|
5327
5355
|
try {
|
|
5328
5356
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5330,7 +5358,7 @@ function po(e) {
|
|
|
5330
5358
|
} catch {}
|
|
5331
5359
|
return { path: "/*" };
|
|
5332
5360
|
}
|
|
5333
|
-
function
|
|
5361
|
+
function ho(e) {
|
|
5334
5362
|
if (!e) return [];
|
|
5335
5363
|
try {
|
|
5336
5364
|
let t = JSON.parse(e);
|
|
@@ -5347,7 +5375,7 @@ function mo(e) {
|
|
|
5347
5375
|
}
|
|
5348
5376
|
//#endregion
|
|
5349
5377
|
//#region src/proxyRoutes/adapter.ts
|
|
5350
|
-
function
|
|
5378
|
+
function go(e) {
|
|
5351
5379
|
return {
|
|
5352
5380
|
async create(n, r, i) {
|
|
5353
5381
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5373,14 +5401,14 @@ function ho(e) {
|
|
|
5373
5401
|
},
|
|
5374
5402
|
async get(t, n) {
|
|
5375
5403
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5376
|
-
return r ?
|
|
5404
|
+
return r ? po(r) : null;
|
|
5377
5405
|
},
|
|
5378
5406
|
async list(t, n = {}) {
|
|
5379
5407
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5380
5408
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5381
5409
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5382
5410
|
return {
|
|
5383
|
-
proxy_routes: o.map(
|
|
5411
|
+
proxy_routes: o.map(po),
|
|
5384
5412
|
start: r * i,
|
|
5385
5413
|
limit: i,
|
|
5386
5414
|
length: o.length
|
|
@@ -5400,7 +5428,7 @@ function ho(e) {
|
|
|
5400
5428
|
}
|
|
5401
5429
|
//#endregion
|
|
5402
5430
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5403
|
-
async function
|
|
5431
|
+
async function _o(e, t) {
|
|
5404
5432
|
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([
|
|
5405
5433
|
"custom_domain_id",
|
|
5406
5434
|
"tenant_id",
|
|
@@ -5412,20 +5440,20 @@ async function go(e, t) {
|
|
|
5412
5440
|
tenant_id: a.tenant_id,
|
|
5413
5441
|
custom_domain_id: a.custom_domain_id,
|
|
5414
5442
|
domain: a.domain,
|
|
5415
|
-
routes: o.map(
|
|
5443
|
+
routes: o.map(po)
|
|
5416
5444
|
};
|
|
5417
5445
|
}
|
|
5418
5446
|
//#endregion
|
|
5419
5447
|
//#region src/proxyRoutes/index.ts
|
|
5420
|
-
function
|
|
5448
|
+
function vo(e) {
|
|
5421
5449
|
return {
|
|
5422
|
-
proxyRoutes:
|
|
5423
|
-
resolveHost: (t) =>
|
|
5450
|
+
proxyRoutes: go(e),
|
|
5451
|
+
resolveHost: (t) => _o(e, t)
|
|
5424
5452
|
};
|
|
5425
5453
|
}
|
|
5426
5454
|
//#endregion
|
|
5427
5455
|
//#region src/scim/adapter.ts
|
|
5428
|
-
function
|
|
5456
|
+
function yo(e) {
|
|
5429
5457
|
if (!e) return [];
|
|
5430
5458
|
try {
|
|
5431
5459
|
let t = JSON.parse(e);
|
|
@@ -5440,7 +5468,7 @@ function vo(e) {
|
|
|
5440
5468
|
return [];
|
|
5441
5469
|
}
|
|
5442
5470
|
}
|
|
5443
|
-
function
|
|
5471
|
+
function bo(e) {
|
|
5444
5472
|
if (!e) return [];
|
|
5445
5473
|
try {
|
|
5446
5474
|
let t = JSON.parse(e);
|
|
@@ -5449,16 +5477,16 @@ function yo(e) {
|
|
|
5449
5477
|
return [];
|
|
5450
5478
|
}
|
|
5451
5479
|
}
|
|
5452
|
-
function
|
|
5480
|
+
function xo(e) {
|
|
5453
5481
|
return {
|
|
5454
5482
|
connection_id: e.connection_id,
|
|
5455
5483
|
user_id_attribute: e.user_id_attribute,
|
|
5456
|
-
mapping:
|
|
5484
|
+
mapping: yo(e.mapping),
|
|
5457
5485
|
created_at: e.created_at,
|
|
5458
5486
|
updated_at: e.updated_at
|
|
5459
5487
|
};
|
|
5460
5488
|
}
|
|
5461
|
-
function
|
|
5489
|
+
function So(e) {
|
|
5462
5490
|
return {
|
|
5463
5491
|
async create(t, n) {
|
|
5464
5492
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5479,7 +5507,7 @@ function xo(e) {
|
|
|
5479
5507
|
},
|
|
5480
5508
|
async get(t, n) {
|
|
5481
5509
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5482
|
-
return r ?
|
|
5510
|
+
return r ? xo(r) : null;
|
|
5483
5511
|
},
|
|
5484
5512
|
async update(t, n, r) {
|
|
5485
5513
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5493,18 +5521,18 @@ function xo(e) {
|
|
|
5493
5521
|
}
|
|
5494
5522
|
};
|
|
5495
5523
|
}
|
|
5496
|
-
function
|
|
5524
|
+
function Co(e) {
|
|
5497
5525
|
return {
|
|
5498
5526
|
token_id: e.token_id,
|
|
5499
5527
|
connection_id: e.connection_id,
|
|
5500
5528
|
token_hash: e.token_hash,
|
|
5501
|
-
scopes:
|
|
5529
|
+
scopes: bo(e.scopes),
|
|
5502
5530
|
valid_until: e.valid_until ?? void 0,
|
|
5503
5531
|
created_at: e.created_at,
|
|
5504
5532
|
last_used_at: e.last_used_at ?? void 0
|
|
5505
5533
|
};
|
|
5506
5534
|
}
|
|
5507
|
-
function
|
|
5535
|
+
function wo(e) {
|
|
5508
5536
|
return {
|
|
5509
5537
|
async create(t, n) {
|
|
5510
5538
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5528,14 +5556,14 @@ function Co(e) {
|
|
|
5528
5556
|
},
|
|
5529
5557
|
async get(t, n) {
|
|
5530
5558
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5531
|
-
return r ?
|
|
5559
|
+
return r ? Co(r) : null;
|
|
5532
5560
|
},
|
|
5533
5561
|
async getByHash(t, n) {
|
|
5534
5562
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5535
|
-
return r ?
|
|
5563
|
+
return r ? Co(r) : null;
|
|
5536
5564
|
},
|
|
5537
5565
|
async listByConnection(t, n) {
|
|
5538
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5566
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Co);
|
|
5539
5567
|
},
|
|
5540
5568
|
async markUsed(t, n, r) {
|
|
5541
5569
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5547,7 +5575,7 @@ function Co(e) {
|
|
|
5547
5575
|
}
|
|
5548
5576
|
};
|
|
5549
5577
|
}
|
|
5550
|
-
function
|
|
5578
|
+
function To(e) {
|
|
5551
5579
|
return {
|
|
5552
5580
|
connection_id: e.connection_id,
|
|
5553
5581
|
external_id: e.external_id,
|
|
@@ -5555,7 +5583,7 @@ function wo(e) {
|
|
|
5555
5583
|
created_at: e.created_at
|
|
5556
5584
|
};
|
|
5557
5585
|
}
|
|
5558
|
-
function
|
|
5586
|
+
function Eo(e) {
|
|
5559
5587
|
return {
|
|
5560
5588
|
async create(t, n) {
|
|
5561
5589
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5574,11 +5602,11 @@ function To(e) {
|
|
|
5574
5602
|
},
|
|
5575
5603
|
async getByExternalId(t, n, r) {
|
|
5576
5604
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5577
|
-
return i ?
|
|
5605
|
+
return i ? To(i) : null;
|
|
5578
5606
|
},
|
|
5579
5607
|
async getByUserId(t, n, r) {
|
|
5580
5608
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5581
|
-
return i ?
|
|
5609
|
+
return i ? To(i) : null;
|
|
5582
5610
|
},
|
|
5583
5611
|
async remove(t, n, r) {
|
|
5584
5612
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5588,7 +5616,7 @@ function To(e) {
|
|
|
5588
5616
|
}
|
|
5589
5617
|
//#endregion
|
|
5590
5618
|
//#region src/tenantOperations/index.ts
|
|
5591
|
-
function
|
|
5619
|
+
function Do(e) {
|
|
5592
5620
|
if (!e) return null;
|
|
5593
5621
|
try {
|
|
5594
5622
|
let t = JSON.parse(e);
|
|
@@ -5610,8 +5638,8 @@ function J(e) {
|
|
|
5610
5638
|
target_database_version: e.target_database_version,
|
|
5611
5639
|
error: e.error,
|
|
5612
5640
|
initiated_by: e.initiated_by,
|
|
5613
|
-
input:
|
|
5614
|
-
result:
|
|
5641
|
+
input: Do(e.input),
|
|
5642
|
+
result: Do(e.result),
|
|
5615
5643
|
claimed_by: e.claimed_by,
|
|
5616
5644
|
claim_expires_at: e.claim_expires_at,
|
|
5617
5645
|
created_at: e.created_at,
|
|
@@ -5619,7 +5647,7 @@ function J(e) {
|
|
|
5619
5647
|
finished_at: e.finished_at
|
|
5620
5648
|
});
|
|
5621
5649
|
}
|
|
5622
|
-
function
|
|
5650
|
+
function Oo(e) {
|
|
5623
5651
|
return {
|
|
5624
5652
|
async create(n) {
|
|
5625
5653
|
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5702,27 +5730,27 @@ function Do(e) {
|
|
|
5702
5730
|
}
|
|
5703
5731
|
//#endregion
|
|
5704
5732
|
//#region src/utils/monotonic-id.ts
|
|
5705
|
-
var
|
|
5706
|
-
function
|
|
5733
|
+
var ko = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ao = 32, jo = 10, Mo = 4, No = 10;
|
|
5734
|
+
function Po(e, t) {
|
|
5707
5735
|
let n = "";
|
|
5708
|
-
for (let r = t; r > 0; r--) n =
|
|
5736
|
+
for (let r = t; r > 0; r--) n = ko.charAt(e % Ao) + n, e = Math.floor(e / Ao);
|
|
5709
5737
|
return n;
|
|
5710
5738
|
}
|
|
5711
|
-
function
|
|
5712
|
-
let e = new Uint8Array(
|
|
5739
|
+
function Fo() {
|
|
5740
|
+
let e = new Uint8Array(No);
|
|
5713
5741
|
crypto.getRandomValues(e);
|
|
5714
5742
|
let t = "";
|
|
5715
|
-
for (let n = 0; n <
|
|
5743
|
+
for (let n = 0; n < No; n++) t += ko.charAt(e[n] % Ao);
|
|
5716
5744
|
return t;
|
|
5717
5745
|
}
|
|
5718
|
-
var
|
|
5719
|
-
function
|
|
5746
|
+
var Io = 0, Lo = 0;
|
|
5747
|
+
function Ro() {
|
|
5720
5748
|
let e = Date.now();
|
|
5721
|
-
return e ===
|
|
5749
|
+
return e === Io ? Lo++ : (Io = e, Lo = 0), Po(e, jo) + Po(Lo, Mo) + Fo();
|
|
5722
5750
|
}
|
|
5723
5751
|
//#endregion
|
|
5724
5752
|
//#region src/tenantOperationEvents/index.ts
|
|
5725
|
-
function
|
|
5753
|
+
function zo(e) {
|
|
5726
5754
|
if (!e) return null;
|
|
5727
5755
|
try {
|
|
5728
5756
|
let t = JSON.parse(e);
|
|
@@ -5730,22 +5758,22 @@ function Ro(e) {
|
|
|
5730
5758
|
} catch {}
|
|
5731
5759
|
return null;
|
|
5732
5760
|
}
|
|
5733
|
-
function
|
|
5761
|
+
function Bo(e) {
|
|
5734
5762
|
return ve.parse({
|
|
5735
5763
|
id: e.id,
|
|
5736
5764
|
operation_id: e.operation_id,
|
|
5737
5765
|
step: e.step,
|
|
5738
5766
|
outcome: e.outcome,
|
|
5739
|
-
detail:
|
|
5767
|
+
detail: zo(e.detail),
|
|
5740
5768
|
attempt: e.attempt,
|
|
5741
5769
|
created_at: e.created_at
|
|
5742
5770
|
});
|
|
5743
5771
|
}
|
|
5744
|
-
function
|
|
5772
|
+
function Vo(e) {
|
|
5745
5773
|
return {
|
|
5746
5774
|
async create(t) {
|
|
5747
5775
|
let n = _e.parse(t), r = {
|
|
5748
|
-
id: `evt_${
|
|
5776
|
+
id: `evt_${Ro()}`,
|
|
5749
5777
|
operation_id: n.operation_id,
|
|
5750
5778
|
step: n.step,
|
|
5751
5779
|
outcome: n.outcome,
|
|
@@ -5753,12 +5781,12 @@ function Bo(e) {
|
|
|
5753
5781
|
attempt: n.attempt,
|
|
5754
5782
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5755
5783
|
};
|
|
5756
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5784
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Bo(r);
|
|
5757
5785
|
},
|
|
5758
5786
|
async listByOperation(t, n = {}) {
|
|
5759
5787
|
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();
|
|
5760
5788
|
return {
|
|
5761
|
-
events: a.map(
|
|
5789
|
+
events: a.map(Bo),
|
|
5762
5790
|
start: r * i,
|
|
5763
5791
|
limit: i,
|
|
5764
5792
|
length: a.length
|
|
@@ -5768,16 +5796,16 @@ function Bo(e) {
|
|
|
5768
5796
|
}
|
|
5769
5797
|
//#endregion
|
|
5770
5798
|
//#region src/tenantOperationRows/index.ts
|
|
5771
|
-
var
|
|
5772
|
-
function
|
|
5799
|
+
var Ho = 50;
|
|
5800
|
+
function Uo(e) {
|
|
5773
5801
|
let t = JSON.parse(e);
|
|
5774
5802
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5775
5803
|
}
|
|
5776
|
-
function
|
|
5804
|
+
function Wo(e) {
|
|
5777
5805
|
return xe.parse({
|
|
5778
5806
|
operation_id: e.operation_id,
|
|
5779
5807
|
seq: e.seq,
|
|
5780
|
-
payload:
|
|
5808
|
+
payload: Uo(e.payload),
|
|
5781
5809
|
status: e.status,
|
|
5782
5810
|
error_code: e.error_code,
|
|
5783
5811
|
error_message: e.error_message,
|
|
@@ -5787,7 +5815,7 @@ function Uo(e) {
|
|
|
5787
5815
|
updated_at: e.updated_at
|
|
5788
5816
|
});
|
|
5789
5817
|
}
|
|
5790
|
-
function
|
|
5818
|
+
function Go(e) {
|
|
5791
5819
|
return {
|
|
5792
5820
|
async createMany(t) {
|
|
5793
5821
|
if (t.length === 0) return 0;
|
|
@@ -5806,11 +5834,11 @@ function Wo(e) {
|
|
|
5806
5834
|
updated_at: n
|
|
5807
5835
|
};
|
|
5808
5836
|
});
|
|
5809
|
-
for (let t = 0; t < r.length; t +=
|
|
5837
|
+
for (let t = 0; t < r.length; t += Ho) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + Ho)).execute();
|
|
5810
5838
|
return r.length;
|
|
5811
5839
|
},
|
|
5812
5840
|
async claimPending(t, n) {
|
|
5813
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5841
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(Wo);
|
|
5814
5842
|
},
|
|
5815
5843
|
async recordOutcomes(t, n) {
|
|
5816
5844
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5859,7 +5887,7 @@ function Wo(e) {
|
|
|
5859
5887
|
}
|
|
5860
5888
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5861
5889
|
return {
|
|
5862
|
-
rows: o.map(
|
|
5890
|
+
rows: o.map(Wo),
|
|
5863
5891
|
start: r * i,
|
|
5864
5892
|
limit: i,
|
|
5865
5893
|
length: o.length
|
|
@@ -5873,7 +5901,7 @@ function Wo(e) {
|
|
|
5873
5901
|
}
|
|
5874
5902
|
//#endregion
|
|
5875
5903
|
//#region src/rollouts/index.ts
|
|
5876
|
-
function
|
|
5904
|
+
function Ko(e) {
|
|
5877
5905
|
if (!e) return null;
|
|
5878
5906
|
try {
|
|
5879
5907
|
return JSON.parse(e);
|
|
@@ -5881,7 +5909,7 @@ function Go(e) {
|
|
|
5881
5909
|
return null;
|
|
5882
5910
|
}
|
|
5883
5911
|
}
|
|
5884
|
-
function
|
|
5912
|
+
function qo(e) {
|
|
5885
5913
|
return pe.parse({
|
|
5886
5914
|
id: e.id,
|
|
5887
5915
|
kind: e.kind,
|
|
@@ -5889,15 +5917,15 @@ function Ko(e) {
|
|
|
5889
5917
|
target_worker_version: e.target_worker_version,
|
|
5890
5918
|
target_database_version: e.target_database_version,
|
|
5891
5919
|
wave_size: e.wave_size,
|
|
5892
|
-
canary_tenant_ids:
|
|
5893
|
-
filter:
|
|
5920
|
+
canary_tenant_ids: Ko(e.canary_tenant_ids),
|
|
5921
|
+
filter: Ko(e.filter),
|
|
5894
5922
|
initiated_by: e.initiated_by,
|
|
5895
5923
|
created_at: e.created_at,
|
|
5896
5924
|
updated_at: e.updated_at,
|
|
5897
5925
|
finished_at: e.finished_at
|
|
5898
5926
|
});
|
|
5899
5927
|
}
|
|
5900
|
-
function
|
|
5928
|
+
function Jo(e) {
|
|
5901
5929
|
return {
|
|
5902
5930
|
async create(n) {
|
|
5903
5931
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5914,16 +5942,16 @@ function qo(e) {
|
|
|
5914
5942
|
updated_at: i,
|
|
5915
5943
|
finished_at: null
|
|
5916
5944
|
};
|
|
5917
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5945
|
+
return await e.insertInto("rollouts").values(a).execute(), qo(a);
|
|
5918
5946
|
},
|
|
5919
5947
|
async get(t) {
|
|
5920
5948
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5921
|
-
return n ?
|
|
5949
|
+
return n ? qo(n) : null;
|
|
5922
5950
|
},
|
|
5923
5951
|
async list(t = {}) {
|
|
5924
5952
|
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();
|
|
5925
5953
|
return {
|
|
5926
|
-
rollouts: i.map(
|
|
5954
|
+
rollouts: i.map(qo),
|
|
5927
5955
|
start: n * r,
|
|
5928
5956
|
limit: r,
|
|
5929
5957
|
length: i.length
|
|
@@ -5943,7 +5971,7 @@ function qo(e) {
|
|
|
5943
5971
|
}
|
|
5944
5972
|
//#endregion
|
|
5945
5973
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5946
|
-
var
|
|
5974
|
+
var Yo = class {
|
|
5947
5975
|
migrations;
|
|
5948
5976
|
constructor(e) {
|
|
5949
5977
|
this.migrations = e;
|
|
@@ -5951,10 +5979,10 @@ var Jo = class {
|
|
|
5951
5979
|
async getMigrations() {
|
|
5952
5980
|
return this.migrations;
|
|
5953
5981
|
}
|
|
5954
|
-
},
|
|
5955
|
-
down: () =>
|
|
5956
|
-
up: () =>
|
|
5957
|
-
}),
|
|
5982
|
+
}, Xo = /* @__PURE__ */ T({
|
|
5983
|
+
down: () => es,
|
|
5984
|
+
up: () => $o
|
|
5985
|
+
}), Zo = [
|
|
5958
5986
|
{
|
|
5959
5987
|
table: "authentication_methods",
|
|
5960
5988
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6220,7 +6248,7 @@ var Jo = class {
|
|
|
6220
6248
|
onDelete: "cascade"
|
|
6221
6249
|
}
|
|
6222
6250
|
];
|
|
6223
|
-
async function
|
|
6251
|
+
async function Qo(e) {
|
|
6224
6252
|
try {
|
|
6225
6253
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
6226
6254
|
} catch {
|
|
@@ -6229,14 +6257,14 @@ async function Zo(e) {
|
|
|
6229
6257
|
}
|
|
6230
6258
|
function Y(e, t) {
|
|
6231
6259
|
let n = e;
|
|
6232
|
-
for (let e of
|
|
6260
|
+
for (let e of Zo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6233
6261
|
let n = t;
|
|
6234
6262
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6235
6263
|
}));
|
|
6236
6264
|
return n;
|
|
6237
6265
|
}
|
|
6238
|
-
async function
|
|
6239
|
-
let t = await
|
|
6266
|
+
async function $o(e) {
|
|
6267
|
+
let t = await Qo(e);
|
|
6240
6268
|
await e.schema.createTable("tenants").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("audience", f`varchar(255)`).addColumn("sender_email", f`varchar(255)`).addColumn("sender_name", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addColumn("support_url", f`varchar(255)`).addColumn("idle_session_lifetime", f`int`).addColumn("session_lifetime", f`int`).addColumn("session_cookie", f`text`).addColumn("allowed_logout_urls", f`text`).addColumn("ephemeral_session_lifetime", f`int`).addColumn("idle_ephemeral_session_lifetime", f`int`).addColumn("default_redirection_uri", f`text`).addColumn("enabled_locales", f`text`).addColumn("default_directory", f`varchar(255)`).addColumn("error_page", f`text`).addColumn("flags", f`text`).addColumn("friendly_name", f`varchar(255)`).addColumn("picture_url", f`text`).addColumn("support_email", f`varchar(255)`).addColumn("sandbox_version", f`varchar(50)`).addColumn("sandbox_versions_available", f`text`).addColumn("legacy_sandbox_version", f`varchar(50)`).addColumn("change_password", f`text`).addColumn("guardian_mfa_page", f`text`).addColumn("device_flow", f`text`).addColumn("default_token_quota", f`text`).addColumn("default_audience", f`varchar(255)`).addColumn("default_organization", f`varchar(255)`).addColumn("sessions", f`text`).addColumn("oidc_logout", f`text`).addColumn("allow_organization_name_in_authentication_api", f`int`).addColumn("customize_mfa_in_postlogin_action", f`int`).addColumn("acr_values_supported", f`text`).addColumn("mtls", f`text`).addColumn("pushed_authorization_requests_supported", f`int`).addColumn("authorization_response_iss_parameter_supported", f`int`).addColumn("mfa", f`text`).addColumn("attack_protection", f`text`).addColumn("default_client_id", f`varchar(255)`).addColumn("deployment_type", f`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", f`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", f`varchar(2048)`).addColumn("provisioning_state_changed_at", f`varchar(35)`).addColumn("bundle_configuration", f`varchar(64)`).addColumn("worker_version", f`varchar(64)`).addColumn("worker_script_name", f`varchar(255)`).addColumn("storage_kind", f`varchar(32)`).addColumn("d1_database_id", f`varchar(64)`).addColumn("database_version", f`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", f`varchar(64)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("results", f`text`, (e) => e.notNull()).addColumn("logs", f`text`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("action_id", f`varchar(255)`, (e) => e.notNull()).addColumn("number", f`int`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("status", f`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed_at_ts", f`bigint`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
6241
6269
|
{
|
|
6242
6270
|
let n = e.schema.createTable("authentication_methods").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("type", f`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", f`varchar(32)`).addColumn("totp_secret", f`varchar(255)`).addColumn("confirmed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("credential_id", f`varchar(512)`).addColumn("public_key", f`text`).addColumn("sign_count", f`int`).addColumn("credential_backed_up", f`int`).addColumn("transports", f`varchar(512)`).addColumn("friendly_name", f`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
@@ -6423,40 +6451,40 @@ async function Qo(e) {
|
|
|
6423
6451
|
"tenant_id",
|
|
6424
6452
|
"phone_number",
|
|
6425
6453
|
"provider"
|
|
6426
|
-
]).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
|
|
6454
|
+
]).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 Zo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6427
6455
|
let n = e;
|
|
6428
6456
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6429
6457
|
}).execute();
|
|
6430
6458
|
}
|
|
6431
|
-
async function
|
|
6459
|
+
async function es(e) {
|
|
6432
6460
|
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();
|
|
6433
6461
|
}
|
|
6434
6462
|
//#endregion
|
|
6435
6463
|
//#region migrate/log.ts
|
|
6436
|
-
var
|
|
6437
|
-
function
|
|
6438
|
-
|
|
6464
|
+
var ts = !1;
|
|
6465
|
+
function ns(e) {
|
|
6466
|
+
ts = e;
|
|
6439
6467
|
}
|
|
6440
6468
|
function X(...e) {
|
|
6441
|
-
|
|
6469
|
+
ts && console.log(...e);
|
|
6442
6470
|
}
|
|
6443
6471
|
function Z(...e) {
|
|
6444
6472
|
console.warn(...e);
|
|
6445
6473
|
}
|
|
6446
6474
|
//#endregion
|
|
6447
6475
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6448
|
-
var
|
|
6449
|
-
down: () =>
|
|
6450
|
-
up: () =>
|
|
6451
|
-
}),
|
|
6452
|
-
async function
|
|
6476
|
+
var rs = /* @__PURE__ */ T({
|
|
6477
|
+
down: () => ms,
|
|
6478
|
+
up: () => ds
|
|
6479
|
+
}), is = 5e4, as = 500;
|
|
6480
|
+
async function os(e) {
|
|
6453
6481
|
try {
|
|
6454
6482
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6455
6483
|
} catch {
|
|
6456
6484
|
return "sqlite";
|
|
6457
6485
|
}
|
|
6458
6486
|
}
|
|
6459
|
-
async function
|
|
6487
|
+
async function ss(e, t, n) {
|
|
6460
6488
|
try {
|
|
6461
6489
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6462
6490
|
} catch (e) {
|
|
@@ -6467,7 +6495,7 @@ async function os(e, t, n) {
|
|
|
6467
6495
|
throw e;
|
|
6468
6496
|
}
|
|
6469
6497
|
}
|
|
6470
|
-
async function
|
|
6498
|
+
async function cs(e, t, n, r) {
|
|
6471
6499
|
try {
|
|
6472
6500
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6473
6501
|
} catch (e) {
|
|
@@ -6478,21 +6506,21 @@ async function ss(e, t, n, r) {
|
|
|
6478
6506
|
throw e;
|
|
6479
6507
|
}
|
|
6480
6508
|
}
|
|
6481
|
-
async function
|
|
6509
|
+
async function ls(e, t) {
|
|
6482
6510
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6483
6511
|
if (t === "sqlite") {
|
|
6484
6512
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6485
6513
|
r = Number(t.numDeletedRows);
|
|
6486
6514
|
} else {
|
|
6487
|
-
let t =
|
|
6488
|
-
for (; t >=
|
|
6489
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6515
|
+
let t = is;
|
|
6516
|
+
for (; t >= is;) {
|
|
6517
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(is).executeTakeFirst();
|
|
6490
6518
|
t = Number(i.numDeletedRows), r += t, t > 0 && X(` Pruned ${r} expired codes row(s)...`);
|
|
6491
6519
|
}
|
|
6492
6520
|
}
|
|
6493
6521
|
return r;
|
|
6494
6522
|
}
|
|
6495
|
-
async function
|
|
6523
|
+
async function us(e) {
|
|
6496
6524
|
let t = 0;
|
|
6497
6525
|
for (;;) {
|
|
6498
6526
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6500,33 +6528,33 @@ async function ls(e) {
|
|
|
6500
6528
|
"code_type",
|
|
6501
6529
|
"tenant_id",
|
|
6502
6530
|
"expires_at"
|
|
6503
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6531
|
+
]).where("expires_at_ts", "is", null).limit(as).execute();
|
|
6504
6532
|
if (n.length === 0) break;
|
|
6505
6533
|
for (let t of n) {
|
|
6506
6534
|
let n = Date.parse(t.expires_at);
|
|
6507
6535
|
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();
|
|
6508
6536
|
}
|
|
6509
|
-
if (t += n.length, n.length <
|
|
6537
|
+
if (t += n.length, n.length < as) break;
|
|
6510
6538
|
}
|
|
6511
6539
|
return t;
|
|
6512
6540
|
}
|
|
6513
|
-
async function
|
|
6514
|
-
let t = await
|
|
6541
|
+
async function ds(e) {
|
|
6542
|
+
let t = await os(e);
|
|
6515
6543
|
try {
|
|
6516
|
-
let n = await
|
|
6544
|
+
let n = await ls(e, t);
|
|
6517
6545
|
X(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6518
6546
|
} catch (e) {
|
|
6519
6547
|
Z(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6520
6548
|
}
|
|
6521
|
-
await
|
|
6549
|
+
await ss(e, "codes", "expires_at_ts"), await cs(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6522
6550
|
try {
|
|
6523
|
-
let t = await
|
|
6551
|
+
let t = await us(e);
|
|
6524
6552
|
X(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6525
6553
|
} catch (e) {
|
|
6526
6554
|
Z(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6527
6555
|
}
|
|
6528
6556
|
}
|
|
6529
|
-
async function
|
|
6557
|
+
async function fs(e, t, n) {
|
|
6530
6558
|
try {
|
|
6531
6559
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6532
6560
|
} catch (e) {
|
|
@@ -6534,7 +6562,7 @@ async function ds(e, t, n) {
|
|
|
6534
6562
|
throw e;
|
|
6535
6563
|
}
|
|
6536
6564
|
}
|
|
6537
|
-
async function
|
|
6565
|
+
async function ps(e, t, n) {
|
|
6538
6566
|
try {
|
|
6539
6567
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6540
6568
|
} catch (e) {
|
|
@@ -6542,16 +6570,16 @@ async function fs(e, t, n) {
|
|
|
6542
6570
|
throw e;
|
|
6543
6571
|
}
|
|
6544
6572
|
}
|
|
6545
|
-
async function
|
|
6546
|
-
await
|
|
6573
|
+
async function ms(e) {
|
|
6574
|
+
await fs(e, "idx_codes_expires_at_ts", "codes"), await ps(e, "codes", "expires_at_ts");
|
|
6547
6575
|
}
|
|
6548
6576
|
//#endregion
|
|
6549
6577
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6550
|
-
var
|
|
6551
|
-
down: () =>
|
|
6552
|
-
up: () =>
|
|
6578
|
+
var hs = /* @__PURE__ */ T({
|
|
6579
|
+
down: () => _s,
|
|
6580
|
+
up: () => gs
|
|
6553
6581
|
});
|
|
6554
|
-
async function
|
|
6582
|
+
async function gs(e) {
|
|
6555
6583
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", f`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(128)`, (e) => e.notNull()).addColumn("scopes", f`text`, (e) => e.notNull()).addColumn("valid_until", f`varchar(35)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", f`varchar(35)`).addPrimaryKeyConstraint("scim_tokens_pk", ["tenant_id", "token_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_connection_idx").on("scim_tokens").columns(["tenant_id", "connection_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_hash_idx").on("scim_tokens").columns(["tenant_id", "token_hash"]).unique().execute(), await e.schema.createTable("scim_external_ids").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("external_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6556
6584
|
"tenant_id",
|
|
6557
6585
|
"connection_id",
|
|
@@ -6562,16 +6590,16 @@ async function hs(e) {
|
|
|
6562
6590
|
"external_id"
|
|
6563
6591
|
]).unique().execute();
|
|
6564
6592
|
}
|
|
6565
|
-
async function
|
|
6593
|
+
async function _s(e) {
|
|
6566
6594
|
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();
|
|
6567
6595
|
}
|
|
6568
6596
|
//#endregion
|
|
6569
6597
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6570
|
-
var
|
|
6571
|
-
down: () =>
|
|
6572
|
-
up: () =>
|
|
6598
|
+
var vs = /* @__PURE__ */ T({
|
|
6599
|
+
down: () => Ss,
|
|
6600
|
+
up: () => bs
|
|
6573
6601
|
});
|
|
6574
|
-
async function
|
|
6602
|
+
async function ys(e, t, n) {
|
|
6575
6603
|
try {
|
|
6576
6604
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6577
6605
|
} catch (e) {
|
|
@@ -6579,10 +6607,10 @@ async function vs(e, t, n) {
|
|
|
6579
6607
|
throw e;
|
|
6580
6608
|
}
|
|
6581
6609
|
}
|
|
6582
|
-
async function
|
|
6583
|
-
await
|
|
6610
|
+
async function bs(e) {
|
|
6611
|
+
await ys(e, "users", "blocked");
|
|
6584
6612
|
}
|
|
6585
|
-
async function
|
|
6613
|
+
async function xs(e, t, n) {
|
|
6586
6614
|
try {
|
|
6587
6615
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6588
6616
|
} catch (e) {
|
|
@@ -6590,16 +6618,16 @@ async function bs(e, t, n) {
|
|
|
6590
6618
|
throw e;
|
|
6591
6619
|
}
|
|
6592
6620
|
}
|
|
6593
|
-
async function
|
|
6594
|
-
await
|
|
6621
|
+
async function Ss(e) {
|
|
6622
|
+
await xs(e, "users", "blocked");
|
|
6595
6623
|
}
|
|
6596
6624
|
//#endregion
|
|
6597
6625
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6598
|
-
var
|
|
6599
|
-
down: () =>
|
|
6600
|
-
up: () =>
|
|
6626
|
+
var Cs = /* @__PURE__ */ T({
|
|
6627
|
+
down: () => Ds,
|
|
6628
|
+
up: () => Ts
|
|
6601
6629
|
});
|
|
6602
|
-
async function
|
|
6630
|
+
async function ws(e, t, n) {
|
|
6603
6631
|
try {
|
|
6604
6632
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6605
6633
|
} catch (e) {
|
|
@@ -6607,10 +6635,10 @@ async function Cs(e, t, n) {
|
|
|
6607
6635
|
throw e;
|
|
6608
6636
|
}
|
|
6609
6637
|
}
|
|
6610
|
-
async function
|
|
6611
|
-
await
|
|
6638
|
+
async function Ts(e) {
|
|
6639
|
+
await ws(e, "prompt_settings", "show_last_used_connection");
|
|
6612
6640
|
}
|
|
6613
|
-
async function
|
|
6641
|
+
async function Es(e, t, n) {
|
|
6614
6642
|
try {
|
|
6615
6643
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6616
6644
|
} catch (e) {
|
|
@@ -6618,16 +6646,16 @@ async function Ts(e, t, n) {
|
|
|
6618
6646
|
throw e;
|
|
6619
6647
|
}
|
|
6620
6648
|
}
|
|
6621
|
-
async function
|
|
6622
|
-
await
|
|
6649
|
+
async function Ds(e) {
|
|
6650
|
+
await Es(e, "prompt_settings", "show_last_used_connection");
|
|
6623
6651
|
}
|
|
6624
6652
|
//#endregion
|
|
6625
6653
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6626
|
-
var
|
|
6627
|
-
down: () =>
|
|
6628
|
-
up: () =>
|
|
6654
|
+
var Os = /* @__PURE__ */ T({
|
|
6655
|
+
down: () => js,
|
|
6656
|
+
up: () => As
|
|
6629
6657
|
});
|
|
6630
|
-
async function
|
|
6658
|
+
async function ks(e, t, n, r) {
|
|
6631
6659
|
try {
|
|
6632
6660
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6633
6661
|
} catch (e) {
|
|
@@ -6638,10 +6666,10 @@ async function Os(e, t, n, r) {
|
|
|
6638
6666
|
throw e;
|
|
6639
6667
|
}
|
|
6640
6668
|
}
|
|
6641
|
-
async function ks(e) {
|
|
6642
|
-
await Os(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6643
|
-
}
|
|
6644
6669
|
async function As(e) {
|
|
6670
|
+
await ks(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6671
|
+
}
|
|
6672
|
+
async function js(e) {
|
|
6645
6673
|
try {
|
|
6646
6674
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6647
6675
|
} catch (e) {
|
|
@@ -6651,11 +6679,11 @@ async function As(e) {
|
|
|
6651
6679
|
}
|
|
6652
6680
|
//#endregion
|
|
6653
6681
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6654
|
-
var
|
|
6655
|
-
down: () =>
|
|
6656
|
-
up: () =>
|
|
6682
|
+
var Ms = /* @__PURE__ */ T({
|
|
6683
|
+
down: () => Is,
|
|
6684
|
+
up: () => Ps
|
|
6657
6685
|
});
|
|
6658
|
-
async function
|
|
6686
|
+
async function Ns(e, t, n, r) {
|
|
6659
6687
|
try {
|
|
6660
6688
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6661
6689
|
} catch (e) {
|
|
@@ -6663,10 +6691,10 @@ async function Ms(e, t, n, r) {
|
|
|
6663
6691
|
throw e;
|
|
6664
6692
|
}
|
|
6665
6693
|
}
|
|
6666
|
-
async function
|
|
6667
|
-
await
|
|
6694
|
+
async function Ps(e) {
|
|
6695
|
+
await Ns(e, "hooks", "page_id", f`varchar(64)`), await Ns(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6668
6696
|
}
|
|
6669
|
-
async function
|
|
6697
|
+
async function Fs(e, t, n) {
|
|
6670
6698
|
try {
|
|
6671
6699
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6672
6700
|
} catch (e) {
|
|
@@ -6674,22 +6702,22 @@ async function Ps(e, t, n) {
|
|
|
6674
6702
|
throw e;
|
|
6675
6703
|
}
|
|
6676
6704
|
}
|
|
6677
|
-
async function
|
|
6678
|
-
await
|
|
6705
|
+
async function Is(e) {
|
|
6706
|
+
await Fs(e, "hooks", "permission_required"), await Fs(e, "hooks", "page_id");
|
|
6679
6707
|
}
|
|
6680
6708
|
//#endregion
|
|
6681
6709
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6682
|
-
var
|
|
6683
|
-
down: () =>
|
|
6684
|
-
up: () =>
|
|
6685
|
-
}),
|
|
6710
|
+
var Ls = /* @__PURE__ */ T({
|
|
6711
|
+
down: () => Us,
|
|
6712
|
+
up: () => Vs
|
|
6713
|
+
}), Rs = [
|
|
6686
6714
|
["session_id", f`varchar(26)`],
|
|
6687
6715
|
["organization", f`varchar(191)`],
|
|
6688
6716
|
["auth_connection", f`varchar(255)`],
|
|
6689
6717
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6690
6718
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6691
6719
|
];
|
|
6692
|
-
async function
|
|
6720
|
+
async function zs(e, t, n, r) {
|
|
6693
6721
|
try {
|
|
6694
6722
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6695
6723
|
} catch (e) {
|
|
@@ -6697,7 +6725,7 @@ async function Rs(e, t, n, r) {
|
|
|
6697
6725
|
throw e;
|
|
6698
6726
|
}
|
|
6699
6727
|
}
|
|
6700
|
-
async function
|
|
6728
|
+
async function Bs(e) {
|
|
6701
6729
|
try {
|
|
6702
6730
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6703
6731
|
} catch (e) {
|
|
@@ -6705,11 +6733,11 @@ async function zs(e) {
|
|
|
6705
6733
|
throw e;
|
|
6706
6734
|
}
|
|
6707
6735
|
}
|
|
6708
|
-
async function
|
|
6709
|
-
for (let [t, n] of
|
|
6710
|
-
await
|
|
6736
|
+
async function Vs(e) {
|
|
6737
|
+
for (let [t, n] of Rs) await zs(e, "refresh_tokens", t, n);
|
|
6738
|
+
await Bs(e);
|
|
6711
6739
|
}
|
|
6712
|
-
async function
|
|
6740
|
+
async function Hs(e, t, n) {
|
|
6713
6741
|
try {
|
|
6714
6742
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6715
6743
|
} catch (e) {
|
|
@@ -6717,23 +6745,23 @@ async function Vs(e, t, n) {
|
|
|
6717
6745
|
throw e;
|
|
6718
6746
|
}
|
|
6719
6747
|
}
|
|
6720
|
-
async function
|
|
6748
|
+
async function Us(e) {
|
|
6721
6749
|
try {
|
|
6722
6750
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6723
6751
|
} catch {}
|
|
6724
|
-
for (let [t] of
|
|
6752
|
+
for (let [t] of Rs) await Hs(e, "refresh_tokens", t);
|
|
6725
6753
|
}
|
|
6726
6754
|
//#endregion
|
|
6727
6755
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6728
|
-
var
|
|
6729
|
-
down: () =>
|
|
6730
|
-
up: () =>
|
|
6731
|
-
}),
|
|
6732
|
-
async function
|
|
6756
|
+
var Ws = /* @__PURE__ */ T({
|
|
6757
|
+
down: () => Xs,
|
|
6758
|
+
up: () => Ys
|
|
6759
|
+
}), Gs = 500, Ks = 20, qs = 500, Js = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6760
|
+
async function Ys(e) {
|
|
6733
6761
|
try {
|
|
6734
6762
|
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);
|
|
6735
|
-
if (n >
|
|
6736
|
-
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6763
|
+
if (n > qs) {
|
|
6764
|
+
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${qs}. SKIPPING — run the bulk path instead: ${Js}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6737
6765
|
return;
|
|
6738
6766
|
}
|
|
6739
6767
|
if (n === 0) {
|
|
@@ -6750,10 +6778,10 @@ async function Js(e) {
|
|
|
6750
6778
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6751
6779
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6752
6780
|
"login_sessions.auth_params as ls_auth_params"
|
|
6753
|
-
]).limit(
|
|
6781
|
+
]).limit(Gs).execute();
|
|
6754
6782
|
if (t.length === 0) break;
|
|
6755
|
-
for (let n = 0; n < t.length; n +=
|
|
6756
|
-
let r = t.slice(n, n +
|
|
6783
|
+
for (let n = 0; n < t.length; n += Ks) {
|
|
6784
|
+
let r = t.slice(n, n + Ks);
|
|
6757
6785
|
await Promise.all(r.map(async (t) => {
|
|
6758
6786
|
let n = null;
|
|
6759
6787
|
if (t.ls_auth_params) try {
|
|
@@ -6770,19 +6798,19 @@ async function Js(e) {
|
|
|
6770
6798
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6771
6799
|
}));
|
|
6772
6800
|
}
|
|
6773
|
-
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6801
|
+
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length < Gs) break;
|
|
6774
6802
|
}
|
|
6775
6803
|
X(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6776
6804
|
} catch (e) {
|
|
6777
6805
|
throw Z("refresh_tokens backfill failed:", e), e;
|
|
6778
6806
|
}
|
|
6779
6807
|
}
|
|
6780
|
-
async function
|
|
6808
|
+
async function Xs() {}
|
|
6781
6809
|
//#endregion
|
|
6782
6810
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6783
|
-
var
|
|
6784
|
-
down: () =>
|
|
6785
|
-
up: () =>
|
|
6811
|
+
var Zs = /* @__PURE__ */ T({
|
|
6812
|
+
down: () => ec,
|
|
6813
|
+
up: () => $s
|
|
6786
6814
|
});
|
|
6787
6815
|
async function Q(e, t, n, r) {
|
|
6788
6816
|
try {
|
|
@@ -6792,7 +6820,7 @@ async function Q(e, t, n, r) {
|
|
|
6792
6820
|
throw e;
|
|
6793
6821
|
}
|
|
6794
6822
|
}
|
|
6795
|
-
async function
|
|
6823
|
+
async function Qs(e, t, n, r) {
|
|
6796
6824
|
try {
|
|
6797
6825
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6798
6826
|
} catch (e) {
|
|
@@ -6800,12 +6828,12 @@ async function Zs(e, t, n, r) {
|
|
|
6800
6828
|
throw e;
|
|
6801
6829
|
}
|
|
6802
6830
|
}
|
|
6803
|
-
async function
|
|
6804
|
-
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await
|
|
6831
|
+
async function $s(e) {
|
|
6832
|
+
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await Qs(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6805
6833
|
"operation_id",
|
|
6806
6834
|
"status",
|
|
6807
6835
|
"seq"
|
|
6808
|
-
]), await
|
|
6836
|
+
]), await Qs(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6809
6837
|
"kind",
|
|
6810
6838
|
"status",
|
|
6811
6839
|
"created_at"
|
|
@@ -6819,7 +6847,7 @@ async function $(e, t, n) {
|
|
|
6819
6847
|
throw e;
|
|
6820
6848
|
}
|
|
6821
6849
|
}
|
|
6822
|
-
async function
|
|
6850
|
+
async function ec(e) {
|
|
6823
6851
|
try {
|
|
6824
6852
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6825
6853
|
} catch {}
|
|
@@ -6827,35 +6855,35 @@ async function $s(e) {
|
|
|
6827
6855
|
}
|
|
6828
6856
|
//#endregion
|
|
6829
6857
|
//#region migrate/migrations/index.ts
|
|
6830
|
-
var
|
|
6831
|
-
"2026-07-16T14:00:00_baseline":
|
|
6832
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6833
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6834
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6835
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6836
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6837
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6838
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6839
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6840
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
6858
|
+
var tc = {
|
|
6859
|
+
"2026-07-16T14:00:00_baseline": Xo,
|
|
6860
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": rs,
|
|
6861
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": hs,
|
|
6862
|
+
"2026-08-05T12:00:00_user_blocked": vs,
|
|
6863
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Cs,
|
|
6864
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Os,
|
|
6865
|
+
"2026-08-11T12:00:00_page_hooks": Ms,
|
|
6866
|
+
"2026-08-20T12:00:00_refresh_token_session_id": Ls,
|
|
6867
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Ws,
|
|
6868
|
+
"2026-09-01T12:00:00_tenant_operation_rows": Zs
|
|
6841
6869
|
};
|
|
6842
6870
|
//#endregion
|
|
6843
6871
|
//#region migrate/migrate.ts
|
|
6844
|
-
async function
|
|
6845
|
-
|
|
6846
|
-
let { error: n, results: r } = await new
|
|
6872
|
+
async function nc(e, t = !1) {
|
|
6873
|
+
ns(t), t && console.log("migrating...");
|
|
6874
|
+
let { error: n, results: r } = await new Te({
|
|
6847
6875
|
db: e,
|
|
6848
|
-
provider: new
|
|
6876
|
+
provider: new Yo(tc)
|
|
6849
6877
|
}).migrateToLatest();
|
|
6850
6878
|
if (r?.forEach((e) => {
|
|
6851
6879
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6852
6880
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6853
6881
|
}
|
|
6854
|
-
async function
|
|
6855
|
-
|
|
6856
|
-
let { error: n, results: r } = await new
|
|
6882
|
+
async function rc(e, t = !1) {
|
|
6883
|
+
ns(t), t && console.log("migrating...");
|
|
6884
|
+
let { error: n, results: r } = await new Te({
|
|
6857
6885
|
db: e,
|
|
6858
|
-
provider: new
|
|
6886
|
+
provider: new Yo(tc)
|
|
6859
6887
|
}).migrateDown();
|
|
6860
6888
|
if (r?.forEach((e) => {
|
|
6861
6889
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6863,65 +6891,65 @@ async function nc(e, t = !1) {
|
|
|
6863
6891
|
}
|
|
6864
6892
|
//#endregion
|
|
6865
6893
|
//#region src/index.ts
|
|
6866
|
-
function
|
|
6894
|
+
function ic(e, t = { useTransactions: !0 }) {
|
|
6867
6895
|
let n = {
|
|
6868
6896
|
actions: We(e),
|
|
6869
|
-
actionExecutions:
|
|
6870
|
-
actionVersions:
|
|
6871
|
-
branding:
|
|
6897
|
+
actionExecutions: Ze(e),
|
|
6898
|
+
actionVersions: et(e),
|
|
6899
|
+
branding: pr(e),
|
|
6872
6900
|
clients: kn(e),
|
|
6873
6901
|
clientConnections: Fn(e),
|
|
6874
6902
|
clientGrants: Hn(e),
|
|
6875
|
-
clientRegistrationTokens:
|
|
6876
|
-
codes:
|
|
6903
|
+
clientRegistrationTokens: $n(e),
|
|
6904
|
+
codes: pn(e),
|
|
6877
6905
|
connections: bn(e),
|
|
6878
|
-
emailProviders:
|
|
6879
|
-
emailTemplates:
|
|
6880
|
-
customDomains:
|
|
6881
|
-
flows:
|
|
6882
|
-
forms:
|
|
6883
|
-
hookCode:
|
|
6884
|
-
hooks:
|
|
6885
|
-
invites:
|
|
6886
|
-
keys:
|
|
6887
|
-
loginSessions:
|
|
6888
|
-
logs:
|
|
6889
|
-
logStreams:
|
|
6890
|
-
migrationSources:
|
|
6906
|
+
emailProviders: $r(e),
|
|
6907
|
+
emailTemplates: oi(e),
|
|
6908
|
+
customDomains: ur(e),
|
|
6909
|
+
flows: kt(e),
|
|
6910
|
+
forms: Ti(e),
|
|
6911
|
+
hookCode: Or(e),
|
|
6912
|
+
hooks: Cr(e),
|
|
6913
|
+
invites: Ea(e),
|
|
6914
|
+
keys: rr(e),
|
|
6915
|
+
loginSessions: Wr(e),
|
|
6916
|
+
logs: Gt(e),
|
|
6917
|
+
logStreams: lo(e),
|
|
6918
|
+
migrationSources: fo(e),
|
|
6891
6919
|
authenticationMethods: Za(e),
|
|
6892
|
-
passwords:
|
|
6893
|
-
promptSettings:
|
|
6894
|
-
proxyRoutes:
|
|
6895
|
-
scimConfigurations:
|
|
6896
|
-
scimTokens:
|
|
6897
|
-
scimExternalIds:
|
|
6898
|
-
refreshTokens:
|
|
6899
|
-
resourceServers:
|
|
6900
|
-
rolePermissions:
|
|
6901
|
-
grants:
|
|
6902
|
-
userPermissions:
|
|
6903
|
-
userRoles:
|
|
6904
|
-
roles:
|
|
6905
|
-
sessions:
|
|
6906
|
-
sessionCleanup:
|
|
6907
|
-
tenants:
|
|
6908
|
-
tenantOperations:
|
|
6909
|
-
tenantOperationEvents:
|
|
6910
|
-
tenantOperationRows:
|
|
6911
|
-
rollouts:
|
|
6912
|
-
themes:
|
|
6913
|
-
universalLoginTemplates:
|
|
6920
|
+
passwords: nn(e),
|
|
6921
|
+
promptSettings: Jr(e),
|
|
6922
|
+
proxyRoutes: go(e),
|
|
6923
|
+
scimConfigurations: So(e),
|
|
6924
|
+
scimTokens: wo(e),
|
|
6925
|
+
scimExternalIds: Eo(e),
|
|
6926
|
+
refreshTokens: _i(e),
|
|
6927
|
+
resourceServers: Mi(e),
|
|
6928
|
+
rolePermissions: Ui(e),
|
|
6929
|
+
grants: Yi(e),
|
|
6930
|
+
userPermissions: ea(e),
|
|
6931
|
+
userRoles: oa(e),
|
|
6932
|
+
roles: Ri(e),
|
|
6933
|
+
sessions: Zt(e),
|
|
6934
|
+
sessionCleanup: yi(e),
|
|
6935
|
+
tenants: Lt(e),
|
|
6936
|
+
tenantOperations: Oo(e),
|
|
6937
|
+
tenantOperationEvents: Vo(e),
|
|
6938
|
+
tenantOperationRows: Go(e),
|
|
6939
|
+
rollouts: Jo(e),
|
|
6940
|
+
themes: Nr(e),
|
|
6941
|
+
universalLoginTemplates: _r(e),
|
|
6914
6942
|
customText: Wa(e),
|
|
6915
|
-
users:
|
|
6916
|
-
userActivity:
|
|
6917
|
-
organizations:
|
|
6918
|
-
organizationConnections:
|
|
6919
|
-
userOrganizations:
|
|
6920
|
-
stats:
|
|
6943
|
+
users: xt(e),
|
|
6944
|
+
userActivity: vt(e),
|
|
6945
|
+
organizations: fa(e),
|
|
6946
|
+
organizationConnections: pa(e),
|
|
6947
|
+
userOrganizations: ba(e),
|
|
6948
|
+
stats: ja(e),
|
|
6921
6949
|
analytics: Ua(e),
|
|
6922
6950
|
outbox: so(e),
|
|
6923
6951
|
async transaction(r) {
|
|
6924
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6952
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(ic(e, {
|
|
6925
6953
|
...t,
|
|
6926
6954
|
useTransactions: !1
|
|
6927
6955
|
})));
|
|
@@ -6930,4 +6958,4 @@ function rc(e, t = { useTransactions: !0 }) {
|
|
|
6930
6958
|
return n;
|
|
6931
6959
|
}
|
|
6932
6960
|
//#endregion
|
|
6933
|
-
export {
|
|
6961
|
+
export { vo as createProxyDataAdapter, go as createProxyRoutesAdapter, ic as default, rc as migrateDown, nc as migrateToLatest };
|