@authhero/kysely-adapter 12.0.0 → 12.2.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 +27 -0
- package/dist/kysely-adapter.mjs +1061 -751
- package/dist/types/migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.d.ts +21 -0
- package/dist/types/migrate/migrations/2026-08-05T12:00:00_user_blocked.d.ts +4 -0
- package/dist/types/migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.d.ts +4 -0
- package/dist/types/migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +8 -0
- package/dist/types/src/actionExecutions/cleanup.d.ts +3 -0
- package/dist/types/src/db.d.ts +27 -0
- package/dist/types/src/scim/adapter.d.ts +6 -0
- package/dist/types/src/scim/index.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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, clientGrantSchema as m, clientRegistrationTokenTypeSchema as h, codeSchema as g, decodeCursor as _, emailTemplateSchema as v, encodeCursor as y, flowSchema as b, formSchema as x, handlerConfigSchema as ee, isPlainObject as te, loginSessionSchema as ne, matchSchema as re, migrationProviderTypeSchema as ie, parseUserId as ae, resourceServerSchema as oe, rolloutInsertSchema as se, rolloutSchema as ce, sanitizeLuceneQuery as S,
|
|
4
|
+
import { LoginSessionState as p, clientGrantSchema as m, clientRegistrationTokenTypeSchema as h, codeSchema as g, decodeCursor as _, emailTemplateSchema as v, encodeCursor as y, flowSchema as b, formSchema as x, handlerConfigSchema as ee, isPlainObject as te, loginSessionSchema as ne, matchSchema as re, migrationProviderTypeSchema as ie, parseUserId as ae, resourceServerSchema as oe, rolloutInsertSchema as se, rolloutSchema as ce, sanitizeLuceneQuery as S, scimMappingEntrySchema as le, tenantOperationEventInsertSchema as ue, tenantOperationEventSchema as de, tenantOperationInsertSchema as fe, tenantOperationSchema as pe } 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 me } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var he = Object.defineProperty, w = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) he(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
15
|
+
return t || he(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
16
|
}, ge = 17, _e = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
@@ -25,33 +25,33 @@ var me = Object.defineProperty, he = (e, t) => {
|
|
|
25
25
|
guardian_factor: "gfa_",
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function T(t) {
|
|
29
29
|
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", ge)();
|
|
30
30
|
return `${_e[t]}${n}`;
|
|
31
31
|
}
|
|
32
32
|
function ve() {
|
|
33
|
-
return
|
|
33
|
+
return T("organization");
|
|
34
34
|
}
|
|
35
35
|
function ye() {
|
|
36
|
-
return
|
|
36
|
+
return T("connection");
|
|
37
37
|
}
|
|
38
38
|
function be() {
|
|
39
|
-
return
|
|
39
|
+
return T("action");
|
|
40
40
|
}
|
|
41
41
|
function xe() {
|
|
42
|
-
return
|
|
42
|
+
return T("action_version");
|
|
43
43
|
}
|
|
44
44
|
function Se() {
|
|
45
|
-
return
|
|
45
|
+
return T("hook");
|
|
46
46
|
}
|
|
47
47
|
function Ce() {
|
|
48
|
-
return
|
|
48
|
+
return T("resource_server");
|
|
49
49
|
}
|
|
50
50
|
function we() {
|
|
51
|
-
return
|
|
51
|
+
return T("hook_code");
|
|
52
52
|
}
|
|
53
53
|
function Te() {
|
|
54
|
-
return
|
|
54
|
+
return T("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
@@ -91,7 +91,7 @@ function Ee(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function E(e) {
|
|
95
95
|
if (e) try {
|
|
96
96
|
return JSON.parse(e);
|
|
97
97
|
} catch {
|
|
@@ -113,9 +113,9 @@ function De(e) {
|
|
|
113
113
|
runtime: m.runtime ?? void 0,
|
|
114
114
|
status: m.status || "built",
|
|
115
115
|
deployed_at: s ? new Date(Number(s)).toISOString() : void 0,
|
|
116
|
-
secrets:
|
|
117
|
-
dependencies:
|
|
118
|
-
supported_triggers:
|
|
116
|
+
secrets: E(c),
|
|
117
|
+
dependencies: E(l),
|
|
118
|
+
supported_triggers: E(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -126,10 +126,10 @@ function De(e) {
|
|
|
126
126
|
function Oe(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function D(e) {
|
|
130
130
|
return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function O(e, t, n, r, i = [], a = {}) {
|
|
133
133
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
134
134
|
let t = a[e];
|
|
135
135
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
@@ -148,7 +148,7 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
148
148
|
if (n) {
|
|
149
149
|
let [, t, r] = n;
|
|
150
150
|
if (!t || !r) return null;
|
|
151
|
-
let i = t.trim(), a =
|
|
151
|
+
let i = t.trim(), a = D(r.replace(/^"(.*)"$/, "$1").trim());
|
|
152
152
|
return o.has(i) ? e(s(c(i)), "like", `%${a}%`) : e(l(i), "=", u(i, a));
|
|
153
153
|
}
|
|
154
154
|
return null;
|
|
@@ -166,8 +166,8 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
166
166
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
167
167
|
else if (e.includes(":")) {
|
|
168
168
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
169
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
170
|
-
} else n = null, r =
|
|
169
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = D(r);
|
|
170
|
+
} else n = null, r = D(e), i = !1;
|
|
171
171
|
return {
|
|
172
172
|
key: n,
|
|
173
173
|
value: r,
|
|
@@ -201,7 +201,7 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/actions/list.ts
|
|
204
|
-
function
|
|
204
|
+
function k(e) {
|
|
205
205
|
if (e) try {
|
|
206
206
|
return JSON.parse(e);
|
|
207
207
|
} catch {
|
|
@@ -211,7 +211,7 @@ function O(e) {
|
|
|
211
211
|
function ke(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
|
-
c && (l =
|
|
214
|
+
c && (l = O(e, l, c, ["name"]));
|
|
215
215
|
let u = (await l.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
216
216
|
let { created_at_ts: n, updated_at_ts: i, deployed_at_ts: a, secrets: o, dependencies: s, supported_triggers: c, is_system: l, inherit: u, tenant_id: d, ...f } = e, p = r({
|
|
217
217
|
created_at_ts: n,
|
|
@@ -224,9 +224,9 @@ function ke(e) {
|
|
|
224
224
|
runtime: f.runtime ?? void 0,
|
|
225
225
|
status: f.status || "built",
|
|
226
226
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
227
|
-
secrets:
|
|
228
|
-
dependencies:
|
|
229
|
-
supported_triggers:
|
|
227
|
+
secrets: k(o),
|
|
228
|
+
dependencies: k(s),
|
|
229
|
+
supported_triggers: k(c),
|
|
230
230
|
is_system: !!l,
|
|
231
231
|
inherit: !!u
|
|
232
232
|
};
|
|
@@ -341,36 +341,64 @@ function Ie(e) {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
|
+
//#region src/actionExecutions/cleanup.ts
|
|
345
|
+
var A = 5e4;
|
|
346
|
+
async function Le(e) {
|
|
347
|
+
try {
|
|
348
|
+
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
349
|
+
} catch {
|
|
350
|
+
return "sqlite";
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function Re(e) {
|
|
354
|
+
let t;
|
|
355
|
+
return async (n) => {
|
|
356
|
+
let r = Date.parse(n);
|
|
357
|
+
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
358
|
+
if (t ??= await Le(e), t === "sqlite") {
|
|
359
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
360
|
+
return Number(t.numDeletedRows);
|
|
361
|
+
}
|
|
362
|
+
let i = 0, a = A;
|
|
363
|
+
for (; a >= A;) {
|
|
364
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(A).executeTakeFirst();
|
|
365
|
+
a = Number(t.numDeletedRows), i += a;
|
|
366
|
+
}
|
|
367
|
+
return i;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
344
371
|
//#region src/actionExecutions/index.ts
|
|
345
|
-
function
|
|
372
|
+
function ze(e) {
|
|
346
373
|
return {
|
|
347
374
|
create: Pe(e),
|
|
348
|
-
get: Ie(e)
|
|
375
|
+
get: Ie(e),
|
|
376
|
+
cleanup: Re(e)
|
|
349
377
|
};
|
|
350
378
|
}
|
|
351
379
|
//#endregion
|
|
352
380
|
//#region src/actionVersions/index.ts
|
|
353
|
-
function
|
|
381
|
+
function j(e) {
|
|
354
382
|
if (e) try {
|
|
355
383
|
return JSON.parse(e);
|
|
356
384
|
} catch {
|
|
357
385
|
return;
|
|
358
386
|
}
|
|
359
387
|
}
|
|
360
|
-
function
|
|
388
|
+
function Be(e) {
|
|
361
389
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
362
390
|
return {
|
|
363
391
|
...c,
|
|
364
392
|
runtime: s ?? void 0,
|
|
365
393
|
deployed: !!o,
|
|
366
|
-
secrets:
|
|
367
|
-
dependencies:
|
|
368
|
-
supported_triggers:
|
|
394
|
+
secrets: j(r),
|
|
395
|
+
dependencies: j(i),
|
|
396
|
+
supported_triggers: j(a),
|
|
369
397
|
created_at: new Date(Number(t)).toISOString(),
|
|
370
398
|
updated_at: new Date(Number(n)).toISOString()
|
|
371
399
|
};
|
|
372
400
|
}
|
|
373
|
-
function
|
|
401
|
+
function Ve(e) {
|
|
374
402
|
return {
|
|
375
403
|
async create(t, n, r) {
|
|
376
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 ?? xe(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
@@ -410,10 +438,10 @@ function ze(e) {
|
|
|
410
438
|
},
|
|
411
439
|
async get(t, n, r) {
|
|
412
440
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
413
|
-
return i ?
|
|
441
|
+
return i ? Be(i) : null;
|
|
414
442
|
},
|
|
415
443
|
async list(t, n, r = {}) {
|
|
416
|
-
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(Be);
|
|
417
445
|
if (!s) return {
|
|
418
446
|
versions: l,
|
|
419
447
|
start: 0,
|
|
@@ -436,7 +464,7 @@ function ze(e) {
|
|
|
436
464
|
}
|
|
437
465
|
//#endregion
|
|
438
466
|
//#region src/outbox/create.ts
|
|
439
|
-
async function
|
|
467
|
+
async function M(e, t, n, r) {
|
|
440
468
|
await e.insertInto("outbox_events").values({
|
|
441
469
|
id: n,
|
|
442
470
|
tenant_id: t,
|
|
@@ -455,15 +483,15 @@ async function A(e, t, n, r) {
|
|
|
455
483
|
error: null
|
|
456
484
|
}).execute();
|
|
457
485
|
}
|
|
458
|
-
function
|
|
486
|
+
function He(e) {
|
|
459
487
|
return async (n, r) => {
|
|
460
488
|
let i = t();
|
|
461
|
-
return await
|
|
489
|
+
return await M(e, n, i, r), i;
|
|
462
490
|
};
|
|
463
491
|
}
|
|
464
492
|
//#endregion
|
|
465
493
|
//#region src/users/create.ts
|
|
466
|
-
function
|
|
494
|
+
function Ue(e) {
|
|
467
495
|
return async (n, r, i) => {
|
|
468
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 = {
|
|
469
497
|
...f,
|
|
@@ -474,6 +502,7 @@ function Ve(e) {
|
|
|
474
502
|
email_verified: +!!r.email_verified,
|
|
475
503
|
phone_verified: s === void 0 ? null : +!!s,
|
|
476
504
|
is_social: +!!r.is_social,
|
|
505
|
+
blocked: +!!r.blocked,
|
|
477
506
|
app_metadata: JSON.stringify(r.app_metadata),
|
|
478
507
|
user_metadata: JSON.stringify(r.user_metadata),
|
|
479
508
|
address: r.address ? JSON.stringify(r.address) : null
|
|
@@ -497,7 +526,7 @@ function Ve(e) {
|
|
|
497
526
|
};
|
|
498
527
|
await e.insertInto("passwords").values(r).execute();
|
|
499
528
|
}
|
|
500
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await M(e, n, t.id, t);
|
|
501
530
|
};
|
|
502
531
|
try {
|
|
503
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
@@ -513,6 +542,7 @@ function Ve(e) {
|
|
|
513
542
|
email_verified: m.email_verified === 1,
|
|
514
543
|
phone_verified: m.phone_verified === null ? void 0 : m.phone_verified === 1,
|
|
515
544
|
is_social: m.is_social === 1,
|
|
545
|
+
blocked: m.blocked == null ? void 0 : m.blocked === 1,
|
|
516
546
|
app_metadata: r.app_metadata,
|
|
517
547
|
user_metadata: r.user_metadata,
|
|
518
548
|
address: r.address
|
|
@@ -521,21 +551,21 @@ function Ve(e) {
|
|
|
521
551
|
}
|
|
522
552
|
//#endregion
|
|
523
553
|
//#region src/users/user-to-identity.ts
|
|
524
|
-
var
|
|
554
|
+
var We = [
|
|
525
555
|
"email",
|
|
526
556
|
"email_verified",
|
|
527
557
|
"phone_number",
|
|
528
558
|
"phone_verified",
|
|
529
559
|
"username"
|
|
530
560
|
];
|
|
531
|
-
function
|
|
561
|
+
function N(e, t = !1) {
|
|
532
562
|
let n = {
|
|
533
563
|
connection: e.connection,
|
|
534
564
|
provider: e.provider,
|
|
535
565
|
user_id: ae(e.user_id).id,
|
|
536
566
|
isSocial: !!e.is_social
|
|
537
567
|
};
|
|
538
|
-
for (let t of
|
|
568
|
+
for (let t of We) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
539
569
|
if (!t) {
|
|
540
570
|
let t = {};
|
|
541
571
|
try {
|
|
@@ -553,7 +583,7 @@ function j(e, t = !1) {
|
|
|
553
583
|
}
|
|
554
584
|
//#endregion
|
|
555
585
|
//#region src/users/get.ts
|
|
556
|
-
function
|
|
586
|
+
function Ge(e) {
|
|
557
587
|
return async (t, n) => {
|
|
558
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([
|
|
559
589
|
"user_activity.last_login",
|
|
@@ -568,27 +598,28 @@ function Ue(e) {
|
|
|
568
598
|
email_verified: r.email_verified === 1,
|
|
569
599
|
phone_verified: r.phone_verified === null ? void 0 : r.phone_verified === 1,
|
|
570
600
|
is_social: r.is_social === 1,
|
|
601
|
+
blocked: r.blocked == null ? void 0 : r.blocked === 1,
|
|
571
602
|
last_login: r.last_login ?? void 0,
|
|
572
603
|
last_ip: r.last_ip ?? void 0,
|
|
573
604
|
login_count: r.login_count ?? 0,
|
|
574
605
|
app_metadata: JSON.parse(r.app_metadata),
|
|
575
606
|
user_metadata: JSON.parse(r.user_metadata),
|
|
576
607
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
577
|
-
identities: [
|
|
608
|
+
identities: [N(r, !0), ...i.map((e) => N(e))]
|
|
578
609
|
});
|
|
579
610
|
};
|
|
580
611
|
}
|
|
581
612
|
//#endregion
|
|
582
613
|
//#region src/helpers/paginate.ts
|
|
583
|
-
function
|
|
614
|
+
function P(e) {
|
|
584
615
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
585
616
|
}
|
|
586
|
-
function
|
|
617
|
+
function Ke(e, t) {
|
|
587
618
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
588
619
|
return n >= 1 ? n : t;
|
|
589
620
|
}
|
|
590
|
-
async function
|
|
591
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
621
|
+
async function F(e, t, n) {
|
|
622
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = Ke(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? _(t.from) : null;
|
|
592
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" });
|
|
593
624
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
594
625
|
else {
|
|
@@ -612,7 +643,7 @@ async function N(e, t, n) {
|
|
|
612
643
|
}
|
|
613
644
|
//#endregion
|
|
614
645
|
//#region src/users/list.ts
|
|
615
|
-
var
|
|
646
|
+
var qe = [
|
|
616
647
|
"user_id",
|
|
617
648
|
"email",
|
|
618
649
|
"email_verified",
|
|
@@ -629,25 +660,26 @@ var Ge = [
|
|
|
629
660
|
"provider",
|
|
630
661
|
"connection",
|
|
631
662
|
"is_social",
|
|
663
|
+
"blocked",
|
|
632
664
|
"last_ip",
|
|
633
665
|
"last_login",
|
|
634
666
|
"login_count",
|
|
635
667
|
"created_at",
|
|
636
668
|
"updated_at"
|
|
637
|
-
],
|
|
669
|
+
], Je = new Set([
|
|
638
670
|
"last_login",
|
|
639
671
|
"last_ip",
|
|
640
672
|
"login_count"
|
|
641
|
-
]),
|
|
673
|
+
]), Ye = Object.fromEntries(qe.map((e) => [e, e === "login_count" ? {
|
|
642
674
|
column: "user_activity.login_count",
|
|
643
675
|
defaultValue: 0
|
|
644
|
-
} :
|
|
676
|
+
} : Je.has(e) ? `user_activity.${e}` : `users.${e}`])), Xe = [
|
|
645
677
|
"email",
|
|
646
678
|
"name",
|
|
647
679
|
"phone_number",
|
|
648
680
|
"user_id"
|
|
649
681
|
];
|
|
650
|
-
async function
|
|
682
|
+
async function Ze(e, t, n) {
|
|
651
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() : [];
|
|
652
684
|
return n.map((e) => {
|
|
653
685
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -656,24 +688,25 @@ async function Ye(e, t, n) {
|
|
|
656
688
|
email_verified: e.email_verified === 1,
|
|
657
689
|
phone_verified: e.phone_verified === null ? void 0 : e.phone_verified === 1,
|
|
658
690
|
is_social: e.is_social === 1,
|
|
691
|
+
blocked: e.blocked == null ? void 0 : e.blocked === 1,
|
|
659
692
|
login_count: e.login_count ?? 0,
|
|
660
693
|
app_metadata: JSON.parse(e.app_metadata),
|
|
661
694
|
user_metadata: JSON.parse(e.user_metadata),
|
|
662
695
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
663
|
-
identities: [
|
|
696
|
+
identities: [N(e, !0), ...t.map((e) => N(e))]
|
|
664
697
|
});
|
|
665
698
|
});
|
|
666
699
|
}
|
|
667
|
-
function
|
|
700
|
+
function Qe(e) {
|
|
668
701
|
return async (t, n = {}) => {
|
|
669
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);
|
|
670
703
|
if (c) {
|
|
671
|
-
let t = S(c,
|
|
672
|
-
t && (l =
|
|
704
|
+
let t = S(c, qe);
|
|
705
|
+
t && (l = O(e, l, t, Xe, [], Ye));
|
|
673
706
|
}
|
|
674
|
-
if (
|
|
707
|
+
if (P(n)) {
|
|
675
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` });
|
|
676
|
-
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 F(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
677
710
|
"user_activity.last_login",
|
|
678
711
|
"user_activity.last_ip",
|
|
679
712
|
"user_activity.login_count"
|
|
@@ -682,7 +715,7 @@ function Xe(e) {
|
|
|
682
715
|
sortOrder: r,
|
|
683
716
|
idColumn: "users.user_id",
|
|
684
717
|
sortKey: `created_at:${r}`
|
|
685
|
-
}), c = await
|
|
718
|
+
}), c = await Ze(e, t, i);
|
|
686
719
|
return {
|
|
687
720
|
users: c,
|
|
688
721
|
start: 0,
|
|
@@ -692,13 +725,13 @@ function Xe(e) {
|
|
|
692
725
|
};
|
|
693
726
|
}
|
|
694
727
|
if (s && s.sort_by) {
|
|
695
|
-
let t =
|
|
728
|
+
let t = Ye[s.sort_by];
|
|
696
729
|
if (t) {
|
|
697
730
|
let { ref: n } = e.dynamic;
|
|
698
731
|
l = l.orderBy(typeof t == "string" ? n(t) : Oe(t), s.sort_order);
|
|
699
732
|
}
|
|
700
733
|
}
|
|
701
|
-
let u = await
|
|
734
|
+
let u = await Ze(e, t, await l.offset(r * i).limit(i).selectAll("users").select([
|
|
702
735
|
"user_activity.last_login",
|
|
703
736
|
"user_activity.last_ip",
|
|
704
737
|
"user_activity.login_count"
|
|
@@ -720,12 +753,12 @@ function Xe(e) {
|
|
|
720
753
|
}
|
|
721
754
|
//#endregion
|
|
722
755
|
//#region src/users/remove.ts
|
|
723
|
-
function
|
|
756
|
+
function $e(e) {
|
|
724
757
|
return async (t, n, r) => {
|
|
725
758
|
let i = async (e) => {
|
|
726
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();
|
|
727
760
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
728
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
761
|
+
for (let n of r?.outboxEvents ?? []) await M(e, t, n.id, n);
|
|
729
762
|
return i.length === 1;
|
|
730
763
|
};
|
|
731
764
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -733,14 +766,14 @@ function Ze(e) {
|
|
|
733
766
|
}
|
|
734
767
|
//#endregion
|
|
735
768
|
//#region src/utils/flatten.ts
|
|
736
|
-
function
|
|
769
|
+
function I(e, t = "", n = {}) {
|
|
737
770
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
738
771
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
739
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
772
|
+
typeof a == "object" && a && !Array.isArray(a) ? I(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
740
773
|
}
|
|
741
774
|
return n;
|
|
742
775
|
}
|
|
743
|
-
function
|
|
776
|
+
function et(e, t) {
|
|
744
777
|
let n = {};
|
|
745
778
|
for (let [r, i] of Object.entries(e)) {
|
|
746
779
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -757,7 +790,7 @@ function Qe(e, t) {
|
|
|
757
790
|
}
|
|
758
791
|
//#endregion
|
|
759
792
|
//#region src/userActivity/index.ts
|
|
760
|
-
function
|
|
793
|
+
function tt(e) {
|
|
761
794
|
return {
|
|
762
795
|
user_id: e.user_id,
|
|
763
796
|
last_login: e.last_login ?? void 0,
|
|
@@ -767,18 +800,18 @@ function $e(e) {
|
|
|
767
800
|
last_password_reset: e.last_password_reset ?? void 0
|
|
768
801
|
};
|
|
769
802
|
}
|
|
770
|
-
function
|
|
803
|
+
function nt(e) {
|
|
771
804
|
let t = {};
|
|
772
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;
|
|
773
806
|
}
|
|
774
|
-
function
|
|
807
|
+
function rt(e) {
|
|
775
808
|
return {
|
|
776
809
|
async get(t, n) {
|
|
777
810
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
778
|
-
return r ?
|
|
811
|
+
return r ? tt(r) : null;
|
|
779
812
|
},
|
|
780
813
|
async upsert(t, n, r) {
|
|
781
|
-
let i =
|
|
814
|
+
let i = nt(r);
|
|
782
815
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
783
816
|
if (Object.keys(i).length === 0) return;
|
|
784
817
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -800,24 +833,25 @@ function tt(e) {
|
|
|
800
833
|
}
|
|
801
834
|
//#endregion
|
|
802
835
|
//#region src/users/update.ts
|
|
803
|
-
function
|
|
836
|
+
function it(e) {
|
|
804
837
|
return async (t, n, r, i) => {
|
|
805
|
-
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 = I({
|
|
806
839
|
...c,
|
|
807
840
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
808
841
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
809
842
|
user_metadata: r.user_metadata ? JSON.stringify(r.user_metadata) : void 0,
|
|
810
843
|
address: r.address ? JSON.stringify(r.address) : void 0,
|
|
811
|
-
phone_verified: r.phone_verified === void 0 ? void 0 : +!!r.phone_verified
|
|
844
|
+
phone_verified: r.phone_verified === void 0 ? void 0 : +!!r.phone_verified,
|
|
845
|
+
blocked: r.blocked === void 0 ? void 0 : +!!r.blocked
|
|
812
846
|
}), u = async (e) => {
|
|
813
847
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
814
848
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
815
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
849
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await rt(e).upsert(t, n, {
|
|
816
850
|
last_login: a,
|
|
817
851
|
last_ip: o,
|
|
818
852
|
login_count: s
|
|
819
853
|
});
|
|
820
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
854
|
+
for (let n of i?.outboxEvents ?? []) await M(e, t, n.id, n);
|
|
821
855
|
return !0;
|
|
822
856
|
};
|
|
823
857
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -825,26 +859,26 @@ function nt(e) {
|
|
|
825
859
|
}
|
|
826
860
|
//#endregion
|
|
827
861
|
//#region src/users/unlink.ts
|
|
828
|
-
function
|
|
862
|
+
function at(e) {
|
|
829
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;
|
|
830
864
|
}
|
|
831
865
|
//#endregion
|
|
832
866
|
//#region src/users/index.ts
|
|
833
|
-
function
|
|
834
|
-
let t =
|
|
867
|
+
function ot(e) {
|
|
868
|
+
let t = Ue(e);
|
|
835
869
|
return {
|
|
836
870
|
create: t,
|
|
837
871
|
rawCreate: t,
|
|
838
|
-
remove:
|
|
839
|
-
get:
|
|
840
|
-
list:
|
|
841
|
-
update:
|
|
842
|
-
unlink:
|
|
872
|
+
remove: $e(e),
|
|
873
|
+
get: Ge(e),
|
|
874
|
+
list: Qe(e),
|
|
875
|
+
update: it(e),
|
|
876
|
+
unlink: at(e)
|
|
843
877
|
};
|
|
844
878
|
}
|
|
845
879
|
//#endregion
|
|
846
880
|
//#region src/flows/create.ts
|
|
847
|
-
function
|
|
881
|
+
function st(e) {
|
|
848
882
|
return async (n, r, i) => {
|
|
849
883
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
850
884
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -862,7 +896,7 @@ function at(e) {
|
|
|
862
896
|
}
|
|
863
897
|
//#endregion
|
|
864
898
|
//#region src/helpers/parse.ts
|
|
865
|
-
function
|
|
899
|
+
function L(e, t) {
|
|
866
900
|
if (!e) return t;
|
|
867
901
|
try {
|
|
868
902
|
return JSON.parse(e);
|
|
@@ -870,7 +904,7 @@ function F(e, t) {
|
|
|
870
904
|
return t;
|
|
871
905
|
}
|
|
872
906
|
}
|
|
873
|
-
function
|
|
907
|
+
function ct(e) {
|
|
874
908
|
if (e) try {
|
|
875
909
|
let t = JSON.parse(e);
|
|
876
910
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -878,33 +912,33 @@ function ot(e) {
|
|
|
878
912
|
return;
|
|
879
913
|
}
|
|
880
914
|
}
|
|
881
|
-
function
|
|
882
|
-
for (let r in t) r in e && (n[r] =
|
|
915
|
+
function lt(e, t, n = { ...e }) {
|
|
916
|
+
for (let r in t) r in e && (n[r] = L(e[r], t[r]));
|
|
883
917
|
return n;
|
|
884
918
|
}
|
|
885
919
|
//#endregion
|
|
886
920
|
//#region src/flows/get.ts
|
|
887
|
-
function
|
|
921
|
+
function ut(e) {
|
|
888
922
|
return async (t, n) => {
|
|
889
923
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
890
924
|
if (!r) return null;
|
|
891
925
|
let i = {
|
|
892
926
|
...r,
|
|
893
|
-
actions:
|
|
927
|
+
actions: L(r.actions, [])
|
|
894
928
|
};
|
|
895
929
|
return b.parse(l(i));
|
|
896
930
|
};
|
|
897
931
|
}
|
|
898
932
|
//#endregion
|
|
899
933
|
//#region src/flows/list.ts
|
|
900
|
-
function
|
|
934
|
+
function dt(e) {
|
|
901
935
|
return async (t, n = {}) => {
|
|
902
936
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
903
|
-
s && (c =
|
|
937
|
+
s && (c = O(e, c, s, []));
|
|
904
938
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
905
939
|
let t = {
|
|
906
940
|
...e,
|
|
907
|
-
actions:
|
|
941
|
+
actions: L(e.actions, [])
|
|
908
942
|
};
|
|
909
943
|
return b.parse(l(t));
|
|
910
944
|
});
|
|
@@ -925,7 +959,7 @@ function lt(e) {
|
|
|
925
959
|
}
|
|
926
960
|
//#endregion
|
|
927
961
|
//#region src/flows/update.ts
|
|
928
|
-
function
|
|
962
|
+
function ft(e) {
|
|
929
963
|
return async (t, n, r) => {
|
|
930
964
|
let i = {
|
|
931
965
|
...r,
|
|
@@ -943,27 +977,27 @@ function ut(e) {
|
|
|
943
977
|
}
|
|
944
978
|
//#endregion
|
|
945
979
|
//#region src/flows/remove.ts
|
|
946
|
-
function
|
|
980
|
+
function pt(e) {
|
|
947
981
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
948
982
|
}
|
|
949
983
|
//#endregion
|
|
950
984
|
//#region src/flows/index.ts
|
|
951
|
-
function
|
|
985
|
+
function mt(e) {
|
|
952
986
|
return {
|
|
953
|
-
create:
|
|
954
|
-
get:
|
|
955
|
-
list:
|
|
956
|
-
update:
|
|
957
|
-
remove:
|
|
987
|
+
create: st(e),
|
|
988
|
+
get: ut(e),
|
|
989
|
+
list: dt(e),
|
|
990
|
+
update: ft(e),
|
|
991
|
+
remove: pt(e)
|
|
958
992
|
};
|
|
959
993
|
}
|
|
960
994
|
//#endregion
|
|
961
995
|
//#region src/tenants/utils.ts
|
|
962
|
-
function
|
|
996
|
+
function ht(e) {
|
|
963
997
|
let t = { ...e };
|
|
964
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);
|
|
965
999
|
}
|
|
966
|
-
function
|
|
1000
|
+
function gt(e) {
|
|
967
1001
|
let t = { ...e };
|
|
968
1002
|
return d(e, [
|
|
969
1003
|
"session_cookie",
|
|
@@ -986,14 +1020,14 @@ function mt(e) {
|
|
|
986
1020
|
}
|
|
987
1021
|
//#endregion
|
|
988
1022
|
//#region src/tenants/create.ts
|
|
989
|
-
function
|
|
1023
|
+
function _t(e) {
|
|
990
1024
|
return async (n, r) => {
|
|
991
1025
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
992
1026
|
...n,
|
|
993
1027
|
id: i?.id ?? n.id ?? t(),
|
|
994
1028
|
created_at: i?.created_at ?? a,
|
|
995
1029
|
updated_at: i?.updated_at ?? a
|
|
996
|
-
}, s =
|
|
1030
|
+
}, s = gt(o);
|
|
997
1031
|
try {
|
|
998
1032
|
await e.insertInto("tenants").values(s).execute();
|
|
999
1033
|
} catch (e) {
|
|
@@ -1005,23 +1039,23 @@ function ht(e) {
|
|
|
1005
1039
|
}
|
|
1006
1040
|
//#endregion
|
|
1007
1041
|
//#region src/tenants/get.ts
|
|
1008
|
-
function
|
|
1042
|
+
function vt(e) {
|
|
1009
1043
|
return async (t) => {
|
|
1010
1044
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1011
|
-
return n ?
|
|
1045
|
+
return n ? ht(n) : null;
|
|
1012
1046
|
};
|
|
1013
1047
|
}
|
|
1014
1048
|
//#endregion
|
|
1015
1049
|
//#region src/tenants/list.ts
|
|
1016
|
-
function
|
|
1050
|
+
function yt(e) {
|
|
1017
1051
|
return async (t) => {
|
|
1018
1052
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1019
1053
|
if (s && s.sort_by) {
|
|
1020
1054
|
let { ref: t } = e.dynamic;
|
|
1021
1055
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1022
1056
|
}
|
|
1023
|
-
c && (n =
|
|
1024
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1057
|
+
c && (n = O(e, n, c, ["friendly_name"]));
|
|
1058
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(ht);
|
|
1025
1059
|
if (!a) return { tenants: l };
|
|
1026
1060
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1027
1061
|
return {
|
|
@@ -1034,10 +1068,10 @@ function _t(e) {
|
|
|
1034
1068
|
}
|
|
1035
1069
|
//#endregion
|
|
1036
1070
|
//#region src/tenants/update.ts
|
|
1037
|
-
function
|
|
1071
|
+
function bt(e) {
|
|
1038
1072
|
return async (t, n) => {
|
|
1039
1073
|
let r = {
|
|
1040
|
-
...
|
|
1074
|
+
...gt(n),
|
|
1041
1075
|
id: t,
|
|
1042
1076
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1043
1077
|
};
|
|
@@ -1046,29 +1080,29 @@ function vt(e) {
|
|
|
1046
1080
|
}
|
|
1047
1081
|
//#endregion
|
|
1048
1082
|
//#region src/tenants/remove.ts
|
|
1049
|
-
function
|
|
1083
|
+
function xt(e) {
|
|
1050
1084
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1051
1085
|
}
|
|
1052
1086
|
//#endregion
|
|
1053
1087
|
//#region src/tenants/index.ts
|
|
1054
|
-
function
|
|
1088
|
+
function St(e) {
|
|
1055
1089
|
return {
|
|
1056
|
-
create:
|
|
1057
|
-
get:
|
|
1058
|
-
list:
|
|
1059
|
-
update:
|
|
1060
|
-
remove:
|
|
1090
|
+
create: _t(e),
|
|
1091
|
+
get: vt(e),
|
|
1092
|
+
list: yt(e),
|
|
1093
|
+
update: bt(e),
|
|
1094
|
+
remove: xt(e)
|
|
1061
1095
|
};
|
|
1062
1096
|
}
|
|
1063
1097
|
//#endregion
|
|
1064
1098
|
//#region src/logs/create.ts
|
|
1065
|
-
function
|
|
1099
|
+
function Ct(e) {
|
|
1066
1100
|
return e ? JSON.stringify(e) : void 0;
|
|
1067
1101
|
}
|
|
1068
|
-
var
|
|
1069
|
-
function
|
|
1102
|
+
var wt = 256;
|
|
1103
|
+
function Tt(e) {
|
|
1070
1104
|
return async (n, r) => {
|
|
1071
|
-
let i = r.user_agent?.slice(0,
|
|
1105
|
+
let i = r.user_agent?.slice(0, wt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1072
1106
|
return await e.insertInto("logs").values({
|
|
1073
1107
|
...s,
|
|
1074
1108
|
log_id: a,
|
|
@@ -1077,8 +1111,8 @@ function Ct(e) {
|
|
|
1077
1111
|
description: r.description?.substring(0, 256),
|
|
1078
1112
|
isMobile: +!!r.isMobile,
|
|
1079
1113
|
scope: r.scope,
|
|
1080
|
-
auth0_client:
|
|
1081
|
-
details:
|
|
1114
|
+
auth0_client: Ct(r.auth0_client),
|
|
1115
|
+
details: Ct(r.details)?.substring(0, 8192),
|
|
1082
1116
|
country_code: o?.country_code,
|
|
1083
1117
|
city_name: o?.city_name,
|
|
1084
1118
|
latitude: o?.latitude,
|
|
@@ -1094,7 +1128,7 @@ function Ct(e) {
|
|
|
1094
1128
|
}
|
|
1095
1129
|
//#endregion
|
|
1096
1130
|
//#region src/logs/logs.ts
|
|
1097
|
-
function
|
|
1131
|
+
function Et(e) {
|
|
1098
1132
|
if (!e) return "";
|
|
1099
1133
|
try {
|
|
1100
1134
|
return JSON.parse(e);
|
|
@@ -1102,13 +1136,13 @@ function wt(e) {
|
|
|
1102
1136
|
return e;
|
|
1103
1137
|
}
|
|
1104
1138
|
}
|
|
1105
|
-
function
|
|
1139
|
+
function Dt(e) {
|
|
1106
1140
|
return {
|
|
1107
1141
|
...e,
|
|
1108
1142
|
client_id: e.client_id,
|
|
1109
1143
|
client_name: e.client_name || "",
|
|
1110
|
-
auth0_client:
|
|
1111
|
-
details:
|
|
1144
|
+
auth0_client: Et(e.auth0_client),
|
|
1145
|
+
details: Et(e.details),
|
|
1112
1146
|
isMobile: !!e.isMobile,
|
|
1113
1147
|
scope: e.scope || void 0,
|
|
1114
1148
|
log_id: e.log_id,
|
|
@@ -1124,7 +1158,7 @@ function I(e) {
|
|
|
1124
1158
|
}
|
|
1125
1159
|
//#endregion
|
|
1126
1160
|
//#region src/logs/list.ts
|
|
1127
|
-
var
|
|
1161
|
+
var Ot = [
|
|
1128
1162
|
"user_id",
|
|
1129
1163
|
"ip",
|
|
1130
1164
|
"type",
|
|
@@ -1150,25 +1184,25 @@ var Tt = [
|
|
|
1150
1184
|
"time_zone",
|
|
1151
1185
|
"continent_code"
|
|
1152
1186
|
];
|
|
1153
|
-
function
|
|
1187
|
+
function kt(e) {
|
|
1154
1188
|
return async (t, n = {}) => {
|
|
1155
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);
|
|
1156
1190
|
if (c) {
|
|
1157
|
-
let t = S(c,
|
|
1158
|
-
t && (d =
|
|
1191
|
+
let t = S(c, Ot);
|
|
1192
|
+
t && (d = O(e, d, t, [
|
|
1159
1193
|
"user_id",
|
|
1160
1194
|
"ip",
|
|
1161
1195
|
"description"
|
|
1162
1196
|
], ["description"]));
|
|
1163
1197
|
}
|
|
1164
|
-
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())), P(n)) {
|
|
1165
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` });
|
|
1166
|
-
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 F(d.selectAll(), n, {
|
|
1167
1201
|
sortColumn: "date",
|
|
1168
1202
|
sortOrder: e,
|
|
1169
1203
|
idColumn: "log_id",
|
|
1170
1204
|
sortKey: `date:${e}`
|
|
1171
|
-
}), a = t.map(
|
|
1205
|
+
}), a = t.map(Dt);
|
|
1172
1206
|
return {
|
|
1173
1207
|
logs: a,
|
|
1174
1208
|
start: 0,
|
|
@@ -1183,7 +1217,7 @@ function Et(e) {
|
|
|
1183
1217
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1184
1218
|
}
|
|
1185
1219
|
f = f.offset(r * i).limit(i);
|
|
1186
|
-
let p = (await f.selectAll().execute()).map(
|
|
1220
|
+
let p = (await f.selectAll().execute()).map(Dt);
|
|
1187
1221
|
if (!a) return {
|
|
1188
1222
|
logs: p,
|
|
1189
1223
|
start: 0,
|
|
@@ -1201,24 +1235,24 @@ function Et(e) {
|
|
|
1201
1235
|
}
|
|
1202
1236
|
//#endregion
|
|
1203
1237
|
//#region src/logs/get.ts
|
|
1204
|
-
function
|
|
1238
|
+
function At(e) {
|
|
1205
1239
|
return async (t, n) => {
|
|
1206
1240
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1207
|
-
return r ?
|
|
1241
|
+
return r ? Dt(r) : null;
|
|
1208
1242
|
};
|
|
1209
1243
|
}
|
|
1210
1244
|
//#endregion
|
|
1211
1245
|
//#region src/logs/index.ts
|
|
1212
|
-
function
|
|
1246
|
+
function jt(e) {
|
|
1213
1247
|
return {
|
|
1214
|
-
create:
|
|
1215
|
-
list:
|
|
1216
|
-
get:
|
|
1248
|
+
create: Tt(e),
|
|
1249
|
+
list: kt(e),
|
|
1250
|
+
get: At(e)
|
|
1217
1251
|
};
|
|
1218
1252
|
}
|
|
1219
1253
|
//#endregion
|
|
1220
1254
|
//#region src/sessions/get.ts
|
|
1221
|
-
function
|
|
1255
|
+
function Mt(e) {
|
|
1222
1256
|
return async (t, n) => {
|
|
1223
1257
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1224
1258
|
if (!i) return null;
|
|
@@ -1252,7 +1286,7 @@ function kt(e) {
|
|
|
1252
1286
|
}
|
|
1253
1287
|
//#endregion
|
|
1254
1288
|
//#region src/sessions/create.ts
|
|
1255
|
-
function
|
|
1289
|
+
function Nt(e) {
|
|
1256
1290
|
return async (t, n) => {
|
|
1257
1291
|
let r = Date.now(), i = c(), a = {
|
|
1258
1292
|
...n,
|
|
@@ -1284,12 +1318,12 @@ function At(e) {
|
|
|
1284
1318
|
}
|
|
1285
1319
|
//#endregion
|
|
1286
1320
|
//#region src/sessions/remove.ts
|
|
1287
|
-
function
|
|
1321
|
+
function Pt(e) {
|
|
1288
1322
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1289
1323
|
}
|
|
1290
1324
|
//#endregion
|
|
1291
1325
|
//#region src/sessions/update.ts
|
|
1292
|
-
function
|
|
1326
|
+
function Ft(e) {
|
|
1293
1327
|
return async (t, n, r) => {
|
|
1294
1328
|
let i = Date.now(), a = {
|
|
1295
1329
|
updated_at_ts: i,
|
|
@@ -1310,10 +1344,10 @@ function Mt(e) {
|
|
|
1310
1344
|
}
|
|
1311
1345
|
//#endregion
|
|
1312
1346
|
//#region src/sessions/list.ts
|
|
1313
|
-
function
|
|
1347
|
+
function It(e) {
|
|
1314
1348
|
return async (t, n = {}) => {
|
|
1315
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);
|
|
1316
|
-
l && (u =
|
|
1350
|
+
l && (u = O(e, u, l, ["user_id", "session_id"]));
|
|
1317
1351
|
let d = u;
|
|
1318
1352
|
if (c && c.sort_by) {
|
|
1319
1353
|
let { ref: t } = e.dynamic;
|
|
@@ -1365,18 +1399,18 @@ function Nt(e) {
|
|
|
1365
1399
|
}
|
|
1366
1400
|
//#endregion
|
|
1367
1401
|
//#region src/sessions/index.ts
|
|
1368
|
-
function
|
|
1402
|
+
function Lt(e) {
|
|
1369
1403
|
return {
|
|
1370
|
-
create:
|
|
1371
|
-
get:
|
|
1372
|
-
list:
|
|
1373
|
-
remove:
|
|
1374
|
-
update:
|
|
1404
|
+
create: Nt(e),
|
|
1405
|
+
get: Mt(e),
|
|
1406
|
+
list: It(e),
|
|
1407
|
+
remove: Pt(e),
|
|
1408
|
+
update: Ft(e)
|
|
1375
1409
|
};
|
|
1376
1410
|
}
|
|
1377
1411
|
//#endregion
|
|
1378
1412
|
//#region src/passwords/get.ts
|
|
1379
|
-
function
|
|
1413
|
+
function Rt(e) {
|
|
1380
1414
|
return async (t, n) => {
|
|
1381
1415
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1382
1416
|
if (!r) return null;
|
|
@@ -1389,7 +1423,7 @@ function Ft(e) {
|
|
|
1389
1423
|
}
|
|
1390
1424
|
//#endregion
|
|
1391
1425
|
//#region src/passwords/create.ts
|
|
1392
|
-
function
|
|
1426
|
+
function zt(e) {
|
|
1393
1427
|
return async (n, r, i) => {
|
|
1394
1428
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1395
1429
|
...r,
|
|
@@ -1407,7 +1441,7 @@ function It(e) {
|
|
|
1407
1441
|
}
|
|
1408
1442
|
//#endregion
|
|
1409
1443
|
//#region src/passwords/update.ts
|
|
1410
|
-
function
|
|
1444
|
+
function Bt(e) {
|
|
1411
1445
|
return async (t, n) => {
|
|
1412
1446
|
let r = e.updateTable("passwords").set({
|
|
1413
1447
|
password: n.password,
|
|
@@ -1420,7 +1454,7 @@ function Lt(e) {
|
|
|
1420
1454
|
}
|
|
1421
1455
|
//#endregion
|
|
1422
1456
|
//#region src/passwords/list.ts
|
|
1423
|
-
function
|
|
1457
|
+
function Vt(e) {
|
|
1424
1458
|
return async (t, n, r) => {
|
|
1425
1459
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1426
1460
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1431,20 +1465,20 @@ function Rt(e) {
|
|
|
1431
1465
|
}
|
|
1432
1466
|
//#endregion
|
|
1433
1467
|
//#region src/passwords/index.ts
|
|
1434
|
-
function
|
|
1468
|
+
function Ht(e) {
|
|
1435
1469
|
return {
|
|
1436
|
-
create:
|
|
1437
|
-
update:
|
|
1438
|
-
get:
|
|
1439
|
-
list:
|
|
1470
|
+
create: zt(e),
|
|
1471
|
+
update: Bt(e),
|
|
1472
|
+
get: Rt(e),
|
|
1473
|
+
list: Vt(e)
|
|
1440
1474
|
};
|
|
1441
1475
|
}
|
|
1442
1476
|
//#endregion
|
|
1443
1477
|
//#region src/codes/list.ts
|
|
1444
|
-
function
|
|
1478
|
+
function Ut(e) {
|
|
1445
1479
|
return async (t, n = {}) => {
|
|
1446
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);
|
|
1447
|
-
s && (c =
|
|
1481
|
+
s && (c = O(e, c, s, ["code", "login_id"]));
|
|
1448
1482
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1449
1483
|
let { tenant_id: t, ...n } = e;
|
|
1450
1484
|
return g.parse(l(n));
|
|
@@ -1466,13 +1500,13 @@ function Bt(e) {
|
|
|
1466
1500
|
}
|
|
1467
1501
|
//#endregion
|
|
1468
1502
|
//#region src/codes/expires-at-ts.ts
|
|
1469
|
-
function
|
|
1503
|
+
function Wt(e) {
|
|
1470
1504
|
let t = new Date(e).getTime();
|
|
1471
1505
|
return Number.isNaN(t) ? 0 : t;
|
|
1472
1506
|
}
|
|
1473
1507
|
//#endregion
|
|
1474
1508
|
//#region src/codes/create.ts
|
|
1475
|
-
function
|
|
1509
|
+
function Gt(e) {
|
|
1476
1510
|
return async (t, n) => {
|
|
1477
1511
|
let r = {
|
|
1478
1512
|
...n,
|
|
@@ -1481,18 +1515,18 @@ function Ht(e) {
|
|
|
1481
1515
|
return await e.insertInto("codes").values({
|
|
1482
1516
|
...r,
|
|
1483
1517
|
tenant_id: t,
|
|
1484
|
-
expires_at_ts:
|
|
1518
|
+
expires_at_ts: Wt(r.expires_at)
|
|
1485
1519
|
}).execute(), r;
|
|
1486
1520
|
};
|
|
1487
1521
|
}
|
|
1488
1522
|
//#endregion
|
|
1489
1523
|
//#region src/codes/remove.ts
|
|
1490
|
-
function
|
|
1524
|
+
function Kt(e) {
|
|
1491
1525
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1492
1526
|
}
|
|
1493
1527
|
//#endregion
|
|
1494
1528
|
//#region src/codes/get.ts
|
|
1495
|
-
function
|
|
1529
|
+
function qt(e) {
|
|
1496
1530
|
return async (t, n, r) => {
|
|
1497
1531
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1498
1532
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1502,38 +1536,38 @@ function Wt(e) {
|
|
|
1502
1536
|
}
|
|
1503
1537
|
//#endregion
|
|
1504
1538
|
//#region src/codes/used.ts
|
|
1505
|
-
function
|
|
1539
|
+
function Jt(e) {
|
|
1506
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;
|
|
1507
1541
|
}
|
|
1508
1542
|
//#endregion
|
|
1509
1543
|
//#region src/codes/consume.ts
|
|
1510
|
-
function
|
|
1544
|
+
function Yt(e) {
|
|
1511
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;
|
|
1512
1546
|
}
|
|
1513
1547
|
//#endregion
|
|
1514
1548
|
//#region src/codes/cleanup.ts
|
|
1515
|
-
function
|
|
1549
|
+
function Xt(e) {
|
|
1516
1550
|
return async (t) => {
|
|
1517
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1551
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", Wt(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1518
1552
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1519
1553
|
};
|
|
1520
1554
|
}
|
|
1521
1555
|
//#endregion
|
|
1522
1556
|
//#region src/codes/index.ts
|
|
1523
|
-
function
|
|
1557
|
+
function Zt(e) {
|
|
1524
1558
|
return {
|
|
1525
|
-
create:
|
|
1526
|
-
list:
|
|
1527
|
-
remove:
|
|
1528
|
-
used:
|
|
1529
|
-
consume:
|
|
1530
|
-
get:
|
|
1531
|
-
cleanup:
|
|
1559
|
+
create: Gt(e),
|
|
1560
|
+
list: Ut(e),
|
|
1561
|
+
remove: Kt(e),
|
|
1562
|
+
used: Jt(e),
|
|
1563
|
+
consume: Yt(e),
|
|
1564
|
+
get: qt(e),
|
|
1565
|
+
cleanup: Xt(e)
|
|
1532
1566
|
};
|
|
1533
1567
|
}
|
|
1534
1568
|
//#endregion
|
|
1535
1569
|
//#region src/connections/create.ts
|
|
1536
|
-
function
|
|
1570
|
+
function Qt(e) {
|
|
1537
1571
|
return async (t, n, r) => {
|
|
1538
1572
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1539
1573
|
delete o.enabled_clients;
|
|
@@ -1554,7 +1588,7 @@ function Yt(e) {
|
|
|
1554
1588
|
}
|
|
1555
1589
|
//#endregion
|
|
1556
1590
|
//#region src/connections/transform.ts
|
|
1557
|
-
function
|
|
1591
|
+
function $t(e) {
|
|
1558
1592
|
let { is_system: t, ...n } = e;
|
|
1559
1593
|
return l({
|
|
1560
1594
|
...n,
|
|
@@ -1562,16 +1596,16 @@ function L(e) {
|
|
|
1562
1596
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1563
1597
|
});
|
|
1564
1598
|
}
|
|
1565
|
-
function
|
|
1566
|
-
return e.map(
|
|
1599
|
+
function en(e) {
|
|
1600
|
+
return e.map($t);
|
|
1567
1601
|
}
|
|
1568
1602
|
//#endregion
|
|
1569
1603
|
//#region src/connections/list.ts
|
|
1570
|
-
function
|
|
1604
|
+
function tn(e) {
|
|
1571
1605
|
return async (t, n = {}) => {
|
|
1572
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);
|
|
1573
|
-
s && (c =
|
|
1574
|
-
let l =
|
|
1607
|
+
s && (c = O(e, c, s, ["user_id", "ip"]));
|
|
1608
|
+
let l = en(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1575
1609
|
if (!a) return {
|
|
1576
1610
|
connections: l,
|
|
1577
1611
|
start: 0,
|
|
@@ -1589,20 +1623,20 @@ function Zt(e) {
|
|
|
1589
1623
|
}
|
|
1590
1624
|
//#endregion
|
|
1591
1625
|
//#region src/connections/remove.ts
|
|
1592
|
-
function
|
|
1626
|
+
function nn(e) {
|
|
1593
1627
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1594
1628
|
}
|
|
1595
1629
|
//#endregion
|
|
1596
1630
|
//#region src/connections/get.ts
|
|
1597
|
-
function
|
|
1631
|
+
function rn(e) {
|
|
1598
1632
|
return async (t, n) => {
|
|
1599
1633
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1600
|
-
return r ?
|
|
1634
|
+
return r ? $t(r) : null;
|
|
1601
1635
|
};
|
|
1602
1636
|
}
|
|
1603
1637
|
//#endregion
|
|
1604
1638
|
//#region src/connections/update.ts
|
|
1605
|
-
function
|
|
1639
|
+
function an(e) {
|
|
1606
1640
|
return async (t, n, r) => {
|
|
1607
1641
|
let { is_system: i, ...a } = r;
|
|
1608
1642
|
delete a.enabled_clients;
|
|
@@ -1619,18 +1653,18 @@ function en(e) {
|
|
|
1619
1653
|
}
|
|
1620
1654
|
//#endregion
|
|
1621
1655
|
//#region src/connections/index.ts
|
|
1622
|
-
function
|
|
1656
|
+
function on(e) {
|
|
1623
1657
|
return {
|
|
1624
|
-
create:
|
|
1625
|
-
get:
|
|
1626
|
-
list:
|
|
1627
|
-
remove:
|
|
1628
|
-
update:
|
|
1658
|
+
create: Qt(e),
|
|
1659
|
+
get: rn(e),
|
|
1660
|
+
list: tn(e),
|
|
1661
|
+
remove: nn(e),
|
|
1662
|
+
update: an(e)
|
|
1629
1663
|
};
|
|
1630
1664
|
}
|
|
1631
1665
|
//#endregion
|
|
1632
1666
|
//#region src/clients/create.ts
|
|
1633
|
-
function
|
|
1667
|
+
function sn(e) {
|
|
1634
1668
|
return async (r, i, a) => {
|
|
1635
1669
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1636
1670
|
...i,
|
|
@@ -1695,7 +1729,7 @@ function nn(e) {
|
|
|
1695
1729
|
}
|
|
1696
1730
|
//#endregion
|
|
1697
1731
|
//#region src/clients/get.ts
|
|
1698
|
-
function
|
|
1732
|
+
function cn(e) {
|
|
1699
1733
|
return async (t, n) => {
|
|
1700
1734
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1701
1735
|
if (!r) return null;
|
|
@@ -1741,7 +1775,7 @@ function rn(e) {
|
|
|
1741
1775
|
}
|
|
1742
1776
|
//#endregion
|
|
1743
1777
|
//#region src/clients/getByClientId.ts
|
|
1744
|
-
function
|
|
1778
|
+
function ln(e) {
|
|
1745
1779
|
return async (t) => {
|
|
1746
1780
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1747
1781
|
return n ? l({
|
|
@@ -1785,7 +1819,7 @@ function an(e) {
|
|
|
1785
1819
|
}
|
|
1786
1820
|
//#endregion
|
|
1787
1821
|
//#region src/clients/list.ts
|
|
1788
|
-
function
|
|
1822
|
+
function un(e) {
|
|
1789
1823
|
return l({
|
|
1790
1824
|
...e,
|
|
1791
1825
|
global: !!e.global,
|
|
@@ -1824,7 +1858,7 @@ function on(e) {
|
|
|
1824
1858
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1825
1859
|
});
|
|
1826
1860
|
}
|
|
1827
|
-
function
|
|
1861
|
+
function dn(e) {
|
|
1828
1862
|
return async (t, n) => {
|
|
1829
1863
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1830
1864
|
if (n?.q) {
|
|
@@ -1834,12 +1868,12 @@ function sn(e) {
|
|
|
1834
1868
|
r = r.where(t, "=", e[2]);
|
|
1835
1869
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1836
1870
|
}
|
|
1837
|
-
if (
|
|
1838
|
-
let { rows: e, limit: t, next: i } = await
|
|
1871
|
+
if (P(n)) {
|
|
1872
|
+
let { rows: e, limit: t, next: i } = await F(r.selectAll(), n, {
|
|
1839
1873
|
sortColumn: "created_at",
|
|
1840
1874
|
sortOrder: "desc",
|
|
1841
1875
|
idColumn: "client_id"
|
|
1842
|
-
}), a = e.map(
|
|
1876
|
+
}), a = e.map(un);
|
|
1843
1877
|
return {
|
|
1844
1878
|
clients: a,
|
|
1845
1879
|
totals: {
|
|
@@ -1872,7 +1906,7 @@ function sn(e) {
|
|
|
1872
1906
|
let a = await r.executeTakeFirst();
|
|
1873
1907
|
c = Number(a?.count || 0);
|
|
1874
1908
|
}
|
|
1875
|
-
let l = s.map(
|
|
1909
|
+
let l = s.map(un);
|
|
1876
1910
|
return {
|
|
1877
1911
|
clients: l,
|
|
1878
1912
|
totals: {
|
|
@@ -1886,12 +1920,12 @@ function sn(e) {
|
|
|
1886
1920
|
}
|
|
1887
1921
|
//#endregion
|
|
1888
1922
|
//#region src/clients/remove.ts
|
|
1889
|
-
function
|
|
1923
|
+
function fn(e) {
|
|
1890
1924
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1891
1925
|
}
|
|
1892
1926
|
//#endregion
|
|
1893
1927
|
//#region src/clients/update.ts
|
|
1894
|
-
function
|
|
1928
|
+
function pn(e) {
|
|
1895
1929
|
return async (t, r, i) => {
|
|
1896
1930
|
let a = {
|
|
1897
1931
|
...i,
|
|
@@ -1938,31 +1972,31 @@ function ln(e) {
|
|
|
1938
1972
|
}
|
|
1939
1973
|
//#endregion
|
|
1940
1974
|
//#region src/clients/index.ts
|
|
1941
|
-
function
|
|
1975
|
+
function mn(e) {
|
|
1942
1976
|
return {
|
|
1943
|
-
create:
|
|
1944
|
-
get:
|
|
1945
|
-
getByClientId:
|
|
1946
|
-
list:
|
|
1947
|
-
remove:
|
|
1948
|
-
update:
|
|
1977
|
+
create: sn(e),
|
|
1978
|
+
get: cn(e),
|
|
1979
|
+
getByClientId: ln(e),
|
|
1980
|
+
list: dn(e),
|
|
1981
|
+
remove: fn(e),
|
|
1982
|
+
update: pn(e)
|
|
1949
1983
|
};
|
|
1950
1984
|
}
|
|
1951
1985
|
//#endregion
|
|
1952
1986
|
//#region src/clientConnections/listByClient.ts
|
|
1953
|
-
function
|
|
1987
|
+
function hn(e) {
|
|
1954
1988
|
return async (t, n) => {
|
|
1955
1989
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1956
1990
|
if (!r) return [];
|
|
1957
1991
|
let i = JSON.parse(r.connections || "[]");
|
|
1958
1992
|
if (i.length === 0) return [];
|
|
1959
|
-
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, $t(e)]));
|
|
1960
1994
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
1961
1995
|
};
|
|
1962
1996
|
}
|
|
1963
1997
|
//#endregion
|
|
1964
1998
|
//#region src/clientConnections/updateByClient.ts
|
|
1965
|
-
function
|
|
1999
|
+
function gn(e) {
|
|
1966
2000
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
1967
2001
|
connections: JSON.stringify(r),
|
|
1968
2002
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1970,7 +2004,7 @@ function fn(e) {
|
|
|
1970
2004
|
}
|
|
1971
2005
|
//#endregion
|
|
1972
2006
|
//#region src/clientConnections/listByConnection.ts
|
|
1973
|
-
function
|
|
2007
|
+
function _n(e) {
|
|
1974
2008
|
return async (t, n) => {
|
|
1975
2009
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
1976
2010
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -1979,7 +2013,7 @@ function pn(e) {
|
|
|
1979
2013
|
}
|
|
1980
2014
|
//#endregion
|
|
1981
2015
|
//#region src/clientConnections/addClientToConnection.ts
|
|
1982
|
-
function
|
|
2016
|
+
function vn(e) {
|
|
1983
2017
|
return async (t, n, r) => {
|
|
1984
2018
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
1985
2019
|
if (!i) return !1;
|
|
@@ -1992,7 +2026,7 @@ function mn(e) {
|
|
|
1992
2026
|
}
|
|
1993
2027
|
//#endregion
|
|
1994
2028
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
1995
|
-
function
|
|
2029
|
+
function yn(e) {
|
|
1996
2030
|
return async (t, n, r) => {
|
|
1997
2031
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
1998
2032
|
if (!i) return !1;
|
|
@@ -2005,18 +2039,18 @@ function hn(e) {
|
|
|
2005
2039
|
}
|
|
2006
2040
|
//#endregion
|
|
2007
2041
|
//#region src/clientConnections/index.ts
|
|
2008
|
-
function
|
|
2042
|
+
function bn(e) {
|
|
2009
2043
|
return {
|
|
2010
|
-
listByClient:
|
|
2011
|
-
updateByClient:
|
|
2012
|
-
listByConnection:
|
|
2013
|
-
addClientToConnection:
|
|
2014
|
-
removeClientFromConnection:
|
|
2044
|
+
listByClient: hn(e),
|
|
2045
|
+
updateByClient: gn(e),
|
|
2046
|
+
listByConnection: _n(e),
|
|
2047
|
+
addClientToConnection: vn(e),
|
|
2048
|
+
removeClientFromConnection: yn(e)
|
|
2015
2049
|
};
|
|
2016
2050
|
}
|
|
2017
2051
|
//#endregion
|
|
2018
2052
|
//#region src/clientGrants/create.ts
|
|
2019
|
-
function
|
|
2053
|
+
function xn(e) {
|
|
2020
2054
|
return async (n, r, i) => {
|
|
2021
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 = {
|
|
2022
2056
|
id: s,
|
|
@@ -2044,7 +2078,7 @@ function _n(e) {
|
|
|
2044
2078
|
}
|
|
2045
2079
|
//#endregion
|
|
2046
2080
|
//#region src/clientGrants/get.ts
|
|
2047
|
-
function
|
|
2081
|
+
function Sn(e) {
|
|
2048
2082
|
return async (t, n) => {
|
|
2049
2083
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2050
2084
|
return r ? l({
|
|
@@ -2064,7 +2098,7 @@ function vn(e) {
|
|
|
2064
2098
|
}
|
|
2065
2099
|
//#endregion
|
|
2066
2100
|
//#region src/clientGrants/list.ts
|
|
2067
|
-
function
|
|
2101
|
+
function Cn(e) {
|
|
2068
2102
|
return m.parse(l({
|
|
2069
2103
|
...e,
|
|
2070
2104
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2073,7 +2107,7 @@ function yn(e) {
|
|
|
2073
2107
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2074
2108
|
}));
|
|
2075
2109
|
}
|
|
2076
|
-
function
|
|
2110
|
+
function wn(e) {
|
|
2077
2111
|
return async (t, n = {}) => {
|
|
2078
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);
|
|
2079
2113
|
if (s) {
|
|
@@ -2084,13 +2118,13 @@ function bn(e) {
|
|
|
2084
2118
|
let e = +(a === "true");
|
|
2085
2119
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2086
2120
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2087
|
-
} else l =
|
|
2121
|
+
} else l = O(e, l, t, []);
|
|
2088
2122
|
}
|
|
2089
|
-
if (
|
|
2090
|
-
let { rows: e, limit: t, next: r } = await
|
|
2123
|
+
if (P(n)) {
|
|
2124
|
+
let { rows: e, limit: t, next: r } = await F(l.selectAll(), n, {
|
|
2091
2125
|
sortColumn: "created_at",
|
|
2092
2126
|
sortOrder: "desc"
|
|
2093
|
-
}), i = e.map(
|
|
2127
|
+
}), i = e.map(Cn);
|
|
2094
2128
|
return {
|
|
2095
2129
|
client_grants: i,
|
|
2096
2130
|
start: 0,
|
|
@@ -2104,7 +2138,7 @@ function bn(e) {
|
|
|
2104
2138
|
let { ref: t } = e.dynamic;
|
|
2105
2139
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2106
2140
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2107
|
-
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(Cn);
|
|
2108
2142
|
if (!a) return {
|
|
2109
2143
|
client_grants: d,
|
|
2110
2144
|
start: 0,
|
|
@@ -2122,12 +2156,12 @@ function bn(e) {
|
|
|
2122
2156
|
}
|
|
2123
2157
|
//#endregion
|
|
2124
2158
|
//#region src/clientGrants/remove.ts
|
|
2125
|
-
function
|
|
2159
|
+
function Tn(e) {
|
|
2126
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;
|
|
2127
2161
|
}
|
|
2128
2162
|
//#endregion
|
|
2129
2163
|
//#region src/clientGrants/update.ts
|
|
2130
|
-
function
|
|
2164
|
+
function En(e) {
|
|
2131
2165
|
return async (t, n, r) => {
|
|
2132
2166
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2133
2167
|
...s,
|
|
@@ -2138,18 +2172,18 @@ function Sn(e) {
|
|
|
2138
2172
|
}
|
|
2139
2173
|
//#endregion
|
|
2140
2174
|
//#region src/clientGrants/index.ts
|
|
2141
|
-
function
|
|
2175
|
+
function Dn(e) {
|
|
2142
2176
|
return {
|
|
2143
|
-
create:
|
|
2144
|
-
get:
|
|
2145
|
-
list:
|
|
2146
|
-
remove:
|
|
2147
|
-
update:
|
|
2177
|
+
create: xn(e),
|
|
2178
|
+
get: Sn(e),
|
|
2179
|
+
list: wn(e),
|
|
2180
|
+
remove: Tn(e),
|
|
2181
|
+
update: En(e)
|
|
2148
2182
|
};
|
|
2149
2183
|
}
|
|
2150
2184
|
//#endregion
|
|
2151
2185
|
//#region src/clientRegistrationTokens/create.ts
|
|
2152
|
-
function
|
|
2186
|
+
function On(e) {
|
|
2153
2187
|
return async (t, n) => {
|
|
2154
2188
|
let r = Date.now();
|
|
2155
2189
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2180,12 +2214,12 @@ function wn(e) {
|
|
|
2180
2214
|
}
|
|
2181
2215
|
//#endregion
|
|
2182
2216
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2183
|
-
function
|
|
2217
|
+
function kn(e) {
|
|
2184
2218
|
let t = h.safeParse(e);
|
|
2185
2219
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2186
2220
|
return t.data;
|
|
2187
2221
|
}
|
|
2188
|
-
function
|
|
2222
|
+
function An(e) {
|
|
2189
2223
|
if (!e) return;
|
|
2190
2224
|
let t;
|
|
2191
2225
|
try {
|
|
@@ -2199,10 +2233,10 @@ function R(e) {
|
|
|
2199
2233
|
return {
|
|
2200
2234
|
id: e.id,
|
|
2201
2235
|
token_hash: e.token_hash,
|
|
2202
|
-
type:
|
|
2236
|
+
type: kn(e.type),
|
|
2203
2237
|
client_id: e.client_id ?? void 0,
|
|
2204
2238
|
sub: e.sub ?? void 0,
|
|
2205
|
-
constraints:
|
|
2239
|
+
constraints: An(e.constraints),
|
|
2206
2240
|
single_use: !!e.single_use,
|
|
2207
2241
|
expires_at: i(e.expires_at_ts),
|
|
2208
2242
|
used_at: i(e.used_at_ts),
|
|
@@ -2212,7 +2246,7 @@ function R(e) {
|
|
|
2212
2246
|
}
|
|
2213
2247
|
//#endregion
|
|
2214
2248
|
//#region src/clientRegistrationTokens/get.ts
|
|
2215
|
-
function
|
|
2249
|
+
function jn(e) {
|
|
2216
2250
|
return async (t, n) => {
|
|
2217
2251
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2218
2252
|
return r ? R(r) : null;
|
|
@@ -2220,7 +2254,7 @@ function Dn(e) {
|
|
|
2220
2254
|
}
|
|
2221
2255
|
//#endregion
|
|
2222
2256
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2223
|
-
function
|
|
2257
|
+
function Mn(e) {
|
|
2224
2258
|
return async (t, n) => {
|
|
2225
2259
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2226
2260
|
return r ? R(r) : null;
|
|
@@ -2228,22 +2262,22 @@ function On(e) {
|
|
|
2228
2262
|
}
|
|
2229
2263
|
//#endregion
|
|
2230
2264
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2231
|
-
function
|
|
2265
|
+
function Nn(e) {
|
|
2232
2266
|
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(R);
|
|
2233
2267
|
}
|
|
2234
2268
|
//#endregion
|
|
2235
2269
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2236
|
-
function
|
|
2270
|
+
function Pn(e) {
|
|
2237
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;
|
|
2238
2272
|
}
|
|
2239
2273
|
//#endregion
|
|
2240
2274
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2241
|
-
function
|
|
2275
|
+
function Fn(e) {
|
|
2242
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;
|
|
2243
2277
|
}
|
|
2244
2278
|
//#endregion
|
|
2245
2279
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2246
|
-
function
|
|
2280
|
+
function In(e) {
|
|
2247
2281
|
return async (t, n, r) => {
|
|
2248
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();
|
|
2249
2283
|
return Number(i.numUpdatedRows);
|
|
@@ -2251,29 +2285,29 @@ function Mn(e) {
|
|
|
2251
2285
|
}
|
|
2252
2286
|
//#endregion
|
|
2253
2287
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2254
|
-
function
|
|
2288
|
+
function Ln(e) {
|
|
2255
2289
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2256
2290
|
}
|
|
2257
2291
|
//#endregion
|
|
2258
2292
|
//#region src/clientRegistrationTokens/index.ts
|
|
2259
|
-
function
|
|
2293
|
+
function Rn(e) {
|
|
2260
2294
|
return {
|
|
2261
|
-
create:
|
|
2262
|
-
get:
|
|
2263
|
-
getByHash:
|
|
2264
|
-
listByClient:
|
|
2265
|
-
markUsed:
|
|
2266
|
-
revoke:
|
|
2267
|
-
revokeByClient:
|
|
2268
|
-
remove:
|
|
2295
|
+
create: On(e),
|
|
2296
|
+
get: jn(e),
|
|
2297
|
+
getByHash: Mn(e),
|
|
2298
|
+
listByClient: Nn(e),
|
|
2299
|
+
markUsed: Pn(e),
|
|
2300
|
+
revoke: Fn(e),
|
|
2301
|
+
revokeByClient: In(e),
|
|
2302
|
+
remove: Ln(e)
|
|
2269
2303
|
};
|
|
2270
2304
|
}
|
|
2271
2305
|
//#endregion
|
|
2272
2306
|
//#region src/keys/list.ts
|
|
2273
|
-
function
|
|
2307
|
+
function zn(e) {
|
|
2274
2308
|
return async (t = {}) => {
|
|
2275
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)]));
|
|
2276
|
-
s && (c =
|
|
2310
|
+
s && (c = O(e, c, s, [
|
|
2277
2311
|
"kid",
|
|
2278
2312
|
"tenant_id",
|
|
2279
2313
|
"connection",
|
|
@@ -2299,7 +2333,7 @@ function Fn(e) {
|
|
|
2299
2333
|
}
|
|
2300
2334
|
//#endregion
|
|
2301
2335
|
//#region src/keys/create.ts
|
|
2302
|
-
function
|
|
2336
|
+
function Bn(e) {
|
|
2303
2337
|
return async (t, n) => {
|
|
2304
2338
|
let r = n?.importMetadata;
|
|
2305
2339
|
await e.insertInto("keys").values({
|
|
@@ -2311,21 +2345,21 @@ function In(e) {
|
|
|
2311
2345
|
}
|
|
2312
2346
|
//#endregion
|
|
2313
2347
|
//#region src/keys/update.ts
|
|
2314
|
-
function
|
|
2348
|
+
function Vn(e) {
|
|
2315
2349
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2316
2350
|
}
|
|
2317
2351
|
//#endregion
|
|
2318
2352
|
//#region src/keys/index.ts
|
|
2319
|
-
function
|
|
2353
|
+
function Hn(e) {
|
|
2320
2354
|
return {
|
|
2321
|
-
create:
|
|
2322
|
-
list:
|
|
2323
|
-
update:
|
|
2355
|
+
create: Bn(e),
|
|
2356
|
+
list: zn(e),
|
|
2357
|
+
update: Vn(e)
|
|
2324
2358
|
};
|
|
2325
2359
|
}
|
|
2326
2360
|
//#endregion
|
|
2327
2361
|
//#region src/customDomains/create.ts
|
|
2328
|
-
function
|
|
2362
|
+
function Un(e) {
|
|
2329
2363
|
return async (n, r, i) => {
|
|
2330
2364
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2331
2365
|
status: "pending",
|
|
@@ -2345,35 +2379,35 @@ function zn(e) {
|
|
|
2345
2379
|
}
|
|
2346
2380
|
//#endregion
|
|
2347
2381
|
//#region src/customDomains/list.ts
|
|
2348
|
-
function
|
|
2382
|
+
function Wn(e) {
|
|
2349
2383
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2350
2384
|
...e,
|
|
2351
2385
|
primary: e.primary === 1,
|
|
2352
|
-
domain_metadata:
|
|
2353
|
-
verification:
|
|
2386
|
+
domain_metadata: L(e.domain_metadata, void 0),
|
|
2387
|
+
verification: L(e.verification, void 0)
|
|
2354
2388
|
}));
|
|
2355
2389
|
}
|
|
2356
2390
|
//#endregion
|
|
2357
2391
|
//#region src/customDomains/remove.ts
|
|
2358
|
-
function
|
|
2392
|
+
function Gn(e) {
|
|
2359
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;
|
|
2360
2394
|
}
|
|
2361
2395
|
//#endregion
|
|
2362
2396
|
//#region src/customDomains/get.ts
|
|
2363
|
-
function
|
|
2397
|
+
function Kn(e) {
|
|
2364
2398
|
return async (t, n) => {
|
|
2365
2399
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2366
2400
|
return r ? {
|
|
2367
2401
|
...r,
|
|
2368
2402
|
primary: r.primary === 1,
|
|
2369
|
-
domain_metadata:
|
|
2370
|
-
verification:
|
|
2403
|
+
domain_metadata: L(r.domain_metadata, void 0),
|
|
2404
|
+
verification: L(r.verification, void 0)
|
|
2371
2405
|
} : null;
|
|
2372
2406
|
};
|
|
2373
2407
|
}
|
|
2374
2408
|
//#endregion
|
|
2375
2409
|
//#region src/customDomains/update.ts
|
|
2376
|
-
function
|
|
2410
|
+
function qn(e) {
|
|
2377
2411
|
return async (t, n, r) => {
|
|
2378
2412
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2379
2413
|
...s,
|
|
@@ -2387,31 +2421,31 @@ function Un(e) {
|
|
|
2387
2421
|
}
|
|
2388
2422
|
//#endregion
|
|
2389
2423
|
//#region src/customDomains/getByDomain.ts
|
|
2390
|
-
function
|
|
2424
|
+
function Jn(e) {
|
|
2391
2425
|
return async (t) => {
|
|
2392
2426
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2393
2427
|
return n ? {
|
|
2394
2428
|
...n,
|
|
2395
2429
|
primary: n.primary === 1,
|
|
2396
|
-
domain_metadata:
|
|
2430
|
+
domain_metadata: L(n.domain_metadata, void 0)
|
|
2397
2431
|
} : null;
|
|
2398
2432
|
};
|
|
2399
2433
|
}
|
|
2400
2434
|
//#endregion
|
|
2401
2435
|
//#region src/customDomains/index.ts
|
|
2402
|
-
function
|
|
2436
|
+
function Yn(e) {
|
|
2403
2437
|
return {
|
|
2404
|
-
create:
|
|
2405
|
-
get:
|
|
2406
|
-
getByDomain:
|
|
2407
|
-
list:
|
|
2408
|
-
remove:
|
|
2409
|
-
update:
|
|
2438
|
+
create: Un(e),
|
|
2439
|
+
get: Kn(e),
|
|
2440
|
+
getByDomain: Jn(e),
|
|
2441
|
+
list: Wn(e),
|
|
2442
|
+
remove: Gn(e),
|
|
2443
|
+
update: qn(e)
|
|
2410
2444
|
};
|
|
2411
2445
|
}
|
|
2412
2446
|
//#endregion
|
|
2413
2447
|
//#region src/branding/get.ts
|
|
2414
|
-
function
|
|
2448
|
+
function Xn(e) {
|
|
2415
2449
|
return async (t) => {
|
|
2416
2450
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2417
2451
|
if (!n) return null;
|
|
@@ -2433,7 +2467,7 @@ function Kn(e) {
|
|
|
2433
2467
|
}
|
|
2434
2468
|
//#endregion
|
|
2435
2469
|
//#region src/branding/set.ts
|
|
2436
|
-
function
|
|
2470
|
+
function Zn(e) {
|
|
2437
2471
|
return async (t, n) => {
|
|
2438
2472
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2439
2473
|
try {
|
|
@@ -2462,15 +2496,15 @@ function qn(e) {
|
|
|
2462
2496
|
}
|
|
2463
2497
|
//#endregion
|
|
2464
2498
|
//#region src/branding/index.ts
|
|
2465
|
-
function
|
|
2499
|
+
function Qn(e) {
|
|
2466
2500
|
return {
|
|
2467
|
-
get:
|
|
2468
|
-
set:
|
|
2501
|
+
get: Xn(e),
|
|
2502
|
+
set: Zn(e)
|
|
2469
2503
|
};
|
|
2470
2504
|
}
|
|
2471
2505
|
//#endregion
|
|
2472
2506
|
//#region src/universalLoginTemplates/get.ts
|
|
2473
|
-
function
|
|
2507
|
+
function $n(e) {
|
|
2474
2508
|
return async (t) => {
|
|
2475
2509
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2476
2510
|
return n ? { body: n.body } : null;
|
|
@@ -2478,7 +2512,7 @@ function Yn(e) {
|
|
|
2478
2512
|
}
|
|
2479
2513
|
//#endregion
|
|
2480
2514
|
//#region src/universalLoginTemplates/set.ts
|
|
2481
|
-
function
|
|
2515
|
+
function er(e) {
|
|
2482
2516
|
return async (t, n, r) => {
|
|
2483
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;
|
|
2484
2518
|
try {
|
|
@@ -2499,26 +2533,26 @@ function Xn(e) {
|
|
|
2499
2533
|
}
|
|
2500
2534
|
//#endregion
|
|
2501
2535
|
//#region src/universalLoginTemplates/delete.ts
|
|
2502
|
-
function
|
|
2536
|
+
function tr(e) {
|
|
2503
2537
|
return async (t) => {
|
|
2504
2538
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2505
2539
|
};
|
|
2506
2540
|
}
|
|
2507
2541
|
//#endregion
|
|
2508
2542
|
//#region src/universalLoginTemplates/index.ts
|
|
2509
|
-
function
|
|
2543
|
+
function nr(e) {
|
|
2510
2544
|
return {
|
|
2511
|
-
get:
|
|
2512
|
-
set:
|
|
2513
|
-
delete:
|
|
2545
|
+
get: $n(e),
|
|
2546
|
+
set: er(e),
|
|
2547
|
+
delete: tr(e)
|
|
2514
2548
|
};
|
|
2515
2549
|
}
|
|
2516
2550
|
//#endregion
|
|
2517
2551
|
//#region src/hooks/list.ts
|
|
2518
|
-
function
|
|
2552
|
+
function rr(e) {
|
|
2519
2553
|
return async (t, n = {}) => {
|
|
2520
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);
|
|
2521
|
-
if (u && (d =
|
|
2555
|
+
if (u && (d = O(e, d, u, [
|
|
2522
2556
|
"url",
|
|
2523
2557
|
"form_id",
|
|
2524
2558
|
"template_id",
|
|
@@ -2537,7 +2571,7 @@ function $n(e) {
|
|
|
2537
2571
|
...u,
|
|
2538
2572
|
enabled: !!n,
|
|
2539
2573
|
synchronous: !!i,
|
|
2540
|
-
metadata:
|
|
2574
|
+
metadata: ct(s)
|
|
2541
2575
|
});
|
|
2542
2576
|
});
|
|
2543
2577
|
if (!s) return {
|
|
@@ -2557,7 +2591,7 @@ function $n(e) {
|
|
|
2557
2591
|
}
|
|
2558
2592
|
//#endregion
|
|
2559
2593
|
//#region src/hooks/get.ts
|
|
2560
|
-
function
|
|
2594
|
+
function ir(e) {
|
|
2561
2595
|
return async (t, n) => {
|
|
2562
2596
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2563
2597
|
if (!i) return null;
|
|
@@ -2570,18 +2604,18 @@ function er(e) {
|
|
|
2570
2604
|
...d,
|
|
2571
2605
|
enabled: !!u.enabled,
|
|
2572
2606
|
synchronous: !!u.synchronous,
|
|
2573
|
-
metadata:
|
|
2607
|
+
metadata: ct(c)
|
|
2574
2608
|
});
|
|
2575
2609
|
};
|
|
2576
2610
|
}
|
|
2577
2611
|
//#endregion
|
|
2578
2612
|
//#region src/hooks/remove.ts
|
|
2579
|
-
function
|
|
2613
|
+
function ar(e) {
|
|
2580
2614
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2581
2615
|
}
|
|
2582
2616
|
//#endregion
|
|
2583
2617
|
//#region src/hooks/create.ts
|
|
2584
|
-
function
|
|
2618
|
+
function or(e) {
|
|
2585
2619
|
return async (t, n, r) => {
|
|
2586
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 || Se()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2587
2621
|
return await e.insertInto("hooks").values({
|
|
@@ -2606,7 +2640,7 @@ function nr(e) {
|
|
|
2606
2640
|
}
|
|
2607
2641
|
//#endregion
|
|
2608
2642
|
//#region src/hooks/update.ts
|
|
2609
|
-
function
|
|
2643
|
+
function sr(e) {
|
|
2610
2644
|
return async (t, n, r) => {
|
|
2611
2645
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2612
2646
|
...o,
|
|
@@ -2620,18 +2654,18 @@ function rr(e) {
|
|
|
2620
2654
|
}
|
|
2621
2655
|
//#endregion
|
|
2622
2656
|
//#region src/hooks/index.ts
|
|
2623
|
-
function
|
|
2657
|
+
function cr(e) {
|
|
2624
2658
|
return {
|
|
2625
|
-
create:
|
|
2626
|
-
get:
|
|
2627
|
-
list:
|
|
2628
|
-
update:
|
|
2629
|
-
remove:
|
|
2659
|
+
create: or(e),
|
|
2660
|
+
get: ir(e),
|
|
2661
|
+
list: rr(e),
|
|
2662
|
+
update: sr(e),
|
|
2663
|
+
remove: ar(e)
|
|
2630
2664
|
};
|
|
2631
2665
|
}
|
|
2632
2666
|
//#endregion
|
|
2633
2667
|
//#region src/hook-code/create.ts
|
|
2634
|
-
function
|
|
2668
|
+
function lr(e) {
|
|
2635
2669
|
return async (t, n, r) => {
|
|
2636
2670
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? we();
|
|
2637
2671
|
return await e.insertInto("hook_code").values({
|
|
@@ -2653,7 +2687,7 @@ function ar(e) {
|
|
|
2653
2687
|
}
|
|
2654
2688
|
//#endregion
|
|
2655
2689
|
//#region src/hook-code/get.ts
|
|
2656
|
-
function
|
|
2690
|
+
function ur(e) {
|
|
2657
2691
|
return async (t, n) => {
|
|
2658
2692
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2659
2693
|
if (!i) return null;
|
|
@@ -2677,7 +2711,7 @@ function or(e) {
|
|
|
2677
2711
|
}
|
|
2678
2712
|
//#endregion
|
|
2679
2713
|
//#region src/hook-code/update.ts
|
|
2680
|
-
function
|
|
2714
|
+
function dr(e) {
|
|
2681
2715
|
return async (t, n, r) => {
|
|
2682
2716
|
let i = { updated_at_ts: Date.now() };
|
|
2683
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;
|
|
@@ -2685,22 +2719,22 @@ function sr(e) {
|
|
|
2685
2719
|
}
|
|
2686
2720
|
//#endregion
|
|
2687
2721
|
//#region src/hook-code/remove.ts
|
|
2688
|
-
function
|
|
2722
|
+
function fr(e) {
|
|
2689
2723
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2690
2724
|
}
|
|
2691
2725
|
//#endregion
|
|
2692
2726
|
//#region src/hook-code/index.ts
|
|
2693
|
-
function
|
|
2727
|
+
function pr(e) {
|
|
2694
2728
|
return {
|
|
2695
|
-
create:
|
|
2696
|
-
get:
|
|
2697
|
-
update:
|
|
2698
|
-
remove:
|
|
2729
|
+
create: lr(e),
|
|
2730
|
+
get: ur(e),
|
|
2731
|
+
update: dr(e),
|
|
2732
|
+
remove: fr(e)
|
|
2699
2733
|
};
|
|
2700
2734
|
}
|
|
2701
2735
|
//#endregion
|
|
2702
2736
|
//#region src/themes/create.ts
|
|
2703
|
-
function
|
|
2737
|
+
function mr(e) {
|
|
2704
2738
|
return async (n, r, i, a) => {
|
|
2705
2739
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2706
2740
|
themeId: o?.id || i || t(),
|
|
@@ -2711,20 +2745,20 @@ function ur(e) {
|
|
|
2711
2745
|
...c,
|
|
2712
2746
|
tenant_id: n
|
|
2713
2747
|
};
|
|
2714
|
-
return await e.insertInto("themes").values(
|
|
2748
|
+
return await e.insertInto("themes").values(I(l)).execute(), c;
|
|
2715
2749
|
};
|
|
2716
2750
|
}
|
|
2717
2751
|
//#endregion
|
|
2718
2752
|
//#region src/themes/remove.ts
|
|
2719
|
-
function
|
|
2753
|
+
function hr(e) {
|
|
2720
2754
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2721
2755
|
}
|
|
2722
2756
|
//#endregion
|
|
2723
2757
|
//#region src/themes/get.ts
|
|
2724
|
-
function
|
|
2758
|
+
function gr(e) {
|
|
2725
2759
|
return async (t, n) => {
|
|
2726
2760
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2727
|
-
return r ? l(
|
|
2761
|
+
return r ? l(et({
|
|
2728
2762
|
...r,
|
|
2729
2763
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2730
2764
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2744,9 +2778,9 @@ function fr(e) {
|
|
|
2744
2778
|
}
|
|
2745
2779
|
//#endregion
|
|
2746
2780
|
//#region src/themes/update.ts
|
|
2747
|
-
function
|
|
2781
|
+
function _r(e) {
|
|
2748
2782
|
return async (t, n, r) => {
|
|
2749
|
-
let { themeId: i, ...a } = r, o =
|
|
2783
|
+
let { themeId: i, ...a } = r, o = I({
|
|
2750
2784
|
...a,
|
|
2751
2785
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2752
2786
|
});
|
|
@@ -2755,17 +2789,17 @@ function pr(e) {
|
|
|
2755
2789
|
}
|
|
2756
2790
|
//#endregion
|
|
2757
2791
|
//#region src/themes/index.ts
|
|
2758
|
-
function
|
|
2792
|
+
function vr(e) {
|
|
2759
2793
|
return {
|
|
2760
|
-
create:
|
|
2761
|
-
get:
|
|
2762
|
-
remove:
|
|
2763
|
-
update:
|
|
2794
|
+
create: mr(e),
|
|
2795
|
+
get: gr(e),
|
|
2796
|
+
remove: hr(e),
|
|
2797
|
+
update: _r(e)
|
|
2764
2798
|
};
|
|
2765
2799
|
}
|
|
2766
2800
|
//#endregion
|
|
2767
2801
|
//#region src/loginSessions/get.ts
|
|
2768
|
-
function
|
|
2802
|
+
function yr(e) {
|
|
2769
2803
|
return async (t, n) => {
|
|
2770
2804
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2771
2805
|
if (!i) return null;
|
|
@@ -2777,7 +2811,7 @@ function hr(e) {
|
|
|
2777
2811
|
"created_at_ts",
|
|
2778
2812
|
"updated_at_ts",
|
|
2779
2813
|
"expires_at_ts"
|
|
2780
|
-
]), f =
|
|
2814
|
+
]), f = et(l({
|
|
2781
2815
|
...u,
|
|
2782
2816
|
...d,
|
|
2783
2817
|
state: i.state || p.PENDING,
|
|
@@ -2789,28 +2823,28 @@ function hr(e) {
|
|
|
2789
2823
|
}
|
|
2790
2824
|
//#endregion
|
|
2791
2825
|
//#region src/utils/ulid.ts
|
|
2792
|
-
var
|
|
2793
|
-
function
|
|
2826
|
+
var br = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", z = 32, xr = 10, Sr = 16;
|
|
2827
|
+
function Cr(e) {
|
|
2794
2828
|
let t = "";
|
|
2795
|
-
for (let n =
|
|
2829
|
+
for (let n = xr; n > 0; n--) t = br.charAt(e % z) + t, e = Math.floor(e / z);
|
|
2796
2830
|
return t;
|
|
2797
2831
|
}
|
|
2798
|
-
function
|
|
2799
|
-
let e = new Uint8Array(
|
|
2832
|
+
function wr() {
|
|
2833
|
+
let e = new Uint8Array(Sr);
|
|
2800
2834
|
crypto.getRandomValues(e);
|
|
2801
2835
|
let t = "";
|
|
2802
|
-
for (let n = 0; n <
|
|
2836
|
+
for (let n = 0; n < Sr; n++) t += br.charAt(e[n] % z);
|
|
2803
2837
|
return t;
|
|
2804
2838
|
}
|
|
2805
|
-
function
|
|
2806
|
-
return
|
|
2839
|
+
function Tr() {
|
|
2840
|
+
return Cr(Date.now()) + wr();
|
|
2807
2841
|
}
|
|
2808
2842
|
//#endregion
|
|
2809
2843
|
//#region src/loginSessions/create.ts
|
|
2810
|
-
function
|
|
2844
|
+
function Er(e) {
|
|
2811
2845
|
return async (t, n) => {
|
|
2812
2846
|
let r = c(), i = {
|
|
2813
|
-
id:
|
|
2847
|
+
id: Tr(),
|
|
2814
2848
|
...n,
|
|
2815
2849
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2816
2850
|
created_at: r,
|
|
@@ -2818,7 +2852,7 @@ function Sr(e) {
|
|
|
2818
2852
|
state: n.state || p.PENDING,
|
|
2819
2853
|
state_data: n.state_data,
|
|
2820
2854
|
failure_reason: n.failure_reason
|
|
2821
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2855
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = I(o);
|
|
2822
2856
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2823
2857
|
...l,
|
|
2824
2858
|
tenant_id: t,
|
|
@@ -2831,7 +2865,7 @@ function Sr(e) {
|
|
|
2831
2865
|
}
|
|
2832
2866
|
//#endregion
|
|
2833
2867
|
//#region src/loginSessions/update.ts
|
|
2834
|
-
function
|
|
2868
|
+
function Dr(e) {
|
|
2835
2869
|
return async (t, n, r) => {
|
|
2836
2870
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2837
2871
|
if (c !== void 0) {
|
|
@@ -2841,7 +2875,7 @@ function Cr(e) {
|
|
|
2841
2875
|
...c
|
|
2842
2876
|
}) };
|
|
2843
2877
|
}
|
|
2844
|
-
let d =
|
|
2878
|
+
let d = I(l);
|
|
2845
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({
|
|
2846
2880
|
...d,
|
|
2847
2881
|
...u,
|
|
@@ -2852,47 +2886,49 @@ function Cr(e) {
|
|
|
2852
2886
|
}
|
|
2853
2887
|
//#endregion
|
|
2854
2888
|
//#region src/loginSessions/remove.ts
|
|
2855
|
-
function
|
|
2889
|
+
function Or(e) {
|
|
2856
2890
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2857
2891
|
}
|
|
2858
2892
|
//#endregion
|
|
2859
2893
|
//#region src/loginSessions/index.ts
|
|
2860
|
-
function
|
|
2894
|
+
function kr(e) {
|
|
2861
2895
|
return {
|
|
2862
|
-
create:
|
|
2863
|
-
get:
|
|
2864
|
-
update:
|
|
2865
|
-
remove:
|
|
2896
|
+
create: Er(e),
|
|
2897
|
+
get: yr(e),
|
|
2898
|
+
update: Dr(e),
|
|
2899
|
+
remove: Or(e)
|
|
2866
2900
|
};
|
|
2867
2901
|
}
|
|
2868
2902
|
//#endregion
|
|
2869
2903
|
//#region src/promptSettings/get.ts
|
|
2870
|
-
function
|
|
2904
|
+
function Ar(e) {
|
|
2871
2905
|
return async (t) => {
|
|
2872
2906
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2873
2907
|
return l({
|
|
2874
2908
|
identifier_first: !!n?.identifier_first,
|
|
2875
2909
|
password_first: !!n?.password_first,
|
|
2876
2910
|
webauthn_platform_first_factor: !!n?.webauthn_platform_first_factor,
|
|
2911
|
+
show_last_used_connection: !!n?.show_last_used_connection,
|
|
2877
2912
|
universal_login_experience: n?.universal_login_experience || "new"
|
|
2878
2913
|
});
|
|
2879
2914
|
};
|
|
2880
2915
|
}
|
|
2881
2916
|
//#endregion
|
|
2882
2917
|
//#region src/promptSettings/set.ts
|
|
2883
|
-
function
|
|
2918
|
+
function jr(e) {
|
|
2884
2919
|
let t = {};
|
|
2885
|
-
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), e.universal_login_experience && (t.universal_login_experience = e.universal_login_experience), t;
|
|
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;
|
|
2886
2921
|
}
|
|
2887
|
-
function
|
|
2922
|
+
function Mr(e) {
|
|
2888
2923
|
return async (t, n) => {
|
|
2889
|
-
let r =
|
|
2924
|
+
let r = jr(n);
|
|
2890
2925
|
try {
|
|
2891
2926
|
await e.insertInto("prompt_settings").values({
|
|
2892
2927
|
tenant_id: t,
|
|
2893
2928
|
identifier_first: r.identifier_first ?? 1,
|
|
2894
2929
|
password_first: r.password_first ?? 0,
|
|
2895
2930
|
webauthn_platform_first_factor: r.webauthn_platform_first_factor ?? 0,
|
|
2931
|
+
show_last_used_connection: r.show_last_used_connection ?? 0,
|
|
2896
2932
|
universal_login_experience: r.universal_login_experience ?? "new"
|
|
2897
2933
|
}).execute();
|
|
2898
2934
|
} catch {
|
|
@@ -2903,15 +2939,15 @@ function Or(e) {
|
|
|
2903
2939
|
}
|
|
2904
2940
|
//#endregion
|
|
2905
2941
|
//#region src/promptSettings/index.ts
|
|
2906
|
-
function
|
|
2942
|
+
function Nr(e) {
|
|
2907
2943
|
return {
|
|
2908
|
-
get:
|
|
2909
|
-
set:
|
|
2944
|
+
get: Ar(e),
|
|
2945
|
+
set: Mr(e)
|
|
2910
2946
|
};
|
|
2911
2947
|
}
|
|
2912
2948
|
//#endregion
|
|
2913
2949
|
//#region src/emailProvideres/get.ts
|
|
2914
|
-
function
|
|
2950
|
+
function Pr(e) {
|
|
2915
2951
|
return async (t) => {
|
|
2916
2952
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2917
2953
|
if (!n) return null;
|
|
@@ -2926,7 +2962,7 @@ function Ar(e) {
|
|
|
2926
2962
|
}
|
|
2927
2963
|
//#endregion
|
|
2928
2964
|
//#region src/emailProvideres/update.ts
|
|
2929
|
-
function
|
|
2965
|
+
function Fr(e) {
|
|
2930
2966
|
return async (t, n) => {
|
|
2931
2967
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2932
2968
|
await e.updateTable("email_providers").set({
|
|
@@ -2939,7 +2975,7 @@ function jr(e) {
|
|
|
2939
2975
|
}
|
|
2940
2976
|
//#endregion
|
|
2941
2977
|
//#region src/emailProvideres/create.ts
|
|
2942
|
-
function
|
|
2978
|
+
function Ir(e) {
|
|
2943
2979
|
return async (t, n, r) => {
|
|
2944
2980
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2945
2981
|
await e.insertInto("email_providers").values({
|
|
@@ -2955,24 +2991,24 @@ function Mr(e) {
|
|
|
2955
2991
|
}
|
|
2956
2992
|
//#endregion
|
|
2957
2993
|
//#region src/emailProvideres/remove.ts
|
|
2958
|
-
function
|
|
2994
|
+
function Lr(e) {
|
|
2959
2995
|
return async (t) => {
|
|
2960
2996
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
2961
2997
|
};
|
|
2962
2998
|
}
|
|
2963
2999
|
//#endregion
|
|
2964
3000
|
//#region src/emailProvideres/index.ts
|
|
2965
|
-
function
|
|
3001
|
+
function Rr(e) {
|
|
2966
3002
|
return {
|
|
2967
|
-
get:
|
|
2968
|
-
create:
|
|
2969
|
-
update:
|
|
2970
|
-
remove:
|
|
3003
|
+
get: Pr(e),
|
|
3004
|
+
create: Ir(e),
|
|
3005
|
+
update: Fr(e),
|
|
3006
|
+
remove: Lr(e)
|
|
2971
3007
|
};
|
|
2972
3008
|
}
|
|
2973
3009
|
//#endregion
|
|
2974
3010
|
//#region src/emailTemplates/row.ts
|
|
2975
|
-
function
|
|
3011
|
+
function zr(e) {
|
|
2976
3012
|
let t = {
|
|
2977
3013
|
template: e.template,
|
|
2978
3014
|
body: e.body,
|
|
@@ -2986,20 +3022,20 @@ function Fr(e) {
|
|
|
2986
3022
|
}
|
|
2987
3023
|
//#endregion
|
|
2988
3024
|
//#region src/emailTemplates/get.ts
|
|
2989
|
-
function
|
|
3025
|
+
function Br(e) {
|
|
2990
3026
|
return async (t, n) => {
|
|
2991
3027
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
2992
|
-
return r ? v.parse(
|
|
3028
|
+
return r ? v.parse(zr(r)) : null;
|
|
2993
3029
|
};
|
|
2994
3030
|
}
|
|
2995
3031
|
//#endregion
|
|
2996
3032
|
//#region src/emailTemplates/list.ts
|
|
2997
|
-
function
|
|
2998
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => v.parse(
|
|
3033
|
+
function Vr(e) {
|
|
3034
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => v.parse(zr(e)));
|
|
2999
3035
|
}
|
|
3000
3036
|
//#endregion
|
|
3001
3037
|
//#region src/emailTemplates/create.ts
|
|
3002
|
-
function
|
|
3038
|
+
function Hr(e) {
|
|
3003
3039
|
return async (t, n, r) => {
|
|
3004
3040
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3005
3041
|
return await e.insertInto("email_templates").values({
|
|
@@ -3020,7 +3056,7 @@ function Rr(e) {
|
|
|
3020
3056
|
}
|
|
3021
3057
|
//#endregion
|
|
3022
3058
|
//#region src/emailTemplates/update.ts
|
|
3023
|
-
function
|
|
3059
|
+
function Ur(e) {
|
|
3024
3060
|
return async (t, n, r) => {
|
|
3025
3061
|
let i = {};
|
|
3026
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;
|
|
@@ -3031,7 +3067,7 @@ function zr(e) {
|
|
|
3031
3067
|
}
|
|
3032
3068
|
//#endregion
|
|
3033
3069
|
//#region src/emailTemplates/remove.ts
|
|
3034
|
-
function
|
|
3070
|
+
function Wr(e) {
|
|
3035
3071
|
return async (t, n) => {
|
|
3036
3072
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3037
3073
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3039,18 +3075,18 @@ function Br(e) {
|
|
|
3039
3075
|
}
|
|
3040
3076
|
//#endregion
|
|
3041
3077
|
//#region src/emailTemplates/index.ts
|
|
3042
|
-
function
|
|
3078
|
+
function Gr(e) {
|
|
3043
3079
|
return {
|
|
3044
|
-
get:
|
|
3045
|
-
list:
|
|
3046
|
-
create:
|
|
3047
|
-
update:
|
|
3048
|
-
remove:
|
|
3080
|
+
get: Br(e),
|
|
3081
|
+
list: Vr(e),
|
|
3082
|
+
create: Hr(e),
|
|
3083
|
+
update: Ur(e),
|
|
3084
|
+
remove: Wr(e)
|
|
3049
3085
|
};
|
|
3050
3086
|
}
|
|
3051
3087
|
//#endregion
|
|
3052
3088
|
//#region src/refreshTokens/get.ts
|
|
3053
|
-
function
|
|
3089
|
+
function Kr(e) {
|
|
3054
3090
|
return async (t, n) => {
|
|
3055
3091
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3056
3092
|
if (!i) return null;
|
|
@@ -3079,7 +3115,7 @@ function Hr(e) {
|
|
|
3079
3115
|
}
|
|
3080
3116
|
//#endregion
|
|
3081
3117
|
//#region src/refreshTokens/getByLookup.ts
|
|
3082
|
-
function
|
|
3118
|
+
function qr(e) {
|
|
3083
3119
|
return async (t, n) => {
|
|
3084
3120
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3085
3121
|
if (!i) return null;
|
|
@@ -3108,7 +3144,7 @@ function Ur(e) {
|
|
|
3108
3144
|
}
|
|
3109
3145
|
//#endregion
|
|
3110
3146
|
//#region src/refreshTokens/create.ts
|
|
3111
|
-
function
|
|
3147
|
+
function Jr(e) {
|
|
3112
3148
|
return async (t, n) => {
|
|
3113
3149
|
let r = c(), i = {
|
|
3114
3150
|
...n,
|
|
@@ -3138,12 +3174,12 @@ function Wr(e) {
|
|
|
3138
3174
|
}
|
|
3139
3175
|
//#endregion
|
|
3140
3176
|
//#region src/refreshTokens/remove.ts
|
|
3141
|
-
function
|
|
3177
|
+
function Yr(e) {
|
|
3142
3178
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3143
3179
|
}
|
|
3144
3180
|
//#endregion
|
|
3145
3181
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3146
|
-
function
|
|
3182
|
+
function Xr(e) {
|
|
3147
3183
|
return async (t, n, r) => {
|
|
3148
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();
|
|
3149
3185
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3151,7 +3187,7 @@ function Kr(e) {
|
|
|
3151
3187
|
}
|
|
3152
3188
|
//#endregion
|
|
3153
3189
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3154
|
-
function
|
|
3190
|
+
function Zr(e) {
|
|
3155
3191
|
return async (t, n, r) => {
|
|
3156
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();
|
|
3157
3193
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3159,7 +3195,7 @@ function qr(e) {
|
|
|
3159
3195
|
}
|
|
3160
3196
|
//#endregion
|
|
3161
3197
|
//#region src/refreshTokens/update.ts
|
|
3162
|
-
function
|
|
3198
|
+
function Qr(e) {
|
|
3163
3199
|
return async (t, n, r, i) => {
|
|
3164
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 = {
|
|
3165
3201
|
...h,
|
|
@@ -3180,10 +3216,10 @@ function Jr(e) {
|
|
|
3180
3216
|
}
|
|
3181
3217
|
//#endregion
|
|
3182
3218
|
//#region src/refreshTokens/list.ts
|
|
3183
|
-
function
|
|
3219
|
+
function $r(e) {
|
|
3184
3220
|
return async (t, n = {}) => {
|
|
3185
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);
|
|
3186
|
-
l && (u =
|
|
3222
|
+
l && (u = O(e, u, l, ["token", "login_id"]));
|
|
3187
3223
|
let d = u;
|
|
3188
3224
|
if (c && c.sort_by) {
|
|
3189
3225
|
let { ref: t } = e.dynamic;
|
|
@@ -3230,24 +3266,24 @@ function Yr(e) {
|
|
|
3230
3266
|
}
|
|
3231
3267
|
//#endregion
|
|
3232
3268
|
//#region src/refreshTokens/index.ts
|
|
3233
|
-
function
|
|
3269
|
+
function ei(e) {
|
|
3234
3270
|
return {
|
|
3235
|
-
create:
|
|
3236
|
-
get:
|
|
3237
|
-
getByLookup:
|
|
3238
|
-
list:
|
|
3239
|
-
remove:
|
|
3240
|
-
revokeByLoginSession:
|
|
3241
|
-
revokeFamily:
|
|
3242
|
-
update:
|
|
3271
|
+
create: Jr(e),
|
|
3272
|
+
get: Kr(e),
|
|
3273
|
+
getByLookup: qr(e),
|
|
3274
|
+
list: $r(e),
|
|
3275
|
+
remove: Yr(e),
|
|
3276
|
+
revokeByLoginSession: Xr(e),
|
|
3277
|
+
revokeFamily: Zr(e),
|
|
3278
|
+
update: Qr(e)
|
|
3243
3279
|
};
|
|
3244
3280
|
}
|
|
3245
3281
|
//#endregion
|
|
3246
3282
|
//#region src/cleanup.ts
|
|
3247
|
-
var
|
|
3248
|
-
function
|
|
3283
|
+
var ti = 10080 * 60 * 1e3;
|
|
3284
|
+
function ni(e) {
|
|
3249
3285
|
return async (t) => {
|
|
3250
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3286
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - ti, a = 1e3;
|
|
3251
3287
|
try {
|
|
3252
3288
|
let t = 0;
|
|
3253
3289
|
for (;;) {
|
|
@@ -3278,7 +3314,7 @@ function Qr(e) {
|
|
|
3278
3314
|
}
|
|
3279
3315
|
//#endregion
|
|
3280
3316
|
//#region src/forms/create.ts
|
|
3281
|
-
function
|
|
3317
|
+
function ri(e) {
|
|
3282
3318
|
return async (n, r, i) => {
|
|
3283
3319
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3284
3320
|
id: a?.id ?? t(),
|
|
@@ -3297,10 +3333,10 @@ function $r(e) {
|
|
|
3297
3333
|
}
|
|
3298
3334
|
//#endregion
|
|
3299
3335
|
//#region src/forms/list.ts
|
|
3300
|
-
function
|
|
3336
|
+
function ii(e) {
|
|
3301
3337
|
return async (t, n = {}) => {
|
|
3302
3338
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3303
|
-
s && (c =
|
|
3339
|
+
s && (c = O(e, c, s, []));
|
|
3304
3340
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3305
3341
|
let t = { ...e };
|
|
3306
3342
|
if (typeof t.nodes == "string") try {
|
|
@@ -3331,7 +3367,7 @@ function ei(e) {
|
|
|
3331
3367
|
}
|
|
3332
3368
|
//#endregion
|
|
3333
3369
|
//#region src/forms/remove.ts
|
|
3334
|
-
function
|
|
3370
|
+
function ai(e) {
|
|
3335
3371
|
return async (t, n) => {
|
|
3336
3372
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3337
3373
|
return r > 0;
|
|
@@ -3339,7 +3375,7 @@ function ti(e) {
|
|
|
3339
3375
|
}
|
|
3340
3376
|
//#endregion
|
|
3341
3377
|
//#region src/forms/get.ts
|
|
3342
|
-
function
|
|
3378
|
+
function oi(e) {
|
|
3343
3379
|
return async (t, n) => {
|
|
3344
3380
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3345
3381
|
if (!r) return null;
|
|
@@ -3358,7 +3394,7 @@ function ni(e) {
|
|
|
3358
3394
|
}
|
|
3359
3395
|
//#endregion
|
|
3360
3396
|
//#region src/forms/update.ts
|
|
3361
|
-
function
|
|
3397
|
+
function si(e) {
|
|
3362
3398
|
return async (t, n, r) => {
|
|
3363
3399
|
let i = {
|
|
3364
3400
|
...r,
|
|
@@ -3375,18 +3411,18 @@ function ri(e) {
|
|
|
3375
3411
|
}
|
|
3376
3412
|
//#endregion
|
|
3377
3413
|
//#region src/forms/index.ts
|
|
3378
|
-
function
|
|
3414
|
+
function ci(e) {
|
|
3379
3415
|
return {
|
|
3380
|
-
create:
|
|
3381
|
-
get:
|
|
3382
|
-
list:
|
|
3383
|
-
remove:
|
|
3384
|
-
update:
|
|
3416
|
+
create: ri(e),
|
|
3417
|
+
get: oi(e),
|
|
3418
|
+
list: ii(e),
|
|
3419
|
+
remove: ai(e),
|
|
3420
|
+
update: si(e)
|
|
3385
3421
|
};
|
|
3386
3422
|
}
|
|
3387
3423
|
//#endregion
|
|
3388
3424
|
//#region src/resourceServers/create.ts
|
|
3389
|
-
function
|
|
3425
|
+
function li(e) {
|
|
3390
3426
|
return async (t, n, r) => {
|
|
3391
3427
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3392
3428
|
...n,
|
|
@@ -3411,7 +3447,7 @@ function ai(e) {
|
|
|
3411
3447
|
}
|
|
3412
3448
|
//#endregion
|
|
3413
3449
|
//#region src/resourceServers/get.ts
|
|
3414
|
-
function
|
|
3450
|
+
function ui(e) {
|
|
3415
3451
|
return async (t, n) => {
|
|
3416
3452
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3417
3453
|
if (!r) return null;
|
|
@@ -3430,7 +3466,7 @@ function oi(e) {
|
|
|
3430
3466
|
}
|
|
3431
3467
|
//#endregion
|
|
3432
3468
|
//#region src/resourceServers/list.ts
|
|
3433
|
-
function
|
|
3469
|
+
function di(e) {
|
|
3434
3470
|
return async (t, n = {}) => {
|
|
3435
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);
|
|
3436
3472
|
if (s) {
|
|
@@ -3438,7 +3474,7 @@ function si(e) {
|
|
|
3438
3474
|
if (i && !o) {
|
|
3439
3475
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3440
3476
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3441
|
-
} else c =
|
|
3477
|
+
} else c = O(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3442
3478
|
}
|
|
3443
3479
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3444
3480
|
let { verification_key: t, scopes: n, options: r, skip_consent_for_verifiable_first_party_clients: i, allow_offline_access: a, is_system: o, metadata: s, ...c } = e, u = l({
|
|
@@ -3470,7 +3506,7 @@ function si(e) {
|
|
|
3470
3506
|
}
|
|
3471
3507
|
//#endregion
|
|
3472
3508
|
//#region src/resourceServers/remove.ts
|
|
3473
|
-
function
|
|
3509
|
+
function fi(e) {
|
|
3474
3510
|
return async (t, n) => {
|
|
3475
3511
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3476
3512
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3478,7 +3514,7 @@ function ci(e) {
|
|
|
3478
3514
|
}
|
|
3479
3515
|
//#endregion
|
|
3480
3516
|
//#region src/resourceServers/update.ts
|
|
3481
|
-
function
|
|
3517
|
+
function pi(e) {
|
|
3482
3518
|
return async (t, n, r) => {
|
|
3483
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 = {
|
|
3484
3520
|
...d,
|
|
@@ -3498,18 +3534,18 @@ function li(e) {
|
|
|
3498
3534
|
}
|
|
3499
3535
|
//#endregion
|
|
3500
3536
|
//#region src/resourceServers/index.ts
|
|
3501
|
-
function
|
|
3537
|
+
function mi(e) {
|
|
3502
3538
|
return {
|
|
3503
|
-
create:
|
|
3504
|
-
get:
|
|
3505
|
-
list:
|
|
3506
|
-
remove:
|
|
3507
|
-
update:
|
|
3539
|
+
create: li(e),
|
|
3540
|
+
get: ui(e),
|
|
3541
|
+
list: di(e),
|
|
3542
|
+
remove: fi(e),
|
|
3543
|
+
update: pi(e)
|
|
3508
3544
|
};
|
|
3509
3545
|
}
|
|
3510
3546
|
//#endregion
|
|
3511
3547
|
//#region src/roles/create.ts
|
|
3512
|
-
function
|
|
3548
|
+
function hi(e) {
|
|
3513
3549
|
return async (n, r, i) => {
|
|
3514
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 = {
|
|
3515
3551
|
id: l,
|
|
@@ -3532,7 +3568,7 @@ function di(e) {
|
|
|
3532
3568
|
}
|
|
3533
3569
|
//#endregion
|
|
3534
3570
|
//#region src/roles/get.ts
|
|
3535
|
-
function
|
|
3571
|
+
function gi(e) {
|
|
3536
3572
|
return async (t, n) => {
|
|
3537
3573
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3538
3574
|
if (!r) return null;
|
|
@@ -3546,10 +3582,10 @@ function fi(e) {
|
|
|
3546
3582
|
}
|
|
3547
3583
|
//#endregion
|
|
3548
3584
|
//#region src/roles/list.ts
|
|
3549
|
-
function
|
|
3585
|
+
function _i(e) {
|
|
3550
3586
|
return async (t, n) => {
|
|
3551
3587
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3552
|
-
n.q && (r =
|
|
3588
|
+
n.q && (r = O(e, r, n.q, ["name"]));
|
|
3553
3589
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3554
3590
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3555
3591
|
return {
|
|
@@ -3575,7 +3611,7 @@ function pi(e) {
|
|
|
3575
3611
|
}
|
|
3576
3612
|
//#endregion
|
|
3577
3613
|
//#region src/roles/update.ts
|
|
3578
|
-
function
|
|
3614
|
+
function vi(e) {
|
|
3579
3615
|
return async (t, n, r) => {
|
|
3580
3616
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3581
3617
|
...o,
|
|
@@ -3588,7 +3624,7 @@ function mi(e) {
|
|
|
3588
3624
|
}
|
|
3589
3625
|
//#endregion
|
|
3590
3626
|
//#region src/roles/remove.ts
|
|
3591
|
-
function
|
|
3627
|
+
function yi(e) {
|
|
3592
3628
|
return async (t, n) => {
|
|
3593
3629
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3594
3630
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3596,18 +3632,18 @@ function hi(e) {
|
|
|
3596
3632
|
}
|
|
3597
3633
|
//#endregion
|
|
3598
3634
|
//#region src/roles/index.ts
|
|
3599
|
-
function
|
|
3635
|
+
function bi(e) {
|
|
3600
3636
|
return {
|
|
3601
|
-
create:
|
|
3602
|
-
get:
|
|
3603
|
-
list:
|
|
3604
|
-
update:
|
|
3605
|
-
remove:
|
|
3637
|
+
create: hi(e),
|
|
3638
|
+
get: gi(e),
|
|
3639
|
+
list: _i(e),
|
|
3640
|
+
update: vi(e),
|
|
3641
|
+
remove: yi(e)
|
|
3606
3642
|
};
|
|
3607
3643
|
}
|
|
3608
3644
|
//#endregion
|
|
3609
3645
|
//#region src/role-permissions/assign.ts
|
|
3610
|
-
function
|
|
3646
|
+
function xi(e) {
|
|
3611
3647
|
return async (t, n, r, i) => {
|
|
3612
3648
|
if (r.length === 0) return !0;
|
|
3613
3649
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3636,7 +3672,7 @@ function _i(e) {
|
|
|
3636
3672
|
}
|
|
3637
3673
|
//#endregion
|
|
3638
3674
|
//#region src/role-permissions/remove.ts
|
|
3639
|
-
function
|
|
3675
|
+
function Si(e) {
|
|
3640
3676
|
return async (t, n, r) => {
|
|
3641
3677
|
if (r.length === 0) return !0;
|
|
3642
3678
|
try {
|
|
@@ -3648,7 +3684,7 @@ function vi(e) {
|
|
|
3648
3684
|
}
|
|
3649
3685
|
//#endregion
|
|
3650
3686
|
//#region src/role-permissions/list.ts
|
|
3651
|
-
function
|
|
3687
|
+
function Ci(e) {
|
|
3652
3688
|
return async (t, n, r = {}) => {
|
|
3653
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([
|
|
3654
3690
|
"role_permissions.role_id",
|
|
@@ -3669,16 +3705,16 @@ function yi(e) {
|
|
|
3669
3705
|
}
|
|
3670
3706
|
//#endregion
|
|
3671
3707
|
//#region src/role-permissions/index.ts
|
|
3672
|
-
function
|
|
3708
|
+
function wi(e) {
|
|
3673
3709
|
return {
|
|
3674
|
-
assign:
|
|
3675
|
-
remove:
|
|
3676
|
-
list:
|
|
3710
|
+
assign: xi(e),
|
|
3711
|
+
remove: Si(e),
|
|
3712
|
+
list: Ci(e)
|
|
3677
3713
|
};
|
|
3678
3714
|
}
|
|
3679
3715
|
//#endregion
|
|
3680
3716
|
//#region src/grants/create.ts
|
|
3681
|
-
function
|
|
3717
|
+
function Ti(e) {
|
|
3682
3718
|
return async (n, r) => {
|
|
3683
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();
|
|
3684
3720
|
if (s) {
|
|
@@ -3715,7 +3751,7 @@ function xi(e) {
|
|
|
3715
3751
|
}
|
|
3716
3752
|
//#endregion
|
|
3717
3753
|
//#region src/grants/get.ts
|
|
3718
|
-
function
|
|
3754
|
+
function Ei(e) {
|
|
3719
3755
|
return async (t, n, r, i) => {
|
|
3720
3756
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3721
3757
|
return a ? {
|
|
@@ -3729,10 +3765,10 @@ function Si(e) {
|
|
|
3729
3765
|
}
|
|
3730
3766
|
//#endregion
|
|
3731
3767
|
//#region src/grants/list.ts
|
|
3732
|
-
function
|
|
3768
|
+
function Di(e) {
|
|
3733
3769
|
return async (t, n = {}) => {
|
|
3734
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);
|
|
3735
|
-
c && (l =
|
|
3771
|
+
c && (l = O(e, l, c, [
|
|
3736
3772
|
"user_id",
|
|
3737
3773
|
"client_id",
|
|
3738
3774
|
"audience"
|
|
@@ -3767,26 +3803,26 @@ function Ci(e) {
|
|
|
3767
3803
|
}
|
|
3768
3804
|
//#endregion
|
|
3769
3805
|
//#region src/grants/remove.ts
|
|
3770
|
-
function
|
|
3806
|
+
function Oi(e) {
|
|
3771
3807
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3772
3808
|
}
|
|
3773
|
-
function
|
|
3809
|
+
function ki(e) {
|
|
3774
3810
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3775
3811
|
}
|
|
3776
3812
|
//#endregion
|
|
3777
3813
|
//#region src/grants/index.ts
|
|
3778
|
-
function
|
|
3814
|
+
function Ai(e) {
|
|
3779
3815
|
return {
|
|
3780
|
-
create:
|
|
3781
|
-
get:
|
|
3782
|
-
list:
|
|
3783
|
-
remove:
|
|
3784
|
-
removeByUser:
|
|
3816
|
+
create: Ti(e),
|
|
3817
|
+
get: Ei(e),
|
|
3818
|
+
list: Di(e),
|
|
3819
|
+
remove: Oi(e),
|
|
3820
|
+
removeByUser: ki(e)
|
|
3785
3821
|
};
|
|
3786
3822
|
}
|
|
3787
3823
|
//#endregion
|
|
3788
3824
|
//#region src/user-permissions/create.ts
|
|
3789
|
-
function
|
|
3825
|
+
function ji(e) {
|
|
3790
3826
|
return async (t, n, r, i, a) => {
|
|
3791
3827
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3792
3828
|
try {
|
|
@@ -3806,7 +3842,7 @@ function Di(e) {
|
|
|
3806
3842
|
}
|
|
3807
3843
|
//#endregion
|
|
3808
3844
|
//#region src/user-permissions/remove.ts
|
|
3809
|
-
function
|
|
3845
|
+
function Mi(e) {
|
|
3810
3846
|
return async (t, n, r, i) => {
|
|
3811
3847
|
try {
|
|
3812
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);
|
|
@@ -3818,7 +3854,7 @@ function Oi(e) {
|
|
|
3818
3854
|
}
|
|
3819
3855
|
//#endregion
|
|
3820
3856
|
//#region src/user-permissions/list.ts
|
|
3821
|
-
function
|
|
3857
|
+
function Ni(e) {
|
|
3822
3858
|
return async (t, n, r, i) => {
|
|
3823
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([
|
|
3824
3860
|
"user_permissions.resource_server_identifier",
|
|
@@ -3841,17 +3877,17 @@ function ki(e) {
|
|
|
3841
3877
|
}
|
|
3842
3878
|
//#endregion
|
|
3843
3879
|
//#region src/user-permissions/index.ts
|
|
3844
|
-
function
|
|
3880
|
+
function Pi(e) {
|
|
3845
3881
|
return {
|
|
3846
|
-
create:
|
|
3847
|
-
remove:
|
|
3848
|
-
list:
|
|
3882
|
+
create: ji(e),
|
|
3883
|
+
remove: Mi(e),
|
|
3884
|
+
list: Ni(e)
|
|
3849
3885
|
};
|
|
3850
3886
|
}
|
|
3851
3887
|
//#endregion
|
|
3852
3888
|
//#region src/user-permissions/adapter.ts
|
|
3853
|
-
function
|
|
3854
|
-
let t =
|
|
3889
|
+
function Fi(e) {
|
|
3890
|
+
let t = Pi(e);
|
|
3855
3891
|
return {
|
|
3856
3892
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3857
3893
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3860,7 +3896,7 @@ function ji(e) {
|
|
|
3860
3896
|
}
|
|
3861
3897
|
//#endregion
|
|
3862
3898
|
//#region src/user-roles/list.ts
|
|
3863
|
-
function
|
|
3899
|
+
function Ii(e) {
|
|
3864
3900
|
return async (t, n, r, i) => {
|
|
3865
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([
|
|
3866
3902
|
"r.id",
|
|
@@ -3874,11 +3910,11 @@ function Mi(e) {
|
|
|
3874
3910
|
}
|
|
3875
3911
|
//#endregion
|
|
3876
3912
|
//#region src/user-roles/list-users.ts
|
|
3877
|
-
function
|
|
3913
|
+
function Li(e) {
|
|
3878
3914
|
return async (t, n, r) => {
|
|
3879
3915
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3880
|
-
if (
|
|
3881
|
-
let { rows: e, limit: t, next: n } = await
|
|
3916
|
+
if (P(r)) {
|
|
3917
|
+
let { rows: e, limit: t, next: n } = await F(i, r, {
|
|
3882
3918
|
sortColumn: "user_id",
|
|
3883
3919
|
sortOrder: "asc",
|
|
3884
3920
|
idColumn: "user_id"
|
|
@@ -3902,7 +3938,7 @@ function Ni(e) {
|
|
|
3902
3938
|
}
|
|
3903
3939
|
//#endregion
|
|
3904
3940
|
//#region src/user-roles/create.ts
|
|
3905
|
-
function
|
|
3941
|
+
function Ri(e) {
|
|
3906
3942
|
return async (t, n, r, i, a) => {
|
|
3907
3943
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3908
3944
|
try {
|
|
@@ -3920,7 +3956,7 @@ function Pi(e) {
|
|
|
3920
3956
|
}
|
|
3921
3957
|
//#endregion
|
|
3922
3958
|
//#region src/user-roles/remove.ts
|
|
3923
|
-
function
|
|
3959
|
+
function zi(e) {
|
|
3924
3960
|
return async (t, n, r, i) => {
|
|
3925
3961
|
try {
|
|
3926
3962
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3932,18 +3968,18 @@ function Fi(e) {
|
|
|
3932
3968
|
}
|
|
3933
3969
|
//#endregion
|
|
3934
3970
|
//#region src/user-roles/index.ts
|
|
3935
|
-
function
|
|
3971
|
+
function Bi(e) {
|
|
3936
3972
|
return {
|
|
3937
|
-
list:
|
|
3938
|
-
listUsers:
|
|
3939
|
-
create:
|
|
3940
|
-
remove:
|
|
3973
|
+
list: Ii(e),
|
|
3974
|
+
listUsers: Li(e),
|
|
3975
|
+
create: Ri(e),
|
|
3976
|
+
remove: zi(e)
|
|
3941
3977
|
};
|
|
3942
3978
|
}
|
|
3943
3979
|
//#endregion
|
|
3944
3980
|
//#region src/user-roles/adapter.ts
|
|
3945
|
-
function
|
|
3946
|
-
let t =
|
|
3981
|
+
function Vi(e) {
|
|
3982
|
+
let t = Bi(e);
|
|
3947
3983
|
return {
|
|
3948
3984
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3949
3985
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3953,7 +3989,7 @@ function Li(e) {
|
|
|
3953
3989
|
}
|
|
3954
3990
|
//#endregion
|
|
3955
3991
|
//#region src/organizations/create.ts
|
|
3956
|
-
function
|
|
3992
|
+
function Hi(e) {
|
|
3957
3993
|
return async (t, n, r) => {
|
|
3958
3994
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3959
3995
|
...n,
|
|
@@ -3981,7 +4017,7 @@ function Ri(e) {
|
|
|
3981
4017
|
}
|
|
3982
4018
|
//#endregion
|
|
3983
4019
|
//#region src/organizations/get.ts
|
|
3984
|
-
function
|
|
4020
|
+
function Ui(e) {
|
|
3985
4021
|
return async (t, n) => {
|
|
3986
4022
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3987
4023
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -3996,15 +4032,15 @@ function zi(e) {
|
|
|
3996
4032
|
//#endregion
|
|
3997
4033
|
//#region src/organizations/list.ts
|
|
3998
4034
|
var B = ["name", "display_name"];
|
|
3999
|
-
function
|
|
4035
|
+
function Wi(e) {
|
|
4000
4036
|
return async (t, n) => {
|
|
4001
4037
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4002
4038
|
if (n?.q) {
|
|
4003
4039
|
let t = S(n.q, B);
|
|
4004
|
-
t && (r =
|
|
4040
|
+
t && (r = O(e, r, t, B));
|
|
4005
4041
|
}
|
|
4006
|
-
if (
|
|
4007
|
-
let { rows: e, limit: t, next: i } = await
|
|
4042
|
+
if (P(n)) {
|
|
4043
|
+
let { rows: e, limit: t, next: i } = await F(r.selectAll(), n, {
|
|
4008
4044
|
sortColumn: "created_at",
|
|
4009
4045
|
sortOrder: "desc"
|
|
4010
4046
|
}), a = e.map((e) => l({
|
|
@@ -4038,7 +4074,7 @@ function Bi(e) {
|
|
|
4038
4074
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4039
4075
|
if (n?.q) {
|
|
4040
4076
|
let t = S(n.q, B);
|
|
4041
|
-
t && (r =
|
|
4077
|
+
t && (r = O(e, r, t, B));
|
|
4042
4078
|
}
|
|
4043
4079
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4044
4080
|
u = Number(i?.count || 0);
|
|
@@ -4061,12 +4097,12 @@ function Bi(e) {
|
|
|
4061
4097
|
}
|
|
4062
4098
|
//#endregion
|
|
4063
4099
|
//#region src/organizations/remove.ts
|
|
4064
|
-
function
|
|
4100
|
+
function Gi(e) {
|
|
4065
4101
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4066
4102
|
}
|
|
4067
4103
|
//#endregion
|
|
4068
4104
|
//#region src/organizations/update.ts
|
|
4069
|
-
function
|
|
4105
|
+
function Ki(e) {
|
|
4070
4106
|
return async (t, n, r) => {
|
|
4071
4107
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4072
4108
|
...c,
|
|
@@ -4082,13 +4118,13 @@ function Hi(e) {
|
|
|
4082
4118
|
}
|
|
4083
4119
|
//#endregion
|
|
4084
4120
|
//#region src/organizations/index.ts
|
|
4085
|
-
function
|
|
4121
|
+
function qi(e) {
|
|
4086
4122
|
return {
|
|
4087
|
-
create:
|
|
4088
|
-
get:
|
|
4089
|
-
list:
|
|
4090
|
-
remove:
|
|
4091
|
-
update:
|
|
4123
|
+
create: Hi(e),
|
|
4124
|
+
get: Ui(e),
|
|
4125
|
+
list: Wi(e),
|
|
4126
|
+
remove: Gi(e),
|
|
4127
|
+
update: Ki(e)
|
|
4092
4128
|
};
|
|
4093
4129
|
}
|
|
4094
4130
|
//#endregion
|
|
@@ -4114,7 +4150,7 @@ async function H(e, t, n) {
|
|
|
4114
4150
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4115
4151
|
};
|
|
4116
4152
|
}
|
|
4117
|
-
function
|
|
4153
|
+
function Ji(e) {
|
|
4118
4154
|
return {
|
|
4119
4155
|
async create(t, n, r, i) {
|
|
4120
4156
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4157,7 +4193,7 @@ function Wi(e) {
|
|
|
4157
4193
|
}
|
|
4158
4194
|
//#endregion
|
|
4159
4195
|
//#region src/user-organizations/create.ts
|
|
4160
|
-
function
|
|
4196
|
+
function Yi(e) {
|
|
4161
4197
|
return async (n, r, i) => {
|
|
4162
4198
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4163
4199
|
id: a?.id ?? t(),
|
|
@@ -4177,7 +4213,7 @@ function Gi(e) {
|
|
|
4177
4213
|
}
|
|
4178
4214
|
//#endregion
|
|
4179
4215
|
//#region src/user-organizations/get.ts
|
|
4180
|
-
function
|
|
4216
|
+
function Xi(e) {
|
|
4181
4217
|
return async (t, n) => {
|
|
4182
4218
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4183
4219
|
return r ? {
|
|
@@ -4191,7 +4227,7 @@ function Ki(e) {
|
|
|
4191
4227
|
}
|
|
4192
4228
|
//#endregion
|
|
4193
4229
|
//#region src/user-organizations/list.ts
|
|
4194
|
-
function
|
|
4230
|
+
function Zi(e) {
|
|
4195
4231
|
return async (t, n) => {
|
|
4196
4232
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4197
4233
|
if (n?.q) {
|
|
@@ -4210,8 +4246,8 @@ function qi(e) {
|
|
|
4210
4246
|
created_at: e.created_at,
|
|
4211
4247
|
updated_at: e.updated_at
|
|
4212
4248
|
});
|
|
4213
|
-
if (
|
|
4214
|
-
let { rows: e, limit: t, next: a } = await
|
|
4249
|
+
if (P(n)) {
|
|
4250
|
+
let { rows: e, limit: t, next: a } = await F(r, n, {
|
|
4215
4251
|
sortColumn: "created_at",
|
|
4216
4252
|
sortOrder: "desc"
|
|
4217
4253
|
});
|
|
@@ -4244,7 +4280,7 @@ function qi(e) {
|
|
|
4244
4280
|
}
|
|
4245
4281
|
//#endregion
|
|
4246
4282
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4247
|
-
function
|
|
4283
|
+
function Qi(e) {
|
|
4248
4284
|
return async (t, n, r) => {
|
|
4249
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([
|
|
4250
4286
|
"organizations.id",
|
|
@@ -4281,12 +4317,12 @@ function Ji(e) {
|
|
|
4281
4317
|
}
|
|
4282
4318
|
//#endregion
|
|
4283
4319
|
//#region src/user-organizations/remove.ts
|
|
4284
|
-
function
|
|
4320
|
+
function $i(e) {
|
|
4285
4321
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4286
4322
|
}
|
|
4287
4323
|
//#endregion
|
|
4288
4324
|
//#region src/user-organizations/update.ts
|
|
4289
|
-
function
|
|
4325
|
+
function ea(e) {
|
|
4290
4326
|
return async (t, n, r) => {
|
|
4291
4327
|
let i = {
|
|
4292
4328
|
...r,
|
|
@@ -4297,19 +4333,19 @@ function Xi(e) {
|
|
|
4297
4333
|
}
|
|
4298
4334
|
//#endregion
|
|
4299
4335
|
//#region src/user-organizations/index.ts
|
|
4300
|
-
function
|
|
4336
|
+
function ta(e) {
|
|
4301
4337
|
return {
|
|
4302
|
-
create:
|
|
4303
|
-
get:
|
|
4304
|
-
list:
|
|
4305
|
-
listUserOrganizations:
|
|
4306
|
-
remove:
|
|
4307
|
-
update:
|
|
4338
|
+
create: Yi(e),
|
|
4339
|
+
get: Xi(e),
|
|
4340
|
+
list: Zi(e),
|
|
4341
|
+
listUserOrganizations: Qi(e),
|
|
4342
|
+
remove: $i(e),
|
|
4343
|
+
update: ea(e)
|
|
4308
4344
|
};
|
|
4309
4345
|
}
|
|
4310
4346
|
//#endregion
|
|
4311
4347
|
//#region src/invites/create.ts
|
|
4312
|
-
function
|
|
4348
|
+
function na(e) {
|
|
4313
4349
|
return async (t, n, r) => {
|
|
4314
4350
|
let i = r?.importMetadata, a = i?.id ?? n.id ?? Te(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4315
4351
|
id: a,
|
|
@@ -4355,11 +4391,11 @@ function Qi(e) {
|
|
|
4355
4391
|
}
|
|
4356
4392
|
//#endregion
|
|
4357
4393
|
//#region src/invites/get.ts
|
|
4358
|
-
function
|
|
4394
|
+
function ra(e) {
|
|
4359
4395
|
return async (t, n) => {
|
|
4360
4396
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4361
4397
|
return r ? l({
|
|
4362
|
-
...
|
|
4398
|
+
...lt(r, {
|
|
4363
4399
|
inviter: {},
|
|
4364
4400
|
invitee: {},
|
|
4365
4401
|
app_metadata: {},
|
|
@@ -4372,7 +4408,7 @@ function $i(e) {
|
|
|
4372
4408
|
}
|
|
4373
4409
|
//#endregion
|
|
4374
4410
|
//#region src/invites/list.ts
|
|
4375
|
-
function
|
|
4411
|
+
function ia(e) {
|
|
4376
4412
|
return async (t, n) => {
|
|
4377
4413
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4378
4414
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4380,7 +4416,7 @@ function ea(e) {
|
|
|
4380
4416
|
r = r.offset(e);
|
|
4381
4417
|
}
|
|
4382
4418
|
let i = (await r.execute()).map((e) => l({
|
|
4383
|
-
...
|
|
4419
|
+
...lt(e, {
|
|
4384
4420
|
inviter: {},
|
|
4385
4421
|
invitee: {},
|
|
4386
4422
|
app_metadata: {},
|
|
@@ -4399,12 +4435,12 @@ function ea(e) {
|
|
|
4399
4435
|
}
|
|
4400
4436
|
//#endregion
|
|
4401
4437
|
//#region src/invites/remove.ts
|
|
4402
|
-
function
|
|
4438
|
+
function aa(e) {
|
|
4403
4439
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4404
4440
|
}
|
|
4405
4441
|
//#endregion
|
|
4406
4442
|
//#region src/invites/update.ts
|
|
4407
|
-
function
|
|
4443
|
+
function oa(e) {
|
|
4408
4444
|
return async (t, n, r) => {
|
|
4409
4445
|
let i = {};
|
|
4410
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;
|
|
@@ -4412,35 +4448,35 @@ function na(e) {
|
|
|
4412
4448
|
}
|
|
4413
4449
|
//#endregion
|
|
4414
4450
|
//#region src/invites/index.ts
|
|
4415
|
-
function
|
|
4451
|
+
function sa(e) {
|
|
4416
4452
|
return {
|
|
4417
|
-
create:
|
|
4418
|
-
get:
|
|
4419
|
-
list:
|
|
4420
|
-
remove:
|
|
4421
|
-
update:
|
|
4453
|
+
create: na(e),
|
|
4454
|
+
get: ra(e),
|
|
4455
|
+
list: ia(e),
|
|
4456
|
+
remove: aa(e),
|
|
4457
|
+
update: oa(e)
|
|
4422
4458
|
};
|
|
4423
4459
|
}
|
|
4424
4460
|
//#endregion
|
|
4425
4461
|
//#region src/stats/index.ts
|
|
4426
|
-
var
|
|
4427
|
-
function
|
|
4462
|
+
var ca = ["s"], la = ["pwd_leak"];
|
|
4463
|
+
function ua(e) {
|
|
4428
4464
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4429
4465
|
}
|
|
4430
|
-
function
|
|
4466
|
+
function da(e) {
|
|
4431
4467
|
return e.toISOString().split("T")[0];
|
|
4432
4468
|
}
|
|
4433
|
-
function
|
|
4469
|
+
function fa(e) {
|
|
4434
4470
|
return {
|
|
4435
4471
|
async getDaily(t, n = {}) {
|
|
4436
4472
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4437
4473
|
o.setDate(o.getDate() - 30);
|
|
4438
|
-
let s = r ?
|
|
4474
|
+
let s = r ? ua(r) : da(o), c = i ? ua(i) : da(a), l = f`DATE(logs.date)`;
|
|
4439
4475
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4440
4476
|
l.as("date"),
|
|
4441
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4477
|
+
e.fn.sum(e.case().when("type", "in", ca).then(1).else(0).end()).as("logins"),
|
|
4442
4478
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4443
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4479
|
+
e.fn.sum(e.case().when("type", "in", la).then(1).else(0).end()).as("leaked_passwords"),
|
|
4444
4480
|
e.fn.min("date").as("first_event"),
|
|
4445
4481
|
e.fn.max("date").as("last_event")
|
|
4446
4482
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4454,13 +4490,13 @@ function ca(e) {
|
|
|
4454
4490
|
},
|
|
4455
4491
|
async getActiveUsers(t) {
|
|
4456
4492
|
let n = /* @__PURE__ */ new Date();
|
|
4457
|
-
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", ca).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4458
4494
|
}
|
|
4459
4495
|
};
|
|
4460
4496
|
}
|
|
4461
4497
|
//#endregion
|
|
4462
4498
|
//#region src/analytics/index.ts
|
|
4463
|
-
var
|
|
4499
|
+
var pa = {
|
|
4464
4500
|
"active-users": ["s", "seacft"],
|
|
4465
4501
|
logins: [
|
|
4466
4502
|
"s",
|
|
@@ -4490,7 +4526,7 @@ var la = {
|
|
|
4490
4526
|
"fvr"
|
|
4491
4527
|
],
|
|
4492
4528
|
"codes-sent": ["cls", "cs"]
|
|
4493
|
-
},
|
|
4529
|
+
}, ma = {
|
|
4494
4530
|
"active-users": {
|
|
4495
4531
|
alias: "active_users",
|
|
4496
4532
|
type: "UInt64",
|
|
@@ -4547,7 +4583,7 @@ var la = {
|
|
|
4547
4583
|
agg: "count"
|
|
4548
4584
|
}
|
|
4549
4585
|
};
|
|
4550
|
-
async function
|
|
4586
|
+
async function ha(e) {
|
|
4551
4587
|
try {
|
|
4552
4588
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4553
4589
|
} catch {
|
|
@@ -4569,7 +4605,7 @@ function U(e, t) {
|
|
|
4569
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);
|
|
4570
4606
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4571
4607
|
}
|
|
4572
|
-
var
|
|
4608
|
+
var ga = [
|
|
4573
4609
|
"January",
|
|
4574
4610
|
"February",
|
|
4575
4611
|
"March",
|
|
@@ -4583,22 +4619,22 @@ var fa = [
|
|
|
4583
4619
|
"November",
|
|
4584
4620
|
"December"
|
|
4585
4621
|
];
|
|
4586
|
-
function
|
|
4622
|
+
function _a(e, t) {
|
|
4587
4623
|
let n = t.getUTCFullYear(), r = U(e, new Date(Date.UTC(n, 0, 1)));
|
|
4588
4624
|
for (let t = 1; t < 12; t++) {
|
|
4589
4625
|
let i = U(e, new Date(Date.UTC(n, t, 1)));
|
|
4590
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4626
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${ga[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').`);
|
|
4591
4627
|
}
|
|
4592
4628
|
}
|
|
4593
|
-
function
|
|
4629
|
+
function va(e) {
|
|
4594
4630
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4595
4631
|
return t * (Number(n) * 60 + Number(r));
|
|
4596
4632
|
}
|
|
4597
|
-
function
|
|
4633
|
+
function ya(e, t) {
|
|
4598
4634
|
let n;
|
|
4599
4635
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4600
4636
|
else {
|
|
4601
|
-
let e =
|
|
4637
|
+
let e = va(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4602
4638
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4603
4639
|
}
|
|
4604
4640
|
switch (e) {
|
|
@@ -4609,7 +4645,7 @@ function ha(e, t) {
|
|
|
4609
4645
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4610
4646
|
}
|
|
4611
4647
|
}
|
|
4612
|
-
function
|
|
4648
|
+
function ba(e, t) {
|
|
4613
4649
|
if (t === "+00:00") switch (e) {
|
|
4614
4650
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4615
4651
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4620,7 +4656,7 @@ function ga(e, t) {
|
|
|
4620
4656
|
}
|
|
4621
4657
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4622
4658
|
}
|
|
4623
|
-
let n =
|
|
4659
|
+
let n = va(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)`;
|
|
4624
4660
|
switch (e) {
|
|
4625
4661
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4626
4662
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4629,12 +4665,12 @@ function ga(e, t) {
|
|
|
4629
4665
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4630
4666
|
}
|
|
4631
4667
|
}
|
|
4632
|
-
function
|
|
4633
|
-
|
|
4668
|
+
function xa(e, t, n, r) {
|
|
4669
|
+
_a(t, n);
|
|
4634
4670
|
let i = U(t, n);
|
|
4635
|
-
return r === "mysql" ?
|
|
4671
|
+
return r === "mysql" ? ba(e, i) : ya(e, i);
|
|
4636
4672
|
}
|
|
4637
|
-
function
|
|
4673
|
+
function Sa(e) {
|
|
4638
4674
|
switch (e) {
|
|
4639
4675
|
case "connection": return "logs.connection";
|
|
4640
4676
|
case "client_id": return "logs.client_id";
|
|
@@ -4643,14 +4679,14 @@ function va(e) {
|
|
|
4643
4679
|
case "time": throw Error("time dimension is handled separately");
|
|
4644
4680
|
}
|
|
4645
4681
|
}
|
|
4646
|
-
function
|
|
4647
|
-
let t = null, n = () => (t ||=
|
|
4682
|
+
function Ca(e) {
|
|
4683
|
+
let t = null, n = () => (t ||= ha(e), t);
|
|
4648
4684
|
return { async query(t, r, i) {
|
|
4649
|
-
let a = Date.now(), o =
|
|
4685
|
+
let a = Date.now(), o = pa[r], s = ma[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4650
4686
|
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));
|
|
4651
4687
|
let d = [], p = [];
|
|
4652
4688
|
for (let e of i.group_by) if (e === "time") {
|
|
4653
|
-
let e =
|
|
4689
|
+
let e = xa(i.interval, i.tz, new Date(i.from), c);
|
|
4654
4690
|
p.push({
|
|
4655
4691
|
alias: "time",
|
|
4656
4692
|
expr: e
|
|
@@ -4659,7 +4695,7 @@ function ya(e) {
|
|
|
4659
4695
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4660
4696
|
});
|
|
4661
4697
|
} else {
|
|
4662
|
-
let t =
|
|
4698
|
+
let t = Sa(e);
|
|
4663
4699
|
p.push({
|
|
4664
4700
|
alias: e,
|
|
4665
4701
|
expr: f`${f.ref(t)}`
|
|
@@ -4701,7 +4737,7 @@ function ya(e) {
|
|
|
4701
4737
|
}
|
|
4702
4738
|
//#endregion
|
|
4703
4739
|
//#region src/customText/index.ts
|
|
4704
|
-
function
|
|
4740
|
+
function wa(e) {
|
|
4705
4741
|
return {
|
|
4706
4742
|
async get(t, n, r) {
|
|
4707
4743
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4740,9 +4776,9 @@ function ba(e) {
|
|
|
4740
4776
|
}
|
|
4741
4777
|
//#endregion
|
|
4742
4778
|
//#region src/authenticationMethods/create.ts
|
|
4743
|
-
function
|
|
4779
|
+
function Ta(e) {
|
|
4744
4780
|
return async (t, n, r) => {
|
|
4745
|
-
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 ??
|
|
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 ?? Tr();
|
|
4746
4782
|
return await e.insertInto("authentication_methods").values({
|
|
4747
4783
|
id: s,
|
|
4748
4784
|
tenant_id: t,
|
|
@@ -4779,7 +4815,7 @@ function xa(e) {
|
|
|
4779
4815
|
}
|
|
4780
4816
|
//#endregion
|
|
4781
4817
|
//#region src/authenticationMethods/get.ts
|
|
4782
|
-
function
|
|
4818
|
+
function Ea(e) {
|
|
4783
4819
|
return async (t, n) => {
|
|
4784
4820
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4785
4821
|
return r ? {
|
|
@@ -4802,7 +4838,7 @@ function Sa(e) {
|
|
|
4802
4838
|
}
|
|
4803
4839
|
//#endregion
|
|
4804
4840
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4805
|
-
function
|
|
4841
|
+
function Da(e) {
|
|
4806
4842
|
return async (t, n) => {
|
|
4807
4843
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4808
4844
|
return r ? {
|
|
@@ -4825,7 +4861,7 @@ function Ca(e) {
|
|
|
4825
4861
|
}
|
|
4826
4862
|
//#endregion
|
|
4827
4863
|
//#region src/authenticationMethods/list.ts
|
|
4828
|
-
function
|
|
4864
|
+
function Oa(e) {
|
|
4829
4865
|
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) => ({
|
|
4830
4866
|
id: e.id,
|
|
4831
4867
|
user_id: e.user_id,
|
|
@@ -4845,35 +4881,35 @@ function wa(e) {
|
|
|
4845
4881
|
}
|
|
4846
4882
|
//#endregion
|
|
4847
4883
|
//#region src/authenticationMethods/update.ts
|
|
4848
|
-
function
|
|
4884
|
+
function ka(e) {
|
|
4849
4885
|
return async (t, n, r) => {
|
|
4850
4886
|
let i = { updated_at_ts: Date.now() };
|
|
4851
4887
|
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();
|
|
4852
|
-
let a = await
|
|
4888
|
+
let a = await Ea(e)(t, n);
|
|
4853
4889
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4854
4890
|
return a;
|
|
4855
4891
|
};
|
|
4856
4892
|
}
|
|
4857
4893
|
//#endregion
|
|
4858
4894
|
//#region src/authenticationMethods/remove.ts
|
|
4859
|
-
function
|
|
4895
|
+
function Aa(e) {
|
|
4860
4896
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4861
4897
|
}
|
|
4862
4898
|
//#endregion
|
|
4863
4899
|
//#region src/authenticationMethods/index.ts
|
|
4864
|
-
function
|
|
4900
|
+
function ja(e) {
|
|
4865
4901
|
return {
|
|
4866
|
-
create:
|
|
4867
|
-
get:
|
|
4868
|
-
getByCredentialId:
|
|
4869
|
-
list:
|
|
4870
|
-
update:
|
|
4871
|
-
remove:
|
|
4902
|
+
create: Ta(e),
|
|
4903
|
+
get: Ea(e),
|
|
4904
|
+
getByCredentialId: Da(e),
|
|
4905
|
+
list: Oa(e),
|
|
4906
|
+
update: ka(e),
|
|
4907
|
+
remove: Aa(e)
|
|
4872
4908
|
};
|
|
4873
4909
|
}
|
|
4874
4910
|
//#endregion
|
|
4875
4911
|
//#region src/outbox/getByIds.ts
|
|
4876
|
-
function
|
|
4912
|
+
function Ma(e) {
|
|
4877
4913
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4878
4914
|
...JSON.parse(e.payload),
|
|
4879
4915
|
id: e.id,
|
|
@@ -4886,7 +4922,7 @@ function Oa(e) {
|
|
|
4886
4922
|
}
|
|
4887
4923
|
//#endregion
|
|
4888
4924
|
//#region src/outbox/getUnprocessed.ts
|
|
4889
|
-
function
|
|
4925
|
+
function Na(e) {
|
|
4890
4926
|
return async (t) => {
|
|
4891
4927
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4892
4928
|
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) => ({
|
|
@@ -4902,7 +4938,7 @@ function ka(e) {
|
|
|
4902
4938
|
}
|
|
4903
4939
|
//#endregion
|
|
4904
4940
|
//#region src/outbox/claimEvents.ts
|
|
4905
|
-
function
|
|
4941
|
+
function Pa(e) {
|
|
4906
4942
|
return async (t, n, r) => {
|
|
4907
4943
|
if (t.length === 0) return [];
|
|
4908
4944
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4914,7 +4950,7 @@ function Aa(e) {
|
|
|
4914
4950
|
}
|
|
4915
4951
|
//#endregion
|
|
4916
4952
|
//#region src/outbox/markProcessed.ts
|
|
4917
|
-
function
|
|
4953
|
+
function Fa(e) {
|
|
4918
4954
|
return async (t) => {
|
|
4919
4955
|
if (t.length === 0) return;
|
|
4920
4956
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4923,7 +4959,7 @@ function ja(e) {
|
|
|
4923
4959
|
}
|
|
4924
4960
|
//#endregion
|
|
4925
4961
|
//#region src/outbox/markRetry.ts
|
|
4926
|
-
function
|
|
4962
|
+
function Ia(e) {
|
|
4927
4963
|
return async (t, n, r) => {
|
|
4928
4964
|
await e.updateTable("outbox_events").set({
|
|
4929
4965
|
error: n,
|
|
@@ -4936,7 +4972,7 @@ function Ma(e) {
|
|
|
4936
4972
|
}
|
|
4937
4973
|
//#endregion
|
|
4938
4974
|
//#region src/outbox/deadLetter.ts
|
|
4939
|
-
function
|
|
4975
|
+
function La(e) {
|
|
4940
4976
|
return async (t, n) => {
|
|
4941
4977
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4942
4978
|
await e.updateTable("outbox_events").set({
|
|
@@ -4948,7 +4984,7 @@ function Na(e) {
|
|
|
4948
4984
|
}
|
|
4949
4985
|
//#endregion
|
|
4950
4986
|
//#region src/outbox/listFailed.ts
|
|
4951
|
-
function
|
|
4987
|
+
function Ra(e) {
|
|
4952
4988
|
return async (t, n = {}) => {
|
|
4953
4989
|
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) => {
|
|
4954
4990
|
let t;
|
|
@@ -4983,7 +5019,7 @@ function Pa(e) {
|
|
|
4983
5019
|
}
|
|
4984
5020
|
//#endregion
|
|
4985
5021
|
//#region src/outbox/replay.ts
|
|
4986
|
-
function
|
|
5022
|
+
function za(e) {
|
|
4987
5023
|
return async (t, n) => {
|
|
4988
5024
|
let r = await e.updateTable("outbox_events").set({
|
|
4989
5025
|
processed_at: null,
|
|
@@ -4998,7 +5034,7 @@ function Fa(e) {
|
|
|
4998
5034
|
}
|
|
4999
5035
|
//#endregion
|
|
5000
5036
|
//#region src/outbox/cleanup.ts
|
|
5001
|
-
function
|
|
5037
|
+
function Ba(e) {
|
|
5002
5038
|
return async (t) => {
|
|
5003
5039
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5004
5040
|
return Number(n.numDeletedRows);
|
|
@@ -5006,18 +5042,18 @@ function Ia(e) {
|
|
|
5006
5042
|
}
|
|
5007
5043
|
//#endregion
|
|
5008
5044
|
//#region src/outbox/index.ts
|
|
5009
|
-
function
|
|
5045
|
+
function Va(e) {
|
|
5010
5046
|
return {
|
|
5011
|
-
create:
|
|
5012
|
-
getByIds:
|
|
5013
|
-
getUnprocessed:
|
|
5014
|
-
claimEvents:
|
|
5015
|
-
markProcessed:
|
|
5016
|
-
markRetry:
|
|
5017
|
-
deadLetter:
|
|
5018
|
-
listFailed:
|
|
5019
|
-
replay:
|
|
5020
|
-
cleanup:
|
|
5047
|
+
create: He(e),
|
|
5048
|
+
getByIds: Ma(e),
|
|
5049
|
+
getUnprocessed: Na(e),
|
|
5050
|
+
claimEvents: Pa(e),
|
|
5051
|
+
markProcessed: Fa(e),
|
|
5052
|
+
markRetry: Ia(e),
|
|
5053
|
+
deadLetter: La(e),
|
|
5054
|
+
listFailed: Ra(e),
|
|
5055
|
+
replay: za(e),
|
|
5056
|
+
cleanup: Ba(e)
|
|
5021
5057
|
};
|
|
5022
5058
|
}
|
|
5023
5059
|
//#endregion
|
|
@@ -5035,7 +5071,7 @@ function W(e) {
|
|
|
5035
5071
|
updated_at: e.updated_at
|
|
5036
5072
|
};
|
|
5037
5073
|
}
|
|
5038
|
-
function
|
|
5074
|
+
function Ha(e) {
|
|
5039
5075
|
return {
|
|
5040
5076
|
async create(n, r, i) {
|
|
5041
5077
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5082,7 +5118,7 @@ function G(e) {
|
|
|
5082
5118
|
updated_at: e.updated_at
|
|
5083
5119
|
};
|
|
5084
5120
|
}
|
|
5085
|
-
function
|
|
5121
|
+
function Ua(e) {
|
|
5086
5122
|
return {
|
|
5087
5123
|
async create(n, r, i) {
|
|
5088
5124
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5122,13 +5158,13 @@ function K(e) {
|
|
|
5122
5158
|
tenant_id: e.tenant_id,
|
|
5123
5159
|
custom_domain_id: e.custom_domain_id,
|
|
5124
5160
|
priority: e.priority,
|
|
5125
|
-
match:
|
|
5126
|
-
handlers:
|
|
5161
|
+
match: Wa(e.match),
|
|
5162
|
+
handlers: Ga(e.handlers),
|
|
5127
5163
|
created_at: e.created_at,
|
|
5128
5164
|
updated_at: e.updated_at
|
|
5129
5165
|
};
|
|
5130
5166
|
}
|
|
5131
|
-
function
|
|
5167
|
+
function Wa(e) {
|
|
5132
5168
|
if (!e) return { path: "/*" };
|
|
5133
5169
|
try {
|
|
5134
5170
|
let t = JSON.parse(e), n = re.safeParse(t);
|
|
@@ -5136,7 +5172,7 @@ function Ba(e) {
|
|
|
5136
5172
|
} catch {}
|
|
5137
5173
|
return { path: "/*" };
|
|
5138
5174
|
}
|
|
5139
|
-
function
|
|
5175
|
+
function Ga(e) {
|
|
5140
5176
|
if (!e) return [];
|
|
5141
5177
|
try {
|
|
5142
5178
|
let t = JSON.parse(e);
|
|
@@ -5206,7 +5242,7 @@ function q(e) {
|
|
|
5206
5242
|
}
|
|
5207
5243
|
//#endregion
|
|
5208
5244
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5209
|
-
async function
|
|
5245
|
+
async function Ka(e, t) {
|
|
5210
5246
|
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([
|
|
5211
5247
|
"custom_domain_id",
|
|
5212
5248
|
"tenant_id",
|
|
@@ -5223,16 +5259,179 @@ async function Ha(e, t) {
|
|
|
5223
5259
|
}
|
|
5224
5260
|
//#endregion
|
|
5225
5261
|
//#region src/proxyRoutes/index.ts
|
|
5226
|
-
function
|
|
5262
|
+
function qa(e) {
|
|
5227
5263
|
return {
|
|
5228
5264
|
proxyRoutes: q(e),
|
|
5229
|
-
resolveHost: (t) =>
|
|
5265
|
+
resolveHost: (t) => Ka(e, t)
|
|
5230
5266
|
};
|
|
5231
5267
|
}
|
|
5232
5268
|
//#endregion
|
|
5233
|
-
//#region src/
|
|
5269
|
+
//#region src/scim/adapter.ts
|
|
5270
|
+
function Ja(e) {
|
|
5271
|
+
if (!e) return [];
|
|
5272
|
+
try {
|
|
5273
|
+
let t = JSON.parse(e);
|
|
5274
|
+
if (!Array.isArray(t)) return [];
|
|
5275
|
+
let n = [];
|
|
5276
|
+
for (let e of t) {
|
|
5277
|
+
let t = le.safeParse(e);
|
|
5278
|
+
t.success && n.push(t.data);
|
|
5279
|
+
}
|
|
5280
|
+
return n;
|
|
5281
|
+
} catch {
|
|
5282
|
+
return [];
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
function Ya(e) {
|
|
5286
|
+
if (!e) return [];
|
|
5287
|
+
try {
|
|
5288
|
+
let t = JSON.parse(e);
|
|
5289
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
5290
|
+
} catch {
|
|
5291
|
+
return [];
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
function Xa(e) {
|
|
5295
|
+
return {
|
|
5296
|
+
connection_id: e.connection_id,
|
|
5297
|
+
user_id_attribute: e.user_id_attribute,
|
|
5298
|
+
mapping: Ja(e.mapping),
|
|
5299
|
+
created_at: e.created_at,
|
|
5300
|
+
updated_at: e.updated_at
|
|
5301
|
+
};
|
|
5302
|
+
}
|
|
5303
|
+
function Za(e) {
|
|
5304
|
+
return {
|
|
5305
|
+
async create(t, n) {
|
|
5306
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5307
|
+
return await e.insertInto("scim_configurations").values({
|
|
5308
|
+
connection_id: n.connection_id,
|
|
5309
|
+
tenant_id: t,
|
|
5310
|
+
user_id_attribute: n.user_id_attribute,
|
|
5311
|
+
mapping: JSON.stringify(n.mapping),
|
|
5312
|
+
created_at: r,
|
|
5313
|
+
updated_at: r
|
|
5314
|
+
}).execute(), {
|
|
5315
|
+
connection_id: n.connection_id,
|
|
5316
|
+
user_id_attribute: n.user_id_attribute,
|
|
5317
|
+
mapping: n.mapping,
|
|
5318
|
+
created_at: r,
|
|
5319
|
+
updated_at: r
|
|
5320
|
+
};
|
|
5321
|
+
},
|
|
5322
|
+
async get(t, n) {
|
|
5323
|
+
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5324
|
+
return r ? Xa(r) : null;
|
|
5325
|
+
},
|
|
5326
|
+
async update(t, n, r) {
|
|
5327
|
+
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5328
|
+
r.user_id_attribute !== void 0 && (i.user_id_attribute = r.user_id_attribute), r.mapping !== void 0 && (i.mapping = JSON.stringify(r.mapping));
|
|
5329
|
+
let a = await e.updateTable("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).set(i).executeTakeFirst();
|
|
5330
|
+
return Number(a.numUpdatedRows) > 0;
|
|
5331
|
+
},
|
|
5332
|
+
async remove(t, n) {
|
|
5333
|
+
let r = await e.deleteFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).executeTakeFirst();
|
|
5334
|
+
return Number(r.numDeletedRows) > 0;
|
|
5335
|
+
}
|
|
5336
|
+
};
|
|
5337
|
+
}
|
|
5234
5338
|
function J(e) {
|
|
5235
|
-
return
|
|
5339
|
+
return {
|
|
5340
|
+
token_id: e.token_id,
|
|
5341
|
+
connection_id: e.connection_id,
|
|
5342
|
+
token_hash: e.token_hash,
|
|
5343
|
+
scopes: Ya(e.scopes),
|
|
5344
|
+
valid_until: e.valid_until ?? void 0,
|
|
5345
|
+
created_at: e.created_at,
|
|
5346
|
+
last_used_at: e.last_used_at ?? void 0
|
|
5347
|
+
};
|
|
5348
|
+
}
|
|
5349
|
+
function Qa(e) {
|
|
5350
|
+
return {
|
|
5351
|
+
async create(t, n) {
|
|
5352
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5353
|
+
return await e.insertInto("scim_tokens").values({
|
|
5354
|
+
token_id: n.token_id,
|
|
5355
|
+
tenant_id: t,
|
|
5356
|
+
connection_id: n.connection_id,
|
|
5357
|
+
token_hash: n.token_hash,
|
|
5358
|
+
scopes: JSON.stringify(n.scopes),
|
|
5359
|
+
valid_until: n.valid_until ?? null,
|
|
5360
|
+
created_at: r,
|
|
5361
|
+
last_used_at: null
|
|
5362
|
+
}).execute(), {
|
|
5363
|
+
token_id: n.token_id,
|
|
5364
|
+
connection_id: n.connection_id,
|
|
5365
|
+
token_hash: n.token_hash,
|
|
5366
|
+
scopes: n.scopes,
|
|
5367
|
+
valid_until: n.valid_until,
|
|
5368
|
+
created_at: r
|
|
5369
|
+
};
|
|
5370
|
+
},
|
|
5371
|
+
async get(t, n) {
|
|
5372
|
+
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5373
|
+
return r ? J(r) : null;
|
|
5374
|
+
},
|
|
5375
|
+
async getByHash(t, n) {
|
|
5376
|
+
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5377
|
+
return r ? J(r) : null;
|
|
5378
|
+
},
|
|
5379
|
+
async listByConnection(t, n) {
|
|
5380
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(J);
|
|
5381
|
+
},
|
|
5382
|
+
async markUsed(t, n, r) {
|
|
5383
|
+
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
5384
|
+
return Number(i.numUpdatedRows) > 0;
|
|
5385
|
+
},
|
|
5386
|
+
async remove(t, n) {
|
|
5387
|
+
let r = await e.deleteFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).executeTakeFirst();
|
|
5388
|
+
return Number(r.numDeletedRows) > 0;
|
|
5389
|
+
}
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
function $a(e) {
|
|
5393
|
+
return {
|
|
5394
|
+
connection_id: e.connection_id,
|
|
5395
|
+
external_id: e.external_id,
|
|
5396
|
+
user_id: e.user_id,
|
|
5397
|
+
created_at: e.created_at
|
|
5398
|
+
};
|
|
5399
|
+
}
|
|
5400
|
+
function eo(e) {
|
|
5401
|
+
return {
|
|
5402
|
+
async create(t, n) {
|
|
5403
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5404
|
+
return await e.insertInto("scim_external_ids").values({
|
|
5405
|
+
tenant_id: t,
|
|
5406
|
+
connection_id: n.connection_id,
|
|
5407
|
+
external_id: n.external_id,
|
|
5408
|
+
user_id: n.user_id,
|
|
5409
|
+
created_at: r
|
|
5410
|
+
}).execute(), {
|
|
5411
|
+
connection_id: n.connection_id,
|
|
5412
|
+
external_id: n.external_id,
|
|
5413
|
+
user_id: n.user_id,
|
|
5414
|
+
created_at: r
|
|
5415
|
+
};
|
|
5416
|
+
},
|
|
5417
|
+
async getByExternalId(t, n, r) {
|
|
5418
|
+
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 ? $a(i) : null;
|
|
5420
|
+
},
|
|
5421
|
+
async getByUserId(t, n, r) {
|
|
5422
|
+
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 ? $a(i) : null;
|
|
5424
|
+
},
|
|
5425
|
+
async remove(t, n, r) {
|
|
5426
|
+
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
5427
|
+
return Number(i.numDeletedRows) > 0;
|
|
5428
|
+
}
|
|
5429
|
+
};
|
|
5430
|
+
}
|
|
5431
|
+
//#endregion
|
|
5432
|
+
//#region src/tenantOperations/index.ts
|
|
5433
|
+
function Y(e) {
|
|
5434
|
+
return pe.parse({
|
|
5236
5435
|
id: e.id,
|
|
5237
5436
|
tenant_id: e.tenant_id,
|
|
5238
5437
|
rollout_id: e.rollout_id,
|
|
@@ -5250,10 +5449,10 @@ function J(e) {
|
|
|
5250
5449
|
finished_at: e.finished_at
|
|
5251
5450
|
});
|
|
5252
5451
|
}
|
|
5253
|
-
function
|
|
5452
|
+
function to(e) {
|
|
5254
5453
|
return {
|
|
5255
5454
|
async create(n) {
|
|
5256
|
-
let r =
|
|
5455
|
+
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5257
5456
|
id: `op_${t()}`,
|
|
5258
5457
|
tenant_id: r.tenant_id,
|
|
5259
5458
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5270,11 +5469,11 @@ function Wa(e) {
|
|
|
5270
5469
|
updated_at: i,
|
|
5271
5470
|
finished_at: null
|
|
5272
5471
|
};
|
|
5273
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5472
|
+
return await e.insertInto("tenant_operations").values(a).execute(), Y(a);
|
|
5274
5473
|
},
|
|
5275
5474
|
async get(t) {
|
|
5276
5475
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5277
|
-
return n ?
|
|
5476
|
+
return n ? Y(n) : null;
|
|
5278
5477
|
},
|
|
5279
5478
|
async list(t = {}) {
|
|
5280
5479
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5285,7 +5484,7 @@ function Wa(e) {
|
|
|
5285
5484
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5286
5485
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5287
5486
|
return {
|
|
5288
|
-
operations: a.map(
|
|
5487
|
+
operations: a.map(Y),
|
|
5289
5488
|
start: n * r,
|
|
5290
5489
|
limit: r,
|
|
5291
5490
|
length: a.length
|
|
@@ -5305,27 +5504,27 @@ function Wa(e) {
|
|
|
5305
5504
|
}
|
|
5306
5505
|
//#endregion
|
|
5307
5506
|
//#region src/utils/monotonic-id.ts
|
|
5308
|
-
var
|
|
5309
|
-
function
|
|
5507
|
+
var no = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", X = 32, ro = 10, io = 4, ao = 10;
|
|
5508
|
+
function oo(e, t) {
|
|
5310
5509
|
let n = "";
|
|
5311
|
-
for (let r = t; r > 0; r--) n =
|
|
5510
|
+
for (let r = t; r > 0; r--) n = no.charAt(e % X) + n, e = Math.floor(e / X);
|
|
5312
5511
|
return n;
|
|
5313
5512
|
}
|
|
5314
|
-
function
|
|
5315
|
-
let e = new Uint8Array(
|
|
5513
|
+
function so() {
|
|
5514
|
+
let e = new Uint8Array(ao);
|
|
5316
5515
|
crypto.getRandomValues(e);
|
|
5317
5516
|
let t = "";
|
|
5318
|
-
for (let n = 0; n <
|
|
5517
|
+
for (let n = 0; n < ao; n++) t += no.charAt(e[n] % X);
|
|
5319
5518
|
return t;
|
|
5320
5519
|
}
|
|
5321
|
-
var
|
|
5322
|
-
function
|
|
5520
|
+
var co = 0, Z = 0;
|
|
5521
|
+
function lo() {
|
|
5323
5522
|
let e = Date.now();
|
|
5324
|
-
return e ===
|
|
5523
|
+
return e === co ? Z++ : (co = e, Z = 0), oo(e, ro) + oo(Z, io) + so();
|
|
5325
5524
|
}
|
|
5326
5525
|
//#endregion
|
|
5327
5526
|
//#region src/tenantOperationEvents/index.ts
|
|
5328
|
-
function
|
|
5527
|
+
function uo(e) {
|
|
5329
5528
|
if (!e) return null;
|
|
5330
5529
|
try {
|
|
5331
5530
|
let t = JSON.parse(e);
|
|
@@ -5333,22 +5532,22 @@ function $a(e) {
|
|
|
5333
5532
|
} catch {}
|
|
5334
5533
|
return null;
|
|
5335
5534
|
}
|
|
5336
|
-
function
|
|
5337
|
-
return
|
|
5535
|
+
function fo(e) {
|
|
5536
|
+
return de.parse({
|
|
5338
5537
|
id: e.id,
|
|
5339
5538
|
operation_id: e.operation_id,
|
|
5340
5539
|
step: e.step,
|
|
5341
5540
|
outcome: e.outcome,
|
|
5342
|
-
detail:
|
|
5541
|
+
detail: uo(e.detail),
|
|
5343
5542
|
attempt: e.attempt,
|
|
5344
5543
|
created_at: e.created_at
|
|
5345
5544
|
});
|
|
5346
5545
|
}
|
|
5347
|
-
function
|
|
5546
|
+
function po(e) {
|
|
5348
5547
|
return {
|
|
5349
5548
|
async create(t) {
|
|
5350
|
-
let n =
|
|
5351
|
-
id: `evt_${
|
|
5549
|
+
let n = ue.parse(t), r = {
|
|
5550
|
+
id: `evt_${lo()}`,
|
|
5352
5551
|
operation_id: n.operation_id,
|
|
5353
5552
|
step: n.step,
|
|
5354
5553
|
outcome: n.outcome,
|
|
@@ -5356,12 +5555,12 @@ function to(e) {
|
|
|
5356
5555
|
attempt: n.attempt,
|
|
5357
5556
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5358
5557
|
};
|
|
5359
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5558
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), fo(r);
|
|
5360
5559
|
},
|
|
5361
5560
|
async listByOperation(t, n = {}) {
|
|
5362
5561
|
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();
|
|
5363
5562
|
return {
|
|
5364
|
-
events: a.map(
|
|
5563
|
+
events: a.map(fo),
|
|
5365
5564
|
start: r * i,
|
|
5366
5565
|
limit: i,
|
|
5367
5566
|
length: a.length
|
|
@@ -5371,7 +5570,7 @@ function to(e) {
|
|
|
5371
5570
|
}
|
|
5372
5571
|
//#endregion
|
|
5373
5572
|
//#region src/rollouts/index.ts
|
|
5374
|
-
function
|
|
5573
|
+
function mo(e) {
|
|
5375
5574
|
if (!e) return null;
|
|
5376
5575
|
try {
|
|
5377
5576
|
return JSON.parse(e);
|
|
@@ -5379,7 +5578,7 @@ function no(e) {
|
|
|
5379
5578
|
return null;
|
|
5380
5579
|
}
|
|
5381
5580
|
}
|
|
5382
|
-
function
|
|
5581
|
+
function ho(e) {
|
|
5383
5582
|
return ce.parse({
|
|
5384
5583
|
id: e.id,
|
|
5385
5584
|
kind: e.kind,
|
|
@@ -5387,15 +5586,15 @@ function Z(e) {
|
|
|
5387
5586
|
target_worker_version: e.target_worker_version,
|
|
5388
5587
|
target_database_version: e.target_database_version,
|
|
5389
5588
|
wave_size: e.wave_size,
|
|
5390
|
-
canary_tenant_ids:
|
|
5391
|
-
filter:
|
|
5589
|
+
canary_tenant_ids: mo(e.canary_tenant_ids),
|
|
5590
|
+
filter: mo(e.filter),
|
|
5392
5591
|
initiated_by: e.initiated_by,
|
|
5393
5592
|
created_at: e.created_at,
|
|
5394
5593
|
updated_at: e.updated_at,
|
|
5395
5594
|
finished_at: e.finished_at
|
|
5396
5595
|
});
|
|
5397
5596
|
}
|
|
5398
|
-
function
|
|
5597
|
+
function go(e) {
|
|
5399
5598
|
return {
|
|
5400
5599
|
async create(n) {
|
|
5401
5600
|
let r = se.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5412,16 +5611,16 @@ function ro(e) {
|
|
|
5412
5611
|
updated_at: i,
|
|
5413
5612
|
finished_at: null
|
|
5414
5613
|
};
|
|
5415
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5614
|
+
return await e.insertInto("rollouts").values(a).execute(), ho(a);
|
|
5416
5615
|
},
|
|
5417
5616
|
async get(t) {
|
|
5418
5617
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5419
|
-
return n ?
|
|
5618
|
+
return n ? ho(n) : null;
|
|
5420
5619
|
},
|
|
5421
5620
|
async list(t = {}) {
|
|
5422
5621
|
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();
|
|
5423
5622
|
return {
|
|
5424
|
-
rollouts: i.map(
|
|
5623
|
+
rollouts: i.map(ho),
|
|
5425
5624
|
start: n * r,
|
|
5426
5625
|
limit: r,
|
|
5427
5626
|
length: i.length
|
|
@@ -5441,7 +5640,7 @@ function ro(e) {
|
|
|
5441
5640
|
}
|
|
5442
5641
|
//#endregion
|
|
5443
5642
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5444
|
-
var
|
|
5643
|
+
var _o = class {
|
|
5445
5644
|
migrations;
|
|
5446
5645
|
constructor(e) {
|
|
5447
5646
|
this.migrations = e;
|
|
@@ -5449,10 +5648,10 @@ var io = class {
|
|
|
5449
5648
|
async getMigrations() {
|
|
5450
5649
|
return this.migrations;
|
|
5451
5650
|
}
|
|
5452
|
-
},
|
|
5453
|
-
down: () =>
|
|
5454
|
-
up: () =>
|
|
5455
|
-
}),
|
|
5651
|
+
}, vo = /* @__PURE__ */ w({
|
|
5652
|
+
down: () => So,
|
|
5653
|
+
up: () => xo
|
|
5654
|
+
}), yo = [
|
|
5456
5655
|
{
|
|
5457
5656
|
table: "authentication_methods",
|
|
5458
5657
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5718,7 +5917,7 @@ var io = class {
|
|
|
5718
5917
|
onDelete: "cascade"
|
|
5719
5918
|
}
|
|
5720
5919
|
];
|
|
5721
|
-
async function
|
|
5920
|
+
async function bo(e) {
|
|
5722
5921
|
try {
|
|
5723
5922
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5724
5923
|
} catch {
|
|
@@ -5727,14 +5926,14 @@ async function so(e) {
|
|
|
5727
5926
|
}
|
|
5728
5927
|
function Q(e, t) {
|
|
5729
5928
|
let n = e;
|
|
5730
|
-
for (let e of
|
|
5929
|
+
for (let e of yo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5731
5930
|
let n = t;
|
|
5732
5931
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5733
5932
|
}));
|
|
5734
5933
|
return n;
|
|
5735
5934
|
}
|
|
5736
|
-
async function
|
|
5737
|
-
let t = await
|
|
5935
|
+
async function xo(e) {
|
|
5936
|
+
let t = await bo(e);
|
|
5738
5937
|
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();
|
|
5739
5938
|
{
|
|
5740
5939
|
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"]);
|
|
@@ -5921,40 +6120,40 @@ async function co(e) {
|
|
|
5921
6120
|
"tenant_id",
|
|
5922
6121
|
"phone_number",
|
|
5923
6122
|
"provider"
|
|
5924
|
-
]).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
|
|
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 yo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
5925
6124
|
let n = e;
|
|
5926
6125
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
5927
6126
|
}).execute();
|
|
5928
6127
|
}
|
|
5929
|
-
async function
|
|
6128
|
+
async function So(e) {
|
|
5930
6129
|
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();
|
|
5931
6130
|
}
|
|
5932
6131
|
//#endregion
|
|
5933
6132
|
//#region migrate/log.ts
|
|
5934
|
-
var
|
|
5935
|
-
function
|
|
5936
|
-
|
|
6133
|
+
var Co = !1;
|
|
6134
|
+
function wo(e) {
|
|
6135
|
+
Co = e;
|
|
5937
6136
|
}
|
|
5938
6137
|
function $(...e) {
|
|
5939
|
-
|
|
6138
|
+
Co && console.log(...e);
|
|
5940
6139
|
}
|
|
5941
|
-
function
|
|
6140
|
+
function To(...e) {
|
|
5942
6141
|
console.warn(...e);
|
|
5943
6142
|
}
|
|
5944
6143
|
//#endregion
|
|
5945
6144
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
5946
|
-
var
|
|
5947
|
-
down: () =>
|
|
5948
|
-
up: () =>
|
|
5949
|
-
}),
|
|
5950
|
-
async function
|
|
6145
|
+
var Eo = /* @__PURE__ */ w({
|
|
6146
|
+
down: () => Lo,
|
|
6147
|
+
up: () => Po
|
|
6148
|
+
}), Do = 5e4, Oo = 500;
|
|
6149
|
+
async function ko(e) {
|
|
5951
6150
|
try {
|
|
5952
6151
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
5953
6152
|
} catch {
|
|
5954
6153
|
return "sqlite";
|
|
5955
6154
|
}
|
|
5956
6155
|
}
|
|
5957
|
-
async function
|
|
6156
|
+
async function Ao(e, t, n) {
|
|
5958
6157
|
try {
|
|
5959
6158
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
5960
6159
|
} catch (e) {
|
|
@@ -5965,7 +6164,7 @@ async function vo(e, t, n) {
|
|
|
5965
6164
|
throw e;
|
|
5966
6165
|
}
|
|
5967
6166
|
}
|
|
5968
|
-
async function
|
|
6167
|
+
async function jo(e, t, n, r) {
|
|
5969
6168
|
try {
|
|
5970
6169
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
5971
6170
|
} catch (e) {
|
|
@@ -5976,21 +6175,21 @@ async function yo(e, t, n, r) {
|
|
|
5976
6175
|
throw e;
|
|
5977
6176
|
}
|
|
5978
6177
|
}
|
|
5979
|
-
async function
|
|
6178
|
+
async function Mo(e, t) {
|
|
5980
6179
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
5981
6180
|
if (t === "sqlite") {
|
|
5982
6181
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
5983
6182
|
r = Number(t.numDeletedRows);
|
|
5984
6183
|
} else {
|
|
5985
|
-
let t =
|
|
5986
|
-
for (; t >=
|
|
5987
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6184
|
+
let t = Do;
|
|
6185
|
+
for (; t >= Do;) {
|
|
6186
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(Do).executeTakeFirst();
|
|
5988
6187
|
t = Number(i.numDeletedRows), r += t, t > 0 && $(` Pruned ${r} expired codes row(s)...`);
|
|
5989
6188
|
}
|
|
5990
6189
|
}
|
|
5991
6190
|
return r;
|
|
5992
6191
|
}
|
|
5993
|
-
async function
|
|
6192
|
+
async function No(e) {
|
|
5994
6193
|
let t = 0;
|
|
5995
6194
|
for (;;) {
|
|
5996
6195
|
let n = await e.selectFrom("codes").select([
|
|
@@ -5998,33 +6197,33 @@ async function xo(e) {
|
|
|
5998
6197
|
"code_type",
|
|
5999
6198
|
"tenant_id",
|
|
6000
6199
|
"expires_at"
|
|
6001
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6200
|
+
]).where("expires_at_ts", "is", null).limit(Oo).execute();
|
|
6002
6201
|
if (n.length === 0) break;
|
|
6003
6202
|
for (let t of n) {
|
|
6004
6203
|
let n = Date.parse(t.expires_at);
|
|
6005
6204
|
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();
|
|
6006
6205
|
}
|
|
6007
|
-
if (t += n.length, n.length <
|
|
6206
|
+
if (t += n.length, n.length < Oo) break;
|
|
6008
6207
|
}
|
|
6009
6208
|
return t;
|
|
6010
6209
|
}
|
|
6011
|
-
async function
|
|
6012
|
-
let t = await
|
|
6210
|
+
async function Po(e) {
|
|
6211
|
+
let t = await ko(e);
|
|
6013
6212
|
try {
|
|
6014
|
-
let n = await
|
|
6213
|
+
let n = await Mo(e, t);
|
|
6015
6214
|
$(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6016
6215
|
} catch (e) {
|
|
6017
|
-
|
|
6216
|
+
To(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6018
6217
|
}
|
|
6019
|
-
await
|
|
6218
|
+
await Ao(e, "codes", "expires_at_ts"), await jo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6020
6219
|
try {
|
|
6021
|
-
let t = await
|
|
6220
|
+
let t = await No(e);
|
|
6022
6221
|
$(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6023
6222
|
} catch (e) {
|
|
6024
|
-
|
|
6223
|
+
To(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6025
6224
|
}
|
|
6026
6225
|
}
|
|
6027
|
-
async function
|
|
6226
|
+
async function Fo(e, t, n) {
|
|
6028
6227
|
try {
|
|
6029
6228
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6030
6229
|
} catch (e) {
|
|
@@ -6032,7 +6231,83 @@ async function Co(e, t, n) {
|
|
|
6032
6231
|
throw e;
|
|
6033
6232
|
}
|
|
6034
6233
|
}
|
|
6035
|
-
async function
|
|
6234
|
+
async function Io(e, t, n) {
|
|
6235
|
+
try {
|
|
6236
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6237
|
+
} catch (e) {
|
|
6238
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6239
|
+
throw e;
|
|
6240
|
+
}
|
|
6241
|
+
}
|
|
6242
|
+
async function Lo(e) {
|
|
6243
|
+
await Fo(e, "idx_codes_expires_at_ts", "codes"), await Io(e, "codes", "expires_at_ts");
|
|
6244
|
+
}
|
|
6245
|
+
//#endregion
|
|
6246
|
+
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6247
|
+
var Ro = /* @__PURE__ */ w({
|
|
6248
|
+
down: () => Bo,
|
|
6249
|
+
up: () => zo
|
|
6250
|
+
});
|
|
6251
|
+
async function zo(e) {
|
|
6252
|
+
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
|
+
"tenant_id",
|
|
6254
|
+
"connection_id",
|
|
6255
|
+
"user_id"
|
|
6256
|
+
]).execute(), await e.schema.createIndex("scim_external_ids_connection_external_idx").on("scim_external_ids").columns([
|
|
6257
|
+
"tenant_id",
|
|
6258
|
+
"connection_id",
|
|
6259
|
+
"external_id"
|
|
6260
|
+
]).unique().execute();
|
|
6261
|
+
}
|
|
6262
|
+
async function Bo(e) {
|
|
6263
|
+
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
|
+
}
|
|
6265
|
+
//#endregion
|
|
6266
|
+
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6267
|
+
var Vo = /* @__PURE__ */ w({
|
|
6268
|
+
down: () => Go,
|
|
6269
|
+
up: () => Uo
|
|
6270
|
+
});
|
|
6271
|
+
async function Ho(e, t, n) {
|
|
6272
|
+
try {
|
|
6273
|
+
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6274
|
+
} catch (e) {
|
|
6275
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6276
|
+
throw e;
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
async function Uo(e) {
|
|
6280
|
+
await Ho(e, "users", "blocked");
|
|
6281
|
+
}
|
|
6282
|
+
async function Wo(e, t, n) {
|
|
6283
|
+
try {
|
|
6284
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6285
|
+
} catch (e) {
|
|
6286
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6287
|
+
throw e;
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
async function Go(e) {
|
|
6291
|
+
await Wo(e, "users", "blocked");
|
|
6292
|
+
}
|
|
6293
|
+
//#endregion
|
|
6294
|
+
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6295
|
+
var Ko = /* @__PURE__ */ w({
|
|
6296
|
+
down: () => Xo,
|
|
6297
|
+
up: () => Jo
|
|
6298
|
+
});
|
|
6299
|
+
async function qo(e, t, n) {
|
|
6300
|
+
try {
|
|
6301
|
+
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6302
|
+
} catch (e) {
|
|
6303
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6304
|
+
throw e;
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6307
|
+
async function Jo(e) {
|
|
6308
|
+
await qo(e, "prompt_settings", "show_last_used_connection");
|
|
6309
|
+
}
|
|
6310
|
+
async function Yo(e, t, n) {
|
|
6036
6311
|
try {
|
|
6037
6312
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6038
6313
|
} catch (e) {
|
|
@@ -6040,32 +6315,64 @@ async function wo(e, t, n) {
|
|
|
6040
6315
|
throw e;
|
|
6041
6316
|
}
|
|
6042
6317
|
}
|
|
6043
|
-
async function
|
|
6044
|
-
await
|
|
6318
|
+
async function Xo(e) {
|
|
6319
|
+
await Yo(e, "prompt_settings", "show_last_used_connection");
|
|
6320
|
+
}
|
|
6321
|
+
//#endregion
|
|
6322
|
+
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6323
|
+
var Zo = /* @__PURE__ */ w({
|
|
6324
|
+
down: () => es,
|
|
6325
|
+
up: () => $o
|
|
6326
|
+
});
|
|
6327
|
+
async function Qo(e, t, n, r) {
|
|
6328
|
+
try {
|
|
6329
|
+
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6330
|
+
} catch (e) {
|
|
6331
|
+
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6332
|
+
$(` Index ${t} already exists, skipping`);
|
|
6333
|
+
return;
|
|
6334
|
+
}
|
|
6335
|
+
throw e;
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
async function $o(e) {
|
|
6339
|
+
await Qo(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6340
|
+
}
|
|
6341
|
+
async function es(e) {
|
|
6342
|
+
try {
|
|
6343
|
+
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6344
|
+
} catch (e) {
|
|
6345
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6346
|
+
throw e;
|
|
6347
|
+
}
|
|
6045
6348
|
}
|
|
6046
6349
|
//#endregion
|
|
6047
6350
|
//#region migrate/migrations/index.ts
|
|
6048
|
-
var
|
|
6049
|
-
"2026-07-16T14:00:00_baseline":
|
|
6050
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6351
|
+
var ts = {
|
|
6352
|
+
"2026-07-16T14:00:00_baseline": vo,
|
|
6353
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Eo,
|
|
6354
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Ro,
|
|
6355
|
+
"2026-08-05T12:00:00_user_blocked": Vo,
|
|
6356
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Ko,
|
|
6357
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Zo
|
|
6051
6358
|
};
|
|
6052
6359
|
//#endregion
|
|
6053
6360
|
//#region migrate/migrate.ts
|
|
6054
|
-
async function
|
|
6055
|
-
|
|
6056
|
-
let { error: n, results: r } = await new
|
|
6361
|
+
async function ns(e, t = !1) {
|
|
6362
|
+
wo(t), t && console.log("migrating...");
|
|
6363
|
+
let { error: n, results: r } = await new me({
|
|
6057
6364
|
db: e,
|
|
6058
|
-
provider: new
|
|
6365
|
+
provider: new _o(ts)
|
|
6059
6366
|
}).migrateToLatest();
|
|
6060
6367
|
if (r?.forEach((e) => {
|
|
6061
6368
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6062
6369
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6063
6370
|
}
|
|
6064
|
-
async function
|
|
6065
|
-
|
|
6066
|
-
let { error: n, results: r } = await new
|
|
6371
|
+
async function rs(e, t = !1) {
|
|
6372
|
+
wo(t), t && console.log("migrating...");
|
|
6373
|
+
let { error: n, results: r } = await new me({
|
|
6067
6374
|
db: e,
|
|
6068
|
-
provider: new
|
|
6375
|
+
provider: new _o(ts)
|
|
6069
6376
|
}).migrateDown();
|
|
6070
6377
|
if (r?.forEach((e) => {
|
|
6071
6378
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6073,61 +6380,64 @@ async function Oo(e, t = !1) {
|
|
|
6073
6380
|
}
|
|
6074
6381
|
//#endregion
|
|
6075
6382
|
//#region src/index.ts
|
|
6076
|
-
function
|
|
6383
|
+
function is(e, t = { useTransactions: !0 }) {
|
|
6077
6384
|
let n = {
|
|
6078
6385
|
actions: Ne(e),
|
|
6079
|
-
actionExecutions:
|
|
6080
|
-
actionVersions:
|
|
6081
|
-
branding:
|
|
6082
|
-
clients:
|
|
6083
|
-
clientConnections:
|
|
6084
|
-
clientGrants:
|
|
6085
|
-
clientRegistrationTokens:
|
|
6086
|
-
codes:
|
|
6087
|
-
connections:
|
|
6088
|
-
emailProviders:
|
|
6089
|
-
emailTemplates:
|
|
6090
|
-
customDomains:
|
|
6091
|
-
flows:
|
|
6092
|
-
forms:
|
|
6093
|
-
hookCode:
|
|
6094
|
-
hooks:
|
|
6095
|
-
invites:
|
|
6096
|
-
keys:
|
|
6097
|
-
loginSessions:
|
|
6098
|
-
logs:
|
|
6099
|
-
logStreams:
|
|
6100
|
-
migrationSources:
|
|
6101
|
-
authenticationMethods:
|
|
6102
|
-
passwords:
|
|
6103
|
-
promptSettings:
|
|
6386
|
+
actionExecutions: ze(e),
|
|
6387
|
+
actionVersions: Ve(e),
|
|
6388
|
+
branding: Qn(e),
|
|
6389
|
+
clients: mn(e),
|
|
6390
|
+
clientConnections: bn(e),
|
|
6391
|
+
clientGrants: Dn(e),
|
|
6392
|
+
clientRegistrationTokens: Rn(e),
|
|
6393
|
+
codes: Zt(e),
|
|
6394
|
+
connections: on(e),
|
|
6395
|
+
emailProviders: Rr(e),
|
|
6396
|
+
emailTemplates: Gr(e),
|
|
6397
|
+
customDomains: Yn(e),
|
|
6398
|
+
flows: mt(e),
|
|
6399
|
+
forms: ci(e),
|
|
6400
|
+
hookCode: pr(e),
|
|
6401
|
+
hooks: cr(e),
|
|
6402
|
+
invites: sa(e),
|
|
6403
|
+
keys: Hn(e),
|
|
6404
|
+
loginSessions: kr(e),
|
|
6405
|
+
logs: jt(e),
|
|
6406
|
+
logStreams: Ha(e),
|
|
6407
|
+
migrationSources: Ua(e),
|
|
6408
|
+
authenticationMethods: ja(e),
|
|
6409
|
+
passwords: Ht(e),
|
|
6410
|
+
promptSettings: Nr(e),
|
|
6104
6411
|
proxyRoutes: q(e),
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6412
|
+
scimConfigurations: Za(e),
|
|
6413
|
+
scimTokens: Qa(e),
|
|
6414
|
+
scimExternalIds: eo(e),
|
|
6415
|
+
refreshTokens: ei(e),
|
|
6416
|
+
resourceServers: mi(e),
|
|
6417
|
+
rolePermissions: wi(e),
|
|
6418
|
+
grants: Ai(e),
|
|
6419
|
+
userPermissions: Fi(e),
|
|
6420
|
+
userRoles: Vi(e),
|
|
6421
|
+
roles: bi(e),
|
|
6422
|
+
sessions: Lt(e),
|
|
6423
|
+
sessionCleanup: ni(e),
|
|
6424
|
+
tenants: St(e),
|
|
6425
|
+
tenantOperations: to(e),
|
|
6426
|
+
tenantOperationEvents: po(e),
|
|
6427
|
+
rollouts: go(e),
|
|
6428
|
+
themes: vr(e),
|
|
6429
|
+
universalLoginTemplates: nr(e),
|
|
6430
|
+
customText: wa(e),
|
|
6431
|
+
users: ot(e),
|
|
6432
|
+
userActivity: rt(e),
|
|
6433
|
+
organizations: qi(e),
|
|
6434
|
+
organizationConnections: Ji(e),
|
|
6435
|
+
userOrganizations: ta(e),
|
|
6436
|
+
stats: fa(e),
|
|
6437
|
+
analytics: Ca(e),
|
|
6438
|
+
outbox: Va(e),
|
|
6129
6439
|
async transaction(r) {
|
|
6130
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6440
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(is(e, {
|
|
6131
6441
|
...t,
|
|
6132
6442
|
useTransactions: !1
|
|
6133
6443
|
})));
|
|
@@ -6136,4 +6446,4 @@ function ko(e, t = { useTransactions: !0 }) {
|
|
|
6136
6446
|
return n;
|
|
6137
6447
|
}
|
|
6138
6448
|
//#endregion
|
|
6139
|
-
export {
|
|
6449
|
+
export { qa as createProxyDataAdapter, q as createProxyRoutesAdapter, is as default, rs as migrateDown, ns as migrateToLatest };
|