@authhero/kysely-adapter 12.1.0 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.d.ts +2 -0
- package/dist/kysely-adapter.mjs +1082 -979
- package/dist/types/migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.d.ts +4 -0
- package/dist/types/migrate/migrations/2026-08-11T12:00:00_page_hooks.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +4 -0
- package/dist/types/src/actionExecutions/cleanup.d.ts +3 -0
- package/dist/types/src/db.d.ts +2 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { customAlphabet as e, nanoid as t } from "nanoid";
|
|
2
2
|
import { booleanToInt as n, convertDatesToAdapter as r, dbDateToIso as i, dbDateToIsoRequired as a, getCountAsInt as o, isoToDbDate as s, nowIso as c, removeNullProperties as l, removeUndefinedAndNull as u, stringifyProperties as d } from "@authhero/adapter-interfaces/sql";
|
|
3
3
|
import { sql as f } from "kysely";
|
|
4
|
-
import { LoginSessionState as p,
|
|
5
|
-
import { HTTPException as
|
|
4
|
+
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildSessionRetention as g, clientGrantSchema as _, clientRegistrationTokenTypeSchema as v, codeSchema as y, decodeCursor as ee, emailTemplateSchema as te, encodeCursor as ne, flowSchema as b, formSchema as x, handlerConfigSchema as re, isPlainObject as ie, loginSessionSchema as ae, matchSchema as oe, migrationProviderTypeSchema as se, parseUserId as ce, resourceServerSchema as le, rolloutInsertSchema as ue, rolloutSchema as de, sanitizeLuceneQuery as S, scimMappingEntrySchema as fe, sessionRetentionWindow as pe, tenantOperationEventInsertSchema as me, tenantOperationEventSchema as he, tenantOperationInsertSchema as ge, tenantOperationSchema as _e } from "@authhero/adapter-interfaces";
|
|
5
|
+
import { HTTPException as C } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as ve } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var ye = Object.defineProperty, w = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) ye(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || ye(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, be = 17, xe = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -25,39 +25,39 @@ var ge = Object.defineProperty, C = (e, t) => {
|
|
|
25
25
|
guardian_factor: "gfa_",
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
31
|
-
}
|
|
32
|
-
function ye() {
|
|
33
|
-
return w("organization");
|
|
34
|
-
}
|
|
35
|
-
function be() {
|
|
36
|
-
return w("connection");
|
|
37
|
-
}
|
|
38
|
-
function xe() {
|
|
39
|
-
return w("action");
|
|
28
|
+
function T(t) {
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", be)();
|
|
30
|
+
return `${xe[t]}${n}`;
|
|
40
31
|
}
|
|
41
32
|
function Se() {
|
|
42
|
-
return
|
|
33
|
+
return T("organization");
|
|
43
34
|
}
|
|
44
35
|
function Ce() {
|
|
45
|
-
return
|
|
36
|
+
return T("connection");
|
|
46
37
|
}
|
|
47
38
|
function we() {
|
|
48
|
-
return
|
|
39
|
+
return T("action");
|
|
49
40
|
}
|
|
50
41
|
function Te() {
|
|
51
|
-
return
|
|
42
|
+
return T("action_version");
|
|
52
43
|
}
|
|
53
44
|
function Ee() {
|
|
54
|
-
return
|
|
45
|
+
return T("hook");
|
|
46
|
+
}
|
|
47
|
+
function De() {
|
|
48
|
+
return T("resource_server");
|
|
49
|
+
}
|
|
50
|
+
function Oe() {
|
|
51
|
+
return T("hook_code");
|
|
52
|
+
}
|
|
53
|
+
function ke() {
|
|
54
|
+
return T("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Ae(e) {
|
|
59
59
|
return async (t, n, r) => {
|
|
60
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ??
|
|
60
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ?? we();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,14 +91,14 @@ function De(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function E(e) {
|
|
95
95
|
if (e) try {
|
|
96
96
|
return JSON.parse(e);
|
|
97
97
|
} catch {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function je(e) {
|
|
102
102
|
return async (t, n) => {
|
|
103
103
|
let i = await e.selectFrom("actions").where("actions.tenant_id", "=", t).where("actions.id", "=", n).selectAll().executeTakeFirst();
|
|
104
104
|
if (!i) return null;
|
|
@@ -113,9 +113,9 @@ function ke(e) {
|
|
|
113
113
|
runtime: m.runtime ?? void 0,
|
|
114
114
|
status: m.status || "built",
|
|
115
115
|
deployed_at: s ? new Date(Number(s)).toISOString() : void 0,
|
|
116
|
-
secrets:
|
|
117
|
-
dependencies:
|
|
118
|
-
supported_triggers:
|
|
116
|
+
secrets: E(c),
|
|
117
|
+
dependencies: E(l),
|
|
118
|
+
supported_triggers: E(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -123,19 +123,19 @@ function ke(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Me(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function D(e) {
|
|
130
130
|
return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function O(e, t, n, r, i = [], a = {}) {
|
|
133
133
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
134
134
|
let t = a[e];
|
|
135
135
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
136
136
|
}, l = (e) => {
|
|
137
137
|
let t = a[e];
|
|
138
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
138
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : Me(t);
|
|
139
139
|
}, u = (e, t) => {
|
|
140
140
|
let n = a[e];
|
|
141
141
|
if (n === void 0 || typeof n == "string") return t;
|
|
@@ -148,7 +148,7 @@ function E(e, t, n, r, i = [], a = {}) {
|
|
|
148
148
|
if (n) {
|
|
149
149
|
let [, t, r] = n;
|
|
150
150
|
if (!t || !r) return null;
|
|
151
|
-
let i = t.trim(), a =
|
|
151
|
+
let i = t.trim(), a = D(r.replace(/^"(.*)"$/, "$1").trim());
|
|
152
152
|
return o.has(i) ? e(s(c(i)), "like", `%${a}%`) : e(l(i), "=", u(i, a));
|
|
153
153
|
}
|
|
154
154
|
return null;
|
|
@@ -166,8 +166,8 @@ function E(e, t, n, r, i = [], a = {}) {
|
|
|
166
166
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
167
167
|
else if (e.includes(":")) {
|
|
168
168
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
169
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
170
|
-
} else n = null, r =
|
|
169
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = D(r);
|
|
170
|
+
} else n = null, r = D(e), i = !1;
|
|
171
171
|
return {
|
|
172
172
|
key: n,
|
|
173
173
|
value: r,
|
|
@@ -201,17 +201,17 @@ function E(e, t, n, r, i = [], a = {}) {
|
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/actions/list.ts
|
|
204
|
-
function
|
|
204
|
+
function k(e) {
|
|
205
205
|
if (e) try {
|
|
206
206
|
return JSON.parse(e);
|
|
207
207
|
} catch {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function Ne(e) {
|
|
212
212
|
return async (t, n = {}) => {
|
|
213
213
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
214
|
-
c && (l =
|
|
214
|
+
c && (l = O(e, l, c, ["name"]));
|
|
215
215
|
let u = (await l.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
216
216
|
let { created_at_ts: n, updated_at_ts: i, deployed_at_ts: a, secrets: o, dependencies: s, supported_triggers: c, is_system: l, inherit: u, tenant_id: d, ...f } = e, p = r({
|
|
217
217
|
created_at_ts: n,
|
|
@@ -224,9 +224,9 @@ function je(e) {
|
|
|
224
224
|
runtime: f.runtime ?? void 0,
|
|
225
225
|
status: f.status || "built",
|
|
226
226
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
227
|
-
secrets:
|
|
228
|
-
dependencies:
|
|
229
|
-
supported_triggers:
|
|
227
|
+
secrets: k(o),
|
|
228
|
+
dependencies: k(s),
|
|
229
|
+
supported_triggers: k(c),
|
|
230
230
|
is_system: !!l,
|
|
231
231
|
inherit: !!u
|
|
232
232
|
};
|
|
@@ -248,7 +248,7 @@ function je(e) {
|
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/actions/update.ts
|
|
251
|
-
function
|
|
251
|
+
function Pe(e) {
|
|
252
252
|
if (!e) return [];
|
|
253
253
|
try {
|
|
254
254
|
let t = JSON.parse(e);
|
|
@@ -257,11 +257,11 @@ function Me(e) {
|
|
|
257
257
|
return [];
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Fe(e) {
|
|
261
261
|
return async (t, n, r) => {
|
|
262
262
|
let i = { updated_at_ts: Date.now() };
|
|
263
263
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
264
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
264
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Pe(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
265
265
|
name: e.name,
|
|
266
266
|
value: o.get(e.name)?.value
|
|
267
267
|
} : e);
|
|
@@ -276,23 +276,23 @@ function Ne(e) {
|
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/actions/remove.ts
|
|
279
|
-
function
|
|
279
|
+
function Ie(e) {
|
|
280
280
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/actions/index.ts
|
|
284
|
-
function
|
|
284
|
+
function Le(e) {
|
|
285
285
|
return {
|
|
286
|
-
create:
|
|
287
|
-
get:
|
|
288
|
-
list:
|
|
289
|
-
update:
|
|
290
|
-
remove:
|
|
286
|
+
create: Ae(e),
|
|
287
|
+
get: je(e),
|
|
288
|
+
list: Ne(e),
|
|
289
|
+
update: Fe(e),
|
|
290
|
+
remove: Ie(e)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/actionExecutions/create.ts
|
|
295
|
-
function
|
|
295
|
+
function Re(e) {
|
|
296
296
|
return async (t, n) => {
|
|
297
297
|
let r = Date.now();
|
|
298
298
|
return await e.insertInto("action_executions").values({
|
|
@@ -318,14 +318,14 @@ function Ie(e) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/actionExecutions/get.ts
|
|
321
|
-
function
|
|
321
|
+
function ze(e) {
|
|
322
322
|
if (e) try {
|
|
323
323
|
return JSON.parse(e);
|
|
324
324
|
} catch {
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function Be(e) {
|
|
329
329
|
return async (t, n) => {
|
|
330
330
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
331
331
|
return r ? {
|
|
@@ -333,47 +333,75 @@ function Re(e) {
|
|
|
333
333
|
tenant_id: r.tenant_id,
|
|
334
334
|
trigger_id: r.trigger_id,
|
|
335
335
|
status: r.status,
|
|
336
|
-
results:
|
|
337
|
-
logs:
|
|
336
|
+
results: ze(r.results) ?? [],
|
|
337
|
+
logs: ze(r.logs),
|
|
338
338
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
339
339
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
340
340
|
} : null;
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
|
+
//#region src/actionExecutions/cleanup.ts
|
|
345
|
+
var A = 5e4;
|
|
346
|
+
async function Ve(e) {
|
|
347
|
+
try {
|
|
348
|
+
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
349
|
+
} catch {
|
|
350
|
+
return "sqlite";
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function He(e) {
|
|
354
|
+
let t;
|
|
355
|
+
return async (n) => {
|
|
356
|
+
let r = Date.parse(n);
|
|
357
|
+
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
358
|
+
if (t ??= await Ve(e), t === "sqlite") {
|
|
359
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
360
|
+
return Number(t.numDeletedRows);
|
|
361
|
+
}
|
|
362
|
+
let i = 0, a = A;
|
|
363
|
+
for (; a >= A;) {
|
|
364
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(A).executeTakeFirst();
|
|
365
|
+
a = Number(t.numDeletedRows), i += a;
|
|
366
|
+
}
|
|
367
|
+
return i;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
344
371
|
//#region src/actionExecutions/index.ts
|
|
345
|
-
function
|
|
372
|
+
function Ue(e) {
|
|
346
373
|
return {
|
|
347
|
-
create:
|
|
348
|
-
get:
|
|
374
|
+
create: Re(e),
|
|
375
|
+
get: Be(e),
|
|
376
|
+
cleanup: He(e)
|
|
349
377
|
};
|
|
350
378
|
}
|
|
351
379
|
//#endregion
|
|
352
380
|
//#region src/actionVersions/index.ts
|
|
353
|
-
function
|
|
381
|
+
function We(e) {
|
|
354
382
|
if (e) try {
|
|
355
383
|
return JSON.parse(e);
|
|
356
384
|
} catch {
|
|
357
385
|
return;
|
|
358
386
|
}
|
|
359
387
|
}
|
|
360
|
-
function
|
|
388
|
+
function Ge(e) {
|
|
361
389
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
362
390
|
return {
|
|
363
391
|
...c,
|
|
364
392
|
runtime: s ?? void 0,
|
|
365
393
|
deployed: !!o,
|
|
366
|
-
secrets:
|
|
367
|
-
dependencies:
|
|
368
|
-
supported_triggers:
|
|
394
|
+
secrets: We(r),
|
|
395
|
+
dependencies: We(i),
|
|
396
|
+
supported_triggers: We(a),
|
|
369
397
|
created_at: new Date(Number(t)).toISOString(),
|
|
370
398
|
updated_at: new Date(Number(n)).toISOString()
|
|
371
399
|
};
|
|
372
400
|
}
|
|
373
|
-
function
|
|
401
|
+
function Ke(e) {
|
|
374
402
|
return {
|
|
375
403
|
async create(t, n, r) {
|
|
376
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ??
|
|
404
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? Te(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
377
405
|
let r = ((await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n.action_id).select("number").orderBy("number", "desc").limit(1).executeTakeFirst())?.number ?? 0) + 1;
|
|
378
406
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
379
407
|
deployed: 0,
|
|
@@ -410,10 +438,10 @@ function Ve(e) {
|
|
|
410
438
|
},
|
|
411
439
|
async get(t, n, r) {
|
|
412
440
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
413
|
-
return i ?
|
|
441
|
+
return i ? Ge(i) : null;
|
|
414
442
|
},
|
|
415
443
|
async list(t, n, r = {}) {
|
|
416
|
-
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(
|
|
444
|
+
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(Ge);
|
|
417
445
|
if (!s) return {
|
|
418
446
|
versions: l,
|
|
419
447
|
start: 0,
|
|
@@ -436,7 +464,7 @@ function Ve(e) {
|
|
|
436
464
|
}
|
|
437
465
|
//#endregion
|
|
438
466
|
//#region src/outbox/create.ts
|
|
439
|
-
async function
|
|
467
|
+
async function j(e, t, n, r) {
|
|
440
468
|
await e.insertInto("outbox_events").values({
|
|
441
469
|
id: n,
|
|
442
470
|
tenant_id: t,
|
|
@@ -455,15 +483,15 @@ async function k(e, t, n, r) {
|
|
|
455
483
|
error: null
|
|
456
484
|
}).execute();
|
|
457
485
|
}
|
|
458
|
-
function
|
|
486
|
+
function qe(e) {
|
|
459
487
|
return async (n, r) => {
|
|
460
488
|
let i = t();
|
|
461
|
-
return await
|
|
489
|
+
return await j(e, n, i, r), i;
|
|
462
490
|
};
|
|
463
491
|
}
|
|
464
492
|
//#endregion
|
|
465
493
|
//#region src/users/create.ts
|
|
466
|
-
function
|
|
494
|
+
function Je(e) {
|
|
467
495
|
return async (n, r, i) => {
|
|
468
496
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
469
497
|
...f,
|
|
@@ -498,12 +526,12 @@ function Ue(e) {
|
|
|
498
526
|
};
|
|
499
527
|
await e.insertInto("passwords").values(r).execute();
|
|
500
528
|
}
|
|
501
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await j(e, n, t.id, t);
|
|
502
530
|
};
|
|
503
531
|
try {
|
|
504
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
505
533
|
} catch (e) {
|
|
506
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
534
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new C(409, { message: "User already exists" }) : new C(500, { message: `${e.code}, ${e.message}` });
|
|
507
535
|
}
|
|
508
536
|
return {
|
|
509
537
|
...m,
|
|
@@ -523,21 +551,21 @@ function Ue(e) {
|
|
|
523
551
|
}
|
|
524
552
|
//#endregion
|
|
525
553
|
//#region src/users/user-to-identity.ts
|
|
526
|
-
var
|
|
554
|
+
var Ye = [
|
|
527
555
|
"email",
|
|
528
556
|
"email_verified",
|
|
529
557
|
"phone_number",
|
|
530
558
|
"phone_verified",
|
|
531
559
|
"username"
|
|
532
560
|
];
|
|
533
|
-
function
|
|
561
|
+
function M(e, t = !1) {
|
|
534
562
|
let n = {
|
|
535
563
|
connection: e.connection,
|
|
536
564
|
provider: e.provider,
|
|
537
|
-
user_id:
|
|
565
|
+
user_id: ce(e.user_id).id,
|
|
538
566
|
isSocial: !!e.is_social
|
|
539
567
|
};
|
|
540
|
-
for (let t of
|
|
568
|
+
for (let t of Ye) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
541
569
|
if (!t) {
|
|
542
570
|
let t = {};
|
|
543
571
|
try {
|
|
@@ -555,7 +583,7 @@ function A(e, t = !1) {
|
|
|
555
583
|
}
|
|
556
584
|
//#endregion
|
|
557
585
|
//#region src/users/get.ts
|
|
558
|
-
function
|
|
586
|
+
function Xe(e) {
|
|
559
587
|
return async (t, n) => {
|
|
560
588
|
let [r, i] = await Promise.all([e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t).where("users.user_id", "=", n).selectAll("users").select([
|
|
561
589
|
"user_activity.last_login",
|
|
@@ -577,22 +605,22 @@ function Ge(e) {
|
|
|
577
605
|
app_metadata: JSON.parse(r.app_metadata),
|
|
578
606
|
user_metadata: JSON.parse(r.user_metadata),
|
|
579
607
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
580
|
-
identities: [
|
|
608
|
+
identities: [M(r, !0), ...i.map((e) => M(e))]
|
|
581
609
|
});
|
|
582
610
|
};
|
|
583
611
|
}
|
|
584
612
|
//#endregion
|
|
585
613
|
//#region src/helpers/paginate.ts
|
|
586
|
-
function
|
|
614
|
+
function N(e) {
|
|
587
615
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
588
616
|
}
|
|
589
|
-
function
|
|
617
|
+
function Ze(e, t) {
|
|
590
618
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
591
619
|
return n >= 1 ? n : t;
|
|
592
620
|
}
|
|
593
|
-
async function
|
|
594
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
595
|
-
if (c && c.k !== n.sortKey) throw new
|
|
621
|
+
async function P(e, t, n) {
|
|
622
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = Ze(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? ee(t.from) : null;
|
|
623
|
+
if (c && c.k !== n.sortKey) throw new C(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
596
624
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
597
625
|
else {
|
|
598
626
|
let e = i === "asc" ? f.raw(">") : f.raw("<");
|
|
@@ -601,7 +629,7 @@ async function M(e, t, n) {
|
|
|
601
629
|
let l = await s.limit(o + 1).execute(), u = l.length > o, d = u ? l.slice(0, o) : l, p;
|
|
602
630
|
if (u && d.length > 0) {
|
|
603
631
|
let e = d[d.length - 1], t = r.split(".").pop(), i = a.split(".").pop(), o = e[t];
|
|
604
|
-
p =
|
|
632
|
+
p = ne({
|
|
605
633
|
s: typeof o == "string" || typeof o == "number" || o === null ? o : String(o),
|
|
606
634
|
i: String(e[i]),
|
|
607
635
|
...n.sortKey !== void 0 && { k: n.sortKey }
|
|
@@ -615,7 +643,7 @@ async function M(e, t, n) {
|
|
|
615
643
|
}
|
|
616
644
|
//#endregion
|
|
617
645
|
//#region src/users/list.ts
|
|
618
|
-
var
|
|
646
|
+
var Qe = [
|
|
619
647
|
"user_id",
|
|
620
648
|
"email",
|
|
621
649
|
"email_verified",
|
|
@@ -638,20 +666,20 @@ var qe = [
|
|
|
638
666
|
"login_count",
|
|
639
667
|
"created_at",
|
|
640
668
|
"updated_at"
|
|
641
|
-
],
|
|
669
|
+
], $e = new Set([
|
|
642
670
|
"last_login",
|
|
643
671
|
"last_ip",
|
|
644
672
|
"login_count"
|
|
645
|
-
]),
|
|
673
|
+
]), et = Object.fromEntries(Qe.map((e) => [e, e === "login_count" ? {
|
|
646
674
|
column: "user_activity.login_count",
|
|
647
675
|
defaultValue: 0
|
|
648
|
-
} :
|
|
676
|
+
} : $e.has(e) ? `user_activity.${e}` : `users.${e}`])), tt = [
|
|
649
677
|
"email",
|
|
650
678
|
"name",
|
|
651
679
|
"phone_number",
|
|
652
680
|
"user_id"
|
|
653
681
|
];
|
|
654
|
-
async function
|
|
682
|
+
async function nt(e, t, n) {
|
|
655
683
|
let r = n.map((e) => e.user_id), i = r.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", r).orderBy("created_at", "asc").execute() : [];
|
|
656
684
|
return n.map((e) => {
|
|
657
685
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -665,20 +693,20 @@ async function Ze(e, t, n) {
|
|
|
665
693
|
app_metadata: JSON.parse(e.app_metadata),
|
|
666
694
|
user_metadata: JSON.parse(e.user_metadata),
|
|
667
695
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
668
|
-
identities: [
|
|
696
|
+
identities: [M(e, !0), ...t.map((e) => M(e))]
|
|
669
697
|
});
|
|
670
698
|
});
|
|
671
699
|
}
|
|
672
|
-
function
|
|
700
|
+
function rt(e) {
|
|
673
701
|
return async (t, n = {}) => {
|
|
674
702
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t);
|
|
675
703
|
if (c) {
|
|
676
|
-
let t =
|
|
677
|
-
t && (l =
|
|
704
|
+
let t = S(c, Qe);
|
|
705
|
+
t && (l = O(e, l, t, tt, [], et));
|
|
678
706
|
}
|
|
679
|
-
if (
|
|
680
|
-
if (s?.sort_by && s.sort_by !== "created_at") throw new
|
|
681
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
707
|
+
if (N(n)) {
|
|
708
|
+
if (s?.sort_by && s.sort_by !== "created_at") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
709
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await P(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
682
710
|
"user_activity.last_login",
|
|
683
711
|
"user_activity.last_ip",
|
|
684
712
|
"user_activity.login_count"
|
|
@@ -687,7 +715,7 @@ function Qe(e) {
|
|
|
687
715
|
sortOrder: r,
|
|
688
716
|
idColumn: "users.user_id",
|
|
689
717
|
sortKey: `created_at:${r}`
|
|
690
|
-
}), c = await
|
|
718
|
+
}), c = await nt(e, t, i);
|
|
691
719
|
return {
|
|
692
720
|
users: c,
|
|
693
721
|
start: 0,
|
|
@@ -697,13 +725,13 @@ function Qe(e) {
|
|
|
697
725
|
};
|
|
698
726
|
}
|
|
699
727
|
if (s && s.sort_by) {
|
|
700
|
-
let t =
|
|
728
|
+
let t = et[s.sort_by];
|
|
701
729
|
if (t) {
|
|
702
730
|
let { ref: n } = e.dynamic;
|
|
703
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
731
|
+
l = l.orderBy(typeof t == "string" ? n(t) : Me(t), s.sort_order);
|
|
704
732
|
}
|
|
705
733
|
}
|
|
706
|
-
let u = await
|
|
734
|
+
let u = await nt(e, t, await l.offset(r * i).limit(i).selectAll("users").select([
|
|
707
735
|
"user_activity.last_login",
|
|
708
736
|
"user_activity.last_ip",
|
|
709
737
|
"user_activity.login_count"
|
|
@@ -725,12 +753,12 @@ function Qe(e) {
|
|
|
725
753
|
}
|
|
726
754
|
//#endregion
|
|
727
755
|
//#region src/users/remove.ts
|
|
728
|
-
function
|
|
756
|
+
function it(e) {
|
|
729
757
|
return async (t, n, r) => {
|
|
730
758
|
let i = async (e) => {
|
|
731
759
|
await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "in", (e) => e.selectFrom("users").select("users.user_id").where("users.tenant_id", "=", t).where((e) => e.or([e("users.user_id", "=", n), e("users.linked_to", "=", n)]))).execute(), await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.linked_to", "=", n).execute();
|
|
732
760
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
733
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
761
|
+
for (let n of r?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
734
762
|
return i.length === 1;
|
|
735
763
|
};
|
|
736
764
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -738,14 +766,14 @@ function $e(e) {
|
|
|
738
766
|
}
|
|
739
767
|
//#endregion
|
|
740
768
|
//#region src/utils/flatten.ts
|
|
741
|
-
function
|
|
769
|
+
function F(e, t = "", n = {}) {
|
|
742
770
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
743
771
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
744
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
772
|
+
typeof a == "object" && a && !Array.isArray(a) ? F(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
745
773
|
}
|
|
746
774
|
return n;
|
|
747
775
|
}
|
|
748
|
-
function
|
|
776
|
+
function at(e, t) {
|
|
749
777
|
let n = {};
|
|
750
778
|
for (let [r, i] of Object.entries(e)) {
|
|
751
779
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -762,7 +790,7 @@ function et(e, t) {
|
|
|
762
790
|
}
|
|
763
791
|
//#endregion
|
|
764
792
|
//#region src/userActivity/index.ts
|
|
765
|
-
function
|
|
793
|
+
function ot(e) {
|
|
766
794
|
return {
|
|
767
795
|
user_id: e.user_id,
|
|
768
796
|
last_login: e.last_login ?? void 0,
|
|
@@ -772,18 +800,18 @@ function tt(e) {
|
|
|
772
800
|
last_password_reset: e.last_password_reset ?? void 0
|
|
773
801
|
};
|
|
774
802
|
}
|
|
775
|
-
function
|
|
803
|
+
function st(e) {
|
|
776
804
|
let t = {};
|
|
777
805
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
778
806
|
}
|
|
779
|
-
function
|
|
807
|
+
function ct(e) {
|
|
780
808
|
return {
|
|
781
809
|
async get(t, n) {
|
|
782
810
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
783
|
-
return r ?
|
|
811
|
+
return r ? ot(r) : null;
|
|
784
812
|
},
|
|
785
813
|
async upsert(t, n, r) {
|
|
786
|
-
let i =
|
|
814
|
+
let i = st(r);
|
|
787
815
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
788
816
|
if (Object.keys(i).length === 0) return;
|
|
789
817
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -805,9 +833,9 @@ function rt(e) {
|
|
|
805
833
|
}
|
|
806
834
|
//#endregion
|
|
807
835
|
//#region src/users/update.ts
|
|
808
|
-
function
|
|
836
|
+
function lt(e) {
|
|
809
837
|
return async (t, n, r, i) => {
|
|
810
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
838
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = F({
|
|
811
839
|
...c,
|
|
812
840
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
813
841
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -818,12 +846,12 @@ function it(e) {
|
|
|
818
846
|
}), u = async (e) => {
|
|
819
847
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
820
848
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
821
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
849
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await ct(e).upsert(t, n, {
|
|
822
850
|
last_login: a,
|
|
823
851
|
last_ip: o,
|
|
824
852
|
login_count: s
|
|
825
853
|
});
|
|
826
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
854
|
+
for (let n of i?.outboxEvents ?? []) await j(e, t, n.id, n);
|
|
827
855
|
return !0;
|
|
828
856
|
};
|
|
829
857
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -831,28 +859,28 @@ function it(e) {
|
|
|
831
859
|
}
|
|
832
860
|
//#endregion
|
|
833
861
|
//#region src/users/unlink.ts
|
|
834
|
-
function
|
|
862
|
+
function ut(e) {
|
|
835
863
|
return async (t, n, r, i) => (await e.updateTable("users").set({ linked_to: null }).where("users.tenant_id", "=", t).where("users.user_id", "=", `${r}|${i}`).where("users.linked_to", "=", `${n}`).execute()).length === 1;
|
|
836
864
|
}
|
|
837
865
|
//#endregion
|
|
838
866
|
//#region src/users/index.ts
|
|
839
|
-
function
|
|
840
|
-
let t =
|
|
867
|
+
function dt(e) {
|
|
868
|
+
let t = Je(e);
|
|
841
869
|
return {
|
|
842
870
|
create: t,
|
|
843
871
|
rawCreate: t,
|
|
844
|
-
remove:
|
|
845
|
-
get:
|
|
846
|
-
list:
|
|
847
|
-
update:
|
|
848
|
-
unlink:
|
|
872
|
+
remove: it(e),
|
|
873
|
+
get: Xe(e),
|
|
874
|
+
list: rt(e),
|
|
875
|
+
update: lt(e),
|
|
876
|
+
unlink: ut(e)
|
|
849
877
|
};
|
|
850
878
|
}
|
|
851
879
|
//#endregion
|
|
852
880
|
//#region src/flows/create.ts
|
|
853
|
-
function
|
|
881
|
+
function ft(e) {
|
|
854
882
|
return async (n, r, i) => {
|
|
855
|
-
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
883
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
856
884
|
id: a?.id ?? `af_${t()}`,
|
|
857
885
|
...r,
|
|
858
886
|
actions: r.actions || [],
|
|
@@ -868,7 +896,7 @@ function st(e) {
|
|
|
868
896
|
}
|
|
869
897
|
//#endregion
|
|
870
898
|
//#region src/helpers/parse.ts
|
|
871
|
-
function
|
|
899
|
+
function I(e, t) {
|
|
872
900
|
if (!e) return t;
|
|
873
901
|
try {
|
|
874
902
|
return JSON.parse(e);
|
|
@@ -876,7 +904,7 @@ function P(e, t) {
|
|
|
876
904
|
return t;
|
|
877
905
|
}
|
|
878
906
|
}
|
|
879
|
-
function
|
|
907
|
+
function pt(e) {
|
|
880
908
|
if (e) try {
|
|
881
909
|
let t = JSON.parse(e);
|
|
882
910
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -884,35 +912,35 @@ function ct(e) {
|
|
|
884
912
|
return;
|
|
885
913
|
}
|
|
886
914
|
}
|
|
887
|
-
function
|
|
888
|
-
for (let r in t) r in e && (n[r] =
|
|
915
|
+
function mt(e, t, n = { ...e }) {
|
|
916
|
+
for (let r in t) r in e && (n[r] = I(e[r], t[r]));
|
|
889
917
|
return n;
|
|
890
918
|
}
|
|
891
919
|
//#endregion
|
|
892
920
|
//#region src/flows/get.ts
|
|
893
|
-
function
|
|
921
|
+
function ht(e) {
|
|
894
922
|
return async (t, n) => {
|
|
895
923
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
896
924
|
if (!r) return null;
|
|
897
925
|
let i = {
|
|
898
926
|
...r,
|
|
899
|
-
actions:
|
|
927
|
+
actions: I(r.actions, [])
|
|
900
928
|
};
|
|
901
|
-
return
|
|
929
|
+
return b.parse(l(i));
|
|
902
930
|
};
|
|
903
931
|
}
|
|
904
932
|
//#endregion
|
|
905
933
|
//#region src/flows/list.ts
|
|
906
|
-
function
|
|
934
|
+
function gt(e) {
|
|
907
935
|
return async (t, n = {}) => {
|
|
908
936
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
909
|
-
s && (c =
|
|
937
|
+
s && (c = O(e, c, s, []));
|
|
910
938
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
911
939
|
let t = {
|
|
912
940
|
...e,
|
|
913
|
-
actions:
|
|
941
|
+
actions: I(e.actions, [])
|
|
914
942
|
};
|
|
915
|
-
return
|
|
943
|
+
return b.parse(l(t));
|
|
916
944
|
});
|
|
917
945
|
if (!a) return {
|
|
918
946
|
flows: u,
|
|
@@ -931,7 +959,7 @@ function dt(e) {
|
|
|
931
959
|
}
|
|
932
960
|
//#endregion
|
|
933
961
|
//#region src/flows/update.ts
|
|
934
|
-
function
|
|
962
|
+
function _t(e) {
|
|
935
963
|
return async (t, n, r) => {
|
|
936
964
|
let i = {
|
|
937
965
|
...r,
|
|
@@ -941,7 +969,7 @@ function ft(e) {
|
|
|
941
969
|
let { numUpdatedRows: a } = await e.updateTable("flows").set(i).where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
942
970
|
if (a === 0n) return null;
|
|
943
971
|
let o = await e.selectFrom("flows").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
944
|
-
return o ?
|
|
972
|
+
return o ? b.parse({
|
|
945
973
|
...o,
|
|
946
974
|
actions: o.actions ? JSON.parse(o.actions) : []
|
|
947
975
|
}) : null;
|
|
@@ -949,27 +977,27 @@ function ft(e) {
|
|
|
949
977
|
}
|
|
950
978
|
//#endregion
|
|
951
979
|
//#region src/flows/remove.ts
|
|
952
|
-
function
|
|
980
|
+
function vt(e) {
|
|
953
981
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
954
982
|
}
|
|
955
983
|
//#endregion
|
|
956
984
|
//#region src/flows/index.ts
|
|
957
|
-
function
|
|
985
|
+
function yt(e) {
|
|
958
986
|
return {
|
|
959
|
-
create:
|
|
960
|
-
get:
|
|
961
|
-
list:
|
|
962
|
-
update:
|
|
963
|
-
remove:
|
|
987
|
+
create: ft(e),
|
|
988
|
+
get: ht(e),
|
|
989
|
+
list: gt(e),
|
|
990
|
+
update: _t(e),
|
|
991
|
+
remove: vt(e)
|
|
964
992
|
};
|
|
965
993
|
}
|
|
966
994
|
//#endregion
|
|
967
995
|
//#region src/tenants/utils.ts
|
|
968
|
-
function
|
|
996
|
+
function bt(e) {
|
|
969
997
|
let t = { ...e };
|
|
970
998
|
return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(e.sandbox_versions_available)), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.attack_protection && typeof e.attack_protection == "string" && (t.attack_protection = JSON.parse(e.attack_protection)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), l(t);
|
|
971
999
|
}
|
|
972
|
-
function
|
|
1000
|
+
function xt(e) {
|
|
973
1001
|
let t = { ...e };
|
|
974
1002
|
return d(e, [
|
|
975
1003
|
"session_cookie",
|
|
@@ -992,42 +1020,42 @@ function gt(e) {
|
|
|
992
1020
|
}
|
|
993
1021
|
//#endregion
|
|
994
1022
|
//#region src/tenants/create.ts
|
|
995
|
-
function
|
|
1023
|
+
function St(e) {
|
|
996
1024
|
return async (n, r) => {
|
|
997
1025
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
998
1026
|
...n,
|
|
999
1027
|
id: i?.id ?? n.id ?? t(),
|
|
1000
1028
|
created_at: i?.created_at ?? a,
|
|
1001
1029
|
updated_at: i?.updated_at ?? a
|
|
1002
|
-
}, s =
|
|
1030
|
+
}, s = xt(o);
|
|
1003
1031
|
try {
|
|
1004
1032
|
await e.insertInto("tenants").values(s).execute();
|
|
1005
1033
|
} catch (e) {
|
|
1006
1034
|
let t = e?.message ?? "";
|
|
1007
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
1035
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new C(409, { message: `Tenant with ID '${o.id}' already exists` }) : e;
|
|
1008
1036
|
}
|
|
1009
1037
|
return o;
|
|
1010
1038
|
};
|
|
1011
1039
|
}
|
|
1012
1040
|
//#endregion
|
|
1013
1041
|
//#region src/tenants/get.ts
|
|
1014
|
-
function
|
|
1042
|
+
function Ct(e) {
|
|
1015
1043
|
return async (t) => {
|
|
1016
1044
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1017
|
-
return n ?
|
|
1045
|
+
return n ? bt(n) : null;
|
|
1018
1046
|
};
|
|
1019
1047
|
}
|
|
1020
1048
|
//#endregion
|
|
1021
1049
|
//#region src/tenants/list.ts
|
|
1022
|
-
function
|
|
1050
|
+
function wt(e) {
|
|
1023
1051
|
return async (t) => {
|
|
1024
1052
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1025
1053
|
if (s && s.sort_by) {
|
|
1026
1054
|
let { ref: t } = e.dynamic;
|
|
1027
1055
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1028
1056
|
}
|
|
1029
|
-
c && (n =
|
|
1030
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1057
|
+
c && (n = O(e, n, c, ["friendly_name"]));
|
|
1058
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(bt);
|
|
1031
1059
|
if (!a) return { tenants: l };
|
|
1032
1060
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1033
1061
|
return {
|
|
@@ -1040,10 +1068,10 @@ function yt(e) {
|
|
|
1040
1068
|
}
|
|
1041
1069
|
//#endregion
|
|
1042
1070
|
//#region src/tenants/update.ts
|
|
1043
|
-
function
|
|
1071
|
+
function Tt(e) {
|
|
1044
1072
|
return async (t, n) => {
|
|
1045
1073
|
let r = {
|
|
1046
|
-
...
|
|
1074
|
+
...xt(n),
|
|
1047
1075
|
id: t,
|
|
1048
1076
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1049
1077
|
};
|
|
@@ -1052,29 +1080,29 @@ function bt(e) {
|
|
|
1052
1080
|
}
|
|
1053
1081
|
//#endregion
|
|
1054
1082
|
//#region src/tenants/remove.ts
|
|
1055
|
-
function
|
|
1083
|
+
function Et(e) {
|
|
1056
1084
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1057
1085
|
}
|
|
1058
1086
|
//#endregion
|
|
1059
1087
|
//#region src/tenants/index.ts
|
|
1060
|
-
function
|
|
1088
|
+
function Dt(e) {
|
|
1061
1089
|
return {
|
|
1062
|
-
create:
|
|
1063
|
-
get:
|
|
1064
|
-
list:
|
|
1065
|
-
update:
|
|
1066
|
-
remove:
|
|
1090
|
+
create: St(e),
|
|
1091
|
+
get: Ct(e),
|
|
1092
|
+
list: wt(e),
|
|
1093
|
+
update: Tt(e),
|
|
1094
|
+
remove: Et(e)
|
|
1067
1095
|
};
|
|
1068
1096
|
}
|
|
1069
1097
|
//#endregion
|
|
1070
1098
|
//#region src/logs/create.ts
|
|
1071
|
-
function
|
|
1099
|
+
function Ot(e) {
|
|
1072
1100
|
return e ? JSON.stringify(e) : void 0;
|
|
1073
1101
|
}
|
|
1074
|
-
var
|
|
1075
|
-
function
|
|
1102
|
+
var kt = 256;
|
|
1103
|
+
function At(e) {
|
|
1076
1104
|
return async (n, r) => {
|
|
1077
|
-
let i = r.user_agent?.slice(0,
|
|
1105
|
+
let i = r.user_agent?.slice(0, kt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1078
1106
|
return await e.insertInto("logs").values({
|
|
1079
1107
|
...s,
|
|
1080
1108
|
log_id: a,
|
|
@@ -1083,8 +1111,8 @@ function Tt(e) {
|
|
|
1083
1111
|
description: r.description?.substring(0, 256),
|
|
1084
1112
|
isMobile: +!!r.isMobile,
|
|
1085
1113
|
scope: r.scope,
|
|
1086
|
-
auth0_client:
|
|
1087
|
-
details:
|
|
1114
|
+
auth0_client: Ot(r.auth0_client),
|
|
1115
|
+
details: Ot(r.details)?.substring(0, 8192),
|
|
1088
1116
|
country_code: o?.country_code,
|
|
1089
1117
|
city_name: o?.city_name,
|
|
1090
1118
|
latitude: o?.latitude,
|
|
@@ -1100,7 +1128,7 @@ function Tt(e) {
|
|
|
1100
1128
|
}
|
|
1101
1129
|
//#endregion
|
|
1102
1130
|
//#region src/logs/logs.ts
|
|
1103
|
-
function
|
|
1131
|
+
function jt(e) {
|
|
1104
1132
|
if (!e) return "";
|
|
1105
1133
|
try {
|
|
1106
1134
|
return JSON.parse(e);
|
|
@@ -1108,13 +1136,13 @@ function Et(e) {
|
|
|
1108
1136
|
return e;
|
|
1109
1137
|
}
|
|
1110
1138
|
}
|
|
1111
|
-
function
|
|
1139
|
+
function L(e) {
|
|
1112
1140
|
return {
|
|
1113
1141
|
...e,
|
|
1114
1142
|
client_id: e.client_id,
|
|
1115
1143
|
client_name: e.client_name || "",
|
|
1116
|
-
auth0_client:
|
|
1117
|
-
details:
|
|
1144
|
+
auth0_client: jt(e.auth0_client),
|
|
1145
|
+
details: jt(e.details),
|
|
1118
1146
|
isMobile: !!e.isMobile,
|
|
1119
1147
|
scope: e.scope || void 0,
|
|
1120
1148
|
log_id: e.log_id,
|
|
@@ -1130,7 +1158,7 @@ function F(e) {
|
|
|
1130
1158
|
}
|
|
1131
1159
|
//#endregion
|
|
1132
1160
|
//#region src/logs/list.ts
|
|
1133
|
-
var
|
|
1161
|
+
var Mt = [
|
|
1134
1162
|
"user_id",
|
|
1135
1163
|
"ip",
|
|
1136
1164
|
"type",
|
|
@@ -1156,25 +1184,25 @@ var Dt = [
|
|
|
1156
1184
|
"time_zone",
|
|
1157
1185
|
"continent_code"
|
|
1158
1186
|
];
|
|
1159
|
-
function
|
|
1187
|
+
function Nt(e) {
|
|
1160
1188
|
return async (t, n = {}) => {
|
|
1161
1189
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, from_date: l, to_date: u } = n, d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
1162
1190
|
if (c) {
|
|
1163
|
-
let t =
|
|
1164
|
-
t && (d =
|
|
1191
|
+
let t = S(c, Mt);
|
|
1192
|
+
t && (d = O(e, d, t, [
|
|
1165
1193
|
"user_id",
|
|
1166
1194
|
"ip",
|
|
1167
1195
|
"description"
|
|
1168
1196
|
], ["description"]));
|
|
1169
1197
|
}
|
|
1170
|
-
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())),
|
|
1171
|
-
if (s?.sort_by && s.sort_by !== "date") throw new
|
|
1172
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1198
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), N(n)) {
|
|
1199
|
+
if (s?.sort_by && s.sort_by !== "date") throw new C(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1200
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await P(d.selectAll(), n, {
|
|
1173
1201
|
sortColumn: "date",
|
|
1174
1202
|
sortOrder: e,
|
|
1175
1203
|
idColumn: "log_id",
|
|
1176
1204
|
sortKey: `date:${e}`
|
|
1177
|
-
}), a = t.map(
|
|
1205
|
+
}), a = t.map(L);
|
|
1178
1206
|
return {
|
|
1179
1207
|
logs: a,
|
|
1180
1208
|
start: 0,
|
|
@@ -1189,7 +1217,7 @@ function Ot(e) {
|
|
|
1189
1217
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1190
1218
|
}
|
|
1191
1219
|
f = f.offset(r * i).limit(i);
|
|
1192
|
-
let p = (await f.selectAll().execute()).map(
|
|
1220
|
+
let p = (await f.selectAll().execute()).map(L);
|
|
1193
1221
|
if (!a) return {
|
|
1194
1222
|
logs: p,
|
|
1195
1223
|
start: 0,
|
|
@@ -1207,24 +1235,24 @@ function Ot(e) {
|
|
|
1207
1235
|
}
|
|
1208
1236
|
//#endregion
|
|
1209
1237
|
//#region src/logs/get.ts
|
|
1210
|
-
function
|
|
1238
|
+
function Pt(e) {
|
|
1211
1239
|
return async (t, n) => {
|
|
1212
1240
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1213
|
-
return r ?
|
|
1241
|
+
return r ? L(r) : null;
|
|
1214
1242
|
};
|
|
1215
1243
|
}
|
|
1216
1244
|
//#endregion
|
|
1217
1245
|
//#region src/logs/index.ts
|
|
1218
|
-
function
|
|
1246
|
+
function Ft(e) {
|
|
1219
1247
|
return {
|
|
1220
|
-
create:
|
|
1221
|
-
list:
|
|
1222
|
-
get:
|
|
1248
|
+
create: At(e),
|
|
1249
|
+
list: Nt(e),
|
|
1250
|
+
get: Pt(e)
|
|
1223
1251
|
};
|
|
1224
1252
|
}
|
|
1225
1253
|
//#endregion
|
|
1226
1254
|
//#region src/sessions/get.ts
|
|
1227
|
-
function
|
|
1255
|
+
function It(e) {
|
|
1228
1256
|
return async (t, n) => {
|
|
1229
1257
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1230
1258
|
if (!i) return null;
|
|
@@ -1258,7 +1286,7 @@ function jt(e) {
|
|
|
1258
1286
|
}
|
|
1259
1287
|
//#endregion
|
|
1260
1288
|
//#region src/sessions/create.ts
|
|
1261
|
-
function
|
|
1289
|
+
function Lt(e) {
|
|
1262
1290
|
return async (t, n) => {
|
|
1263
1291
|
let r = Date.now(), i = c(), a = {
|
|
1264
1292
|
...n,
|
|
@@ -1290,12 +1318,12 @@ function Mt(e) {
|
|
|
1290
1318
|
}
|
|
1291
1319
|
//#endregion
|
|
1292
1320
|
//#region src/sessions/remove.ts
|
|
1293
|
-
function
|
|
1321
|
+
function Rt(e) {
|
|
1294
1322
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1295
1323
|
}
|
|
1296
1324
|
//#endregion
|
|
1297
1325
|
//#region src/sessions/update.ts
|
|
1298
|
-
function
|
|
1326
|
+
function zt(e) {
|
|
1299
1327
|
return async (t, n, r) => {
|
|
1300
1328
|
let i = Date.now(), a = {
|
|
1301
1329
|
updated_at_ts: i,
|
|
@@ -1316,10 +1344,10 @@ function Pt(e) {
|
|
|
1316
1344
|
}
|
|
1317
1345
|
//#endregion
|
|
1318
1346
|
//#region src/sessions/list.ts
|
|
1319
|
-
function
|
|
1347
|
+
function Bt(e) {
|
|
1320
1348
|
return async (t, n = {}) => {
|
|
1321
1349
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
1322
|
-
l && (u =
|
|
1350
|
+
l && (u = O(e, u, l, ["user_id", "session_id"]));
|
|
1323
1351
|
let d = u;
|
|
1324
1352
|
if (c && c.sort_by) {
|
|
1325
1353
|
let { ref: t } = e.dynamic;
|
|
@@ -1371,18 +1399,18 @@ function Ft(e) {
|
|
|
1371
1399
|
}
|
|
1372
1400
|
//#endregion
|
|
1373
1401
|
//#region src/sessions/index.ts
|
|
1374
|
-
function
|
|
1402
|
+
function Vt(e) {
|
|
1375
1403
|
return {
|
|
1376
|
-
create:
|
|
1377
|
-
get:
|
|
1378
|
-
list:
|
|
1379
|
-
remove:
|
|
1380
|
-
update:
|
|
1404
|
+
create: Lt(e),
|
|
1405
|
+
get: It(e),
|
|
1406
|
+
list: Bt(e),
|
|
1407
|
+
remove: Rt(e),
|
|
1408
|
+
update: zt(e)
|
|
1381
1409
|
};
|
|
1382
1410
|
}
|
|
1383
1411
|
//#endregion
|
|
1384
1412
|
//#region src/passwords/get.ts
|
|
1385
|
-
function
|
|
1413
|
+
function Ht(e) {
|
|
1386
1414
|
return async (t, n) => {
|
|
1387
1415
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1388
1416
|
if (!r) return null;
|
|
@@ -1395,7 +1423,7 @@ function Lt(e) {
|
|
|
1395
1423
|
}
|
|
1396
1424
|
//#endregion
|
|
1397
1425
|
//#region src/passwords/create.ts
|
|
1398
|
-
function
|
|
1426
|
+
function Ut(e) {
|
|
1399
1427
|
return async (n, r, i) => {
|
|
1400
1428
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1401
1429
|
...r,
|
|
@@ -1413,7 +1441,7 @@ function Rt(e) {
|
|
|
1413
1441
|
}
|
|
1414
1442
|
//#endregion
|
|
1415
1443
|
//#region src/passwords/update.ts
|
|
1416
|
-
function
|
|
1444
|
+
function Wt(e) {
|
|
1417
1445
|
return async (t, n) => {
|
|
1418
1446
|
let r = e.updateTable("passwords").set({
|
|
1419
1447
|
password: n.password,
|
|
@@ -1426,7 +1454,7 @@ function zt(e) {
|
|
|
1426
1454
|
}
|
|
1427
1455
|
//#endregion
|
|
1428
1456
|
//#region src/passwords/list.ts
|
|
1429
|
-
function
|
|
1457
|
+
function Gt(e) {
|
|
1430
1458
|
return async (t, n, r) => {
|
|
1431
1459
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1432
1460
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1437,23 +1465,23 @@ function Bt(e) {
|
|
|
1437
1465
|
}
|
|
1438
1466
|
//#endregion
|
|
1439
1467
|
//#region src/passwords/index.ts
|
|
1440
|
-
function
|
|
1468
|
+
function Kt(e) {
|
|
1441
1469
|
return {
|
|
1442
|
-
create:
|
|
1443
|
-
update:
|
|
1444
|
-
get:
|
|
1445
|
-
list:
|
|
1470
|
+
create: Ut(e),
|
|
1471
|
+
update: Wt(e),
|
|
1472
|
+
get: Ht(e),
|
|
1473
|
+
list: Gt(e)
|
|
1446
1474
|
};
|
|
1447
1475
|
}
|
|
1448
1476
|
//#endregion
|
|
1449
1477
|
//#region src/codes/list.ts
|
|
1450
|
-
function
|
|
1478
|
+
function qt(e) {
|
|
1451
1479
|
return async (t, n = {}) => {
|
|
1452
1480
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1453
|
-
s && (c =
|
|
1481
|
+
s && (c = O(e, c, s, ["code", "login_id"]));
|
|
1454
1482
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1455
1483
|
let { tenant_id: t, ...n } = e;
|
|
1456
|
-
return
|
|
1484
|
+
return y.parse(l(n));
|
|
1457
1485
|
});
|
|
1458
1486
|
if (!a) return {
|
|
1459
1487
|
codes: u,
|
|
@@ -1472,13 +1500,13 @@ function Ht(e) {
|
|
|
1472
1500
|
}
|
|
1473
1501
|
//#endregion
|
|
1474
1502
|
//#region src/codes/expires-at-ts.ts
|
|
1475
|
-
function
|
|
1503
|
+
function Jt(e) {
|
|
1476
1504
|
let t = new Date(e).getTime();
|
|
1477
1505
|
return Number.isNaN(t) ? 0 : t;
|
|
1478
1506
|
}
|
|
1479
1507
|
//#endregion
|
|
1480
1508
|
//#region src/codes/create.ts
|
|
1481
|
-
function
|
|
1509
|
+
function Yt(e) {
|
|
1482
1510
|
return async (t, n) => {
|
|
1483
1511
|
let r = {
|
|
1484
1512
|
...n,
|
|
@@ -1487,18 +1515,18 @@ function Wt(e) {
|
|
|
1487
1515
|
return await e.insertInto("codes").values({
|
|
1488
1516
|
...r,
|
|
1489
1517
|
tenant_id: t,
|
|
1490
|
-
expires_at_ts:
|
|
1518
|
+
expires_at_ts: Jt(r.expires_at)
|
|
1491
1519
|
}).execute(), r;
|
|
1492
1520
|
};
|
|
1493
1521
|
}
|
|
1494
1522
|
//#endregion
|
|
1495
1523
|
//#region src/codes/remove.ts
|
|
1496
|
-
function
|
|
1524
|
+
function Xt(e) {
|
|
1497
1525
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1498
1526
|
}
|
|
1499
1527
|
//#endregion
|
|
1500
1528
|
//#region src/codes/get.ts
|
|
1501
|
-
function
|
|
1529
|
+
function Zt(e) {
|
|
1502
1530
|
return async (t, n, r) => {
|
|
1503
1531
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1504
1532
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1508,44 +1536,44 @@ function Kt(e) {
|
|
|
1508
1536
|
}
|
|
1509
1537
|
//#endregion
|
|
1510
1538
|
//#region src/codes/used.ts
|
|
1511
|
-
function
|
|
1539
|
+
function Qt(e) {
|
|
1512
1540
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numUpdatedRows > 0;
|
|
1513
1541
|
}
|
|
1514
1542
|
//#endregion
|
|
1515
1543
|
//#region src/codes/consume.ts
|
|
1516
|
-
function
|
|
1544
|
+
function $t(e) {
|
|
1517
1545
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).where("codes.used_at", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
1518
1546
|
}
|
|
1519
1547
|
//#endregion
|
|
1520
1548
|
//#region src/codes/cleanup.ts
|
|
1521
|
-
function
|
|
1549
|
+
function en(e) {
|
|
1522
1550
|
return async (t) => {
|
|
1523
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1551
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", Jt(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1524
1552
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1525
1553
|
};
|
|
1526
1554
|
}
|
|
1527
1555
|
//#endregion
|
|
1528
1556
|
//#region src/codes/index.ts
|
|
1529
|
-
function
|
|
1557
|
+
function tn(e) {
|
|
1530
1558
|
return {
|
|
1531
|
-
create:
|
|
1532
|
-
list:
|
|
1533
|
-
remove:
|
|
1534
|
-
used:
|
|
1535
|
-
consume:
|
|
1536
|
-
get:
|
|
1537
|
-
cleanup:
|
|
1559
|
+
create: Yt(e),
|
|
1560
|
+
list: qt(e),
|
|
1561
|
+
remove: Xt(e),
|
|
1562
|
+
used: Qt(e),
|
|
1563
|
+
consume: $t(e),
|
|
1564
|
+
get: Zt(e),
|
|
1565
|
+
cleanup: en(e)
|
|
1538
1566
|
};
|
|
1539
1567
|
}
|
|
1540
1568
|
//#endregion
|
|
1541
1569
|
//#region src/connections/create.ts
|
|
1542
|
-
function
|
|
1570
|
+
function nn(e) {
|
|
1543
1571
|
return async (t, n, r) => {
|
|
1544
1572
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1545
1573
|
delete o.enabled_clients;
|
|
1546
1574
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1547
1575
|
...o,
|
|
1548
|
-
id: i?.id ?? o.id ??
|
|
1576
|
+
id: i?.id ?? o.id ?? Ce(),
|
|
1549
1577
|
is_system: a ? !0 : void 0,
|
|
1550
1578
|
created_at: i?.created_at ?? s,
|
|
1551
1579
|
updated_at: i?.updated_at ?? s
|
|
@@ -1560,7 +1588,7 @@ function Zt(e) {
|
|
|
1560
1588
|
}
|
|
1561
1589
|
//#endregion
|
|
1562
1590
|
//#region src/connections/transform.ts
|
|
1563
|
-
function
|
|
1591
|
+
function R(e) {
|
|
1564
1592
|
let { is_system: t, ...n } = e;
|
|
1565
1593
|
return l({
|
|
1566
1594
|
...n,
|
|
@@ -1568,16 +1596,16 @@ function I(e) {
|
|
|
1568
1596
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1569
1597
|
});
|
|
1570
1598
|
}
|
|
1571
|
-
function
|
|
1572
|
-
return e.map(
|
|
1599
|
+
function rn(e) {
|
|
1600
|
+
return e.map(R);
|
|
1573
1601
|
}
|
|
1574
1602
|
//#endregion
|
|
1575
1603
|
//#region src/connections/list.ts
|
|
1576
|
-
function
|
|
1604
|
+
function an(e) {
|
|
1577
1605
|
return async (t, n = {}) => {
|
|
1578
1606
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1579
|
-
s && (c =
|
|
1580
|
-
let l =
|
|
1607
|
+
s && (c = O(e, c, s, ["user_id", "ip"]));
|
|
1608
|
+
let l = rn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1581
1609
|
if (!a) return {
|
|
1582
1610
|
connections: l,
|
|
1583
1611
|
start: 0,
|
|
@@ -1595,20 +1623,20 @@ function $t(e) {
|
|
|
1595
1623
|
}
|
|
1596
1624
|
//#endregion
|
|
1597
1625
|
//#region src/connections/remove.ts
|
|
1598
|
-
function
|
|
1626
|
+
function on(e) {
|
|
1599
1627
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1600
1628
|
}
|
|
1601
1629
|
//#endregion
|
|
1602
1630
|
//#region src/connections/get.ts
|
|
1603
|
-
function
|
|
1631
|
+
function sn(e) {
|
|
1604
1632
|
return async (t, n) => {
|
|
1605
1633
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1606
|
-
return r ?
|
|
1634
|
+
return r ? R(r) : null;
|
|
1607
1635
|
};
|
|
1608
1636
|
}
|
|
1609
1637
|
//#endregion
|
|
1610
1638
|
//#region src/connections/update.ts
|
|
1611
|
-
function
|
|
1639
|
+
function cn(e) {
|
|
1612
1640
|
return async (t, n, r) => {
|
|
1613
1641
|
let { is_system: i, ...a } = r;
|
|
1614
1642
|
delete a.enabled_clients;
|
|
@@ -1625,18 +1653,18 @@ function nn(e) {
|
|
|
1625
1653
|
}
|
|
1626
1654
|
//#endregion
|
|
1627
1655
|
//#region src/connections/index.ts
|
|
1628
|
-
function
|
|
1656
|
+
function ln(e) {
|
|
1629
1657
|
return {
|
|
1630
|
-
create:
|
|
1631
|
-
get:
|
|
1632
|
-
list:
|
|
1633
|
-
remove:
|
|
1634
|
-
update:
|
|
1658
|
+
create: nn(e),
|
|
1659
|
+
get: sn(e),
|
|
1660
|
+
list: an(e),
|
|
1661
|
+
remove: on(e),
|
|
1662
|
+
update: cn(e)
|
|
1635
1663
|
};
|
|
1636
1664
|
}
|
|
1637
1665
|
//#endregion
|
|
1638
1666
|
//#region src/clients/create.ts
|
|
1639
|
-
function
|
|
1667
|
+
function un(e) {
|
|
1640
1668
|
return async (r, i, a) => {
|
|
1641
1669
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1642
1670
|
...i,
|
|
@@ -1701,7 +1729,7 @@ function an(e) {
|
|
|
1701
1729
|
}
|
|
1702
1730
|
//#endregion
|
|
1703
1731
|
//#region src/clients/get.ts
|
|
1704
|
-
function
|
|
1732
|
+
function dn(e) {
|
|
1705
1733
|
return async (t, n) => {
|
|
1706
1734
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1707
1735
|
if (!r) return null;
|
|
@@ -1747,7 +1775,7 @@ function on(e) {
|
|
|
1747
1775
|
}
|
|
1748
1776
|
//#endregion
|
|
1749
1777
|
//#region src/clients/getByClientId.ts
|
|
1750
|
-
function
|
|
1778
|
+
function fn(e) {
|
|
1751
1779
|
return async (t) => {
|
|
1752
1780
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1753
1781
|
return n ? l({
|
|
@@ -1791,7 +1819,7 @@ function sn(e) {
|
|
|
1791
1819
|
}
|
|
1792
1820
|
//#endregion
|
|
1793
1821
|
//#region src/clients/list.ts
|
|
1794
|
-
function
|
|
1822
|
+
function pn(e) {
|
|
1795
1823
|
return l({
|
|
1796
1824
|
...e,
|
|
1797
1825
|
global: !!e.global,
|
|
@@ -1830,7 +1858,7 @@ function cn(e) {
|
|
|
1830
1858
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1831
1859
|
});
|
|
1832
1860
|
}
|
|
1833
|
-
function
|
|
1861
|
+
function mn(e) {
|
|
1834
1862
|
return async (t, n) => {
|
|
1835
1863
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1836
1864
|
if (n?.q) {
|
|
@@ -1840,12 +1868,12 @@ function ln(e) {
|
|
|
1840
1868
|
r = r.where(t, "=", e[2]);
|
|
1841
1869
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1842
1870
|
}
|
|
1843
|
-
if (
|
|
1844
|
-
let { rows: e, limit: t, next: i } = await
|
|
1871
|
+
if (N(n)) {
|
|
1872
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
1845
1873
|
sortColumn: "created_at",
|
|
1846
1874
|
sortOrder: "desc",
|
|
1847
1875
|
idColumn: "client_id"
|
|
1848
|
-
}), a = e.map(
|
|
1876
|
+
}), a = e.map(pn);
|
|
1849
1877
|
return {
|
|
1850
1878
|
clients: a,
|
|
1851
1879
|
totals: {
|
|
@@ -1878,7 +1906,7 @@ function ln(e) {
|
|
|
1878
1906
|
let a = await r.executeTakeFirst();
|
|
1879
1907
|
c = Number(a?.count || 0);
|
|
1880
1908
|
}
|
|
1881
|
-
let l = s.map(
|
|
1909
|
+
let l = s.map(pn);
|
|
1882
1910
|
return {
|
|
1883
1911
|
clients: l,
|
|
1884
1912
|
totals: {
|
|
@@ -1892,12 +1920,12 @@ function ln(e) {
|
|
|
1892
1920
|
}
|
|
1893
1921
|
//#endregion
|
|
1894
1922
|
//#region src/clients/remove.ts
|
|
1895
|
-
function
|
|
1923
|
+
function hn(e) {
|
|
1896
1924
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1897
1925
|
}
|
|
1898
1926
|
//#endregion
|
|
1899
1927
|
//#region src/clients/update.ts
|
|
1900
|
-
function
|
|
1928
|
+
function gn(e) {
|
|
1901
1929
|
return async (t, r, i) => {
|
|
1902
1930
|
let a = {
|
|
1903
1931
|
...i,
|
|
@@ -1944,31 +1972,31 @@ function dn(e) {
|
|
|
1944
1972
|
}
|
|
1945
1973
|
//#endregion
|
|
1946
1974
|
//#region src/clients/index.ts
|
|
1947
|
-
function
|
|
1975
|
+
function _n(e) {
|
|
1948
1976
|
return {
|
|
1949
|
-
create:
|
|
1950
|
-
get:
|
|
1951
|
-
getByClientId:
|
|
1952
|
-
list:
|
|
1953
|
-
remove:
|
|
1954
|
-
update:
|
|
1977
|
+
create: un(e),
|
|
1978
|
+
get: dn(e),
|
|
1979
|
+
getByClientId: fn(e),
|
|
1980
|
+
list: mn(e),
|
|
1981
|
+
remove: hn(e),
|
|
1982
|
+
update: gn(e)
|
|
1955
1983
|
};
|
|
1956
1984
|
}
|
|
1957
1985
|
//#endregion
|
|
1958
1986
|
//#region src/clientConnections/listByClient.ts
|
|
1959
|
-
function
|
|
1987
|
+
function vn(e) {
|
|
1960
1988
|
return async (t, n) => {
|
|
1961
1989
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1962
1990
|
if (!r) return [];
|
|
1963
1991
|
let i = JSON.parse(r.connections || "[]");
|
|
1964
1992
|
if (i.length === 0) return [];
|
|
1965
|
-
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id,
|
|
1993
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, R(e)]));
|
|
1966
1994
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
1967
1995
|
};
|
|
1968
1996
|
}
|
|
1969
1997
|
//#endregion
|
|
1970
1998
|
//#region src/clientConnections/updateByClient.ts
|
|
1971
|
-
function
|
|
1999
|
+
function yn(e) {
|
|
1972
2000
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
1973
2001
|
connections: JSON.stringify(r),
|
|
1974
2002
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1976,7 +2004,7 @@ function mn(e) {
|
|
|
1976
2004
|
}
|
|
1977
2005
|
//#endregion
|
|
1978
2006
|
//#region src/clientConnections/listByConnection.ts
|
|
1979
|
-
function
|
|
2007
|
+
function bn(e) {
|
|
1980
2008
|
return async (t, n) => {
|
|
1981
2009
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
1982
2010
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -1985,7 +2013,7 @@ function hn(e) {
|
|
|
1985
2013
|
}
|
|
1986
2014
|
//#endregion
|
|
1987
2015
|
//#region src/clientConnections/addClientToConnection.ts
|
|
1988
|
-
function
|
|
2016
|
+
function xn(e) {
|
|
1989
2017
|
return async (t, n, r) => {
|
|
1990
2018
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
1991
2019
|
if (!i) return !1;
|
|
@@ -1998,7 +2026,7 @@ function gn(e) {
|
|
|
1998
2026
|
}
|
|
1999
2027
|
//#endregion
|
|
2000
2028
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2001
|
-
function
|
|
2029
|
+
function Sn(e) {
|
|
2002
2030
|
return async (t, n, r) => {
|
|
2003
2031
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2004
2032
|
if (!i) return !1;
|
|
@@ -2011,18 +2039,18 @@ function _n(e) {
|
|
|
2011
2039
|
}
|
|
2012
2040
|
//#endregion
|
|
2013
2041
|
//#region src/clientConnections/index.ts
|
|
2014
|
-
function
|
|
2042
|
+
function Cn(e) {
|
|
2015
2043
|
return {
|
|
2016
|
-
listByClient:
|
|
2017
|
-
updateByClient:
|
|
2018
|
-
listByConnection:
|
|
2019
|
-
addClientToConnection:
|
|
2020
|
-
removeClientFromConnection:
|
|
2044
|
+
listByClient: vn(e),
|
|
2045
|
+
updateByClient: yn(e),
|
|
2046
|
+
listByConnection: bn(e),
|
|
2047
|
+
addClientToConnection: xn(e),
|
|
2048
|
+
removeClientFromConnection: Sn(e)
|
|
2021
2049
|
};
|
|
2022
2050
|
}
|
|
2023
2051
|
//#endregion
|
|
2024
2052
|
//#region src/clientGrants/create.ts
|
|
2025
|
-
function
|
|
2053
|
+
function wn(e) {
|
|
2026
2054
|
return async (n, r, i) => {
|
|
2027
2055
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? t(), c = a?.created_at ?? o, u = a?.updated_at ?? a?.created_at ?? o, { scope: d, authorization_details_types: f, ...p } = r, m = {
|
|
2028
2056
|
id: s,
|
|
@@ -2050,7 +2078,7 @@ function yn(e) {
|
|
|
2050
2078
|
}
|
|
2051
2079
|
//#endregion
|
|
2052
2080
|
//#region src/clientGrants/get.ts
|
|
2053
|
-
function
|
|
2081
|
+
function Tn(e) {
|
|
2054
2082
|
return async (t, n) => {
|
|
2055
2083
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2056
2084
|
return r ? l({
|
|
@@ -2070,8 +2098,8 @@ function bn(e) {
|
|
|
2070
2098
|
}
|
|
2071
2099
|
//#endregion
|
|
2072
2100
|
//#region src/clientGrants/list.ts
|
|
2073
|
-
function
|
|
2074
|
-
return
|
|
2101
|
+
function En(e) {
|
|
2102
|
+
return _.parse(l({
|
|
2075
2103
|
...e,
|
|
2076
2104
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
2077
2105
|
allow_any_organization: !!e.allow_any_organization,
|
|
@@ -2079,7 +2107,7 @@ function xn(e) {
|
|
|
2079
2107
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2080
2108
|
}));
|
|
2081
2109
|
}
|
|
2082
|
-
function
|
|
2110
|
+
function Dn(e) {
|
|
2083
2111
|
return async (t, n = {}) => {
|
|
2084
2112
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s, sort: c } = n, l = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
|
|
2085
2113
|
if (s) {
|
|
@@ -2090,13 +2118,13 @@ function Sn(e) {
|
|
|
2090
2118
|
let e = +(a === "true");
|
|
2091
2119
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2092
2120
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2093
|
-
} else l =
|
|
2121
|
+
} else l = O(e, l, t, []);
|
|
2094
2122
|
}
|
|
2095
|
-
if (
|
|
2096
|
-
let { rows: e, limit: t, next: r } = await
|
|
2123
|
+
if (N(n)) {
|
|
2124
|
+
let { rows: e, limit: t, next: r } = await P(l.selectAll(), n, {
|
|
2097
2125
|
sortColumn: "created_at",
|
|
2098
2126
|
sortOrder: "desc"
|
|
2099
|
-
}), i = e.map(
|
|
2127
|
+
}), i = e.map(En);
|
|
2100
2128
|
return {
|
|
2101
2129
|
client_grants: i,
|
|
2102
2130
|
start: 0,
|
|
@@ -2110,7 +2138,7 @@ function Sn(e) {
|
|
|
2110
2138
|
let { ref: t } = e.dynamic;
|
|
2111
2139
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2112
2140
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2113
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2141
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(En);
|
|
2114
2142
|
if (!a) return {
|
|
2115
2143
|
client_grants: d,
|
|
2116
2144
|
start: 0,
|
|
@@ -2128,12 +2156,12 @@ function Sn(e) {
|
|
|
2128
2156
|
}
|
|
2129
2157
|
//#endregion
|
|
2130
2158
|
//#region src/clientGrants/remove.ts
|
|
2131
|
-
function
|
|
2159
|
+
function On(e) {
|
|
2132
2160
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2133
2161
|
}
|
|
2134
2162
|
//#endregion
|
|
2135
2163
|
//#region src/clientGrants/update.ts
|
|
2136
|
-
function
|
|
2164
|
+
function kn(e) {
|
|
2137
2165
|
return async (t, n, r) => {
|
|
2138
2166
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2139
2167
|
...s,
|
|
@@ -2144,18 +2172,18 @@ function wn(e) {
|
|
|
2144
2172
|
}
|
|
2145
2173
|
//#endregion
|
|
2146
2174
|
//#region src/clientGrants/index.ts
|
|
2147
|
-
function
|
|
2175
|
+
function An(e) {
|
|
2148
2176
|
return {
|
|
2149
|
-
create:
|
|
2150
|
-
get:
|
|
2151
|
-
list:
|
|
2152
|
-
remove:
|
|
2153
|
-
update:
|
|
2177
|
+
create: wn(e),
|
|
2178
|
+
get: Tn(e),
|
|
2179
|
+
list: Dn(e),
|
|
2180
|
+
remove: On(e),
|
|
2181
|
+
update: kn(e)
|
|
2154
2182
|
};
|
|
2155
2183
|
}
|
|
2156
2184
|
//#endregion
|
|
2157
2185
|
//#region src/clientRegistrationTokens/create.ts
|
|
2158
|
-
function
|
|
2186
|
+
function jn(e) {
|
|
2159
2187
|
return async (t, n) => {
|
|
2160
2188
|
let r = Date.now();
|
|
2161
2189
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2186,12 +2214,12 @@ function En(e) {
|
|
|
2186
2214
|
}
|
|
2187
2215
|
//#endregion
|
|
2188
2216
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2189
|
-
function
|
|
2190
|
-
let t =
|
|
2217
|
+
function Mn(e) {
|
|
2218
|
+
let t = v.safeParse(e);
|
|
2191
2219
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2192
2220
|
return t.data;
|
|
2193
2221
|
}
|
|
2194
|
-
function
|
|
2222
|
+
function Nn(e) {
|
|
2195
2223
|
if (!e) return;
|
|
2196
2224
|
let t;
|
|
2197
2225
|
try {
|
|
@@ -2199,16 +2227,16 @@ function On(e) {
|
|
|
2199
2227
|
} catch {
|
|
2200
2228
|
return;
|
|
2201
2229
|
}
|
|
2202
|
-
return
|
|
2230
|
+
return ie(t) ? t : void 0;
|
|
2203
2231
|
}
|
|
2204
|
-
function
|
|
2232
|
+
function z(e) {
|
|
2205
2233
|
return {
|
|
2206
2234
|
id: e.id,
|
|
2207
2235
|
token_hash: e.token_hash,
|
|
2208
|
-
type:
|
|
2236
|
+
type: Mn(e.type),
|
|
2209
2237
|
client_id: e.client_id ?? void 0,
|
|
2210
2238
|
sub: e.sub ?? void 0,
|
|
2211
|
-
constraints:
|
|
2239
|
+
constraints: Nn(e.constraints),
|
|
2212
2240
|
single_use: !!e.single_use,
|
|
2213
2241
|
expires_at: i(e.expires_at_ts),
|
|
2214
2242
|
used_at: i(e.used_at_ts),
|
|
@@ -2218,38 +2246,38 @@ function L(e) {
|
|
|
2218
2246
|
}
|
|
2219
2247
|
//#endregion
|
|
2220
2248
|
//#region src/clientRegistrationTokens/get.ts
|
|
2221
|
-
function
|
|
2249
|
+
function Pn(e) {
|
|
2222
2250
|
return async (t, n) => {
|
|
2223
2251
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2224
|
-
return r ?
|
|
2252
|
+
return r ? z(r) : null;
|
|
2225
2253
|
};
|
|
2226
2254
|
}
|
|
2227
2255
|
//#endregion
|
|
2228
2256
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2229
|
-
function
|
|
2257
|
+
function Fn(e) {
|
|
2230
2258
|
return async (t, n) => {
|
|
2231
2259
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2232
|
-
return r ?
|
|
2260
|
+
return r ? z(r) : null;
|
|
2233
2261
|
};
|
|
2234
2262
|
}
|
|
2235
2263
|
//#endregion
|
|
2236
2264
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2237
|
-
function
|
|
2238
|
-
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(
|
|
2265
|
+
function In(e) {
|
|
2266
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(z);
|
|
2239
2267
|
}
|
|
2240
2268
|
//#endregion
|
|
2241
2269
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2242
|
-
function
|
|
2270
|
+
function Ln(e) {
|
|
2243
2271
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ used_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("used_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2244
2272
|
}
|
|
2245
2273
|
//#endregion
|
|
2246
2274
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2247
|
-
function
|
|
2275
|
+
function Rn(e) {
|
|
2248
2276
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2249
2277
|
}
|
|
2250
2278
|
//#endregion
|
|
2251
2279
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2252
|
-
function
|
|
2280
|
+
function zn(e) {
|
|
2253
2281
|
return async (t, n, r) => {
|
|
2254
2282
|
let i = await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("client_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
2255
2283
|
return Number(i.numUpdatedRows);
|
|
@@ -2257,29 +2285,29 @@ function Pn(e) {
|
|
|
2257
2285
|
}
|
|
2258
2286
|
//#endregion
|
|
2259
2287
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2260
|
-
function
|
|
2288
|
+
function Bn(e) {
|
|
2261
2289
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2262
2290
|
}
|
|
2263
2291
|
//#endregion
|
|
2264
2292
|
//#region src/clientRegistrationTokens/index.ts
|
|
2265
|
-
function
|
|
2293
|
+
function Vn(e) {
|
|
2266
2294
|
return {
|
|
2267
|
-
create:
|
|
2268
|
-
get:
|
|
2269
|
-
getByHash:
|
|
2270
|
-
listByClient:
|
|
2271
|
-
markUsed:
|
|
2272
|
-
revoke:
|
|
2273
|
-
revokeByClient:
|
|
2274
|
-
remove:
|
|
2295
|
+
create: jn(e),
|
|
2296
|
+
get: Pn(e),
|
|
2297
|
+
getByHash: Fn(e),
|
|
2298
|
+
listByClient: In(e),
|
|
2299
|
+
markUsed: Ln(e),
|
|
2300
|
+
revoke: Rn(e),
|
|
2301
|
+
revokeByClient: zn(e),
|
|
2302
|
+
remove: Bn(e)
|
|
2275
2303
|
};
|
|
2276
2304
|
}
|
|
2277
2305
|
//#endregion
|
|
2278
2306
|
//#region src/keys/list.ts
|
|
2279
|
-
function
|
|
2307
|
+
function Hn(e) {
|
|
2280
2308
|
return async (t = {}) => {
|
|
2281
2309
|
let { page: n = 0, per_page: r = 100, include_totals: i = !1, sort: a, q: s } = t, c = e.selectFrom("keys").where((e) => e.or([e("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()), e("revoked_at", "is", null)]));
|
|
2282
|
-
s && (c =
|
|
2310
|
+
s && (c = O(e, c, s, [
|
|
2283
2311
|
"kid",
|
|
2284
2312
|
"tenant_id",
|
|
2285
2313
|
"connection",
|
|
@@ -2305,7 +2333,7 @@ function Ln(e) {
|
|
|
2305
2333
|
}
|
|
2306
2334
|
//#endregion
|
|
2307
2335
|
//#region src/keys/create.ts
|
|
2308
|
-
function
|
|
2336
|
+
function Un(e) {
|
|
2309
2337
|
return async (t, n) => {
|
|
2310
2338
|
let r = n?.importMetadata;
|
|
2311
2339
|
await e.insertInto("keys").values({
|
|
@@ -2317,21 +2345,21 @@ function Rn(e) {
|
|
|
2317
2345
|
}
|
|
2318
2346
|
//#endregion
|
|
2319
2347
|
//#region src/keys/update.ts
|
|
2320
|
-
function
|
|
2348
|
+
function Wn(e) {
|
|
2321
2349
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2322
2350
|
}
|
|
2323
2351
|
//#endregion
|
|
2324
2352
|
//#region src/keys/index.ts
|
|
2325
|
-
function
|
|
2353
|
+
function Gn(e) {
|
|
2326
2354
|
return {
|
|
2327
|
-
create:
|
|
2328
|
-
list:
|
|
2329
|
-
update:
|
|
2355
|
+
create: Un(e),
|
|
2356
|
+
list: Hn(e),
|
|
2357
|
+
update: Wn(e)
|
|
2330
2358
|
};
|
|
2331
2359
|
}
|
|
2332
2360
|
//#endregion
|
|
2333
2361
|
//#region src/customDomains/create.ts
|
|
2334
|
-
function
|
|
2362
|
+
function Kn(e) {
|
|
2335
2363
|
return async (n, r, i) => {
|
|
2336
2364
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2337
2365
|
status: "pending",
|
|
@@ -2351,35 +2379,35 @@ function Vn(e) {
|
|
|
2351
2379
|
}
|
|
2352
2380
|
//#endregion
|
|
2353
2381
|
//#region src/customDomains/list.ts
|
|
2354
|
-
function
|
|
2382
|
+
function qn(e) {
|
|
2355
2383
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2356
2384
|
...e,
|
|
2357
2385
|
primary: e.primary === 1,
|
|
2358
|
-
domain_metadata:
|
|
2359
|
-
verification:
|
|
2386
|
+
domain_metadata: I(e.domain_metadata, void 0),
|
|
2387
|
+
verification: I(e.verification, void 0)
|
|
2360
2388
|
}));
|
|
2361
2389
|
}
|
|
2362
2390
|
//#endregion
|
|
2363
2391
|
//#region src/customDomains/remove.ts
|
|
2364
|
-
function
|
|
2392
|
+
function Jn(e) {
|
|
2365
2393
|
return async (t, n) => (await e.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).execute()).length > 0;
|
|
2366
2394
|
}
|
|
2367
2395
|
//#endregion
|
|
2368
2396
|
//#region src/customDomains/get.ts
|
|
2369
|
-
function
|
|
2397
|
+
function Yn(e) {
|
|
2370
2398
|
return async (t, n) => {
|
|
2371
2399
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2372
2400
|
return r ? {
|
|
2373
2401
|
...r,
|
|
2374
2402
|
primary: r.primary === 1,
|
|
2375
|
-
domain_metadata:
|
|
2376
|
-
verification:
|
|
2403
|
+
domain_metadata: I(r.domain_metadata, void 0),
|
|
2404
|
+
verification: I(r.verification, void 0)
|
|
2377
2405
|
} : null;
|
|
2378
2406
|
};
|
|
2379
2407
|
}
|
|
2380
2408
|
//#endregion
|
|
2381
2409
|
//#region src/customDomains/update.ts
|
|
2382
|
-
function
|
|
2410
|
+
function Xn(e) {
|
|
2383
2411
|
return async (t, n, r) => {
|
|
2384
2412
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2385
2413
|
...s,
|
|
@@ -2393,31 +2421,31 @@ function Gn(e) {
|
|
|
2393
2421
|
}
|
|
2394
2422
|
//#endregion
|
|
2395
2423
|
//#region src/customDomains/getByDomain.ts
|
|
2396
|
-
function
|
|
2424
|
+
function Zn(e) {
|
|
2397
2425
|
return async (t) => {
|
|
2398
2426
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2399
2427
|
return n ? {
|
|
2400
2428
|
...n,
|
|
2401
2429
|
primary: n.primary === 1,
|
|
2402
|
-
domain_metadata:
|
|
2430
|
+
domain_metadata: I(n.domain_metadata, void 0)
|
|
2403
2431
|
} : null;
|
|
2404
2432
|
};
|
|
2405
2433
|
}
|
|
2406
2434
|
//#endregion
|
|
2407
2435
|
//#region src/customDomains/index.ts
|
|
2408
|
-
function
|
|
2436
|
+
function Qn(e) {
|
|
2409
2437
|
return {
|
|
2410
|
-
create:
|
|
2411
|
-
get:
|
|
2412
|
-
getByDomain:
|
|
2413
|
-
list:
|
|
2414
|
-
remove:
|
|
2415
|
-
update:
|
|
2438
|
+
create: Kn(e),
|
|
2439
|
+
get: Yn(e),
|
|
2440
|
+
getByDomain: Zn(e),
|
|
2441
|
+
list: qn(e),
|
|
2442
|
+
remove: Jn(e),
|
|
2443
|
+
update: Xn(e)
|
|
2416
2444
|
};
|
|
2417
2445
|
}
|
|
2418
2446
|
//#endregion
|
|
2419
2447
|
//#region src/branding/get.ts
|
|
2420
|
-
function
|
|
2448
|
+
function $n(e) {
|
|
2421
2449
|
return async (t) => {
|
|
2422
2450
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2423
2451
|
if (!n) return null;
|
|
@@ -2439,7 +2467,7 @@ function Jn(e) {
|
|
|
2439
2467
|
}
|
|
2440
2468
|
//#endregion
|
|
2441
2469
|
//#region src/branding/set.ts
|
|
2442
|
-
function
|
|
2470
|
+
function er(e) {
|
|
2443
2471
|
return async (t, n) => {
|
|
2444
2472
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2445
2473
|
try {
|
|
@@ -2468,15 +2496,15 @@ function Yn(e) {
|
|
|
2468
2496
|
}
|
|
2469
2497
|
//#endregion
|
|
2470
2498
|
//#region src/branding/index.ts
|
|
2471
|
-
function
|
|
2499
|
+
function tr(e) {
|
|
2472
2500
|
return {
|
|
2473
|
-
get:
|
|
2474
|
-
set:
|
|
2501
|
+
get: $n(e),
|
|
2502
|
+
set: er(e)
|
|
2475
2503
|
};
|
|
2476
2504
|
}
|
|
2477
2505
|
//#endregion
|
|
2478
2506
|
//#region src/universalLoginTemplates/get.ts
|
|
2479
|
-
function
|
|
2507
|
+
function nr(e) {
|
|
2480
2508
|
return async (t) => {
|
|
2481
2509
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2482
2510
|
return n ? { body: n.body } : null;
|
|
@@ -2484,7 +2512,7 @@ function Zn(e) {
|
|
|
2484
2512
|
}
|
|
2485
2513
|
//#endregion
|
|
2486
2514
|
//#region src/universalLoginTemplates/set.ts
|
|
2487
|
-
function
|
|
2515
|
+
function rr(e) {
|
|
2488
2516
|
return async (t, n, r) => {
|
|
2489
2517
|
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : a;
|
|
2490
2518
|
try {
|
|
@@ -2505,26 +2533,26 @@ function Qn(e) {
|
|
|
2505
2533
|
}
|
|
2506
2534
|
//#endregion
|
|
2507
2535
|
//#region src/universalLoginTemplates/delete.ts
|
|
2508
|
-
function
|
|
2536
|
+
function ir(e) {
|
|
2509
2537
|
return async (t) => {
|
|
2510
2538
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2511
2539
|
};
|
|
2512
2540
|
}
|
|
2513
2541
|
//#endregion
|
|
2514
2542
|
//#region src/universalLoginTemplates/index.ts
|
|
2515
|
-
function
|
|
2543
|
+
function ar(e) {
|
|
2516
2544
|
return {
|
|
2517
|
-
get:
|
|
2518
|
-
set:
|
|
2519
|
-
delete:
|
|
2545
|
+
get: nr(e),
|
|
2546
|
+
set: rr(e),
|
|
2547
|
+
delete: ir(e)
|
|
2520
2548
|
};
|
|
2521
2549
|
}
|
|
2522
2550
|
//#endregion
|
|
2523
2551
|
//#region src/hooks/list.ts
|
|
2524
|
-
function
|
|
2552
|
+
function or(e) {
|
|
2525
2553
|
return async (t, n = {}) => {
|
|
2526
2554
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: u } = n, d = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
|
|
2527
|
-
if (u && (d =
|
|
2555
|
+
if (u && (d = O(e, d, u, [
|
|
2528
2556
|
"url",
|
|
2529
2557
|
"form_id",
|
|
2530
2558
|
"template_id",
|
|
@@ -2543,7 +2571,7 @@ function tr(e) {
|
|
|
2543
2571
|
...u,
|
|
2544
2572
|
enabled: !!n,
|
|
2545
2573
|
synchronous: !!i,
|
|
2546
|
-
metadata:
|
|
2574
|
+
metadata: pt(s)
|
|
2547
2575
|
});
|
|
2548
2576
|
});
|
|
2549
2577
|
if (!s) return {
|
|
@@ -2563,7 +2591,7 @@ function tr(e) {
|
|
|
2563
2591
|
}
|
|
2564
2592
|
//#endregion
|
|
2565
2593
|
//#region src/hooks/get.ts
|
|
2566
|
-
function
|
|
2594
|
+
function sr(e) {
|
|
2567
2595
|
return async (t, n) => {
|
|
2568
2596
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2569
2597
|
if (!i) return null;
|
|
@@ -2576,20 +2604,20 @@ function nr(e) {
|
|
|
2576
2604
|
...d,
|
|
2577
2605
|
enabled: !!u.enabled,
|
|
2578
2606
|
synchronous: !!u.synchronous,
|
|
2579
|
-
metadata:
|
|
2607
|
+
metadata: pt(c)
|
|
2580
2608
|
});
|
|
2581
2609
|
};
|
|
2582
2610
|
}
|
|
2583
2611
|
//#endregion
|
|
2584
2612
|
//#region src/hooks/remove.ts
|
|
2585
|
-
function
|
|
2613
|
+
function cr(e) {
|
|
2586
2614
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2587
2615
|
}
|
|
2588
2616
|
//#endregion
|
|
2589
2617
|
//#region src/hooks/create.ts
|
|
2590
|
-
function
|
|
2618
|
+
function lr(e) {
|
|
2591
2619
|
return async (t, n, r) => {
|
|
2592
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id ||
|
|
2620
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Ee()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2593
2621
|
return await e.insertInto("hooks").values({
|
|
2594
2622
|
...p,
|
|
2595
2623
|
hook_id: c,
|
|
@@ -2612,7 +2640,7 @@ function ir(e) {
|
|
|
2612
2640
|
}
|
|
2613
2641
|
//#endregion
|
|
2614
2642
|
//#region src/hooks/update.ts
|
|
2615
|
-
function
|
|
2643
|
+
function ur(e) {
|
|
2616
2644
|
return async (t, n, r) => {
|
|
2617
2645
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2618
2646
|
...o,
|
|
@@ -2626,20 +2654,20 @@ function ar(e) {
|
|
|
2626
2654
|
}
|
|
2627
2655
|
//#endregion
|
|
2628
2656
|
//#region src/hooks/index.ts
|
|
2629
|
-
function
|
|
2657
|
+
function dr(e) {
|
|
2630
2658
|
return {
|
|
2631
|
-
create:
|
|
2632
|
-
get:
|
|
2633
|
-
list:
|
|
2634
|
-
update:
|
|
2635
|
-
remove:
|
|
2659
|
+
create: lr(e),
|
|
2660
|
+
get: sr(e),
|
|
2661
|
+
list: or(e),
|
|
2662
|
+
update: ur(e),
|
|
2663
|
+
remove: cr(e)
|
|
2636
2664
|
};
|
|
2637
2665
|
}
|
|
2638
2666
|
//#endregion
|
|
2639
2667
|
//#region src/hook-code/create.ts
|
|
2640
|
-
function
|
|
2668
|
+
function fr(e) {
|
|
2641
2669
|
return async (t, n, r) => {
|
|
2642
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2670
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Oe();
|
|
2643
2671
|
return await e.insertInto("hook_code").values({
|
|
2644
2672
|
id: c,
|
|
2645
2673
|
tenant_id: t,
|
|
@@ -2659,7 +2687,7 @@ function sr(e) {
|
|
|
2659
2687
|
}
|
|
2660
2688
|
//#endregion
|
|
2661
2689
|
//#region src/hook-code/get.ts
|
|
2662
|
-
function
|
|
2690
|
+
function pr(e) {
|
|
2663
2691
|
return async (t, n) => {
|
|
2664
2692
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2665
2693
|
if (!i) return null;
|
|
@@ -2683,7 +2711,7 @@ function cr(e) {
|
|
|
2683
2711
|
}
|
|
2684
2712
|
//#endregion
|
|
2685
2713
|
//#region src/hook-code/update.ts
|
|
2686
|
-
function
|
|
2714
|
+
function mr(e) {
|
|
2687
2715
|
return async (t, n, r) => {
|
|
2688
2716
|
let i = { updated_at_ts: Date.now() };
|
|
2689
2717
|
return r.code !== void 0 && (i.code = r.code), r.secrets !== void 0 && (i.secrets = JSON.stringify(r.secrets)), (await e.updateTable("hook_code").set(i).where("hook_code.id", "=", n).where("hook_code.tenant_id", "=", t).executeTakeFirst()).numUpdatedRows > 0;
|
|
@@ -2691,22 +2719,22 @@ function lr(e) {
|
|
|
2691
2719
|
}
|
|
2692
2720
|
//#endregion
|
|
2693
2721
|
//#region src/hook-code/remove.ts
|
|
2694
|
-
function
|
|
2722
|
+
function hr(e) {
|
|
2695
2723
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2696
2724
|
}
|
|
2697
2725
|
//#endregion
|
|
2698
2726
|
//#region src/hook-code/index.ts
|
|
2699
|
-
function
|
|
2727
|
+
function gr(e) {
|
|
2700
2728
|
return {
|
|
2701
|
-
create:
|
|
2702
|
-
get:
|
|
2703
|
-
update:
|
|
2704
|
-
remove:
|
|
2729
|
+
create: fr(e),
|
|
2730
|
+
get: pr(e),
|
|
2731
|
+
update: mr(e),
|
|
2732
|
+
remove: hr(e)
|
|
2705
2733
|
};
|
|
2706
2734
|
}
|
|
2707
2735
|
//#endregion
|
|
2708
2736
|
//#region src/themes/create.ts
|
|
2709
|
-
function
|
|
2737
|
+
function _r(e) {
|
|
2710
2738
|
return async (n, r, i, a) => {
|
|
2711
2739
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2712
2740
|
themeId: o?.id || i || t(),
|
|
@@ -2717,20 +2745,20 @@ function fr(e) {
|
|
|
2717
2745
|
...c,
|
|
2718
2746
|
tenant_id: n
|
|
2719
2747
|
};
|
|
2720
|
-
return await e.insertInto("themes").values(
|
|
2748
|
+
return await e.insertInto("themes").values(F(l)).execute(), c;
|
|
2721
2749
|
};
|
|
2722
2750
|
}
|
|
2723
2751
|
//#endregion
|
|
2724
2752
|
//#region src/themes/remove.ts
|
|
2725
|
-
function
|
|
2753
|
+
function vr(e) {
|
|
2726
2754
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2727
2755
|
}
|
|
2728
2756
|
//#endregion
|
|
2729
2757
|
//#region src/themes/get.ts
|
|
2730
|
-
function
|
|
2758
|
+
function yr(e) {
|
|
2731
2759
|
return async (t, n) => {
|
|
2732
2760
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2733
|
-
return r ? l(
|
|
2761
|
+
return r ? l(at({
|
|
2734
2762
|
...r,
|
|
2735
2763
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2736
2764
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2750,9 +2778,9 @@ function mr(e) {
|
|
|
2750
2778
|
}
|
|
2751
2779
|
//#endregion
|
|
2752
2780
|
//#region src/themes/update.ts
|
|
2753
|
-
function
|
|
2781
|
+
function br(e) {
|
|
2754
2782
|
return async (t, n, r) => {
|
|
2755
|
-
let { themeId: i, ...a } = r, o =
|
|
2783
|
+
let { themeId: i, ...a } = r, o = F({
|
|
2756
2784
|
...a,
|
|
2757
2785
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2758
2786
|
});
|
|
@@ -2761,17 +2789,17 @@ function hr(e) {
|
|
|
2761
2789
|
}
|
|
2762
2790
|
//#endregion
|
|
2763
2791
|
//#region src/themes/index.ts
|
|
2764
|
-
function
|
|
2792
|
+
function xr(e) {
|
|
2765
2793
|
return {
|
|
2766
|
-
create:
|
|
2767
|
-
get:
|
|
2768
|
-
remove:
|
|
2769
|
-
update:
|
|
2794
|
+
create: _r(e),
|
|
2795
|
+
get: yr(e),
|
|
2796
|
+
remove: vr(e),
|
|
2797
|
+
update: br(e)
|
|
2770
2798
|
};
|
|
2771
2799
|
}
|
|
2772
2800
|
//#endregion
|
|
2773
2801
|
//#region src/loginSessions/get.ts
|
|
2774
|
-
function
|
|
2802
|
+
function Sr(e) {
|
|
2775
2803
|
return async (t, n) => {
|
|
2776
2804
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2777
2805
|
if (!i) return null;
|
|
@@ -2783,40 +2811,40 @@ function _r(e) {
|
|
|
2783
2811
|
"created_at_ts",
|
|
2784
2812
|
"updated_at_ts",
|
|
2785
2813
|
"expires_at_ts"
|
|
2786
|
-
]), f =
|
|
2814
|
+
]), f = at(l({
|
|
2787
2815
|
...u,
|
|
2788
2816
|
...d,
|
|
2789
2817
|
state: i.state || p.PENDING,
|
|
2790
2818
|
state_data: i.state_data,
|
|
2791
2819
|
failure_reason: i.failure_reason
|
|
2792
2820
|
}), ["auth_strategy"]);
|
|
2793
|
-
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {},
|
|
2821
|
+
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {}, ae.parse(f);
|
|
2794
2822
|
};
|
|
2795
2823
|
}
|
|
2796
2824
|
//#endregion
|
|
2797
2825
|
//#region src/utils/ulid.ts
|
|
2798
|
-
var
|
|
2799
|
-
function
|
|
2826
|
+
var Cr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", B = 32, wr = 10, Tr = 16;
|
|
2827
|
+
function Er(e) {
|
|
2800
2828
|
let t = "";
|
|
2801
|
-
for (let n =
|
|
2829
|
+
for (let n = wr; n > 0; n--) t = Cr.charAt(e % B) + t, e = Math.floor(e / B);
|
|
2802
2830
|
return t;
|
|
2803
2831
|
}
|
|
2804
|
-
function
|
|
2805
|
-
let e = new Uint8Array(
|
|
2832
|
+
function Dr() {
|
|
2833
|
+
let e = new Uint8Array(Tr);
|
|
2806
2834
|
crypto.getRandomValues(e);
|
|
2807
2835
|
let t = "";
|
|
2808
|
-
for (let n = 0; n <
|
|
2836
|
+
for (let n = 0; n < Tr; n++) t += Cr.charAt(e[n] % B);
|
|
2809
2837
|
return t;
|
|
2810
2838
|
}
|
|
2811
|
-
function
|
|
2812
|
-
return
|
|
2839
|
+
function Or() {
|
|
2840
|
+
return Er(Date.now()) + Dr();
|
|
2813
2841
|
}
|
|
2814
2842
|
//#endregion
|
|
2815
2843
|
//#region src/loginSessions/create.ts
|
|
2816
|
-
function
|
|
2844
|
+
function kr(e) {
|
|
2817
2845
|
return async (t, n) => {
|
|
2818
2846
|
let r = c(), i = {
|
|
2819
|
-
id:
|
|
2847
|
+
id: Or(),
|
|
2820
2848
|
...n,
|
|
2821
2849
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2822
2850
|
created_at: r,
|
|
@@ -2824,7 +2852,7 @@ function wr(e) {
|
|
|
2824
2852
|
state: n.state || p.PENDING,
|
|
2825
2853
|
state_data: n.state_data,
|
|
2826
2854
|
failure_reason: n.failure_reason
|
|
2827
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2855
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = F(o);
|
|
2828
2856
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2829
2857
|
...l,
|
|
2830
2858
|
tenant_id: t,
|
|
@@ -2837,7 +2865,7 @@ function wr(e) {
|
|
|
2837
2865
|
}
|
|
2838
2866
|
//#endregion
|
|
2839
2867
|
//#region src/loginSessions/update.ts
|
|
2840
|
-
function
|
|
2868
|
+
function Ar(e) {
|
|
2841
2869
|
return async (t, n, r) => {
|
|
2842
2870
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2843
2871
|
if (c !== void 0) {
|
|
@@ -2847,7 +2875,7 @@ function Tr(e) {
|
|
|
2847
2875
|
...c
|
|
2848
2876
|
}) };
|
|
2849
2877
|
}
|
|
2850
|
-
let d =
|
|
2878
|
+
let d = F(l);
|
|
2851
2879
|
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2852
2880
|
...d,
|
|
2853
2881
|
...u,
|
|
@@ -2858,22 +2886,22 @@ function Tr(e) {
|
|
|
2858
2886
|
}
|
|
2859
2887
|
//#endregion
|
|
2860
2888
|
//#region src/loginSessions/remove.ts
|
|
2861
|
-
function
|
|
2889
|
+
function jr(e) {
|
|
2862
2890
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2863
2891
|
}
|
|
2864
2892
|
//#endregion
|
|
2865
2893
|
//#region src/loginSessions/index.ts
|
|
2866
|
-
function
|
|
2894
|
+
function Mr(e) {
|
|
2867
2895
|
return {
|
|
2868
|
-
create:
|
|
2869
|
-
get:
|
|
2870
|
-
update:
|
|
2871
|
-
remove:
|
|
2896
|
+
create: kr(e),
|
|
2897
|
+
get: Sr(e),
|
|
2898
|
+
update: Ar(e),
|
|
2899
|
+
remove: jr(e)
|
|
2872
2900
|
};
|
|
2873
2901
|
}
|
|
2874
2902
|
//#endregion
|
|
2875
2903
|
//#region src/promptSettings/get.ts
|
|
2876
|
-
function
|
|
2904
|
+
function Nr(e) {
|
|
2877
2905
|
return async (t) => {
|
|
2878
2906
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2879
2907
|
return l({
|
|
@@ -2887,13 +2915,13 @@ function Or(e) {
|
|
|
2887
2915
|
}
|
|
2888
2916
|
//#endregion
|
|
2889
2917
|
//#region src/promptSettings/set.ts
|
|
2890
|
-
function
|
|
2918
|
+
function Pr(e) {
|
|
2891
2919
|
let t = {};
|
|
2892
2920
|
return typeof e.identifier_first == "boolean" && (t.identifier_first = +!!e.identifier_first), typeof e.password_first == "boolean" && (t.password_first = +!!e.password_first), typeof e.webauthn_platform_first_factor == "boolean" && (t.webauthn_platform_first_factor = +!!e.webauthn_platform_first_factor), typeof e.show_last_used_connection == "boolean" && (t.show_last_used_connection = +!!e.show_last_used_connection), e.universal_login_experience && (t.universal_login_experience = e.universal_login_experience), t;
|
|
2893
2921
|
}
|
|
2894
|
-
function
|
|
2922
|
+
function Fr(e) {
|
|
2895
2923
|
return async (t, n) => {
|
|
2896
|
-
let r =
|
|
2924
|
+
let r = Pr(n);
|
|
2897
2925
|
try {
|
|
2898
2926
|
await e.insertInto("prompt_settings").values({
|
|
2899
2927
|
tenant_id: t,
|
|
@@ -2911,15 +2939,15 @@ function Ar(e) {
|
|
|
2911
2939
|
}
|
|
2912
2940
|
//#endregion
|
|
2913
2941
|
//#region src/promptSettings/index.ts
|
|
2914
|
-
function
|
|
2942
|
+
function Ir(e) {
|
|
2915
2943
|
return {
|
|
2916
|
-
get:
|
|
2917
|
-
set:
|
|
2944
|
+
get: Nr(e),
|
|
2945
|
+
set: Fr(e)
|
|
2918
2946
|
};
|
|
2919
2947
|
}
|
|
2920
2948
|
//#endregion
|
|
2921
2949
|
//#region src/emailProvideres/get.ts
|
|
2922
|
-
function
|
|
2950
|
+
function Lr(e) {
|
|
2923
2951
|
return async (t) => {
|
|
2924
2952
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2925
2953
|
if (!n) return null;
|
|
@@ -2934,7 +2962,7 @@ function Mr(e) {
|
|
|
2934
2962
|
}
|
|
2935
2963
|
//#endregion
|
|
2936
2964
|
//#region src/emailProvideres/update.ts
|
|
2937
|
-
function
|
|
2965
|
+
function Rr(e) {
|
|
2938
2966
|
return async (t, n) => {
|
|
2939
2967
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2940
2968
|
await e.updateTable("email_providers").set({
|
|
@@ -2947,7 +2975,7 @@ function Nr(e) {
|
|
|
2947
2975
|
}
|
|
2948
2976
|
//#endregion
|
|
2949
2977
|
//#region src/emailProvideres/create.ts
|
|
2950
|
-
function
|
|
2978
|
+
function zr(e) {
|
|
2951
2979
|
return async (t, n, r) => {
|
|
2952
2980
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2953
2981
|
await e.insertInto("email_providers").values({
|
|
@@ -2963,24 +2991,24 @@ function Pr(e) {
|
|
|
2963
2991
|
}
|
|
2964
2992
|
//#endregion
|
|
2965
2993
|
//#region src/emailProvideres/remove.ts
|
|
2966
|
-
function
|
|
2994
|
+
function Br(e) {
|
|
2967
2995
|
return async (t) => {
|
|
2968
2996
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
2969
2997
|
};
|
|
2970
2998
|
}
|
|
2971
2999
|
//#endregion
|
|
2972
3000
|
//#region src/emailProvideres/index.ts
|
|
2973
|
-
function
|
|
3001
|
+
function Vr(e) {
|
|
2974
3002
|
return {
|
|
2975
|
-
get:
|
|
2976
|
-
create:
|
|
2977
|
-
update:
|
|
2978
|
-
remove:
|
|
3003
|
+
get: Lr(e),
|
|
3004
|
+
create: zr(e),
|
|
3005
|
+
update: Rr(e),
|
|
3006
|
+
remove: Br(e)
|
|
2979
3007
|
};
|
|
2980
3008
|
}
|
|
2981
3009
|
//#endregion
|
|
2982
3010
|
//#region src/emailTemplates/row.ts
|
|
2983
|
-
function
|
|
3011
|
+
function Hr(e) {
|
|
2984
3012
|
let t = {
|
|
2985
3013
|
template: e.template,
|
|
2986
3014
|
body: e.body,
|
|
@@ -2994,20 +3022,20 @@ function Lr(e) {
|
|
|
2994
3022
|
}
|
|
2995
3023
|
//#endregion
|
|
2996
3024
|
//#region src/emailTemplates/get.ts
|
|
2997
|
-
function
|
|
3025
|
+
function Ur(e) {
|
|
2998
3026
|
return async (t, n) => {
|
|
2999
3027
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3000
|
-
return r ?
|
|
3028
|
+
return r ? te.parse(Hr(r)) : null;
|
|
3001
3029
|
};
|
|
3002
3030
|
}
|
|
3003
3031
|
//#endregion
|
|
3004
3032
|
//#region src/emailTemplates/list.ts
|
|
3005
|
-
function
|
|
3006
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) =>
|
|
3033
|
+
function Wr(e) {
|
|
3034
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => te.parse(Hr(e)));
|
|
3007
3035
|
}
|
|
3008
3036
|
//#endregion
|
|
3009
3037
|
//#region src/emailTemplates/create.ts
|
|
3010
|
-
function
|
|
3038
|
+
function Gr(e) {
|
|
3011
3039
|
return async (t, n, r) => {
|
|
3012
3040
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3013
3041
|
return await e.insertInto("email_templates").values({
|
|
@@ -3028,7 +3056,7 @@ function Br(e) {
|
|
|
3028
3056
|
}
|
|
3029
3057
|
//#endregion
|
|
3030
3058
|
//#region src/emailTemplates/update.ts
|
|
3031
|
-
function
|
|
3059
|
+
function Kr(e) {
|
|
3032
3060
|
return async (t, n, r) => {
|
|
3033
3061
|
let i = {};
|
|
3034
3062
|
if (r.body !== void 0 && (i.body = r.body), r.from !== void 0 && (i.from = r.from), r.subject !== void 0 && (i.subject = r.subject), r.syntax !== void 0 && (i.syntax = r.syntax), r.resultUrl !== void 0 && (i.result_url = r.resultUrl), r.urlLifetimeInSeconds !== void 0 && (i.url_lifetime_in_seconds = r.urlLifetimeInSeconds), r.includeEmailInRedirect !== void 0 && (i.include_email_in_redirect = +!!r.includeEmailInRedirect), r.enabled !== void 0 && (i.enabled = +!!r.enabled), Object.keys(i).length === 0) return await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).select("template").executeTakeFirst() !== void 0;
|
|
@@ -3039,7 +3067,7 @@ function Vr(e) {
|
|
|
3039
3067
|
}
|
|
3040
3068
|
//#endregion
|
|
3041
3069
|
//#region src/emailTemplates/remove.ts
|
|
3042
|
-
function
|
|
3070
|
+
function qr(e) {
|
|
3043
3071
|
return async (t, n) => {
|
|
3044
3072
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3045
3073
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3047,18 +3075,18 @@ function Hr(e) {
|
|
|
3047
3075
|
}
|
|
3048
3076
|
//#endregion
|
|
3049
3077
|
//#region src/emailTemplates/index.ts
|
|
3050
|
-
function
|
|
3078
|
+
function Jr(e) {
|
|
3051
3079
|
return {
|
|
3052
|
-
get:
|
|
3053
|
-
list:
|
|
3054
|
-
create:
|
|
3055
|
-
update:
|
|
3056
|
-
remove:
|
|
3080
|
+
get: Ur(e),
|
|
3081
|
+
list: Wr(e),
|
|
3082
|
+
create: Gr(e),
|
|
3083
|
+
update: Kr(e),
|
|
3084
|
+
remove: qr(e)
|
|
3057
3085
|
};
|
|
3058
3086
|
}
|
|
3059
3087
|
//#endregion
|
|
3060
3088
|
//#region src/refreshTokens/get.ts
|
|
3061
|
-
function
|
|
3089
|
+
function Yr(e) {
|
|
3062
3090
|
return async (t, n) => {
|
|
3063
3091
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3064
3092
|
if (!i) return null;
|
|
@@ -3087,7 +3115,7 @@ function Wr(e) {
|
|
|
3087
3115
|
}
|
|
3088
3116
|
//#endregion
|
|
3089
3117
|
//#region src/refreshTokens/getByLookup.ts
|
|
3090
|
-
function
|
|
3118
|
+
function Xr(e) {
|
|
3091
3119
|
return async (t, n) => {
|
|
3092
3120
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3093
3121
|
if (!i) return null;
|
|
@@ -3116,7 +3144,7 @@ function Gr(e) {
|
|
|
3116
3144
|
}
|
|
3117
3145
|
//#endregion
|
|
3118
3146
|
//#region src/refreshTokens/create.ts
|
|
3119
|
-
function
|
|
3147
|
+
function Zr(e) {
|
|
3120
3148
|
return async (t, n) => {
|
|
3121
3149
|
let r = c(), i = {
|
|
3122
3150
|
...n,
|
|
@@ -3146,12 +3174,12 @@ function Kr(e) {
|
|
|
3146
3174
|
}
|
|
3147
3175
|
//#endregion
|
|
3148
3176
|
//#region src/refreshTokens/remove.ts
|
|
3149
|
-
function
|
|
3177
|
+
function Qr(e) {
|
|
3150
3178
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3151
3179
|
}
|
|
3152
3180
|
//#endregion
|
|
3153
3181
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3154
|
-
function
|
|
3182
|
+
function $r(e) {
|
|
3155
3183
|
return async (t, n, r) => {
|
|
3156
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();
|
|
3157
3185
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3159,7 +3187,7 @@ function Jr(e) {
|
|
|
3159
3187
|
}
|
|
3160
3188
|
//#endregion
|
|
3161
3189
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3162
|
-
function
|
|
3190
|
+
function ei(e) {
|
|
3163
3191
|
return async (t, n, r) => {
|
|
3164
3192
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("family_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3165
3193
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3167,7 +3195,7 @@ function Yr(e) {
|
|
|
3167
3195
|
}
|
|
3168
3196
|
//#endregion
|
|
3169
3197
|
//#region src/refreshTokens/update.ts
|
|
3170
|
-
function
|
|
3198
|
+
function ti(e) {
|
|
3171
3199
|
return async (t, n, r, i) => {
|
|
3172
3200
|
let { created_at: a, expires_at: o, idle_expires_at: c, last_exchanged_at: l, revoked_at: u, rotated_at: d, device: f, resource_servers: p, rotating: m, ...h } = r, g = {
|
|
3173
3201
|
...h,
|
|
@@ -3179,19 +3207,19 @@ function Xr(e) {
|
|
|
3179
3207
|
last_exchanged_at_ts: l === void 0 ? void 0 : s(l),
|
|
3180
3208
|
revoked_at_ts: u === void 0 ? void 0 : s(u),
|
|
3181
3209
|
rotated_at_ts: d === void 0 ? void 0 : s(d)
|
|
3182
|
-
}, _ = i?.loginSessionBump, v = _ ? s(_.expires_at) : null,
|
|
3210
|
+
}, _ = i?.loginSessionBump, v = _ ? s(_.expires_at) : null, y = await e.updateTable("refresh_tokens").set(g).where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).executeTakeFirst();
|
|
3183
3211
|
return _?.login_id && v && v > 0 && await e.updateTable("login_sessions").set({
|
|
3184
3212
|
expires_at_ts: v,
|
|
3185
3213
|
updated_at_ts: Date.now()
|
|
3186
|
-
}).where("tenant_id", "=", t).where("id", "=", _.login_id).where("expires_at_ts", "<", v).execute().catch(() => {}), (
|
|
3214
|
+
}).where("tenant_id", "=", t).where("id", "=", _.login_id).where("expires_at_ts", "<", v).execute().catch(() => {}), (y?.numUpdatedRows ?? 0n) > 0n;
|
|
3187
3215
|
};
|
|
3188
3216
|
}
|
|
3189
3217
|
//#endregion
|
|
3190
3218
|
//#region src/refreshTokens/list.ts
|
|
3191
|
-
function
|
|
3219
|
+
function ni(e) {
|
|
3192
3220
|
return async (t, n = {}) => {
|
|
3193
3221
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3194
|
-
l && (u =
|
|
3222
|
+
l && (u = O(e, u, l, ["token", "login_id"]));
|
|
3195
3223
|
let d = u;
|
|
3196
3224
|
if (c && c.sort_by) {
|
|
3197
3225
|
let { ref: t } = e.dynamic;
|
|
@@ -3238,24 +3266,24 @@ function Zr(e) {
|
|
|
3238
3266
|
}
|
|
3239
3267
|
//#endregion
|
|
3240
3268
|
//#region src/refreshTokens/index.ts
|
|
3241
|
-
function
|
|
3269
|
+
function ri(e) {
|
|
3242
3270
|
return {
|
|
3243
|
-
create:
|
|
3244
|
-
get:
|
|
3245
|
-
getByLookup:
|
|
3246
|
-
list:
|
|
3247
|
-
remove:
|
|
3248
|
-
revokeByLoginSession:
|
|
3249
|
-
revokeFamily:
|
|
3250
|
-
update:
|
|
3271
|
+
create: Zr(e),
|
|
3272
|
+
get: Yr(e),
|
|
3273
|
+
getByLookup: Xr(e),
|
|
3274
|
+
list: ni(e),
|
|
3275
|
+
remove: Qr(e),
|
|
3276
|
+
revokeByLoginSession: $r(e),
|
|
3277
|
+
revokeFamily: ei(e),
|
|
3278
|
+
update: ti(e)
|
|
3251
3279
|
};
|
|
3252
3280
|
}
|
|
3253
3281
|
//#endregion
|
|
3254
3282
|
//#region src/cleanup.ts
|
|
3255
|
-
var
|
|
3256
|
-
function
|
|
3283
|
+
var ii = 10080 * 60 * 1e3;
|
|
3284
|
+
function ai(e) {
|
|
3257
3285
|
return async (t) => {
|
|
3258
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3286
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - ii, a = 1e3;
|
|
3259
3287
|
try {
|
|
3260
3288
|
let t = 0;
|
|
3261
3289
|
for (;;) {
|
|
@@ -3286,9 +3314,9 @@ function ei(e) {
|
|
|
3286
3314
|
}
|
|
3287
3315
|
//#endregion
|
|
3288
3316
|
//#region src/forms/create.ts
|
|
3289
|
-
function
|
|
3317
|
+
function oi(e) {
|
|
3290
3318
|
return async (n, r, i) => {
|
|
3291
|
-
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
3319
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3292
3320
|
id: a?.id ?? t(),
|
|
3293
3321
|
...r,
|
|
3294
3322
|
created_at: a?.created_at ?? o,
|
|
@@ -3300,15 +3328,15 @@ function ti(e) {
|
|
|
3300
3328
|
start: JSON.stringify(s.start || {}),
|
|
3301
3329
|
ending: JSON.stringify(s.ending || {}),
|
|
3302
3330
|
tenant_id: n
|
|
3303
|
-
}).execute(),
|
|
3331
|
+
}).execute(), x.parse(s);
|
|
3304
3332
|
};
|
|
3305
3333
|
}
|
|
3306
3334
|
//#endregion
|
|
3307
3335
|
//#region src/forms/list.ts
|
|
3308
|
-
function
|
|
3336
|
+
function si(e) {
|
|
3309
3337
|
return async (t, n = {}) => {
|
|
3310
3338
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3311
|
-
s && (c =
|
|
3339
|
+
s && (c = O(e, c, s, []));
|
|
3312
3340
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3313
3341
|
let t = { ...e };
|
|
3314
3342
|
if (typeof t.nodes == "string") try {
|
|
@@ -3320,7 +3348,7 @@ function ni(e) {
|
|
|
3320
3348
|
if (typeof t.ending == "string") try {
|
|
3321
3349
|
t.ending = JSON.parse(t.ending);
|
|
3322
3350
|
} catch {}
|
|
3323
|
-
return
|
|
3351
|
+
return x.parse(l(t));
|
|
3324
3352
|
});
|
|
3325
3353
|
if (!a) return {
|
|
3326
3354
|
forms: u,
|
|
@@ -3339,7 +3367,7 @@ function ni(e) {
|
|
|
3339
3367
|
}
|
|
3340
3368
|
//#endregion
|
|
3341
3369
|
//#region src/forms/remove.ts
|
|
3342
|
-
function
|
|
3370
|
+
function ci(e) {
|
|
3343
3371
|
return async (t, n) => {
|
|
3344
3372
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3345
3373
|
return r > 0;
|
|
@@ -3347,7 +3375,7 @@ function ri(e) {
|
|
|
3347
3375
|
}
|
|
3348
3376
|
//#endregion
|
|
3349
3377
|
//#region src/forms/get.ts
|
|
3350
|
-
function
|
|
3378
|
+
function li(e) {
|
|
3351
3379
|
return async (t, n) => {
|
|
3352
3380
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3353
3381
|
if (!r) return null;
|
|
@@ -3361,12 +3389,12 @@ function ii(e) {
|
|
|
3361
3389
|
if (typeof i.ending == "string") try {
|
|
3362
3390
|
i.ending = JSON.parse(i.ending);
|
|
3363
3391
|
} catch {}
|
|
3364
|
-
return
|
|
3392
|
+
return x.parse(l(i));
|
|
3365
3393
|
};
|
|
3366
3394
|
}
|
|
3367
3395
|
//#endregion
|
|
3368
3396
|
//#region src/forms/update.ts
|
|
3369
|
-
function
|
|
3397
|
+
function ui(e) {
|
|
3370
3398
|
return async (t, n, r) => {
|
|
3371
3399
|
let i = {
|
|
3372
3400
|
...r,
|
|
@@ -3383,25 +3411,25 @@ function ai(e) {
|
|
|
3383
3411
|
}
|
|
3384
3412
|
//#endregion
|
|
3385
3413
|
//#region src/forms/index.ts
|
|
3386
|
-
function
|
|
3414
|
+
function di(e) {
|
|
3387
3415
|
return {
|
|
3388
|
-
create:
|
|
3389
|
-
get:
|
|
3390
|
-
list:
|
|
3391
|
-
remove:
|
|
3392
|
-
update:
|
|
3416
|
+
create: oi(e),
|
|
3417
|
+
get: li(e),
|
|
3418
|
+
list: si(e),
|
|
3419
|
+
remove: ci(e),
|
|
3420
|
+
update: ui(e)
|
|
3393
3421
|
};
|
|
3394
3422
|
}
|
|
3395
3423
|
//#endregion
|
|
3396
3424
|
//#region src/resourceServers/create.ts
|
|
3397
|
-
function
|
|
3425
|
+
function fi(e) {
|
|
3398
3426
|
return async (t, n, r) => {
|
|
3399
3427
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3400
3428
|
...n,
|
|
3401
|
-
id: i?.id ?? n.id ??
|
|
3429
|
+
id: i?.id ?? n.id ?? De(),
|
|
3402
3430
|
created_at: o,
|
|
3403
3431
|
updated_at: s
|
|
3404
|
-
}, u =
|
|
3432
|
+
}, u = le.parse(c), { verificationKey: d, scopes: f, options: p, skip_consent_for_verifiable_first_party_clients: m, allow_offline_access: h, is_system: g, metadata: _, ...v } = u, y = {
|
|
3405
3433
|
...v,
|
|
3406
3434
|
tenant_id: t,
|
|
3407
3435
|
scopes: f ? JSON.stringify(f) : "[]",
|
|
@@ -3414,12 +3442,12 @@ function si(e) {
|
|
|
3414
3442
|
created_at: o,
|
|
3415
3443
|
updated_at: s
|
|
3416
3444
|
};
|
|
3417
|
-
return await e.insertInto("resource_servers").values(
|
|
3445
|
+
return await e.insertInto("resource_servers").values(y).execute(), l(u);
|
|
3418
3446
|
};
|
|
3419
3447
|
}
|
|
3420
3448
|
//#endregion
|
|
3421
3449
|
//#region src/resourceServers/get.ts
|
|
3422
|
-
function
|
|
3450
|
+
function pi(e) {
|
|
3423
3451
|
return async (t, n) => {
|
|
3424
3452
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3425
3453
|
if (!r) return null;
|
|
@@ -3438,7 +3466,7 @@ function ci(e) {
|
|
|
3438
3466
|
}
|
|
3439
3467
|
//#endregion
|
|
3440
3468
|
//#region src/resourceServers/list.ts
|
|
3441
|
-
function
|
|
3469
|
+
function mi(e) {
|
|
3442
3470
|
return async (t, n = {}) => {
|
|
3443
3471
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
|
|
3444
3472
|
if (s) {
|
|
@@ -3446,7 +3474,7 @@ function li(e) {
|
|
|
3446
3474
|
if (i && !o) {
|
|
3447
3475
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3448
3476
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3449
|
-
} else c =
|
|
3477
|
+
} else c = O(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3450
3478
|
}
|
|
3451
3479
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3452
3480
|
let { verification_key: t, scopes: n, options: r, skip_consent_for_verifiable_first_party_clients: i, allow_offline_access: a, is_system: o, metadata: s, ...c } = e, u = l({
|
|
@@ -3478,7 +3506,7 @@ function li(e) {
|
|
|
3478
3506
|
}
|
|
3479
3507
|
//#endregion
|
|
3480
3508
|
//#region src/resourceServers/remove.ts
|
|
3481
|
-
function
|
|
3509
|
+
function hi(e) {
|
|
3482
3510
|
return async (t, n) => {
|
|
3483
3511
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3484
3512
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3486,7 +3514,7 @@ function ui(e) {
|
|
|
3486
3514
|
}
|
|
3487
3515
|
//#endregion
|
|
3488
3516
|
//#region src/resourceServers/update.ts
|
|
3489
|
-
function
|
|
3517
|
+
function gi(e) {
|
|
3490
3518
|
return async (t, n, r) => {
|
|
3491
3519
|
let { verificationKey: i, scopes: a, options: o, skip_consent_for_verifiable_first_party_clients: s, allow_offline_access: c, is_system: l, metadata: u, ...d } = r, f = {
|
|
3492
3520
|
...d,
|
|
@@ -3506,18 +3534,18 @@ function di(e) {
|
|
|
3506
3534
|
}
|
|
3507
3535
|
//#endregion
|
|
3508
3536
|
//#region src/resourceServers/index.ts
|
|
3509
|
-
function
|
|
3537
|
+
function _i(e) {
|
|
3510
3538
|
return {
|
|
3511
|
-
create:
|
|
3512
|
-
get:
|
|
3513
|
-
list:
|
|
3514
|
-
remove:
|
|
3515
|
-
update:
|
|
3539
|
+
create: fi(e),
|
|
3540
|
+
get: pi(e),
|
|
3541
|
+
list: mi(e),
|
|
3542
|
+
remove: hi(e),
|
|
3543
|
+
update: gi(e)
|
|
3516
3544
|
};
|
|
3517
3545
|
}
|
|
3518
3546
|
//#endregion
|
|
3519
3547
|
//#region src/roles/create.ts
|
|
3520
|
-
function
|
|
3548
|
+
function vi(e) {
|
|
3521
3549
|
return async (n, r, i) => {
|
|
3522
3550
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.created_at ?? o, c = a?.updated_at ?? o, l = a?.id || r.id || t(), { is_system: u, id: d, metadata: f, ...p } = r, m = {
|
|
3523
3551
|
id: l,
|
|
@@ -3540,7 +3568,7 @@ function pi(e) {
|
|
|
3540
3568
|
}
|
|
3541
3569
|
//#endregion
|
|
3542
3570
|
//#region src/roles/get.ts
|
|
3543
|
-
function
|
|
3571
|
+
function yi(e) {
|
|
3544
3572
|
return async (t, n) => {
|
|
3545
3573
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3546
3574
|
if (!r) return null;
|
|
@@ -3554,10 +3582,10 @@ function mi(e) {
|
|
|
3554
3582
|
}
|
|
3555
3583
|
//#endregion
|
|
3556
3584
|
//#region src/roles/list.ts
|
|
3557
|
-
function
|
|
3585
|
+
function bi(e) {
|
|
3558
3586
|
return async (t, n) => {
|
|
3559
3587
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3560
|
-
n.q && (r =
|
|
3588
|
+
n.q && (r = O(e, r, n.q, ["name"]));
|
|
3561
3589
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3562
3590
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3563
3591
|
return {
|
|
@@ -3583,7 +3611,7 @@ function hi(e) {
|
|
|
3583
3611
|
}
|
|
3584
3612
|
//#endregion
|
|
3585
3613
|
//#region src/roles/update.ts
|
|
3586
|
-
function
|
|
3614
|
+
function xi(e) {
|
|
3587
3615
|
return async (t, n, r) => {
|
|
3588
3616
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3589
3617
|
...o,
|
|
@@ -3596,7 +3624,7 @@ function gi(e) {
|
|
|
3596
3624
|
}
|
|
3597
3625
|
//#endregion
|
|
3598
3626
|
//#region src/roles/remove.ts
|
|
3599
|
-
function
|
|
3627
|
+
function Si(e) {
|
|
3600
3628
|
return async (t, n) => {
|
|
3601
3629
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3602
3630
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3604,18 +3632,18 @@ function _i(e) {
|
|
|
3604
3632
|
}
|
|
3605
3633
|
//#endregion
|
|
3606
3634
|
//#region src/roles/index.ts
|
|
3607
|
-
function
|
|
3635
|
+
function Ci(e) {
|
|
3608
3636
|
return {
|
|
3609
|
-
create:
|
|
3610
|
-
get:
|
|
3611
|
-
list:
|
|
3612
|
-
update:
|
|
3613
|
-
remove:
|
|
3637
|
+
create: vi(e),
|
|
3638
|
+
get: yi(e),
|
|
3639
|
+
list: bi(e),
|
|
3640
|
+
update: xi(e),
|
|
3641
|
+
remove: Si(e)
|
|
3614
3642
|
};
|
|
3615
3643
|
}
|
|
3616
3644
|
//#endregion
|
|
3617
3645
|
//#region src/role-permissions/assign.ts
|
|
3618
|
-
function
|
|
3646
|
+
function wi(e) {
|
|
3619
3647
|
return async (t, n, r, i) => {
|
|
3620
3648
|
if (r.length === 0) return !0;
|
|
3621
3649
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3644,7 +3672,7 @@ function yi(e) {
|
|
|
3644
3672
|
}
|
|
3645
3673
|
//#endregion
|
|
3646
3674
|
//#region src/role-permissions/remove.ts
|
|
3647
|
-
function
|
|
3675
|
+
function Ti(e) {
|
|
3648
3676
|
return async (t, n, r) => {
|
|
3649
3677
|
if (r.length === 0) return !0;
|
|
3650
3678
|
try {
|
|
@@ -3656,7 +3684,7 @@ function bi(e) {
|
|
|
3656
3684
|
}
|
|
3657
3685
|
//#endregion
|
|
3658
3686
|
//#region src/role-permissions/list.ts
|
|
3659
|
-
function
|
|
3687
|
+
function Ei(e) {
|
|
3660
3688
|
return async (t, n, r = {}) => {
|
|
3661
3689
|
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s = e.selectFrom("role_permissions").leftJoin("resource_servers", (e) => e.onRef("role_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("role_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3662
3690
|
"role_permissions.role_id",
|
|
@@ -3677,16 +3705,16 @@ function xi(e) {
|
|
|
3677
3705
|
}
|
|
3678
3706
|
//#endregion
|
|
3679
3707
|
//#region src/role-permissions/index.ts
|
|
3680
|
-
function
|
|
3708
|
+
function Di(e) {
|
|
3681
3709
|
return {
|
|
3682
|
-
assign:
|
|
3683
|
-
remove:
|
|
3684
|
-
list:
|
|
3710
|
+
assign: wi(e),
|
|
3711
|
+
remove: Ti(e),
|
|
3712
|
+
list: Ei(e)
|
|
3685
3713
|
};
|
|
3686
3714
|
}
|
|
3687
3715
|
//#endregion
|
|
3688
3716
|
//#region src/grants/create.ts
|
|
3689
|
-
function
|
|
3717
|
+
function Oi(e) {
|
|
3690
3718
|
return async (n, r) => {
|
|
3691
3719
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = r.scope ?? [], o = r.audience ?? "", s = await e.selectFrom("grants").where("tenant_id", "=", n).where("user_id", "=", r.user_id).where("client_id", "=", r.clientID).where("audience", "=", o).selectAll().executeTakeFirst();
|
|
3692
3720
|
if (s) {
|
|
@@ -3723,7 +3751,7 @@ function Ci(e) {
|
|
|
3723
3751
|
}
|
|
3724
3752
|
//#endregion
|
|
3725
3753
|
//#region src/grants/get.ts
|
|
3726
|
-
function
|
|
3754
|
+
function ki(e) {
|
|
3727
3755
|
return async (t, n, r, i) => {
|
|
3728
3756
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3729
3757
|
return a ? {
|
|
@@ -3737,10 +3765,10 @@ function wi(e) {
|
|
|
3737
3765
|
}
|
|
3738
3766
|
//#endregion
|
|
3739
3767
|
//#region src/grants/list.ts
|
|
3740
|
-
function
|
|
3768
|
+
function Ai(e) {
|
|
3741
3769
|
return async (t, n = {}) => {
|
|
3742
3770
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("grants").where("grants.tenant_id", "=", t);
|
|
3743
|
-
c && (l =
|
|
3771
|
+
c && (l = O(e, l, c, [
|
|
3744
3772
|
"user_id",
|
|
3745
3773
|
"client_id",
|
|
3746
3774
|
"audience"
|
|
@@ -3775,26 +3803,26 @@ function Ti(e) {
|
|
|
3775
3803
|
}
|
|
3776
3804
|
//#endregion
|
|
3777
3805
|
//#region src/grants/remove.ts
|
|
3778
|
-
function
|
|
3806
|
+
function ji(e) {
|
|
3779
3807
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3780
3808
|
}
|
|
3781
|
-
function
|
|
3809
|
+
function Mi(e) {
|
|
3782
3810
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3783
3811
|
}
|
|
3784
3812
|
//#endregion
|
|
3785
3813
|
//#region src/grants/index.ts
|
|
3786
|
-
function
|
|
3814
|
+
function Ni(e) {
|
|
3787
3815
|
return {
|
|
3788
|
-
create:
|
|
3789
|
-
get:
|
|
3790
|
-
list:
|
|
3791
|
-
remove:
|
|
3792
|
-
removeByUser:
|
|
3816
|
+
create: Oi(e),
|
|
3817
|
+
get: ki(e),
|
|
3818
|
+
list: Ai(e),
|
|
3819
|
+
remove: ji(e),
|
|
3820
|
+
removeByUser: Mi(e)
|
|
3793
3821
|
};
|
|
3794
3822
|
}
|
|
3795
3823
|
//#endregion
|
|
3796
3824
|
//#region src/user-permissions/create.ts
|
|
3797
|
-
function
|
|
3825
|
+
function Pi(e) {
|
|
3798
3826
|
return async (t, n, r, i, a) => {
|
|
3799
3827
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3800
3828
|
try {
|
|
@@ -3814,7 +3842,7 @@ function ki(e) {
|
|
|
3814
3842
|
}
|
|
3815
3843
|
//#endregion
|
|
3816
3844
|
//#region src/user-permissions/remove.ts
|
|
3817
|
-
function
|
|
3845
|
+
function Fi(e) {
|
|
3818
3846
|
return async (t, n, r, i) => {
|
|
3819
3847
|
try {
|
|
3820
3848
|
let a = e.deleteFrom("user_permissions").where("tenant_id", "=", t).where("user_id", "=", n).where("resource_server_identifier", "=", r.resource_server_identifier).where("permission_name", "=", r.permission_name);
|
|
@@ -3826,7 +3854,7 @@ function Ai(e) {
|
|
|
3826
3854
|
}
|
|
3827
3855
|
//#endregion
|
|
3828
3856
|
//#region src/user-permissions/list.ts
|
|
3829
|
-
function
|
|
3857
|
+
function Ii(e) {
|
|
3830
3858
|
return async (t, n, r, i) => {
|
|
3831
3859
|
let a = e.selectFrom("user_permissions").leftJoin("resource_servers", (e) => e.onRef("user_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("user_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3832
3860
|
"user_permissions.resource_server_identifier",
|
|
@@ -3849,17 +3877,17 @@ function ji(e) {
|
|
|
3849
3877
|
}
|
|
3850
3878
|
//#endregion
|
|
3851
3879
|
//#region src/user-permissions/index.ts
|
|
3852
|
-
function
|
|
3880
|
+
function Li(e) {
|
|
3853
3881
|
return {
|
|
3854
|
-
create:
|
|
3855
|
-
remove:
|
|
3856
|
-
list:
|
|
3882
|
+
create: Pi(e),
|
|
3883
|
+
remove: Fi(e),
|
|
3884
|
+
list: Ii(e)
|
|
3857
3885
|
};
|
|
3858
3886
|
}
|
|
3859
3887
|
//#endregion
|
|
3860
3888
|
//#region src/user-permissions/adapter.ts
|
|
3861
|
-
function
|
|
3862
|
-
let t =
|
|
3889
|
+
function Ri(e) {
|
|
3890
|
+
let t = Li(e);
|
|
3863
3891
|
return {
|
|
3864
3892
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3865
3893
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3868,7 +3896,7 @@ function Ni(e) {
|
|
|
3868
3896
|
}
|
|
3869
3897
|
//#endregion
|
|
3870
3898
|
//#region src/user-roles/list.ts
|
|
3871
|
-
function
|
|
3899
|
+
function zi(e) {
|
|
3872
3900
|
return async (t, n, r, i) => {
|
|
3873
3901
|
let a = e.selectFrom("user_roles as ur").innerJoin("roles as r", (e) => e.onRef("ur.role_id", "=", "r.id").onRef("ur.tenant_id", "=", "r.tenant_id")).select([
|
|
3874
3902
|
"r.id",
|
|
@@ -3882,11 +3910,11 @@ function Pi(e) {
|
|
|
3882
3910
|
}
|
|
3883
3911
|
//#endregion
|
|
3884
3912
|
//#region src/user-roles/list-users.ts
|
|
3885
|
-
function
|
|
3913
|
+
function Bi(e) {
|
|
3886
3914
|
return async (t, n, r) => {
|
|
3887
3915
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3888
|
-
if (
|
|
3889
|
-
let { rows: e, limit: t, next: n } = await
|
|
3916
|
+
if (N(r)) {
|
|
3917
|
+
let { rows: e, limit: t, next: n } = await P(i, r, {
|
|
3890
3918
|
sortColumn: "user_id",
|
|
3891
3919
|
sortOrder: "asc",
|
|
3892
3920
|
idColumn: "user_id"
|
|
@@ -3910,7 +3938,7 @@ function Fi(e) {
|
|
|
3910
3938
|
}
|
|
3911
3939
|
//#endregion
|
|
3912
3940
|
//#region src/user-roles/create.ts
|
|
3913
|
-
function
|
|
3941
|
+
function Vi(e) {
|
|
3914
3942
|
return async (t, n, r, i, a) => {
|
|
3915
3943
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3916
3944
|
try {
|
|
@@ -3928,7 +3956,7 @@ function Ii(e) {
|
|
|
3928
3956
|
}
|
|
3929
3957
|
//#endregion
|
|
3930
3958
|
//#region src/user-roles/remove.ts
|
|
3931
|
-
function
|
|
3959
|
+
function Hi(e) {
|
|
3932
3960
|
return async (t, n, r, i) => {
|
|
3933
3961
|
try {
|
|
3934
3962
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3940,18 +3968,18 @@ function Li(e) {
|
|
|
3940
3968
|
}
|
|
3941
3969
|
//#endregion
|
|
3942
3970
|
//#region src/user-roles/index.ts
|
|
3943
|
-
function
|
|
3971
|
+
function Ui(e) {
|
|
3944
3972
|
return {
|
|
3945
|
-
list:
|
|
3946
|
-
listUsers:
|
|
3947
|
-
create:
|
|
3948
|
-
remove:
|
|
3973
|
+
list: zi(e),
|
|
3974
|
+
listUsers: Bi(e),
|
|
3975
|
+
create: Vi(e),
|
|
3976
|
+
remove: Hi(e)
|
|
3949
3977
|
};
|
|
3950
3978
|
}
|
|
3951
3979
|
//#endregion
|
|
3952
3980
|
//#region src/user-roles/adapter.ts
|
|
3953
|
-
function
|
|
3954
|
-
let t =
|
|
3981
|
+
function Wi(e) {
|
|
3982
|
+
let t = Ui(e);
|
|
3955
3983
|
return {
|
|
3956
3984
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3957
3985
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3961,11 +3989,11 @@ function zi(e) {
|
|
|
3961
3989
|
}
|
|
3962
3990
|
//#endregion
|
|
3963
3991
|
//#region src/organizations/create.ts
|
|
3964
|
-
function
|
|
3992
|
+
function Gi(e) {
|
|
3965
3993
|
return async (t, n, r) => {
|
|
3966
3994
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3967
3995
|
...n,
|
|
3968
|
-
id: i?.id || n.id ||
|
|
3996
|
+
id: i?.id || n.id || Se(),
|
|
3969
3997
|
tenant_id: t,
|
|
3970
3998
|
created_at: i?.created_at ?? a,
|
|
3971
3999
|
updated_at: i?.updated_at ?? a,
|
|
@@ -3977,7 +4005,7 @@ function Bi(e) {
|
|
|
3977
4005
|
try {
|
|
3978
4006
|
await e.insertInto("organizations").values(o).execute();
|
|
3979
4007
|
} catch (e) {
|
|
3980
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4008
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new C(409, { message: "Organization already exists" }) : e;
|
|
3981
4009
|
}
|
|
3982
4010
|
return {
|
|
3983
4011
|
...n,
|
|
@@ -3989,7 +4017,7 @@ function Bi(e) {
|
|
|
3989
4017
|
}
|
|
3990
4018
|
//#endregion
|
|
3991
4019
|
//#region src/organizations/get.ts
|
|
3992
|
-
function
|
|
4020
|
+
function Ki(e) {
|
|
3993
4021
|
return async (t, n) => {
|
|
3994
4022
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3995
4023
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4003,16 +4031,16 @@ function Vi(e) {
|
|
|
4003
4031
|
}
|
|
4004
4032
|
//#endregion
|
|
4005
4033
|
//#region src/organizations/list.ts
|
|
4006
|
-
var
|
|
4007
|
-
function
|
|
4034
|
+
var V = ["name", "display_name"];
|
|
4035
|
+
function qi(e) {
|
|
4008
4036
|
return async (t, n) => {
|
|
4009
4037
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4010
4038
|
if (n?.q) {
|
|
4011
|
-
let t =
|
|
4012
|
-
t && (r =
|
|
4039
|
+
let t = S(n.q, V);
|
|
4040
|
+
t && (r = O(e, r, t, V));
|
|
4013
4041
|
}
|
|
4014
|
-
if (
|
|
4015
|
-
let { rows: e, limit: t, next: i } = await
|
|
4042
|
+
if (N(n)) {
|
|
4043
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
4016
4044
|
sortColumn: "created_at",
|
|
4017
4045
|
sortOrder: "desc"
|
|
4018
4046
|
}), a = e.map((e) => l({
|
|
@@ -4045,8 +4073,8 @@ function Hi(e) {
|
|
|
4045
4073
|
if (n?.include_totals) {
|
|
4046
4074
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4047
4075
|
if (n?.q) {
|
|
4048
|
-
let t =
|
|
4049
|
-
t && (r =
|
|
4076
|
+
let t = S(n.q, V);
|
|
4077
|
+
t && (r = O(e, r, t, V));
|
|
4050
4078
|
}
|
|
4051
4079
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4052
4080
|
u = Number(i?.count || 0);
|
|
@@ -4069,12 +4097,12 @@ function Hi(e) {
|
|
|
4069
4097
|
}
|
|
4070
4098
|
//#endregion
|
|
4071
4099
|
//#region src/organizations/remove.ts
|
|
4072
|
-
function
|
|
4100
|
+
function Ji(e) {
|
|
4073
4101
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4074
4102
|
}
|
|
4075
4103
|
//#endregion
|
|
4076
4104
|
//#region src/organizations/update.ts
|
|
4077
|
-
function
|
|
4105
|
+
function Yi(e) {
|
|
4078
4106
|
return async (t, n, r) => {
|
|
4079
4107
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4080
4108
|
...c,
|
|
@@ -4090,18 +4118,18 @@ function Wi(e) {
|
|
|
4090
4118
|
}
|
|
4091
4119
|
//#endregion
|
|
4092
4120
|
//#region src/organizations/index.ts
|
|
4093
|
-
function
|
|
4121
|
+
function Xi(e) {
|
|
4094
4122
|
return {
|
|
4095
|
-
create:
|
|
4096
|
-
get:
|
|
4097
|
-
list:
|
|
4098
|
-
remove:
|
|
4099
|
-
update:
|
|
4123
|
+
create: Gi(e),
|
|
4124
|
+
get: Ki(e),
|
|
4125
|
+
list: qi(e),
|
|
4126
|
+
remove: Ji(e),
|
|
4127
|
+
update: Yi(e)
|
|
4100
4128
|
};
|
|
4101
4129
|
}
|
|
4102
4130
|
//#endregion
|
|
4103
4131
|
//#region src/organization-connections/index.ts
|
|
4104
|
-
function
|
|
4132
|
+
function H(e, t) {
|
|
4105
4133
|
return {
|
|
4106
4134
|
connection_id: e.connection_id,
|
|
4107
4135
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4115,14 +4143,14 @@ function B(e, t) {
|
|
|
4115
4143
|
updated_at: e.updated_at
|
|
4116
4144
|
};
|
|
4117
4145
|
}
|
|
4118
|
-
async function
|
|
4146
|
+
async function U(e, t, n) {
|
|
4119
4147
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4120
4148
|
if (r) return {
|
|
4121
4149
|
name: r.name,
|
|
4122
4150
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4123
4151
|
};
|
|
4124
4152
|
}
|
|
4125
|
-
function
|
|
4153
|
+
function Zi(e) {
|
|
4126
4154
|
return {
|
|
4127
4155
|
async create(t, n, r, i) {
|
|
4128
4156
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4135,19 +4163,19 @@ function Ki(e) {
|
|
|
4135
4163
|
created_at: a?.created_at ?? o,
|
|
4136
4164
|
updated_at: a?.updated_at ?? o
|
|
4137
4165
|
};
|
|
4138
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4166
|
+
return await e.insertInto("organization_connections").values(s).execute(), H(s, await U(e, t, r.connection_id));
|
|
4139
4167
|
},
|
|
4140
4168
|
async list(t, n) {
|
|
4141
4169
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4142
4170
|
for (let n of r) {
|
|
4143
|
-
let r = await
|
|
4144
|
-
i.push(
|
|
4171
|
+
let r = await U(e, t, n.connection_id);
|
|
4172
|
+
i.push(H(n, r));
|
|
4145
4173
|
}
|
|
4146
4174
|
return i;
|
|
4147
4175
|
},
|
|
4148
4176
|
async get(t, n, r) {
|
|
4149
4177
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4150
|
-
return i ?
|
|
4178
|
+
return i ? H(i, await U(e, t, r)) : null;
|
|
4151
4179
|
},
|
|
4152
4180
|
async update(t, n, r, i) {
|
|
4153
4181
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4155,7 +4183,7 @@ function Ki(e) {
|
|
|
4155
4183
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4156
4184
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4157
4185
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4158
|
-
return s ?
|
|
4186
|
+
return s ? H(s, await U(e, t, r)) : null;
|
|
4159
4187
|
},
|
|
4160
4188
|
async remove(t, n, r) {
|
|
4161
4189
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4165,7 +4193,7 @@ function Ki(e) {
|
|
|
4165
4193
|
}
|
|
4166
4194
|
//#endregion
|
|
4167
4195
|
//#region src/user-organizations/create.ts
|
|
4168
|
-
function
|
|
4196
|
+
function Qi(e) {
|
|
4169
4197
|
return async (n, r, i) => {
|
|
4170
4198
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4171
4199
|
id: a?.id ?? t(),
|
|
@@ -4178,14 +4206,14 @@ function qi(e) {
|
|
|
4178
4206
|
try {
|
|
4179
4207
|
await e.insertInto("user_organizations").values(s).execute();
|
|
4180
4208
|
} catch (e) {
|
|
4181
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new
|
|
4209
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new C(409, { message: "User is already a member of this organization" }) : e;
|
|
4182
4210
|
}
|
|
4183
4211
|
return { ...s };
|
|
4184
4212
|
};
|
|
4185
4213
|
}
|
|
4186
4214
|
//#endregion
|
|
4187
4215
|
//#region src/user-organizations/get.ts
|
|
4188
|
-
function
|
|
4216
|
+
function $i(e) {
|
|
4189
4217
|
return async (t, n) => {
|
|
4190
4218
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4191
4219
|
return r ? {
|
|
@@ -4199,7 +4227,7 @@ function Ji(e) {
|
|
|
4199
4227
|
}
|
|
4200
4228
|
//#endregion
|
|
4201
4229
|
//#region src/user-organizations/list.ts
|
|
4202
|
-
function
|
|
4230
|
+
function ea(e) {
|
|
4203
4231
|
return async (t, n) => {
|
|
4204
4232
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4205
4233
|
if (n?.q) {
|
|
@@ -4218,8 +4246,8 @@ function Yi(e) {
|
|
|
4218
4246
|
created_at: e.created_at,
|
|
4219
4247
|
updated_at: e.updated_at
|
|
4220
4248
|
});
|
|
4221
|
-
if (
|
|
4222
|
-
let { rows: e, limit: t, next: a } = await
|
|
4249
|
+
if (N(n)) {
|
|
4250
|
+
let { rows: e, limit: t, next: a } = await P(r, n, {
|
|
4223
4251
|
sortColumn: "created_at",
|
|
4224
4252
|
sortOrder: "desc"
|
|
4225
4253
|
});
|
|
@@ -4252,7 +4280,7 @@ function Yi(e) {
|
|
|
4252
4280
|
}
|
|
4253
4281
|
//#endregion
|
|
4254
4282
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4255
|
-
function
|
|
4283
|
+
function ta(e) {
|
|
4256
4284
|
return async (t, n, r) => {
|
|
4257
4285
|
let i = r?.page || 0, a = r?.per_page || 50, o = i * a, s = e.selectFrom("user_organizations").innerJoin("organizations", (e) => e.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)).select([
|
|
4258
4286
|
"organizations.id",
|
|
@@ -4289,12 +4317,12 @@ function Xi(e) {
|
|
|
4289
4317
|
}
|
|
4290
4318
|
//#endregion
|
|
4291
4319
|
//#region src/user-organizations/remove.ts
|
|
4292
|
-
function
|
|
4320
|
+
function na(e) {
|
|
4293
4321
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4294
4322
|
}
|
|
4295
4323
|
//#endregion
|
|
4296
4324
|
//#region src/user-organizations/update.ts
|
|
4297
|
-
function
|
|
4325
|
+
function ra(e) {
|
|
4298
4326
|
return async (t, n, r) => {
|
|
4299
4327
|
let i = {
|
|
4300
4328
|
...r,
|
|
@@ -4305,21 +4333,21 @@ function Qi(e) {
|
|
|
4305
4333
|
}
|
|
4306
4334
|
//#endregion
|
|
4307
4335
|
//#region src/user-organizations/index.ts
|
|
4308
|
-
function
|
|
4336
|
+
function ia(e) {
|
|
4309
4337
|
return {
|
|
4310
|
-
create:
|
|
4311
|
-
get:
|
|
4312
|
-
list:
|
|
4313
|
-
listUserOrganizations:
|
|
4314
|
-
remove:
|
|
4315
|
-
update:
|
|
4338
|
+
create: Qi(e),
|
|
4339
|
+
get: $i(e),
|
|
4340
|
+
list: ea(e),
|
|
4341
|
+
listUserOrganizations: ta(e),
|
|
4342
|
+
remove: na(e),
|
|
4343
|
+
update: ra(e)
|
|
4316
4344
|
};
|
|
4317
4345
|
}
|
|
4318
4346
|
//#endregion
|
|
4319
4347
|
//#region src/invites/create.ts
|
|
4320
|
-
function
|
|
4348
|
+
function aa(e) {
|
|
4321
4349
|
return async (t, n, r) => {
|
|
4322
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4350
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? ke(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4323
4351
|
id: a,
|
|
4324
4352
|
tenant_id: t,
|
|
4325
4353
|
organization_id: n.organization_id,
|
|
@@ -4340,7 +4368,7 @@ function ea(e) {
|
|
|
4340
4368
|
try {
|
|
4341
4369
|
await e.insertInto("invites").values(l).execute();
|
|
4342
4370
|
} catch (e) {
|
|
4343
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4371
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new C(409, { message: "Invite already exists" }) : e;
|
|
4344
4372
|
}
|
|
4345
4373
|
return {
|
|
4346
4374
|
id: a,
|
|
@@ -4363,11 +4391,11 @@ function ea(e) {
|
|
|
4363
4391
|
}
|
|
4364
4392
|
//#endregion
|
|
4365
4393
|
//#region src/invites/get.ts
|
|
4366
|
-
function
|
|
4394
|
+
function oa(e) {
|
|
4367
4395
|
return async (t, n) => {
|
|
4368
4396
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4369
4397
|
return r ? l({
|
|
4370
|
-
...
|
|
4398
|
+
...mt(r, {
|
|
4371
4399
|
inviter: {},
|
|
4372
4400
|
invitee: {},
|
|
4373
4401
|
app_metadata: {},
|
|
@@ -4380,7 +4408,7 @@ function ta(e) {
|
|
|
4380
4408
|
}
|
|
4381
4409
|
//#endregion
|
|
4382
4410
|
//#region src/invites/list.ts
|
|
4383
|
-
function
|
|
4411
|
+
function sa(e) {
|
|
4384
4412
|
return async (t, n) => {
|
|
4385
4413
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4386
4414
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4388,7 +4416,7 @@ function na(e) {
|
|
|
4388
4416
|
r = r.offset(e);
|
|
4389
4417
|
}
|
|
4390
4418
|
let i = (await r.execute()).map((e) => l({
|
|
4391
|
-
...
|
|
4419
|
+
...mt(e, {
|
|
4392
4420
|
inviter: {},
|
|
4393
4421
|
invitee: {},
|
|
4394
4422
|
app_metadata: {},
|
|
@@ -4407,12 +4435,12 @@ function na(e) {
|
|
|
4407
4435
|
}
|
|
4408
4436
|
//#endregion
|
|
4409
4437
|
//#region src/invites/remove.ts
|
|
4410
|
-
function
|
|
4438
|
+
function ca(e) {
|
|
4411
4439
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4412
4440
|
}
|
|
4413
4441
|
//#endregion
|
|
4414
4442
|
//#region src/invites/update.ts
|
|
4415
|
-
function
|
|
4443
|
+
function la(e) {
|
|
4416
4444
|
return async (t, n, r) => {
|
|
4417
4445
|
let i = {};
|
|
4418
4446
|
return r.inviter !== void 0 && (i.inviter = JSON.stringify(r.inviter)), r.invitee !== void 0 && (i.invitee = JSON.stringify(r.invitee)), r.client_id !== void 0 && (i.client_id = r.client_id), r.connection_id !== void 0 && (i.connection_id = r.connection_id), r.app_metadata !== void 0 && (i.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (i.user_metadata = JSON.stringify(r.user_metadata)), r.roles !== void 0 && (i.roles = JSON.stringify(r.roles)), r.ttl_sec !== void 0 && (i.ttl_sec = r.ttl_sec, i.expires_at = new Date(Date.now() + r.ttl_sec * 1e3).toISOString()), r.send_invitation_email !== void 0 && (i.send_invitation_email = +!!r.send_invitation_email), Object.keys(i).length === 0 ? !0 : (await e.updateTable("invites").set(i).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numUpdatedRows > 0n;
|
|
@@ -4420,35 +4448,35 @@ function ia(e) {
|
|
|
4420
4448
|
}
|
|
4421
4449
|
//#endregion
|
|
4422
4450
|
//#region src/invites/index.ts
|
|
4423
|
-
function
|
|
4451
|
+
function ua(e) {
|
|
4424
4452
|
return {
|
|
4425
|
-
create:
|
|
4426
|
-
get:
|
|
4427
|
-
list:
|
|
4428
|
-
remove:
|
|
4429
|
-
update:
|
|
4453
|
+
create: aa(e),
|
|
4454
|
+
get: oa(e),
|
|
4455
|
+
list: sa(e),
|
|
4456
|
+
remove: ca(e),
|
|
4457
|
+
update: la(e)
|
|
4430
4458
|
};
|
|
4431
4459
|
}
|
|
4432
4460
|
//#endregion
|
|
4433
4461
|
//#region src/stats/index.ts
|
|
4434
|
-
var
|
|
4435
|
-
function
|
|
4462
|
+
var da = ["s"], fa = ["pwd_leak"];
|
|
4463
|
+
function pa(e) {
|
|
4436
4464
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4437
4465
|
}
|
|
4438
|
-
function
|
|
4466
|
+
function ma(e) {
|
|
4439
4467
|
return e.toISOString().split("T")[0];
|
|
4440
4468
|
}
|
|
4441
|
-
function
|
|
4469
|
+
function ha(e) {
|
|
4442
4470
|
return {
|
|
4443
4471
|
async getDaily(t, n = {}) {
|
|
4444
4472
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4445
4473
|
o.setDate(o.getDate() - 30);
|
|
4446
|
-
let s = r ?
|
|
4474
|
+
let s = r ? pa(r) : ma(o), c = i ? pa(i) : ma(a), l = f`DATE(logs.date)`;
|
|
4447
4475
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4448
4476
|
l.as("date"),
|
|
4449
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4477
|
+
e.fn.sum(e.case().when("type", "in", da).then(1).else(0).end()).as("logins"),
|
|
4450
4478
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4451
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4479
|
+
e.fn.sum(e.case().when("type", "in", fa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4452
4480
|
e.fn.min("date").as("first_event"),
|
|
4453
4481
|
e.fn.max("date").as("last_event")
|
|
4454
4482
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4462,13 +4490,13 @@ function ua(e) {
|
|
|
4462
4490
|
},
|
|
4463
4491
|
async getActiveUsers(t) {
|
|
4464
4492
|
let n = /* @__PURE__ */ new Date();
|
|
4465
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4493
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", da).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4466
4494
|
}
|
|
4467
4495
|
};
|
|
4468
4496
|
}
|
|
4469
4497
|
//#endregion
|
|
4470
4498
|
//#region src/analytics/index.ts
|
|
4471
|
-
var
|
|
4499
|
+
var ga = {
|
|
4472
4500
|
"active-users": ["s", "seacft"],
|
|
4473
4501
|
logins: [
|
|
4474
4502
|
"s",
|
|
@@ -4498,7 +4526,7 @@ var da = {
|
|
|
4498
4526
|
"fvr"
|
|
4499
4527
|
],
|
|
4500
4528
|
"codes-sent": ["cls", "cs"]
|
|
4501
|
-
},
|
|
4529
|
+
}, _a = {
|
|
4502
4530
|
"active-users": {
|
|
4503
4531
|
alias: "active_users",
|
|
4504
4532
|
type: "UInt64",
|
|
@@ -4555,14 +4583,14 @@ var da = {
|
|
|
4555
4583
|
agg: "count"
|
|
4556
4584
|
}
|
|
4557
4585
|
};
|
|
4558
|
-
async function
|
|
4586
|
+
async function va(e) {
|
|
4559
4587
|
try {
|
|
4560
4588
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4561
4589
|
} catch {
|
|
4562
4590
|
return "sqlite";
|
|
4563
4591
|
}
|
|
4564
4592
|
}
|
|
4565
|
-
function
|
|
4593
|
+
function W(e, t) {
|
|
4566
4594
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4567
4595
|
timeZone: e,
|
|
4568
4596
|
year: "numeric",
|
|
@@ -4577,7 +4605,7 @@ function H(e, t) {
|
|
|
4577
4605
|
let i = r.hour === "24" ? "00" : r.hour, a = Date.UTC(Number(r.year), Number(r.month) - 1, Number(r.day), Number(i), Number(r.minute), Number(r.second)), o = Math.round((a - t.getTime()) / 6e4), s = o >= 0 ? "+" : "-", c = Math.abs(o);
|
|
4578
4606
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4579
4607
|
}
|
|
4580
|
-
var
|
|
4608
|
+
var ya = [
|
|
4581
4609
|
"January",
|
|
4582
4610
|
"February",
|
|
4583
4611
|
"March",
|
|
@@ -4591,22 +4619,22 @@ var ma = [
|
|
|
4591
4619
|
"November",
|
|
4592
4620
|
"December"
|
|
4593
4621
|
];
|
|
4594
|
-
function
|
|
4595
|
-
let n = t.getUTCFullYear(), r =
|
|
4622
|
+
function ba(e, t) {
|
|
4623
|
+
let n = t.getUTCFullYear(), r = W(e, new Date(Date.UTC(n, 0, 1)));
|
|
4596
4624
|
for (let t = 1; t < 12; t++) {
|
|
4597
|
-
let i =
|
|
4598
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4625
|
+
let i = W(e, new Date(Date.UTC(n, t, 1)));
|
|
4626
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${ya[t]}) and cannot be bucketed with a single fixed offset by the SQL analytics adapter. Use a fixed-offset zone (e.g. 'UTC' or '+02:00').`);
|
|
4599
4627
|
}
|
|
4600
4628
|
}
|
|
4601
|
-
function
|
|
4629
|
+
function xa(e) {
|
|
4602
4630
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4603
4631
|
return t * (Number(n) * 60 + Number(r));
|
|
4604
4632
|
}
|
|
4605
|
-
function
|
|
4633
|
+
function Sa(e, t) {
|
|
4606
4634
|
let n;
|
|
4607
4635
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4608
4636
|
else {
|
|
4609
|
-
let e =
|
|
4637
|
+
let e = xa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4610
4638
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4611
4639
|
}
|
|
4612
4640
|
switch (e) {
|
|
@@ -4617,7 +4645,7 @@ function _a(e, t) {
|
|
|
4617
4645
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4618
4646
|
}
|
|
4619
4647
|
}
|
|
4620
|
-
function
|
|
4648
|
+
function Ca(e, t) {
|
|
4621
4649
|
if (t === "+00:00") switch (e) {
|
|
4622
4650
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4623
4651
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4628,7 +4656,7 @@ function va(e, t) {
|
|
|
4628
4656
|
}
|
|
4629
4657
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4630
4658
|
}
|
|
4631
|
-
let n =
|
|
4659
|
+
let n = xa(t), r = f`date_add(str_to_date(substring(${f.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${f.lit(n)} minute)`;
|
|
4632
4660
|
switch (e) {
|
|
4633
4661
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4634
4662
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4637,12 +4665,12 @@ function va(e, t) {
|
|
|
4637
4665
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4638
4666
|
}
|
|
4639
4667
|
}
|
|
4640
|
-
function
|
|
4641
|
-
|
|
4642
|
-
let i =
|
|
4643
|
-
return r === "mysql" ?
|
|
4668
|
+
function wa(e, t, n, r) {
|
|
4669
|
+
ba(t, n);
|
|
4670
|
+
let i = W(t, n);
|
|
4671
|
+
return r === "mysql" ? Ca(e, i) : Sa(e, i);
|
|
4644
4672
|
}
|
|
4645
|
-
function
|
|
4673
|
+
function Ta(e) {
|
|
4646
4674
|
switch (e) {
|
|
4647
4675
|
case "connection": return "logs.connection";
|
|
4648
4676
|
case "client_id": return "logs.client_id";
|
|
@@ -4651,65 +4679,82 @@ function ba(e) {
|
|
|
4651
4679
|
case "time": throw Error("time dimension is handled separately");
|
|
4652
4680
|
}
|
|
4653
4681
|
}
|
|
4654
|
-
function
|
|
4655
|
-
let t = null, n = () => (t ||=
|
|
4656
|
-
return {
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
let e
|
|
4682
|
+
function Ea(e) {
|
|
4683
|
+
let t = null, n = () => (t ||= va(e), t);
|
|
4684
|
+
return {
|
|
4685
|
+
async query(t, r, i) {
|
|
4686
|
+
let a = Date.now(), o = ga[r], s = _a[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4687
|
+
u = u.where("date", ">=", i.from).where("date", "<", i.to), u = u.where("type", "in", o), i.filters.connection?.length && (u = u.where("connection", "in", i.filters.connection)), i.filters.client_id?.length && (u = u.where("client_id", "in", i.filters.client_id)), i.filters.user_type?.length && (u = u.where("strategy_type", "in", i.filters.user_type)), i.filters.user_id?.length && (u = u.where("user_id", "in", i.filters.user_id));
|
|
4688
|
+
let d = [], p = [];
|
|
4689
|
+
for (let e of i.group_by) if (e === "time") {
|
|
4690
|
+
let e = wa(i.interval, i.tz, new Date(i.from), c);
|
|
4691
|
+
p.push({
|
|
4692
|
+
alias: "time",
|
|
4693
|
+
expr: e
|
|
4694
|
+
}), d.push(e), l.push({
|
|
4695
|
+
name: "time",
|
|
4696
|
+
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4697
|
+
});
|
|
4698
|
+
} else {
|
|
4699
|
+
let t = Ta(e);
|
|
4700
|
+
p.push({
|
|
4701
|
+
alias: e,
|
|
4702
|
+
expr: f`${f.ref(t)}`
|
|
4703
|
+
}), d.push(f`${f.ref(t)}`), l.push({
|
|
4704
|
+
name: e,
|
|
4705
|
+
type: "String"
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
let m = s.agg === "uniq" ? f`COUNT(DISTINCT ${f.ref("logs.user_id")})` : f`COUNT(*)`;
|
|
4662
4709
|
p.push({
|
|
4663
|
-
alias:
|
|
4664
|
-
expr:
|
|
4665
|
-
}),
|
|
4666
|
-
name:
|
|
4667
|
-
type:
|
|
4710
|
+
alias: s.alias,
|
|
4711
|
+
expr: m
|
|
4712
|
+
}), l.push({
|
|
4713
|
+
name: s.alias,
|
|
4714
|
+
type: s.type
|
|
4668
4715
|
});
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4716
|
+
let h = u.select(p.map(({ alias: e, expr: t }) => t.as(e)));
|
|
4717
|
+
if (d.length > 0 && (h = h.groupBy(d)), i.order_by) {
|
|
4718
|
+
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4719
|
+
h = h.orderBy(t, e ? "desc" : "asc");
|
|
4720
|
+
} else h = i.group_by.length > 0 && i.group_by[0] === "time" ? h.orderBy("time", "asc") : h.orderBy(s.alias, "desc");
|
|
4721
|
+
h = h.limit(i.limit).offset(i.offset);
|
|
4722
|
+
let g = (await h.execute()).map((e) => {
|
|
4723
|
+
let t = {};
|
|
4724
|
+
for (let n of l) {
|
|
4725
|
+
let r = e[n.name];
|
|
4726
|
+
t[n.name] = n.type === "UInt64" ? Number(r) || 0 : r ?? "";
|
|
4727
|
+
}
|
|
4728
|
+
return t;
|
|
4677
4729
|
});
|
|
4730
|
+
return {
|
|
4731
|
+
meta: l,
|
|
4732
|
+
data: g,
|
|
4733
|
+
rows: g.length,
|
|
4734
|
+
rows_before_limit_at_least: g.length,
|
|
4735
|
+
statistics: { elapsed: (Date.now() - a) / 1e3 }
|
|
4736
|
+
};
|
|
4737
|
+
},
|
|
4738
|
+
async sessionRetention(t, r) {
|
|
4739
|
+
let i = Date.now(), { sinceMs: a } = pe(r.weeks, i), o = await n(), s = (e) => {
|
|
4740
|
+
let t = e === "used_at_ts" ? f`(COALESCE(${f.ref("used_at_ts")}, ${f.ref("created_at_ts")}) + ${f.lit(m)})` : f`(${f.ref(e)} + ${f.lit(m)})`;
|
|
4741
|
+
return o === "mysql" ? f`${t} DIV ${f.lit(h)}` : f`${t} / ${f.lit(h)}`;
|
|
4742
|
+
};
|
|
4743
|
+
return g((await e.selectFrom("sessions").where("tenant_id", "=", t).where("created_at_ts", ">=", a).select([
|
|
4744
|
+
s("created_at_ts").as("created_week"),
|
|
4745
|
+
s("used_at_ts").as("used_week"),
|
|
4746
|
+
f`COUNT(*)`.as("count")
|
|
4747
|
+
]).groupBy([s("created_at_ts"), s("used_at_ts")]).execute()).map((e) => ({
|
|
4748
|
+
created_week: Math.floor(Number(e.created_week)),
|
|
4749
|
+
used_week: Math.floor(Number(e.used_week)),
|
|
4750
|
+
count: Number(e.count)
|
|
4751
|
+
})), r.weeks, i);
|
|
4678
4752
|
}
|
|
4679
|
-
|
|
4680
|
-
p.push({
|
|
4681
|
-
alias: s.alias,
|
|
4682
|
-
expr: m
|
|
4683
|
-
}), l.push({
|
|
4684
|
-
name: s.alias,
|
|
4685
|
-
type: s.type
|
|
4686
|
-
});
|
|
4687
|
-
let h = u.select(p.map(({ alias: e, expr: t }) => t.as(e)));
|
|
4688
|
-
if (d.length > 0 && (h = h.groupBy(d)), i.order_by) {
|
|
4689
|
-
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4690
|
-
h = h.orderBy(t, e ? "desc" : "asc");
|
|
4691
|
-
} else h = i.group_by.length > 0 && i.group_by[0] === "time" ? h.orderBy("time", "asc") : h.orderBy(s.alias, "desc");
|
|
4692
|
-
h = h.limit(i.limit).offset(i.offset);
|
|
4693
|
-
let g = (await h.execute()).map((e) => {
|
|
4694
|
-
let t = {};
|
|
4695
|
-
for (let n of l) {
|
|
4696
|
-
let r = e[n.name];
|
|
4697
|
-
t[n.name] = n.type === "UInt64" ? Number(r) || 0 : r ?? "";
|
|
4698
|
-
}
|
|
4699
|
-
return t;
|
|
4700
|
-
});
|
|
4701
|
-
return {
|
|
4702
|
-
meta: l,
|
|
4703
|
-
data: g,
|
|
4704
|
-
rows: g.length,
|
|
4705
|
-
rows_before_limit_at_least: g.length,
|
|
4706
|
-
statistics: { elapsed: (Date.now() - a) / 1e3 }
|
|
4707
|
-
};
|
|
4708
|
-
} };
|
|
4753
|
+
};
|
|
4709
4754
|
}
|
|
4710
4755
|
//#endregion
|
|
4711
4756
|
//#region src/customText/index.ts
|
|
4712
|
-
function
|
|
4757
|
+
function Da(e) {
|
|
4713
4758
|
return {
|
|
4714
4759
|
async get(t, n, r) {
|
|
4715
4760
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4748,9 +4793,9 @@ function Sa(e) {
|
|
|
4748
4793
|
}
|
|
4749
4794
|
//#endregion
|
|
4750
4795
|
//#region src/authenticationMethods/create.ts
|
|
4751
|
-
function
|
|
4796
|
+
function Oa(e) {
|
|
4752
4797
|
return async (t, n, r) => {
|
|
4753
|
-
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ??
|
|
4798
|
+
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ?? Or();
|
|
4754
4799
|
return await e.insertInto("authentication_methods").values({
|
|
4755
4800
|
id: s,
|
|
4756
4801
|
tenant_id: t,
|
|
@@ -4787,7 +4832,7 @@ function Ca(e) {
|
|
|
4787
4832
|
}
|
|
4788
4833
|
//#endregion
|
|
4789
4834
|
//#region src/authenticationMethods/get.ts
|
|
4790
|
-
function
|
|
4835
|
+
function ka(e) {
|
|
4791
4836
|
return async (t, n) => {
|
|
4792
4837
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4793
4838
|
return r ? {
|
|
@@ -4810,7 +4855,7 @@ function wa(e) {
|
|
|
4810
4855
|
}
|
|
4811
4856
|
//#endregion
|
|
4812
4857
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4813
|
-
function
|
|
4858
|
+
function Aa(e) {
|
|
4814
4859
|
return async (t, n) => {
|
|
4815
4860
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4816
4861
|
return r ? {
|
|
@@ -4833,7 +4878,7 @@ function Ta(e) {
|
|
|
4833
4878
|
}
|
|
4834
4879
|
//#endregion
|
|
4835
4880
|
//#region src/authenticationMethods/list.ts
|
|
4836
|
-
function
|
|
4881
|
+
function ja(e) {
|
|
4837
4882
|
return async (t, n) => (await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "=", n).selectAll().execute()).map((e) => ({
|
|
4838
4883
|
id: e.id,
|
|
4839
4884
|
user_id: e.user_id,
|
|
@@ -4853,35 +4898,35 @@ function Ea(e) {
|
|
|
4853
4898
|
}
|
|
4854
4899
|
//#endregion
|
|
4855
4900
|
//#region src/authenticationMethods/update.ts
|
|
4856
|
-
function
|
|
4901
|
+
function Ma(e) {
|
|
4857
4902
|
return async (t, n, r) => {
|
|
4858
4903
|
let i = { updated_at_ts: Date.now() };
|
|
4859
4904
|
r.phone_number !== void 0 && (i.phone_number = r.phone_number), r.totp_secret !== void 0 && (i.totp_secret = r.totp_secret), r.credential_id !== void 0 && (i.credential_id = r.credential_id), r.public_key !== void 0 && (i.public_key = r.public_key), r.sign_count !== void 0 && (i.sign_count = r.sign_count), r.credential_backed_up !== void 0 && (i.credential_backed_up = +!!r.credential_backed_up), r.transports !== void 0 && (i.transports = JSON.stringify(r.transports)), r.friendly_name !== void 0 && (i.friendly_name = r.friendly_name), r.confirmed !== void 0 && (i.confirmed = +!!r.confirmed), await e.updateTable("authentication_methods").set(i).where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).execute();
|
|
4860
|
-
let a = await
|
|
4905
|
+
let a = await ka(e)(t, n);
|
|
4861
4906
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4862
4907
|
return a;
|
|
4863
4908
|
};
|
|
4864
4909
|
}
|
|
4865
4910
|
//#endregion
|
|
4866
4911
|
//#region src/authenticationMethods/remove.ts
|
|
4867
|
-
function
|
|
4912
|
+
function Na(e) {
|
|
4868
4913
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4869
4914
|
}
|
|
4870
4915
|
//#endregion
|
|
4871
4916
|
//#region src/authenticationMethods/index.ts
|
|
4872
|
-
function
|
|
4917
|
+
function Pa(e) {
|
|
4873
4918
|
return {
|
|
4874
|
-
create:
|
|
4875
|
-
get:
|
|
4876
|
-
getByCredentialId:
|
|
4877
|
-
list:
|
|
4878
|
-
update:
|
|
4879
|
-
remove:
|
|
4919
|
+
create: Oa(e),
|
|
4920
|
+
get: ka(e),
|
|
4921
|
+
getByCredentialId: Aa(e),
|
|
4922
|
+
list: ja(e),
|
|
4923
|
+
update: Ma(e),
|
|
4924
|
+
remove: Na(e)
|
|
4880
4925
|
};
|
|
4881
4926
|
}
|
|
4882
4927
|
//#endregion
|
|
4883
4928
|
//#region src/outbox/getByIds.ts
|
|
4884
|
-
function
|
|
4929
|
+
function Fa(e) {
|
|
4885
4930
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4886
4931
|
...JSON.parse(e.payload),
|
|
4887
4932
|
id: e.id,
|
|
@@ -4894,7 +4939,7 @@ function Aa(e) {
|
|
|
4894
4939
|
}
|
|
4895
4940
|
//#endregion
|
|
4896
4941
|
//#region src/outbox/getUnprocessed.ts
|
|
4897
|
-
function
|
|
4942
|
+
function Ia(e) {
|
|
4898
4943
|
return async (t) => {
|
|
4899
4944
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4900
4945
|
return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where((e) => e.or([e("next_retry_at", "is", null), e("next_retry_at", "<=", n)])).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).orderBy("created_at", "asc").orderBy("id", "asc").limit(t).execute()).map((e) => ({
|
|
@@ -4910,7 +4955,7 @@ function ja(e) {
|
|
|
4910
4955
|
}
|
|
4911
4956
|
//#endregion
|
|
4912
4957
|
//#region src/outbox/claimEvents.ts
|
|
4913
|
-
function
|
|
4958
|
+
function La(e) {
|
|
4914
4959
|
return async (t, n, r) => {
|
|
4915
4960
|
if (t.length === 0) return [];
|
|
4916
4961
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4922,7 +4967,7 @@ function Ma(e) {
|
|
|
4922
4967
|
}
|
|
4923
4968
|
//#endregion
|
|
4924
4969
|
//#region src/outbox/markProcessed.ts
|
|
4925
|
-
function
|
|
4970
|
+
function Ra(e) {
|
|
4926
4971
|
return async (t) => {
|
|
4927
4972
|
if (t.length === 0) return;
|
|
4928
4973
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4931,7 +4976,7 @@ function Na(e) {
|
|
|
4931
4976
|
}
|
|
4932
4977
|
//#endregion
|
|
4933
4978
|
//#region src/outbox/markRetry.ts
|
|
4934
|
-
function
|
|
4979
|
+
function za(e) {
|
|
4935
4980
|
return async (t, n, r) => {
|
|
4936
4981
|
await e.updateTable("outbox_events").set({
|
|
4937
4982
|
error: n,
|
|
@@ -4944,7 +4989,7 @@ function Pa(e) {
|
|
|
4944
4989
|
}
|
|
4945
4990
|
//#endregion
|
|
4946
4991
|
//#region src/outbox/deadLetter.ts
|
|
4947
|
-
function
|
|
4992
|
+
function Ba(e) {
|
|
4948
4993
|
return async (t, n) => {
|
|
4949
4994
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4950
4995
|
await e.updateTable("outbox_events").set({
|
|
@@ -4956,7 +5001,7 @@ function Fa(e) {
|
|
|
4956
5001
|
}
|
|
4957
5002
|
//#endregion
|
|
4958
5003
|
//#region src/outbox/listFailed.ts
|
|
4959
|
-
function
|
|
5004
|
+
function Va(e) {
|
|
4960
5005
|
return async (t, n = {}) => {
|
|
4961
5006
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1 } = n, o = (await e.selectFrom("outbox_events").selectAll().where("tenant_id", "=", t).where("dead_lettered_at", "is not", null).orderBy("dead_lettered_at", "desc").orderBy("id", "asc").offset(r * i).limit(i).execute()).flatMap((e) => {
|
|
4962
5007
|
let t;
|
|
@@ -4991,7 +5036,7 @@ function Ia(e) {
|
|
|
4991
5036
|
}
|
|
4992
5037
|
//#endregion
|
|
4993
5038
|
//#region src/outbox/replay.ts
|
|
4994
|
-
function
|
|
5039
|
+
function Ha(e) {
|
|
4995
5040
|
return async (t, n) => {
|
|
4996
5041
|
let r = await e.updateTable("outbox_events").set({
|
|
4997
5042
|
processed_at: null,
|
|
@@ -5006,7 +5051,7 @@ function La(e) {
|
|
|
5006
5051
|
}
|
|
5007
5052
|
//#endregion
|
|
5008
5053
|
//#region src/outbox/cleanup.ts
|
|
5009
|
-
function
|
|
5054
|
+
function Ua(e) {
|
|
5010
5055
|
return async (t) => {
|
|
5011
5056
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5012
5057
|
return Number(n.numDeletedRows);
|
|
@@ -5014,23 +5059,23 @@ function Ra(e) {
|
|
|
5014
5059
|
}
|
|
5015
5060
|
//#endregion
|
|
5016
5061
|
//#region src/outbox/index.ts
|
|
5017
|
-
function
|
|
5062
|
+
function Wa(e) {
|
|
5018
5063
|
return {
|
|
5019
|
-
create:
|
|
5020
|
-
getByIds:
|
|
5021
|
-
getUnprocessed:
|
|
5022
|
-
claimEvents:
|
|
5023
|
-
markProcessed:
|
|
5024
|
-
markRetry:
|
|
5025
|
-
deadLetter:
|
|
5026
|
-
listFailed:
|
|
5027
|
-
replay:
|
|
5028
|
-
cleanup:
|
|
5064
|
+
create: qe(e),
|
|
5065
|
+
getByIds: Fa(e),
|
|
5066
|
+
getUnprocessed: Ia(e),
|
|
5067
|
+
claimEvents: La(e),
|
|
5068
|
+
markProcessed: Ra(e),
|
|
5069
|
+
markRetry: za(e),
|
|
5070
|
+
deadLetter: Ba(e),
|
|
5071
|
+
listFailed: Va(e),
|
|
5072
|
+
replay: Ha(e),
|
|
5073
|
+
cleanup: Ua(e)
|
|
5029
5074
|
};
|
|
5030
5075
|
}
|
|
5031
5076
|
//#endregion
|
|
5032
5077
|
//#region src/log-streams/index.ts
|
|
5033
|
-
function
|
|
5078
|
+
function G(e) {
|
|
5034
5079
|
return {
|
|
5035
5080
|
id: e.id,
|
|
5036
5081
|
name: e.name,
|
|
@@ -5043,7 +5088,7 @@ function U(e) {
|
|
|
5043
5088
|
updated_at: e.updated_at
|
|
5044
5089
|
};
|
|
5045
5090
|
}
|
|
5046
|
-
function
|
|
5091
|
+
function Ga(e) {
|
|
5047
5092
|
return {
|
|
5048
5093
|
async create(n, r, i) {
|
|
5049
5094
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5058,14 +5103,14 @@ function Ba(e) {
|
|
|
5058
5103
|
created_at: a?.created_at ?? o,
|
|
5059
5104
|
updated_at: a?.updated_at ?? o
|
|
5060
5105
|
};
|
|
5061
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5106
|
+
return await e.insertInto("log_streams").values(s).execute(), G(s);
|
|
5062
5107
|
},
|
|
5063
5108
|
async get(t, n) {
|
|
5064
5109
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5065
|
-
return r ?
|
|
5110
|
+
return r ? G(r) : null;
|
|
5066
5111
|
},
|
|
5067
5112
|
async list(t) {
|
|
5068
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5113
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(G);
|
|
5069
5114
|
},
|
|
5070
5115
|
async update(t, n, r) {
|
|
5071
5116
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5078,11 +5123,11 @@ function Ba(e) {
|
|
|
5078
5123
|
}
|
|
5079
5124
|
//#endregion
|
|
5080
5125
|
//#region src/migrationSources/index.ts
|
|
5081
|
-
function
|
|
5126
|
+
function K(e) {
|
|
5082
5127
|
return {
|
|
5083
5128
|
id: e.id,
|
|
5084
5129
|
name: e.name,
|
|
5085
|
-
provider:
|
|
5130
|
+
provider: se.parse(e.provider),
|
|
5086
5131
|
connection: e.connection,
|
|
5087
5132
|
enabled: e.enabled === 1,
|
|
5088
5133
|
credentials: JSON.parse(e.credentials),
|
|
@@ -5090,7 +5135,7 @@ function W(e) {
|
|
|
5090
5135
|
updated_at: e.updated_at
|
|
5091
5136
|
};
|
|
5092
5137
|
}
|
|
5093
|
-
function
|
|
5138
|
+
function Ka(e) {
|
|
5094
5139
|
return {
|
|
5095
5140
|
async create(n, r, i) {
|
|
5096
5141
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5104,14 +5149,14 @@ function Va(e) {
|
|
|
5104
5149
|
created_at: a?.created_at ?? o,
|
|
5105
5150
|
updated_at: a?.updated_at ?? o
|
|
5106
5151
|
};
|
|
5107
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5152
|
+
return await e.insertInto("migration_sources").values(l).execute(), K(l);
|
|
5108
5153
|
},
|
|
5109
5154
|
async get(t, n) {
|
|
5110
5155
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5111
|
-
return r ?
|
|
5156
|
+
return r ? K(r) : null;
|
|
5112
5157
|
},
|
|
5113
5158
|
async list(t) {
|
|
5114
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5159
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(K);
|
|
5115
5160
|
},
|
|
5116
5161
|
async update(t, n, r) {
|
|
5117
5162
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5124,34 +5169,34 @@ function Va(e) {
|
|
|
5124
5169
|
}
|
|
5125
5170
|
//#endregion
|
|
5126
5171
|
//#region src/proxyRoutes/serialize.ts
|
|
5127
|
-
function
|
|
5172
|
+
function q(e) {
|
|
5128
5173
|
return {
|
|
5129
5174
|
id: e.id,
|
|
5130
5175
|
tenant_id: e.tenant_id,
|
|
5131
5176
|
custom_domain_id: e.custom_domain_id,
|
|
5132
5177
|
priority: e.priority,
|
|
5133
|
-
match:
|
|
5134
|
-
handlers:
|
|
5178
|
+
match: qa(e.match),
|
|
5179
|
+
handlers: Ja(e.handlers),
|
|
5135
5180
|
created_at: e.created_at,
|
|
5136
5181
|
updated_at: e.updated_at
|
|
5137
5182
|
};
|
|
5138
5183
|
}
|
|
5139
|
-
function
|
|
5184
|
+
function qa(e) {
|
|
5140
5185
|
if (!e) return { path: "/*" };
|
|
5141
5186
|
try {
|
|
5142
|
-
let t = JSON.parse(e), n =
|
|
5187
|
+
let t = JSON.parse(e), n = oe.safeParse(t);
|
|
5143
5188
|
if (n.success) return n.data;
|
|
5144
5189
|
} catch {}
|
|
5145
5190
|
return { path: "/*" };
|
|
5146
5191
|
}
|
|
5147
|
-
function
|
|
5192
|
+
function Ja(e) {
|
|
5148
5193
|
if (!e) return [];
|
|
5149
5194
|
try {
|
|
5150
5195
|
let t = JSON.parse(e);
|
|
5151
5196
|
if (!Array.isArray(t)) return [];
|
|
5152
5197
|
let n = [];
|
|
5153
5198
|
for (let e of t) {
|
|
5154
|
-
let t =
|
|
5199
|
+
let t = re.safeParse(e);
|
|
5155
5200
|
t.success && n.push(t.data);
|
|
5156
5201
|
}
|
|
5157
5202
|
return n;
|
|
@@ -5161,7 +5206,7 @@ function Ua(e) {
|
|
|
5161
5206
|
}
|
|
5162
5207
|
//#endregion
|
|
5163
5208
|
//#region src/proxyRoutes/adapter.ts
|
|
5164
|
-
function
|
|
5209
|
+
function J(e) {
|
|
5165
5210
|
return {
|
|
5166
5211
|
async create(n, r, i) {
|
|
5167
5212
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5187,14 +5232,14 @@ function K(e) {
|
|
|
5187
5232
|
},
|
|
5188
5233
|
async get(t, n) {
|
|
5189
5234
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5190
|
-
return r ?
|
|
5235
|
+
return r ? q(r) : null;
|
|
5191
5236
|
},
|
|
5192
5237
|
async list(t, n = {}) {
|
|
5193
5238
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5194
5239
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5195
5240
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5196
5241
|
return {
|
|
5197
|
-
proxy_routes: o.map(
|
|
5242
|
+
proxy_routes: o.map(q),
|
|
5198
5243
|
start: r * i,
|
|
5199
5244
|
limit: i,
|
|
5200
5245
|
length: o.length
|
|
@@ -5214,7 +5259,7 @@ function K(e) {
|
|
|
5214
5259
|
}
|
|
5215
5260
|
//#endregion
|
|
5216
5261
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5217
|
-
async function
|
|
5262
|
+
async function Ya(e, t) {
|
|
5218
5263
|
let n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n), i = (r.endsWith(".") ? r.slice(0, -1) : r).toLowerCase(), a = await e.selectFrom("custom_domains").where("domain", "=", i).select([
|
|
5219
5264
|
"custom_domain_id",
|
|
5220
5265
|
"tenant_id",
|
|
@@ -5226,27 +5271,27 @@ async function Wa(e, t) {
|
|
|
5226
5271
|
tenant_id: a.tenant_id,
|
|
5227
5272
|
custom_domain_id: a.custom_domain_id,
|
|
5228
5273
|
domain: a.domain,
|
|
5229
|
-
routes: o.map(
|
|
5274
|
+
routes: o.map(q)
|
|
5230
5275
|
};
|
|
5231
5276
|
}
|
|
5232
5277
|
//#endregion
|
|
5233
5278
|
//#region src/proxyRoutes/index.ts
|
|
5234
|
-
function
|
|
5279
|
+
function Xa(e) {
|
|
5235
5280
|
return {
|
|
5236
|
-
proxyRoutes:
|
|
5237
|
-
resolveHost: (t) =>
|
|
5281
|
+
proxyRoutes: J(e),
|
|
5282
|
+
resolveHost: (t) => Ya(e, t)
|
|
5238
5283
|
};
|
|
5239
5284
|
}
|
|
5240
5285
|
//#endregion
|
|
5241
5286
|
//#region src/scim/adapter.ts
|
|
5242
|
-
function
|
|
5287
|
+
function Za(e) {
|
|
5243
5288
|
if (!e) return [];
|
|
5244
5289
|
try {
|
|
5245
5290
|
let t = JSON.parse(e);
|
|
5246
5291
|
if (!Array.isArray(t)) return [];
|
|
5247
5292
|
let n = [];
|
|
5248
5293
|
for (let e of t) {
|
|
5249
|
-
let t =
|
|
5294
|
+
let t = fe.safeParse(e);
|
|
5250
5295
|
t.success && n.push(t.data);
|
|
5251
5296
|
}
|
|
5252
5297
|
return n;
|
|
@@ -5254,7 +5299,7 @@ function Ka(e) {
|
|
|
5254
5299
|
return [];
|
|
5255
5300
|
}
|
|
5256
5301
|
}
|
|
5257
|
-
function
|
|
5302
|
+
function Qa(e) {
|
|
5258
5303
|
if (!e) return [];
|
|
5259
5304
|
try {
|
|
5260
5305
|
let t = JSON.parse(e);
|
|
@@ -5263,16 +5308,16 @@ function qa(e) {
|
|
|
5263
5308
|
return [];
|
|
5264
5309
|
}
|
|
5265
5310
|
}
|
|
5266
|
-
function
|
|
5311
|
+
function $a(e) {
|
|
5267
5312
|
return {
|
|
5268
5313
|
connection_id: e.connection_id,
|
|
5269
5314
|
user_id_attribute: e.user_id_attribute,
|
|
5270
|
-
mapping:
|
|
5315
|
+
mapping: Za(e.mapping),
|
|
5271
5316
|
created_at: e.created_at,
|
|
5272
5317
|
updated_at: e.updated_at
|
|
5273
5318
|
};
|
|
5274
5319
|
}
|
|
5275
|
-
function
|
|
5320
|
+
function eo(e) {
|
|
5276
5321
|
return {
|
|
5277
5322
|
async create(t, n) {
|
|
5278
5323
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5293,7 +5338,7 @@ function Ya(e) {
|
|
|
5293
5338
|
},
|
|
5294
5339
|
async get(t, n) {
|
|
5295
5340
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5296
|
-
return r ?
|
|
5341
|
+
return r ? $a(r) : null;
|
|
5297
5342
|
},
|
|
5298
5343
|
async update(t, n, r) {
|
|
5299
5344
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5307,18 +5352,18 @@ function Ya(e) {
|
|
|
5307
5352
|
}
|
|
5308
5353
|
};
|
|
5309
5354
|
}
|
|
5310
|
-
function
|
|
5355
|
+
function Y(e) {
|
|
5311
5356
|
return {
|
|
5312
5357
|
token_id: e.token_id,
|
|
5313
5358
|
connection_id: e.connection_id,
|
|
5314
5359
|
token_hash: e.token_hash,
|
|
5315
|
-
scopes:
|
|
5360
|
+
scopes: Qa(e.scopes),
|
|
5316
5361
|
valid_until: e.valid_until ?? void 0,
|
|
5317
5362
|
created_at: e.created_at,
|
|
5318
5363
|
last_used_at: e.last_used_at ?? void 0
|
|
5319
5364
|
};
|
|
5320
5365
|
}
|
|
5321
|
-
function
|
|
5366
|
+
function to(e) {
|
|
5322
5367
|
return {
|
|
5323
5368
|
async create(t, n) {
|
|
5324
5369
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5342,14 +5387,14 @@ function Xa(e) {
|
|
|
5342
5387
|
},
|
|
5343
5388
|
async get(t, n) {
|
|
5344
5389
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5345
|
-
return r ?
|
|
5390
|
+
return r ? Y(r) : null;
|
|
5346
5391
|
},
|
|
5347
5392
|
async getByHash(t, n) {
|
|
5348
5393
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5349
|
-
return r ?
|
|
5394
|
+
return r ? Y(r) : null;
|
|
5350
5395
|
},
|
|
5351
5396
|
async listByConnection(t, n) {
|
|
5352
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5397
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Y);
|
|
5353
5398
|
},
|
|
5354
5399
|
async markUsed(t, n, r) {
|
|
5355
5400
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5361,7 +5406,7 @@ function Xa(e) {
|
|
|
5361
5406
|
}
|
|
5362
5407
|
};
|
|
5363
5408
|
}
|
|
5364
|
-
function
|
|
5409
|
+
function no(e) {
|
|
5365
5410
|
return {
|
|
5366
5411
|
connection_id: e.connection_id,
|
|
5367
5412
|
external_id: e.external_id,
|
|
@@ -5369,7 +5414,7 @@ function Za(e) {
|
|
|
5369
5414
|
created_at: e.created_at
|
|
5370
5415
|
};
|
|
5371
5416
|
}
|
|
5372
|
-
function
|
|
5417
|
+
function ro(e) {
|
|
5373
5418
|
return {
|
|
5374
5419
|
async create(t, n) {
|
|
5375
5420
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5388,11 +5433,11 @@ function Qa(e) {
|
|
|
5388
5433
|
},
|
|
5389
5434
|
async getByExternalId(t, n, r) {
|
|
5390
5435
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5391
|
-
return i ?
|
|
5436
|
+
return i ? no(i) : null;
|
|
5392
5437
|
},
|
|
5393
5438
|
async getByUserId(t, n, r) {
|
|
5394
5439
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5395
|
-
return i ?
|
|
5440
|
+
return i ? no(i) : null;
|
|
5396
5441
|
},
|
|
5397
5442
|
async remove(t, n, r) {
|
|
5398
5443
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5402,8 +5447,8 @@ function Qa(e) {
|
|
|
5402
5447
|
}
|
|
5403
5448
|
//#endregion
|
|
5404
5449
|
//#region src/tenantOperations/index.ts
|
|
5405
|
-
function
|
|
5406
|
-
return
|
|
5450
|
+
function X(e) {
|
|
5451
|
+
return _e.parse({
|
|
5407
5452
|
id: e.id,
|
|
5408
5453
|
tenant_id: e.tenant_id,
|
|
5409
5454
|
rollout_id: e.rollout_id,
|
|
@@ -5421,10 +5466,10 @@ function J(e) {
|
|
|
5421
5466
|
finished_at: e.finished_at
|
|
5422
5467
|
});
|
|
5423
5468
|
}
|
|
5424
|
-
function
|
|
5469
|
+
function io(e) {
|
|
5425
5470
|
return {
|
|
5426
5471
|
async create(n) {
|
|
5427
|
-
let r =
|
|
5472
|
+
let r = ge.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5428
5473
|
id: `op_${t()}`,
|
|
5429
5474
|
tenant_id: r.tenant_id,
|
|
5430
5475
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5441,11 +5486,11 @@ function $a(e) {
|
|
|
5441
5486
|
updated_at: i,
|
|
5442
5487
|
finished_at: null
|
|
5443
5488
|
};
|
|
5444
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5489
|
+
return await e.insertInto("tenant_operations").values(a).execute(), X(a);
|
|
5445
5490
|
},
|
|
5446
5491
|
async get(t) {
|
|
5447
5492
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5448
|
-
return n ?
|
|
5493
|
+
return n ? X(n) : null;
|
|
5449
5494
|
},
|
|
5450
5495
|
async list(t = {}) {
|
|
5451
5496
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5456,7 +5501,7 @@ function $a(e) {
|
|
|
5456
5501
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5457
5502
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5458
5503
|
return {
|
|
5459
|
-
operations: a.map(
|
|
5504
|
+
operations: a.map(X),
|
|
5460
5505
|
start: n * r,
|
|
5461
5506
|
limit: r,
|
|
5462
5507
|
length: a.length
|
|
@@ -5476,27 +5521,27 @@ function $a(e) {
|
|
|
5476
5521
|
}
|
|
5477
5522
|
//#endregion
|
|
5478
5523
|
//#region src/utils/monotonic-id.ts
|
|
5479
|
-
var
|
|
5480
|
-
function
|
|
5524
|
+
var ao = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Z = 32, oo = 10, so = 4, co = 10;
|
|
5525
|
+
function lo(e, t) {
|
|
5481
5526
|
let n = "";
|
|
5482
|
-
for (let r = t; r > 0; r--) n =
|
|
5527
|
+
for (let r = t; r > 0; r--) n = ao.charAt(e % Z) + n, e = Math.floor(e / Z);
|
|
5483
5528
|
return n;
|
|
5484
5529
|
}
|
|
5485
|
-
function
|
|
5486
|
-
let e = new Uint8Array(
|
|
5530
|
+
function uo() {
|
|
5531
|
+
let e = new Uint8Array(co);
|
|
5487
5532
|
crypto.getRandomValues(e);
|
|
5488
5533
|
let t = "";
|
|
5489
|
-
for (let n = 0; n <
|
|
5534
|
+
for (let n = 0; n < co; n++) t += ao.charAt(e[n] % Z);
|
|
5490
5535
|
return t;
|
|
5491
5536
|
}
|
|
5492
|
-
var
|
|
5493
|
-
function
|
|
5537
|
+
var fo = 0, po = 0;
|
|
5538
|
+
function mo() {
|
|
5494
5539
|
let e = Date.now();
|
|
5495
|
-
return e ===
|
|
5540
|
+
return e === fo ? po++ : (fo = e, po = 0), lo(e, oo) + lo(po, so) + uo();
|
|
5496
5541
|
}
|
|
5497
5542
|
//#endregion
|
|
5498
5543
|
//#region src/tenantOperationEvents/index.ts
|
|
5499
|
-
function
|
|
5544
|
+
function ho(e) {
|
|
5500
5545
|
if (!e) return null;
|
|
5501
5546
|
try {
|
|
5502
5547
|
let t = JSON.parse(e);
|
|
@@ -5504,22 +5549,22 @@ function lo(e) {
|
|
|
5504
5549
|
} catch {}
|
|
5505
5550
|
return null;
|
|
5506
5551
|
}
|
|
5507
|
-
function
|
|
5508
|
-
return
|
|
5552
|
+
function go(e) {
|
|
5553
|
+
return he.parse({
|
|
5509
5554
|
id: e.id,
|
|
5510
5555
|
operation_id: e.operation_id,
|
|
5511
5556
|
step: e.step,
|
|
5512
5557
|
outcome: e.outcome,
|
|
5513
|
-
detail:
|
|
5558
|
+
detail: ho(e.detail),
|
|
5514
5559
|
attempt: e.attempt,
|
|
5515
5560
|
created_at: e.created_at
|
|
5516
5561
|
});
|
|
5517
5562
|
}
|
|
5518
|
-
function
|
|
5563
|
+
function _o(e) {
|
|
5519
5564
|
return {
|
|
5520
5565
|
async create(t) {
|
|
5521
|
-
let n =
|
|
5522
|
-
id: `evt_${
|
|
5566
|
+
let n = me.parse(t), r = {
|
|
5567
|
+
id: `evt_${mo()}`,
|
|
5523
5568
|
operation_id: n.operation_id,
|
|
5524
5569
|
step: n.step,
|
|
5525
5570
|
outcome: n.outcome,
|
|
@@ -5527,12 +5572,12 @@ function fo(e) {
|
|
|
5527
5572
|
attempt: n.attempt,
|
|
5528
5573
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5529
5574
|
};
|
|
5530
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5575
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), go(r);
|
|
5531
5576
|
},
|
|
5532
5577
|
async listByOperation(t, n = {}) {
|
|
5533
5578
|
let r = n.page ?? 0, i = n.per_page ?? 100, a = await e.selectFrom("tenant_operation_events").where("operation_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").offset(r * i).limit(i).execute();
|
|
5534
5579
|
return {
|
|
5535
|
-
events: a.map(
|
|
5580
|
+
events: a.map(go),
|
|
5536
5581
|
start: r * i,
|
|
5537
5582
|
limit: i,
|
|
5538
5583
|
length: a.length
|
|
@@ -5542,7 +5587,7 @@ function fo(e) {
|
|
|
5542
5587
|
}
|
|
5543
5588
|
//#endregion
|
|
5544
5589
|
//#region src/rollouts/index.ts
|
|
5545
|
-
function
|
|
5590
|
+
function vo(e) {
|
|
5546
5591
|
if (!e) return null;
|
|
5547
5592
|
try {
|
|
5548
5593
|
return JSON.parse(e);
|
|
@@ -5550,26 +5595,26 @@ function po(e) {
|
|
|
5550
5595
|
return null;
|
|
5551
5596
|
}
|
|
5552
5597
|
}
|
|
5553
|
-
function
|
|
5554
|
-
return
|
|
5598
|
+
function yo(e) {
|
|
5599
|
+
return de.parse({
|
|
5555
5600
|
id: e.id,
|
|
5556
5601
|
kind: e.kind,
|
|
5557
5602
|
status: e.status,
|
|
5558
5603
|
target_worker_version: e.target_worker_version,
|
|
5559
5604
|
target_database_version: e.target_database_version,
|
|
5560
5605
|
wave_size: e.wave_size,
|
|
5561
|
-
canary_tenant_ids:
|
|
5562
|
-
filter:
|
|
5606
|
+
canary_tenant_ids: vo(e.canary_tenant_ids),
|
|
5607
|
+
filter: vo(e.filter),
|
|
5563
5608
|
initiated_by: e.initiated_by,
|
|
5564
5609
|
created_at: e.created_at,
|
|
5565
5610
|
updated_at: e.updated_at,
|
|
5566
5611
|
finished_at: e.finished_at
|
|
5567
5612
|
});
|
|
5568
5613
|
}
|
|
5569
|
-
function
|
|
5614
|
+
function bo(e) {
|
|
5570
5615
|
return {
|
|
5571
5616
|
async create(n) {
|
|
5572
|
-
let r =
|
|
5617
|
+
let r = ue.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5573
5618
|
id: `rol_${t()}`,
|
|
5574
5619
|
kind: r.kind,
|
|
5575
5620
|
status: "pending",
|
|
@@ -5583,16 +5628,16 @@ function mo(e) {
|
|
|
5583
5628
|
updated_at: i,
|
|
5584
5629
|
finished_at: null
|
|
5585
5630
|
};
|
|
5586
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5631
|
+
return await e.insertInto("rollouts").values(a).execute(), yo(a);
|
|
5587
5632
|
},
|
|
5588
5633
|
async get(t) {
|
|
5589
5634
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5590
|
-
return n ?
|
|
5635
|
+
return n ? yo(n) : null;
|
|
5591
5636
|
},
|
|
5592
5637
|
async list(t = {}) {
|
|
5593
5638
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = await e.selectFrom("rollouts").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5594
5639
|
return {
|
|
5595
|
-
rollouts: i.map(
|
|
5640
|
+
rollouts: i.map(yo),
|
|
5596
5641
|
start: n * r,
|
|
5597
5642
|
limit: r,
|
|
5598
5643
|
length: i.length
|
|
@@ -5612,7 +5657,7 @@ function mo(e) {
|
|
|
5612
5657
|
}
|
|
5613
5658
|
//#endregion
|
|
5614
5659
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5615
|
-
var
|
|
5660
|
+
var xo = class {
|
|
5616
5661
|
migrations;
|
|
5617
5662
|
constructor(e) {
|
|
5618
5663
|
this.migrations = e;
|
|
@@ -5620,10 +5665,10 @@ var ho = class {
|
|
|
5620
5665
|
async getMigrations() {
|
|
5621
5666
|
return this.migrations;
|
|
5622
5667
|
}
|
|
5623
|
-
},
|
|
5624
|
-
down: () =>
|
|
5625
|
-
up: () =>
|
|
5626
|
-
}),
|
|
5668
|
+
}, So = /* @__PURE__ */ w({
|
|
5669
|
+
down: () => Eo,
|
|
5670
|
+
up: () => To
|
|
5671
|
+
}), Co = [
|
|
5627
5672
|
{
|
|
5628
5673
|
table: "authentication_methods",
|
|
5629
5674
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5889,47 +5934,47 @@ var ho = class {
|
|
|
5889
5934
|
onDelete: "cascade"
|
|
5890
5935
|
}
|
|
5891
5936
|
];
|
|
5892
|
-
async function
|
|
5937
|
+
async function wo(e) {
|
|
5893
5938
|
try {
|
|
5894
5939
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5895
5940
|
} catch {
|
|
5896
5941
|
return !1;
|
|
5897
5942
|
}
|
|
5898
5943
|
}
|
|
5899
|
-
function
|
|
5944
|
+
function Q(e, t) {
|
|
5900
5945
|
let n = e;
|
|
5901
|
-
for (let e of
|
|
5946
|
+
for (let e of Co) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5902
5947
|
let n = t;
|
|
5903
5948
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5904
5949
|
}));
|
|
5905
5950
|
return n;
|
|
5906
5951
|
}
|
|
5907
|
-
async function
|
|
5908
|
-
let t = await
|
|
5952
|
+
async function To(e) {
|
|
5953
|
+
let t = await wo(e);
|
|
5909
5954
|
await e.schema.createTable("tenants").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("audience", f`varchar(255)`).addColumn("sender_email", f`varchar(255)`).addColumn("sender_name", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addColumn("support_url", f`varchar(255)`).addColumn("idle_session_lifetime", f`int`).addColumn("session_lifetime", f`int`).addColumn("session_cookie", f`text`).addColumn("allowed_logout_urls", f`text`).addColumn("ephemeral_session_lifetime", f`int`).addColumn("idle_ephemeral_session_lifetime", f`int`).addColumn("default_redirection_uri", f`text`).addColumn("enabled_locales", f`text`).addColumn("default_directory", f`varchar(255)`).addColumn("error_page", f`text`).addColumn("flags", f`text`).addColumn("friendly_name", f`varchar(255)`).addColumn("picture_url", f`text`).addColumn("support_email", f`varchar(255)`).addColumn("sandbox_version", f`varchar(50)`).addColumn("sandbox_versions_available", f`text`).addColumn("legacy_sandbox_version", f`varchar(50)`).addColumn("change_password", f`text`).addColumn("guardian_mfa_page", f`text`).addColumn("device_flow", f`text`).addColumn("default_token_quota", f`text`).addColumn("default_audience", f`varchar(255)`).addColumn("default_organization", f`varchar(255)`).addColumn("sessions", f`text`).addColumn("oidc_logout", f`text`).addColumn("allow_organization_name_in_authentication_api", f`int`).addColumn("customize_mfa_in_postlogin_action", f`int`).addColumn("acr_values_supported", f`text`).addColumn("mtls", f`text`).addColumn("pushed_authorization_requests_supported", f`int`).addColumn("authorization_response_iss_parameter_supported", f`int`).addColumn("mfa", f`text`).addColumn("attack_protection", f`text`).addColumn("default_client_id", f`varchar(255)`).addColumn("deployment_type", f`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", f`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", f`varchar(2048)`).addColumn("provisioning_state_changed_at", f`varchar(35)`).addColumn("bundle_configuration", f`varchar(64)`).addColumn("worker_version", f`varchar(64)`).addColumn("worker_script_name", f`varchar(255)`).addColumn("storage_kind", f`varchar(32)`).addColumn("d1_database_id", f`varchar(64)`).addColumn("database_version", f`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", f`varchar(64)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("results", f`text`, (e) => e.notNull()).addColumn("logs", f`text`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("action_id", f`varchar(255)`, (e) => e.notNull()).addColumn("number", f`int`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("status", f`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed_at_ts", f`bigint`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
5910
5955
|
{
|
|
5911
5956
|
let n = e.schema.createTable("authentication_methods").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("type", f`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", f`varchar(32)`).addColumn("totp_secret", f`varchar(255)`).addColumn("confirmed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("credential_id", f`varchar(512)`).addColumn("public_key", f`text`).addColumn("sign_count", f`int`).addColumn("credential_backed_up", f`int`).addColumn("transports", f`varchar(512)`).addColumn("friendly_name", f`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
5912
|
-
t && (n =
|
|
5957
|
+
t && (n = Q(n, "authentication_methods")), await n.execute();
|
|
5913
5958
|
}
|
|
5914
5959
|
{
|
|
5915
5960
|
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"]);
|
|
5916
|
-
t && (n =
|
|
5961
|
+
t && (n = Q(n, "branding")), await n.execute();
|
|
5917
5962
|
}
|
|
5918
5963
|
{
|
|
5919
5964
|
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"]);
|
|
5920
|
-
t && (n =
|
|
5965
|
+
t && (n = Q(n, "clients")), await n.execute();
|
|
5921
5966
|
}
|
|
5922
5967
|
{
|
|
5923
5968
|
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"]);
|
|
5924
|
-
t && (n =
|
|
5969
|
+
t && (n = Q(n, "client_grants")), await n.execute();
|
|
5925
5970
|
}
|
|
5926
5971
|
{
|
|
5927
5972
|
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"]);
|
|
5928
|
-
t && (n =
|
|
5973
|
+
t && (n = Q(n, "client_registration_tokens")), await n.execute();
|
|
5929
5974
|
}
|
|
5930
5975
|
{
|
|
5931
5976
|
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"]);
|
|
5932
|
-
t && (n =
|
|
5977
|
+
t && (n = Q(n, "users")), await n.execute();
|
|
5933
5978
|
}
|
|
5934
5979
|
{
|
|
5935
5980
|
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", [
|
|
@@ -5937,16 +5982,16 @@ async function yo(e) {
|
|
|
5937
5982
|
"code_type",
|
|
5938
5983
|
"tenant_id"
|
|
5939
5984
|
]);
|
|
5940
|
-
t && (n =
|
|
5985
|
+
t && (n = Q(n, "codes")), await n.execute();
|
|
5941
5986
|
}
|
|
5942
5987
|
{
|
|
5943
5988
|
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"]);
|
|
5944
|
-
t && (n =
|
|
5989
|
+
t && (n = Q(n, "connections")), await n.execute();
|
|
5945
5990
|
}
|
|
5946
5991
|
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();
|
|
5947
5992
|
{
|
|
5948
5993
|
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"]);
|
|
5949
|
-
t && (n =
|
|
5994
|
+
t && (n = Q(n, "custom_domains")), await n.execute();
|
|
5950
5995
|
}
|
|
5951
5996
|
{
|
|
5952
5997
|
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", [
|
|
@@ -5954,56 +5999,56 @@ async function yo(e) {
|
|
|
5954
5999
|
"prompt",
|
|
5955
6000
|
"language"
|
|
5956
6001
|
]);
|
|
5957
|
-
t && (n =
|
|
6002
|
+
t && (n = Q(n, "custom_text")), await n.execute();
|
|
5958
6003
|
}
|
|
5959
6004
|
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();
|
|
5960
6005
|
{
|
|
5961
6006
|
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"]);
|
|
5962
|
-
t && (n =
|
|
6007
|
+
t && (n = Q(n, "email_templates")), await n.execute();
|
|
5963
6008
|
}
|
|
5964
6009
|
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();
|
|
5965
6010
|
{
|
|
5966
6011
|
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"]);
|
|
5967
|
-
t && (n =
|
|
6012
|
+
t && (n = Q(n, "grants")), await n.execute();
|
|
5968
6013
|
}
|
|
5969
6014
|
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();
|
|
5970
6015
|
{
|
|
5971
6016
|
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"]);
|
|
5972
|
-
t && (n =
|
|
6017
|
+
t && (n = Q(n, "hooks")), await n.execute();
|
|
5973
6018
|
}
|
|
5974
6019
|
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();
|
|
5975
6020
|
{
|
|
5976
6021
|
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"]);
|
|
5977
|
-
t && (n =
|
|
6022
|
+
t && (n = Q(n, "keys")), await n.execute();
|
|
5978
6023
|
}
|
|
5979
6024
|
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();
|
|
5980
6025
|
{
|
|
5981
6026
|
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"]);
|
|
5982
|
-
t && (n =
|
|
6027
|
+
t && (n = Q(n, "sessions")), await n.execute();
|
|
5983
6028
|
}
|
|
5984
6029
|
{
|
|
5985
6030
|
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"]);
|
|
5986
|
-
t && (n =
|
|
6031
|
+
t && (n = Q(n, "login_sessions")), await n.execute();
|
|
5987
6032
|
}
|
|
5988
6033
|
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();
|
|
5989
6034
|
{
|
|
5990
6035
|
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"]);
|
|
5991
|
-
t && (n =
|
|
6036
|
+
t && (n = Q(n, "migrations")), await n.execute();
|
|
5992
6037
|
}
|
|
5993
6038
|
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();
|
|
5994
6039
|
{
|
|
5995
6040
|
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());
|
|
5996
|
-
t && (n =
|
|
6041
|
+
t && (n = Q(n, "organization_connections")), await n.execute();
|
|
5997
6042
|
}
|
|
5998
6043
|
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();
|
|
5999
6044
|
{
|
|
6000
6045
|
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"]);
|
|
6001
|
-
t && (n =
|
|
6046
|
+
t && (n = Q(n, "passwords")), await n.execute();
|
|
6002
6047
|
}
|
|
6003
6048
|
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();
|
|
6004
6049
|
{
|
|
6005
6050
|
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"]);
|
|
6006
|
-
t && (n =
|
|
6051
|
+
t && (n = Q(n, "refresh_tokens")), await n.execute();
|
|
6007
6052
|
}
|
|
6008
6053
|
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", [
|
|
6009
6054
|
"tenant_id",
|
|
@@ -6013,23 +6058,23 @@ async function yo(e) {
|
|
|
6013
6058
|
]).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();
|
|
6014
6059
|
{
|
|
6015
6060
|
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"]);
|
|
6016
|
-
t && (n =
|
|
6061
|
+
t && (n = Q(n, "tenant_operation_events")), await n.execute();
|
|
6017
6062
|
}
|
|
6018
6063
|
{
|
|
6019
6064
|
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"]);
|
|
6020
|
-
t && (n =
|
|
6065
|
+
t && (n = Q(n, "themes")), await n.execute();
|
|
6021
6066
|
}
|
|
6022
6067
|
{
|
|
6023
6068
|
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"]);
|
|
6024
|
-
t && (n =
|
|
6069
|
+
t && (n = Q(n, "universal_login_templates")), await n.execute();
|
|
6025
6070
|
}
|
|
6026
6071
|
{
|
|
6027
6072
|
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"]);
|
|
6028
|
-
t && (n =
|
|
6073
|
+
t && (n = Q(n, "user_activity")), await n.execute();
|
|
6029
6074
|
}
|
|
6030
6075
|
{
|
|
6031
6076
|
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"]);
|
|
6032
|
-
t && (n =
|
|
6077
|
+
t && (n = Q(n, "user_organizations")), await n.execute();
|
|
6033
6078
|
}
|
|
6034
6079
|
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", [
|
|
6035
6080
|
"tenant_id",
|
|
@@ -6092,76 +6137,76 @@ async function yo(e) {
|
|
|
6092
6137
|
"tenant_id",
|
|
6093
6138
|
"phone_number",
|
|
6094
6139
|
"provider"
|
|
6095
|
-
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of
|
|
6140
|
+
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of Co) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6096
6141
|
let n = e;
|
|
6097
6142
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6098
6143
|
}).execute();
|
|
6099
6144
|
}
|
|
6100
|
-
async function
|
|
6145
|
+
async function Eo(e) {
|
|
6101
6146
|
await e.schema.dropTable("user_roles").ifExists().execute(), await e.schema.dropTable("user_permissions").ifExists().execute(), await e.schema.dropTable("user_organizations").ifExists().execute(), await e.schema.dropTable("user_activity").ifExists().execute(), await e.schema.dropTable("universal_login_templates").ifExists().execute(), await e.schema.dropTable("themes").ifExists().execute(), await e.schema.dropTable("tenant_operation_events").ifExists().execute(), await e.schema.dropTable("tenant_operations").ifExists().execute(), await e.schema.dropTable("rollouts").ifExists().execute(), await e.schema.dropTable("roles").ifExists().execute(), await e.schema.dropTable("role_permissions").ifExists().execute(), await e.schema.dropTable("resource_servers").ifExists().execute(), await e.schema.dropTable("refresh_tokens").ifExists().execute(), await e.schema.dropTable("proxy_routes").ifExists().execute(), await e.schema.dropTable("prompt_settings").ifExists().execute(), await e.schema.dropTable("passwords").ifExists().execute(), await e.schema.dropTable("outbox_events").ifExists().execute(), await e.schema.dropTable("organization_connections").ifExists().execute(), await e.schema.dropTable("organizations").ifExists().execute(), await e.schema.dropTable("migrations").ifExists().execute(), await e.schema.dropTable("migration_sources").ifExists().execute(), await e.schema.dropTable("logs").ifExists().execute(), await e.schema.dropTable("login_sessions").ifExists().execute(), await e.schema.dropTable("sessions").ifExists().execute(), await e.schema.dropTable("log_streams").ifExists().execute(), await e.schema.dropTable("keys").ifExists().execute(), await e.schema.dropTable("invites").ifExists().execute(), await e.schema.dropTable("hooks").ifExists().execute(), await e.schema.dropTable("hook_code").ifExists().execute(), await e.schema.dropTable("grants").ifExists().execute(), await e.schema.dropTable("forms").ifExists().execute(), await e.schema.dropTable("flows").ifExists().execute(), await e.schema.dropTable("email_templates").ifExists().execute(), await e.schema.dropTable("email_providers").ifExists().execute(), await e.schema.dropTable("custom_text").ifExists().execute(), await e.schema.dropTable("custom_domains").ifExists().execute(), await e.schema.dropTable("control_plane_comm_keys").ifExists().execute(), await e.schema.dropTable("connections").ifExists().execute(), await e.schema.dropTable("codes").ifExists().execute(), await e.schema.dropTable("users").ifExists().execute(), await e.schema.dropTable("client_registration_tokens").ifExists().execute(), await e.schema.dropTable("client_grants").ifExists().execute(), await e.schema.dropTable("clients").ifExists().execute(), await e.schema.dropTable("branding").ifExists().execute(), await e.schema.dropTable("authentication_methods").ifExists().execute(), await e.schema.dropTable("actions").ifExists().execute(), await e.schema.dropTable("action_versions").ifExists().execute(), await e.schema.dropTable("action_executions").ifExists().execute(), await e.schema.dropTable("tenants").ifExists().execute();
|
|
6102
6147
|
}
|
|
6103
6148
|
//#endregion
|
|
6104
6149
|
//#region migrate/log.ts
|
|
6105
|
-
var
|
|
6106
|
-
function
|
|
6107
|
-
|
|
6150
|
+
var Do = !1;
|
|
6151
|
+
function Oo(e) {
|
|
6152
|
+
Do = e;
|
|
6108
6153
|
}
|
|
6109
|
-
function
|
|
6110
|
-
|
|
6154
|
+
function $(...e) {
|
|
6155
|
+
Do && console.log(...e);
|
|
6111
6156
|
}
|
|
6112
|
-
function
|
|
6157
|
+
function ko(...e) {
|
|
6113
6158
|
console.warn(...e);
|
|
6114
6159
|
}
|
|
6115
6160
|
//#endregion
|
|
6116
6161
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6117
|
-
var
|
|
6118
|
-
down: () =>
|
|
6119
|
-
up: () =>
|
|
6120
|
-
}),
|
|
6121
|
-
async function
|
|
6162
|
+
var Ao = /* @__PURE__ */ w({
|
|
6163
|
+
down: () => Vo,
|
|
6164
|
+
up: () => Ro
|
|
6165
|
+
}), jo = 5e4, Mo = 500;
|
|
6166
|
+
async function No(e) {
|
|
6122
6167
|
try {
|
|
6123
6168
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6124
6169
|
} catch {
|
|
6125
6170
|
return "sqlite";
|
|
6126
6171
|
}
|
|
6127
6172
|
}
|
|
6128
|
-
async function
|
|
6173
|
+
async function Po(e, t, n) {
|
|
6129
6174
|
try {
|
|
6130
6175
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6131
6176
|
} catch (e) {
|
|
6132
6177
|
if (e instanceof Error && (e.message.includes("1060") || e.message.includes("duplicate column"))) {
|
|
6133
|
-
|
|
6178
|
+
$(` Column ${t}.${n} already exists, skipping`);
|
|
6134
6179
|
return;
|
|
6135
6180
|
}
|
|
6136
6181
|
throw e;
|
|
6137
6182
|
}
|
|
6138
6183
|
}
|
|
6139
|
-
async function
|
|
6184
|
+
async function Fo(e, t, n, r) {
|
|
6140
6185
|
try {
|
|
6141
6186
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6142
6187
|
} catch (e) {
|
|
6143
6188
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6144
|
-
|
|
6189
|
+
$(` Index ${t} already exists, skipping`);
|
|
6145
6190
|
return;
|
|
6146
6191
|
}
|
|
6147
6192
|
throw e;
|
|
6148
6193
|
}
|
|
6149
6194
|
}
|
|
6150
|
-
async function
|
|
6195
|
+
async function Io(e, t) {
|
|
6151
6196
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6152
6197
|
if (t === "sqlite") {
|
|
6153
6198
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6154
6199
|
r = Number(t.numDeletedRows);
|
|
6155
6200
|
} else {
|
|
6156
|
-
let t =
|
|
6157
|
-
for (; t >=
|
|
6158
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6159
|
-
t = Number(i.numDeletedRows), r += t, t > 0 &&
|
|
6201
|
+
let t = jo;
|
|
6202
|
+
for (; t >= jo;) {
|
|
6203
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(jo).executeTakeFirst();
|
|
6204
|
+
t = Number(i.numDeletedRows), r += t, t > 0 && $(` Pruned ${r} expired codes row(s)...`);
|
|
6160
6205
|
}
|
|
6161
6206
|
}
|
|
6162
6207
|
return r;
|
|
6163
6208
|
}
|
|
6164
|
-
async function
|
|
6209
|
+
async function Lo(e) {
|
|
6165
6210
|
let t = 0;
|
|
6166
6211
|
for (;;) {
|
|
6167
6212
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6169,33 +6214,33 @@ async function Ao(e) {
|
|
|
6169
6214
|
"code_type",
|
|
6170
6215
|
"tenant_id",
|
|
6171
6216
|
"expires_at"
|
|
6172
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6217
|
+
]).where("expires_at_ts", "is", null).limit(Mo).execute();
|
|
6173
6218
|
if (n.length === 0) break;
|
|
6174
6219
|
for (let t of n) {
|
|
6175
6220
|
let n = Date.parse(t.expires_at);
|
|
6176
6221
|
await e.updateTable("codes").set({ expires_at_ts: Number.isNaN(n) ? 0 : n }).where("code_id", "=", t.code_id).where("code_type", "=", t.code_type).where("tenant_id", "=", t.tenant_id).execute();
|
|
6177
6222
|
}
|
|
6178
|
-
if (t += n.length, n.length <
|
|
6223
|
+
if (t += n.length, n.length < Mo) break;
|
|
6179
6224
|
}
|
|
6180
6225
|
return t;
|
|
6181
6226
|
}
|
|
6182
|
-
async function
|
|
6183
|
-
let t = await
|
|
6227
|
+
async function Ro(e) {
|
|
6228
|
+
let t = await No(e);
|
|
6184
6229
|
try {
|
|
6185
|
-
let n = await
|
|
6186
|
-
|
|
6230
|
+
let n = await Io(e, t);
|
|
6231
|
+
$(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6187
6232
|
} catch (e) {
|
|
6188
|
-
|
|
6233
|
+
ko(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6189
6234
|
}
|
|
6190
|
-
await
|
|
6235
|
+
await Po(e, "codes", "expires_at_ts"), await Fo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6191
6236
|
try {
|
|
6192
|
-
let t = await
|
|
6193
|
-
|
|
6237
|
+
let t = await Lo(e);
|
|
6238
|
+
$(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6194
6239
|
} catch (e) {
|
|
6195
|
-
|
|
6240
|
+
ko(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6196
6241
|
}
|
|
6197
6242
|
}
|
|
6198
|
-
async function
|
|
6243
|
+
async function zo(e, t, n) {
|
|
6199
6244
|
try {
|
|
6200
6245
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6201
6246
|
} catch (e) {
|
|
@@ -6203,7 +6248,7 @@ async function Mo(e, t, n) {
|
|
|
6203
6248
|
throw e;
|
|
6204
6249
|
}
|
|
6205
6250
|
}
|
|
6206
|
-
async function
|
|
6251
|
+
async function Bo(e, t, n) {
|
|
6207
6252
|
try {
|
|
6208
6253
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6209
6254
|
} catch (e) {
|
|
@@ -6211,16 +6256,16 @@ async function No(e, t, n) {
|
|
|
6211
6256
|
throw e;
|
|
6212
6257
|
}
|
|
6213
6258
|
}
|
|
6214
|
-
async function
|
|
6215
|
-
await
|
|
6259
|
+
async function Vo(e) {
|
|
6260
|
+
await zo(e, "idx_codes_expires_at_ts", "codes"), await Bo(e, "codes", "expires_at_ts");
|
|
6216
6261
|
}
|
|
6217
6262
|
//#endregion
|
|
6218
6263
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6219
|
-
var
|
|
6220
|
-
down: () =>
|
|
6221
|
-
up: () =>
|
|
6264
|
+
var Ho = /* @__PURE__ */ w({
|
|
6265
|
+
down: () => Wo,
|
|
6266
|
+
up: () => Uo
|
|
6222
6267
|
});
|
|
6223
|
-
async function
|
|
6268
|
+
async function Uo(e) {
|
|
6224
6269
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", f`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(128)`, (e) => e.notNull()).addColumn("scopes", f`text`, (e) => e.notNull()).addColumn("valid_until", f`varchar(35)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", f`varchar(35)`).addPrimaryKeyConstraint("scim_tokens_pk", ["tenant_id", "token_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_connection_idx").on("scim_tokens").columns(["tenant_id", "connection_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_hash_idx").on("scim_tokens").columns(["tenant_id", "token_hash"]).unique().execute(), await e.schema.createTable("scim_external_ids").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("external_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6225
6270
|
"tenant_id",
|
|
6226
6271
|
"connection_id",
|
|
@@ -6231,16 +6276,16 @@ async function Io(e) {
|
|
|
6231
6276
|
"external_id"
|
|
6232
6277
|
]).unique().execute();
|
|
6233
6278
|
}
|
|
6234
|
-
async function
|
|
6279
|
+
async function Wo(e) {
|
|
6235
6280
|
await e.schema.dropTable("scim_external_ids").ifExists().execute(), await e.schema.dropTable("scim_tokens").ifExists().execute(), await e.schema.dropTable("scim_configurations").ifExists().execute();
|
|
6236
6281
|
}
|
|
6237
6282
|
//#endregion
|
|
6238
6283
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6239
|
-
var
|
|
6240
|
-
down: () =>
|
|
6241
|
-
up: () =>
|
|
6284
|
+
var Go = /* @__PURE__ */ w({
|
|
6285
|
+
down: () => Yo,
|
|
6286
|
+
up: () => qo
|
|
6242
6287
|
});
|
|
6243
|
-
async function
|
|
6288
|
+
async function Ko(e, t, n) {
|
|
6244
6289
|
try {
|
|
6245
6290
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6246
6291
|
} catch (e) {
|
|
@@ -6248,10 +6293,10 @@ async function zo(e, t, n) {
|
|
|
6248
6293
|
throw e;
|
|
6249
6294
|
}
|
|
6250
6295
|
}
|
|
6251
|
-
async function
|
|
6252
|
-
await
|
|
6296
|
+
async function qo(e) {
|
|
6297
|
+
await Ko(e, "users", "blocked");
|
|
6253
6298
|
}
|
|
6254
|
-
async function
|
|
6299
|
+
async function Jo(e, t, n) {
|
|
6255
6300
|
try {
|
|
6256
6301
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6257
6302
|
} catch (e) {
|
|
@@ -6259,16 +6304,16 @@ async function Vo(e, t, n) {
|
|
|
6259
6304
|
throw e;
|
|
6260
6305
|
}
|
|
6261
6306
|
}
|
|
6262
|
-
async function
|
|
6263
|
-
await
|
|
6307
|
+
async function Yo(e) {
|
|
6308
|
+
await Jo(e, "users", "blocked");
|
|
6264
6309
|
}
|
|
6265
6310
|
//#endregion
|
|
6266
6311
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6267
|
-
var
|
|
6268
|
-
down: () =>
|
|
6269
|
-
up: () =>
|
|
6312
|
+
var Xo = /* @__PURE__ */ w({
|
|
6313
|
+
down: () => es,
|
|
6314
|
+
up: () => Qo
|
|
6270
6315
|
});
|
|
6271
|
-
async function
|
|
6316
|
+
async function Zo(e, t, n) {
|
|
6272
6317
|
try {
|
|
6273
6318
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6274
6319
|
} catch (e) {
|
|
@@ -6276,10 +6321,10 @@ async function Wo(e, t, n) {
|
|
|
6276
6321
|
throw e;
|
|
6277
6322
|
}
|
|
6278
6323
|
}
|
|
6279
|
-
async function
|
|
6280
|
-
await
|
|
6324
|
+
async function Qo(e) {
|
|
6325
|
+
await Zo(e, "prompt_settings", "show_last_used_connection");
|
|
6281
6326
|
}
|
|
6282
|
-
async function
|
|
6327
|
+
async function $o(e, t, n) {
|
|
6283
6328
|
try {
|
|
6284
6329
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6285
6330
|
} catch (e) {
|
|
@@ -6287,35 +6332,93 @@ async function Ko(e, t, n) {
|
|
|
6287
6332
|
throw e;
|
|
6288
6333
|
}
|
|
6289
6334
|
}
|
|
6290
|
-
async function
|
|
6291
|
-
await
|
|
6335
|
+
async function es(e) {
|
|
6336
|
+
await $o(e, "prompt_settings", "show_last_used_connection");
|
|
6337
|
+
}
|
|
6338
|
+
//#endregion
|
|
6339
|
+
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6340
|
+
var ts = /* @__PURE__ */ w({
|
|
6341
|
+
down: () => is,
|
|
6342
|
+
up: () => rs
|
|
6343
|
+
});
|
|
6344
|
+
async function ns(e, t, n, r) {
|
|
6345
|
+
try {
|
|
6346
|
+
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6347
|
+
} catch (e) {
|
|
6348
|
+
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6349
|
+
$(` Index ${t} already exists, skipping`);
|
|
6350
|
+
return;
|
|
6351
|
+
}
|
|
6352
|
+
throw e;
|
|
6353
|
+
}
|
|
6354
|
+
}
|
|
6355
|
+
async function rs(e) {
|
|
6356
|
+
await ns(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6357
|
+
}
|
|
6358
|
+
async function is(e) {
|
|
6359
|
+
try {
|
|
6360
|
+
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6361
|
+
} catch (e) {
|
|
6362
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6363
|
+
throw e;
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
//#endregion
|
|
6367
|
+
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6368
|
+
var as = /* @__PURE__ */ w({
|
|
6369
|
+
down: () => ls,
|
|
6370
|
+
up: () => ss
|
|
6371
|
+
});
|
|
6372
|
+
async function os(e, t, n, r) {
|
|
6373
|
+
try {
|
|
6374
|
+
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6375
|
+
} catch (e) {
|
|
6376
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6377
|
+
throw e;
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
async function ss(e) {
|
|
6381
|
+
await os(e, "hooks", "page_id", f`varchar(64)`), await os(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6382
|
+
}
|
|
6383
|
+
async function cs(e, t, n) {
|
|
6384
|
+
try {
|
|
6385
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6386
|
+
} catch (e) {
|
|
6387
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6388
|
+
throw e;
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
async function ls(e) {
|
|
6392
|
+
await cs(e, "hooks", "permission_required"), await cs(e, "hooks", "page_id");
|
|
6292
6393
|
}
|
|
6293
6394
|
//#endregion
|
|
6294
6395
|
//#region migrate/migrations/index.ts
|
|
6295
|
-
var
|
|
6296
|
-
"2026-07-16T14:00:00_baseline":
|
|
6297
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6298
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6299
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6300
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6396
|
+
var us = {
|
|
6397
|
+
"2026-07-16T14:00:00_baseline": So,
|
|
6398
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Ao,
|
|
6399
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Ho,
|
|
6400
|
+
"2026-08-05T12:00:00_user_blocked": Go,
|
|
6401
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Xo,
|
|
6402
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": ts,
|
|
6403
|
+
"2026-08-11T12:00:00_page_hooks": as
|
|
6301
6404
|
};
|
|
6302
6405
|
//#endregion
|
|
6303
6406
|
//#region migrate/migrate.ts
|
|
6304
|
-
async function
|
|
6305
|
-
|
|
6306
|
-
let { error: n, results: r } = await new
|
|
6407
|
+
async function ds(e, t = !1) {
|
|
6408
|
+
Oo(t), t && console.log("migrating...");
|
|
6409
|
+
let { error: n, results: r } = await new ve({
|
|
6307
6410
|
db: e,
|
|
6308
|
-
provider: new
|
|
6411
|
+
provider: new xo(us)
|
|
6309
6412
|
}).migrateToLatest();
|
|
6310
6413
|
if (r?.forEach((e) => {
|
|
6311
6414
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6312
6415
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6313
6416
|
}
|
|
6314
|
-
async function
|
|
6315
|
-
|
|
6316
|
-
let { error: n, results: r } = await new
|
|
6417
|
+
async function fs(e, t = !1) {
|
|
6418
|
+
Oo(t), t && console.log("migrating...");
|
|
6419
|
+
let { error: n, results: r } = await new ve({
|
|
6317
6420
|
db: e,
|
|
6318
|
-
provider: new
|
|
6421
|
+
provider: new xo(us)
|
|
6319
6422
|
}).migrateDown();
|
|
6320
6423
|
if (r?.forEach((e) => {
|
|
6321
6424
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6323,64 +6426,64 @@ async function Xo(e, t = !1) {
|
|
|
6323
6426
|
}
|
|
6324
6427
|
//#endregion
|
|
6325
6428
|
//#region src/index.ts
|
|
6326
|
-
function
|
|
6429
|
+
function ps(e, t = { useTransactions: !0 }) {
|
|
6327
6430
|
let n = {
|
|
6328
|
-
actions:
|
|
6329
|
-
actionExecutions:
|
|
6330
|
-
actionVersions:
|
|
6331
|
-
branding:
|
|
6332
|
-
clients:
|
|
6333
|
-
clientConnections:
|
|
6334
|
-
clientGrants:
|
|
6335
|
-
clientRegistrationTokens:
|
|
6336
|
-
codes:
|
|
6337
|
-
connections:
|
|
6338
|
-
emailProviders:
|
|
6339
|
-
emailTemplates:
|
|
6340
|
-
customDomains:
|
|
6341
|
-
flows:
|
|
6342
|
-
forms:
|
|
6343
|
-
hookCode:
|
|
6344
|
-
hooks:
|
|
6345
|
-
invites:
|
|
6346
|
-
keys:
|
|
6347
|
-
loginSessions:
|
|
6348
|
-
logs:
|
|
6349
|
-
logStreams:
|
|
6350
|
-
migrationSources:
|
|
6351
|
-
authenticationMethods:
|
|
6352
|
-
passwords:
|
|
6353
|
-
promptSettings:
|
|
6354
|
-
proxyRoutes:
|
|
6355
|
-
scimConfigurations:
|
|
6356
|
-
scimTokens:
|
|
6357
|
-
scimExternalIds:
|
|
6358
|
-
refreshTokens:
|
|
6359
|
-
resourceServers:
|
|
6360
|
-
rolePermissions:
|
|
6361
|
-
grants:
|
|
6362
|
-
userPermissions:
|
|
6363
|
-
userRoles:
|
|
6364
|
-
roles:
|
|
6365
|
-
sessions:
|
|
6366
|
-
sessionCleanup:
|
|
6367
|
-
tenants:
|
|
6368
|
-
tenantOperations:
|
|
6369
|
-
tenantOperationEvents:
|
|
6370
|
-
rollouts:
|
|
6371
|
-
themes:
|
|
6372
|
-
universalLoginTemplates:
|
|
6373
|
-
customText:
|
|
6374
|
-
users:
|
|
6375
|
-
userActivity:
|
|
6376
|
-
organizations:
|
|
6377
|
-
organizationConnections:
|
|
6378
|
-
userOrganizations:
|
|
6379
|
-
stats:
|
|
6380
|
-
analytics:
|
|
6381
|
-
outbox:
|
|
6431
|
+
actions: Le(e),
|
|
6432
|
+
actionExecutions: Ue(e),
|
|
6433
|
+
actionVersions: Ke(e),
|
|
6434
|
+
branding: tr(e),
|
|
6435
|
+
clients: _n(e),
|
|
6436
|
+
clientConnections: Cn(e),
|
|
6437
|
+
clientGrants: An(e),
|
|
6438
|
+
clientRegistrationTokens: Vn(e),
|
|
6439
|
+
codes: tn(e),
|
|
6440
|
+
connections: ln(e),
|
|
6441
|
+
emailProviders: Vr(e),
|
|
6442
|
+
emailTemplates: Jr(e),
|
|
6443
|
+
customDomains: Qn(e),
|
|
6444
|
+
flows: yt(e),
|
|
6445
|
+
forms: di(e),
|
|
6446
|
+
hookCode: gr(e),
|
|
6447
|
+
hooks: dr(e),
|
|
6448
|
+
invites: ua(e),
|
|
6449
|
+
keys: Gn(e),
|
|
6450
|
+
loginSessions: Mr(e),
|
|
6451
|
+
logs: Ft(e),
|
|
6452
|
+
logStreams: Ga(e),
|
|
6453
|
+
migrationSources: Ka(e),
|
|
6454
|
+
authenticationMethods: Pa(e),
|
|
6455
|
+
passwords: Kt(e),
|
|
6456
|
+
promptSettings: Ir(e),
|
|
6457
|
+
proxyRoutes: J(e),
|
|
6458
|
+
scimConfigurations: eo(e),
|
|
6459
|
+
scimTokens: to(e),
|
|
6460
|
+
scimExternalIds: ro(e),
|
|
6461
|
+
refreshTokens: ri(e),
|
|
6462
|
+
resourceServers: _i(e),
|
|
6463
|
+
rolePermissions: Di(e),
|
|
6464
|
+
grants: Ni(e),
|
|
6465
|
+
userPermissions: Ri(e),
|
|
6466
|
+
userRoles: Wi(e),
|
|
6467
|
+
roles: Ci(e),
|
|
6468
|
+
sessions: Vt(e),
|
|
6469
|
+
sessionCleanup: ai(e),
|
|
6470
|
+
tenants: Dt(e),
|
|
6471
|
+
tenantOperations: io(e),
|
|
6472
|
+
tenantOperationEvents: _o(e),
|
|
6473
|
+
rollouts: bo(e),
|
|
6474
|
+
themes: xr(e),
|
|
6475
|
+
universalLoginTemplates: ar(e),
|
|
6476
|
+
customText: Da(e),
|
|
6477
|
+
users: dt(e),
|
|
6478
|
+
userActivity: ct(e),
|
|
6479
|
+
organizations: Xi(e),
|
|
6480
|
+
organizationConnections: Zi(e),
|
|
6481
|
+
userOrganizations: ia(e),
|
|
6482
|
+
stats: ha(e),
|
|
6483
|
+
analytics: Ea(e),
|
|
6484
|
+
outbox: Wa(e),
|
|
6382
6485
|
async transaction(r) {
|
|
6383
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6486
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(ps(e, {
|
|
6384
6487
|
...t,
|
|
6385
6488
|
useTransactions: !1
|
|
6386
6489
|
})));
|
|
@@ -6389,4 +6492,4 @@ function Zo(e, t = { useTransactions: !0 }) {
|
|
|
6389
6492
|
return n;
|
|
6390
6493
|
}
|
|
6391
6494
|
//#endregion
|
|
6392
|
-
export {
|
|
6495
|
+
export { Xa as createProxyDataAdapter, J as createProxyRoutesAdapter, ps as default, fs as migrateDown, ds as migrateToLatest };
|