@authhero/kysely-adapter 12.7.0 → 12.8.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.mjs +1095 -976
- package/dist/types/src/cleanup.d.ts +20 -0
- package/dist/types/src/helpers/database-type.d.ts +15 -0
- package/dist/types/src/users/createMany.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { customAlphabet as e, nanoid as t } from "nanoid";
|
|
2
2
|
import { booleanToInt as n, convertDatesToAdapter as r, dbDateToIso as i, dbDateToIsoRequired as a, getCountAsInt as o, isoToDbDate as s, nowIso as c, removeNullProperties as l, removeUndefinedAndNull as u, stringifyProperties as d } from "@authhero/adapter-interfaces/sql";
|
|
3
3
|
import { sql as f } from "kysely";
|
|
4
|
-
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he, splitLuceneOrGroups as ge, tenantOperationEventInsertSchema as _e, tenantOperationEventSchema as ve, tenantOperationInsertSchema as ye, tenantOperationRowInsertSchema as be, tenantOperationRowSchema as xe, tenantOperationSchema as Se, tokenizeLuceneQuery as Ce, unescapeLuceneValue as
|
|
5
|
-
import { HTTPException as
|
|
4
|
+
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he, splitLuceneOrGroups as ge, tenantOperationEventInsertSchema as _e, tenantOperationEventSchema as ve, tenantOperationInsertSchema as ye, tenantOperationRowInsertSchema as be, tenantOperationRowSchema as xe, tenantOperationSchema as Se, tokenizeLuceneQuery as Ce, unescapeLuceneValue as C, unquoteLuceneValue as w } from "@authhero/adapter-interfaces";
|
|
5
|
+
import { HTTPException as T } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as we } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var Te = Object.defineProperty, E = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) Te(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || Te(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, Ee = 17, De = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -25,39 +25,39 @@ var Ee = Object.defineProperty, T = (e, t) => {
|
|
|
25
25
|
guardian_factor: "gfa_",
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
28
|
+
function D(t) {
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", Ee)();
|
|
30
|
+
return `${De[t]}${n}`;
|
|
31
|
+
}
|
|
32
|
+
function Oe() {
|
|
33
|
+
return D("organization");
|
|
31
34
|
}
|
|
32
35
|
function ke() {
|
|
33
|
-
return
|
|
36
|
+
return D("connection");
|
|
34
37
|
}
|
|
35
38
|
function Ae() {
|
|
36
|
-
return
|
|
39
|
+
return D("action");
|
|
37
40
|
}
|
|
38
41
|
function je() {
|
|
39
|
-
return
|
|
42
|
+
return D("action_version");
|
|
40
43
|
}
|
|
41
44
|
function Me() {
|
|
42
|
-
return
|
|
45
|
+
return D("hook");
|
|
43
46
|
}
|
|
44
47
|
function Ne() {
|
|
45
|
-
return
|
|
48
|
+
return D("resource_server");
|
|
46
49
|
}
|
|
47
50
|
function Pe() {
|
|
48
|
-
return
|
|
51
|
+
return D("hook_code");
|
|
49
52
|
}
|
|
50
53
|
function Fe() {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
function Ie() {
|
|
54
|
-
return E("invite");
|
|
54
|
+
return D("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Ie(e) {
|
|
59
59
|
return async (t, n, r) => {
|
|
60
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ??
|
|
60
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ?? Ae();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,14 +91,14 @@ function Le(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function Le(e) {
|
|
95
95
|
if (e) try {
|
|
96
96
|
return JSON.parse(e);
|
|
97
97
|
} catch {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Re(e) {
|
|
102
102
|
return async (t, n) => {
|
|
103
103
|
let i = await e.selectFrom("actions").where("actions.tenant_id", "=", t).where("actions.id", "=", n).selectAll().executeTakeFirst();
|
|
104
104
|
if (!i) return null;
|
|
@@ -113,9 +113,9 @@ function ze(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: Le(c),
|
|
117
|
+
dependencies: Le(l),
|
|
118
|
+
supported_triggers: Le(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -123,16 +123,16 @@ function ze(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function ze(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function O(e, t, n, r, i = [], a = {}) {
|
|
130
130
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
131
131
|
let t = a[e];
|
|
132
132
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
133
133
|
}, l = (e) => {
|
|
134
134
|
let t = a[e];
|
|
135
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
135
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : ze(t);
|
|
136
136
|
}, u = (e, t) => {
|
|
137
137
|
let n = a[e];
|
|
138
138
|
if (n === void 0 || typeof n == "string") return t;
|
|
@@ -146,7 +146,7 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
146
146
|
if (!n) return null;
|
|
147
147
|
let [, r, i] = n;
|
|
148
148
|
if (!r || !i) return null;
|
|
149
|
-
let a = r.trim(), d =
|
|
149
|
+
let a = r.trim(), d = C(i.replace(/^"(.*)"$/, "$1").trim());
|
|
150
150
|
return o.has(a) ? e(s(c(a)), "like", `%${d}%`) : e(l(a), "=", u(a, d));
|
|
151
151
|
}).filter((e) => e !== null);
|
|
152
152
|
return n.length === 0 ? null : n.length === 1 ? n[0] : e.and(n);
|
|
@@ -158,8 +158,8 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
158
158
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
159
159
|
else if (e.includes(":")) {
|
|
160
160
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
161
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
162
|
-
} else n = null, r =
|
|
161
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = C(r);
|
|
162
|
+
} else n = null, r = C(e), i = !1;
|
|
163
163
|
return {
|
|
164
164
|
key: n,
|
|
165
165
|
value: r,
|
|
@@ -199,17 +199,17 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/actions/list.ts
|
|
202
|
-
function
|
|
202
|
+
function k(e) {
|
|
203
203
|
if (e) try {
|
|
204
204
|
return JSON.parse(e);
|
|
205
205
|
} catch {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Be(e) {
|
|
210
210
|
return async (t, n = {}) => {
|
|
211
211
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
212
|
-
c && (l =
|
|
212
|
+
c && (l = O(e, l, c, ["name"]));
|
|
213
213
|
let u = (await l.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
214
214
|
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({
|
|
215
215
|
created_at_ts: n,
|
|
@@ -222,9 +222,9 @@ function He(e) {
|
|
|
222
222
|
runtime: f.runtime ?? void 0,
|
|
223
223
|
status: f.status || "built",
|
|
224
224
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
225
|
-
secrets:
|
|
226
|
-
dependencies:
|
|
227
|
-
supported_triggers:
|
|
225
|
+
secrets: k(o),
|
|
226
|
+
dependencies: k(s),
|
|
227
|
+
supported_triggers: k(c),
|
|
228
228
|
is_system: !!l,
|
|
229
229
|
inherit: !!u
|
|
230
230
|
};
|
|
@@ -246,7 +246,7 @@ function He(e) {
|
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/actions/update.ts
|
|
249
|
-
function
|
|
249
|
+
function Ve(e) {
|
|
250
250
|
if (!e) return [];
|
|
251
251
|
try {
|
|
252
252
|
let t = JSON.parse(e);
|
|
@@ -255,11 +255,11 @@ function Ue(e) {
|
|
|
255
255
|
return [];
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function He(e) {
|
|
259
259
|
return async (t, n, r) => {
|
|
260
260
|
let i = { updated_at_ts: Date.now() };
|
|
261
261
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
262
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
262
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Ve(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
263
263
|
name: e.name,
|
|
264
264
|
value: o.get(e.name)?.value
|
|
265
265
|
} : e);
|
|
@@ -274,23 +274,23 @@ function We(e) {
|
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
276
|
//#region src/actions/remove.ts
|
|
277
|
-
function
|
|
277
|
+
function Ue(e) {
|
|
278
278
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
279
279
|
}
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/actions/index.ts
|
|
282
|
-
function
|
|
282
|
+
function We(e) {
|
|
283
283
|
return {
|
|
284
|
-
create:
|
|
285
|
-
get:
|
|
286
|
-
list:
|
|
287
|
-
update:
|
|
288
|
-
remove:
|
|
284
|
+
create: Ie(e),
|
|
285
|
+
get: Re(e),
|
|
286
|
+
list: Be(e),
|
|
287
|
+
update: He(e),
|
|
288
|
+
remove: Ue(e)
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/actionExecutions/create.ts
|
|
293
|
-
function
|
|
293
|
+
function Ge(e) {
|
|
294
294
|
return async (t, n) => {
|
|
295
295
|
let r = Date.now();
|
|
296
296
|
return await e.insertInto("action_executions").values({
|
|
@@ -316,14 +316,14 @@ function qe(e) {
|
|
|
316
316
|
}
|
|
317
317
|
//#endregion
|
|
318
318
|
//#region src/actionExecutions/get.ts
|
|
319
|
-
function
|
|
319
|
+
function Ke(e) {
|
|
320
320
|
if (e) try {
|
|
321
321
|
return JSON.parse(e);
|
|
322
322
|
} catch {
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function qe(e) {
|
|
327
327
|
return async (t, n) => {
|
|
328
328
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
329
329
|
return r ? {
|
|
@@ -331,35 +331,37 @@ function Ye(e) {
|
|
|
331
331
|
tenant_id: r.tenant_id,
|
|
332
332
|
trigger_id: r.trigger_id,
|
|
333
333
|
status: r.status,
|
|
334
|
-
results:
|
|
335
|
-
logs:
|
|
334
|
+
results: Ke(r.results) ?? [],
|
|
335
|
+
logs: Ke(r.logs),
|
|
336
336
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
337
337
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
338
338
|
} : null;
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
342
|
-
//#region src/
|
|
343
|
-
|
|
344
|
-
async function Ze(e) {
|
|
342
|
+
//#region src/helpers/database-type.ts
|
|
343
|
+
async function Je(e) {
|
|
345
344
|
try {
|
|
346
345
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
347
346
|
} catch {
|
|
348
347
|
return "sqlite";
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
|
-
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/actionExecutions/cleanup.ts
|
|
352
|
+
var A = 5e4;
|
|
353
|
+
function Ye(e) {
|
|
352
354
|
let t;
|
|
353
355
|
return async (n) => {
|
|
354
356
|
let r = Date.parse(n);
|
|
355
357
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
356
|
-
if (t ??= await
|
|
358
|
+
if (t ??= await Je(e), t === "sqlite") {
|
|
357
359
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
358
360
|
return Number(t.numDeletedRows);
|
|
359
361
|
}
|
|
360
|
-
let i = 0, a =
|
|
361
|
-
for (; a >=
|
|
362
|
-
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(
|
|
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();
|
|
363
365
|
a = Number(t.numDeletedRows), i += a;
|
|
364
366
|
}
|
|
365
367
|
return i;
|
|
@@ -367,39 +369,39 @@ function Qe(e) {
|
|
|
367
369
|
}
|
|
368
370
|
//#endregion
|
|
369
371
|
//#region src/actionExecutions/index.ts
|
|
370
|
-
function
|
|
372
|
+
function Xe(e) {
|
|
371
373
|
return {
|
|
372
|
-
create:
|
|
373
|
-
get:
|
|
374
|
-
cleanup:
|
|
374
|
+
create: Ge(e),
|
|
375
|
+
get: qe(e),
|
|
376
|
+
cleanup: Ye(e)
|
|
375
377
|
};
|
|
376
378
|
}
|
|
377
379
|
//#endregion
|
|
378
380
|
//#region src/actionVersions/index.ts
|
|
379
|
-
function
|
|
381
|
+
function Ze(e) {
|
|
380
382
|
if (e) try {
|
|
381
383
|
return JSON.parse(e);
|
|
382
384
|
} catch {
|
|
383
385
|
return;
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
|
-
function
|
|
388
|
+
function Qe(e) {
|
|
387
389
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
388
390
|
return {
|
|
389
391
|
...c,
|
|
390
392
|
runtime: s ?? void 0,
|
|
391
393
|
deployed: !!o,
|
|
392
|
-
secrets:
|
|
393
|
-
dependencies:
|
|
394
|
-
supported_triggers:
|
|
394
|
+
secrets: Ze(r),
|
|
395
|
+
dependencies: Ze(i),
|
|
396
|
+
supported_triggers: Ze(a),
|
|
395
397
|
created_at: new Date(Number(t)).toISOString(),
|
|
396
398
|
updated_at: new Date(Number(n)).toISOString()
|
|
397
399
|
};
|
|
398
400
|
}
|
|
399
|
-
function
|
|
401
|
+
function $e(e) {
|
|
400
402
|
return {
|
|
401
403
|
async create(t, n, r) {
|
|
402
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ??
|
|
404
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? je(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
403
405
|
let r = ((await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n.action_id).select("number").orderBy("number", "desc").limit(1).executeTakeFirst())?.number ?? 0) + 1;
|
|
404
406
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
405
407
|
deployed: 0,
|
|
@@ -436,10 +438,10 @@ function nt(e) {
|
|
|
436
438
|
},
|
|
437
439
|
async get(t, n, r) {
|
|
438
440
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
439
|
-
return i ?
|
|
441
|
+
return i ? Qe(i) : null;
|
|
440
442
|
},
|
|
441
443
|
async list(t, n, r = {}) {
|
|
442
|
-
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(Qe);
|
|
443
445
|
if (!s) return {
|
|
444
446
|
versions: l,
|
|
445
447
|
start: 0,
|
|
@@ -462,7 +464,7 @@ function nt(e) {
|
|
|
462
464
|
}
|
|
463
465
|
//#endregion
|
|
464
466
|
//#region src/outbox/create.ts
|
|
465
|
-
async function
|
|
467
|
+
async function j(e, t, n, r) {
|
|
466
468
|
await e.insertInto("outbox_events").values({
|
|
467
469
|
id: n,
|
|
468
470
|
tenant_id: t,
|
|
@@ -481,15 +483,15 @@ async function O(e, t, n, r) {
|
|
|
481
483
|
error: null
|
|
482
484
|
}).execute();
|
|
483
485
|
}
|
|
484
|
-
function
|
|
486
|
+
function et(e) {
|
|
485
487
|
return async (n, r) => {
|
|
486
488
|
let i = t();
|
|
487
|
-
return await
|
|
489
|
+
return await j(e, n, i, r), i;
|
|
488
490
|
};
|
|
489
491
|
}
|
|
490
492
|
//#endregion
|
|
491
493
|
//#region src/users/create.ts
|
|
492
|
-
function
|
|
494
|
+
function tt(e) {
|
|
493
495
|
return async (n, r, i) => {
|
|
494
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 = {
|
|
495
497
|
...f,
|
|
@@ -524,12 +526,12 @@ function it(e) {
|
|
|
524
526
|
};
|
|
525
527
|
await e.insertInto("passwords").values(r).execute();
|
|
526
528
|
}
|
|
527
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await j(e, n, t.id, t);
|
|
528
530
|
};
|
|
529
531
|
try {
|
|
530
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
531
533
|
} catch (e) {
|
|
532
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
534
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new T(409, { message: "User already exists" }) : new T(500, { message: `${e.code}, ${e.message}` });
|
|
533
535
|
}
|
|
534
536
|
return {
|
|
535
537
|
...m,
|
|
@@ -548,22 +550,86 @@ function it(e) {
|
|
|
548
550
|
};
|
|
549
551
|
}
|
|
550
552
|
//#endregion
|
|
553
|
+
//#region src/users/createMany.ts
|
|
554
|
+
var M = 500;
|
|
555
|
+
function nt(e) {
|
|
556
|
+
let t = e;
|
|
557
|
+
return t.identities !== void 0 || t.last_login !== void 0 || t.last_ip !== void 0 || t.login_count !== void 0;
|
|
558
|
+
}
|
|
559
|
+
function rt(e) {
|
|
560
|
+
return async (n, r, i) => {
|
|
561
|
+
if (r.length === 0) return [];
|
|
562
|
+
if (i?.outboxEvents?.length) throw new T(400, { message: "createMany does not persist outbox events; use create for those users" });
|
|
563
|
+
if (r.find(nt)) throw new T(400, { message: "createMany does not write identities or activity counters; use create for those users" });
|
|
564
|
+
let a = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => {
|
|
565
|
+
let { identities: r, phone_verified: i, password: o, last_login: s, last_ip: c, login_count: l, ...u } = e, d = {
|
|
566
|
+
...u,
|
|
567
|
+
created_at: u.created_at ?? a,
|
|
568
|
+
updated_at: u.updated_at ?? a,
|
|
569
|
+
user_id: u.user_id,
|
|
570
|
+
tenant_id: n,
|
|
571
|
+
email_verified: +!!e.email_verified,
|
|
572
|
+
phone_verified: i === void 0 ? null : +!!i,
|
|
573
|
+
is_social: +!!e.is_social,
|
|
574
|
+
blocked: +!!e.blocked,
|
|
575
|
+
app_metadata: JSON.stringify(e.app_metadata),
|
|
576
|
+
user_metadata: JSON.stringify(e.user_metadata),
|
|
577
|
+
address: e.address ? JSON.stringify(e.address) : null
|
|
578
|
+
};
|
|
579
|
+
return {
|
|
580
|
+
sqlUser: d,
|
|
581
|
+
passwordRecord: o && d.user_id ? {
|
|
582
|
+
id: t(),
|
|
583
|
+
user_id: d.user_id,
|
|
584
|
+
password: o.hash,
|
|
585
|
+
algorithm: o.algorithm,
|
|
586
|
+
is_current: 1,
|
|
587
|
+
created_at: a,
|
|
588
|
+
updated_at: a,
|
|
589
|
+
tenant_id: n
|
|
590
|
+
} : void 0,
|
|
591
|
+
original: e
|
|
592
|
+
};
|
|
593
|
+
}), s = o.map((e) => e.sqlUser), c = o.map((e) => e.passwordRecord).filter((e) => e !== void 0), l = async (e) => {
|
|
594
|
+
for (let t = 0; t < s.length; t += M) await e.insertInto("users").values(s.slice(t, t + M)).execute();
|
|
595
|
+
for (let t = 0; t < c.length; t += M) await e.insertInto("passwords").values(c.slice(t, t + M)).execute();
|
|
596
|
+
};
|
|
597
|
+
try {
|
|
598
|
+
e.isTransaction ? await l(e) : await e.transaction().execute(l);
|
|
599
|
+
} catch (e) {
|
|
600
|
+
let t = e?.code, n = e instanceof Error ? e.message : String(e);
|
|
601
|
+
throw t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || n.includes("AlreadyExists") ? new T(409, { message: "User already exists" }) : new T(500, { message: `${String(t)}, ${n}` });
|
|
602
|
+
}
|
|
603
|
+
return o.map(({ sqlUser: e, original: t }) => ({
|
|
604
|
+
...e,
|
|
605
|
+
login_count: 0,
|
|
606
|
+
email_verified: !!e.email_verified,
|
|
607
|
+
is_social: !!e.is_social,
|
|
608
|
+
blocked: !!e.blocked,
|
|
609
|
+
phone_verified: e.phone_verified === null ? void 0 : !!e.phone_verified,
|
|
610
|
+
app_metadata: t.app_metadata,
|
|
611
|
+
user_metadata: t.user_metadata,
|
|
612
|
+
address: t.address
|
|
613
|
+
}));
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
551
617
|
//#region src/users/user-to-identity.ts
|
|
552
|
-
var
|
|
618
|
+
var it = [
|
|
553
619
|
"email",
|
|
554
620
|
"email_verified",
|
|
555
621
|
"phone_number",
|
|
556
622
|
"phone_verified",
|
|
557
623
|
"username"
|
|
558
624
|
];
|
|
559
|
-
function
|
|
625
|
+
function N(e, t = !1) {
|
|
560
626
|
let n = {
|
|
561
627
|
connection: e.connection,
|
|
562
628
|
provider: e.provider,
|
|
563
629
|
user_id: ue(e.user_id).id,
|
|
564
630
|
isSocial: !!e.is_social
|
|
565
631
|
};
|
|
566
|
-
for (let t of
|
|
632
|
+
for (let t of it) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
567
633
|
if (!t) {
|
|
568
634
|
let t = {};
|
|
569
635
|
try {
|
|
@@ -581,7 +647,7 @@ function k(e, t = !1) {
|
|
|
581
647
|
}
|
|
582
648
|
//#endregion
|
|
583
649
|
//#region src/users/get.ts
|
|
584
|
-
function
|
|
650
|
+
function at(e) {
|
|
585
651
|
return async (t, n) => {
|
|
586
652
|
let [r, i] = await Promise.all([e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t).where("users.user_id", "=", n).selectAll("users").select([
|
|
587
653
|
"user_activity.last_login",
|
|
@@ -603,22 +669,22 @@ function ot(e) {
|
|
|
603
669
|
app_metadata: JSON.parse(r.app_metadata),
|
|
604
670
|
user_metadata: JSON.parse(r.user_metadata),
|
|
605
671
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
606
|
-
identities: [
|
|
672
|
+
identities: [N(r, !0), ...i.map((e) => N(e))]
|
|
607
673
|
});
|
|
608
674
|
};
|
|
609
675
|
}
|
|
610
676
|
//#endregion
|
|
611
677
|
//#region src/helpers/paginate.ts
|
|
612
|
-
function
|
|
678
|
+
function P(e) {
|
|
613
679
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
614
680
|
}
|
|
615
|
-
function
|
|
681
|
+
function ot(e, t) {
|
|
616
682
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
617
683
|
return n >= 1 ? n : t;
|
|
618
684
|
}
|
|
619
|
-
async function
|
|
620
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
621
|
-
if (c && c.k !== n.sortKey) throw new
|
|
685
|
+
async function F(e, t, n) {
|
|
686
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = ot(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
687
|
+
if (c && c.k !== n.sortKey) throw new T(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
622
688
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
623
689
|
else {
|
|
624
690
|
let e = i === "asc" ? f.raw(">") : f.raw("<");
|
|
@@ -641,7 +707,7 @@ async function j(e, t, n) {
|
|
|
641
707
|
}
|
|
642
708
|
//#endregion
|
|
643
709
|
//#region src/users/list.ts
|
|
644
|
-
var
|
|
710
|
+
var st = [
|
|
645
711
|
"user_id",
|
|
646
712
|
"email",
|
|
647
713
|
"email_verified",
|
|
@@ -664,20 +730,20 @@ var ct = [
|
|
|
664
730
|
"login_count",
|
|
665
731
|
"created_at",
|
|
666
732
|
"updated_at"
|
|
667
|
-
],
|
|
733
|
+
], ct = new Set([
|
|
668
734
|
"last_login",
|
|
669
735
|
"last_ip",
|
|
670
736
|
"login_count"
|
|
671
|
-
]),
|
|
737
|
+
]), lt = Object.fromEntries(st.map((e) => [e, e === "login_count" ? {
|
|
672
738
|
column: "user_activity.login_count",
|
|
673
739
|
defaultValue: 0
|
|
674
|
-
} :
|
|
740
|
+
} : ct.has(e) ? `user_activity.${e}` : `users.${e}`])), ut = [
|
|
675
741
|
"email",
|
|
676
742
|
"name",
|
|
677
743
|
"phone_number",
|
|
678
744
|
"user_id"
|
|
679
745
|
];
|
|
680
|
-
async function
|
|
746
|
+
async function dt(e, t, n) {
|
|
681
747
|
let r = n.map((e) => e.user_id), i = r.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", r).orderBy("created_at", "asc").execute() : [];
|
|
682
748
|
return n.map((e) => {
|
|
683
749
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -691,20 +757,20 @@ async function ft(e, t, n) {
|
|
|
691
757
|
app_metadata: JSON.parse(e.app_metadata),
|
|
692
758
|
user_metadata: JSON.parse(e.user_metadata),
|
|
693
759
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
694
|
-
identities: [
|
|
760
|
+
identities: [N(e, !0), ...t.map((e) => N(e))]
|
|
695
761
|
});
|
|
696
762
|
});
|
|
697
763
|
}
|
|
698
|
-
function
|
|
764
|
+
function ft(e) {
|
|
699
765
|
return async (t, n = {}) => {
|
|
700
766
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t);
|
|
701
767
|
if (c) {
|
|
702
|
-
let t = S(c,
|
|
703
|
-
t && (l =
|
|
768
|
+
let t = S(c, st);
|
|
769
|
+
t && (l = O(e, l, t, ut, [], lt));
|
|
704
770
|
}
|
|
705
|
-
if (
|
|
706
|
-
if (s?.sort_by && s.sort_by !== "created_at") throw new
|
|
707
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
771
|
+
if (P(n)) {
|
|
772
|
+
if (s?.sort_by && s.sort_by !== "created_at") throw new T(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
773
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await F(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
708
774
|
"user_activity.last_login",
|
|
709
775
|
"user_activity.last_ip",
|
|
710
776
|
"user_activity.login_count"
|
|
@@ -713,7 +779,7 @@ function pt(e) {
|
|
|
713
779
|
sortOrder: r,
|
|
714
780
|
idColumn: "users.user_id",
|
|
715
781
|
sortKey: `created_at:${r}`
|
|
716
|
-
}), c = await
|
|
782
|
+
}), c = await dt(e, t, i);
|
|
717
783
|
return {
|
|
718
784
|
users: c,
|
|
719
785
|
start: 0,
|
|
@@ -723,17 +789,17 @@ function pt(e) {
|
|
|
723
789
|
};
|
|
724
790
|
}
|
|
725
791
|
if (s && s.sort_by) {
|
|
726
|
-
let t =
|
|
792
|
+
let t = lt[s.sort_by];
|
|
727
793
|
if (t) {
|
|
728
794
|
let { ref: n } = e.dynamic;
|
|
729
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
795
|
+
l = l.orderBy(typeof t == "string" ? n(t) : ze(t), s.sort_order);
|
|
730
796
|
}
|
|
731
797
|
}
|
|
732
798
|
let u = l.offset(r * i).limit(i), [d, f] = await Promise.all([u.selectAll("users").select([
|
|
733
799
|
"user_activity.last_login",
|
|
734
800
|
"user_activity.last_ip",
|
|
735
801
|
"user_activity.login_count"
|
|
736
|
-
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await
|
|
802
|
+
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await dt(e, t, d);
|
|
737
803
|
if (!f) return {
|
|
738
804
|
users: p,
|
|
739
805
|
start: 0,
|
|
@@ -751,12 +817,12 @@ function pt(e) {
|
|
|
751
817
|
}
|
|
752
818
|
//#endregion
|
|
753
819
|
//#region src/users/remove.ts
|
|
754
|
-
function
|
|
820
|
+
function pt(e) {
|
|
755
821
|
return async (t, n, r) => {
|
|
756
822
|
let i = async (e) => {
|
|
757
823
|
await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "in", (e) => e.selectFrom("users").select("users.user_id").where("users.tenant_id", "=", t).where((e) => e.or([e("users.user_id", "=", n), e("users.linked_to", "=", n)]))).execute(), await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.linked_to", "=", n).execute();
|
|
758
824
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
759
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
825
|
+
for (let n of r?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
760
826
|
return i.length === 1;
|
|
761
827
|
};
|
|
762
828
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -764,14 +830,14 @@ function mt(e) {
|
|
|
764
830
|
}
|
|
765
831
|
//#endregion
|
|
766
832
|
//#region src/utils/flatten.ts
|
|
767
|
-
function
|
|
833
|
+
function I(e, t = "", n = {}) {
|
|
768
834
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
769
835
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
770
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
836
|
+
typeof a == "object" && a && !Array.isArray(a) ? I(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
771
837
|
}
|
|
772
838
|
return n;
|
|
773
839
|
}
|
|
774
|
-
function
|
|
840
|
+
function mt(e, t) {
|
|
775
841
|
let n = {};
|
|
776
842
|
for (let [r, i] of Object.entries(e)) {
|
|
777
843
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -788,7 +854,7 @@ function ht(e, t) {
|
|
|
788
854
|
}
|
|
789
855
|
//#endregion
|
|
790
856
|
//#region src/userActivity/index.ts
|
|
791
|
-
function
|
|
857
|
+
function ht(e) {
|
|
792
858
|
return {
|
|
793
859
|
user_id: e.user_id,
|
|
794
860
|
last_login: e.last_login ?? void 0,
|
|
@@ -798,18 +864,18 @@ function gt(e) {
|
|
|
798
864
|
last_password_reset: e.last_password_reset ?? void 0
|
|
799
865
|
};
|
|
800
866
|
}
|
|
801
|
-
function
|
|
867
|
+
function gt(e) {
|
|
802
868
|
let t = {};
|
|
803
869
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
804
870
|
}
|
|
805
|
-
function
|
|
871
|
+
function _t(e) {
|
|
806
872
|
return {
|
|
807
873
|
async get(t, n) {
|
|
808
874
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
809
|
-
return r ?
|
|
875
|
+
return r ? ht(r) : null;
|
|
810
876
|
},
|
|
811
877
|
async upsert(t, n, r) {
|
|
812
|
-
let i =
|
|
878
|
+
let i = gt(r);
|
|
813
879
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
814
880
|
if (Object.keys(i).length === 0) return;
|
|
815
881
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -831,9 +897,9 @@ function vt(e) {
|
|
|
831
897
|
}
|
|
832
898
|
//#endregion
|
|
833
899
|
//#region src/users/update.ts
|
|
834
|
-
function
|
|
900
|
+
function vt(e) {
|
|
835
901
|
return async (t, n, r, i) => {
|
|
836
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
902
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = I({
|
|
837
903
|
...c,
|
|
838
904
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
839
905
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -844,12 +910,12 @@ function yt(e) {
|
|
|
844
910
|
}), u = async (e) => {
|
|
845
911
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
846
912
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
847
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
913
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await _t(e).upsert(t, n, {
|
|
848
914
|
last_login: a,
|
|
849
915
|
last_ip: o,
|
|
850
916
|
login_count: s
|
|
851
917
|
});
|
|
852
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
918
|
+
for (let n of i?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
853
919
|
return !0;
|
|
854
920
|
};
|
|
855
921
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -857,26 +923,27 @@ function yt(e) {
|
|
|
857
923
|
}
|
|
858
924
|
//#endregion
|
|
859
925
|
//#region src/users/unlink.ts
|
|
860
|
-
function
|
|
926
|
+
function yt(e) {
|
|
861
927
|
return async (t, n, r, i) => (await e.updateTable("users").set({ linked_to: null }).where("users.tenant_id", "=", t).where("users.user_id", "=", `${r}|${i}`).where("users.linked_to", "=", `${n}`).execute()).length === 1;
|
|
862
928
|
}
|
|
863
929
|
//#endregion
|
|
864
930
|
//#region src/users/index.ts
|
|
865
|
-
function
|
|
866
|
-
let t =
|
|
931
|
+
function bt(e) {
|
|
932
|
+
let t = tt(e);
|
|
867
933
|
return {
|
|
868
934
|
create: t,
|
|
869
935
|
rawCreate: t,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
936
|
+
createMany: rt(e),
|
|
937
|
+
remove: pt(e),
|
|
938
|
+
get: at(e),
|
|
939
|
+
list: ft(e),
|
|
940
|
+
update: vt(e),
|
|
941
|
+
unlink: yt(e)
|
|
875
942
|
};
|
|
876
943
|
}
|
|
877
944
|
//#endregion
|
|
878
945
|
//#region src/flows/create.ts
|
|
879
|
-
function
|
|
946
|
+
function xt(e) {
|
|
880
947
|
return async (n, r, i) => {
|
|
881
948
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
882
949
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -894,7 +961,7 @@ function St(e) {
|
|
|
894
961
|
}
|
|
895
962
|
//#endregion
|
|
896
963
|
//#region src/helpers/parse.ts
|
|
897
|
-
function
|
|
964
|
+
function L(e, t) {
|
|
898
965
|
if (!e) return t;
|
|
899
966
|
try {
|
|
900
967
|
return JSON.parse(e);
|
|
@@ -902,7 +969,7 @@ function N(e, t) {
|
|
|
902
969
|
return t;
|
|
903
970
|
}
|
|
904
971
|
}
|
|
905
|
-
function
|
|
972
|
+
function St(e) {
|
|
906
973
|
if (e) try {
|
|
907
974
|
let t = JSON.parse(e);
|
|
908
975
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -910,33 +977,33 @@ function Ct(e) {
|
|
|
910
977
|
return;
|
|
911
978
|
}
|
|
912
979
|
}
|
|
913
|
-
function
|
|
914
|
-
for (let r in t) r in e && (n[r] =
|
|
980
|
+
function Ct(e, t, n = { ...e }) {
|
|
981
|
+
for (let r in t) r in e && (n[r] = L(e[r], t[r]));
|
|
915
982
|
return n;
|
|
916
983
|
}
|
|
917
984
|
//#endregion
|
|
918
985
|
//#region src/flows/get.ts
|
|
919
|
-
function
|
|
986
|
+
function wt(e) {
|
|
920
987
|
return async (t, n) => {
|
|
921
988
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
922
989
|
if (!r) return null;
|
|
923
990
|
let i = {
|
|
924
991
|
...r,
|
|
925
|
-
actions:
|
|
992
|
+
actions: L(r.actions, [])
|
|
926
993
|
};
|
|
927
994
|
return b.parse(l(i));
|
|
928
995
|
};
|
|
929
996
|
}
|
|
930
997
|
//#endregion
|
|
931
998
|
//#region src/flows/list.ts
|
|
932
|
-
function
|
|
999
|
+
function Tt(e) {
|
|
933
1000
|
return async (t, n = {}) => {
|
|
934
1001
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
935
|
-
s && (c =
|
|
1002
|
+
s && (c = O(e, c, s, []));
|
|
936
1003
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
937
1004
|
let t = {
|
|
938
1005
|
...e,
|
|
939
|
-
actions:
|
|
1006
|
+
actions: L(e.actions, [])
|
|
940
1007
|
};
|
|
941
1008
|
return b.parse(l(t));
|
|
942
1009
|
});
|
|
@@ -957,7 +1024,7 @@ function Et(e) {
|
|
|
957
1024
|
}
|
|
958
1025
|
//#endregion
|
|
959
1026
|
//#region src/flows/update.ts
|
|
960
|
-
function
|
|
1027
|
+
function Et(e) {
|
|
961
1028
|
return async (t, n, r) => {
|
|
962
1029
|
let i = {
|
|
963
1030
|
...r,
|
|
@@ -975,27 +1042,27 @@ function Dt(e) {
|
|
|
975
1042
|
}
|
|
976
1043
|
//#endregion
|
|
977
1044
|
//#region src/flows/remove.ts
|
|
978
|
-
function
|
|
1045
|
+
function Dt(e) {
|
|
979
1046
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
980
1047
|
}
|
|
981
1048
|
//#endregion
|
|
982
1049
|
//#region src/flows/index.ts
|
|
983
|
-
function
|
|
1050
|
+
function Ot(e) {
|
|
984
1051
|
return {
|
|
985
|
-
create:
|
|
986
|
-
get:
|
|
987
|
-
list:
|
|
988
|
-
update:
|
|
989
|
-
remove:
|
|
1052
|
+
create: xt(e),
|
|
1053
|
+
get: wt(e),
|
|
1054
|
+
list: Tt(e),
|
|
1055
|
+
update: Et(e),
|
|
1056
|
+
remove: Dt(e)
|
|
990
1057
|
};
|
|
991
1058
|
}
|
|
992
1059
|
//#endregion
|
|
993
1060
|
//#region src/tenants/utils.ts
|
|
994
|
-
function
|
|
1061
|
+
function kt(e) {
|
|
995
1062
|
let t = { ...e };
|
|
996
1063
|
return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(e.sandbox_versions_available)), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.attack_protection && typeof e.attack_protection == "string" && (t.attack_protection = JSON.parse(e.attack_protection)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), l(t);
|
|
997
1064
|
}
|
|
998
|
-
function
|
|
1065
|
+
function At(e) {
|
|
999
1066
|
let t = { ...e };
|
|
1000
1067
|
return d(e, [
|
|
1001
1068
|
"session_cookie",
|
|
@@ -1018,42 +1085,42 @@ function jt(e) {
|
|
|
1018
1085
|
}
|
|
1019
1086
|
//#endregion
|
|
1020
1087
|
//#region src/tenants/create.ts
|
|
1021
|
-
function
|
|
1088
|
+
function jt(e) {
|
|
1022
1089
|
return async (n, r) => {
|
|
1023
1090
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
1024
1091
|
...n,
|
|
1025
1092
|
id: i?.id ?? n.id ?? t(),
|
|
1026
1093
|
created_at: i?.created_at ?? a,
|
|
1027
1094
|
updated_at: i?.updated_at ?? a
|
|
1028
|
-
}, s =
|
|
1095
|
+
}, s = At(o);
|
|
1029
1096
|
try {
|
|
1030
1097
|
await e.insertInto("tenants").values(s).execute();
|
|
1031
1098
|
} catch (e) {
|
|
1032
1099
|
let t = e?.message ?? "";
|
|
1033
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
1100
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new T(409, { message: `Tenant with ID '${o.id}' already exists` }) : e;
|
|
1034
1101
|
}
|
|
1035
1102
|
return o;
|
|
1036
1103
|
};
|
|
1037
1104
|
}
|
|
1038
1105
|
//#endregion
|
|
1039
1106
|
//#region src/tenants/get.ts
|
|
1040
|
-
function
|
|
1107
|
+
function Mt(e) {
|
|
1041
1108
|
return async (t) => {
|
|
1042
1109
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1043
|
-
return n ?
|
|
1110
|
+
return n ? kt(n) : null;
|
|
1044
1111
|
};
|
|
1045
1112
|
}
|
|
1046
1113
|
//#endregion
|
|
1047
1114
|
//#region src/tenants/list.ts
|
|
1048
|
-
function
|
|
1115
|
+
function Nt(e) {
|
|
1049
1116
|
return async (t) => {
|
|
1050
1117
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1051
1118
|
if (s && s.sort_by) {
|
|
1052
1119
|
let { ref: t } = e.dynamic;
|
|
1053
1120
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1054
1121
|
}
|
|
1055
|
-
c && (n =
|
|
1056
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1122
|
+
c && (n = O(e, n, c, ["friendly_name"]));
|
|
1123
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(kt);
|
|
1057
1124
|
if (!a) return { tenants: l };
|
|
1058
1125
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1059
1126
|
return {
|
|
@@ -1066,10 +1133,10 @@ function Pt(e) {
|
|
|
1066
1133
|
}
|
|
1067
1134
|
//#endregion
|
|
1068
1135
|
//#region src/tenants/update.ts
|
|
1069
|
-
function
|
|
1136
|
+
function Pt(e) {
|
|
1070
1137
|
return async (t, n) => {
|
|
1071
1138
|
let r = {
|
|
1072
|
-
...
|
|
1139
|
+
...At(n),
|
|
1073
1140
|
id: t,
|
|
1074
1141
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1075
1142
|
};
|
|
@@ -1078,29 +1145,29 @@ function Ft(e) {
|
|
|
1078
1145
|
}
|
|
1079
1146
|
//#endregion
|
|
1080
1147
|
//#region src/tenants/remove.ts
|
|
1081
|
-
function
|
|
1148
|
+
function Ft(e) {
|
|
1082
1149
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1083
1150
|
}
|
|
1084
1151
|
//#endregion
|
|
1085
1152
|
//#region src/tenants/index.ts
|
|
1086
|
-
function
|
|
1153
|
+
function It(e) {
|
|
1087
1154
|
return {
|
|
1088
|
-
create:
|
|
1089
|
-
get:
|
|
1090
|
-
list:
|
|
1091
|
-
update:
|
|
1092
|
-
remove:
|
|
1155
|
+
create: jt(e),
|
|
1156
|
+
get: Mt(e),
|
|
1157
|
+
list: Nt(e),
|
|
1158
|
+
update: Pt(e),
|
|
1159
|
+
remove: Ft(e)
|
|
1093
1160
|
};
|
|
1094
1161
|
}
|
|
1095
1162
|
//#endregion
|
|
1096
1163
|
//#region src/logs/create.ts
|
|
1097
|
-
function
|
|
1164
|
+
function Lt(e) {
|
|
1098
1165
|
return e ? JSON.stringify(e) : void 0;
|
|
1099
1166
|
}
|
|
1100
|
-
var
|
|
1101
|
-
function
|
|
1167
|
+
var Rt = 256;
|
|
1168
|
+
function zt(e) {
|
|
1102
1169
|
return async (n, r) => {
|
|
1103
|
-
let i = r.user_agent?.slice(0,
|
|
1170
|
+
let i = r.user_agent?.slice(0, Rt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1104
1171
|
return await e.insertInto("logs").values({
|
|
1105
1172
|
...s,
|
|
1106
1173
|
log_id: a,
|
|
@@ -1109,8 +1176,8 @@ function Bt(e) {
|
|
|
1109
1176
|
description: r.description?.substring(0, 256),
|
|
1110
1177
|
isMobile: +!!r.isMobile,
|
|
1111
1178
|
scope: r.scope,
|
|
1112
|
-
auth0_client:
|
|
1113
|
-
details:
|
|
1179
|
+
auth0_client: Lt(r.auth0_client),
|
|
1180
|
+
details: Lt(r.details)?.substring(0, 8192),
|
|
1114
1181
|
country_code: o?.country_code,
|
|
1115
1182
|
city_name: o?.city_name,
|
|
1116
1183
|
latitude: o?.latitude,
|
|
@@ -1126,7 +1193,7 @@ function Bt(e) {
|
|
|
1126
1193
|
}
|
|
1127
1194
|
//#endregion
|
|
1128
1195
|
//#region src/logs/logs.ts
|
|
1129
|
-
function
|
|
1196
|
+
function Bt(e) {
|
|
1130
1197
|
if (!e) return "";
|
|
1131
1198
|
try {
|
|
1132
1199
|
return JSON.parse(e);
|
|
@@ -1134,13 +1201,13 @@ function Vt(e) {
|
|
|
1134
1201
|
return e;
|
|
1135
1202
|
}
|
|
1136
1203
|
}
|
|
1137
|
-
function
|
|
1204
|
+
function R(e) {
|
|
1138
1205
|
return {
|
|
1139
1206
|
...e,
|
|
1140
1207
|
client_id: e.client_id,
|
|
1141
1208
|
client_name: e.client_name || "",
|
|
1142
|
-
auth0_client:
|
|
1143
|
-
details:
|
|
1209
|
+
auth0_client: Bt(e.auth0_client),
|
|
1210
|
+
details: Bt(e.details),
|
|
1144
1211
|
isMobile: !!e.isMobile,
|
|
1145
1212
|
scope: e.scope || void 0,
|
|
1146
1213
|
log_id: e.log_id,
|
|
@@ -1156,7 +1223,7 @@ function P(e) {
|
|
|
1156
1223
|
}
|
|
1157
1224
|
//#endregion
|
|
1158
1225
|
//#region src/logs/list.ts
|
|
1159
|
-
var
|
|
1226
|
+
var Vt = [
|
|
1160
1227
|
"user_id",
|
|
1161
1228
|
"ip",
|
|
1162
1229
|
"type",
|
|
@@ -1182,25 +1249,25 @@ var Ht = [
|
|
|
1182
1249
|
"time_zone",
|
|
1183
1250
|
"continent_code"
|
|
1184
1251
|
];
|
|
1185
|
-
function
|
|
1252
|
+
function Ht(e) {
|
|
1186
1253
|
return async (t, n = {}) => {
|
|
1187
1254
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, from_date: l, to_date: u } = n, d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
1188
1255
|
if (c) {
|
|
1189
|
-
let t = S(c,
|
|
1190
|
-
t && (d =
|
|
1256
|
+
let t = S(c, Vt);
|
|
1257
|
+
t && (d = O(e, d, t, [
|
|
1191
1258
|
"user_id",
|
|
1192
1259
|
"ip",
|
|
1193
1260
|
"description"
|
|
1194
1261
|
], ["description"]));
|
|
1195
1262
|
}
|
|
1196
|
-
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())),
|
|
1197
|
-
if (s?.sort_by && s.sort_by !== "date") throw new
|
|
1198
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1263
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), P(n)) {
|
|
1264
|
+
if (s?.sort_by && s.sort_by !== "date") throw new T(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1265
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await F(d.selectAll(), n, {
|
|
1199
1266
|
sortColumn: "date",
|
|
1200
1267
|
sortOrder: e,
|
|
1201
1268
|
idColumn: "log_id",
|
|
1202
1269
|
sortKey: `date:${e}`
|
|
1203
|
-
}), a = t.map(
|
|
1270
|
+
}), a = t.map(R);
|
|
1204
1271
|
return {
|
|
1205
1272
|
logs: a,
|
|
1206
1273
|
start: 0,
|
|
@@ -1215,7 +1282,7 @@ function Ut(e) {
|
|
|
1215
1282
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1216
1283
|
}
|
|
1217
1284
|
f = f.offset(r * i).limit(i);
|
|
1218
|
-
let p = (await f.selectAll().execute()).map(
|
|
1285
|
+
let p = (await f.selectAll().execute()).map(R);
|
|
1219
1286
|
if (!a) return {
|
|
1220
1287
|
logs: p,
|
|
1221
1288
|
start: 0,
|
|
@@ -1233,24 +1300,24 @@ function Ut(e) {
|
|
|
1233
1300
|
}
|
|
1234
1301
|
//#endregion
|
|
1235
1302
|
//#region src/logs/get.ts
|
|
1236
|
-
function
|
|
1303
|
+
function Ut(e) {
|
|
1237
1304
|
return async (t, n) => {
|
|
1238
1305
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1239
|
-
return r ?
|
|
1306
|
+
return r ? R(r) : null;
|
|
1240
1307
|
};
|
|
1241
1308
|
}
|
|
1242
1309
|
//#endregion
|
|
1243
1310
|
//#region src/logs/index.ts
|
|
1244
|
-
function
|
|
1311
|
+
function Wt(e) {
|
|
1245
1312
|
return {
|
|
1246
|
-
create:
|
|
1247
|
-
list:
|
|
1248
|
-
get:
|
|
1313
|
+
create: zt(e),
|
|
1314
|
+
list: Ht(e),
|
|
1315
|
+
get: Ut(e)
|
|
1249
1316
|
};
|
|
1250
1317
|
}
|
|
1251
1318
|
//#endregion
|
|
1252
1319
|
//#region src/sessions/get.ts
|
|
1253
|
-
function
|
|
1320
|
+
function Gt(e) {
|
|
1254
1321
|
return async (t, n) => {
|
|
1255
1322
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1256
1323
|
if (!i) return null;
|
|
@@ -1284,7 +1351,7 @@ function Kt(e) {
|
|
|
1284
1351
|
}
|
|
1285
1352
|
//#endregion
|
|
1286
1353
|
//#region src/sessions/create.ts
|
|
1287
|
-
function
|
|
1354
|
+
function Kt(e) {
|
|
1288
1355
|
return async (t, n) => {
|
|
1289
1356
|
let r = Date.now(), i = c(), a = {
|
|
1290
1357
|
...n,
|
|
@@ -1316,12 +1383,12 @@ function qt(e) {
|
|
|
1316
1383
|
}
|
|
1317
1384
|
//#endregion
|
|
1318
1385
|
//#region src/sessions/remove.ts
|
|
1319
|
-
function
|
|
1386
|
+
function qt(e) {
|
|
1320
1387
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1321
1388
|
}
|
|
1322
1389
|
//#endregion
|
|
1323
1390
|
//#region src/sessions/update.ts
|
|
1324
|
-
function
|
|
1391
|
+
function Jt(e) {
|
|
1325
1392
|
return async (t, n, r) => {
|
|
1326
1393
|
let i = Date.now(), a = {
|
|
1327
1394
|
updated_at_ts: i,
|
|
@@ -1342,10 +1409,10 @@ function Yt(e) {
|
|
|
1342
1409
|
}
|
|
1343
1410
|
//#endregion
|
|
1344
1411
|
//#region src/sessions/list.ts
|
|
1345
|
-
function
|
|
1412
|
+
function Yt(e) {
|
|
1346
1413
|
return async (t, n = {}) => {
|
|
1347
1414
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
1348
|
-
l && (u =
|
|
1415
|
+
l && (u = O(e, u, l, ["user_id", "session_id"]));
|
|
1349
1416
|
let d = u;
|
|
1350
1417
|
if (c && c.sort_by) {
|
|
1351
1418
|
let { ref: t } = e.dynamic;
|
|
@@ -1397,18 +1464,18 @@ function Xt(e) {
|
|
|
1397
1464
|
}
|
|
1398
1465
|
//#endregion
|
|
1399
1466
|
//#region src/sessions/index.ts
|
|
1400
|
-
function
|
|
1467
|
+
function Xt(e) {
|
|
1401
1468
|
return {
|
|
1402
|
-
create:
|
|
1403
|
-
get:
|
|
1404
|
-
list:
|
|
1405
|
-
remove:
|
|
1406
|
-
update:
|
|
1469
|
+
create: Kt(e),
|
|
1470
|
+
get: Gt(e),
|
|
1471
|
+
list: Yt(e),
|
|
1472
|
+
remove: qt(e),
|
|
1473
|
+
update: Jt(e)
|
|
1407
1474
|
};
|
|
1408
1475
|
}
|
|
1409
1476
|
//#endregion
|
|
1410
1477
|
//#region src/passwords/get.ts
|
|
1411
|
-
function
|
|
1478
|
+
function Zt(e) {
|
|
1412
1479
|
return async (t, n) => {
|
|
1413
1480
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1414
1481
|
if (!r) return null;
|
|
@@ -1421,7 +1488,7 @@ function Qt(e) {
|
|
|
1421
1488
|
}
|
|
1422
1489
|
//#endregion
|
|
1423
1490
|
//#region src/passwords/create.ts
|
|
1424
|
-
function
|
|
1491
|
+
function Qt(e) {
|
|
1425
1492
|
return async (n, r, i) => {
|
|
1426
1493
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1427
1494
|
...r,
|
|
@@ -1439,7 +1506,7 @@ function $t(e) {
|
|
|
1439
1506
|
}
|
|
1440
1507
|
//#endregion
|
|
1441
1508
|
//#region src/passwords/update.ts
|
|
1442
|
-
function
|
|
1509
|
+
function $t(e) {
|
|
1443
1510
|
return async (t, n) => {
|
|
1444
1511
|
let r = e.updateTable("passwords").set({
|
|
1445
1512
|
password: n.password,
|
|
@@ -1452,7 +1519,7 @@ function en(e) {
|
|
|
1452
1519
|
}
|
|
1453
1520
|
//#endregion
|
|
1454
1521
|
//#region src/passwords/list.ts
|
|
1455
|
-
function
|
|
1522
|
+
function en(e) {
|
|
1456
1523
|
return async (t, n, r) => {
|
|
1457
1524
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1458
1525
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1463,20 +1530,20 @@ function tn(e) {
|
|
|
1463
1530
|
}
|
|
1464
1531
|
//#endregion
|
|
1465
1532
|
//#region src/passwords/index.ts
|
|
1466
|
-
function
|
|
1533
|
+
function tn(e) {
|
|
1467
1534
|
return {
|
|
1468
|
-
create:
|
|
1469
|
-
update:
|
|
1470
|
-
get:
|
|
1471
|
-
list:
|
|
1535
|
+
create: Qt(e),
|
|
1536
|
+
update: $t(e),
|
|
1537
|
+
get: Zt(e),
|
|
1538
|
+
list: en(e)
|
|
1472
1539
|
};
|
|
1473
1540
|
}
|
|
1474
1541
|
//#endregion
|
|
1475
1542
|
//#region src/codes/list.ts
|
|
1476
|
-
function
|
|
1543
|
+
function nn(e) {
|
|
1477
1544
|
return async (t, n = {}) => {
|
|
1478
1545
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1479
|
-
s && (c =
|
|
1546
|
+
s && (c = O(e, c, s, ["code", "login_id"]));
|
|
1480
1547
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1481
1548
|
let { tenant_id: t, ...n } = e;
|
|
1482
1549
|
return ee.parse(l(n));
|
|
@@ -1498,13 +1565,13 @@ function rn(e) {
|
|
|
1498
1565
|
}
|
|
1499
1566
|
//#endregion
|
|
1500
1567
|
//#region src/codes/expires-at-ts.ts
|
|
1501
|
-
function
|
|
1568
|
+
function rn(e) {
|
|
1502
1569
|
let t = new Date(e).getTime();
|
|
1503
1570
|
return Number.isNaN(t) ? 0 : t;
|
|
1504
1571
|
}
|
|
1505
1572
|
//#endregion
|
|
1506
1573
|
//#region src/codes/create.ts
|
|
1507
|
-
function
|
|
1574
|
+
function an(e) {
|
|
1508
1575
|
return async (t, n) => {
|
|
1509
1576
|
let r = {
|
|
1510
1577
|
...n,
|
|
@@ -1513,18 +1580,18 @@ function on(e) {
|
|
|
1513
1580
|
return await e.insertInto("codes").values({
|
|
1514
1581
|
...r,
|
|
1515
1582
|
tenant_id: t,
|
|
1516
|
-
expires_at_ts:
|
|
1583
|
+
expires_at_ts: rn(r.expires_at)
|
|
1517
1584
|
}).execute(), r;
|
|
1518
1585
|
};
|
|
1519
1586
|
}
|
|
1520
1587
|
//#endregion
|
|
1521
1588
|
//#region src/codes/remove.ts
|
|
1522
|
-
function
|
|
1589
|
+
function on(e) {
|
|
1523
1590
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1524
1591
|
}
|
|
1525
1592
|
//#endregion
|
|
1526
1593
|
//#region src/codes/get.ts
|
|
1527
|
-
function
|
|
1594
|
+
function sn(e) {
|
|
1528
1595
|
return async (t, n, r) => {
|
|
1529
1596
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1530
1597
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1534,32 +1601,51 @@ function cn(e) {
|
|
|
1534
1601
|
}
|
|
1535
1602
|
//#endregion
|
|
1536
1603
|
//#region src/codes/used.ts
|
|
1537
|
-
function
|
|
1604
|
+
function cn(e) {
|
|
1538
1605
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numUpdatedRows > 0;
|
|
1539
1606
|
}
|
|
1540
1607
|
//#endregion
|
|
1541
1608
|
//#region src/codes/consume.ts
|
|
1542
|
-
function
|
|
1609
|
+
function ln(e) {
|
|
1543
1610
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).where("codes.used_at", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
1544
1611
|
}
|
|
1545
1612
|
//#endregion
|
|
1546
1613
|
//#region src/codes/cleanup.ts
|
|
1614
|
+
var z = 5e4;
|
|
1615
|
+
async function un(e, t) {
|
|
1616
|
+
if (!t) return e();
|
|
1617
|
+
let n = 0, r = z;
|
|
1618
|
+
for (; r >= z;) r = await e(z), n += r;
|
|
1619
|
+
return n;
|
|
1620
|
+
}
|
|
1547
1621
|
function dn(e) {
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1622
|
+
let t;
|
|
1623
|
+
return async (n) => {
|
|
1624
|
+
t ??= await Je(e);
|
|
1625
|
+
let r = t === "mysql";
|
|
1626
|
+
return await un(async (t) => {
|
|
1627
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "<", rn(n));
|
|
1628
|
+
t !== void 0 && (r = r.limit(t));
|
|
1629
|
+
let i = await r.executeTakeFirst();
|
|
1630
|
+
return Number(i.numDeletedRows);
|
|
1631
|
+
}, r) + await un(async (t) => {
|
|
1632
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", n);
|
|
1633
|
+
t !== void 0 && (r = r.limit(t));
|
|
1634
|
+
let i = await r.executeTakeFirst();
|
|
1635
|
+
return Number(i.numDeletedRows);
|
|
1636
|
+
}, r);
|
|
1551
1637
|
};
|
|
1552
1638
|
}
|
|
1553
1639
|
//#endregion
|
|
1554
1640
|
//#region src/codes/index.ts
|
|
1555
1641
|
function fn(e) {
|
|
1556
1642
|
return {
|
|
1557
|
-
create:
|
|
1558
|
-
list:
|
|
1559
|
-
remove:
|
|
1560
|
-
used:
|
|
1561
|
-
consume:
|
|
1562
|
-
get:
|
|
1643
|
+
create: an(e),
|
|
1644
|
+
list: nn(e),
|
|
1645
|
+
remove: on(e),
|
|
1646
|
+
used: cn(e),
|
|
1647
|
+
consume: ln(e),
|
|
1648
|
+
get: sn(e),
|
|
1563
1649
|
cleanup: dn(e)
|
|
1564
1650
|
};
|
|
1565
1651
|
}
|
|
@@ -1571,7 +1657,7 @@ function pn(e) {
|
|
|
1571
1657
|
delete o.enabled_clients;
|
|
1572
1658
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1573
1659
|
...o,
|
|
1574
|
-
id: i?.id ?? o.id ??
|
|
1660
|
+
id: i?.id ?? o.id ?? ke(),
|
|
1575
1661
|
is_system: a ? !0 : void 0,
|
|
1576
1662
|
created_at: i?.created_at ?? s,
|
|
1577
1663
|
updated_at: i?.updated_at ?? s
|
|
@@ -1586,7 +1672,7 @@ function pn(e) {
|
|
|
1586
1672
|
}
|
|
1587
1673
|
//#endregion
|
|
1588
1674
|
//#region src/connections/transform.ts
|
|
1589
|
-
function
|
|
1675
|
+
function mn(e) {
|
|
1590
1676
|
let { is_system: t, ...n } = e;
|
|
1591
1677
|
return l({
|
|
1592
1678
|
...n,
|
|
@@ -1594,16 +1680,16 @@ function F(e) {
|
|
|
1594
1680
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1595
1681
|
});
|
|
1596
1682
|
}
|
|
1597
|
-
function
|
|
1598
|
-
return e.map(
|
|
1683
|
+
function hn(e) {
|
|
1684
|
+
return e.map(mn);
|
|
1599
1685
|
}
|
|
1600
1686
|
//#endregion
|
|
1601
1687
|
//#region src/connections/list.ts
|
|
1602
|
-
function
|
|
1688
|
+
function gn(e) {
|
|
1603
1689
|
return async (t, n = {}) => {
|
|
1604
1690
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1605
|
-
s && (c =
|
|
1606
|
-
let l =
|
|
1691
|
+
s && (c = O(e, c, s, ["user_id", "ip"]));
|
|
1692
|
+
let l = hn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1607
1693
|
if (!a) return {
|
|
1608
1694
|
connections: l,
|
|
1609
1695
|
start: 0,
|
|
@@ -1621,20 +1707,20 @@ function hn(e) {
|
|
|
1621
1707
|
}
|
|
1622
1708
|
//#endregion
|
|
1623
1709
|
//#region src/connections/remove.ts
|
|
1624
|
-
function
|
|
1710
|
+
function _n(e) {
|
|
1625
1711
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1626
1712
|
}
|
|
1627
1713
|
//#endregion
|
|
1628
1714
|
//#region src/connections/get.ts
|
|
1629
|
-
function
|
|
1715
|
+
function vn(e) {
|
|
1630
1716
|
return async (t, n) => {
|
|
1631
1717
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1632
|
-
return r ?
|
|
1718
|
+
return r ? mn(r) : null;
|
|
1633
1719
|
};
|
|
1634
1720
|
}
|
|
1635
1721
|
//#endregion
|
|
1636
1722
|
//#region src/connections/update.ts
|
|
1637
|
-
function
|
|
1723
|
+
function yn(e) {
|
|
1638
1724
|
return async (t, n, r) => {
|
|
1639
1725
|
let { is_system: i, ...a } = r;
|
|
1640
1726
|
delete a.enabled_clients;
|
|
@@ -1651,18 +1737,18 @@ function vn(e) {
|
|
|
1651
1737
|
}
|
|
1652
1738
|
//#endregion
|
|
1653
1739
|
//#region src/connections/index.ts
|
|
1654
|
-
function
|
|
1740
|
+
function bn(e) {
|
|
1655
1741
|
return {
|
|
1656
1742
|
create: pn(e),
|
|
1657
|
-
get:
|
|
1658
|
-
list:
|
|
1659
|
-
remove:
|
|
1660
|
-
update:
|
|
1743
|
+
get: vn(e),
|
|
1744
|
+
list: gn(e),
|
|
1745
|
+
remove: _n(e),
|
|
1746
|
+
update: yn(e)
|
|
1661
1747
|
};
|
|
1662
1748
|
}
|
|
1663
1749
|
//#endregion
|
|
1664
1750
|
//#region src/clients/create.ts
|
|
1665
|
-
function
|
|
1751
|
+
function xn(e) {
|
|
1666
1752
|
return async (r, i, a) => {
|
|
1667
1753
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1668
1754
|
...i,
|
|
@@ -1727,7 +1813,7 @@ function bn(e) {
|
|
|
1727
1813
|
}
|
|
1728
1814
|
//#endregion
|
|
1729
1815
|
//#region src/clients/get.ts
|
|
1730
|
-
function
|
|
1816
|
+
function Sn(e) {
|
|
1731
1817
|
return async (t, n) => {
|
|
1732
1818
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1733
1819
|
if (!r) return null;
|
|
@@ -1773,7 +1859,7 @@ function xn(e) {
|
|
|
1773
1859
|
}
|
|
1774
1860
|
//#endregion
|
|
1775
1861
|
//#region src/clients/getByClientId.ts
|
|
1776
|
-
function
|
|
1862
|
+
function Cn(e) {
|
|
1777
1863
|
return async (t) => {
|
|
1778
1864
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1779
1865
|
return n ? l({
|
|
@@ -1817,7 +1903,7 @@ function Sn(e) {
|
|
|
1817
1903
|
}
|
|
1818
1904
|
//#endregion
|
|
1819
1905
|
//#region src/clients/list.ts
|
|
1820
|
-
function
|
|
1906
|
+
function wn(e) {
|
|
1821
1907
|
return l({
|
|
1822
1908
|
...e,
|
|
1823
1909
|
global: !!e.global,
|
|
@@ -1856,33 +1942,33 @@ function Cn(e) {
|
|
|
1856
1942
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1857
1943
|
});
|
|
1858
1944
|
}
|
|
1859
|
-
function
|
|
1945
|
+
function Tn(e) {
|
|
1860
1946
|
let t = Ce(e);
|
|
1861
1947
|
if (t.length !== 1) return null;
|
|
1862
1948
|
let n = t[0].match(/^([a-zA-Z_][a-zA-Z0-9_]*):(.+)$/);
|
|
1863
1949
|
if (!n) return null;
|
|
1864
|
-
let r =
|
|
1950
|
+
let r = w(n[2]);
|
|
1865
1951
|
return r ? {
|
|
1866
1952
|
field: n[1],
|
|
1867
1953
|
value: r
|
|
1868
1954
|
} : null;
|
|
1869
1955
|
}
|
|
1870
|
-
function
|
|
1956
|
+
function En(e) {
|
|
1871
1957
|
return async (t, n) => {
|
|
1872
1958
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1873
1959
|
if (n?.q) {
|
|
1874
|
-
let e =
|
|
1960
|
+
let e = Tn(n.q);
|
|
1875
1961
|
if (e && i.has(e.field)) {
|
|
1876
1962
|
let t = e.field;
|
|
1877
1963
|
r = r.where(t, "=", e.value);
|
|
1878
1964
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1879
1965
|
}
|
|
1880
|
-
if (
|
|
1881
|
-
let { rows: e, limit: t, next: i } = await
|
|
1966
|
+
if (P(n)) {
|
|
1967
|
+
let { rows: e, limit: t, next: i } = await F(r.selectAll(), n, {
|
|
1882
1968
|
sortColumn: "created_at",
|
|
1883
1969
|
sortOrder: "desc",
|
|
1884
1970
|
idColumn: "client_id"
|
|
1885
|
-
}), a = e.map(
|
|
1971
|
+
}), a = e.map(wn);
|
|
1886
1972
|
return {
|
|
1887
1973
|
clients: a,
|
|
1888
1974
|
totals: {
|
|
@@ -1906,7 +1992,7 @@ function Tn(e) {
|
|
|
1906
1992
|
if (n?.include_totals) {
|
|
1907
1993
|
let r = e.selectFrom("clients").select(f`count(*)`.as("count")).where("clients.tenant_id", "=", t);
|
|
1908
1994
|
if (n?.q) {
|
|
1909
|
-
let e =
|
|
1995
|
+
let e = Tn(n.q);
|
|
1910
1996
|
if (e && i.has(e.field)) {
|
|
1911
1997
|
let t = e.field;
|
|
1912
1998
|
r = r.where(t, "=", e.value);
|
|
@@ -1915,7 +2001,7 @@ function Tn(e) {
|
|
|
1915
2001
|
let a = await r.executeTakeFirst();
|
|
1916
2002
|
c = Number(a?.count || 0);
|
|
1917
2003
|
}
|
|
1918
|
-
let l = s.map(
|
|
2004
|
+
let l = s.map(wn);
|
|
1919
2005
|
return {
|
|
1920
2006
|
clients: l,
|
|
1921
2007
|
totals: {
|
|
@@ -1929,12 +2015,12 @@ function Tn(e) {
|
|
|
1929
2015
|
}
|
|
1930
2016
|
//#endregion
|
|
1931
2017
|
//#region src/clients/remove.ts
|
|
1932
|
-
function
|
|
2018
|
+
function Dn(e) {
|
|
1933
2019
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1934
2020
|
}
|
|
1935
2021
|
//#endregion
|
|
1936
2022
|
//#region src/clients/update.ts
|
|
1937
|
-
function
|
|
2023
|
+
function On(e) {
|
|
1938
2024
|
return async (t, r, i) => {
|
|
1939
2025
|
let a = {
|
|
1940
2026
|
...i,
|
|
@@ -1981,31 +2067,31 @@ function Dn(e) {
|
|
|
1981
2067
|
}
|
|
1982
2068
|
//#endregion
|
|
1983
2069
|
//#region src/clients/index.ts
|
|
1984
|
-
function
|
|
2070
|
+
function kn(e) {
|
|
1985
2071
|
return {
|
|
1986
|
-
create:
|
|
1987
|
-
get:
|
|
1988
|
-
getByClientId:
|
|
1989
|
-
list:
|
|
1990
|
-
remove:
|
|
1991
|
-
update:
|
|
2072
|
+
create: xn(e),
|
|
2073
|
+
get: Sn(e),
|
|
2074
|
+
getByClientId: Cn(e),
|
|
2075
|
+
list: En(e),
|
|
2076
|
+
remove: Dn(e),
|
|
2077
|
+
update: On(e)
|
|
1992
2078
|
};
|
|
1993
2079
|
}
|
|
1994
2080
|
//#endregion
|
|
1995
2081
|
//#region src/clientConnections/listByClient.ts
|
|
1996
|
-
function
|
|
2082
|
+
function An(e) {
|
|
1997
2083
|
return async (t, n) => {
|
|
1998
2084
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1999
2085
|
if (!r) return [];
|
|
2000
2086
|
let i = JSON.parse(r.connections || "[]");
|
|
2001
2087
|
if (i.length === 0) return [];
|
|
2002
|
-
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,
|
|
2088
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, mn(e)]));
|
|
2003
2089
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2004
2090
|
};
|
|
2005
2091
|
}
|
|
2006
2092
|
//#endregion
|
|
2007
2093
|
//#region src/clientConnections/updateByClient.ts
|
|
2008
|
-
function
|
|
2094
|
+
function jn(e) {
|
|
2009
2095
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
2010
2096
|
connections: JSON.stringify(r),
|
|
2011
2097
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2013,7 +2099,7 @@ function An(e) {
|
|
|
2013
2099
|
}
|
|
2014
2100
|
//#endregion
|
|
2015
2101
|
//#region src/clientConnections/listByConnection.ts
|
|
2016
|
-
function
|
|
2102
|
+
function Mn(e) {
|
|
2017
2103
|
return async (t, n) => {
|
|
2018
2104
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
2019
2105
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -2022,7 +2108,7 @@ function jn(e) {
|
|
|
2022
2108
|
}
|
|
2023
2109
|
//#endregion
|
|
2024
2110
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2025
|
-
function
|
|
2111
|
+
function Nn(e) {
|
|
2026
2112
|
return async (t, n, r) => {
|
|
2027
2113
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2028
2114
|
if (!i) return !1;
|
|
@@ -2035,7 +2121,7 @@ function Mn(e) {
|
|
|
2035
2121
|
}
|
|
2036
2122
|
//#endregion
|
|
2037
2123
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2038
|
-
function
|
|
2124
|
+
function Pn(e) {
|
|
2039
2125
|
return async (t, n, r) => {
|
|
2040
2126
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2041
2127
|
if (!i) return !1;
|
|
@@ -2048,18 +2134,18 @@ function Nn(e) {
|
|
|
2048
2134
|
}
|
|
2049
2135
|
//#endregion
|
|
2050
2136
|
//#region src/clientConnections/index.ts
|
|
2051
|
-
function
|
|
2137
|
+
function Fn(e) {
|
|
2052
2138
|
return {
|
|
2053
|
-
listByClient:
|
|
2054
|
-
updateByClient:
|
|
2055
|
-
listByConnection:
|
|
2056
|
-
addClientToConnection:
|
|
2057
|
-
removeClientFromConnection:
|
|
2139
|
+
listByClient: An(e),
|
|
2140
|
+
updateByClient: jn(e),
|
|
2141
|
+
listByConnection: Mn(e),
|
|
2142
|
+
addClientToConnection: Nn(e),
|
|
2143
|
+
removeClientFromConnection: Pn(e)
|
|
2058
2144
|
};
|
|
2059
2145
|
}
|
|
2060
2146
|
//#endregion
|
|
2061
2147
|
//#region src/clientGrants/create.ts
|
|
2062
|
-
function
|
|
2148
|
+
function In(e) {
|
|
2063
2149
|
return async (n, r, i) => {
|
|
2064
2150
|
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 = {
|
|
2065
2151
|
id: s,
|
|
@@ -2087,7 +2173,7 @@ function Fn(e) {
|
|
|
2087
2173
|
}
|
|
2088
2174
|
//#endregion
|
|
2089
2175
|
//#region src/clientGrants/get.ts
|
|
2090
|
-
function
|
|
2176
|
+
function Ln(e) {
|
|
2091
2177
|
return async (t, n) => {
|
|
2092
2178
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2093
2179
|
return r ? l({
|
|
@@ -2107,7 +2193,7 @@ function In(e) {
|
|
|
2107
2193
|
}
|
|
2108
2194
|
//#endregion
|
|
2109
2195
|
//#region src/clientGrants/list.ts
|
|
2110
|
-
function
|
|
2196
|
+
function Rn(e) {
|
|
2111
2197
|
return v.parse(l({
|
|
2112
2198
|
...e,
|
|
2113
2199
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2116,7 +2202,7 @@ function Ln(e) {
|
|
|
2116
2202
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2117
2203
|
}));
|
|
2118
2204
|
}
|
|
2119
|
-
function
|
|
2205
|
+
function zn(e) {
|
|
2120
2206
|
return async (t, n = {}) => {
|
|
2121
2207
|
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);
|
|
2122
2208
|
if (s) {
|
|
@@ -2127,13 +2213,13 @@ function Rn(e) {
|
|
|
2127
2213
|
let e = +(a === "true");
|
|
2128
2214
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2129
2215
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2130
|
-
} else l =
|
|
2216
|
+
} else l = O(e, l, t, []);
|
|
2131
2217
|
}
|
|
2132
|
-
if (
|
|
2133
|
-
let { rows: e, limit: t, next: r } = await
|
|
2218
|
+
if (P(n)) {
|
|
2219
|
+
let { rows: e, limit: t, next: r } = await F(l.selectAll(), n, {
|
|
2134
2220
|
sortColumn: "created_at",
|
|
2135
2221
|
sortOrder: "desc"
|
|
2136
|
-
}), i = e.map(
|
|
2222
|
+
}), i = e.map(Rn);
|
|
2137
2223
|
return {
|
|
2138
2224
|
client_grants: i,
|
|
2139
2225
|
start: 0,
|
|
@@ -2146,8 +2232,8 @@ function Rn(e) {
|
|
|
2146
2232
|
if (c) {
|
|
2147
2233
|
let { ref: t } = e.dynamic;
|
|
2148
2234
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2149
|
-
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2150
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2235
|
+
} else u = u.orderBy("client_grants.created_at", "desc").orderBy("client_grants.id", "desc");
|
|
2236
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(Rn);
|
|
2151
2237
|
if (!a) return {
|
|
2152
2238
|
client_grants: d,
|
|
2153
2239
|
start: 0,
|
|
@@ -2165,12 +2251,12 @@ function Rn(e) {
|
|
|
2165
2251
|
}
|
|
2166
2252
|
//#endregion
|
|
2167
2253
|
//#region src/clientGrants/remove.ts
|
|
2168
|
-
function
|
|
2254
|
+
function Bn(e) {
|
|
2169
2255
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2170
2256
|
}
|
|
2171
2257
|
//#endregion
|
|
2172
2258
|
//#region src/clientGrants/update.ts
|
|
2173
|
-
function
|
|
2259
|
+
function Vn(e) {
|
|
2174
2260
|
return async (t, n, r) => {
|
|
2175
2261
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2176
2262
|
...s,
|
|
@@ -2181,18 +2267,18 @@ function Bn(e) {
|
|
|
2181
2267
|
}
|
|
2182
2268
|
//#endregion
|
|
2183
2269
|
//#region src/clientGrants/index.ts
|
|
2184
|
-
function
|
|
2270
|
+
function Hn(e) {
|
|
2185
2271
|
return {
|
|
2186
|
-
create:
|
|
2187
|
-
get:
|
|
2188
|
-
list:
|
|
2189
|
-
remove:
|
|
2190
|
-
update:
|
|
2272
|
+
create: In(e),
|
|
2273
|
+
get: Ln(e),
|
|
2274
|
+
list: zn(e),
|
|
2275
|
+
remove: Bn(e),
|
|
2276
|
+
update: Vn(e)
|
|
2191
2277
|
};
|
|
2192
2278
|
}
|
|
2193
2279
|
//#endregion
|
|
2194
2280
|
//#region src/clientRegistrationTokens/create.ts
|
|
2195
|
-
function
|
|
2281
|
+
function Un(e) {
|
|
2196
2282
|
return async (t, n) => {
|
|
2197
2283
|
let r = Date.now();
|
|
2198
2284
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2223,12 +2309,12 @@ function Hn(e) {
|
|
|
2223
2309
|
}
|
|
2224
2310
|
//#endregion
|
|
2225
2311
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2226
|
-
function
|
|
2312
|
+
function Wn(e) {
|
|
2227
2313
|
let t = y.safeParse(e);
|
|
2228
2314
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2229
2315
|
return t.data;
|
|
2230
2316
|
}
|
|
2231
|
-
function
|
|
2317
|
+
function Gn(e) {
|
|
2232
2318
|
if (!e) return;
|
|
2233
2319
|
let t;
|
|
2234
2320
|
try {
|
|
@@ -2238,14 +2324,14 @@ function Wn(e) {
|
|
|
2238
2324
|
}
|
|
2239
2325
|
return oe(t) ? t : void 0;
|
|
2240
2326
|
}
|
|
2241
|
-
function
|
|
2327
|
+
function Kn(e) {
|
|
2242
2328
|
return {
|
|
2243
2329
|
id: e.id,
|
|
2244
2330
|
token_hash: e.token_hash,
|
|
2245
|
-
type:
|
|
2331
|
+
type: Wn(e.type),
|
|
2246
2332
|
client_id: e.client_id ?? void 0,
|
|
2247
2333
|
sub: e.sub ?? void 0,
|
|
2248
|
-
constraints:
|
|
2334
|
+
constraints: Gn(e.constraints),
|
|
2249
2335
|
single_use: !!e.single_use,
|
|
2250
2336
|
expires_at: i(e.expires_at_ts),
|
|
2251
2337
|
used_at: i(e.used_at_ts),
|
|
@@ -2255,38 +2341,38 @@ function I(e) {
|
|
|
2255
2341
|
}
|
|
2256
2342
|
//#endregion
|
|
2257
2343
|
//#region src/clientRegistrationTokens/get.ts
|
|
2258
|
-
function
|
|
2344
|
+
function qn(e) {
|
|
2259
2345
|
return async (t, n) => {
|
|
2260
2346
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2261
|
-
return r ?
|
|
2347
|
+
return r ? Kn(r) : null;
|
|
2262
2348
|
};
|
|
2263
2349
|
}
|
|
2264
2350
|
//#endregion
|
|
2265
2351
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2266
|
-
function
|
|
2352
|
+
function Jn(e) {
|
|
2267
2353
|
return async (t, n) => {
|
|
2268
2354
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2269
|
-
return r ?
|
|
2355
|
+
return r ? Kn(r) : null;
|
|
2270
2356
|
};
|
|
2271
2357
|
}
|
|
2272
2358
|
//#endregion
|
|
2273
2359
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2274
|
-
function
|
|
2275
|
-
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(
|
|
2360
|
+
function Yn(e) {
|
|
2361
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(Kn);
|
|
2276
2362
|
}
|
|
2277
2363
|
//#endregion
|
|
2278
2364
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2279
|
-
function
|
|
2365
|
+
function Xn(e) {
|
|
2280
2366
|
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;
|
|
2281
2367
|
}
|
|
2282
2368
|
//#endregion
|
|
2283
2369
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2284
|
-
function
|
|
2370
|
+
function Zn(e) {
|
|
2285
2371
|
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;
|
|
2286
2372
|
}
|
|
2287
2373
|
//#endregion
|
|
2288
2374
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2289
|
-
function
|
|
2375
|
+
function Qn(e) {
|
|
2290
2376
|
return async (t, n, r) => {
|
|
2291
2377
|
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();
|
|
2292
2378
|
return Number(i.numUpdatedRows);
|
|
@@ -2294,29 +2380,29 @@ function Xn(e) {
|
|
|
2294
2380
|
}
|
|
2295
2381
|
//#endregion
|
|
2296
2382
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2297
|
-
function
|
|
2383
|
+
function $n(e) {
|
|
2298
2384
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2299
2385
|
}
|
|
2300
2386
|
//#endregion
|
|
2301
2387
|
//#region src/clientRegistrationTokens/index.ts
|
|
2302
|
-
function
|
|
2388
|
+
function er(e) {
|
|
2303
2389
|
return {
|
|
2304
|
-
create:
|
|
2305
|
-
get:
|
|
2306
|
-
getByHash:
|
|
2307
|
-
listByClient:
|
|
2308
|
-
markUsed:
|
|
2309
|
-
revoke:
|
|
2310
|
-
revokeByClient:
|
|
2311
|
-
remove:
|
|
2390
|
+
create: Un(e),
|
|
2391
|
+
get: qn(e),
|
|
2392
|
+
getByHash: Jn(e),
|
|
2393
|
+
listByClient: Yn(e),
|
|
2394
|
+
markUsed: Xn(e),
|
|
2395
|
+
revoke: Zn(e),
|
|
2396
|
+
revokeByClient: Qn(e),
|
|
2397
|
+
remove: $n(e)
|
|
2312
2398
|
};
|
|
2313
2399
|
}
|
|
2314
2400
|
//#endregion
|
|
2315
2401
|
//#region src/keys/list.ts
|
|
2316
|
-
function
|
|
2402
|
+
function tr(e) {
|
|
2317
2403
|
return async (t = {}) => {
|
|
2318
2404
|
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)]));
|
|
2319
|
-
s && (c =
|
|
2405
|
+
s && (c = O(e, c, s, [
|
|
2320
2406
|
"kid",
|
|
2321
2407
|
"tenant_id",
|
|
2322
2408
|
"connection",
|
|
@@ -2342,7 +2428,7 @@ function $n(e) {
|
|
|
2342
2428
|
}
|
|
2343
2429
|
//#endregion
|
|
2344
2430
|
//#region src/keys/create.ts
|
|
2345
|
-
function
|
|
2431
|
+
function nr(e) {
|
|
2346
2432
|
return async (t, n) => {
|
|
2347
2433
|
let r = n?.importMetadata;
|
|
2348
2434
|
await e.insertInto("keys").values({
|
|
@@ -2354,21 +2440,21 @@ function er(e) {
|
|
|
2354
2440
|
}
|
|
2355
2441
|
//#endregion
|
|
2356
2442
|
//#region src/keys/update.ts
|
|
2357
|
-
function
|
|
2443
|
+
function rr(e) {
|
|
2358
2444
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2359
2445
|
}
|
|
2360
2446
|
//#endregion
|
|
2361
2447
|
//#region src/keys/index.ts
|
|
2362
|
-
function
|
|
2448
|
+
function ir(e) {
|
|
2363
2449
|
return {
|
|
2364
|
-
create:
|
|
2365
|
-
list:
|
|
2366
|
-
update:
|
|
2450
|
+
create: nr(e),
|
|
2451
|
+
list: tr(e),
|
|
2452
|
+
update: rr(e)
|
|
2367
2453
|
};
|
|
2368
2454
|
}
|
|
2369
2455
|
//#endregion
|
|
2370
2456
|
//#region src/customDomains/create.ts
|
|
2371
|
-
function
|
|
2457
|
+
function ar(e) {
|
|
2372
2458
|
return async (n, r, i) => {
|
|
2373
2459
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2374
2460
|
status: "pending",
|
|
@@ -2389,35 +2475,35 @@ function rr(e) {
|
|
|
2389
2475
|
}
|
|
2390
2476
|
//#endregion
|
|
2391
2477
|
//#region src/customDomains/list.ts
|
|
2392
|
-
function
|
|
2478
|
+
function or(e) {
|
|
2393
2479
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2394
2480
|
...e,
|
|
2395
2481
|
primary: e.primary === 1,
|
|
2396
|
-
domain_metadata:
|
|
2397
|
-
verification:
|
|
2482
|
+
domain_metadata: L(e.domain_metadata, void 0),
|
|
2483
|
+
verification: L(e.verification, void 0)
|
|
2398
2484
|
}));
|
|
2399
2485
|
}
|
|
2400
2486
|
//#endregion
|
|
2401
2487
|
//#region src/customDomains/remove.ts
|
|
2402
|
-
function
|
|
2488
|
+
function sr(e) {
|
|
2403
2489
|
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;
|
|
2404
2490
|
}
|
|
2405
2491
|
//#endregion
|
|
2406
2492
|
//#region src/customDomains/get.ts
|
|
2407
|
-
function
|
|
2493
|
+
function cr(e) {
|
|
2408
2494
|
return async (t, n) => {
|
|
2409
2495
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2410
2496
|
return r ? {
|
|
2411
2497
|
...r,
|
|
2412
2498
|
primary: r.primary === 1,
|
|
2413
|
-
domain_metadata:
|
|
2414
|
-
verification:
|
|
2499
|
+
domain_metadata: L(r.domain_metadata, void 0),
|
|
2500
|
+
verification: L(r.verification, void 0)
|
|
2415
2501
|
} : null;
|
|
2416
2502
|
};
|
|
2417
2503
|
}
|
|
2418
2504
|
//#endregion
|
|
2419
2505
|
//#region src/customDomains/update.ts
|
|
2420
|
-
function
|
|
2506
|
+
function lr(e) {
|
|
2421
2507
|
return async (t, n, r) => {
|
|
2422
2508
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2423
2509
|
...s,
|
|
@@ -2431,32 +2517,32 @@ function sr(e) {
|
|
|
2431
2517
|
}
|
|
2432
2518
|
//#endregion
|
|
2433
2519
|
//#region src/customDomains/getByDomain.ts
|
|
2434
|
-
function
|
|
2520
|
+
function ur(e) {
|
|
2435
2521
|
return async (t) => {
|
|
2436
2522
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2437
2523
|
return n ? {
|
|
2438
2524
|
...n,
|
|
2439
2525
|
primary: n.primary === 1,
|
|
2440
|
-
domain_metadata:
|
|
2441
|
-
verification:
|
|
2526
|
+
domain_metadata: L(n.domain_metadata, void 0),
|
|
2527
|
+
verification: L(n.verification, void 0)
|
|
2442
2528
|
} : null;
|
|
2443
2529
|
};
|
|
2444
2530
|
}
|
|
2445
2531
|
//#endregion
|
|
2446
2532
|
//#region src/customDomains/index.ts
|
|
2447
|
-
function
|
|
2533
|
+
function dr(e) {
|
|
2448
2534
|
return {
|
|
2449
|
-
create:
|
|
2450
|
-
get:
|
|
2451
|
-
getByDomain:
|
|
2452
|
-
list:
|
|
2453
|
-
remove:
|
|
2454
|
-
update:
|
|
2535
|
+
create: ar(e),
|
|
2536
|
+
get: cr(e),
|
|
2537
|
+
getByDomain: ur(e),
|
|
2538
|
+
list: or(e),
|
|
2539
|
+
remove: sr(e),
|
|
2540
|
+
update: lr(e)
|
|
2455
2541
|
};
|
|
2456
2542
|
}
|
|
2457
2543
|
//#endregion
|
|
2458
2544
|
//#region src/branding/get.ts
|
|
2459
|
-
function
|
|
2545
|
+
function fr(e) {
|
|
2460
2546
|
return async (t) => {
|
|
2461
2547
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2462
2548
|
if (!n) return null;
|
|
@@ -2478,7 +2564,7 @@ function ur(e) {
|
|
|
2478
2564
|
}
|
|
2479
2565
|
//#endregion
|
|
2480
2566
|
//#region src/branding/set.ts
|
|
2481
|
-
function
|
|
2567
|
+
function pr(e) {
|
|
2482
2568
|
return async (t, n) => {
|
|
2483
2569
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2484
2570
|
try {
|
|
@@ -2507,15 +2593,15 @@ function dr(e) {
|
|
|
2507
2593
|
}
|
|
2508
2594
|
//#endregion
|
|
2509
2595
|
//#region src/branding/index.ts
|
|
2510
|
-
function
|
|
2596
|
+
function mr(e) {
|
|
2511
2597
|
return {
|
|
2512
|
-
get:
|
|
2513
|
-
set:
|
|
2598
|
+
get: fr(e),
|
|
2599
|
+
set: pr(e)
|
|
2514
2600
|
};
|
|
2515
2601
|
}
|
|
2516
2602
|
//#endregion
|
|
2517
2603
|
//#region src/universalLoginTemplates/get.ts
|
|
2518
|
-
function
|
|
2604
|
+
function hr(e) {
|
|
2519
2605
|
return async (t) => {
|
|
2520
2606
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2521
2607
|
return n ? { body: n.body } : null;
|
|
@@ -2523,7 +2609,7 @@ function pr(e) {
|
|
|
2523
2609
|
}
|
|
2524
2610
|
//#endregion
|
|
2525
2611
|
//#region src/universalLoginTemplates/set.ts
|
|
2526
|
-
function
|
|
2612
|
+
function gr(e) {
|
|
2527
2613
|
return async (t, n, r) => {
|
|
2528
2614
|
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;
|
|
2529
2615
|
try {
|
|
@@ -2544,26 +2630,26 @@ function mr(e) {
|
|
|
2544
2630
|
}
|
|
2545
2631
|
//#endregion
|
|
2546
2632
|
//#region src/universalLoginTemplates/delete.ts
|
|
2547
|
-
function
|
|
2633
|
+
function _r(e) {
|
|
2548
2634
|
return async (t) => {
|
|
2549
2635
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2550
2636
|
};
|
|
2551
2637
|
}
|
|
2552
2638
|
//#endregion
|
|
2553
2639
|
//#region src/universalLoginTemplates/index.ts
|
|
2554
|
-
function
|
|
2640
|
+
function vr(e) {
|
|
2555
2641
|
return {
|
|
2556
|
-
get:
|
|
2557
|
-
set:
|
|
2558
|
-
delete:
|
|
2642
|
+
get: hr(e),
|
|
2643
|
+
set: gr(e),
|
|
2644
|
+
delete: _r(e)
|
|
2559
2645
|
};
|
|
2560
2646
|
}
|
|
2561
2647
|
//#endregion
|
|
2562
2648
|
//#region src/hooks/list.ts
|
|
2563
|
-
function
|
|
2649
|
+
function yr(e) {
|
|
2564
2650
|
return async (t, n = {}) => {
|
|
2565
2651
|
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);
|
|
2566
|
-
if (u && (d =
|
|
2652
|
+
if (u && (d = O(e, d, u, [
|
|
2567
2653
|
"url",
|
|
2568
2654
|
"form_id",
|
|
2569
2655
|
"template_id",
|
|
@@ -2582,7 +2668,7 @@ function _r(e) {
|
|
|
2582
2668
|
...u,
|
|
2583
2669
|
enabled: !!n,
|
|
2584
2670
|
synchronous: !!i,
|
|
2585
|
-
metadata:
|
|
2671
|
+
metadata: St(s)
|
|
2586
2672
|
});
|
|
2587
2673
|
});
|
|
2588
2674
|
if (!s) return {
|
|
@@ -2602,7 +2688,7 @@ function _r(e) {
|
|
|
2602
2688
|
}
|
|
2603
2689
|
//#endregion
|
|
2604
2690
|
//#region src/hooks/get.ts
|
|
2605
|
-
function
|
|
2691
|
+
function br(e) {
|
|
2606
2692
|
return async (t, n) => {
|
|
2607
2693
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2608
2694
|
if (!i) return null;
|
|
@@ -2615,20 +2701,20 @@ function vr(e) {
|
|
|
2615
2701
|
...d,
|
|
2616
2702
|
enabled: !!u.enabled,
|
|
2617
2703
|
synchronous: !!u.synchronous,
|
|
2618
|
-
metadata:
|
|
2704
|
+
metadata: St(c)
|
|
2619
2705
|
});
|
|
2620
2706
|
};
|
|
2621
2707
|
}
|
|
2622
2708
|
//#endregion
|
|
2623
2709
|
//#region src/hooks/remove.ts
|
|
2624
|
-
function
|
|
2710
|
+
function xr(e) {
|
|
2625
2711
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2626
2712
|
}
|
|
2627
2713
|
//#endregion
|
|
2628
2714
|
//#region src/hooks/create.ts
|
|
2629
|
-
function
|
|
2715
|
+
function Sr(e) {
|
|
2630
2716
|
return async (t, n, r) => {
|
|
2631
|
-
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 ||
|
|
2717
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Me()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2632
2718
|
return await e.insertInto("hooks").values({
|
|
2633
2719
|
...p,
|
|
2634
2720
|
hook_id: c,
|
|
@@ -2651,7 +2737,7 @@ function br(e) {
|
|
|
2651
2737
|
}
|
|
2652
2738
|
//#endregion
|
|
2653
2739
|
//#region src/hooks/update.ts
|
|
2654
|
-
function
|
|
2740
|
+
function Cr(e) {
|
|
2655
2741
|
return async (t, n, r) => {
|
|
2656
2742
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2657
2743
|
...o,
|
|
@@ -2665,20 +2751,20 @@ function xr(e) {
|
|
|
2665
2751
|
}
|
|
2666
2752
|
//#endregion
|
|
2667
2753
|
//#region src/hooks/index.ts
|
|
2668
|
-
function
|
|
2754
|
+
function wr(e) {
|
|
2669
2755
|
return {
|
|
2670
|
-
create:
|
|
2671
|
-
get:
|
|
2672
|
-
list:
|
|
2673
|
-
update:
|
|
2674
|
-
remove:
|
|
2756
|
+
create: Sr(e),
|
|
2757
|
+
get: br(e),
|
|
2758
|
+
list: yr(e),
|
|
2759
|
+
update: Cr(e),
|
|
2760
|
+
remove: xr(e)
|
|
2675
2761
|
};
|
|
2676
2762
|
}
|
|
2677
2763
|
//#endregion
|
|
2678
2764
|
//#region src/hook-code/create.ts
|
|
2679
|
-
function
|
|
2765
|
+
function Tr(e) {
|
|
2680
2766
|
return async (t, n, r) => {
|
|
2681
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2767
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Pe();
|
|
2682
2768
|
return await e.insertInto("hook_code").values({
|
|
2683
2769
|
id: c,
|
|
2684
2770
|
tenant_id: t,
|
|
@@ -2698,7 +2784,7 @@ function Cr(e) {
|
|
|
2698
2784
|
}
|
|
2699
2785
|
//#endregion
|
|
2700
2786
|
//#region src/hook-code/get.ts
|
|
2701
|
-
function
|
|
2787
|
+
function Er(e) {
|
|
2702
2788
|
return async (t, n) => {
|
|
2703
2789
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2704
2790
|
if (!i) return null;
|
|
@@ -2722,7 +2808,7 @@ function wr(e) {
|
|
|
2722
2808
|
}
|
|
2723
2809
|
//#endregion
|
|
2724
2810
|
//#region src/hook-code/update.ts
|
|
2725
|
-
function
|
|
2811
|
+
function Dr(e) {
|
|
2726
2812
|
return async (t, n, r) => {
|
|
2727
2813
|
let i = { updated_at_ts: Date.now() };
|
|
2728
2814
|
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;
|
|
@@ -2730,22 +2816,22 @@ function Tr(e) {
|
|
|
2730
2816
|
}
|
|
2731
2817
|
//#endregion
|
|
2732
2818
|
//#region src/hook-code/remove.ts
|
|
2733
|
-
function
|
|
2819
|
+
function Or(e) {
|
|
2734
2820
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2735
2821
|
}
|
|
2736
2822
|
//#endregion
|
|
2737
2823
|
//#region src/hook-code/index.ts
|
|
2738
|
-
function
|
|
2824
|
+
function kr(e) {
|
|
2739
2825
|
return {
|
|
2740
|
-
create:
|
|
2741
|
-
get:
|
|
2742
|
-
update:
|
|
2743
|
-
remove:
|
|
2826
|
+
create: Tr(e),
|
|
2827
|
+
get: Er(e),
|
|
2828
|
+
update: Dr(e),
|
|
2829
|
+
remove: Or(e)
|
|
2744
2830
|
};
|
|
2745
2831
|
}
|
|
2746
2832
|
//#endregion
|
|
2747
2833
|
//#region src/themes/create.ts
|
|
2748
|
-
function
|
|
2834
|
+
function Ar(e) {
|
|
2749
2835
|
return async (n, r, i, a) => {
|
|
2750
2836
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2751
2837
|
themeId: o?.id || i || t(),
|
|
@@ -2756,20 +2842,20 @@ function Or(e) {
|
|
|
2756
2842
|
...c,
|
|
2757
2843
|
tenant_id: n
|
|
2758
2844
|
};
|
|
2759
|
-
return await e.insertInto("themes").values(
|
|
2845
|
+
return await e.insertInto("themes").values(I(l)).execute(), c;
|
|
2760
2846
|
};
|
|
2761
2847
|
}
|
|
2762
2848
|
//#endregion
|
|
2763
2849
|
//#region src/themes/remove.ts
|
|
2764
|
-
function
|
|
2850
|
+
function jr(e) {
|
|
2765
2851
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2766
2852
|
}
|
|
2767
2853
|
//#endregion
|
|
2768
2854
|
//#region src/themes/get.ts
|
|
2769
|
-
function
|
|
2855
|
+
function Mr(e) {
|
|
2770
2856
|
return async (t, n) => {
|
|
2771
2857
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2772
|
-
return r ? l(
|
|
2858
|
+
return r ? l(mt({
|
|
2773
2859
|
...r,
|
|
2774
2860
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2775
2861
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2789,9 +2875,9 @@ function Ar(e) {
|
|
|
2789
2875
|
}
|
|
2790
2876
|
//#endregion
|
|
2791
2877
|
//#region src/themes/update.ts
|
|
2792
|
-
function
|
|
2878
|
+
function Nr(e) {
|
|
2793
2879
|
return async (t, n, r) => {
|
|
2794
|
-
let { themeId: i, ...a } = r, o =
|
|
2880
|
+
let { themeId: i, ...a } = r, o = I({
|
|
2795
2881
|
...a,
|
|
2796
2882
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2797
2883
|
});
|
|
@@ -2800,17 +2886,17 @@ function jr(e) {
|
|
|
2800
2886
|
}
|
|
2801
2887
|
//#endregion
|
|
2802
2888
|
//#region src/themes/index.ts
|
|
2803
|
-
function
|
|
2889
|
+
function Pr(e) {
|
|
2804
2890
|
return {
|
|
2805
|
-
create:
|
|
2806
|
-
get:
|
|
2807
|
-
remove:
|
|
2808
|
-
update:
|
|
2891
|
+
create: Ar(e),
|
|
2892
|
+
get: Mr(e),
|
|
2893
|
+
remove: jr(e),
|
|
2894
|
+
update: Nr(e)
|
|
2809
2895
|
};
|
|
2810
2896
|
}
|
|
2811
2897
|
//#endregion
|
|
2812
2898
|
//#region src/loginSessions/get.ts
|
|
2813
|
-
function
|
|
2899
|
+
function Fr(e) {
|
|
2814
2900
|
return async (t, n) => {
|
|
2815
2901
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2816
2902
|
if (!i) return null;
|
|
@@ -2822,7 +2908,7 @@ function Nr(e) {
|
|
|
2822
2908
|
"created_at_ts",
|
|
2823
2909
|
"updated_at_ts",
|
|
2824
2910
|
"expires_at_ts"
|
|
2825
|
-
]), f =
|
|
2911
|
+
]), f = mt(l({
|
|
2826
2912
|
...u,
|
|
2827
2913
|
...d,
|
|
2828
2914
|
state: i.state || p.PENDING,
|
|
@@ -2834,28 +2920,28 @@ function Nr(e) {
|
|
|
2834
2920
|
}
|
|
2835
2921
|
//#endregion
|
|
2836
2922
|
//#region src/utils/ulid.ts
|
|
2837
|
-
var
|
|
2838
|
-
function
|
|
2923
|
+
var Ir = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Lr = 32, Rr = 10, zr = 16;
|
|
2924
|
+
function Br(e) {
|
|
2839
2925
|
let t = "";
|
|
2840
|
-
for (let n =
|
|
2926
|
+
for (let n = Rr; n > 0; n--) t = Ir.charAt(e % Lr) + t, e = Math.floor(e / Lr);
|
|
2841
2927
|
return t;
|
|
2842
2928
|
}
|
|
2843
|
-
function
|
|
2844
|
-
let e = new Uint8Array(
|
|
2929
|
+
function Vr() {
|
|
2930
|
+
let e = new Uint8Array(zr);
|
|
2845
2931
|
crypto.getRandomValues(e);
|
|
2846
2932
|
let t = "";
|
|
2847
|
-
for (let n = 0; n <
|
|
2933
|
+
for (let n = 0; n < zr; n++) t += Ir.charAt(e[n] % Lr);
|
|
2848
2934
|
return t;
|
|
2849
2935
|
}
|
|
2850
|
-
function
|
|
2851
|
-
return
|
|
2936
|
+
function Hr() {
|
|
2937
|
+
return Br(Date.now()) + Vr();
|
|
2852
2938
|
}
|
|
2853
2939
|
//#endregion
|
|
2854
2940
|
//#region src/loginSessions/create.ts
|
|
2855
|
-
function
|
|
2941
|
+
function Ur(e) {
|
|
2856
2942
|
return async (t, n) => {
|
|
2857
2943
|
let r = c(), i = {
|
|
2858
|
-
id:
|
|
2944
|
+
id: Hr(),
|
|
2859
2945
|
...n,
|
|
2860
2946
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2861
2947
|
created_at: r,
|
|
@@ -2863,7 +2949,7 @@ function Br(e) {
|
|
|
2863
2949
|
state: n.state || p.PENDING,
|
|
2864
2950
|
state_data: n.state_data,
|
|
2865
2951
|
failure_reason: n.failure_reason
|
|
2866
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2952
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = I(o);
|
|
2867
2953
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2868
2954
|
...l,
|
|
2869
2955
|
tenant_id: t,
|
|
@@ -2876,7 +2962,7 @@ function Br(e) {
|
|
|
2876
2962
|
}
|
|
2877
2963
|
//#endregion
|
|
2878
2964
|
//#region src/loginSessions/update.ts
|
|
2879
|
-
function
|
|
2965
|
+
function Wr(e) {
|
|
2880
2966
|
return async (t, n, r) => {
|
|
2881
2967
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2882
2968
|
if (c !== void 0) {
|
|
@@ -2886,7 +2972,7 @@ function Vr(e) {
|
|
|
2886
2972
|
...c
|
|
2887
2973
|
}) };
|
|
2888
2974
|
}
|
|
2889
|
-
let d =
|
|
2975
|
+
let d = I(l);
|
|
2890
2976
|
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({
|
|
2891
2977
|
...d,
|
|
2892
2978
|
...u,
|
|
@@ -2897,22 +2983,22 @@ function Vr(e) {
|
|
|
2897
2983
|
}
|
|
2898
2984
|
//#endregion
|
|
2899
2985
|
//#region src/loginSessions/remove.ts
|
|
2900
|
-
function
|
|
2986
|
+
function Gr(e) {
|
|
2901
2987
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2902
2988
|
}
|
|
2903
2989
|
//#endregion
|
|
2904
2990
|
//#region src/loginSessions/index.ts
|
|
2905
|
-
function
|
|
2991
|
+
function Kr(e) {
|
|
2906
2992
|
return {
|
|
2907
|
-
create:
|
|
2908
|
-
get:
|
|
2909
|
-
update:
|
|
2910
|
-
remove:
|
|
2993
|
+
create: Ur(e),
|
|
2994
|
+
get: Fr(e),
|
|
2995
|
+
update: Wr(e),
|
|
2996
|
+
remove: Gr(e)
|
|
2911
2997
|
};
|
|
2912
2998
|
}
|
|
2913
2999
|
//#endregion
|
|
2914
3000
|
//#region src/promptSettings/get.ts
|
|
2915
|
-
function
|
|
3001
|
+
function qr(e) {
|
|
2916
3002
|
return async (t) => {
|
|
2917
3003
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2918
3004
|
return l({
|
|
@@ -2926,13 +3012,13 @@ function Wr(e) {
|
|
|
2926
3012
|
}
|
|
2927
3013
|
//#endregion
|
|
2928
3014
|
//#region src/promptSettings/set.ts
|
|
2929
|
-
function
|
|
3015
|
+
function Jr(e) {
|
|
2930
3016
|
let t = {};
|
|
2931
3017
|
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;
|
|
2932
3018
|
}
|
|
2933
|
-
function
|
|
3019
|
+
function Yr(e) {
|
|
2934
3020
|
return async (t, n) => {
|
|
2935
|
-
let r =
|
|
3021
|
+
let r = Jr(n);
|
|
2936
3022
|
try {
|
|
2937
3023
|
await e.insertInto("prompt_settings").values({
|
|
2938
3024
|
tenant_id: t,
|
|
@@ -2950,15 +3036,15 @@ function Kr(e) {
|
|
|
2950
3036
|
}
|
|
2951
3037
|
//#endregion
|
|
2952
3038
|
//#region src/promptSettings/index.ts
|
|
2953
|
-
function
|
|
3039
|
+
function Xr(e) {
|
|
2954
3040
|
return {
|
|
2955
|
-
get:
|
|
2956
|
-
set:
|
|
3041
|
+
get: qr(e),
|
|
3042
|
+
set: Yr(e)
|
|
2957
3043
|
};
|
|
2958
3044
|
}
|
|
2959
3045
|
//#endregion
|
|
2960
3046
|
//#region src/emailProvideres/get.ts
|
|
2961
|
-
function
|
|
3047
|
+
function Zr(e) {
|
|
2962
3048
|
return async (t) => {
|
|
2963
3049
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2964
3050
|
if (!n) return null;
|
|
@@ -2973,7 +3059,7 @@ function Jr(e) {
|
|
|
2973
3059
|
}
|
|
2974
3060
|
//#endregion
|
|
2975
3061
|
//#region src/emailProvideres/update.ts
|
|
2976
|
-
function
|
|
3062
|
+
function Qr(e) {
|
|
2977
3063
|
return async (t, n) => {
|
|
2978
3064
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2979
3065
|
await e.updateTable("email_providers").set({
|
|
@@ -2986,7 +3072,7 @@ function Yr(e) {
|
|
|
2986
3072
|
}
|
|
2987
3073
|
//#endregion
|
|
2988
3074
|
//#region src/emailProvideres/create.ts
|
|
2989
|
-
function
|
|
3075
|
+
function $r(e) {
|
|
2990
3076
|
return async (t, n, r) => {
|
|
2991
3077
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2992
3078
|
await e.insertInto("email_providers").values({
|
|
@@ -3002,24 +3088,24 @@ function Xr(e) {
|
|
|
3002
3088
|
}
|
|
3003
3089
|
//#endregion
|
|
3004
3090
|
//#region src/emailProvideres/remove.ts
|
|
3005
|
-
function
|
|
3091
|
+
function ei(e) {
|
|
3006
3092
|
return async (t) => {
|
|
3007
3093
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3008
3094
|
};
|
|
3009
3095
|
}
|
|
3010
3096
|
//#endregion
|
|
3011
3097
|
//#region src/emailProvideres/index.ts
|
|
3012
|
-
function
|
|
3098
|
+
function ti(e) {
|
|
3013
3099
|
return {
|
|
3014
|
-
get:
|
|
3015
|
-
create:
|
|
3016
|
-
update:
|
|
3017
|
-
remove:
|
|
3100
|
+
get: Zr(e),
|
|
3101
|
+
create: $r(e),
|
|
3102
|
+
update: Qr(e),
|
|
3103
|
+
remove: ei(e)
|
|
3018
3104
|
};
|
|
3019
3105
|
}
|
|
3020
3106
|
//#endregion
|
|
3021
3107
|
//#region src/emailTemplates/row.ts
|
|
3022
|
-
function
|
|
3108
|
+
function ni(e) {
|
|
3023
3109
|
let t = {
|
|
3024
3110
|
template: e.template,
|
|
3025
3111
|
body: e.body,
|
|
@@ -3033,20 +3119,20 @@ function $r(e) {
|
|
|
3033
3119
|
}
|
|
3034
3120
|
//#endregion
|
|
3035
3121
|
//#region src/emailTemplates/get.ts
|
|
3036
|
-
function
|
|
3122
|
+
function ri(e) {
|
|
3037
3123
|
return async (t, n) => {
|
|
3038
3124
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3039
|
-
return r ? ne.parse(
|
|
3125
|
+
return r ? ne.parse(ni(r)) : null;
|
|
3040
3126
|
};
|
|
3041
3127
|
}
|
|
3042
3128
|
//#endregion
|
|
3043
3129
|
//#region src/emailTemplates/list.ts
|
|
3044
|
-
function
|
|
3045
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(
|
|
3130
|
+
function ii(e) {
|
|
3131
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(ni(e)));
|
|
3046
3132
|
}
|
|
3047
3133
|
//#endregion
|
|
3048
3134
|
//#region src/emailTemplates/create.ts
|
|
3049
|
-
function
|
|
3135
|
+
function ai(e) {
|
|
3050
3136
|
return async (t, n, r) => {
|
|
3051
3137
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3052
3138
|
return await e.insertInto("email_templates").values({
|
|
@@ -3067,7 +3153,7 @@ function ni(e) {
|
|
|
3067
3153
|
}
|
|
3068
3154
|
//#endregion
|
|
3069
3155
|
//#region src/emailTemplates/update.ts
|
|
3070
|
-
function
|
|
3156
|
+
function oi(e) {
|
|
3071
3157
|
return async (t, n, r) => {
|
|
3072
3158
|
let i = {};
|
|
3073
3159
|
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;
|
|
@@ -3078,7 +3164,7 @@ function ri(e) {
|
|
|
3078
3164
|
}
|
|
3079
3165
|
//#endregion
|
|
3080
3166
|
//#region src/emailTemplates/remove.ts
|
|
3081
|
-
function
|
|
3167
|
+
function si(e) {
|
|
3082
3168
|
return async (t, n) => {
|
|
3083
3169
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3084
3170
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3086,18 +3172,18 @@ function ii(e) {
|
|
|
3086
3172
|
}
|
|
3087
3173
|
//#endregion
|
|
3088
3174
|
//#region src/emailTemplates/index.ts
|
|
3089
|
-
function
|
|
3175
|
+
function ci(e) {
|
|
3090
3176
|
return {
|
|
3091
|
-
get:
|
|
3092
|
-
list:
|
|
3093
|
-
create:
|
|
3094
|
-
update:
|
|
3095
|
-
remove:
|
|
3177
|
+
get: ri(e),
|
|
3178
|
+
list: ii(e),
|
|
3179
|
+
create: ai(e),
|
|
3180
|
+
update: oi(e),
|
|
3181
|
+
remove: si(e)
|
|
3096
3182
|
};
|
|
3097
3183
|
}
|
|
3098
3184
|
//#endregion
|
|
3099
3185
|
//#region src/refreshTokens/to-refresh-token.ts
|
|
3100
|
-
function
|
|
3186
|
+
function B(e) {
|
|
3101
3187
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: i, idle_expires_at_ts: a, last_exchanged_at_ts: o, revoked_at_ts: s, rotated_at_ts: c, auth_strategy_strategy: u, auth_strategy_strategy_type: d, ...f } = e, p = r({
|
|
3102
3188
|
created_at_ts: n,
|
|
3103
3189
|
expires_at_ts: i,
|
|
@@ -3126,23 +3212,23 @@ function R(e) {
|
|
|
3126
3212
|
}
|
|
3127
3213
|
//#endregion
|
|
3128
3214
|
//#region src/refreshTokens/get.ts
|
|
3129
|
-
function
|
|
3215
|
+
function li(e) {
|
|
3130
3216
|
return async (t, n) => {
|
|
3131
3217
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3132
|
-
return r ?
|
|
3218
|
+
return r ? B(r) : null;
|
|
3133
3219
|
};
|
|
3134
3220
|
}
|
|
3135
3221
|
//#endregion
|
|
3136
3222
|
//#region src/refreshTokens/getByLookup.ts
|
|
3137
|
-
function
|
|
3223
|
+
function ui(e) {
|
|
3138
3224
|
return async (t, n) => {
|
|
3139
3225
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3140
|
-
return r ?
|
|
3226
|
+
return r ? B(r) : null;
|
|
3141
3227
|
};
|
|
3142
3228
|
}
|
|
3143
3229
|
//#endregion
|
|
3144
3230
|
//#region src/refreshTokens/create.ts
|
|
3145
|
-
function
|
|
3231
|
+
function di(e) {
|
|
3146
3232
|
return async (t, n) => {
|
|
3147
3233
|
let r = c(), i = {
|
|
3148
3234
|
...n,
|
|
@@ -3174,12 +3260,12 @@ function ci(e) {
|
|
|
3174
3260
|
}
|
|
3175
3261
|
//#endregion
|
|
3176
3262
|
//#region src/refreshTokens/remove.ts
|
|
3177
|
-
function
|
|
3263
|
+
function fi(e) {
|
|
3178
3264
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3179
3265
|
}
|
|
3180
3266
|
//#endregion
|
|
3181
3267
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3182
|
-
function
|
|
3268
|
+
function pi(e) {
|
|
3183
3269
|
return async (t, n, r) => {
|
|
3184
3270
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("login_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3185
3271
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3187,7 +3273,7 @@ function ui(e) {
|
|
|
3187
3273
|
}
|
|
3188
3274
|
//#endregion
|
|
3189
3275
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3190
|
-
function
|
|
3276
|
+
function mi(e) {
|
|
3191
3277
|
return async (t, n, r) => {
|
|
3192
3278
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("session_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3193
3279
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3195,7 +3281,7 @@ function di(e) {
|
|
|
3195
3281
|
}
|
|
3196
3282
|
//#endregion
|
|
3197
3283
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3198
|
-
function
|
|
3284
|
+
function hi(e) {
|
|
3199
3285
|
return async (t, n, r) => {
|
|
3200
3286
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("user_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3201
3287
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3203,7 +3289,7 @@ function fi(e) {
|
|
|
3203
3289
|
}
|
|
3204
3290
|
//#endregion
|
|
3205
3291
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3206
|
-
function
|
|
3292
|
+
function gi(e) {
|
|
3207
3293
|
return async (t, n, r) => {
|
|
3208
3294
|
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();
|
|
3209
3295
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3211,7 +3297,7 @@ function pi(e) {
|
|
|
3211
3297
|
}
|
|
3212
3298
|
//#endregion
|
|
3213
3299
|
//#region src/refreshTokens/update.ts
|
|
3214
|
-
function
|
|
3300
|
+
function _i(e) {
|
|
3215
3301
|
return async (t, n, r, i) => {
|
|
3216
3302
|
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 = {
|
|
3217
3303
|
...h,
|
|
@@ -3232,14 +3318,14 @@ function mi(e) {
|
|
|
3232
3318
|
}
|
|
3233
3319
|
//#endregion
|
|
3234
3320
|
//#region src/refreshTokens/list.ts
|
|
3235
|
-
function
|
|
3321
|
+
function vi(e) {
|
|
3236
3322
|
return async (t, n = {}) => {
|
|
3237
3323
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, user_id: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3238
|
-
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u =
|
|
3239
|
-
let { rows: e, limit: t, next: r } = await
|
|
3324
|
+
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = O(e, u, c, ["token", "login_id"])), P(n)) {
|
|
3325
|
+
let { rows: e, limit: t, next: r } = await F(u.selectAll(), n, {
|
|
3240
3326
|
sortColumn: "created_at_ts",
|
|
3241
3327
|
sortOrder: "desc"
|
|
3242
|
-
}), i = e.map(
|
|
3328
|
+
}), i = e.map(B);
|
|
3243
3329
|
return {
|
|
3244
3330
|
refresh_tokens: i,
|
|
3245
3331
|
start: 0,
|
|
@@ -3254,7 +3340,7 @@ function hi(e) {
|
|
|
3254
3340
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3255
3341
|
}
|
|
3256
3342
|
d = d.offset(r * i).limit(i);
|
|
3257
|
-
let f = (await d.selectAll().execute()).map(
|
|
3343
|
+
let f = (await d.selectAll().execute()).map(B);
|
|
3258
3344
|
if (!a) return {
|
|
3259
3345
|
refresh_tokens: f,
|
|
3260
3346
|
start: 0,
|
|
@@ -3272,57 +3358,90 @@ function hi(e) {
|
|
|
3272
3358
|
}
|
|
3273
3359
|
//#endregion
|
|
3274
3360
|
//#region src/refreshTokens/index.ts
|
|
3275
|
-
function
|
|
3361
|
+
function yi(e) {
|
|
3276
3362
|
return {
|
|
3277
|
-
create:
|
|
3278
|
-
get:
|
|
3279
|
-
getByLookup:
|
|
3280
|
-
list:
|
|
3281
|
-
remove:
|
|
3282
|
-
revokeByLoginSession:
|
|
3283
|
-
revokeBySession:
|
|
3284
|
-
revokeByUser:
|
|
3285
|
-
revokeFamily:
|
|
3286
|
-
update:
|
|
3363
|
+
create: di(e),
|
|
3364
|
+
get: li(e),
|
|
3365
|
+
getByLookup: ui(e),
|
|
3366
|
+
list: vi(e),
|
|
3367
|
+
remove: fi(e),
|
|
3368
|
+
revokeByLoginSession: pi(e),
|
|
3369
|
+
revokeBySession: mi(e),
|
|
3370
|
+
revokeByUser: hi(e),
|
|
3371
|
+
revokeFamily: gi(e),
|
|
3372
|
+
update: _i(e)
|
|
3287
3373
|
};
|
|
3288
3374
|
}
|
|
3289
3375
|
//#endregion
|
|
3290
3376
|
//#region src/cleanup.ts
|
|
3291
|
-
var
|
|
3292
|
-
function
|
|
3377
|
+
var bi = 10080 * 60 * 1e3, V = 1e3;
|
|
3378
|
+
function xi(e) {
|
|
3293
3379
|
return async (t) => {
|
|
3294
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3380
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - bi, a = (t) => async () => {
|
|
3381
|
+
let a = e.deleteFrom("refresh_tokens").where(t, "<", i);
|
|
3382
|
+
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3383
|
+
let o = await a.limit(V).execute();
|
|
3384
|
+
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3385
|
+
}, o = (t) => async () => {
|
|
3386
|
+
let a = e.deleteFrom("sessions").where(t, "<", i);
|
|
3387
|
+
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3388
|
+
let o = await a.limit(V).execute();
|
|
3389
|
+
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3390
|
+
}, s = [
|
|
3391
|
+
{
|
|
3392
|
+
table: "login_sessions",
|
|
3393
|
+
label: "login_sessions.expires_at_ts",
|
|
3394
|
+
deleteBatch: async () => {
|
|
3395
|
+
let t = e.deleteFrom("login_sessions").where("expires_at_ts", "<", i);
|
|
3396
|
+
n && (t = t.where("tenant_id", "=", n)), r && (t = t.where("user_id", "=", r));
|
|
3397
|
+
let a = await t.limit(V).execute();
|
|
3398
|
+
return Number(a[0]?.numDeletedRows ?? 0);
|
|
3399
|
+
}
|
|
3400
|
+
},
|
|
3401
|
+
{
|
|
3402
|
+
table: "refresh_tokens",
|
|
3403
|
+
label: "refresh_tokens.expires_at_ts",
|
|
3404
|
+
deleteBatch: a("expires_at_ts")
|
|
3405
|
+
},
|
|
3406
|
+
{
|
|
3407
|
+
table: "refresh_tokens",
|
|
3408
|
+
label: "refresh_tokens.idle_expires_at_ts",
|
|
3409
|
+
deleteBatch: a("idle_expires_at_ts")
|
|
3410
|
+
},
|
|
3411
|
+
{
|
|
3412
|
+
table: "sessions",
|
|
3413
|
+
label: "sessions.expires_at_ts",
|
|
3414
|
+
deleteBatch: o("expires_at_ts")
|
|
3415
|
+
},
|
|
3416
|
+
{
|
|
3417
|
+
table: "sessions",
|
|
3418
|
+
label: "sessions.idle_expires_at_ts",
|
|
3419
|
+
deleteBatch: o("idle_expires_at_ts")
|
|
3309
3420
|
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3421
|
+
].map((e) => ({
|
|
3422
|
+
...e,
|
|
3423
|
+
deleted: 0,
|
|
3424
|
+
drained: !1,
|
|
3425
|
+
failed: !1
|
|
3426
|
+
})), c = 0;
|
|
3427
|
+
for (; c < 300 && s.some((e) => !e.drained);) for (let e of s) if (!(e.drained || c >= 300)) {
|
|
3428
|
+
c += 1;
|
|
3429
|
+
try {
|
|
3430
|
+
let t = await e.deleteBatch();
|
|
3431
|
+
e.deleted += t, t < V && (e.drained = !0);
|
|
3432
|
+
} catch (t) {
|
|
3433
|
+
e.failed = !0, e.drained = !0, console.error(`Error during session cleanup (${e.label}):`, t);
|
|
3316
3434
|
}
|
|
3317
|
-
(t > 0 || o > 0 || s > 0) && console.log(`Session cleanup: deleted ${t} refresh_tokens, ${o} sessions, ${s} login_sessions`);
|
|
3318
|
-
} catch (e) {
|
|
3319
|
-
console.error("Error during session cleanup:", e);
|
|
3320
3435
|
}
|
|
3436
|
+
let l = /* @__PURE__ */ new Map();
|
|
3437
|
+
for (let e of s) l.set(e.table, (l.get(e.table) ?? 0) + e.deleted);
|
|
3438
|
+
let u = [...l].map(([e, t]) => `${t} ${e}`).join(", "), d = s.filter((e) => e.failed).map((e) => e.label), f = s.filter((e) => !e.drained).map((e) => e.label);
|
|
3439
|
+
d.length > 0 ? console.warn(`Session cleanup: ${d.join(", ")} failed. Deleted ${u}`) : f.length > 0 ? console.warn(`Session cleanup: batch budget of 300 exhausted before ${f.join(", ")} drained. Deleted ${u}`) : s.some((e) => e.deleted > 0) && console.log(`Session cleanup: deleted ${u}`);
|
|
3321
3440
|
};
|
|
3322
3441
|
}
|
|
3323
3442
|
//#endregion
|
|
3324
3443
|
//#region src/forms/create.ts
|
|
3325
|
-
function
|
|
3444
|
+
function Si(e) {
|
|
3326
3445
|
return async (n, r, i) => {
|
|
3327
3446
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3328
3447
|
id: a?.id ?? t(),
|
|
@@ -3341,10 +3460,10 @@ function yi(e) {
|
|
|
3341
3460
|
}
|
|
3342
3461
|
//#endregion
|
|
3343
3462
|
//#region src/forms/list.ts
|
|
3344
|
-
function
|
|
3463
|
+
function Ci(e) {
|
|
3345
3464
|
return async (t, n = {}) => {
|
|
3346
3465
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3347
|
-
s && (c =
|
|
3466
|
+
s && (c = O(e, c, s, []));
|
|
3348
3467
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3349
3468
|
let t = { ...e };
|
|
3350
3469
|
if (typeof t.nodes == "string") try {
|
|
@@ -3375,7 +3494,7 @@ function bi(e) {
|
|
|
3375
3494
|
}
|
|
3376
3495
|
//#endregion
|
|
3377
3496
|
//#region src/forms/remove.ts
|
|
3378
|
-
function
|
|
3497
|
+
function wi(e) {
|
|
3379
3498
|
return async (t, n) => {
|
|
3380
3499
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3381
3500
|
return r > 0;
|
|
@@ -3383,7 +3502,7 @@ function xi(e) {
|
|
|
3383
3502
|
}
|
|
3384
3503
|
//#endregion
|
|
3385
3504
|
//#region src/forms/get.ts
|
|
3386
|
-
function
|
|
3505
|
+
function Ti(e) {
|
|
3387
3506
|
return async (t, n) => {
|
|
3388
3507
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3389
3508
|
if (!r) return null;
|
|
@@ -3402,7 +3521,7 @@ function Si(e) {
|
|
|
3402
3521
|
}
|
|
3403
3522
|
//#endregion
|
|
3404
3523
|
//#region src/forms/update.ts
|
|
3405
|
-
function
|
|
3524
|
+
function Ei(e) {
|
|
3406
3525
|
return async (t, n, r) => {
|
|
3407
3526
|
let i = {
|
|
3408
3527
|
...r,
|
|
@@ -3419,22 +3538,22 @@ function Ci(e) {
|
|
|
3419
3538
|
}
|
|
3420
3539
|
//#endregion
|
|
3421
3540
|
//#region src/forms/index.ts
|
|
3422
|
-
function
|
|
3541
|
+
function Di(e) {
|
|
3423
3542
|
return {
|
|
3424
|
-
create:
|
|
3425
|
-
get:
|
|
3426
|
-
list:
|
|
3427
|
-
remove:
|
|
3428
|
-
update:
|
|
3543
|
+
create: Si(e),
|
|
3544
|
+
get: Ti(e),
|
|
3545
|
+
list: Ci(e),
|
|
3546
|
+
remove: wi(e),
|
|
3547
|
+
update: Ei(e)
|
|
3429
3548
|
};
|
|
3430
3549
|
}
|
|
3431
3550
|
//#endregion
|
|
3432
3551
|
//#region src/resourceServers/create.ts
|
|
3433
|
-
function
|
|
3552
|
+
function Oi(e) {
|
|
3434
3553
|
return async (t, n, r) => {
|
|
3435
3554
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3436
3555
|
...n,
|
|
3437
|
-
id: i?.id ?? n.id ??
|
|
3556
|
+
id: i?.id ?? n.id ?? Ne(),
|
|
3438
3557
|
created_at: o,
|
|
3439
3558
|
updated_at: s
|
|
3440
3559
|
}, u = de.parse(c), { verificationKey: d, scopes: f, options: p, skip_consent_for_verifiable_first_party_clients: m, allow_offline_access: h, is_system: g, metadata: _, ...v } = u, y = {
|
|
@@ -3455,7 +3574,7 @@ function Ti(e) {
|
|
|
3455
3574
|
}
|
|
3456
3575
|
//#endregion
|
|
3457
3576
|
//#region src/resourceServers/get.ts
|
|
3458
|
-
function
|
|
3577
|
+
function ki(e) {
|
|
3459
3578
|
return async (t, n) => {
|
|
3460
3579
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3461
3580
|
if (!r) return null;
|
|
@@ -3474,15 +3593,15 @@ function Ei(e) {
|
|
|
3474
3593
|
}
|
|
3475
3594
|
//#endregion
|
|
3476
3595
|
//#region src/resourceServers/list.ts
|
|
3477
|
-
function
|
|
3596
|
+
function Ai(e) {
|
|
3478
3597
|
return async (t, n = {}) => {
|
|
3479
3598
|
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);
|
|
3480
3599
|
if (s) {
|
|
3481
|
-
let t = s.trim(), n = t.split(/\s+/), r = n.length === 1 ? n[0] : void 0, i = r ? r.match(/^(-)?(name|identifier):(.*)$/) : null, a = i ?
|
|
3600
|
+
let t = s.trim(), n = t.split(/\s+/), r = n.length === 1 ? n[0] : void 0, i = r ? r.match(/^(-)?(name|identifier):(.*)$/) : null, a = i ? w(i[3]) : "", o = /^(>=|>|<=|<)/.test(a || "");
|
|
3482
3601
|
if (i && !o) {
|
|
3483
3602
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3484
3603
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3485
|
-
} else c =
|
|
3604
|
+
} else c = O(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3486
3605
|
}
|
|
3487
3606
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3488
3607
|
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({
|
|
@@ -3514,7 +3633,7 @@ function Di(e) {
|
|
|
3514
3633
|
}
|
|
3515
3634
|
//#endregion
|
|
3516
3635
|
//#region src/resourceServers/remove.ts
|
|
3517
|
-
function
|
|
3636
|
+
function ji(e) {
|
|
3518
3637
|
return async (t, n) => {
|
|
3519
3638
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3520
3639
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3522,7 +3641,7 @@ function Oi(e) {
|
|
|
3522
3641
|
}
|
|
3523
3642
|
//#endregion
|
|
3524
3643
|
//#region src/resourceServers/update.ts
|
|
3525
|
-
function
|
|
3644
|
+
function Mi(e) {
|
|
3526
3645
|
return async (t, n, r) => {
|
|
3527
3646
|
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 = {
|
|
3528
3647
|
...d,
|
|
@@ -3542,18 +3661,18 @@ function ki(e) {
|
|
|
3542
3661
|
}
|
|
3543
3662
|
//#endregion
|
|
3544
3663
|
//#region src/resourceServers/index.ts
|
|
3545
|
-
function
|
|
3664
|
+
function Ni(e) {
|
|
3546
3665
|
return {
|
|
3547
|
-
create:
|
|
3548
|
-
get:
|
|
3549
|
-
list:
|
|
3550
|
-
remove:
|
|
3551
|
-
update:
|
|
3666
|
+
create: Oi(e),
|
|
3667
|
+
get: ki(e),
|
|
3668
|
+
list: Ai(e),
|
|
3669
|
+
remove: ji(e),
|
|
3670
|
+
update: Mi(e)
|
|
3552
3671
|
};
|
|
3553
3672
|
}
|
|
3554
3673
|
//#endregion
|
|
3555
3674
|
//#region src/roles/create.ts
|
|
3556
|
-
function
|
|
3675
|
+
function Pi(e) {
|
|
3557
3676
|
return async (n, r, i) => {
|
|
3558
3677
|
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 = {
|
|
3559
3678
|
id: l,
|
|
@@ -3576,7 +3695,7 @@ function ji(e) {
|
|
|
3576
3695
|
}
|
|
3577
3696
|
//#endregion
|
|
3578
3697
|
//#region src/roles/get.ts
|
|
3579
|
-
function
|
|
3698
|
+
function Fi(e) {
|
|
3580
3699
|
return async (t, n) => {
|
|
3581
3700
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3582
3701
|
if (!r) return null;
|
|
@@ -3590,10 +3709,10 @@ function Mi(e) {
|
|
|
3590
3709
|
}
|
|
3591
3710
|
//#endregion
|
|
3592
3711
|
//#region src/roles/list.ts
|
|
3593
|
-
function
|
|
3712
|
+
function Ii(e) {
|
|
3594
3713
|
return async (t, n) => {
|
|
3595
3714
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3596
|
-
n.q && (r =
|
|
3715
|
+
n.q && (r = O(e, r, n.q, ["name"]));
|
|
3597
3716
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3598
3717
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3599
3718
|
return {
|
|
@@ -3619,7 +3738,7 @@ function Ni(e) {
|
|
|
3619
3738
|
}
|
|
3620
3739
|
//#endregion
|
|
3621
3740
|
//#region src/roles/update.ts
|
|
3622
|
-
function
|
|
3741
|
+
function Li(e) {
|
|
3623
3742
|
return async (t, n, r) => {
|
|
3624
3743
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3625
3744
|
...o,
|
|
@@ -3632,7 +3751,7 @@ function Pi(e) {
|
|
|
3632
3751
|
}
|
|
3633
3752
|
//#endregion
|
|
3634
3753
|
//#region src/roles/remove.ts
|
|
3635
|
-
function
|
|
3754
|
+
function Ri(e) {
|
|
3636
3755
|
return async (t, n) => {
|
|
3637
3756
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3638
3757
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3640,23 +3759,23 @@ function Fi(e) {
|
|
|
3640
3759
|
}
|
|
3641
3760
|
//#endregion
|
|
3642
3761
|
//#region src/roles/index.ts
|
|
3643
|
-
function
|
|
3762
|
+
function zi(e) {
|
|
3644
3763
|
return {
|
|
3645
|
-
create:
|
|
3646
|
-
get:
|
|
3647
|
-
list:
|
|
3648
|
-
update:
|
|
3649
|
-
remove:
|
|
3764
|
+
create: Pi(e),
|
|
3765
|
+
get: Fi(e),
|
|
3766
|
+
list: Ii(e),
|
|
3767
|
+
update: Li(e),
|
|
3768
|
+
remove: Ri(e)
|
|
3650
3769
|
};
|
|
3651
3770
|
}
|
|
3652
3771
|
//#endregion
|
|
3653
3772
|
//#region src/role-permissions/assign.ts
|
|
3654
|
-
function
|
|
3773
|
+
function Bi(e) {
|
|
3655
3774
|
if (typeof e != "object" || !e) return !1;
|
|
3656
3775
|
let { code: t, message: n } = e;
|
|
3657
3776
|
return t === "SQLITE_CONSTRAINT" || t === "SQLITE_CONSTRAINT_PRIMARYKEY" || t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || t === "23505" ? !0 : typeof n == "string" && (n.includes("UNIQUE constraint failed") || n.includes("Duplicate entry") || n.includes("duplicate key") || n.includes("AlreadyExists"));
|
|
3658
3777
|
}
|
|
3659
|
-
function
|
|
3778
|
+
function Vi(e) {
|
|
3660
3779
|
return async (t, n, r, i) => {
|
|
3661
3780
|
if (r.length === 0) return !0;
|
|
3662
3781
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3673,7 +3792,7 @@ function Ri(e) {
|
|
|
3673
3792
|
try {
|
|
3674
3793
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3675
3794
|
} catch (e) {
|
|
3676
|
-
if (
|
|
3795
|
+
if (Bi(e)) continue;
|
|
3677
3796
|
throw e;
|
|
3678
3797
|
}
|
|
3679
3798
|
}
|
|
@@ -3685,7 +3804,7 @@ function Ri(e) {
|
|
|
3685
3804
|
}
|
|
3686
3805
|
//#endregion
|
|
3687
3806
|
//#region src/role-permissions/remove.ts
|
|
3688
|
-
function
|
|
3807
|
+
function Hi(e) {
|
|
3689
3808
|
return async (t, n, r) => {
|
|
3690
3809
|
if (r.length === 0) return !0;
|
|
3691
3810
|
try {
|
|
@@ -3697,7 +3816,7 @@ function zi(e) {
|
|
|
3697
3816
|
}
|
|
3698
3817
|
//#endregion
|
|
3699
3818
|
//#region src/role-permissions/list.ts
|
|
3700
|
-
function
|
|
3819
|
+
function Ui(e) {
|
|
3701
3820
|
return async (t, n, r = {}) => {
|
|
3702
3821
|
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([
|
|
3703
3822
|
"role_permissions.role_id",
|
|
@@ -3718,16 +3837,16 @@ function Bi(e) {
|
|
|
3718
3837
|
}
|
|
3719
3838
|
//#endregion
|
|
3720
3839
|
//#region src/role-permissions/index.ts
|
|
3721
|
-
function
|
|
3840
|
+
function Wi(e) {
|
|
3722
3841
|
return {
|
|
3723
|
-
assign:
|
|
3724
|
-
remove:
|
|
3725
|
-
list:
|
|
3842
|
+
assign: Vi(e),
|
|
3843
|
+
remove: Hi(e),
|
|
3844
|
+
list: Ui(e)
|
|
3726
3845
|
};
|
|
3727
3846
|
}
|
|
3728
3847
|
//#endregion
|
|
3729
3848
|
//#region src/grants/create.ts
|
|
3730
|
-
function
|
|
3849
|
+
function Gi(e) {
|
|
3731
3850
|
return async (n, r) => {
|
|
3732
3851
|
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();
|
|
3733
3852
|
if (s) {
|
|
@@ -3764,7 +3883,7 @@ function Hi(e) {
|
|
|
3764
3883
|
}
|
|
3765
3884
|
//#endregion
|
|
3766
3885
|
//#region src/grants/get.ts
|
|
3767
|
-
function
|
|
3886
|
+
function Ki(e) {
|
|
3768
3887
|
return async (t, n, r, i) => {
|
|
3769
3888
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3770
3889
|
return a ? {
|
|
@@ -3778,10 +3897,10 @@ function Ui(e) {
|
|
|
3778
3897
|
}
|
|
3779
3898
|
//#endregion
|
|
3780
3899
|
//#region src/grants/list.ts
|
|
3781
|
-
function
|
|
3900
|
+
function qi(e) {
|
|
3782
3901
|
return async (t, n = {}) => {
|
|
3783
3902
|
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);
|
|
3784
|
-
c && (l =
|
|
3903
|
+
c && (l = O(e, l, c, [
|
|
3785
3904
|
"user_id",
|
|
3786
3905
|
"client_id",
|
|
3787
3906
|
"audience"
|
|
@@ -3816,26 +3935,26 @@ function Wi(e) {
|
|
|
3816
3935
|
}
|
|
3817
3936
|
//#endregion
|
|
3818
3937
|
//#region src/grants/remove.ts
|
|
3819
|
-
function
|
|
3938
|
+
function Ji(e) {
|
|
3820
3939
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3821
3940
|
}
|
|
3822
|
-
function
|
|
3941
|
+
function Yi(e) {
|
|
3823
3942
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3824
3943
|
}
|
|
3825
3944
|
//#endregion
|
|
3826
3945
|
//#region src/grants/index.ts
|
|
3827
|
-
function
|
|
3946
|
+
function Xi(e) {
|
|
3828
3947
|
return {
|
|
3829
|
-
create:
|
|
3830
|
-
get:
|
|
3831
|
-
list:
|
|
3832
|
-
remove:
|
|
3833
|
-
removeByUser:
|
|
3948
|
+
create: Gi(e),
|
|
3949
|
+
get: Ki(e),
|
|
3950
|
+
list: qi(e),
|
|
3951
|
+
remove: Ji(e),
|
|
3952
|
+
removeByUser: Yi(e)
|
|
3834
3953
|
};
|
|
3835
3954
|
}
|
|
3836
3955
|
//#endregion
|
|
3837
3956
|
//#region src/user-permissions/create.ts
|
|
3838
|
-
function
|
|
3957
|
+
function Zi(e) {
|
|
3839
3958
|
return async (t, n, r, i, a) => {
|
|
3840
3959
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3841
3960
|
try {
|
|
@@ -3855,7 +3974,7 @@ function Ji(e) {
|
|
|
3855
3974
|
}
|
|
3856
3975
|
//#endregion
|
|
3857
3976
|
//#region src/user-permissions/remove.ts
|
|
3858
|
-
function
|
|
3977
|
+
function Qi(e) {
|
|
3859
3978
|
return async (t, n, r, i) => {
|
|
3860
3979
|
try {
|
|
3861
3980
|
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);
|
|
@@ -3867,7 +3986,7 @@ function Yi(e) {
|
|
|
3867
3986
|
}
|
|
3868
3987
|
//#endregion
|
|
3869
3988
|
//#region src/user-permissions/list.ts
|
|
3870
|
-
function
|
|
3989
|
+
function $i(e) {
|
|
3871
3990
|
return async (t, n, r, i) => {
|
|
3872
3991
|
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([
|
|
3873
3992
|
"user_permissions.resource_server_identifier",
|
|
@@ -3890,17 +4009,17 @@ function Xi(e) {
|
|
|
3890
4009
|
}
|
|
3891
4010
|
//#endregion
|
|
3892
4011
|
//#region src/user-permissions/index.ts
|
|
3893
|
-
function
|
|
4012
|
+
function ea(e) {
|
|
3894
4013
|
return {
|
|
3895
|
-
create:
|
|
3896
|
-
remove:
|
|
3897
|
-
list:
|
|
4014
|
+
create: Zi(e),
|
|
4015
|
+
remove: Qi(e),
|
|
4016
|
+
list: $i(e)
|
|
3898
4017
|
};
|
|
3899
4018
|
}
|
|
3900
4019
|
//#endregion
|
|
3901
4020
|
//#region src/user-permissions/adapter.ts
|
|
3902
|
-
function
|
|
3903
|
-
let t =
|
|
4021
|
+
function ta(e) {
|
|
4022
|
+
let t = ea(e);
|
|
3904
4023
|
return {
|
|
3905
4024
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3906
4025
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3909,7 +4028,7 @@ function Qi(e) {
|
|
|
3909
4028
|
}
|
|
3910
4029
|
//#endregion
|
|
3911
4030
|
//#region src/user-roles/list.ts
|
|
3912
|
-
function
|
|
4031
|
+
function na(e) {
|
|
3913
4032
|
return async (t, n, r, i) => {
|
|
3914
4033
|
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([
|
|
3915
4034
|
"r.id",
|
|
@@ -3923,11 +4042,11 @@ function $i(e) {
|
|
|
3923
4042
|
}
|
|
3924
4043
|
//#endregion
|
|
3925
4044
|
//#region src/user-roles/list-users.ts
|
|
3926
|
-
function
|
|
4045
|
+
function ra(e) {
|
|
3927
4046
|
return async (t, n, r) => {
|
|
3928
4047
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3929
|
-
if (
|
|
3930
|
-
let { rows: e, limit: t, next: n } = await
|
|
4048
|
+
if (P(r)) {
|
|
4049
|
+
let { rows: e, limit: t, next: n } = await F(i, r, {
|
|
3931
4050
|
sortColumn: "user_id",
|
|
3932
4051
|
sortOrder: "asc",
|
|
3933
4052
|
idColumn: "user_id"
|
|
@@ -3951,7 +4070,7 @@ function ea(e) {
|
|
|
3951
4070
|
}
|
|
3952
4071
|
//#endregion
|
|
3953
4072
|
//#region src/user-roles/create.ts
|
|
3954
|
-
function
|
|
4073
|
+
function ia(e) {
|
|
3955
4074
|
return async (t, n, r, i, a) => {
|
|
3956
4075
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3957
4076
|
try {
|
|
@@ -3969,7 +4088,7 @@ function ta(e) {
|
|
|
3969
4088
|
}
|
|
3970
4089
|
//#endregion
|
|
3971
4090
|
//#region src/user-roles/remove.ts
|
|
3972
|
-
function
|
|
4091
|
+
function aa(e) {
|
|
3973
4092
|
return async (t, n, r, i) => {
|
|
3974
4093
|
try {
|
|
3975
4094
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3981,18 +4100,18 @@ function na(e) {
|
|
|
3981
4100
|
}
|
|
3982
4101
|
//#endregion
|
|
3983
4102
|
//#region src/user-roles/index.ts
|
|
3984
|
-
function
|
|
4103
|
+
function oa(e) {
|
|
3985
4104
|
return {
|
|
3986
|
-
list:
|
|
3987
|
-
listUsers:
|
|
3988
|
-
create:
|
|
3989
|
-
remove:
|
|
4105
|
+
list: na(e),
|
|
4106
|
+
listUsers: ra(e),
|
|
4107
|
+
create: ia(e),
|
|
4108
|
+
remove: aa(e)
|
|
3990
4109
|
};
|
|
3991
4110
|
}
|
|
3992
4111
|
//#endregion
|
|
3993
4112
|
//#region src/user-roles/adapter.ts
|
|
3994
|
-
function
|
|
3995
|
-
let t =
|
|
4113
|
+
function sa(e) {
|
|
4114
|
+
let t = oa(e);
|
|
3996
4115
|
return {
|
|
3997
4116
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3998
4117
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4002,11 +4121,11 @@ function ia(e) {
|
|
|
4002
4121
|
}
|
|
4003
4122
|
//#endregion
|
|
4004
4123
|
//#region src/organizations/create.ts
|
|
4005
|
-
function
|
|
4124
|
+
function ca(e) {
|
|
4006
4125
|
return async (t, n, r) => {
|
|
4007
4126
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4008
4127
|
...n,
|
|
4009
|
-
id: i?.id || n.id ||
|
|
4128
|
+
id: i?.id || n.id || Oe(),
|
|
4010
4129
|
tenant_id: t,
|
|
4011
4130
|
created_at: i?.created_at ?? a,
|
|
4012
4131
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4018,7 +4137,7 @@ function aa(e) {
|
|
|
4018
4137
|
try {
|
|
4019
4138
|
await e.insertInto("organizations").values(o).execute();
|
|
4020
4139
|
} catch (e) {
|
|
4021
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4140
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new T(409, { message: "Organization already exists" }) : e;
|
|
4022
4141
|
}
|
|
4023
4142
|
return {
|
|
4024
4143
|
...n,
|
|
@@ -4030,7 +4149,7 @@ function aa(e) {
|
|
|
4030
4149
|
}
|
|
4031
4150
|
//#endregion
|
|
4032
4151
|
//#region src/organizations/get.ts
|
|
4033
|
-
function
|
|
4152
|
+
function la(e) {
|
|
4034
4153
|
return async (t, n) => {
|
|
4035
4154
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4036
4155
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4044,16 +4163,16 @@ function oa(e) {
|
|
|
4044
4163
|
}
|
|
4045
4164
|
//#endregion
|
|
4046
4165
|
//#region src/organizations/list.ts
|
|
4047
|
-
var
|
|
4048
|
-
function
|
|
4166
|
+
var H = ["name", "display_name"];
|
|
4167
|
+
function ua(e) {
|
|
4049
4168
|
return async (t, n) => {
|
|
4050
4169
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4051
4170
|
if (n?.q) {
|
|
4052
|
-
let t = S(n.q,
|
|
4053
|
-
t && (r =
|
|
4171
|
+
let t = S(n.q, H);
|
|
4172
|
+
t && (r = O(e, r, t, H));
|
|
4054
4173
|
}
|
|
4055
|
-
if (
|
|
4056
|
-
let { rows: e, limit: t, next: i } = await
|
|
4174
|
+
if (P(n)) {
|
|
4175
|
+
let { rows: e, limit: t, next: i } = await F(r.selectAll(), n, {
|
|
4057
4176
|
sortColumn: "created_at",
|
|
4058
4177
|
sortOrder: "desc"
|
|
4059
4178
|
}), a = e.map((e) => l({
|
|
@@ -4086,8 +4205,8 @@ function sa(e) {
|
|
|
4086
4205
|
if (n?.include_totals) {
|
|
4087
4206
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4088
4207
|
if (n?.q) {
|
|
4089
|
-
let t = S(n.q,
|
|
4090
|
-
t && (r =
|
|
4208
|
+
let t = S(n.q, H);
|
|
4209
|
+
t && (r = O(e, r, t, H));
|
|
4091
4210
|
}
|
|
4092
4211
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4093
4212
|
u = Number(i?.count || 0);
|
|
@@ -4110,7 +4229,7 @@ function sa(e) {
|
|
|
4110
4229
|
}
|
|
4111
4230
|
//#endregion
|
|
4112
4231
|
//#region src/organizations/remove.ts
|
|
4113
|
-
function
|
|
4232
|
+
function da(e) {
|
|
4114
4233
|
return async (t, n) => {
|
|
4115
4234
|
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4116
4235
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -4118,7 +4237,7 @@ function ca(e) {
|
|
|
4118
4237
|
}
|
|
4119
4238
|
//#endregion
|
|
4120
4239
|
//#region src/organizations/update.ts
|
|
4121
|
-
function
|
|
4240
|
+
function fa(e) {
|
|
4122
4241
|
return async (t, n, r) => {
|
|
4123
4242
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4124
4243
|
...c,
|
|
@@ -4134,18 +4253,18 @@ function la(e) {
|
|
|
4134
4253
|
}
|
|
4135
4254
|
//#endregion
|
|
4136
4255
|
//#region src/organizations/index.ts
|
|
4137
|
-
function
|
|
4256
|
+
function pa(e) {
|
|
4138
4257
|
return {
|
|
4139
|
-
create:
|
|
4140
|
-
get:
|
|
4141
|
-
list:
|
|
4142
|
-
remove:
|
|
4143
|
-
update:
|
|
4258
|
+
create: ca(e),
|
|
4259
|
+
get: la(e),
|
|
4260
|
+
list: ua(e),
|
|
4261
|
+
remove: da(e),
|
|
4262
|
+
update: fa(e)
|
|
4144
4263
|
};
|
|
4145
4264
|
}
|
|
4146
4265
|
//#endregion
|
|
4147
4266
|
//#region src/organization-connections/index.ts
|
|
4148
|
-
function
|
|
4267
|
+
function U(e, t) {
|
|
4149
4268
|
return {
|
|
4150
4269
|
connection_id: e.connection_id,
|
|
4151
4270
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4159,14 +4278,14 @@ function B(e, t) {
|
|
|
4159
4278
|
updated_at: e.updated_at
|
|
4160
4279
|
};
|
|
4161
4280
|
}
|
|
4162
|
-
async function
|
|
4281
|
+
async function W(e, t, n) {
|
|
4163
4282
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4164
4283
|
if (r) return {
|
|
4165
4284
|
name: r.name,
|
|
4166
4285
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4167
4286
|
};
|
|
4168
4287
|
}
|
|
4169
|
-
function
|
|
4288
|
+
function ma(e) {
|
|
4170
4289
|
return {
|
|
4171
4290
|
async create(t, n, r, i) {
|
|
4172
4291
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4179,19 +4298,19 @@ function da(e) {
|
|
|
4179
4298
|
created_at: a?.created_at ?? o,
|
|
4180
4299
|
updated_at: a?.updated_at ?? o
|
|
4181
4300
|
};
|
|
4182
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4301
|
+
return await e.insertInto("organization_connections").values(s).execute(), U(s, await W(e, t, r.connection_id));
|
|
4183
4302
|
},
|
|
4184
4303
|
async list(t, n) {
|
|
4185
4304
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4186
4305
|
for (let n of r) {
|
|
4187
|
-
let r = await
|
|
4188
|
-
i.push(
|
|
4306
|
+
let r = await W(e, t, n.connection_id);
|
|
4307
|
+
i.push(U(n, r));
|
|
4189
4308
|
}
|
|
4190
4309
|
return i;
|
|
4191
4310
|
},
|
|
4192
4311
|
async get(t, n, r) {
|
|
4193
4312
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4194
|
-
return i ?
|
|
4313
|
+
return i ? U(i, await W(e, t, r)) : null;
|
|
4195
4314
|
},
|
|
4196
4315
|
async update(t, n, r, i) {
|
|
4197
4316
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4199,7 +4318,7 @@ function da(e) {
|
|
|
4199
4318
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4200
4319
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4201
4320
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4202
|
-
return s ?
|
|
4321
|
+
return s ? U(s, await W(e, t, r)) : null;
|
|
4203
4322
|
},
|
|
4204
4323
|
async remove(t, n, r) {
|
|
4205
4324
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4209,7 +4328,7 @@ function da(e) {
|
|
|
4209
4328
|
}
|
|
4210
4329
|
//#endregion
|
|
4211
4330
|
//#region src/user-organizations/create.ts
|
|
4212
|
-
function
|
|
4331
|
+
function ha(e) {
|
|
4213
4332
|
return async (n, r, i) => {
|
|
4214
4333
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4215
4334
|
id: a?.id ?? t(),
|
|
@@ -4222,14 +4341,14 @@ function fa(e) {
|
|
|
4222
4341
|
try {
|
|
4223
4342
|
await e.insertInto("user_organizations").values(s).execute();
|
|
4224
4343
|
} catch (e) {
|
|
4225
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new
|
|
4344
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new T(409, { message: "User is already a member of this organization" }) : e;
|
|
4226
4345
|
}
|
|
4227
4346
|
return { ...s };
|
|
4228
4347
|
};
|
|
4229
4348
|
}
|
|
4230
4349
|
//#endregion
|
|
4231
4350
|
//#region src/user-organizations/get.ts
|
|
4232
|
-
function
|
|
4351
|
+
function ga(e) {
|
|
4233
4352
|
return async (t, n) => {
|
|
4234
4353
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4235
4354
|
return r ? {
|
|
@@ -4243,13 +4362,13 @@ function pa(e) {
|
|
|
4243
4362
|
}
|
|
4244
4363
|
//#endregion
|
|
4245
4364
|
//#region src/user-organizations/list.ts
|
|
4246
|
-
function
|
|
4247
|
-
return
|
|
4365
|
+
function G(e, t) {
|
|
4366
|
+
return w(e.slice(t.length + 1));
|
|
4248
4367
|
}
|
|
4249
|
-
function
|
|
4368
|
+
function _a(e) {
|
|
4250
4369
|
return async (t, n) => {
|
|
4251
4370
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4252
|
-
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=",
|
|
4371
|
+
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", G(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", G(n.q, "organization_id"))));
|
|
4253
4372
|
let i = (e) => ({
|
|
4254
4373
|
id: e.id,
|
|
4255
4374
|
user_id: e.user_id,
|
|
@@ -4257,8 +4376,8 @@ function ma(e) {
|
|
|
4257
4376
|
created_at: e.created_at,
|
|
4258
4377
|
updated_at: e.updated_at
|
|
4259
4378
|
});
|
|
4260
|
-
if (
|
|
4261
|
-
let { rows: e, limit: t, next: a } = await
|
|
4379
|
+
if (P(n)) {
|
|
4380
|
+
let { rows: e, limit: t, next: a } = await F(r, n, {
|
|
4262
4381
|
sortColumn: "created_at",
|
|
4263
4382
|
sortOrder: "desc"
|
|
4264
4383
|
});
|
|
@@ -4271,7 +4390,7 @@ function ma(e) {
|
|
|
4271
4390
|
};
|
|
4272
4391
|
}
|
|
4273
4392
|
let a = n?.page || 0, o = n?.per_page || 50, s = a * o, c = await r.orderBy("created_at", "desc").limit(o).offset(s).execute(), l = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
|
|
4274
|
-
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=",
|
|
4393
|
+
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=", G(n.q, "user_id")) : n.q.startsWith("organization_id:") && (l = l.where("organization_id", "=", G(n.q, "organization_id"))));
|
|
4275
4394
|
let u = await l.executeTakeFirst();
|
|
4276
4395
|
return {
|
|
4277
4396
|
userOrganizations: c.map(i),
|
|
@@ -4283,7 +4402,7 @@ function ma(e) {
|
|
|
4283
4402
|
}
|
|
4284
4403
|
//#endregion
|
|
4285
4404
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4286
|
-
function
|
|
4405
|
+
function va(e) {
|
|
4287
4406
|
return async (t, n, r) => {
|
|
4288
4407
|
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([
|
|
4289
4408
|
"organizations.id",
|
|
@@ -4320,12 +4439,12 @@ function ha(e) {
|
|
|
4320
4439
|
}
|
|
4321
4440
|
//#endregion
|
|
4322
4441
|
//#region src/user-organizations/remove.ts
|
|
4323
|
-
function
|
|
4442
|
+
function ya(e) {
|
|
4324
4443
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4325
4444
|
}
|
|
4326
4445
|
//#endregion
|
|
4327
4446
|
//#region src/user-organizations/update.ts
|
|
4328
|
-
function
|
|
4447
|
+
function ba(e) {
|
|
4329
4448
|
return async (t, n, r) => {
|
|
4330
4449
|
let i = {
|
|
4331
4450
|
...r,
|
|
@@ -4336,21 +4455,21 @@ function _a(e) {
|
|
|
4336
4455
|
}
|
|
4337
4456
|
//#endregion
|
|
4338
4457
|
//#region src/user-organizations/index.ts
|
|
4339
|
-
function
|
|
4458
|
+
function xa(e) {
|
|
4340
4459
|
return {
|
|
4341
|
-
create:
|
|
4342
|
-
get:
|
|
4343
|
-
list:
|
|
4344
|
-
listUserOrganizations:
|
|
4345
|
-
remove:
|
|
4346
|
-
update:
|
|
4460
|
+
create: ha(e),
|
|
4461
|
+
get: ga(e),
|
|
4462
|
+
list: _a(e),
|
|
4463
|
+
listUserOrganizations: va(e),
|
|
4464
|
+
remove: ya(e),
|
|
4465
|
+
update: ba(e)
|
|
4347
4466
|
};
|
|
4348
4467
|
}
|
|
4349
4468
|
//#endregion
|
|
4350
4469
|
//#region src/invites/create.ts
|
|
4351
|
-
function
|
|
4470
|
+
function Sa(e) {
|
|
4352
4471
|
return async (t, n, r) => {
|
|
4353
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4472
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Fe(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4354
4473
|
id: a,
|
|
4355
4474
|
tenant_id: t,
|
|
4356
4475
|
organization_id: n.organization_id,
|
|
@@ -4371,7 +4490,7 @@ function ya(e) {
|
|
|
4371
4490
|
try {
|
|
4372
4491
|
await e.insertInto("invites").values(l).execute();
|
|
4373
4492
|
} catch (e) {
|
|
4374
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4493
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new T(409, { message: "Invite already exists" }) : e;
|
|
4375
4494
|
}
|
|
4376
4495
|
return {
|
|
4377
4496
|
id: a,
|
|
@@ -4394,11 +4513,11 @@ function ya(e) {
|
|
|
4394
4513
|
}
|
|
4395
4514
|
//#endregion
|
|
4396
4515
|
//#region src/invites/get.ts
|
|
4397
|
-
function
|
|
4516
|
+
function Ca(e) {
|
|
4398
4517
|
return async (t, n) => {
|
|
4399
4518
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4400
4519
|
return r ? l({
|
|
4401
|
-
...
|
|
4520
|
+
...Ct(r, {
|
|
4402
4521
|
inviter: {},
|
|
4403
4522
|
invitee: {},
|
|
4404
4523
|
app_metadata: {},
|
|
@@ -4411,7 +4530,7 @@ function ba(e) {
|
|
|
4411
4530
|
}
|
|
4412
4531
|
//#endregion
|
|
4413
4532
|
//#region src/invites/list.ts
|
|
4414
|
-
function
|
|
4533
|
+
function wa(e) {
|
|
4415
4534
|
return async (t, n) => {
|
|
4416
4535
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4417
4536
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4419,7 +4538,7 @@ function xa(e) {
|
|
|
4419
4538
|
r = r.offset(e);
|
|
4420
4539
|
}
|
|
4421
4540
|
let i = (await r.execute()).map((e) => l({
|
|
4422
|
-
...
|
|
4541
|
+
...Ct(e, {
|
|
4423
4542
|
inviter: {},
|
|
4424
4543
|
invitee: {},
|
|
4425
4544
|
app_metadata: {},
|
|
@@ -4438,12 +4557,12 @@ function xa(e) {
|
|
|
4438
4557
|
}
|
|
4439
4558
|
//#endregion
|
|
4440
4559
|
//#region src/invites/remove.ts
|
|
4441
|
-
function
|
|
4560
|
+
function Ta(e) {
|
|
4442
4561
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4443
4562
|
}
|
|
4444
4563
|
//#endregion
|
|
4445
4564
|
//#region src/invites/update.ts
|
|
4446
|
-
function
|
|
4565
|
+
function Ea(e) {
|
|
4447
4566
|
return async (t, n, r) => {
|
|
4448
4567
|
let i = {};
|
|
4449
4568
|
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;
|
|
@@ -4451,35 +4570,35 @@ function Ca(e) {
|
|
|
4451
4570
|
}
|
|
4452
4571
|
//#endregion
|
|
4453
4572
|
//#region src/invites/index.ts
|
|
4454
|
-
function
|
|
4573
|
+
function Da(e) {
|
|
4455
4574
|
return {
|
|
4456
|
-
create:
|
|
4457
|
-
get:
|
|
4458
|
-
list:
|
|
4459
|
-
remove:
|
|
4460
|
-
update:
|
|
4575
|
+
create: Sa(e),
|
|
4576
|
+
get: Ca(e),
|
|
4577
|
+
list: wa(e),
|
|
4578
|
+
remove: Ta(e),
|
|
4579
|
+
update: Ea(e)
|
|
4461
4580
|
};
|
|
4462
4581
|
}
|
|
4463
4582
|
//#endregion
|
|
4464
4583
|
//#region src/stats/index.ts
|
|
4465
|
-
var
|
|
4466
|
-
function
|
|
4584
|
+
var Oa = ["s"], ka = ["pwd_leak"];
|
|
4585
|
+
function Aa(e) {
|
|
4467
4586
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4468
4587
|
}
|
|
4469
|
-
function
|
|
4588
|
+
function ja(e) {
|
|
4470
4589
|
return e.toISOString().split("T")[0];
|
|
4471
4590
|
}
|
|
4472
|
-
function
|
|
4591
|
+
function Ma(e) {
|
|
4473
4592
|
return {
|
|
4474
4593
|
async getDaily(t, n = {}) {
|
|
4475
4594
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4476
4595
|
o.setDate(o.getDate() - 30);
|
|
4477
|
-
let s = r ?
|
|
4596
|
+
let s = r ? Aa(r) : ja(o), c = i ? Aa(i) : ja(a), l = f`DATE(logs.date)`;
|
|
4478
4597
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4479
4598
|
l.as("date"),
|
|
4480
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4599
|
+
e.fn.sum(e.case().when("type", "in", Oa).then(1).else(0).end()).as("logins"),
|
|
4481
4600
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4482
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4601
|
+
e.fn.sum(e.case().when("type", "in", ka).then(1).else(0).end()).as("leaked_passwords"),
|
|
4483
4602
|
e.fn.min("date").as("first_event"),
|
|
4484
4603
|
e.fn.max("date").as("last_event")
|
|
4485
4604
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4493,13 +4612,13 @@ function ka(e) {
|
|
|
4493
4612
|
},
|
|
4494
4613
|
async getActiveUsers(t) {
|
|
4495
4614
|
let n = /* @__PURE__ */ new Date();
|
|
4496
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4615
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", Oa).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4497
4616
|
}
|
|
4498
4617
|
};
|
|
4499
4618
|
}
|
|
4500
4619
|
//#endregion
|
|
4501
4620
|
//#region src/analytics/index.ts
|
|
4502
|
-
var
|
|
4621
|
+
var Na = {
|
|
4503
4622
|
"active-users": ["s", "seacft"],
|
|
4504
4623
|
logins: [
|
|
4505
4624
|
"s",
|
|
@@ -4529,7 +4648,7 @@ var Aa = {
|
|
|
4529
4648
|
"fvr"
|
|
4530
4649
|
],
|
|
4531
4650
|
"codes-sent": ["cls", "cs"]
|
|
4532
|
-
},
|
|
4651
|
+
}, Pa = {
|
|
4533
4652
|
"active-users": {
|
|
4534
4653
|
alias: "active_users",
|
|
4535
4654
|
type: "UInt64",
|
|
@@ -4586,14 +4705,14 @@ var Aa = {
|
|
|
4586
4705
|
agg: "count"
|
|
4587
4706
|
}
|
|
4588
4707
|
};
|
|
4589
|
-
async function
|
|
4708
|
+
async function Fa(e) {
|
|
4590
4709
|
try {
|
|
4591
4710
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4592
4711
|
} catch {
|
|
4593
4712
|
return "sqlite";
|
|
4594
4713
|
}
|
|
4595
4714
|
}
|
|
4596
|
-
function
|
|
4715
|
+
function K(e, t) {
|
|
4597
4716
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4598
4717
|
timeZone: e,
|
|
4599
4718
|
year: "numeric",
|
|
@@ -4608,7 +4727,7 @@ function U(e, t) {
|
|
|
4608
4727
|
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);
|
|
4609
4728
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4610
4729
|
}
|
|
4611
|
-
var
|
|
4730
|
+
var Ia = [
|
|
4612
4731
|
"January",
|
|
4613
4732
|
"February",
|
|
4614
4733
|
"March",
|
|
@@ -4622,22 +4741,22 @@ var Na = [
|
|
|
4622
4741
|
"November",
|
|
4623
4742
|
"December"
|
|
4624
4743
|
];
|
|
4625
|
-
function
|
|
4626
|
-
let n = t.getUTCFullYear(), r =
|
|
4744
|
+
function La(e, t) {
|
|
4745
|
+
let n = t.getUTCFullYear(), r = K(e, new Date(Date.UTC(n, 0, 1)));
|
|
4627
4746
|
for (let t = 1; t < 12; t++) {
|
|
4628
|
-
let i =
|
|
4629
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4747
|
+
let i = K(e, new Date(Date.UTC(n, t, 1)));
|
|
4748
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ia[t]}) and cannot be bucketed with a single fixed offset by the SQL analytics adapter. Use a fixed-offset zone (e.g. 'UTC' or '+02:00').`);
|
|
4630
4749
|
}
|
|
4631
4750
|
}
|
|
4632
|
-
function
|
|
4751
|
+
function Ra(e) {
|
|
4633
4752
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4634
4753
|
return t * (Number(n) * 60 + Number(r));
|
|
4635
4754
|
}
|
|
4636
|
-
function
|
|
4755
|
+
function za(e, t) {
|
|
4637
4756
|
let n;
|
|
4638
4757
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4639
4758
|
else {
|
|
4640
|
-
let e =
|
|
4759
|
+
let e = Ra(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4641
4760
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4642
4761
|
}
|
|
4643
4762
|
switch (e) {
|
|
@@ -4648,7 +4767,7 @@ function Ia(e, t) {
|
|
|
4648
4767
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4649
4768
|
}
|
|
4650
4769
|
}
|
|
4651
|
-
function
|
|
4770
|
+
function Ba(e, t) {
|
|
4652
4771
|
if (t === "+00:00") switch (e) {
|
|
4653
4772
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4654
4773
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4659,7 +4778,7 @@ function La(e, t) {
|
|
|
4659
4778
|
}
|
|
4660
4779
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4661
4780
|
}
|
|
4662
|
-
let n =
|
|
4781
|
+
let n = Ra(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)`;
|
|
4663
4782
|
switch (e) {
|
|
4664
4783
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4665
4784
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4668,12 +4787,12 @@ function La(e, t) {
|
|
|
4668
4787
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4669
4788
|
}
|
|
4670
4789
|
}
|
|
4671
|
-
function
|
|
4672
|
-
|
|
4673
|
-
let i =
|
|
4674
|
-
return r === "mysql" ?
|
|
4790
|
+
function Va(e, t, n, r) {
|
|
4791
|
+
La(t, n);
|
|
4792
|
+
let i = K(t, n);
|
|
4793
|
+
return r === "mysql" ? Ba(e, i) : za(e, i);
|
|
4675
4794
|
}
|
|
4676
|
-
function
|
|
4795
|
+
function Ha(e) {
|
|
4677
4796
|
switch (e) {
|
|
4678
4797
|
case "connection": return "logs.connection";
|
|
4679
4798
|
case "client_id": return "logs.client_id";
|
|
@@ -4682,15 +4801,15 @@ function za(e) {
|
|
|
4682
4801
|
case "time": throw Error("time dimension is handled separately");
|
|
4683
4802
|
}
|
|
4684
4803
|
}
|
|
4685
|
-
function
|
|
4686
|
-
let t = null, n = () => (t ||=
|
|
4804
|
+
function Ua(e) {
|
|
4805
|
+
let t = null, n = () => (t ||= Fa(e), t);
|
|
4687
4806
|
return {
|
|
4688
4807
|
async query(t, r, i) {
|
|
4689
|
-
let a = Date.now(), o =
|
|
4808
|
+
let a = Date.now(), o = Na[r], s = Pa[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4690
4809
|
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));
|
|
4691
4810
|
let d = [], p = [];
|
|
4692
4811
|
for (let e of i.group_by) if (e === "time") {
|
|
4693
|
-
let e =
|
|
4812
|
+
let e = Va(i.interval, i.tz, new Date(i.from), c);
|
|
4694
4813
|
p.push({
|
|
4695
4814
|
alias: "time",
|
|
4696
4815
|
expr: e
|
|
@@ -4699,7 +4818,7 @@ function Ba(e) {
|
|
|
4699
4818
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4700
4819
|
});
|
|
4701
4820
|
} else {
|
|
4702
|
-
let t =
|
|
4821
|
+
let t = Ha(e);
|
|
4703
4822
|
p.push({
|
|
4704
4823
|
alias: e,
|
|
4705
4824
|
expr: f`${f.ref(t)}`
|
|
@@ -4774,7 +4893,7 @@ function Ba(e) {
|
|
|
4774
4893
|
}
|
|
4775
4894
|
//#endregion
|
|
4776
4895
|
//#region src/customText/index.ts
|
|
4777
|
-
function
|
|
4896
|
+
function Wa(e) {
|
|
4778
4897
|
return {
|
|
4779
4898
|
async get(t, n, r) {
|
|
4780
4899
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4813,9 +4932,9 @@ function Va(e) {
|
|
|
4813
4932
|
}
|
|
4814
4933
|
//#endregion
|
|
4815
4934
|
//#region src/authenticationMethods/create.ts
|
|
4816
|
-
function
|
|
4935
|
+
function Ga(e) {
|
|
4817
4936
|
return async (t, n, r) => {
|
|
4818
|
-
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 ??
|
|
4937
|
+
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ?? Hr();
|
|
4819
4938
|
return await e.insertInto("authentication_methods").values({
|
|
4820
4939
|
id: s,
|
|
4821
4940
|
tenant_id: t,
|
|
@@ -4852,7 +4971,7 @@ function Ha(e) {
|
|
|
4852
4971
|
}
|
|
4853
4972
|
//#endregion
|
|
4854
4973
|
//#region src/authenticationMethods/get.ts
|
|
4855
|
-
function
|
|
4974
|
+
function Ka(e) {
|
|
4856
4975
|
return async (t, n) => {
|
|
4857
4976
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4858
4977
|
return r ? {
|
|
@@ -4875,7 +4994,7 @@ function Ua(e) {
|
|
|
4875
4994
|
}
|
|
4876
4995
|
//#endregion
|
|
4877
4996
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4878
|
-
function
|
|
4997
|
+
function qa(e) {
|
|
4879
4998
|
return async (t, n) => {
|
|
4880
4999
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4881
5000
|
return r ? {
|
|
@@ -4898,7 +5017,7 @@ function Wa(e) {
|
|
|
4898
5017
|
}
|
|
4899
5018
|
//#endregion
|
|
4900
5019
|
//#region src/authenticationMethods/list.ts
|
|
4901
|
-
function
|
|
5020
|
+
function Ja(e) {
|
|
4902
5021
|
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) => ({
|
|
4903
5022
|
id: e.id,
|
|
4904
5023
|
user_id: e.user_id,
|
|
@@ -4918,35 +5037,35 @@ function Ga(e) {
|
|
|
4918
5037
|
}
|
|
4919
5038
|
//#endregion
|
|
4920
5039
|
//#region src/authenticationMethods/update.ts
|
|
4921
|
-
function
|
|
5040
|
+
function Ya(e) {
|
|
4922
5041
|
return async (t, n, r) => {
|
|
4923
5042
|
let i = { updated_at_ts: Date.now() };
|
|
4924
5043
|
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();
|
|
4925
|
-
let a = await
|
|
5044
|
+
let a = await Ka(e)(t, n);
|
|
4926
5045
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4927
5046
|
return a;
|
|
4928
5047
|
};
|
|
4929
5048
|
}
|
|
4930
5049
|
//#endregion
|
|
4931
5050
|
//#region src/authenticationMethods/remove.ts
|
|
4932
|
-
function
|
|
5051
|
+
function Xa(e) {
|
|
4933
5052
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4934
5053
|
}
|
|
4935
5054
|
//#endregion
|
|
4936
5055
|
//#region src/authenticationMethods/index.ts
|
|
4937
|
-
function
|
|
5056
|
+
function Za(e) {
|
|
4938
5057
|
return {
|
|
4939
|
-
create:
|
|
4940
|
-
get:
|
|
4941
|
-
getByCredentialId:
|
|
4942
|
-
list:
|
|
4943
|
-
update:
|
|
4944
|
-
remove:
|
|
5058
|
+
create: Ga(e),
|
|
5059
|
+
get: Ka(e),
|
|
5060
|
+
getByCredentialId: qa(e),
|
|
5061
|
+
list: Ja(e),
|
|
5062
|
+
update: Ya(e),
|
|
5063
|
+
remove: Xa(e)
|
|
4945
5064
|
};
|
|
4946
5065
|
}
|
|
4947
5066
|
//#endregion
|
|
4948
5067
|
//#region src/outbox/getByIds.ts
|
|
4949
|
-
function
|
|
5068
|
+
function Qa(e) {
|
|
4950
5069
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4951
5070
|
...JSON.parse(e.payload),
|
|
4952
5071
|
id: e.id,
|
|
@@ -4959,7 +5078,7 @@ function Ya(e) {
|
|
|
4959
5078
|
}
|
|
4960
5079
|
//#endregion
|
|
4961
5080
|
//#region src/outbox/getUnprocessed.ts
|
|
4962
|
-
function
|
|
5081
|
+
function $a(e) {
|
|
4963
5082
|
return async (t) => {
|
|
4964
5083
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4965
5084
|
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) => ({
|
|
@@ -4975,7 +5094,7 @@ function Xa(e) {
|
|
|
4975
5094
|
}
|
|
4976
5095
|
//#endregion
|
|
4977
5096
|
//#region src/outbox/claimEvents.ts
|
|
4978
|
-
function
|
|
5097
|
+
function eo(e) {
|
|
4979
5098
|
return async (t, n, r) => {
|
|
4980
5099
|
if (t.length === 0) return [];
|
|
4981
5100
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4987,7 +5106,7 @@ function Za(e) {
|
|
|
4987
5106
|
}
|
|
4988
5107
|
//#endregion
|
|
4989
5108
|
//#region src/outbox/markProcessed.ts
|
|
4990
|
-
function
|
|
5109
|
+
function to(e) {
|
|
4991
5110
|
return async (t) => {
|
|
4992
5111
|
if (t.length === 0) return;
|
|
4993
5112
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4996,7 +5115,7 @@ function Qa(e) {
|
|
|
4996
5115
|
}
|
|
4997
5116
|
//#endregion
|
|
4998
5117
|
//#region src/outbox/markRetry.ts
|
|
4999
|
-
function
|
|
5118
|
+
function no(e) {
|
|
5000
5119
|
return async (t, n, r) => {
|
|
5001
5120
|
await e.updateTable("outbox_events").set({
|
|
5002
5121
|
error: n,
|
|
@@ -5009,7 +5128,7 @@ function $a(e) {
|
|
|
5009
5128
|
}
|
|
5010
5129
|
//#endregion
|
|
5011
5130
|
//#region src/outbox/deadLetter.ts
|
|
5012
|
-
function
|
|
5131
|
+
function ro(e) {
|
|
5013
5132
|
return async (t, n) => {
|
|
5014
5133
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5015
5134
|
await e.updateTable("outbox_events").set({
|
|
@@ -5021,7 +5140,7 @@ function eo(e) {
|
|
|
5021
5140
|
}
|
|
5022
5141
|
//#endregion
|
|
5023
5142
|
//#region src/outbox/listFailed.ts
|
|
5024
|
-
function
|
|
5143
|
+
function io(e) {
|
|
5025
5144
|
return async (t, n = {}) => {
|
|
5026
5145
|
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) => {
|
|
5027
5146
|
let t;
|
|
@@ -5056,7 +5175,7 @@ function to(e) {
|
|
|
5056
5175
|
}
|
|
5057
5176
|
//#endregion
|
|
5058
5177
|
//#region src/outbox/replay.ts
|
|
5059
|
-
function
|
|
5178
|
+
function ao(e) {
|
|
5060
5179
|
return async (t, n) => {
|
|
5061
5180
|
let r = await e.updateTable("outbox_events").set({
|
|
5062
5181
|
processed_at: null,
|
|
@@ -5073,7 +5192,7 @@ function no(e) {
|
|
|
5073
5192
|
}
|
|
5074
5193
|
//#endregion
|
|
5075
5194
|
//#region src/outbox/cleanup.ts
|
|
5076
|
-
function
|
|
5195
|
+
function oo(e) {
|
|
5077
5196
|
return async (t) => {
|
|
5078
5197
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5079
5198
|
return Number(n.numDeletedRows);
|
|
@@ -5081,23 +5200,23 @@ function ro(e) {
|
|
|
5081
5200
|
}
|
|
5082
5201
|
//#endregion
|
|
5083
5202
|
//#region src/outbox/index.ts
|
|
5084
|
-
function
|
|
5203
|
+
function so(e) {
|
|
5085
5204
|
return {
|
|
5086
|
-
create:
|
|
5087
|
-
getByIds:
|
|
5088
|
-
getUnprocessed:
|
|
5089
|
-
claimEvents:
|
|
5090
|
-
markProcessed:
|
|
5091
|
-
markRetry:
|
|
5092
|
-
deadLetter:
|
|
5093
|
-
listFailed:
|
|
5094
|
-
replay:
|
|
5095
|
-
cleanup:
|
|
5205
|
+
create: et(e),
|
|
5206
|
+
getByIds: Qa(e),
|
|
5207
|
+
getUnprocessed: $a(e),
|
|
5208
|
+
claimEvents: eo(e),
|
|
5209
|
+
markProcessed: to(e),
|
|
5210
|
+
markRetry: no(e),
|
|
5211
|
+
deadLetter: ro(e),
|
|
5212
|
+
listFailed: io(e),
|
|
5213
|
+
replay: ao(e),
|
|
5214
|
+
cleanup: oo(e)
|
|
5096
5215
|
};
|
|
5097
5216
|
}
|
|
5098
5217
|
//#endregion
|
|
5099
5218
|
//#region src/log-streams/index.ts
|
|
5100
|
-
function
|
|
5219
|
+
function q(e) {
|
|
5101
5220
|
return {
|
|
5102
5221
|
id: e.id,
|
|
5103
5222
|
name: e.name,
|
|
@@ -5110,7 +5229,7 @@ function W(e) {
|
|
|
5110
5229
|
updated_at: e.updated_at
|
|
5111
5230
|
};
|
|
5112
5231
|
}
|
|
5113
|
-
function
|
|
5232
|
+
function co(e) {
|
|
5114
5233
|
return {
|
|
5115
5234
|
async create(n, r, i) {
|
|
5116
5235
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5125,14 +5244,14 @@ function ao(e) {
|
|
|
5125
5244
|
created_at: a?.created_at ?? o,
|
|
5126
5245
|
updated_at: a?.updated_at ?? o
|
|
5127
5246
|
};
|
|
5128
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5247
|
+
return await e.insertInto("log_streams").values(s).execute(), q(s);
|
|
5129
5248
|
},
|
|
5130
5249
|
async get(t, n) {
|
|
5131
5250
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5132
|
-
return r ?
|
|
5251
|
+
return r ? q(r) : null;
|
|
5133
5252
|
},
|
|
5134
5253
|
async list(t) {
|
|
5135
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5254
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(q);
|
|
5136
5255
|
},
|
|
5137
5256
|
async update(t, n, r) {
|
|
5138
5257
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5145,7 +5264,7 @@ function ao(e) {
|
|
|
5145
5264
|
}
|
|
5146
5265
|
//#endregion
|
|
5147
5266
|
//#region src/migrationSources/index.ts
|
|
5148
|
-
function
|
|
5267
|
+
function lo(e) {
|
|
5149
5268
|
return {
|
|
5150
5269
|
id: e.id,
|
|
5151
5270
|
name: e.name,
|
|
@@ -5157,7 +5276,7 @@ function G(e) {
|
|
|
5157
5276
|
updated_at: e.updated_at
|
|
5158
5277
|
};
|
|
5159
5278
|
}
|
|
5160
|
-
function
|
|
5279
|
+
function uo(e) {
|
|
5161
5280
|
return {
|
|
5162
5281
|
async create(n, r, i) {
|
|
5163
5282
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5171,14 +5290,14 @@ function oo(e) {
|
|
|
5171
5290
|
created_at: a?.created_at ?? o,
|
|
5172
5291
|
updated_at: a?.updated_at ?? o
|
|
5173
5292
|
};
|
|
5174
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5293
|
+
return await e.insertInto("migration_sources").values(l).execute(), lo(l);
|
|
5175
5294
|
},
|
|
5176
5295
|
async get(t, n) {
|
|
5177
5296
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5178
|
-
return r ?
|
|
5297
|
+
return r ? lo(r) : null;
|
|
5179
5298
|
},
|
|
5180
5299
|
async list(t) {
|
|
5181
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5300
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(lo);
|
|
5182
5301
|
},
|
|
5183
5302
|
async update(t, n, r) {
|
|
5184
5303
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5191,19 +5310,19 @@ function oo(e) {
|
|
|
5191
5310
|
}
|
|
5192
5311
|
//#endregion
|
|
5193
5312
|
//#region src/proxyRoutes/serialize.ts
|
|
5194
|
-
function
|
|
5313
|
+
function fo(e) {
|
|
5195
5314
|
return {
|
|
5196
5315
|
id: e.id,
|
|
5197
5316
|
tenant_id: e.tenant_id,
|
|
5198
5317
|
custom_domain_id: e.custom_domain_id,
|
|
5199
5318
|
priority: e.priority,
|
|
5200
|
-
match:
|
|
5201
|
-
handlers:
|
|
5319
|
+
match: po(e.match),
|
|
5320
|
+
handlers: mo(e.handlers),
|
|
5202
5321
|
created_at: e.created_at,
|
|
5203
5322
|
updated_at: e.updated_at
|
|
5204
5323
|
};
|
|
5205
5324
|
}
|
|
5206
|
-
function
|
|
5325
|
+
function po(e) {
|
|
5207
5326
|
if (!e) return { path: "/*" };
|
|
5208
5327
|
try {
|
|
5209
5328
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5211,7 +5330,7 @@ function so(e) {
|
|
|
5211
5330
|
} catch {}
|
|
5212
5331
|
return { path: "/*" };
|
|
5213
5332
|
}
|
|
5214
|
-
function
|
|
5333
|
+
function mo(e) {
|
|
5215
5334
|
if (!e) return [];
|
|
5216
5335
|
try {
|
|
5217
5336
|
let t = JSON.parse(e);
|
|
@@ -5228,7 +5347,7 @@ function co(e) {
|
|
|
5228
5347
|
}
|
|
5229
5348
|
//#endregion
|
|
5230
5349
|
//#region src/proxyRoutes/adapter.ts
|
|
5231
|
-
function
|
|
5350
|
+
function ho(e) {
|
|
5232
5351
|
return {
|
|
5233
5352
|
async create(n, r, i) {
|
|
5234
5353
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5254,14 +5373,14 @@ function q(e) {
|
|
|
5254
5373
|
},
|
|
5255
5374
|
async get(t, n) {
|
|
5256
5375
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5257
|
-
return r ?
|
|
5376
|
+
return r ? fo(r) : null;
|
|
5258
5377
|
},
|
|
5259
5378
|
async list(t, n = {}) {
|
|
5260
5379
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5261
5380
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5262
5381
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5263
5382
|
return {
|
|
5264
|
-
proxy_routes: o.map(
|
|
5383
|
+
proxy_routes: o.map(fo),
|
|
5265
5384
|
start: r * i,
|
|
5266
5385
|
limit: i,
|
|
5267
5386
|
length: o.length
|
|
@@ -5281,7 +5400,7 @@ function q(e) {
|
|
|
5281
5400
|
}
|
|
5282
5401
|
//#endregion
|
|
5283
5402
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5284
|
-
async function
|
|
5403
|
+
async function go(e, t) {
|
|
5285
5404
|
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([
|
|
5286
5405
|
"custom_domain_id",
|
|
5287
5406
|
"tenant_id",
|
|
@@ -5293,20 +5412,20 @@ async function lo(e, t) {
|
|
|
5293
5412
|
tenant_id: a.tenant_id,
|
|
5294
5413
|
custom_domain_id: a.custom_domain_id,
|
|
5295
5414
|
domain: a.domain,
|
|
5296
|
-
routes: o.map(
|
|
5415
|
+
routes: o.map(fo)
|
|
5297
5416
|
};
|
|
5298
5417
|
}
|
|
5299
5418
|
//#endregion
|
|
5300
5419
|
//#region src/proxyRoutes/index.ts
|
|
5301
|
-
function
|
|
5420
|
+
function _o(e) {
|
|
5302
5421
|
return {
|
|
5303
|
-
proxyRoutes:
|
|
5304
|
-
resolveHost: (t) =>
|
|
5422
|
+
proxyRoutes: ho(e),
|
|
5423
|
+
resolveHost: (t) => go(e, t)
|
|
5305
5424
|
};
|
|
5306
5425
|
}
|
|
5307
5426
|
//#endregion
|
|
5308
5427
|
//#region src/scim/adapter.ts
|
|
5309
|
-
function
|
|
5428
|
+
function vo(e) {
|
|
5310
5429
|
if (!e) return [];
|
|
5311
5430
|
try {
|
|
5312
5431
|
let t = JSON.parse(e);
|
|
@@ -5321,7 +5440,7 @@ function fo(e) {
|
|
|
5321
5440
|
return [];
|
|
5322
5441
|
}
|
|
5323
5442
|
}
|
|
5324
|
-
function
|
|
5443
|
+
function yo(e) {
|
|
5325
5444
|
if (!e) return [];
|
|
5326
5445
|
try {
|
|
5327
5446
|
let t = JSON.parse(e);
|
|
@@ -5330,16 +5449,16 @@ function po(e) {
|
|
|
5330
5449
|
return [];
|
|
5331
5450
|
}
|
|
5332
5451
|
}
|
|
5333
|
-
function
|
|
5452
|
+
function bo(e) {
|
|
5334
5453
|
return {
|
|
5335
5454
|
connection_id: e.connection_id,
|
|
5336
5455
|
user_id_attribute: e.user_id_attribute,
|
|
5337
|
-
mapping:
|
|
5456
|
+
mapping: vo(e.mapping),
|
|
5338
5457
|
created_at: e.created_at,
|
|
5339
5458
|
updated_at: e.updated_at
|
|
5340
5459
|
};
|
|
5341
5460
|
}
|
|
5342
|
-
function
|
|
5461
|
+
function xo(e) {
|
|
5343
5462
|
return {
|
|
5344
5463
|
async create(t, n) {
|
|
5345
5464
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5360,7 +5479,7 @@ function ho(e) {
|
|
|
5360
5479
|
},
|
|
5361
5480
|
async get(t, n) {
|
|
5362
5481
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5363
|
-
return r ?
|
|
5482
|
+
return r ? bo(r) : null;
|
|
5364
5483
|
},
|
|
5365
5484
|
async update(t, n, r) {
|
|
5366
5485
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5374,18 +5493,18 @@ function ho(e) {
|
|
|
5374
5493
|
}
|
|
5375
5494
|
};
|
|
5376
5495
|
}
|
|
5377
|
-
function
|
|
5496
|
+
function So(e) {
|
|
5378
5497
|
return {
|
|
5379
5498
|
token_id: e.token_id,
|
|
5380
5499
|
connection_id: e.connection_id,
|
|
5381
5500
|
token_hash: e.token_hash,
|
|
5382
|
-
scopes:
|
|
5501
|
+
scopes: yo(e.scopes),
|
|
5383
5502
|
valid_until: e.valid_until ?? void 0,
|
|
5384
5503
|
created_at: e.created_at,
|
|
5385
5504
|
last_used_at: e.last_used_at ?? void 0
|
|
5386
5505
|
};
|
|
5387
5506
|
}
|
|
5388
|
-
function
|
|
5507
|
+
function Co(e) {
|
|
5389
5508
|
return {
|
|
5390
5509
|
async create(t, n) {
|
|
5391
5510
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5409,14 +5528,14 @@ function _o(e) {
|
|
|
5409
5528
|
},
|
|
5410
5529
|
async get(t, n) {
|
|
5411
5530
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5412
|
-
return r ?
|
|
5531
|
+
return r ? So(r) : null;
|
|
5413
5532
|
},
|
|
5414
5533
|
async getByHash(t, n) {
|
|
5415
5534
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5416
|
-
return r ?
|
|
5535
|
+
return r ? So(r) : null;
|
|
5417
5536
|
},
|
|
5418
5537
|
async listByConnection(t, n) {
|
|
5419
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5538
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(So);
|
|
5420
5539
|
},
|
|
5421
5540
|
async markUsed(t, n, r) {
|
|
5422
5541
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5428,7 +5547,7 @@ function _o(e) {
|
|
|
5428
5547
|
}
|
|
5429
5548
|
};
|
|
5430
5549
|
}
|
|
5431
|
-
function
|
|
5550
|
+
function wo(e) {
|
|
5432
5551
|
return {
|
|
5433
5552
|
connection_id: e.connection_id,
|
|
5434
5553
|
external_id: e.external_id,
|
|
@@ -5436,7 +5555,7 @@ function vo(e) {
|
|
|
5436
5555
|
created_at: e.created_at
|
|
5437
5556
|
};
|
|
5438
5557
|
}
|
|
5439
|
-
function
|
|
5558
|
+
function To(e) {
|
|
5440
5559
|
return {
|
|
5441
5560
|
async create(t, n) {
|
|
5442
5561
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5455,11 +5574,11 @@ function yo(e) {
|
|
|
5455
5574
|
},
|
|
5456
5575
|
async getByExternalId(t, n, r) {
|
|
5457
5576
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5458
|
-
return i ?
|
|
5577
|
+
return i ? wo(i) : null;
|
|
5459
5578
|
},
|
|
5460
5579
|
async getByUserId(t, n, r) {
|
|
5461
5580
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5462
|
-
return i ?
|
|
5581
|
+
return i ? wo(i) : null;
|
|
5463
5582
|
},
|
|
5464
5583
|
async remove(t, n, r) {
|
|
5465
5584
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5469,7 +5588,7 @@ function yo(e) {
|
|
|
5469
5588
|
}
|
|
5470
5589
|
//#endregion
|
|
5471
5590
|
//#region src/tenantOperations/index.ts
|
|
5472
|
-
function
|
|
5591
|
+
function Eo(e) {
|
|
5473
5592
|
if (!e) return null;
|
|
5474
5593
|
try {
|
|
5475
5594
|
let t = JSON.parse(e);
|
|
@@ -5491,8 +5610,8 @@ function J(e) {
|
|
|
5491
5610
|
target_database_version: e.target_database_version,
|
|
5492
5611
|
error: e.error,
|
|
5493
5612
|
initiated_by: e.initiated_by,
|
|
5494
|
-
input:
|
|
5495
|
-
result:
|
|
5613
|
+
input: Eo(e.input),
|
|
5614
|
+
result: Eo(e.result),
|
|
5496
5615
|
claimed_by: e.claimed_by,
|
|
5497
5616
|
claim_expires_at: e.claim_expires_at,
|
|
5498
5617
|
created_at: e.created_at,
|
|
@@ -5500,7 +5619,7 @@ function J(e) {
|
|
|
5500
5619
|
finished_at: e.finished_at
|
|
5501
5620
|
});
|
|
5502
5621
|
}
|
|
5503
|
-
function
|
|
5622
|
+
function Do(e) {
|
|
5504
5623
|
return {
|
|
5505
5624
|
async create(n) {
|
|
5506
5625
|
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5583,27 +5702,27 @@ function xo(e) {
|
|
|
5583
5702
|
}
|
|
5584
5703
|
//#endregion
|
|
5585
5704
|
//#region src/utils/monotonic-id.ts
|
|
5586
|
-
var
|
|
5587
|
-
function
|
|
5705
|
+
var Oo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ko = 32, Ao = 10, jo = 4, Mo = 10;
|
|
5706
|
+
function No(e, t) {
|
|
5588
5707
|
let n = "";
|
|
5589
|
-
for (let r = t; r > 0; r--) n =
|
|
5708
|
+
for (let r = t; r > 0; r--) n = Oo.charAt(e % ko) + n, e = Math.floor(e / ko);
|
|
5590
5709
|
return n;
|
|
5591
5710
|
}
|
|
5592
|
-
function
|
|
5593
|
-
let e = new Uint8Array(
|
|
5711
|
+
function Po() {
|
|
5712
|
+
let e = new Uint8Array(Mo);
|
|
5594
5713
|
crypto.getRandomValues(e);
|
|
5595
5714
|
let t = "";
|
|
5596
|
-
for (let n = 0; n <
|
|
5715
|
+
for (let n = 0; n < Mo; n++) t += Oo.charAt(e[n] % ko);
|
|
5597
5716
|
return t;
|
|
5598
5717
|
}
|
|
5599
|
-
var
|
|
5600
|
-
function
|
|
5718
|
+
var Fo = 0, Io = 0;
|
|
5719
|
+
function Lo() {
|
|
5601
5720
|
let e = Date.now();
|
|
5602
|
-
return e ===
|
|
5721
|
+
return e === Fo ? Io++ : (Fo = e, Io = 0), No(e, Ao) + No(Io, jo) + Po();
|
|
5603
5722
|
}
|
|
5604
5723
|
//#endregion
|
|
5605
5724
|
//#region src/tenantOperationEvents/index.ts
|
|
5606
|
-
function
|
|
5725
|
+
function Ro(e) {
|
|
5607
5726
|
if (!e) return null;
|
|
5608
5727
|
try {
|
|
5609
5728
|
let t = JSON.parse(e);
|
|
@@ -5611,22 +5730,22 @@ function Mo(e) {
|
|
|
5611
5730
|
} catch {}
|
|
5612
5731
|
return null;
|
|
5613
5732
|
}
|
|
5614
|
-
function
|
|
5733
|
+
function zo(e) {
|
|
5615
5734
|
return ve.parse({
|
|
5616
5735
|
id: e.id,
|
|
5617
5736
|
operation_id: e.operation_id,
|
|
5618
5737
|
step: e.step,
|
|
5619
5738
|
outcome: e.outcome,
|
|
5620
|
-
detail:
|
|
5739
|
+
detail: Ro(e.detail),
|
|
5621
5740
|
attempt: e.attempt,
|
|
5622
5741
|
created_at: e.created_at
|
|
5623
5742
|
});
|
|
5624
5743
|
}
|
|
5625
|
-
function
|
|
5744
|
+
function Bo(e) {
|
|
5626
5745
|
return {
|
|
5627
5746
|
async create(t) {
|
|
5628
5747
|
let n = _e.parse(t), r = {
|
|
5629
|
-
id: `evt_${
|
|
5748
|
+
id: `evt_${Lo()}`,
|
|
5630
5749
|
operation_id: n.operation_id,
|
|
5631
5750
|
step: n.step,
|
|
5632
5751
|
outcome: n.outcome,
|
|
@@ -5634,12 +5753,12 @@ function Po(e) {
|
|
|
5634
5753
|
attempt: n.attempt,
|
|
5635
5754
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5636
5755
|
};
|
|
5637
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5756
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), zo(r);
|
|
5638
5757
|
},
|
|
5639
5758
|
async listByOperation(t, n = {}) {
|
|
5640
5759
|
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();
|
|
5641
5760
|
return {
|
|
5642
|
-
events: a.map(
|
|
5761
|
+
events: a.map(zo),
|
|
5643
5762
|
start: r * i,
|
|
5644
5763
|
limit: i,
|
|
5645
5764
|
length: a.length
|
|
@@ -5649,16 +5768,16 @@ function Po(e) {
|
|
|
5649
5768
|
}
|
|
5650
5769
|
//#endregion
|
|
5651
5770
|
//#region src/tenantOperationRows/index.ts
|
|
5652
|
-
var
|
|
5653
|
-
function
|
|
5771
|
+
var Vo = 50;
|
|
5772
|
+
function Ho(e) {
|
|
5654
5773
|
let t = JSON.parse(e);
|
|
5655
5774
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5656
5775
|
}
|
|
5657
|
-
function
|
|
5776
|
+
function Uo(e) {
|
|
5658
5777
|
return xe.parse({
|
|
5659
5778
|
operation_id: e.operation_id,
|
|
5660
5779
|
seq: e.seq,
|
|
5661
|
-
payload:
|
|
5780
|
+
payload: Ho(e.payload),
|
|
5662
5781
|
status: e.status,
|
|
5663
5782
|
error_code: e.error_code,
|
|
5664
5783
|
error_message: e.error_message,
|
|
@@ -5668,7 +5787,7 @@ function Lo(e) {
|
|
|
5668
5787
|
updated_at: e.updated_at
|
|
5669
5788
|
});
|
|
5670
5789
|
}
|
|
5671
|
-
function
|
|
5790
|
+
function Wo(e) {
|
|
5672
5791
|
return {
|
|
5673
5792
|
async createMany(t) {
|
|
5674
5793
|
if (t.length === 0) return 0;
|
|
@@ -5687,11 +5806,11 @@ function Ro(e) {
|
|
|
5687
5806
|
updated_at: n
|
|
5688
5807
|
};
|
|
5689
5808
|
});
|
|
5690
|
-
for (let t = 0; t < r.length; t +=
|
|
5809
|
+
for (let t = 0; t < r.length; t += Vo) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + Vo)).execute();
|
|
5691
5810
|
return r.length;
|
|
5692
5811
|
},
|
|
5693
5812
|
async claimPending(t, n) {
|
|
5694
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5813
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(Uo);
|
|
5695
5814
|
},
|
|
5696
5815
|
async recordOutcomes(t, n) {
|
|
5697
5816
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5740,7 +5859,7 @@ function Ro(e) {
|
|
|
5740
5859
|
}
|
|
5741
5860
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5742
5861
|
return {
|
|
5743
|
-
rows: o.map(
|
|
5862
|
+
rows: o.map(Uo),
|
|
5744
5863
|
start: r * i,
|
|
5745
5864
|
limit: i,
|
|
5746
5865
|
length: o.length
|
|
@@ -5754,7 +5873,7 @@ function Ro(e) {
|
|
|
5754
5873
|
}
|
|
5755
5874
|
//#endregion
|
|
5756
5875
|
//#region src/rollouts/index.ts
|
|
5757
|
-
function
|
|
5876
|
+
function Go(e) {
|
|
5758
5877
|
if (!e) return null;
|
|
5759
5878
|
try {
|
|
5760
5879
|
return JSON.parse(e);
|
|
@@ -5762,7 +5881,7 @@ function zo(e) {
|
|
|
5762
5881
|
return null;
|
|
5763
5882
|
}
|
|
5764
5883
|
}
|
|
5765
|
-
function
|
|
5884
|
+
function Ko(e) {
|
|
5766
5885
|
return pe.parse({
|
|
5767
5886
|
id: e.id,
|
|
5768
5887
|
kind: e.kind,
|
|
@@ -5770,15 +5889,15 @@ function Bo(e) {
|
|
|
5770
5889
|
target_worker_version: e.target_worker_version,
|
|
5771
5890
|
target_database_version: e.target_database_version,
|
|
5772
5891
|
wave_size: e.wave_size,
|
|
5773
|
-
canary_tenant_ids:
|
|
5774
|
-
filter:
|
|
5892
|
+
canary_tenant_ids: Go(e.canary_tenant_ids),
|
|
5893
|
+
filter: Go(e.filter),
|
|
5775
5894
|
initiated_by: e.initiated_by,
|
|
5776
5895
|
created_at: e.created_at,
|
|
5777
5896
|
updated_at: e.updated_at,
|
|
5778
5897
|
finished_at: e.finished_at
|
|
5779
5898
|
});
|
|
5780
5899
|
}
|
|
5781
|
-
function
|
|
5900
|
+
function qo(e) {
|
|
5782
5901
|
return {
|
|
5783
5902
|
async create(n) {
|
|
5784
5903
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5795,16 +5914,16 @@ function Vo(e) {
|
|
|
5795
5914
|
updated_at: i,
|
|
5796
5915
|
finished_at: null
|
|
5797
5916
|
};
|
|
5798
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5917
|
+
return await e.insertInto("rollouts").values(a).execute(), Ko(a);
|
|
5799
5918
|
},
|
|
5800
5919
|
async get(t) {
|
|
5801
5920
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5802
|
-
return n ?
|
|
5921
|
+
return n ? Ko(n) : null;
|
|
5803
5922
|
},
|
|
5804
5923
|
async list(t = {}) {
|
|
5805
5924
|
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();
|
|
5806
5925
|
return {
|
|
5807
|
-
rollouts: i.map(
|
|
5926
|
+
rollouts: i.map(Ko),
|
|
5808
5927
|
start: n * r,
|
|
5809
5928
|
limit: r,
|
|
5810
5929
|
length: i.length
|
|
@@ -5824,7 +5943,7 @@ function Vo(e) {
|
|
|
5824
5943
|
}
|
|
5825
5944
|
//#endregion
|
|
5826
5945
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5827
|
-
var
|
|
5946
|
+
var Jo = class {
|
|
5828
5947
|
migrations;
|
|
5829
5948
|
constructor(e) {
|
|
5830
5949
|
this.migrations = e;
|
|
@@ -5832,10 +5951,10 @@ var Ho = class {
|
|
|
5832
5951
|
async getMigrations() {
|
|
5833
5952
|
return this.migrations;
|
|
5834
5953
|
}
|
|
5835
|
-
},
|
|
5836
|
-
down: () =>
|
|
5837
|
-
up: () =>
|
|
5838
|
-
}),
|
|
5954
|
+
}, Yo = /* @__PURE__ */ E({
|
|
5955
|
+
down: () => $o,
|
|
5956
|
+
up: () => Qo
|
|
5957
|
+
}), Xo = [
|
|
5839
5958
|
{
|
|
5840
5959
|
table: "authentication_methods",
|
|
5841
5960
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6101,7 +6220,7 @@ var Ho = class {
|
|
|
6101
6220
|
onDelete: "cascade"
|
|
6102
6221
|
}
|
|
6103
6222
|
];
|
|
6104
|
-
async function
|
|
6223
|
+
async function Zo(e) {
|
|
6105
6224
|
try {
|
|
6106
6225
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
6107
6226
|
} catch {
|
|
@@ -6110,14 +6229,14 @@ async function Go(e) {
|
|
|
6110
6229
|
}
|
|
6111
6230
|
function Y(e, t) {
|
|
6112
6231
|
let n = e;
|
|
6113
|
-
for (let e of
|
|
6232
|
+
for (let e of Xo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6114
6233
|
let n = t;
|
|
6115
6234
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6116
6235
|
}));
|
|
6117
6236
|
return n;
|
|
6118
6237
|
}
|
|
6119
|
-
async function
|
|
6120
|
-
let t = await
|
|
6238
|
+
async function Qo(e) {
|
|
6239
|
+
let t = await Zo(e);
|
|
6121
6240
|
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();
|
|
6122
6241
|
{
|
|
6123
6242
|
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"]);
|
|
@@ -6304,40 +6423,40 @@ async function Ko(e) {
|
|
|
6304
6423
|
"tenant_id",
|
|
6305
6424
|
"phone_number",
|
|
6306
6425
|
"provider"
|
|
6307
|
-
]).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
|
|
6426
|
+
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of Xo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6308
6427
|
let n = e;
|
|
6309
6428
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6310
6429
|
}).execute();
|
|
6311
6430
|
}
|
|
6312
|
-
async function
|
|
6431
|
+
async function $o(e) {
|
|
6313
6432
|
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();
|
|
6314
6433
|
}
|
|
6315
6434
|
//#endregion
|
|
6316
6435
|
//#region migrate/log.ts
|
|
6317
|
-
var
|
|
6318
|
-
function
|
|
6319
|
-
|
|
6436
|
+
var es = !1;
|
|
6437
|
+
function ts(e) {
|
|
6438
|
+
es = e;
|
|
6320
6439
|
}
|
|
6321
6440
|
function X(...e) {
|
|
6322
|
-
|
|
6441
|
+
es && console.log(...e);
|
|
6323
6442
|
}
|
|
6324
6443
|
function Z(...e) {
|
|
6325
6444
|
console.warn(...e);
|
|
6326
6445
|
}
|
|
6327
6446
|
//#endregion
|
|
6328
6447
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6329
|
-
var
|
|
6330
|
-
down: () =>
|
|
6331
|
-
up: () =>
|
|
6332
|
-
}),
|
|
6333
|
-
async function
|
|
6448
|
+
var ns = /* @__PURE__ */ E({
|
|
6449
|
+
down: () => ps,
|
|
6450
|
+
up: () => us
|
|
6451
|
+
}), rs = 5e4, is = 500;
|
|
6452
|
+
async function as(e) {
|
|
6334
6453
|
try {
|
|
6335
6454
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6336
6455
|
} catch {
|
|
6337
6456
|
return "sqlite";
|
|
6338
6457
|
}
|
|
6339
6458
|
}
|
|
6340
|
-
async function
|
|
6459
|
+
async function os(e, t, n) {
|
|
6341
6460
|
try {
|
|
6342
6461
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6343
6462
|
} catch (e) {
|
|
@@ -6348,7 +6467,7 @@ async function es(e, t, n) {
|
|
|
6348
6467
|
throw e;
|
|
6349
6468
|
}
|
|
6350
6469
|
}
|
|
6351
|
-
async function
|
|
6470
|
+
async function ss(e, t, n, r) {
|
|
6352
6471
|
try {
|
|
6353
6472
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6354
6473
|
} catch (e) {
|
|
@@ -6359,21 +6478,21 @@ async function ts(e, t, n, r) {
|
|
|
6359
6478
|
throw e;
|
|
6360
6479
|
}
|
|
6361
6480
|
}
|
|
6362
|
-
async function
|
|
6481
|
+
async function cs(e, t) {
|
|
6363
6482
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6364
6483
|
if (t === "sqlite") {
|
|
6365
6484
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6366
6485
|
r = Number(t.numDeletedRows);
|
|
6367
6486
|
} else {
|
|
6368
|
-
let t =
|
|
6369
|
-
for (; t >=
|
|
6370
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6487
|
+
let t = rs;
|
|
6488
|
+
for (; t >= rs;) {
|
|
6489
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(rs).executeTakeFirst();
|
|
6371
6490
|
t = Number(i.numDeletedRows), r += t, t > 0 && X(` Pruned ${r} expired codes row(s)...`);
|
|
6372
6491
|
}
|
|
6373
6492
|
}
|
|
6374
6493
|
return r;
|
|
6375
6494
|
}
|
|
6376
|
-
async function
|
|
6495
|
+
async function ls(e) {
|
|
6377
6496
|
let t = 0;
|
|
6378
6497
|
for (;;) {
|
|
6379
6498
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6381,33 +6500,33 @@ async function rs(e) {
|
|
|
6381
6500
|
"code_type",
|
|
6382
6501
|
"tenant_id",
|
|
6383
6502
|
"expires_at"
|
|
6384
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6503
|
+
]).where("expires_at_ts", "is", null).limit(is).execute();
|
|
6385
6504
|
if (n.length === 0) break;
|
|
6386
6505
|
for (let t of n) {
|
|
6387
6506
|
let n = Date.parse(t.expires_at);
|
|
6388
6507
|
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();
|
|
6389
6508
|
}
|
|
6390
|
-
if (t += n.length, n.length <
|
|
6509
|
+
if (t += n.length, n.length < is) break;
|
|
6391
6510
|
}
|
|
6392
6511
|
return t;
|
|
6393
6512
|
}
|
|
6394
|
-
async function
|
|
6395
|
-
let t = await
|
|
6513
|
+
async function us(e) {
|
|
6514
|
+
let t = await as(e);
|
|
6396
6515
|
try {
|
|
6397
|
-
let n = await
|
|
6516
|
+
let n = await cs(e, t);
|
|
6398
6517
|
X(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6399
6518
|
} catch (e) {
|
|
6400
6519
|
Z(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6401
6520
|
}
|
|
6402
|
-
await
|
|
6521
|
+
await os(e, "codes", "expires_at_ts"), await ss(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6403
6522
|
try {
|
|
6404
|
-
let t = await
|
|
6523
|
+
let t = await ls(e);
|
|
6405
6524
|
X(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6406
6525
|
} catch (e) {
|
|
6407
6526
|
Z(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6408
6527
|
}
|
|
6409
6528
|
}
|
|
6410
|
-
async function
|
|
6529
|
+
async function ds(e, t, n) {
|
|
6411
6530
|
try {
|
|
6412
6531
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6413
6532
|
} catch (e) {
|
|
@@ -6415,7 +6534,7 @@ async function as(e, t, n) {
|
|
|
6415
6534
|
throw e;
|
|
6416
6535
|
}
|
|
6417
6536
|
}
|
|
6418
|
-
async function
|
|
6537
|
+
async function fs(e, t, n) {
|
|
6419
6538
|
try {
|
|
6420
6539
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6421
6540
|
} catch (e) {
|
|
@@ -6423,16 +6542,16 @@ async function os(e, t, n) {
|
|
|
6423
6542
|
throw e;
|
|
6424
6543
|
}
|
|
6425
6544
|
}
|
|
6426
|
-
async function
|
|
6427
|
-
await
|
|
6545
|
+
async function ps(e) {
|
|
6546
|
+
await ds(e, "idx_codes_expires_at_ts", "codes"), await fs(e, "codes", "expires_at_ts");
|
|
6428
6547
|
}
|
|
6429
6548
|
//#endregion
|
|
6430
6549
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6431
|
-
var
|
|
6432
|
-
down: () =>
|
|
6433
|
-
up: () =>
|
|
6550
|
+
var ms = /* @__PURE__ */ E({
|
|
6551
|
+
down: () => gs,
|
|
6552
|
+
up: () => hs
|
|
6434
6553
|
});
|
|
6435
|
-
async function
|
|
6554
|
+
async function hs(e) {
|
|
6436
6555
|
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", [
|
|
6437
6556
|
"tenant_id",
|
|
6438
6557
|
"connection_id",
|
|
@@ -6443,16 +6562,16 @@ async function ls(e) {
|
|
|
6443
6562
|
"external_id"
|
|
6444
6563
|
]).unique().execute();
|
|
6445
6564
|
}
|
|
6446
|
-
async function
|
|
6565
|
+
async function gs(e) {
|
|
6447
6566
|
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();
|
|
6448
6567
|
}
|
|
6449
6568
|
//#endregion
|
|
6450
6569
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6451
|
-
var
|
|
6452
|
-
down: () =>
|
|
6453
|
-
up: () =>
|
|
6570
|
+
var _s = /* @__PURE__ */ E({
|
|
6571
|
+
down: () => xs,
|
|
6572
|
+
up: () => ys
|
|
6454
6573
|
});
|
|
6455
|
-
async function
|
|
6574
|
+
async function vs(e, t, n) {
|
|
6456
6575
|
try {
|
|
6457
6576
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6458
6577
|
} catch (e) {
|
|
@@ -6460,10 +6579,10 @@ async function fs(e, t, n) {
|
|
|
6460
6579
|
throw e;
|
|
6461
6580
|
}
|
|
6462
6581
|
}
|
|
6463
|
-
async function
|
|
6464
|
-
await
|
|
6582
|
+
async function ys(e) {
|
|
6583
|
+
await vs(e, "users", "blocked");
|
|
6465
6584
|
}
|
|
6466
|
-
async function
|
|
6585
|
+
async function bs(e, t, n) {
|
|
6467
6586
|
try {
|
|
6468
6587
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6469
6588
|
} catch (e) {
|
|
@@ -6471,16 +6590,16 @@ async function ms(e, t, n) {
|
|
|
6471
6590
|
throw e;
|
|
6472
6591
|
}
|
|
6473
6592
|
}
|
|
6474
|
-
async function
|
|
6475
|
-
await
|
|
6593
|
+
async function xs(e) {
|
|
6594
|
+
await bs(e, "users", "blocked");
|
|
6476
6595
|
}
|
|
6477
6596
|
//#endregion
|
|
6478
6597
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6479
|
-
var
|
|
6480
|
-
down: () =>
|
|
6481
|
-
up: () =>
|
|
6598
|
+
var Ss = /* @__PURE__ */ E({
|
|
6599
|
+
down: () => Es,
|
|
6600
|
+
up: () => ws
|
|
6482
6601
|
});
|
|
6483
|
-
async function
|
|
6602
|
+
async function Cs(e, t, n) {
|
|
6484
6603
|
try {
|
|
6485
6604
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6486
6605
|
} catch (e) {
|
|
@@ -6488,10 +6607,10 @@ async function _s(e, t, n) {
|
|
|
6488
6607
|
throw e;
|
|
6489
6608
|
}
|
|
6490
6609
|
}
|
|
6491
|
-
async function
|
|
6492
|
-
await
|
|
6610
|
+
async function ws(e) {
|
|
6611
|
+
await Cs(e, "prompt_settings", "show_last_used_connection");
|
|
6493
6612
|
}
|
|
6494
|
-
async function
|
|
6613
|
+
async function Ts(e, t, n) {
|
|
6495
6614
|
try {
|
|
6496
6615
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6497
6616
|
} catch (e) {
|
|
@@ -6499,16 +6618,16 @@ async function ys(e, t, n) {
|
|
|
6499
6618
|
throw e;
|
|
6500
6619
|
}
|
|
6501
6620
|
}
|
|
6502
|
-
async function
|
|
6503
|
-
await
|
|
6621
|
+
async function Es(e) {
|
|
6622
|
+
await Ts(e, "prompt_settings", "show_last_used_connection");
|
|
6504
6623
|
}
|
|
6505
6624
|
//#endregion
|
|
6506
6625
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6507
|
-
var
|
|
6508
|
-
down: () =>
|
|
6509
|
-
up: () =>
|
|
6626
|
+
var Ds = /* @__PURE__ */ E({
|
|
6627
|
+
down: () => As,
|
|
6628
|
+
up: () => ks
|
|
6510
6629
|
});
|
|
6511
|
-
async function
|
|
6630
|
+
async function Os(e, t, n, r) {
|
|
6512
6631
|
try {
|
|
6513
6632
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6514
6633
|
} catch (e) {
|
|
@@ -6519,10 +6638,10 @@ async function Ss(e, t, n, r) {
|
|
|
6519
6638
|
throw e;
|
|
6520
6639
|
}
|
|
6521
6640
|
}
|
|
6522
|
-
async function
|
|
6523
|
-
await
|
|
6641
|
+
async function ks(e) {
|
|
6642
|
+
await Os(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6524
6643
|
}
|
|
6525
|
-
async function
|
|
6644
|
+
async function As(e) {
|
|
6526
6645
|
try {
|
|
6527
6646
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6528
6647
|
} catch (e) {
|
|
@@ -6532,11 +6651,11 @@ async function ws(e) {
|
|
|
6532
6651
|
}
|
|
6533
6652
|
//#endregion
|
|
6534
6653
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6535
|
-
var
|
|
6536
|
-
down: () =>
|
|
6537
|
-
up: () =>
|
|
6654
|
+
var js = /* @__PURE__ */ E({
|
|
6655
|
+
down: () => Fs,
|
|
6656
|
+
up: () => Ns
|
|
6538
6657
|
});
|
|
6539
|
-
async function
|
|
6658
|
+
async function Ms(e, t, n, r) {
|
|
6540
6659
|
try {
|
|
6541
6660
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6542
6661
|
} catch (e) {
|
|
@@ -6544,10 +6663,10 @@ async function Es(e, t, n, r) {
|
|
|
6544
6663
|
throw e;
|
|
6545
6664
|
}
|
|
6546
6665
|
}
|
|
6547
|
-
async function
|
|
6548
|
-
await
|
|
6666
|
+
async function Ns(e) {
|
|
6667
|
+
await Ms(e, "hooks", "page_id", f`varchar(64)`), await Ms(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6549
6668
|
}
|
|
6550
|
-
async function
|
|
6669
|
+
async function Ps(e, t, n) {
|
|
6551
6670
|
try {
|
|
6552
6671
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6553
6672
|
} catch (e) {
|
|
@@ -6555,22 +6674,22 @@ async function Os(e, t, n) {
|
|
|
6555
6674
|
throw e;
|
|
6556
6675
|
}
|
|
6557
6676
|
}
|
|
6558
|
-
async function
|
|
6559
|
-
await
|
|
6677
|
+
async function Fs(e) {
|
|
6678
|
+
await Ps(e, "hooks", "permission_required"), await Ps(e, "hooks", "page_id");
|
|
6560
6679
|
}
|
|
6561
6680
|
//#endregion
|
|
6562
6681
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6563
|
-
var
|
|
6564
|
-
down: () =>
|
|
6565
|
-
up: () =>
|
|
6566
|
-
}),
|
|
6682
|
+
var Is = /* @__PURE__ */ E({
|
|
6683
|
+
down: () => Hs,
|
|
6684
|
+
up: () => Bs
|
|
6685
|
+
}), Ls = [
|
|
6567
6686
|
["session_id", f`varchar(26)`],
|
|
6568
6687
|
["organization", f`varchar(191)`],
|
|
6569
6688
|
["auth_connection", f`varchar(255)`],
|
|
6570
6689
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6571
6690
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6572
6691
|
];
|
|
6573
|
-
async function
|
|
6692
|
+
async function Rs(e, t, n, r) {
|
|
6574
6693
|
try {
|
|
6575
6694
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6576
6695
|
} catch (e) {
|
|
@@ -6578,7 +6697,7 @@ async function Ms(e, t, n, r) {
|
|
|
6578
6697
|
throw e;
|
|
6579
6698
|
}
|
|
6580
6699
|
}
|
|
6581
|
-
async function
|
|
6700
|
+
async function zs(e) {
|
|
6582
6701
|
try {
|
|
6583
6702
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6584
6703
|
} catch (e) {
|
|
@@ -6586,11 +6705,11 @@ async function Ns(e) {
|
|
|
6586
6705
|
throw e;
|
|
6587
6706
|
}
|
|
6588
6707
|
}
|
|
6589
|
-
async function
|
|
6590
|
-
for (let [t, n] of
|
|
6591
|
-
await
|
|
6708
|
+
async function Bs(e) {
|
|
6709
|
+
for (let [t, n] of Ls) await Rs(e, "refresh_tokens", t, n);
|
|
6710
|
+
await zs(e);
|
|
6592
6711
|
}
|
|
6593
|
-
async function
|
|
6712
|
+
async function Vs(e, t, n) {
|
|
6594
6713
|
try {
|
|
6595
6714
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6596
6715
|
} catch (e) {
|
|
@@ -6598,23 +6717,23 @@ async function Fs(e, t, n) {
|
|
|
6598
6717
|
throw e;
|
|
6599
6718
|
}
|
|
6600
6719
|
}
|
|
6601
|
-
async function
|
|
6720
|
+
async function Hs(e) {
|
|
6602
6721
|
try {
|
|
6603
6722
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6604
6723
|
} catch {}
|
|
6605
|
-
for (let [t] of
|
|
6724
|
+
for (let [t] of Ls) await Vs(e, "refresh_tokens", t);
|
|
6606
6725
|
}
|
|
6607
6726
|
//#endregion
|
|
6608
6727
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6609
|
-
var
|
|
6610
|
-
down: () =>
|
|
6611
|
-
up: () =>
|
|
6612
|
-
}),
|
|
6613
|
-
async function
|
|
6728
|
+
var Us = /* @__PURE__ */ E({
|
|
6729
|
+
down: () => Ys,
|
|
6730
|
+
up: () => Js
|
|
6731
|
+
}), Ws = 500, Gs = 20, Ks = 500, qs = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6732
|
+
async function Js(e) {
|
|
6614
6733
|
try {
|
|
6615
6734
|
let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select((e) => e.fn.countAll().as("count")).executeTakeFirst(), n = Number(t?.count ?? 0);
|
|
6616
|
-
if (n >
|
|
6617
|
-
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6735
|
+
if (n > Ks) {
|
|
6736
|
+
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${Ks}. SKIPPING — run the bulk path instead: ${qs}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6618
6737
|
return;
|
|
6619
6738
|
}
|
|
6620
6739
|
if (n === 0) {
|
|
@@ -6631,10 +6750,10 @@ async function Hs(e) {
|
|
|
6631
6750
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6632
6751
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6633
6752
|
"login_sessions.auth_params as ls_auth_params"
|
|
6634
|
-
]).limit(
|
|
6753
|
+
]).limit(Ws).execute();
|
|
6635
6754
|
if (t.length === 0) break;
|
|
6636
|
-
for (let n = 0; n < t.length; n +=
|
|
6637
|
-
let r = t.slice(n, n +
|
|
6755
|
+
for (let n = 0; n < t.length; n += Gs) {
|
|
6756
|
+
let r = t.slice(n, n + Gs);
|
|
6638
6757
|
await Promise.all(r.map(async (t) => {
|
|
6639
6758
|
let n = null;
|
|
6640
6759
|
if (t.ls_auth_params) try {
|
|
@@ -6651,19 +6770,19 @@ async function Hs(e) {
|
|
|
6651
6770
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6652
6771
|
}));
|
|
6653
6772
|
}
|
|
6654
|
-
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6773
|
+
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length < Ws) break;
|
|
6655
6774
|
}
|
|
6656
6775
|
X(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6657
6776
|
} catch (e) {
|
|
6658
6777
|
throw Z("refresh_tokens backfill failed:", e), e;
|
|
6659
6778
|
}
|
|
6660
6779
|
}
|
|
6661
|
-
async function
|
|
6780
|
+
async function Ys() {}
|
|
6662
6781
|
//#endregion
|
|
6663
6782
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6664
|
-
var
|
|
6665
|
-
down: () =>
|
|
6666
|
-
up: () =>
|
|
6783
|
+
var Xs = /* @__PURE__ */ E({
|
|
6784
|
+
down: () => $s,
|
|
6785
|
+
up: () => Qs
|
|
6667
6786
|
});
|
|
6668
6787
|
async function Q(e, t, n, r) {
|
|
6669
6788
|
try {
|
|
@@ -6673,7 +6792,7 @@ async function Q(e, t, n, r) {
|
|
|
6673
6792
|
throw e;
|
|
6674
6793
|
}
|
|
6675
6794
|
}
|
|
6676
|
-
async function
|
|
6795
|
+
async function Zs(e, t, n, r) {
|
|
6677
6796
|
try {
|
|
6678
6797
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6679
6798
|
} catch (e) {
|
|
@@ -6681,12 +6800,12 @@ async function Gs(e, t, n, r) {
|
|
|
6681
6800
|
throw e;
|
|
6682
6801
|
}
|
|
6683
6802
|
}
|
|
6684
|
-
async function
|
|
6685
|
-
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await
|
|
6803
|
+
async function Qs(e) {
|
|
6804
|
+
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await Zs(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6686
6805
|
"operation_id",
|
|
6687
6806
|
"status",
|
|
6688
6807
|
"seq"
|
|
6689
|
-
]), await
|
|
6808
|
+
]), await Zs(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6690
6809
|
"kind",
|
|
6691
6810
|
"status",
|
|
6692
6811
|
"created_at"
|
|
@@ -6700,7 +6819,7 @@ async function $(e, t, n) {
|
|
|
6700
6819
|
throw e;
|
|
6701
6820
|
}
|
|
6702
6821
|
}
|
|
6703
|
-
async function
|
|
6822
|
+
async function $s(e) {
|
|
6704
6823
|
try {
|
|
6705
6824
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6706
6825
|
} catch {}
|
|
@@ -6708,35 +6827,35 @@ async function qs(e) {
|
|
|
6708
6827
|
}
|
|
6709
6828
|
//#endregion
|
|
6710
6829
|
//#region migrate/migrations/index.ts
|
|
6711
|
-
var
|
|
6712
|
-
"2026-07-16T14:00:00_baseline":
|
|
6713
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6714
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6715
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6716
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6717
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6718
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6719
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6720
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6721
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
6830
|
+
var ec = {
|
|
6831
|
+
"2026-07-16T14:00:00_baseline": Yo,
|
|
6832
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": ns,
|
|
6833
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": ms,
|
|
6834
|
+
"2026-08-05T12:00:00_user_blocked": _s,
|
|
6835
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Ss,
|
|
6836
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Ds,
|
|
6837
|
+
"2026-08-11T12:00:00_page_hooks": js,
|
|
6838
|
+
"2026-08-20T12:00:00_refresh_token_session_id": Is,
|
|
6839
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Us,
|
|
6840
|
+
"2026-09-01T12:00:00_tenant_operation_rows": Xs
|
|
6722
6841
|
};
|
|
6723
6842
|
//#endregion
|
|
6724
6843
|
//#region migrate/migrate.ts
|
|
6725
|
-
async function
|
|
6726
|
-
|
|
6727
|
-
let { error: n, results: r } = await new
|
|
6844
|
+
async function tc(e, t = !1) {
|
|
6845
|
+
ts(t), t && console.log("migrating...");
|
|
6846
|
+
let { error: n, results: r } = await new we({
|
|
6728
6847
|
db: e,
|
|
6729
|
-
provider: new
|
|
6848
|
+
provider: new Jo(ec)
|
|
6730
6849
|
}).migrateToLatest();
|
|
6731
6850
|
if (r?.forEach((e) => {
|
|
6732
6851
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6733
6852
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6734
6853
|
}
|
|
6735
|
-
async function
|
|
6736
|
-
|
|
6737
|
-
let { error: n, results: r } = await new
|
|
6854
|
+
async function nc(e, t = !1) {
|
|
6855
|
+
ts(t), t && console.log("migrating...");
|
|
6856
|
+
let { error: n, results: r } = await new we({
|
|
6738
6857
|
db: e,
|
|
6739
|
-
provider: new
|
|
6858
|
+
provider: new Jo(ec)
|
|
6740
6859
|
}).migrateDown();
|
|
6741
6860
|
if (r?.forEach((e) => {
|
|
6742
6861
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6744,65 +6863,65 @@ async function Xs(e, t = !1) {
|
|
|
6744
6863
|
}
|
|
6745
6864
|
//#endregion
|
|
6746
6865
|
//#region src/index.ts
|
|
6747
|
-
function
|
|
6866
|
+
function rc(e, t = { useTransactions: !0 }) {
|
|
6748
6867
|
let n = {
|
|
6749
|
-
actions:
|
|
6750
|
-
actionExecutions:
|
|
6751
|
-
actionVersions:
|
|
6752
|
-
branding:
|
|
6753
|
-
clients:
|
|
6754
|
-
clientConnections:
|
|
6755
|
-
clientGrants:
|
|
6756
|
-
clientRegistrationTokens:
|
|
6868
|
+
actions: We(e),
|
|
6869
|
+
actionExecutions: Xe(e),
|
|
6870
|
+
actionVersions: $e(e),
|
|
6871
|
+
branding: mr(e),
|
|
6872
|
+
clients: kn(e),
|
|
6873
|
+
clientConnections: Fn(e),
|
|
6874
|
+
clientGrants: Hn(e),
|
|
6875
|
+
clientRegistrationTokens: er(e),
|
|
6757
6876
|
codes: fn(e),
|
|
6758
|
-
connections:
|
|
6759
|
-
emailProviders:
|
|
6760
|
-
emailTemplates:
|
|
6761
|
-
customDomains:
|
|
6762
|
-
flows:
|
|
6763
|
-
forms:
|
|
6764
|
-
hookCode:
|
|
6765
|
-
hooks:
|
|
6766
|
-
invites:
|
|
6767
|
-
keys:
|
|
6768
|
-
loginSessions:
|
|
6769
|
-
logs:
|
|
6770
|
-
logStreams:
|
|
6771
|
-
migrationSources:
|
|
6772
|
-
authenticationMethods:
|
|
6773
|
-
passwords:
|
|
6774
|
-
promptSettings:
|
|
6775
|
-
proxyRoutes:
|
|
6776
|
-
scimConfigurations:
|
|
6777
|
-
scimTokens:
|
|
6778
|
-
scimExternalIds:
|
|
6779
|
-
refreshTokens:
|
|
6780
|
-
resourceServers:
|
|
6781
|
-
rolePermissions:
|
|
6782
|
-
grants:
|
|
6783
|
-
userPermissions:
|
|
6784
|
-
userRoles:
|
|
6785
|
-
roles:
|
|
6786
|
-
sessions:
|
|
6787
|
-
sessionCleanup:
|
|
6788
|
-
tenants:
|
|
6789
|
-
tenantOperations:
|
|
6790
|
-
tenantOperationEvents:
|
|
6791
|
-
tenantOperationRows:
|
|
6792
|
-
rollouts:
|
|
6793
|
-
themes:
|
|
6794
|
-
universalLoginTemplates:
|
|
6795
|
-
customText:
|
|
6796
|
-
users:
|
|
6797
|
-
userActivity:
|
|
6798
|
-
organizations:
|
|
6799
|
-
organizationConnections:
|
|
6800
|
-
userOrganizations:
|
|
6801
|
-
stats:
|
|
6802
|
-
analytics:
|
|
6803
|
-
outbox:
|
|
6877
|
+
connections: bn(e),
|
|
6878
|
+
emailProviders: ti(e),
|
|
6879
|
+
emailTemplates: ci(e),
|
|
6880
|
+
customDomains: dr(e),
|
|
6881
|
+
flows: Ot(e),
|
|
6882
|
+
forms: Di(e),
|
|
6883
|
+
hookCode: kr(e),
|
|
6884
|
+
hooks: wr(e),
|
|
6885
|
+
invites: Da(e),
|
|
6886
|
+
keys: ir(e),
|
|
6887
|
+
loginSessions: Kr(e),
|
|
6888
|
+
logs: Wt(e),
|
|
6889
|
+
logStreams: co(e),
|
|
6890
|
+
migrationSources: uo(e),
|
|
6891
|
+
authenticationMethods: Za(e),
|
|
6892
|
+
passwords: tn(e),
|
|
6893
|
+
promptSettings: Xr(e),
|
|
6894
|
+
proxyRoutes: ho(e),
|
|
6895
|
+
scimConfigurations: xo(e),
|
|
6896
|
+
scimTokens: Co(e),
|
|
6897
|
+
scimExternalIds: To(e),
|
|
6898
|
+
refreshTokens: yi(e),
|
|
6899
|
+
resourceServers: Ni(e),
|
|
6900
|
+
rolePermissions: Wi(e),
|
|
6901
|
+
grants: Xi(e),
|
|
6902
|
+
userPermissions: ta(e),
|
|
6903
|
+
userRoles: sa(e),
|
|
6904
|
+
roles: zi(e),
|
|
6905
|
+
sessions: Xt(e),
|
|
6906
|
+
sessionCleanup: xi(e),
|
|
6907
|
+
tenants: It(e),
|
|
6908
|
+
tenantOperations: Do(e),
|
|
6909
|
+
tenantOperationEvents: Bo(e),
|
|
6910
|
+
tenantOperationRows: Wo(e),
|
|
6911
|
+
rollouts: qo(e),
|
|
6912
|
+
themes: Pr(e),
|
|
6913
|
+
universalLoginTemplates: vr(e),
|
|
6914
|
+
customText: Wa(e),
|
|
6915
|
+
users: bt(e),
|
|
6916
|
+
userActivity: _t(e),
|
|
6917
|
+
organizations: pa(e),
|
|
6918
|
+
organizationConnections: ma(e),
|
|
6919
|
+
userOrganizations: xa(e),
|
|
6920
|
+
stats: Ma(e),
|
|
6921
|
+
analytics: Ua(e),
|
|
6922
|
+
outbox: so(e),
|
|
6804
6923
|
async transaction(r) {
|
|
6805
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6924
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(rc(e, {
|
|
6806
6925
|
...t,
|
|
6807
6926
|
useTransactions: !1
|
|
6808
6927
|
})));
|
|
@@ -6811,4 +6930,4 @@ function Zs(e, t = { useTransactions: !0 }) {
|
|
|
6811
6930
|
return n;
|
|
6812
6931
|
}
|
|
6813
6932
|
//#endregion
|
|
6814
|
-
export {
|
|
6933
|
+
export { _o as createProxyDataAdapter, ho as createProxyRoutesAdapter, rc as default, nc as migrateDown, tc as migrateToLatest };
|