@authhero/kysely-adapter 12.3.0 → 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 L(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 Mt = [
|
|
|
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 Nt(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 Nt(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 Nt(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 It(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 Lt(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 zt(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 Bt(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 Ht(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 Ut(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 Wt(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 Gt(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 qt(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 Yt(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 Zt(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
|
|
@@ -1588,7 +1588,7 @@ function nn(e) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
//#endregion
|
|
1590
1590
|
//#region src/connections/transform.ts
|
|
1591
|
-
function
|
|
1591
|
+
function L(e) {
|
|
1592
1592
|
let { is_system: t, ...n } = e;
|
|
1593
1593
|
return l({
|
|
1594
1594
|
...n,
|
|
@@ -1596,16 +1596,16 @@ function R(e) {
|
|
|
1596
1596
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1597
1597
|
});
|
|
1598
1598
|
}
|
|
1599
|
-
function
|
|
1600
|
-
return e.map(
|
|
1599
|
+
function on(e) {
|
|
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,20 +1623,20 @@ function an(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
|
-
return r ?
|
|
1634
|
+
return r ? L(r) : null;
|
|
1635
1635
|
};
|
|
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 cn(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 un(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 dn(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 fn(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 pn(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 mn(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 mn(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 mn(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,31 +1972,31 @@ function gn(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 [];
|
|
1991
1991
|
let i = JSON.parse(r.connections || "[]");
|
|
1992
1992
|
if (i.length === 0) return [];
|
|
1993
|
-
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id,
|
|
1993
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, L(e)]));
|
|
1994
1994
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
1995
1995
|
};
|
|
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 yn(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 bn(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 xn(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 Sn(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 wn(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 Tn(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 En(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 Dn(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 Dn(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 Dn(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 kn(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 jn(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 Nn(e) {
|
|
|
2227
2227
|
} catch {
|
|
2228
2228
|
return;
|
|
2229
2229
|
}
|
|
2230
|
-
return
|
|
2230
|
+
return ae(t) ? t : void 0;
|
|
2231
2231
|
}
|
|
2232
|
-
function
|
|
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,38 +2246,38 @@ function z(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
|
-
return r ?
|
|
2252
|
+
return r ? R(r) : null;
|
|
2253
2253
|
};
|
|
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
|
-
return r ?
|
|
2260
|
+
return r ? R(r) : null;
|
|
2261
2261
|
};
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2265
|
-
function
|
|
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(
|
|
2265
|
+
function Rn(e) {
|
|
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 zn(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 Hn(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 Un(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 Kn(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 qn(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 Yn(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 Xn(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 Zn(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 $n(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 er(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 nr(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 rr(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 or(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 or(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 sr(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 lr(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 ur(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 fr(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 pr(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 mr(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 _r(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 yr(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 br(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 Sr(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 kr(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 Ar(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 Nr(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 Fr(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 Lr(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 Rr(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 zr(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 Hr(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 Gr(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 Kr(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 qr(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 Yr(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 Xr(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 Zr(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 $r(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 ei(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 ti(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 ni(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 ai(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 oi(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 si(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 ci(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 li(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 ui(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 fi(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 pi(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 mi(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 hi(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 gi(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 vi(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 yi(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 bi(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 xi(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,18 +3632,23 @@ function Si(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
|
+
if (typeof e != "object" || !e) return !1;
|
|
3648
|
+
let { code: t, message: n } = e;
|
|
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
|
+
}
|
|
3651
|
+
function Di(e) {
|
|
3647
3652
|
return async (t, n, r, i) => {
|
|
3648
3653
|
if (r.length === 0) return !0;
|
|
3649
3654
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3660,7 +3665,7 @@ function wi(e) {
|
|
|
3660
3665
|
try {
|
|
3661
3666
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3662
3667
|
} catch (e) {
|
|
3663
|
-
if (e
|
|
3668
|
+
if (Ei(e)) continue;
|
|
3664
3669
|
throw e;
|
|
3665
3670
|
}
|
|
3666
3671
|
}
|
|
@@ -3672,11 +3677,11 @@ function wi(e) {
|
|
|
3672
3677
|
}
|
|
3673
3678
|
//#endregion
|
|
3674
3679
|
//#region src/role-permissions/remove.ts
|
|
3675
|
-
function
|
|
3680
|
+
function Oi(e) {
|
|
3676
3681
|
return async (t, n, r) => {
|
|
3677
3682
|
if (r.length === 0) return !0;
|
|
3678
3683
|
try {
|
|
3679
|
-
return
|
|
3684
|
+
return await Promise.all(r.map((r) => e.deleteFrom("role_permissions").where("tenant_id", "=", t).where("role_id", "=", n).where("resource_server_identifier", "=", r.resource_server_identifier).where("permission_name", "=", r.permission_name).executeTakeFirst())), !0;
|
|
3680
3685
|
} catch (e) {
|
|
3681
3686
|
return console.error("Error removing role permissions:", e), !1;
|
|
3682
3687
|
}
|
|
@@ -3684,7 +3689,7 @@ function Ti(e) {
|
|
|
3684
3689
|
}
|
|
3685
3690
|
//#endregion
|
|
3686
3691
|
//#region src/role-permissions/list.ts
|
|
3687
|
-
function
|
|
3692
|
+
function ki(e) {
|
|
3688
3693
|
return async (t, n, r = {}) => {
|
|
3689
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([
|
|
3690
3695
|
"role_permissions.role_id",
|
|
@@ -3705,16 +3710,16 @@ function Ei(e) {
|
|
|
3705
3710
|
}
|
|
3706
3711
|
//#endregion
|
|
3707
3712
|
//#region src/role-permissions/index.ts
|
|
3708
|
-
function
|
|
3713
|
+
function Ai(e) {
|
|
3709
3714
|
return {
|
|
3710
|
-
assign:
|
|
3711
|
-
remove:
|
|
3712
|
-
list:
|
|
3715
|
+
assign: Di(e),
|
|
3716
|
+
remove: Oi(e),
|
|
3717
|
+
list: ki(e)
|
|
3713
3718
|
};
|
|
3714
3719
|
}
|
|
3715
3720
|
//#endregion
|
|
3716
3721
|
//#region src/grants/create.ts
|
|
3717
|
-
function
|
|
3722
|
+
function ji(e) {
|
|
3718
3723
|
return async (n, r) => {
|
|
3719
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();
|
|
3720
3725
|
if (s) {
|
|
@@ -3751,7 +3756,7 @@ function Oi(e) {
|
|
|
3751
3756
|
}
|
|
3752
3757
|
//#endregion
|
|
3753
3758
|
//#region src/grants/get.ts
|
|
3754
|
-
function
|
|
3759
|
+
function Mi(e) {
|
|
3755
3760
|
return async (t, n, r, i) => {
|
|
3756
3761
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3757
3762
|
return a ? {
|
|
@@ -3765,7 +3770,7 @@ function ki(e) {
|
|
|
3765
3770
|
}
|
|
3766
3771
|
//#endregion
|
|
3767
3772
|
//#region src/grants/list.ts
|
|
3768
|
-
function
|
|
3773
|
+
function Ni(e) {
|
|
3769
3774
|
return async (t, n = {}) => {
|
|
3770
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);
|
|
3771
3776
|
c && (l = O(e, l, c, [
|
|
@@ -3803,26 +3808,26 @@ function Ai(e) {
|
|
|
3803
3808
|
}
|
|
3804
3809
|
//#endregion
|
|
3805
3810
|
//#region src/grants/remove.ts
|
|
3806
|
-
function
|
|
3811
|
+
function Pi(e) {
|
|
3807
3812
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3808
3813
|
}
|
|
3809
|
-
function
|
|
3814
|
+
function Fi(e) {
|
|
3810
3815
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3811
3816
|
}
|
|
3812
3817
|
//#endregion
|
|
3813
3818
|
//#region src/grants/index.ts
|
|
3814
|
-
function
|
|
3819
|
+
function Ii(e) {
|
|
3815
3820
|
return {
|
|
3816
|
-
create:
|
|
3817
|
-
get:
|
|
3818
|
-
list:
|
|
3819
|
-
remove:
|
|
3820
|
-
removeByUser:
|
|
3821
|
+
create: ji(e),
|
|
3822
|
+
get: Mi(e),
|
|
3823
|
+
list: Ni(e),
|
|
3824
|
+
remove: Pi(e),
|
|
3825
|
+
removeByUser: Fi(e)
|
|
3821
3826
|
};
|
|
3822
3827
|
}
|
|
3823
3828
|
//#endregion
|
|
3824
3829
|
//#region src/user-permissions/create.ts
|
|
3825
|
-
function
|
|
3830
|
+
function Li(e) {
|
|
3826
3831
|
return async (t, n, r, i, a) => {
|
|
3827
3832
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3828
3833
|
try {
|
|
@@ -3842,7 +3847,7 @@ function Pi(e) {
|
|
|
3842
3847
|
}
|
|
3843
3848
|
//#endregion
|
|
3844
3849
|
//#region src/user-permissions/remove.ts
|
|
3845
|
-
function
|
|
3850
|
+
function Ri(e) {
|
|
3846
3851
|
return async (t, n, r, i) => {
|
|
3847
3852
|
try {
|
|
3848
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);
|
|
@@ -3854,7 +3859,7 @@ function Fi(e) {
|
|
|
3854
3859
|
}
|
|
3855
3860
|
//#endregion
|
|
3856
3861
|
//#region src/user-permissions/list.ts
|
|
3857
|
-
function
|
|
3862
|
+
function zi(e) {
|
|
3858
3863
|
return async (t, n, r, i) => {
|
|
3859
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([
|
|
3860
3865
|
"user_permissions.resource_server_identifier",
|
|
@@ -3877,17 +3882,17 @@ function Ii(e) {
|
|
|
3877
3882
|
}
|
|
3878
3883
|
//#endregion
|
|
3879
3884
|
//#region src/user-permissions/index.ts
|
|
3880
|
-
function
|
|
3885
|
+
function Bi(e) {
|
|
3881
3886
|
return {
|
|
3882
|
-
create:
|
|
3883
|
-
remove:
|
|
3884
|
-
list:
|
|
3887
|
+
create: Li(e),
|
|
3888
|
+
remove: Ri(e),
|
|
3889
|
+
list: zi(e)
|
|
3885
3890
|
};
|
|
3886
3891
|
}
|
|
3887
3892
|
//#endregion
|
|
3888
3893
|
//#region src/user-permissions/adapter.ts
|
|
3889
|
-
function
|
|
3890
|
-
let t =
|
|
3894
|
+
function Vi(e) {
|
|
3895
|
+
let t = Bi(e);
|
|
3891
3896
|
return {
|
|
3892
3897
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3893
3898
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3896,7 +3901,7 @@ function Ri(e) {
|
|
|
3896
3901
|
}
|
|
3897
3902
|
//#endregion
|
|
3898
3903
|
//#region src/user-roles/list.ts
|
|
3899
|
-
function
|
|
3904
|
+
function Hi(e) {
|
|
3900
3905
|
return async (t, n, r, i) => {
|
|
3901
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([
|
|
3902
3907
|
"r.id",
|
|
@@ -3910,7 +3915,7 @@ function zi(e) {
|
|
|
3910
3915
|
}
|
|
3911
3916
|
//#endregion
|
|
3912
3917
|
//#region src/user-roles/list-users.ts
|
|
3913
|
-
function
|
|
3918
|
+
function Ui(e) {
|
|
3914
3919
|
return async (t, n, r) => {
|
|
3915
3920
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3916
3921
|
if (N(r)) {
|
|
@@ -3938,7 +3943,7 @@ function Bi(e) {
|
|
|
3938
3943
|
}
|
|
3939
3944
|
//#endregion
|
|
3940
3945
|
//#region src/user-roles/create.ts
|
|
3941
|
-
function
|
|
3946
|
+
function Wi(e) {
|
|
3942
3947
|
return async (t, n, r, i, a) => {
|
|
3943
3948
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3944
3949
|
try {
|
|
@@ -3956,7 +3961,7 @@ function Vi(e) {
|
|
|
3956
3961
|
}
|
|
3957
3962
|
//#endregion
|
|
3958
3963
|
//#region src/user-roles/remove.ts
|
|
3959
|
-
function
|
|
3964
|
+
function Gi(e) {
|
|
3960
3965
|
return async (t, n, r, i) => {
|
|
3961
3966
|
try {
|
|
3962
3967
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3968,18 +3973,18 @@ function Hi(e) {
|
|
|
3968
3973
|
}
|
|
3969
3974
|
//#endregion
|
|
3970
3975
|
//#region src/user-roles/index.ts
|
|
3971
|
-
function
|
|
3976
|
+
function Ki(e) {
|
|
3972
3977
|
return {
|
|
3973
|
-
list:
|
|
3974
|
-
listUsers:
|
|
3975
|
-
create:
|
|
3976
|
-
remove:
|
|
3978
|
+
list: Hi(e),
|
|
3979
|
+
listUsers: Ui(e),
|
|
3980
|
+
create: Wi(e),
|
|
3981
|
+
remove: Gi(e)
|
|
3977
3982
|
};
|
|
3978
3983
|
}
|
|
3979
3984
|
//#endregion
|
|
3980
3985
|
//#region src/user-roles/adapter.ts
|
|
3981
|
-
function
|
|
3982
|
-
let t =
|
|
3986
|
+
function qi(e) {
|
|
3987
|
+
let t = Ki(e);
|
|
3983
3988
|
return {
|
|
3984
3989
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3985
3990
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3989,11 +3994,11 @@ function Wi(e) {
|
|
|
3989
3994
|
}
|
|
3990
3995
|
//#endregion
|
|
3991
3996
|
//#region src/organizations/create.ts
|
|
3992
|
-
function
|
|
3997
|
+
function Ji(e) {
|
|
3993
3998
|
return async (t, n, r) => {
|
|
3994
3999
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3995
4000
|
...n,
|
|
3996
|
-
id: i?.id || n.id ||
|
|
4001
|
+
id: i?.id || n.id || Ce(),
|
|
3997
4002
|
tenant_id: t,
|
|
3998
4003
|
created_at: i?.created_at ?? a,
|
|
3999
4004
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4017,7 +4022,7 @@ function Gi(e) {
|
|
|
4017
4022
|
}
|
|
4018
4023
|
//#endregion
|
|
4019
4024
|
//#region src/organizations/get.ts
|
|
4020
|
-
function
|
|
4025
|
+
function Yi(e) {
|
|
4021
4026
|
return async (t, n) => {
|
|
4022
4027
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4023
4028
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4031,13 +4036,13 @@ function Ki(e) {
|
|
|
4031
4036
|
}
|
|
4032
4037
|
//#endregion
|
|
4033
4038
|
//#region src/organizations/list.ts
|
|
4034
|
-
var
|
|
4035
|
-
function
|
|
4039
|
+
var B = ["name", "display_name"];
|
|
4040
|
+
function Xi(e) {
|
|
4036
4041
|
return async (t, n) => {
|
|
4037
4042
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4038
4043
|
if (n?.q) {
|
|
4039
|
-
let t = S(n.q,
|
|
4040
|
-
t && (r = O(e, r, t,
|
|
4044
|
+
let t = S(n.q, B);
|
|
4045
|
+
t && (r = O(e, r, t, B));
|
|
4041
4046
|
}
|
|
4042
4047
|
if (N(n)) {
|
|
4043
4048
|
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
@@ -4073,8 +4078,8 @@ function qi(e) {
|
|
|
4073
4078
|
if (n?.include_totals) {
|
|
4074
4079
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4075
4080
|
if (n?.q) {
|
|
4076
|
-
let t = S(n.q,
|
|
4077
|
-
t && (r = O(e, r, t,
|
|
4081
|
+
let t = S(n.q, B);
|
|
4082
|
+
t && (r = O(e, r, t, B));
|
|
4078
4083
|
}
|
|
4079
4084
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4080
4085
|
u = Number(i?.count || 0);
|
|
@@ -4097,12 +4102,12 @@ function qi(e) {
|
|
|
4097
4102
|
}
|
|
4098
4103
|
//#endregion
|
|
4099
4104
|
//#region src/organizations/remove.ts
|
|
4100
|
-
function
|
|
4105
|
+
function Zi(e) {
|
|
4101
4106
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4102
4107
|
}
|
|
4103
4108
|
//#endregion
|
|
4104
4109
|
//#region src/organizations/update.ts
|
|
4105
|
-
function
|
|
4110
|
+
function Qi(e) {
|
|
4106
4111
|
return async (t, n, r) => {
|
|
4107
4112
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4108
4113
|
...c,
|
|
@@ -4118,18 +4123,18 @@ function Yi(e) {
|
|
|
4118
4123
|
}
|
|
4119
4124
|
//#endregion
|
|
4120
4125
|
//#region src/organizations/index.ts
|
|
4121
|
-
function
|
|
4126
|
+
function $i(e) {
|
|
4122
4127
|
return {
|
|
4123
|
-
create:
|
|
4124
|
-
get:
|
|
4125
|
-
list:
|
|
4126
|
-
remove:
|
|
4127
|
-
update:
|
|
4128
|
+
create: Ji(e),
|
|
4129
|
+
get: Yi(e),
|
|
4130
|
+
list: Xi(e),
|
|
4131
|
+
remove: Zi(e),
|
|
4132
|
+
update: Qi(e)
|
|
4128
4133
|
};
|
|
4129
4134
|
}
|
|
4130
4135
|
//#endregion
|
|
4131
4136
|
//#region src/organization-connections/index.ts
|
|
4132
|
-
function
|
|
4137
|
+
function V(e, t) {
|
|
4133
4138
|
return {
|
|
4134
4139
|
connection_id: e.connection_id,
|
|
4135
4140
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4143,14 +4148,14 @@ function H(e, t) {
|
|
|
4143
4148
|
updated_at: e.updated_at
|
|
4144
4149
|
};
|
|
4145
4150
|
}
|
|
4146
|
-
async function
|
|
4151
|
+
async function H(e, t, n) {
|
|
4147
4152
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4148
4153
|
if (r) return {
|
|
4149
4154
|
name: r.name,
|
|
4150
4155
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4151
4156
|
};
|
|
4152
4157
|
}
|
|
4153
|
-
function
|
|
4158
|
+
function ea(e) {
|
|
4154
4159
|
return {
|
|
4155
4160
|
async create(t, n, r, i) {
|
|
4156
4161
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4163,19 +4168,19 @@ function Zi(e) {
|
|
|
4163
4168
|
created_at: a?.created_at ?? o,
|
|
4164
4169
|
updated_at: a?.updated_at ?? o
|
|
4165
4170
|
};
|
|
4166
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4171
|
+
return await e.insertInto("organization_connections").values(s).execute(), V(s, await H(e, t, r.connection_id));
|
|
4167
4172
|
},
|
|
4168
4173
|
async list(t, n) {
|
|
4169
4174
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4170
4175
|
for (let n of r) {
|
|
4171
|
-
let r = await
|
|
4172
|
-
i.push(
|
|
4176
|
+
let r = await H(e, t, n.connection_id);
|
|
4177
|
+
i.push(V(n, r));
|
|
4173
4178
|
}
|
|
4174
4179
|
return i;
|
|
4175
4180
|
},
|
|
4176
4181
|
async get(t, n, r) {
|
|
4177
4182
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4178
|
-
return i ?
|
|
4183
|
+
return i ? V(i, await H(e, t, r)) : null;
|
|
4179
4184
|
},
|
|
4180
4185
|
async update(t, n, r, i) {
|
|
4181
4186
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4183,7 +4188,7 @@ function Zi(e) {
|
|
|
4183
4188
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4184
4189
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4185
4190
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4186
|
-
return s ?
|
|
4191
|
+
return s ? V(s, await H(e, t, r)) : null;
|
|
4187
4192
|
},
|
|
4188
4193
|
async remove(t, n, r) {
|
|
4189
4194
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4193,7 +4198,7 @@ function Zi(e) {
|
|
|
4193
4198
|
}
|
|
4194
4199
|
//#endregion
|
|
4195
4200
|
//#region src/user-organizations/create.ts
|
|
4196
|
-
function
|
|
4201
|
+
function ta(e) {
|
|
4197
4202
|
return async (n, r, i) => {
|
|
4198
4203
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4199
4204
|
id: a?.id ?? t(),
|
|
@@ -4213,7 +4218,7 @@ function Qi(e) {
|
|
|
4213
4218
|
}
|
|
4214
4219
|
//#endregion
|
|
4215
4220
|
//#region src/user-organizations/get.ts
|
|
4216
|
-
function
|
|
4221
|
+
function na(e) {
|
|
4217
4222
|
return async (t, n) => {
|
|
4218
4223
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4219
4224
|
return r ? {
|
|
@@ -4227,7 +4232,7 @@ function $i(e) {
|
|
|
4227
4232
|
}
|
|
4228
4233
|
//#endregion
|
|
4229
4234
|
//#region src/user-organizations/list.ts
|
|
4230
|
-
function
|
|
4235
|
+
function ra(e) {
|
|
4231
4236
|
return async (t, n) => {
|
|
4232
4237
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4233
4238
|
if (n?.q) {
|
|
@@ -4280,7 +4285,7 @@ function ea(e) {
|
|
|
4280
4285
|
}
|
|
4281
4286
|
//#endregion
|
|
4282
4287
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4283
|
-
function
|
|
4288
|
+
function ia(e) {
|
|
4284
4289
|
return async (t, n, r) => {
|
|
4285
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([
|
|
4286
4291
|
"organizations.id",
|
|
@@ -4317,12 +4322,12 @@ function ta(e) {
|
|
|
4317
4322
|
}
|
|
4318
4323
|
//#endregion
|
|
4319
4324
|
//#region src/user-organizations/remove.ts
|
|
4320
|
-
function
|
|
4325
|
+
function aa(e) {
|
|
4321
4326
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4322
4327
|
}
|
|
4323
4328
|
//#endregion
|
|
4324
4329
|
//#region src/user-organizations/update.ts
|
|
4325
|
-
function
|
|
4330
|
+
function oa(e) {
|
|
4326
4331
|
return async (t, n, r) => {
|
|
4327
4332
|
let i = {
|
|
4328
4333
|
...r,
|
|
@@ -4333,21 +4338,21 @@ function ra(e) {
|
|
|
4333
4338
|
}
|
|
4334
4339
|
//#endregion
|
|
4335
4340
|
//#region src/user-organizations/index.ts
|
|
4336
|
-
function
|
|
4341
|
+
function sa(e) {
|
|
4337
4342
|
return {
|
|
4338
|
-
create:
|
|
4339
|
-
get:
|
|
4340
|
-
list:
|
|
4341
|
-
listUserOrganizations:
|
|
4342
|
-
remove:
|
|
4343
|
-
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)
|
|
4344
4349
|
};
|
|
4345
4350
|
}
|
|
4346
4351
|
//#endregion
|
|
4347
4352
|
//#region src/invites/create.ts
|
|
4348
|
-
function
|
|
4353
|
+
function ca(e) {
|
|
4349
4354
|
return async (t, n, r) => {
|
|
4350
|
-
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 = {
|
|
4351
4356
|
id: a,
|
|
4352
4357
|
tenant_id: t,
|
|
4353
4358
|
organization_id: n.organization_id,
|
|
@@ -4391,11 +4396,11 @@ function aa(e) {
|
|
|
4391
4396
|
}
|
|
4392
4397
|
//#endregion
|
|
4393
4398
|
//#region src/invites/get.ts
|
|
4394
|
-
function
|
|
4399
|
+
function la(e) {
|
|
4395
4400
|
return async (t, n) => {
|
|
4396
4401
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4397
4402
|
return r ? l({
|
|
4398
|
-
...
|
|
4403
|
+
...ht(r, {
|
|
4399
4404
|
inviter: {},
|
|
4400
4405
|
invitee: {},
|
|
4401
4406
|
app_metadata: {},
|
|
@@ -4408,7 +4413,7 @@ function oa(e) {
|
|
|
4408
4413
|
}
|
|
4409
4414
|
//#endregion
|
|
4410
4415
|
//#region src/invites/list.ts
|
|
4411
|
-
function
|
|
4416
|
+
function ua(e) {
|
|
4412
4417
|
return async (t, n) => {
|
|
4413
4418
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4414
4419
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4416,7 +4421,7 @@ function sa(e) {
|
|
|
4416
4421
|
r = r.offset(e);
|
|
4417
4422
|
}
|
|
4418
4423
|
let i = (await r.execute()).map((e) => l({
|
|
4419
|
-
...
|
|
4424
|
+
...ht(e, {
|
|
4420
4425
|
inviter: {},
|
|
4421
4426
|
invitee: {},
|
|
4422
4427
|
app_metadata: {},
|
|
@@ -4435,12 +4440,12 @@ function sa(e) {
|
|
|
4435
4440
|
}
|
|
4436
4441
|
//#endregion
|
|
4437
4442
|
//#region src/invites/remove.ts
|
|
4438
|
-
function
|
|
4443
|
+
function da(e) {
|
|
4439
4444
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4440
4445
|
}
|
|
4441
4446
|
//#endregion
|
|
4442
4447
|
//#region src/invites/update.ts
|
|
4443
|
-
function
|
|
4448
|
+
function fa(e) {
|
|
4444
4449
|
return async (t, n, r) => {
|
|
4445
4450
|
let i = {};
|
|
4446
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;
|
|
@@ -4448,35 +4453,35 @@ function la(e) {
|
|
|
4448
4453
|
}
|
|
4449
4454
|
//#endregion
|
|
4450
4455
|
//#region src/invites/index.ts
|
|
4451
|
-
function
|
|
4456
|
+
function pa(e) {
|
|
4452
4457
|
return {
|
|
4453
|
-
create:
|
|
4454
|
-
get:
|
|
4455
|
-
list:
|
|
4456
|
-
remove:
|
|
4457
|
-
update:
|
|
4458
|
+
create: ca(e),
|
|
4459
|
+
get: la(e),
|
|
4460
|
+
list: ua(e),
|
|
4461
|
+
remove: da(e),
|
|
4462
|
+
update: fa(e)
|
|
4458
4463
|
};
|
|
4459
4464
|
}
|
|
4460
4465
|
//#endregion
|
|
4461
4466
|
//#region src/stats/index.ts
|
|
4462
|
-
var
|
|
4463
|
-
function
|
|
4467
|
+
var ma = ["s"], ha = ["pwd_leak"];
|
|
4468
|
+
function ga(e) {
|
|
4464
4469
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4465
4470
|
}
|
|
4466
|
-
function
|
|
4471
|
+
function _a(e) {
|
|
4467
4472
|
return e.toISOString().split("T")[0];
|
|
4468
4473
|
}
|
|
4469
|
-
function
|
|
4474
|
+
function va(e) {
|
|
4470
4475
|
return {
|
|
4471
4476
|
async getDaily(t, n = {}) {
|
|
4472
4477
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4473
4478
|
o.setDate(o.getDate() - 30);
|
|
4474
|
-
let s = r ?
|
|
4479
|
+
let s = r ? ga(r) : _a(o), c = i ? ga(i) : _a(a), l = f`DATE(logs.date)`;
|
|
4475
4480
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4476
4481
|
l.as("date"),
|
|
4477
|
-
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"),
|
|
4478
4483
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4479
|
-
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"),
|
|
4480
4485
|
e.fn.min("date").as("first_event"),
|
|
4481
4486
|
e.fn.max("date").as("last_event")
|
|
4482
4487
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4490,13 +4495,13 @@ function ha(e) {
|
|
|
4490
4495
|
},
|
|
4491
4496
|
async getActiveUsers(t) {
|
|
4492
4497
|
let n = /* @__PURE__ */ new Date();
|
|
4493
|
-
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;
|
|
4494
4499
|
}
|
|
4495
4500
|
};
|
|
4496
4501
|
}
|
|
4497
4502
|
//#endregion
|
|
4498
4503
|
//#region src/analytics/index.ts
|
|
4499
|
-
var
|
|
4504
|
+
var ya = {
|
|
4500
4505
|
"active-users": ["s", "seacft"],
|
|
4501
4506
|
logins: [
|
|
4502
4507
|
"s",
|
|
@@ -4526,7 +4531,7 @@ var ga = {
|
|
|
4526
4531
|
"fvr"
|
|
4527
4532
|
],
|
|
4528
4533
|
"codes-sent": ["cls", "cs"]
|
|
4529
|
-
},
|
|
4534
|
+
}, ba = {
|
|
4530
4535
|
"active-users": {
|
|
4531
4536
|
alias: "active_users",
|
|
4532
4537
|
type: "UInt64",
|
|
@@ -4583,14 +4588,14 @@ var ga = {
|
|
|
4583
4588
|
agg: "count"
|
|
4584
4589
|
}
|
|
4585
4590
|
};
|
|
4586
|
-
async function
|
|
4591
|
+
async function xa(e) {
|
|
4587
4592
|
try {
|
|
4588
4593
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4589
4594
|
} catch {
|
|
4590
4595
|
return "sqlite";
|
|
4591
4596
|
}
|
|
4592
4597
|
}
|
|
4593
|
-
function
|
|
4598
|
+
function U(e, t) {
|
|
4594
4599
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4595
4600
|
timeZone: e,
|
|
4596
4601
|
year: "numeric",
|
|
@@ -4605,7 +4610,7 @@ function W(e, t) {
|
|
|
4605
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);
|
|
4606
4611
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4607
4612
|
}
|
|
4608
|
-
var
|
|
4613
|
+
var Sa = [
|
|
4609
4614
|
"January",
|
|
4610
4615
|
"February",
|
|
4611
4616
|
"March",
|
|
@@ -4619,22 +4624,22 @@ var ya = [
|
|
|
4619
4624
|
"November",
|
|
4620
4625
|
"December"
|
|
4621
4626
|
];
|
|
4622
|
-
function
|
|
4623
|
-
let n = t.getUTCFullYear(), r =
|
|
4627
|
+
function Ca(e, t) {
|
|
4628
|
+
let n = t.getUTCFullYear(), r = U(e, new Date(Date.UTC(n, 0, 1)));
|
|
4624
4629
|
for (let t = 1; t < 12; t++) {
|
|
4625
|
-
let i =
|
|
4626
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
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 ${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').`);
|
|
4627
4632
|
}
|
|
4628
4633
|
}
|
|
4629
|
-
function
|
|
4634
|
+
function wa(e) {
|
|
4630
4635
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4631
4636
|
return t * (Number(n) * 60 + Number(r));
|
|
4632
4637
|
}
|
|
4633
|
-
function
|
|
4638
|
+
function Ta(e, t) {
|
|
4634
4639
|
let n;
|
|
4635
4640
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4636
4641
|
else {
|
|
4637
|
-
let e =
|
|
4642
|
+
let e = wa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4638
4643
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4639
4644
|
}
|
|
4640
4645
|
switch (e) {
|
|
@@ -4645,7 +4650,7 @@ function Sa(e, t) {
|
|
|
4645
4650
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4646
4651
|
}
|
|
4647
4652
|
}
|
|
4648
|
-
function
|
|
4653
|
+
function Ea(e, t) {
|
|
4649
4654
|
if (t === "+00:00") switch (e) {
|
|
4650
4655
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4651
4656
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4656,7 +4661,7 @@ function Ca(e, t) {
|
|
|
4656
4661
|
}
|
|
4657
4662
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4658
4663
|
}
|
|
4659
|
-
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)`;
|
|
4660
4665
|
switch (e) {
|
|
4661
4666
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4662
4667
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4665,12 +4670,12 @@ function Ca(e, t) {
|
|
|
4665
4670
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4666
4671
|
}
|
|
4667
4672
|
}
|
|
4668
|
-
function
|
|
4669
|
-
|
|
4670
|
-
let i =
|
|
4671
|
-
return r === "mysql" ?
|
|
4673
|
+
function Da(e, t, n, r) {
|
|
4674
|
+
Ca(t, n);
|
|
4675
|
+
let i = U(t, n);
|
|
4676
|
+
return r === "mysql" ? Ea(e, i) : Ta(e, i);
|
|
4672
4677
|
}
|
|
4673
|
-
function
|
|
4678
|
+
function Oa(e) {
|
|
4674
4679
|
switch (e) {
|
|
4675
4680
|
case "connection": return "logs.connection";
|
|
4676
4681
|
case "client_id": return "logs.client_id";
|
|
@@ -4679,15 +4684,15 @@ function Ta(e) {
|
|
|
4679
4684
|
case "time": throw Error("time dimension is handled separately");
|
|
4680
4685
|
}
|
|
4681
4686
|
}
|
|
4682
|
-
function
|
|
4683
|
-
let t = null, n = () => (t ||=
|
|
4687
|
+
function ka(e) {
|
|
4688
|
+
let t = null, n = () => (t ||= xa(e), t);
|
|
4684
4689
|
return {
|
|
4685
4690
|
async query(t, r, i) {
|
|
4686
|
-
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);
|
|
4687
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));
|
|
4688
4693
|
let d = [], p = [];
|
|
4689
4694
|
for (let e of i.group_by) if (e === "time") {
|
|
4690
|
-
let e =
|
|
4695
|
+
let e = Da(i.interval, i.tz, new Date(i.from), c);
|
|
4691
4696
|
p.push({
|
|
4692
4697
|
alias: "time",
|
|
4693
4698
|
expr: e
|
|
@@ -4696,7 +4701,7 @@ function Ea(e) {
|
|
|
4696
4701
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4697
4702
|
});
|
|
4698
4703
|
} else {
|
|
4699
|
-
let t =
|
|
4704
|
+
let t = Oa(e);
|
|
4700
4705
|
p.push({
|
|
4701
4706
|
alias: e,
|
|
4702
4707
|
expr: f`${f.ref(t)}`
|
|
@@ -4736,11 +4741,11 @@ function Ea(e) {
|
|
|
4736
4741
|
};
|
|
4737
4742
|
},
|
|
4738
4743
|
async sessionRetention(t, r) {
|
|
4739
|
-
let i = Date.now(), { sinceMs: a } =
|
|
4744
|
+
let i = Date.now(), { sinceMs: a } = me(r.weeks, i), o = await n(), s = (e) => {
|
|
4740
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)})`;
|
|
4741
4746
|
return o === "mysql" ? f`${t} DIV ${f.lit(h)}` : f`${t} / ${f.lit(h)}`;
|
|
4742
4747
|
};
|
|
4743
|
-
return
|
|
4748
|
+
return _((await e.selectFrom("sessions").where("tenant_id", "=", t).where("created_at_ts", ">=", a).select([
|
|
4744
4749
|
s("created_at_ts").as("created_week"),
|
|
4745
4750
|
s("used_at_ts").as("used_week"),
|
|
4746
4751
|
f`COUNT(*)`.as("count")
|
|
@@ -4749,12 +4754,29 @@ function Ea(e) {
|
|
|
4749
4754
|
used_week: Math.floor(Number(e.used_week)),
|
|
4750
4755
|
count: Number(e.count)
|
|
4751
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);
|
|
4752
4774
|
}
|
|
4753
4775
|
};
|
|
4754
4776
|
}
|
|
4755
4777
|
//#endregion
|
|
4756
4778
|
//#region src/customText/index.ts
|
|
4757
|
-
function
|
|
4779
|
+
function Aa(e) {
|
|
4758
4780
|
return {
|
|
4759
4781
|
async get(t, n, r) {
|
|
4760
4782
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4793,9 +4815,9 @@ function Da(e) {
|
|
|
4793
4815
|
}
|
|
4794
4816
|
//#endregion
|
|
4795
4817
|
//#region src/authenticationMethods/create.ts
|
|
4796
|
-
function
|
|
4818
|
+
function ja(e) {
|
|
4797
4819
|
return async (t, n, r) => {
|
|
4798
|
-
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();
|
|
4799
4821
|
return await e.insertInto("authentication_methods").values({
|
|
4800
4822
|
id: s,
|
|
4801
4823
|
tenant_id: t,
|
|
@@ -4832,7 +4854,7 @@ function Oa(e) {
|
|
|
4832
4854
|
}
|
|
4833
4855
|
//#endregion
|
|
4834
4856
|
//#region src/authenticationMethods/get.ts
|
|
4835
|
-
function
|
|
4857
|
+
function Ma(e) {
|
|
4836
4858
|
return async (t, n) => {
|
|
4837
4859
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4838
4860
|
return r ? {
|
|
@@ -4855,7 +4877,7 @@ function ka(e) {
|
|
|
4855
4877
|
}
|
|
4856
4878
|
//#endregion
|
|
4857
4879
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4858
|
-
function
|
|
4880
|
+
function Na(e) {
|
|
4859
4881
|
return async (t, n) => {
|
|
4860
4882
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4861
4883
|
return r ? {
|
|
@@ -4878,7 +4900,7 @@ function Aa(e) {
|
|
|
4878
4900
|
}
|
|
4879
4901
|
//#endregion
|
|
4880
4902
|
//#region src/authenticationMethods/list.ts
|
|
4881
|
-
function
|
|
4903
|
+
function Pa(e) {
|
|
4882
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) => ({
|
|
4883
4905
|
id: e.id,
|
|
4884
4906
|
user_id: e.user_id,
|
|
@@ -4898,35 +4920,35 @@ function ja(e) {
|
|
|
4898
4920
|
}
|
|
4899
4921
|
//#endregion
|
|
4900
4922
|
//#region src/authenticationMethods/update.ts
|
|
4901
|
-
function
|
|
4923
|
+
function Fa(e) {
|
|
4902
4924
|
return async (t, n, r) => {
|
|
4903
4925
|
let i = { updated_at_ts: Date.now() };
|
|
4904
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();
|
|
4905
|
-
let a = await
|
|
4927
|
+
let a = await Ma(e)(t, n);
|
|
4906
4928
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4907
4929
|
return a;
|
|
4908
4930
|
};
|
|
4909
4931
|
}
|
|
4910
4932
|
//#endregion
|
|
4911
4933
|
//#region src/authenticationMethods/remove.ts
|
|
4912
|
-
function
|
|
4934
|
+
function Ia(e) {
|
|
4913
4935
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4914
4936
|
}
|
|
4915
4937
|
//#endregion
|
|
4916
4938
|
//#region src/authenticationMethods/index.ts
|
|
4917
|
-
function
|
|
4939
|
+
function La(e) {
|
|
4918
4940
|
return {
|
|
4919
|
-
create:
|
|
4920
|
-
get:
|
|
4921
|
-
getByCredentialId:
|
|
4922
|
-
list:
|
|
4923
|
-
update:
|
|
4924
|
-
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)
|
|
4925
4947
|
};
|
|
4926
4948
|
}
|
|
4927
4949
|
//#endregion
|
|
4928
4950
|
//#region src/outbox/getByIds.ts
|
|
4929
|
-
function
|
|
4951
|
+
function Ra(e) {
|
|
4930
4952
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4931
4953
|
...JSON.parse(e.payload),
|
|
4932
4954
|
id: e.id,
|
|
@@ -4939,7 +4961,7 @@ function Fa(e) {
|
|
|
4939
4961
|
}
|
|
4940
4962
|
//#endregion
|
|
4941
4963
|
//#region src/outbox/getUnprocessed.ts
|
|
4942
|
-
function
|
|
4964
|
+
function za(e) {
|
|
4943
4965
|
return async (t) => {
|
|
4944
4966
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4945
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) => ({
|
|
@@ -4955,7 +4977,7 @@ function Ia(e) {
|
|
|
4955
4977
|
}
|
|
4956
4978
|
//#endregion
|
|
4957
4979
|
//#region src/outbox/claimEvents.ts
|
|
4958
|
-
function
|
|
4980
|
+
function Ba(e) {
|
|
4959
4981
|
return async (t, n, r) => {
|
|
4960
4982
|
if (t.length === 0) return [];
|
|
4961
4983
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4967,7 +4989,7 @@ function La(e) {
|
|
|
4967
4989
|
}
|
|
4968
4990
|
//#endregion
|
|
4969
4991
|
//#region src/outbox/markProcessed.ts
|
|
4970
|
-
function
|
|
4992
|
+
function Va(e) {
|
|
4971
4993
|
return async (t) => {
|
|
4972
4994
|
if (t.length === 0) return;
|
|
4973
4995
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4976,7 +4998,7 @@ function Ra(e) {
|
|
|
4976
4998
|
}
|
|
4977
4999
|
//#endregion
|
|
4978
5000
|
//#region src/outbox/markRetry.ts
|
|
4979
|
-
function
|
|
5001
|
+
function Ha(e) {
|
|
4980
5002
|
return async (t, n, r) => {
|
|
4981
5003
|
await e.updateTable("outbox_events").set({
|
|
4982
5004
|
error: n,
|
|
@@ -4989,7 +5011,7 @@ function za(e) {
|
|
|
4989
5011
|
}
|
|
4990
5012
|
//#endregion
|
|
4991
5013
|
//#region src/outbox/deadLetter.ts
|
|
4992
|
-
function
|
|
5014
|
+
function Ua(e) {
|
|
4993
5015
|
return async (t, n) => {
|
|
4994
5016
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4995
5017
|
await e.updateTable("outbox_events").set({
|
|
@@ -5001,7 +5023,7 @@ function Ba(e) {
|
|
|
5001
5023
|
}
|
|
5002
5024
|
//#endregion
|
|
5003
5025
|
//#region src/outbox/listFailed.ts
|
|
5004
|
-
function
|
|
5026
|
+
function Wa(e) {
|
|
5005
5027
|
return async (t, n = {}) => {
|
|
5006
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) => {
|
|
5007
5029
|
let t;
|
|
@@ -5036,7 +5058,7 @@ function Va(e) {
|
|
|
5036
5058
|
}
|
|
5037
5059
|
//#endregion
|
|
5038
5060
|
//#region src/outbox/replay.ts
|
|
5039
|
-
function
|
|
5061
|
+
function Ga(e) {
|
|
5040
5062
|
return async (t, n) => {
|
|
5041
5063
|
let r = await e.updateTable("outbox_events").set({
|
|
5042
5064
|
processed_at: null,
|
|
@@ -5051,7 +5073,7 @@ function Ha(e) {
|
|
|
5051
5073
|
}
|
|
5052
5074
|
//#endregion
|
|
5053
5075
|
//#region src/outbox/cleanup.ts
|
|
5054
|
-
function
|
|
5076
|
+
function Ka(e) {
|
|
5055
5077
|
return async (t) => {
|
|
5056
5078
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5057
5079
|
return Number(n.numDeletedRows);
|
|
@@ -5059,23 +5081,23 @@ function Ua(e) {
|
|
|
5059
5081
|
}
|
|
5060
5082
|
//#endregion
|
|
5061
5083
|
//#region src/outbox/index.ts
|
|
5062
|
-
function
|
|
5084
|
+
function qa(e) {
|
|
5063
5085
|
return {
|
|
5064
|
-
create:
|
|
5065
|
-
getByIds:
|
|
5066
|
-
getUnprocessed:
|
|
5067
|
-
claimEvents:
|
|
5068
|
-
markProcessed:
|
|
5069
|
-
markRetry:
|
|
5070
|
-
deadLetter:
|
|
5071
|
-
listFailed:
|
|
5072
|
-
replay:
|
|
5073
|
-
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)
|
|
5074
5096
|
};
|
|
5075
5097
|
}
|
|
5076
5098
|
//#endregion
|
|
5077
5099
|
//#region src/log-streams/index.ts
|
|
5078
|
-
function
|
|
5100
|
+
function W(e) {
|
|
5079
5101
|
return {
|
|
5080
5102
|
id: e.id,
|
|
5081
5103
|
name: e.name,
|
|
@@ -5088,7 +5110,7 @@ function G(e) {
|
|
|
5088
5110
|
updated_at: e.updated_at
|
|
5089
5111
|
};
|
|
5090
5112
|
}
|
|
5091
|
-
function
|
|
5113
|
+
function Ja(e) {
|
|
5092
5114
|
return {
|
|
5093
5115
|
async create(n, r, i) {
|
|
5094
5116
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5103,14 +5125,14 @@ function Ga(e) {
|
|
|
5103
5125
|
created_at: a?.created_at ?? o,
|
|
5104
5126
|
updated_at: a?.updated_at ?? o
|
|
5105
5127
|
};
|
|
5106
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5128
|
+
return await e.insertInto("log_streams").values(s).execute(), W(s);
|
|
5107
5129
|
},
|
|
5108
5130
|
async get(t, n) {
|
|
5109
5131
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5110
|
-
return r ?
|
|
5132
|
+
return r ? W(r) : null;
|
|
5111
5133
|
},
|
|
5112
5134
|
async list(t) {
|
|
5113
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5135
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(W);
|
|
5114
5136
|
},
|
|
5115
5137
|
async update(t, n, r) {
|
|
5116
5138
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5123,11 +5145,11 @@ function Ga(e) {
|
|
|
5123
5145
|
}
|
|
5124
5146
|
//#endregion
|
|
5125
5147
|
//#region src/migrationSources/index.ts
|
|
5126
|
-
function
|
|
5148
|
+
function G(e) {
|
|
5127
5149
|
return {
|
|
5128
5150
|
id: e.id,
|
|
5129
5151
|
name: e.name,
|
|
5130
|
-
provider:
|
|
5152
|
+
provider: ce.parse(e.provider),
|
|
5131
5153
|
connection: e.connection,
|
|
5132
5154
|
enabled: e.enabled === 1,
|
|
5133
5155
|
credentials: JSON.parse(e.credentials),
|
|
@@ -5135,7 +5157,7 @@ function K(e) {
|
|
|
5135
5157
|
updated_at: e.updated_at
|
|
5136
5158
|
};
|
|
5137
5159
|
}
|
|
5138
|
-
function
|
|
5160
|
+
function Ya(e) {
|
|
5139
5161
|
return {
|
|
5140
5162
|
async create(n, r, i) {
|
|
5141
5163
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5149,14 +5171,14 @@ function Ka(e) {
|
|
|
5149
5171
|
created_at: a?.created_at ?? o,
|
|
5150
5172
|
updated_at: a?.updated_at ?? o
|
|
5151
5173
|
};
|
|
5152
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5174
|
+
return await e.insertInto("migration_sources").values(l).execute(), G(l);
|
|
5153
5175
|
},
|
|
5154
5176
|
async get(t, n) {
|
|
5155
5177
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5156
|
-
return r ?
|
|
5178
|
+
return r ? G(r) : null;
|
|
5157
5179
|
},
|
|
5158
5180
|
async list(t) {
|
|
5159
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5181
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(G);
|
|
5160
5182
|
},
|
|
5161
5183
|
async update(t, n, r) {
|
|
5162
5184
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5169,34 +5191,34 @@ function Ka(e) {
|
|
|
5169
5191
|
}
|
|
5170
5192
|
//#endregion
|
|
5171
5193
|
//#region src/proxyRoutes/serialize.ts
|
|
5172
|
-
function
|
|
5194
|
+
function K(e) {
|
|
5173
5195
|
return {
|
|
5174
5196
|
id: e.id,
|
|
5175
5197
|
tenant_id: e.tenant_id,
|
|
5176
5198
|
custom_domain_id: e.custom_domain_id,
|
|
5177
5199
|
priority: e.priority,
|
|
5178
|
-
match:
|
|
5179
|
-
handlers:
|
|
5200
|
+
match: Xa(e.match),
|
|
5201
|
+
handlers: Za(e.handlers),
|
|
5180
5202
|
created_at: e.created_at,
|
|
5181
5203
|
updated_at: e.updated_at
|
|
5182
5204
|
};
|
|
5183
5205
|
}
|
|
5184
|
-
function
|
|
5206
|
+
function Xa(e) {
|
|
5185
5207
|
if (!e) return { path: "/*" };
|
|
5186
5208
|
try {
|
|
5187
|
-
let t = JSON.parse(e), n =
|
|
5209
|
+
let t = JSON.parse(e), n = se.safeParse(t);
|
|
5188
5210
|
if (n.success) return n.data;
|
|
5189
5211
|
} catch {}
|
|
5190
5212
|
return { path: "/*" };
|
|
5191
5213
|
}
|
|
5192
|
-
function
|
|
5214
|
+
function Za(e) {
|
|
5193
5215
|
if (!e) return [];
|
|
5194
5216
|
try {
|
|
5195
5217
|
let t = JSON.parse(e);
|
|
5196
5218
|
if (!Array.isArray(t)) return [];
|
|
5197
5219
|
let n = [];
|
|
5198
5220
|
for (let e of t) {
|
|
5199
|
-
let t =
|
|
5221
|
+
let t = ie.safeParse(e);
|
|
5200
5222
|
t.success && n.push(t.data);
|
|
5201
5223
|
}
|
|
5202
5224
|
return n;
|
|
@@ -5206,7 +5228,7 @@ function Ja(e) {
|
|
|
5206
5228
|
}
|
|
5207
5229
|
//#endregion
|
|
5208
5230
|
//#region src/proxyRoutes/adapter.ts
|
|
5209
|
-
function
|
|
5231
|
+
function q(e) {
|
|
5210
5232
|
return {
|
|
5211
5233
|
async create(n, r, i) {
|
|
5212
5234
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5232,14 +5254,14 @@ function J(e) {
|
|
|
5232
5254
|
},
|
|
5233
5255
|
async get(t, n) {
|
|
5234
5256
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5235
|
-
return r ?
|
|
5257
|
+
return r ? K(r) : null;
|
|
5236
5258
|
},
|
|
5237
5259
|
async list(t, n = {}) {
|
|
5238
5260
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5239
5261
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5240
5262
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5241
5263
|
return {
|
|
5242
|
-
proxy_routes: o.map(
|
|
5264
|
+
proxy_routes: o.map(K),
|
|
5243
5265
|
start: r * i,
|
|
5244
5266
|
limit: i,
|
|
5245
5267
|
length: o.length
|
|
@@ -5259,7 +5281,7 @@ function J(e) {
|
|
|
5259
5281
|
}
|
|
5260
5282
|
//#endregion
|
|
5261
5283
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5262
|
-
async function
|
|
5284
|
+
async function Qa(e, t) {
|
|
5263
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([
|
|
5264
5286
|
"custom_domain_id",
|
|
5265
5287
|
"tenant_id",
|
|
@@ -5271,27 +5293,27 @@ async function Ya(e, t) {
|
|
|
5271
5293
|
tenant_id: a.tenant_id,
|
|
5272
5294
|
custom_domain_id: a.custom_domain_id,
|
|
5273
5295
|
domain: a.domain,
|
|
5274
|
-
routes: o.map(
|
|
5296
|
+
routes: o.map(K)
|
|
5275
5297
|
};
|
|
5276
5298
|
}
|
|
5277
5299
|
//#endregion
|
|
5278
5300
|
//#region src/proxyRoutes/index.ts
|
|
5279
|
-
function
|
|
5301
|
+
function $a(e) {
|
|
5280
5302
|
return {
|
|
5281
|
-
proxyRoutes:
|
|
5282
|
-
resolveHost: (t) =>
|
|
5303
|
+
proxyRoutes: q(e),
|
|
5304
|
+
resolveHost: (t) => Qa(e, t)
|
|
5283
5305
|
};
|
|
5284
5306
|
}
|
|
5285
5307
|
//#endregion
|
|
5286
5308
|
//#region src/scim/adapter.ts
|
|
5287
|
-
function
|
|
5309
|
+
function eo(e) {
|
|
5288
5310
|
if (!e) return [];
|
|
5289
5311
|
try {
|
|
5290
5312
|
let t = JSON.parse(e);
|
|
5291
5313
|
if (!Array.isArray(t)) return [];
|
|
5292
5314
|
let n = [];
|
|
5293
5315
|
for (let e of t) {
|
|
5294
|
-
let t =
|
|
5316
|
+
let t = pe.safeParse(e);
|
|
5295
5317
|
t.success && n.push(t.data);
|
|
5296
5318
|
}
|
|
5297
5319
|
return n;
|
|
@@ -5299,7 +5321,7 @@ function Za(e) {
|
|
|
5299
5321
|
return [];
|
|
5300
5322
|
}
|
|
5301
5323
|
}
|
|
5302
|
-
function
|
|
5324
|
+
function to(e) {
|
|
5303
5325
|
if (!e) return [];
|
|
5304
5326
|
try {
|
|
5305
5327
|
let t = JSON.parse(e);
|
|
@@ -5308,16 +5330,16 @@ function Qa(e) {
|
|
|
5308
5330
|
return [];
|
|
5309
5331
|
}
|
|
5310
5332
|
}
|
|
5311
|
-
function
|
|
5333
|
+
function no(e) {
|
|
5312
5334
|
return {
|
|
5313
5335
|
connection_id: e.connection_id,
|
|
5314
5336
|
user_id_attribute: e.user_id_attribute,
|
|
5315
|
-
mapping:
|
|
5337
|
+
mapping: eo(e.mapping),
|
|
5316
5338
|
created_at: e.created_at,
|
|
5317
5339
|
updated_at: e.updated_at
|
|
5318
5340
|
};
|
|
5319
5341
|
}
|
|
5320
|
-
function
|
|
5342
|
+
function ro(e) {
|
|
5321
5343
|
return {
|
|
5322
5344
|
async create(t, n) {
|
|
5323
5345
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5338,7 +5360,7 @@ function eo(e) {
|
|
|
5338
5360
|
},
|
|
5339
5361
|
async get(t, n) {
|
|
5340
5362
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5341
|
-
return r ?
|
|
5363
|
+
return r ? no(r) : null;
|
|
5342
5364
|
},
|
|
5343
5365
|
async update(t, n, r) {
|
|
5344
5366
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5352,18 +5374,18 @@ function eo(e) {
|
|
|
5352
5374
|
}
|
|
5353
5375
|
};
|
|
5354
5376
|
}
|
|
5355
|
-
function
|
|
5377
|
+
function J(e) {
|
|
5356
5378
|
return {
|
|
5357
5379
|
token_id: e.token_id,
|
|
5358
5380
|
connection_id: e.connection_id,
|
|
5359
5381
|
token_hash: e.token_hash,
|
|
5360
|
-
scopes:
|
|
5382
|
+
scopes: to(e.scopes),
|
|
5361
5383
|
valid_until: e.valid_until ?? void 0,
|
|
5362
5384
|
created_at: e.created_at,
|
|
5363
5385
|
last_used_at: e.last_used_at ?? void 0
|
|
5364
5386
|
};
|
|
5365
5387
|
}
|
|
5366
|
-
function
|
|
5388
|
+
function io(e) {
|
|
5367
5389
|
return {
|
|
5368
5390
|
async create(t, n) {
|
|
5369
5391
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5387,14 +5409,14 @@ function to(e) {
|
|
|
5387
5409
|
},
|
|
5388
5410
|
async get(t, n) {
|
|
5389
5411
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5390
|
-
return r ?
|
|
5412
|
+
return r ? J(r) : null;
|
|
5391
5413
|
},
|
|
5392
5414
|
async getByHash(t, n) {
|
|
5393
5415
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5394
|
-
return r ?
|
|
5416
|
+
return r ? J(r) : null;
|
|
5395
5417
|
},
|
|
5396
5418
|
async listByConnection(t, n) {
|
|
5397
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5419
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(J);
|
|
5398
5420
|
},
|
|
5399
5421
|
async markUsed(t, n, r) {
|
|
5400
5422
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5406,7 +5428,7 @@ function to(e) {
|
|
|
5406
5428
|
}
|
|
5407
5429
|
};
|
|
5408
5430
|
}
|
|
5409
|
-
function
|
|
5431
|
+
function ao(e) {
|
|
5410
5432
|
return {
|
|
5411
5433
|
connection_id: e.connection_id,
|
|
5412
5434
|
external_id: e.external_id,
|
|
@@ -5414,7 +5436,7 @@ function no(e) {
|
|
|
5414
5436
|
created_at: e.created_at
|
|
5415
5437
|
};
|
|
5416
5438
|
}
|
|
5417
|
-
function
|
|
5439
|
+
function oo(e) {
|
|
5418
5440
|
return {
|
|
5419
5441
|
async create(t, n) {
|
|
5420
5442
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5433,11 +5455,11 @@ function ro(e) {
|
|
|
5433
5455
|
},
|
|
5434
5456
|
async getByExternalId(t, n, r) {
|
|
5435
5457
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5436
|
-
return i ?
|
|
5458
|
+
return i ? ao(i) : null;
|
|
5437
5459
|
},
|
|
5438
5460
|
async getByUserId(t, n, r) {
|
|
5439
5461
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5440
|
-
return i ?
|
|
5462
|
+
return i ? ao(i) : null;
|
|
5441
5463
|
},
|
|
5442
5464
|
async remove(t, n, r) {
|
|
5443
5465
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5447,8 +5469,8 @@ function ro(e) {
|
|
|
5447
5469
|
}
|
|
5448
5470
|
//#endregion
|
|
5449
5471
|
//#region src/tenantOperations/index.ts
|
|
5450
|
-
function
|
|
5451
|
-
return
|
|
5472
|
+
function Y(e) {
|
|
5473
|
+
return ve.parse({
|
|
5452
5474
|
id: e.id,
|
|
5453
5475
|
tenant_id: e.tenant_id,
|
|
5454
5476
|
rollout_id: e.rollout_id,
|
|
@@ -5466,10 +5488,10 @@ function X(e) {
|
|
|
5466
5488
|
finished_at: e.finished_at
|
|
5467
5489
|
});
|
|
5468
5490
|
}
|
|
5469
|
-
function
|
|
5491
|
+
function so(e) {
|
|
5470
5492
|
return {
|
|
5471
5493
|
async create(n) {
|
|
5472
|
-
let r =
|
|
5494
|
+
let r = _e.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5473
5495
|
id: `op_${t()}`,
|
|
5474
5496
|
tenant_id: r.tenant_id,
|
|
5475
5497
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5486,11 +5508,11 @@ function io(e) {
|
|
|
5486
5508
|
updated_at: i,
|
|
5487
5509
|
finished_at: null
|
|
5488
5510
|
};
|
|
5489
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5511
|
+
return await e.insertInto("tenant_operations").values(a).execute(), Y(a);
|
|
5490
5512
|
},
|
|
5491
5513
|
async get(t) {
|
|
5492
5514
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5493
|
-
return n ?
|
|
5515
|
+
return n ? Y(n) : null;
|
|
5494
5516
|
},
|
|
5495
5517
|
async list(t = {}) {
|
|
5496
5518
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5501,7 +5523,7 @@ function io(e) {
|
|
|
5501
5523
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5502
5524
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5503
5525
|
return {
|
|
5504
|
-
operations: a.map(
|
|
5526
|
+
operations: a.map(Y),
|
|
5505
5527
|
start: n * r,
|
|
5506
5528
|
limit: r,
|
|
5507
5529
|
length: a.length
|
|
@@ -5521,27 +5543,27 @@ function io(e) {
|
|
|
5521
5543
|
}
|
|
5522
5544
|
//#endregion
|
|
5523
5545
|
//#region src/utils/monotonic-id.ts
|
|
5524
|
-
var
|
|
5525
|
-
function
|
|
5546
|
+
var co = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", X = 32, lo = 10, uo = 4, fo = 10;
|
|
5547
|
+
function po(e, t) {
|
|
5526
5548
|
let n = "";
|
|
5527
|
-
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);
|
|
5528
5550
|
return n;
|
|
5529
5551
|
}
|
|
5530
|
-
function
|
|
5531
|
-
let e = new Uint8Array(
|
|
5552
|
+
function mo() {
|
|
5553
|
+
let e = new Uint8Array(fo);
|
|
5532
5554
|
crypto.getRandomValues(e);
|
|
5533
5555
|
let t = "";
|
|
5534
|
-
for (let n = 0; n <
|
|
5556
|
+
for (let n = 0; n < fo; n++) t += co.charAt(e[n] % X);
|
|
5535
5557
|
return t;
|
|
5536
5558
|
}
|
|
5537
|
-
var
|
|
5538
|
-
function
|
|
5559
|
+
var ho = 0, Z = 0;
|
|
5560
|
+
function go() {
|
|
5539
5561
|
let e = Date.now();
|
|
5540
|
-
return e ===
|
|
5562
|
+
return e === ho ? Z++ : (ho = e, Z = 0), po(e, lo) + po(Z, uo) + mo();
|
|
5541
5563
|
}
|
|
5542
5564
|
//#endregion
|
|
5543
5565
|
//#region src/tenantOperationEvents/index.ts
|
|
5544
|
-
function
|
|
5566
|
+
function _o(e) {
|
|
5545
5567
|
if (!e) return null;
|
|
5546
5568
|
try {
|
|
5547
5569
|
let t = JSON.parse(e);
|
|
@@ -5549,22 +5571,22 @@ function ho(e) {
|
|
|
5549
5571
|
} catch {}
|
|
5550
5572
|
return null;
|
|
5551
5573
|
}
|
|
5552
|
-
function
|
|
5553
|
-
return
|
|
5574
|
+
function vo(e) {
|
|
5575
|
+
return ge.parse({
|
|
5554
5576
|
id: e.id,
|
|
5555
5577
|
operation_id: e.operation_id,
|
|
5556
5578
|
step: e.step,
|
|
5557
5579
|
outcome: e.outcome,
|
|
5558
|
-
detail:
|
|
5580
|
+
detail: _o(e.detail),
|
|
5559
5581
|
attempt: e.attempt,
|
|
5560
5582
|
created_at: e.created_at
|
|
5561
5583
|
});
|
|
5562
5584
|
}
|
|
5563
|
-
function
|
|
5585
|
+
function yo(e) {
|
|
5564
5586
|
return {
|
|
5565
5587
|
async create(t) {
|
|
5566
|
-
let n =
|
|
5567
|
-
id: `evt_${
|
|
5588
|
+
let n = he.parse(t), r = {
|
|
5589
|
+
id: `evt_${go()}`,
|
|
5568
5590
|
operation_id: n.operation_id,
|
|
5569
5591
|
step: n.step,
|
|
5570
5592
|
outcome: n.outcome,
|
|
@@ -5572,12 +5594,12 @@ function _o(e) {
|
|
|
5572
5594
|
attempt: n.attempt,
|
|
5573
5595
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5574
5596
|
};
|
|
5575
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5597
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), vo(r);
|
|
5576
5598
|
},
|
|
5577
5599
|
async listByOperation(t, n = {}) {
|
|
5578
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();
|
|
5579
5601
|
return {
|
|
5580
|
-
events: a.map(
|
|
5602
|
+
events: a.map(vo),
|
|
5581
5603
|
start: r * i,
|
|
5582
5604
|
limit: i,
|
|
5583
5605
|
length: a.length
|
|
@@ -5587,7 +5609,7 @@ function _o(e) {
|
|
|
5587
5609
|
}
|
|
5588
5610
|
//#endregion
|
|
5589
5611
|
//#region src/rollouts/index.ts
|
|
5590
|
-
function
|
|
5612
|
+
function bo(e) {
|
|
5591
5613
|
if (!e) return null;
|
|
5592
5614
|
try {
|
|
5593
5615
|
return JSON.parse(e);
|
|
@@ -5595,26 +5617,26 @@ function vo(e) {
|
|
|
5595
5617
|
return null;
|
|
5596
5618
|
}
|
|
5597
5619
|
}
|
|
5598
|
-
function
|
|
5599
|
-
return
|
|
5620
|
+
function xo(e) {
|
|
5621
|
+
return fe.parse({
|
|
5600
5622
|
id: e.id,
|
|
5601
5623
|
kind: e.kind,
|
|
5602
5624
|
status: e.status,
|
|
5603
5625
|
target_worker_version: e.target_worker_version,
|
|
5604
5626
|
target_database_version: e.target_database_version,
|
|
5605
5627
|
wave_size: e.wave_size,
|
|
5606
|
-
canary_tenant_ids:
|
|
5607
|
-
filter:
|
|
5628
|
+
canary_tenant_ids: bo(e.canary_tenant_ids),
|
|
5629
|
+
filter: bo(e.filter),
|
|
5608
5630
|
initiated_by: e.initiated_by,
|
|
5609
5631
|
created_at: e.created_at,
|
|
5610
5632
|
updated_at: e.updated_at,
|
|
5611
5633
|
finished_at: e.finished_at
|
|
5612
5634
|
});
|
|
5613
5635
|
}
|
|
5614
|
-
function
|
|
5636
|
+
function So(e) {
|
|
5615
5637
|
return {
|
|
5616
5638
|
async create(n) {
|
|
5617
|
-
let r =
|
|
5639
|
+
let r = de.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5618
5640
|
id: `rol_${t()}`,
|
|
5619
5641
|
kind: r.kind,
|
|
5620
5642
|
status: "pending",
|
|
@@ -5628,16 +5650,16 @@ function bo(e) {
|
|
|
5628
5650
|
updated_at: i,
|
|
5629
5651
|
finished_at: null
|
|
5630
5652
|
};
|
|
5631
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5653
|
+
return await e.insertInto("rollouts").values(a).execute(), xo(a);
|
|
5632
5654
|
},
|
|
5633
5655
|
async get(t) {
|
|
5634
5656
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5635
|
-
return n ?
|
|
5657
|
+
return n ? xo(n) : null;
|
|
5636
5658
|
},
|
|
5637
5659
|
async list(t = {}) {
|
|
5638
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();
|
|
5639
5661
|
return {
|
|
5640
|
-
rollouts: i.map(
|
|
5662
|
+
rollouts: i.map(xo),
|
|
5641
5663
|
start: n * r,
|
|
5642
5664
|
limit: r,
|
|
5643
5665
|
length: i.length
|
|
@@ -5657,7 +5679,7 @@ function bo(e) {
|
|
|
5657
5679
|
}
|
|
5658
5680
|
//#endregion
|
|
5659
5681
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5660
|
-
var
|
|
5682
|
+
var Co = class {
|
|
5661
5683
|
migrations;
|
|
5662
5684
|
constructor(e) {
|
|
5663
5685
|
this.migrations = e;
|
|
@@ -5665,10 +5687,10 @@ var xo = class {
|
|
|
5665
5687
|
async getMigrations() {
|
|
5666
5688
|
return this.migrations;
|
|
5667
5689
|
}
|
|
5668
|
-
},
|
|
5669
|
-
down: () =>
|
|
5670
|
-
up: () =>
|
|
5671
|
-
}),
|
|
5690
|
+
}, wo = /* @__PURE__ */ w({
|
|
5691
|
+
down: () => Oo,
|
|
5692
|
+
up: () => Do
|
|
5693
|
+
}), To = [
|
|
5672
5694
|
{
|
|
5673
5695
|
table: "authentication_methods",
|
|
5674
5696
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5934,7 +5956,7 @@ var xo = class {
|
|
|
5934
5956
|
onDelete: "cascade"
|
|
5935
5957
|
}
|
|
5936
5958
|
];
|
|
5937
|
-
async function
|
|
5959
|
+
async function Eo(e) {
|
|
5938
5960
|
try {
|
|
5939
5961
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5940
5962
|
} catch {
|
|
@@ -5943,14 +5965,14 @@ async function wo(e) {
|
|
|
5943
5965
|
}
|
|
5944
5966
|
function Q(e, t) {
|
|
5945
5967
|
let n = e;
|
|
5946
|
-
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) => {
|
|
5947
5969
|
let n = t;
|
|
5948
5970
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5949
5971
|
}));
|
|
5950
5972
|
return n;
|
|
5951
5973
|
}
|
|
5952
|
-
async function
|
|
5953
|
-
let t = await
|
|
5974
|
+
async function Do(e) {
|
|
5975
|
+
let t = await Eo(e);
|
|
5954
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();
|
|
5955
5977
|
{
|
|
5956
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"]);
|
|
@@ -6137,40 +6159,40 @@ async function To(e) {
|
|
|
6137
6159
|
"tenant_id",
|
|
6138
6160
|
"phone_number",
|
|
6139
6161
|
"provider"
|
|
6140
|
-
]).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) => {
|
|
6141
6163
|
let n = e;
|
|
6142
6164
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6143
6165
|
}).execute();
|
|
6144
6166
|
}
|
|
6145
|
-
async function
|
|
6167
|
+
async function Oo(e) {
|
|
6146
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();
|
|
6147
6169
|
}
|
|
6148
6170
|
//#endregion
|
|
6149
6171
|
//#region migrate/log.ts
|
|
6150
|
-
var
|
|
6151
|
-
function
|
|
6152
|
-
|
|
6172
|
+
var ko = !1;
|
|
6173
|
+
function Ao(e) {
|
|
6174
|
+
ko = e;
|
|
6153
6175
|
}
|
|
6154
6176
|
function $(...e) {
|
|
6155
|
-
|
|
6177
|
+
ko && console.log(...e);
|
|
6156
6178
|
}
|
|
6157
|
-
function
|
|
6179
|
+
function jo(...e) {
|
|
6158
6180
|
console.warn(...e);
|
|
6159
6181
|
}
|
|
6160
6182
|
//#endregion
|
|
6161
6183
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6162
|
-
var
|
|
6163
|
-
down: () =>
|
|
6164
|
-
up: () =>
|
|
6165
|
-
}),
|
|
6166
|
-
async function
|
|
6184
|
+
var Mo = /* @__PURE__ */ w({
|
|
6185
|
+
down: () => Uo,
|
|
6186
|
+
up: () => Bo
|
|
6187
|
+
}), No = 5e4, Po = 500;
|
|
6188
|
+
async function Fo(e) {
|
|
6167
6189
|
try {
|
|
6168
6190
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6169
6191
|
} catch {
|
|
6170
6192
|
return "sqlite";
|
|
6171
6193
|
}
|
|
6172
6194
|
}
|
|
6173
|
-
async function
|
|
6195
|
+
async function Io(e, t, n) {
|
|
6174
6196
|
try {
|
|
6175
6197
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6176
6198
|
} catch (e) {
|
|
@@ -6181,7 +6203,7 @@ async function Po(e, t, n) {
|
|
|
6181
6203
|
throw e;
|
|
6182
6204
|
}
|
|
6183
6205
|
}
|
|
6184
|
-
async function
|
|
6206
|
+
async function Lo(e, t, n, r) {
|
|
6185
6207
|
try {
|
|
6186
6208
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6187
6209
|
} catch (e) {
|
|
@@ -6192,21 +6214,21 @@ async function Fo(e, t, n, r) {
|
|
|
6192
6214
|
throw e;
|
|
6193
6215
|
}
|
|
6194
6216
|
}
|
|
6195
|
-
async function
|
|
6217
|
+
async function Ro(e, t) {
|
|
6196
6218
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6197
6219
|
if (t === "sqlite") {
|
|
6198
6220
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6199
6221
|
r = Number(t.numDeletedRows);
|
|
6200
6222
|
} else {
|
|
6201
|
-
let t =
|
|
6202
|
-
for (; t >=
|
|
6203
|
-
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();
|
|
6204
6226
|
t = Number(i.numDeletedRows), r += t, t > 0 && $(` Pruned ${r} expired codes row(s)...`);
|
|
6205
6227
|
}
|
|
6206
6228
|
}
|
|
6207
6229
|
return r;
|
|
6208
6230
|
}
|
|
6209
|
-
async function
|
|
6231
|
+
async function zo(e) {
|
|
6210
6232
|
let t = 0;
|
|
6211
6233
|
for (;;) {
|
|
6212
6234
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6214,33 +6236,33 @@ async function Lo(e) {
|
|
|
6214
6236
|
"code_type",
|
|
6215
6237
|
"tenant_id",
|
|
6216
6238
|
"expires_at"
|
|
6217
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6239
|
+
]).where("expires_at_ts", "is", null).limit(Po).execute();
|
|
6218
6240
|
if (n.length === 0) break;
|
|
6219
6241
|
for (let t of n) {
|
|
6220
6242
|
let n = Date.parse(t.expires_at);
|
|
6221
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();
|
|
6222
6244
|
}
|
|
6223
|
-
if (t += n.length, n.length <
|
|
6245
|
+
if (t += n.length, n.length < Po) break;
|
|
6224
6246
|
}
|
|
6225
6247
|
return t;
|
|
6226
6248
|
}
|
|
6227
|
-
async function
|
|
6228
|
-
let t = await
|
|
6249
|
+
async function Bo(e) {
|
|
6250
|
+
let t = await Fo(e);
|
|
6229
6251
|
try {
|
|
6230
|
-
let n = await
|
|
6252
|
+
let n = await Ro(e, t);
|
|
6231
6253
|
$(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6232
6254
|
} catch (e) {
|
|
6233
|
-
|
|
6255
|
+
jo(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6234
6256
|
}
|
|
6235
|
-
await
|
|
6257
|
+
await Io(e, "codes", "expires_at_ts"), await Lo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6236
6258
|
try {
|
|
6237
|
-
let t = await
|
|
6259
|
+
let t = await zo(e);
|
|
6238
6260
|
$(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6239
6261
|
} catch (e) {
|
|
6240
|
-
|
|
6262
|
+
jo(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6241
6263
|
}
|
|
6242
6264
|
}
|
|
6243
|
-
async function
|
|
6265
|
+
async function Vo(e, t, n) {
|
|
6244
6266
|
try {
|
|
6245
6267
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6246
6268
|
} catch (e) {
|
|
@@ -6248,7 +6270,7 @@ async function zo(e, t, n) {
|
|
|
6248
6270
|
throw e;
|
|
6249
6271
|
}
|
|
6250
6272
|
}
|
|
6251
|
-
async function
|
|
6273
|
+
async function Ho(e, t, n) {
|
|
6252
6274
|
try {
|
|
6253
6275
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6254
6276
|
} catch (e) {
|
|
@@ -6256,16 +6278,16 @@ async function Bo(e, t, n) {
|
|
|
6256
6278
|
throw e;
|
|
6257
6279
|
}
|
|
6258
6280
|
}
|
|
6259
|
-
async function
|
|
6260
|
-
await
|
|
6281
|
+
async function Uo(e) {
|
|
6282
|
+
await Vo(e, "idx_codes_expires_at_ts", "codes"), await Ho(e, "codes", "expires_at_ts");
|
|
6261
6283
|
}
|
|
6262
6284
|
//#endregion
|
|
6263
6285
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6264
|
-
var
|
|
6265
|
-
down: () =>
|
|
6266
|
-
up: () =>
|
|
6286
|
+
var Wo = /* @__PURE__ */ w({
|
|
6287
|
+
down: () => Ko,
|
|
6288
|
+
up: () => Go
|
|
6267
6289
|
});
|
|
6268
|
-
async function
|
|
6290
|
+
async function Go(e) {
|
|
6269
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", [
|
|
6270
6292
|
"tenant_id",
|
|
6271
6293
|
"connection_id",
|
|
@@ -6276,16 +6298,16 @@ async function Uo(e) {
|
|
|
6276
6298
|
"external_id"
|
|
6277
6299
|
]).unique().execute();
|
|
6278
6300
|
}
|
|
6279
|
-
async function
|
|
6301
|
+
async function Ko(e) {
|
|
6280
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();
|
|
6281
6303
|
}
|
|
6282
6304
|
//#endregion
|
|
6283
6305
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6284
|
-
var
|
|
6285
|
-
down: () =>
|
|
6286
|
-
up: () =>
|
|
6306
|
+
var qo = /* @__PURE__ */ w({
|
|
6307
|
+
down: () => Zo,
|
|
6308
|
+
up: () => Yo
|
|
6287
6309
|
});
|
|
6288
|
-
async function
|
|
6310
|
+
async function Jo(e, t, n) {
|
|
6289
6311
|
try {
|
|
6290
6312
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6291
6313
|
} catch (e) {
|
|
@@ -6293,10 +6315,10 @@ async function Ko(e, t, n) {
|
|
|
6293
6315
|
throw e;
|
|
6294
6316
|
}
|
|
6295
6317
|
}
|
|
6296
|
-
async function
|
|
6297
|
-
await
|
|
6318
|
+
async function Yo(e) {
|
|
6319
|
+
await Jo(e, "users", "blocked");
|
|
6298
6320
|
}
|
|
6299
|
-
async function
|
|
6321
|
+
async function Xo(e, t, n) {
|
|
6300
6322
|
try {
|
|
6301
6323
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6302
6324
|
} catch (e) {
|
|
@@ -6304,16 +6326,16 @@ async function Jo(e, t, n) {
|
|
|
6304
6326
|
throw e;
|
|
6305
6327
|
}
|
|
6306
6328
|
}
|
|
6307
|
-
async function
|
|
6308
|
-
await
|
|
6329
|
+
async function Zo(e) {
|
|
6330
|
+
await Xo(e, "users", "blocked");
|
|
6309
6331
|
}
|
|
6310
6332
|
//#endregion
|
|
6311
6333
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6312
|
-
var
|
|
6313
|
-
down: () =>
|
|
6314
|
-
up: () =>
|
|
6334
|
+
var Qo = /* @__PURE__ */ w({
|
|
6335
|
+
down: () => ns,
|
|
6336
|
+
up: () => es
|
|
6315
6337
|
});
|
|
6316
|
-
async function
|
|
6338
|
+
async function $o(e, t, n) {
|
|
6317
6339
|
try {
|
|
6318
6340
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6319
6341
|
} catch (e) {
|
|
@@ -6321,10 +6343,10 @@ async function Zo(e, t, n) {
|
|
|
6321
6343
|
throw e;
|
|
6322
6344
|
}
|
|
6323
6345
|
}
|
|
6324
|
-
async function
|
|
6325
|
-
await
|
|
6346
|
+
async function es(e) {
|
|
6347
|
+
await $o(e, "prompt_settings", "show_last_used_connection");
|
|
6326
6348
|
}
|
|
6327
|
-
async function
|
|
6349
|
+
async function ts(e, t, n) {
|
|
6328
6350
|
try {
|
|
6329
6351
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6330
6352
|
} catch (e) {
|
|
@@ -6332,16 +6354,16 @@ async function $o(e, t, n) {
|
|
|
6332
6354
|
throw e;
|
|
6333
6355
|
}
|
|
6334
6356
|
}
|
|
6335
|
-
async function
|
|
6336
|
-
await
|
|
6357
|
+
async function ns(e) {
|
|
6358
|
+
await ts(e, "prompt_settings", "show_last_used_connection");
|
|
6337
6359
|
}
|
|
6338
6360
|
//#endregion
|
|
6339
6361
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6340
|
-
var
|
|
6341
|
-
down: () =>
|
|
6342
|
-
up: () =>
|
|
6362
|
+
var rs = /* @__PURE__ */ w({
|
|
6363
|
+
down: () => os,
|
|
6364
|
+
up: () => as
|
|
6343
6365
|
});
|
|
6344
|
-
async function
|
|
6366
|
+
async function is(e, t, n, r) {
|
|
6345
6367
|
try {
|
|
6346
6368
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6347
6369
|
} catch (e) {
|
|
@@ -6352,10 +6374,10 @@ async function ns(e, t, n, r) {
|
|
|
6352
6374
|
throw e;
|
|
6353
6375
|
}
|
|
6354
6376
|
}
|
|
6355
|
-
async function
|
|
6356
|
-
await
|
|
6377
|
+
async function as(e) {
|
|
6378
|
+
await is(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6357
6379
|
}
|
|
6358
|
-
async function
|
|
6380
|
+
async function os(e) {
|
|
6359
6381
|
try {
|
|
6360
6382
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6361
6383
|
} catch (e) {
|
|
@@ -6365,11 +6387,11 @@ async function is(e) {
|
|
|
6365
6387
|
}
|
|
6366
6388
|
//#endregion
|
|
6367
6389
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6368
|
-
var
|
|
6369
|
-
down: () =>
|
|
6370
|
-
up: () =>
|
|
6390
|
+
var ss = /* @__PURE__ */ w({
|
|
6391
|
+
down: () => ds,
|
|
6392
|
+
up: () => ls
|
|
6371
6393
|
});
|
|
6372
|
-
async function
|
|
6394
|
+
async function cs(e, t, n, r) {
|
|
6373
6395
|
try {
|
|
6374
6396
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6375
6397
|
} catch (e) {
|
|
@@ -6377,10 +6399,10 @@ async function os(e, t, n, r) {
|
|
|
6377
6399
|
throw e;
|
|
6378
6400
|
}
|
|
6379
6401
|
}
|
|
6380
|
-
async function
|
|
6381
|
-
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)`);
|
|
6382
6404
|
}
|
|
6383
|
-
async function
|
|
6405
|
+
async function us(e, t, n) {
|
|
6384
6406
|
try {
|
|
6385
6407
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6386
6408
|
} catch (e) {
|
|
@@ -6388,37 +6410,37 @@ async function cs(e, t, n) {
|
|
|
6388
6410
|
throw e;
|
|
6389
6411
|
}
|
|
6390
6412
|
}
|
|
6391
|
-
async function
|
|
6392
|
-
await
|
|
6413
|
+
async function ds(e) {
|
|
6414
|
+
await us(e, "hooks", "permission_required"), await us(e, "hooks", "page_id");
|
|
6393
6415
|
}
|
|
6394
6416
|
//#endregion
|
|
6395
6417
|
//#region migrate/migrations/index.ts
|
|
6396
|
-
var
|
|
6397
|
-
"2026-07-16T14:00:00_baseline":
|
|
6398
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6399
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6400
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6401
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6402
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6403
|
-
"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
|
|
6404
6426
|
};
|
|
6405
6427
|
//#endregion
|
|
6406
6428
|
//#region migrate/migrate.ts
|
|
6407
|
-
async function
|
|
6408
|
-
|
|
6409
|
-
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({
|
|
6410
6432
|
db: e,
|
|
6411
|
-
provider: new
|
|
6433
|
+
provider: new Co(fs)
|
|
6412
6434
|
}).migrateToLatest();
|
|
6413
6435
|
if (r?.forEach((e) => {
|
|
6414
6436
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6415
6437
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6416
6438
|
}
|
|
6417
|
-
async function
|
|
6418
|
-
|
|
6419
|
-
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({
|
|
6420
6442
|
db: e,
|
|
6421
|
-
provider: new
|
|
6443
|
+
provider: new Co(fs)
|
|
6422
6444
|
}).migrateDown();
|
|
6423
6445
|
if (r?.forEach((e) => {
|
|
6424
6446
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6426,64 +6448,64 @@ async function fs(e, t = !1) {
|
|
|
6426
6448
|
}
|
|
6427
6449
|
//#endregion
|
|
6428
6450
|
//#region src/index.ts
|
|
6429
|
-
function
|
|
6451
|
+
function hs(e, t = { useTransactions: !0 }) {
|
|
6430
6452
|
let n = {
|
|
6431
|
-
actions:
|
|
6432
|
-
actionExecutions:
|
|
6433
|
-
actionVersions:
|
|
6434
|
-
branding:
|
|
6435
|
-
clients:
|
|
6436
|
-
clientConnections:
|
|
6437
|
-
clientGrants:
|
|
6438
|
-
clientRegistrationTokens:
|
|
6439
|
-
codes:
|
|
6440
|
-
connections:
|
|
6441
|
-
emailProviders:
|
|
6442
|
-
emailTemplates:
|
|
6443
|
-
customDomains:
|
|
6444
|
-
flows:
|
|
6445
|
-
forms:
|
|
6446
|
-
hookCode:
|
|
6447
|
-
hooks:
|
|
6448
|
-
invites:
|
|
6449
|
-
keys:
|
|
6450
|
-
loginSessions:
|
|
6451
|
-
logs:
|
|
6452
|
-
logStreams:
|
|
6453
|
-
migrationSources:
|
|
6454
|
-
authenticationMethods:
|
|
6455
|
-
passwords:
|
|
6456
|
-
promptSettings:
|
|
6457
|
-
proxyRoutes:
|
|
6458
|
-
scimConfigurations:
|
|
6459
|
-
scimTokens:
|
|
6460
|
-
scimExternalIds:
|
|
6461
|
-
refreshTokens:
|
|
6462
|
-
resourceServers:
|
|
6463
|
-
rolePermissions:
|
|
6464
|
-
grants:
|
|
6465
|
-
userPermissions:
|
|
6466
|
-
userRoles:
|
|
6467
|
-
roles:
|
|
6468
|
-
sessions:
|
|
6469
|
-
sessionCleanup:
|
|
6470
|
-
tenants:
|
|
6471
|
-
tenantOperations:
|
|
6472
|
-
tenantOperationEvents:
|
|
6473
|
-
rollouts:
|
|
6474
|
-
themes:
|
|
6475
|
-
universalLoginTemplates:
|
|
6476
|
-
customText:
|
|
6477
|
-
users:
|
|
6478
|
-
userActivity:
|
|
6479
|
-
organizations:
|
|
6480
|
-
organizationConnections:
|
|
6481
|
-
userOrganizations:
|
|
6482
|
-
stats:
|
|
6483
|
-
analytics:
|
|
6484
|
-
outbox:
|
|
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),
|
|
6479
|
+
proxyRoutes: q(e),
|
|
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),
|
|
6485
6507
|
async transaction(r) {
|
|
6486
|
-
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, {
|
|
6487
6509
|
...t,
|
|
6488
6510
|
useTransactions: !1
|
|
6489
6511
|
})));
|
|
@@ -6492,4 +6514,4 @@ function ps(e, t = { useTransactions: !0 }) {
|
|
|
6492
6514
|
return n;
|
|
6493
6515
|
}
|
|
6494
6516
|
//#endregion
|
|
6495
|
-
export {
|
|
6517
|
+
export { $a as createProxyDataAdapter, q as createProxyRoutesAdapter, hs as default, ms as migrateDown, ps as migrateToLatest };
|