@authhero/kysely-adapter 12.2.0 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.d.ts +2 -0
- package/dist/kysely-adapter.mjs +950 -904
- package/dist/types/migrate/migrations/2026-08-11T12:00:00_page_hooks.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +2 -0
- package/dist/types/src/db.d.ts +2 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
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,
|
|
4
|
+
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildSessionRetention as g, clientGrantSchema as _, clientRegistrationTokenTypeSchema as v, codeSchema as y, decodeCursor as ee, emailTemplateSchema as te, encodeCursor as ne, flowSchema as b, formSchema as x, handlerConfigSchema as re, isPlainObject as ie, loginSessionSchema as ae, matchSchema as oe, migrationProviderTypeSchema as se, parseUserId as ce, resourceServerSchema as le, rolloutInsertSchema as ue, rolloutSchema as de, sanitizeLuceneQuery as S, scimMappingEntrySchema as fe, sessionRetentionWindow as pe, tenantOperationEventInsertSchema as me, tenantOperationEventSchema as he, tenantOperationInsertSchema as ge, tenantOperationSchema as _e } 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 ve } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var ye = Object.defineProperty, w = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) ye(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || ye(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, be = 17, xe = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -26,38 +26,38 @@ var he = 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", be)();
|
|
30
|
+
return `${xe[t]}${n}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Se() {
|
|
33
33
|
return T("organization");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Ce() {
|
|
36
36
|
return T("connection");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function we() {
|
|
39
39
|
return T("action");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Te() {
|
|
42
42
|
return T("action_version");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Ee() {
|
|
45
45
|
return T("hook");
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function De() {
|
|
48
48
|
return T("resource_server");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Oe() {
|
|
51
51
|
return T("hook_code");
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function ke() {
|
|
54
54
|
return T("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Ae(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 ?? we();
|
|
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 je(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 De(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Me(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) : Me(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 Ne(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 ke(e) {
|
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/actions/update.ts
|
|
251
|
-
function
|
|
251
|
+
function Pe(e) {
|
|
252
252
|
if (!e) return [];
|
|
253
253
|
try {
|
|
254
254
|
let t = JSON.parse(e);
|
|
@@ -257,11 +257,11 @@ function Ae(e) {
|
|
|
257
257
|
return [];
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Fe(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(Pe(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 je(e) {
|
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/actions/remove.ts
|
|
279
|
-
function
|
|
279
|
+
function Ie(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 Le(e) {
|
|
285
285
|
return {
|
|
286
|
-
create:
|
|
287
|
-
get:
|
|
288
|
-
list:
|
|
289
|
-
update:
|
|
290
|
-
remove:
|
|
286
|
+
create: Ae(e),
|
|
287
|
+
get: je(e),
|
|
288
|
+
list: Ne(e),
|
|
289
|
+
update: Fe(e),
|
|
290
|
+
remove: Ie(e)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/actionExecutions/create.ts
|
|
295
|
-
function
|
|
295
|
+
function Re(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 Pe(e) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/actionExecutions/get.ts
|
|
321
|
-
function
|
|
321
|
+
function ze(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 Be(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 Ie(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: ze(r.results) ?? [],
|
|
337
|
+
logs: ze(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 Ie(e) {
|
|
|
343
343
|
//#endregion
|
|
344
344
|
//#region src/actionExecutions/cleanup.ts
|
|
345
345
|
var A = 5e4;
|
|
346
|
-
async function
|
|
346
|
+
async function Ve(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 He(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 Ve(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 Re(e) {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/actionExecutions/index.ts
|
|
372
|
-
function
|
|
372
|
+
function Ue(e) {
|
|
373
373
|
return {
|
|
374
|
-
create:
|
|
375
|
-
get:
|
|
376
|
-
cleanup:
|
|
374
|
+
create: Re(e),
|
|
375
|
+
get: Be(e),
|
|
376
|
+
cleanup: He(e)
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/actionVersions/index.ts
|
|
381
|
-
function
|
|
381
|
+
function We(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 Ge(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: We(r),
|
|
395
|
+
dependencies: We(i),
|
|
396
|
+
supported_triggers: We(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 Ke(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 ?? Te(), 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 Ve(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 ? Ge(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(Ge);
|
|
445
445
|
if (!s) return {
|
|
446
446
|
versions: l,
|
|
447
447
|
start: 0,
|
|
@@ -464,7 +464,7 @@ function Ve(e) {
|
|
|
464
464
|
}
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/outbox/create.ts
|
|
467
|
-
async function
|
|
467
|
+
async function j(e, t, n, r) {
|
|
468
468
|
await e.insertInto("outbox_events").values({
|
|
469
469
|
id: n,
|
|
470
470
|
tenant_id: t,
|
|
@@ -483,15 +483,15 @@ async function M(e, t, n, r) {
|
|
|
483
483
|
error: null
|
|
484
484
|
}).execute();
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function qe(e) {
|
|
487
487
|
return async (n, r) => {
|
|
488
488
|
let i = t();
|
|
489
|
-
return await
|
|
489
|
+
return await j(e, n, i, r), i;
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/users/create.ts
|
|
494
|
-
function
|
|
494
|
+
function Je(e) {
|
|
495
495
|
return async (n, r, i) => {
|
|
496
496
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
497
497
|
...f,
|
|
@@ -526,7 +526,7 @@ function Ue(e) {
|
|
|
526
526
|
};
|
|
527
527
|
await e.insertInto("passwords").values(r).execute();
|
|
528
528
|
}
|
|
529
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await j(e, n, t.id, t);
|
|
530
530
|
};
|
|
531
531
|
try {
|
|
532
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
@@ -551,21 +551,21 @@ function Ue(e) {
|
|
|
551
551
|
}
|
|
552
552
|
//#endregion
|
|
553
553
|
//#region src/users/user-to-identity.ts
|
|
554
|
-
var
|
|
554
|
+
var Ye = [
|
|
555
555
|
"email",
|
|
556
556
|
"email_verified",
|
|
557
557
|
"phone_number",
|
|
558
558
|
"phone_verified",
|
|
559
559
|
"username"
|
|
560
560
|
];
|
|
561
|
-
function
|
|
561
|
+
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: ce(e.user_id).id,
|
|
566
566
|
isSocial: !!e.is_social
|
|
567
567
|
};
|
|
568
|
-
for (let t of
|
|
568
|
+
for (let t of Ye) 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 N(e, t = !1) {
|
|
|
583
583
|
}
|
|
584
584
|
//#endregion
|
|
585
585
|
//#region src/users/get.ts
|
|
586
|
-
function
|
|
586
|
+
function Xe(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",
|
|
@@ -605,21 +605,21 @@ function Ge(e) {
|
|
|
605
605
|
app_metadata: JSON.parse(r.app_metadata),
|
|
606
606
|
user_metadata: JSON.parse(r.user_metadata),
|
|
607
607
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
608
|
-
identities: [
|
|
608
|
+
identities: [M(r, !0), ...i.map((e) => M(e))]
|
|
609
609
|
});
|
|
610
610
|
};
|
|
611
611
|
}
|
|
612
612
|
//#endregion
|
|
613
613
|
//#region src/helpers/paginate.ts
|
|
614
|
-
function
|
|
614
|
+
function N(e) {
|
|
615
615
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function Ze(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
|
-
async function
|
|
622
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
621
|
+
async function P(e, t, n) {
|
|
622
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = Ze(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? ee(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 F(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 = ne({
|
|
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 F(e, t, n) {
|
|
|
643
643
|
}
|
|
644
644
|
//#endregion
|
|
645
645
|
//#region src/users/list.ts
|
|
646
|
-
var
|
|
646
|
+
var Qe = [
|
|
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
|
+
], $e = new Set([
|
|
670
670
|
"last_login",
|
|
671
671
|
"last_ip",
|
|
672
672
|
"login_count"
|
|
673
|
-
]),
|
|
673
|
+
]), et = Object.fromEntries(Qe.map((e) => [e, e === "login_count" ? {
|
|
674
674
|
column: "user_activity.login_count",
|
|
675
675
|
defaultValue: 0
|
|
676
|
-
} :
|
|
676
|
+
} : $e.has(e) ? `user_activity.${e}` : `users.${e}`])), tt = [
|
|
677
677
|
"email",
|
|
678
678
|
"name",
|
|
679
679
|
"phone_number",
|
|
680
680
|
"user_id"
|
|
681
681
|
];
|
|
682
|
-
async function
|
|
682
|
+
async function nt(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);
|
|
@@ -693,20 +693,20 @@ async function Ze(e, t, n) {
|
|
|
693
693
|
app_metadata: JSON.parse(e.app_metadata),
|
|
694
694
|
user_metadata: JSON.parse(e.user_metadata),
|
|
695
695
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
696
|
-
identities: [
|
|
696
|
+
identities: [M(e, !0), ...t.map((e) => M(e))]
|
|
697
697
|
});
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function rt(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, Qe);
|
|
705
|
+
t && (l = O(e, l, t, tt, [], et));
|
|
706
706
|
}
|
|
707
|
-
if (
|
|
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` });
|
|
709
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
709
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await P(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
710
710
|
"user_activity.last_login",
|
|
711
711
|
"user_activity.last_ip",
|
|
712
712
|
"user_activity.login_count"
|
|
@@ -715,7 +715,7 @@ function Qe(e) {
|
|
|
715
715
|
sortOrder: r,
|
|
716
716
|
idColumn: "users.user_id",
|
|
717
717
|
sortKey: `created_at:${r}`
|
|
718
|
-
}), c = await
|
|
718
|
+
}), c = await nt(e, t, i);
|
|
719
719
|
return {
|
|
720
720
|
users: c,
|
|
721
721
|
start: 0,
|
|
@@ -725,13 +725,13 @@ function Qe(e) {
|
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
727
|
if (s && s.sort_by) {
|
|
728
|
-
let t =
|
|
728
|
+
let t = et[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) : Me(t), s.sort_order);
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
let u = await
|
|
734
|
+
let u = await nt(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,12 +753,12 @@ function Qe(e) {
|
|
|
753
753
|
}
|
|
754
754
|
//#endregion
|
|
755
755
|
//#region src/users/remove.ts
|
|
756
|
-
function
|
|
756
|
+
function it(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();
|
|
760
760
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
761
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
761
|
+
for (let n of r?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
762
762
|
return i.length === 1;
|
|
763
763
|
};
|
|
764
764
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -766,14 +766,14 @@ function $e(e) {
|
|
|
766
766
|
}
|
|
767
767
|
//#endregion
|
|
768
768
|
//#region src/utils/flatten.ts
|
|
769
|
-
function
|
|
769
|
+
function F(e, t = "", n = {}) {
|
|
770
770
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
771
771
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
772
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
772
|
+
typeof a == "object" && a && !Array.isArray(a) ? F(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
773
773
|
}
|
|
774
774
|
return n;
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function at(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 et(e, t) {
|
|
|
790
790
|
}
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region src/userActivity/index.ts
|
|
793
|
-
function
|
|
793
|
+
function ot(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 tt(e) {
|
|
|
800
800
|
last_password_reset: e.last_password_reset ?? void 0
|
|
801
801
|
};
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function st(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 ct(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 ? ot(r) : null;
|
|
812
812
|
},
|
|
813
813
|
async upsert(t, n, r) {
|
|
814
|
-
let i =
|
|
814
|
+
let i = st(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,9 +833,9 @@ function rt(e) {
|
|
|
833
833
|
}
|
|
834
834
|
//#endregion
|
|
835
835
|
//#region src/users/update.ts
|
|
836
|
-
function
|
|
836
|
+
function lt(e) {
|
|
837
837
|
return async (t, n, r, i) => {
|
|
838
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
838
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = F({
|
|
839
839
|
...c,
|
|
840
840
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
841
841
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -846,12 +846,12 @@ function it(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 ct(e).upsert(t, n, {
|
|
850
850
|
last_login: a,
|
|
851
851
|
last_ip: o,
|
|
852
852
|
login_count: s
|
|
853
853
|
});
|
|
854
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
854
|
+
for (let n of i?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
855
855
|
return !0;
|
|
856
856
|
};
|
|
857
857
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -859,26 +859,26 @@ function it(e) {
|
|
|
859
859
|
}
|
|
860
860
|
//#endregion
|
|
861
861
|
//#region src/users/unlink.ts
|
|
862
|
-
function
|
|
862
|
+
function ut(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 dt(e) {
|
|
868
|
+
let t = Je(e);
|
|
869
869
|
return {
|
|
870
870
|
create: t,
|
|
871
871
|
rawCreate: t,
|
|
872
|
-
remove:
|
|
873
|
-
get:
|
|
874
|
-
list:
|
|
875
|
-
update:
|
|
876
|
-
unlink:
|
|
872
|
+
remove: it(e),
|
|
873
|
+
get: Xe(e),
|
|
874
|
+
list: rt(e),
|
|
875
|
+
update: lt(e),
|
|
876
|
+
unlink: ut(e)
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
879
|
//#endregion
|
|
880
880
|
//#region src/flows/create.ts
|
|
881
|
-
function
|
|
881
|
+
function ft(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()}`,
|
|
@@ -896,7 +896,7 @@ function st(e) {
|
|
|
896
896
|
}
|
|
897
897
|
//#endregion
|
|
898
898
|
//#region src/helpers/parse.ts
|
|
899
|
-
function
|
|
899
|
+
function I(e, t) {
|
|
900
900
|
if (!e) return t;
|
|
901
901
|
try {
|
|
902
902
|
return JSON.parse(e);
|
|
@@ -904,7 +904,7 @@ function L(e, t) {
|
|
|
904
904
|
return t;
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function pt(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,33 +912,33 @@ function ct(e) {
|
|
|
912
912
|
return;
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
function
|
|
916
|
-
for (let r in t) r in e && (n[r] =
|
|
915
|
+
function mt(e, t, n = { ...e }) {
|
|
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 ht(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;
|
|
925
925
|
let i = {
|
|
926
926
|
...r,
|
|
927
|
-
actions:
|
|
927
|
+
actions: I(r.actions, [])
|
|
928
928
|
};
|
|
929
929
|
return b.parse(l(i));
|
|
930
930
|
};
|
|
931
931
|
}
|
|
932
932
|
//#endregion
|
|
933
933
|
//#region src/flows/list.ts
|
|
934
|
-
function
|
|
934
|
+
function gt(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, []));
|
|
938
938
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
939
939
|
let t = {
|
|
940
940
|
...e,
|
|
941
|
-
actions:
|
|
941
|
+
actions: I(e.actions, [])
|
|
942
942
|
};
|
|
943
943
|
return b.parse(l(t));
|
|
944
944
|
});
|
|
@@ -959,7 +959,7 @@ function dt(e) {
|
|
|
959
959
|
}
|
|
960
960
|
//#endregion
|
|
961
961
|
//#region src/flows/update.ts
|
|
962
|
-
function
|
|
962
|
+
function _t(e) {
|
|
963
963
|
return async (t, n, r) => {
|
|
964
964
|
let i = {
|
|
965
965
|
...r,
|
|
@@ -977,27 +977,27 @@ function ft(e) {
|
|
|
977
977
|
}
|
|
978
978
|
//#endregion
|
|
979
979
|
//#region src/flows/remove.ts
|
|
980
|
-
function
|
|
980
|
+
function vt(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 yt(e) {
|
|
986
986
|
return {
|
|
987
|
-
create:
|
|
988
|
-
get:
|
|
989
|
-
list:
|
|
990
|
-
update:
|
|
991
|
-
remove:
|
|
987
|
+
create: ft(e),
|
|
988
|
+
get: ht(e),
|
|
989
|
+
list: gt(e),
|
|
990
|
+
update: _t(e),
|
|
991
|
+
remove: vt(e)
|
|
992
992
|
};
|
|
993
993
|
}
|
|
994
994
|
//#endregion
|
|
995
995
|
//#region src/tenants/utils.ts
|
|
996
|
-
function
|
|
996
|
+
function bt(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 xt(e) {
|
|
1001
1001
|
let t = { ...e };
|
|
1002
1002
|
return d(e, [
|
|
1003
1003
|
"session_cookie",
|
|
@@ -1020,14 +1020,14 @@ function gt(e) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
//#endregion
|
|
1022
1022
|
//#region src/tenants/create.ts
|
|
1023
|
-
function
|
|
1023
|
+
function St(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 = xt(o);
|
|
1031
1031
|
try {
|
|
1032
1032
|
await e.insertInto("tenants").values(s).execute();
|
|
1033
1033
|
} catch (e) {
|
|
@@ -1039,15 +1039,15 @@ function _t(e) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
//#endregion
|
|
1041
1041
|
//#region src/tenants/get.ts
|
|
1042
|
-
function
|
|
1042
|
+
function Ct(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 ? bt(n) : null;
|
|
1046
1046
|
};
|
|
1047
1047
|
}
|
|
1048
1048
|
//#endregion
|
|
1049
1049
|
//#region src/tenants/list.ts
|
|
1050
|
-
function
|
|
1050
|
+
function wt(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 yt(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(bt);
|
|
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 yt(e) {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
//#endregion
|
|
1070
1070
|
//#region src/tenants/update.ts
|
|
1071
|
-
function
|
|
1071
|
+
function Tt(e) {
|
|
1072
1072
|
return async (t, n) => {
|
|
1073
1073
|
let r = {
|
|
1074
|
-
...
|
|
1074
|
+
...xt(n),
|
|
1075
1075
|
id: t,
|
|
1076
1076
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1077
1077
|
};
|
|
@@ -1080,29 +1080,29 @@ function bt(e) {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
//#endregion
|
|
1082
1082
|
//#region src/tenants/remove.ts
|
|
1083
|
-
function
|
|
1083
|
+
function Et(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 Dt(e) {
|
|
1089
1089
|
return {
|
|
1090
|
-
create:
|
|
1091
|
-
get:
|
|
1092
|
-
list:
|
|
1093
|
-
update:
|
|
1094
|
-
remove:
|
|
1090
|
+
create: St(e),
|
|
1091
|
+
get: Ct(e),
|
|
1092
|
+
list: wt(e),
|
|
1093
|
+
update: Tt(e),
|
|
1094
|
+
remove: Et(e)
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
1097
1097
|
//#endregion
|
|
1098
1098
|
//#region src/logs/create.ts
|
|
1099
|
-
function
|
|
1099
|
+
function Ot(e) {
|
|
1100
1100
|
return e ? JSON.stringify(e) : void 0;
|
|
1101
1101
|
}
|
|
1102
|
-
var
|
|
1103
|
-
function
|
|
1102
|
+
var kt = 256;
|
|
1103
|
+
function At(e) {
|
|
1104
1104
|
return async (n, r) => {
|
|
1105
|
-
let i = r.user_agent?.slice(0,
|
|
1105
|
+
let i = r.user_agent?.slice(0, kt), 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 Tt(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: Ot(r.auth0_client),
|
|
1115
|
+
details: Ot(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 Tt(e) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
//#endregion
|
|
1130
1130
|
//#region src/logs/logs.ts
|
|
1131
|
-
function
|
|
1131
|
+
function jt(e) {
|
|
1132
1132
|
if (!e) return "";
|
|
1133
1133
|
try {
|
|
1134
1134
|
return JSON.parse(e);
|
|
@@ -1136,13 +1136,13 @@ function Et(e) {
|
|
|
1136
1136
|
return e;
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
function
|
|
1139
|
+
function L(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: jt(e.auth0_client),
|
|
1145
|
+
details: jt(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 Dt(e) {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
//#endregion
|
|
1160
1160
|
//#region src/logs/list.ts
|
|
1161
|
-
var
|
|
1161
|
+
var Mt = [
|
|
1162
1162
|
"user_id",
|
|
1163
1163
|
"ip",
|
|
1164
1164
|
"type",
|
|
@@ -1184,25 +1184,25 @@ var Ot = [
|
|
|
1184
1184
|
"time_zone",
|
|
1185
1185
|
"continent_code"
|
|
1186
1186
|
];
|
|
1187
|
-
function
|
|
1187
|
+
function Nt(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, Mt);
|
|
1192
1192
|
t && (d = O(e, d, t, [
|
|
1193
1193
|
"user_id",
|
|
1194
1194
|
"ip",
|
|
1195
1195
|
"description"
|
|
1196
1196
|
], ["description"]));
|
|
1197
1197
|
}
|
|
1198
|
-
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())),
|
|
1198
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), N(n)) {
|
|
1199
1199
|
if (s?.sort_by && s.sort_by !== "date") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1200
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1200
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await P(d.selectAll(), n, {
|
|
1201
1201
|
sortColumn: "date",
|
|
1202
1202
|
sortOrder: e,
|
|
1203
1203
|
idColumn: "log_id",
|
|
1204
1204
|
sortKey: `date:${e}`
|
|
1205
|
-
}), a = t.map(
|
|
1205
|
+
}), a = t.map(L);
|
|
1206
1206
|
return {
|
|
1207
1207
|
logs: a,
|
|
1208
1208
|
start: 0,
|
|
@@ -1217,7 +1217,7 @@ function kt(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(L);
|
|
1221
1221
|
if (!a) return {
|
|
1222
1222
|
logs: p,
|
|
1223
1223
|
start: 0,
|
|
@@ -1235,24 +1235,24 @@ function kt(e) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
//#endregion
|
|
1237
1237
|
//#region src/logs/get.ts
|
|
1238
|
-
function
|
|
1238
|
+
function Pt(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 ? L(r) : null;
|
|
1242
1242
|
};
|
|
1243
1243
|
}
|
|
1244
1244
|
//#endregion
|
|
1245
1245
|
//#region src/logs/index.ts
|
|
1246
|
-
function
|
|
1246
|
+
function Ft(e) {
|
|
1247
1247
|
return {
|
|
1248
|
-
create:
|
|
1249
|
-
list:
|
|
1250
|
-
get:
|
|
1248
|
+
create: At(e),
|
|
1249
|
+
list: Nt(e),
|
|
1250
|
+
get: Pt(e)
|
|
1251
1251
|
};
|
|
1252
1252
|
}
|
|
1253
1253
|
//#endregion
|
|
1254
1254
|
//#region src/sessions/get.ts
|
|
1255
|
-
function
|
|
1255
|
+
function It(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 Mt(e) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
//#endregion
|
|
1288
1288
|
//#region src/sessions/create.ts
|
|
1289
|
-
function
|
|
1289
|
+
function Lt(e) {
|
|
1290
1290
|
return async (t, n) => {
|
|
1291
1291
|
let r = Date.now(), i = c(), a = {
|
|
1292
1292
|
...n,
|
|
@@ -1318,12 +1318,12 @@ function Nt(e) {
|
|
|
1318
1318
|
}
|
|
1319
1319
|
//#endregion
|
|
1320
1320
|
//#region src/sessions/remove.ts
|
|
1321
|
-
function
|
|
1321
|
+
function Rt(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 zt(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 Ft(e) {
|
|
|
1344
1344
|
}
|
|
1345
1345
|
//#endregion
|
|
1346
1346
|
//#region src/sessions/list.ts
|
|
1347
|
-
function
|
|
1347
|
+
function Bt(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 It(e) {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
//#endregion
|
|
1401
1401
|
//#region src/sessions/index.ts
|
|
1402
|
-
function
|
|
1402
|
+
function Vt(e) {
|
|
1403
1403
|
return {
|
|
1404
|
-
create:
|
|
1405
|
-
get:
|
|
1406
|
-
list:
|
|
1407
|
-
remove:
|
|
1408
|
-
update:
|
|
1404
|
+
create: Lt(e),
|
|
1405
|
+
get: It(e),
|
|
1406
|
+
list: Bt(e),
|
|
1407
|
+
remove: Rt(e),
|
|
1408
|
+
update: zt(e)
|
|
1409
1409
|
};
|
|
1410
1410
|
}
|
|
1411
1411
|
//#endregion
|
|
1412
1412
|
//#region src/passwords/get.ts
|
|
1413
|
-
function
|
|
1413
|
+
function Ht(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 Rt(e) {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
//#endregion
|
|
1425
1425
|
//#region src/passwords/create.ts
|
|
1426
|
-
function
|
|
1426
|
+
function Ut(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 zt(e) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
//#endregion
|
|
1443
1443
|
//#region src/passwords/update.ts
|
|
1444
|
-
function
|
|
1444
|
+
function Wt(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 Bt(e) {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
//#endregion
|
|
1456
1456
|
//#region src/passwords/list.ts
|
|
1457
|
-
function
|
|
1457
|
+
function Gt(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 Vt(e) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
//#endregion
|
|
1467
1467
|
//#region src/passwords/index.ts
|
|
1468
|
-
function
|
|
1468
|
+
function Kt(e) {
|
|
1469
1469
|
return {
|
|
1470
|
-
create:
|
|
1471
|
-
update:
|
|
1472
|
-
get:
|
|
1473
|
-
list:
|
|
1470
|
+
create: Ut(e),
|
|
1471
|
+
update: Wt(e),
|
|
1472
|
+
get: Ht(e),
|
|
1473
|
+
list: Gt(e)
|
|
1474
1474
|
};
|
|
1475
1475
|
}
|
|
1476
1476
|
//#endregion
|
|
1477
1477
|
//#region src/codes/list.ts
|
|
1478
|
-
function
|
|
1478
|
+
function qt(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 y.parse(l(n));
|
|
1485
1485
|
});
|
|
1486
1486
|
if (!a) return {
|
|
1487
1487
|
codes: u,
|
|
@@ -1500,13 +1500,13 @@ function Ut(e) {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
//#endregion
|
|
1502
1502
|
//#region src/codes/expires-at-ts.ts
|
|
1503
|
-
function
|
|
1503
|
+
function Jt(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 Yt(e) {
|
|
1510
1510
|
return async (t, n) => {
|
|
1511
1511
|
let r = {
|
|
1512
1512
|
...n,
|
|
@@ -1515,18 +1515,18 @@ function Gt(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: Jt(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 Xt(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 Zt(e) {
|
|
1530
1530
|
return async (t, n, r) => {
|
|
1531
1531
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1532
1532
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1536,44 +1536,44 @@ function qt(e) {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
//#endregion
|
|
1538
1538
|
//#region src/codes/used.ts
|
|
1539
|
-
function
|
|
1539
|
+
function Qt(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 $t(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 en(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", "<", Jt(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 tn(e) {
|
|
1558
1558
|
return {
|
|
1559
|
-
create:
|
|
1560
|
-
list:
|
|
1561
|
-
remove:
|
|
1562
|
-
used:
|
|
1563
|
-
consume:
|
|
1564
|
-
get:
|
|
1565
|
-
cleanup:
|
|
1559
|
+
create: Yt(e),
|
|
1560
|
+
list: qt(e),
|
|
1561
|
+
remove: Xt(e),
|
|
1562
|
+
used: Qt(e),
|
|
1563
|
+
consume: $t(e),
|
|
1564
|
+
get: Zt(e),
|
|
1565
|
+
cleanup: en(e)
|
|
1566
1566
|
};
|
|
1567
1567
|
}
|
|
1568
1568
|
//#endregion
|
|
1569
1569
|
//#region src/connections/create.ts
|
|
1570
|
-
function
|
|
1570
|
+
function nn(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 ?? Ce(),
|
|
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 Qt(e) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
//#endregion
|
|
1590
1590
|
//#region src/connections/transform.ts
|
|
1591
|
-
function
|
|
1591
|
+
function R(e) {
|
|
1592
1592
|
let { is_system: t, ...n } = e;
|
|
1593
1593
|
return l({
|
|
1594
1594
|
...n,
|
|
@@ -1596,16 +1596,16 @@ function $t(e) {
|
|
|
1596
1596
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1597
1597
|
});
|
|
1598
1598
|
}
|
|
1599
|
-
function
|
|
1600
|
-
return e.map(
|
|
1599
|
+
function rn(e) {
|
|
1600
|
+
return e.map(R);
|
|
1601
1601
|
}
|
|
1602
1602
|
//#endregion
|
|
1603
1603
|
//#region src/connections/list.ts
|
|
1604
|
-
function
|
|
1604
|
+
function an(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 = rn(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 tn(e) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region src/connections/remove.ts
|
|
1626
|
-
function
|
|
1626
|
+
function on(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 sn(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 ? R(r) : null;
|
|
1635
1635
|
};
|
|
1636
1636
|
}
|
|
1637
1637
|
//#endregion
|
|
1638
1638
|
//#region src/connections/update.ts
|
|
1639
|
-
function
|
|
1639
|
+
function cn(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 an(e) {
|
|
|
1653
1653
|
}
|
|
1654
1654
|
//#endregion
|
|
1655
1655
|
//#region src/connections/index.ts
|
|
1656
|
-
function
|
|
1656
|
+
function ln(e) {
|
|
1657
1657
|
return {
|
|
1658
|
-
create:
|
|
1659
|
-
get:
|
|
1660
|
-
list:
|
|
1661
|
-
remove:
|
|
1662
|
-
update:
|
|
1658
|
+
create: nn(e),
|
|
1659
|
+
get: sn(e),
|
|
1660
|
+
list: an(e),
|
|
1661
|
+
remove: on(e),
|
|
1662
|
+
update: cn(e)
|
|
1663
1663
|
};
|
|
1664
1664
|
}
|
|
1665
1665
|
//#endregion
|
|
1666
1666
|
//#region src/clients/create.ts
|
|
1667
|
-
function
|
|
1667
|
+
function un(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 sn(e) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
//#endregion
|
|
1731
1731
|
//#region src/clients/get.ts
|
|
1732
|
-
function
|
|
1732
|
+
function dn(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 cn(e) {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
//#endregion
|
|
1777
1777
|
//#region src/clients/getByClientId.ts
|
|
1778
|
-
function
|
|
1778
|
+
function fn(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 ln(e) {
|
|
|
1819
1819
|
}
|
|
1820
1820
|
//#endregion
|
|
1821
1821
|
//#region src/clients/list.ts
|
|
1822
|
-
function
|
|
1822
|
+
function pn(e) {
|
|
1823
1823
|
return l({
|
|
1824
1824
|
...e,
|
|
1825
1825
|
global: !!e.global,
|
|
@@ -1858,7 +1858,7 @@ function un(e) {
|
|
|
1858
1858
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1859
1859
|
});
|
|
1860
1860
|
}
|
|
1861
|
-
function
|
|
1861
|
+
function mn(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) {
|
|
@@ -1868,12 +1868,12 @@ function dn(e) {
|
|
|
1868
1868
|
r = r.where(t, "=", e[2]);
|
|
1869
1869
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1870
1870
|
}
|
|
1871
|
-
if (
|
|
1872
|
-
let { rows: e, limit: t, next: i } = await
|
|
1871
|
+
if (N(n)) {
|
|
1872
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
1873
1873
|
sortColumn: "created_at",
|
|
1874
1874
|
sortOrder: "desc",
|
|
1875
1875
|
idColumn: "client_id"
|
|
1876
|
-
}), a = e.map(
|
|
1876
|
+
}), a = e.map(pn);
|
|
1877
1877
|
return {
|
|
1878
1878
|
clients: a,
|
|
1879
1879
|
totals: {
|
|
@@ -1906,7 +1906,7 @@ function dn(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(pn);
|
|
1910
1910
|
return {
|
|
1911
1911
|
clients: l,
|
|
1912
1912
|
totals: {
|
|
@@ -1920,12 +1920,12 @@ function dn(e) {
|
|
|
1920
1920
|
}
|
|
1921
1921
|
//#endregion
|
|
1922
1922
|
//#region src/clients/remove.ts
|
|
1923
|
-
function
|
|
1923
|
+
function hn(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 gn(e) {
|
|
1929
1929
|
return async (t, r, i) => {
|
|
1930
1930
|
let a = {
|
|
1931
1931
|
...i,
|
|
@@ -1972,31 +1972,31 @@ function pn(e) {
|
|
|
1972
1972
|
}
|
|
1973
1973
|
//#endregion
|
|
1974
1974
|
//#region src/clients/index.ts
|
|
1975
|
-
function
|
|
1975
|
+
function _n(e) {
|
|
1976
1976
|
return {
|
|
1977
|
-
create:
|
|
1978
|
-
get:
|
|
1979
|
-
getByClientId:
|
|
1980
|
-
list:
|
|
1981
|
-
remove:
|
|
1982
|
-
update:
|
|
1977
|
+
create: un(e),
|
|
1978
|
+
get: dn(e),
|
|
1979
|
+
getByClientId: fn(e),
|
|
1980
|
+
list: mn(e),
|
|
1981
|
+
remove: hn(e),
|
|
1982
|
+
update: gn(e)
|
|
1983
1983
|
};
|
|
1984
1984
|
}
|
|
1985
1985
|
//#endregion
|
|
1986
1986
|
//#region src/clientConnections/listByClient.ts
|
|
1987
|
-
function
|
|
1987
|
+
function vn(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, R(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 yn(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 gn(e) {
|
|
|
2004
2004
|
}
|
|
2005
2005
|
//#endregion
|
|
2006
2006
|
//#region src/clientConnections/listByConnection.ts
|
|
2007
|
-
function
|
|
2007
|
+
function bn(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 _n(e) {
|
|
|
2013
2013
|
}
|
|
2014
2014
|
//#endregion
|
|
2015
2015
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2016
|
-
function
|
|
2016
|
+
function xn(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 vn(e) {
|
|
|
2026
2026
|
}
|
|
2027
2027
|
//#endregion
|
|
2028
2028
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2029
|
-
function
|
|
2029
|
+
function Sn(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 yn(e) {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
//#endregion
|
|
2041
2041
|
//#region src/clientConnections/index.ts
|
|
2042
|
-
function
|
|
2042
|
+
function Cn(e) {
|
|
2043
2043
|
return {
|
|
2044
|
-
listByClient:
|
|
2045
|
-
updateByClient:
|
|
2046
|
-
listByConnection:
|
|
2047
|
-
addClientToConnection:
|
|
2048
|
-
removeClientFromConnection:
|
|
2044
|
+
listByClient: vn(e),
|
|
2045
|
+
updateByClient: yn(e),
|
|
2046
|
+
listByConnection: bn(e),
|
|
2047
|
+
addClientToConnection: xn(e),
|
|
2048
|
+
removeClientFromConnection: Sn(e)
|
|
2049
2049
|
};
|
|
2050
2050
|
}
|
|
2051
2051
|
//#endregion
|
|
2052
2052
|
//#region src/clientGrants/create.ts
|
|
2053
|
-
function
|
|
2053
|
+
function wn(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 xn(e) {
|
|
|
2078
2078
|
}
|
|
2079
2079
|
//#endregion
|
|
2080
2080
|
//#region src/clientGrants/get.ts
|
|
2081
|
-
function
|
|
2081
|
+
function Tn(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 Sn(e) {
|
|
|
2098
2098
|
}
|
|
2099
2099
|
//#endregion
|
|
2100
2100
|
//#region src/clientGrants/list.ts
|
|
2101
|
-
function
|
|
2102
|
-
return
|
|
2101
|
+
function En(e) {
|
|
2102
|
+
return _.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 Cn(e) {
|
|
|
2107
2107
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2108
2108
|
}));
|
|
2109
2109
|
}
|
|
2110
|
-
function
|
|
2110
|
+
function Dn(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) {
|
|
@@ -2120,11 +2120,11 @@ function wn(e) {
|
|
|
2120
2120
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2121
2121
|
} else l = O(e, l, t, []);
|
|
2122
2122
|
}
|
|
2123
|
-
if (
|
|
2124
|
-
let { rows: e, limit: t, next: r } = await
|
|
2123
|
+
if (N(n)) {
|
|
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(En);
|
|
2128
2128
|
return {
|
|
2129
2129
|
client_grants: i,
|
|
2130
2130
|
start: 0,
|
|
@@ -2138,7 +2138,7 @@ function wn(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(En);
|
|
2142
2142
|
if (!a) return {
|
|
2143
2143
|
client_grants: d,
|
|
2144
2144
|
start: 0,
|
|
@@ -2156,12 +2156,12 @@ function wn(e) {
|
|
|
2156
2156
|
}
|
|
2157
2157
|
//#endregion
|
|
2158
2158
|
//#region src/clientGrants/remove.ts
|
|
2159
|
-
function
|
|
2159
|
+
function On(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 kn(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 En(e) {
|
|
|
2172
2172
|
}
|
|
2173
2173
|
//#endregion
|
|
2174
2174
|
//#region src/clientGrants/index.ts
|
|
2175
|
-
function
|
|
2175
|
+
function An(e) {
|
|
2176
2176
|
return {
|
|
2177
|
-
create:
|
|
2178
|
-
get:
|
|
2179
|
-
list:
|
|
2180
|
-
remove:
|
|
2181
|
-
update:
|
|
2177
|
+
create: wn(e),
|
|
2178
|
+
get: Tn(e),
|
|
2179
|
+
list: Dn(e),
|
|
2180
|
+
remove: On(e),
|
|
2181
|
+
update: kn(e)
|
|
2182
2182
|
};
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/clientRegistrationTokens/create.ts
|
|
2186
|
-
function
|
|
2186
|
+
function jn(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 On(e) {
|
|
|
2214
2214
|
}
|
|
2215
2215
|
//#endregion
|
|
2216
2216
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2217
|
-
function
|
|
2218
|
-
let t =
|
|
2217
|
+
function Mn(e) {
|
|
2218
|
+
let t = v.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 Nn(e) {
|
|
2223
2223
|
if (!e) return;
|
|
2224
2224
|
let t;
|
|
2225
2225
|
try {
|
|
@@ -2227,16 +2227,16 @@ function An(e) {
|
|
|
2227
2227
|
} catch {
|
|
2228
2228
|
return;
|
|
2229
2229
|
}
|
|
2230
|
-
return
|
|
2230
|
+
return ie(t) ? t : void 0;
|
|
2231
2231
|
}
|
|
2232
|
-
function
|
|
2232
|
+
function z(e) {
|
|
2233
2233
|
return {
|
|
2234
2234
|
id: e.id,
|
|
2235
2235
|
token_hash: e.token_hash,
|
|
2236
|
-
type:
|
|
2236
|
+
type: Mn(e.type),
|
|
2237
2237
|
client_id: e.client_id ?? void 0,
|
|
2238
2238
|
sub: e.sub ?? void 0,
|
|
2239
|
-
constraints:
|
|
2239
|
+
constraints: Nn(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 R(e) {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/clientRegistrationTokens/get.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Pn(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 ? z(r) : null;
|
|
2253
2253
|
};
|
|
2254
2254
|
}
|
|
2255
2255
|
//#endregion
|
|
2256
2256
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2257
|
-
function
|
|
2257
|
+
function Fn(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 ? z(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 In(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(z);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2270
|
-
function
|
|
2270
|
+
function Ln(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 Rn(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 zn(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 In(e) {
|
|
|
2285
2285
|
}
|
|
2286
2286
|
//#endregion
|
|
2287
2287
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2288
|
-
function
|
|
2288
|
+
function Bn(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 Vn(e) {
|
|
2294
2294
|
return {
|
|
2295
|
-
create:
|
|
2296
|
-
get:
|
|
2297
|
-
getByHash:
|
|
2298
|
-
listByClient:
|
|
2299
|
-
markUsed:
|
|
2300
|
-
revoke:
|
|
2301
|
-
revokeByClient:
|
|
2302
|
-
remove:
|
|
2295
|
+
create: jn(e),
|
|
2296
|
+
get: Pn(e),
|
|
2297
|
+
getByHash: Fn(e),
|
|
2298
|
+
listByClient: In(e),
|
|
2299
|
+
markUsed: Ln(e),
|
|
2300
|
+
revoke: Rn(e),
|
|
2301
|
+
revokeByClient: zn(e),
|
|
2302
|
+
remove: Bn(e)
|
|
2303
2303
|
};
|
|
2304
2304
|
}
|
|
2305
2305
|
//#endregion
|
|
2306
2306
|
//#region src/keys/list.ts
|
|
2307
|
-
function
|
|
2307
|
+
function Hn(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 zn(e) {
|
|
|
2333
2333
|
}
|
|
2334
2334
|
//#endregion
|
|
2335
2335
|
//#region src/keys/create.ts
|
|
2336
|
-
function
|
|
2336
|
+
function Un(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 Bn(e) {
|
|
|
2345
2345
|
}
|
|
2346
2346
|
//#endregion
|
|
2347
2347
|
//#region src/keys/update.ts
|
|
2348
|
-
function
|
|
2348
|
+
function Wn(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 Gn(e) {
|
|
2354
2354
|
return {
|
|
2355
|
-
create:
|
|
2356
|
-
list:
|
|
2357
|
-
update:
|
|
2355
|
+
create: Un(e),
|
|
2356
|
+
list: Hn(e),
|
|
2357
|
+
update: Wn(e)
|
|
2358
2358
|
};
|
|
2359
2359
|
}
|
|
2360
2360
|
//#endregion
|
|
2361
2361
|
//#region src/customDomains/create.ts
|
|
2362
|
-
function
|
|
2362
|
+
function Kn(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,35 +2379,35 @@ function Un(e) {
|
|
|
2379
2379
|
}
|
|
2380
2380
|
//#endregion
|
|
2381
2381
|
//#region src/customDomains/list.ts
|
|
2382
|
-
function
|
|
2382
|
+
function qn(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,
|
|
2386
|
-
domain_metadata:
|
|
2387
|
-
verification:
|
|
2386
|
+
domain_metadata: I(e.domain_metadata, void 0),
|
|
2387
|
+
verification: I(e.verification, void 0)
|
|
2388
2388
|
}));
|
|
2389
2389
|
}
|
|
2390
2390
|
//#endregion
|
|
2391
2391
|
//#region src/customDomains/remove.ts
|
|
2392
|
-
function
|
|
2392
|
+
function Jn(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 Yn(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 ? {
|
|
2401
2401
|
...r,
|
|
2402
2402
|
primary: r.primary === 1,
|
|
2403
|
-
domain_metadata:
|
|
2404
|
-
verification:
|
|
2403
|
+
domain_metadata: I(r.domain_metadata, void 0),
|
|
2404
|
+
verification: I(r.verification, void 0)
|
|
2405
2405
|
} : null;
|
|
2406
2406
|
};
|
|
2407
2407
|
}
|
|
2408
2408
|
//#endregion
|
|
2409
2409
|
//#region src/customDomains/update.ts
|
|
2410
|
-
function
|
|
2410
|
+
function Xn(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,31 +2421,31 @@ function qn(e) {
|
|
|
2421
2421
|
}
|
|
2422
2422
|
//#endregion
|
|
2423
2423
|
//#region src/customDomains/getByDomain.ts
|
|
2424
|
-
function
|
|
2424
|
+
function Zn(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 ? {
|
|
2428
2428
|
...n,
|
|
2429
2429
|
primary: n.primary === 1,
|
|
2430
|
-
domain_metadata:
|
|
2430
|
+
domain_metadata: I(n.domain_metadata, void 0)
|
|
2431
2431
|
} : null;
|
|
2432
2432
|
};
|
|
2433
2433
|
}
|
|
2434
2434
|
//#endregion
|
|
2435
2435
|
//#region src/customDomains/index.ts
|
|
2436
|
-
function
|
|
2436
|
+
function Qn(e) {
|
|
2437
2437
|
return {
|
|
2438
|
-
create:
|
|
2439
|
-
get:
|
|
2440
|
-
getByDomain:
|
|
2441
|
-
list:
|
|
2442
|
-
remove:
|
|
2443
|
-
update:
|
|
2438
|
+
create: Kn(e),
|
|
2439
|
+
get: Yn(e),
|
|
2440
|
+
getByDomain: Zn(e),
|
|
2441
|
+
list: qn(e),
|
|
2442
|
+
remove: Jn(e),
|
|
2443
|
+
update: Xn(e)
|
|
2444
2444
|
};
|
|
2445
2445
|
}
|
|
2446
2446
|
//#endregion
|
|
2447
2447
|
//#region src/branding/get.ts
|
|
2448
|
-
function
|
|
2448
|
+
function $n(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 Xn(e) {
|
|
|
2467
2467
|
}
|
|
2468
2468
|
//#endregion
|
|
2469
2469
|
//#region src/branding/set.ts
|
|
2470
|
-
function
|
|
2470
|
+
function er(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 Zn(e) {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
//#endregion
|
|
2498
2498
|
//#region src/branding/index.ts
|
|
2499
|
-
function
|
|
2499
|
+
function tr(e) {
|
|
2500
2500
|
return {
|
|
2501
|
-
get:
|
|
2502
|
-
set:
|
|
2501
|
+
get: $n(e),
|
|
2502
|
+
set: er(e)
|
|
2503
2503
|
};
|
|
2504
2504
|
}
|
|
2505
2505
|
//#endregion
|
|
2506
2506
|
//#region src/universalLoginTemplates/get.ts
|
|
2507
|
-
function
|
|
2507
|
+
function nr(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 $n(e) {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
//#endregion
|
|
2514
2514
|
//#region src/universalLoginTemplates/set.ts
|
|
2515
|
-
function
|
|
2515
|
+
function rr(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 er(e) {
|
|
|
2533
2533
|
}
|
|
2534
2534
|
//#endregion
|
|
2535
2535
|
//#region src/universalLoginTemplates/delete.ts
|
|
2536
|
-
function
|
|
2536
|
+
function ir(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 ar(e) {
|
|
2544
2544
|
return {
|
|
2545
|
-
get:
|
|
2546
|
-
set:
|
|
2547
|
-
delete:
|
|
2545
|
+
get: nr(e),
|
|
2546
|
+
set: rr(e),
|
|
2547
|
+
delete: ir(e)
|
|
2548
2548
|
};
|
|
2549
2549
|
}
|
|
2550
2550
|
//#endregion
|
|
2551
2551
|
//#region src/hooks/list.ts
|
|
2552
|
-
function
|
|
2552
|
+
function or(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 rr(e) {
|
|
|
2571
2571
|
...u,
|
|
2572
2572
|
enabled: !!n,
|
|
2573
2573
|
synchronous: !!i,
|
|
2574
|
-
metadata:
|
|
2574
|
+
metadata: pt(s)
|
|
2575
2575
|
});
|
|
2576
2576
|
});
|
|
2577
2577
|
if (!s) return {
|
|
@@ -2591,7 +2591,7 @@ function rr(e) {
|
|
|
2591
2591
|
}
|
|
2592
2592
|
//#endregion
|
|
2593
2593
|
//#region src/hooks/get.ts
|
|
2594
|
-
function
|
|
2594
|
+
function sr(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 ir(e) {
|
|
|
2604
2604
|
...d,
|
|
2605
2605
|
enabled: !!u.enabled,
|
|
2606
2606
|
synchronous: !!u.synchronous,
|
|
2607
|
-
metadata:
|
|
2607
|
+
metadata: pt(c)
|
|
2608
2608
|
});
|
|
2609
2609
|
};
|
|
2610
2610
|
}
|
|
2611
2611
|
//#endregion
|
|
2612
2612
|
//#region src/hooks/remove.ts
|
|
2613
|
-
function
|
|
2613
|
+
function cr(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 lr(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 || Ee()), { 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 or(e) {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
//#endregion
|
|
2642
2642
|
//#region src/hooks/update.ts
|
|
2643
|
-
function
|
|
2643
|
+
function ur(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 sr(e) {
|
|
|
2654
2654
|
}
|
|
2655
2655
|
//#endregion
|
|
2656
2656
|
//#region src/hooks/index.ts
|
|
2657
|
-
function
|
|
2657
|
+
function dr(e) {
|
|
2658
2658
|
return {
|
|
2659
|
-
create:
|
|
2660
|
-
get:
|
|
2661
|
-
list:
|
|
2662
|
-
update:
|
|
2663
|
-
remove:
|
|
2659
|
+
create: lr(e),
|
|
2660
|
+
get: sr(e),
|
|
2661
|
+
list: or(e),
|
|
2662
|
+
update: ur(e),
|
|
2663
|
+
remove: cr(e)
|
|
2664
2664
|
};
|
|
2665
2665
|
}
|
|
2666
2666
|
//#endregion
|
|
2667
2667
|
//#region src/hook-code/create.ts
|
|
2668
|
-
function
|
|
2668
|
+
function fr(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 ?? Oe();
|
|
2671
2671
|
return await e.insertInto("hook_code").values({
|
|
2672
2672
|
id: c,
|
|
2673
2673
|
tenant_id: t,
|
|
@@ -2687,7 +2687,7 @@ function lr(e) {
|
|
|
2687
2687
|
}
|
|
2688
2688
|
//#endregion
|
|
2689
2689
|
//#region src/hook-code/get.ts
|
|
2690
|
-
function
|
|
2690
|
+
function pr(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 ur(e) {
|
|
|
2711
2711
|
}
|
|
2712
2712
|
//#endregion
|
|
2713
2713
|
//#region src/hook-code/update.ts
|
|
2714
|
-
function
|
|
2714
|
+
function mr(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 dr(e) {
|
|
|
2719
2719
|
}
|
|
2720
2720
|
//#endregion
|
|
2721
2721
|
//#region src/hook-code/remove.ts
|
|
2722
|
-
function
|
|
2722
|
+
function hr(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 gr(e) {
|
|
2728
2728
|
return {
|
|
2729
|
-
create:
|
|
2730
|
-
get:
|
|
2731
|
-
update:
|
|
2732
|
-
remove:
|
|
2729
|
+
create: fr(e),
|
|
2730
|
+
get: pr(e),
|
|
2731
|
+
update: mr(e),
|
|
2732
|
+
remove: hr(e)
|
|
2733
2733
|
};
|
|
2734
2734
|
}
|
|
2735
2735
|
//#endregion
|
|
2736
2736
|
//#region src/themes/create.ts
|
|
2737
|
-
function
|
|
2737
|
+
function _r(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(),
|
|
@@ -2745,20 +2745,20 @@ function mr(e) {
|
|
|
2745
2745
|
...c,
|
|
2746
2746
|
tenant_id: n
|
|
2747
2747
|
};
|
|
2748
|
-
return await e.insertInto("themes").values(
|
|
2748
|
+
return await e.insertInto("themes").values(F(l)).execute(), c;
|
|
2749
2749
|
};
|
|
2750
2750
|
}
|
|
2751
2751
|
//#endregion
|
|
2752
2752
|
//#region src/themes/remove.ts
|
|
2753
|
-
function
|
|
2753
|
+
function vr(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 yr(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(at({
|
|
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,9 +2778,9 @@ function gr(e) {
|
|
|
2778
2778
|
}
|
|
2779
2779
|
//#endregion
|
|
2780
2780
|
//#region src/themes/update.ts
|
|
2781
|
-
function
|
|
2781
|
+
function br(e) {
|
|
2782
2782
|
return async (t, n, r) => {
|
|
2783
|
-
let { themeId: i, ...a } = r, o =
|
|
2783
|
+
let { themeId: i, ...a } = r, o = F({
|
|
2784
2784
|
...a,
|
|
2785
2785
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2786
2786
|
});
|
|
@@ -2789,17 +2789,17 @@ function _r(e) {
|
|
|
2789
2789
|
}
|
|
2790
2790
|
//#endregion
|
|
2791
2791
|
//#region src/themes/index.ts
|
|
2792
|
-
function
|
|
2792
|
+
function xr(e) {
|
|
2793
2793
|
return {
|
|
2794
|
-
create:
|
|
2795
|
-
get:
|
|
2796
|
-
remove:
|
|
2797
|
-
update:
|
|
2794
|
+
create: _r(e),
|
|
2795
|
+
get: yr(e),
|
|
2796
|
+
remove: vr(e),
|
|
2797
|
+
update: br(e)
|
|
2798
2798
|
};
|
|
2799
2799
|
}
|
|
2800
2800
|
//#endregion
|
|
2801
2801
|
//#region src/loginSessions/get.ts
|
|
2802
|
-
function
|
|
2802
|
+
function Sr(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 yr(e) {
|
|
|
2811
2811
|
"created_at_ts",
|
|
2812
2812
|
"updated_at_ts",
|
|
2813
2813
|
"expires_at_ts"
|
|
2814
|
-
]), f =
|
|
2814
|
+
]), f = at(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) : {}, ae.parse(f);
|
|
2822
2822
|
};
|
|
2823
2823
|
}
|
|
2824
2824
|
//#endregion
|
|
2825
2825
|
//#region src/utils/ulid.ts
|
|
2826
|
-
var
|
|
2827
|
-
function
|
|
2826
|
+
var Cr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", B = 32, wr = 10, Tr = 16;
|
|
2827
|
+
function Er(e) {
|
|
2828
2828
|
let t = "";
|
|
2829
|
-
for (let n =
|
|
2829
|
+
for (let n = wr; n > 0; n--) t = Cr.charAt(e % B) + t, e = Math.floor(e / B);
|
|
2830
2830
|
return t;
|
|
2831
2831
|
}
|
|
2832
|
-
function
|
|
2833
|
-
let e = new Uint8Array(
|
|
2832
|
+
function Dr() {
|
|
2833
|
+
let e = new Uint8Array(Tr);
|
|
2834
2834
|
crypto.getRandomValues(e);
|
|
2835
2835
|
let t = "";
|
|
2836
|
-
for (let n = 0; n <
|
|
2836
|
+
for (let n = 0; n < Tr; n++) t += Cr.charAt(e[n] % B);
|
|
2837
2837
|
return t;
|
|
2838
2838
|
}
|
|
2839
|
-
function
|
|
2840
|
-
return
|
|
2839
|
+
function Or() {
|
|
2840
|
+
return Er(Date.now()) + Dr();
|
|
2841
2841
|
}
|
|
2842
2842
|
//#endregion
|
|
2843
2843
|
//#region src/loginSessions/create.ts
|
|
2844
|
-
function
|
|
2844
|
+
function kr(e) {
|
|
2845
2845
|
return async (t, n) => {
|
|
2846
2846
|
let r = c(), i = {
|
|
2847
|
-
id:
|
|
2847
|
+
id: Or(),
|
|
2848
2848
|
...n,
|
|
2849
2849
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2850
2850
|
created_at: r,
|
|
@@ -2852,7 +2852,7 @@ function Er(e) {
|
|
|
2852
2852
|
state: n.state || p.PENDING,
|
|
2853
2853
|
state_data: n.state_data,
|
|
2854
2854
|
failure_reason: n.failure_reason
|
|
2855
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2855
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = F(o);
|
|
2856
2856
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2857
2857
|
...l,
|
|
2858
2858
|
tenant_id: t,
|
|
@@ -2865,7 +2865,7 @@ function Er(e) {
|
|
|
2865
2865
|
}
|
|
2866
2866
|
//#endregion
|
|
2867
2867
|
//#region src/loginSessions/update.ts
|
|
2868
|
-
function
|
|
2868
|
+
function Ar(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) {
|
|
@@ -2875,7 +2875,7 @@ function Dr(e) {
|
|
|
2875
2875
|
...c
|
|
2876
2876
|
}) };
|
|
2877
2877
|
}
|
|
2878
|
-
let d =
|
|
2878
|
+
let d = F(l);
|
|
2879
2879
|
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2880
2880
|
...d,
|
|
2881
2881
|
...u,
|
|
@@ -2886,22 +2886,22 @@ function Dr(e) {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
//#endregion
|
|
2888
2888
|
//#region src/loginSessions/remove.ts
|
|
2889
|
-
function
|
|
2889
|
+
function jr(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 Mr(e) {
|
|
2895
2895
|
return {
|
|
2896
|
-
create:
|
|
2897
|
-
get:
|
|
2898
|
-
update:
|
|
2899
|
-
remove:
|
|
2896
|
+
create: kr(e),
|
|
2897
|
+
get: Sr(e),
|
|
2898
|
+
update: Ar(e),
|
|
2899
|
+
remove: jr(e)
|
|
2900
2900
|
};
|
|
2901
2901
|
}
|
|
2902
2902
|
//#endregion
|
|
2903
2903
|
//#region src/promptSettings/get.ts
|
|
2904
|
-
function
|
|
2904
|
+
function Nr(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 Ar(e) {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
//#endregion
|
|
2917
2917
|
//#region src/promptSettings/set.ts
|
|
2918
|
-
function
|
|
2918
|
+
function Pr(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 Fr(e) {
|
|
2923
2923
|
return async (t, n) => {
|
|
2924
|
-
let r =
|
|
2924
|
+
let r = Pr(n);
|
|
2925
2925
|
try {
|
|
2926
2926
|
await e.insertInto("prompt_settings").values({
|
|
2927
2927
|
tenant_id: t,
|
|
@@ -2939,15 +2939,15 @@ function Mr(e) {
|
|
|
2939
2939
|
}
|
|
2940
2940
|
//#endregion
|
|
2941
2941
|
//#region src/promptSettings/index.ts
|
|
2942
|
-
function
|
|
2942
|
+
function Ir(e) {
|
|
2943
2943
|
return {
|
|
2944
|
-
get:
|
|
2945
|
-
set:
|
|
2944
|
+
get: Nr(e),
|
|
2945
|
+
set: Fr(e)
|
|
2946
2946
|
};
|
|
2947
2947
|
}
|
|
2948
2948
|
//#endregion
|
|
2949
2949
|
//#region src/emailProvideres/get.ts
|
|
2950
|
-
function
|
|
2950
|
+
function Lr(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 Pr(e) {
|
|
|
2962
2962
|
}
|
|
2963
2963
|
//#endregion
|
|
2964
2964
|
//#region src/emailProvideres/update.ts
|
|
2965
|
-
function
|
|
2965
|
+
function Rr(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 Fr(e) {
|
|
|
2975
2975
|
}
|
|
2976
2976
|
//#endregion
|
|
2977
2977
|
//#region src/emailProvideres/create.ts
|
|
2978
|
-
function
|
|
2978
|
+
function zr(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 Ir(e) {
|
|
|
2991
2991
|
}
|
|
2992
2992
|
//#endregion
|
|
2993
2993
|
//#region src/emailProvideres/remove.ts
|
|
2994
|
-
function
|
|
2994
|
+
function Br(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 Vr(e) {
|
|
3002
3002
|
return {
|
|
3003
|
-
get:
|
|
3004
|
-
create:
|
|
3005
|
-
update:
|
|
3006
|
-
remove:
|
|
3003
|
+
get: Lr(e),
|
|
3004
|
+
create: zr(e),
|
|
3005
|
+
update: Rr(e),
|
|
3006
|
+
remove: Br(e)
|
|
3007
3007
|
};
|
|
3008
3008
|
}
|
|
3009
3009
|
//#endregion
|
|
3010
3010
|
//#region src/emailTemplates/row.ts
|
|
3011
|
-
function
|
|
3011
|
+
function Hr(e) {
|
|
3012
3012
|
let t = {
|
|
3013
3013
|
template: e.template,
|
|
3014
3014
|
body: e.body,
|
|
@@ -3022,20 +3022,20 @@ function zr(e) {
|
|
|
3022
3022
|
}
|
|
3023
3023
|
//#endregion
|
|
3024
3024
|
//#region src/emailTemplates/get.ts
|
|
3025
|
-
function
|
|
3025
|
+
function Ur(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 ? te.parse(Hr(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 Wr(e) {
|
|
3034
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => te.parse(Hr(e)));
|
|
3035
3035
|
}
|
|
3036
3036
|
//#endregion
|
|
3037
3037
|
//#region src/emailTemplates/create.ts
|
|
3038
|
-
function
|
|
3038
|
+
function Gr(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 Hr(e) {
|
|
|
3056
3056
|
}
|
|
3057
3057
|
//#endregion
|
|
3058
3058
|
//#region src/emailTemplates/update.ts
|
|
3059
|
-
function
|
|
3059
|
+
function Kr(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 Ur(e) {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
//#endregion
|
|
3069
3069
|
//#region src/emailTemplates/remove.ts
|
|
3070
|
-
function
|
|
3070
|
+
function qr(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 Wr(e) {
|
|
|
3075
3075
|
}
|
|
3076
3076
|
//#endregion
|
|
3077
3077
|
//#region src/emailTemplates/index.ts
|
|
3078
|
-
function
|
|
3078
|
+
function Jr(e) {
|
|
3079
3079
|
return {
|
|
3080
|
-
get:
|
|
3081
|
-
list:
|
|
3082
|
-
create:
|
|
3083
|
-
update:
|
|
3084
|
-
remove:
|
|
3080
|
+
get: Ur(e),
|
|
3081
|
+
list: Wr(e),
|
|
3082
|
+
create: Gr(e),
|
|
3083
|
+
update: Kr(e),
|
|
3084
|
+
remove: qr(e)
|
|
3085
3085
|
};
|
|
3086
3086
|
}
|
|
3087
3087
|
//#endregion
|
|
3088
3088
|
//#region src/refreshTokens/get.ts
|
|
3089
|
-
function
|
|
3089
|
+
function Yr(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 Kr(e) {
|
|
|
3115
3115
|
}
|
|
3116
3116
|
//#endregion
|
|
3117
3117
|
//#region src/refreshTokens/getByLookup.ts
|
|
3118
|
-
function
|
|
3118
|
+
function Xr(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 qr(e) {
|
|
|
3144
3144
|
}
|
|
3145
3145
|
//#endregion
|
|
3146
3146
|
//#region src/refreshTokens/create.ts
|
|
3147
|
-
function
|
|
3147
|
+
function Zr(e) {
|
|
3148
3148
|
return async (t, n) => {
|
|
3149
3149
|
let r = c(), i = {
|
|
3150
3150
|
...n,
|
|
@@ -3174,12 +3174,12 @@ function Jr(e) {
|
|
|
3174
3174
|
}
|
|
3175
3175
|
//#endregion
|
|
3176
3176
|
//#region src/refreshTokens/remove.ts
|
|
3177
|
-
function
|
|
3177
|
+
function Qr(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 $r(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 Xr(e) {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
//#endregion
|
|
3189
3189
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3190
|
-
function
|
|
3190
|
+
function ei(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 Zr(e) {
|
|
|
3195
3195
|
}
|
|
3196
3196
|
//#endregion
|
|
3197
3197
|
//#region src/refreshTokens/update.ts
|
|
3198
|
-
function
|
|
3198
|
+
function ti(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 Qr(e) {
|
|
|
3216
3216
|
}
|
|
3217
3217
|
//#endregion
|
|
3218
3218
|
//#region src/refreshTokens/list.ts
|
|
3219
|
-
function
|
|
3219
|
+
function ni(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 $r(e) {
|
|
|
3266
3266
|
}
|
|
3267
3267
|
//#endregion
|
|
3268
3268
|
//#region src/refreshTokens/index.ts
|
|
3269
|
-
function
|
|
3269
|
+
function ri(e) {
|
|
3270
3270
|
return {
|
|
3271
|
-
create:
|
|
3272
|
-
get:
|
|
3273
|
-
getByLookup:
|
|
3274
|
-
list:
|
|
3275
|
-
remove:
|
|
3276
|
-
revokeByLoginSession:
|
|
3277
|
-
revokeFamily:
|
|
3278
|
-
update:
|
|
3271
|
+
create: Zr(e),
|
|
3272
|
+
get: Yr(e),
|
|
3273
|
+
getByLookup: Xr(e),
|
|
3274
|
+
list: ni(e),
|
|
3275
|
+
remove: Qr(e),
|
|
3276
|
+
revokeByLoginSession: $r(e),
|
|
3277
|
+
revokeFamily: ei(e),
|
|
3278
|
+
update: ti(e)
|
|
3279
3279
|
};
|
|
3280
3280
|
}
|
|
3281
3281
|
//#endregion
|
|
3282
3282
|
//#region src/cleanup.ts
|
|
3283
|
-
var
|
|
3284
|
-
function
|
|
3283
|
+
var ii = 10080 * 60 * 1e3;
|
|
3284
|
+
function ai(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() - ii, a = 1e3;
|
|
3287
3287
|
try {
|
|
3288
3288
|
let t = 0;
|
|
3289
3289
|
for (;;) {
|
|
@@ -3314,7 +3314,7 @@ function ni(e) {
|
|
|
3314
3314
|
}
|
|
3315
3315
|
//#endregion
|
|
3316
3316
|
//#region src/forms/create.ts
|
|
3317
|
-
function
|
|
3317
|
+
function oi(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 ri(e) {
|
|
|
3333
3333
|
}
|
|
3334
3334
|
//#endregion
|
|
3335
3335
|
//#region src/forms/list.ts
|
|
3336
|
-
function
|
|
3336
|
+
function si(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 ii(e) {
|
|
|
3367
3367
|
}
|
|
3368
3368
|
//#endregion
|
|
3369
3369
|
//#region src/forms/remove.ts
|
|
3370
|
-
function
|
|
3370
|
+
function ci(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 ai(e) {
|
|
|
3375
3375
|
}
|
|
3376
3376
|
//#endregion
|
|
3377
3377
|
//#region src/forms/get.ts
|
|
3378
|
-
function
|
|
3378
|
+
function li(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 oi(e) {
|
|
|
3394
3394
|
}
|
|
3395
3395
|
//#endregion
|
|
3396
3396
|
//#region src/forms/update.ts
|
|
3397
|
-
function
|
|
3397
|
+
function ui(e) {
|
|
3398
3398
|
return async (t, n, r) => {
|
|
3399
3399
|
let i = {
|
|
3400
3400
|
...r,
|
|
@@ -3411,25 +3411,25 @@ function si(e) {
|
|
|
3411
3411
|
}
|
|
3412
3412
|
//#endregion
|
|
3413
3413
|
//#region src/forms/index.ts
|
|
3414
|
-
function
|
|
3414
|
+
function di(e) {
|
|
3415
3415
|
return {
|
|
3416
|
-
create:
|
|
3417
|
-
get:
|
|
3418
|
-
list:
|
|
3419
|
-
remove:
|
|
3420
|
-
update:
|
|
3416
|
+
create: oi(e),
|
|
3417
|
+
get: li(e),
|
|
3418
|
+
list: si(e),
|
|
3419
|
+
remove: ci(e),
|
|
3420
|
+
update: ui(e)
|
|
3421
3421
|
};
|
|
3422
3422
|
}
|
|
3423
3423
|
//#endregion
|
|
3424
3424
|
//#region src/resourceServers/create.ts
|
|
3425
|
-
function
|
|
3425
|
+
function fi(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 ?? De(),
|
|
3430
3430
|
created_at: o,
|
|
3431
3431
|
updated_at: s
|
|
3432
|
-
}, u =
|
|
3432
|
+
}, u = le.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 li(e) {
|
|
|
3447
3447
|
}
|
|
3448
3448
|
//#endregion
|
|
3449
3449
|
//#region src/resourceServers/get.ts
|
|
3450
|
-
function
|
|
3450
|
+
function pi(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 ui(e) {
|
|
|
3466
3466
|
}
|
|
3467
3467
|
//#endregion
|
|
3468
3468
|
//#region src/resourceServers/list.ts
|
|
3469
|
-
function
|
|
3469
|
+
function mi(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 di(e) {
|
|
|
3506
3506
|
}
|
|
3507
3507
|
//#endregion
|
|
3508
3508
|
//#region src/resourceServers/remove.ts
|
|
3509
|
-
function
|
|
3509
|
+
function hi(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 fi(e) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
//#endregion
|
|
3516
3516
|
//#region src/resourceServers/update.ts
|
|
3517
|
-
function
|
|
3517
|
+
function gi(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 pi(e) {
|
|
|
3534
3534
|
}
|
|
3535
3535
|
//#endregion
|
|
3536
3536
|
//#region src/resourceServers/index.ts
|
|
3537
|
-
function
|
|
3537
|
+
function _i(e) {
|
|
3538
3538
|
return {
|
|
3539
|
-
create:
|
|
3540
|
-
get:
|
|
3541
|
-
list:
|
|
3542
|
-
remove:
|
|
3543
|
-
update:
|
|
3539
|
+
create: fi(e),
|
|
3540
|
+
get: pi(e),
|
|
3541
|
+
list: mi(e),
|
|
3542
|
+
remove: hi(e),
|
|
3543
|
+
update: gi(e)
|
|
3544
3544
|
};
|
|
3545
3545
|
}
|
|
3546
3546
|
//#endregion
|
|
3547
3547
|
//#region src/roles/create.ts
|
|
3548
|
-
function
|
|
3548
|
+
function vi(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 hi(e) {
|
|
|
3568
3568
|
}
|
|
3569
3569
|
//#endregion
|
|
3570
3570
|
//#region src/roles/get.ts
|
|
3571
|
-
function
|
|
3571
|
+
function yi(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 gi(e) {
|
|
|
3582
3582
|
}
|
|
3583
3583
|
//#endregion
|
|
3584
3584
|
//#region src/roles/list.ts
|
|
3585
|
-
function
|
|
3585
|
+
function bi(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 _i(e) {
|
|
|
3611
3611
|
}
|
|
3612
3612
|
//#endregion
|
|
3613
3613
|
//#region src/roles/update.ts
|
|
3614
|
-
function
|
|
3614
|
+
function xi(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 vi(e) {
|
|
|
3624
3624
|
}
|
|
3625
3625
|
//#endregion
|
|
3626
3626
|
//#region src/roles/remove.ts
|
|
3627
|
-
function
|
|
3627
|
+
function Si(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,18 @@ function yi(e) {
|
|
|
3632
3632
|
}
|
|
3633
3633
|
//#endregion
|
|
3634
3634
|
//#region src/roles/index.ts
|
|
3635
|
-
function
|
|
3635
|
+
function Ci(e) {
|
|
3636
3636
|
return {
|
|
3637
|
-
create:
|
|
3638
|
-
get:
|
|
3639
|
-
list:
|
|
3640
|
-
update:
|
|
3641
|
-
remove:
|
|
3637
|
+
create: vi(e),
|
|
3638
|
+
get: yi(e),
|
|
3639
|
+
list: bi(e),
|
|
3640
|
+
update: xi(e),
|
|
3641
|
+
remove: Si(e)
|
|
3642
3642
|
};
|
|
3643
3643
|
}
|
|
3644
3644
|
//#endregion
|
|
3645
3645
|
//#region src/role-permissions/assign.ts
|
|
3646
|
-
function
|
|
3646
|
+
function wi(e) {
|
|
3647
3647
|
return async (t, n, r, i) => {
|
|
3648
3648
|
if (r.length === 0) return !0;
|
|
3649
3649
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3672,7 +3672,7 @@ function xi(e) {
|
|
|
3672
3672
|
}
|
|
3673
3673
|
//#endregion
|
|
3674
3674
|
//#region src/role-permissions/remove.ts
|
|
3675
|
-
function
|
|
3675
|
+
function Ti(e) {
|
|
3676
3676
|
return async (t, n, r) => {
|
|
3677
3677
|
if (r.length === 0) return !0;
|
|
3678
3678
|
try {
|
|
@@ -3684,7 +3684,7 @@ function Si(e) {
|
|
|
3684
3684
|
}
|
|
3685
3685
|
//#endregion
|
|
3686
3686
|
//#region src/role-permissions/list.ts
|
|
3687
|
-
function
|
|
3687
|
+
function Ei(e) {
|
|
3688
3688
|
return async (t, n, r = {}) => {
|
|
3689
3689
|
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
3690
|
"role_permissions.role_id",
|
|
@@ -3705,16 +3705,16 @@ function Ci(e) {
|
|
|
3705
3705
|
}
|
|
3706
3706
|
//#endregion
|
|
3707
3707
|
//#region src/role-permissions/index.ts
|
|
3708
|
-
function
|
|
3708
|
+
function Di(e) {
|
|
3709
3709
|
return {
|
|
3710
|
-
assign:
|
|
3711
|
-
remove:
|
|
3712
|
-
list:
|
|
3710
|
+
assign: wi(e),
|
|
3711
|
+
remove: Ti(e),
|
|
3712
|
+
list: Ei(e)
|
|
3713
3713
|
};
|
|
3714
3714
|
}
|
|
3715
3715
|
//#endregion
|
|
3716
3716
|
//#region src/grants/create.ts
|
|
3717
|
-
function
|
|
3717
|
+
function Oi(e) {
|
|
3718
3718
|
return async (n, r) => {
|
|
3719
3719
|
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
3720
|
if (s) {
|
|
@@ -3751,7 +3751,7 @@ function Ti(e) {
|
|
|
3751
3751
|
}
|
|
3752
3752
|
//#endregion
|
|
3753
3753
|
//#region src/grants/get.ts
|
|
3754
|
-
function
|
|
3754
|
+
function ki(e) {
|
|
3755
3755
|
return async (t, n, r, i) => {
|
|
3756
3756
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3757
3757
|
return a ? {
|
|
@@ -3765,7 +3765,7 @@ function Ei(e) {
|
|
|
3765
3765
|
}
|
|
3766
3766
|
//#endregion
|
|
3767
3767
|
//#region src/grants/list.ts
|
|
3768
|
-
function
|
|
3768
|
+
function Ai(e) {
|
|
3769
3769
|
return async (t, n = {}) => {
|
|
3770
3770
|
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
3771
|
c && (l = O(e, l, c, [
|
|
@@ -3803,26 +3803,26 @@ function Di(e) {
|
|
|
3803
3803
|
}
|
|
3804
3804
|
//#endregion
|
|
3805
3805
|
//#region src/grants/remove.ts
|
|
3806
|
-
function
|
|
3806
|
+
function ji(e) {
|
|
3807
3807
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3808
3808
|
}
|
|
3809
|
-
function
|
|
3809
|
+
function Mi(e) {
|
|
3810
3810
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3811
3811
|
}
|
|
3812
3812
|
//#endregion
|
|
3813
3813
|
//#region src/grants/index.ts
|
|
3814
|
-
function
|
|
3814
|
+
function Ni(e) {
|
|
3815
3815
|
return {
|
|
3816
|
-
create:
|
|
3817
|
-
get:
|
|
3818
|
-
list:
|
|
3819
|
-
remove:
|
|
3820
|
-
removeByUser:
|
|
3816
|
+
create: Oi(e),
|
|
3817
|
+
get: ki(e),
|
|
3818
|
+
list: Ai(e),
|
|
3819
|
+
remove: ji(e),
|
|
3820
|
+
removeByUser: Mi(e)
|
|
3821
3821
|
};
|
|
3822
3822
|
}
|
|
3823
3823
|
//#endregion
|
|
3824
3824
|
//#region src/user-permissions/create.ts
|
|
3825
|
-
function
|
|
3825
|
+
function Pi(e) {
|
|
3826
3826
|
return async (t, n, r, i, a) => {
|
|
3827
3827
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3828
3828
|
try {
|
|
@@ -3842,7 +3842,7 @@ function ji(e) {
|
|
|
3842
3842
|
}
|
|
3843
3843
|
//#endregion
|
|
3844
3844
|
//#region src/user-permissions/remove.ts
|
|
3845
|
-
function
|
|
3845
|
+
function Fi(e) {
|
|
3846
3846
|
return async (t, n, r, i) => {
|
|
3847
3847
|
try {
|
|
3848
3848
|
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 +3854,7 @@ function Mi(e) {
|
|
|
3854
3854
|
}
|
|
3855
3855
|
//#endregion
|
|
3856
3856
|
//#region src/user-permissions/list.ts
|
|
3857
|
-
function
|
|
3857
|
+
function Ii(e) {
|
|
3858
3858
|
return async (t, n, r, i) => {
|
|
3859
3859
|
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
3860
|
"user_permissions.resource_server_identifier",
|
|
@@ -3877,17 +3877,17 @@ function Ni(e) {
|
|
|
3877
3877
|
}
|
|
3878
3878
|
//#endregion
|
|
3879
3879
|
//#region src/user-permissions/index.ts
|
|
3880
|
-
function
|
|
3880
|
+
function Li(e) {
|
|
3881
3881
|
return {
|
|
3882
|
-
create:
|
|
3883
|
-
remove:
|
|
3884
|
-
list:
|
|
3882
|
+
create: Pi(e),
|
|
3883
|
+
remove: Fi(e),
|
|
3884
|
+
list: Ii(e)
|
|
3885
3885
|
};
|
|
3886
3886
|
}
|
|
3887
3887
|
//#endregion
|
|
3888
3888
|
//#region src/user-permissions/adapter.ts
|
|
3889
|
-
function
|
|
3890
|
-
let t =
|
|
3889
|
+
function Ri(e) {
|
|
3890
|
+
let t = Li(e);
|
|
3891
3891
|
return {
|
|
3892
3892
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3893
3893
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3896,7 +3896,7 @@ function Fi(e) {
|
|
|
3896
3896
|
}
|
|
3897
3897
|
//#endregion
|
|
3898
3898
|
//#region src/user-roles/list.ts
|
|
3899
|
-
function
|
|
3899
|
+
function zi(e) {
|
|
3900
3900
|
return async (t, n, r, i) => {
|
|
3901
3901
|
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
3902
|
"r.id",
|
|
@@ -3910,11 +3910,11 @@ function Ii(e) {
|
|
|
3910
3910
|
}
|
|
3911
3911
|
//#endregion
|
|
3912
3912
|
//#region src/user-roles/list-users.ts
|
|
3913
|
-
function
|
|
3913
|
+
function Bi(e) {
|
|
3914
3914
|
return async (t, n, r) => {
|
|
3915
3915
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3916
|
-
if (
|
|
3917
|
-
let { rows: e, limit: t, next: n } = await
|
|
3916
|
+
if (N(r)) {
|
|
3917
|
+
let { rows: e, limit: t, next: n } = await P(i, r, {
|
|
3918
3918
|
sortColumn: "user_id",
|
|
3919
3919
|
sortOrder: "asc",
|
|
3920
3920
|
idColumn: "user_id"
|
|
@@ -3938,7 +3938,7 @@ function Li(e) {
|
|
|
3938
3938
|
}
|
|
3939
3939
|
//#endregion
|
|
3940
3940
|
//#region src/user-roles/create.ts
|
|
3941
|
-
function
|
|
3941
|
+
function Vi(e) {
|
|
3942
3942
|
return async (t, n, r, i, a) => {
|
|
3943
3943
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3944
3944
|
try {
|
|
@@ -3956,7 +3956,7 @@ function Ri(e) {
|
|
|
3956
3956
|
}
|
|
3957
3957
|
//#endregion
|
|
3958
3958
|
//#region src/user-roles/remove.ts
|
|
3959
|
-
function
|
|
3959
|
+
function Hi(e) {
|
|
3960
3960
|
return async (t, n, r, i) => {
|
|
3961
3961
|
try {
|
|
3962
3962
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3968,18 +3968,18 @@ function zi(e) {
|
|
|
3968
3968
|
}
|
|
3969
3969
|
//#endregion
|
|
3970
3970
|
//#region src/user-roles/index.ts
|
|
3971
|
-
function
|
|
3971
|
+
function Ui(e) {
|
|
3972
3972
|
return {
|
|
3973
|
-
list:
|
|
3974
|
-
listUsers:
|
|
3975
|
-
create:
|
|
3976
|
-
remove:
|
|
3973
|
+
list: zi(e),
|
|
3974
|
+
listUsers: Bi(e),
|
|
3975
|
+
create: Vi(e),
|
|
3976
|
+
remove: Hi(e)
|
|
3977
3977
|
};
|
|
3978
3978
|
}
|
|
3979
3979
|
//#endregion
|
|
3980
3980
|
//#region src/user-roles/adapter.ts
|
|
3981
|
-
function
|
|
3982
|
-
let t =
|
|
3981
|
+
function Wi(e) {
|
|
3982
|
+
let t = Ui(e);
|
|
3983
3983
|
return {
|
|
3984
3984
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3985
3985
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3989,11 +3989,11 @@ function Vi(e) {
|
|
|
3989
3989
|
}
|
|
3990
3990
|
//#endregion
|
|
3991
3991
|
//#region src/organizations/create.ts
|
|
3992
|
-
function
|
|
3992
|
+
function Gi(e) {
|
|
3993
3993
|
return async (t, n, r) => {
|
|
3994
3994
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3995
3995
|
...n,
|
|
3996
|
-
id: i?.id || n.id ||
|
|
3996
|
+
id: i?.id || n.id || Se(),
|
|
3997
3997
|
tenant_id: t,
|
|
3998
3998
|
created_at: i?.created_at ?? a,
|
|
3999
3999
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4017,7 +4017,7 @@ function Hi(e) {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
//#endregion
|
|
4019
4019
|
//#region src/organizations/get.ts
|
|
4020
|
-
function
|
|
4020
|
+
function Ki(e) {
|
|
4021
4021
|
return async (t, n) => {
|
|
4022
4022
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4023
4023
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4031,16 +4031,16 @@ function Ui(e) {
|
|
|
4031
4031
|
}
|
|
4032
4032
|
//#endregion
|
|
4033
4033
|
//#region src/organizations/list.ts
|
|
4034
|
-
var
|
|
4035
|
-
function
|
|
4034
|
+
var V = ["name", "display_name"];
|
|
4035
|
+
function qi(e) {
|
|
4036
4036
|
return async (t, n) => {
|
|
4037
4037
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4038
4038
|
if (n?.q) {
|
|
4039
|
-
let t = S(n.q,
|
|
4040
|
-
t && (r = O(e, r, t,
|
|
4039
|
+
let t = S(n.q, V);
|
|
4040
|
+
t && (r = O(e, r, t, V));
|
|
4041
4041
|
}
|
|
4042
|
-
if (
|
|
4043
|
-
let { rows: e, limit: t, next: i } = await
|
|
4042
|
+
if (N(n)) {
|
|
4043
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
4044
4044
|
sortColumn: "created_at",
|
|
4045
4045
|
sortOrder: "desc"
|
|
4046
4046
|
}), a = e.map((e) => l({
|
|
@@ -4073,8 +4073,8 @@ function Wi(e) {
|
|
|
4073
4073
|
if (n?.include_totals) {
|
|
4074
4074
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4075
4075
|
if (n?.q) {
|
|
4076
|
-
let t = S(n.q,
|
|
4077
|
-
t && (r = O(e, r, t,
|
|
4076
|
+
let t = S(n.q, V);
|
|
4077
|
+
t && (r = O(e, r, t, V));
|
|
4078
4078
|
}
|
|
4079
4079
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4080
4080
|
u = Number(i?.count || 0);
|
|
@@ -4097,12 +4097,12 @@ function Wi(e) {
|
|
|
4097
4097
|
}
|
|
4098
4098
|
//#endregion
|
|
4099
4099
|
//#region src/organizations/remove.ts
|
|
4100
|
-
function
|
|
4100
|
+
function Ji(e) {
|
|
4101
4101
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4102
4102
|
}
|
|
4103
4103
|
//#endregion
|
|
4104
4104
|
//#region src/organizations/update.ts
|
|
4105
|
-
function
|
|
4105
|
+
function Yi(e) {
|
|
4106
4106
|
return async (t, n, r) => {
|
|
4107
4107
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4108
4108
|
...c,
|
|
@@ -4118,18 +4118,18 @@ function Ki(e) {
|
|
|
4118
4118
|
}
|
|
4119
4119
|
//#endregion
|
|
4120
4120
|
//#region src/organizations/index.ts
|
|
4121
|
-
function
|
|
4121
|
+
function Xi(e) {
|
|
4122
4122
|
return {
|
|
4123
|
-
create:
|
|
4124
|
-
get:
|
|
4125
|
-
list:
|
|
4126
|
-
remove:
|
|
4127
|
-
update:
|
|
4123
|
+
create: Gi(e),
|
|
4124
|
+
get: Ki(e),
|
|
4125
|
+
list: qi(e),
|
|
4126
|
+
remove: Ji(e),
|
|
4127
|
+
update: Yi(e)
|
|
4128
4128
|
};
|
|
4129
4129
|
}
|
|
4130
4130
|
//#endregion
|
|
4131
4131
|
//#region src/organization-connections/index.ts
|
|
4132
|
-
function
|
|
4132
|
+
function H(e, t) {
|
|
4133
4133
|
return {
|
|
4134
4134
|
connection_id: e.connection_id,
|
|
4135
4135
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4143,14 +4143,14 @@ function V(e, t) {
|
|
|
4143
4143
|
updated_at: e.updated_at
|
|
4144
4144
|
};
|
|
4145
4145
|
}
|
|
4146
|
-
async function
|
|
4146
|
+
async function U(e, t, n) {
|
|
4147
4147
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4148
4148
|
if (r) return {
|
|
4149
4149
|
name: r.name,
|
|
4150
4150
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4151
4151
|
};
|
|
4152
4152
|
}
|
|
4153
|
-
function
|
|
4153
|
+
function Zi(e) {
|
|
4154
4154
|
return {
|
|
4155
4155
|
async create(t, n, r, i) {
|
|
4156
4156
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4163,19 +4163,19 @@ function Ji(e) {
|
|
|
4163
4163
|
created_at: a?.created_at ?? o,
|
|
4164
4164
|
updated_at: a?.updated_at ?? o
|
|
4165
4165
|
};
|
|
4166
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4166
|
+
return await e.insertInto("organization_connections").values(s).execute(), H(s, await U(e, t, r.connection_id));
|
|
4167
4167
|
},
|
|
4168
4168
|
async list(t, n) {
|
|
4169
4169
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4170
4170
|
for (let n of r) {
|
|
4171
|
-
let r = await
|
|
4172
|
-
i.push(
|
|
4171
|
+
let r = await U(e, t, n.connection_id);
|
|
4172
|
+
i.push(H(n, r));
|
|
4173
4173
|
}
|
|
4174
4174
|
return i;
|
|
4175
4175
|
},
|
|
4176
4176
|
async get(t, n, r) {
|
|
4177
4177
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4178
|
-
return i ?
|
|
4178
|
+
return i ? H(i, await U(e, t, r)) : null;
|
|
4179
4179
|
},
|
|
4180
4180
|
async update(t, n, r, i) {
|
|
4181
4181
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4183,7 +4183,7 @@ function Ji(e) {
|
|
|
4183
4183
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4184
4184
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4185
4185
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4186
|
-
return s ?
|
|
4186
|
+
return s ? H(s, await U(e, t, r)) : null;
|
|
4187
4187
|
},
|
|
4188
4188
|
async remove(t, n, r) {
|
|
4189
4189
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4193,7 +4193,7 @@ function Ji(e) {
|
|
|
4193
4193
|
}
|
|
4194
4194
|
//#endregion
|
|
4195
4195
|
//#region src/user-organizations/create.ts
|
|
4196
|
-
function
|
|
4196
|
+
function Qi(e) {
|
|
4197
4197
|
return async (n, r, i) => {
|
|
4198
4198
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4199
4199
|
id: a?.id ?? t(),
|
|
@@ -4213,7 +4213,7 @@ function Yi(e) {
|
|
|
4213
4213
|
}
|
|
4214
4214
|
//#endregion
|
|
4215
4215
|
//#region src/user-organizations/get.ts
|
|
4216
|
-
function
|
|
4216
|
+
function $i(e) {
|
|
4217
4217
|
return async (t, n) => {
|
|
4218
4218
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4219
4219
|
return r ? {
|
|
@@ -4227,7 +4227,7 @@ function Xi(e) {
|
|
|
4227
4227
|
}
|
|
4228
4228
|
//#endregion
|
|
4229
4229
|
//#region src/user-organizations/list.ts
|
|
4230
|
-
function
|
|
4230
|
+
function ea(e) {
|
|
4231
4231
|
return async (t, n) => {
|
|
4232
4232
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4233
4233
|
if (n?.q) {
|
|
@@ -4246,8 +4246,8 @@ function Zi(e) {
|
|
|
4246
4246
|
created_at: e.created_at,
|
|
4247
4247
|
updated_at: e.updated_at
|
|
4248
4248
|
});
|
|
4249
|
-
if (
|
|
4250
|
-
let { rows: e, limit: t, next: a } = await
|
|
4249
|
+
if (N(n)) {
|
|
4250
|
+
let { rows: e, limit: t, next: a } = await P(r, n, {
|
|
4251
4251
|
sortColumn: "created_at",
|
|
4252
4252
|
sortOrder: "desc"
|
|
4253
4253
|
});
|
|
@@ -4280,7 +4280,7 @@ function Zi(e) {
|
|
|
4280
4280
|
}
|
|
4281
4281
|
//#endregion
|
|
4282
4282
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4283
|
-
function
|
|
4283
|
+
function ta(e) {
|
|
4284
4284
|
return async (t, n, r) => {
|
|
4285
4285
|
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
4286
|
"organizations.id",
|
|
@@ -4317,12 +4317,12 @@ function Qi(e) {
|
|
|
4317
4317
|
}
|
|
4318
4318
|
//#endregion
|
|
4319
4319
|
//#region src/user-organizations/remove.ts
|
|
4320
|
-
function
|
|
4320
|
+
function na(e) {
|
|
4321
4321
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4322
4322
|
}
|
|
4323
4323
|
//#endregion
|
|
4324
4324
|
//#region src/user-organizations/update.ts
|
|
4325
|
-
function
|
|
4325
|
+
function ra(e) {
|
|
4326
4326
|
return async (t, n, r) => {
|
|
4327
4327
|
let i = {
|
|
4328
4328
|
...r,
|
|
@@ -4333,21 +4333,21 @@ function ea(e) {
|
|
|
4333
4333
|
}
|
|
4334
4334
|
//#endregion
|
|
4335
4335
|
//#region src/user-organizations/index.ts
|
|
4336
|
-
function
|
|
4336
|
+
function ia(e) {
|
|
4337
4337
|
return {
|
|
4338
|
-
create:
|
|
4339
|
-
get:
|
|
4340
|
-
list:
|
|
4341
|
-
listUserOrganizations:
|
|
4342
|
-
remove:
|
|
4343
|
-
update:
|
|
4338
|
+
create: Qi(e),
|
|
4339
|
+
get: $i(e),
|
|
4340
|
+
list: ea(e),
|
|
4341
|
+
listUserOrganizations: ta(e),
|
|
4342
|
+
remove: na(e),
|
|
4343
|
+
update: ra(e)
|
|
4344
4344
|
};
|
|
4345
4345
|
}
|
|
4346
4346
|
//#endregion
|
|
4347
4347
|
//#region src/invites/create.ts
|
|
4348
|
-
function
|
|
4348
|
+
function aa(e) {
|
|
4349
4349
|
return async (t, n, r) => {
|
|
4350
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4350
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? ke(), 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
4351
|
id: a,
|
|
4352
4352
|
tenant_id: t,
|
|
4353
4353
|
organization_id: n.organization_id,
|
|
@@ -4391,11 +4391,11 @@ function na(e) {
|
|
|
4391
4391
|
}
|
|
4392
4392
|
//#endregion
|
|
4393
4393
|
//#region src/invites/get.ts
|
|
4394
|
-
function
|
|
4394
|
+
function oa(e) {
|
|
4395
4395
|
return async (t, n) => {
|
|
4396
4396
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4397
4397
|
return r ? l({
|
|
4398
|
-
...
|
|
4398
|
+
...mt(r, {
|
|
4399
4399
|
inviter: {},
|
|
4400
4400
|
invitee: {},
|
|
4401
4401
|
app_metadata: {},
|
|
@@ -4408,7 +4408,7 @@ function ra(e) {
|
|
|
4408
4408
|
}
|
|
4409
4409
|
//#endregion
|
|
4410
4410
|
//#region src/invites/list.ts
|
|
4411
|
-
function
|
|
4411
|
+
function sa(e) {
|
|
4412
4412
|
return async (t, n) => {
|
|
4413
4413
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4414
4414
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4416,7 +4416,7 @@ function ia(e) {
|
|
|
4416
4416
|
r = r.offset(e);
|
|
4417
4417
|
}
|
|
4418
4418
|
let i = (await r.execute()).map((e) => l({
|
|
4419
|
-
...
|
|
4419
|
+
...mt(e, {
|
|
4420
4420
|
inviter: {},
|
|
4421
4421
|
invitee: {},
|
|
4422
4422
|
app_metadata: {},
|
|
@@ -4435,12 +4435,12 @@ function ia(e) {
|
|
|
4435
4435
|
}
|
|
4436
4436
|
//#endregion
|
|
4437
4437
|
//#region src/invites/remove.ts
|
|
4438
|
-
function
|
|
4438
|
+
function ca(e) {
|
|
4439
4439
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4440
4440
|
}
|
|
4441
4441
|
//#endregion
|
|
4442
4442
|
//#region src/invites/update.ts
|
|
4443
|
-
function
|
|
4443
|
+
function la(e) {
|
|
4444
4444
|
return async (t, n, r) => {
|
|
4445
4445
|
let i = {};
|
|
4446
4446
|
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 +4448,35 @@ function oa(e) {
|
|
|
4448
4448
|
}
|
|
4449
4449
|
//#endregion
|
|
4450
4450
|
//#region src/invites/index.ts
|
|
4451
|
-
function
|
|
4451
|
+
function ua(e) {
|
|
4452
4452
|
return {
|
|
4453
|
-
create:
|
|
4454
|
-
get:
|
|
4455
|
-
list:
|
|
4456
|
-
remove:
|
|
4457
|
-
update:
|
|
4453
|
+
create: aa(e),
|
|
4454
|
+
get: oa(e),
|
|
4455
|
+
list: sa(e),
|
|
4456
|
+
remove: ca(e),
|
|
4457
|
+
update: la(e)
|
|
4458
4458
|
};
|
|
4459
4459
|
}
|
|
4460
4460
|
//#endregion
|
|
4461
4461
|
//#region src/stats/index.ts
|
|
4462
|
-
var
|
|
4463
|
-
function
|
|
4462
|
+
var da = ["s"], fa = ["pwd_leak"];
|
|
4463
|
+
function pa(e) {
|
|
4464
4464
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4465
4465
|
}
|
|
4466
|
-
function
|
|
4466
|
+
function ma(e) {
|
|
4467
4467
|
return e.toISOString().split("T")[0];
|
|
4468
4468
|
}
|
|
4469
|
-
function
|
|
4469
|
+
function ha(e) {
|
|
4470
4470
|
return {
|
|
4471
4471
|
async getDaily(t, n = {}) {
|
|
4472
4472
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4473
4473
|
o.setDate(o.getDate() - 30);
|
|
4474
|
-
let s = r ?
|
|
4474
|
+
let s = r ? pa(r) : ma(o), c = i ? pa(i) : ma(a), l = f`DATE(logs.date)`;
|
|
4475
4475
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4476
4476
|
l.as("date"),
|
|
4477
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4477
|
+
e.fn.sum(e.case().when("type", "in", da).then(1).else(0).end()).as("logins"),
|
|
4478
4478
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4479
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4479
|
+
e.fn.sum(e.case().when("type", "in", fa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4480
4480
|
e.fn.min("date").as("first_event"),
|
|
4481
4481
|
e.fn.max("date").as("last_event")
|
|
4482
4482
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4490,13 +4490,13 @@ function fa(e) {
|
|
|
4490
4490
|
},
|
|
4491
4491
|
async getActiveUsers(t) {
|
|
4492
4492
|
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",
|
|
4493
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", da).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4494
4494
|
}
|
|
4495
4495
|
};
|
|
4496
4496
|
}
|
|
4497
4497
|
//#endregion
|
|
4498
4498
|
//#region src/analytics/index.ts
|
|
4499
|
-
var
|
|
4499
|
+
var ga = {
|
|
4500
4500
|
"active-users": ["s", "seacft"],
|
|
4501
4501
|
logins: [
|
|
4502
4502
|
"s",
|
|
@@ -4526,7 +4526,7 @@ var pa = {
|
|
|
4526
4526
|
"fvr"
|
|
4527
4527
|
],
|
|
4528
4528
|
"codes-sent": ["cls", "cs"]
|
|
4529
|
-
},
|
|
4529
|
+
}, _a = {
|
|
4530
4530
|
"active-users": {
|
|
4531
4531
|
alias: "active_users",
|
|
4532
4532
|
type: "UInt64",
|
|
@@ -4583,14 +4583,14 @@ var pa = {
|
|
|
4583
4583
|
agg: "count"
|
|
4584
4584
|
}
|
|
4585
4585
|
};
|
|
4586
|
-
async function
|
|
4586
|
+
async function va(e) {
|
|
4587
4587
|
try {
|
|
4588
4588
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4589
4589
|
} catch {
|
|
4590
4590
|
return "sqlite";
|
|
4591
4591
|
}
|
|
4592
4592
|
}
|
|
4593
|
-
function
|
|
4593
|
+
function W(e, t) {
|
|
4594
4594
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4595
4595
|
timeZone: e,
|
|
4596
4596
|
year: "numeric",
|
|
@@ -4605,7 +4605,7 @@ function U(e, t) {
|
|
|
4605
4605
|
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
4606
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4607
4607
|
}
|
|
4608
|
-
var
|
|
4608
|
+
var ya = [
|
|
4609
4609
|
"January",
|
|
4610
4610
|
"February",
|
|
4611
4611
|
"March",
|
|
@@ -4619,22 +4619,22 @@ var ga = [
|
|
|
4619
4619
|
"November",
|
|
4620
4620
|
"December"
|
|
4621
4621
|
];
|
|
4622
|
-
function
|
|
4623
|
-
let n = t.getUTCFullYear(), r =
|
|
4622
|
+
function ba(e, t) {
|
|
4623
|
+
let n = t.getUTCFullYear(), r = W(e, new Date(Date.UTC(n, 0, 1)));
|
|
4624
4624
|
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 ${
|
|
4625
|
+
let i = W(e, new Date(Date.UTC(n, t, 1)));
|
|
4626
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${ya[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
4627
|
}
|
|
4628
4628
|
}
|
|
4629
|
-
function
|
|
4629
|
+
function xa(e) {
|
|
4630
4630
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4631
4631
|
return t * (Number(n) * 60 + Number(r));
|
|
4632
4632
|
}
|
|
4633
|
-
function
|
|
4633
|
+
function Sa(e, t) {
|
|
4634
4634
|
let n;
|
|
4635
4635
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4636
4636
|
else {
|
|
4637
|
-
let e =
|
|
4637
|
+
let e = xa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4638
4638
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4639
4639
|
}
|
|
4640
4640
|
switch (e) {
|
|
@@ -4645,7 +4645,7 @@ function ya(e, t) {
|
|
|
4645
4645
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4646
4646
|
}
|
|
4647
4647
|
}
|
|
4648
|
-
function
|
|
4648
|
+
function Ca(e, t) {
|
|
4649
4649
|
if (t === "+00:00") switch (e) {
|
|
4650
4650
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4651
4651
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4656,7 +4656,7 @@ function ba(e, t) {
|
|
|
4656
4656
|
}
|
|
4657
4657
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4658
4658
|
}
|
|
4659
|
-
let n =
|
|
4659
|
+
let n = xa(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
4660
|
switch (e) {
|
|
4661
4661
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4662
4662
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4665,12 +4665,12 @@ function ba(e, t) {
|
|
|
4665
4665
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4666
4666
|
}
|
|
4667
4667
|
}
|
|
4668
|
-
function
|
|
4669
|
-
|
|
4670
|
-
let i =
|
|
4671
|
-
return r === "mysql" ?
|
|
4668
|
+
function wa(e, t, n, r) {
|
|
4669
|
+
ba(t, n);
|
|
4670
|
+
let i = W(t, n);
|
|
4671
|
+
return r === "mysql" ? Ca(e, i) : Sa(e, i);
|
|
4672
4672
|
}
|
|
4673
|
-
function
|
|
4673
|
+
function Ta(e) {
|
|
4674
4674
|
switch (e) {
|
|
4675
4675
|
case "connection": return "logs.connection";
|
|
4676
4676
|
case "client_id": return "logs.client_id";
|
|
@@ -4679,65 +4679,82 @@ function Sa(e) {
|
|
|
4679
4679
|
case "time": throw Error("time dimension is handled separately");
|
|
4680
4680
|
}
|
|
4681
4681
|
}
|
|
4682
|
-
function
|
|
4683
|
-
let t = null, n = () => (t ||=
|
|
4684
|
-
return {
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
let e
|
|
4682
|
+
function Ea(e) {
|
|
4683
|
+
let t = null, n = () => (t ||= va(e), t);
|
|
4684
|
+
return {
|
|
4685
|
+
async query(t, r, i) {
|
|
4686
|
+
let a = Date.now(), o = ga[r], s = _a[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4687
|
+
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
|
+
let d = [], p = [];
|
|
4689
|
+
for (let e of i.group_by) if (e === "time") {
|
|
4690
|
+
let e = wa(i.interval, i.tz, new Date(i.from), c);
|
|
4691
|
+
p.push({
|
|
4692
|
+
alias: "time",
|
|
4693
|
+
expr: e
|
|
4694
|
+
}), d.push(e), l.push({
|
|
4695
|
+
name: "time",
|
|
4696
|
+
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4697
|
+
});
|
|
4698
|
+
} else {
|
|
4699
|
+
let t = Ta(e);
|
|
4700
|
+
p.push({
|
|
4701
|
+
alias: e,
|
|
4702
|
+
expr: f`${f.ref(t)}`
|
|
4703
|
+
}), d.push(f`${f.ref(t)}`), l.push({
|
|
4704
|
+
name: e,
|
|
4705
|
+
type: "String"
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
let m = s.agg === "uniq" ? f`COUNT(DISTINCT ${f.ref("logs.user_id")})` : f`COUNT(*)`;
|
|
4690
4709
|
p.push({
|
|
4691
|
-
alias:
|
|
4692
|
-
expr:
|
|
4693
|
-
}),
|
|
4694
|
-
name:
|
|
4695
|
-
type:
|
|
4710
|
+
alias: s.alias,
|
|
4711
|
+
expr: m
|
|
4712
|
+
}), l.push({
|
|
4713
|
+
name: s.alias,
|
|
4714
|
+
type: s.type
|
|
4696
4715
|
});
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4716
|
+
let h = u.select(p.map(({ alias: e, expr: t }) => t.as(e)));
|
|
4717
|
+
if (d.length > 0 && (h = h.groupBy(d)), i.order_by) {
|
|
4718
|
+
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4719
|
+
h = h.orderBy(t, e ? "desc" : "asc");
|
|
4720
|
+
} else h = i.group_by.length > 0 && i.group_by[0] === "time" ? h.orderBy("time", "asc") : h.orderBy(s.alias, "desc");
|
|
4721
|
+
h = h.limit(i.limit).offset(i.offset);
|
|
4722
|
+
let g = (await h.execute()).map((e) => {
|
|
4723
|
+
let t = {};
|
|
4724
|
+
for (let n of l) {
|
|
4725
|
+
let r = e[n.name];
|
|
4726
|
+
t[n.name] = n.type === "UInt64" ? Number(r) || 0 : r ?? "";
|
|
4727
|
+
}
|
|
4728
|
+
return t;
|
|
4705
4729
|
});
|
|
4730
|
+
return {
|
|
4731
|
+
meta: l,
|
|
4732
|
+
data: g,
|
|
4733
|
+
rows: g.length,
|
|
4734
|
+
rows_before_limit_at_least: g.length,
|
|
4735
|
+
statistics: { elapsed: (Date.now() - a) / 1e3 }
|
|
4736
|
+
};
|
|
4737
|
+
},
|
|
4738
|
+
async sessionRetention(t, r) {
|
|
4739
|
+
let i = Date.now(), { sinceMs: a } = pe(r.weeks, i), o = await n(), s = (e) => {
|
|
4740
|
+
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
|
+
return o === "mysql" ? f`${t} DIV ${f.lit(h)}` : f`${t} / ${f.lit(h)}`;
|
|
4742
|
+
};
|
|
4743
|
+
return g((await e.selectFrom("sessions").where("tenant_id", "=", t).where("created_at_ts", ">=", a).select([
|
|
4744
|
+
s("created_at_ts").as("created_week"),
|
|
4745
|
+
s("used_at_ts").as("used_week"),
|
|
4746
|
+
f`COUNT(*)`.as("count")
|
|
4747
|
+
]).groupBy([s("created_at_ts"), s("used_at_ts")]).execute()).map((e) => ({
|
|
4748
|
+
created_week: Math.floor(Number(e.created_week)),
|
|
4749
|
+
used_week: Math.floor(Number(e.used_week)),
|
|
4750
|
+
count: Number(e.count)
|
|
4751
|
+
})), r.weeks, i);
|
|
4706
4752
|
}
|
|
4707
|
-
|
|
4708
|
-
p.push({
|
|
4709
|
-
alias: s.alias,
|
|
4710
|
-
expr: m
|
|
4711
|
-
}), l.push({
|
|
4712
|
-
name: s.alias,
|
|
4713
|
-
type: s.type
|
|
4714
|
-
});
|
|
4715
|
-
let h = u.select(p.map(({ alias: e, expr: t }) => t.as(e)));
|
|
4716
|
-
if (d.length > 0 && (h = h.groupBy(d)), i.order_by) {
|
|
4717
|
-
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4718
|
-
h = h.orderBy(t, e ? "desc" : "asc");
|
|
4719
|
-
} else h = i.group_by.length > 0 && i.group_by[0] === "time" ? h.orderBy("time", "asc") : h.orderBy(s.alias, "desc");
|
|
4720
|
-
h = h.limit(i.limit).offset(i.offset);
|
|
4721
|
-
let g = (await h.execute()).map((e) => {
|
|
4722
|
-
let t = {};
|
|
4723
|
-
for (let n of l) {
|
|
4724
|
-
let r = e[n.name];
|
|
4725
|
-
t[n.name] = n.type === "UInt64" ? Number(r) || 0 : r ?? "";
|
|
4726
|
-
}
|
|
4727
|
-
return t;
|
|
4728
|
-
});
|
|
4729
|
-
return {
|
|
4730
|
-
meta: l,
|
|
4731
|
-
data: g,
|
|
4732
|
-
rows: g.length,
|
|
4733
|
-
rows_before_limit_at_least: g.length,
|
|
4734
|
-
statistics: { elapsed: (Date.now() - a) / 1e3 }
|
|
4735
|
-
};
|
|
4736
|
-
} };
|
|
4753
|
+
};
|
|
4737
4754
|
}
|
|
4738
4755
|
//#endregion
|
|
4739
4756
|
//#region src/customText/index.ts
|
|
4740
|
-
function
|
|
4757
|
+
function Da(e) {
|
|
4741
4758
|
return {
|
|
4742
4759
|
async get(t, n, r) {
|
|
4743
4760
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4776,9 +4793,9 @@ function wa(e) {
|
|
|
4776
4793
|
}
|
|
4777
4794
|
//#endregion
|
|
4778
4795
|
//#region src/authenticationMethods/create.ts
|
|
4779
|
-
function
|
|
4796
|
+
function Oa(e) {
|
|
4780
4797
|
return async (t, n, r) => {
|
|
4781
|
-
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 ??
|
|
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 ?? Or();
|
|
4782
4799
|
return await e.insertInto("authentication_methods").values({
|
|
4783
4800
|
id: s,
|
|
4784
4801
|
tenant_id: t,
|
|
@@ -4815,7 +4832,7 @@ function Ta(e) {
|
|
|
4815
4832
|
}
|
|
4816
4833
|
//#endregion
|
|
4817
4834
|
//#region src/authenticationMethods/get.ts
|
|
4818
|
-
function
|
|
4835
|
+
function ka(e) {
|
|
4819
4836
|
return async (t, n) => {
|
|
4820
4837
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4821
4838
|
return r ? {
|
|
@@ -4838,7 +4855,7 @@ function Ea(e) {
|
|
|
4838
4855
|
}
|
|
4839
4856
|
//#endregion
|
|
4840
4857
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4841
|
-
function
|
|
4858
|
+
function Aa(e) {
|
|
4842
4859
|
return async (t, n) => {
|
|
4843
4860
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4844
4861
|
return r ? {
|
|
@@ -4861,7 +4878,7 @@ function Da(e) {
|
|
|
4861
4878
|
}
|
|
4862
4879
|
//#endregion
|
|
4863
4880
|
//#region src/authenticationMethods/list.ts
|
|
4864
|
-
function
|
|
4881
|
+
function ja(e) {
|
|
4865
4882
|
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) => ({
|
|
4866
4883
|
id: e.id,
|
|
4867
4884
|
user_id: e.user_id,
|
|
@@ -4881,35 +4898,35 @@ function Oa(e) {
|
|
|
4881
4898
|
}
|
|
4882
4899
|
//#endregion
|
|
4883
4900
|
//#region src/authenticationMethods/update.ts
|
|
4884
|
-
function
|
|
4901
|
+
function Ma(e) {
|
|
4885
4902
|
return async (t, n, r) => {
|
|
4886
4903
|
let i = { updated_at_ts: Date.now() };
|
|
4887
4904
|
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();
|
|
4888
|
-
let a = await
|
|
4905
|
+
let a = await ka(e)(t, n);
|
|
4889
4906
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4890
4907
|
return a;
|
|
4891
4908
|
};
|
|
4892
4909
|
}
|
|
4893
4910
|
//#endregion
|
|
4894
4911
|
//#region src/authenticationMethods/remove.ts
|
|
4895
|
-
function
|
|
4912
|
+
function Na(e) {
|
|
4896
4913
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4897
4914
|
}
|
|
4898
4915
|
//#endregion
|
|
4899
4916
|
//#region src/authenticationMethods/index.ts
|
|
4900
|
-
function
|
|
4917
|
+
function Pa(e) {
|
|
4901
4918
|
return {
|
|
4902
|
-
create:
|
|
4903
|
-
get:
|
|
4904
|
-
getByCredentialId:
|
|
4905
|
-
list:
|
|
4906
|
-
update:
|
|
4907
|
-
remove:
|
|
4919
|
+
create: Oa(e),
|
|
4920
|
+
get: ka(e),
|
|
4921
|
+
getByCredentialId: Aa(e),
|
|
4922
|
+
list: ja(e),
|
|
4923
|
+
update: Ma(e),
|
|
4924
|
+
remove: Na(e)
|
|
4908
4925
|
};
|
|
4909
4926
|
}
|
|
4910
4927
|
//#endregion
|
|
4911
4928
|
//#region src/outbox/getByIds.ts
|
|
4912
|
-
function
|
|
4929
|
+
function Fa(e) {
|
|
4913
4930
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4914
4931
|
...JSON.parse(e.payload),
|
|
4915
4932
|
id: e.id,
|
|
@@ -4922,7 +4939,7 @@ function Ma(e) {
|
|
|
4922
4939
|
}
|
|
4923
4940
|
//#endregion
|
|
4924
4941
|
//#region src/outbox/getUnprocessed.ts
|
|
4925
|
-
function
|
|
4942
|
+
function Ia(e) {
|
|
4926
4943
|
return async (t) => {
|
|
4927
4944
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4928
4945
|
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) => ({
|
|
@@ -4938,7 +4955,7 @@ function Na(e) {
|
|
|
4938
4955
|
}
|
|
4939
4956
|
//#endregion
|
|
4940
4957
|
//#region src/outbox/claimEvents.ts
|
|
4941
|
-
function
|
|
4958
|
+
function La(e) {
|
|
4942
4959
|
return async (t, n, r) => {
|
|
4943
4960
|
if (t.length === 0) return [];
|
|
4944
4961
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4950,7 +4967,7 @@ function Pa(e) {
|
|
|
4950
4967
|
}
|
|
4951
4968
|
//#endregion
|
|
4952
4969
|
//#region src/outbox/markProcessed.ts
|
|
4953
|
-
function
|
|
4970
|
+
function Ra(e) {
|
|
4954
4971
|
return async (t) => {
|
|
4955
4972
|
if (t.length === 0) return;
|
|
4956
4973
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4959,7 +4976,7 @@ function Fa(e) {
|
|
|
4959
4976
|
}
|
|
4960
4977
|
//#endregion
|
|
4961
4978
|
//#region src/outbox/markRetry.ts
|
|
4962
|
-
function
|
|
4979
|
+
function za(e) {
|
|
4963
4980
|
return async (t, n, r) => {
|
|
4964
4981
|
await e.updateTable("outbox_events").set({
|
|
4965
4982
|
error: n,
|
|
@@ -4972,7 +4989,7 @@ function Ia(e) {
|
|
|
4972
4989
|
}
|
|
4973
4990
|
//#endregion
|
|
4974
4991
|
//#region src/outbox/deadLetter.ts
|
|
4975
|
-
function
|
|
4992
|
+
function Ba(e) {
|
|
4976
4993
|
return async (t, n) => {
|
|
4977
4994
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4978
4995
|
await e.updateTable("outbox_events").set({
|
|
@@ -4984,7 +5001,7 @@ function La(e) {
|
|
|
4984
5001
|
}
|
|
4985
5002
|
//#endregion
|
|
4986
5003
|
//#region src/outbox/listFailed.ts
|
|
4987
|
-
function
|
|
5004
|
+
function Va(e) {
|
|
4988
5005
|
return async (t, n = {}) => {
|
|
4989
5006
|
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) => {
|
|
4990
5007
|
let t;
|
|
@@ -5019,7 +5036,7 @@ function Ra(e) {
|
|
|
5019
5036
|
}
|
|
5020
5037
|
//#endregion
|
|
5021
5038
|
//#region src/outbox/replay.ts
|
|
5022
|
-
function
|
|
5039
|
+
function Ha(e) {
|
|
5023
5040
|
return async (t, n) => {
|
|
5024
5041
|
let r = await e.updateTable("outbox_events").set({
|
|
5025
5042
|
processed_at: null,
|
|
@@ -5034,7 +5051,7 @@ function za(e) {
|
|
|
5034
5051
|
}
|
|
5035
5052
|
//#endregion
|
|
5036
5053
|
//#region src/outbox/cleanup.ts
|
|
5037
|
-
function
|
|
5054
|
+
function Ua(e) {
|
|
5038
5055
|
return async (t) => {
|
|
5039
5056
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5040
5057
|
return Number(n.numDeletedRows);
|
|
@@ -5042,23 +5059,23 @@ function Ba(e) {
|
|
|
5042
5059
|
}
|
|
5043
5060
|
//#endregion
|
|
5044
5061
|
//#region src/outbox/index.ts
|
|
5045
|
-
function
|
|
5062
|
+
function Wa(e) {
|
|
5046
5063
|
return {
|
|
5047
|
-
create:
|
|
5048
|
-
getByIds:
|
|
5049
|
-
getUnprocessed:
|
|
5050
|
-
claimEvents:
|
|
5051
|
-
markProcessed:
|
|
5052
|
-
markRetry:
|
|
5053
|
-
deadLetter:
|
|
5054
|
-
listFailed:
|
|
5055
|
-
replay:
|
|
5056
|
-
cleanup:
|
|
5064
|
+
create: qe(e),
|
|
5065
|
+
getByIds: Fa(e),
|
|
5066
|
+
getUnprocessed: Ia(e),
|
|
5067
|
+
claimEvents: La(e),
|
|
5068
|
+
markProcessed: Ra(e),
|
|
5069
|
+
markRetry: za(e),
|
|
5070
|
+
deadLetter: Ba(e),
|
|
5071
|
+
listFailed: Va(e),
|
|
5072
|
+
replay: Ha(e),
|
|
5073
|
+
cleanup: Ua(e)
|
|
5057
5074
|
};
|
|
5058
5075
|
}
|
|
5059
5076
|
//#endregion
|
|
5060
5077
|
//#region src/log-streams/index.ts
|
|
5061
|
-
function
|
|
5078
|
+
function G(e) {
|
|
5062
5079
|
return {
|
|
5063
5080
|
id: e.id,
|
|
5064
5081
|
name: e.name,
|
|
@@ -5071,7 +5088,7 @@ function W(e) {
|
|
|
5071
5088
|
updated_at: e.updated_at
|
|
5072
5089
|
};
|
|
5073
5090
|
}
|
|
5074
|
-
function
|
|
5091
|
+
function Ga(e) {
|
|
5075
5092
|
return {
|
|
5076
5093
|
async create(n, r, i) {
|
|
5077
5094
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5086,14 +5103,14 @@ function Ha(e) {
|
|
|
5086
5103
|
created_at: a?.created_at ?? o,
|
|
5087
5104
|
updated_at: a?.updated_at ?? o
|
|
5088
5105
|
};
|
|
5089
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5106
|
+
return await e.insertInto("log_streams").values(s).execute(), G(s);
|
|
5090
5107
|
},
|
|
5091
5108
|
async get(t, n) {
|
|
5092
5109
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5093
|
-
return r ?
|
|
5110
|
+
return r ? G(r) : null;
|
|
5094
5111
|
},
|
|
5095
5112
|
async list(t) {
|
|
5096
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5113
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(G);
|
|
5097
5114
|
},
|
|
5098
5115
|
async update(t, n, r) {
|
|
5099
5116
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5106,11 +5123,11 @@ function Ha(e) {
|
|
|
5106
5123
|
}
|
|
5107
5124
|
//#endregion
|
|
5108
5125
|
//#region src/migrationSources/index.ts
|
|
5109
|
-
function
|
|
5126
|
+
function K(e) {
|
|
5110
5127
|
return {
|
|
5111
5128
|
id: e.id,
|
|
5112
5129
|
name: e.name,
|
|
5113
|
-
provider:
|
|
5130
|
+
provider: se.parse(e.provider),
|
|
5114
5131
|
connection: e.connection,
|
|
5115
5132
|
enabled: e.enabled === 1,
|
|
5116
5133
|
credentials: JSON.parse(e.credentials),
|
|
@@ -5118,7 +5135,7 @@ function G(e) {
|
|
|
5118
5135
|
updated_at: e.updated_at
|
|
5119
5136
|
};
|
|
5120
5137
|
}
|
|
5121
|
-
function
|
|
5138
|
+
function Ka(e) {
|
|
5122
5139
|
return {
|
|
5123
5140
|
async create(n, r, i) {
|
|
5124
5141
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5132,14 +5149,14 @@ function Ua(e) {
|
|
|
5132
5149
|
created_at: a?.created_at ?? o,
|
|
5133
5150
|
updated_at: a?.updated_at ?? o
|
|
5134
5151
|
};
|
|
5135
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5152
|
+
return await e.insertInto("migration_sources").values(l).execute(), K(l);
|
|
5136
5153
|
},
|
|
5137
5154
|
async get(t, n) {
|
|
5138
5155
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5139
|
-
return r ?
|
|
5156
|
+
return r ? K(r) : null;
|
|
5140
5157
|
},
|
|
5141
5158
|
async list(t) {
|
|
5142
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5159
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(K);
|
|
5143
5160
|
},
|
|
5144
5161
|
async update(t, n, r) {
|
|
5145
5162
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5152,34 +5169,34 @@ function Ua(e) {
|
|
|
5152
5169
|
}
|
|
5153
5170
|
//#endregion
|
|
5154
5171
|
//#region src/proxyRoutes/serialize.ts
|
|
5155
|
-
function
|
|
5172
|
+
function q(e) {
|
|
5156
5173
|
return {
|
|
5157
5174
|
id: e.id,
|
|
5158
5175
|
tenant_id: e.tenant_id,
|
|
5159
5176
|
custom_domain_id: e.custom_domain_id,
|
|
5160
5177
|
priority: e.priority,
|
|
5161
|
-
match:
|
|
5162
|
-
handlers:
|
|
5178
|
+
match: qa(e.match),
|
|
5179
|
+
handlers: Ja(e.handlers),
|
|
5163
5180
|
created_at: e.created_at,
|
|
5164
5181
|
updated_at: e.updated_at
|
|
5165
5182
|
};
|
|
5166
5183
|
}
|
|
5167
|
-
function
|
|
5184
|
+
function qa(e) {
|
|
5168
5185
|
if (!e) return { path: "/*" };
|
|
5169
5186
|
try {
|
|
5170
|
-
let t = JSON.parse(e), n =
|
|
5187
|
+
let t = JSON.parse(e), n = oe.safeParse(t);
|
|
5171
5188
|
if (n.success) return n.data;
|
|
5172
5189
|
} catch {}
|
|
5173
5190
|
return { path: "/*" };
|
|
5174
5191
|
}
|
|
5175
|
-
function
|
|
5192
|
+
function Ja(e) {
|
|
5176
5193
|
if (!e) return [];
|
|
5177
5194
|
try {
|
|
5178
5195
|
let t = JSON.parse(e);
|
|
5179
5196
|
if (!Array.isArray(t)) return [];
|
|
5180
5197
|
let n = [];
|
|
5181
5198
|
for (let e of t) {
|
|
5182
|
-
let t =
|
|
5199
|
+
let t = re.safeParse(e);
|
|
5183
5200
|
t.success && n.push(t.data);
|
|
5184
5201
|
}
|
|
5185
5202
|
return n;
|
|
@@ -5189,7 +5206,7 @@ function Ga(e) {
|
|
|
5189
5206
|
}
|
|
5190
5207
|
//#endregion
|
|
5191
5208
|
//#region src/proxyRoutes/adapter.ts
|
|
5192
|
-
function
|
|
5209
|
+
function J(e) {
|
|
5193
5210
|
return {
|
|
5194
5211
|
async create(n, r, i) {
|
|
5195
5212
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5215,14 +5232,14 @@ function q(e) {
|
|
|
5215
5232
|
},
|
|
5216
5233
|
async get(t, n) {
|
|
5217
5234
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5218
|
-
return r ?
|
|
5235
|
+
return r ? q(r) : null;
|
|
5219
5236
|
},
|
|
5220
5237
|
async list(t, n = {}) {
|
|
5221
5238
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5222
5239
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5223
5240
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5224
5241
|
return {
|
|
5225
|
-
proxy_routes: o.map(
|
|
5242
|
+
proxy_routes: o.map(q),
|
|
5226
5243
|
start: r * i,
|
|
5227
5244
|
limit: i,
|
|
5228
5245
|
length: o.length
|
|
@@ -5242,7 +5259,7 @@ function q(e) {
|
|
|
5242
5259
|
}
|
|
5243
5260
|
//#endregion
|
|
5244
5261
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5245
|
-
async function
|
|
5262
|
+
async function Ya(e, t) {
|
|
5246
5263
|
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([
|
|
5247
5264
|
"custom_domain_id",
|
|
5248
5265
|
"tenant_id",
|
|
@@ -5254,27 +5271,27 @@ async function Ka(e, t) {
|
|
|
5254
5271
|
tenant_id: a.tenant_id,
|
|
5255
5272
|
custom_domain_id: a.custom_domain_id,
|
|
5256
5273
|
domain: a.domain,
|
|
5257
|
-
routes: o.map(
|
|
5274
|
+
routes: o.map(q)
|
|
5258
5275
|
};
|
|
5259
5276
|
}
|
|
5260
5277
|
//#endregion
|
|
5261
5278
|
//#region src/proxyRoutes/index.ts
|
|
5262
|
-
function
|
|
5279
|
+
function Xa(e) {
|
|
5263
5280
|
return {
|
|
5264
|
-
proxyRoutes:
|
|
5265
|
-
resolveHost: (t) =>
|
|
5281
|
+
proxyRoutes: J(e),
|
|
5282
|
+
resolveHost: (t) => Ya(e, t)
|
|
5266
5283
|
};
|
|
5267
5284
|
}
|
|
5268
5285
|
//#endregion
|
|
5269
5286
|
//#region src/scim/adapter.ts
|
|
5270
|
-
function
|
|
5287
|
+
function Za(e) {
|
|
5271
5288
|
if (!e) return [];
|
|
5272
5289
|
try {
|
|
5273
5290
|
let t = JSON.parse(e);
|
|
5274
5291
|
if (!Array.isArray(t)) return [];
|
|
5275
5292
|
let n = [];
|
|
5276
5293
|
for (let e of t) {
|
|
5277
|
-
let t =
|
|
5294
|
+
let t = fe.safeParse(e);
|
|
5278
5295
|
t.success && n.push(t.data);
|
|
5279
5296
|
}
|
|
5280
5297
|
return n;
|
|
@@ -5282,7 +5299,7 @@ function Ja(e) {
|
|
|
5282
5299
|
return [];
|
|
5283
5300
|
}
|
|
5284
5301
|
}
|
|
5285
|
-
function
|
|
5302
|
+
function Qa(e) {
|
|
5286
5303
|
if (!e) return [];
|
|
5287
5304
|
try {
|
|
5288
5305
|
let t = JSON.parse(e);
|
|
@@ -5291,16 +5308,16 @@ function Ya(e) {
|
|
|
5291
5308
|
return [];
|
|
5292
5309
|
}
|
|
5293
5310
|
}
|
|
5294
|
-
function
|
|
5311
|
+
function $a(e) {
|
|
5295
5312
|
return {
|
|
5296
5313
|
connection_id: e.connection_id,
|
|
5297
5314
|
user_id_attribute: e.user_id_attribute,
|
|
5298
|
-
mapping:
|
|
5315
|
+
mapping: Za(e.mapping),
|
|
5299
5316
|
created_at: e.created_at,
|
|
5300
5317
|
updated_at: e.updated_at
|
|
5301
5318
|
};
|
|
5302
5319
|
}
|
|
5303
|
-
function
|
|
5320
|
+
function eo(e) {
|
|
5304
5321
|
return {
|
|
5305
5322
|
async create(t, n) {
|
|
5306
5323
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5321,7 +5338,7 @@ function Za(e) {
|
|
|
5321
5338
|
},
|
|
5322
5339
|
async get(t, n) {
|
|
5323
5340
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5324
|
-
return r ?
|
|
5341
|
+
return r ? $a(r) : null;
|
|
5325
5342
|
},
|
|
5326
5343
|
async update(t, n, r) {
|
|
5327
5344
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5335,18 +5352,18 @@ function Za(e) {
|
|
|
5335
5352
|
}
|
|
5336
5353
|
};
|
|
5337
5354
|
}
|
|
5338
|
-
function
|
|
5355
|
+
function Y(e) {
|
|
5339
5356
|
return {
|
|
5340
5357
|
token_id: e.token_id,
|
|
5341
5358
|
connection_id: e.connection_id,
|
|
5342
5359
|
token_hash: e.token_hash,
|
|
5343
|
-
scopes:
|
|
5360
|
+
scopes: Qa(e.scopes),
|
|
5344
5361
|
valid_until: e.valid_until ?? void 0,
|
|
5345
5362
|
created_at: e.created_at,
|
|
5346
5363
|
last_used_at: e.last_used_at ?? void 0
|
|
5347
5364
|
};
|
|
5348
5365
|
}
|
|
5349
|
-
function
|
|
5366
|
+
function to(e) {
|
|
5350
5367
|
return {
|
|
5351
5368
|
async create(t, n) {
|
|
5352
5369
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5370,14 +5387,14 @@ function Qa(e) {
|
|
|
5370
5387
|
},
|
|
5371
5388
|
async get(t, n) {
|
|
5372
5389
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5373
|
-
return r ?
|
|
5390
|
+
return r ? Y(r) : null;
|
|
5374
5391
|
},
|
|
5375
5392
|
async getByHash(t, n) {
|
|
5376
5393
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5377
|
-
return r ?
|
|
5394
|
+
return r ? Y(r) : null;
|
|
5378
5395
|
},
|
|
5379
5396
|
async listByConnection(t, n) {
|
|
5380
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5397
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Y);
|
|
5381
5398
|
},
|
|
5382
5399
|
async markUsed(t, n, r) {
|
|
5383
5400
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5389,7 +5406,7 @@ function Qa(e) {
|
|
|
5389
5406
|
}
|
|
5390
5407
|
};
|
|
5391
5408
|
}
|
|
5392
|
-
function
|
|
5409
|
+
function no(e) {
|
|
5393
5410
|
return {
|
|
5394
5411
|
connection_id: e.connection_id,
|
|
5395
5412
|
external_id: e.external_id,
|
|
@@ -5397,7 +5414,7 @@ function $a(e) {
|
|
|
5397
5414
|
created_at: e.created_at
|
|
5398
5415
|
};
|
|
5399
5416
|
}
|
|
5400
|
-
function
|
|
5417
|
+
function ro(e) {
|
|
5401
5418
|
return {
|
|
5402
5419
|
async create(t, n) {
|
|
5403
5420
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5416,11 +5433,11 @@ function eo(e) {
|
|
|
5416
5433
|
},
|
|
5417
5434
|
async getByExternalId(t, n, r) {
|
|
5418
5435
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5419
|
-
return i ?
|
|
5436
|
+
return i ? no(i) : null;
|
|
5420
5437
|
},
|
|
5421
5438
|
async getByUserId(t, n, r) {
|
|
5422
5439
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5423
|
-
return i ?
|
|
5440
|
+
return i ? no(i) : null;
|
|
5424
5441
|
},
|
|
5425
5442
|
async remove(t, n, r) {
|
|
5426
5443
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5430,8 +5447,8 @@ function eo(e) {
|
|
|
5430
5447
|
}
|
|
5431
5448
|
//#endregion
|
|
5432
5449
|
//#region src/tenantOperations/index.ts
|
|
5433
|
-
function
|
|
5434
|
-
return
|
|
5450
|
+
function X(e) {
|
|
5451
|
+
return _e.parse({
|
|
5435
5452
|
id: e.id,
|
|
5436
5453
|
tenant_id: e.tenant_id,
|
|
5437
5454
|
rollout_id: e.rollout_id,
|
|
@@ -5449,10 +5466,10 @@ function Y(e) {
|
|
|
5449
5466
|
finished_at: e.finished_at
|
|
5450
5467
|
});
|
|
5451
5468
|
}
|
|
5452
|
-
function
|
|
5469
|
+
function io(e) {
|
|
5453
5470
|
return {
|
|
5454
5471
|
async create(n) {
|
|
5455
|
-
let r =
|
|
5472
|
+
let r = ge.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5456
5473
|
id: `op_${t()}`,
|
|
5457
5474
|
tenant_id: r.tenant_id,
|
|
5458
5475
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5469,11 +5486,11 @@ function to(e) {
|
|
|
5469
5486
|
updated_at: i,
|
|
5470
5487
|
finished_at: null
|
|
5471
5488
|
};
|
|
5472
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5489
|
+
return await e.insertInto("tenant_operations").values(a).execute(), X(a);
|
|
5473
5490
|
},
|
|
5474
5491
|
async get(t) {
|
|
5475
5492
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5476
|
-
return n ?
|
|
5493
|
+
return n ? X(n) : null;
|
|
5477
5494
|
},
|
|
5478
5495
|
async list(t = {}) {
|
|
5479
5496
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5484,7 +5501,7 @@ function to(e) {
|
|
|
5484
5501
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5485
5502
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5486
5503
|
return {
|
|
5487
|
-
operations: a.map(
|
|
5504
|
+
operations: a.map(X),
|
|
5488
5505
|
start: n * r,
|
|
5489
5506
|
limit: r,
|
|
5490
5507
|
length: a.length
|
|
@@ -5504,27 +5521,27 @@ function to(e) {
|
|
|
5504
5521
|
}
|
|
5505
5522
|
//#endregion
|
|
5506
5523
|
//#region src/utils/monotonic-id.ts
|
|
5507
|
-
var
|
|
5508
|
-
function
|
|
5524
|
+
var ao = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Z = 32, oo = 10, so = 4, co = 10;
|
|
5525
|
+
function lo(e, t) {
|
|
5509
5526
|
let n = "";
|
|
5510
|
-
for (let r = t; r > 0; r--) n =
|
|
5527
|
+
for (let r = t; r > 0; r--) n = ao.charAt(e % Z) + n, e = Math.floor(e / Z);
|
|
5511
5528
|
return n;
|
|
5512
5529
|
}
|
|
5513
|
-
function
|
|
5514
|
-
let e = new Uint8Array(
|
|
5530
|
+
function uo() {
|
|
5531
|
+
let e = new Uint8Array(co);
|
|
5515
5532
|
crypto.getRandomValues(e);
|
|
5516
5533
|
let t = "";
|
|
5517
|
-
for (let n = 0; n <
|
|
5534
|
+
for (let n = 0; n < co; n++) t += ao.charAt(e[n] % Z);
|
|
5518
5535
|
return t;
|
|
5519
5536
|
}
|
|
5520
|
-
var
|
|
5521
|
-
function
|
|
5537
|
+
var fo = 0, po = 0;
|
|
5538
|
+
function mo() {
|
|
5522
5539
|
let e = Date.now();
|
|
5523
|
-
return e ===
|
|
5540
|
+
return e === fo ? po++ : (fo = e, po = 0), lo(e, oo) + lo(po, so) + uo();
|
|
5524
5541
|
}
|
|
5525
5542
|
//#endregion
|
|
5526
5543
|
//#region src/tenantOperationEvents/index.ts
|
|
5527
|
-
function
|
|
5544
|
+
function ho(e) {
|
|
5528
5545
|
if (!e) return null;
|
|
5529
5546
|
try {
|
|
5530
5547
|
let t = JSON.parse(e);
|
|
@@ -5532,22 +5549,22 @@ function uo(e) {
|
|
|
5532
5549
|
} catch {}
|
|
5533
5550
|
return null;
|
|
5534
5551
|
}
|
|
5535
|
-
function
|
|
5536
|
-
return
|
|
5552
|
+
function go(e) {
|
|
5553
|
+
return he.parse({
|
|
5537
5554
|
id: e.id,
|
|
5538
5555
|
operation_id: e.operation_id,
|
|
5539
5556
|
step: e.step,
|
|
5540
5557
|
outcome: e.outcome,
|
|
5541
|
-
detail:
|
|
5558
|
+
detail: ho(e.detail),
|
|
5542
5559
|
attempt: e.attempt,
|
|
5543
5560
|
created_at: e.created_at
|
|
5544
5561
|
});
|
|
5545
5562
|
}
|
|
5546
|
-
function
|
|
5563
|
+
function _o(e) {
|
|
5547
5564
|
return {
|
|
5548
5565
|
async create(t) {
|
|
5549
|
-
let n =
|
|
5550
|
-
id: `evt_${
|
|
5566
|
+
let n = me.parse(t), r = {
|
|
5567
|
+
id: `evt_${mo()}`,
|
|
5551
5568
|
operation_id: n.operation_id,
|
|
5552
5569
|
step: n.step,
|
|
5553
5570
|
outcome: n.outcome,
|
|
@@ -5555,12 +5572,12 @@ function po(e) {
|
|
|
5555
5572
|
attempt: n.attempt,
|
|
5556
5573
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5557
5574
|
};
|
|
5558
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5575
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), go(r);
|
|
5559
5576
|
},
|
|
5560
5577
|
async listByOperation(t, n = {}) {
|
|
5561
5578
|
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();
|
|
5562
5579
|
return {
|
|
5563
|
-
events: a.map(
|
|
5580
|
+
events: a.map(go),
|
|
5564
5581
|
start: r * i,
|
|
5565
5582
|
limit: i,
|
|
5566
5583
|
length: a.length
|
|
@@ -5570,7 +5587,7 @@ function po(e) {
|
|
|
5570
5587
|
}
|
|
5571
5588
|
//#endregion
|
|
5572
5589
|
//#region src/rollouts/index.ts
|
|
5573
|
-
function
|
|
5590
|
+
function vo(e) {
|
|
5574
5591
|
if (!e) return null;
|
|
5575
5592
|
try {
|
|
5576
5593
|
return JSON.parse(e);
|
|
@@ -5578,26 +5595,26 @@ function mo(e) {
|
|
|
5578
5595
|
return null;
|
|
5579
5596
|
}
|
|
5580
5597
|
}
|
|
5581
|
-
function
|
|
5582
|
-
return
|
|
5598
|
+
function yo(e) {
|
|
5599
|
+
return de.parse({
|
|
5583
5600
|
id: e.id,
|
|
5584
5601
|
kind: e.kind,
|
|
5585
5602
|
status: e.status,
|
|
5586
5603
|
target_worker_version: e.target_worker_version,
|
|
5587
5604
|
target_database_version: e.target_database_version,
|
|
5588
5605
|
wave_size: e.wave_size,
|
|
5589
|
-
canary_tenant_ids:
|
|
5590
|
-
filter:
|
|
5606
|
+
canary_tenant_ids: vo(e.canary_tenant_ids),
|
|
5607
|
+
filter: vo(e.filter),
|
|
5591
5608
|
initiated_by: e.initiated_by,
|
|
5592
5609
|
created_at: e.created_at,
|
|
5593
5610
|
updated_at: e.updated_at,
|
|
5594
5611
|
finished_at: e.finished_at
|
|
5595
5612
|
});
|
|
5596
5613
|
}
|
|
5597
|
-
function
|
|
5614
|
+
function bo(e) {
|
|
5598
5615
|
return {
|
|
5599
5616
|
async create(n) {
|
|
5600
|
-
let r =
|
|
5617
|
+
let r = ue.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5601
5618
|
id: `rol_${t()}`,
|
|
5602
5619
|
kind: r.kind,
|
|
5603
5620
|
status: "pending",
|
|
@@ -5611,16 +5628,16 @@ function go(e) {
|
|
|
5611
5628
|
updated_at: i,
|
|
5612
5629
|
finished_at: null
|
|
5613
5630
|
};
|
|
5614
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5631
|
+
return await e.insertInto("rollouts").values(a).execute(), yo(a);
|
|
5615
5632
|
},
|
|
5616
5633
|
async get(t) {
|
|
5617
5634
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5618
|
-
return n ?
|
|
5635
|
+
return n ? yo(n) : null;
|
|
5619
5636
|
},
|
|
5620
5637
|
async list(t = {}) {
|
|
5621
5638
|
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();
|
|
5622
5639
|
return {
|
|
5623
|
-
rollouts: i.map(
|
|
5640
|
+
rollouts: i.map(yo),
|
|
5624
5641
|
start: n * r,
|
|
5625
5642
|
limit: r,
|
|
5626
5643
|
length: i.length
|
|
@@ -5640,7 +5657,7 @@ function go(e) {
|
|
|
5640
5657
|
}
|
|
5641
5658
|
//#endregion
|
|
5642
5659
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5643
|
-
var
|
|
5660
|
+
var xo = class {
|
|
5644
5661
|
migrations;
|
|
5645
5662
|
constructor(e) {
|
|
5646
5663
|
this.migrations = e;
|
|
@@ -5648,10 +5665,10 @@ var _o = class {
|
|
|
5648
5665
|
async getMigrations() {
|
|
5649
5666
|
return this.migrations;
|
|
5650
5667
|
}
|
|
5651
|
-
},
|
|
5652
|
-
down: () =>
|
|
5653
|
-
up: () =>
|
|
5654
|
-
}),
|
|
5668
|
+
}, So = /* @__PURE__ */ w({
|
|
5669
|
+
down: () => Eo,
|
|
5670
|
+
up: () => To
|
|
5671
|
+
}), Co = [
|
|
5655
5672
|
{
|
|
5656
5673
|
table: "authentication_methods",
|
|
5657
5674
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5917,7 +5934,7 @@ var _o = class {
|
|
|
5917
5934
|
onDelete: "cascade"
|
|
5918
5935
|
}
|
|
5919
5936
|
];
|
|
5920
|
-
async function
|
|
5937
|
+
async function wo(e) {
|
|
5921
5938
|
try {
|
|
5922
5939
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5923
5940
|
} catch {
|
|
@@ -5926,14 +5943,14 @@ async function bo(e) {
|
|
|
5926
5943
|
}
|
|
5927
5944
|
function Q(e, t) {
|
|
5928
5945
|
let n = e;
|
|
5929
|
-
for (let e of
|
|
5946
|
+
for (let e of Co) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5930
5947
|
let n = t;
|
|
5931
5948
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5932
5949
|
}));
|
|
5933
5950
|
return n;
|
|
5934
5951
|
}
|
|
5935
|
-
async function
|
|
5936
|
-
let t = await
|
|
5952
|
+
async function To(e) {
|
|
5953
|
+
let t = await wo(e);
|
|
5937
5954
|
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();
|
|
5938
5955
|
{
|
|
5939
5956
|
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"]);
|
|
@@ -6120,40 +6137,40 @@ async function xo(e) {
|
|
|
6120
6137
|
"tenant_id",
|
|
6121
6138
|
"phone_number",
|
|
6122
6139
|
"provider"
|
|
6123
|
-
]).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
|
|
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 Co) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6124
6141
|
let n = e;
|
|
6125
6142
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6126
6143
|
}).execute();
|
|
6127
6144
|
}
|
|
6128
|
-
async function
|
|
6145
|
+
async function Eo(e) {
|
|
6129
6146
|
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();
|
|
6130
6147
|
}
|
|
6131
6148
|
//#endregion
|
|
6132
6149
|
//#region migrate/log.ts
|
|
6133
|
-
var
|
|
6134
|
-
function
|
|
6135
|
-
|
|
6150
|
+
var Do = !1;
|
|
6151
|
+
function Oo(e) {
|
|
6152
|
+
Do = e;
|
|
6136
6153
|
}
|
|
6137
6154
|
function $(...e) {
|
|
6138
|
-
|
|
6155
|
+
Do && console.log(...e);
|
|
6139
6156
|
}
|
|
6140
|
-
function
|
|
6157
|
+
function ko(...e) {
|
|
6141
6158
|
console.warn(...e);
|
|
6142
6159
|
}
|
|
6143
6160
|
//#endregion
|
|
6144
6161
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6145
|
-
var
|
|
6146
|
-
down: () =>
|
|
6147
|
-
up: () =>
|
|
6148
|
-
}),
|
|
6149
|
-
async function
|
|
6162
|
+
var Ao = /* @__PURE__ */ w({
|
|
6163
|
+
down: () => Vo,
|
|
6164
|
+
up: () => Ro
|
|
6165
|
+
}), jo = 5e4, Mo = 500;
|
|
6166
|
+
async function No(e) {
|
|
6150
6167
|
try {
|
|
6151
6168
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6152
6169
|
} catch {
|
|
6153
6170
|
return "sqlite";
|
|
6154
6171
|
}
|
|
6155
6172
|
}
|
|
6156
|
-
async function
|
|
6173
|
+
async function Po(e, t, n) {
|
|
6157
6174
|
try {
|
|
6158
6175
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6159
6176
|
} catch (e) {
|
|
@@ -6164,7 +6181,7 @@ async function Ao(e, t, n) {
|
|
|
6164
6181
|
throw e;
|
|
6165
6182
|
}
|
|
6166
6183
|
}
|
|
6167
|
-
async function
|
|
6184
|
+
async function Fo(e, t, n, r) {
|
|
6168
6185
|
try {
|
|
6169
6186
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6170
6187
|
} catch (e) {
|
|
@@ -6175,21 +6192,21 @@ async function jo(e, t, n, r) {
|
|
|
6175
6192
|
throw e;
|
|
6176
6193
|
}
|
|
6177
6194
|
}
|
|
6178
|
-
async function
|
|
6195
|
+
async function Io(e, t) {
|
|
6179
6196
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6180
6197
|
if (t === "sqlite") {
|
|
6181
6198
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6182
6199
|
r = Number(t.numDeletedRows);
|
|
6183
6200
|
} else {
|
|
6184
|
-
let t =
|
|
6185
|
-
for (; t >=
|
|
6186
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6201
|
+
let t = jo;
|
|
6202
|
+
for (; t >= jo;) {
|
|
6203
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(jo).executeTakeFirst();
|
|
6187
6204
|
t = Number(i.numDeletedRows), r += t, t > 0 && $(` Pruned ${r} expired codes row(s)...`);
|
|
6188
6205
|
}
|
|
6189
6206
|
}
|
|
6190
6207
|
return r;
|
|
6191
6208
|
}
|
|
6192
|
-
async function
|
|
6209
|
+
async function Lo(e) {
|
|
6193
6210
|
let t = 0;
|
|
6194
6211
|
for (;;) {
|
|
6195
6212
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6197,33 +6214,33 @@ async function No(e) {
|
|
|
6197
6214
|
"code_type",
|
|
6198
6215
|
"tenant_id",
|
|
6199
6216
|
"expires_at"
|
|
6200
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6217
|
+
]).where("expires_at_ts", "is", null).limit(Mo).execute();
|
|
6201
6218
|
if (n.length === 0) break;
|
|
6202
6219
|
for (let t of n) {
|
|
6203
6220
|
let n = Date.parse(t.expires_at);
|
|
6204
6221
|
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();
|
|
6205
6222
|
}
|
|
6206
|
-
if (t += n.length, n.length <
|
|
6223
|
+
if (t += n.length, n.length < Mo) break;
|
|
6207
6224
|
}
|
|
6208
6225
|
return t;
|
|
6209
6226
|
}
|
|
6210
|
-
async function
|
|
6211
|
-
let t = await
|
|
6227
|
+
async function Ro(e) {
|
|
6228
|
+
let t = await No(e);
|
|
6212
6229
|
try {
|
|
6213
|
-
let n = await
|
|
6230
|
+
let n = await Io(e, t);
|
|
6214
6231
|
$(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6215
6232
|
} catch (e) {
|
|
6216
|
-
|
|
6233
|
+
ko(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6217
6234
|
}
|
|
6218
|
-
await
|
|
6235
|
+
await Po(e, "codes", "expires_at_ts"), await Fo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6219
6236
|
try {
|
|
6220
|
-
let t = await
|
|
6237
|
+
let t = await Lo(e);
|
|
6221
6238
|
$(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6222
6239
|
} catch (e) {
|
|
6223
|
-
|
|
6240
|
+
ko(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6224
6241
|
}
|
|
6225
6242
|
}
|
|
6226
|
-
async function
|
|
6243
|
+
async function zo(e, t, n) {
|
|
6227
6244
|
try {
|
|
6228
6245
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6229
6246
|
} catch (e) {
|
|
@@ -6231,7 +6248,7 @@ async function Fo(e, t, n) {
|
|
|
6231
6248
|
throw e;
|
|
6232
6249
|
}
|
|
6233
6250
|
}
|
|
6234
|
-
async function
|
|
6251
|
+
async function Bo(e, t, n) {
|
|
6235
6252
|
try {
|
|
6236
6253
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6237
6254
|
} catch (e) {
|
|
@@ -6239,16 +6256,16 @@ async function Io(e, t, n) {
|
|
|
6239
6256
|
throw e;
|
|
6240
6257
|
}
|
|
6241
6258
|
}
|
|
6242
|
-
async function
|
|
6243
|
-
await
|
|
6259
|
+
async function Vo(e) {
|
|
6260
|
+
await zo(e, "idx_codes_expires_at_ts", "codes"), await Bo(e, "codes", "expires_at_ts");
|
|
6244
6261
|
}
|
|
6245
6262
|
//#endregion
|
|
6246
6263
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6247
|
-
var
|
|
6248
|
-
down: () =>
|
|
6249
|
-
up: () =>
|
|
6264
|
+
var Ho = /* @__PURE__ */ w({
|
|
6265
|
+
down: () => Wo,
|
|
6266
|
+
up: () => Uo
|
|
6250
6267
|
});
|
|
6251
|
-
async function
|
|
6268
|
+
async function Uo(e) {
|
|
6252
6269
|
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", [
|
|
6253
6270
|
"tenant_id",
|
|
6254
6271
|
"connection_id",
|
|
@@ -6259,16 +6276,16 @@ async function zo(e) {
|
|
|
6259
6276
|
"external_id"
|
|
6260
6277
|
]).unique().execute();
|
|
6261
6278
|
}
|
|
6262
|
-
async function
|
|
6279
|
+
async function Wo(e) {
|
|
6263
6280
|
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();
|
|
6264
6281
|
}
|
|
6265
6282
|
//#endregion
|
|
6266
6283
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6267
|
-
var
|
|
6268
|
-
down: () =>
|
|
6269
|
-
up: () =>
|
|
6284
|
+
var Go = /* @__PURE__ */ w({
|
|
6285
|
+
down: () => Yo,
|
|
6286
|
+
up: () => qo
|
|
6270
6287
|
});
|
|
6271
|
-
async function
|
|
6288
|
+
async function Ko(e, t, n) {
|
|
6272
6289
|
try {
|
|
6273
6290
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6274
6291
|
} catch (e) {
|
|
@@ -6276,10 +6293,10 @@ async function Ho(e, t, n) {
|
|
|
6276
6293
|
throw e;
|
|
6277
6294
|
}
|
|
6278
6295
|
}
|
|
6279
|
-
async function
|
|
6280
|
-
await
|
|
6296
|
+
async function qo(e) {
|
|
6297
|
+
await Ko(e, "users", "blocked");
|
|
6281
6298
|
}
|
|
6282
|
-
async function
|
|
6299
|
+
async function Jo(e, t, n) {
|
|
6283
6300
|
try {
|
|
6284
6301
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6285
6302
|
} catch (e) {
|
|
@@ -6287,16 +6304,16 @@ async function Wo(e, t, n) {
|
|
|
6287
6304
|
throw e;
|
|
6288
6305
|
}
|
|
6289
6306
|
}
|
|
6290
|
-
async function
|
|
6291
|
-
await
|
|
6307
|
+
async function Yo(e) {
|
|
6308
|
+
await Jo(e, "users", "blocked");
|
|
6292
6309
|
}
|
|
6293
6310
|
//#endregion
|
|
6294
6311
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6295
|
-
var
|
|
6296
|
-
down: () =>
|
|
6297
|
-
up: () =>
|
|
6312
|
+
var Xo = /* @__PURE__ */ w({
|
|
6313
|
+
down: () => es,
|
|
6314
|
+
up: () => Qo
|
|
6298
6315
|
});
|
|
6299
|
-
async function
|
|
6316
|
+
async function Zo(e, t, n) {
|
|
6300
6317
|
try {
|
|
6301
6318
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6302
6319
|
} catch (e) {
|
|
@@ -6304,10 +6321,10 @@ async function qo(e, t, n) {
|
|
|
6304
6321
|
throw e;
|
|
6305
6322
|
}
|
|
6306
6323
|
}
|
|
6307
|
-
async function
|
|
6308
|
-
await
|
|
6324
|
+
async function Qo(e) {
|
|
6325
|
+
await Zo(e, "prompt_settings", "show_last_used_connection");
|
|
6309
6326
|
}
|
|
6310
|
-
async function
|
|
6327
|
+
async function $o(e, t, n) {
|
|
6311
6328
|
try {
|
|
6312
6329
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6313
6330
|
} catch (e) {
|
|
@@ -6315,16 +6332,16 @@ async function Yo(e, t, n) {
|
|
|
6315
6332
|
throw e;
|
|
6316
6333
|
}
|
|
6317
6334
|
}
|
|
6318
|
-
async function
|
|
6319
|
-
await
|
|
6335
|
+
async function es(e) {
|
|
6336
|
+
await $o(e, "prompt_settings", "show_last_used_connection");
|
|
6320
6337
|
}
|
|
6321
6338
|
//#endregion
|
|
6322
6339
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6323
|
-
var
|
|
6324
|
-
down: () =>
|
|
6325
|
-
up: () =>
|
|
6340
|
+
var ts = /* @__PURE__ */ w({
|
|
6341
|
+
down: () => is,
|
|
6342
|
+
up: () => rs
|
|
6326
6343
|
});
|
|
6327
|
-
async function
|
|
6344
|
+
async function ns(e, t, n, r) {
|
|
6328
6345
|
try {
|
|
6329
6346
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6330
6347
|
} catch (e) {
|
|
@@ -6335,10 +6352,10 @@ async function Qo(e, t, n, r) {
|
|
|
6335
6352
|
throw e;
|
|
6336
6353
|
}
|
|
6337
6354
|
}
|
|
6338
|
-
async function
|
|
6339
|
-
await
|
|
6355
|
+
async function rs(e) {
|
|
6356
|
+
await ns(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6340
6357
|
}
|
|
6341
|
-
async function
|
|
6358
|
+
async function is(e) {
|
|
6342
6359
|
try {
|
|
6343
6360
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6344
6361
|
} catch (e) {
|
|
@@ -6347,32 +6364,61 @@ async function es(e) {
|
|
|
6347
6364
|
}
|
|
6348
6365
|
}
|
|
6349
6366
|
//#endregion
|
|
6367
|
+
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6368
|
+
var as = /* @__PURE__ */ w({
|
|
6369
|
+
down: () => ls,
|
|
6370
|
+
up: () => ss
|
|
6371
|
+
});
|
|
6372
|
+
async function os(e, t, n, r) {
|
|
6373
|
+
try {
|
|
6374
|
+
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6375
|
+
} catch (e) {
|
|
6376
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6377
|
+
throw e;
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
async function ss(e) {
|
|
6381
|
+
await os(e, "hooks", "page_id", f`varchar(64)`), await os(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6382
|
+
}
|
|
6383
|
+
async function cs(e, t, n) {
|
|
6384
|
+
try {
|
|
6385
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6386
|
+
} catch (e) {
|
|
6387
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6388
|
+
throw e;
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
async function ls(e) {
|
|
6392
|
+
await cs(e, "hooks", "permission_required"), await cs(e, "hooks", "page_id");
|
|
6393
|
+
}
|
|
6394
|
+
//#endregion
|
|
6350
6395
|
//#region migrate/migrations/index.ts
|
|
6351
|
-
var
|
|
6352
|
-
"2026-07-16T14:00:00_baseline":
|
|
6353
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6354
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6355
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6356
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6357
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6396
|
+
var us = {
|
|
6397
|
+
"2026-07-16T14:00:00_baseline": So,
|
|
6398
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Ao,
|
|
6399
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Ho,
|
|
6400
|
+
"2026-08-05T12:00:00_user_blocked": Go,
|
|
6401
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Xo,
|
|
6402
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": ts,
|
|
6403
|
+
"2026-08-11T12:00:00_page_hooks": as
|
|
6358
6404
|
};
|
|
6359
6405
|
//#endregion
|
|
6360
6406
|
//#region migrate/migrate.ts
|
|
6361
|
-
async function
|
|
6362
|
-
|
|
6363
|
-
let { error: n, results: r } = await new
|
|
6407
|
+
async function ds(e, t = !1) {
|
|
6408
|
+
Oo(t), t && console.log("migrating...");
|
|
6409
|
+
let { error: n, results: r } = await new ve({
|
|
6364
6410
|
db: e,
|
|
6365
|
-
provider: new
|
|
6411
|
+
provider: new xo(us)
|
|
6366
6412
|
}).migrateToLatest();
|
|
6367
6413
|
if (r?.forEach((e) => {
|
|
6368
6414
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6369
6415
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6370
6416
|
}
|
|
6371
|
-
async function
|
|
6372
|
-
|
|
6373
|
-
let { error: n, results: r } = await new
|
|
6417
|
+
async function fs(e, t = !1) {
|
|
6418
|
+
Oo(t), t && console.log("migrating...");
|
|
6419
|
+
let { error: n, results: r } = await new ve({
|
|
6374
6420
|
db: e,
|
|
6375
|
-
provider: new
|
|
6421
|
+
provider: new xo(us)
|
|
6376
6422
|
}).migrateDown();
|
|
6377
6423
|
if (r?.forEach((e) => {
|
|
6378
6424
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6380,64 +6426,64 @@ async function rs(e, t = !1) {
|
|
|
6380
6426
|
}
|
|
6381
6427
|
//#endregion
|
|
6382
6428
|
//#region src/index.ts
|
|
6383
|
-
function
|
|
6429
|
+
function ps(e, t = { useTransactions: !0 }) {
|
|
6384
6430
|
let n = {
|
|
6385
|
-
actions:
|
|
6386
|
-
actionExecutions:
|
|
6387
|
-
actionVersions:
|
|
6388
|
-
branding:
|
|
6389
|
-
clients:
|
|
6390
|
-
clientConnections:
|
|
6391
|
-
clientGrants:
|
|
6392
|
-
clientRegistrationTokens:
|
|
6393
|
-
codes:
|
|
6394
|
-
connections:
|
|
6395
|
-
emailProviders:
|
|
6396
|
-
emailTemplates:
|
|
6397
|
-
customDomains:
|
|
6398
|
-
flows:
|
|
6399
|
-
forms:
|
|
6400
|
-
hookCode:
|
|
6401
|
-
hooks:
|
|
6402
|
-
invites:
|
|
6403
|
-
keys:
|
|
6404
|
-
loginSessions:
|
|
6405
|
-
logs:
|
|
6406
|
-
logStreams:
|
|
6407
|
-
migrationSources:
|
|
6408
|
-
authenticationMethods:
|
|
6409
|
-
passwords:
|
|
6410
|
-
promptSettings:
|
|
6411
|
-
proxyRoutes:
|
|
6412
|
-
scimConfigurations:
|
|
6413
|
-
scimTokens:
|
|
6414
|
-
scimExternalIds:
|
|
6415
|
-
refreshTokens:
|
|
6416
|
-
resourceServers:
|
|
6417
|
-
rolePermissions:
|
|
6418
|
-
grants:
|
|
6419
|
-
userPermissions:
|
|
6420
|
-
userRoles:
|
|
6421
|
-
roles:
|
|
6422
|
-
sessions:
|
|
6423
|
-
sessionCleanup:
|
|
6424
|
-
tenants:
|
|
6425
|
-
tenantOperations:
|
|
6426
|
-
tenantOperationEvents:
|
|
6427
|
-
rollouts:
|
|
6428
|
-
themes:
|
|
6429
|
-
universalLoginTemplates:
|
|
6430
|
-
customText:
|
|
6431
|
-
users:
|
|
6432
|
-
userActivity:
|
|
6433
|
-
organizations:
|
|
6434
|
-
organizationConnections:
|
|
6435
|
-
userOrganizations:
|
|
6436
|
-
stats:
|
|
6437
|
-
analytics:
|
|
6438
|
-
outbox:
|
|
6431
|
+
actions: Le(e),
|
|
6432
|
+
actionExecutions: Ue(e),
|
|
6433
|
+
actionVersions: Ke(e),
|
|
6434
|
+
branding: tr(e),
|
|
6435
|
+
clients: _n(e),
|
|
6436
|
+
clientConnections: Cn(e),
|
|
6437
|
+
clientGrants: An(e),
|
|
6438
|
+
clientRegistrationTokens: Vn(e),
|
|
6439
|
+
codes: tn(e),
|
|
6440
|
+
connections: ln(e),
|
|
6441
|
+
emailProviders: Vr(e),
|
|
6442
|
+
emailTemplates: Jr(e),
|
|
6443
|
+
customDomains: Qn(e),
|
|
6444
|
+
flows: yt(e),
|
|
6445
|
+
forms: di(e),
|
|
6446
|
+
hookCode: gr(e),
|
|
6447
|
+
hooks: dr(e),
|
|
6448
|
+
invites: ua(e),
|
|
6449
|
+
keys: Gn(e),
|
|
6450
|
+
loginSessions: Mr(e),
|
|
6451
|
+
logs: Ft(e),
|
|
6452
|
+
logStreams: Ga(e),
|
|
6453
|
+
migrationSources: Ka(e),
|
|
6454
|
+
authenticationMethods: Pa(e),
|
|
6455
|
+
passwords: Kt(e),
|
|
6456
|
+
promptSettings: Ir(e),
|
|
6457
|
+
proxyRoutes: J(e),
|
|
6458
|
+
scimConfigurations: eo(e),
|
|
6459
|
+
scimTokens: to(e),
|
|
6460
|
+
scimExternalIds: ro(e),
|
|
6461
|
+
refreshTokens: ri(e),
|
|
6462
|
+
resourceServers: _i(e),
|
|
6463
|
+
rolePermissions: Di(e),
|
|
6464
|
+
grants: Ni(e),
|
|
6465
|
+
userPermissions: Ri(e),
|
|
6466
|
+
userRoles: Wi(e),
|
|
6467
|
+
roles: Ci(e),
|
|
6468
|
+
sessions: Vt(e),
|
|
6469
|
+
sessionCleanup: ai(e),
|
|
6470
|
+
tenants: Dt(e),
|
|
6471
|
+
tenantOperations: io(e),
|
|
6472
|
+
tenantOperationEvents: _o(e),
|
|
6473
|
+
rollouts: bo(e),
|
|
6474
|
+
themes: xr(e),
|
|
6475
|
+
universalLoginTemplates: ar(e),
|
|
6476
|
+
customText: Da(e),
|
|
6477
|
+
users: dt(e),
|
|
6478
|
+
userActivity: ct(e),
|
|
6479
|
+
organizations: Xi(e),
|
|
6480
|
+
organizationConnections: Zi(e),
|
|
6481
|
+
userOrganizations: ia(e),
|
|
6482
|
+
stats: ha(e),
|
|
6483
|
+
analytics: Ea(e),
|
|
6484
|
+
outbox: Wa(e),
|
|
6439
6485
|
async transaction(r) {
|
|
6440
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6486
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(ps(e, {
|
|
6441
6487
|
...t,
|
|
6442
6488
|
useTransactions: !1
|
|
6443
6489
|
})));
|
|
@@ -6446,4 +6492,4 @@ function is(e, t = { useTransactions: !0 }) {
|
|
|
6446
6492
|
return n;
|
|
6447
6493
|
}
|
|
6448
6494
|
//#endregion
|
|
6449
|
-
export {
|
|
6495
|
+
export { Xa as createProxyDataAdapter, J as createProxyRoutesAdapter, ps as default, fs as migrateDown, ds as migrateToLatest };
|