@authhero/kysely-adapter 12.3.1 → 12.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -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,
|
|
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, isPlainObject as ae, loginSessionSchema as oe, matchSchema as se, migrationProviderTypeSchema as ce, parseUserId as le, resourceServerSchema as ue, rolloutInsertSchema as de, rolloutSchema as fe, sanitizeLuceneQuery as S, scimMappingEntrySchema as pe, sessionRetentionWindow as me, tenantOperationEventInsertSchema as he, tenantOperationEventSchema as ge, tenantOperationInsertSchema as _e, tenantOperationSchema as ve } from "@authhero/adapter-interfaces";
|
|
5
5
|
import { HTTPException as C } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as ye } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var be = Object.defineProperty, w = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) be(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || be(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, xe = 17, Se = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -26,38 +26,38 @@ var ye = Object.defineProperty, w = (e, t) => {
|
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
28
|
function T(t) {
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", xe)();
|
|
30
|
+
return `${Se[t]}${n}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Ce() {
|
|
33
33
|
return T("organization");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function we() {
|
|
36
36
|
return T("connection");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Te() {
|
|
39
39
|
return T("action");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Ee() {
|
|
42
42
|
return T("action_version");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function De() {
|
|
45
45
|
return T("hook");
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Oe() {
|
|
48
48
|
return T("resource_server");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function ke() {
|
|
51
51
|
return T("hook_code");
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Ae() {
|
|
54
54
|
return T("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function je(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 ?? Te();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -98,7 +98,7 @@ function E(e) {
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Me(e) {
|
|
102
102
|
return async (t, n) => {
|
|
103
103
|
let i = await e.selectFrom("actions").where("actions.tenant_id", "=", t).where("actions.id", "=", n).selectAll().executeTakeFirst();
|
|
104
104
|
if (!i) return null;
|
|
@@ -123,7 +123,7 @@ function je(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Ne(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
129
|
function D(e) {
|
|
@@ -135,7 +135,7 @@ function O(e, t, n, r, i = [], a = {}) {
|
|
|
135
135
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
136
136
|
}, l = (e) => {
|
|
137
137
|
let t = a[e];
|
|
138
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
138
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : Ne(t);
|
|
139
139
|
}, u = (e, t) => {
|
|
140
140
|
let n = a[e];
|
|
141
141
|
if (n === void 0 || typeof n == "string") return t;
|
|
@@ -208,7 +208,7 @@ function k(e) {
|
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function Pe(e) {
|
|
212
212
|
return async (t, n = {}) => {
|
|
213
213
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
214
214
|
c && (l = O(e, l, c, ["name"]));
|
|
@@ -248,7 +248,7 @@ function Ne(e) {
|
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/actions/update.ts
|
|
251
|
-
function
|
|
251
|
+
function Fe(e) {
|
|
252
252
|
if (!e) return [];
|
|
253
253
|
try {
|
|
254
254
|
let t = JSON.parse(e);
|
|
@@ -257,11 +257,11 @@ function Pe(e) {
|
|
|
257
257
|
return [];
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ie(e) {
|
|
261
261
|
return async (t, n, r) => {
|
|
262
262
|
let i = { updated_at_ts: Date.now() };
|
|
263
263
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
264
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
264
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Fe(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
265
265
|
name: e.name,
|
|
266
266
|
value: o.get(e.name)?.value
|
|
267
267
|
} : e);
|
|
@@ -276,23 +276,23 @@ function Fe(e) {
|
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/actions/remove.ts
|
|
279
|
-
function
|
|
279
|
+
function Le(e) {
|
|
280
280
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/actions/index.ts
|
|
284
|
-
function
|
|
284
|
+
function Re(e) {
|
|
285
285
|
return {
|
|
286
|
-
create:
|
|
287
|
-
get:
|
|
288
|
-
list:
|
|
289
|
-
update:
|
|
290
|
-
remove:
|
|
286
|
+
create: je(e),
|
|
287
|
+
get: Me(e),
|
|
288
|
+
list: Pe(e),
|
|
289
|
+
update: Ie(e),
|
|
290
|
+
remove: Le(e)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/actionExecutions/create.ts
|
|
295
|
-
function
|
|
295
|
+
function ze(e) {
|
|
296
296
|
return async (t, n) => {
|
|
297
297
|
let r = Date.now();
|
|
298
298
|
return await e.insertInto("action_executions").values({
|
|
@@ -318,14 +318,14 @@ function Re(e) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/actionExecutions/get.ts
|
|
321
|
-
function
|
|
321
|
+
function Be(e) {
|
|
322
322
|
if (e) try {
|
|
323
323
|
return JSON.parse(e);
|
|
324
324
|
} catch {
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function Ve(e) {
|
|
329
329
|
return async (t, n) => {
|
|
330
330
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
331
331
|
return r ? {
|
|
@@ -333,8 +333,8 @@ function Be(e) {
|
|
|
333
333
|
tenant_id: r.tenant_id,
|
|
334
334
|
trigger_id: r.trigger_id,
|
|
335
335
|
status: r.status,
|
|
336
|
-
results:
|
|
337
|
-
logs:
|
|
336
|
+
results: Be(r.results) ?? [],
|
|
337
|
+
logs: Be(r.logs),
|
|
338
338
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
339
339
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
340
340
|
} : null;
|
|
@@ -343,19 +343,19 @@ function Be(e) {
|
|
|
343
343
|
//#endregion
|
|
344
344
|
//#region src/actionExecutions/cleanup.ts
|
|
345
345
|
var A = 5e4;
|
|
346
|
-
async function
|
|
346
|
+
async function He(e) {
|
|
347
347
|
try {
|
|
348
348
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
349
349
|
} catch {
|
|
350
350
|
return "sqlite";
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function Ue(e) {
|
|
354
354
|
let t;
|
|
355
355
|
return async (n) => {
|
|
356
356
|
let r = Date.parse(n);
|
|
357
357
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
358
|
-
if (t ??= await
|
|
358
|
+
if (t ??= await He(e), t === "sqlite") {
|
|
359
359
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
360
360
|
return Number(t.numDeletedRows);
|
|
361
361
|
}
|
|
@@ -369,39 +369,39 @@ function He(e) {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/actionExecutions/index.ts
|
|
372
|
-
function
|
|
372
|
+
function We(e) {
|
|
373
373
|
return {
|
|
374
|
-
create:
|
|
375
|
-
get:
|
|
376
|
-
cleanup:
|
|
374
|
+
create: ze(e),
|
|
375
|
+
get: Ve(e),
|
|
376
|
+
cleanup: Ue(e)
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/actionVersions/index.ts
|
|
381
|
-
function
|
|
381
|
+
function Ge(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 Ke(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: Ge(r),
|
|
395
|
+
dependencies: Ge(i),
|
|
396
|
+
supported_triggers: Ge(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 qe(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 ?? Ee(), 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 Ke(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 ? Ke(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(Ke);
|
|
445
445
|
if (!s) return {
|
|
446
446
|
versions: l,
|
|
447
447
|
start: 0,
|
|
@@ -483,7 +483,7 @@ async function j(e, t, n, r) {
|
|
|
483
483
|
error: null
|
|
484
484
|
}).execute();
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Je(e) {
|
|
487
487
|
return async (n, r) => {
|
|
488
488
|
let i = t();
|
|
489
489
|
return await j(e, n, i, r), i;
|
|
@@ -491,7 +491,7 @@ function qe(e) {
|
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/users/create.ts
|
|
494
|
-
function
|
|
494
|
+
function Ye(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,
|
|
@@ -551,7 +551,7 @@ function Je(e) {
|
|
|
551
551
|
}
|
|
552
552
|
//#endregion
|
|
553
553
|
//#region src/users/user-to-identity.ts
|
|
554
|
-
var
|
|
554
|
+
var Xe = [
|
|
555
555
|
"email",
|
|
556
556
|
"email_verified",
|
|
557
557
|
"phone_number",
|
|
@@ -562,10 +562,10 @@ function M(e, t = !1) {
|
|
|
562
562
|
let n = {
|
|
563
563
|
connection: e.connection,
|
|
564
564
|
provider: e.provider,
|
|
565
|
-
user_id:
|
|
565
|
+
user_id: le(e.user_id).id,
|
|
566
566
|
isSocial: !!e.is_social
|
|
567
567
|
};
|
|
568
|
-
for (let t of
|
|
568
|
+
for (let t of Xe) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
569
569
|
if (!t) {
|
|
570
570
|
let t = {};
|
|
571
571
|
try {
|
|
@@ -583,7 +583,7 @@ function M(e, t = !1) {
|
|
|
583
583
|
}
|
|
584
584
|
//#endregion
|
|
585
585
|
//#region src/users/get.ts
|
|
586
|
-
function
|
|
586
|
+
function Ze(e) {
|
|
587
587
|
return async (t, n) => {
|
|
588
588
|
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([
|
|
589
589
|
"user_activity.last_login",
|
|
@@ -614,12 +614,12 @@ function Xe(e) {
|
|
|
614
614
|
function N(e) {
|
|
615
615
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function Qe(e, t) {
|
|
618
618
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
619
619
|
return n >= 1 ? n : t;
|
|
620
620
|
}
|
|
621
621
|
async function P(e, t, n) {
|
|
622
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
622
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = Qe(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
623
623
|
if (c && c.k !== n.sortKey) throw new C(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
624
624
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
625
625
|
else {
|
|
@@ -629,7 +629,7 @@ async function P(e, t, n) {
|
|
|
629
629
|
let l = await s.limit(o + 1).execute(), u = l.length > o, d = u ? l.slice(0, o) : l, p;
|
|
630
630
|
if (u && d.length > 0) {
|
|
631
631
|
let e = d[d.length - 1], t = r.split(".").pop(), i = a.split(".").pop(), o = e[t];
|
|
632
|
-
p =
|
|
632
|
+
p = re({
|
|
633
633
|
s: typeof o == "string" || typeof o == "number" || o === null ? o : String(o),
|
|
634
634
|
i: String(e[i]),
|
|
635
635
|
...n.sortKey !== void 0 && { k: n.sortKey }
|
|
@@ -643,7 +643,7 @@ async function P(e, t, n) {
|
|
|
643
643
|
}
|
|
644
644
|
//#endregion
|
|
645
645
|
//#region src/users/list.ts
|
|
646
|
-
var
|
|
646
|
+
var $e = [
|
|
647
647
|
"user_id",
|
|
648
648
|
"email",
|
|
649
649
|
"email_verified",
|
|
@@ -666,20 +666,20 @@ var Qe = [
|
|
|
666
666
|
"login_count",
|
|
667
667
|
"created_at",
|
|
668
668
|
"updated_at"
|
|
669
|
-
],
|
|
669
|
+
], et = new Set([
|
|
670
670
|
"last_login",
|
|
671
671
|
"last_ip",
|
|
672
672
|
"login_count"
|
|
673
|
-
]),
|
|
673
|
+
]), tt = Object.fromEntries($e.map((e) => [e, e === "login_count" ? {
|
|
674
674
|
column: "user_activity.login_count",
|
|
675
675
|
defaultValue: 0
|
|
676
|
-
} :
|
|
676
|
+
} : et.has(e) ? `user_activity.${e}` : `users.${e}`])), nt = [
|
|
677
677
|
"email",
|
|
678
678
|
"name",
|
|
679
679
|
"phone_number",
|
|
680
680
|
"user_id"
|
|
681
681
|
];
|
|
682
|
-
async function
|
|
682
|
+
async function rt(e, t, n) {
|
|
683
683
|
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() : [];
|
|
684
684
|
return n.map((e) => {
|
|
685
685
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -697,12 +697,12 @@ async function nt(e, t, n) {
|
|
|
697
697
|
});
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function it(e) {
|
|
701
701
|
return async (t, n = {}) => {
|
|
702
702
|
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);
|
|
703
703
|
if (c) {
|
|
704
|
-
let t = S(c,
|
|
705
|
-
t && (l = O(e, l, t,
|
|
704
|
+
let t = S(c, $e);
|
|
705
|
+
t && (l = O(e, l, t, nt, [], tt));
|
|
706
706
|
}
|
|
707
707
|
if (N(n)) {
|
|
708
708
|
if (s?.sort_by && s.sort_by !== "created_at") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
@@ -715,7 +715,7 @@ function rt(e) {
|
|
|
715
715
|
sortOrder: r,
|
|
716
716
|
idColumn: "users.user_id",
|
|
717
717
|
sortKey: `created_at:${r}`
|
|
718
|
-
}), c = await
|
|
718
|
+
}), c = await rt(e, t, i);
|
|
719
719
|
return {
|
|
720
720
|
users: c,
|
|
721
721
|
start: 0,
|
|
@@ -725,13 +725,13 @@ function rt(e) {
|
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
727
|
if (s && s.sort_by) {
|
|
728
|
-
let t =
|
|
728
|
+
let t = tt[s.sort_by];
|
|
729
729
|
if (t) {
|
|
730
730
|
let { ref: n } = e.dynamic;
|
|
731
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
731
|
+
l = l.orderBy(typeof t == "string" ? n(t) : Ne(t), s.sort_order);
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
let u = await
|
|
734
|
+
let u = await rt(e, t, await l.offset(r * i).limit(i).selectAll("users").select([
|
|
735
735
|
"user_activity.last_login",
|
|
736
736
|
"user_activity.last_ip",
|
|
737
737
|
"user_activity.login_count"
|
|
@@ -753,7 +753,7 @@ function rt(e) {
|
|
|
753
753
|
}
|
|
754
754
|
//#endregion
|
|
755
755
|
//#region src/users/remove.ts
|
|
756
|
-
function
|
|
756
|
+
function at(e) {
|
|
757
757
|
return async (t, n, r) => {
|
|
758
758
|
let i = async (e) => {
|
|
759
759
|
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();
|
|
@@ -773,7 +773,7 @@ function F(e, t = "", n = {}) {
|
|
|
773
773
|
}
|
|
774
774
|
return n;
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function ot(e, t) {
|
|
777
777
|
let n = {};
|
|
778
778
|
for (let [r, i] of Object.entries(e)) {
|
|
779
779
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -790,7 +790,7 @@ function at(e, t) {
|
|
|
790
790
|
}
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region src/userActivity/index.ts
|
|
793
|
-
function
|
|
793
|
+
function st(e) {
|
|
794
794
|
return {
|
|
795
795
|
user_id: e.user_id,
|
|
796
796
|
last_login: e.last_login ?? void 0,
|
|
@@ -800,18 +800,18 @@ function ot(e) {
|
|
|
800
800
|
last_password_reset: e.last_password_reset ?? void 0
|
|
801
801
|
};
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function ct(e) {
|
|
804
804
|
let t = {};
|
|
805
805
|
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;
|
|
806
806
|
}
|
|
807
|
-
function
|
|
807
|
+
function lt(e) {
|
|
808
808
|
return {
|
|
809
809
|
async get(t, n) {
|
|
810
810
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
811
|
-
return r ?
|
|
811
|
+
return r ? st(r) : null;
|
|
812
812
|
},
|
|
813
813
|
async upsert(t, n, r) {
|
|
814
|
-
let i =
|
|
814
|
+
let i = ct(r);
|
|
815
815
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
816
816
|
if (Object.keys(i).length === 0) return;
|
|
817
817
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -833,7 +833,7 @@ function ct(e) {
|
|
|
833
833
|
}
|
|
834
834
|
//#endregion
|
|
835
835
|
//#region src/users/update.ts
|
|
836
|
-
function
|
|
836
|
+
function ut(e) {
|
|
837
837
|
return async (t, n, r, i) => {
|
|
838
838
|
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = F({
|
|
839
839
|
...c,
|
|
@@ -846,7 +846,7 @@ function lt(e) {
|
|
|
846
846
|
}), u = async (e) => {
|
|
847
847
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
848
848
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
849
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
849
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await lt(e).upsert(t, n, {
|
|
850
850
|
last_login: a,
|
|
851
851
|
last_ip: o,
|
|
852
852
|
login_count: s
|
|
@@ -859,26 +859,26 @@ function lt(e) {
|
|
|
859
859
|
}
|
|
860
860
|
//#endregion
|
|
861
861
|
//#region src/users/unlink.ts
|
|
862
|
-
function
|
|
862
|
+
function dt(e) {
|
|
863
863
|
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;
|
|
864
864
|
}
|
|
865
865
|
//#endregion
|
|
866
866
|
//#region src/users/index.ts
|
|
867
|
-
function
|
|
868
|
-
let t =
|
|
867
|
+
function ft(e) {
|
|
868
|
+
let t = Ye(e);
|
|
869
869
|
return {
|
|
870
870
|
create: t,
|
|
871
871
|
rawCreate: t,
|
|
872
|
-
remove:
|
|
873
|
-
get:
|
|
874
|
-
list:
|
|
875
|
-
update:
|
|
876
|
-
unlink:
|
|
872
|
+
remove: at(e),
|
|
873
|
+
get: Ze(e),
|
|
874
|
+
list: it(e),
|
|
875
|
+
update: ut(e),
|
|
876
|
+
unlink: dt(e)
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
879
|
//#endregion
|
|
880
880
|
//#region src/flows/create.ts
|
|
881
|
-
function
|
|
881
|
+
function pt(e) {
|
|
882
882
|
return async (n, r, i) => {
|
|
883
883
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
884
884
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -904,7 +904,7 @@ function I(e, t) {
|
|
|
904
904
|
return t;
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function mt(e) {
|
|
908
908
|
if (e) try {
|
|
909
909
|
let t = JSON.parse(e);
|
|
910
910
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -912,13 +912,13 @@ function pt(e) {
|
|
|
912
912
|
return;
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
function
|
|
915
|
+
function ht(e, t, n = { ...e }) {
|
|
916
916
|
for (let r in t) r in e && (n[r] = I(e[r], t[r]));
|
|
917
917
|
return n;
|
|
918
918
|
}
|
|
919
919
|
//#endregion
|
|
920
920
|
//#region src/flows/get.ts
|
|
921
|
-
function
|
|
921
|
+
function gt(e) {
|
|
922
922
|
return async (t, n) => {
|
|
923
923
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
924
924
|
if (!r) return null;
|
|
@@ -931,7 +931,7 @@ function ht(e) {
|
|
|
931
931
|
}
|
|
932
932
|
//#endregion
|
|
933
933
|
//#region src/flows/list.ts
|
|
934
|
-
function
|
|
934
|
+
function _t(e) {
|
|
935
935
|
return async (t, n = {}) => {
|
|
936
936
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
937
937
|
s && (c = O(e, c, s, []));
|
|
@@ -959,7 +959,7 @@ function gt(e) {
|
|
|
959
959
|
}
|
|
960
960
|
//#endregion
|
|
961
961
|
//#region src/flows/update.ts
|
|
962
|
-
function
|
|
962
|
+
function vt(e) {
|
|
963
963
|
return async (t, n, r) => {
|
|
964
964
|
let i = {
|
|
965
965
|
...r,
|
|
@@ -977,27 +977,27 @@ function _t(e) {
|
|
|
977
977
|
}
|
|
978
978
|
//#endregion
|
|
979
979
|
//#region src/flows/remove.ts
|
|
980
|
-
function
|
|
980
|
+
function yt(e) {
|
|
981
981
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
982
982
|
}
|
|
983
983
|
//#endregion
|
|
984
984
|
//#region src/flows/index.ts
|
|
985
|
-
function
|
|
985
|
+
function bt(e) {
|
|
986
986
|
return {
|
|
987
|
-
create:
|
|
988
|
-
get:
|
|
989
|
-
list:
|
|
990
|
-
update:
|
|
991
|
-
remove:
|
|
987
|
+
create: pt(e),
|
|
988
|
+
get: gt(e),
|
|
989
|
+
list: _t(e),
|
|
990
|
+
update: vt(e),
|
|
991
|
+
remove: yt(e)
|
|
992
992
|
};
|
|
993
993
|
}
|
|
994
994
|
//#endregion
|
|
995
995
|
//#region src/tenants/utils.ts
|
|
996
|
-
function
|
|
996
|
+
function xt(e) {
|
|
997
997
|
let t = { ...e };
|
|
998
998
|
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);
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1000
|
+
function St(e) {
|
|
1001
1001
|
let t = { ...e };
|
|
1002
1002
|
return d(e, [
|
|
1003
1003
|
"session_cookie",
|
|
@@ -1020,14 +1020,14 @@ function xt(e) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
//#endregion
|
|
1022
1022
|
//#region src/tenants/create.ts
|
|
1023
|
-
function
|
|
1023
|
+
function Ct(e) {
|
|
1024
1024
|
return async (n, r) => {
|
|
1025
1025
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
1026
1026
|
...n,
|
|
1027
1027
|
id: i?.id ?? n.id ?? t(),
|
|
1028
1028
|
created_at: i?.created_at ?? a,
|
|
1029
1029
|
updated_at: i?.updated_at ?? a
|
|
1030
|
-
}, s =
|
|
1030
|
+
}, s = St(o);
|
|
1031
1031
|
try {
|
|
1032
1032
|
await e.insertInto("tenants").values(s).execute();
|
|
1033
1033
|
} catch (e) {
|
|
@@ -1039,15 +1039,15 @@ function St(e) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
//#endregion
|
|
1041
1041
|
//#region src/tenants/get.ts
|
|
1042
|
-
function
|
|
1042
|
+
function wt(e) {
|
|
1043
1043
|
return async (t) => {
|
|
1044
1044
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1045
|
-
return n ?
|
|
1045
|
+
return n ? xt(n) : null;
|
|
1046
1046
|
};
|
|
1047
1047
|
}
|
|
1048
1048
|
//#endregion
|
|
1049
1049
|
//#region src/tenants/list.ts
|
|
1050
|
-
function
|
|
1050
|
+
function Tt(e) {
|
|
1051
1051
|
return async (t) => {
|
|
1052
1052
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1053
1053
|
if (s && s.sort_by) {
|
|
@@ -1055,7 +1055,7 @@ function wt(e) {
|
|
|
1055
1055
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1056
1056
|
}
|
|
1057
1057
|
c && (n = O(e, n, c, ["friendly_name"]));
|
|
1058
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1058
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(xt);
|
|
1059
1059
|
if (!a) return { tenants: l };
|
|
1060
1060
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1061
1061
|
return {
|
|
@@ -1068,10 +1068,10 @@ function wt(e) {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
//#endregion
|
|
1070
1070
|
//#region src/tenants/update.ts
|
|
1071
|
-
function
|
|
1071
|
+
function Et(e) {
|
|
1072
1072
|
return async (t, n) => {
|
|
1073
1073
|
let r = {
|
|
1074
|
-
...
|
|
1074
|
+
...St(n),
|
|
1075
1075
|
id: t,
|
|
1076
1076
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1077
1077
|
};
|
|
@@ -1080,29 +1080,29 @@ function Tt(e) {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
//#endregion
|
|
1082
1082
|
//#region src/tenants/remove.ts
|
|
1083
|
-
function
|
|
1083
|
+
function Dt(e) {
|
|
1084
1084
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1085
1085
|
}
|
|
1086
1086
|
//#endregion
|
|
1087
1087
|
//#region src/tenants/index.ts
|
|
1088
|
-
function
|
|
1088
|
+
function Ot(e) {
|
|
1089
1089
|
return {
|
|
1090
|
-
create:
|
|
1091
|
-
get:
|
|
1092
|
-
list:
|
|
1093
|
-
update:
|
|
1094
|
-
remove:
|
|
1090
|
+
create: Ct(e),
|
|
1091
|
+
get: wt(e),
|
|
1092
|
+
list: Tt(e),
|
|
1093
|
+
update: Et(e),
|
|
1094
|
+
remove: Dt(e)
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
1097
1097
|
//#endregion
|
|
1098
1098
|
//#region src/logs/create.ts
|
|
1099
|
-
function
|
|
1099
|
+
function kt(e) {
|
|
1100
1100
|
return e ? JSON.stringify(e) : void 0;
|
|
1101
1101
|
}
|
|
1102
|
-
var
|
|
1103
|
-
function
|
|
1102
|
+
var At = 256;
|
|
1103
|
+
function jt(e) {
|
|
1104
1104
|
return async (n, r) => {
|
|
1105
|
-
let i = r.user_agent?.slice(0,
|
|
1105
|
+
let i = r.user_agent?.slice(0, At), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1106
1106
|
return await e.insertInto("logs").values({
|
|
1107
1107
|
...s,
|
|
1108
1108
|
log_id: a,
|
|
@@ -1111,8 +1111,8 @@ function At(e) {
|
|
|
1111
1111
|
description: r.description?.substring(0, 256),
|
|
1112
1112
|
isMobile: +!!r.isMobile,
|
|
1113
1113
|
scope: r.scope,
|
|
1114
|
-
auth0_client:
|
|
1115
|
-
details:
|
|
1114
|
+
auth0_client: kt(r.auth0_client),
|
|
1115
|
+
details: kt(r.details)?.substring(0, 8192),
|
|
1116
1116
|
country_code: o?.country_code,
|
|
1117
1117
|
city_name: o?.city_name,
|
|
1118
1118
|
latitude: o?.latitude,
|
|
@@ -1128,7 +1128,7 @@ function At(e) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
//#endregion
|
|
1130
1130
|
//#region src/logs/logs.ts
|
|
1131
|
-
function
|
|
1131
|
+
function Mt(e) {
|
|
1132
1132
|
if (!e) return "";
|
|
1133
1133
|
try {
|
|
1134
1134
|
return JSON.parse(e);
|
|
@@ -1136,13 +1136,13 @@ function jt(e) {
|
|
|
1136
1136
|
return e;
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
function
|
|
1139
|
+
function Nt(e) {
|
|
1140
1140
|
return {
|
|
1141
1141
|
...e,
|
|
1142
1142
|
client_id: e.client_id,
|
|
1143
1143
|
client_name: e.client_name || "",
|
|
1144
|
-
auth0_client:
|
|
1145
|
-
details:
|
|
1144
|
+
auth0_client: Mt(e.auth0_client),
|
|
1145
|
+
details: Mt(e.details),
|
|
1146
1146
|
isMobile: !!e.isMobile,
|
|
1147
1147
|
scope: e.scope || void 0,
|
|
1148
1148
|
log_id: e.log_id,
|
|
@@ -1158,7 +1158,7 @@ function Mt(e) {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
//#endregion
|
|
1160
1160
|
//#region src/logs/list.ts
|
|
1161
|
-
var
|
|
1161
|
+
var Pt = [
|
|
1162
1162
|
"user_id",
|
|
1163
1163
|
"ip",
|
|
1164
1164
|
"type",
|
|
@@ -1184,11 +1184,11 @@ var Nt = [
|
|
|
1184
1184
|
"time_zone",
|
|
1185
1185
|
"continent_code"
|
|
1186
1186
|
];
|
|
1187
|
-
function
|
|
1187
|
+
function Ft(e) {
|
|
1188
1188
|
return async (t, n = {}) => {
|
|
1189
1189
|
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);
|
|
1190
1190
|
if (c) {
|
|
1191
|
-
let t = S(c,
|
|
1191
|
+
let t = S(c, Pt);
|
|
1192
1192
|
t && (d = O(e, d, t, [
|
|
1193
1193
|
"user_id",
|
|
1194
1194
|
"ip",
|
|
@@ -1202,7 +1202,7 @@ function Pt(e) {
|
|
|
1202
1202
|
sortOrder: e,
|
|
1203
1203
|
idColumn: "log_id",
|
|
1204
1204
|
sortKey: `date:${e}`
|
|
1205
|
-
}), a = t.map(
|
|
1205
|
+
}), a = t.map(Nt);
|
|
1206
1206
|
return {
|
|
1207
1207
|
logs: a,
|
|
1208
1208
|
start: 0,
|
|
@@ -1217,7 +1217,7 @@ function Pt(e) {
|
|
|
1217
1217
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1218
1218
|
}
|
|
1219
1219
|
f = f.offset(r * i).limit(i);
|
|
1220
|
-
let p = (await f.selectAll().execute()).map(
|
|
1220
|
+
let p = (await f.selectAll().execute()).map(Nt);
|
|
1221
1221
|
if (!a) return {
|
|
1222
1222
|
logs: p,
|
|
1223
1223
|
start: 0,
|
|
@@ -1235,24 +1235,24 @@ function Pt(e) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
//#endregion
|
|
1237
1237
|
//#region src/logs/get.ts
|
|
1238
|
-
function
|
|
1238
|
+
function It(e) {
|
|
1239
1239
|
return async (t, n) => {
|
|
1240
1240
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1241
|
-
return r ?
|
|
1241
|
+
return r ? Nt(r) : null;
|
|
1242
1242
|
};
|
|
1243
1243
|
}
|
|
1244
1244
|
//#endregion
|
|
1245
1245
|
//#region src/logs/index.ts
|
|
1246
|
-
function
|
|
1246
|
+
function Lt(e) {
|
|
1247
1247
|
return {
|
|
1248
|
-
create:
|
|
1249
|
-
list:
|
|
1250
|
-
get:
|
|
1248
|
+
create: jt(e),
|
|
1249
|
+
list: Ft(e),
|
|
1250
|
+
get: It(e)
|
|
1251
1251
|
};
|
|
1252
1252
|
}
|
|
1253
1253
|
//#endregion
|
|
1254
1254
|
//#region src/sessions/get.ts
|
|
1255
|
-
function
|
|
1255
|
+
function Rt(e) {
|
|
1256
1256
|
return async (t, n) => {
|
|
1257
1257
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1258
1258
|
if (!i) return null;
|
|
@@ -1286,7 +1286,7 @@ function Lt(e) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
//#endregion
|
|
1288
1288
|
//#region src/sessions/create.ts
|
|
1289
|
-
function
|
|
1289
|
+
function zt(e) {
|
|
1290
1290
|
return async (t, n) => {
|
|
1291
1291
|
let r = Date.now(), i = c(), a = {
|
|
1292
1292
|
...n,
|
|
@@ -1318,12 +1318,12 @@ function Rt(e) {
|
|
|
1318
1318
|
}
|
|
1319
1319
|
//#endregion
|
|
1320
1320
|
//#region src/sessions/remove.ts
|
|
1321
|
-
function
|
|
1321
|
+
function Bt(e) {
|
|
1322
1322
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1323
1323
|
}
|
|
1324
1324
|
//#endregion
|
|
1325
1325
|
//#region src/sessions/update.ts
|
|
1326
|
-
function
|
|
1326
|
+
function Vt(e) {
|
|
1327
1327
|
return async (t, n, r) => {
|
|
1328
1328
|
let i = Date.now(), a = {
|
|
1329
1329
|
updated_at_ts: i,
|
|
@@ -1344,7 +1344,7 @@ function Bt(e) {
|
|
|
1344
1344
|
}
|
|
1345
1345
|
//#endregion
|
|
1346
1346
|
//#region src/sessions/list.ts
|
|
1347
|
-
function
|
|
1347
|
+
function Ht(e) {
|
|
1348
1348
|
return async (t, n = {}) => {
|
|
1349
1349
|
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);
|
|
1350
1350
|
l && (u = O(e, u, l, ["user_id", "session_id"]));
|
|
@@ -1399,18 +1399,18 @@ function Vt(e) {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
//#endregion
|
|
1401
1401
|
//#region src/sessions/index.ts
|
|
1402
|
-
function
|
|
1402
|
+
function Ut(e) {
|
|
1403
1403
|
return {
|
|
1404
|
-
create:
|
|
1405
|
-
get:
|
|
1406
|
-
list:
|
|
1407
|
-
remove:
|
|
1408
|
-
update:
|
|
1404
|
+
create: zt(e),
|
|
1405
|
+
get: Rt(e),
|
|
1406
|
+
list: Ht(e),
|
|
1407
|
+
remove: Bt(e),
|
|
1408
|
+
update: Vt(e)
|
|
1409
1409
|
};
|
|
1410
1410
|
}
|
|
1411
1411
|
//#endregion
|
|
1412
1412
|
//#region src/passwords/get.ts
|
|
1413
|
-
function
|
|
1413
|
+
function Wt(e) {
|
|
1414
1414
|
return async (t, n) => {
|
|
1415
1415
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1416
1416
|
if (!r) return null;
|
|
@@ -1423,7 +1423,7 @@ function Ut(e) {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
//#endregion
|
|
1425
1425
|
//#region src/passwords/create.ts
|
|
1426
|
-
function
|
|
1426
|
+
function Gt(e) {
|
|
1427
1427
|
return async (n, r, i) => {
|
|
1428
1428
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1429
1429
|
...r,
|
|
@@ -1441,7 +1441,7 @@ function Wt(e) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
//#endregion
|
|
1443
1443
|
//#region src/passwords/update.ts
|
|
1444
|
-
function
|
|
1444
|
+
function Kt(e) {
|
|
1445
1445
|
return async (t, n) => {
|
|
1446
1446
|
let r = e.updateTable("passwords").set({
|
|
1447
1447
|
password: n.password,
|
|
@@ -1454,7 +1454,7 @@ function Gt(e) {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
//#endregion
|
|
1456
1456
|
//#region src/passwords/list.ts
|
|
1457
|
-
function
|
|
1457
|
+
function qt(e) {
|
|
1458
1458
|
return async (t, n, r) => {
|
|
1459
1459
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1460
1460
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1465,23 +1465,23 @@ function Kt(e) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
//#endregion
|
|
1467
1467
|
//#region src/passwords/index.ts
|
|
1468
|
-
function
|
|
1468
|
+
function Jt(e) {
|
|
1469
1469
|
return {
|
|
1470
|
-
create:
|
|
1471
|
-
update:
|
|
1472
|
-
get:
|
|
1473
|
-
list:
|
|
1470
|
+
create: Gt(e),
|
|
1471
|
+
update: Kt(e),
|
|
1472
|
+
get: Wt(e),
|
|
1473
|
+
list: qt(e)
|
|
1474
1474
|
};
|
|
1475
1475
|
}
|
|
1476
1476
|
//#endregion
|
|
1477
1477
|
//#region src/codes/list.ts
|
|
1478
|
-
function
|
|
1478
|
+
function Yt(e) {
|
|
1479
1479
|
return async (t, n = {}) => {
|
|
1480
1480
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1481
1481
|
s && (c = O(e, c, s, ["code", "login_id"]));
|
|
1482
1482
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1483
1483
|
let { tenant_id: t, ...n } = e;
|
|
1484
|
-
return
|
|
1484
|
+
return ee.parse(l(n));
|
|
1485
1485
|
});
|
|
1486
1486
|
if (!a) return {
|
|
1487
1487
|
codes: u,
|
|
@@ -1500,13 +1500,13 @@ function Jt(e) {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
//#endregion
|
|
1502
1502
|
//#region src/codes/expires-at-ts.ts
|
|
1503
|
-
function
|
|
1503
|
+
function Xt(e) {
|
|
1504
1504
|
let t = new Date(e).getTime();
|
|
1505
1505
|
return Number.isNaN(t) ? 0 : t;
|
|
1506
1506
|
}
|
|
1507
1507
|
//#endregion
|
|
1508
1508
|
//#region src/codes/create.ts
|
|
1509
|
-
function
|
|
1509
|
+
function Zt(e) {
|
|
1510
1510
|
return async (t, n) => {
|
|
1511
1511
|
let r = {
|
|
1512
1512
|
...n,
|
|
@@ -1515,18 +1515,18 @@ function Xt(e) {
|
|
|
1515
1515
|
return await e.insertInto("codes").values({
|
|
1516
1516
|
...r,
|
|
1517
1517
|
tenant_id: t,
|
|
1518
|
-
expires_at_ts:
|
|
1518
|
+
expires_at_ts: Xt(r.expires_at)
|
|
1519
1519
|
}).execute(), r;
|
|
1520
1520
|
};
|
|
1521
1521
|
}
|
|
1522
1522
|
//#endregion
|
|
1523
1523
|
//#region src/codes/remove.ts
|
|
1524
|
-
function
|
|
1524
|
+
function Qt(e) {
|
|
1525
1525
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1526
1526
|
}
|
|
1527
1527
|
//#endregion
|
|
1528
1528
|
//#region src/codes/get.ts
|
|
1529
|
-
function
|
|
1529
|
+
function $t(e) {
|
|
1530
1530
|
return async (t, n, r) => {
|
|
1531
1531
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1532
1532
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1536,44 +1536,44 @@ function Qt(e) {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
//#endregion
|
|
1538
1538
|
//#region src/codes/used.ts
|
|
1539
|
-
function
|
|
1539
|
+
function en(e) {
|
|
1540
1540
|
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;
|
|
1541
1541
|
}
|
|
1542
1542
|
//#endregion
|
|
1543
1543
|
//#region src/codes/consume.ts
|
|
1544
|
-
function
|
|
1544
|
+
function tn(e) {
|
|
1545
1545
|
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;
|
|
1546
1546
|
}
|
|
1547
1547
|
//#endregion
|
|
1548
1548
|
//#region src/codes/cleanup.ts
|
|
1549
|
-
function
|
|
1549
|
+
function nn(e) {
|
|
1550
1550
|
return async (t) => {
|
|
1551
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1551
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", Xt(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1552
1552
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
1555
|
//#endregion
|
|
1556
1556
|
//#region src/codes/index.ts
|
|
1557
|
-
function
|
|
1557
|
+
function rn(e) {
|
|
1558
1558
|
return {
|
|
1559
|
-
create:
|
|
1560
|
-
list:
|
|
1561
|
-
remove:
|
|
1562
|
-
used:
|
|
1563
|
-
consume:
|
|
1564
|
-
get:
|
|
1565
|
-
cleanup:
|
|
1559
|
+
create: Zt(e),
|
|
1560
|
+
list: Yt(e),
|
|
1561
|
+
remove: Qt(e),
|
|
1562
|
+
used: en(e),
|
|
1563
|
+
consume: tn(e),
|
|
1564
|
+
get: $t(e),
|
|
1565
|
+
cleanup: nn(e)
|
|
1566
1566
|
};
|
|
1567
1567
|
}
|
|
1568
1568
|
//#endregion
|
|
1569
1569
|
//#region src/connections/create.ts
|
|
1570
|
-
function
|
|
1570
|
+
function an(e) {
|
|
1571
1571
|
return async (t, n, r) => {
|
|
1572
1572
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1573
1573
|
delete o.enabled_clients;
|
|
1574
1574
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1575
1575
|
...o,
|
|
1576
|
-
id: i?.id ?? o.id ??
|
|
1576
|
+
id: i?.id ?? o.id ?? we(),
|
|
1577
1577
|
is_system: a ? !0 : void 0,
|
|
1578
1578
|
created_at: i?.created_at ?? s,
|
|
1579
1579
|
updated_at: i?.updated_at ?? s
|
|
@@ -1596,16 +1596,16 @@ function L(e) {
|
|
|
1596
1596
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1597
1597
|
});
|
|
1598
1598
|
}
|
|
1599
|
-
function
|
|
1599
|
+
function on(e) {
|
|
1600
1600
|
return e.map(L);
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
1603
|
//#region src/connections/list.ts
|
|
1604
|
-
function
|
|
1604
|
+
function sn(e) {
|
|
1605
1605
|
return async (t, n = {}) => {
|
|
1606
1606
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1607
1607
|
s && (c = O(e, c, s, ["user_id", "ip"]));
|
|
1608
|
-
let l =
|
|
1608
|
+
let l = on(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1609
1609
|
if (!a) return {
|
|
1610
1610
|
connections: l,
|
|
1611
1611
|
start: 0,
|
|
@@ -1623,12 +1623,12 @@ function on(e) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region src/connections/remove.ts
|
|
1626
|
-
function
|
|
1626
|
+
function cn(e) {
|
|
1627
1627
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1628
1628
|
}
|
|
1629
1629
|
//#endregion
|
|
1630
1630
|
//#region src/connections/get.ts
|
|
1631
|
-
function
|
|
1631
|
+
function ln(e) {
|
|
1632
1632
|
return async (t, n) => {
|
|
1633
1633
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1634
1634
|
return r ? L(r) : null;
|
|
@@ -1636,7 +1636,7 @@ function cn(e) {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
//#endregion
|
|
1638
1638
|
//#region src/connections/update.ts
|
|
1639
|
-
function
|
|
1639
|
+
function un(e) {
|
|
1640
1640
|
return async (t, n, r) => {
|
|
1641
1641
|
let { is_system: i, ...a } = r;
|
|
1642
1642
|
delete a.enabled_clients;
|
|
@@ -1653,18 +1653,18 @@ function ln(e) {
|
|
|
1653
1653
|
}
|
|
1654
1654
|
//#endregion
|
|
1655
1655
|
//#region src/connections/index.ts
|
|
1656
|
-
function
|
|
1656
|
+
function dn(e) {
|
|
1657
1657
|
return {
|
|
1658
|
-
create:
|
|
1659
|
-
get:
|
|
1660
|
-
list:
|
|
1661
|
-
remove:
|
|
1662
|
-
update:
|
|
1658
|
+
create: an(e),
|
|
1659
|
+
get: ln(e),
|
|
1660
|
+
list: sn(e),
|
|
1661
|
+
remove: cn(e),
|
|
1662
|
+
update: un(e)
|
|
1663
1663
|
};
|
|
1664
1664
|
}
|
|
1665
1665
|
//#endregion
|
|
1666
1666
|
//#region src/clients/create.ts
|
|
1667
|
-
function
|
|
1667
|
+
function fn(e) {
|
|
1668
1668
|
return async (r, i, a) => {
|
|
1669
1669
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1670
1670
|
...i,
|
|
@@ -1729,7 +1729,7 @@ function dn(e) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
//#endregion
|
|
1731
1731
|
//#region src/clients/get.ts
|
|
1732
|
-
function
|
|
1732
|
+
function pn(e) {
|
|
1733
1733
|
return async (t, n) => {
|
|
1734
1734
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1735
1735
|
if (!r) return null;
|
|
@@ -1775,7 +1775,7 @@ function fn(e) {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
//#endregion
|
|
1777
1777
|
//#region src/clients/getByClientId.ts
|
|
1778
|
-
function
|
|
1778
|
+
function mn(e) {
|
|
1779
1779
|
return async (t) => {
|
|
1780
1780
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1781
1781
|
return n ? l({
|
|
@@ -1819,7 +1819,7 @@ function pn(e) {
|
|
|
1819
1819
|
}
|
|
1820
1820
|
//#endregion
|
|
1821
1821
|
//#region src/clients/list.ts
|
|
1822
|
-
function
|
|
1822
|
+
function hn(e) {
|
|
1823
1823
|
return l({
|
|
1824
1824
|
...e,
|
|
1825
1825
|
global: !!e.global,
|
|
@@ -1858,7 +1858,7 @@ function mn(e) {
|
|
|
1858
1858
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1859
1859
|
});
|
|
1860
1860
|
}
|
|
1861
|
-
function
|
|
1861
|
+
function gn(e) {
|
|
1862
1862
|
return async (t, n) => {
|
|
1863
1863
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1864
1864
|
if (n?.q) {
|
|
@@ -1873,7 +1873,7 @@ function hn(e) {
|
|
|
1873
1873
|
sortColumn: "created_at",
|
|
1874
1874
|
sortOrder: "desc",
|
|
1875
1875
|
idColumn: "client_id"
|
|
1876
|
-
}), a = e.map(
|
|
1876
|
+
}), a = e.map(hn);
|
|
1877
1877
|
return {
|
|
1878
1878
|
clients: a,
|
|
1879
1879
|
totals: {
|
|
@@ -1906,7 +1906,7 @@ function hn(e) {
|
|
|
1906
1906
|
let a = await r.executeTakeFirst();
|
|
1907
1907
|
c = Number(a?.count || 0);
|
|
1908
1908
|
}
|
|
1909
|
-
let l = s.map(
|
|
1909
|
+
let l = s.map(hn);
|
|
1910
1910
|
return {
|
|
1911
1911
|
clients: l,
|
|
1912
1912
|
totals: {
|
|
@@ -1920,12 +1920,12 @@ function hn(e) {
|
|
|
1920
1920
|
}
|
|
1921
1921
|
//#endregion
|
|
1922
1922
|
//#region src/clients/remove.ts
|
|
1923
|
-
function
|
|
1923
|
+
function _n(e) {
|
|
1924
1924
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1925
1925
|
}
|
|
1926
1926
|
//#endregion
|
|
1927
1927
|
//#region src/clients/update.ts
|
|
1928
|
-
function
|
|
1928
|
+
function vn(e) {
|
|
1929
1929
|
return async (t, r, i) => {
|
|
1930
1930
|
let a = {
|
|
1931
1931
|
...i,
|
|
@@ -1972,19 +1972,19 @@ function _n(e) {
|
|
|
1972
1972
|
}
|
|
1973
1973
|
//#endregion
|
|
1974
1974
|
//#region src/clients/index.ts
|
|
1975
|
-
function
|
|
1975
|
+
function yn(e) {
|
|
1976
1976
|
return {
|
|
1977
|
-
create:
|
|
1978
|
-
get:
|
|
1979
|
-
getByClientId:
|
|
1980
|
-
list:
|
|
1981
|
-
remove:
|
|
1982
|
-
update:
|
|
1977
|
+
create: fn(e),
|
|
1978
|
+
get: pn(e),
|
|
1979
|
+
getByClientId: mn(e),
|
|
1980
|
+
list: gn(e),
|
|
1981
|
+
remove: _n(e),
|
|
1982
|
+
update: vn(e)
|
|
1983
1983
|
};
|
|
1984
1984
|
}
|
|
1985
1985
|
//#endregion
|
|
1986
1986
|
//#region src/clientConnections/listByClient.ts
|
|
1987
|
-
function
|
|
1987
|
+
function bn(e) {
|
|
1988
1988
|
return async (t, n) => {
|
|
1989
1989
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1990
1990
|
if (!r) return [];
|
|
@@ -1996,7 +1996,7 @@ function yn(e) {
|
|
|
1996
1996
|
}
|
|
1997
1997
|
//#endregion
|
|
1998
1998
|
//#region src/clientConnections/updateByClient.ts
|
|
1999
|
-
function
|
|
1999
|
+
function xn(e) {
|
|
2000
2000
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
2001
2001
|
connections: JSON.stringify(r),
|
|
2002
2002
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2004,7 +2004,7 @@ function bn(e) {
|
|
|
2004
2004
|
}
|
|
2005
2005
|
//#endregion
|
|
2006
2006
|
//#region src/clientConnections/listByConnection.ts
|
|
2007
|
-
function
|
|
2007
|
+
function Sn(e) {
|
|
2008
2008
|
return async (t, n) => {
|
|
2009
2009
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
2010
2010
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -2013,7 +2013,7 @@ function xn(e) {
|
|
|
2013
2013
|
}
|
|
2014
2014
|
//#endregion
|
|
2015
2015
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2016
|
-
function
|
|
2016
|
+
function Cn(e) {
|
|
2017
2017
|
return async (t, n, r) => {
|
|
2018
2018
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2019
2019
|
if (!i) return !1;
|
|
@@ -2026,7 +2026,7 @@ function Sn(e) {
|
|
|
2026
2026
|
}
|
|
2027
2027
|
//#endregion
|
|
2028
2028
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2029
|
-
function
|
|
2029
|
+
function wn(e) {
|
|
2030
2030
|
return async (t, n, r) => {
|
|
2031
2031
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2032
2032
|
if (!i) return !1;
|
|
@@ -2039,18 +2039,18 @@ function Cn(e) {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
//#endregion
|
|
2041
2041
|
//#region src/clientConnections/index.ts
|
|
2042
|
-
function
|
|
2042
|
+
function Tn(e) {
|
|
2043
2043
|
return {
|
|
2044
|
-
listByClient:
|
|
2045
|
-
updateByClient:
|
|
2046
|
-
listByConnection:
|
|
2047
|
-
addClientToConnection:
|
|
2048
|
-
removeClientFromConnection:
|
|
2044
|
+
listByClient: bn(e),
|
|
2045
|
+
updateByClient: xn(e),
|
|
2046
|
+
listByConnection: Sn(e),
|
|
2047
|
+
addClientToConnection: Cn(e),
|
|
2048
|
+
removeClientFromConnection: wn(e)
|
|
2049
2049
|
};
|
|
2050
2050
|
}
|
|
2051
2051
|
//#endregion
|
|
2052
2052
|
//#region src/clientGrants/create.ts
|
|
2053
|
-
function
|
|
2053
|
+
function En(e) {
|
|
2054
2054
|
return async (n, r, i) => {
|
|
2055
2055
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? t(), c = a?.created_at ?? o, u = a?.updated_at ?? a?.created_at ?? o, { scope: d, authorization_details_types: f, ...p } = r, m = {
|
|
2056
2056
|
id: s,
|
|
@@ -2078,7 +2078,7 @@ function Tn(e) {
|
|
|
2078
2078
|
}
|
|
2079
2079
|
//#endregion
|
|
2080
2080
|
//#region src/clientGrants/get.ts
|
|
2081
|
-
function
|
|
2081
|
+
function Dn(e) {
|
|
2082
2082
|
return async (t, n) => {
|
|
2083
2083
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2084
2084
|
return r ? l({
|
|
@@ -2098,8 +2098,8 @@ function En(e) {
|
|
|
2098
2098
|
}
|
|
2099
2099
|
//#endregion
|
|
2100
2100
|
//#region src/clientGrants/list.ts
|
|
2101
|
-
function
|
|
2102
|
-
return
|
|
2101
|
+
function On(e) {
|
|
2102
|
+
return v.parse(l({
|
|
2103
2103
|
...e,
|
|
2104
2104
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
2105
2105
|
allow_any_organization: !!e.allow_any_organization,
|
|
@@ -2107,7 +2107,7 @@ function Dn(e) {
|
|
|
2107
2107
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2108
2108
|
}));
|
|
2109
2109
|
}
|
|
2110
|
-
function
|
|
2110
|
+
function kn(e) {
|
|
2111
2111
|
return async (t, n = {}) => {
|
|
2112
2112
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s, sort: c } = n, l = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
|
|
2113
2113
|
if (s) {
|
|
@@ -2124,7 +2124,7 @@ function On(e) {
|
|
|
2124
2124
|
let { rows: e, limit: t, next: r } = await P(l.selectAll(), n, {
|
|
2125
2125
|
sortColumn: "created_at",
|
|
2126
2126
|
sortOrder: "desc"
|
|
2127
|
-
}), i = e.map(
|
|
2127
|
+
}), i = e.map(On);
|
|
2128
2128
|
return {
|
|
2129
2129
|
client_grants: i,
|
|
2130
2130
|
start: 0,
|
|
@@ -2138,7 +2138,7 @@ function On(e) {
|
|
|
2138
2138
|
let { ref: t } = e.dynamic;
|
|
2139
2139
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2140
2140
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2141
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2141
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(On);
|
|
2142
2142
|
if (!a) return {
|
|
2143
2143
|
client_grants: d,
|
|
2144
2144
|
start: 0,
|
|
@@ -2156,12 +2156,12 @@ function On(e) {
|
|
|
2156
2156
|
}
|
|
2157
2157
|
//#endregion
|
|
2158
2158
|
//#region src/clientGrants/remove.ts
|
|
2159
|
-
function
|
|
2159
|
+
function An(e) {
|
|
2160
2160
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2161
2161
|
}
|
|
2162
2162
|
//#endregion
|
|
2163
2163
|
//#region src/clientGrants/update.ts
|
|
2164
|
-
function
|
|
2164
|
+
function jn(e) {
|
|
2165
2165
|
return async (t, n, r) => {
|
|
2166
2166
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2167
2167
|
...s,
|
|
@@ -2172,18 +2172,18 @@ function An(e) {
|
|
|
2172
2172
|
}
|
|
2173
2173
|
//#endregion
|
|
2174
2174
|
//#region src/clientGrants/index.ts
|
|
2175
|
-
function
|
|
2175
|
+
function Mn(e) {
|
|
2176
2176
|
return {
|
|
2177
|
-
create:
|
|
2178
|
-
get:
|
|
2179
|
-
list:
|
|
2180
|
-
remove:
|
|
2181
|
-
update:
|
|
2177
|
+
create: En(e),
|
|
2178
|
+
get: Dn(e),
|
|
2179
|
+
list: kn(e),
|
|
2180
|
+
remove: An(e),
|
|
2181
|
+
update: jn(e)
|
|
2182
2182
|
};
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/clientRegistrationTokens/create.ts
|
|
2186
|
-
function
|
|
2186
|
+
function Nn(e) {
|
|
2187
2187
|
return async (t, n) => {
|
|
2188
2188
|
let r = Date.now();
|
|
2189
2189
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2214,12 +2214,12 @@ function Mn(e) {
|
|
|
2214
2214
|
}
|
|
2215
2215
|
//#endregion
|
|
2216
2216
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2217
|
-
function
|
|
2218
|
-
let t =
|
|
2217
|
+
function Pn(e) {
|
|
2218
|
+
let t = y.safeParse(e);
|
|
2219
2219
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2220
2220
|
return t.data;
|
|
2221
2221
|
}
|
|
2222
|
-
function
|
|
2222
|
+
function Fn(e) {
|
|
2223
2223
|
if (!e) return;
|
|
2224
2224
|
let t;
|
|
2225
2225
|
try {
|
|
@@ -2227,16 +2227,16 @@ function Pn(e) {
|
|
|
2227
2227
|
} catch {
|
|
2228
2228
|
return;
|
|
2229
2229
|
}
|
|
2230
|
-
return
|
|
2230
|
+
return ae(t) ? t : void 0;
|
|
2231
2231
|
}
|
|
2232
2232
|
function R(e) {
|
|
2233
2233
|
return {
|
|
2234
2234
|
id: e.id,
|
|
2235
2235
|
token_hash: e.token_hash,
|
|
2236
|
-
type:
|
|
2236
|
+
type: Pn(e.type),
|
|
2237
2237
|
client_id: e.client_id ?? void 0,
|
|
2238
2238
|
sub: e.sub ?? void 0,
|
|
2239
|
-
constraints:
|
|
2239
|
+
constraints: Fn(e.constraints),
|
|
2240
2240
|
single_use: !!e.single_use,
|
|
2241
2241
|
expires_at: i(e.expires_at_ts),
|
|
2242
2242
|
used_at: i(e.used_at_ts),
|
|
@@ -2246,7 +2246,7 @@ function R(e) {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/clientRegistrationTokens/get.ts
|
|
2249
|
-
function
|
|
2249
|
+
function In(e) {
|
|
2250
2250
|
return async (t, n) => {
|
|
2251
2251
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2252
2252
|
return r ? R(r) : null;
|
|
@@ -2254,7 +2254,7 @@ function Fn(e) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
//#endregion
|
|
2256
2256
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2257
|
-
function
|
|
2257
|
+
function Ln(e) {
|
|
2258
2258
|
return async (t, n) => {
|
|
2259
2259
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2260
2260
|
return r ? R(r) : null;
|
|
@@ -2262,22 +2262,22 @@ function In(e) {
|
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2265
|
-
function
|
|
2265
|
+
function Rn(e) {
|
|
2266
2266
|
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(R);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2270
|
-
function
|
|
2270
|
+
function zn(e) {
|
|
2271
2271
|
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;
|
|
2272
2272
|
}
|
|
2273
2273
|
//#endregion
|
|
2274
2274
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2275
|
-
function
|
|
2275
|
+
function Bn(e) {
|
|
2276
2276
|
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;
|
|
2277
2277
|
}
|
|
2278
2278
|
//#endregion
|
|
2279
2279
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2280
|
-
function
|
|
2280
|
+
function Vn(e) {
|
|
2281
2281
|
return async (t, n, r) => {
|
|
2282
2282
|
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();
|
|
2283
2283
|
return Number(i.numUpdatedRows);
|
|
@@ -2285,26 +2285,26 @@ function Bn(e) {
|
|
|
2285
2285
|
}
|
|
2286
2286
|
//#endregion
|
|
2287
2287
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2288
|
-
function
|
|
2288
|
+
function Hn(e) {
|
|
2289
2289
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2290
2290
|
}
|
|
2291
2291
|
//#endregion
|
|
2292
2292
|
//#region src/clientRegistrationTokens/index.ts
|
|
2293
|
-
function
|
|
2293
|
+
function Un(e) {
|
|
2294
2294
|
return {
|
|
2295
|
-
create:
|
|
2296
|
-
get:
|
|
2297
|
-
getByHash:
|
|
2298
|
-
listByClient:
|
|
2299
|
-
markUsed:
|
|
2300
|
-
revoke:
|
|
2301
|
-
revokeByClient:
|
|
2302
|
-
remove:
|
|
2295
|
+
create: Nn(e),
|
|
2296
|
+
get: In(e),
|
|
2297
|
+
getByHash: Ln(e),
|
|
2298
|
+
listByClient: Rn(e),
|
|
2299
|
+
markUsed: zn(e),
|
|
2300
|
+
revoke: Bn(e),
|
|
2301
|
+
revokeByClient: Vn(e),
|
|
2302
|
+
remove: Hn(e)
|
|
2303
2303
|
};
|
|
2304
2304
|
}
|
|
2305
2305
|
//#endregion
|
|
2306
2306
|
//#region src/keys/list.ts
|
|
2307
|
-
function
|
|
2307
|
+
function Wn(e) {
|
|
2308
2308
|
return async (t = {}) => {
|
|
2309
2309
|
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)]));
|
|
2310
2310
|
s && (c = O(e, c, s, [
|
|
@@ -2333,7 +2333,7 @@ function Un(e) {
|
|
|
2333
2333
|
}
|
|
2334
2334
|
//#endregion
|
|
2335
2335
|
//#region src/keys/create.ts
|
|
2336
|
-
function
|
|
2336
|
+
function Gn(e) {
|
|
2337
2337
|
return async (t, n) => {
|
|
2338
2338
|
let r = n?.importMetadata;
|
|
2339
2339
|
await e.insertInto("keys").values({
|
|
@@ -2345,21 +2345,21 @@ function Wn(e) {
|
|
|
2345
2345
|
}
|
|
2346
2346
|
//#endregion
|
|
2347
2347
|
//#region src/keys/update.ts
|
|
2348
|
-
function
|
|
2348
|
+
function Kn(e) {
|
|
2349
2349
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2350
2350
|
}
|
|
2351
2351
|
//#endregion
|
|
2352
2352
|
//#region src/keys/index.ts
|
|
2353
|
-
function
|
|
2353
|
+
function qn(e) {
|
|
2354
2354
|
return {
|
|
2355
|
-
create:
|
|
2356
|
-
list:
|
|
2357
|
-
update:
|
|
2355
|
+
create: Gn(e),
|
|
2356
|
+
list: Wn(e),
|
|
2357
|
+
update: Kn(e)
|
|
2358
2358
|
};
|
|
2359
2359
|
}
|
|
2360
2360
|
//#endregion
|
|
2361
2361
|
//#region src/customDomains/create.ts
|
|
2362
|
-
function
|
|
2362
|
+
function Jn(e) {
|
|
2363
2363
|
return async (n, r, i) => {
|
|
2364
2364
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2365
2365
|
status: "pending",
|
|
@@ -2379,7 +2379,7 @@ function qn(e) {
|
|
|
2379
2379
|
}
|
|
2380
2380
|
//#endregion
|
|
2381
2381
|
//#region src/customDomains/list.ts
|
|
2382
|
-
function
|
|
2382
|
+
function Yn(e) {
|
|
2383
2383
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2384
2384
|
...e,
|
|
2385
2385
|
primary: e.primary === 1,
|
|
@@ -2389,12 +2389,12 @@ function Jn(e) {
|
|
|
2389
2389
|
}
|
|
2390
2390
|
//#endregion
|
|
2391
2391
|
//#region src/customDomains/remove.ts
|
|
2392
|
-
function
|
|
2392
|
+
function Xn(e) {
|
|
2393
2393
|
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;
|
|
2394
2394
|
}
|
|
2395
2395
|
//#endregion
|
|
2396
2396
|
//#region src/customDomains/get.ts
|
|
2397
|
-
function
|
|
2397
|
+
function Zn(e) {
|
|
2398
2398
|
return async (t, n) => {
|
|
2399
2399
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2400
2400
|
return r ? {
|
|
@@ -2407,7 +2407,7 @@ function Xn(e) {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
//#endregion
|
|
2409
2409
|
//#region src/customDomains/update.ts
|
|
2410
|
-
function
|
|
2410
|
+
function Qn(e) {
|
|
2411
2411
|
return async (t, n, r) => {
|
|
2412
2412
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2413
2413
|
...s,
|
|
@@ -2421,7 +2421,7 @@ function Zn(e) {
|
|
|
2421
2421
|
}
|
|
2422
2422
|
//#endregion
|
|
2423
2423
|
//#region src/customDomains/getByDomain.ts
|
|
2424
|
-
function
|
|
2424
|
+
function $n(e) {
|
|
2425
2425
|
return async (t) => {
|
|
2426
2426
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2427
2427
|
return n ? {
|
|
@@ -2433,19 +2433,19 @@ function Qn(e) {
|
|
|
2433
2433
|
}
|
|
2434
2434
|
//#endregion
|
|
2435
2435
|
//#region src/customDomains/index.ts
|
|
2436
|
-
function
|
|
2436
|
+
function er(e) {
|
|
2437
2437
|
return {
|
|
2438
|
-
create:
|
|
2439
|
-
get:
|
|
2440
|
-
getByDomain:
|
|
2441
|
-
list:
|
|
2442
|
-
remove:
|
|
2443
|
-
update:
|
|
2438
|
+
create: Jn(e),
|
|
2439
|
+
get: Zn(e),
|
|
2440
|
+
getByDomain: $n(e),
|
|
2441
|
+
list: Yn(e),
|
|
2442
|
+
remove: Xn(e),
|
|
2443
|
+
update: Qn(e)
|
|
2444
2444
|
};
|
|
2445
2445
|
}
|
|
2446
2446
|
//#endregion
|
|
2447
2447
|
//#region src/branding/get.ts
|
|
2448
|
-
function
|
|
2448
|
+
function tr(e) {
|
|
2449
2449
|
return async (t) => {
|
|
2450
2450
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2451
2451
|
if (!n) return null;
|
|
@@ -2467,7 +2467,7 @@ function er(e) {
|
|
|
2467
2467
|
}
|
|
2468
2468
|
//#endregion
|
|
2469
2469
|
//#region src/branding/set.ts
|
|
2470
|
-
function
|
|
2470
|
+
function nr(e) {
|
|
2471
2471
|
return async (t, n) => {
|
|
2472
2472
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2473
2473
|
try {
|
|
@@ -2496,15 +2496,15 @@ function tr(e) {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
//#endregion
|
|
2498
2498
|
//#region src/branding/index.ts
|
|
2499
|
-
function
|
|
2499
|
+
function rr(e) {
|
|
2500
2500
|
return {
|
|
2501
|
-
get:
|
|
2502
|
-
set:
|
|
2501
|
+
get: tr(e),
|
|
2502
|
+
set: nr(e)
|
|
2503
2503
|
};
|
|
2504
2504
|
}
|
|
2505
2505
|
//#endregion
|
|
2506
2506
|
//#region src/universalLoginTemplates/get.ts
|
|
2507
|
-
function
|
|
2507
|
+
function ir(e) {
|
|
2508
2508
|
return async (t) => {
|
|
2509
2509
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2510
2510
|
return n ? { body: n.body } : null;
|
|
@@ -2512,7 +2512,7 @@ function rr(e) {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
//#endregion
|
|
2514
2514
|
//#region src/universalLoginTemplates/set.ts
|
|
2515
|
-
function
|
|
2515
|
+
function ar(e) {
|
|
2516
2516
|
return async (t, n, r) => {
|
|
2517
2517
|
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;
|
|
2518
2518
|
try {
|
|
@@ -2533,23 +2533,23 @@ function ir(e) {
|
|
|
2533
2533
|
}
|
|
2534
2534
|
//#endregion
|
|
2535
2535
|
//#region src/universalLoginTemplates/delete.ts
|
|
2536
|
-
function
|
|
2536
|
+
function or(e) {
|
|
2537
2537
|
return async (t) => {
|
|
2538
2538
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2539
2539
|
};
|
|
2540
2540
|
}
|
|
2541
2541
|
//#endregion
|
|
2542
2542
|
//#region src/universalLoginTemplates/index.ts
|
|
2543
|
-
function
|
|
2543
|
+
function sr(e) {
|
|
2544
2544
|
return {
|
|
2545
|
-
get:
|
|
2546
|
-
set:
|
|
2547
|
-
delete:
|
|
2545
|
+
get: ir(e),
|
|
2546
|
+
set: ar(e),
|
|
2547
|
+
delete: or(e)
|
|
2548
2548
|
};
|
|
2549
2549
|
}
|
|
2550
2550
|
//#endregion
|
|
2551
2551
|
//#region src/hooks/list.ts
|
|
2552
|
-
function
|
|
2552
|
+
function cr(e) {
|
|
2553
2553
|
return async (t, n = {}) => {
|
|
2554
2554
|
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);
|
|
2555
2555
|
if (u && (d = O(e, d, u, [
|
|
@@ -2571,7 +2571,7 @@ function sr(e) {
|
|
|
2571
2571
|
...u,
|
|
2572
2572
|
enabled: !!n,
|
|
2573
2573
|
synchronous: !!i,
|
|
2574
|
-
metadata:
|
|
2574
|
+
metadata: mt(s)
|
|
2575
2575
|
});
|
|
2576
2576
|
});
|
|
2577
2577
|
if (!s) return {
|
|
@@ -2591,7 +2591,7 @@ function sr(e) {
|
|
|
2591
2591
|
}
|
|
2592
2592
|
//#endregion
|
|
2593
2593
|
//#region src/hooks/get.ts
|
|
2594
|
-
function
|
|
2594
|
+
function lr(e) {
|
|
2595
2595
|
return async (t, n) => {
|
|
2596
2596
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2597
2597
|
if (!i) return null;
|
|
@@ -2604,20 +2604,20 @@ function cr(e) {
|
|
|
2604
2604
|
...d,
|
|
2605
2605
|
enabled: !!u.enabled,
|
|
2606
2606
|
synchronous: !!u.synchronous,
|
|
2607
|
-
metadata:
|
|
2607
|
+
metadata: mt(c)
|
|
2608
2608
|
});
|
|
2609
2609
|
};
|
|
2610
2610
|
}
|
|
2611
2611
|
//#endregion
|
|
2612
2612
|
//#region src/hooks/remove.ts
|
|
2613
|
-
function
|
|
2613
|
+
function ur(e) {
|
|
2614
2614
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2615
2615
|
}
|
|
2616
2616
|
//#endregion
|
|
2617
2617
|
//#region src/hooks/create.ts
|
|
2618
|
-
function
|
|
2618
|
+
function dr(e) {
|
|
2619
2619
|
return async (t, n, r) => {
|
|
2620
|
-
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 ||
|
|
2620
|
+
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 || De()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2621
2621
|
return await e.insertInto("hooks").values({
|
|
2622
2622
|
...p,
|
|
2623
2623
|
hook_id: c,
|
|
@@ -2640,7 +2640,7 @@ function ur(e) {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
//#endregion
|
|
2642
2642
|
//#region src/hooks/update.ts
|
|
2643
|
-
function
|
|
2643
|
+
function fr(e) {
|
|
2644
2644
|
return async (t, n, r) => {
|
|
2645
2645
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2646
2646
|
...o,
|
|
@@ -2654,20 +2654,20 @@ function dr(e) {
|
|
|
2654
2654
|
}
|
|
2655
2655
|
//#endregion
|
|
2656
2656
|
//#region src/hooks/index.ts
|
|
2657
|
-
function
|
|
2657
|
+
function pr(e) {
|
|
2658
2658
|
return {
|
|
2659
|
-
create:
|
|
2660
|
-
get:
|
|
2661
|
-
list:
|
|
2662
|
-
update:
|
|
2663
|
-
remove:
|
|
2659
|
+
create: dr(e),
|
|
2660
|
+
get: lr(e),
|
|
2661
|
+
list: cr(e),
|
|
2662
|
+
update: fr(e),
|
|
2663
|
+
remove: ur(e)
|
|
2664
2664
|
};
|
|
2665
2665
|
}
|
|
2666
2666
|
//#endregion
|
|
2667
2667
|
//#region src/hook-code/create.ts
|
|
2668
|
-
function
|
|
2668
|
+
function mr(e) {
|
|
2669
2669
|
return async (t, n, r) => {
|
|
2670
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2670
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? ke();
|
|
2671
2671
|
return await e.insertInto("hook_code").values({
|
|
2672
2672
|
id: c,
|
|
2673
2673
|
tenant_id: t,
|
|
@@ -2687,7 +2687,7 @@ function pr(e) {
|
|
|
2687
2687
|
}
|
|
2688
2688
|
//#endregion
|
|
2689
2689
|
//#region src/hook-code/get.ts
|
|
2690
|
-
function
|
|
2690
|
+
function hr(e) {
|
|
2691
2691
|
return async (t, n) => {
|
|
2692
2692
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2693
2693
|
if (!i) return null;
|
|
@@ -2711,7 +2711,7 @@ function mr(e) {
|
|
|
2711
2711
|
}
|
|
2712
2712
|
//#endregion
|
|
2713
2713
|
//#region src/hook-code/update.ts
|
|
2714
|
-
function
|
|
2714
|
+
function gr(e) {
|
|
2715
2715
|
return async (t, n, r) => {
|
|
2716
2716
|
let i = { updated_at_ts: Date.now() };
|
|
2717
2717
|
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;
|
|
@@ -2719,22 +2719,22 @@ function hr(e) {
|
|
|
2719
2719
|
}
|
|
2720
2720
|
//#endregion
|
|
2721
2721
|
//#region src/hook-code/remove.ts
|
|
2722
|
-
function
|
|
2722
|
+
function _r(e) {
|
|
2723
2723
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2724
2724
|
}
|
|
2725
2725
|
//#endregion
|
|
2726
2726
|
//#region src/hook-code/index.ts
|
|
2727
|
-
function
|
|
2727
|
+
function vr(e) {
|
|
2728
2728
|
return {
|
|
2729
|
-
create:
|
|
2730
|
-
get:
|
|
2731
|
-
update:
|
|
2732
|
-
remove:
|
|
2729
|
+
create: mr(e),
|
|
2730
|
+
get: hr(e),
|
|
2731
|
+
update: gr(e),
|
|
2732
|
+
remove: _r(e)
|
|
2733
2733
|
};
|
|
2734
2734
|
}
|
|
2735
2735
|
//#endregion
|
|
2736
2736
|
//#region src/themes/create.ts
|
|
2737
|
-
function
|
|
2737
|
+
function yr(e) {
|
|
2738
2738
|
return async (n, r, i, a) => {
|
|
2739
2739
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2740
2740
|
themeId: o?.id || i || t(),
|
|
@@ -2750,15 +2750,15 @@ function vr(e) {
|
|
|
2750
2750
|
}
|
|
2751
2751
|
//#endregion
|
|
2752
2752
|
//#region src/themes/remove.ts
|
|
2753
|
-
function
|
|
2753
|
+
function br(e) {
|
|
2754
2754
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2755
2755
|
}
|
|
2756
2756
|
//#endregion
|
|
2757
2757
|
//#region src/themes/get.ts
|
|
2758
|
-
function
|
|
2758
|
+
function xr(e) {
|
|
2759
2759
|
return async (t, n) => {
|
|
2760
2760
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2761
|
-
return r ? l(
|
|
2761
|
+
return r ? l(ot({
|
|
2762
2762
|
...r,
|
|
2763
2763
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2764
2764
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2778,7 +2778,7 @@ function br(e) {
|
|
|
2778
2778
|
}
|
|
2779
2779
|
//#endregion
|
|
2780
2780
|
//#region src/themes/update.ts
|
|
2781
|
-
function
|
|
2781
|
+
function Sr(e) {
|
|
2782
2782
|
return async (t, n, r) => {
|
|
2783
2783
|
let { themeId: i, ...a } = r, o = F({
|
|
2784
2784
|
...a,
|
|
@@ -2789,17 +2789,17 @@ function xr(e) {
|
|
|
2789
2789
|
}
|
|
2790
2790
|
//#endregion
|
|
2791
2791
|
//#region src/themes/index.ts
|
|
2792
|
-
function
|
|
2792
|
+
function Cr(e) {
|
|
2793
2793
|
return {
|
|
2794
|
-
create:
|
|
2795
|
-
get:
|
|
2796
|
-
remove:
|
|
2797
|
-
update:
|
|
2794
|
+
create: yr(e),
|
|
2795
|
+
get: xr(e),
|
|
2796
|
+
remove: br(e),
|
|
2797
|
+
update: Sr(e)
|
|
2798
2798
|
};
|
|
2799
2799
|
}
|
|
2800
2800
|
//#endregion
|
|
2801
2801
|
//#region src/loginSessions/get.ts
|
|
2802
|
-
function
|
|
2802
|
+
function wr(e) {
|
|
2803
2803
|
return async (t, n) => {
|
|
2804
2804
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2805
2805
|
if (!i) return null;
|
|
@@ -2811,40 +2811,40 @@ function Cr(e) {
|
|
|
2811
2811
|
"created_at_ts",
|
|
2812
2812
|
"updated_at_ts",
|
|
2813
2813
|
"expires_at_ts"
|
|
2814
|
-
]), f =
|
|
2814
|
+
]), f = ot(l({
|
|
2815
2815
|
...u,
|
|
2816
2816
|
...d,
|
|
2817
2817
|
state: i.state || p.PENDING,
|
|
2818
2818
|
state_data: i.state_data,
|
|
2819
2819
|
failure_reason: i.failure_reason
|
|
2820
2820
|
}), ["auth_strategy"]);
|
|
2821
|
-
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {},
|
|
2821
|
+
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {}, oe.parse(f);
|
|
2822
2822
|
};
|
|
2823
2823
|
}
|
|
2824
2824
|
//#endregion
|
|
2825
2825
|
//#region src/utils/ulid.ts
|
|
2826
|
-
var
|
|
2827
|
-
function
|
|
2826
|
+
var Tr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", z = 32, Er = 10, Dr = 16;
|
|
2827
|
+
function Or(e) {
|
|
2828
2828
|
let t = "";
|
|
2829
|
-
for (let n =
|
|
2829
|
+
for (let n = Er; n > 0; n--) t = Tr.charAt(e % z) + t, e = Math.floor(e / z);
|
|
2830
2830
|
return t;
|
|
2831
2831
|
}
|
|
2832
|
-
function
|
|
2833
|
-
let e = new Uint8Array(
|
|
2832
|
+
function kr() {
|
|
2833
|
+
let e = new Uint8Array(Dr);
|
|
2834
2834
|
crypto.getRandomValues(e);
|
|
2835
2835
|
let t = "";
|
|
2836
|
-
for (let n = 0; n <
|
|
2836
|
+
for (let n = 0; n < Dr; n++) t += Tr.charAt(e[n] % z);
|
|
2837
2837
|
return t;
|
|
2838
2838
|
}
|
|
2839
|
-
function
|
|
2840
|
-
return
|
|
2839
|
+
function Ar() {
|
|
2840
|
+
return Or(Date.now()) + kr();
|
|
2841
2841
|
}
|
|
2842
2842
|
//#endregion
|
|
2843
2843
|
//#region src/loginSessions/create.ts
|
|
2844
|
-
function
|
|
2844
|
+
function jr(e) {
|
|
2845
2845
|
return async (t, n) => {
|
|
2846
2846
|
let r = c(), i = {
|
|
2847
|
-
id:
|
|
2847
|
+
id: Ar(),
|
|
2848
2848
|
...n,
|
|
2849
2849
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2850
2850
|
created_at: r,
|
|
@@ -2865,7 +2865,7 @@ function Ar(e) {
|
|
|
2865
2865
|
}
|
|
2866
2866
|
//#endregion
|
|
2867
2867
|
//#region src/loginSessions/update.ts
|
|
2868
|
-
function
|
|
2868
|
+
function Mr(e) {
|
|
2869
2869
|
return async (t, n, r) => {
|
|
2870
2870
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2871
2871
|
if (c !== void 0) {
|
|
@@ -2886,22 +2886,22 @@ function jr(e) {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
//#endregion
|
|
2888
2888
|
//#region src/loginSessions/remove.ts
|
|
2889
|
-
function
|
|
2889
|
+
function Nr(e) {
|
|
2890
2890
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2891
2891
|
}
|
|
2892
2892
|
//#endregion
|
|
2893
2893
|
//#region src/loginSessions/index.ts
|
|
2894
|
-
function
|
|
2894
|
+
function Pr(e) {
|
|
2895
2895
|
return {
|
|
2896
|
-
create:
|
|
2897
|
-
get:
|
|
2898
|
-
update:
|
|
2899
|
-
remove:
|
|
2896
|
+
create: jr(e),
|
|
2897
|
+
get: wr(e),
|
|
2898
|
+
update: Mr(e),
|
|
2899
|
+
remove: Nr(e)
|
|
2900
2900
|
};
|
|
2901
2901
|
}
|
|
2902
2902
|
//#endregion
|
|
2903
2903
|
//#region src/promptSettings/get.ts
|
|
2904
|
-
function
|
|
2904
|
+
function Fr(e) {
|
|
2905
2905
|
return async (t) => {
|
|
2906
2906
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2907
2907
|
return l({
|
|
@@ -2915,13 +2915,13 @@ function Pr(e) {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
//#endregion
|
|
2917
2917
|
//#region src/promptSettings/set.ts
|
|
2918
|
-
function
|
|
2918
|
+
function Ir(e) {
|
|
2919
2919
|
let t = {};
|
|
2920
2920
|
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;
|
|
2921
2921
|
}
|
|
2922
|
-
function
|
|
2922
|
+
function Lr(e) {
|
|
2923
2923
|
return async (t, n) => {
|
|
2924
|
-
let r =
|
|
2924
|
+
let r = Ir(n);
|
|
2925
2925
|
try {
|
|
2926
2926
|
await e.insertInto("prompt_settings").values({
|
|
2927
2927
|
tenant_id: t,
|
|
@@ -2939,15 +2939,15 @@ function Ir(e) {
|
|
|
2939
2939
|
}
|
|
2940
2940
|
//#endregion
|
|
2941
2941
|
//#region src/promptSettings/index.ts
|
|
2942
|
-
function
|
|
2942
|
+
function Rr(e) {
|
|
2943
2943
|
return {
|
|
2944
|
-
get:
|
|
2945
|
-
set:
|
|
2944
|
+
get: Fr(e),
|
|
2945
|
+
set: Lr(e)
|
|
2946
2946
|
};
|
|
2947
2947
|
}
|
|
2948
2948
|
//#endregion
|
|
2949
2949
|
//#region src/emailProvideres/get.ts
|
|
2950
|
-
function
|
|
2950
|
+
function zr(e) {
|
|
2951
2951
|
return async (t) => {
|
|
2952
2952
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2953
2953
|
if (!n) return null;
|
|
@@ -2962,7 +2962,7 @@ function Rr(e) {
|
|
|
2962
2962
|
}
|
|
2963
2963
|
//#endregion
|
|
2964
2964
|
//#region src/emailProvideres/update.ts
|
|
2965
|
-
function
|
|
2965
|
+
function Br(e) {
|
|
2966
2966
|
return async (t, n) => {
|
|
2967
2967
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2968
2968
|
await e.updateTable("email_providers").set({
|
|
@@ -2975,7 +2975,7 @@ function zr(e) {
|
|
|
2975
2975
|
}
|
|
2976
2976
|
//#endregion
|
|
2977
2977
|
//#region src/emailProvideres/create.ts
|
|
2978
|
-
function
|
|
2978
|
+
function Vr(e) {
|
|
2979
2979
|
return async (t, n, r) => {
|
|
2980
2980
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2981
2981
|
await e.insertInto("email_providers").values({
|
|
@@ -2991,24 +2991,24 @@ function Br(e) {
|
|
|
2991
2991
|
}
|
|
2992
2992
|
//#endregion
|
|
2993
2993
|
//#region src/emailProvideres/remove.ts
|
|
2994
|
-
function
|
|
2994
|
+
function Hr(e) {
|
|
2995
2995
|
return async (t) => {
|
|
2996
2996
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
2997
2997
|
};
|
|
2998
2998
|
}
|
|
2999
2999
|
//#endregion
|
|
3000
3000
|
//#region src/emailProvideres/index.ts
|
|
3001
|
-
function
|
|
3001
|
+
function Ur(e) {
|
|
3002
3002
|
return {
|
|
3003
|
-
get:
|
|
3004
|
-
create:
|
|
3005
|
-
update:
|
|
3006
|
-
remove:
|
|
3003
|
+
get: zr(e),
|
|
3004
|
+
create: Vr(e),
|
|
3005
|
+
update: Br(e),
|
|
3006
|
+
remove: Hr(e)
|
|
3007
3007
|
};
|
|
3008
3008
|
}
|
|
3009
3009
|
//#endregion
|
|
3010
3010
|
//#region src/emailTemplates/row.ts
|
|
3011
|
-
function
|
|
3011
|
+
function Wr(e) {
|
|
3012
3012
|
let t = {
|
|
3013
3013
|
template: e.template,
|
|
3014
3014
|
body: e.body,
|
|
@@ -3022,20 +3022,20 @@ function Ur(e) {
|
|
|
3022
3022
|
}
|
|
3023
3023
|
//#endregion
|
|
3024
3024
|
//#region src/emailTemplates/get.ts
|
|
3025
|
-
function
|
|
3025
|
+
function Gr(e) {
|
|
3026
3026
|
return async (t, n) => {
|
|
3027
3027
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3028
|
-
return r ?
|
|
3028
|
+
return r ? ne.parse(Wr(r)) : null;
|
|
3029
3029
|
};
|
|
3030
3030
|
}
|
|
3031
3031
|
//#endregion
|
|
3032
3032
|
//#region src/emailTemplates/list.ts
|
|
3033
|
-
function
|
|
3034
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) =>
|
|
3033
|
+
function Kr(e) {
|
|
3034
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(Wr(e)));
|
|
3035
3035
|
}
|
|
3036
3036
|
//#endregion
|
|
3037
3037
|
//#region src/emailTemplates/create.ts
|
|
3038
|
-
function
|
|
3038
|
+
function qr(e) {
|
|
3039
3039
|
return async (t, n, r) => {
|
|
3040
3040
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3041
3041
|
return await e.insertInto("email_templates").values({
|
|
@@ -3056,7 +3056,7 @@ function Kr(e) {
|
|
|
3056
3056
|
}
|
|
3057
3057
|
//#endregion
|
|
3058
3058
|
//#region src/emailTemplates/update.ts
|
|
3059
|
-
function
|
|
3059
|
+
function Jr(e) {
|
|
3060
3060
|
return async (t, n, r) => {
|
|
3061
3061
|
let i = {};
|
|
3062
3062
|
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;
|
|
@@ -3067,7 +3067,7 @@ function qr(e) {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
//#endregion
|
|
3069
3069
|
//#region src/emailTemplates/remove.ts
|
|
3070
|
-
function
|
|
3070
|
+
function Yr(e) {
|
|
3071
3071
|
return async (t, n) => {
|
|
3072
3072
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3073
3073
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3075,18 +3075,18 @@ function Jr(e) {
|
|
|
3075
3075
|
}
|
|
3076
3076
|
//#endregion
|
|
3077
3077
|
//#region src/emailTemplates/index.ts
|
|
3078
|
-
function
|
|
3078
|
+
function Xr(e) {
|
|
3079
3079
|
return {
|
|
3080
|
-
get:
|
|
3081
|
-
list:
|
|
3082
|
-
create:
|
|
3083
|
-
update:
|
|
3084
|
-
remove:
|
|
3080
|
+
get: Gr(e),
|
|
3081
|
+
list: Kr(e),
|
|
3082
|
+
create: qr(e),
|
|
3083
|
+
update: Jr(e),
|
|
3084
|
+
remove: Yr(e)
|
|
3085
3085
|
};
|
|
3086
3086
|
}
|
|
3087
3087
|
//#endregion
|
|
3088
3088
|
//#region src/refreshTokens/get.ts
|
|
3089
|
-
function
|
|
3089
|
+
function Zr(e) {
|
|
3090
3090
|
return async (t, n) => {
|
|
3091
3091
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3092
3092
|
if (!i) return null;
|
|
@@ -3115,7 +3115,7 @@ function Xr(e) {
|
|
|
3115
3115
|
}
|
|
3116
3116
|
//#endregion
|
|
3117
3117
|
//#region src/refreshTokens/getByLookup.ts
|
|
3118
|
-
function
|
|
3118
|
+
function Qr(e) {
|
|
3119
3119
|
return async (t, n) => {
|
|
3120
3120
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3121
3121
|
if (!i) return null;
|
|
@@ -3144,7 +3144,7 @@ function Zr(e) {
|
|
|
3144
3144
|
}
|
|
3145
3145
|
//#endregion
|
|
3146
3146
|
//#region src/refreshTokens/create.ts
|
|
3147
|
-
function
|
|
3147
|
+
function $r(e) {
|
|
3148
3148
|
return async (t, n) => {
|
|
3149
3149
|
let r = c(), i = {
|
|
3150
3150
|
...n,
|
|
@@ -3174,12 +3174,12 @@ function Qr(e) {
|
|
|
3174
3174
|
}
|
|
3175
3175
|
//#endregion
|
|
3176
3176
|
//#region src/refreshTokens/remove.ts
|
|
3177
|
-
function
|
|
3177
|
+
function ei(e) {
|
|
3178
3178
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3179
3179
|
}
|
|
3180
3180
|
//#endregion
|
|
3181
3181
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3182
|
-
function
|
|
3182
|
+
function ti(e) {
|
|
3183
3183
|
return async (t, n, r) => {
|
|
3184
3184
|
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();
|
|
3185
3185
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3187,7 +3187,7 @@ function ei(e) {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
//#endregion
|
|
3189
3189
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3190
|
-
function
|
|
3190
|
+
function ni(e) {
|
|
3191
3191
|
return async (t, n, r) => {
|
|
3192
3192
|
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();
|
|
3193
3193
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3195,7 +3195,7 @@ function ti(e) {
|
|
|
3195
3195
|
}
|
|
3196
3196
|
//#endregion
|
|
3197
3197
|
//#region src/refreshTokens/update.ts
|
|
3198
|
-
function
|
|
3198
|
+
function ri(e) {
|
|
3199
3199
|
return async (t, n, r, i) => {
|
|
3200
3200
|
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 = {
|
|
3201
3201
|
...h,
|
|
@@ -3216,7 +3216,7 @@ function ni(e) {
|
|
|
3216
3216
|
}
|
|
3217
3217
|
//#endregion
|
|
3218
3218
|
//#region src/refreshTokens/list.ts
|
|
3219
|
-
function
|
|
3219
|
+
function ii(e) {
|
|
3220
3220
|
return async (t, n = {}) => {
|
|
3221
3221
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3222
3222
|
l && (u = O(e, u, l, ["token", "login_id"]));
|
|
@@ -3266,24 +3266,24 @@ function ri(e) {
|
|
|
3266
3266
|
}
|
|
3267
3267
|
//#endregion
|
|
3268
3268
|
//#region src/refreshTokens/index.ts
|
|
3269
|
-
function
|
|
3269
|
+
function ai(e) {
|
|
3270
3270
|
return {
|
|
3271
|
-
create:
|
|
3272
|
-
get:
|
|
3273
|
-
getByLookup:
|
|
3274
|
-
list:
|
|
3275
|
-
remove:
|
|
3276
|
-
revokeByLoginSession:
|
|
3277
|
-
revokeFamily:
|
|
3278
|
-
update:
|
|
3271
|
+
create: $r(e),
|
|
3272
|
+
get: Zr(e),
|
|
3273
|
+
getByLookup: Qr(e),
|
|
3274
|
+
list: ii(e),
|
|
3275
|
+
remove: ei(e),
|
|
3276
|
+
revokeByLoginSession: ti(e),
|
|
3277
|
+
revokeFamily: ni(e),
|
|
3278
|
+
update: ri(e)
|
|
3279
3279
|
};
|
|
3280
3280
|
}
|
|
3281
3281
|
//#endregion
|
|
3282
3282
|
//#region src/cleanup.ts
|
|
3283
|
-
var
|
|
3284
|
-
function
|
|
3283
|
+
var oi = 10080 * 60 * 1e3;
|
|
3284
|
+
function si(e) {
|
|
3285
3285
|
return async (t) => {
|
|
3286
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3286
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - oi, a = 1e3;
|
|
3287
3287
|
try {
|
|
3288
3288
|
let t = 0;
|
|
3289
3289
|
for (;;) {
|
|
@@ -3314,7 +3314,7 @@ function oi(e) {
|
|
|
3314
3314
|
}
|
|
3315
3315
|
//#endregion
|
|
3316
3316
|
//#region src/forms/create.ts
|
|
3317
|
-
function
|
|
3317
|
+
function ci(e) {
|
|
3318
3318
|
return async (n, r, i) => {
|
|
3319
3319
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3320
3320
|
id: a?.id ?? t(),
|
|
@@ -3333,7 +3333,7 @@ function si(e) {
|
|
|
3333
3333
|
}
|
|
3334
3334
|
//#endregion
|
|
3335
3335
|
//#region src/forms/list.ts
|
|
3336
|
-
function
|
|
3336
|
+
function li(e) {
|
|
3337
3337
|
return async (t, n = {}) => {
|
|
3338
3338
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3339
3339
|
s && (c = O(e, c, s, []));
|
|
@@ -3367,7 +3367,7 @@ function ci(e) {
|
|
|
3367
3367
|
}
|
|
3368
3368
|
//#endregion
|
|
3369
3369
|
//#region src/forms/remove.ts
|
|
3370
|
-
function
|
|
3370
|
+
function ui(e) {
|
|
3371
3371
|
return async (t, n) => {
|
|
3372
3372
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3373
3373
|
return r > 0;
|
|
@@ -3375,7 +3375,7 @@ function li(e) {
|
|
|
3375
3375
|
}
|
|
3376
3376
|
//#endregion
|
|
3377
3377
|
//#region src/forms/get.ts
|
|
3378
|
-
function
|
|
3378
|
+
function di(e) {
|
|
3379
3379
|
return async (t, n) => {
|
|
3380
3380
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3381
3381
|
if (!r) return null;
|
|
@@ -3394,7 +3394,7 @@ function ui(e) {
|
|
|
3394
3394
|
}
|
|
3395
3395
|
//#endregion
|
|
3396
3396
|
//#region src/forms/update.ts
|
|
3397
|
-
function
|
|
3397
|
+
function fi(e) {
|
|
3398
3398
|
return async (t, n, r) => {
|
|
3399
3399
|
let i = {
|
|
3400
3400
|
...r,
|
|
@@ -3411,25 +3411,25 @@ function di(e) {
|
|
|
3411
3411
|
}
|
|
3412
3412
|
//#endregion
|
|
3413
3413
|
//#region src/forms/index.ts
|
|
3414
|
-
function
|
|
3414
|
+
function pi(e) {
|
|
3415
3415
|
return {
|
|
3416
|
-
create:
|
|
3417
|
-
get:
|
|
3418
|
-
list:
|
|
3419
|
-
remove:
|
|
3420
|
-
update:
|
|
3416
|
+
create: ci(e),
|
|
3417
|
+
get: di(e),
|
|
3418
|
+
list: li(e),
|
|
3419
|
+
remove: ui(e),
|
|
3420
|
+
update: fi(e)
|
|
3421
3421
|
};
|
|
3422
3422
|
}
|
|
3423
3423
|
//#endregion
|
|
3424
3424
|
//#region src/resourceServers/create.ts
|
|
3425
|
-
function
|
|
3425
|
+
function mi(e) {
|
|
3426
3426
|
return async (t, n, r) => {
|
|
3427
3427
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3428
3428
|
...n,
|
|
3429
|
-
id: i?.id ?? n.id ??
|
|
3429
|
+
id: i?.id ?? n.id ?? Oe(),
|
|
3430
3430
|
created_at: o,
|
|
3431
3431
|
updated_at: s
|
|
3432
|
-
}, u =
|
|
3432
|
+
}, u = ue.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 = {
|
|
3433
3433
|
...v,
|
|
3434
3434
|
tenant_id: t,
|
|
3435
3435
|
scopes: f ? JSON.stringify(f) : "[]",
|
|
@@ -3447,7 +3447,7 @@ function pi(e) {
|
|
|
3447
3447
|
}
|
|
3448
3448
|
//#endregion
|
|
3449
3449
|
//#region src/resourceServers/get.ts
|
|
3450
|
-
function
|
|
3450
|
+
function hi(e) {
|
|
3451
3451
|
return async (t, n) => {
|
|
3452
3452
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3453
3453
|
if (!r) return null;
|
|
@@ -3466,7 +3466,7 @@ function mi(e) {
|
|
|
3466
3466
|
}
|
|
3467
3467
|
//#endregion
|
|
3468
3468
|
//#region src/resourceServers/list.ts
|
|
3469
|
-
function
|
|
3469
|
+
function gi(e) {
|
|
3470
3470
|
return async (t, n = {}) => {
|
|
3471
3471
|
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);
|
|
3472
3472
|
if (s) {
|
|
@@ -3506,7 +3506,7 @@ function hi(e) {
|
|
|
3506
3506
|
}
|
|
3507
3507
|
//#endregion
|
|
3508
3508
|
//#region src/resourceServers/remove.ts
|
|
3509
|
-
function
|
|
3509
|
+
function _i(e) {
|
|
3510
3510
|
return async (t, n) => {
|
|
3511
3511
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3512
3512
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3514,7 +3514,7 @@ function gi(e) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
//#endregion
|
|
3516
3516
|
//#region src/resourceServers/update.ts
|
|
3517
|
-
function
|
|
3517
|
+
function vi(e) {
|
|
3518
3518
|
return async (t, n, r) => {
|
|
3519
3519
|
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 = {
|
|
3520
3520
|
...d,
|
|
@@ -3534,18 +3534,18 @@ function _i(e) {
|
|
|
3534
3534
|
}
|
|
3535
3535
|
//#endregion
|
|
3536
3536
|
//#region src/resourceServers/index.ts
|
|
3537
|
-
function
|
|
3537
|
+
function yi(e) {
|
|
3538
3538
|
return {
|
|
3539
|
-
create:
|
|
3540
|
-
get:
|
|
3541
|
-
list:
|
|
3542
|
-
remove:
|
|
3543
|
-
update:
|
|
3539
|
+
create: mi(e),
|
|
3540
|
+
get: hi(e),
|
|
3541
|
+
list: gi(e),
|
|
3542
|
+
remove: _i(e),
|
|
3543
|
+
update: vi(e)
|
|
3544
3544
|
};
|
|
3545
3545
|
}
|
|
3546
3546
|
//#endregion
|
|
3547
3547
|
//#region src/roles/create.ts
|
|
3548
|
-
function
|
|
3548
|
+
function bi(e) {
|
|
3549
3549
|
return async (n, r, i) => {
|
|
3550
3550
|
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 = {
|
|
3551
3551
|
id: l,
|
|
@@ -3568,7 +3568,7 @@ function yi(e) {
|
|
|
3568
3568
|
}
|
|
3569
3569
|
//#endregion
|
|
3570
3570
|
//#region src/roles/get.ts
|
|
3571
|
-
function
|
|
3571
|
+
function xi(e) {
|
|
3572
3572
|
return async (t, n) => {
|
|
3573
3573
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3574
3574
|
if (!r) return null;
|
|
@@ -3582,7 +3582,7 @@ function bi(e) {
|
|
|
3582
3582
|
}
|
|
3583
3583
|
//#endregion
|
|
3584
3584
|
//#region src/roles/list.ts
|
|
3585
|
-
function
|
|
3585
|
+
function Si(e) {
|
|
3586
3586
|
return async (t, n) => {
|
|
3587
3587
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3588
3588
|
n.q && (r = O(e, r, n.q, ["name"]));
|
|
@@ -3611,7 +3611,7 @@ function xi(e) {
|
|
|
3611
3611
|
}
|
|
3612
3612
|
//#endregion
|
|
3613
3613
|
//#region src/roles/update.ts
|
|
3614
|
-
function
|
|
3614
|
+
function Ci(e) {
|
|
3615
3615
|
return async (t, n, r) => {
|
|
3616
3616
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3617
3617
|
...o,
|
|
@@ -3624,7 +3624,7 @@ function Si(e) {
|
|
|
3624
3624
|
}
|
|
3625
3625
|
//#endregion
|
|
3626
3626
|
//#region src/roles/remove.ts
|
|
3627
|
-
function
|
|
3627
|
+
function wi(e) {
|
|
3628
3628
|
return async (t, n) => {
|
|
3629
3629
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3630
3630
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3632,23 +3632,23 @@ function Ci(e) {
|
|
|
3632
3632
|
}
|
|
3633
3633
|
//#endregion
|
|
3634
3634
|
//#region src/roles/index.ts
|
|
3635
|
-
function
|
|
3635
|
+
function Ti(e) {
|
|
3636
3636
|
return {
|
|
3637
|
-
create:
|
|
3638
|
-
get:
|
|
3639
|
-
list:
|
|
3640
|
-
update:
|
|
3641
|
-
remove:
|
|
3637
|
+
create: bi(e),
|
|
3638
|
+
get: xi(e),
|
|
3639
|
+
list: Si(e),
|
|
3640
|
+
update: Ci(e),
|
|
3641
|
+
remove: wi(e)
|
|
3642
3642
|
};
|
|
3643
3643
|
}
|
|
3644
3644
|
//#endregion
|
|
3645
3645
|
//#region src/role-permissions/assign.ts
|
|
3646
|
-
function
|
|
3646
|
+
function Ei(e) {
|
|
3647
3647
|
if (typeof e != "object" || !e) return !1;
|
|
3648
3648
|
let { code: t, message: n } = e;
|
|
3649
3649
|
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"));
|
|
3650
3650
|
}
|
|
3651
|
-
function
|
|
3651
|
+
function Di(e) {
|
|
3652
3652
|
return async (t, n, r, i) => {
|
|
3653
3653
|
if (r.length === 0) return !0;
|
|
3654
3654
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3665,7 +3665,7 @@ function Ei(e) {
|
|
|
3665
3665
|
try {
|
|
3666
3666
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3667
3667
|
} catch (e) {
|
|
3668
|
-
if (
|
|
3668
|
+
if (Ei(e)) continue;
|
|
3669
3669
|
throw e;
|
|
3670
3670
|
}
|
|
3671
3671
|
}
|
|
@@ -3677,7 +3677,7 @@ function Ei(e) {
|
|
|
3677
3677
|
}
|
|
3678
3678
|
//#endregion
|
|
3679
3679
|
//#region src/role-permissions/remove.ts
|
|
3680
|
-
function
|
|
3680
|
+
function Oi(e) {
|
|
3681
3681
|
return async (t, n, r) => {
|
|
3682
3682
|
if (r.length === 0) return !0;
|
|
3683
3683
|
try {
|
|
@@ -3689,7 +3689,7 @@ function Di(e) {
|
|
|
3689
3689
|
}
|
|
3690
3690
|
//#endregion
|
|
3691
3691
|
//#region src/role-permissions/list.ts
|
|
3692
|
-
function
|
|
3692
|
+
function ki(e) {
|
|
3693
3693
|
return async (t, n, r = {}) => {
|
|
3694
3694
|
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([
|
|
3695
3695
|
"role_permissions.role_id",
|
|
@@ -3710,16 +3710,16 @@ function Oi(e) {
|
|
|
3710
3710
|
}
|
|
3711
3711
|
//#endregion
|
|
3712
3712
|
//#region src/role-permissions/index.ts
|
|
3713
|
-
function
|
|
3713
|
+
function Ai(e) {
|
|
3714
3714
|
return {
|
|
3715
|
-
assign:
|
|
3716
|
-
remove:
|
|
3717
|
-
list:
|
|
3715
|
+
assign: Di(e),
|
|
3716
|
+
remove: Oi(e),
|
|
3717
|
+
list: ki(e)
|
|
3718
3718
|
};
|
|
3719
3719
|
}
|
|
3720
3720
|
//#endregion
|
|
3721
3721
|
//#region src/grants/create.ts
|
|
3722
|
-
function
|
|
3722
|
+
function ji(e) {
|
|
3723
3723
|
return async (n, r) => {
|
|
3724
3724
|
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();
|
|
3725
3725
|
if (s) {
|
|
@@ -3756,7 +3756,7 @@ function Ai(e) {
|
|
|
3756
3756
|
}
|
|
3757
3757
|
//#endregion
|
|
3758
3758
|
//#region src/grants/get.ts
|
|
3759
|
-
function
|
|
3759
|
+
function Mi(e) {
|
|
3760
3760
|
return async (t, n, r, i) => {
|
|
3761
3761
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3762
3762
|
return a ? {
|
|
@@ -3770,7 +3770,7 @@ function ji(e) {
|
|
|
3770
3770
|
}
|
|
3771
3771
|
//#endregion
|
|
3772
3772
|
//#region src/grants/list.ts
|
|
3773
|
-
function
|
|
3773
|
+
function Ni(e) {
|
|
3774
3774
|
return async (t, n = {}) => {
|
|
3775
3775
|
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);
|
|
3776
3776
|
c && (l = O(e, l, c, [
|
|
@@ -3808,26 +3808,26 @@ function Mi(e) {
|
|
|
3808
3808
|
}
|
|
3809
3809
|
//#endregion
|
|
3810
3810
|
//#region src/grants/remove.ts
|
|
3811
|
-
function
|
|
3811
|
+
function Pi(e) {
|
|
3812
3812
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3813
3813
|
}
|
|
3814
|
-
function
|
|
3814
|
+
function Fi(e) {
|
|
3815
3815
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3816
3816
|
}
|
|
3817
3817
|
//#endregion
|
|
3818
3818
|
//#region src/grants/index.ts
|
|
3819
|
-
function
|
|
3819
|
+
function Ii(e) {
|
|
3820
3820
|
return {
|
|
3821
|
-
create:
|
|
3822
|
-
get:
|
|
3823
|
-
list:
|
|
3824
|
-
remove:
|
|
3825
|
-
removeByUser:
|
|
3821
|
+
create: ji(e),
|
|
3822
|
+
get: Mi(e),
|
|
3823
|
+
list: Ni(e),
|
|
3824
|
+
remove: Pi(e),
|
|
3825
|
+
removeByUser: Fi(e)
|
|
3826
3826
|
};
|
|
3827
3827
|
}
|
|
3828
3828
|
//#endregion
|
|
3829
3829
|
//#region src/user-permissions/create.ts
|
|
3830
|
-
function
|
|
3830
|
+
function Li(e) {
|
|
3831
3831
|
return async (t, n, r, i, a) => {
|
|
3832
3832
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3833
3833
|
try {
|
|
@@ -3847,7 +3847,7 @@ function Ii(e) {
|
|
|
3847
3847
|
}
|
|
3848
3848
|
//#endregion
|
|
3849
3849
|
//#region src/user-permissions/remove.ts
|
|
3850
|
-
function
|
|
3850
|
+
function Ri(e) {
|
|
3851
3851
|
return async (t, n, r, i) => {
|
|
3852
3852
|
try {
|
|
3853
3853
|
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);
|
|
@@ -3859,7 +3859,7 @@ function Li(e) {
|
|
|
3859
3859
|
}
|
|
3860
3860
|
//#endregion
|
|
3861
3861
|
//#region src/user-permissions/list.ts
|
|
3862
|
-
function
|
|
3862
|
+
function zi(e) {
|
|
3863
3863
|
return async (t, n, r, i) => {
|
|
3864
3864
|
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([
|
|
3865
3865
|
"user_permissions.resource_server_identifier",
|
|
@@ -3882,17 +3882,17 @@ function Ri(e) {
|
|
|
3882
3882
|
}
|
|
3883
3883
|
//#endregion
|
|
3884
3884
|
//#region src/user-permissions/index.ts
|
|
3885
|
-
function
|
|
3885
|
+
function Bi(e) {
|
|
3886
3886
|
return {
|
|
3887
|
-
create:
|
|
3888
|
-
remove:
|
|
3889
|
-
list:
|
|
3887
|
+
create: Li(e),
|
|
3888
|
+
remove: Ri(e),
|
|
3889
|
+
list: zi(e)
|
|
3890
3890
|
};
|
|
3891
3891
|
}
|
|
3892
3892
|
//#endregion
|
|
3893
3893
|
//#region src/user-permissions/adapter.ts
|
|
3894
|
-
function
|
|
3895
|
-
let t =
|
|
3894
|
+
function Vi(e) {
|
|
3895
|
+
let t = Bi(e);
|
|
3896
3896
|
return {
|
|
3897
3897
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3898
3898
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3901,7 +3901,7 @@ function Bi(e) {
|
|
|
3901
3901
|
}
|
|
3902
3902
|
//#endregion
|
|
3903
3903
|
//#region src/user-roles/list.ts
|
|
3904
|
-
function
|
|
3904
|
+
function Hi(e) {
|
|
3905
3905
|
return async (t, n, r, i) => {
|
|
3906
3906
|
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([
|
|
3907
3907
|
"r.id",
|
|
@@ -3915,7 +3915,7 @@ function Vi(e) {
|
|
|
3915
3915
|
}
|
|
3916
3916
|
//#endregion
|
|
3917
3917
|
//#region src/user-roles/list-users.ts
|
|
3918
|
-
function
|
|
3918
|
+
function Ui(e) {
|
|
3919
3919
|
return async (t, n, r) => {
|
|
3920
3920
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3921
3921
|
if (N(r)) {
|
|
@@ -3943,7 +3943,7 @@ function Hi(e) {
|
|
|
3943
3943
|
}
|
|
3944
3944
|
//#endregion
|
|
3945
3945
|
//#region src/user-roles/create.ts
|
|
3946
|
-
function
|
|
3946
|
+
function Wi(e) {
|
|
3947
3947
|
return async (t, n, r, i, a) => {
|
|
3948
3948
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3949
3949
|
try {
|
|
@@ -3961,7 +3961,7 @@ function Ui(e) {
|
|
|
3961
3961
|
}
|
|
3962
3962
|
//#endregion
|
|
3963
3963
|
//#region src/user-roles/remove.ts
|
|
3964
|
-
function
|
|
3964
|
+
function Gi(e) {
|
|
3965
3965
|
return async (t, n, r, i) => {
|
|
3966
3966
|
try {
|
|
3967
3967
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3973,18 +3973,18 @@ function Wi(e) {
|
|
|
3973
3973
|
}
|
|
3974
3974
|
//#endregion
|
|
3975
3975
|
//#region src/user-roles/index.ts
|
|
3976
|
-
function
|
|
3976
|
+
function Ki(e) {
|
|
3977
3977
|
return {
|
|
3978
|
-
list:
|
|
3979
|
-
listUsers:
|
|
3980
|
-
create:
|
|
3981
|
-
remove:
|
|
3978
|
+
list: Hi(e),
|
|
3979
|
+
listUsers: Ui(e),
|
|
3980
|
+
create: Wi(e),
|
|
3981
|
+
remove: Gi(e)
|
|
3982
3982
|
};
|
|
3983
3983
|
}
|
|
3984
3984
|
//#endregion
|
|
3985
3985
|
//#region src/user-roles/adapter.ts
|
|
3986
|
-
function
|
|
3987
|
-
let t =
|
|
3986
|
+
function qi(e) {
|
|
3987
|
+
let t = Ki(e);
|
|
3988
3988
|
return {
|
|
3989
3989
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3990
3990
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3994,11 +3994,11 @@ function Ki(e) {
|
|
|
3994
3994
|
}
|
|
3995
3995
|
//#endregion
|
|
3996
3996
|
//#region src/organizations/create.ts
|
|
3997
|
-
function
|
|
3997
|
+
function Ji(e) {
|
|
3998
3998
|
return async (t, n, r) => {
|
|
3999
3999
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4000
4000
|
...n,
|
|
4001
|
-
id: i?.id || n.id ||
|
|
4001
|
+
id: i?.id || n.id || Ce(),
|
|
4002
4002
|
tenant_id: t,
|
|
4003
4003
|
created_at: i?.created_at ?? a,
|
|
4004
4004
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4022,7 +4022,7 @@ function qi(e) {
|
|
|
4022
4022
|
}
|
|
4023
4023
|
//#endregion
|
|
4024
4024
|
//#region src/organizations/get.ts
|
|
4025
|
-
function
|
|
4025
|
+
function Yi(e) {
|
|
4026
4026
|
return async (t, n) => {
|
|
4027
4027
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4028
4028
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4037,7 +4037,7 @@ function Ji(e) {
|
|
|
4037
4037
|
//#endregion
|
|
4038
4038
|
//#region src/organizations/list.ts
|
|
4039
4039
|
var B = ["name", "display_name"];
|
|
4040
|
-
function
|
|
4040
|
+
function Xi(e) {
|
|
4041
4041
|
return async (t, n) => {
|
|
4042
4042
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4043
4043
|
if (n?.q) {
|
|
@@ -4102,12 +4102,12 @@ function Yi(e) {
|
|
|
4102
4102
|
}
|
|
4103
4103
|
//#endregion
|
|
4104
4104
|
//#region src/organizations/remove.ts
|
|
4105
|
-
function
|
|
4105
|
+
function Zi(e) {
|
|
4106
4106
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4107
4107
|
}
|
|
4108
4108
|
//#endregion
|
|
4109
4109
|
//#region src/organizations/update.ts
|
|
4110
|
-
function
|
|
4110
|
+
function Qi(e) {
|
|
4111
4111
|
return async (t, n, r) => {
|
|
4112
4112
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4113
4113
|
...c,
|
|
@@ -4123,13 +4123,13 @@ function Zi(e) {
|
|
|
4123
4123
|
}
|
|
4124
4124
|
//#endregion
|
|
4125
4125
|
//#region src/organizations/index.ts
|
|
4126
|
-
function
|
|
4126
|
+
function $i(e) {
|
|
4127
4127
|
return {
|
|
4128
|
-
create:
|
|
4129
|
-
get:
|
|
4130
|
-
list:
|
|
4131
|
-
remove:
|
|
4132
|
-
update:
|
|
4128
|
+
create: Ji(e),
|
|
4129
|
+
get: Yi(e),
|
|
4130
|
+
list: Xi(e),
|
|
4131
|
+
remove: Zi(e),
|
|
4132
|
+
update: Qi(e)
|
|
4133
4133
|
};
|
|
4134
4134
|
}
|
|
4135
4135
|
//#endregion
|
|
@@ -4155,7 +4155,7 @@ async function H(e, t, n) {
|
|
|
4155
4155
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4156
4156
|
};
|
|
4157
4157
|
}
|
|
4158
|
-
function
|
|
4158
|
+
function ea(e) {
|
|
4159
4159
|
return {
|
|
4160
4160
|
async create(t, n, r, i) {
|
|
4161
4161
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4198,7 +4198,7 @@ function $i(e) {
|
|
|
4198
4198
|
}
|
|
4199
4199
|
//#endregion
|
|
4200
4200
|
//#region src/user-organizations/create.ts
|
|
4201
|
-
function
|
|
4201
|
+
function ta(e) {
|
|
4202
4202
|
return async (n, r, i) => {
|
|
4203
4203
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4204
4204
|
id: a?.id ?? t(),
|
|
@@ -4218,7 +4218,7 @@ function ea(e) {
|
|
|
4218
4218
|
}
|
|
4219
4219
|
//#endregion
|
|
4220
4220
|
//#region src/user-organizations/get.ts
|
|
4221
|
-
function
|
|
4221
|
+
function na(e) {
|
|
4222
4222
|
return async (t, n) => {
|
|
4223
4223
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4224
4224
|
return r ? {
|
|
@@ -4232,7 +4232,7 @@ function ta(e) {
|
|
|
4232
4232
|
}
|
|
4233
4233
|
//#endregion
|
|
4234
4234
|
//#region src/user-organizations/list.ts
|
|
4235
|
-
function
|
|
4235
|
+
function ra(e) {
|
|
4236
4236
|
return async (t, n) => {
|
|
4237
4237
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4238
4238
|
if (n?.q) {
|
|
@@ -4285,7 +4285,7 @@ function na(e) {
|
|
|
4285
4285
|
}
|
|
4286
4286
|
//#endregion
|
|
4287
4287
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4288
|
-
function
|
|
4288
|
+
function ia(e) {
|
|
4289
4289
|
return async (t, n, r) => {
|
|
4290
4290
|
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([
|
|
4291
4291
|
"organizations.id",
|
|
@@ -4322,12 +4322,12 @@ function ra(e) {
|
|
|
4322
4322
|
}
|
|
4323
4323
|
//#endregion
|
|
4324
4324
|
//#region src/user-organizations/remove.ts
|
|
4325
|
-
function
|
|
4325
|
+
function aa(e) {
|
|
4326
4326
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4327
4327
|
}
|
|
4328
4328
|
//#endregion
|
|
4329
4329
|
//#region src/user-organizations/update.ts
|
|
4330
|
-
function
|
|
4330
|
+
function oa(e) {
|
|
4331
4331
|
return async (t, n, r) => {
|
|
4332
4332
|
let i = {
|
|
4333
4333
|
...r,
|
|
@@ -4338,21 +4338,21 @@ function aa(e) {
|
|
|
4338
4338
|
}
|
|
4339
4339
|
//#endregion
|
|
4340
4340
|
//#region src/user-organizations/index.ts
|
|
4341
|
-
function
|
|
4341
|
+
function sa(e) {
|
|
4342
4342
|
return {
|
|
4343
|
-
create:
|
|
4344
|
-
get:
|
|
4345
|
-
list:
|
|
4346
|
-
listUserOrganizations:
|
|
4347
|
-
remove:
|
|
4348
|
-
update:
|
|
4343
|
+
create: ta(e),
|
|
4344
|
+
get: na(e),
|
|
4345
|
+
list: ra(e),
|
|
4346
|
+
listUserOrganizations: ia(e),
|
|
4347
|
+
remove: aa(e),
|
|
4348
|
+
update: oa(e)
|
|
4349
4349
|
};
|
|
4350
4350
|
}
|
|
4351
4351
|
//#endregion
|
|
4352
4352
|
//#region src/invites/create.ts
|
|
4353
|
-
function
|
|
4353
|
+
function ca(e) {
|
|
4354
4354
|
return async (t, n, r) => {
|
|
4355
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4355
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Ae(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4356
4356
|
id: a,
|
|
4357
4357
|
tenant_id: t,
|
|
4358
4358
|
organization_id: n.organization_id,
|
|
@@ -4396,11 +4396,11 @@ function sa(e) {
|
|
|
4396
4396
|
}
|
|
4397
4397
|
//#endregion
|
|
4398
4398
|
//#region src/invites/get.ts
|
|
4399
|
-
function
|
|
4399
|
+
function la(e) {
|
|
4400
4400
|
return async (t, n) => {
|
|
4401
4401
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4402
4402
|
return r ? l({
|
|
4403
|
-
...
|
|
4403
|
+
...ht(r, {
|
|
4404
4404
|
inviter: {},
|
|
4405
4405
|
invitee: {},
|
|
4406
4406
|
app_metadata: {},
|
|
@@ -4413,7 +4413,7 @@ function ca(e) {
|
|
|
4413
4413
|
}
|
|
4414
4414
|
//#endregion
|
|
4415
4415
|
//#region src/invites/list.ts
|
|
4416
|
-
function
|
|
4416
|
+
function ua(e) {
|
|
4417
4417
|
return async (t, n) => {
|
|
4418
4418
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4419
4419
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4421,7 +4421,7 @@ function la(e) {
|
|
|
4421
4421
|
r = r.offset(e);
|
|
4422
4422
|
}
|
|
4423
4423
|
let i = (await r.execute()).map((e) => l({
|
|
4424
|
-
...
|
|
4424
|
+
...ht(e, {
|
|
4425
4425
|
inviter: {},
|
|
4426
4426
|
invitee: {},
|
|
4427
4427
|
app_metadata: {},
|
|
@@ -4440,12 +4440,12 @@ function la(e) {
|
|
|
4440
4440
|
}
|
|
4441
4441
|
//#endregion
|
|
4442
4442
|
//#region src/invites/remove.ts
|
|
4443
|
-
function
|
|
4443
|
+
function da(e) {
|
|
4444
4444
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4445
4445
|
}
|
|
4446
4446
|
//#endregion
|
|
4447
4447
|
//#region src/invites/update.ts
|
|
4448
|
-
function
|
|
4448
|
+
function fa(e) {
|
|
4449
4449
|
return async (t, n, r) => {
|
|
4450
4450
|
let i = {};
|
|
4451
4451
|
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;
|
|
@@ -4453,35 +4453,35 @@ function da(e) {
|
|
|
4453
4453
|
}
|
|
4454
4454
|
//#endregion
|
|
4455
4455
|
//#region src/invites/index.ts
|
|
4456
|
-
function
|
|
4456
|
+
function pa(e) {
|
|
4457
4457
|
return {
|
|
4458
|
-
create:
|
|
4459
|
-
get:
|
|
4460
|
-
list:
|
|
4461
|
-
remove:
|
|
4462
|
-
update:
|
|
4458
|
+
create: ca(e),
|
|
4459
|
+
get: la(e),
|
|
4460
|
+
list: ua(e),
|
|
4461
|
+
remove: da(e),
|
|
4462
|
+
update: fa(e)
|
|
4463
4463
|
};
|
|
4464
4464
|
}
|
|
4465
4465
|
//#endregion
|
|
4466
4466
|
//#region src/stats/index.ts
|
|
4467
|
-
var
|
|
4468
|
-
function
|
|
4467
|
+
var ma = ["s"], ha = ["pwd_leak"];
|
|
4468
|
+
function ga(e) {
|
|
4469
4469
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4470
4470
|
}
|
|
4471
|
-
function
|
|
4471
|
+
function _a(e) {
|
|
4472
4472
|
return e.toISOString().split("T")[0];
|
|
4473
4473
|
}
|
|
4474
|
-
function
|
|
4474
|
+
function va(e) {
|
|
4475
4475
|
return {
|
|
4476
4476
|
async getDaily(t, n = {}) {
|
|
4477
4477
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4478
4478
|
o.setDate(o.getDate() - 30);
|
|
4479
|
-
let s = r ?
|
|
4479
|
+
let s = r ? ga(r) : _a(o), c = i ? ga(i) : _a(a), l = f`DATE(logs.date)`;
|
|
4480
4480
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4481
4481
|
l.as("date"),
|
|
4482
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4482
|
+
e.fn.sum(e.case().when("type", "in", ma).then(1).else(0).end()).as("logins"),
|
|
4483
4483
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4484
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4484
|
+
e.fn.sum(e.case().when("type", "in", ha).then(1).else(0).end()).as("leaked_passwords"),
|
|
4485
4485
|
e.fn.min("date").as("first_event"),
|
|
4486
4486
|
e.fn.max("date").as("last_event")
|
|
4487
4487
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4495,13 +4495,13 @@ function _a(e) {
|
|
|
4495
4495
|
},
|
|
4496
4496
|
async getActiveUsers(t) {
|
|
4497
4497
|
let n = /* @__PURE__ */ new Date();
|
|
4498
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4498
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", ma).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4499
4499
|
}
|
|
4500
4500
|
};
|
|
4501
4501
|
}
|
|
4502
4502
|
//#endregion
|
|
4503
4503
|
//#region src/analytics/index.ts
|
|
4504
|
-
var
|
|
4504
|
+
var ya = {
|
|
4505
4505
|
"active-users": ["s", "seacft"],
|
|
4506
4506
|
logins: [
|
|
4507
4507
|
"s",
|
|
@@ -4531,7 +4531,7 @@ var va = {
|
|
|
4531
4531
|
"fvr"
|
|
4532
4532
|
],
|
|
4533
4533
|
"codes-sent": ["cls", "cs"]
|
|
4534
|
-
},
|
|
4534
|
+
}, ba = {
|
|
4535
4535
|
"active-users": {
|
|
4536
4536
|
alias: "active_users",
|
|
4537
4537
|
type: "UInt64",
|
|
@@ -4588,7 +4588,7 @@ var va = {
|
|
|
4588
4588
|
agg: "count"
|
|
4589
4589
|
}
|
|
4590
4590
|
};
|
|
4591
|
-
async function
|
|
4591
|
+
async function xa(e) {
|
|
4592
4592
|
try {
|
|
4593
4593
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4594
4594
|
} catch {
|
|
@@ -4610,7 +4610,7 @@ function U(e, t) {
|
|
|
4610
4610
|
let i = r.hour === "24" ? "00" : r.hour, a = Date.UTC(Number(r.year), Number(r.month) - 1, Number(r.day), Number(i), Number(r.minute), Number(r.second)), o = Math.round((a - t.getTime()) / 6e4), s = o >= 0 ? "+" : "-", c = Math.abs(o);
|
|
4611
4611
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4612
4612
|
}
|
|
4613
|
-
var
|
|
4613
|
+
var Sa = [
|
|
4614
4614
|
"January",
|
|
4615
4615
|
"February",
|
|
4616
4616
|
"March",
|
|
@@ -4624,22 +4624,22 @@ var xa = [
|
|
|
4624
4624
|
"November",
|
|
4625
4625
|
"December"
|
|
4626
4626
|
];
|
|
4627
|
-
function
|
|
4627
|
+
function Ca(e, t) {
|
|
4628
4628
|
let n = t.getUTCFullYear(), r = U(e, new Date(Date.UTC(n, 0, 1)));
|
|
4629
4629
|
for (let t = 1; t < 12; t++) {
|
|
4630
4630
|
let i = U(e, new Date(Date.UTC(n, t, 1)));
|
|
4631
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4631
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Sa[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').`);
|
|
4632
4632
|
}
|
|
4633
4633
|
}
|
|
4634
|
-
function
|
|
4634
|
+
function wa(e) {
|
|
4635
4635
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4636
4636
|
return t * (Number(n) * 60 + Number(r));
|
|
4637
4637
|
}
|
|
4638
|
-
function
|
|
4638
|
+
function Ta(e, t) {
|
|
4639
4639
|
let n;
|
|
4640
4640
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4641
4641
|
else {
|
|
4642
|
-
let e =
|
|
4642
|
+
let e = wa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4643
4643
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4644
4644
|
}
|
|
4645
4645
|
switch (e) {
|
|
@@ -4650,7 +4650,7 @@ function wa(e, t) {
|
|
|
4650
4650
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4651
4651
|
}
|
|
4652
4652
|
}
|
|
4653
|
-
function
|
|
4653
|
+
function Ea(e, t) {
|
|
4654
4654
|
if (t === "+00:00") switch (e) {
|
|
4655
4655
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4656
4656
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4661,7 +4661,7 @@ function Ta(e, t) {
|
|
|
4661
4661
|
}
|
|
4662
4662
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4663
4663
|
}
|
|
4664
|
-
let n =
|
|
4664
|
+
let n = wa(t), r = f`date_add(str_to_date(substring(${f.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${f.lit(n)} minute)`;
|
|
4665
4665
|
switch (e) {
|
|
4666
4666
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4667
4667
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4670,12 +4670,12 @@ function Ta(e, t) {
|
|
|
4670
4670
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4671
4671
|
}
|
|
4672
4672
|
}
|
|
4673
|
-
function
|
|
4674
|
-
|
|
4673
|
+
function Da(e, t, n, r) {
|
|
4674
|
+
Ca(t, n);
|
|
4675
4675
|
let i = U(t, n);
|
|
4676
|
-
return r === "mysql" ?
|
|
4676
|
+
return r === "mysql" ? Ea(e, i) : Ta(e, i);
|
|
4677
4677
|
}
|
|
4678
|
-
function
|
|
4678
|
+
function Oa(e) {
|
|
4679
4679
|
switch (e) {
|
|
4680
4680
|
case "connection": return "logs.connection";
|
|
4681
4681
|
case "client_id": return "logs.client_id";
|
|
@@ -4684,15 +4684,15 @@ function Da(e) {
|
|
|
4684
4684
|
case "time": throw Error("time dimension is handled separately");
|
|
4685
4685
|
}
|
|
4686
4686
|
}
|
|
4687
|
-
function
|
|
4688
|
-
let t = null, n = () => (t ||=
|
|
4687
|
+
function ka(e) {
|
|
4688
|
+
let t = null, n = () => (t ||= xa(e), t);
|
|
4689
4689
|
return {
|
|
4690
4690
|
async query(t, r, i) {
|
|
4691
|
-
let a = Date.now(), o =
|
|
4691
|
+
let a = Date.now(), o = ya[r], s = ba[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4692
4692
|
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));
|
|
4693
4693
|
let d = [], p = [];
|
|
4694
4694
|
for (let e of i.group_by) if (e === "time") {
|
|
4695
|
-
let e =
|
|
4695
|
+
let e = Da(i.interval, i.tz, new Date(i.from), c);
|
|
4696
4696
|
p.push({
|
|
4697
4697
|
alias: "time",
|
|
4698
4698
|
expr: e
|
|
@@ -4701,7 +4701,7 @@ function Oa(e) {
|
|
|
4701
4701
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4702
4702
|
});
|
|
4703
4703
|
} else {
|
|
4704
|
-
let t =
|
|
4704
|
+
let t = Oa(e);
|
|
4705
4705
|
p.push({
|
|
4706
4706
|
alias: e,
|
|
4707
4707
|
expr: f`${f.ref(t)}`
|
|
@@ -4741,11 +4741,11 @@ function Oa(e) {
|
|
|
4741
4741
|
};
|
|
4742
4742
|
},
|
|
4743
4743
|
async sessionRetention(t, r) {
|
|
4744
|
-
let i = Date.now(), { sinceMs: a } =
|
|
4744
|
+
let i = Date.now(), { sinceMs: a } = me(r.weeks, i), o = await n(), s = (e) => {
|
|
4745
4745
|
let t = e === "used_at_ts" ? f`(COALESCE(${f.ref("used_at_ts")}, ${f.ref("created_at_ts")}) + ${f.lit(m)})` : f`(${f.ref(e)} + ${f.lit(m)})`;
|
|
4746
4746
|
return o === "mysql" ? f`${t} DIV ${f.lit(h)}` : f`${t} / ${f.lit(h)}`;
|
|
4747
4747
|
};
|
|
4748
|
-
return
|
|
4748
|
+
return _((await e.selectFrom("sessions").where("tenant_id", "=", t).where("created_at_ts", ">=", a).select([
|
|
4749
4749
|
s("created_at_ts").as("created_week"),
|
|
4750
4750
|
s("used_at_ts").as("used_week"),
|
|
4751
4751
|
f`COUNT(*)`.as("count")
|
|
@@ -4754,12 +4754,29 @@ function Oa(e) {
|
|
|
4754
4754
|
used_week: Math.floor(Number(e.used_week)),
|
|
4755
4755
|
count: Number(e.count)
|
|
4756
4756
|
})), r.weeks, i);
|
|
4757
|
+
},
|
|
4758
|
+
async refreshTokenRetention(t, r) {
|
|
4759
|
+
let i = Date.now(), { sinceMs: a } = me(r.weeks, i), o = await n(), s = (e) => {
|
|
4760
|
+
let t = f`(${e} + ${f.lit(m)})`;
|
|
4761
|
+
return o === "mysql" ? f`${t} DIV ${f.lit(h)}` : f`${t} / ${f.lit(h)}`;
|
|
4762
|
+
}, c = e.selectFrom("refresh_tokens").where("tenant_id", "=", t).select([f`MIN(${f.ref("created_at_ts")})`.as("min_created"), f`MAX(COALESCE(${f.ref("last_exchanged_at_ts")}, ${f.ref("created_at_ts")}))`.as("max_used")]).groupBy(f`COALESCE(${f.ref("family_id")}, ${f.ref("id")})`);
|
|
4763
|
+
r.client_id && r.client_id.length > 0 && (c = c.where("client_id", "in", r.client_id));
|
|
4764
|
+
let l = s(f.ref("min_created")), u = s(f.ref("max_used"));
|
|
4765
|
+
return g((await e.selectFrom(c.as("families")).where("min_created", ">=", a).select([
|
|
4766
|
+
l.as("created_week"),
|
|
4767
|
+
u.as("used_week"),
|
|
4768
|
+
f`COUNT(*)`.as("count")
|
|
4769
|
+
]).groupBy([l, u]).execute()).map((e) => ({
|
|
4770
|
+
created_week: Math.floor(Number(e.created_week)),
|
|
4771
|
+
used_week: Math.floor(Number(e.used_week)),
|
|
4772
|
+
count: Number(e.count)
|
|
4773
|
+
})), r.weeks, i);
|
|
4757
4774
|
}
|
|
4758
4775
|
};
|
|
4759
4776
|
}
|
|
4760
4777
|
//#endregion
|
|
4761
4778
|
//#region src/customText/index.ts
|
|
4762
|
-
function
|
|
4779
|
+
function Aa(e) {
|
|
4763
4780
|
return {
|
|
4764
4781
|
async get(t, n, r) {
|
|
4765
4782
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4798,9 +4815,9 @@ function ka(e) {
|
|
|
4798
4815
|
}
|
|
4799
4816
|
//#endregion
|
|
4800
4817
|
//#region src/authenticationMethods/create.ts
|
|
4801
|
-
function
|
|
4818
|
+
function ja(e) {
|
|
4802
4819
|
return async (t, n, r) => {
|
|
4803
|
-
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 ??
|
|
4820
|
+
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 ?? Ar();
|
|
4804
4821
|
return await e.insertInto("authentication_methods").values({
|
|
4805
4822
|
id: s,
|
|
4806
4823
|
tenant_id: t,
|
|
@@ -4837,7 +4854,7 @@ function Aa(e) {
|
|
|
4837
4854
|
}
|
|
4838
4855
|
//#endregion
|
|
4839
4856
|
//#region src/authenticationMethods/get.ts
|
|
4840
|
-
function
|
|
4857
|
+
function Ma(e) {
|
|
4841
4858
|
return async (t, n) => {
|
|
4842
4859
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4843
4860
|
return r ? {
|
|
@@ -4860,7 +4877,7 @@ function ja(e) {
|
|
|
4860
4877
|
}
|
|
4861
4878
|
//#endregion
|
|
4862
4879
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4863
|
-
function
|
|
4880
|
+
function Na(e) {
|
|
4864
4881
|
return async (t, n) => {
|
|
4865
4882
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4866
4883
|
return r ? {
|
|
@@ -4883,7 +4900,7 @@ function Ma(e) {
|
|
|
4883
4900
|
}
|
|
4884
4901
|
//#endregion
|
|
4885
4902
|
//#region src/authenticationMethods/list.ts
|
|
4886
|
-
function
|
|
4903
|
+
function Pa(e) {
|
|
4887
4904
|
return async (t, n) => (await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "=", n).selectAll().execute()).map((e) => ({
|
|
4888
4905
|
id: e.id,
|
|
4889
4906
|
user_id: e.user_id,
|
|
@@ -4903,35 +4920,35 @@ function Na(e) {
|
|
|
4903
4920
|
}
|
|
4904
4921
|
//#endregion
|
|
4905
4922
|
//#region src/authenticationMethods/update.ts
|
|
4906
|
-
function
|
|
4923
|
+
function Fa(e) {
|
|
4907
4924
|
return async (t, n, r) => {
|
|
4908
4925
|
let i = { updated_at_ts: Date.now() };
|
|
4909
4926
|
r.phone_number !== void 0 && (i.phone_number = r.phone_number), r.totp_secret !== void 0 && (i.totp_secret = r.totp_secret), r.credential_id !== void 0 && (i.credential_id = r.credential_id), r.public_key !== void 0 && (i.public_key = r.public_key), r.sign_count !== void 0 && (i.sign_count = r.sign_count), r.credential_backed_up !== void 0 && (i.credential_backed_up = +!!r.credential_backed_up), r.transports !== void 0 && (i.transports = JSON.stringify(r.transports)), r.friendly_name !== void 0 && (i.friendly_name = r.friendly_name), r.confirmed !== void 0 && (i.confirmed = +!!r.confirmed), await e.updateTable("authentication_methods").set(i).where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).execute();
|
|
4910
|
-
let a = await
|
|
4927
|
+
let a = await Ma(e)(t, n);
|
|
4911
4928
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4912
4929
|
return a;
|
|
4913
4930
|
};
|
|
4914
4931
|
}
|
|
4915
4932
|
//#endregion
|
|
4916
4933
|
//#region src/authenticationMethods/remove.ts
|
|
4917
|
-
function
|
|
4934
|
+
function Ia(e) {
|
|
4918
4935
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4919
4936
|
}
|
|
4920
4937
|
//#endregion
|
|
4921
4938
|
//#region src/authenticationMethods/index.ts
|
|
4922
|
-
function
|
|
4939
|
+
function La(e) {
|
|
4923
4940
|
return {
|
|
4924
|
-
create:
|
|
4925
|
-
get:
|
|
4926
|
-
getByCredentialId:
|
|
4927
|
-
list:
|
|
4928
|
-
update:
|
|
4929
|
-
remove:
|
|
4941
|
+
create: ja(e),
|
|
4942
|
+
get: Ma(e),
|
|
4943
|
+
getByCredentialId: Na(e),
|
|
4944
|
+
list: Pa(e),
|
|
4945
|
+
update: Fa(e),
|
|
4946
|
+
remove: Ia(e)
|
|
4930
4947
|
};
|
|
4931
4948
|
}
|
|
4932
4949
|
//#endregion
|
|
4933
4950
|
//#region src/outbox/getByIds.ts
|
|
4934
|
-
function
|
|
4951
|
+
function Ra(e) {
|
|
4935
4952
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4936
4953
|
...JSON.parse(e.payload),
|
|
4937
4954
|
id: e.id,
|
|
@@ -4944,7 +4961,7 @@ function La(e) {
|
|
|
4944
4961
|
}
|
|
4945
4962
|
//#endregion
|
|
4946
4963
|
//#region src/outbox/getUnprocessed.ts
|
|
4947
|
-
function
|
|
4964
|
+
function za(e) {
|
|
4948
4965
|
return async (t) => {
|
|
4949
4966
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4950
4967
|
return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where((e) => e.or([e("next_retry_at", "is", null), e("next_retry_at", "<=", n)])).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).orderBy("created_at", "asc").orderBy("id", "asc").limit(t).execute()).map((e) => ({
|
|
@@ -4960,7 +4977,7 @@ function Ra(e) {
|
|
|
4960
4977
|
}
|
|
4961
4978
|
//#endregion
|
|
4962
4979
|
//#region src/outbox/claimEvents.ts
|
|
4963
|
-
function
|
|
4980
|
+
function Ba(e) {
|
|
4964
4981
|
return async (t, n, r) => {
|
|
4965
4982
|
if (t.length === 0) return [];
|
|
4966
4983
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4972,7 +4989,7 @@ function za(e) {
|
|
|
4972
4989
|
}
|
|
4973
4990
|
//#endregion
|
|
4974
4991
|
//#region src/outbox/markProcessed.ts
|
|
4975
|
-
function
|
|
4992
|
+
function Va(e) {
|
|
4976
4993
|
return async (t) => {
|
|
4977
4994
|
if (t.length === 0) return;
|
|
4978
4995
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4981,7 +4998,7 @@ function Ba(e) {
|
|
|
4981
4998
|
}
|
|
4982
4999
|
//#endregion
|
|
4983
5000
|
//#region src/outbox/markRetry.ts
|
|
4984
|
-
function
|
|
5001
|
+
function Ha(e) {
|
|
4985
5002
|
return async (t, n, r) => {
|
|
4986
5003
|
await e.updateTable("outbox_events").set({
|
|
4987
5004
|
error: n,
|
|
@@ -4994,7 +5011,7 @@ function Va(e) {
|
|
|
4994
5011
|
}
|
|
4995
5012
|
//#endregion
|
|
4996
5013
|
//#region src/outbox/deadLetter.ts
|
|
4997
|
-
function
|
|
5014
|
+
function Ua(e) {
|
|
4998
5015
|
return async (t, n) => {
|
|
4999
5016
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5000
5017
|
await e.updateTable("outbox_events").set({
|
|
@@ -5006,7 +5023,7 @@ function Ha(e) {
|
|
|
5006
5023
|
}
|
|
5007
5024
|
//#endregion
|
|
5008
5025
|
//#region src/outbox/listFailed.ts
|
|
5009
|
-
function
|
|
5026
|
+
function Wa(e) {
|
|
5010
5027
|
return async (t, n = {}) => {
|
|
5011
5028
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1 } = n, o = (await e.selectFrom("outbox_events").selectAll().where("tenant_id", "=", t).where("dead_lettered_at", "is not", null).orderBy("dead_lettered_at", "desc").orderBy("id", "asc").offset(r * i).limit(i).execute()).flatMap((e) => {
|
|
5012
5029
|
let t;
|
|
@@ -5041,7 +5058,7 @@ function Ua(e) {
|
|
|
5041
5058
|
}
|
|
5042
5059
|
//#endregion
|
|
5043
5060
|
//#region src/outbox/replay.ts
|
|
5044
|
-
function
|
|
5061
|
+
function Ga(e) {
|
|
5045
5062
|
return async (t, n) => {
|
|
5046
5063
|
let r = await e.updateTable("outbox_events").set({
|
|
5047
5064
|
processed_at: null,
|
|
@@ -5056,7 +5073,7 @@ function Wa(e) {
|
|
|
5056
5073
|
}
|
|
5057
5074
|
//#endregion
|
|
5058
5075
|
//#region src/outbox/cleanup.ts
|
|
5059
|
-
function
|
|
5076
|
+
function Ka(e) {
|
|
5060
5077
|
return async (t) => {
|
|
5061
5078
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5062
5079
|
return Number(n.numDeletedRows);
|
|
@@ -5064,18 +5081,18 @@ function Ga(e) {
|
|
|
5064
5081
|
}
|
|
5065
5082
|
//#endregion
|
|
5066
5083
|
//#region src/outbox/index.ts
|
|
5067
|
-
function
|
|
5084
|
+
function qa(e) {
|
|
5068
5085
|
return {
|
|
5069
|
-
create:
|
|
5070
|
-
getByIds:
|
|
5071
|
-
getUnprocessed:
|
|
5072
|
-
claimEvents:
|
|
5073
|
-
markProcessed:
|
|
5074
|
-
markRetry:
|
|
5075
|
-
deadLetter:
|
|
5076
|
-
listFailed:
|
|
5077
|
-
replay:
|
|
5078
|
-
cleanup:
|
|
5086
|
+
create: Je(e),
|
|
5087
|
+
getByIds: Ra(e),
|
|
5088
|
+
getUnprocessed: za(e),
|
|
5089
|
+
claimEvents: Ba(e),
|
|
5090
|
+
markProcessed: Va(e),
|
|
5091
|
+
markRetry: Ha(e),
|
|
5092
|
+
deadLetter: Ua(e),
|
|
5093
|
+
listFailed: Wa(e),
|
|
5094
|
+
replay: Ga(e),
|
|
5095
|
+
cleanup: Ka(e)
|
|
5079
5096
|
};
|
|
5080
5097
|
}
|
|
5081
5098
|
//#endregion
|
|
@@ -5093,7 +5110,7 @@ function W(e) {
|
|
|
5093
5110
|
updated_at: e.updated_at
|
|
5094
5111
|
};
|
|
5095
5112
|
}
|
|
5096
|
-
function
|
|
5113
|
+
function Ja(e) {
|
|
5097
5114
|
return {
|
|
5098
5115
|
async create(n, r, i) {
|
|
5099
5116
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5132,7 +5149,7 @@ function G(e) {
|
|
|
5132
5149
|
return {
|
|
5133
5150
|
id: e.id,
|
|
5134
5151
|
name: e.name,
|
|
5135
|
-
provider:
|
|
5152
|
+
provider: ce.parse(e.provider),
|
|
5136
5153
|
connection: e.connection,
|
|
5137
5154
|
enabled: e.enabled === 1,
|
|
5138
5155
|
credentials: JSON.parse(e.credentials),
|
|
@@ -5140,7 +5157,7 @@ function G(e) {
|
|
|
5140
5157
|
updated_at: e.updated_at
|
|
5141
5158
|
};
|
|
5142
5159
|
}
|
|
5143
|
-
function
|
|
5160
|
+
function Ya(e) {
|
|
5144
5161
|
return {
|
|
5145
5162
|
async create(n, r, i) {
|
|
5146
5163
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5180,28 +5197,28 @@ function K(e) {
|
|
|
5180
5197
|
tenant_id: e.tenant_id,
|
|
5181
5198
|
custom_domain_id: e.custom_domain_id,
|
|
5182
5199
|
priority: e.priority,
|
|
5183
|
-
match:
|
|
5184
|
-
handlers:
|
|
5200
|
+
match: Xa(e.match),
|
|
5201
|
+
handlers: Za(e.handlers),
|
|
5185
5202
|
created_at: e.created_at,
|
|
5186
5203
|
updated_at: e.updated_at
|
|
5187
5204
|
};
|
|
5188
5205
|
}
|
|
5189
|
-
function
|
|
5206
|
+
function Xa(e) {
|
|
5190
5207
|
if (!e) return { path: "/*" };
|
|
5191
5208
|
try {
|
|
5192
|
-
let t = JSON.parse(e), n =
|
|
5209
|
+
let t = JSON.parse(e), n = se.safeParse(t);
|
|
5193
5210
|
if (n.success) return n.data;
|
|
5194
5211
|
} catch {}
|
|
5195
5212
|
return { path: "/*" };
|
|
5196
5213
|
}
|
|
5197
|
-
function
|
|
5214
|
+
function Za(e) {
|
|
5198
5215
|
if (!e) return [];
|
|
5199
5216
|
try {
|
|
5200
5217
|
let t = JSON.parse(e);
|
|
5201
5218
|
if (!Array.isArray(t)) return [];
|
|
5202
5219
|
let n = [];
|
|
5203
5220
|
for (let e of t) {
|
|
5204
|
-
let t =
|
|
5221
|
+
let t = ie.safeParse(e);
|
|
5205
5222
|
t.success && n.push(t.data);
|
|
5206
5223
|
}
|
|
5207
5224
|
return n;
|
|
@@ -5264,7 +5281,7 @@ function q(e) {
|
|
|
5264
5281
|
}
|
|
5265
5282
|
//#endregion
|
|
5266
5283
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5267
|
-
async function
|
|
5284
|
+
async function Qa(e, t) {
|
|
5268
5285
|
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([
|
|
5269
5286
|
"custom_domain_id",
|
|
5270
5287
|
"tenant_id",
|
|
@@ -5281,22 +5298,22 @@ async function Za(e, t) {
|
|
|
5281
5298
|
}
|
|
5282
5299
|
//#endregion
|
|
5283
5300
|
//#region src/proxyRoutes/index.ts
|
|
5284
|
-
function
|
|
5301
|
+
function $a(e) {
|
|
5285
5302
|
return {
|
|
5286
5303
|
proxyRoutes: q(e),
|
|
5287
|
-
resolveHost: (t) =>
|
|
5304
|
+
resolveHost: (t) => Qa(e, t)
|
|
5288
5305
|
};
|
|
5289
5306
|
}
|
|
5290
5307
|
//#endregion
|
|
5291
5308
|
//#region src/scim/adapter.ts
|
|
5292
|
-
function
|
|
5309
|
+
function eo(e) {
|
|
5293
5310
|
if (!e) return [];
|
|
5294
5311
|
try {
|
|
5295
5312
|
let t = JSON.parse(e);
|
|
5296
5313
|
if (!Array.isArray(t)) return [];
|
|
5297
5314
|
let n = [];
|
|
5298
5315
|
for (let e of t) {
|
|
5299
|
-
let t =
|
|
5316
|
+
let t = pe.safeParse(e);
|
|
5300
5317
|
t.success && n.push(t.data);
|
|
5301
5318
|
}
|
|
5302
5319
|
return n;
|
|
@@ -5304,7 +5321,7 @@ function $a(e) {
|
|
|
5304
5321
|
return [];
|
|
5305
5322
|
}
|
|
5306
5323
|
}
|
|
5307
|
-
function
|
|
5324
|
+
function to(e) {
|
|
5308
5325
|
if (!e) return [];
|
|
5309
5326
|
try {
|
|
5310
5327
|
let t = JSON.parse(e);
|
|
@@ -5313,16 +5330,16 @@ function eo(e) {
|
|
|
5313
5330
|
return [];
|
|
5314
5331
|
}
|
|
5315
5332
|
}
|
|
5316
|
-
function
|
|
5333
|
+
function no(e) {
|
|
5317
5334
|
return {
|
|
5318
5335
|
connection_id: e.connection_id,
|
|
5319
5336
|
user_id_attribute: e.user_id_attribute,
|
|
5320
|
-
mapping:
|
|
5337
|
+
mapping: eo(e.mapping),
|
|
5321
5338
|
created_at: e.created_at,
|
|
5322
5339
|
updated_at: e.updated_at
|
|
5323
5340
|
};
|
|
5324
5341
|
}
|
|
5325
|
-
function
|
|
5342
|
+
function ro(e) {
|
|
5326
5343
|
return {
|
|
5327
5344
|
async create(t, n) {
|
|
5328
5345
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5343,7 +5360,7 @@ function no(e) {
|
|
|
5343
5360
|
},
|
|
5344
5361
|
async get(t, n) {
|
|
5345
5362
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5346
|
-
return r ?
|
|
5363
|
+
return r ? no(r) : null;
|
|
5347
5364
|
},
|
|
5348
5365
|
async update(t, n, r) {
|
|
5349
5366
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5362,13 +5379,13 @@ function J(e) {
|
|
|
5362
5379
|
token_id: e.token_id,
|
|
5363
5380
|
connection_id: e.connection_id,
|
|
5364
5381
|
token_hash: e.token_hash,
|
|
5365
|
-
scopes:
|
|
5382
|
+
scopes: to(e.scopes),
|
|
5366
5383
|
valid_until: e.valid_until ?? void 0,
|
|
5367
5384
|
created_at: e.created_at,
|
|
5368
5385
|
last_used_at: e.last_used_at ?? void 0
|
|
5369
5386
|
};
|
|
5370
5387
|
}
|
|
5371
|
-
function
|
|
5388
|
+
function io(e) {
|
|
5372
5389
|
return {
|
|
5373
5390
|
async create(t, n) {
|
|
5374
5391
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5411,7 +5428,7 @@ function ro(e) {
|
|
|
5411
5428
|
}
|
|
5412
5429
|
};
|
|
5413
5430
|
}
|
|
5414
|
-
function
|
|
5431
|
+
function ao(e) {
|
|
5415
5432
|
return {
|
|
5416
5433
|
connection_id: e.connection_id,
|
|
5417
5434
|
external_id: e.external_id,
|
|
@@ -5419,7 +5436,7 @@ function io(e) {
|
|
|
5419
5436
|
created_at: e.created_at
|
|
5420
5437
|
};
|
|
5421
5438
|
}
|
|
5422
|
-
function
|
|
5439
|
+
function oo(e) {
|
|
5423
5440
|
return {
|
|
5424
5441
|
async create(t, n) {
|
|
5425
5442
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5438,11 +5455,11 @@ function ao(e) {
|
|
|
5438
5455
|
},
|
|
5439
5456
|
async getByExternalId(t, n, r) {
|
|
5440
5457
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5441
|
-
return i ?
|
|
5458
|
+
return i ? ao(i) : null;
|
|
5442
5459
|
},
|
|
5443
5460
|
async getByUserId(t, n, r) {
|
|
5444
5461
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5445
|
-
return i ?
|
|
5462
|
+
return i ? ao(i) : null;
|
|
5446
5463
|
},
|
|
5447
5464
|
async remove(t, n, r) {
|
|
5448
5465
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5453,7 +5470,7 @@ function ao(e) {
|
|
|
5453
5470
|
//#endregion
|
|
5454
5471
|
//#region src/tenantOperations/index.ts
|
|
5455
5472
|
function Y(e) {
|
|
5456
|
-
return
|
|
5473
|
+
return ve.parse({
|
|
5457
5474
|
id: e.id,
|
|
5458
5475
|
tenant_id: e.tenant_id,
|
|
5459
5476
|
rollout_id: e.rollout_id,
|
|
@@ -5471,10 +5488,10 @@ function Y(e) {
|
|
|
5471
5488
|
finished_at: e.finished_at
|
|
5472
5489
|
});
|
|
5473
5490
|
}
|
|
5474
|
-
function
|
|
5491
|
+
function so(e) {
|
|
5475
5492
|
return {
|
|
5476
5493
|
async create(n) {
|
|
5477
|
-
let r =
|
|
5494
|
+
let r = _e.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5478
5495
|
id: `op_${t()}`,
|
|
5479
5496
|
tenant_id: r.tenant_id,
|
|
5480
5497
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5526,27 +5543,27 @@ function oo(e) {
|
|
|
5526
5543
|
}
|
|
5527
5544
|
//#endregion
|
|
5528
5545
|
//#region src/utils/monotonic-id.ts
|
|
5529
|
-
var
|
|
5530
|
-
function
|
|
5546
|
+
var co = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", X = 32, lo = 10, uo = 4, fo = 10;
|
|
5547
|
+
function po(e, t) {
|
|
5531
5548
|
let n = "";
|
|
5532
|
-
for (let r = t; r > 0; r--) n =
|
|
5549
|
+
for (let r = t; r > 0; r--) n = co.charAt(e % X) + n, e = Math.floor(e / X);
|
|
5533
5550
|
return n;
|
|
5534
5551
|
}
|
|
5535
|
-
function
|
|
5536
|
-
let e = new Uint8Array(
|
|
5552
|
+
function mo() {
|
|
5553
|
+
let e = new Uint8Array(fo);
|
|
5537
5554
|
crypto.getRandomValues(e);
|
|
5538
5555
|
let t = "";
|
|
5539
|
-
for (let n = 0; n <
|
|
5556
|
+
for (let n = 0; n < fo; n++) t += co.charAt(e[n] % X);
|
|
5540
5557
|
return t;
|
|
5541
5558
|
}
|
|
5542
|
-
var
|
|
5543
|
-
function
|
|
5559
|
+
var ho = 0, Z = 0;
|
|
5560
|
+
function go() {
|
|
5544
5561
|
let e = Date.now();
|
|
5545
|
-
return e ===
|
|
5562
|
+
return e === ho ? Z++ : (ho = e, Z = 0), po(e, lo) + po(Z, uo) + mo();
|
|
5546
5563
|
}
|
|
5547
5564
|
//#endregion
|
|
5548
5565
|
//#region src/tenantOperationEvents/index.ts
|
|
5549
|
-
function
|
|
5566
|
+
function _o(e) {
|
|
5550
5567
|
if (!e) return null;
|
|
5551
5568
|
try {
|
|
5552
5569
|
let t = JSON.parse(e);
|
|
@@ -5554,22 +5571,22 @@ function go(e) {
|
|
|
5554
5571
|
} catch {}
|
|
5555
5572
|
return null;
|
|
5556
5573
|
}
|
|
5557
|
-
function
|
|
5558
|
-
return
|
|
5574
|
+
function vo(e) {
|
|
5575
|
+
return ge.parse({
|
|
5559
5576
|
id: e.id,
|
|
5560
5577
|
operation_id: e.operation_id,
|
|
5561
5578
|
step: e.step,
|
|
5562
5579
|
outcome: e.outcome,
|
|
5563
|
-
detail:
|
|
5580
|
+
detail: _o(e.detail),
|
|
5564
5581
|
attempt: e.attempt,
|
|
5565
5582
|
created_at: e.created_at
|
|
5566
5583
|
});
|
|
5567
5584
|
}
|
|
5568
|
-
function
|
|
5585
|
+
function yo(e) {
|
|
5569
5586
|
return {
|
|
5570
5587
|
async create(t) {
|
|
5571
|
-
let n =
|
|
5572
|
-
id: `evt_${
|
|
5588
|
+
let n = he.parse(t), r = {
|
|
5589
|
+
id: `evt_${go()}`,
|
|
5573
5590
|
operation_id: n.operation_id,
|
|
5574
5591
|
step: n.step,
|
|
5575
5592
|
outcome: n.outcome,
|
|
@@ -5577,12 +5594,12 @@ function vo(e) {
|
|
|
5577
5594
|
attempt: n.attempt,
|
|
5578
5595
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5579
5596
|
};
|
|
5580
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5597
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), vo(r);
|
|
5581
5598
|
},
|
|
5582
5599
|
async listByOperation(t, n = {}) {
|
|
5583
5600
|
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();
|
|
5584
5601
|
return {
|
|
5585
|
-
events: a.map(
|
|
5602
|
+
events: a.map(vo),
|
|
5586
5603
|
start: r * i,
|
|
5587
5604
|
limit: i,
|
|
5588
5605
|
length: a.length
|
|
@@ -5592,7 +5609,7 @@ function vo(e) {
|
|
|
5592
5609
|
}
|
|
5593
5610
|
//#endregion
|
|
5594
5611
|
//#region src/rollouts/index.ts
|
|
5595
|
-
function
|
|
5612
|
+
function bo(e) {
|
|
5596
5613
|
if (!e) return null;
|
|
5597
5614
|
try {
|
|
5598
5615
|
return JSON.parse(e);
|
|
@@ -5600,26 +5617,26 @@ function yo(e) {
|
|
|
5600
5617
|
return null;
|
|
5601
5618
|
}
|
|
5602
5619
|
}
|
|
5603
|
-
function
|
|
5604
|
-
return
|
|
5620
|
+
function xo(e) {
|
|
5621
|
+
return fe.parse({
|
|
5605
5622
|
id: e.id,
|
|
5606
5623
|
kind: e.kind,
|
|
5607
5624
|
status: e.status,
|
|
5608
5625
|
target_worker_version: e.target_worker_version,
|
|
5609
5626
|
target_database_version: e.target_database_version,
|
|
5610
5627
|
wave_size: e.wave_size,
|
|
5611
|
-
canary_tenant_ids:
|
|
5612
|
-
filter:
|
|
5628
|
+
canary_tenant_ids: bo(e.canary_tenant_ids),
|
|
5629
|
+
filter: bo(e.filter),
|
|
5613
5630
|
initiated_by: e.initiated_by,
|
|
5614
5631
|
created_at: e.created_at,
|
|
5615
5632
|
updated_at: e.updated_at,
|
|
5616
5633
|
finished_at: e.finished_at
|
|
5617
5634
|
});
|
|
5618
5635
|
}
|
|
5619
|
-
function
|
|
5636
|
+
function So(e) {
|
|
5620
5637
|
return {
|
|
5621
5638
|
async create(n) {
|
|
5622
|
-
let r =
|
|
5639
|
+
let r = de.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5623
5640
|
id: `rol_${t()}`,
|
|
5624
5641
|
kind: r.kind,
|
|
5625
5642
|
status: "pending",
|
|
@@ -5633,16 +5650,16 @@ function xo(e) {
|
|
|
5633
5650
|
updated_at: i,
|
|
5634
5651
|
finished_at: null
|
|
5635
5652
|
};
|
|
5636
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5653
|
+
return await e.insertInto("rollouts").values(a).execute(), xo(a);
|
|
5637
5654
|
},
|
|
5638
5655
|
async get(t) {
|
|
5639
5656
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5640
|
-
return n ?
|
|
5657
|
+
return n ? xo(n) : null;
|
|
5641
5658
|
},
|
|
5642
5659
|
async list(t = {}) {
|
|
5643
5660
|
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();
|
|
5644
5661
|
return {
|
|
5645
|
-
rollouts: i.map(
|
|
5662
|
+
rollouts: i.map(xo),
|
|
5646
5663
|
start: n * r,
|
|
5647
5664
|
limit: r,
|
|
5648
5665
|
length: i.length
|
|
@@ -5662,7 +5679,7 @@ function xo(e) {
|
|
|
5662
5679
|
}
|
|
5663
5680
|
//#endregion
|
|
5664
5681
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5665
|
-
var
|
|
5682
|
+
var Co = class {
|
|
5666
5683
|
migrations;
|
|
5667
5684
|
constructor(e) {
|
|
5668
5685
|
this.migrations = e;
|
|
@@ -5670,10 +5687,10 @@ var So = class {
|
|
|
5670
5687
|
async getMigrations() {
|
|
5671
5688
|
return this.migrations;
|
|
5672
5689
|
}
|
|
5673
|
-
},
|
|
5674
|
-
down: () =>
|
|
5675
|
-
up: () =>
|
|
5676
|
-
}),
|
|
5690
|
+
}, wo = /* @__PURE__ */ w({
|
|
5691
|
+
down: () => Oo,
|
|
5692
|
+
up: () => Do
|
|
5693
|
+
}), To = [
|
|
5677
5694
|
{
|
|
5678
5695
|
table: "authentication_methods",
|
|
5679
5696
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5939,7 +5956,7 @@ var So = class {
|
|
|
5939
5956
|
onDelete: "cascade"
|
|
5940
5957
|
}
|
|
5941
5958
|
];
|
|
5942
|
-
async function
|
|
5959
|
+
async function Eo(e) {
|
|
5943
5960
|
try {
|
|
5944
5961
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5945
5962
|
} catch {
|
|
@@ -5948,14 +5965,14 @@ async function To(e) {
|
|
|
5948
5965
|
}
|
|
5949
5966
|
function Q(e, t) {
|
|
5950
5967
|
let n = e;
|
|
5951
|
-
for (let e of
|
|
5968
|
+
for (let e of To) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5952
5969
|
let n = t;
|
|
5953
5970
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5954
5971
|
}));
|
|
5955
5972
|
return n;
|
|
5956
5973
|
}
|
|
5957
|
-
async function
|
|
5958
|
-
let t = await
|
|
5974
|
+
async function Do(e) {
|
|
5975
|
+
let t = await Eo(e);
|
|
5959
5976
|
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();
|
|
5960
5977
|
{
|
|
5961
5978
|
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"]);
|
|
@@ -6142,40 +6159,40 @@ async function Eo(e) {
|
|
|
6142
6159
|
"tenant_id",
|
|
6143
6160
|
"phone_number",
|
|
6144
6161
|
"provider"
|
|
6145
|
-
]).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
|
|
6162
|
+
]).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 To) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6146
6163
|
let n = e;
|
|
6147
6164
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6148
6165
|
}).execute();
|
|
6149
6166
|
}
|
|
6150
|
-
async function
|
|
6167
|
+
async function Oo(e) {
|
|
6151
6168
|
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();
|
|
6152
6169
|
}
|
|
6153
6170
|
//#endregion
|
|
6154
6171
|
//#region migrate/log.ts
|
|
6155
|
-
var
|
|
6156
|
-
function
|
|
6157
|
-
|
|
6172
|
+
var ko = !1;
|
|
6173
|
+
function Ao(e) {
|
|
6174
|
+
ko = e;
|
|
6158
6175
|
}
|
|
6159
6176
|
function $(...e) {
|
|
6160
|
-
|
|
6177
|
+
ko && console.log(...e);
|
|
6161
6178
|
}
|
|
6162
|
-
function
|
|
6179
|
+
function jo(...e) {
|
|
6163
6180
|
console.warn(...e);
|
|
6164
6181
|
}
|
|
6165
6182
|
//#endregion
|
|
6166
6183
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6167
|
-
var
|
|
6168
|
-
down: () =>
|
|
6169
|
-
up: () =>
|
|
6170
|
-
}),
|
|
6171
|
-
async function
|
|
6184
|
+
var Mo = /* @__PURE__ */ w({
|
|
6185
|
+
down: () => Uo,
|
|
6186
|
+
up: () => Bo
|
|
6187
|
+
}), No = 5e4, Po = 500;
|
|
6188
|
+
async function Fo(e) {
|
|
6172
6189
|
try {
|
|
6173
6190
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6174
6191
|
} catch {
|
|
6175
6192
|
return "sqlite";
|
|
6176
6193
|
}
|
|
6177
6194
|
}
|
|
6178
|
-
async function
|
|
6195
|
+
async function Io(e, t, n) {
|
|
6179
6196
|
try {
|
|
6180
6197
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6181
6198
|
} catch (e) {
|
|
@@ -6186,7 +6203,7 @@ async function Fo(e, t, n) {
|
|
|
6186
6203
|
throw e;
|
|
6187
6204
|
}
|
|
6188
6205
|
}
|
|
6189
|
-
async function
|
|
6206
|
+
async function Lo(e, t, n, r) {
|
|
6190
6207
|
try {
|
|
6191
6208
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6192
6209
|
} catch (e) {
|
|
@@ -6197,21 +6214,21 @@ async function Io(e, t, n, r) {
|
|
|
6197
6214
|
throw e;
|
|
6198
6215
|
}
|
|
6199
6216
|
}
|
|
6200
|
-
async function
|
|
6217
|
+
async function Ro(e, t) {
|
|
6201
6218
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6202
6219
|
if (t === "sqlite") {
|
|
6203
6220
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6204
6221
|
r = Number(t.numDeletedRows);
|
|
6205
6222
|
} else {
|
|
6206
|
-
let t =
|
|
6207
|
-
for (; t >=
|
|
6208
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6223
|
+
let t = No;
|
|
6224
|
+
for (; t >= No;) {
|
|
6225
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(No).executeTakeFirst();
|
|
6209
6226
|
t = Number(i.numDeletedRows), r += t, t > 0 && $(` Pruned ${r} expired codes row(s)...`);
|
|
6210
6227
|
}
|
|
6211
6228
|
}
|
|
6212
6229
|
return r;
|
|
6213
6230
|
}
|
|
6214
|
-
async function
|
|
6231
|
+
async function zo(e) {
|
|
6215
6232
|
let t = 0;
|
|
6216
6233
|
for (;;) {
|
|
6217
6234
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6219,33 +6236,33 @@ async function Ro(e) {
|
|
|
6219
6236
|
"code_type",
|
|
6220
6237
|
"tenant_id",
|
|
6221
6238
|
"expires_at"
|
|
6222
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6239
|
+
]).where("expires_at_ts", "is", null).limit(Po).execute();
|
|
6223
6240
|
if (n.length === 0) break;
|
|
6224
6241
|
for (let t of n) {
|
|
6225
6242
|
let n = Date.parse(t.expires_at);
|
|
6226
6243
|
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();
|
|
6227
6244
|
}
|
|
6228
|
-
if (t += n.length, n.length <
|
|
6245
|
+
if (t += n.length, n.length < Po) break;
|
|
6229
6246
|
}
|
|
6230
6247
|
return t;
|
|
6231
6248
|
}
|
|
6232
|
-
async function
|
|
6233
|
-
let t = await
|
|
6249
|
+
async function Bo(e) {
|
|
6250
|
+
let t = await Fo(e);
|
|
6234
6251
|
try {
|
|
6235
|
-
let n = await
|
|
6252
|
+
let n = await Ro(e, t);
|
|
6236
6253
|
$(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6237
6254
|
} catch (e) {
|
|
6238
|
-
|
|
6255
|
+
jo(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6239
6256
|
}
|
|
6240
|
-
await
|
|
6257
|
+
await Io(e, "codes", "expires_at_ts"), await Lo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6241
6258
|
try {
|
|
6242
|
-
let t = await
|
|
6259
|
+
let t = await zo(e);
|
|
6243
6260
|
$(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6244
6261
|
} catch (e) {
|
|
6245
|
-
|
|
6262
|
+
jo(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6246
6263
|
}
|
|
6247
6264
|
}
|
|
6248
|
-
async function
|
|
6265
|
+
async function Vo(e, t, n) {
|
|
6249
6266
|
try {
|
|
6250
6267
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6251
6268
|
} catch (e) {
|
|
@@ -6253,7 +6270,7 @@ async function Bo(e, t, n) {
|
|
|
6253
6270
|
throw e;
|
|
6254
6271
|
}
|
|
6255
6272
|
}
|
|
6256
|
-
async function
|
|
6273
|
+
async function Ho(e, t, n) {
|
|
6257
6274
|
try {
|
|
6258
6275
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6259
6276
|
} catch (e) {
|
|
@@ -6261,16 +6278,16 @@ async function Vo(e, t, n) {
|
|
|
6261
6278
|
throw e;
|
|
6262
6279
|
}
|
|
6263
6280
|
}
|
|
6264
|
-
async function
|
|
6265
|
-
await
|
|
6281
|
+
async function Uo(e) {
|
|
6282
|
+
await Vo(e, "idx_codes_expires_at_ts", "codes"), await Ho(e, "codes", "expires_at_ts");
|
|
6266
6283
|
}
|
|
6267
6284
|
//#endregion
|
|
6268
6285
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6269
|
-
var
|
|
6270
|
-
down: () =>
|
|
6271
|
-
up: () =>
|
|
6286
|
+
var Wo = /* @__PURE__ */ w({
|
|
6287
|
+
down: () => Ko,
|
|
6288
|
+
up: () => Go
|
|
6272
6289
|
});
|
|
6273
|
-
async function
|
|
6290
|
+
async function Go(e) {
|
|
6274
6291
|
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", [
|
|
6275
6292
|
"tenant_id",
|
|
6276
6293
|
"connection_id",
|
|
@@ -6281,16 +6298,16 @@ async function Wo(e) {
|
|
|
6281
6298
|
"external_id"
|
|
6282
6299
|
]).unique().execute();
|
|
6283
6300
|
}
|
|
6284
|
-
async function
|
|
6301
|
+
async function Ko(e) {
|
|
6285
6302
|
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();
|
|
6286
6303
|
}
|
|
6287
6304
|
//#endregion
|
|
6288
6305
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6289
|
-
var
|
|
6290
|
-
down: () =>
|
|
6291
|
-
up: () =>
|
|
6306
|
+
var qo = /* @__PURE__ */ w({
|
|
6307
|
+
down: () => Zo,
|
|
6308
|
+
up: () => Yo
|
|
6292
6309
|
});
|
|
6293
|
-
async function
|
|
6310
|
+
async function Jo(e, t, n) {
|
|
6294
6311
|
try {
|
|
6295
6312
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6296
6313
|
} catch (e) {
|
|
@@ -6298,10 +6315,10 @@ async function qo(e, t, n) {
|
|
|
6298
6315
|
throw e;
|
|
6299
6316
|
}
|
|
6300
6317
|
}
|
|
6301
|
-
async function
|
|
6302
|
-
await
|
|
6318
|
+
async function Yo(e) {
|
|
6319
|
+
await Jo(e, "users", "blocked");
|
|
6303
6320
|
}
|
|
6304
|
-
async function
|
|
6321
|
+
async function Xo(e, t, n) {
|
|
6305
6322
|
try {
|
|
6306
6323
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6307
6324
|
} catch (e) {
|
|
@@ -6309,16 +6326,16 @@ async function Yo(e, t, n) {
|
|
|
6309
6326
|
throw e;
|
|
6310
6327
|
}
|
|
6311
6328
|
}
|
|
6312
|
-
async function
|
|
6313
|
-
await
|
|
6329
|
+
async function Zo(e) {
|
|
6330
|
+
await Xo(e, "users", "blocked");
|
|
6314
6331
|
}
|
|
6315
6332
|
//#endregion
|
|
6316
6333
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6317
|
-
var
|
|
6318
|
-
down: () =>
|
|
6319
|
-
up: () =>
|
|
6334
|
+
var Qo = /* @__PURE__ */ w({
|
|
6335
|
+
down: () => ns,
|
|
6336
|
+
up: () => es
|
|
6320
6337
|
});
|
|
6321
|
-
async function
|
|
6338
|
+
async function $o(e, t, n) {
|
|
6322
6339
|
try {
|
|
6323
6340
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6324
6341
|
} catch (e) {
|
|
@@ -6326,10 +6343,10 @@ async function Qo(e, t, n) {
|
|
|
6326
6343
|
throw e;
|
|
6327
6344
|
}
|
|
6328
6345
|
}
|
|
6329
|
-
async function
|
|
6330
|
-
await
|
|
6346
|
+
async function es(e) {
|
|
6347
|
+
await $o(e, "prompt_settings", "show_last_used_connection");
|
|
6331
6348
|
}
|
|
6332
|
-
async function
|
|
6349
|
+
async function ts(e, t, n) {
|
|
6333
6350
|
try {
|
|
6334
6351
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6335
6352
|
} catch (e) {
|
|
@@ -6337,16 +6354,16 @@ async function es(e, t, n) {
|
|
|
6337
6354
|
throw e;
|
|
6338
6355
|
}
|
|
6339
6356
|
}
|
|
6340
|
-
async function
|
|
6341
|
-
await
|
|
6357
|
+
async function ns(e) {
|
|
6358
|
+
await ts(e, "prompt_settings", "show_last_used_connection");
|
|
6342
6359
|
}
|
|
6343
6360
|
//#endregion
|
|
6344
6361
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6345
|
-
var
|
|
6346
|
-
down: () =>
|
|
6347
|
-
up: () =>
|
|
6362
|
+
var rs = /* @__PURE__ */ w({
|
|
6363
|
+
down: () => os,
|
|
6364
|
+
up: () => as
|
|
6348
6365
|
});
|
|
6349
|
-
async function
|
|
6366
|
+
async function is(e, t, n, r) {
|
|
6350
6367
|
try {
|
|
6351
6368
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6352
6369
|
} catch (e) {
|
|
@@ -6357,10 +6374,10 @@ async function rs(e, t, n, r) {
|
|
|
6357
6374
|
throw e;
|
|
6358
6375
|
}
|
|
6359
6376
|
}
|
|
6360
|
-
async function is(e) {
|
|
6361
|
-
await rs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6362
|
-
}
|
|
6363
6377
|
async function as(e) {
|
|
6378
|
+
await is(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6379
|
+
}
|
|
6380
|
+
async function os(e) {
|
|
6364
6381
|
try {
|
|
6365
6382
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6366
6383
|
} catch (e) {
|
|
@@ -6370,11 +6387,11 @@ async function as(e) {
|
|
|
6370
6387
|
}
|
|
6371
6388
|
//#endregion
|
|
6372
6389
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6373
|
-
var
|
|
6374
|
-
down: () =>
|
|
6375
|
-
up: () =>
|
|
6390
|
+
var ss = /* @__PURE__ */ w({
|
|
6391
|
+
down: () => ds,
|
|
6392
|
+
up: () => ls
|
|
6376
6393
|
});
|
|
6377
|
-
async function
|
|
6394
|
+
async function cs(e, t, n, r) {
|
|
6378
6395
|
try {
|
|
6379
6396
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6380
6397
|
} catch (e) {
|
|
@@ -6382,10 +6399,10 @@ async function ss(e, t, n, r) {
|
|
|
6382
6399
|
throw e;
|
|
6383
6400
|
}
|
|
6384
6401
|
}
|
|
6385
|
-
async function
|
|
6386
|
-
await
|
|
6402
|
+
async function ls(e) {
|
|
6403
|
+
await cs(e, "hooks", "page_id", f`varchar(64)`), await cs(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6387
6404
|
}
|
|
6388
|
-
async function
|
|
6405
|
+
async function us(e, t, n) {
|
|
6389
6406
|
try {
|
|
6390
6407
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6391
6408
|
} catch (e) {
|
|
@@ -6393,37 +6410,37 @@ async function ls(e, t, n) {
|
|
|
6393
6410
|
throw e;
|
|
6394
6411
|
}
|
|
6395
6412
|
}
|
|
6396
|
-
async function
|
|
6397
|
-
await
|
|
6413
|
+
async function ds(e) {
|
|
6414
|
+
await us(e, "hooks", "permission_required"), await us(e, "hooks", "page_id");
|
|
6398
6415
|
}
|
|
6399
6416
|
//#endregion
|
|
6400
6417
|
//#region migrate/migrations/index.ts
|
|
6401
|
-
var
|
|
6402
|
-
"2026-07-16T14:00:00_baseline":
|
|
6403
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6404
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6405
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6406
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6407
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6408
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6418
|
+
var fs = {
|
|
6419
|
+
"2026-07-16T14:00:00_baseline": wo,
|
|
6420
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Mo,
|
|
6421
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Wo,
|
|
6422
|
+
"2026-08-05T12:00:00_user_blocked": qo,
|
|
6423
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Qo,
|
|
6424
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": rs,
|
|
6425
|
+
"2026-08-11T12:00:00_page_hooks": ss
|
|
6409
6426
|
};
|
|
6410
6427
|
//#endregion
|
|
6411
6428
|
//#region migrate/migrate.ts
|
|
6412
|
-
async function
|
|
6413
|
-
|
|
6414
|
-
let { error: n, results: r } = await new
|
|
6429
|
+
async function ps(e, t = !1) {
|
|
6430
|
+
Ao(t), t && console.log("migrating...");
|
|
6431
|
+
let { error: n, results: r } = await new ye({
|
|
6415
6432
|
db: e,
|
|
6416
|
-
provider: new
|
|
6433
|
+
provider: new Co(fs)
|
|
6417
6434
|
}).migrateToLatest();
|
|
6418
6435
|
if (r?.forEach((e) => {
|
|
6419
6436
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6420
6437
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6421
6438
|
}
|
|
6422
|
-
async function
|
|
6423
|
-
|
|
6424
|
-
let { error: n, results: r } = await new
|
|
6439
|
+
async function ms(e, t = !1) {
|
|
6440
|
+
Ao(t), t && console.log("migrating...");
|
|
6441
|
+
let { error: n, results: r } = await new ye({
|
|
6425
6442
|
db: e,
|
|
6426
|
-
provider: new
|
|
6443
|
+
provider: new Co(fs)
|
|
6427
6444
|
}).migrateDown();
|
|
6428
6445
|
if (r?.forEach((e) => {
|
|
6429
6446
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6431,64 +6448,64 @@ async function ps(e, t = !1) {
|
|
|
6431
6448
|
}
|
|
6432
6449
|
//#endregion
|
|
6433
6450
|
//#region src/index.ts
|
|
6434
|
-
function
|
|
6451
|
+
function hs(e, t = { useTransactions: !0 }) {
|
|
6435
6452
|
let n = {
|
|
6436
|
-
actions:
|
|
6437
|
-
actionExecutions:
|
|
6438
|
-
actionVersions:
|
|
6439
|
-
branding:
|
|
6440
|
-
clients:
|
|
6441
|
-
clientConnections:
|
|
6442
|
-
clientGrants:
|
|
6443
|
-
clientRegistrationTokens:
|
|
6444
|
-
codes:
|
|
6445
|
-
connections:
|
|
6446
|
-
emailProviders:
|
|
6447
|
-
emailTemplates:
|
|
6448
|
-
customDomains:
|
|
6449
|
-
flows:
|
|
6450
|
-
forms:
|
|
6451
|
-
hookCode:
|
|
6452
|
-
hooks:
|
|
6453
|
-
invites:
|
|
6454
|
-
keys:
|
|
6455
|
-
loginSessions:
|
|
6456
|
-
logs:
|
|
6457
|
-
logStreams:
|
|
6458
|
-
migrationSources:
|
|
6459
|
-
authenticationMethods:
|
|
6460
|
-
passwords:
|
|
6461
|
-
promptSettings:
|
|
6453
|
+
actions: Re(e),
|
|
6454
|
+
actionExecutions: We(e),
|
|
6455
|
+
actionVersions: qe(e),
|
|
6456
|
+
branding: rr(e),
|
|
6457
|
+
clients: yn(e),
|
|
6458
|
+
clientConnections: Tn(e),
|
|
6459
|
+
clientGrants: Mn(e),
|
|
6460
|
+
clientRegistrationTokens: Un(e),
|
|
6461
|
+
codes: rn(e),
|
|
6462
|
+
connections: dn(e),
|
|
6463
|
+
emailProviders: Ur(e),
|
|
6464
|
+
emailTemplates: Xr(e),
|
|
6465
|
+
customDomains: er(e),
|
|
6466
|
+
flows: bt(e),
|
|
6467
|
+
forms: pi(e),
|
|
6468
|
+
hookCode: vr(e),
|
|
6469
|
+
hooks: pr(e),
|
|
6470
|
+
invites: pa(e),
|
|
6471
|
+
keys: qn(e),
|
|
6472
|
+
loginSessions: Pr(e),
|
|
6473
|
+
logs: Lt(e),
|
|
6474
|
+
logStreams: Ja(e),
|
|
6475
|
+
migrationSources: Ya(e),
|
|
6476
|
+
authenticationMethods: La(e),
|
|
6477
|
+
passwords: Jt(e),
|
|
6478
|
+
promptSettings: Rr(e),
|
|
6462
6479
|
proxyRoutes: q(e),
|
|
6463
|
-
scimConfigurations:
|
|
6464
|
-
scimTokens:
|
|
6465
|
-
scimExternalIds:
|
|
6466
|
-
refreshTokens:
|
|
6467
|
-
resourceServers:
|
|
6468
|
-
rolePermissions:
|
|
6469
|
-
grants:
|
|
6470
|
-
userPermissions:
|
|
6471
|
-
userRoles:
|
|
6472
|
-
roles:
|
|
6473
|
-
sessions:
|
|
6474
|
-
sessionCleanup:
|
|
6475
|
-
tenants:
|
|
6476
|
-
tenantOperations:
|
|
6477
|
-
tenantOperationEvents:
|
|
6478
|
-
rollouts:
|
|
6479
|
-
themes:
|
|
6480
|
-
universalLoginTemplates:
|
|
6481
|
-
customText:
|
|
6482
|
-
users:
|
|
6483
|
-
userActivity:
|
|
6484
|
-
organizations:
|
|
6485
|
-
organizationConnections:
|
|
6486
|
-
userOrganizations:
|
|
6487
|
-
stats:
|
|
6488
|
-
analytics:
|
|
6489
|
-
outbox:
|
|
6480
|
+
scimConfigurations: ro(e),
|
|
6481
|
+
scimTokens: io(e),
|
|
6482
|
+
scimExternalIds: oo(e),
|
|
6483
|
+
refreshTokens: ai(e),
|
|
6484
|
+
resourceServers: yi(e),
|
|
6485
|
+
rolePermissions: Ai(e),
|
|
6486
|
+
grants: Ii(e),
|
|
6487
|
+
userPermissions: Vi(e),
|
|
6488
|
+
userRoles: qi(e),
|
|
6489
|
+
roles: Ti(e),
|
|
6490
|
+
sessions: Ut(e),
|
|
6491
|
+
sessionCleanup: si(e),
|
|
6492
|
+
tenants: Ot(e),
|
|
6493
|
+
tenantOperations: so(e),
|
|
6494
|
+
tenantOperationEvents: yo(e),
|
|
6495
|
+
rollouts: So(e),
|
|
6496
|
+
themes: Cr(e),
|
|
6497
|
+
universalLoginTemplates: sr(e),
|
|
6498
|
+
customText: Aa(e),
|
|
6499
|
+
users: ft(e),
|
|
6500
|
+
userActivity: lt(e),
|
|
6501
|
+
organizations: $i(e),
|
|
6502
|
+
organizationConnections: ea(e),
|
|
6503
|
+
userOrganizations: sa(e),
|
|
6504
|
+
stats: va(e),
|
|
6505
|
+
analytics: ka(e),
|
|
6506
|
+
outbox: qa(e),
|
|
6490
6507
|
async transaction(r) {
|
|
6491
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6508
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(hs(e, {
|
|
6492
6509
|
...t,
|
|
6493
6510
|
useTransactions: !1
|
|
6494
6511
|
})));
|
|
@@ -6497,4 +6514,4 @@ function ms(e, t = { useTransactions: !0 }) {
|
|
|
6497
6514
|
return n;
|
|
6498
6515
|
}
|
|
6499
6516
|
//#endregion
|
|
6500
|
-
export {
|
|
6517
|
+
export { $a as createProxyDataAdapter, q as createProxyRoutesAdapter, hs as default, ms as migrateDown, ps as migrateToLatest };
|