@authhero/kysely-adapter 12.6.2 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.d.ts +16 -0
- package/dist/kysely-adapter.mjs +1127 -930
- package/dist/types/migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +2 -0
- package/dist/types/src/db.d.ts +16 -0
- package/dist/types/src/tenantOperationRows/index.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,
|
|
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 we, unquoteLuceneValue as C } from "@authhero/adapter-interfaces";
|
|
5
5
|
import { HTTPException as w } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as Te } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var Ee = Object.defineProperty, T = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) Ee(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || Ee(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, De = 17, Oe = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -26,38 +26,38 @@ var we = Object.defineProperty, T = (e, t) => {
|
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
28
|
function E(t) {
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", De)();
|
|
30
|
+
return `${Oe[t]}${n}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ke() {
|
|
33
33
|
return E("organization");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Ae() {
|
|
36
36
|
return E("connection");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function je() {
|
|
39
39
|
return E("action");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Me() {
|
|
42
42
|
return E("action_version");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Ne() {
|
|
45
45
|
return E("hook");
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Pe() {
|
|
48
48
|
return E("resource_server");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Fe() {
|
|
51
51
|
return E("hook_code");
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Ie() {
|
|
54
54
|
return E("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Le(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 ?? je();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,14 +91,14 @@ function Fe(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function Re(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 ze(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 Ie(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: Re(c),
|
|
117
|
+
dependencies: Re(l),
|
|
118
|
+
supported_triggers: Re(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -123,16 +123,16 @@ function Ie(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Be(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function D(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) : Be(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 O(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 = we(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 O(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 = we(r);
|
|
162
|
+
} else n = null, r = we(e), i = !1;
|
|
163
163
|
return {
|
|
164
164
|
key: n,
|
|
165
165
|
value: r,
|
|
@@ -199,17 +199,17 @@ function O(e, t, n, r, i = [], a = {}) {
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/actions/list.ts
|
|
202
|
-
function
|
|
202
|
+
function Ve(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 He(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 = D(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 Re(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: Ve(o),
|
|
226
|
+
dependencies: Ve(s),
|
|
227
|
+
supported_triggers: Ve(c),
|
|
228
228
|
is_system: !!l,
|
|
229
229
|
inherit: !!u
|
|
230
230
|
};
|
|
@@ -246,7 +246,7 @@ function Re(e) {
|
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/actions/update.ts
|
|
249
|
-
function
|
|
249
|
+
function Ue(e) {
|
|
250
250
|
if (!e) return [];
|
|
251
251
|
try {
|
|
252
252
|
let t = JSON.parse(e);
|
|
@@ -255,11 +255,11 @@ function ze(e) {
|
|
|
255
255
|
return [];
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function We(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(Ue(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 Be(e) {
|
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
276
|
//#region src/actions/remove.ts
|
|
277
|
-
function
|
|
277
|
+
function Ge(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 Ke(e) {
|
|
283
283
|
return {
|
|
284
|
-
create:
|
|
285
|
-
get:
|
|
286
|
-
list:
|
|
287
|
-
update:
|
|
288
|
-
remove:
|
|
284
|
+
create: Le(e),
|
|
285
|
+
get: ze(e),
|
|
286
|
+
list: He(e),
|
|
287
|
+
update: We(e),
|
|
288
|
+
remove: Ge(e)
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/actionExecutions/create.ts
|
|
293
|
-
function
|
|
293
|
+
function qe(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 Ue(e) {
|
|
|
316
316
|
}
|
|
317
317
|
//#endregion
|
|
318
318
|
//#region src/actionExecutions/get.ts
|
|
319
|
-
function
|
|
319
|
+
function Je(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 Ye(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,8 +331,8 @@ function Ge(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: Je(r.results) ?? [],
|
|
335
|
+
logs: Je(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;
|
|
@@ -340,26 +340,26 @@ function Ge(e) {
|
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
342
342
|
//#region src/actionExecutions/cleanup.ts
|
|
343
|
-
var
|
|
344
|
-
async function
|
|
343
|
+
var Xe = 5e4;
|
|
344
|
+
async function Ze(e) {
|
|
345
345
|
try {
|
|
346
346
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
347
347
|
} catch {
|
|
348
348
|
return "sqlite";
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function Qe(e) {
|
|
352
352
|
let t;
|
|
353
353
|
return async (n) => {
|
|
354
354
|
let r = Date.parse(n);
|
|
355
355
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
356
|
-
if (t ??= await
|
|
356
|
+
if (t ??= await Ze(e), t === "sqlite") {
|
|
357
357
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
358
358
|
return Number(t.numDeletedRows);
|
|
359
359
|
}
|
|
360
|
-
let i = 0, a =
|
|
361
|
-
for (; a >=
|
|
362
|
-
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(
|
|
360
|
+
let i = 0, a = Xe;
|
|
361
|
+
for (; a >= Xe;) {
|
|
362
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(Xe).executeTakeFirst();
|
|
363
363
|
a = Number(t.numDeletedRows), i += a;
|
|
364
364
|
}
|
|
365
365
|
return i;
|
|
@@ -367,39 +367,39 @@ function qe(e) {
|
|
|
367
367
|
}
|
|
368
368
|
//#endregion
|
|
369
369
|
//#region src/actionExecutions/index.ts
|
|
370
|
-
function
|
|
370
|
+
function $e(e) {
|
|
371
371
|
return {
|
|
372
|
-
create:
|
|
373
|
-
get:
|
|
374
|
-
cleanup:
|
|
372
|
+
create: qe(e),
|
|
373
|
+
get: Ye(e),
|
|
374
|
+
cleanup: Qe(e)
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
//#endregion
|
|
378
378
|
//#region src/actionVersions/index.ts
|
|
379
|
-
function
|
|
379
|
+
function et(e) {
|
|
380
380
|
if (e) try {
|
|
381
381
|
return JSON.parse(e);
|
|
382
382
|
} catch {
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function tt(e) {
|
|
387
387
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
388
388
|
return {
|
|
389
389
|
...c,
|
|
390
390
|
runtime: s ?? void 0,
|
|
391
391
|
deployed: !!o,
|
|
392
|
-
secrets:
|
|
393
|
-
dependencies:
|
|
394
|
-
supported_triggers:
|
|
392
|
+
secrets: et(r),
|
|
393
|
+
dependencies: et(i),
|
|
394
|
+
supported_triggers: et(a),
|
|
395
395
|
created_at: new Date(Number(t)).toISOString(),
|
|
396
396
|
updated_at: new Date(Number(n)).toISOString()
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function nt(e) {
|
|
400
400
|
return {
|
|
401
401
|
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 ??
|
|
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 ?? Me(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
403
403
|
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
404
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
405
405
|
deployed: 0,
|
|
@@ -436,10 +436,10 @@ function Xe(e) {
|
|
|
436
436
|
},
|
|
437
437
|
async get(t, n, r) {
|
|
438
438
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
439
|
-
return i ?
|
|
439
|
+
return i ? tt(i) : null;
|
|
440
440
|
},
|
|
441
441
|
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(
|
|
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(tt);
|
|
443
443
|
if (!s) return {
|
|
444
444
|
versions: l,
|
|
445
445
|
start: 0,
|
|
@@ -462,7 +462,7 @@ function Xe(e) {
|
|
|
462
462
|
}
|
|
463
463
|
//#endregion
|
|
464
464
|
//#region src/outbox/create.ts
|
|
465
|
-
async function
|
|
465
|
+
async function O(e, t, n, r) {
|
|
466
466
|
await e.insertInto("outbox_events").values({
|
|
467
467
|
id: n,
|
|
468
468
|
tenant_id: t,
|
|
@@ -481,15 +481,15 @@ async function M(e, t, n, r) {
|
|
|
481
481
|
error: null
|
|
482
482
|
}).execute();
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function rt(e) {
|
|
485
485
|
return async (n, r) => {
|
|
486
486
|
let i = t();
|
|
487
|
-
return await
|
|
487
|
+
return await O(e, n, i, r), i;
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
490
|
//#endregion
|
|
491
491
|
//#region src/users/create.ts
|
|
492
|
-
function
|
|
492
|
+
function it(e) {
|
|
493
493
|
return async (n, r, i) => {
|
|
494
494
|
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
495
|
...f,
|
|
@@ -524,7 +524,7 @@ function Qe(e) {
|
|
|
524
524
|
};
|
|
525
525
|
await e.insertInto("passwords").values(r).execute();
|
|
526
526
|
}
|
|
527
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
527
|
+
for (let t of i?.outboxEvents ?? []) await O(e, n, t.id, t);
|
|
528
528
|
};
|
|
529
529
|
try {
|
|
530
530
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
@@ -549,21 +549,21 @@ function Qe(e) {
|
|
|
549
549
|
}
|
|
550
550
|
//#endregion
|
|
551
551
|
//#region src/users/user-to-identity.ts
|
|
552
|
-
var
|
|
552
|
+
var at = [
|
|
553
553
|
"email",
|
|
554
554
|
"email_verified",
|
|
555
555
|
"phone_number",
|
|
556
556
|
"phone_verified",
|
|
557
557
|
"username"
|
|
558
558
|
];
|
|
559
|
-
function
|
|
559
|
+
function k(e, t = !1) {
|
|
560
560
|
let n = {
|
|
561
561
|
connection: e.connection,
|
|
562
562
|
provider: e.provider,
|
|
563
563
|
user_id: ue(e.user_id).id,
|
|
564
564
|
isSocial: !!e.is_social
|
|
565
565
|
};
|
|
566
|
-
for (let t of
|
|
566
|
+
for (let t of at) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
567
567
|
if (!t) {
|
|
568
568
|
let t = {};
|
|
569
569
|
try {
|
|
@@ -581,7 +581,7 @@ function N(e, t = !1) {
|
|
|
581
581
|
}
|
|
582
582
|
//#endregion
|
|
583
583
|
//#region src/users/get.ts
|
|
584
|
-
function
|
|
584
|
+
function ot(e) {
|
|
585
585
|
return async (t, n) => {
|
|
586
586
|
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
587
|
"user_activity.last_login",
|
|
@@ -603,21 +603,21 @@ function et(e) {
|
|
|
603
603
|
app_metadata: JSON.parse(r.app_metadata),
|
|
604
604
|
user_metadata: JSON.parse(r.user_metadata),
|
|
605
605
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
606
|
-
identities: [
|
|
606
|
+
identities: [k(r, !0), ...i.map((e) => k(e))]
|
|
607
607
|
});
|
|
608
608
|
};
|
|
609
609
|
}
|
|
610
610
|
//#endregion
|
|
611
611
|
//#region src/helpers/paginate.ts
|
|
612
|
-
function
|
|
612
|
+
function A(e) {
|
|
613
613
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function st(e, t) {
|
|
616
616
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
617
617
|
return n >= 1 ? n : t;
|
|
618
618
|
}
|
|
619
|
-
async function
|
|
620
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
619
|
+
async function j(e, t, n) {
|
|
620
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = st(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
621
621
|
if (c && c.k !== n.sortKey) throw new w(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
622
622
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
623
623
|
else {
|
|
@@ -641,7 +641,7 @@ async function F(e, t, n) {
|
|
|
641
641
|
}
|
|
642
642
|
//#endregion
|
|
643
643
|
//#region src/users/list.ts
|
|
644
|
-
var
|
|
644
|
+
var ct = [
|
|
645
645
|
"user_id",
|
|
646
646
|
"email",
|
|
647
647
|
"email_verified",
|
|
@@ -664,20 +664,20 @@ var nt = [
|
|
|
664
664
|
"login_count",
|
|
665
665
|
"created_at",
|
|
666
666
|
"updated_at"
|
|
667
|
-
],
|
|
667
|
+
], lt = new Set([
|
|
668
668
|
"last_login",
|
|
669
669
|
"last_ip",
|
|
670
670
|
"login_count"
|
|
671
|
-
]),
|
|
671
|
+
]), ut = Object.fromEntries(ct.map((e) => [e, e === "login_count" ? {
|
|
672
672
|
column: "user_activity.login_count",
|
|
673
673
|
defaultValue: 0
|
|
674
|
-
} :
|
|
674
|
+
} : lt.has(e) ? `user_activity.${e}` : `users.${e}`])), dt = [
|
|
675
675
|
"email",
|
|
676
676
|
"name",
|
|
677
677
|
"phone_number",
|
|
678
678
|
"user_id"
|
|
679
679
|
];
|
|
680
|
-
async function
|
|
680
|
+
async function ft(e, t, n) {
|
|
681
681
|
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
682
|
return n.map((e) => {
|
|
683
683
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -691,20 +691,20 @@ async function ot(e, t, n) {
|
|
|
691
691
|
app_metadata: JSON.parse(e.app_metadata),
|
|
692
692
|
user_metadata: JSON.parse(e.user_metadata),
|
|
693
693
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
694
|
-
identities: [
|
|
694
|
+
identities: [k(e, !0), ...t.map((e) => k(e))]
|
|
695
695
|
});
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function pt(e) {
|
|
699
699
|
return async (t, n = {}) => {
|
|
700
700
|
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
701
|
if (c) {
|
|
702
|
-
let t = S(c,
|
|
703
|
-
t && (l =
|
|
702
|
+
let t = S(c, ct);
|
|
703
|
+
t && (l = D(e, l, t, dt, [], ut));
|
|
704
704
|
}
|
|
705
|
-
if (
|
|
705
|
+
if (A(n)) {
|
|
706
706
|
if (s?.sort_by && s.sort_by !== "created_at") throw new w(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
707
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
707
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await j(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
708
708
|
"user_activity.last_login",
|
|
709
709
|
"user_activity.last_ip",
|
|
710
710
|
"user_activity.login_count"
|
|
@@ -713,7 +713,7 @@ function st(e) {
|
|
|
713
713
|
sortOrder: r,
|
|
714
714
|
idColumn: "users.user_id",
|
|
715
715
|
sortKey: `created_at:${r}`
|
|
716
|
-
}), c = await
|
|
716
|
+
}), c = await ft(e, t, i);
|
|
717
717
|
return {
|
|
718
718
|
users: c,
|
|
719
719
|
start: 0,
|
|
@@ -723,17 +723,17 @@ function st(e) {
|
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
725
|
if (s && s.sort_by) {
|
|
726
|
-
let t =
|
|
726
|
+
let t = ut[s.sort_by];
|
|
727
727
|
if (t) {
|
|
728
728
|
let { ref: n } = e.dynamic;
|
|
729
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
729
|
+
l = l.orderBy(typeof t == "string" ? n(t) : Be(t), s.sort_order);
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
let u = l.offset(r * i).limit(i), [d, f] = await Promise.all([u.selectAll("users").select([
|
|
733
733
|
"user_activity.last_login",
|
|
734
734
|
"user_activity.last_ip",
|
|
735
735
|
"user_activity.login_count"
|
|
736
|
-
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await
|
|
736
|
+
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await ft(e, t, d);
|
|
737
737
|
if (!f) return {
|
|
738
738
|
users: p,
|
|
739
739
|
start: 0,
|
|
@@ -751,12 +751,12 @@ function st(e) {
|
|
|
751
751
|
}
|
|
752
752
|
//#endregion
|
|
753
753
|
//#region src/users/remove.ts
|
|
754
|
-
function
|
|
754
|
+
function mt(e) {
|
|
755
755
|
return async (t, n, r) => {
|
|
756
756
|
let i = async (e) => {
|
|
757
757
|
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
758
|
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
|
|
759
|
+
for (let n of r?.outboxEvents ?? []) await O(e, t, n.id, n);
|
|
760
760
|
return i.length === 1;
|
|
761
761
|
};
|
|
762
762
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -764,14 +764,14 @@ function ct(e) {
|
|
|
764
764
|
}
|
|
765
765
|
//#endregion
|
|
766
766
|
//#region src/utils/flatten.ts
|
|
767
|
-
function
|
|
767
|
+
function M(e, t = "", n = {}) {
|
|
768
768
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
769
769
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
770
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
770
|
+
typeof a == "object" && a && !Array.isArray(a) ? M(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
771
771
|
}
|
|
772
772
|
return n;
|
|
773
773
|
}
|
|
774
|
-
function
|
|
774
|
+
function ht(e, t) {
|
|
775
775
|
let n = {};
|
|
776
776
|
for (let [r, i] of Object.entries(e)) {
|
|
777
777
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -788,7 +788,7 @@ function lt(e, t) {
|
|
|
788
788
|
}
|
|
789
789
|
//#endregion
|
|
790
790
|
//#region src/userActivity/index.ts
|
|
791
|
-
function
|
|
791
|
+
function gt(e) {
|
|
792
792
|
return {
|
|
793
793
|
user_id: e.user_id,
|
|
794
794
|
last_login: e.last_login ?? void 0,
|
|
@@ -798,18 +798,18 @@ function ut(e) {
|
|
|
798
798
|
last_password_reset: e.last_password_reset ?? void 0
|
|
799
799
|
};
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function _t(e) {
|
|
802
802
|
let t = {};
|
|
803
803
|
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
804
|
}
|
|
805
|
-
function
|
|
805
|
+
function vt(e) {
|
|
806
806
|
return {
|
|
807
807
|
async get(t, n) {
|
|
808
808
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
809
|
-
return r ?
|
|
809
|
+
return r ? gt(r) : null;
|
|
810
810
|
},
|
|
811
811
|
async upsert(t, n, r) {
|
|
812
|
-
let i =
|
|
812
|
+
let i = _t(r);
|
|
813
813
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
814
814
|
if (Object.keys(i).length === 0) return;
|
|
815
815
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -831,9 +831,9 @@ function ft(e) {
|
|
|
831
831
|
}
|
|
832
832
|
//#endregion
|
|
833
833
|
//#region src/users/update.ts
|
|
834
|
-
function
|
|
834
|
+
function yt(e) {
|
|
835
835
|
return async (t, n, r, i) => {
|
|
836
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
836
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = M({
|
|
837
837
|
...c,
|
|
838
838
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
839
839
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -844,12 +844,12 @@ function pt(e) {
|
|
|
844
844
|
}), u = async (e) => {
|
|
845
845
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
846
846
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
847
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
847
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await vt(e).upsert(t, n, {
|
|
848
848
|
last_login: a,
|
|
849
849
|
last_ip: o,
|
|
850
850
|
login_count: s
|
|
851
851
|
});
|
|
852
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
852
|
+
for (let n of i?.outboxEvents ?? []) await O(e, t, n.id, n);
|
|
853
853
|
return !0;
|
|
854
854
|
};
|
|
855
855
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -857,26 +857,26 @@ function pt(e) {
|
|
|
857
857
|
}
|
|
858
858
|
//#endregion
|
|
859
859
|
//#region src/users/unlink.ts
|
|
860
|
-
function
|
|
860
|
+
function bt(e) {
|
|
861
861
|
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
862
|
}
|
|
863
863
|
//#endregion
|
|
864
864
|
//#region src/users/index.ts
|
|
865
|
-
function
|
|
866
|
-
let t =
|
|
865
|
+
function xt(e) {
|
|
866
|
+
let t = it(e);
|
|
867
867
|
return {
|
|
868
868
|
create: t,
|
|
869
869
|
rawCreate: t,
|
|
870
|
-
remove:
|
|
871
|
-
get:
|
|
872
|
-
list:
|
|
873
|
-
update:
|
|
874
|
-
unlink:
|
|
870
|
+
remove: mt(e),
|
|
871
|
+
get: ot(e),
|
|
872
|
+
list: pt(e),
|
|
873
|
+
update: yt(e),
|
|
874
|
+
unlink: bt(e)
|
|
875
875
|
};
|
|
876
876
|
}
|
|
877
877
|
//#endregion
|
|
878
878
|
//#region src/flows/create.ts
|
|
879
|
-
function
|
|
879
|
+
function St(e) {
|
|
880
880
|
return async (n, r, i) => {
|
|
881
881
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
882
882
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -894,7 +894,7 @@ function gt(e) {
|
|
|
894
894
|
}
|
|
895
895
|
//#endregion
|
|
896
896
|
//#region src/helpers/parse.ts
|
|
897
|
-
function
|
|
897
|
+
function N(e, t) {
|
|
898
898
|
if (!e) return t;
|
|
899
899
|
try {
|
|
900
900
|
return JSON.parse(e);
|
|
@@ -902,7 +902,7 @@ function L(e, t) {
|
|
|
902
902
|
return t;
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function Ct(e) {
|
|
906
906
|
if (e) try {
|
|
907
907
|
let t = JSON.parse(e);
|
|
908
908
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -910,33 +910,33 @@ function _t(e) {
|
|
|
910
910
|
return;
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
|
-
function
|
|
914
|
-
for (let r in t) r in e && (n[r] =
|
|
913
|
+
function wt(e, t, n = { ...e }) {
|
|
914
|
+
for (let r in t) r in e && (n[r] = N(e[r], t[r]));
|
|
915
915
|
return n;
|
|
916
916
|
}
|
|
917
917
|
//#endregion
|
|
918
918
|
//#region src/flows/get.ts
|
|
919
|
-
function
|
|
919
|
+
function Tt(e) {
|
|
920
920
|
return async (t, n) => {
|
|
921
921
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
922
922
|
if (!r) return null;
|
|
923
923
|
let i = {
|
|
924
924
|
...r,
|
|
925
|
-
actions:
|
|
925
|
+
actions: N(r.actions, [])
|
|
926
926
|
};
|
|
927
927
|
return b.parse(l(i));
|
|
928
928
|
};
|
|
929
929
|
}
|
|
930
930
|
//#endregion
|
|
931
931
|
//#region src/flows/list.ts
|
|
932
|
-
function
|
|
932
|
+
function Et(e) {
|
|
933
933
|
return async (t, n = {}) => {
|
|
934
934
|
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 =
|
|
935
|
+
s && (c = D(e, c, s, []));
|
|
936
936
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
937
937
|
let t = {
|
|
938
938
|
...e,
|
|
939
|
-
actions:
|
|
939
|
+
actions: N(e.actions, [])
|
|
940
940
|
};
|
|
941
941
|
return b.parse(l(t));
|
|
942
942
|
});
|
|
@@ -957,7 +957,7 @@ function bt(e) {
|
|
|
957
957
|
}
|
|
958
958
|
//#endregion
|
|
959
959
|
//#region src/flows/update.ts
|
|
960
|
-
function
|
|
960
|
+
function Dt(e) {
|
|
961
961
|
return async (t, n, r) => {
|
|
962
962
|
let i = {
|
|
963
963
|
...r,
|
|
@@ -975,27 +975,27 @@ function xt(e) {
|
|
|
975
975
|
}
|
|
976
976
|
//#endregion
|
|
977
977
|
//#region src/flows/remove.ts
|
|
978
|
-
function
|
|
978
|
+
function Ot(e) {
|
|
979
979
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
980
980
|
}
|
|
981
981
|
//#endregion
|
|
982
982
|
//#region src/flows/index.ts
|
|
983
|
-
function
|
|
983
|
+
function kt(e) {
|
|
984
984
|
return {
|
|
985
|
-
create:
|
|
986
|
-
get:
|
|
987
|
-
list:
|
|
988
|
-
update:
|
|
989
|
-
remove:
|
|
985
|
+
create: St(e),
|
|
986
|
+
get: Tt(e),
|
|
987
|
+
list: Et(e),
|
|
988
|
+
update: Dt(e),
|
|
989
|
+
remove: Ot(e)
|
|
990
990
|
};
|
|
991
991
|
}
|
|
992
992
|
//#endregion
|
|
993
993
|
//#region src/tenants/utils.ts
|
|
994
|
-
function
|
|
994
|
+
function At(e) {
|
|
995
995
|
let t = { ...e };
|
|
996
996
|
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
997
|
}
|
|
998
|
-
function
|
|
998
|
+
function jt(e) {
|
|
999
999
|
let t = { ...e };
|
|
1000
1000
|
return d(e, [
|
|
1001
1001
|
"session_cookie",
|
|
@@ -1018,14 +1018,14 @@ function Tt(e) {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
//#endregion
|
|
1020
1020
|
//#region src/tenants/create.ts
|
|
1021
|
-
function
|
|
1021
|
+
function Mt(e) {
|
|
1022
1022
|
return async (n, r) => {
|
|
1023
1023
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
1024
1024
|
...n,
|
|
1025
1025
|
id: i?.id ?? n.id ?? t(),
|
|
1026
1026
|
created_at: i?.created_at ?? a,
|
|
1027
1027
|
updated_at: i?.updated_at ?? a
|
|
1028
|
-
}, s =
|
|
1028
|
+
}, s = jt(o);
|
|
1029
1029
|
try {
|
|
1030
1030
|
await e.insertInto("tenants").values(s).execute();
|
|
1031
1031
|
} catch (e) {
|
|
@@ -1037,23 +1037,23 @@ function Et(e) {
|
|
|
1037
1037
|
}
|
|
1038
1038
|
//#endregion
|
|
1039
1039
|
//#region src/tenants/get.ts
|
|
1040
|
-
function
|
|
1040
|
+
function Nt(e) {
|
|
1041
1041
|
return async (t) => {
|
|
1042
1042
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1043
|
-
return n ?
|
|
1043
|
+
return n ? At(n) : null;
|
|
1044
1044
|
};
|
|
1045
1045
|
}
|
|
1046
1046
|
//#endregion
|
|
1047
1047
|
//#region src/tenants/list.ts
|
|
1048
|
-
function
|
|
1048
|
+
function Pt(e) {
|
|
1049
1049
|
return async (t) => {
|
|
1050
1050
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1051
1051
|
if (s && s.sort_by) {
|
|
1052
1052
|
let { ref: t } = e.dynamic;
|
|
1053
1053
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1054
1054
|
}
|
|
1055
|
-
c && (n =
|
|
1056
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1055
|
+
c && (n = D(e, n, c, ["friendly_name"]));
|
|
1056
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(At);
|
|
1057
1057
|
if (!a) return { tenants: l };
|
|
1058
1058
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1059
1059
|
return {
|
|
@@ -1066,10 +1066,10 @@ function Ot(e) {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
//#endregion
|
|
1068
1068
|
//#region src/tenants/update.ts
|
|
1069
|
-
function
|
|
1069
|
+
function Ft(e) {
|
|
1070
1070
|
return async (t, n) => {
|
|
1071
1071
|
let r = {
|
|
1072
|
-
...
|
|
1072
|
+
...jt(n),
|
|
1073
1073
|
id: t,
|
|
1074
1074
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1075
1075
|
};
|
|
@@ -1078,29 +1078,29 @@ function kt(e) {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
//#endregion
|
|
1080
1080
|
//#region src/tenants/remove.ts
|
|
1081
|
-
function
|
|
1081
|
+
function It(e) {
|
|
1082
1082
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1083
1083
|
}
|
|
1084
1084
|
//#endregion
|
|
1085
1085
|
//#region src/tenants/index.ts
|
|
1086
|
-
function
|
|
1086
|
+
function Lt(e) {
|
|
1087
1087
|
return {
|
|
1088
|
-
create:
|
|
1089
|
-
get:
|
|
1090
|
-
list:
|
|
1091
|
-
update:
|
|
1092
|
-
remove:
|
|
1088
|
+
create: Mt(e),
|
|
1089
|
+
get: Nt(e),
|
|
1090
|
+
list: Pt(e),
|
|
1091
|
+
update: Ft(e),
|
|
1092
|
+
remove: It(e)
|
|
1093
1093
|
};
|
|
1094
1094
|
}
|
|
1095
1095
|
//#endregion
|
|
1096
1096
|
//#region src/logs/create.ts
|
|
1097
|
-
function
|
|
1097
|
+
function Rt(e) {
|
|
1098
1098
|
return e ? JSON.stringify(e) : void 0;
|
|
1099
1099
|
}
|
|
1100
|
-
var
|
|
1101
|
-
function
|
|
1100
|
+
var zt = 256;
|
|
1101
|
+
function Bt(e) {
|
|
1102
1102
|
return async (n, r) => {
|
|
1103
|
-
let i = r.user_agent?.slice(0,
|
|
1103
|
+
let i = r.user_agent?.slice(0, zt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1104
1104
|
return await e.insertInto("logs").values({
|
|
1105
1105
|
...s,
|
|
1106
1106
|
log_id: a,
|
|
@@ -1109,8 +1109,8 @@ function Pt(e) {
|
|
|
1109
1109
|
description: r.description?.substring(0, 256),
|
|
1110
1110
|
isMobile: +!!r.isMobile,
|
|
1111
1111
|
scope: r.scope,
|
|
1112
|
-
auth0_client:
|
|
1113
|
-
details:
|
|
1112
|
+
auth0_client: Rt(r.auth0_client),
|
|
1113
|
+
details: Rt(r.details)?.substring(0, 8192),
|
|
1114
1114
|
country_code: o?.country_code,
|
|
1115
1115
|
city_name: o?.city_name,
|
|
1116
1116
|
latitude: o?.latitude,
|
|
@@ -1126,7 +1126,7 @@ function Pt(e) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
//#endregion
|
|
1128
1128
|
//#region src/logs/logs.ts
|
|
1129
|
-
function
|
|
1129
|
+
function Vt(e) {
|
|
1130
1130
|
if (!e) return "";
|
|
1131
1131
|
try {
|
|
1132
1132
|
return JSON.parse(e);
|
|
@@ -1134,13 +1134,13 @@ function Ft(e) {
|
|
|
1134
1134
|
return e;
|
|
1135
1135
|
}
|
|
1136
1136
|
}
|
|
1137
|
-
function
|
|
1137
|
+
function P(e) {
|
|
1138
1138
|
return {
|
|
1139
1139
|
...e,
|
|
1140
1140
|
client_id: e.client_id,
|
|
1141
1141
|
client_name: e.client_name || "",
|
|
1142
|
-
auth0_client:
|
|
1143
|
-
details:
|
|
1142
|
+
auth0_client: Vt(e.auth0_client),
|
|
1143
|
+
details: Vt(e.details),
|
|
1144
1144
|
isMobile: !!e.isMobile,
|
|
1145
1145
|
scope: e.scope || void 0,
|
|
1146
1146
|
log_id: e.log_id,
|
|
@@ -1156,7 +1156,7 @@ function It(e) {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
//#endregion
|
|
1158
1158
|
//#region src/logs/list.ts
|
|
1159
|
-
var
|
|
1159
|
+
var Ht = [
|
|
1160
1160
|
"user_id",
|
|
1161
1161
|
"ip",
|
|
1162
1162
|
"type",
|
|
@@ -1182,25 +1182,25 @@ var Lt = [
|
|
|
1182
1182
|
"time_zone",
|
|
1183
1183
|
"continent_code"
|
|
1184
1184
|
];
|
|
1185
|
-
function
|
|
1185
|
+
function Ut(e) {
|
|
1186
1186
|
return async (t, n = {}) => {
|
|
1187
1187
|
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
1188
|
if (c) {
|
|
1189
|
-
let t = S(c,
|
|
1190
|
-
t && (d =
|
|
1189
|
+
let t = S(c, Ht);
|
|
1190
|
+
t && (d = D(e, d, t, [
|
|
1191
1191
|
"user_id",
|
|
1192
1192
|
"ip",
|
|
1193
1193
|
"description"
|
|
1194
1194
|
], ["description"]));
|
|
1195
1195
|
}
|
|
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())),
|
|
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())), A(n)) {
|
|
1197
1197
|
if (s?.sort_by && s.sort_by !== "date") throw new w(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1198
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1198
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await j(d.selectAll(), n, {
|
|
1199
1199
|
sortColumn: "date",
|
|
1200
1200
|
sortOrder: e,
|
|
1201
1201
|
idColumn: "log_id",
|
|
1202
1202
|
sortKey: `date:${e}`
|
|
1203
|
-
}), a = t.map(
|
|
1203
|
+
}), a = t.map(P);
|
|
1204
1204
|
return {
|
|
1205
1205
|
logs: a,
|
|
1206
1206
|
start: 0,
|
|
@@ -1215,7 +1215,7 @@ function Rt(e) {
|
|
|
1215
1215
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1216
1216
|
}
|
|
1217
1217
|
f = f.offset(r * i).limit(i);
|
|
1218
|
-
let p = (await f.selectAll().execute()).map(
|
|
1218
|
+
let p = (await f.selectAll().execute()).map(P);
|
|
1219
1219
|
if (!a) return {
|
|
1220
1220
|
logs: p,
|
|
1221
1221
|
start: 0,
|
|
@@ -1233,24 +1233,24 @@ function Rt(e) {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
//#endregion
|
|
1235
1235
|
//#region src/logs/get.ts
|
|
1236
|
-
function
|
|
1236
|
+
function Wt(e) {
|
|
1237
1237
|
return async (t, n) => {
|
|
1238
1238
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1239
|
-
return r ?
|
|
1239
|
+
return r ? P(r) : null;
|
|
1240
1240
|
};
|
|
1241
1241
|
}
|
|
1242
1242
|
//#endregion
|
|
1243
1243
|
//#region src/logs/index.ts
|
|
1244
|
-
function
|
|
1244
|
+
function Gt(e) {
|
|
1245
1245
|
return {
|
|
1246
|
-
create:
|
|
1247
|
-
list:
|
|
1248
|
-
get:
|
|
1246
|
+
create: Bt(e),
|
|
1247
|
+
list: Ut(e),
|
|
1248
|
+
get: Wt(e)
|
|
1249
1249
|
};
|
|
1250
1250
|
}
|
|
1251
1251
|
//#endregion
|
|
1252
1252
|
//#region src/sessions/get.ts
|
|
1253
|
-
function
|
|
1253
|
+
function Kt(e) {
|
|
1254
1254
|
return async (t, n) => {
|
|
1255
1255
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1256
1256
|
if (!i) return null;
|
|
@@ -1284,7 +1284,7 @@ function Vt(e) {
|
|
|
1284
1284
|
}
|
|
1285
1285
|
//#endregion
|
|
1286
1286
|
//#region src/sessions/create.ts
|
|
1287
|
-
function
|
|
1287
|
+
function qt(e) {
|
|
1288
1288
|
return async (t, n) => {
|
|
1289
1289
|
let r = Date.now(), i = c(), a = {
|
|
1290
1290
|
...n,
|
|
@@ -1316,12 +1316,12 @@ function Ht(e) {
|
|
|
1316
1316
|
}
|
|
1317
1317
|
//#endregion
|
|
1318
1318
|
//#region src/sessions/remove.ts
|
|
1319
|
-
function
|
|
1319
|
+
function Jt(e) {
|
|
1320
1320
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1321
1321
|
}
|
|
1322
1322
|
//#endregion
|
|
1323
1323
|
//#region src/sessions/update.ts
|
|
1324
|
-
function
|
|
1324
|
+
function Yt(e) {
|
|
1325
1325
|
return async (t, n, r) => {
|
|
1326
1326
|
let i = Date.now(), a = {
|
|
1327
1327
|
updated_at_ts: i,
|
|
@@ -1342,10 +1342,10 @@ function Wt(e) {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
//#endregion
|
|
1344
1344
|
//#region src/sessions/list.ts
|
|
1345
|
-
function
|
|
1345
|
+
function Xt(e) {
|
|
1346
1346
|
return async (t, n = {}) => {
|
|
1347
1347
|
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 =
|
|
1348
|
+
l && (u = D(e, u, l, ["user_id", "session_id"]));
|
|
1349
1349
|
let d = u;
|
|
1350
1350
|
if (c && c.sort_by) {
|
|
1351
1351
|
let { ref: t } = e.dynamic;
|
|
@@ -1397,18 +1397,18 @@ function Gt(e) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
//#endregion
|
|
1399
1399
|
//#region src/sessions/index.ts
|
|
1400
|
-
function
|
|
1400
|
+
function Zt(e) {
|
|
1401
1401
|
return {
|
|
1402
|
-
create:
|
|
1403
|
-
get:
|
|
1404
|
-
list:
|
|
1405
|
-
remove:
|
|
1406
|
-
update:
|
|
1402
|
+
create: qt(e),
|
|
1403
|
+
get: Kt(e),
|
|
1404
|
+
list: Xt(e),
|
|
1405
|
+
remove: Jt(e),
|
|
1406
|
+
update: Yt(e)
|
|
1407
1407
|
};
|
|
1408
1408
|
}
|
|
1409
1409
|
//#endregion
|
|
1410
1410
|
//#region src/passwords/get.ts
|
|
1411
|
-
function
|
|
1411
|
+
function Qt(e) {
|
|
1412
1412
|
return async (t, n) => {
|
|
1413
1413
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1414
1414
|
if (!r) return null;
|
|
@@ -1421,7 +1421,7 @@ function qt(e) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
//#endregion
|
|
1423
1423
|
//#region src/passwords/create.ts
|
|
1424
|
-
function
|
|
1424
|
+
function $t(e) {
|
|
1425
1425
|
return async (n, r, i) => {
|
|
1426
1426
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1427
1427
|
...r,
|
|
@@ -1439,7 +1439,7 @@ function Jt(e) {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
//#endregion
|
|
1441
1441
|
//#region src/passwords/update.ts
|
|
1442
|
-
function
|
|
1442
|
+
function en(e) {
|
|
1443
1443
|
return async (t, n) => {
|
|
1444
1444
|
let r = e.updateTable("passwords").set({
|
|
1445
1445
|
password: n.password,
|
|
@@ -1452,7 +1452,7 @@ function Yt(e) {
|
|
|
1452
1452
|
}
|
|
1453
1453
|
//#endregion
|
|
1454
1454
|
//#region src/passwords/list.ts
|
|
1455
|
-
function
|
|
1455
|
+
function tn(e) {
|
|
1456
1456
|
return async (t, n, r) => {
|
|
1457
1457
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1458
1458
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1463,20 +1463,20 @@ function Xt(e) {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
//#endregion
|
|
1465
1465
|
//#region src/passwords/index.ts
|
|
1466
|
-
function
|
|
1466
|
+
function nn(e) {
|
|
1467
1467
|
return {
|
|
1468
|
-
create:
|
|
1469
|
-
update:
|
|
1470
|
-
get:
|
|
1471
|
-
list:
|
|
1468
|
+
create: $t(e),
|
|
1469
|
+
update: en(e),
|
|
1470
|
+
get: Qt(e),
|
|
1471
|
+
list: tn(e)
|
|
1472
1472
|
};
|
|
1473
1473
|
}
|
|
1474
1474
|
//#endregion
|
|
1475
1475
|
//#region src/codes/list.ts
|
|
1476
|
-
function
|
|
1476
|
+
function rn(e) {
|
|
1477
1477
|
return async (t, n = {}) => {
|
|
1478
1478
|
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 =
|
|
1479
|
+
s && (c = D(e, c, s, ["code", "login_id"]));
|
|
1480
1480
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1481
1481
|
let { tenant_id: t, ...n } = e;
|
|
1482
1482
|
return ee.parse(l(n));
|
|
@@ -1498,13 +1498,13 @@ function Qt(e) {
|
|
|
1498
1498
|
}
|
|
1499
1499
|
//#endregion
|
|
1500
1500
|
//#region src/codes/expires-at-ts.ts
|
|
1501
|
-
function
|
|
1501
|
+
function an(e) {
|
|
1502
1502
|
let t = new Date(e).getTime();
|
|
1503
1503
|
return Number.isNaN(t) ? 0 : t;
|
|
1504
1504
|
}
|
|
1505
1505
|
//#endregion
|
|
1506
1506
|
//#region src/codes/create.ts
|
|
1507
|
-
function
|
|
1507
|
+
function on(e) {
|
|
1508
1508
|
return async (t, n) => {
|
|
1509
1509
|
let r = {
|
|
1510
1510
|
...n,
|
|
@@ -1513,18 +1513,18 @@ function en(e) {
|
|
|
1513
1513
|
return await e.insertInto("codes").values({
|
|
1514
1514
|
...r,
|
|
1515
1515
|
tenant_id: t,
|
|
1516
|
-
expires_at_ts:
|
|
1516
|
+
expires_at_ts: an(r.expires_at)
|
|
1517
1517
|
}).execute(), r;
|
|
1518
1518
|
};
|
|
1519
1519
|
}
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/codes/remove.ts
|
|
1522
|
-
function
|
|
1522
|
+
function sn(e) {
|
|
1523
1523
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1524
1524
|
}
|
|
1525
1525
|
//#endregion
|
|
1526
1526
|
//#region src/codes/get.ts
|
|
1527
|
-
function
|
|
1527
|
+
function cn(e) {
|
|
1528
1528
|
return async (t, n, r) => {
|
|
1529
1529
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1530
1530
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1534,44 +1534,44 @@ function nn(e) {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
//#endregion
|
|
1536
1536
|
//#region src/codes/used.ts
|
|
1537
|
-
function
|
|
1537
|
+
function ln(e) {
|
|
1538
1538
|
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
1539
|
}
|
|
1540
1540
|
//#endregion
|
|
1541
1541
|
//#region src/codes/consume.ts
|
|
1542
|
-
function
|
|
1542
|
+
function un(e) {
|
|
1543
1543
|
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
1544
|
}
|
|
1545
1545
|
//#endregion
|
|
1546
1546
|
//#region src/codes/cleanup.ts
|
|
1547
|
-
function
|
|
1547
|
+
function dn(e) {
|
|
1548
1548
|
return async (t) => {
|
|
1549
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1549
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", an(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1550
1550
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1551
1551
|
};
|
|
1552
1552
|
}
|
|
1553
1553
|
//#endregion
|
|
1554
1554
|
//#region src/codes/index.ts
|
|
1555
|
-
function
|
|
1555
|
+
function fn(e) {
|
|
1556
1556
|
return {
|
|
1557
|
-
create:
|
|
1558
|
-
list:
|
|
1559
|
-
remove:
|
|
1560
|
-
used:
|
|
1561
|
-
consume:
|
|
1562
|
-
get:
|
|
1563
|
-
cleanup:
|
|
1557
|
+
create: on(e),
|
|
1558
|
+
list: rn(e),
|
|
1559
|
+
remove: sn(e),
|
|
1560
|
+
used: ln(e),
|
|
1561
|
+
consume: un(e),
|
|
1562
|
+
get: cn(e),
|
|
1563
|
+
cleanup: dn(e)
|
|
1564
1564
|
};
|
|
1565
1565
|
}
|
|
1566
1566
|
//#endregion
|
|
1567
1567
|
//#region src/connections/create.ts
|
|
1568
|
-
function
|
|
1568
|
+
function pn(e) {
|
|
1569
1569
|
return async (t, n, r) => {
|
|
1570
1570
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1571
1571
|
delete o.enabled_clients;
|
|
1572
1572
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1573
1573
|
...o,
|
|
1574
|
-
id: i?.id ?? o.id ??
|
|
1574
|
+
id: i?.id ?? o.id ?? Ae(),
|
|
1575
1575
|
is_system: a ? !0 : void 0,
|
|
1576
1576
|
created_at: i?.created_at ?? s,
|
|
1577
1577
|
updated_at: i?.updated_at ?? s
|
|
@@ -1586,7 +1586,7 @@ function cn(e) {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
//#endregion
|
|
1588
1588
|
//#region src/connections/transform.ts
|
|
1589
|
-
function
|
|
1589
|
+
function F(e) {
|
|
1590
1590
|
let { is_system: t, ...n } = e;
|
|
1591
1591
|
return l({
|
|
1592
1592
|
...n,
|
|
@@ -1594,16 +1594,16 @@ function ln(e) {
|
|
|
1594
1594
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1595
1595
|
});
|
|
1596
1596
|
}
|
|
1597
|
-
function
|
|
1598
|
-
return e.map(
|
|
1597
|
+
function mn(e) {
|
|
1598
|
+
return e.map(F);
|
|
1599
1599
|
}
|
|
1600
1600
|
//#endregion
|
|
1601
1601
|
//#region src/connections/list.ts
|
|
1602
|
-
function
|
|
1602
|
+
function hn(e) {
|
|
1603
1603
|
return async (t, n = {}) => {
|
|
1604
1604
|
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 =
|
|
1605
|
+
s && (c = D(e, c, s, ["user_id", "ip"]));
|
|
1606
|
+
let l = mn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1607
1607
|
if (!a) return {
|
|
1608
1608
|
connections: l,
|
|
1609
1609
|
start: 0,
|
|
@@ -1621,20 +1621,20 @@ function dn(e) {
|
|
|
1621
1621
|
}
|
|
1622
1622
|
//#endregion
|
|
1623
1623
|
//#region src/connections/remove.ts
|
|
1624
|
-
function
|
|
1624
|
+
function gn(e) {
|
|
1625
1625
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1626
1626
|
}
|
|
1627
1627
|
//#endregion
|
|
1628
1628
|
//#region src/connections/get.ts
|
|
1629
|
-
function
|
|
1629
|
+
function _n(e) {
|
|
1630
1630
|
return async (t, n) => {
|
|
1631
1631
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1632
|
-
return r ?
|
|
1632
|
+
return r ? F(r) : null;
|
|
1633
1633
|
};
|
|
1634
1634
|
}
|
|
1635
1635
|
//#endregion
|
|
1636
1636
|
//#region src/connections/update.ts
|
|
1637
|
-
function
|
|
1637
|
+
function vn(e) {
|
|
1638
1638
|
return async (t, n, r) => {
|
|
1639
1639
|
let { is_system: i, ...a } = r;
|
|
1640
1640
|
delete a.enabled_clients;
|
|
@@ -1651,18 +1651,18 @@ function mn(e) {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
//#endregion
|
|
1653
1653
|
//#region src/connections/index.ts
|
|
1654
|
-
function
|
|
1654
|
+
function yn(e) {
|
|
1655
1655
|
return {
|
|
1656
|
-
create:
|
|
1657
|
-
get:
|
|
1658
|
-
list:
|
|
1659
|
-
remove:
|
|
1660
|
-
update:
|
|
1656
|
+
create: pn(e),
|
|
1657
|
+
get: _n(e),
|
|
1658
|
+
list: hn(e),
|
|
1659
|
+
remove: gn(e),
|
|
1660
|
+
update: vn(e)
|
|
1661
1661
|
};
|
|
1662
1662
|
}
|
|
1663
1663
|
//#endregion
|
|
1664
1664
|
//#region src/clients/create.ts
|
|
1665
|
-
function
|
|
1665
|
+
function bn(e) {
|
|
1666
1666
|
return async (r, i, a) => {
|
|
1667
1667
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1668
1668
|
...i,
|
|
@@ -1727,7 +1727,7 @@ function gn(e) {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
//#endregion
|
|
1729
1729
|
//#region src/clients/get.ts
|
|
1730
|
-
function
|
|
1730
|
+
function xn(e) {
|
|
1731
1731
|
return async (t, n) => {
|
|
1732
1732
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1733
1733
|
if (!r) return null;
|
|
@@ -1773,7 +1773,7 @@ function _n(e) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
//#endregion
|
|
1775
1775
|
//#region src/clients/getByClientId.ts
|
|
1776
|
-
function
|
|
1776
|
+
function Sn(e) {
|
|
1777
1777
|
return async (t) => {
|
|
1778
1778
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1779
1779
|
return n ? l({
|
|
@@ -1817,7 +1817,7 @@ function vn(e) {
|
|
|
1817
1817
|
}
|
|
1818
1818
|
//#endregion
|
|
1819
1819
|
//#region src/clients/list.ts
|
|
1820
|
-
function
|
|
1820
|
+
function Cn(e) {
|
|
1821
1821
|
return l({
|
|
1822
1822
|
...e,
|
|
1823
1823
|
global: !!e.global,
|
|
@@ -1856,8 +1856,8 @@ function yn(e) {
|
|
|
1856
1856
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1857
1857
|
});
|
|
1858
1858
|
}
|
|
1859
|
-
function
|
|
1860
|
-
let t =
|
|
1859
|
+
function wn(e) {
|
|
1860
|
+
let t = Ce(e);
|
|
1861
1861
|
if (t.length !== 1) return null;
|
|
1862
1862
|
let n = t[0].match(/^([a-zA-Z_][a-zA-Z0-9_]*):(.+)$/);
|
|
1863
1863
|
if (!n) return null;
|
|
@@ -1867,22 +1867,22 @@ function bn(e) {
|
|
|
1867
1867
|
value: r
|
|
1868
1868
|
} : null;
|
|
1869
1869
|
}
|
|
1870
|
-
function
|
|
1870
|
+
function Tn(e) {
|
|
1871
1871
|
return async (t, n) => {
|
|
1872
1872
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1873
1873
|
if (n?.q) {
|
|
1874
|
-
let e =
|
|
1874
|
+
let e = wn(n.q);
|
|
1875
1875
|
if (e && i.has(e.field)) {
|
|
1876
1876
|
let t = e.field;
|
|
1877
1877
|
r = r.where(t, "=", e.value);
|
|
1878
1878
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1879
1879
|
}
|
|
1880
|
-
if (
|
|
1881
|
-
let { rows: e, limit: t, next: i } = await
|
|
1880
|
+
if (A(n)) {
|
|
1881
|
+
let { rows: e, limit: t, next: i } = await j(r.selectAll(), n, {
|
|
1882
1882
|
sortColumn: "created_at",
|
|
1883
1883
|
sortOrder: "desc",
|
|
1884
1884
|
idColumn: "client_id"
|
|
1885
|
-
}), a = e.map(
|
|
1885
|
+
}), a = e.map(Cn);
|
|
1886
1886
|
return {
|
|
1887
1887
|
clients: a,
|
|
1888
1888
|
totals: {
|
|
@@ -1906,7 +1906,7 @@ function xn(e) {
|
|
|
1906
1906
|
if (n?.include_totals) {
|
|
1907
1907
|
let r = e.selectFrom("clients").select(f`count(*)`.as("count")).where("clients.tenant_id", "=", t);
|
|
1908
1908
|
if (n?.q) {
|
|
1909
|
-
let e =
|
|
1909
|
+
let e = wn(n.q);
|
|
1910
1910
|
if (e && i.has(e.field)) {
|
|
1911
1911
|
let t = e.field;
|
|
1912
1912
|
r = r.where(t, "=", e.value);
|
|
@@ -1915,7 +1915,7 @@ function xn(e) {
|
|
|
1915
1915
|
let a = await r.executeTakeFirst();
|
|
1916
1916
|
c = Number(a?.count || 0);
|
|
1917
1917
|
}
|
|
1918
|
-
let l = s.map(
|
|
1918
|
+
let l = s.map(Cn);
|
|
1919
1919
|
return {
|
|
1920
1920
|
clients: l,
|
|
1921
1921
|
totals: {
|
|
@@ -1929,12 +1929,12 @@ function xn(e) {
|
|
|
1929
1929
|
}
|
|
1930
1930
|
//#endregion
|
|
1931
1931
|
//#region src/clients/remove.ts
|
|
1932
|
-
function
|
|
1932
|
+
function En(e) {
|
|
1933
1933
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1934
1934
|
}
|
|
1935
1935
|
//#endregion
|
|
1936
1936
|
//#region src/clients/update.ts
|
|
1937
|
-
function
|
|
1937
|
+
function Dn(e) {
|
|
1938
1938
|
return async (t, r, i) => {
|
|
1939
1939
|
let a = {
|
|
1940
1940
|
...i,
|
|
@@ -1981,31 +1981,31 @@ function Cn(e) {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
//#endregion
|
|
1983
1983
|
//#region src/clients/index.ts
|
|
1984
|
-
function
|
|
1984
|
+
function On(e) {
|
|
1985
1985
|
return {
|
|
1986
|
-
create:
|
|
1987
|
-
get:
|
|
1988
|
-
getByClientId:
|
|
1989
|
-
list:
|
|
1990
|
-
remove:
|
|
1991
|
-
update:
|
|
1986
|
+
create: bn(e),
|
|
1987
|
+
get: xn(e),
|
|
1988
|
+
getByClientId: Sn(e),
|
|
1989
|
+
list: Tn(e),
|
|
1990
|
+
remove: En(e),
|
|
1991
|
+
update: Dn(e)
|
|
1992
1992
|
};
|
|
1993
1993
|
}
|
|
1994
1994
|
//#endregion
|
|
1995
1995
|
//#region src/clientConnections/listByClient.ts
|
|
1996
|
-
function
|
|
1996
|
+
function kn(e) {
|
|
1997
1997
|
return async (t, n) => {
|
|
1998
1998
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1999
1999
|
if (!r) return [];
|
|
2000
2000
|
let i = JSON.parse(r.connections || "[]");
|
|
2001
2001
|
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,
|
|
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, F(e)]));
|
|
2003
2003
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2004
2004
|
};
|
|
2005
2005
|
}
|
|
2006
2006
|
//#endregion
|
|
2007
2007
|
//#region src/clientConnections/updateByClient.ts
|
|
2008
|
-
function
|
|
2008
|
+
function An(e) {
|
|
2009
2009
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
2010
2010
|
connections: JSON.stringify(r),
|
|
2011
2011
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2013,7 +2013,7 @@ function En(e) {
|
|
|
2013
2013
|
}
|
|
2014
2014
|
//#endregion
|
|
2015
2015
|
//#region src/clientConnections/listByConnection.ts
|
|
2016
|
-
function
|
|
2016
|
+
function jn(e) {
|
|
2017
2017
|
return async (t, n) => {
|
|
2018
2018
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
2019
2019
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -2022,7 +2022,7 @@ function Dn(e) {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
//#endregion
|
|
2024
2024
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2025
|
-
function
|
|
2025
|
+
function Mn(e) {
|
|
2026
2026
|
return async (t, n, r) => {
|
|
2027
2027
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2028
2028
|
if (!i) return !1;
|
|
@@ -2035,7 +2035,7 @@ function On(e) {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
//#endregion
|
|
2037
2037
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2038
|
-
function
|
|
2038
|
+
function Nn(e) {
|
|
2039
2039
|
return async (t, n, r) => {
|
|
2040
2040
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2041
2041
|
if (!i) return !1;
|
|
@@ -2048,18 +2048,18 @@ function kn(e) {
|
|
|
2048
2048
|
}
|
|
2049
2049
|
//#endregion
|
|
2050
2050
|
//#region src/clientConnections/index.ts
|
|
2051
|
-
function
|
|
2051
|
+
function Pn(e) {
|
|
2052
2052
|
return {
|
|
2053
|
-
listByClient:
|
|
2054
|
-
updateByClient:
|
|
2055
|
-
listByConnection:
|
|
2056
|
-
addClientToConnection:
|
|
2057
|
-
removeClientFromConnection:
|
|
2053
|
+
listByClient: kn(e),
|
|
2054
|
+
updateByClient: An(e),
|
|
2055
|
+
listByConnection: jn(e),
|
|
2056
|
+
addClientToConnection: Mn(e),
|
|
2057
|
+
removeClientFromConnection: Nn(e)
|
|
2058
2058
|
};
|
|
2059
2059
|
}
|
|
2060
2060
|
//#endregion
|
|
2061
2061
|
//#region src/clientGrants/create.ts
|
|
2062
|
-
function
|
|
2062
|
+
function Fn(e) {
|
|
2063
2063
|
return async (n, r, i) => {
|
|
2064
2064
|
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
2065
|
id: s,
|
|
@@ -2087,7 +2087,7 @@ function jn(e) {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
//#endregion
|
|
2089
2089
|
//#region src/clientGrants/get.ts
|
|
2090
|
-
function
|
|
2090
|
+
function In(e) {
|
|
2091
2091
|
return async (t, n) => {
|
|
2092
2092
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2093
2093
|
return r ? l({
|
|
@@ -2107,7 +2107,7 @@ function Mn(e) {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
//#endregion
|
|
2109
2109
|
//#region src/clientGrants/list.ts
|
|
2110
|
-
function
|
|
2110
|
+
function Ln(e) {
|
|
2111
2111
|
return v.parse(l({
|
|
2112
2112
|
...e,
|
|
2113
2113
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2116,7 +2116,7 @@ function Nn(e) {
|
|
|
2116
2116
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2117
2117
|
}));
|
|
2118
2118
|
}
|
|
2119
|
-
function
|
|
2119
|
+
function Rn(e) {
|
|
2120
2120
|
return async (t, n = {}) => {
|
|
2121
2121
|
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
2122
|
if (s) {
|
|
@@ -2127,13 +2127,13 @@ function Pn(e) {
|
|
|
2127
2127
|
let e = +(a === "true");
|
|
2128
2128
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2129
2129
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2130
|
-
} else l =
|
|
2130
|
+
} else l = D(e, l, t, []);
|
|
2131
2131
|
}
|
|
2132
|
-
if (
|
|
2133
|
-
let { rows: e, limit: t, next: r } = await
|
|
2132
|
+
if (A(n)) {
|
|
2133
|
+
let { rows: e, limit: t, next: r } = await j(l.selectAll(), n, {
|
|
2134
2134
|
sortColumn: "created_at",
|
|
2135
2135
|
sortOrder: "desc"
|
|
2136
|
-
}), i = e.map(
|
|
2136
|
+
}), i = e.map(Ln);
|
|
2137
2137
|
return {
|
|
2138
2138
|
client_grants: i,
|
|
2139
2139
|
start: 0,
|
|
@@ -2147,7 +2147,7 @@ function Pn(e) {
|
|
|
2147
2147
|
let { ref: t } = e.dynamic;
|
|
2148
2148
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2149
2149
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2150
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2150
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(Ln);
|
|
2151
2151
|
if (!a) return {
|
|
2152
2152
|
client_grants: d,
|
|
2153
2153
|
start: 0,
|
|
@@ -2165,12 +2165,12 @@ function Pn(e) {
|
|
|
2165
2165
|
}
|
|
2166
2166
|
//#endregion
|
|
2167
2167
|
//#region src/clientGrants/remove.ts
|
|
2168
|
-
function
|
|
2168
|
+
function zn(e) {
|
|
2169
2169
|
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
2170
|
}
|
|
2171
2171
|
//#endregion
|
|
2172
2172
|
//#region src/clientGrants/update.ts
|
|
2173
|
-
function
|
|
2173
|
+
function Bn(e) {
|
|
2174
2174
|
return async (t, n, r) => {
|
|
2175
2175
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2176
2176
|
...s,
|
|
@@ -2181,18 +2181,18 @@ function In(e) {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
//#endregion
|
|
2183
2183
|
//#region src/clientGrants/index.ts
|
|
2184
|
-
function
|
|
2184
|
+
function Vn(e) {
|
|
2185
2185
|
return {
|
|
2186
|
-
create:
|
|
2187
|
-
get:
|
|
2188
|
-
list:
|
|
2189
|
-
remove:
|
|
2190
|
-
update:
|
|
2186
|
+
create: Fn(e),
|
|
2187
|
+
get: In(e),
|
|
2188
|
+
list: Rn(e),
|
|
2189
|
+
remove: zn(e),
|
|
2190
|
+
update: Bn(e)
|
|
2191
2191
|
};
|
|
2192
2192
|
}
|
|
2193
2193
|
//#endregion
|
|
2194
2194
|
//#region src/clientRegistrationTokens/create.ts
|
|
2195
|
-
function
|
|
2195
|
+
function Hn(e) {
|
|
2196
2196
|
return async (t, n) => {
|
|
2197
2197
|
let r = Date.now();
|
|
2198
2198
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2223,12 +2223,12 @@ function Rn(e) {
|
|
|
2223
2223
|
}
|
|
2224
2224
|
//#endregion
|
|
2225
2225
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2226
|
-
function
|
|
2226
|
+
function Un(e) {
|
|
2227
2227
|
let t = y.safeParse(e);
|
|
2228
2228
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2229
2229
|
return t.data;
|
|
2230
2230
|
}
|
|
2231
|
-
function
|
|
2231
|
+
function Wn(e) {
|
|
2232
2232
|
if (!e) return;
|
|
2233
2233
|
let t;
|
|
2234
2234
|
try {
|
|
@@ -2238,14 +2238,14 @@ function Bn(e) {
|
|
|
2238
2238
|
}
|
|
2239
2239
|
return oe(t) ? t : void 0;
|
|
2240
2240
|
}
|
|
2241
|
-
function
|
|
2241
|
+
function I(e) {
|
|
2242
2242
|
return {
|
|
2243
2243
|
id: e.id,
|
|
2244
2244
|
token_hash: e.token_hash,
|
|
2245
|
-
type:
|
|
2245
|
+
type: Un(e.type),
|
|
2246
2246
|
client_id: e.client_id ?? void 0,
|
|
2247
2247
|
sub: e.sub ?? void 0,
|
|
2248
|
-
constraints:
|
|
2248
|
+
constraints: Wn(e.constraints),
|
|
2249
2249
|
single_use: !!e.single_use,
|
|
2250
2250
|
expires_at: i(e.expires_at_ts),
|
|
2251
2251
|
used_at: i(e.used_at_ts),
|
|
@@ -2255,38 +2255,38 @@ function Vn(e) {
|
|
|
2255
2255
|
}
|
|
2256
2256
|
//#endregion
|
|
2257
2257
|
//#region src/clientRegistrationTokens/get.ts
|
|
2258
|
-
function
|
|
2258
|
+
function Gn(e) {
|
|
2259
2259
|
return async (t, n) => {
|
|
2260
2260
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2261
|
-
return r ?
|
|
2261
|
+
return r ? I(r) : null;
|
|
2262
2262
|
};
|
|
2263
2263
|
}
|
|
2264
2264
|
//#endregion
|
|
2265
2265
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2266
|
-
function
|
|
2266
|
+
function Kn(e) {
|
|
2267
2267
|
return async (t, n) => {
|
|
2268
2268
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2269
|
-
return r ?
|
|
2269
|
+
return r ? I(r) : null;
|
|
2270
2270
|
};
|
|
2271
2271
|
}
|
|
2272
2272
|
//#endregion
|
|
2273
2273
|
//#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(
|
|
2274
|
+
function qn(e) {
|
|
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(I);
|
|
2276
2276
|
}
|
|
2277
2277
|
//#endregion
|
|
2278
2278
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2279
|
-
function
|
|
2279
|
+
function Jn(e) {
|
|
2280
2280
|
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
2281
|
}
|
|
2282
2282
|
//#endregion
|
|
2283
2283
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2284
|
-
function
|
|
2284
|
+
function Yn(e) {
|
|
2285
2285
|
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
2286
|
}
|
|
2287
2287
|
//#endregion
|
|
2288
2288
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2289
|
-
function
|
|
2289
|
+
function Xn(e) {
|
|
2290
2290
|
return async (t, n, r) => {
|
|
2291
2291
|
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
2292
|
return Number(i.numUpdatedRows);
|
|
@@ -2294,29 +2294,29 @@ function qn(e) {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
//#endregion
|
|
2296
2296
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2297
|
-
function
|
|
2297
|
+
function Zn(e) {
|
|
2298
2298
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2299
2299
|
}
|
|
2300
2300
|
//#endregion
|
|
2301
2301
|
//#region src/clientRegistrationTokens/index.ts
|
|
2302
|
-
function
|
|
2302
|
+
function Qn(e) {
|
|
2303
2303
|
return {
|
|
2304
|
-
create:
|
|
2305
|
-
get:
|
|
2306
|
-
getByHash:
|
|
2307
|
-
listByClient:
|
|
2308
|
-
markUsed:
|
|
2309
|
-
revoke:
|
|
2310
|
-
revokeByClient:
|
|
2311
|
-
remove:
|
|
2304
|
+
create: Hn(e),
|
|
2305
|
+
get: Gn(e),
|
|
2306
|
+
getByHash: Kn(e),
|
|
2307
|
+
listByClient: qn(e),
|
|
2308
|
+
markUsed: Jn(e),
|
|
2309
|
+
revoke: Yn(e),
|
|
2310
|
+
revokeByClient: Xn(e),
|
|
2311
|
+
remove: Zn(e)
|
|
2312
2312
|
};
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/keys/list.ts
|
|
2316
|
-
function
|
|
2316
|
+
function $n(e) {
|
|
2317
2317
|
return async (t = {}) => {
|
|
2318
2318
|
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 =
|
|
2319
|
+
s && (c = D(e, c, s, [
|
|
2320
2320
|
"kid",
|
|
2321
2321
|
"tenant_id",
|
|
2322
2322
|
"connection",
|
|
@@ -2342,7 +2342,7 @@ function Xn(e) {
|
|
|
2342
2342
|
}
|
|
2343
2343
|
//#endregion
|
|
2344
2344
|
//#region src/keys/create.ts
|
|
2345
|
-
function
|
|
2345
|
+
function er(e) {
|
|
2346
2346
|
return async (t, n) => {
|
|
2347
2347
|
let r = n?.importMetadata;
|
|
2348
2348
|
await e.insertInto("keys").values({
|
|
@@ -2354,21 +2354,21 @@ function Zn(e) {
|
|
|
2354
2354
|
}
|
|
2355
2355
|
//#endregion
|
|
2356
2356
|
//#region src/keys/update.ts
|
|
2357
|
-
function
|
|
2357
|
+
function tr(e) {
|
|
2358
2358
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2359
2359
|
}
|
|
2360
2360
|
//#endregion
|
|
2361
2361
|
//#region src/keys/index.ts
|
|
2362
|
-
function
|
|
2362
|
+
function nr(e) {
|
|
2363
2363
|
return {
|
|
2364
|
-
create:
|
|
2365
|
-
list:
|
|
2366
|
-
update:
|
|
2364
|
+
create: er(e),
|
|
2365
|
+
list: $n(e),
|
|
2366
|
+
update: tr(e)
|
|
2367
2367
|
};
|
|
2368
2368
|
}
|
|
2369
2369
|
//#endregion
|
|
2370
2370
|
//#region src/customDomains/create.ts
|
|
2371
|
-
function
|
|
2371
|
+
function rr(e) {
|
|
2372
2372
|
return async (n, r, i) => {
|
|
2373
2373
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2374
2374
|
status: "pending",
|
|
@@ -2389,35 +2389,35 @@ function er(e) {
|
|
|
2389
2389
|
}
|
|
2390
2390
|
//#endregion
|
|
2391
2391
|
//#region src/customDomains/list.ts
|
|
2392
|
-
function
|
|
2392
|
+
function ir(e) {
|
|
2393
2393
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2394
2394
|
...e,
|
|
2395
2395
|
primary: e.primary === 1,
|
|
2396
|
-
domain_metadata:
|
|
2397
|
-
verification:
|
|
2396
|
+
domain_metadata: N(e.domain_metadata, void 0),
|
|
2397
|
+
verification: N(e.verification, void 0)
|
|
2398
2398
|
}));
|
|
2399
2399
|
}
|
|
2400
2400
|
//#endregion
|
|
2401
2401
|
//#region src/customDomains/remove.ts
|
|
2402
|
-
function
|
|
2402
|
+
function ar(e) {
|
|
2403
2403
|
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
2404
|
}
|
|
2405
2405
|
//#endregion
|
|
2406
2406
|
//#region src/customDomains/get.ts
|
|
2407
|
-
function
|
|
2407
|
+
function or(e) {
|
|
2408
2408
|
return async (t, n) => {
|
|
2409
2409
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2410
2410
|
return r ? {
|
|
2411
2411
|
...r,
|
|
2412
2412
|
primary: r.primary === 1,
|
|
2413
|
-
domain_metadata:
|
|
2414
|
-
verification:
|
|
2413
|
+
domain_metadata: N(r.domain_metadata, void 0),
|
|
2414
|
+
verification: N(r.verification, void 0)
|
|
2415
2415
|
} : null;
|
|
2416
2416
|
};
|
|
2417
2417
|
}
|
|
2418
2418
|
//#endregion
|
|
2419
2419
|
//#region src/customDomains/update.ts
|
|
2420
|
-
function
|
|
2420
|
+
function sr(e) {
|
|
2421
2421
|
return async (t, n, r) => {
|
|
2422
2422
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2423
2423
|
...s,
|
|
@@ -2431,32 +2431,32 @@ function ir(e) {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
//#endregion
|
|
2433
2433
|
//#region src/customDomains/getByDomain.ts
|
|
2434
|
-
function
|
|
2434
|
+
function cr(e) {
|
|
2435
2435
|
return async (t) => {
|
|
2436
2436
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2437
2437
|
return n ? {
|
|
2438
2438
|
...n,
|
|
2439
2439
|
primary: n.primary === 1,
|
|
2440
|
-
domain_metadata:
|
|
2441
|
-
verification:
|
|
2440
|
+
domain_metadata: N(n.domain_metadata, void 0),
|
|
2441
|
+
verification: N(n.verification, void 0)
|
|
2442
2442
|
} : null;
|
|
2443
2443
|
};
|
|
2444
2444
|
}
|
|
2445
2445
|
//#endregion
|
|
2446
2446
|
//#region src/customDomains/index.ts
|
|
2447
|
-
function
|
|
2447
|
+
function lr(e) {
|
|
2448
2448
|
return {
|
|
2449
|
-
create:
|
|
2450
|
-
get:
|
|
2451
|
-
getByDomain:
|
|
2452
|
-
list:
|
|
2453
|
-
remove:
|
|
2454
|
-
update:
|
|
2449
|
+
create: rr(e),
|
|
2450
|
+
get: or(e),
|
|
2451
|
+
getByDomain: cr(e),
|
|
2452
|
+
list: ir(e),
|
|
2453
|
+
remove: ar(e),
|
|
2454
|
+
update: sr(e)
|
|
2455
2455
|
};
|
|
2456
2456
|
}
|
|
2457
2457
|
//#endregion
|
|
2458
2458
|
//#region src/branding/get.ts
|
|
2459
|
-
function
|
|
2459
|
+
function ur(e) {
|
|
2460
2460
|
return async (t) => {
|
|
2461
2461
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2462
2462
|
if (!n) return null;
|
|
@@ -2478,7 +2478,7 @@ function sr(e) {
|
|
|
2478
2478
|
}
|
|
2479
2479
|
//#endregion
|
|
2480
2480
|
//#region src/branding/set.ts
|
|
2481
|
-
function
|
|
2481
|
+
function dr(e) {
|
|
2482
2482
|
return async (t, n) => {
|
|
2483
2483
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2484
2484
|
try {
|
|
@@ -2507,15 +2507,15 @@ function cr(e) {
|
|
|
2507
2507
|
}
|
|
2508
2508
|
//#endregion
|
|
2509
2509
|
//#region src/branding/index.ts
|
|
2510
|
-
function
|
|
2510
|
+
function fr(e) {
|
|
2511
2511
|
return {
|
|
2512
|
-
get:
|
|
2513
|
-
set:
|
|
2512
|
+
get: ur(e),
|
|
2513
|
+
set: dr(e)
|
|
2514
2514
|
};
|
|
2515
2515
|
}
|
|
2516
2516
|
//#endregion
|
|
2517
2517
|
//#region src/universalLoginTemplates/get.ts
|
|
2518
|
-
function
|
|
2518
|
+
function pr(e) {
|
|
2519
2519
|
return async (t) => {
|
|
2520
2520
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2521
2521
|
return n ? { body: n.body } : null;
|
|
@@ -2523,7 +2523,7 @@ function ur(e) {
|
|
|
2523
2523
|
}
|
|
2524
2524
|
//#endregion
|
|
2525
2525
|
//#region src/universalLoginTemplates/set.ts
|
|
2526
|
-
function
|
|
2526
|
+
function mr(e) {
|
|
2527
2527
|
return async (t, n, r) => {
|
|
2528
2528
|
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
2529
|
try {
|
|
@@ -2544,26 +2544,26 @@ function dr(e) {
|
|
|
2544
2544
|
}
|
|
2545
2545
|
//#endregion
|
|
2546
2546
|
//#region src/universalLoginTemplates/delete.ts
|
|
2547
|
-
function
|
|
2547
|
+
function hr(e) {
|
|
2548
2548
|
return async (t) => {
|
|
2549
2549
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2550
2550
|
};
|
|
2551
2551
|
}
|
|
2552
2552
|
//#endregion
|
|
2553
2553
|
//#region src/universalLoginTemplates/index.ts
|
|
2554
|
-
function
|
|
2554
|
+
function gr(e) {
|
|
2555
2555
|
return {
|
|
2556
|
-
get:
|
|
2557
|
-
set:
|
|
2558
|
-
delete:
|
|
2556
|
+
get: pr(e),
|
|
2557
|
+
set: mr(e),
|
|
2558
|
+
delete: hr(e)
|
|
2559
2559
|
};
|
|
2560
2560
|
}
|
|
2561
2561
|
//#endregion
|
|
2562
2562
|
//#region src/hooks/list.ts
|
|
2563
|
-
function
|
|
2563
|
+
function _r(e) {
|
|
2564
2564
|
return async (t, n = {}) => {
|
|
2565
2565
|
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 =
|
|
2566
|
+
if (u && (d = D(e, d, u, [
|
|
2567
2567
|
"url",
|
|
2568
2568
|
"form_id",
|
|
2569
2569
|
"template_id",
|
|
@@ -2582,7 +2582,7 @@ function mr(e) {
|
|
|
2582
2582
|
...u,
|
|
2583
2583
|
enabled: !!n,
|
|
2584
2584
|
synchronous: !!i,
|
|
2585
|
-
metadata:
|
|
2585
|
+
metadata: Ct(s)
|
|
2586
2586
|
});
|
|
2587
2587
|
});
|
|
2588
2588
|
if (!s) return {
|
|
@@ -2602,7 +2602,7 @@ function mr(e) {
|
|
|
2602
2602
|
}
|
|
2603
2603
|
//#endregion
|
|
2604
2604
|
//#region src/hooks/get.ts
|
|
2605
|
-
function
|
|
2605
|
+
function vr(e) {
|
|
2606
2606
|
return async (t, n) => {
|
|
2607
2607
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2608
2608
|
if (!i) return null;
|
|
@@ -2615,20 +2615,20 @@ function hr(e) {
|
|
|
2615
2615
|
...d,
|
|
2616
2616
|
enabled: !!u.enabled,
|
|
2617
2617
|
synchronous: !!u.synchronous,
|
|
2618
|
-
metadata:
|
|
2618
|
+
metadata: Ct(c)
|
|
2619
2619
|
});
|
|
2620
2620
|
};
|
|
2621
2621
|
}
|
|
2622
2622
|
//#endregion
|
|
2623
2623
|
//#region src/hooks/remove.ts
|
|
2624
|
-
function
|
|
2624
|
+
function yr(e) {
|
|
2625
2625
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2626
2626
|
}
|
|
2627
2627
|
//#endregion
|
|
2628
2628
|
//#region src/hooks/create.ts
|
|
2629
|
-
function
|
|
2629
|
+
function br(e) {
|
|
2630
2630
|
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 ||
|
|
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 || Ne()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2632
2632
|
return await e.insertInto("hooks").values({
|
|
2633
2633
|
...p,
|
|
2634
2634
|
hook_id: c,
|
|
@@ -2651,7 +2651,7 @@ function _r(e) {
|
|
|
2651
2651
|
}
|
|
2652
2652
|
//#endregion
|
|
2653
2653
|
//#region src/hooks/update.ts
|
|
2654
|
-
function
|
|
2654
|
+
function xr(e) {
|
|
2655
2655
|
return async (t, n, r) => {
|
|
2656
2656
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2657
2657
|
...o,
|
|
@@ -2665,20 +2665,20 @@ function vr(e) {
|
|
|
2665
2665
|
}
|
|
2666
2666
|
//#endregion
|
|
2667
2667
|
//#region src/hooks/index.ts
|
|
2668
|
-
function
|
|
2668
|
+
function Sr(e) {
|
|
2669
2669
|
return {
|
|
2670
|
-
create:
|
|
2671
|
-
get:
|
|
2672
|
-
list:
|
|
2673
|
-
update:
|
|
2674
|
-
remove:
|
|
2670
|
+
create: br(e),
|
|
2671
|
+
get: vr(e),
|
|
2672
|
+
list: _r(e),
|
|
2673
|
+
update: xr(e),
|
|
2674
|
+
remove: yr(e)
|
|
2675
2675
|
};
|
|
2676
2676
|
}
|
|
2677
2677
|
//#endregion
|
|
2678
2678
|
//#region src/hook-code/create.ts
|
|
2679
|
-
function
|
|
2679
|
+
function Cr(e) {
|
|
2680
2680
|
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 ??
|
|
2681
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Fe();
|
|
2682
2682
|
return await e.insertInto("hook_code").values({
|
|
2683
2683
|
id: c,
|
|
2684
2684
|
tenant_id: t,
|
|
@@ -2698,7 +2698,7 @@ function br(e) {
|
|
|
2698
2698
|
}
|
|
2699
2699
|
//#endregion
|
|
2700
2700
|
//#region src/hook-code/get.ts
|
|
2701
|
-
function
|
|
2701
|
+
function wr(e) {
|
|
2702
2702
|
return async (t, n) => {
|
|
2703
2703
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2704
2704
|
if (!i) return null;
|
|
@@ -2722,7 +2722,7 @@ function xr(e) {
|
|
|
2722
2722
|
}
|
|
2723
2723
|
//#endregion
|
|
2724
2724
|
//#region src/hook-code/update.ts
|
|
2725
|
-
function
|
|
2725
|
+
function Tr(e) {
|
|
2726
2726
|
return async (t, n, r) => {
|
|
2727
2727
|
let i = { updated_at_ts: Date.now() };
|
|
2728
2728
|
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 +2730,22 @@ function Sr(e) {
|
|
|
2730
2730
|
}
|
|
2731
2731
|
//#endregion
|
|
2732
2732
|
//#region src/hook-code/remove.ts
|
|
2733
|
-
function
|
|
2733
|
+
function Er(e) {
|
|
2734
2734
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2735
2735
|
}
|
|
2736
2736
|
//#endregion
|
|
2737
2737
|
//#region src/hook-code/index.ts
|
|
2738
|
-
function
|
|
2738
|
+
function Dr(e) {
|
|
2739
2739
|
return {
|
|
2740
|
-
create:
|
|
2741
|
-
get:
|
|
2742
|
-
update:
|
|
2743
|
-
remove:
|
|
2740
|
+
create: Cr(e),
|
|
2741
|
+
get: wr(e),
|
|
2742
|
+
update: Tr(e),
|
|
2743
|
+
remove: Er(e)
|
|
2744
2744
|
};
|
|
2745
2745
|
}
|
|
2746
2746
|
//#endregion
|
|
2747
2747
|
//#region src/themes/create.ts
|
|
2748
|
-
function
|
|
2748
|
+
function Or(e) {
|
|
2749
2749
|
return async (n, r, i, a) => {
|
|
2750
2750
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2751
2751
|
themeId: o?.id || i || t(),
|
|
@@ -2756,20 +2756,20 @@ function Tr(e) {
|
|
|
2756
2756
|
...c,
|
|
2757
2757
|
tenant_id: n
|
|
2758
2758
|
};
|
|
2759
|
-
return await e.insertInto("themes").values(
|
|
2759
|
+
return await e.insertInto("themes").values(M(l)).execute(), c;
|
|
2760
2760
|
};
|
|
2761
2761
|
}
|
|
2762
2762
|
//#endregion
|
|
2763
2763
|
//#region src/themes/remove.ts
|
|
2764
|
-
function
|
|
2764
|
+
function kr(e) {
|
|
2765
2765
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2766
2766
|
}
|
|
2767
2767
|
//#endregion
|
|
2768
2768
|
//#region src/themes/get.ts
|
|
2769
|
-
function
|
|
2769
|
+
function Ar(e) {
|
|
2770
2770
|
return async (t, n) => {
|
|
2771
2771
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2772
|
-
return r ? l(
|
|
2772
|
+
return r ? l(ht({
|
|
2773
2773
|
...r,
|
|
2774
2774
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2775
2775
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2789,9 +2789,9 @@ function Dr(e) {
|
|
|
2789
2789
|
}
|
|
2790
2790
|
//#endregion
|
|
2791
2791
|
//#region src/themes/update.ts
|
|
2792
|
-
function
|
|
2792
|
+
function jr(e) {
|
|
2793
2793
|
return async (t, n, r) => {
|
|
2794
|
-
let { themeId: i, ...a } = r, o =
|
|
2794
|
+
let { themeId: i, ...a } = r, o = M({
|
|
2795
2795
|
...a,
|
|
2796
2796
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2797
2797
|
});
|
|
@@ -2800,17 +2800,17 @@ function Or(e) {
|
|
|
2800
2800
|
}
|
|
2801
2801
|
//#endregion
|
|
2802
2802
|
//#region src/themes/index.ts
|
|
2803
|
-
function
|
|
2803
|
+
function Mr(e) {
|
|
2804
2804
|
return {
|
|
2805
|
-
create:
|
|
2806
|
-
get:
|
|
2807
|
-
remove:
|
|
2808
|
-
update:
|
|
2805
|
+
create: Or(e),
|
|
2806
|
+
get: Ar(e),
|
|
2807
|
+
remove: kr(e),
|
|
2808
|
+
update: jr(e)
|
|
2809
2809
|
};
|
|
2810
2810
|
}
|
|
2811
2811
|
//#endregion
|
|
2812
2812
|
//#region src/loginSessions/get.ts
|
|
2813
|
-
function
|
|
2813
|
+
function Nr(e) {
|
|
2814
2814
|
return async (t, n) => {
|
|
2815
2815
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2816
2816
|
if (!i) return null;
|
|
@@ -2822,7 +2822,7 @@ function Ar(e) {
|
|
|
2822
2822
|
"created_at_ts",
|
|
2823
2823
|
"updated_at_ts",
|
|
2824
2824
|
"expires_at_ts"
|
|
2825
|
-
]), f =
|
|
2825
|
+
]), f = ht(l({
|
|
2826
2826
|
...u,
|
|
2827
2827
|
...d,
|
|
2828
2828
|
state: i.state || p.PENDING,
|
|
@@ -2834,28 +2834,28 @@ function Ar(e) {
|
|
|
2834
2834
|
}
|
|
2835
2835
|
//#endregion
|
|
2836
2836
|
//#region src/utils/ulid.ts
|
|
2837
|
-
var
|
|
2838
|
-
function
|
|
2837
|
+
var Pr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", L = 32, Fr = 10, Ir = 16;
|
|
2838
|
+
function Lr(e) {
|
|
2839
2839
|
let t = "";
|
|
2840
|
-
for (let n =
|
|
2840
|
+
for (let n = Fr; n > 0; n--) t = Pr.charAt(e % L) + t, e = Math.floor(e / L);
|
|
2841
2841
|
return t;
|
|
2842
2842
|
}
|
|
2843
|
-
function
|
|
2844
|
-
let e = new Uint8Array(
|
|
2843
|
+
function Rr() {
|
|
2844
|
+
let e = new Uint8Array(Ir);
|
|
2845
2845
|
crypto.getRandomValues(e);
|
|
2846
2846
|
let t = "";
|
|
2847
|
-
for (let n = 0; n <
|
|
2847
|
+
for (let n = 0; n < Ir; n++) t += Pr.charAt(e[n] % L);
|
|
2848
2848
|
return t;
|
|
2849
2849
|
}
|
|
2850
|
-
function
|
|
2851
|
-
return
|
|
2850
|
+
function zr() {
|
|
2851
|
+
return Lr(Date.now()) + Rr();
|
|
2852
2852
|
}
|
|
2853
2853
|
//#endregion
|
|
2854
2854
|
//#region src/loginSessions/create.ts
|
|
2855
|
-
function
|
|
2855
|
+
function Br(e) {
|
|
2856
2856
|
return async (t, n) => {
|
|
2857
2857
|
let r = c(), i = {
|
|
2858
|
-
id:
|
|
2858
|
+
id: zr(),
|
|
2859
2859
|
...n,
|
|
2860
2860
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2861
2861
|
created_at: r,
|
|
@@ -2863,7 +2863,7 @@ function Rr(e) {
|
|
|
2863
2863
|
state: n.state || p.PENDING,
|
|
2864
2864
|
state_data: n.state_data,
|
|
2865
2865
|
failure_reason: n.failure_reason
|
|
2866
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2866
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = M(o);
|
|
2867
2867
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2868
2868
|
...l,
|
|
2869
2869
|
tenant_id: t,
|
|
@@ -2876,7 +2876,7 @@ function Rr(e) {
|
|
|
2876
2876
|
}
|
|
2877
2877
|
//#endregion
|
|
2878
2878
|
//#region src/loginSessions/update.ts
|
|
2879
|
-
function
|
|
2879
|
+
function Vr(e) {
|
|
2880
2880
|
return async (t, n, r) => {
|
|
2881
2881
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2882
2882
|
if (c !== void 0) {
|
|
@@ -2886,7 +2886,7 @@ function zr(e) {
|
|
|
2886
2886
|
...c
|
|
2887
2887
|
}) };
|
|
2888
2888
|
}
|
|
2889
|
-
let d =
|
|
2889
|
+
let d = M(l);
|
|
2890
2890
|
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
2891
|
...d,
|
|
2892
2892
|
...u,
|
|
@@ -2897,22 +2897,22 @@ function zr(e) {
|
|
|
2897
2897
|
}
|
|
2898
2898
|
//#endregion
|
|
2899
2899
|
//#region src/loginSessions/remove.ts
|
|
2900
|
-
function
|
|
2900
|
+
function Hr(e) {
|
|
2901
2901
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2902
2902
|
}
|
|
2903
2903
|
//#endregion
|
|
2904
2904
|
//#region src/loginSessions/index.ts
|
|
2905
|
-
function
|
|
2905
|
+
function Ur(e) {
|
|
2906
2906
|
return {
|
|
2907
|
-
create:
|
|
2908
|
-
get:
|
|
2909
|
-
update:
|
|
2910
|
-
remove:
|
|
2907
|
+
create: Br(e),
|
|
2908
|
+
get: Nr(e),
|
|
2909
|
+
update: Vr(e),
|
|
2910
|
+
remove: Hr(e)
|
|
2911
2911
|
};
|
|
2912
2912
|
}
|
|
2913
2913
|
//#endregion
|
|
2914
2914
|
//#region src/promptSettings/get.ts
|
|
2915
|
-
function
|
|
2915
|
+
function Wr(e) {
|
|
2916
2916
|
return async (t) => {
|
|
2917
2917
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2918
2918
|
return l({
|
|
@@ -2926,13 +2926,13 @@ function Hr(e) {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
//#endregion
|
|
2928
2928
|
//#region src/promptSettings/set.ts
|
|
2929
|
-
function
|
|
2929
|
+
function Gr(e) {
|
|
2930
2930
|
let t = {};
|
|
2931
2931
|
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
2932
|
}
|
|
2933
|
-
function
|
|
2933
|
+
function Kr(e) {
|
|
2934
2934
|
return async (t, n) => {
|
|
2935
|
-
let r =
|
|
2935
|
+
let r = Gr(n);
|
|
2936
2936
|
try {
|
|
2937
2937
|
await e.insertInto("prompt_settings").values({
|
|
2938
2938
|
tenant_id: t,
|
|
@@ -2950,15 +2950,15 @@ function Wr(e) {
|
|
|
2950
2950
|
}
|
|
2951
2951
|
//#endregion
|
|
2952
2952
|
//#region src/promptSettings/index.ts
|
|
2953
|
-
function
|
|
2953
|
+
function qr(e) {
|
|
2954
2954
|
return {
|
|
2955
|
-
get:
|
|
2956
|
-
set:
|
|
2955
|
+
get: Wr(e),
|
|
2956
|
+
set: Kr(e)
|
|
2957
2957
|
};
|
|
2958
2958
|
}
|
|
2959
2959
|
//#endregion
|
|
2960
2960
|
//#region src/emailProvideres/get.ts
|
|
2961
|
-
function
|
|
2961
|
+
function Jr(e) {
|
|
2962
2962
|
return async (t) => {
|
|
2963
2963
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2964
2964
|
if (!n) return null;
|
|
@@ -2973,7 +2973,7 @@ function Kr(e) {
|
|
|
2973
2973
|
}
|
|
2974
2974
|
//#endregion
|
|
2975
2975
|
//#region src/emailProvideres/update.ts
|
|
2976
|
-
function
|
|
2976
|
+
function Yr(e) {
|
|
2977
2977
|
return async (t, n) => {
|
|
2978
2978
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2979
2979
|
await e.updateTable("email_providers").set({
|
|
@@ -2986,7 +2986,7 @@ function qr(e) {
|
|
|
2986
2986
|
}
|
|
2987
2987
|
//#endregion
|
|
2988
2988
|
//#region src/emailProvideres/create.ts
|
|
2989
|
-
function
|
|
2989
|
+
function Xr(e) {
|
|
2990
2990
|
return async (t, n, r) => {
|
|
2991
2991
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2992
2992
|
await e.insertInto("email_providers").values({
|
|
@@ -3002,24 +3002,24 @@ function Jr(e) {
|
|
|
3002
3002
|
}
|
|
3003
3003
|
//#endregion
|
|
3004
3004
|
//#region src/emailProvideres/remove.ts
|
|
3005
|
-
function
|
|
3005
|
+
function Zr(e) {
|
|
3006
3006
|
return async (t) => {
|
|
3007
3007
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3008
3008
|
};
|
|
3009
3009
|
}
|
|
3010
3010
|
//#endregion
|
|
3011
3011
|
//#region src/emailProvideres/index.ts
|
|
3012
|
-
function
|
|
3012
|
+
function Qr(e) {
|
|
3013
3013
|
return {
|
|
3014
|
-
get:
|
|
3015
|
-
create:
|
|
3016
|
-
update:
|
|
3017
|
-
remove:
|
|
3014
|
+
get: Jr(e),
|
|
3015
|
+
create: Xr(e),
|
|
3016
|
+
update: Yr(e),
|
|
3017
|
+
remove: Zr(e)
|
|
3018
3018
|
};
|
|
3019
3019
|
}
|
|
3020
3020
|
//#endregion
|
|
3021
3021
|
//#region src/emailTemplates/row.ts
|
|
3022
|
-
function
|
|
3022
|
+
function $r(e) {
|
|
3023
3023
|
let t = {
|
|
3024
3024
|
template: e.template,
|
|
3025
3025
|
body: e.body,
|
|
@@ -3033,20 +3033,20 @@ function Zr(e) {
|
|
|
3033
3033
|
}
|
|
3034
3034
|
//#endregion
|
|
3035
3035
|
//#region src/emailTemplates/get.ts
|
|
3036
|
-
function
|
|
3036
|
+
function ei(e) {
|
|
3037
3037
|
return async (t, n) => {
|
|
3038
3038
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3039
|
-
return r ? ne.parse(
|
|
3039
|
+
return r ? ne.parse($r(r)) : null;
|
|
3040
3040
|
};
|
|
3041
3041
|
}
|
|
3042
3042
|
//#endregion
|
|
3043
3043
|
//#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(
|
|
3044
|
+
function ti(e) {
|
|
3045
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse($r(e)));
|
|
3046
3046
|
}
|
|
3047
3047
|
//#endregion
|
|
3048
3048
|
//#region src/emailTemplates/create.ts
|
|
3049
|
-
function
|
|
3049
|
+
function ni(e) {
|
|
3050
3050
|
return async (t, n, r) => {
|
|
3051
3051
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3052
3052
|
return await e.insertInto("email_templates").values({
|
|
@@ -3067,7 +3067,7 @@ function ei(e) {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
//#endregion
|
|
3069
3069
|
//#region src/emailTemplates/update.ts
|
|
3070
|
-
function
|
|
3070
|
+
function ri(e) {
|
|
3071
3071
|
return async (t, n, r) => {
|
|
3072
3072
|
let i = {};
|
|
3073
3073
|
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 +3078,7 @@ function ti(e) {
|
|
|
3078
3078
|
}
|
|
3079
3079
|
//#endregion
|
|
3080
3080
|
//#region src/emailTemplates/remove.ts
|
|
3081
|
-
function
|
|
3081
|
+
function ii(e) {
|
|
3082
3082
|
return async (t, n) => {
|
|
3083
3083
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3084
3084
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3086,13 +3086,13 @@ function ni(e) {
|
|
|
3086
3086
|
}
|
|
3087
3087
|
//#endregion
|
|
3088
3088
|
//#region src/emailTemplates/index.ts
|
|
3089
|
-
function
|
|
3089
|
+
function ai(e) {
|
|
3090
3090
|
return {
|
|
3091
|
-
get:
|
|
3092
|
-
list:
|
|
3093
|
-
create:
|
|
3094
|
-
update:
|
|
3095
|
-
remove:
|
|
3091
|
+
get: ei(e),
|
|
3092
|
+
list: ti(e),
|
|
3093
|
+
create: ni(e),
|
|
3094
|
+
update: ri(e),
|
|
3095
|
+
remove: ii(e)
|
|
3096
3096
|
};
|
|
3097
3097
|
}
|
|
3098
3098
|
//#endregion
|
|
@@ -3126,7 +3126,7 @@ function R(e) {
|
|
|
3126
3126
|
}
|
|
3127
3127
|
//#endregion
|
|
3128
3128
|
//#region src/refreshTokens/get.ts
|
|
3129
|
-
function
|
|
3129
|
+
function oi(e) {
|
|
3130
3130
|
return async (t, n) => {
|
|
3131
3131
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3132
3132
|
return r ? R(r) : null;
|
|
@@ -3134,7 +3134,7 @@ function ii(e) {
|
|
|
3134
3134
|
}
|
|
3135
3135
|
//#endregion
|
|
3136
3136
|
//#region src/refreshTokens/getByLookup.ts
|
|
3137
|
-
function
|
|
3137
|
+
function si(e) {
|
|
3138
3138
|
return async (t, n) => {
|
|
3139
3139
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3140
3140
|
return r ? R(r) : null;
|
|
@@ -3142,7 +3142,7 @@ function ai(e) {
|
|
|
3142
3142
|
}
|
|
3143
3143
|
//#endregion
|
|
3144
3144
|
//#region src/refreshTokens/create.ts
|
|
3145
|
-
function
|
|
3145
|
+
function ci(e) {
|
|
3146
3146
|
return async (t, n) => {
|
|
3147
3147
|
let r = c(), i = {
|
|
3148
3148
|
...n,
|
|
@@ -3174,12 +3174,12 @@ function oi(e) {
|
|
|
3174
3174
|
}
|
|
3175
3175
|
//#endregion
|
|
3176
3176
|
//#region src/refreshTokens/remove.ts
|
|
3177
|
-
function
|
|
3177
|
+
function li(e) {
|
|
3178
3178
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3179
3179
|
}
|
|
3180
3180
|
//#endregion
|
|
3181
3181
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3182
|
-
function
|
|
3182
|
+
function ui(e) {
|
|
3183
3183
|
return async (t, n, r) => {
|
|
3184
3184
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("login_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3185
3185
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3187,7 +3187,7 @@ function ci(e) {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
//#endregion
|
|
3189
3189
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3190
|
-
function
|
|
3190
|
+
function di(e) {
|
|
3191
3191
|
return async (t, n, r) => {
|
|
3192
3192
|
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
3193
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3195,7 +3195,7 @@ function li(e) {
|
|
|
3195
3195
|
}
|
|
3196
3196
|
//#endregion
|
|
3197
3197
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3198
|
-
function
|
|
3198
|
+
function fi(e) {
|
|
3199
3199
|
return async (t, n, r) => {
|
|
3200
3200
|
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
3201
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3203,7 +3203,7 @@ function ui(e) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
//#endregion
|
|
3205
3205
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3206
|
-
function
|
|
3206
|
+
function pi(e) {
|
|
3207
3207
|
return async (t, n, r) => {
|
|
3208
3208
|
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
3209
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3211,7 +3211,7 @@ function di(e) {
|
|
|
3211
3211
|
}
|
|
3212
3212
|
//#endregion
|
|
3213
3213
|
//#region src/refreshTokens/update.ts
|
|
3214
|
-
function
|
|
3214
|
+
function mi(e) {
|
|
3215
3215
|
return async (t, n, r, i) => {
|
|
3216
3216
|
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
3217
|
...h,
|
|
@@ -3232,11 +3232,11 @@ function fi(e) {
|
|
|
3232
3232
|
}
|
|
3233
3233
|
//#endregion
|
|
3234
3234
|
//#region src/refreshTokens/list.ts
|
|
3235
|
-
function
|
|
3235
|
+
function hi(e) {
|
|
3236
3236
|
return async (t, n = {}) => {
|
|
3237
3237
|
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
|
|
3238
|
+
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = D(e, u, c, ["token", "login_id"])), A(n)) {
|
|
3239
|
+
let { rows: e, limit: t, next: r } = await j(u.selectAll(), n, {
|
|
3240
3240
|
sortColumn: "created_at_ts",
|
|
3241
3241
|
sortOrder: "desc"
|
|
3242
3242
|
}), i = e.map(R);
|
|
@@ -3272,26 +3272,26 @@ function pi(e) {
|
|
|
3272
3272
|
}
|
|
3273
3273
|
//#endregion
|
|
3274
3274
|
//#region src/refreshTokens/index.ts
|
|
3275
|
-
function
|
|
3275
|
+
function gi(e) {
|
|
3276
3276
|
return {
|
|
3277
|
-
create:
|
|
3278
|
-
get:
|
|
3279
|
-
getByLookup:
|
|
3280
|
-
list:
|
|
3281
|
-
remove:
|
|
3282
|
-
revokeByLoginSession:
|
|
3283
|
-
revokeBySession:
|
|
3284
|
-
revokeByUser:
|
|
3285
|
-
revokeFamily:
|
|
3286
|
-
update:
|
|
3277
|
+
create: ci(e),
|
|
3278
|
+
get: oi(e),
|
|
3279
|
+
getByLookup: si(e),
|
|
3280
|
+
list: hi(e),
|
|
3281
|
+
remove: li(e),
|
|
3282
|
+
revokeByLoginSession: ui(e),
|
|
3283
|
+
revokeBySession: di(e),
|
|
3284
|
+
revokeByUser: fi(e),
|
|
3285
|
+
revokeFamily: pi(e),
|
|
3286
|
+
update: mi(e)
|
|
3287
3287
|
};
|
|
3288
3288
|
}
|
|
3289
3289
|
//#endregion
|
|
3290
3290
|
//#region src/cleanup.ts
|
|
3291
|
-
var
|
|
3292
|
-
function
|
|
3291
|
+
var _i = 10080 * 60 * 1e3;
|
|
3292
|
+
function vi(e) {
|
|
3293
3293
|
return async (t) => {
|
|
3294
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3294
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - _i, a = 1e3;
|
|
3295
3295
|
try {
|
|
3296
3296
|
let t = 0;
|
|
3297
3297
|
for (;;) {
|
|
@@ -3322,7 +3322,7 @@ function gi(e) {
|
|
|
3322
3322
|
}
|
|
3323
3323
|
//#endregion
|
|
3324
3324
|
//#region src/forms/create.ts
|
|
3325
|
-
function
|
|
3325
|
+
function yi(e) {
|
|
3326
3326
|
return async (n, r, i) => {
|
|
3327
3327
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3328
3328
|
id: a?.id ?? t(),
|
|
@@ -3341,10 +3341,10 @@ function _i(e) {
|
|
|
3341
3341
|
}
|
|
3342
3342
|
//#endregion
|
|
3343
3343
|
//#region src/forms/list.ts
|
|
3344
|
-
function
|
|
3344
|
+
function bi(e) {
|
|
3345
3345
|
return async (t, n = {}) => {
|
|
3346
3346
|
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 =
|
|
3347
|
+
s && (c = D(e, c, s, []));
|
|
3348
3348
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3349
3349
|
let t = { ...e };
|
|
3350
3350
|
if (typeof t.nodes == "string") try {
|
|
@@ -3375,7 +3375,7 @@ function vi(e) {
|
|
|
3375
3375
|
}
|
|
3376
3376
|
//#endregion
|
|
3377
3377
|
//#region src/forms/remove.ts
|
|
3378
|
-
function
|
|
3378
|
+
function xi(e) {
|
|
3379
3379
|
return async (t, n) => {
|
|
3380
3380
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3381
3381
|
return r > 0;
|
|
@@ -3383,7 +3383,7 @@ function yi(e) {
|
|
|
3383
3383
|
}
|
|
3384
3384
|
//#endregion
|
|
3385
3385
|
//#region src/forms/get.ts
|
|
3386
|
-
function
|
|
3386
|
+
function Si(e) {
|
|
3387
3387
|
return async (t, n) => {
|
|
3388
3388
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3389
3389
|
if (!r) return null;
|
|
@@ -3402,7 +3402,7 @@ function bi(e) {
|
|
|
3402
3402
|
}
|
|
3403
3403
|
//#endregion
|
|
3404
3404
|
//#region src/forms/update.ts
|
|
3405
|
-
function
|
|
3405
|
+
function Ci(e) {
|
|
3406
3406
|
return async (t, n, r) => {
|
|
3407
3407
|
let i = {
|
|
3408
3408
|
...r,
|
|
@@ -3419,22 +3419,22 @@ function xi(e) {
|
|
|
3419
3419
|
}
|
|
3420
3420
|
//#endregion
|
|
3421
3421
|
//#region src/forms/index.ts
|
|
3422
|
-
function
|
|
3422
|
+
function wi(e) {
|
|
3423
3423
|
return {
|
|
3424
|
-
create:
|
|
3425
|
-
get:
|
|
3426
|
-
list:
|
|
3427
|
-
remove:
|
|
3428
|
-
update:
|
|
3424
|
+
create: yi(e),
|
|
3425
|
+
get: Si(e),
|
|
3426
|
+
list: bi(e),
|
|
3427
|
+
remove: xi(e),
|
|
3428
|
+
update: Ci(e)
|
|
3429
3429
|
};
|
|
3430
3430
|
}
|
|
3431
3431
|
//#endregion
|
|
3432
3432
|
//#region src/resourceServers/create.ts
|
|
3433
|
-
function
|
|
3433
|
+
function Ti(e) {
|
|
3434
3434
|
return async (t, n, r) => {
|
|
3435
3435
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3436
3436
|
...n,
|
|
3437
|
-
id: i?.id ?? n.id ??
|
|
3437
|
+
id: i?.id ?? n.id ?? Pe(),
|
|
3438
3438
|
created_at: o,
|
|
3439
3439
|
updated_at: s
|
|
3440
3440
|
}, 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 +3455,7 @@ function Ci(e) {
|
|
|
3455
3455
|
}
|
|
3456
3456
|
//#endregion
|
|
3457
3457
|
//#region src/resourceServers/get.ts
|
|
3458
|
-
function
|
|
3458
|
+
function Ei(e) {
|
|
3459
3459
|
return async (t, n) => {
|
|
3460
3460
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3461
3461
|
if (!r) return null;
|
|
@@ -3474,7 +3474,7 @@ function wi(e) {
|
|
|
3474
3474
|
}
|
|
3475
3475
|
//#endregion
|
|
3476
3476
|
//#region src/resourceServers/list.ts
|
|
3477
|
-
function
|
|
3477
|
+
function Di(e) {
|
|
3478
3478
|
return async (t, n = {}) => {
|
|
3479
3479
|
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
3480
|
if (s) {
|
|
@@ -3482,7 +3482,7 @@ function Ti(e) {
|
|
|
3482
3482
|
if (i && !o) {
|
|
3483
3483
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3484
3484
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3485
|
-
} else c =
|
|
3485
|
+
} else c = D(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3486
3486
|
}
|
|
3487
3487
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3488
3488
|
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 +3514,7 @@ function Ti(e) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
//#endregion
|
|
3516
3516
|
//#region src/resourceServers/remove.ts
|
|
3517
|
-
function
|
|
3517
|
+
function Oi(e) {
|
|
3518
3518
|
return async (t, n) => {
|
|
3519
3519
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3520
3520
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3522,7 +3522,7 @@ function Ei(e) {
|
|
|
3522
3522
|
}
|
|
3523
3523
|
//#endregion
|
|
3524
3524
|
//#region src/resourceServers/update.ts
|
|
3525
|
-
function
|
|
3525
|
+
function ki(e) {
|
|
3526
3526
|
return async (t, n, r) => {
|
|
3527
3527
|
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
3528
|
...d,
|
|
@@ -3542,18 +3542,18 @@ function Di(e) {
|
|
|
3542
3542
|
}
|
|
3543
3543
|
//#endregion
|
|
3544
3544
|
//#region src/resourceServers/index.ts
|
|
3545
|
-
function
|
|
3545
|
+
function Ai(e) {
|
|
3546
3546
|
return {
|
|
3547
|
-
create:
|
|
3548
|
-
get:
|
|
3549
|
-
list:
|
|
3550
|
-
remove:
|
|
3551
|
-
update:
|
|
3547
|
+
create: Ti(e),
|
|
3548
|
+
get: Ei(e),
|
|
3549
|
+
list: Di(e),
|
|
3550
|
+
remove: Oi(e),
|
|
3551
|
+
update: ki(e)
|
|
3552
3552
|
};
|
|
3553
3553
|
}
|
|
3554
3554
|
//#endregion
|
|
3555
3555
|
//#region src/roles/create.ts
|
|
3556
|
-
function
|
|
3556
|
+
function ji(e) {
|
|
3557
3557
|
return async (n, r, i) => {
|
|
3558
3558
|
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
3559
|
id: l,
|
|
@@ -3576,7 +3576,7 @@ function ki(e) {
|
|
|
3576
3576
|
}
|
|
3577
3577
|
//#endregion
|
|
3578
3578
|
//#region src/roles/get.ts
|
|
3579
|
-
function
|
|
3579
|
+
function Mi(e) {
|
|
3580
3580
|
return async (t, n) => {
|
|
3581
3581
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3582
3582
|
if (!r) return null;
|
|
@@ -3590,10 +3590,10 @@ function Ai(e) {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
//#endregion
|
|
3592
3592
|
//#region src/roles/list.ts
|
|
3593
|
-
function
|
|
3593
|
+
function Ni(e) {
|
|
3594
3594
|
return async (t, n) => {
|
|
3595
3595
|
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 =
|
|
3596
|
+
n.q && (r = D(e, r, n.q, ["name"]));
|
|
3597
3597
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3598
3598
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3599
3599
|
return {
|
|
@@ -3619,7 +3619,7 @@ function ji(e) {
|
|
|
3619
3619
|
}
|
|
3620
3620
|
//#endregion
|
|
3621
3621
|
//#region src/roles/update.ts
|
|
3622
|
-
function
|
|
3622
|
+
function Pi(e) {
|
|
3623
3623
|
return async (t, n, r) => {
|
|
3624
3624
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3625
3625
|
...o,
|
|
@@ -3632,7 +3632,7 @@ function Mi(e) {
|
|
|
3632
3632
|
}
|
|
3633
3633
|
//#endregion
|
|
3634
3634
|
//#region src/roles/remove.ts
|
|
3635
|
-
function
|
|
3635
|
+
function Fi(e) {
|
|
3636
3636
|
return async (t, n) => {
|
|
3637
3637
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3638
3638
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3640,23 +3640,23 @@ function Ni(e) {
|
|
|
3640
3640
|
}
|
|
3641
3641
|
//#endregion
|
|
3642
3642
|
//#region src/roles/index.ts
|
|
3643
|
-
function
|
|
3643
|
+
function Ii(e) {
|
|
3644
3644
|
return {
|
|
3645
|
-
create:
|
|
3646
|
-
get:
|
|
3647
|
-
list:
|
|
3648
|
-
update:
|
|
3649
|
-
remove:
|
|
3645
|
+
create: ji(e),
|
|
3646
|
+
get: Mi(e),
|
|
3647
|
+
list: Ni(e),
|
|
3648
|
+
update: Pi(e),
|
|
3649
|
+
remove: Fi(e)
|
|
3650
3650
|
};
|
|
3651
3651
|
}
|
|
3652
3652
|
//#endregion
|
|
3653
3653
|
//#region src/role-permissions/assign.ts
|
|
3654
|
-
function
|
|
3654
|
+
function Li(e) {
|
|
3655
3655
|
if (typeof e != "object" || !e) return !1;
|
|
3656
3656
|
let { code: t, message: n } = e;
|
|
3657
3657
|
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
3658
|
}
|
|
3659
|
-
function
|
|
3659
|
+
function Ri(e) {
|
|
3660
3660
|
return async (t, n, r, i) => {
|
|
3661
3661
|
if (r.length === 0) return !0;
|
|
3662
3662
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3673,7 +3673,7 @@ function Ii(e) {
|
|
|
3673
3673
|
try {
|
|
3674
3674
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3675
3675
|
} catch (e) {
|
|
3676
|
-
if (
|
|
3676
|
+
if (Li(e)) continue;
|
|
3677
3677
|
throw e;
|
|
3678
3678
|
}
|
|
3679
3679
|
}
|
|
@@ -3685,7 +3685,7 @@ function Ii(e) {
|
|
|
3685
3685
|
}
|
|
3686
3686
|
//#endregion
|
|
3687
3687
|
//#region src/role-permissions/remove.ts
|
|
3688
|
-
function
|
|
3688
|
+
function zi(e) {
|
|
3689
3689
|
return async (t, n, r) => {
|
|
3690
3690
|
if (r.length === 0) return !0;
|
|
3691
3691
|
try {
|
|
@@ -3697,7 +3697,7 @@ function Li(e) {
|
|
|
3697
3697
|
}
|
|
3698
3698
|
//#endregion
|
|
3699
3699
|
//#region src/role-permissions/list.ts
|
|
3700
|
-
function
|
|
3700
|
+
function Bi(e) {
|
|
3701
3701
|
return async (t, n, r = {}) => {
|
|
3702
3702
|
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
3703
|
"role_permissions.role_id",
|
|
@@ -3718,16 +3718,16 @@ function Ri(e) {
|
|
|
3718
3718
|
}
|
|
3719
3719
|
//#endregion
|
|
3720
3720
|
//#region src/role-permissions/index.ts
|
|
3721
|
-
function
|
|
3721
|
+
function Vi(e) {
|
|
3722
3722
|
return {
|
|
3723
|
-
assign:
|
|
3724
|
-
remove:
|
|
3725
|
-
list:
|
|
3723
|
+
assign: Ri(e),
|
|
3724
|
+
remove: zi(e),
|
|
3725
|
+
list: Bi(e)
|
|
3726
3726
|
};
|
|
3727
3727
|
}
|
|
3728
3728
|
//#endregion
|
|
3729
3729
|
//#region src/grants/create.ts
|
|
3730
|
-
function
|
|
3730
|
+
function Hi(e) {
|
|
3731
3731
|
return async (n, r) => {
|
|
3732
3732
|
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
3733
|
if (s) {
|
|
@@ -3764,7 +3764,7 @@ function Bi(e) {
|
|
|
3764
3764
|
}
|
|
3765
3765
|
//#endregion
|
|
3766
3766
|
//#region src/grants/get.ts
|
|
3767
|
-
function
|
|
3767
|
+
function Ui(e) {
|
|
3768
3768
|
return async (t, n, r, i) => {
|
|
3769
3769
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3770
3770
|
return a ? {
|
|
@@ -3778,10 +3778,10 @@ function Vi(e) {
|
|
|
3778
3778
|
}
|
|
3779
3779
|
//#endregion
|
|
3780
3780
|
//#region src/grants/list.ts
|
|
3781
|
-
function
|
|
3781
|
+
function Wi(e) {
|
|
3782
3782
|
return async (t, n = {}) => {
|
|
3783
3783
|
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 =
|
|
3784
|
+
c && (l = D(e, l, c, [
|
|
3785
3785
|
"user_id",
|
|
3786
3786
|
"client_id",
|
|
3787
3787
|
"audience"
|
|
@@ -3816,26 +3816,26 @@ function Hi(e) {
|
|
|
3816
3816
|
}
|
|
3817
3817
|
//#endregion
|
|
3818
3818
|
//#region src/grants/remove.ts
|
|
3819
|
-
function
|
|
3819
|
+
function Gi(e) {
|
|
3820
3820
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3821
3821
|
}
|
|
3822
|
-
function
|
|
3822
|
+
function Ki(e) {
|
|
3823
3823
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3824
3824
|
}
|
|
3825
3825
|
//#endregion
|
|
3826
3826
|
//#region src/grants/index.ts
|
|
3827
|
-
function
|
|
3827
|
+
function qi(e) {
|
|
3828
3828
|
return {
|
|
3829
|
-
create:
|
|
3830
|
-
get:
|
|
3831
|
-
list:
|
|
3832
|
-
remove:
|
|
3833
|
-
removeByUser:
|
|
3829
|
+
create: Hi(e),
|
|
3830
|
+
get: Ui(e),
|
|
3831
|
+
list: Wi(e),
|
|
3832
|
+
remove: Gi(e),
|
|
3833
|
+
removeByUser: Ki(e)
|
|
3834
3834
|
};
|
|
3835
3835
|
}
|
|
3836
3836
|
//#endregion
|
|
3837
3837
|
//#region src/user-permissions/create.ts
|
|
3838
|
-
function
|
|
3838
|
+
function Ji(e) {
|
|
3839
3839
|
return async (t, n, r, i, a) => {
|
|
3840
3840
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3841
3841
|
try {
|
|
@@ -3855,7 +3855,7 @@ function Ki(e) {
|
|
|
3855
3855
|
}
|
|
3856
3856
|
//#endregion
|
|
3857
3857
|
//#region src/user-permissions/remove.ts
|
|
3858
|
-
function
|
|
3858
|
+
function Yi(e) {
|
|
3859
3859
|
return async (t, n, r, i) => {
|
|
3860
3860
|
try {
|
|
3861
3861
|
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 +3867,7 @@ function qi(e) {
|
|
|
3867
3867
|
}
|
|
3868
3868
|
//#endregion
|
|
3869
3869
|
//#region src/user-permissions/list.ts
|
|
3870
|
-
function
|
|
3870
|
+
function Xi(e) {
|
|
3871
3871
|
return async (t, n, r, i) => {
|
|
3872
3872
|
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
3873
|
"user_permissions.resource_server_identifier",
|
|
@@ -3890,17 +3890,17 @@ function Ji(e) {
|
|
|
3890
3890
|
}
|
|
3891
3891
|
//#endregion
|
|
3892
3892
|
//#region src/user-permissions/index.ts
|
|
3893
|
-
function
|
|
3893
|
+
function Zi(e) {
|
|
3894
3894
|
return {
|
|
3895
|
-
create:
|
|
3896
|
-
remove:
|
|
3897
|
-
list:
|
|
3895
|
+
create: Ji(e),
|
|
3896
|
+
remove: Yi(e),
|
|
3897
|
+
list: Xi(e)
|
|
3898
3898
|
};
|
|
3899
3899
|
}
|
|
3900
3900
|
//#endregion
|
|
3901
3901
|
//#region src/user-permissions/adapter.ts
|
|
3902
|
-
function
|
|
3903
|
-
let t =
|
|
3902
|
+
function Qi(e) {
|
|
3903
|
+
let t = Zi(e);
|
|
3904
3904
|
return {
|
|
3905
3905
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3906
3906
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3909,7 +3909,7 @@ function Xi(e) {
|
|
|
3909
3909
|
}
|
|
3910
3910
|
//#endregion
|
|
3911
3911
|
//#region src/user-roles/list.ts
|
|
3912
|
-
function
|
|
3912
|
+
function $i(e) {
|
|
3913
3913
|
return async (t, n, r, i) => {
|
|
3914
3914
|
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
3915
|
"r.id",
|
|
@@ -3923,11 +3923,11 @@ function Zi(e) {
|
|
|
3923
3923
|
}
|
|
3924
3924
|
//#endregion
|
|
3925
3925
|
//#region src/user-roles/list-users.ts
|
|
3926
|
-
function
|
|
3926
|
+
function ea(e) {
|
|
3927
3927
|
return async (t, n, r) => {
|
|
3928
3928
|
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
|
|
3929
|
+
if (A(r)) {
|
|
3930
|
+
let { rows: e, limit: t, next: n } = await j(i, r, {
|
|
3931
3931
|
sortColumn: "user_id",
|
|
3932
3932
|
sortOrder: "asc",
|
|
3933
3933
|
idColumn: "user_id"
|
|
@@ -3951,7 +3951,7 @@ function Qi(e) {
|
|
|
3951
3951
|
}
|
|
3952
3952
|
//#endregion
|
|
3953
3953
|
//#region src/user-roles/create.ts
|
|
3954
|
-
function
|
|
3954
|
+
function ta(e) {
|
|
3955
3955
|
return async (t, n, r, i, a) => {
|
|
3956
3956
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3957
3957
|
try {
|
|
@@ -3969,7 +3969,7 @@ function $i(e) {
|
|
|
3969
3969
|
}
|
|
3970
3970
|
//#endregion
|
|
3971
3971
|
//#region src/user-roles/remove.ts
|
|
3972
|
-
function
|
|
3972
|
+
function na(e) {
|
|
3973
3973
|
return async (t, n, r, i) => {
|
|
3974
3974
|
try {
|
|
3975
3975
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3981,18 +3981,18 @@ function ea(e) {
|
|
|
3981
3981
|
}
|
|
3982
3982
|
//#endregion
|
|
3983
3983
|
//#region src/user-roles/index.ts
|
|
3984
|
-
function
|
|
3984
|
+
function ra(e) {
|
|
3985
3985
|
return {
|
|
3986
|
-
list:
|
|
3987
|
-
listUsers:
|
|
3988
|
-
create:
|
|
3989
|
-
remove:
|
|
3986
|
+
list: $i(e),
|
|
3987
|
+
listUsers: ea(e),
|
|
3988
|
+
create: ta(e),
|
|
3989
|
+
remove: na(e)
|
|
3990
3990
|
};
|
|
3991
3991
|
}
|
|
3992
3992
|
//#endregion
|
|
3993
3993
|
//#region src/user-roles/adapter.ts
|
|
3994
|
-
function
|
|
3995
|
-
let t =
|
|
3994
|
+
function ia(e) {
|
|
3995
|
+
let t = ra(e);
|
|
3996
3996
|
return {
|
|
3997
3997
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3998
3998
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4002,11 +4002,11 @@ function na(e) {
|
|
|
4002
4002
|
}
|
|
4003
4003
|
//#endregion
|
|
4004
4004
|
//#region src/organizations/create.ts
|
|
4005
|
-
function
|
|
4005
|
+
function aa(e) {
|
|
4006
4006
|
return async (t, n, r) => {
|
|
4007
4007
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4008
4008
|
...n,
|
|
4009
|
-
id: i?.id || n.id ||
|
|
4009
|
+
id: i?.id || n.id || ke(),
|
|
4010
4010
|
tenant_id: t,
|
|
4011
4011
|
created_at: i?.created_at ?? a,
|
|
4012
4012
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4030,7 +4030,7 @@ function ra(e) {
|
|
|
4030
4030
|
}
|
|
4031
4031
|
//#endregion
|
|
4032
4032
|
//#region src/organizations/get.ts
|
|
4033
|
-
function
|
|
4033
|
+
function oa(e) {
|
|
4034
4034
|
return async (t, n) => {
|
|
4035
4035
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4036
4036
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4045,15 +4045,15 @@ function ia(e) {
|
|
|
4045
4045
|
//#endregion
|
|
4046
4046
|
//#region src/organizations/list.ts
|
|
4047
4047
|
var z = ["name", "display_name"];
|
|
4048
|
-
function
|
|
4048
|
+
function sa(e) {
|
|
4049
4049
|
return async (t, n) => {
|
|
4050
4050
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4051
4051
|
if (n?.q) {
|
|
4052
4052
|
let t = S(n.q, z);
|
|
4053
|
-
t && (r =
|
|
4053
|
+
t && (r = D(e, r, t, z));
|
|
4054
4054
|
}
|
|
4055
|
-
if (
|
|
4056
|
-
let { rows: e, limit: t, next: i } = await
|
|
4055
|
+
if (A(n)) {
|
|
4056
|
+
let { rows: e, limit: t, next: i } = await j(r.selectAll(), n, {
|
|
4057
4057
|
sortColumn: "created_at",
|
|
4058
4058
|
sortOrder: "desc"
|
|
4059
4059
|
}), a = e.map((e) => l({
|
|
@@ -4087,7 +4087,7 @@ function aa(e) {
|
|
|
4087
4087
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4088
4088
|
if (n?.q) {
|
|
4089
4089
|
let t = S(n.q, z);
|
|
4090
|
-
t && (r =
|
|
4090
|
+
t && (r = D(e, r, t, z));
|
|
4091
4091
|
}
|
|
4092
4092
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4093
4093
|
u = Number(i?.count || 0);
|
|
@@ -4110,12 +4110,15 @@ function aa(e) {
|
|
|
4110
4110
|
}
|
|
4111
4111
|
//#endregion
|
|
4112
4112
|
//#region src/organizations/remove.ts
|
|
4113
|
-
function
|
|
4114
|
-
return async (t, n) =>
|
|
4113
|
+
function ca(e) {
|
|
4114
|
+
return async (t, n) => {
|
|
4115
|
+
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4116
|
+
return Number(r.numDeletedRows) > 0;
|
|
4117
|
+
};
|
|
4115
4118
|
}
|
|
4116
4119
|
//#endregion
|
|
4117
4120
|
//#region src/organizations/update.ts
|
|
4118
|
-
function
|
|
4121
|
+
function la(e) {
|
|
4119
4122
|
return async (t, n, r) => {
|
|
4120
4123
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4121
4124
|
...c,
|
|
@@ -4131,13 +4134,13 @@ function sa(e) {
|
|
|
4131
4134
|
}
|
|
4132
4135
|
//#endregion
|
|
4133
4136
|
//#region src/organizations/index.ts
|
|
4134
|
-
function
|
|
4137
|
+
function ua(e) {
|
|
4135
4138
|
return {
|
|
4136
|
-
create:
|
|
4137
|
-
get:
|
|
4138
|
-
list:
|
|
4139
|
-
remove:
|
|
4140
|
-
update:
|
|
4139
|
+
create: aa(e),
|
|
4140
|
+
get: oa(e),
|
|
4141
|
+
list: sa(e),
|
|
4142
|
+
remove: ca(e),
|
|
4143
|
+
update: la(e)
|
|
4141
4144
|
};
|
|
4142
4145
|
}
|
|
4143
4146
|
//#endregion
|
|
@@ -4163,7 +4166,7 @@ async function V(e, t, n) {
|
|
|
4163
4166
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4164
4167
|
};
|
|
4165
4168
|
}
|
|
4166
|
-
function
|
|
4169
|
+
function da(e) {
|
|
4167
4170
|
return {
|
|
4168
4171
|
async create(t, n, r, i) {
|
|
4169
4172
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4206,7 +4209,7 @@ function la(e) {
|
|
|
4206
4209
|
}
|
|
4207
4210
|
//#endregion
|
|
4208
4211
|
//#region src/user-organizations/create.ts
|
|
4209
|
-
function
|
|
4212
|
+
function fa(e) {
|
|
4210
4213
|
return async (n, r, i) => {
|
|
4211
4214
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4212
4215
|
id: a?.id ?? t(),
|
|
@@ -4226,7 +4229,7 @@ function ua(e) {
|
|
|
4226
4229
|
}
|
|
4227
4230
|
//#endregion
|
|
4228
4231
|
//#region src/user-organizations/get.ts
|
|
4229
|
-
function
|
|
4232
|
+
function pa(e) {
|
|
4230
4233
|
return async (t, n) => {
|
|
4231
4234
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4232
4235
|
return r ? {
|
|
@@ -4243,7 +4246,7 @@ function da(e) {
|
|
|
4243
4246
|
function H(e, t) {
|
|
4244
4247
|
return C(e.slice(t.length + 1));
|
|
4245
4248
|
}
|
|
4246
|
-
function
|
|
4249
|
+
function ma(e) {
|
|
4247
4250
|
return async (t, n) => {
|
|
4248
4251
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4249
4252
|
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", H(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", H(n.q, "organization_id"))));
|
|
@@ -4254,8 +4257,8 @@ function fa(e) {
|
|
|
4254
4257
|
created_at: e.created_at,
|
|
4255
4258
|
updated_at: e.updated_at
|
|
4256
4259
|
});
|
|
4257
|
-
if (
|
|
4258
|
-
let { rows: e, limit: t, next: a } = await
|
|
4260
|
+
if (A(n)) {
|
|
4261
|
+
let { rows: e, limit: t, next: a } = await j(r, n, {
|
|
4259
4262
|
sortColumn: "created_at",
|
|
4260
4263
|
sortOrder: "desc"
|
|
4261
4264
|
});
|
|
@@ -4280,7 +4283,7 @@ function fa(e) {
|
|
|
4280
4283
|
}
|
|
4281
4284
|
//#endregion
|
|
4282
4285
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4283
|
-
function
|
|
4286
|
+
function ha(e) {
|
|
4284
4287
|
return async (t, n, r) => {
|
|
4285
4288
|
let i = r?.page || 0, a = r?.per_page || 50, o = i * a, s = e.selectFrom("user_organizations").innerJoin("organizations", (e) => e.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)).select([
|
|
4286
4289
|
"organizations.id",
|
|
@@ -4317,12 +4320,12 @@ function pa(e) {
|
|
|
4317
4320
|
}
|
|
4318
4321
|
//#endregion
|
|
4319
4322
|
//#region src/user-organizations/remove.ts
|
|
4320
|
-
function
|
|
4323
|
+
function ga(e) {
|
|
4321
4324
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4322
4325
|
}
|
|
4323
4326
|
//#endregion
|
|
4324
4327
|
//#region src/user-organizations/update.ts
|
|
4325
|
-
function
|
|
4328
|
+
function _a(e) {
|
|
4326
4329
|
return async (t, n, r) => {
|
|
4327
4330
|
let i = {
|
|
4328
4331
|
...r,
|
|
@@ -4333,21 +4336,21 @@ function ha(e) {
|
|
|
4333
4336
|
}
|
|
4334
4337
|
//#endregion
|
|
4335
4338
|
//#region src/user-organizations/index.ts
|
|
4336
|
-
function
|
|
4339
|
+
function va(e) {
|
|
4337
4340
|
return {
|
|
4338
|
-
create:
|
|
4339
|
-
get:
|
|
4340
|
-
list:
|
|
4341
|
-
listUserOrganizations:
|
|
4342
|
-
remove:
|
|
4343
|
-
update:
|
|
4341
|
+
create: fa(e),
|
|
4342
|
+
get: pa(e),
|
|
4343
|
+
list: ma(e),
|
|
4344
|
+
listUserOrganizations: ha(e),
|
|
4345
|
+
remove: ga(e),
|
|
4346
|
+
update: _a(e)
|
|
4344
4347
|
};
|
|
4345
4348
|
}
|
|
4346
4349
|
//#endregion
|
|
4347
4350
|
//#region src/invites/create.ts
|
|
4348
|
-
function
|
|
4351
|
+
function ya(e) {
|
|
4349
4352
|
return async (t, n, r) => {
|
|
4350
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4353
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Ie(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4351
4354
|
id: a,
|
|
4352
4355
|
tenant_id: t,
|
|
4353
4356
|
organization_id: n.organization_id,
|
|
@@ -4391,11 +4394,11 @@ function _a(e) {
|
|
|
4391
4394
|
}
|
|
4392
4395
|
//#endregion
|
|
4393
4396
|
//#region src/invites/get.ts
|
|
4394
|
-
function
|
|
4397
|
+
function ba(e) {
|
|
4395
4398
|
return async (t, n) => {
|
|
4396
4399
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4397
4400
|
return r ? l({
|
|
4398
|
-
...
|
|
4401
|
+
...wt(r, {
|
|
4399
4402
|
inviter: {},
|
|
4400
4403
|
invitee: {},
|
|
4401
4404
|
app_metadata: {},
|
|
@@ -4408,7 +4411,7 @@ function va(e) {
|
|
|
4408
4411
|
}
|
|
4409
4412
|
//#endregion
|
|
4410
4413
|
//#region src/invites/list.ts
|
|
4411
|
-
function
|
|
4414
|
+
function xa(e) {
|
|
4412
4415
|
return async (t, n) => {
|
|
4413
4416
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4414
4417
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4416,7 +4419,7 @@ function ya(e) {
|
|
|
4416
4419
|
r = r.offset(e);
|
|
4417
4420
|
}
|
|
4418
4421
|
let i = (await r.execute()).map((e) => l({
|
|
4419
|
-
...
|
|
4422
|
+
...wt(e, {
|
|
4420
4423
|
inviter: {},
|
|
4421
4424
|
invitee: {},
|
|
4422
4425
|
app_metadata: {},
|
|
@@ -4435,12 +4438,12 @@ function ya(e) {
|
|
|
4435
4438
|
}
|
|
4436
4439
|
//#endregion
|
|
4437
4440
|
//#region src/invites/remove.ts
|
|
4438
|
-
function
|
|
4441
|
+
function Sa(e) {
|
|
4439
4442
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4440
4443
|
}
|
|
4441
4444
|
//#endregion
|
|
4442
4445
|
//#region src/invites/update.ts
|
|
4443
|
-
function
|
|
4446
|
+
function Ca(e) {
|
|
4444
4447
|
return async (t, n, r) => {
|
|
4445
4448
|
let i = {};
|
|
4446
4449
|
return r.inviter !== void 0 && (i.inviter = JSON.stringify(r.inviter)), r.invitee !== void 0 && (i.invitee = JSON.stringify(r.invitee)), r.client_id !== void 0 && (i.client_id = r.client_id), r.connection_id !== void 0 && (i.connection_id = r.connection_id), r.app_metadata !== void 0 && (i.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (i.user_metadata = JSON.stringify(r.user_metadata)), r.roles !== void 0 && (i.roles = JSON.stringify(r.roles)), r.ttl_sec !== void 0 && (i.ttl_sec = r.ttl_sec, i.expires_at = new Date(Date.now() + r.ttl_sec * 1e3).toISOString()), r.send_invitation_email !== void 0 && (i.send_invitation_email = +!!r.send_invitation_email), Object.keys(i).length === 0 ? !0 : (await e.updateTable("invites").set(i).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numUpdatedRows > 0n;
|
|
@@ -4448,35 +4451,35 @@ function xa(e) {
|
|
|
4448
4451
|
}
|
|
4449
4452
|
//#endregion
|
|
4450
4453
|
//#region src/invites/index.ts
|
|
4451
|
-
function
|
|
4454
|
+
function wa(e) {
|
|
4452
4455
|
return {
|
|
4453
|
-
create:
|
|
4454
|
-
get:
|
|
4455
|
-
list:
|
|
4456
|
-
remove:
|
|
4457
|
-
update:
|
|
4456
|
+
create: ya(e),
|
|
4457
|
+
get: ba(e),
|
|
4458
|
+
list: xa(e),
|
|
4459
|
+
remove: Sa(e),
|
|
4460
|
+
update: Ca(e)
|
|
4458
4461
|
};
|
|
4459
4462
|
}
|
|
4460
4463
|
//#endregion
|
|
4461
4464
|
//#region src/stats/index.ts
|
|
4462
|
-
var
|
|
4463
|
-
function
|
|
4465
|
+
var Ta = ["s"], Ea = ["pwd_leak"];
|
|
4466
|
+
function Da(e) {
|
|
4464
4467
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4465
4468
|
}
|
|
4466
|
-
function
|
|
4469
|
+
function Oa(e) {
|
|
4467
4470
|
return e.toISOString().split("T")[0];
|
|
4468
4471
|
}
|
|
4469
|
-
function
|
|
4472
|
+
function ka(e) {
|
|
4470
4473
|
return {
|
|
4471
4474
|
async getDaily(t, n = {}) {
|
|
4472
4475
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4473
4476
|
o.setDate(o.getDate() - 30);
|
|
4474
|
-
let s = r ?
|
|
4477
|
+
let s = r ? Da(r) : Oa(o), c = i ? Da(i) : Oa(a), l = f`DATE(logs.date)`;
|
|
4475
4478
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4476
4479
|
l.as("date"),
|
|
4477
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4480
|
+
e.fn.sum(e.case().when("type", "in", Ta).then(1).else(0).end()).as("logins"),
|
|
4478
4481
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4479
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4482
|
+
e.fn.sum(e.case().when("type", "in", Ea).then(1).else(0).end()).as("leaked_passwords"),
|
|
4480
4483
|
e.fn.min("date").as("first_event"),
|
|
4481
4484
|
e.fn.max("date").as("last_event")
|
|
4482
4485
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4490,13 +4493,13 @@ function Da(e) {
|
|
|
4490
4493
|
},
|
|
4491
4494
|
async getActiveUsers(t) {
|
|
4492
4495
|
let n = /* @__PURE__ */ new Date();
|
|
4493
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4496
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", Ta).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4494
4497
|
}
|
|
4495
4498
|
};
|
|
4496
4499
|
}
|
|
4497
4500
|
//#endregion
|
|
4498
4501
|
//#region src/analytics/index.ts
|
|
4499
|
-
var
|
|
4502
|
+
var Aa = {
|
|
4500
4503
|
"active-users": ["s", "seacft"],
|
|
4501
4504
|
logins: [
|
|
4502
4505
|
"s",
|
|
@@ -4526,7 +4529,7 @@ var Oa = {
|
|
|
4526
4529
|
"fvr"
|
|
4527
4530
|
],
|
|
4528
4531
|
"codes-sent": ["cls", "cs"]
|
|
4529
|
-
},
|
|
4532
|
+
}, ja = {
|
|
4530
4533
|
"active-users": {
|
|
4531
4534
|
alias: "active_users",
|
|
4532
4535
|
type: "UInt64",
|
|
@@ -4583,7 +4586,7 @@ var Oa = {
|
|
|
4583
4586
|
agg: "count"
|
|
4584
4587
|
}
|
|
4585
4588
|
};
|
|
4586
|
-
async function
|
|
4589
|
+
async function Ma(e) {
|
|
4587
4590
|
try {
|
|
4588
4591
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4589
4592
|
} catch {
|
|
@@ -4605,7 +4608,7 @@ function U(e, t) {
|
|
|
4605
4608
|
let i = r.hour === "24" ? "00" : r.hour, a = Date.UTC(Number(r.year), Number(r.month) - 1, Number(r.day), Number(i), Number(r.minute), Number(r.second)), o = Math.round((a - t.getTime()) / 6e4), s = o >= 0 ? "+" : "-", c = Math.abs(o);
|
|
4606
4609
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4607
4610
|
}
|
|
4608
|
-
var
|
|
4611
|
+
var Na = [
|
|
4609
4612
|
"January",
|
|
4610
4613
|
"February",
|
|
4611
4614
|
"March",
|
|
@@ -4619,22 +4622,22 @@ var ja = [
|
|
|
4619
4622
|
"November",
|
|
4620
4623
|
"December"
|
|
4621
4624
|
];
|
|
4622
|
-
function
|
|
4625
|
+
function Pa(e, t) {
|
|
4623
4626
|
let n = t.getUTCFullYear(), r = U(e, new Date(Date.UTC(n, 0, 1)));
|
|
4624
4627
|
for (let t = 1; t < 12; t++) {
|
|
4625
4628
|
let i = U(e, new Date(Date.UTC(n, t, 1)));
|
|
4626
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4629
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Na[t]}) and cannot be bucketed with a single fixed offset by the SQL analytics adapter. Use a fixed-offset zone (e.g. 'UTC' or '+02:00').`);
|
|
4627
4630
|
}
|
|
4628
4631
|
}
|
|
4629
|
-
function
|
|
4632
|
+
function Fa(e) {
|
|
4630
4633
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4631
4634
|
return t * (Number(n) * 60 + Number(r));
|
|
4632
4635
|
}
|
|
4633
|
-
function
|
|
4636
|
+
function Ia(e, t) {
|
|
4634
4637
|
let n;
|
|
4635
4638
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4636
4639
|
else {
|
|
4637
|
-
let e =
|
|
4640
|
+
let e = Fa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4638
4641
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4639
4642
|
}
|
|
4640
4643
|
switch (e) {
|
|
@@ -4645,7 +4648,7 @@ function Pa(e, t) {
|
|
|
4645
4648
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4646
4649
|
}
|
|
4647
4650
|
}
|
|
4648
|
-
function
|
|
4651
|
+
function La(e, t) {
|
|
4649
4652
|
if (t === "+00:00") switch (e) {
|
|
4650
4653
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4651
4654
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4656,7 +4659,7 @@ function Fa(e, t) {
|
|
|
4656
4659
|
}
|
|
4657
4660
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4658
4661
|
}
|
|
4659
|
-
let n =
|
|
4662
|
+
let n = Fa(t), r = f`date_add(str_to_date(substring(${f.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${f.lit(n)} minute)`;
|
|
4660
4663
|
switch (e) {
|
|
4661
4664
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4662
4665
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4665,12 +4668,12 @@ function Fa(e, t) {
|
|
|
4665
4668
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4666
4669
|
}
|
|
4667
4670
|
}
|
|
4668
|
-
function
|
|
4669
|
-
|
|
4671
|
+
function Ra(e, t, n, r) {
|
|
4672
|
+
Pa(t, n);
|
|
4670
4673
|
let i = U(t, n);
|
|
4671
|
-
return r === "mysql" ?
|
|
4674
|
+
return r === "mysql" ? La(e, i) : Ia(e, i);
|
|
4672
4675
|
}
|
|
4673
|
-
function
|
|
4676
|
+
function za(e) {
|
|
4674
4677
|
switch (e) {
|
|
4675
4678
|
case "connection": return "logs.connection";
|
|
4676
4679
|
case "client_id": return "logs.client_id";
|
|
@@ -4679,15 +4682,15 @@ function La(e) {
|
|
|
4679
4682
|
case "time": throw Error("time dimension is handled separately");
|
|
4680
4683
|
}
|
|
4681
4684
|
}
|
|
4682
|
-
function
|
|
4683
|
-
let t = null, n = () => (t ||=
|
|
4685
|
+
function Ba(e) {
|
|
4686
|
+
let t = null, n = () => (t ||= Ma(e), t);
|
|
4684
4687
|
return {
|
|
4685
4688
|
async query(t, r, i) {
|
|
4686
|
-
let a = Date.now(), o =
|
|
4689
|
+
let a = Date.now(), o = Aa[r], s = ja[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4687
4690
|
u = u.where("date", ">=", i.from).where("date", "<", i.to), u = u.where("type", "in", o), i.filters.connection?.length && (u = u.where("connection", "in", i.filters.connection)), i.filters.client_id?.length && (u = u.where("client_id", "in", i.filters.client_id)), i.filters.user_type?.length && (u = u.where("strategy_type", "in", i.filters.user_type)), i.filters.user_id?.length && (u = u.where("user_id", "in", i.filters.user_id));
|
|
4688
4691
|
let d = [], p = [];
|
|
4689
4692
|
for (let e of i.group_by) if (e === "time") {
|
|
4690
|
-
let e =
|
|
4693
|
+
let e = Ra(i.interval, i.tz, new Date(i.from), c);
|
|
4691
4694
|
p.push({
|
|
4692
4695
|
alias: "time",
|
|
4693
4696
|
expr: e
|
|
@@ -4696,7 +4699,7 @@ function Ra(e) {
|
|
|
4696
4699
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4697
4700
|
});
|
|
4698
4701
|
} else {
|
|
4699
|
-
let t =
|
|
4702
|
+
let t = za(e);
|
|
4700
4703
|
p.push({
|
|
4701
4704
|
alias: e,
|
|
4702
4705
|
expr: f`${f.ref(t)}`
|
|
@@ -4771,7 +4774,7 @@ function Ra(e) {
|
|
|
4771
4774
|
}
|
|
4772
4775
|
//#endregion
|
|
4773
4776
|
//#region src/customText/index.ts
|
|
4774
|
-
function
|
|
4777
|
+
function Va(e) {
|
|
4775
4778
|
return {
|
|
4776
4779
|
async get(t, n, r) {
|
|
4777
4780
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4810,9 +4813,9 @@ function za(e) {
|
|
|
4810
4813
|
}
|
|
4811
4814
|
//#endregion
|
|
4812
4815
|
//#region src/authenticationMethods/create.ts
|
|
4813
|
-
function
|
|
4816
|
+
function Ha(e) {
|
|
4814
4817
|
return async (t, n, r) => {
|
|
4815
|
-
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 ??
|
|
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 ?? zr();
|
|
4816
4819
|
return await e.insertInto("authentication_methods").values({
|
|
4817
4820
|
id: s,
|
|
4818
4821
|
tenant_id: t,
|
|
@@ -4849,7 +4852,7 @@ function Ba(e) {
|
|
|
4849
4852
|
}
|
|
4850
4853
|
//#endregion
|
|
4851
4854
|
//#region src/authenticationMethods/get.ts
|
|
4852
|
-
function
|
|
4855
|
+
function Ua(e) {
|
|
4853
4856
|
return async (t, n) => {
|
|
4854
4857
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4855
4858
|
return r ? {
|
|
@@ -4872,7 +4875,7 @@ function Va(e) {
|
|
|
4872
4875
|
}
|
|
4873
4876
|
//#endregion
|
|
4874
4877
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4875
|
-
function
|
|
4878
|
+
function Wa(e) {
|
|
4876
4879
|
return async (t, n) => {
|
|
4877
4880
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4878
4881
|
return r ? {
|
|
@@ -4895,7 +4898,7 @@ function Ha(e) {
|
|
|
4895
4898
|
}
|
|
4896
4899
|
//#endregion
|
|
4897
4900
|
//#region src/authenticationMethods/list.ts
|
|
4898
|
-
function
|
|
4901
|
+
function Ga(e) {
|
|
4899
4902
|
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) => ({
|
|
4900
4903
|
id: e.id,
|
|
4901
4904
|
user_id: e.user_id,
|
|
@@ -4915,35 +4918,35 @@ function Ua(e) {
|
|
|
4915
4918
|
}
|
|
4916
4919
|
//#endregion
|
|
4917
4920
|
//#region src/authenticationMethods/update.ts
|
|
4918
|
-
function
|
|
4921
|
+
function Ka(e) {
|
|
4919
4922
|
return async (t, n, r) => {
|
|
4920
4923
|
let i = { updated_at_ts: Date.now() };
|
|
4921
4924
|
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();
|
|
4922
|
-
let a = await
|
|
4925
|
+
let a = await Ua(e)(t, n);
|
|
4923
4926
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4924
4927
|
return a;
|
|
4925
4928
|
};
|
|
4926
4929
|
}
|
|
4927
4930
|
//#endregion
|
|
4928
4931
|
//#region src/authenticationMethods/remove.ts
|
|
4929
|
-
function
|
|
4932
|
+
function qa(e) {
|
|
4930
4933
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4931
4934
|
}
|
|
4932
4935
|
//#endregion
|
|
4933
4936
|
//#region src/authenticationMethods/index.ts
|
|
4934
|
-
function
|
|
4937
|
+
function Ja(e) {
|
|
4935
4938
|
return {
|
|
4936
|
-
create:
|
|
4937
|
-
get:
|
|
4938
|
-
getByCredentialId:
|
|
4939
|
-
list:
|
|
4940
|
-
update:
|
|
4941
|
-
remove:
|
|
4939
|
+
create: Ha(e),
|
|
4940
|
+
get: Ua(e),
|
|
4941
|
+
getByCredentialId: Wa(e),
|
|
4942
|
+
list: Ga(e),
|
|
4943
|
+
update: Ka(e),
|
|
4944
|
+
remove: qa(e)
|
|
4942
4945
|
};
|
|
4943
4946
|
}
|
|
4944
4947
|
//#endregion
|
|
4945
4948
|
//#region src/outbox/getByIds.ts
|
|
4946
|
-
function
|
|
4949
|
+
function Ya(e) {
|
|
4947
4950
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4948
4951
|
...JSON.parse(e.payload),
|
|
4949
4952
|
id: e.id,
|
|
@@ -4956,7 +4959,7 @@ function qa(e) {
|
|
|
4956
4959
|
}
|
|
4957
4960
|
//#endregion
|
|
4958
4961
|
//#region src/outbox/getUnprocessed.ts
|
|
4959
|
-
function
|
|
4962
|
+
function Xa(e) {
|
|
4960
4963
|
return async (t) => {
|
|
4961
4964
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4962
4965
|
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) => ({
|
|
@@ -4972,7 +4975,7 @@ function Ja(e) {
|
|
|
4972
4975
|
}
|
|
4973
4976
|
//#endregion
|
|
4974
4977
|
//#region src/outbox/claimEvents.ts
|
|
4975
|
-
function
|
|
4978
|
+
function Za(e) {
|
|
4976
4979
|
return async (t, n, r) => {
|
|
4977
4980
|
if (t.length === 0) return [];
|
|
4978
4981
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4984,7 +4987,7 @@ function Ya(e) {
|
|
|
4984
4987
|
}
|
|
4985
4988
|
//#endregion
|
|
4986
4989
|
//#region src/outbox/markProcessed.ts
|
|
4987
|
-
function
|
|
4990
|
+
function Qa(e) {
|
|
4988
4991
|
return async (t) => {
|
|
4989
4992
|
if (t.length === 0) return;
|
|
4990
4993
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4993,7 +4996,7 @@ function Xa(e) {
|
|
|
4993
4996
|
}
|
|
4994
4997
|
//#endregion
|
|
4995
4998
|
//#region src/outbox/markRetry.ts
|
|
4996
|
-
function
|
|
4999
|
+
function $a(e) {
|
|
4997
5000
|
return async (t, n, r) => {
|
|
4998
5001
|
await e.updateTable("outbox_events").set({
|
|
4999
5002
|
error: n,
|
|
@@ -5006,7 +5009,7 @@ function Za(e) {
|
|
|
5006
5009
|
}
|
|
5007
5010
|
//#endregion
|
|
5008
5011
|
//#region src/outbox/deadLetter.ts
|
|
5009
|
-
function
|
|
5012
|
+
function eo(e) {
|
|
5010
5013
|
return async (t, n) => {
|
|
5011
5014
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5012
5015
|
await e.updateTable("outbox_events").set({
|
|
@@ -5018,7 +5021,7 @@ function Qa(e) {
|
|
|
5018
5021
|
}
|
|
5019
5022
|
//#endregion
|
|
5020
5023
|
//#region src/outbox/listFailed.ts
|
|
5021
|
-
function
|
|
5024
|
+
function to(e) {
|
|
5022
5025
|
return async (t, n = {}) => {
|
|
5023
5026
|
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) => {
|
|
5024
5027
|
let t;
|
|
@@ -5053,7 +5056,7 @@ function $a(e) {
|
|
|
5053
5056
|
}
|
|
5054
5057
|
//#endregion
|
|
5055
5058
|
//#region src/outbox/replay.ts
|
|
5056
|
-
function
|
|
5059
|
+
function no(e) {
|
|
5057
5060
|
return async (t, n) => {
|
|
5058
5061
|
let r = await e.updateTable("outbox_events").set({
|
|
5059
5062
|
processed_at: null,
|
|
@@ -5070,7 +5073,7 @@ function eo(e) {
|
|
|
5070
5073
|
}
|
|
5071
5074
|
//#endregion
|
|
5072
5075
|
//#region src/outbox/cleanup.ts
|
|
5073
|
-
function
|
|
5076
|
+
function ro(e) {
|
|
5074
5077
|
return async (t) => {
|
|
5075
5078
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5076
5079
|
return Number(n.numDeletedRows);
|
|
@@ -5078,18 +5081,18 @@ function to(e) {
|
|
|
5078
5081
|
}
|
|
5079
5082
|
//#endregion
|
|
5080
5083
|
//#region src/outbox/index.ts
|
|
5081
|
-
function
|
|
5084
|
+
function io(e) {
|
|
5082
5085
|
return {
|
|
5083
|
-
create:
|
|
5084
|
-
getByIds:
|
|
5085
|
-
getUnprocessed:
|
|
5086
|
-
claimEvents:
|
|
5087
|
-
markProcessed:
|
|
5088
|
-
markRetry:
|
|
5089
|
-
deadLetter:
|
|
5090
|
-
listFailed:
|
|
5091
|
-
replay:
|
|
5092
|
-
cleanup:
|
|
5086
|
+
create: rt(e),
|
|
5087
|
+
getByIds: Ya(e),
|
|
5088
|
+
getUnprocessed: Xa(e),
|
|
5089
|
+
claimEvents: Za(e),
|
|
5090
|
+
markProcessed: Qa(e),
|
|
5091
|
+
markRetry: $a(e),
|
|
5092
|
+
deadLetter: eo(e),
|
|
5093
|
+
listFailed: to(e),
|
|
5094
|
+
replay: no(e),
|
|
5095
|
+
cleanup: ro(e)
|
|
5093
5096
|
};
|
|
5094
5097
|
}
|
|
5095
5098
|
//#endregion
|
|
@@ -5107,7 +5110,7 @@ function W(e) {
|
|
|
5107
5110
|
updated_at: e.updated_at
|
|
5108
5111
|
};
|
|
5109
5112
|
}
|
|
5110
|
-
function
|
|
5113
|
+
function ao(e) {
|
|
5111
5114
|
return {
|
|
5112
5115
|
async create(n, r, i) {
|
|
5113
5116
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5154,7 +5157,7 @@ function G(e) {
|
|
|
5154
5157
|
updated_at: e.updated_at
|
|
5155
5158
|
};
|
|
5156
5159
|
}
|
|
5157
|
-
function
|
|
5160
|
+
function oo(e) {
|
|
5158
5161
|
return {
|
|
5159
5162
|
async create(n, r, i) {
|
|
5160
5163
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5194,13 +5197,13 @@ function K(e) {
|
|
|
5194
5197
|
tenant_id: e.tenant_id,
|
|
5195
5198
|
custom_domain_id: e.custom_domain_id,
|
|
5196
5199
|
priority: e.priority,
|
|
5197
|
-
match:
|
|
5198
|
-
handlers:
|
|
5200
|
+
match: so(e.match),
|
|
5201
|
+
handlers: co(e.handlers),
|
|
5199
5202
|
created_at: e.created_at,
|
|
5200
5203
|
updated_at: e.updated_at
|
|
5201
5204
|
};
|
|
5202
5205
|
}
|
|
5203
|
-
function
|
|
5206
|
+
function so(e) {
|
|
5204
5207
|
if (!e) return { path: "/*" };
|
|
5205
5208
|
try {
|
|
5206
5209
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5208,7 +5211,7 @@ function ao(e) {
|
|
|
5208
5211
|
} catch {}
|
|
5209
5212
|
return { path: "/*" };
|
|
5210
5213
|
}
|
|
5211
|
-
function
|
|
5214
|
+
function co(e) {
|
|
5212
5215
|
if (!e) return [];
|
|
5213
5216
|
try {
|
|
5214
5217
|
let t = JSON.parse(e);
|
|
@@ -5278,7 +5281,7 @@ function q(e) {
|
|
|
5278
5281
|
}
|
|
5279
5282
|
//#endregion
|
|
5280
5283
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5281
|
-
async function
|
|
5284
|
+
async function lo(e, t) {
|
|
5282
5285
|
let n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n), i = (r.endsWith(".") ? r.slice(0, -1) : r).toLowerCase(), a = await e.selectFrom("custom_domains").where("domain", "=", i).select([
|
|
5283
5286
|
"custom_domain_id",
|
|
5284
5287
|
"tenant_id",
|
|
@@ -5295,15 +5298,15 @@ async function so(e, t) {
|
|
|
5295
5298
|
}
|
|
5296
5299
|
//#endregion
|
|
5297
5300
|
//#region src/proxyRoutes/index.ts
|
|
5298
|
-
function
|
|
5301
|
+
function uo(e) {
|
|
5299
5302
|
return {
|
|
5300
5303
|
proxyRoutes: q(e),
|
|
5301
|
-
resolveHost: (t) =>
|
|
5304
|
+
resolveHost: (t) => lo(e, t)
|
|
5302
5305
|
};
|
|
5303
5306
|
}
|
|
5304
5307
|
//#endregion
|
|
5305
5308
|
//#region src/scim/adapter.ts
|
|
5306
|
-
function
|
|
5309
|
+
function fo(e) {
|
|
5307
5310
|
if (!e) return [];
|
|
5308
5311
|
try {
|
|
5309
5312
|
let t = JSON.parse(e);
|
|
@@ -5318,7 +5321,7 @@ function lo(e) {
|
|
|
5318
5321
|
return [];
|
|
5319
5322
|
}
|
|
5320
5323
|
}
|
|
5321
|
-
function
|
|
5324
|
+
function po(e) {
|
|
5322
5325
|
if (!e) return [];
|
|
5323
5326
|
try {
|
|
5324
5327
|
let t = JSON.parse(e);
|
|
@@ -5327,16 +5330,16 @@ function uo(e) {
|
|
|
5327
5330
|
return [];
|
|
5328
5331
|
}
|
|
5329
5332
|
}
|
|
5330
|
-
function
|
|
5333
|
+
function mo(e) {
|
|
5331
5334
|
return {
|
|
5332
5335
|
connection_id: e.connection_id,
|
|
5333
5336
|
user_id_attribute: e.user_id_attribute,
|
|
5334
|
-
mapping:
|
|
5337
|
+
mapping: fo(e.mapping),
|
|
5335
5338
|
created_at: e.created_at,
|
|
5336
5339
|
updated_at: e.updated_at
|
|
5337
5340
|
};
|
|
5338
5341
|
}
|
|
5339
|
-
function
|
|
5342
|
+
function ho(e) {
|
|
5340
5343
|
return {
|
|
5341
5344
|
async create(t, n) {
|
|
5342
5345
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5357,7 +5360,7 @@ function po(e) {
|
|
|
5357
5360
|
},
|
|
5358
5361
|
async get(t, n) {
|
|
5359
5362
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5360
|
-
return r ?
|
|
5363
|
+
return r ? mo(r) : null;
|
|
5361
5364
|
},
|
|
5362
5365
|
async update(t, n, r) {
|
|
5363
5366
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5371,18 +5374,18 @@ function po(e) {
|
|
|
5371
5374
|
}
|
|
5372
5375
|
};
|
|
5373
5376
|
}
|
|
5374
|
-
function
|
|
5377
|
+
function go(e) {
|
|
5375
5378
|
return {
|
|
5376
5379
|
token_id: e.token_id,
|
|
5377
5380
|
connection_id: e.connection_id,
|
|
5378
5381
|
token_hash: e.token_hash,
|
|
5379
|
-
scopes:
|
|
5382
|
+
scopes: po(e.scopes),
|
|
5380
5383
|
valid_until: e.valid_until ?? void 0,
|
|
5381
5384
|
created_at: e.created_at,
|
|
5382
5385
|
last_used_at: e.last_used_at ?? void 0
|
|
5383
5386
|
};
|
|
5384
5387
|
}
|
|
5385
|
-
function
|
|
5388
|
+
function _o(e) {
|
|
5386
5389
|
return {
|
|
5387
5390
|
async create(t, n) {
|
|
5388
5391
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5406,14 +5409,14 @@ function mo(e) {
|
|
|
5406
5409
|
},
|
|
5407
5410
|
async get(t, n) {
|
|
5408
5411
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5409
|
-
return r ?
|
|
5412
|
+
return r ? go(r) : null;
|
|
5410
5413
|
},
|
|
5411
5414
|
async getByHash(t, n) {
|
|
5412
5415
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5413
|
-
return r ?
|
|
5416
|
+
return r ? go(r) : null;
|
|
5414
5417
|
},
|
|
5415
5418
|
async listByConnection(t, n) {
|
|
5416
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5419
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(go);
|
|
5417
5420
|
},
|
|
5418
5421
|
async markUsed(t, n, r) {
|
|
5419
5422
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5425,7 +5428,7 @@ function mo(e) {
|
|
|
5425
5428
|
}
|
|
5426
5429
|
};
|
|
5427
5430
|
}
|
|
5428
|
-
function
|
|
5431
|
+
function vo(e) {
|
|
5429
5432
|
return {
|
|
5430
5433
|
connection_id: e.connection_id,
|
|
5431
5434
|
external_id: e.external_id,
|
|
@@ -5433,7 +5436,7 @@ function ho(e) {
|
|
|
5433
5436
|
created_at: e.created_at
|
|
5434
5437
|
};
|
|
5435
5438
|
}
|
|
5436
|
-
function
|
|
5439
|
+
function yo(e) {
|
|
5437
5440
|
return {
|
|
5438
5441
|
async create(t, n) {
|
|
5439
5442
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5452,11 +5455,11 @@ function go(e) {
|
|
|
5452
5455
|
},
|
|
5453
5456
|
async getByExternalId(t, n, r) {
|
|
5454
5457
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5455
|
-
return i ?
|
|
5458
|
+
return i ? vo(i) : null;
|
|
5456
5459
|
},
|
|
5457
5460
|
async getByUserId(t, n, r) {
|
|
5458
5461
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5459
|
-
return i ?
|
|
5462
|
+
return i ? vo(i) : null;
|
|
5460
5463
|
},
|
|
5461
5464
|
async remove(t, n, r) {
|
|
5462
5465
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5466,8 +5469,16 @@ function go(e) {
|
|
|
5466
5469
|
}
|
|
5467
5470
|
//#endregion
|
|
5468
5471
|
//#region src/tenantOperations/index.ts
|
|
5469
|
-
function
|
|
5470
|
-
return
|
|
5472
|
+
function bo(e) {
|
|
5473
|
+
if (!e) return null;
|
|
5474
|
+
try {
|
|
5475
|
+
let t = JSON.parse(e);
|
|
5476
|
+
if (t && typeof t == "object" && !Array.isArray(t)) return Object.fromEntries(Object.entries(t));
|
|
5477
|
+
} catch {}
|
|
5478
|
+
return null;
|
|
5479
|
+
}
|
|
5480
|
+
function J(e) {
|
|
5481
|
+
return Se.parse({
|
|
5471
5482
|
id: e.id,
|
|
5472
5483
|
tenant_id: e.tenant_id,
|
|
5473
5484
|
rollout_id: e.rollout_id,
|
|
@@ -5480,12 +5491,16 @@ function Y(e) {
|
|
|
5480
5491
|
target_database_version: e.target_database_version,
|
|
5481
5492
|
error: e.error,
|
|
5482
5493
|
initiated_by: e.initiated_by,
|
|
5494
|
+
input: bo(e.input),
|
|
5495
|
+
result: bo(e.result),
|
|
5496
|
+
claimed_by: e.claimed_by,
|
|
5497
|
+
claim_expires_at: e.claim_expires_at,
|
|
5483
5498
|
created_at: e.created_at,
|
|
5484
5499
|
updated_at: e.updated_at,
|
|
5485
5500
|
finished_at: e.finished_at
|
|
5486
5501
|
});
|
|
5487
5502
|
}
|
|
5488
|
-
function
|
|
5503
|
+
function xo(e) {
|
|
5489
5504
|
return {
|
|
5490
5505
|
async create(n) {
|
|
5491
5506
|
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5501,15 +5516,19 @@ function _o(e) {
|
|
|
5501
5516
|
target_database_version: r.target_database_version ?? null,
|
|
5502
5517
|
error: null,
|
|
5503
5518
|
initiated_by: r.initiated_by ?? null,
|
|
5519
|
+
input: r.input ? JSON.stringify(r.input) : null,
|
|
5520
|
+
result: null,
|
|
5521
|
+
claimed_by: null,
|
|
5522
|
+
claim_expires_at: null,
|
|
5504
5523
|
created_at: i,
|
|
5505
5524
|
updated_at: i,
|
|
5506
5525
|
finished_at: null
|
|
5507
5526
|
};
|
|
5508
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5527
|
+
return await e.insertInto("tenant_operations").values(a).execute(), J(a);
|
|
5509
5528
|
},
|
|
5510
5529
|
async get(t) {
|
|
5511
5530
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5512
|
-
return n ?
|
|
5531
|
+
return n ? J(n) : null;
|
|
5513
5532
|
},
|
|
5514
5533
|
async list(t = {}) {
|
|
5515
5534
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5520,7 +5539,7 @@ function _o(e) {
|
|
|
5520
5539
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5521
5540
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5522
5541
|
return {
|
|
5523
|
-
operations: a.map(
|
|
5542
|
+
operations: a.map(J),
|
|
5524
5543
|
start: n * r,
|
|
5525
5544
|
limit: r,
|
|
5526
5545
|
length: a.length
|
|
@@ -5528,10 +5547,34 @@ function _o(e) {
|
|
|
5528
5547
|
},
|
|
5529
5548
|
async update(t, n) {
|
|
5530
5549
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5531
|
-
n.status !== void 0 && (r.status = n.status), n.current_step !== void 0 && (r.current_step = n.current_step), n.engine_instance_id !== void 0 && (r.engine_instance_id = n.engine_instance_id), n.target_worker_version !== void 0 && (r.target_worker_version = n.target_worker_version), n.target_database_version !== void 0 && (r.target_database_version = n.target_database_version), n.error !== void 0 && (r.error = n.error), n.finished_at !== void 0 && (r.finished_at = n.finished_at);
|
|
5550
|
+
n.status !== void 0 && (r.status = n.status), n.current_step !== void 0 && (r.current_step = n.current_step), n.engine_instance_id !== void 0 && (r.engine_instance_id = n.engine_instance_id), n.target_worker_version !== void 0 && (r.target_worker_version = n.target_worker_version), n.target_database_version !== void 0 && (r.target_database_version = n.target_database_version), n.error !== void 0 && (r.error = n.error), n.result !== void 0 && (r.result = n.result ? JSON.stringify(n.result) : null), n.claimed_by !== void 0 && (r.claimed_by = n.claimed_by), n.claim_expires_at !== void 0 && (r.claim_expires_at = n.claim_expires_at), n.finished_at !== void 0 && (r.finished_at = n.finished_at);
|
|
5532
5551
|
let i = await e.updateTable("tenant_operations").where("id", "=", t).set(r).executeTakeFirst();
|
|
5533
5552
|
return Number(i.numUpdatedRows) > 0;
|
|
5534
5553
|
},
|
|
5554
|
+
async claim(t, n, r) {
|
|
5555
|
+
let i = /* @__PURE__ */ new Date(), a = i.toISOString(), o = new Date(i.getTime() + r).toISOString();
|
|
5556
|
+
return await e.updateTable("tenant_operations").where("id", "=", t).where((e) => e.or([
|
|
5557
|
+
e("claimed_by", "is", null),
|
|
5558
|
+
e("claim_expires_at", "<=", a),
|
|
5559
|
+
e("claimed_by", "=", n)
|
|
5560
|
+
])).set({
|
|
5561
|
+
claimed_by: n,
|
|
5562
|
+
claim_expires_at: o,
|
|
5563
|
+
updated_at: a
|
|
5564
|
+
}).executeTakeFirst(), (await e.selectFrom("tenant_operations").where("id", "=", t).select(["claimed_by"]).executeTakeFirst())?.claimed_by === n;
|
|
5565
|
+
},
|
|
5566
|
+
async release(t, n) {
|
|
5567
|
+
let r = await e.updateTable("tenant_operations").where("id", "=", t).where("claimed_by", "=", n).set({
|
|
5568
|
+
claimed_by: null,
|
|
5569
|
+
claim_expires_at: null,
|
|
5570
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5571
|
+
}).executeTakeFirst();
|
|
5572
|
+
return Number(r.numUpdatedRows) > 0;
|
|
5573
|
+
},
|
|
5574
|
+
async listResumable(t) {
|
|
5575
|
+
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
5576
|
+
return (await e.selectFrom("tenant_operations").where("kind", "=", t.kind).where("status", "in", ["pending", "running"]).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").limit(t.limit).execute()).map(J);
|
|
5577
|
+
},
|
|
5535
5578
|
async remove(t) {
|
|
5536
5579
|
let n = await e.deleteFrom("tenant_operations").where("id", "=", t).executeTakeFirst();
|
|
5537
5580
|
return Number(n.numDeletedRows) > 0;
|
|
@@ -5540,27 +5583,27 @@ function _o(e) {
|
|
|
5540
5583
|
}
|
|
5541
5584
|
//#endregion
|
|
5542
5585
|
//#region src/utils/monotonic-id.ts
|
|
5543
|
-
var
|
|
5544
|
-
function
|
|
5586
|
+
var So = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Co = 32, wo = 10, To = 4, Eo = 10;
|
|
5587
|
+
function Do(e, t) {
|
|
5545
5588
|
let n = "";
|
|
5546
|
-
for (let r = t; r > 0; r--) n =
|
|
5589
|
+
for (let r = t; r > 0; r--) n = So.charAt(e % Co) + n, e = Math.floor(e / Co);
|
|
5547
5590
|
return n;
|
|
5548
5591
|
}
|
|
5549
|
-
function
|
|
5550
|
-
let e = new Uint8Array(
|
|
5592
|
+
function Oo() {
|
|
5593
|
+
let e = new Uint8Array(Eo);
|
|
5551
5594
|
crypto.getRandomValues(e);
|
|
5552
5595
|
let t = "";
|
|
5553
|
-
for (let n = 0; n <
|
|
5596
|
+
for (let n = 0; n < Eo; n++) t += So.charAt(e[n] % Co);
|
|
5554
5597
|
return t;
|
|
5555
5598
|
}
|
|
5556
|
-
var
|
|
5557
|
-
function
|
|
5599
|
+
var ko = 0, Ao = 0;
|
|
5600
|
+
function jo() {
|
|
5558
5601
|
let e = Date.now();
|
|
5559
|
-
return e ===
|
|
5602
|
+
return e === ko ? Ao++ : (ko = e, Ao = 0), Do(e, wo) + Do(Ao, To) + Oo();
|
|
5560
5603
|
}
|
|
5561
5604
|
//#endregion
|
|
5562
5605
|
//#region src/tenantOperationEvents/index.ts
|
|
5563
|
-
function
|
|
5606
|
+
function Mo(e) {
|
|
5564
5607
|
if (!e) return null;
|
|
5565
5608
|
try {
|
|
5566
5609
|
let t = JSON.parse(e);
|
|
@@ -5568,22 +5611,22 @@ function Do(e) {
|
|
|
5568
5611
|
} catch {}
|
|
5569
5612
|
return null;
|
|
5570
5613
|
}
|
|
5571
|
-
function
|
|
5614
|
+
function No(e) {
|
|
5572
5615
|
return ve.parse({
|
|
5573
5616
|
id: e.id,
|
|
5574
5617
|
operation_id: e.operation_id,
|
|
5575
5618
|
step: e.step,
|
|
5576
5619
|
outcome: e.outcome,
|
|
5577
|
-
detail:
|
|
5620
|
+
detail: Mo(e.detail),
|
|
5578
5621
|
attempt: e.attempt,
|
|
5579
5622
|
created_at: e.created_at
|
|
5580
5623
|
});
|
|
5581
5624
|
}
|
|
5582
|
-
function
|
|
5625
|
+
function Po(e) {
|
|
5583
5626
|
return {
|
|
5584
5627
|
async create(t) {
|
|
5585
5628
|
let n = _e.parse(t), r = {
|
|
5586
|
-
id: `evt_${
|
|
5629
|
+
id: `evt_${jo()}`,
|
|
5587
5630
|
operation_id: n.operation_id,
|
|
5588
5631
|
step: n.step,
|
|
5589
5632
|
outcome: n.outcome,
|
|
@@ -5591,12 +5634,12 @@ function ko(e) {
|
|
|
5591
5634
|
attempt: n.attempt,
|
|
5592
5635
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5593
5636
|
};
|
|
5594
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5637
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), No(r);
|
|
5595
5638
|
},
|
|
5596
5639
|
async listByOperation(t, n = {}) {
|
|
5597
5640
|
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();
|
|
5598
5641
|
return {
|
|
5599
|
-
events: a.map(
|
|
5642
|
+
events: a.map(No),
|
|
5600
5643
|
start: r * i,
|
|
5601
5644
|
limit: i,
|
|
5602
5645
|
length: a.length
|
|
@@ -5605,8 +5648,113 @@ function ko(e) {
|
|
|
5605
5648
|
};
|
|
5606
5649
|
}
|
|
5607
5650
|
//#endregion
|
|
5651
|
+
//#region src/tenantOperationRows/index.ts
|
|
5652
|
+
var Fo = 50;
|
|
5653
|
+
function Io(e) {
|
|
5654
|
+
let t = JSON.parse(e);
|
|
5655
|
+
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5656
|
+
}
|
|
5657
|
+
function Lo(e) {
|
|
5658
|
+
return xe.parse({
|
|
5659
|
+
operation_id: e.operation_id,
|
|
5660
|
+
seq: e.seq,
|
|
5661
|
+
payload: Io(e.payload),
|
|
5662
|
+
status: e.status,
|
|
5663
|
+
error_code: e.error_code,
|
|
5664
|
+
error_message: e.error_message,
|
|
5665
|
+
error_path: e.error_path,
|
|
5666
|
+
entity_id: e.entity_id,
|
|
5667
|
+
created_at: e.created_at,
|
|
5668
|
+
updated_at: e.updated_at
|
|
5669
|
+
});
|
|
5670
|
+
}
|
|
5671
|
+
function Ro(e) {
|
|
5672
|
+
return {
|
|
5673
|
+
async createMany(t) {
|
|
5674
|
+
if (t.length === 0) return 0;
|
|
5675
|
+
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.map((e) => {
|
|
5676
|
+
let t = be.parse(e);
|
|
5677
|
+
return {
|
|
5678
|
+
operation_id: t.operation_id,
|
|
5679
|
+
seq: t.seq,
|
|
5680
|
+
payload: JSON.stringify(t.payload),
|
|
5681
|
+
status: t.status,
|
|
5682
|
+
error_code: t.error_code ?? null,
|
|
5683
|
+
error_message: t.error_message ?? null,
|
|
5684
|
+
error_path: t.error_path ?? null,
|
|
5685
|
+
entity_id: t.entity_id ?? null,
|
|
5686
|
+
created_at: n,
|
|
5687
|
+
updated_at: n
|
|
5688
|
+
};
|
|
5689
|
+
});
|
|
5690
|
+
for (let t = 0; t < r.length; t += Fo) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + Fo)).execute();
|
|
5691
|
+
return r.length;
|
|
5692
|
+
},
|
|
5693
|
+
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(Lo);
|
|
5695
|
+
},
|
|
5696
|
+
async recordOutcomes(t, n) {
|
|
5697
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
5698
|
+
for (let a of n) {
|
|
5699
|
+
let n = await e.updateTable("tenant_operation_rows").where("operation_id", "=", t).where("seq", "=", a.seq).where("status", "=", "pending").set({
|
|
5700
|
+
status: a.status,
|
|
5701
|
+
error_code: a.error_code ?? null,
|
|
5702
|
+
error_message: a.error_message ?? null,
|
|
5703
|
+
error_path: a.error_path ?? null,
|
|
5704
|
+
entity_id: a.entity_id ?? null,
|
|
5705
|
+
updated_at: r
|
|
5706
|
+
}).executeTakeFirst();
|
|
5707
|
+
i += Number(n.numUpdatedRows);
|
|
5708
|
+
}
|
|
5709
|
+
return i;
|
|
5710
|
+
},
|
|
5711
|
+
async countByStatus(t) {
|
|
5712
|
+
let n = await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).select(({ fn: e }) => ["status", e.count("seq").as("count")]).groupBy("status").execute(), r = {
|
|
5713
|
+
total: 0,
|
|
5714
|
+
pending: 0,
|
|
5715
|
+
inserted: 0,
|
|
5716
|
+
updated: 0,
|
|
5717
|
+
failed: 0,
|
|
5718
|
+
skipped: 0
|
|
5719
|
+
};
|
|
5720
|
+
for (let e of n) {
|
|
5721
|
+
let t = Number(e.count);
|
|
5722
|
+
switch (r.total += t, e.status) {
|
|
5723
|
+
case "pending":
|
|
5724
|
+
case "inserted":
|
|
5725
|
+
case "updated":
|
|
5726
|
+
case "failed":
|
|
5727
|
+
case "skipped":
|
|
5728
|
+
r[e.status] += t;
|
|
5729
|
+
break;
|
|
5730
|
+
default: break;
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5733
|
+
return r;
|
|
5734
|
+
},
|
|
5735
|
+
async list(t, n = {}) {
|
|
5736
|
+
let r = n.page ?? 0, i = n.per_page ?? 100, a = e.selectFrom("tenant_operation_rows").where("operation_id", "=", t);
|
|
5737
|
+
if (n.status !== void 0) {
|
|
5738
|
+
let e = Array.isArray(n.status) ? n.status : [n.status];
|
|
5739
|
+
a = a.where("status", "in", e);
|
|
5740
|
+
}
|
|
5741
|
+
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5742
|
+
return {
|
|
5743
|
+
rows: o.map(Lo),
|
|
5744
|
+
start: r * i,
|
|
5745
|
+
limit: i,
|
|
5746
|
+
length: o.length
|
|
5747
|
+
};
|
|
5748
|
+
},
|
|
5749
|
+
async removeByOperation(t) {
|
|
5750
|
+
let n = await e.deleteFrom("tenant_operation_rows").where("operation_id", "=", t).executeTakeFirst();
|
|
5751
|
+
return Number(n.numDeletedRows);
|
|
5752
|
+
}
|
|
5753
|
+
};
|
|
5754
|
+
}
|
|
5755
|
+
//#endregion
|
|
5608
5756
|
//#region src/rollouts/index.ts
|
|
5609
|
-
function
|
|
5757
|
+
function zo(e) {
|
|
5610
5758
|
if (!e) return null;
|
|
5611
5759
|
try {
|
|
5612
5760
|
return JSON.parse(e);
|
|
@@ -5614,7 +5762,7 @@ function Ao(e) {
|
|
|
5614
5762
|
return null;
|
|
5615
5763
|
}
|
|
5616
5764
|
}
|
|
5617
|
-
function
|
|
5765
|
+
function Bo(e) {
|
|
5618
5766
|
return pe.parse({
|
|
5619
5767
|
id: e.id,
|
|
5620
5768
|
kind: e.kind,
|
|
@@ -5622,15 +5770,15 @@ function jo(e) {
|
|
|
5622
5770
|
target_worker_version: e.target_worker_version,
|
|
5623
5771
|
target_database_version: e.target_database_version,
|
|
5624
5772
|
wave_size: e.wave_size,
|
|
5625
|
-
canary_tenant_ids:
|
|
5626
|
-
filter:
|
|
5773
|
+
canary_tenant_ids: zo(e.canary_tenant_ids),
|
|
5774
|
+
filter: zo(e.filter),
|
|
5627
5775
|
initiated_by: e.initiated_by,
|
|
5628
5776
|
created_at: e.created_at,
|
|
5629
5777
|
updated_at: e.updated_at,
|
|
5630
5778
|
finished_at: e.finished_at
|
|
5631
5779
|
});
|
|
5632
5780
|
}
|
|
5633
|
-
function
|
|
5781
|
+
function Vo(e) {
|
|
5634
5782
|
return {
|
|
5635
5783
|
async create(n) {
|
|
5636
5784
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5647,16 +5795,16 @@ function Mo(e) {
|
|
|
5647
5795
|
updated_at: i,
|
|
5648
5796
|
finished_at: null
|
|
5649
5797
|
};
|
|
5650
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5798
|
+
return await e.insertInto("rollouts").values(a).execute(), Bo(a);
|
|
5651
5799
|
},
|
|
5652
5800
|
async get(t) {
|
|
5653
5801
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5654
|
-
return n ?
|
|
5802
|
+
return n ? Bo(n) : null;
|
|
5655
5803
|
},
|
|
5656
5804
|
async list(t = {}) {
|
|
5657
5805
|
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();
|
|
5658
5806
|
return {
|
|
5659
|
-
rollouts: i.map(
|
|
5807
|
+
rollouts: i.map(Bo),
|
|
5660
5808
|
start: n * r,
|
|
5661
5809
|
limit: r,
|
|
5662
5810
|
length: i.length
|
|
@@ -5676,7 +5824,7 @@ function Mo(e) {
|
|
|
5676
5824
|
}
|
|
5677
5825
|
//#endregion
|
|
5678
5826
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5679
|
-
var
|
|
5827
|
+
var Ho = class {
|
|
5680
5828
|
migrations;
|
|
5681
5829
|
constructor(e) {
|
|
5682
5830
|
this.migrations = e;
|
|
@@ -5684,10 +5832,10 @@ var No = class {
|
|
|
5684
5832
|
async getMigrations() {
|
|
5685
5833
|
return this.migrations;
|
|
5686
5834
|
}
|
|
5687
|
-
},
|
|
5688
|
-
down: () =>
|
|
5689
|
-
up: () =>
|
|
5690
|
-
}),
|
|
5835
|
+
}, Uo = /* @__PURE__ */ T({
|
|
5836
|
+
down: () => qo,
|
|
5837
|
+
up: () => Ko
|
|
5838
|
+
}), Wo = [
|
|
5691
5839
|
{
|
|
5692
5840
|
table: "authentication_methods",
|
|
5693
5841
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5953,47 +6101,47 @@ var No = class {
|
|
|
5953
6101
|
onDelete: "cascade"
|
|
5954
6102
|
}
|
|
5955
6103
|
];
|
|
5956
|
-
async function
|
|
6104
|
+
async function Go(e) {
|
|
5957
6105
|
try {
|
|
5958
6106
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5959
6107
|
} catch {
|
|
5960
6108
|
return !1;
|
|
5961
6109
|
}
|
|
5962
6110
|
}
|
|
5963
|
-
function
|
|
6111
|
+
function Y(e, t) {
|
|
5964
6112
|
let n = e;
|
|
5965
|
-
for (let e of
|
|
6113
|
+
for (let e of Wo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5966
6114
|
let n = t;
|
|
5967
6115
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5968
6116
|
}));
|
|
5969
6117
|
return n;
|
|
5970
6118
|
}
|
|
5971
|
-
async function
|
|
5972
|
-
let t = await
|
|
6119
|
+
async function Ko(e) {
|
|
6120
|
+
let t = await Go(e);
|
|
5973
6121
|
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();
|
|
5974
6122
|
{
|
|
5975
6123
|
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"]);
|
|
5976
|
-
t && (n =
|
|
6124
|
+
t && (n = Y(n, "authentication_methods")), await n.execute();
|
|
5977
6125
|
}
|
|
5978
6126
|
{
|
|
5979
6127
|
let n = e.schema.createTable("branding").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("logo_url", f`varchar(512)`).addColumn("favicon_url", f`varchar(512)`).addColumn("font_url", f`varchar(512)`).addColumn("colors_primary", f`varchar(8)`).addColumn("colors_page_background_type", f`varchar(32)`).addColumn("colors_page_background_start", f`varchar(8)`).addColumn("colors_page_background_end", f`varchar(8)`).addColumn("colors_page_background_angle_dev", f`int`).addColumn("dark_mode", f`varchar(8)`).addPrimaryKeyConstraint("branding_pk", ["tenant_id"]);
|
|
5980
|
-
t && (n =
|
|
6128
|
+
t && (n = Y(n, "branding")), await n.execute();
|
|
5981
6129
|
}
|
|
5982
6130
|
{
|
|
5983
6131
|
let n = e.schema.createTable("clients").addColumn("client_id", f`varchar(191)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("description", f`varchar(140)`).addColumn("global", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("client_secret", f`varchar(255)`).addColumn("app_type", f`varchar(64)`, (e) => e.defaultTo("regular_web")).addColumn("logo_uri", f`varchar(2083)`).addColumn("is_first_party", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("oidc_conformant", f`int`, (e) => e.notNull().defaultTo(1)).addColumn("callbacks", f`text`, (e) => e.notNull()).addColumn("allowed_origins", f`text`, (e) => e.notNull()).addColumn("web_origins", f`text`, (e) => e.notNull()).addColumn("client_aliases", f`text`, (e) => e.notNull()).addColumn("allowed_clients", f`text`, (e) => e.notNull()).addColumn("allowed_logout_urls", f`text`, (e) => e.notNull()).addColumn("session_transfer", f`text`, (e) => e.notNull()).addColumn("oidc_logout", f`text`, (e) => e.notNull()).addColumn("grant_types", f`text`, (e) => e.notNull()).addColumn("jwt_configuration", f`text`, (e) => e.notNull()).addColumn("signing_keys", f`text`, (e) => e.notNull()).addColumn("encryption_key", f`text`, (e) => e.notNull()).addColumn("sso", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("sso_disabled", f`int`, (e) => e.notNull().defaultTo(1)).addColumn("cross_origin_authentication", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("cross_origin_loc", f`varchar(2083)`).addColumn("custom_login_page_on", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("custom_login_page", f`text`).addColumn("custom_login_page_preview", f`text`).addColumn("form_template", f`text`).addColumn("addons", f`text`, (e) => e.notNull()).addColumn("token_endpoint_auth_method", f`varchar(64)`, (e) => e.defaultTo("client_secret_basic")).addColumn("client_metadata", f`text`, (e) => e.notNull()).addColumn("mobile", f`text`, (e) => e.notNull()).addColumn("initiate_login_uri", f`varchar(2083)`).addColumn("native_social_login", f`text`, (e) => e.notNull()).addColumn("refresh_token", f`text`, (e) => e.notNull()).addColumn("default_organization", f`text`, (e) => e.notNull()).addColumn("organization_usage", f`varchar(32)`, (e) => e.defaultTo("deny")).addColumn("organization_require_behavior", f`varchar(32)`, (e) => e.defaultTo("no_prompt")).addColumn("client_authentication_methods", f`text`, (e) => e.notNull()).addColumn("require_pushed_authorization_requests", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("require_proof_of_possession", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("signed_request_object", f`text`, (e) => e.notNull()).addColumn("compliance_level", f`varchar(64)`).addColumn("par_request_expiry", f`int`).addColumn("token_quota", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("connections", f`text`).addColumn("auth0_conformant", f`int`, (e) => e.defaultTo(1)).addColumn("owner_user_id", f`varchar(255)`).addColumn("registration_type", f`varchar(32)`).addColumn("registration_metadata", f`text`).addColumn("user_linking_mode", f`varchar(16)`).addColumn("hide_sign_up_disabled_error", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("clients_pk", ["tenant_id", "client_id"]);
|
|
5984
|
-
t && (n =
|
|
6132
|
+
t && (n = Y(n, "clients")), await n.execute();
|
|
5985
6133
|
}
|
|
5986
6134
|
{
|
|
5987
6135
|
let n = e.schema.createTable("client_grants").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("client_id", f`varchar(191)`, (e) => e.notNull()).addColumn("audience", f`varchar(191)`, (e) => e.notNull()).addColumn("scope", f`text`).addColumn("organization_usage", f`varchar(32)`).addColumn("allow_any_organization", f`int`, (e) => e.defaultTo(0)).addColumn("is_system", f`int`, (e) => e.defaultTo(0)).addColumn("subject_type", f`varchar(32)`).addColumn("authorization_details_types", f`text`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("client_grants_pk", ["tenant_id", "id"]);
|
|
5988
|
-
t && (n =
|
|
6136
|
+
t && (n = Y(n, "client_grants")), await n.execute();
|
|
5989
6137
|
}
|
|
5990
6138
|
{
|
|
5991
6139
|
let n = e.schema.createTable("client_registration_tokens").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(64)`, (e) => e.notNull()).addColumn("type", f`varchar(8)`, (e) => e.notNull()).addColumn("client_id", f`varchar(191)`).addColumn("sub", f`varchar(255)`).addColumn("constraints", f`text`).addColumn("single_use", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("used_at_ts", f`bigint`).addColumn("expires_at_ts", f`bigint`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("revoked_at_ts", f`bigint`).addPrimaryKeyConstraint("client_registration_tokens_pk", ["id"]);
|
|
5992
|
-
t && (n =
|
|
6140
|
+
t && (n = Y(n, "client_registration_tokens")), await n.execute();
|
|
5993
6141
|
}
|
|
5994
6142
|
{
|
|
5995
6143
|
let n = e.schema.createTable("users").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("email", f`varchar(255)`).addColumn("given_name", f`varchar(255)`).addColumn("family_name", f`varchar(255)`).addColumn("nickname", f`varchar(255)`).addColumn("name", f`varchar(255)`).addColumn("picture", f`text`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("linked_to", f`varchar(255)`).addColumn("provider", f`varchar(255)`, (e) => e.notNull()).addColumn("connection", f`varchar(255)`, (e) => e.notNull()).addColumn("email_verified", f`tinyint(1)`, (e) => e.notNull()).addColumn("is_social", f`tinyint(1)`, (e) => e.notNull()).addColumn("app_metadata", f`text`, (e) => e.notNull().defaultTo(f`('{}')`)).addColumn("profileData", f`text`).addColumn("locale", f`varchar(64)`).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("phone_number", f`varchar(17)`).addColumn("phone_verified", f`tinyint(1)`).addColumn("username", f`varchar(128)`).addColumn("user_metadata", f`text`).addColumn("middle_name", f`varchar(100)`).addColumn("profile", f`text`).addColumn("website", f`text`).addColumn("gender", f`varchar(50)`).addColumn("birthdate", f`varchar(10)`).addColumn("zoneinfo", f`varchar(100)`).addColumn("preferred_username", f`varchar(255)`).addColumn("address", f`text`).addColumn("registration_completed_at", f`varchar(35)`).addPrimaryKeyConstraint("users_pk", ["tenant_id", "user_id"]);
|
|
5996
|
-
t && (n =
|
|
6144
|
+
t && (n = Y(n, "users")), await n.execute();
|
|
5997
6145
|
}
|
|
5998
6146
|
{
|
|
5999
6147
|
let n = e.schema.createTable("codes").addColumn("code_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`).addColumn("login_id", f`varchar(255)`).addColumn("connection_id", f`varchar(255)`).addColumn("code_type", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("expires_at", f`varchar(255)`, (e) => e.notNull()).addColumn("used_at", f`varchar(255)`).addColumn("code_verifier", f`varchar(128)`).addColumn("code_challenge", f`varchar(128)`).addColumn("code_challenge_method", f`varchar(5)`).addColumn("redirect_uri", f`varchar(1024)`).addColumn("nonce", f`varchar(1024)`).addColumn("state", f`varchar(2048)`).addColumn("otp", f`varchar(32)`).addPrimaryKeyConstraint("codes_pk", [
|
|
@@ -6001,16 +6149,16 @@ async function Lo(e) {
|
|
|
6001
6149
|
"code_type",
|
|
6002
6150
|
"tenant_id"
|
|
6003
6151
|
]);
|
|
6004
|
-
t && (n =
|
|
6152
|
+
t && (n = Y(n, "codes")), await n.execute();
|
|
6005
6153
|
}
|
|
6006
6154
|
{
|
|
6007
6155
|
let n = e.schema.createTable("connections").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("response_type", f`varchar(255)`).addColumn("response_mode", f`varchar(255)`).addColumn("strategy", f`varchar(64)`).addColumn("options", f`varchar(8192)`, (e) => e.notNull().defaultTo("{}")).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addColumn("display_name", f`varchar(255)`).addColumn("is_domain_connection", f`int`).addColumn("show_as_button", f`int`).addColumn("metadata", f`varchar(4096)`).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("connections_pk", ["tenant_id", "id"]);
|
|
6008
|
-
t && (n =
|
|
6156
|
+
t && (n = Y(n, "connections")), await n.execute();
|
|
6009
6157
|
}
|
|
6010
6158
|
await e.schema.createTable("control_plane_comm_keys").addColumn("kid", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("public_jwk", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("revoked_at", f`varchar(35)`).addPrimaryKeyConstraint("control_plane_comm_keys_pk", ["kid"]).execute();
|
|
6011
6159
|
{
|
|
6012
6160
|
let n = e.schema.createTable("custom_domains").addColumn("custom_domain_id", f`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("domain", f`varchar(255)`, (e) => e.notNull()).addColumn("primary", f`tinyint(1)`, (e) => e.notNull()).addColumn("status", f`varchar(50)`, (e) => e.notNull()).addColumn("type", f`varchar(50)`, (e) => e.notNull()).addColumn("origin_domain_name", f`varchar(255)`).addColumn("verification", f`varchar(2048)`).addColumn("custom_client_ip_header", f`varchar(50)`).addColumn("tls_policy", f`varchar(50)`).addColumn("domain_metadata", f`varchar(2048)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("custom_domains_pk", ["custom_domain_id"]);
|
|
6013
|
-
t && (n =
|
|
6161
|
+
t && (n = Y(n, "custom_domains")), await n.execute();
|
|
6014
6162
|
}
|
|
6015
6163
|
{
|
|
6016
6164
|
let n = e.schema.createTable("custom_text").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("prompt", f`varchar(64)`, (e) => e.notNull()).addColumn("language", f`varchar(16)`, (e) => e.notNull()).addColumn("custom_text", f`text`, (e) => e.notNull()).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("custom_text_pk", [
|
|
@@ -6018,56 +6166,56 @@ async function Lo(e) {
|
|
|
6018
6166
|
"prompt",
|
|
6019
6167
|
"language"
|
|
6020
6168
|
]);
|
|
6021
|
-
t && (n =
|
|
6169
|
+
t && (n = Y(n, "custom_text")), await n.execute();
|
|
6022
6170
|
}
|
|
6023
6171
|
await e.schema.createTable("email_providers").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("enabled", f`tinyint(1)`, (e) => e.notNull()).addColumn("default_from_address", f`varchar(255)`).addColumn("credentials", f`varchar(2048)`, (e) => e.notNull().defaultTo("{}")).addColumn("settings", f`varchar(2048)`, (e) => e.notNull().defaultTo("{}")).addColumn("created_at", f`varchar(29)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(29)`, (e) => e.notNull()).addPrimaryKeyConstraint("email_providers_pk", ["tenant_id"]).execute();
|
|
6024
6172
|
{
|
|
6025
6173
|
let n = e.schema.createTable("email_templates").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("template", f`varchar(64)`, (e) => e.notNull()).addColumn("body", f`text`, (e) => e.notNull()).addColumn("from", f`varchar(255)`, (e) => e.notNull()).addColumn("subject", f`varchar(255)`, (e) => e.notNull()).addColumn("syntax", f`varchar(16)`, (e) => e.notNull().defaultTo("liquid")).addColumn("result_url", f`varchar(2048)`).addColumn("url_lifetime_in_seconds", f`int`).addColumn("include_email_in_redirect", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("enabled", f`int`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("email_templates_pk", ["tenant_id", "template"]);
|
|
6026
|
-
t && (n =
|
|
6174
|
+
t && (n = Y(n, "email_templates")), await n.execute();
|
|
6027
6175
|
}
|
|
6028
6176
|
await e.schema.createTable("flows").addColumn("id", f`varchar(24)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(150)`, (e) => e.notNull()).addColumn("actions", f`text`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("flows_pk", ["id"]).execute(), await e.schema.createTable("forms").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("messages", f`varchar(255)`).addColumn("languages", f`varchar(255)`).addColumn("translations", f`varchar(4096)`).addColumn("nodes", f`varchar(4096)`).addColumn("start", f`varchar(255)`).addColumn("ending", f`varchar(255)`).addColumn("style", f`varchar(1042)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addPrimaryKeyConstraint("forms_pk", ["id"]).execute();
|
|
6029
6177
|
{
|
|
6030
6178
|
let n = e.schema.createTable("grants").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(191)`, (e) => e.notNull()).addColumn("client_id", f`varchar(191)`, (e) => e.notNull()).addColumn("audience", f`varchar(100)`, (e) => e.notNull().defaultTo("")).addColumn("scope", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("grants_pk", ["id"]);
|
|
6031
|
-
t && (n =
|
|
6179
|
+
t && (n = Y(n, "grants")), await n.execute();
|
|
6032
6180
|
}
|
|
6033
6181
|
await e.schema.createTable("hook_code").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("secrets", f`text`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("hook_code_pk", ["id"]).execute();
|
|
6034
6182
|
{
|
|
6035
6183
|
let n = e.schema.createTable("hooks").addColumn("hook_id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("trigger_id", f`varchar(255)`, (e) => e.notNull()).addColumn("enabled", f`tinyint(1)`, (e) => e.notNull()).addColumn("synchronous", f`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("priority", f`int`).addColumn("form_id", f`varchar(128)`).addColumn("url", f`varchar(512)`).addColumn("template_id", f`varchar(64)`).addColumn("created_at_ts", f`bigint`).addColumn("updated_at_ts", f`bigint`).addColumn("code_id", f`varchar(21)`).addColumn("metadata", f`text`).addPrimaryKeyConstraint("hooks_pk", ["hook_id"]);
|
|
6036
|
-
t && (n =
|
|
6184
|
+
t && (n = Y(n, "hooks")), await n.execute();
|
|
6037
6185
|
}
|
|
6038
6186
|
await e.schema.createTable("invites").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", f`varchar(21)`, (e) => e.notNull()).addColumn("inviter", f`text`, (e) => e.notNull()).addColumn("invitee", f`text`, (e) => e.notNull()).addColumn("client_id", f`varchar(191)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(21)`).addColumn("invitation_url", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("expires_at", f`varchar(35)`, (e) => e.notNull()).addColumn("app_metadata", f`text`).addColumn("user_metadata", f`text`).addColumn("roles", f`text`).addColumn("ticket_id", f`varchar(191)`).addColumn("ttl_sec", f`int`).addColumn("send_invitation_email", f`int`).addPrimaryKeyConstraint("invites_pk", ["id"]).execute();
|
|
6039
6187
|
{
|
|
6040
6188
|
let n = e.schema.createTable("keys").addColumn("kid", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("revoked_at", f`varchar(255)`).addColumn("cert", f`varchar(4096)`).addColumn("pkcs7", f`varchar(4096)`).addColumn("fingerprint", f`varchar(256)`).addColumn("thumbprint", f`varchar(256)`).addColumn("current_since", f`varchar(256)`).addColumn("current_until", f`varchar(256)`).addColumn("type", f`varchar(50)`, (e) => e.notNull().defaultTo("jwt_signing")).addColumn("connection", f`varchar(255)`).addPrimaryKeyConstraint("keys_pk", ["kid"]);
|
|
6041
|
-
t && (n =
|
|
6189
|
+
t && (n = Y(n, "keys")), await n.execute();
|
|
6042
6190
|
}
|
|
6043
6191
|
await e.schema.createTable("log_streams").addColumn("id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("type", f`varchar(64)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("sink", f`text`, (e) => e.notNull()).addColumn("filters", f`text`).addColumn("is_priority", f`tinyint(1)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("log_streams_pk", ["id"]).execute();
|
|
6044
6192
|
{
|
|
6045
6193
|
let n = e.schema.createTable("sessions").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`).addColumn("device", f`text`, (e) => e.notNull()).addColumn("clients", f`text`, (e) => e.notNull()).addColumn("login_session_id", f`varchar(26)`).addColumn("created_at_ts", f`bigint`).addColumn("updated_at_ts", f`bigint`).addColumn("expires_at_ts", f`bigint`).addColumn("idle_expires_at_ts", f`bigint`).addColumn("authenticated_at_ts", f`bigint`).addColumn("last_interaction_at_ts", f`bigint`).addColumn("used_at_ts", f`bigint`).addColumn("revoked_at_ts", f`bigint`).addPrimaryKeyConstraint("sessions_pk", ["tenant_id", "id"]);
|
|
6046
|
-
t && (n =
|
|
6194
|
+
t && (n = Y(n, "sessions")), await n.execute();
|
|
6047
6195
|
}
|
|
6048
6196
|
{
|
|
6049
6197
|
let n = e.schema.createTable("login_sessions").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("session_id", f`varchar(26)`).addColumn("csrf_token", f`varchar(26)`).addColumn("authorization_url", f`text`).addColumn("ip", f`varchar(39)`).addColumn("useragent", f`text`).addColumn("auth0Client", f`varchar(255)`).addColumn("state", f`varchar(50)`, (e) => e.defaultTo("pending")).addColumn("state_data", f`text`).addColumn("failure_reason", f`text`).addColumn("user_id", f`varchar(255)`).addColumn("created_at_ts", f`bigint`).addColumn("updated_at_ts", f`bigint`).addColumn("expires_at_ts", f`bigint`).addColumn("auth_connection", f`varchar(255)`).addColumn("auth_strategy_strategy", f`varchar(64)`).addColumn("auth_strategy_strategy_type", f`varchar(64)`).addColumn("authenticated_at", f`varchar(35)`).addColumn("auth_params", f`text`).addPrimaryKeyConstraint("login_sessions_pk", ["tenant_id", "id"]);
|
|
6050
|
-
t && (n =
|
|
6198
|
+
t && (n = Y(n, "login_sessions")), await n.execute();
|
|
6051
6199
|
}
|
|
6052
6200
|
await e.schema.createTable("logs").addColumn("log_id", f`varchar(21)`, (e) => e.notNull()).addColumn("category", f`varchar(255)`).addColumn("tenant_id", f`varchar(64)`).addColumn("user_id", f`varchar(64)`).addColumn("ip", f`varchar(255)`).addColumn("type", f`varchar(8)`, (e) => e.notNull()).addColumn("date", f`varchar(25)`, (e) => e.notNull()).addColumn("client_id", f`varchar(255)`).addColumn("client_name", f`varchar(255)`).addColumn("user_agent", f`varchar(255)`).addColumn("description", f`varchar(255)`).addColumn("details", f`varchar(2048)`).addColumn("isMobile", f`int`).addColumn("user_name", f`varchar(255)`).addColumn("connection", f`varchar(255)`).addColumn("connection_id", f`varchar(255)`).addColumn("audience", f`varchar(255)`).addColumn("scope", f`varchar(255)`).addColumn("strategy", f`varchar(255)`).addColumn("strategy_type", f`varchar(255)`).addColumn("hostname", f`varchar(255)`).addColumn("auth0_client", f`varchar(8192)`).addColumn("session_connection", f`varchar(255)`).addColumn("country_code", f`varchar(2)`).addColumn("country_code3", f`varchar(3)`).addColumn("country_name", f`varchar(255)`).addColumn("city_name", f`varchar(255)`).addColumn("latitude", f`varchar(255)`).addColumn("longitude", f`varchar(255)`).addColumn("time_zone", f`varchar(255)`).addColumn("continent_code", f`varchar(2)`).addPrimaryKeyConstraint("logs_pk", ["log_id"]).execute(), await e.schema.createTable("migration_sources").addColumn("id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("provider", f`varchar(32)`, (e) => e.notNull()).addColumn("connection", f`varchar(255)`, (e) => e.notNull()).addColumn("enabled", f`tinyint(1)`, (e) => e.notNull()).addColumn("credentials", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("migration_sources_pk", ["id"]).execute();
|
|
6053
6201
|
{
|
|
6054
6202
|
let n = e.schema.createTable("migrations").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("provider", f`varchar(255)`).addColumn("client_id", f`varchar(255)`).addColumn("origin", f`varchar(255)`).addColumn("domain", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addPrimaryKeyConstraint("migrations_pk", ["id"]);
|
|
6055
|
-
t && (n =
|
|
6203
|
+
t && (n = Y(n, "migrations")), await n.execute();
|
|
6056
6204
|
}
|
|
6057
6205
|
await e.schema.createTable("organizations").addColumn("id", f`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(256)`, (e) => e.notNull()).addColumn("name", f`varchar(256)`, (e) => e.notNull()).addColumn("display_name", f`varchar(256)`).addColumn("branding", f`text`).addColumn("metadata", f`text`).addColumn("enabled_connections", f`text`).addColumn("token_quota", f`text`).addColumn("created_at", f`varchar(256)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(256)`, (e) => e.notNull()).addPrimaryKeyConstraint("organizations_pk", ["id"]).execute();
|
|
6058
6206
|
{
|
|
6059
6207
|
let n = e.schema.createTable("organization_connections").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", f`varchar(21)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(191)`, (e) => e.notNull()).addColumn("assign_membership_on_login", f`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("show_as_button", f`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("is_signup_enabled", f`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull());
|
|
6060
|
-
t && (n =
|
|
6208
|
+
t && (n = Y(n, "organization_connections")), await n.execute();
|
|
6061
6209
|
}
|
|
6062
6210
|
await e.schema.createTable("outbox_events").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("event_type", f`varchar(255)`, (e) => e.notNull()).addColumn("log_type", f`varchar(64)`, (e) => e.notNull()).addColumn("aggregate_type", f`varchar(64)`, (e) => e.notNull()).addColumn("aggregate_id", f`varchar(255)`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("processed_at", f`varchar(35)`).addColumn("retry_count", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("next_retry_at", f`varchar(35)`).addColumn("error", f`text`).addColumn("claimed_by", f`varchar(64)`).addColumn("claim_expires_at", f`varchar(35)`).addColumn("dead_lettered_at", f`varchar(35)`).addColumn("final_error", f`text`).addPrimaryKeyConstraint("outbox_events_pk", ["id"]).execute();
|
|
6063
6211
|
{
|
|
6064
6212
|
let n = e.schema.createTable("passwords").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("user_id", f`varchar(191)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("password", f`varchar(255)`, (e) => e.notNull()).addColumn("algorithm", f`varchar(255)`, (e) => e.notNull().defaultTo("bcrypt")).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("is_current", f`int`, (e) => e.notNull().defaultTo(1)).addPrimaryKeyConstraint("passwords_pk", ["id"]);
|
|
6065
|
-
t && (n =
|
|
6213
|
+
t && (n = Y(n, "passwords")), await n.execute();
|
|
6066
6214
|
}
|
|
6067
6215
|
await e.schema.createTable("prompt_settings").addColumn("tenant_id", f`varchar(64)`, (e) => e.notNull()).addColumn("universal_login_experience", f`varchar(16)`, (e) => e.notNull().defaultTo("new")).addColumn("identifier_first", f`tinyint(1)`, (e) => e.notNull().defaultTo(1)).addColumn("password_first", f`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addColumn("webauthn_platform_first_factor", f`tinyint(1)`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("prompt_settings_pk", ["tenant_id"]).execute(), await e.schema.createTable("proxy_routes").addColumn("id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("custom_domain_id", f`varchar(256)`, (e) => e.notNull()).addColumn("priority", f`int`, (e) => e.notNull().defaultTo(100)).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("match", f`varchar(2048)`, (e) => e.notNull().defaultTo("{\"path\":\"/*\"}")).addColumn("handlers", f`text`, (e) => e.notNull()).addPrimaryKeyConstraint("proxy_routes_pk", ["id"]).execute();
|
|
6068
6216
|
{
|
|
6069
6217
|
let n = e.schema.createTable("refresh_tokens").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("client_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`).addColumn("resource_servers", f`text`, (e) => e.notNull()).addColumn("device", f`text`, (e) => e.notNull()).addColumn("rotating", f`tinyint(1)`, (e) => e.notNull()).addColumn("created_at_ts", f`bigint`).addColumn("expires_at_ts", f`bigint`).addColumn("idle_expires_at_ts", f`bigint`).addColumn("last_exchanged_at_ts", f`bigint`).addColumn("login_id", f`varchar(26)`, (e) => e.notNull()).addColumn("revoked_at_ts", f`bigint`).addColumn("token_lookup", f`varchar(16)`).addColumn("token_hash", f`varchar(64)`).addColumn("family_id", f`varchar(26)`).addColumn("rotated_to", f`varchar(26)`).addColumn("rotated_at_ts", f`bigint`).addPrimaryKeyConstraint("refresh_tokens_pk", ["tenant_id", "id"]);
|
|
6070
|
-
t && (n =
|
|
6218
|
+
t && (n = Y(n, "refresh_tokens")), await n.execute();
|
|
6071
6219
|
}
|
|
6072
6220
|
await e.schema.createTable("resource_servers").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("identifier", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("scopes", f`text`).addColumn("signing_alg", f`varchar(64)`).addColumn("signing_secret", f`varchar(2048)`).addColumn("token_lifetime", f`int`).addColumn("token_lifetime_for_web", f`int`).addColumn("skip_consent_for_verifiable_first_party_clients", f`int`).addColumn("allow_offline_access", f`int`).addColumn("verification_key", f`varchar(4096)`).addColumn("options", f`varchar(4096)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("metadata", f`varchar(4096)`).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await e.schema.createTable("role_permissions").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("role_id", f`varchar(21)`, (e) => e.notNull()).addColumn("resource_server_identifier", f`varchar(191)`, (e) => e.notNull()).addColumn("permission_name", f`varchar(191)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("role_permissions_pk", [
|
|
6073
6221
|
"tenant_id",
|
|
@@ -6077,23 +6225,23 @@ async function Lo(e) {
|
|
|
6077
6225
|
]).execute(), await e.schema.createTable("roles").addColumn("id", f`varchar(21)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(50)`, (e) => e.notNull()).addColumn("description", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("metadata", f`varchar(4096)`).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await e.schema.createTable("rollouts").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("kind", f`varchar(32)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("target_worker_version", f`varchar(255)`).addColumn("target_database_version", f`varchar(255)`).addColumn("wave_size", f`int`, (e) => e.notNull().defaultTo(10)).addColumn("canary_tenant_ids", f`text`).addColumn("filter", f`text`).addColumn("initiated_by", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("finished_at", f`varchar(35)`).addPrimaryKeyConstraint("rollouts_pk", ["id"]).execute(), await e.schema.createTable("tenant_operations").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`).addColumn("rollout_id", f`varchar(255)`).addColumn("kind", f`varchar(32)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("current_step", f`varchar(255)`).addColumn("engine", f`varchar(64)`, (e) => e.notNull()).addColumn("engine_instance_id", f`varchar(100)`).addColumn("target_worker_version", f`varchar(255)`).addColumn("target_database_version", f`varchar(255)`).addColumn("error", f`text`).addColumn("initiated_by", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addColumn("finished_at", f`varchar(35)`).addPrimaryKeyConstraint("tenant_operations_pk", ["id"]).execute();
|
|
6078
6226
|
{
|
|
6079
6227
|
let n = e.schema.createTable("tenant_operation_events").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("step", f`varchar(255)`, (e) => e.notNull()).addColumn("outcome", f`varchar(32)`, (e) => e.notNull()).addColumn("detail", f`text`).addColumn("attempt", f`int`, (e) => e.notNull().defaultTo(1)).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_events_pk", ["id"]);
|
|
6080
|
-
t && (n =
|
|
6228
|
+
t && (n = Y(n, "tenant_operation_events")), await n.execute();
|
|
6081
6229
|
}
|
|
6082
6230
|
{
|
|
6083
6231
|
let n = e.schema.createTable("themes").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("themeId", f`varchar(21)`, (e) => e.notNull()).addColumn("displayName", f`varchar(255)`, (e) => e.notNull()).addColumn("colors_primary_button_label", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_primary_button", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_secondary_button_border", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_secondary_button_label", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_base_focus_color", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_base_hover_color", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_body_text", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_captcha_widget_theme", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_error", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_header", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_icons", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_background", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_border", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_filled_text", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_input_labels_placeholders", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_links_focused_components", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_success", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_widget_background", f`varchar(24)`, (e) => e.notNull()).addColumn("colors_widget_border", f`varchar(24)`, (e) => e.notNull()).addColumn("borders_button_border_radius", f`int`, (e) => e.notNull()).addColumn("borders_button_border_weight", f`int`, (e) => e.notNull()).addColumn("borders_buttons_style", f`varchar(24)`, (e) => e.notNull()).addColumn("borders_input_border_radius", f`int`, (e) => e.notNull()).addColumn("borders_input_border_weight", f`int`, (e) => e.notNull()).addColumn("borders_inputs_style", f`varchar(24)`, (e) => e.notNull()).addColumn("borders_show_widget_shadow", f`tinyint(1)`, (e) => e.notNull()).addColumn("borders_widget_border_weight", f`int`, (e) => e.notNull()).addColumn("borders_widget_corner_radius", f`int`, (e) => e.notNull()).addColumn("fonts_body_text_bold", f`int`, (e) => e.notNull()).addColumn("fonts_body_text_size", f`int`, (e) => e.notNull()).addColumn("fonts_buttons_text_bold", f`int`, (e) => e.notNull()).addColumn("fonts_buttons_text_size", f`int`, (e) => e.notNull()).addColumn("fonts_font_url", f`varchar(255)`, (e) => e.notNull()).addColumn("fonts_input_labels_bold", f`int`, (e) => e.notNull()).addColumn("fonts_input_labels_size", f`int`, (e) => e.notNull()).addColumn("fonts_links_bold", f`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_links_size", f`int`, (e) => e.notNull()).addColumn("fonts_links_style", f`varchar(24)`, (e) => e.notNull()).addColumn("fonts_reference_text_size", f`int`, (e) => e.notNull()).addColumn("fonts_subtitle_bold", f`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_subtitle_size", f`int`, (e) => e.notNull()).addColumn("fonts_title_bold", f`tinyint(1)`, (e) => e.notNull()).addColumn("fonts_title_size", f`int`, (e) => e.notNull()).addColumn("page_background_background_color", f`varchar(24)`, (e) => e.notNull()).addColumn("page_background_background_image_url", f`varchar(255)`, (e) => e.notNull()).addColumn("page_background_page_layout", f`varchar(24)`, (e) => e.notNull()).addColumn("widget_header_text_alignment", f`varchar(24)`, (e) => e.notNull()).addColumn("widget_logo_height", f`int`, (e) => e.notNull()).addColumn("widget_logo_position", f`varchar(24)`, (e) => e.notNull()).addColumn("widget_logo_url", f`varchar(255)`, (e) => e.notNull()).addColumn("widget_social_buttons_layout", f`varchar(24)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("themes_pk", ["tenant_id", "themeId"]);
|
|
6084
|
-
t && (n =
|
|
6232
|
+
t && (n = Y(n, "themes")), await n.execute();
|
|
6085
6233
|
}
|
|
6086
6234
|
{
|
|
6087
6235
|
let n = e.schema.createTable("universal_login_templates").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("body", f`text`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("universal_login_templates_pk", ["tenant_id"]);
|
|
6088
|
-
t && (n =
|
|
6236
|
+
t && (n = Y(n, "universal_login_templates")), await n.execute();
|
|
6089
6237
|
}
|
|
6090
6238
|
{
|
|
6091
6239
|
let n = e.schema.createTable("user_activity").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("last_login", f`varchar(35)`).addColumn("last_ip", f`varchar(45)`).addColumn("login_count", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("failed_logins", f`text`).addColumn("last_password_reset", f`varchar(35)`).addPrimaryKeyConstraint("user_activity_pk", ["tenant_id", "user_id"]);
|
|
6092
|
-
t && (n =
|
|
6240
|
+
t && (n = Y(n, "user_activity")), await n.execute();
|
|
6093
6241
|
}
|
|
6094
6242
|
{
|
|
6095
6243
|
let n = e.schema.createTable("user_organizations").addColumn("id", f`varchar(256)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(256)`, (e) => e.notNull()).addColumn("user_id", f`varchar(256)`, (e) => e.notNull()).addColumn("organization_id", f`varchar(256)`, (e) => e.notNull()).addColumn("created_at", f`varchar(256)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(256)`, (e) => e.notNull()).addPrimaryKeyConstraint("user_organizations_pk", ["id"]);
|
|
6096
|
-
t && (n =
|
|
6244
|
+
t && (n = Y(n, "user_organizations")), await n.execute();
|
|
6097
6245
|
}
|
|
6098
6246
|
if (await e.schema.createTable("user_permissions").addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(191)`, (e) => e.notNull()).addColumn("resource_server_identifier", f`varchar(100)`, (e) => e.notNull()).addColumn("permission_name", f`varchar(191)`, (e) => e.notNull()).addColumn("organization_id", f`varchar(21)`, (e) => e.notNull().defaultTo("")).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("user_permissions_pk", [
|
|
6099
6247
|
"tenant_id",
|
|
@@ -6156,76 +6304,76 @@ async function Lo(e) {
|
|
|
6156
6304
|
"tenant_id",
|
|
6157
6305
|
"phone_number",
|
|
6158
6306
|
"provider"
|
|
6159
|
-
]).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
|
|
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 Wo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6160
6308
|
let n = e;
|
|
6161
6309
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6162
6310
|
}).execute();
|
|
6163
6311
|
}
|
|
6164
|
-
async function
|
|
6312
|
+
async function qo(e) {
|
|
6165
6313
|
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();
|
|
6166
6314
|
}
|
|
6167
6315
|
//#endregion
|
|
6168
6316
|
//#region migrate/log.ts
|
|
6169
|
-
var
|
|
6170
|
-
function
|
|
6171
|
-
|
|
6317
|
+
var Jo = !1;
|
|
6318
|
+
function Yo(e) {
|
|
6319
|
+
Jo = e;
|
|
6172
6320
|
}
|
|
6173
|
-
function
|
|
6174
|
-
|
|
6321
|
+
function X(...e) {
|
|
6322
|
+
Jo && console.log(...e);
|
|
6175
6323
|
}
|
|
6176
|
-
function
|
|
6324
|
+
function Z(...e) {
|
|
6177
6325
|
console.warn(...e);
|
|
6178
6326
|
}
|
|
6179
6327
|
//#endregion
|
|
6180
6328
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6181
|
-
var
|
|
6182
|
-
down: () =>
|
|
6183
|
-
up: () =>
|
|
6184
|
-
}),
|
|
6185
|
-
async function
|
|
6329
|
+
var Xo = /* @__PURE__ */ T({
|
|
6330
|
+
down: () => ss,
|
|
6331
|
+
up: () => is
|
|
6332
|
+
}), Zo = 5e4, Qo = 500;
|
|
6333
|
+
async function $o(e) {
|
|
6186
6334
|
try {
|
|
6187
6335
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6188
6336
|
} catch {
|
|
6189
6337
|
return "sqlite";
|
|
6190
6338
|
}
|
|
6191
6339
|
}
|
|
6192
|
-
async function
|
|
6340
|
+
async function es(e, t, n) {
|
|
6193
6341
|
try {
|
|
6194
6342
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6195
6343
|
} catch (e) {
|
|
6196
6344
|
if (e instanceof Error && (e.message.includes("1060") || e.message.includes("duplicate column"))) {
|
|
6197
|
-
|
|
6345
|
+
X(` Column ${t}.${n} already exists, skipping`);
|
|
6198
6346
|
return;
|
|
6199
6347
|
}
|
|
6200
6348
|
throw e;
|
|
6201
6349
|
}
|
|
6202
6350
|
}
|
|
6203
|
-
async function
|
|
6351
|
+
async function ts(e, t, n, r) {
|
|
6204
6352
|
try {
|
|
6205
6353
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6206
6354
|
} catch (e) {
|
|
6207
6355
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6208
|
-
|
|
6356
|
+
X(` Index ${t} already exists, skipping`);
|
|
6209
6357
|
return;
|
|
6210
6358
|
}
|
|
6211
6359
|
throw e;
|
|
6212
6360
|
}
|
|
6213
6361
|
}
|
|
6214
|
-
async function
|
|
6362
|
+
async function ns(e, t) {
|
|
6215
6363
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6216
6364
|
if (t === "sqlite") {
|
|
6217
6365
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6218
6366
|
r = Number(t.numDeletedRows);
|
|
6219
6367
|
} else {
|
|
6220
|
-
let t =
|
|
6221
|
-
for (; t >=
|
|
6222
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6223
|
-
t = Number(i.numDeletedRows), r += t, t > 0 &&
|
|
6368
|
+
let t = Zo;
|
|
6369
|
+
for (; t >= Zo;) {
|
|
6370
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(Zo).executeTakeFirst();
|
|
6371
|
+
t = Number(i.numDeletedRows), r += t, t > 0 && X(` Pruned ${r} expired codes row(s)...`);
|
|
6224
6372
|
}
|
|
6225
6373
|
}
|
|
6226
6374
|
return r;
|
|
6227
6375
|
}
|
|
6228
|
-
async function
|
|
6376
|
+
async function rs(e) {
|
|
6229
6377
|
let t = 0;
|
|
6230
6378
|
for (;;) {
|
|
6231
6379
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6233,33 +6381,33 @@ async function Jo(e) {
|
|
|
6233
6381
|
"code_type",
|
|
6234
6382
|
"tenant_id",
|
|
6235
6383
|
"expires_at"
|
|
6236
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6384
|
+
]).where("expires_at_ts", "is", null).limit(Qo).execute();
|
|
6237
6385
|
if (n.length === 0) break;
|
|
6238
6386
|
for (let t of n) {
|
|
6239
6387
|
let n = Date.parse(t.expires_at);
|
|
6240
6388
|
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();
|
|
6241
6389
|
}
|
|
6242
|
-
if (t += n.length, n.length <
|
|
6390
|
+
if (t += n.length, n.length < Qo) break;
|
|
6243
6391
|
}
|
|
6244
6392
|
return t;
|
|
6245
6393
|
}
|
|
6246
|
-
async function
|
|
6247
|
-
let t = await
|
|
6394
|
+
async function is(e) {
|
|
6395
|
+
let t = await $o(e);
|
|
6248
6396
|
try {
|
|
6249
|
-
let n = await
|
|
6250
|
-
|
|
6397
|
+
let n = await ns(e, t);
|
|
6398
|
+
X(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6251
6399
|
} catch (e) {
|
|
6252
|
-
|
|
6400
|
+
Z(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6253
6401
|
}
|
|
6254
|
-
await
|
|
6402
|
+
await es(e, "codes", "expires_at_ts"), await ts(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6255
6403
|
try {
|
|
6256
|
-
let t = await
|
|
6257
|
-
|
|
6404
|
+
let t = await rs(e);
|
|
6405
|
+
X(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6258
6406
|
} catch (e) {
|
|
6259
|
-
|
|
6407
|
+
Z(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6260
6408
|
}
|
|
6261
6409
|
}
|
|
6262
|
-
async function
|
|
6410
|
+
async function as(e, t, n) {
|
|
6263
6411
|
try {
|
|
6264
6412
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6265
6413
|
} catch (e) {
|
|
@@ -6267,7 +6415,7 @@ async function Xo(e, t, n) {
|
|
|
6267
6415
|
throw e;
|
|
6268
6416
|
}
|
|
6269
6417
|
}
|
|
6270
|
-
async function
|
|
6418
|
+
async function os(e, t, n) {
|
|
6271
6419
|
try {
|
|
6272
6420
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6273
6421
|
} catch (e) {
|
|
@@ -6275,16 +6423,16 @@ async function Zo(e, t, n) {
|
|
|
6275
6423
|
throw e;
|
|
6276
6424
|
}
|
|
6277
6425
|
}
|
|
6278
|
-
async function
|
|
6279
|
-
await
|
|
6426
|
+
async function ss(e) {
|
|
6427
|
+
await as(e, "idx_codes_expires_at_ts", "codes"), await os(e, "codes", "expires_at_ts");
|
|
6280
6428
|
}
|
|
6281
6429
|
//#endregion
|
|
6282
6430
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6283
|
-
var
|
|
6284
|
-
down: () =>
|
|
6285
|
-
up: () =>
|
|
6431
|
+
var cs = /* @__PURE__ */ T({
|
|
6432
|
+
down: () => us,
|
|
6433
|
+
up: () => ls
|
|
6286
6434
|
});
|
|
6287
|
-
async function
|
|
6435
|
+
async function ls(e) {
|
|
6288
6436
|
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", [
|
|
6289
6437
|
"tenant_id",
|
|
6290
6438
|
"connection_id",
|
|
@@ -6295,16 +6443,16 @@ async function es(e) {
|
|
|
6295
6443
|
"external_id"
|
|
6296
6444
|
]).unique().execute();
|
|
6297
6445
|
}
|
|
6298
|
-
async function
|
|
6446
|
+
async function us(e) {
|
|
6299
6447
|
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();
|
|
6300
6448
|
}
|
|
6301
6449
|
//#endregion
|
|
6302
6450
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6303
|
-
var
|
|
6304
|
-
down: () =>
|
|
6305
|
-
up: () =>
|
|
6451
|
+
var ds = /* @__PURE__ */ T({
|
|
6452
|
+
down: () => hs,
|
|
6453
|
+
up: () => ps
|
|
6306
6454
|
});
|
|
6307
|
-
async function
|
|
6455
|
+
async function fs(e, t, n) {
|
|
6308
6456
|
try {
|
|
6309
6457
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6310
6458
|
} catch (e) {
|
|
@@ -6312,10 +6460,10 @@ async function rs(e, t, n) {
|
|
|
6312
6460
|
throw e;
|
|
6313
6461
|
}
|
|
6314
6462
|
}
|
|
6315
|
-
async function
|
|
6316
|
-
await
|
|
6463
|
+
async function ps(e) {
|
|
6464
|
+
await fs(e, "users", "blocked");
|
|
6317
6465
|
}
|
|
6318
|
-
async function
|
|
6466
|
+
async function ms(e, t, n) {
|
|
6319
6467
|
try {
|
|
6320
6468
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6321
6469
|
} catch (e) {
|
|
@@ -6323,16 +6471,16 @@ async function as(e, t, n) {
|
|
|
6323
6471
|
throw e;
|
|
6324
6472
|
}
|
|
6325
6473
|
}
|
|
6326
|
-
async function
|
|
6327
|
-
await
|
|
6474
|
+
async function hs(e) {
|
|
6475
|
+
await ms(e, "users", "blocked");
|
|
6328
6476
|
}
|
|
6329
6477
|
//#endregion
|
|
6330
6478
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6331
|
-
var
|
|
6332
|
-
down: () =>
|
|
6333
|
-
up: () =>
|
|
6479
|
+
var gs = /* @__PURE__ */ T({
|
|
6480
|
+
down: () => bs,
|
|
6481
|
+
up: () => vs
|
|
6334
6482
|
});
|
|
6335
|
-
async function
|
|
6483
|
+
async function _s(e, t, n) {
|
|
6336
6484
|
try {
|
|
6337
6485
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6338
6486
|
} catch (e) {
|
|
@@ -6340,10 +6488,10 @@ async function cs(e, t, n) {
|
|
|
6340
6488
|
throw e;
|
|
6341
6489
|
}
|
|
6342
6490
|
}
|
|
6343
|
-
async function
|
|
6344
|
-
await
|
|
6491
|
+
async function vs(e) {
|
|
6492
|
+
await _s(e, "prompt_settings", "show_last_used_connection");
|
|
6345
6493
|
}
|
|
6346
|
-
async function
|
|
6494
|
+
async function ys(e, t, n) {
|
|
6347
6495
|
try {
|
|
6348
6496
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6349
6497
|
} catch (e) {
|
|
@@ -6351,30 +6499,30 @@ async function us(e, t, n) {
|
|
|
6351
6499
|
throw e;
|
|
6352
6500
|
}
|
|
6353
6501
|
}
|
|
6354
|
-
async function
|
|
6355
|
-
await
|
|
6502
|
+
async function bs(e) {
|
|
6503
|
+
await ys(e, "prompt_settings", "show_last_used_connection");
|
|
6356
6504
|
}
|
|
6357
6505
|
//#endregion
|
|
6358
6506
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6359
|
-
var
|
|
6360
|
-
down: () =>
|
|
6361
|
-
up: () =>
|
|
6507
|
+
var xs = /* @__PURE__ */ T({
|
|
6508
|
+
down: () => ws,
|
|
6509
|
+
up: () => Cs
|
|
6362
6510
|
});
|
|
6363
|
-
async function
|
|
6511
|
+
async function Ss(e, t, n, r) {
|
|
6364
6512
|
try {
|
|
6365
6513
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6366
6514
|
} catch (e) {
|
|
6367
6515
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6368
|
-
|
|
6516
|
+
X(` Index ${t} already exists, skipping`);
|
|
6369
6517
|
return;
|
|
6370
6518
|
}
|
|
6371
6519
|
throw e;
|
|
6372
6520
|
}
|
|
6373
6521
|
}
|
|
6374
|
-
async function
|
|
6375
|
-
await
|
|
6522
|
+
async function Cs(e) {
|
|
6523
|
+
await Ss(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6376
6524
|
}
|
|
6377
|
-
async function
|
|
6525
|
+
async function ws(e) {
|
|
6378
6526
|
try {
|
|
6379
6527
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6380
6528
|
} catch (e) {
|
|
@@ -6384,11 +6532,11 @@ async function hs(e) {
|
|
|
6384
6532
|
}
|
|
6385
6533
|
//#endregion
|
|
6386
6534
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6387
|
-
var
|
|
6388
|
-
down: () =>
|
|
6389
|
-
up: () =>
|
|
6535
|
+
var Ts = /* @__PURE__ */ T({
|
|
6536
|
+
down: () => ks,
|
|
6537
|
+
up: () => Ds
|
|
6390
6538
|
});
|
|
6391
|
-
async function
|
|
6539
|
+
async function Es(e, t, n, r) {
|
|
6392
6540
|
try {
|
|
6393
6541
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6394
6542
|
} catch (e) {
|
|
@@ -6396,10 +6544,10 @@ async function _s(e, t, n, r) {
|
|
|
6396
6544
|
throw e;
|
|
6397
6545
|
}
|
|
6398
6546
|
}
|
|
6399
|
-
async function
|
|
6400
|
-
await
|
|
6547
|
+
async function Ds(e) {
|
|
6548
|
+
await Es(e, "hooks", "page_id", f`varchar(64)`), await Es(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6401
6549
|
}
|
|
6402
|
-
async function
|
|
6550
|
+
async function Os(e, t, n) {
|
|
6403
6551
|
try {
|
|
6404
6552
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6405
6553
|
} catch (e) {
|
|
@@ -6407,22 +6555,22 @@ async function ys(e, t, n) {
|
|
|
6407
6555
|
throw e;
|
|
6408
6556
|
}
|
|
6409
6557
|
}
|
|
6410
|
-
async function
|
|
6411
|
-
await
|
|
6558
|
+
async function ks(e) {
|
|
6559
|
+
await Os(e, "hooks", "permission_required"), await Os(e, "hooks", "page_id");
|
|
6412
6560
|
}
|
|
6413
6561
|
//#endregion
|
|
6414
6562
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6415
|
-
var
|
|
6416
|
-
down: () =>
|
|
6417
|
-
up: () =>
|
|
6418
|
-
}),
|
|
6563
|
+
var As = /* @__PURE__ */ T({
|
|
6564
|
+
down: () => Is,
|
|
6565
|
+
up: () => Ps
|
|
6566
|
+
}), js = [
|
|
6419
6567
|
["session_id", f`varchar(26)`],
|
|
6420
6568
|
["organization", f`varchar(191)`],
|
|
6421
6569
|
["auth_connection", f`varchar(255)`],
|
|
6422
6570
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6423
6571
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6424
6572
|
];
|
|
6425
|
-
async function
|
|
6573
|
+
async function Ms(e, t, n, r) {
|
|
6426
6574
|
try {
|
|
6427
6575
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6428
6576
|
} catch (e) {
|
|
@@ -6430,7 +6578,7 @@ async function Cs(e, t, n, r) {
|
|
|
6430
6578
|
throw e;
|
|
6431
6579
|
}
|
|
6432
6580
|
}
|
|
6433
|
-
async function
|
|
6581
|
+
async function Ns(e) {
|
|
6434
6582
|
try {
|
|
6435
6583
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6436
6584
|
} catch (e) {
|
|
@@ -6438,11 +6586,11 @@ async function ws(e) {
|
|
|
6438
6586
|
throw e;
|
|
6439
6587
|
}
|
|
6440
6588
|
}
|
|
6441
|
-
async function
|
|
6442
|
-
for (let [t, n] of
|
|
6443
|
-
await
|
|
6589
|
+
async function Ps(e) {
|
|
6590
|
+
for (let [t, n] of js) await Ms(e, "refresh_tokens", t, n);
|
|
6591
|
+
await Ns(e);
|
|
6444
6592
|
}
|
|
6445
|
-
async function
|
|
6593
|
+
async function Fs(e, t, n) {
|
|
6446
6594
|
try {
|
|
6447
6595
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6448
6596
|
} catch (e) {
|
|
@@ -6450,27 +6598,27 @@ async function Es(e, t, n) {
|
|
|
6450
6598
|
throw e;
|
|
6451
6599
|
}
|
|
6452
6600
|
}
|
|
6453
|
-
async function
|
|
6601
|
+
async function Is(e) {
|
|
6454
6602
|
try {
|
|
6455
6603
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6456
6604
|
} catch {}
|
|
6457
|
-
for (let [t] of
|
|
6605
|
+
for (let [t] of js) await Fs(e, "refresh_tokens", t);
|
|
6458
6606
|
}
|
|
6459
6607
|
//#endregion
|
|
6460
6608
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6461
|
-
var
|
|
6462
|
-
down: () =>
|
|
6463
|
-
up: () =>
|
|
6464
|
-
}),
|
|
6465
|
-
async function
|
|
6609
|
+
var Ls = /* @__PURE__ */ T({
|
|
6610
|
+
down: () => Us,
|
|
6611
|
+
up: () => Hs
|
|
6612
|
+
}), Rs = 500, zs = 20, Bs = 500, Vs = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6613
|
+
async function Hs(e) {
|
|
6466
6614
|
try {
|
|
6467
6615
|
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);
|
|
6468
|
-
if (n >
|
|
6469
|
-
|
|
6616
|
+
if (n > Bs) {
|
|
6617
|
+
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${Bs}. SKIPPING — run the bulk path instead: ${Vs}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6470
6618
|
return;
|
|
6471
6619
|
}
|
|
6472
6620
|
if (n === 0) {
|
|
6473
|
-
|
|
6621
|
+
X("refresh_tokens backfill: nothing to do");
|
|
6474
6622
|
return;
|
|
6475
6623
|
}
|
|
6476
6624
|
let r = 0;
|
|
@@ -6483,16 +6631,16 @@ async function Ns(e) {
|
|
|
6483
6631
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6484
6632
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6485
6633
|
"login_sessions.auth_params as ls_auth_params"
|
|
6486
|
-
]).limit(
|
|
6634
|
+
]).limit(Rs).execute();
|
|
6487
6635
|
if (t.length === 0) break;
|
|
6488
|
-
for (let n = 0; n < t.length; n +=
|
|
6489
|
-
let r = t.slice(n, n +
|
|
6636
|
+
for (let n = 0; n < t.length; n += zs) {
|
|
6637
|
+
let r = t.slice(n, n + zs);
|
|
6490
6638
|
await Promise.all(r.map(async (t) => {
|
|
6491
6639
|
let n = null;
|
|
6492
6640
|
if (t.ls_auth_params) try {
|
|
6493
6641
|
n = JSON.parse(t.ls_auth_params)?.organization ?? null;
|
|
6494
6642
|
} catch {
|
|
6495
|
-
|
|
6643
|
+
Z(`refresh_tokens backfill: unparseable auth_params on login_session for token ${t.id}`);
|
|
6496
6644
|
}
|
|
6497
6645
|
await e.updateTable("refresh_tokens").set({
|
|
6498
6646
|
session_id: t.ls_session_id,
|
|
@@ -6503,44 +6651,92 @@ async function Ns(e) {
|
|
|
6503
6651
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6504
6652
|
}));
|
|
6505
6653
|
}
|
|
6506
|
-
if (r += t.length,
|
|
6654
|
+
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length < Rs) break;
|
|
6507
6655
|
}
|
|
6508
|
-
|
|
6656
|
+
X(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6657
|
+
} catch (e) {
|
|
6658
|
+
throw Z("refresh_tokens backfill failed:", e), e;
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
async function Us() {}
|
|
6662
|
+
//#endregion
|
|
6663
|
+
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6664
|
+
var Ws = /* @__PURE__ */ T({
|
|
6665
|
+
down: () => qs,
|
|
6666
|
+
up: () => Ks
|
|
6667
|
+
});
|
|
6668
|
+
async function Q(e, t, n, r) {
|
|
6669
|
+
try {
|
|
6670
|
+
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6671
|
+
} catch (e) {
|
|
6672
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6673
|
+
throw e;
|
|
6674
|
+
}
|
|
6675
|
+
}
|
|
6676
|
+
async function Gs(e, t, n, r) {
|
|
6677
|
+
try {
|
|
6678
|
+
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6679
|
+
} catch (e) {
|
|
6680
|
+
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) return;
|
|
6681
|
+
throw e;
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
async function Ks(e) {
|
|
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 Gs(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6686
|
+
"operation_id",
|
|
6687
|
+
"status",
|
|
6688
|
+
"seq"
|
|
6689
|
+
]), await Gs(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6690
|
+
"kind",
|
|
6691
|
+
"status",
|
|
6692
|
+
"created_at"
|
|
6693
|
+
]);
|
|
6694
|
+
}
|
|
6695
|
+
async function $(e, t, n) {
|
|
6696
|
+
try {
|
|
6697
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6509
6698
|
} catch (e) {
|
|
6510
|
-
|
|
6699
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6700
|
+
throw e;
|
|
6511
6701
|
}
|
|
6512
6702
|
}
|
|
6513
|
-
async function
|
|
6703
|
+
async function qs(e) {
|
|
6704
|
+
try {
|
|
6705
|
+
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6706
|
+
} catch {}
|
|
6707
|
+
await e.schema.dropTable("tenant_operation_rows").ifExists().execute(), await $(e, "tenant_operations", "claim_expires_at"), await $(e, "tenant_operations", "claimed_by"), await $(e, "tenant_operations", "result"), await $(e, "tenant_operations", "input");
|
|
6708
|
+
}
|
|
6514
6709
|
//#endregion
|
|
6515
6710
|
//#region migrate/migrations/index.ts
|
|
6516
|
-
var
|
|
6517
|
-
"2026-07-16T14:00:00_baseline":
|
|
6518
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6519
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6520
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6521
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6522
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6523
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6524
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6525
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6711
|
+
var Js = {
|
|
6712
|
+
"2026-07-16T14:00:00_baseline": Uo,
|
|
6713
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Xo,
|
|
6714
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": cs,
|
|
6715
|
+
"2026-08-05T12:00:00_user_blocked": ds,
|
|
6716
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": gs,
|
|
6717
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": xs,
|
|
6718
|
+
"2026-08-11T12:00:00_page_hooks": Ts,
|
|
6719
|
+
"2026-08-20T12:00:00_refresh_token_session_id": As,
|
|
6720
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Ls,
|
|
6721
|
+
"2026-09-01T12:00:00_tenant_operation_rows": Ws
|
|
6526
6722
|
};
|
|
6527
6723
|
//#endregion
|
|
6528
6724
|
//#region migrate/migrate.ts
|
|
6529
|
-
async function
|
|
6530
|
-
|
|
6531
|
-
let { error: n, results: r } = await new
|
|
6725
|
+
async function Ys(e, t = !1) {
|
|
6726
|
+
Yo(t), t && console.log("migrating...");
|
|
6727
|
+
let { error: n, results: r } = await new Te({
|
|
6532
6728
|
db: e,
|
|
6533
|
-
provider: new
|
|
6729
|
+
provider: new Ho(Js)
|
|
6534
6730
|
}).migrateToLatest();
|
|
6535
6731
|
if (r?.forEach((e) => {
|
|
6536
6732
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6537
6733
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6538
6734
|
}
|
|
6539
|
-
async function
|
|
6540
|
-
|
|
6541
|
-
let { error: n, results: r } = await new
|
|
6735
|
+
async function Xs(e, t = !1) {
|
|
6736
|
+
Yo(t), t && console.log("migrating...");
|
|
6737
|
+
let { error: n, results: r } = await new Te({
|
|
6542
6738
|
db: e,
|
|
6543
|
-
provider: new
|
|
6739
|
+
provider: new Ho(Js)
|
|
6544
6740
|
}).migrateDown();
|
|
6545
6741
|
if (r?.forEach((e) => {
|
|
6546
6742
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6548,64 +6744,65 @@ async function Ls(e, t = !1) {
|
|
|
6548
6744
|
}
|
|
6549
6745
|
//#endregion
|
|
6550
6746
|
//#region src/index.ts
|
|
6551
|
-
function
|
|
6747
|
+
function Zs(e, t = { useTransactions: !0 }) {
|
|
6552
6748
|
let n = {
|
|
6553
|
-
actions:
|
|
6554
|
-
actionExecutions:
|
|
6555
|
-
actionVersions:
|
|
6556
|
-
branding:
|
|
6557
|
-
clients:
|
|
6558
|
-
clientConnections:
|
|
6559
|
-
clientGrants:
|
|
6560
|
-
clientRegistrationTokens:
|
|
6561
|
-
codes:
|
|
6562
|
-
connections:
|
|
6563
|
-
emailProviders:
|
|
6564
|
-
emailTemplates:
|
|
6565
|
-
customDomains:
|
|
6566
|
-
flows:
|
|
6567
|
-
forms:
|
|
6568
|
-
hookCode:
|
|
6569
|
-
hooks:
|
|
6570
|
-
invites:
|
|
6571
|
-
keys:
|
|
6572
|
-
loginSessions:
|
|
6573
|
-
logs:
|
|
6574
|
-
logStreams:
|
|
6575
|
-
migrationSources:
|
|
6576
|
-
authenticationMethods:
|
|
6577
|
-
passwords:
|
|
6578
|
-
promptSettings:
|
|
6749
|
+
actions: Ke(e),
|
|
6750
|
+
actionExecutions: $e(e),
|
|
6751
|
+
actionVersions: nt(e),
|
|
6752
|
+
branding: fr(e),
|
|
6753
|
+
clients: On(e),
|
|
6754
|
+
clientConnections: Pn(e),
|
|
6755
|
+
clientGrants: Vn(e),
|
|
6756
|
+
clientRegistrationTokens: Qn(e),
|
|
6757
|
+
codes: fn(e),
|
|
6758
|
+
connections: yn(e),
|
|
6759
|
+
emailProviders: Qr(e),
|
|
6760
|
+
emailTemplates: ai(e),
|
|
6761
|
+
customDomains: lr(e),
|
|
6762
|
+
flows: kt(e),
|
|
6763
|
+
forms: wi(e),
|
|
6764
|
+
hookCode: Dr(e),
|
|
6765
|
+
hooks: Sr(e),
|
|
6766
|
+
invites: wa(e),
|
|
6767
|
+
keys: nr(e),
|
|
6768
|
+
loginSessions: Ur(e),
|
|
6769
|
+
logs: Gt(e),
|
|
6770
|
+
logStreams: ao(e),
|
|
6771
|
+
migrationSources: oo(e),
|
|
6772
|
+
authenticationMethods: Ja(e),
|
|
6773
|
+
passwords: nn(e),
|
|
6774
|
+
promptSettings: qr(e),
|
|
6579
6775
|
proxyRoutes: q(e),
|
|
6580
|
-
scimConfigurations:
|
|
6581
|
-
scimTokens:
|
|
6582
|
-
scimExternalIds:
|
|
6583
|
-
refreshTokens:
|
|
6584
|
-
resourceServers:
|
|
6585
|
-
rolePermissions:
|
|
6586
|
-
grants:
|
|
6587
|
-
userPermissions:
|
|
6588
|
-
userRoles:
|
|
6589
|
-
roles:
|
|
6590
|
-
sessions:
|
|
6591
|
-
sessionCleanup:
|
|
6592
|
-
tenants:
|
|
6593
|
-
tenantOperations:
|
|
6594
|
-
tenantOperationEvents:
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6776
|
+
scimConfigurations: ho(e),
|
|
6777
|
+
scimTokens: _o(e),
|
|
6778
|
+
scimExternalIds: yo(e),
|
|
6779
|
+
refreshTokens: gi(e),
|
|
6780
|
+
resourceServers: Ai(e),
|
|
6781
|
+
rolePermissions: Vi(e),
|
|
6782
|
+
grants: qi(e),
|
|
6783
|
+
userPermissions: Qi(e),
|
|
6784
|
+
userRoles: ia(e),
|
|
6785
|
+
roles: Ii(e),
|
|
6786
|
+
sessions: Zt(e),
|
|
6787
|
+
sessionCleanup: vi(e),
|
|
6788
|
+
tenants: Lt(e),
|
|
6789
|
+
tenantOperations: xo(e),
|
|
6790
|
+
tenantOperationEvents: Po(e),
|
|
6791
|
+
tenantOperationRows: Ro(e),
|
|
6792
|
+
rollouts: Vo(e),
|
|
6793
|
+
themes: Mr(e),
|
|
6794
|
+
universalLoginTemplates: gr(e),
|
|
6795
|
+
customText: Va(e),
|
|
6796
|
+
users: xt(e),
|
|
6797
|
+
userActivity: vt(e),
|
|
6798
|
+
organizations: ua(e),
|
|
6799
|
+
organizationConnections: da(e),
|
|
6800
|
+
userOrganizations: va(e),
|
|
6801
|
+
stats: ka(e),
|
|
6802
|
+
analytics: Ba(e),
|
|
6803
|
+
outbox: io(e),
|
|
6607
6804
|
async transaction(r) {
|
|
6608
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6805
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Zs(e, {
|
|
6609
6806
|
...t,
|
|
6610
6807
|
useTransactions: !1
|
|
6611
6808
|
})));
|
|
@@ -6614,4 +6811,4 @@ function Rs(e, t = { useTransactions: !0 }) {
|
|
|
6614
6811
|
return n;
|
|
6615
6812
|
}
|
|
6616
6813
|
//#endregion
|
|
6617
|
-
export {
|
|
6814
|
+
export { uo as createProxyDataAdapter, q as createProxyRoutesAdapter, Zs as default, Xs as migrateDown, Ys as migrateToLatest };
|