@authhero/kysely-adapter 12.5.1 → 12.6.1
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.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { customAlphabet as e, nanoid as t } from "nanoid";
|
|
2
2
|
import { booleanToInt as n, convertDatesToAdapter as r, dbDateToIso as i, dbDateToIsoRequired as a, getCountAsInt as o, isoToDbDate as s, nowIso as c, removeNullProperties as l, removeUndefinedAndNull as u, stringifyProperties as d } from "@authhero/adapter-interfaces/sql";
|
|
3
3
|
import { sql as f } from "kysely";
|
|
4
|
-
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he,
|
|
4
|
+
import { LoginSessionState as p, MONDAY_EPOCH_SHIFT_MS as m, WEEK_MS as h, buildRefreshTokenRetention as g, buildSessionRetention as _, clientGrantSchema as v, clientRegistrationTokenTypeSchema as y, codeSchema as ee, decodeCursor as te, emailTemplateSchema as ne, encodeCursor as re, flowSchema as b, formSchema as x, handlerConfigSchema as ie, isEmailSearchTerm as ae, isPlainObject as oe, loginSessionSchema as se, matchSchema as ce, migrationProviderTypeSchema as le, parseUserId as ue, resourceServerSchema as de, rolloutInsertSchema as fe, rolloutSchema as pe, sanitizeLuceneQuery as S, scimMappingEntrySchema as me, sessionRetentionWindow as he, splitLuceneOrGroups as ge, tenantOperationEventInsertSchema as _e, tenantOperationEventSchema as ve, tenantOperationInsertSchema as ye, tenantOperationSchema as be, tokenizeLuceneQuery as xe, unescapeLuceneValue as Se, unquoteLuceneValue as Ce } from "@authhero/adapter-interfaces";
|
|
5
5
|
import { HTTPException as C } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as we } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var Te = Object.defineProperty, w = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) Te(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || Te(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, Ee = 17, De = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -26,38 +26,38 @@ var xe = Object.defineProperty, w = (e, t) => {
|
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
28
|
function T(t) {
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", Ee)();
|
|
30
|
+
return `${De[t]}${n}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Oe() {
|
|
33
33
|
return T("organization");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function ke() {
|
|
36
36
|
return T("connection");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ae() {
|
|
39
39
|
return T("action");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function je() {
|
|
42
42
|
return T("action_version");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Me() {
|
|
45
45
|
return T("hook");
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Ne() {
|
|
48
48
|
return T("resource_server");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Pe() {
|
|
51
51
|
return T("hook_code");
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Fe() {
|
|
54
54
|
return T("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function Ie(e) {
|
|
59
59
|
return async (t, n, r) => {
|
|
60
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ??
|
|
60
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : o, c = i?.id ?? Ae();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,14 +91,14 @@ function Me(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 Le(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 Pe(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,51 +123,43 @@ function Pe(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Re(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function E(e) {
|
|
130
|
-
return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
|
|
131
|
-
}
|
|
132
129
|
function D(e, t, n, r, i = [], a = {}) {
|
|
133
130
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
134
131
|
let t = a[e];
|
|
135
132
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
136
133
|
}, l = (e) => {
|
|
137
134
|
let t = a[e];
|
|
138
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
135
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : Re(t);
|
|
139
136
|
}, u = (e, t) => {
|
|
140
137
|
let n = a[e];
|
|
141
138
|
if (n === void 0 || typeof n == "string") return t;
|
|
142
139
|
let r = Number(t);
|
|
143
140
|
return Number.isFinite(r) ? r : t;
|
|
144
|
-
}, d = n
|
|
145
|
-
|
|
141
|
+
}, d = ge(n);
|
|
142
|
+
return d.length > 1 ? t.where((e) => {
|
|
146
143
|
let t = d.map((t) => {
|
|
147
|
-
let n = t.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
let n = t.map((t) => {
|
|
145
|
+
let n = t.match(/^([^:]+):(.+)$/);
|
|
146
|
+
if (!n) return null;
|
|
147
|
+
let [, r, i] = n;
|
|
148
|
+
if (!r || !i) return null;
|
|
149
|
+
let a = r.trim(), d = Se(i.replace(/^"(.*)"$/, "$1").trim());
|
|
150
|
+
return o.has(a) ? e(s(c(a)), "like", `%${d}%`) : e(l(a), "=", u(a, d));
|
|
151
|
+
}).filter((e) => e !== null);
|
|
152
|
+
return n.length === 0 ? null : n.length === 1 ? n[0] : e.and(n);
|
|
155
153
|
}).filter((e) => e !== null);
|
|
156
154
|
return e.or(t);
|
|
157
|
-
})
|
|
158
|
-
let f = [], p = "", m = !1;
|
|
159
|
-
for (let e = 0; e < n.length; e++) {
|
|
160
|
-
let t = n[e];
|
|
161
|
-
t === "\"" ? (m = !m, p += t) : t === " " && !m ? p.trim() && (f.push(p.trim()), p = "") : p += t;
|
|
162
|
-
}
|
|
163
|
-
return p.trim() && f.push(p.trim()), f.filter((e) => e !== "AND").map((e) => e.replace(/^([^:]+)=/g, "$1:")).map((e) => {
|
|
155
|
+
}) : ((d[0] ?? []).filter((e) => e !== "AND").map((e) => e.replace(/^([^:]+)=/g, "$1:")).map((e) => {
|
|
164
156
|
let t = e.startsWith("-"), n = null, r = "", i = !1, a;
|
|
165
157
|
if (e.startsWith("-_exists_:")) n = e.substring(10), i = !0, t = !0;
|
|
166
158
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
167
159
|
else if (e.includes(":")) {
|
|
168
160
|
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 =
|
|
161
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = Se(r);
|
|
162
|
+
} else n = null, r = Se(e), i = !1;
|
|
171
163
|
return {
|
|
172
164
|
key: n,
|
|
173
165
|
value: r,
|
|
@@ -203,18 +195,18 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
203
195
|
}
|
|
204
196
|
t = t.where((e) => e.or(r.map((t) => t === "user_id" ? e(s(c(t)), "=", n) : e(s(c(t)), "like", `%${n}%`))));
|
|
205
197
|
}
|
|
206
|
-
}), t;
|
|
198
|
+
}), t);
|
|
207
199
|
}
|
|
208
200
|
//#endregion
|
|
209
201
|
//#region src/actions/list.ts
|
|
210
|
-
function
|
|
202
|
+
function ze(e) {
|
|
211
203
|
if (e) try {
|
|
212
204
|
return JSON.parse(e);
|
|
213
205
|
} catch {
|
|
214
206
|
return;
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
|
-
function
|
|
209
|
+
function Be(e) {
|
|
218
210
|
return async (t, n = {}) => {
|
|
219
211
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
220
212
|
c && (l = D(e, l, c, ["name"]));
|
|
@@ -230,9 +222,9 @@ function Ie(e) {
|
|
|
230
222
|
runtime: f.runtime ?? void 0,
|
|
231
223
|
status: f.status || "built",
|
|
232
224
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
233
|
-
secrets:
|
|
234
|
-
dependencies:
|
|
235
|
-
supported_triggers:
|
|
225
|
+
secrets: ze(o),
|
|
226
|
+
dependencies: ze(s),
|
|
227
|
+
supported_triggers: ze(c),
|
|
236
228
|
is_system: !!l,
|
|
237
229
|
inherit: !!u
|
|
238
230
|
};
|
|
@@ -254,7 +246,7 @@ function Ie(e) {
|
|
|
254
246
|
}
|
|
255
247
|
//#endregion
|
|
256
248
|
//#region src/actions/update.ts
|
|
257
|
-
function
|
|
249
|
+
function Ve(e) {
|
|
258
250
|
if (!e) return [];
|
|
259
251
|
try {
|
|
260
252
|
let t = JSON.parse(e);
|
|
@@ -263,11 +255,11 @@ function Le(e) {
|
|
|
263
255
|
return [];
|
|
264
256
|
}
|
|
265
257
|
}
|
|
266
|
-
function
|
|
258
|
+
function He(e) {
|
|
267
259
|
return async (t, n, r) => {
|
|
268
260
|
let i = { updated_at_ts: Date.now() };
|
|
269
261
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
270
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
262
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Ve(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
271
263
|
name: e.name,
|
|
272
264
|
value: o.get(e.name)?.value
|
|
273
265
|
} : e);
|
|
@@ -282,23 +274,23 @@ function Re(e) {
|
|
|
282
274
|
}
|
|
283
275
|
//#endregion
|
|
284
276
|
//#region src/actions/remove.ts
|
|
285
|
-
function
|
|
277
|
+
function Ue(e) {
|
|
286
278
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
287
279
|
}
|
|
288
280
|
//#endregion
|
|
289
281
|
//#region src/actions/index.ts
|
|
290
|
-
function
|
|
282
|
+
function We(e) {
|
|
291
283
|
return {
|
|
292
|
-
create:
|
|
293
|
-
get:
|
|
294
|
-
list:
|
|
295
|
-
update:
|
|
296
|
-
remove:
|
|
284
|
+
create: Ie(e),
|
|
285
|
+
get: Le(e),
|
|
286
|
+
list: Be(e),
|
|
287
|
+
update: He(e),
|
|
288
|
+
remove: Ue(e)
|
|
297
289
|
};
|
|
298
290
|
}
|
|
299
291
|
//#endregion
|
|
300
292
|
//#region src/actionExecutions/create.ts
|
|
301
|
-
function
|
|
293
|
+
function Ge(e) {
|
|
302
294
|
return async (t, n) => {
|
|
303
295
|
let r = Date.now();
|
|
304
296
|
return await e.insertInto("action_executions").values({
|
|
@@ -324,14 +316,14 @@ function Ve(e) {
|
|
|
324
316
|
}
|
|
325
317
|
//#endregion
|
|
326
318
|
//#region src/actionExecutions/get.ts
|
|
327
|
-
function
|
|
319
|
+
function Ke(e) {
|
|
328
320
|
if (e) try {
|
|
329
321
|
return JSON.parse(e);
|
|
330
322
|
} catch {
|
|
331
323
|
return;
|
|
332
324
|
}
|
|
333
325
|
}
|
|
334
|
-
function
|
|
326
|
+
function qe(e) {
|
|
335
327
|
return async (t, n) => {
|
|
336
328
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
337
329
|
return r ? {
|
|
@@ -339,8 +331,8 @@ function Ue(e) {
|
|
|
339
331
|
tenant_id: r.tenant_id,
|
|
340
332
|
trigger_id: r.trigger_id,
|
|
341
333
|
status: r.status,
|
|
342
|
-
results:
|
|
343
|
-
logs:
|
|
334
|
+
results: Ke(r.results) ?? [],
|
|
335
|
+
logs: Ke(r.logs),
|
|
344
336
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
345
337
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
346
338
|
} : null;
|
|
@@ -348,26 +340,26 @@ function Ue(e) {
|
|
|
348
340
|
}
|
|
349
341
|
//#endregion
|
|
350
342
|
//#region src/actionExecutions/cleanup.ts
|
|
351
|
-
var
|
|
352
|
-
async function
|
|
343
|
+
var O = 5e4;
|
|
344
|
+
async function Je(e) {
|
|
353
345
|
try {
|
|
354
346
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
355
347
|
} catch {
|
|
356
348
|
return "sqlite";
|
|
357
349
|
}
|
|
358
350
|
}
|
|
359
|
-
function
|
|
351
|
+
function Ye(e) {
|
|
360
352
|
let t;
|
|
361
353
|
return async (n) => {
|
|
362
354
|
let r = Date.parse(n);
|
|
363
355
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
364
|
-
if (t ??= await
|
|
356
|
+
if (t ??= await Je(e), t === "sqlite") {
|
|
365
357
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
366
358
|
return Number(t.numDeletedRows);
|
|
367
359
|
}
|
|
368
|
-
let i = 0, a =
|
|
369
|
-
for (; a >=
|
|
370
|
-
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(
|
|
360
|
+
let i = 0, a = O;
|
|
361
|
+
for (; a >= O;) {
|
|
362
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(O).executeTakeFirst();
|
|
371
363
|
a = Number(t.numDeletedRows), i += a;
|
|
372
364
|
}
|
|
373
365
|
return i;
|
|
@@ -375,39 +367,39 @@ function Ge(e) {
|
|
|
375
367
|
}
|
|
376
368
|
//#endregion
|
|
377
369
|
//#region src/actionExecutions/index.ts
|
|
378
|
-
function
|
|
370
|
+
function Xe(e) {
|
|
379
371
|
return {
|
|
380
|
-
create:
|
|
381
|
-
get:
|
|
382
|
-
cleanup:
|
|
372
|
+
create: Ge(e),
|
|
373
|
+
get: qe(e),
|
|
374
|
+
cleanup: Ye(e)
|
|
383
375
|
};
|
|
384
376
|
}
|
|
385
377
|
//#endregion
|
|
386
378
|
//#region src/actionVersions/index.ts
|
|
387
|
-
function
|
|
379
|
+
function k(e) {
|
|
388
380
|
if (e) try {
|
|
389
381
|
return JSON.parse(e);
|
|
390
382
|
} catch {
|
|
391
383
|
return;
|
|
392
384
|
}
|
|
393
385
|
}
|
|
394
|
-
function
|
|
386
|
+
function Ze(e) {
|
|
395
387
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
396
388
|
return {
|
|
397
389
|
...c,
|
|
398
390
|
runtime: s ?? void 0,
|
|
399
391
|
deployed: !!o,
|
|
400
|
-
secrets:
|
|
401
|
-
dependencies:
|
|
402
|
-
supported_triggers:
|
|
392
|
+
secrets: k(r),
|
|
393
|
+
dependencies: k(i),
|
|
394
|
+
supported_triggers: k(a),
|
|
403
395
|
created_at: new Date(Number(t)).toISOString(),
|
|
404
396
|
updated_at: new Date(Number(n)).toISOString()
|
|
405
397
|
};
|
|
406
398
|
}
|
|
407
|
-
function
|
|
399
|
+
function Qe(e) {
|
|
408
400
|
return {
|
|
409
401
|
async create(t, n, r) {
|
|
410
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ??
|
|
402
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? je(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
411
403
|
let r = ((await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n.action_id).select("number").orderBy("number", "desc").limit(1).executeTakeFirst())?.number ?? 0) + 1;
|
|
412
404
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
413
405
|
deployed: 0,
|
|
@@ -444,10 +436,10 @@ function Ye(e) {
|
|
|
444
436
|
},
|
|
445
437
|
async get(t, n, r) {
|
|
446
438
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
447
|
-
return i ?
|
|
439
|
+
return i ? Ze(i) : null;
|
|
448
440
|
},
|
|
449
441
|
async list(t, n, r = {}) {
|
|
450
|
-
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(
|
|
442
|
+
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(Ze);
|
|
451
443
|
if (!s) return {
|
|
452
444
|
versions: l,
|
|
453
445
|
start: 0,
|
|
@@ -489,7 +481,7 @@ async function A(e, t, n, r) {
|
|
|
489
481
|
error: null
|
|
490
482
|
}).execute();
|
|
491
483
|
}
|
|
492
|
-
function
|
|
484
|
+
function $e(e) {
|
|
493
485
|
return async (n, r) => {
|
|
494
486
|
let i = t();
|
|
495
487
|
return await A(e, n, i, r), i;
|
|
@@ -497,7 +489,7 @@ function Xe(e) {
|
|
|
497
489
|
}
|
|
498
490
|
//#endregion
|
|
499
491
|
//#region src/users/create.ts
|
|
500
|
-
function
|
|
492
|
+
function et(e) {
|
|
501
493
|
return async (n, r, i) => {
|
|
502
494
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
503
495
|
...f,
|
|
@@ -557,7 +549,7 @@ function Ze(e) {
|
|
|
557
549
|
}
|
|
558
550
|
//#endregion
|
|
559
551
|
//#region src/users/user-to-identity.ts
|
|
560
|
-
var
|
|
552
|
+
var tt = [
|
|
561
553
|
"email",
|
|
562
554
|
"email_verified",
|
|
563
555
|
"phone_number",
|
|
@@ -571,7 +563,7 @@ function j(e, t = !1) {
|
|
|
571
563
|
user_id: ue(e.user_id).id,
|
|
572
564
|
isSocial: !!e.is_social
|
|
573
565
|
};
|
|
574
|
-
for (let t of
|
|
566
|
+
for (let t of tt) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
575
567
|
if (!t) {
|
|
576
568
|
let t = {};
|
|
577
569
|
try {
|
|
@@ -589,7 +581,7 @@ function j(e, t = !1) {
|
|
|
589
581
|
}
|
|
590
582
|
//#endregion
|
|
591
583
|
//#region src/users/get.ts
|
|
592
|
-
function
|
|
584
|
+
function nt(e) {
|
|
593
585
|
return async (t, n) => {
|
|
594
586
|
let [r, i] = await Promise.all([e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t).where("users.user_id", "=", n).selectAll("users").select([
|
|
595
587
|
"user_activity.last_login",
|
|
@@ -620,12 +612,12 @@ function $e(e) {
|
|
|
620
612
|
function M(e) {
|
|
621
613
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
622
614
|
}
|
|
623
|
-
function
|
|
615
|
+
function rt(e, t) {
|
|
624
616
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
625
617
|
return n >= 1 ? n : t;
|
|
626
618
|
}
|
|
627
619
|
async function N(e, t, n) {
|
|
628
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
620
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = rt(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
629
621
|
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" });
|
|
630
622
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
631
623
|
else {
|
|
@@ -649,7 +641,7 @@ async function N(e, t, n) {
|
|
|
649
641
|
}
|
|
650
642
|
//#endregion
|
|
651
643
|
//#region src/users/list.ts
|
|
652
|
-
var
|
|
644
|
+
var it = [
|
|
653
645
|
"user_id",
|
|
654
646
|
"email",
|
|
655
647
|
"email_verified",
|
|
@@ -672,20 +664,20 @@ var tt = [
|
|
|
672
664
|
"login_count",
|
|
673
665
|
"created_at",
|
|
674
666
|
"updated_at"
|
|
675
|
-
],
|
|
667
|
+
], at = new Set([
|
|
676
668
|
"last_login",
|
|
677
669
|
"last_ip",
|
|
678
670
|
"login_count"
|
|
679
|
-
]),
|
|
671
|
+
]), ot = Object.fromEntries(it.map((e) => [e, e === "login_count" ? {
|
|
680
672
|
column: "user_activity.login_count",
|
|
681
673
|
defaultValue: 0
|
|
682
|
-
} :
|
|
674
|
+
} : at.has(e) ? `user_activity.${e}` : `users.${e}`])), st = [
|
|
683
675
|
"email",
|
|
684
676
|
"name",
|
|
685
677
|
"phone_number",
|
|
686
678
|
"user_id"
|
|
687
679
|
];
|
|
688
|
-
async function
|
|
680
|
+
async function ct(e, t, n) {
|
|
689
681
|
let r = n.map((e) => e.user_id), i = r.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", r).orderBy("created_at", "asc").execute() : [];
|
|
690
682
|
return n.map((e) => {
|
|
691
683
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -703,12 +695,12 @@ async function at(e, t, n) {
|
|
|
703
695
|
});
|
|
704
696
|
});
|
|
705
697
|
}
|
|
706
|
-
function
|
|
698
|
+
function lt(e) {
|
|
707
699
|
return async (t, n = {}) => {
|
|
708
700
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t);
|
|
709
701
|
if (c) {
|
|
710
|
-
let t = S(c,
|
|
711
|
-
t && (l = D(e, l, t,
|
|
702
|
+
let t = S(c, it);
|
|
703
|
+
t && (l = D(e, l, t, st, [], ot));
|
|
712
704
|
}
|
|
713
705
|
if (M(n)) {
|
|
714
706
|
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` });
|
|
@@ -721,7 +713,7 @@ function ot(e) {
|
|
|
721
713
|
sortOrder: r,
|
|
722
714
|
idColumn: "users.user_id",
|
|
723
715
|
sortKey: `created_at:${r}`
|
|
724
|
-
}), c = await
|
|
716
|
+
}), c = await ct(e, t, i);
|
|
725
717
|
return {
|
|
726
718
|
users: c,
|
|
727
719
|
start: 0,
|
|
@@ -731,17 +723,17 @@ function ot(e) {
|
|
|
731
723
|
};
|
|
732
724
|
}
|
|
733
725
|
if (s && s.sort_by) {
|
|
734
|
-
let t =
|
|
726
|
+
let t = ot[s.sort_by];
|
|
735
727
|
if (t) {
|
|
736
728
|
let { ref: n } = e.dynamic;
|
|
737
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
729
|
+
l = l.orderBy(typeof t == "string" ? n(t) : Re(t), s.sort_order);
|
|
738
730
|
}
|
|
739
731
|
}
|
|
740
732
|
let u = l.offset(r * i).limit(i), [d, f] = await Promise.all([u.selectAll("users").select([
|
|
741
733
|
"user_activity.last_login",
|
|
742
734
|
"user_activity.last_ip",
|
|
743
735
|
"user_activity.login_count"
|
|
744
|
-
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await
|
|
736
|
+
]).execute(), a ? l.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow() : void 0]), p = await ct(e, t, d);
|
|
745
737
|
if (!f) return {
|
|
746
738
|
users: p,
|
|
747
739
|
start: 0,
|
|
@@ -759,7 +751,7 @@ function ot(e) {
|
|
|
759
751
|
}
|
|
760
752
|
//#endregion
|
|
761
753
|
//#region src/users/remove.ts
|
|
762
|
-
function
|
|
754
|
+
function ut(e) {
|
|
763
755
|
return async (t, n, r) => {
|
|
764
756
|
let i = async (e) => {
|
|
765
757
|
await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "in", (e) => e.selectFrom("users").select("users.user_id").where("users.tenant_id", "=", t).where((e) => e.or([e("users.user_id", "=", n), e("users.linked_to", "=", n)]))).execute(), await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.linked_to", "=", n).execute();
|
|
@@ -779,7 +771,7 @@ function P(e, t = "", n = {}) {
|
|
|
779
771
|
}
|
|
780
772
|
return n;
|
|
781
773
|
}
|
|
782
|
-
function
|
|
774
|
+
function dt(e, t) {
|
|
783
775
|
let n = {};
|
|
784
776
|
for (let [r, i] of Object.entries(e)) {
|
|
785
777
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -796,7 +788,7 @@ function ct(e, t) {
|
|
|
796
788
|
}
|
|
797
789
|
//#endregion
|
|
798
790
|
//#region src/userActivity/index.ts
|
|
799
|
-
function
|
|
791
|
+
function ft(e) {
|
|
800
792
|
return {
|
|
801
793
|
user_id: e.user_id,
|
|
802
794
|
last_login: e.last_login ?? void 0,
|
|
@@ -806,18 +798,18 @@ function lt(e) {
|
|
|
806
798
|
last_password_reset: e.last_password_reset ?? void 0
|
|
807
799
|
};
|
|
808
800
|
}
|
|
809
|
-
function
|
|
801
|
+
function pt(e) {
|
|
810
802
|
let t = {};
|
|
811
803
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
812
804
|
}
|
|
813
|
-
function
|
|
805
|
+
function mt(e) {
|
|
814
806
|
return {
|
|
815
807
|
async get(t, n) {
|
|
816
808
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
817
|
-
return r ?
|
|
809
|
+
return r ? ft(r) : null;
|
|
818
810
|
},
|
|
819
811
|
async upsert(t, n, r) {
|
|
820
|
-
let i =
|
|
812
|
+
let i = pt(r);
|
|
821
813
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
822
814
|
if (Object.keys(i).length === 0) return;
|
|
823
815
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -839,7 +831,7 @@ function dt(e) {
|
|
|
839
831
|
}
|
|
840
832
|
//#endregion
|
|
841
833
|
//#region src/users/update.ts
|
|
842
|
-
function
|
|
834
|
+
function ht(e) {
|
|
843
835
|
return async (t, n, r, i) => {
|
|
844
836
|
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = P({
|
|
845
837
|
...c,
|
|
@@ -852,7 +844,7 @@ function ft(e) {
|
|
|
852
844
|
}), u = async (e) => {
|
|
853
845
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
854
846
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
855
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
847
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await mt(e).upsert(t, n, {
|
|
856
848
|
last_login: a,
|
|
857
849
|
last_ip: o,
|
|
858
850
|
login_count: s
|
|
@@ -865,26 +857,26 @@ function ft(e) {
|
|
|
865
857
|
}
|
|
866
858
|
//#endregion
|
|
867
859
|
//#region src/users/unlink.ts
|
|
868
|
-
function
|
|
860
|
+
function gt(e) {
|
|
869
861
|
return async (t, n, r, i) => (await e.updateTable("users").set({ linked_to: null }).where("users.tenant_id", "=", t).where("users.user_id", "=", `${r}|${i}`).where("users.linked_to", "=", `${n}`).execute()).length === 1;
|
|
870
862
|
}
|
|
871
863
|
//#endregion
|
|
872
864
|
//#region src/users/index.ts
|
|
873
|
-
function
|
|
874
|
-
let t =
|
|
865
|
+
function _t(e) {
|
|
866
|
+
let t = et(e);
|
|
875
867
|
return {
|
|
876
868
|
create: t,
|
|
877
869
|
rawCreate: t,
|
|
878
|
-
remove:
|
|
879
|
-
get:
|
|
880
|
-
list:
|
|
881
|
-
update:
|
|
882
|
-
unlink:
|
|
870
|
+
remove: ut(e),
|
|
871
|
+
get: nt(e),
|
|
872
|
+
list: lt(e),
|
|
873
|
+
update: ht(e),
|
|
874
|
+
unlink: gt(e)
|
|
883
875
|
};
|
|
884
876
|
}
|
|
885
877
|
//#endregion
|
|
886
878
|
//#region src/flows/create.ts
|
|
887
|
-
function
|
|
879
|
+
function vt(e) {
|
|
888
880
|
return async (n, r, i) => {
|
|
889
881
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
890
882
|
id: a?.id ?? `af_${t()}`,
|
|
@@ -910,7 +902,7 @@ function F(e, t) {
|
|
|
910
902
|
return t;
|
|
911
903
|
}
|
|
912
904
|
}
|
|
913
|
-
function
|
|
905
|
+
function yt(e) {
|
|
914
906
|
if (e) try {
|
|
915
907
|
let t = JSON.parse(e);
|
|
916
908
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -918,13 +910,13 @@ function gt(e) {
|
|
|
918
910
|
return;
|
|
919
911
|
}
|
|
920
912
|
}
|
|
921
|
-
function
|
|
913
|
+
function bt(e, t, n = { ...e }) {
|
|
922
914
|
for (let r in t) r in e && (n[r] = F(e[r], t[r]));
|
|
923
915
|
return n;
|
|
924
916
|
}
|
|
925
917
|
//#endregion
|
|
926
918
|
//#region src/flows/get.ts
|
|
927
|
-
function
|
|
919
|
+
function xt(e) {
|
|
928
920
|
return async (t, n) => {
|
|
929
921
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
930
922
|
if (!r) return null;
|
|
@@ -937,7 +929,7 @@ function vt(e) {
|
|
|
937
929
|
}
|
|
938
930
|
//#endregion
|
|
939
931
|
//#region src/flows/list.ts
|
|
940
|
-
function
|
|
932
|
+
function St(e) {
|
|
941
933
|
return async (t, n = {}) => {
|
|
942
934
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
943
935
|
s && (c = D(e, c, s, []));
|
|
@@ -965,7 +957,7 @@ function yt(e) {
|
|
|
965
957
|
}
|
|
966
958
|
//#endregion
|
|
967
959
|
//#region src/flows/update.ts
|
|
968
|
-
function
|
|
960
|
+
function Ct(e) {
|
|
969
961
|
return async (t, n, r) => {
|
|
970
962
|
let i = {
|
|
971
963
|
...r,
|
|
@@ -983,27 +975,27 @@ function bt(e) {
|
|
|
983
975
|
}
|
|
984
976
|
//#endregion
|
|
985
977
|
//#region src/flows/remove.ts
|
|
986
|
-
function
|
|
978
|
+
function wt(e) {
|
|
987
979
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
988
980
|
}
|
|
989
981
|
//#endregion
|
|
990
982
|
//#region src/flows/index.ts
|
|
991
|
-
function
|
|
983
|
+
function Tt(e) {
|
|
992
984
|
return {
|
|
993
|
-
create:
|
|
994
|
-
get:
|
|
995
|
-
list:
|
|
996
|
-
update:
|
|
997
|
-
remove:
|
|
985
|
+
create: vt(e),
|
|
986
|
+
get: xt(e),
|
|
987
|
+
list: St(e),
|
|
988
|
+
update: Ct(e),
|
|
989
|
+
remove: wt(e)
|
|
998
990
|
};
|
|
999
991
|
}
|
|
1000
992
|
//#endregion
|
|
1001
993
|
//#region src/tenants/utils.ts
|
|
1002
|
-
function
|
|
994
|
+
function Et(e) {
|
|
1003
995
|
let t = { ...e };
|
|
1004
996
|
return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(e.sandbox_versions_available)), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.attack_protection && typeof e.attack_protection == "string" && (t.attack_protection = JSON.parse(e.attack_protection)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), l(t);
|
|
1005
997
|
}
|
|
1006
|
-
function
|
|
998
|
+
function Dt(e) {
|
|
1007
999
|
let t = { ...e };
|
|
1008
1000
|
return d(e, [
|
|
1009
1001
|
"session_cookie",
|
|
@@ -1026,14 +1018,14 @@ function wt(e) {
|
|
|
1026
1018
|
}
|
|
1027
1019
|
//#endregion
|
|
1028
1020
|
//#region src/tenants/create.ts
|
|
1029
|
-
function
|
|
1021
|
+
function Ot(e) {
|
|
1030
1022
|
return async (n, r) => {
|
|
1031
1023
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
1032
1024
|
...n,
|
|
1033
1025
|
id: i?.id ?? n.id ?? t(),
|
|
1034
1026
|
created_at: i?.created_at ?? a,
|
|
1035
1027
|
updated_at: i?.updated_at ?? a
|
|
1036
|
-
}, s =
|
|
1028
|
+
}, s = Dt(o);
|
|
1037
1029
|
try {
|
|
1038
1030
|
await e.insertInto("tenants").values(s).execute();
|
|
1039
1031
|
} catch (e) {
|
|
@@ -1045,15 +1037,15 @@ function Tt(e) {
|
|
|
1045
1037
|
}
|
|
1046
1038
|
//#endregion
|
|
1047
1039
|
//#region src/tenants/get.ts
|
|
1048
|
-
function
|
|
1040
|
+
function kt(e) {
|
|
1049
1041
|
return async (t) => {
|
|
1050
1042
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1051
|
-
return n ?
|
|
1043
|
+
return n ? Et(n) : null;
|
|
1052
1044
|
};
|
|
1053
1045
|
}
|
|
1054
1046
|
//#endregion
|
|
1055
1047
|
//#region src/tenants/list.ts
|
|
1056
|
-
function
|
|
1048
|
+
function At(e) {
|
|
1057
1049
|
return async (t) => {
|
|
1058
1050
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1059
1051
|
if (s && s.sort_by) {
|
|
@@ -1061,7 +1053,7 @@ function Dt(e) {
|
|
|
1061
1053
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1062
1054
|
}
|
|
1063
1055
|
c && (n = D(e, n, c, ["friendly_name"]));
|
|
1064
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1056
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(Et);
|
|
1065
1057
|
if (!a) return { tenants: l };
|
|
1066
1058
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1067
1059
|
return {
|
|
@@ -1074,10 +1066,10 @@ function Dt(e) {
|
|
|
1074
1066
|
}
|
|
1075
1067
|
//#endregion
|
|
1076
1068
|
//#region src/tenants/update.ts
|
|
1077
|
-
function
|
|
1069
|
+
function jt(e) {
|
|
1078
1070
|
return async (t, n) => {
|
|
1079
1071
|
let r = {
|
|
1080
|
-
...
|
|
1072
|
+
...Dt(n),
|
|
1081
1073
|
id: t,
|
|
1082
1074
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1083
1075
|
};
|
|
@@ -1086,29 +1078,29 @@ function Ot(e) {
|
|
|
1086
1078
|
}
|
|
1087
1079
|
//#endregion
|
|
1088
1080
|
//#region src/tenants/remove.ts
|
|
1089
|
-
function
|
|
1081
|
+
function Mt(e) {
|
|
1090
1082
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1091
1083
|
}
|
|
1092
1084
|
//#endregion
|
|
1093
1085
|
//#region src/tenants/index.ts
|
|
1094
|
-
function
|
|
1086
|
+
function Nt(e) {
|
|
1095
1087
|
return {
|
|
1096
|
-
create:
|
|
1097
|
-
get:
|
|
1098
|
-
list:
|
|
1099
|
-
update:
|
|
1100
|
-
remove:
|
|
1088
|
+
create: Ot(e),
|
|
1089
|
+
get: kt(e),
|
|
1090
|
+
list: At(e),
|
|
1091
|
+
update: jt(e),
|
|
1092
|
+
remove: Mt(e)
|
|
1101
1093
|
};
|
|
1102
1094
|
}
|
|
1103
1095
|
//#endregion
|
|
1104
1096
|
//#region src/logs/create.ts
|
|
1105
|
-
function
|
|
1097
|
+
function Pt(e) {
|
|
1106
1098
|
return e ? JSON.stringify(e) : void 0;
|
|
1107
1099
|
}
|
|
1108
|
-
var
|
|
1109
|
-
function
|
|
1100
|
+
var Ft = 256;
|
|
1101
|
+
function It(e) {
|
|
1110
1102
|
return async (n, r) => {
|
|
1111
|
-
let i = r.user_agent?.slice(0,
|
|
1103
|
+
let i = r.user_agent?.slice(0, Ft), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1112
1104
|
return await e.insertInto("logs").values({
|
|
1113
1105
|
...s,
|
|
1114
1106
|
log_id: a,
|
|
@@ -1117,8 +1109,8 @@ function Nt(e) {
|
|
|
1117
1109
|
description: r.description?.substring(0, 256),
|
|
1118
1110
|
isMobile: +!!r.isMobile,
|
|
1119
1111
|
scope: r.scope,
|
|
1120
|
-
auth0_client:
|
|
1121
|
-
details:
|
|
1112
|
+
auth0_client: Pt(r.auth0_client),
|
|
1113
|
+
details: Pt(r.details)?.substring(0, 8192),
|
|
1122
1114
|
country_code: o?.country_code,
|
|
1123
1115
|
city_name: o?.city_name,
|
|
1124
1116
|
latitude: o?.latitude,
|
|
@@ -1134,7 +1126,7 @@ function Nt(e) {
|
|
|
1134
1126
|
}
|
|
1135
1127
|
//#endregion
|
|
1136
1128
|
//#region src/logs/logs.ts
|
|
1137
|
-
function
|
|
1129
|
+
function Lt(e) {
|
|
1138
1130
|
if (!e) return "";
|
|
1139
1131
|
try {
|
|
1140
1132
|
return JSON.parse(e);
|
|
@@ -1147,8 +1139,8 @@ function I(e) {
|
|
|
1147
1139
|
...e,
|
|
1148
1140
|
client_id: e.client_id,
|
|
1149
1141
|
client_name: e.client_name || "",
|
|
1150
|
-
auth0_client:
|
|
1151
|
-
details:
|
|
1142
|
+
auth0_client: Lt(e.auth0_client),
|
|
1143
|
+
details: Lt(e.details),
|
|
1152
1144
|
isMobile: !!e.isMobile,
|
|
1153
1145
|
scope: e.scope || void 0,
|
|
1154
1146
|
log_id: e.log_id,
|
|
@@ -1164,7 +1156,7 @@ function I(e) {
|
|
|
1164
1156
|
}
|
|
1165
1157
|
//#endregion
|
|
1166
1158
|
//#region src/logs/list.ts
|
|
1167
|
-
var
|
|
1159
|
+
var Rt = [
|
|
1168
1160
|
"user_id",
|
|
1169
1161
|
"ip",
|
|
1170
1162
|
"type",
|
|
@@ -1190,11 +1182,11 @@ var Ft = [
|
|
|
1190
1182
|
"time_zone",
|
|
1191
1183
|
"continent_code"
|
|
1192
1184
|
];
|
|
1193
|
-
function
|
|
1185
|
+
function zt(e) {
|
|
1194
1186
|
return async (t, n = {}) => {
|
|
1195
1187
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, from_date: l, to_date: u } = n, d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
1196
1188
|
if (c) {
|
|
1197
|
-
let t = S(c,
|
|
1189
|
+
let t = S(c, Rt);
|
|
1198
1190
|
t && (d = D(e, d, t, [
|
|
1199
1191
|
"user_id",
|
|
1200
1192
|
"ip",
|
|
@@ -1241,7 +1233,7 @@ function It(e) {
|
|
|
1241
1233
|
}
|
|
1242
1234
|
//#endregion
|
|
1243
1235
|
//#region src/logs/get.ts
|
|
1244
|
-
function
|
|
1236
|
+
function Bt(e) {
|
|
1245
1237
|
return async (t, n) => {
|
|
1246
1238
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1247
1239
|
return r ? I(r) : null;
|
|
@@ -1249,16 +1241,16 @@ function Lt(e) {
|
|
|
1249
1241
|
}
|
|
1250
1242
|
//#endregion
|
|
1251
1243
|
//#region src/logs/index.ts
|
|
1252
|
-
function
|
|
1244
|
+
function Vt(e) {
|
|
1253
1245
|
return {
|
|
1254
|
-
create:
|
|
1255
|
-
list:
|
|
1256
|
-
get:
|
|
1246
|
+
create: It(e),
|
|
1247
|
+
list: zt(e),
|
|
1248
|
+
get: Bt(e)
|
|
1257
1249
|
};
|
|
1258
1250
|
}
|
|
1259
1251
|
//#endregion
|
|
1260
1252
|
//#region src/sessions/get.ts
|
|
1261
|
-
function
|
|
1253
|
+
function Ht(e) {
|
|
1262
1254
|
return async (t, n) => {
|
|
1263
1255
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1264
1256
|
if (!i) return null;
|
|
@@ -1292,7 +1284,7 @@ function zt(e) {
|
|
|
1292
1284
|
}
|
|
1293
1285
|
//#endregion
|
|
1294
1286
|
//#region src/sessions/create.ts
|
|
1295
|
-
function
|
|
1287
|
+
function Ut(e) {
|
|
1296
1288
|
return async (t, n) => {
|
|
1297
1289
|
let r = Date.now(), i = c(), a = {
|
|
1298
1290
|
...n,
|
|
@@ -1324,12 +1316,12 @@ function Bt(e) {
|
|
|
1324
1316
|
}
|
|
1325
1317
|
//#endregion
|
|
1326
1318
|
//#region src/sessions/remove.ts
|
|
1327
|
-
function
|
|
1319
|
+
function Wt(e) {
|
|
1328
1320
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1329
1321
|
}
|
|
1330
1322
|
//#endregion
|
|
1331
1323
|
//#region src/sessions/update.ts
|
|
1332
|
-
function
|
|
1324
|
+
function Gt(e) {
|
|
1333
1325
|
return async (t, n, r) => {
|
|
1334
1326
|
let i = Date.now(), a = {
|
|
1335
1327
|
updated_at_ts: i,
|
|
@@ -1350,7 +1342,7 @@ function Ht(e) {
|
|
|
1350
1342
|
}
|
|
1351
1343
|
//#endregion
|
|
1352
1344
|
//#region src/sessions/list.ts
|
|
1353
|
-
function
|
|
1345
|
+
function Kt(e) {
|
|
1354
1346
|
return async (t, n = {}) => {
|
|
1355
1347
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
1356
1348
|
l && (u = D(e, u, l, ["user_id", "session_id"]));
|
|
@@ -1405,18 +1397,18 @@ function Ut(e) {
|
|
|
1405
1397
|
}
|
|
1406
1398
|
//#endregion
|
|
1407
1399
|
//#region src/sessions/index.ts
|
|
1408
|
-
function
|
|
1400
|
+
function qt(e) {
|
|
1409
1401
|
return {
|
|
1410
|
-
create:
|
|
1411
|
-
get:
|
|
1412
|
-
list:
|
|
1413
|
-
remove:
|
|
1414
|
-
update:
|
|
1402
|
+
create: Ut(e),
|
|
1403
|
+
get: Ht(e),
|
|
1404
|
+
list: Kt(e),
|
|
1405
|
+
remove: Wt(e),
|
|
1406
|
+
update: Gt(e)
|
|
1415
1407
|
};
|
|
1416
1408
|
}
|
|
1417
1409
|
//#endregion
|
|
1418
1410
|
//#region src/passwords/get.ts
|
|
1419
|
-
function
|
|
1411
|
+
function Jt(e) {
|
|
1420
1412
|
return async (t, n) => {
|
|
1421
1413
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1422
1414
|
if (!r) return null;
|
|
@@ -1429,7 +1421,7 @@ function Gt(e) {
|
|
|
1429
1421
|
}
|
|
1430
1422
|
//#endregion
|
|
1431
1423
|
//#region src/passwords/create.ts
|
|
1432
|
-
function
|
|
1424
|
+
function Yt(e) {
|
|
1433
1425
|
return async (n, r, i) => {
|
|
1434
1426
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1435
1427
|
...r,
|
|
@@ -1447,7 +1439,7 @@ function Kt(e) {
|
|
|
1447
1439
|
}
|
|
1448
1440
|
//#endregion
|
|
1449
1441
|
//#region src/passwords/update.ts
|
|
1450
|
-
function
|
|
1442
|
+
function Xt(e) {
|
|
1451
1443
|
return async (t, n) => {
|
|
1452
1444
|
let r = e.updateTable("passwords").set({
|
|
1453
1445
|
password: n.password,
|
|
@@ -1460,7 +1452,7 @@ function qt(e) {
|
|
|
1460
1452
|
}
|
|
1461
1453
|
//#endregion
|
|
1462
1454
|
//#region src/passwords/list.ts
|
|
1463
|
-
function
|
|
1455
|
+
function Zt(e) {
|
|
1464
1456
|
return async (t, n, r) => {
|
|
1465
1457
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1466
1458
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1471,17 +1463,17 @@ function Jt(e) {
|
|
|
1471
1463
|
}
|
|
1472
1464
|
//#endregion
|
|
1473
1465
|
//#region src/passwords/index.ts
|
|
1474
|
-
function
|
|
1466
|
+
function Qt(e) {
|
|
1475
1467
|
return {
|
|
1476
|
-
create:
|
|
1477
|
-
update:
|
|
1478
|
-
get:
|
|
1479
|
-
list:
|
|
1468
|
+
create: Yt(e),
|
|
1469
|
+
update: Xt(e),
|
|
1470
|
+
get: Jt(e),
|
|
1471
|
+
list: Zt(e)
|
|
1480
1472
|
};
|
|
1481
1473
|
}
|
|
1482
1474
|
//#endregion
|
|
1483
1475
|
//#region src/codes/list.ts
|
|
1484
|
-
function
|
|
1476
|
+
function $t(e) {
|
|
1485
1477
|
return async (t, n = {}) => {
|
|
1486
1478
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1487
1479
|
s && (c = D(e, c, s, ["code", "login_id"]));
|
|
@@ -1506,13 +1498,13 @@ function Xt(e) {
|
|
|
1506
1498
|
}
|
|
1507
1499
|
//#endregion
|
|
1508
1500
|
//#region src/codes/expires-at-ts.ts
|
|
1509
|
-
function
|
|
1501
|
+
function en(e) {
|
|
1510
1502
|
let t = new Date(e).getTime();
|
|
1511
1503
|
return Number.isNaN(t) ? 0 : t;
|
|
1512
1504
|
}
|
|
1513
1505
|
//#endregion
|
|
1514
1506
|
//#region src/codes/create.ts
|
|
1515
|
-
function
|
|
1507
|
+
function tn(e) {
|
|
1516
1508
|
return async (t, n) => {
|
|
1517
1509
|
let r = {
|
|
1518
1510
|
...n,
|
|
@@ -1521,18 +1513,18 @@ function Qt(e) {
|
|
|
1521
1513
|
return await e.insertInto("codes").values({
|
|
1522
1514
|
...r,
|
|
1523
1515
|
tenant_id: t,
|
|
1524
|
-
expires_at_ts:
|
|
1516
|
+
expires_at_ts: en(r.expires_at)
|
|
1525
1517
|
}).execute(), r;
|
|
1526
1518
|
};
|
|
1527
1519
|
}
|
|
1528
1520
|
//#endregion
|
|
1529
1521
|
//#region src/codes/remove.ts
|
|
1530
|
-
function
|
|
1522
|
+
function nn(e) {
|
|
1531
1523
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1532
1524
|
}
|
|
1533
1525
|
//#endregion
|
|
1534
1526
|
//#region src/codes/get.ts
|
|
1535
|
-
function
|
|
1527
|
+
function rn(e) {
|
|
1536
1528
|
return async (t, n, r) => {
|
|
1537
1529
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1538
1530
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1542,44 +1534,44 @@ function en(e) {
|
|
|
1542
1534
|
}
|
|
1543
1535
|
//#endregion
|
|
1544
1536
|
//#region src/codes/used.ts
|
|
1545
|
-
function
|
|
1537
|
+
function an(e) {
|
|
1546
1538
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numUpdatedRows > 0;
|
|
1547
1539
|
}
|
|
1548
1540
|
//#endregion
|
|
1549
1541
|
//#region src/codes/consume.ts
|
|
1550
|
-
function
|
|
1542
|
+
function on(e) {
|
|
1551
1543
|
return async (t, n) => (await e.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).where("codes.used_at", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
1552
1544
|
}
|
|
1553
1545
|
//#endregion
|
|
1554
1546
|
//#region src/codes/cleanup.ts
|
|
1555
|
-
function
|
|
1547
|
+
function sn(e) {
|
|
1556
1548
|
return async (t) => {
|
|
1557
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1549
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", en(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1558
1550
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1559
1551
|
};
|
|
1560
1552
|
}
|
|
1561
1553
|
//#endregion
|
|
1562
1554
|
//#region src/codes/index.ts
|
|
1563
|
-
function
|
|
1555
|
+
function cn(e) {
|
|
1564
1556
|
return {
|
|
1565
|
-
create:
|
|
1566
|
-
list:
|
|
1567
|
-
remove:
|
|
1568
|
-
used:
|
|
1569
|
-
consume:
|
|
1570
|
-
get:
|
|
1571
|
-
cleanup:
|
|
1557
|
+
create: tn(e),
|
|
1558
|
+
list: $t(e),
|
|
1559
|
+
remove: nn(e),
|
|
1560
|
+
used: an(e),
|
|
1561
|
+
consume: on(e),
|
|
1562
|
+
get: rn(e),
|
|
1563
|
+
cleanup: sn(e)
|
|
1572
1564
|
};
|
|
1573
1565
|
}
|
|
1574
1566
|
//#endregion
|
|
1575
1567
|
//#region src/connections/create.ts
|
|
1576
|
-
function
|
|
1568
|
+
function ln(e) {
|
|
1577
1569
|
return async (t, n, r) => {
|
|
1578
1570
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1579
1571
|
delete o.enabled_clients;
|
|
1580
1572
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1581
1573
|
...o,
|
|
1582
|
-
id: i?.id ?? o.id ??
|
|
1574
|
+
id: i?.id ?? o.id ?? ke(),
|
|
1583
1575
|
is_system: a ? !0 : void 0,
|
|
1584
1576
|
created_at: i?.created_at ?? s,
|
|
1585
1577
|
updated_at: i?.updated_at ?? s
|
|
@@ -1594,7 +1586,7 @@ function on(e) {
|
|
|
1594
1586
|
}
|
|
1595
1587
|
//#endregion
|
|
1596
1588
|
//#region src/connections/transform.ts
|
|
1597
|
-
function
|
|
1589
|
+
function un(e) {
|
|
1598
1590
|
let { is_system: t, ...n } = e;
|
|
1599
1591
|
return l({
|
|
1600
1592
|
...n,
|
|
@@ -1602,16 +1594,16 @@ function L(e) {
|
|
|
1602
1594
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1603
1595
|
});
|
|
1604
1596
|
}
|
|
1605
|
-
function
|
|
1606
|
-
return e.map(
|
|
1597
|
+
function dn(e) {
|
|
1598
|
+
return e.map(un);
|
|
1607
1599
|
}
|
|
1608
1600
|
//#endregion
|
|
1609
1601
|
//#region src/connections/list.ts
|
|
1610
|
-
function
|
|
1602
|
+
function fn(e) {
|
|
1611
1603
|
return async (t, n = {}) => {
|
|
1612
1604
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1613
1605
|
s && (c = D(e, c, s, ["user_id", "ip"]));
|
|
1614
|
-
let l =
|
|
1606
|
+
let l = dn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1615
1607
|
if (!a) return {
|
|
1616
1608
|
connections: l,
|
|
1617
1609
|
start: 0,
|
|
@@ -1629,20 +1621,20 @@ function cn(e) {
|
|
|
1629
1621
|
}
|
|
1630
1622
|
//#endregion
|
|
1631
1623
|
//#region src/connections/remove.ts
|
|
1632
|
-
function
|
|
1624
|
+
function pn(e) {
|
|
1633
1625
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1634
1626
|
}
|
|
1635
1627
|
//#endregion
|
|
1636
1628
|
//#region src/connections/get.ts
|
|
1637
|
-
function
|
|
1629
|
+
function mn(e) {
|
|
1638
1630
|
return async (t, n) => {
|
|
1639
1631
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1640
|
-
return r ?
|
|
1632
|
+
return r ? un(r) : null;
|
|
1641
1633
|
};
|
|
1642
1634
|
}
|
|
1643
1635
|
//#endregion
|
|
1644
1636
|
//#region src/connections/update.ts
|
|
1645
|
-
function
|
|
1637
|
+
function hn(e) {
|
|
1646
1638
|
return async (t, n, r) => {
|
|
1647
1639
|
let { is_system: i, ...a } = r;
|
|
1648
1640
|
delete a.enabled_clients;
|
|
@@ -1659,18 +1651,18 @@ function dn(e) {
|
|
|
1659
1651
|
}
|
|
1660
1652
|
//#endregion
|
|
1661
1653
|
//#region src/connections/index.ts
|
|
1662
|
-
function
|
|
1654
|
+
function gn(e) {
|
|
1663
1655
|
return {
|
|
1664
|
-
create:
|
|
1665
|
-
get:
|
|
1666
|
-
list:
|
|
1667
|
-
remove:
|
|
1668
|
-
update:
|
|
1656
|
+
create: ln(e),
|
|
1657
|
+
get: mn(e),
|
|
1658
|
+
list: fn(e),
|
|
1659
|
+
remove: pn(e),
|
|
1660
|
+
update: hn(e)
|
|
1669
1661
|
};
|
|
1670
1662
|
}
|
|
1671
1663
|
//#endregion
|
|
1672
1664
|
//#region src/clients/create.ts
|
|
1673
|
-
function
|
|
1665
|
+
function _n(e) {
|
|
1674
1666
|
return async (r, i, a) => {
|
|
1675
1667
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1676
1668
|
...i,
|
|
@@ -1735,7 +1727,7 @@ function pn(e) {
|
|
|
1735
1727
|
}
|
|
1736
1728
|
//#endregion
|
|
1737
1729
|
//#region src/clients/get.ts
|
|
1738
|
-
function
|
|
1730
|
+
function vn(e) {
|
|
1739
1731
|
return async (t, n) => {
|
|
1740
1732
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1741
1733
|
if (!r) return null;
|
|
@@ -1781,7 +1773,7 @@ function mn(e) {
|
|
|
1781
1773
|
}
|
|
1782
1774
|
//#endregion
|
|
1783
1775
|
//#region src/clients/getByClientId.ts
|
|
1784
|
-
function
|
|
1776
|
+
function yn(e) {
|
|
1785
1777
|
return async (t) => {
|
|
1786
1778
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1787
1779
|
return n ? l({
|
|
@@ -1825,7 +1817,7 @@ function hn(e) {
|
|
|
1825
1817
|
}
|
|
1826
1818
|
//#endregion
|
|
1827
1819
|
//#region src/clients/list.ts
|
|
1828
|
-
function
|
|
1820
|
+
function bn(e) {
|
|
1829
1821
|
return l({
|
|
1830
1822
|
...e,
|
|
1831
1823
|
global: !!e.global,
|
|
@@ -1864,14 +1856,25 @@ function gn(e) {
|
|
|
1864
1856
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1865
1857
|
});
|
|
1866
1858
|
}
|
|
1867
|
-
function
|
|
1859
|
+
function xn(e) {
|
|
1860
|
+
let t = xe(e);
|
|
1861
|
+
if (t.length !== 1) return null;
|
|
1862
|
+
let n = t[0].match(/^([a-zA-Z_][a-zA-Z0-9_]*):(.+)$/);
|
|
1863
|
+
if (!n) return null;
|
|
1864
|
+
let r = Ce(n[2]);
|
|
1865
|
+
return r ? {
|
|
1866
|
+
field: n[1],
|
|
1867
|
+
value: r
|
|
1868
|
+
} : null;
|
|
1869
|
+
}
|
|
1870
|
+
function Sn(e) {
|
|
1868
1871
|
return async (t, n) => {
|
|
1869
1872
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1870
1873
|
if (n?.q) {
|
|
1871
|
-
let e = n.q
|
|
1872
|
-
if (e && i.has(e
|
|
1873
|
-
let t = e
|
|
1874
|
-
r = r.where(t, "=", e
|
|
1874
|
+
let e = xn(n.q);
|
|
1875
|
+
if (e && i.has(e.field)) {
|
|
1876
|
+
let t = e.field;
|
|
1877
|
+
r = r.where(t, "=", e.value);
|
|
1875
1878
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1876
1879
|
}
|
|
1877
1880
|
if (M(n)) {
|
|
@@ -1879,7 +1882,7 @@ function _n(e) {
|
|
|
1879
1882
|
sortColumn: "created_at",
|
|
1880
1883
|
sortOrder: "desc",
|
|
1881
1884
|
idColumn: "client_id"
|
|
1882
|
-
}), a = e.map(
|
|
1885
|
+
}), a = e.map(bn);
|
|
1883
1886
|
return {
|
|
1884
1887
|
clients: a,
|
|
1885
1888
|
totals: {
|
|
@@ -1903,16 +1906,16 @@ function _n(e) {
|
|
|
1903
1906
|
if (n?.include_totals) {
|
|
1904
1907
|
let r = e.selectFrom("clients").select(f`count(*)`.as("count")).where("clients.tenant_id", "=", t);
|
|
1905
1908
|
if (n?.q) {
|
|
1906
|
-
let e = n.q
|
|
1907
|
-
if (e && i.has(e
|
|
1908
|
-
let t = e
|
|
1909
|
-
r = r.where(t, "=", e
|
|
1909
|
+
let e = xn(n.q);
|
|
1910
|
+
if (e && i.has(e.field)) {
|
|
1911
|
+
let t = e.field;
|
|
1912
|
+
r = r.where(t, "=", e.value);
|
|
1910
1913
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1911
1914
|
}
|
|
1912
1915
|
let a = await r.executeTakeFirst();
|
|
1913
1916
|
c = Number(a?.count || 0);
|
|
1914
1917
|
}
|
|
1915
|
-
let l = s.map(
|
|
1918
|
+
let l = s.map(bn);
|
|
1916
1919
|
return {
|
|
1917
1920
|
clients: l,
|
|
1918
1921
|
totals: {
|
|
@@ -1926,12 +1929,12 @@ function _n(e) {
|
|
|
1926
1929
|
}
|
|
1927
1930
|
//#endregion
|
|
1928
1931
|
//#region src/clients/remove.ts
|
|
1929
|
-
function
|
|
1932
|
+
function Cn(e) {
|
|
1930
1933
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1931
1934
|
}
|
|
1932
1935
|
//#endregion
|
|
1933
1936
|
//#region src/clients/update.ts
|
|
1934
|
-
function
|
|
1937
|
+
function wn(e) {
|
|
1935
1938
|
return async (t, r, i) => {
|
|
1936
1939
|
let a = {
|
|
1937
1940
|
...i,
|
|
@@ -1978,31 +1981,31 @@ function yn(e) {
|
|
|
1978
1981
|
}
|
|
1979
1982
|
//#endregion
|
|
1980
1983
|
//#region src/clients/index.ts
|
|
1981
|
-
function
|
|
1984
|
+
function Tn(e) {
|
|
1982
1985
|
return {
|
|
1983
|
-
create:
|
|
1984
|
-
get:
|
|
1985
|
-
getByClientId:
|
|
1986
|
-
list:
|
|
1987
|
-
remove:
|
|
1988
|
-
update:
|
|
1986
|
+
create: _n(e),
|
|
1987
|
+
get: vn(e),
|
|
1988
|
+
getByClientId: yn(e),
|
|
1989
|
+
list: Sn(e),
|
|
1990
|
+
remove: Cn(e),
|
|
1991
|
+
update: wn(e)
|
|
1989
1992
|
};
|
|
1990
1993
|
}
|
|
1991
1994
|
//#endregion
|
|
1992
1995
|
//#region src/clientConnections/listByClient.ts
|
|
1993
|
-
function
|
|
1996
|
+
function En(e) {
|
|
1994
1997
|
return async (t, n) => {
|
|
1995
1998
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1996
1999
|
if (!r) return [];
|
|
1997
2000
|
let i = JSON.parse(r.connections || "[]");
|
|
1998
2001
|
if (i.length === 0) return [];
|
|
1999
|
-
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id,
|
|
2002
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, un(e)]));
|
|
2000
2003
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2001
2004
|
};
|
|
2002
2005
|
}
|
|
2003
2006
|
//#endregion
|
|
2004
2007
|
//#region src/clientConnections/updateByClient.ts
|
|
2005
|
-
function
|
|
2008
|
+
function Dn(e) {
|
|
2006
2009
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
2007
2010
|
connections: JSON.stringify(r),
|
|
2008
2011
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2010,7 +2013,7 @@ function Sn(e) {
|
|
|
2010
2013
|
}
|
|
2011
2014
|
//#endregion
|
|
2012
2015
|
//#region src/clientConnections/listByConnection.ts
|
|
2013
|
-
function
|
|
2016
|
+
function On(e) {
|
|
2014
2017
|
return async (t, n) => {
|
|
2015
2018
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
2016
2019
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -2019,7 +2022,7 @@ function Cn(e) {
|
|
|
2019
2022
|
}
|
|
2020
2023
|
//#endregion
|
|
2021
2024
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2022
|
-
function
|
|
2025
|
+
function kn(e) {
|
|
2023
2026
|
return async (t, n, r) => {
|
|
2024
2027
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2025
2028
|
if (!i) return !1;
|
|
@@ -2032,7 +2035,7 @@ function wn(e) {
|
|
|
2032
2035
|
}
|
|
2033
2036
|
//#endregion
|
|
2034
2037
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2035
|
-
function
|
|
2038
|
+
function An(e) {
|
|
2036
2039
|
return async (t, n, r) => {
|
|
2037
2040
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2038
2041
|
if (!i) return !1;
|
|
@@ -2045,18 +2048,18 @@ function Tn(e) {
|
|
|
2045
2048
|
}
|
|
2046
2049
|
//#endregion
|
|
2047
2050
|
//#region src/clientConnections/index.ts
|
|
2048
|
-
function
|
|
2051
|
+
function jn(e) {
|
|
2049
2052
|
return {
|
|
2050
|
-
listByClient:
|
|
2051
|
-
updateByClient:
|
|
2052
|
-
listByConnection:
|
|
2053
|
-
addClientToConnection:
|
|
2054
|
-
removeClientFromConnection:
|
|
2053
|
+
listByClient: En(e),
|
|
2054
|
+
updateByClient: Dn(e),
|
|
2055
|
+
listByConnection: On(e),
|
|
2056
|
+
addClientToConnection: kn(e),
|
|
2057
|
+
removeClientFromConnection: An(e)
|
|
2055
2058
|
};
|
|
2056
2059
|
}
|
|
2057
2060
|
//#endregion
|
|
2058
2061
|
//#region src/clientGrants/create.ts
|
|
2059
|
-
function
|
|
2062
|
+
function Mn(e) {
|
|
2060
2063
|
return async (n, r, i) => {
|
|
2061
2064
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? t(), c = a?.created_at ?? o, u = a?.updated_at ?? a?.created_at ?? o, { scope: d, authorization_details_types: f, ...p } = r, m = {
|
|
2062
2065
|
id: s,
|
|
@@ -2084,7 +2087,7 @@ function Dn(e) {
|
|
|
2084
2087
|
}
|
|
2085
2088
|
//#endregion
|
|
2086
2089
|
//#region src/clientGrants/get.ts
|
|
2087
|
-
function
|
|
2090
|
+
function Nn(e) {
|
|
2088
2091
|
return async (t, n) => {
|
|
2089
2092
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2090
2093
|
return r ? l({
|
|
@@ -2104,7 +2107,7 @@ function On(e) {
|
|
|
2104
2107
|
}
|
|
2105
2108
|
//#endregion
|
|
2106
2109
|
//#region src/clientGrants/list.ts
|
|
2107
|
-
function
|
|
2110
|
+
function Pn(e) {
|
|
2108
2111
|
return v.parse(l({
|
|
2109
2112
|
...e,
|
|
2110
2113
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2113,7 +2116,7 @@ function kn(e) {
|
|
|
2113
2116
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2114
2117
|
}));
|
|
2115
2118
|
}
|
|
2116
|
-
function
|
|
2119
|
+
function Fn(e) {
|
|
2117
2120
|
return async (t, n = {}) => {
|
|
2118
2121
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s, sort: c } = n, l = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
|
|
2119
2122
|
if (s) {
|
|
@@ -2130,7 +2133,7 @@ function An(e) {
|
|
|
2130
2133
|
let { rows: e, limit: t, next: r } = await N(l.selectAll(), n, {
|
|
2131
2134
|
sortColumn: "created_at",
|
|
2132
2135
|
sortOrder: "desc"
|
|
2133
|
-
}), i = e.map(
|
|
2136
|
+
}), i = e.map(Pn);
|
|
2134
2137
|
return {
|
|
2135
2138
|
client_grants: i,
|
|
2136
2139
|
start: 0,
|
|
@@ -2144,7 +2147,7 @@ function An(e) {
|
|
|
2144
2147
|
let { ref: t } = e.dynamic;
|
|
2145
2148
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2146
2149
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2147
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2150
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(Pn);
|
|
2148
2151
|
if (!a) return {
|
|
2149
2152
|
client_grants: d,
|
|
2150
2153
|
start: 0,
|
|
@@ -2162,12 +2165,12 @@ function An(e) {
|
|
|
2162
2165
|
}
|
|
2163
2166
|
//#endregion
|
|
2164
2167
|
//#region src/clientGrants/remove.ts
|
|
2165
|
-
function
|
|
2168
|
+
function In(e) {
|
|
2166
2169
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2167
2170
|
}
|
|
2168
2171
|
//#endregion
|
|
2169
2172
|
//#region src/clientGrants/update.ts
|
|
2170
|
-
function
|
|
2173
|
+
function Ln(e) {
|
|
2171
2174
|
return async (t, n, r) => {
|
|
2172
2175
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2173
2176
|
...s,
|
|
@@ -2178,18 +2181,18 @@ function Mn(e) {
|
|
|
2178
2181
|
}
|
|
2179
2182
|
//#endregion
|
|
2180
2183
|
//#region src/clientGrants/index.ts
|
|
2181
|
-
function
|
|
2184
|
+
function Rn(e) {
|
|
2182
2185
|
return {
|
|
2183
|
-
create:
|
|
2184
|
-
get:
|
|
2185
|
-
list:
|
|
2186
|
-
remove:
|
|
2187
|
-
update:
|
|
2186
|
+
create: Mn(e),
|
|
2187
|
+
get: Nn(e),
|
|
2188
|
+
list: Fn(e),
|
|
2189
|
+
remove: In(e),
|
|
2190
|
+
update: Ln(e)
|
|
2188
2191
|
};
|
|
2189
2192
|
}
|
|
2190
2193
|
//#endregion
|
|
2191
2194
|
//#region src/clientRegistrationTokens/create.ts
|
|
2192
|
-
function
|
|
2195
|
+
function zn(e) {
|
|
2193
2196
|
return async (t, n) => {
|
|
2194
2197
|
let r = Date.now();
|
|
2195
2198
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2220,12 +2223,12 @@ function Pn(e) {
|
|
|
2220
2223
|
}
|
|
2221
2224
|
//#endregion
|
|
2222
2225
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2223
|
-
function
|
|
2226
|
+
function Bn(e) {
|
|
2224
2227
|
let t = y.safeParse(e);
|
|
2225
2228
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2226
2229
|
return t.data;
|
|
2227
2230
|
}
|
|
2228
|
-
function
|
|
2231
|
+
function Vn(e) {
|
|
2229
2232
|
if (!e) return;
|
|
2230
2233
|
let t;
|
|
2231
2234
|
try {
|
|
@@ -2235,14 +2238,14 @@ function In(e) {
|
|
|
2235
2238
|
}
|
|
2236
2239
|
return oe(t) ? t : void 0;
|
|
2237
2240
|
}
|
|
2238
|
-
function
|
|
2241
|
+
function Hn(e) {
|
|
2239
2242
|
return {
|
|
2240
2243
|
id: e.id,
|
|
2241
2244
|
token_hash: e.token_hash,
|
|
2242
|
-
type:
|
|
2245
|
+
type: Bn(e.type),
|
|
2243
2246
|
client_id: e.client_id ?? void 0,
|
|
2244
2247
|
sub: e.sub ?? void 0,
|
|
2245
|
-
constraints:
|
|
2248
|
+
constraints: Vn(e.constraints),
|
|
2246
2249
|
single_use: !!e.single_use,
|
|
2247
2250
|
expires_at: i(e.expires_at_ts),
|
|
2248
2251
|
used_at: i(e.used_at_ts),
|
|
@@ -2252,38 +2255,38 @@ function R(e) {
|
|
|
2252
2255
|
}
|
|
2253
2256
|
//#endregion
|
|
2254
2257
|
//#region src/clientRegistrationTokens/get.ts
|
|
2255
|
-
function
|
|
2258
|
+
function Un(e) {
|
|
2256
2259
|
return async (t, n) => {
|
|
2257
2260
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2258
|
-
return r ?
|
|
2261
|
+
return r ? Hn(r) : null;
|
|
2259
2262
|
};
|
|
2260
2263
|
}
|
|
2261
2264
|
//#endregion
|
|
2262
2265
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2263
|
-
function
|
|
2266
|
+
function Wn(e) {
|
|
2264
2267
|
return async (t, n) => {
|
|
2265
2268
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2266
|
-
return r ?
|
|
2269
|
+
return r ? Hn(r) : null;
|
|
2267
2270
|
};
|
|
2268
2271
|
}
|
|
2269
2272
|
//#endregion
|
|
2270
2273
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2271
|
-
function
|
|
2272
|
-
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(
|
|
2274
|
+
function Gn(e) {
|
|
2275
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(Hn);
|
|
2273
2276
|
}
|
|
2274
2277
|
//#endregion
|
|
2275
2278
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2276
|
-
function
|
|
2279
|
+
function Kn(e) {
|
|
2277
2280
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ used_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("used_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2278
2281
|
}
|
|
2279
2282
|
//#endregion
|
|
2280
2283
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2281
|
-
function
|
|
2284
|
+
function qn(e) {
|
|
2282
2285
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2283
2286
|
}
|
|
2284
2287
|
//#endregion
|
|
2285
2288
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2286
|
-
function
|
|
2289
|
+
function Jn(e) {
|
|
2287
2290
|
return async (t, n, r) => {
|
|
2288
2291
|
let i = await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("client_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
2289
2292
|
return Number(i.numUpdatedRows);
|
|
@@ -2291,26 +2294,26 @@ function Hn(e) {
|
|
|
2291
2294
|
}
|
|
2292
2295
|
//#endregion
|
|
2293
2296
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2294
|
-
function
|
|
2297
|
+
function Yn(e) {
|
|
2295
2298
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2296
2299
|
}
|
|
2297
2300
|
//#endregion
|
|
2298
2301
|
//#region src/clientRegistrationTokens/index.ts
|
|
2299
|
-
function
|
|
2302
|
+
function Xn(e) {
|
|
2300
2303
|
return {
|
|
2301
|
-
create:
|
|
2302
|
-
get:
|
|
2303
|
-
getByHash:
|
|
2304
|
-
listByClient:
|
|
2305
|
-
markUsed:
|
|
2306
|
-
revoke:
|
|
2307
|
-
revokeByClient:
|
|
2308
|
-
remove:
|
|
2304
|
+
create: zn(e),
|
|
2305
|
+
get: Un(e),
|
|
2306
|
+
getByHash: Wn(e),
|
|
2307
|
+
listByClient: Gn(e),
|
|
2308
|
+
markUsed: Kn(e),
|
|
2309
|
+
revoke: qn(e),
|
|
2310
|
+
revokeByClient: Jn(e),
|
|
2311
|
+
remove: Yn(e)
|
|
2309
2312
|
};
|
|
2310
2313
|
}
|
|
2311
2314
|
//#endregion
|
|
2312
2315
|
//#region src/keys/list.ts
|
|
2313
|
-
function
|
|
2316
|
+
function Zn(e) {
|
|
2314
2317
|
return async (t = {}) => {
|
|
2315
2318
|
let { page: n = 0, per_page: r = 100, include_totals: i = !1, sort: a, q: s } = t, c = e.selectFrom("keys").where((e) => e.or([e("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()), e("revoked_at", "is", null)]));
|
|
2316
2319
|
s && (c = D(e, c, s, [
|
|
@@ -2339,7 +2342,7 @@ function Gn(e) {
|
|
|
2339
2342
|
}
|
|
2340
2343
|
//#endregion
|
|
2341
2344
|
//#region src/keys/create.ts
|
|
2342
|
-
function
|
|
2345
|
+
function Qn(e) {
|
|
2343
2346
|
return async (t, n) => {
|
|
2344
2347
|
let r = n?.importMetadata;
|
|
2345
2348
|
await e.insertInto("keys").values({
|
|
@@ -2351,21 +2354,21 @@ function Kn(e) {
|
|
|
2351
2354
|
}
|
|
2352
2355
|
//#endregion
|
|
2353
2356
|
//#region src/keys/update.ts
|
|
2354
|
-
function
|
|
2357
|
+
function $n(e) {
|
|
2355
2358
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2356
2359
|
}
|
|
2357
2360
|
//#endregion
|
|
2358
2361
|
//#region src/keys/index.ts
|
|
2359
|
-
function
|
|
2362
|
+
function er(e) {
|
|
2360
2363
|
return {
|
|
2361
|
-
create:
|
|
2362
|
-
list:
|
|
2363
|
-
update:
|
|
2364
|
+
create: Qn(e),
|
|
2365
|
+
list: Zn(e),
|
|
2366
|
+
update: $n(e)
|
|
2364
2367
|
};
|
|
2365
2368
|
}
|
|
2366
2369
|
//#endregion
|
|
2367
2370
|
//#region src/customDomains/create.ts
|
|
2368
|
-
function
|
|
2371
|
+
function tr(e) {
|
|
2369
2372
|
return async (n, r, i) => {
|
|
2370
2373
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2371
2374
|
status: "pending",
|
|
@@ -2385,7 +2388,7 @@ function Yn(e) {
|
|
|
2385
2388
|
}
|
|
2386
2389
|
//#endregion
|
|
2387
2390
|
//#region src/customDomains/list.ts
|
|
2388
|
-
function
|
|
2391
|
+
function nr(e) {
|
|
2389
2392
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2390
2393
|
...e,
|
|
2391
2394
|
primary: e.primary === 1,
|
|
@@ -2395,12 +2398,12 @@ function Xn(e) {
|
|
|
2395
2398
|
}
|
|
2396
2399
|
//#endregion
|
|
2397
2400
|
//#region src/customDomains/remove.ts
|
|
2398
|
-
function
|
|
2401
|
+
function rr(e) {
|
|
2399
2402
|
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;
|
|
2400
2403
|
}
|
|
2401
2404
|
//#endregion
|
|
2402
2405
|
//#region src/customDomains/get.ts
|
|
2403
|
-
function
|
|
2406
|
+
function ir(e) {
|
|
2404
2407
|
return async (t, n) => {
|
|
2405
2408
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2406
2409
|
return r ? {
|
|
@@ -2413,7 +2416,7 @@ function Qn(e) {
|
|
|
2413
2416
|
}
|
|
2414
2417
|
//#endregion
|
|
2415
2418
|
//#region src/customDomains/update.ts
|
|
2416
|
-
function
|
|
2419
|
+
function ar(e) {
|
|
2417
2420
|
return async (t, n, r) => {
|
|
2418
2421
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2419
2422
|
...s,
|
|
@@ -2427,7 +2430,7 @@ function $n(e) {
|
|
|
2427
2430
|
}
|
|
2428
2431
|
//#endregion
|
|
2429
2432
|
//#region src/customDomains/getByDomain.ts
|
|
2430
|
-
function
|
|
2433
|
+
function or(e) {
|
|
2431
2434
|
return async (t) => {
|
|
2432
2435
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2433
2436
|
return n ? {
|
|
@@ -2439,19 +2442,19 @@ function er(e) {
|
|
|
2439
2442
|
}
|
|
2440
2443
|
//#endregion
|
|
2441
2444
|
//#region src/customDomains/index.ts
|
|
2442
|
-
function
|
|
2445
|
+
function sr(e) {
|
|
2443
2446
|
return {
|
|
2444
|
-
create:
|
|
2445
|
-
get:
|
|
2446
|
-
getByDomain:
|
|
2447
|
-
list:
|
|
2448
|
-
remove:
|
|
2449
|
-
update:
|
|
2447
|
+
create: tr(e),
|
|
2448
|
+
get: ir(e),
|
|
2449
|
+
getByDomain: or(e),
|
|
2450
|
+
list: nr(e),
|
|
2451
|
+
remove: rr(e),
|
|
2452
|
+
update: ar(e)
|
|
2450
2453
|
};
|
|
2451
2454
|
}
|
|
2452
2455
|
//#endregion
|
|
2453
2456
|
//#region src/branding/get.ts
|
|
2454
|
-
function
|
|
2457
|
+
function cr(e) {
|
|
2455
2458
|
return async (t) => {
|
|
2456
2459
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2457
2460
|
if (!n) return null;
|
|
@@ -2473,7 +2476,7 @@ function nr(e) {
|
|
|
2473
2476
|
}
|
|
2474
2477
|
//#endregion
|
|
2475
2478
|
//#region src/branding/set.ts
|
|
2476
|
-
function
|
|
2479
|
+
function lr(e) {
|
|
2477
2480
|
return async (t, n) => {
|
|
2478
2481
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2479
2482
|
try {
|
|
@@ -2502,15 +2505,15 @@ function rr(e) {
|
|
|
2502
2505
|
}
|
|
2503
2506
|
//#endregion
|
|
2504
2507
|
//#region src/branding/index.ts
|
|
2505
|
-
function
|
|
2508
|
+
function ur(e) {
|
|
2506
2509
|
return {
|
|
2507
|
-
get:
|
|
2508
|
-
set:
|
|
2510
|
+
get: cr(e),
|
|
2511
|
+
set: lr(e)
|
|
2509
2512
|
};
|
|
2510
2513
|
}
|
|
2511
2514
|
//#endregion
|
|
2512
2515
|
//#region src/universalLoginTemplates/get.ts
|
|
2513
|
-
function
|
|
2516
|
+
function dr(e) {
|
|
2514
2517
|
return async (t) => {
|
|
2515
2518
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2516
2519
|
return n ? { body: n.body } : null;
|
|
@@ -2518,7 +2521,7 @@ function ar(e) {
|
|
|
2518
2521
|
}
|
|
2519
2522
|
//#endregion
|
|
2520
2523
|
//#region src/universalLoginTemplates/set.ts
|
|
2521
|
-
function
|
|
2524
|
+
function fr(e) {
|
|
2522
2525
|
return async (t, n, r) => {
|
|
2523
2526
|
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;
|
|
2524
2527
|
try {
|
|
@@ -2539,23 +2542,23 @@ function or(e) {
|
|
|
2539
2542
|
}
|
|
2540
2543
|
//#endregion
|
|
2541
2544
|
//#region src/universalLoginTemplates/delete.ts
|
|
2542
|
-
function
|
|
2545
|
+
function pr(e) {
|
|
2543
2546
|
return async (t) => {
|
|
2544
2547
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2545
2548
|
};
|
|
2546
2549
|
}
|
|
2547
2550
|
//#endregion
|
|
2548
2551
|
//#region src/universalLoginTemplates/index.ts
|
|
2549
|
-
function
|
|
2552
|
+
function mr(e) {
|
|
2550
2553
|
return {
|
|
2551
|
-
get:
|
|
2552
|
-
set:
|
|
2553
|
-
delete:
|
|
2554
|
+
get: dr(e),
|
|
2555
|
+
set: fr(e),
|
|
2556
|
+
delete: pr(e)
|
|
2554
2557
|
};
|
|
2555
2558
|
}
|
|
2556
2559
|
//#endregion
|
|
2557
2560
|
//#region src/hooks/list.ts
|
|
2558
|
-
function
|
|
2561
|
+
function hr(e) {
|
|
2559
2562
|
return async (t, n = {}) => {
|
|
2560
2563
|
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);
|
|
2561
2564
|
if (u && (d = D(e, d, u, [
|
|
@@ -2577,7 +2580,7 @@ function lr(e) {
|
|
|
2577
2580
|
...u,
|
|
2578
2581
|
enabled: !!n,
|
|
2579
2582
|
synchronous: !!i,
|
|
2580
|
-
metadata:
|
|
2583
|
+
metadata: yt(s)
|
|
2581
2584
|
});
|
|
2582
2585
|
});
|
|
2583
2586
|
if (!s) return {
|
|
@@ -2597,7 +2600,7 @@ function lr(e) {
|
|
|
2597
2600
|
}
|
|
2598
2601
|
//#endregion
|
|
2599
2602
|
//#region src/hooks/get.ts
|
|
2600
|
-
function
|
|
2603
|
+
function gr(e) {
|
|
2601
2604
|
return async (t, n) => {
|
|
2602
2605
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2603
2606
|
if (!i) return null;
|
|
@@ -2610,20 +2613,20 @@ function ur(e) {
|
|
|
2610
2613
|
...d,
|
|
2611
2614
|
enabled: !!u.enabled,
|
|
2612
2615
|
synchronous: !!u.synchronous,
|
|
2613
|
-
metadata:
|
|
2616
|
+
metadata: yt(c)
|
|
2614
2617
|
});
|
|
2615
2618
|
};
|
|
2616
2619
|
}
|
|
2617
2620
|
//#endregion
|
|
2618
2621
|
//#region src/hooks/remove.ts
|
|
2619
|
-
function
|
|
2622
|
+
function _r(e) {
|
|
2620
2623
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2621
2624
|
}
|
|
2622
2625
|
//#endregion
|
|
2623
2626
|
//#region src/hooks/create.ts
|
|
2624
|
-
function
|
|
2627
|
+
function vr(e) {
|
|
2625
2628
|
return async (t, n, r) => {
|
|
2626
|
-
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 ||
|
|
2629
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Me()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2627
2630
|
return await e.insertInto("hooks").values({
|
|
2628
2631
|
...p,
|
|
2629
2632
|
hook_id: c,
|
|
@@ -2646,7 +2649,7 @@ function fr(e) {
|
|
|
2646
2649
|
}
|
|
2647
2650
|
//#endregion
|
|
2648
2651
|
//#region src/hooks/update.ts
|
|
2649
|
-
function
|
|
2652
|
+
function yr(e) {
|
|
2650
2653
|
return async (t, n, r) => {
|
|
2651
2654
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2652
2655
|
...o,
|
|
@@ -2660,20 +2663,20 @@ function pr(e) {
|
|
|
2660
2663
|
}
|
|
2661
2664
|
//#endregion
|
|
2662
2665
|
//#region src/hooks/index.ts
|
|
2663
|
-
function
|
|
2666
|
+
function br(e) {
|
|
2664
2667
|
return {
|
|
2665
|
-
create:
|
|
2666
|
-
get:
|
|
2667
|
-
list:
|
|
2668
|
-
update:
|
|
2669
|
-
remove:
|
|
2668
|
+
create: vr(e),
|
|
2669
|
+
get: gr(e),
|
|
2670
|
+
list: hr(e),
|
|
2671
|
+
update: yr(e),
|
|
2672
|
+
remove: _r(e)
|
|
2670
2673
|
};
|
|
2671
2674
|
}
|
|
2672
2675
|
//#endregion
|
|
2673
2676
|
//#region src/hook-code/create.ts
|
|
2674
|
-
function
|
|
2677
|
+
function xr(e) {
|
|
2675
2678
|
return async (t, n, r) => {
|
|
2676
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2679
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Pe();
|
|
2677
2680
|
return await e.insertInto("hook_code").values({
|
|
2678
2681
|
id: c,
|
|
2679
2682
|
tenant_id: t,
|
|
@@ -2693,7 +2696,7 @@ function hr(e) {
|
|
|
2693
2696
|
}
|
|
2694
2697
|
//#endregion
|
|
2695
2698
|
//#region src/hook-code/get.ts
|
|
2696
|
-
function
|
|
2699
|
+
function Sr(e) {
|
|
2697
2700
|
return async (t, n) => {
|
|
2698
2701
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2699
2702
|
if (!i) return null;
|
|
@@ -2717,7 +2720,7 @@ function gr(e) {
|
|
|
2717
2720
|
}
|
|
2718
2721
|
//#endregion
|
|
2719
2722
|
//#region src/hook-code/update.ts
|
|
2720
|
-
function
|
|
2723
|
+
function Cr(e) {
|
|
2721
2724
|
return async (t, n, r) => {
|
|
2722
2725
|
let i = { updated_at_ts: Date.now() };
|
|
2723
2726
|
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;
|
|
@@ -2725,22 +2728,22 @@ function _r(e) {
|
|
|
2725
2728
|
}
|
|
2726
2729
|
//#endregion
|
|
2727
2730
|
//#region src/hook-code/remove.ts
|
|
2728
|
-
function
|
|
2731
|
+
function wr(e) {
|
|
2729
2732
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2730
2733
|
}
|
|
2731
2734
|
//#endregion
|
|
2732
2735
|
//#region src/hook-code/index.ts
|
|
2733
|
-
function
|
|
2736
|
+
function Tr(e) {
|
|
2734
2737
|
return {
|
|
2735
|
-
create:
|
|
2736
|
-
get:
|
|
2737
|
-
update:
|
|
2738
|
-
remove:
|
|
2738
|
+
create: xr(e),
|
|
2739
|
+
get: Sr(e),
|
|
2740
|
+
update: Cr(e),
|
|
2741
|
+
remove: wr(e)
|
|
2739
2742
|
};
|
|
2740
2743
|
}
|
|
2741
2744
|
//#endregion
|
|
2742
2745
|
//#region src/themes/create.ts
|
|
2743
|
-
function
|
|
2746
|
+
function Er(e) {
|
|
2744
2747
|
return async (n, r, i, a) => {
|
|
2745
2748
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2746
2749
|
themeId: o?.id || i || t(),
|
|
@@ -2756,15 +2759,15 @@ function br(e) {
|
|
|
2756
2759
|
}
|
|
2757
2760
|
//#endregion
|
|
2758
2761
|
//#region src/themes/remove.ts
|
|
2759
|
-
function
|
|
2762
|
+
function Dr(e) {
|
|
2760
2763
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2761
2764
|
}
|
|
2762
2765
|
//#endregion
|
|
2763
2766
|
//#region src/themes/get.ts
|
|
2764
|
-
function
|
|
2767
|
+
function Or(e) {
|
|
2765
2768
|
return async (t, n) => {
|
|
2766
2769
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2767
|
-
return r ? l(
|
|
2770
|
+
return r ? l(dt({
|
|
2768
2771
|
...r,
|
|
2769
2772
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2770
2773
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2784,7 +2787,7 @@ function Sr(e) {
|
|
|
2784
2787
|
}
|
|
2785
2788
|
//#endregion
|
|
2786
2789
|
//#region src/themes/update.ts
|
|
2787
|
-
function
|
|
2790
|
+
function kr(e) {
|
|
2788
2791
|
return async (t, n, r) => {
|
|
2789
2792
|
let { themeId: i, ...a } = r, o = P({
|
|
2790
2793
|
...a,
|
|
@@ -2795,17 +2798,17 @@ function Cr(e) {
|
|
|
2795
2798
|
}
|
|
2796
2799
|
//#endregion
|
|
2797
2800
|
//#region src/themes/index.ts
|
|
2798
|
-
function
|
|
2801
|
+
function Ar(e) {
|
|
2799
2802
|
return {
|
|
2800
|
-
create:
|
|
2801
|
-
get:
|
|
2802
|
-
remove:
|
|
2803
|
-
update:
|
|
2803
|
+
create: Er(e),
|
|
2804
|
+
get: Or(e),
|
|
2805
|
+
remove: Dr(e),
|
|
2806
|
+
update: kr(e)
|
|
2804
2807
|
};
|
|
2805
2808
|
}
|
|
2806
2809
|
//#endregion
|
|
2807
2810
|
//#region src/loginSessions/get.ts
|
|
2808
|
-
function
|
|
2811
|
+
function jr(e) {
|
|
2809
2812
|
return async (t, n) => {
|
|
2810
2813
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2811
2814
|
if (!i) return null;
|
|
@@ -2817,7 +2820,7 @@ function Tr(e) {
|
|
|
2817
2820
|
"created_at_ts",
|
|
2818
2821
|
"updated_at_ts",
|
|
2819
2822
|
"expires_at_ts"
|
|
2820
|
-
]), f =
|
|
2823
|
+
]), f = dt(l({
|
|
2821
2824
|
...u,
|
|
2822
2825
|
...d,
|
|
2823
2826
|
state: i.state || p.PENDING,
|
|
@@ -2829,28 +2832,28 @@ function Tr(e) {
|
|
|
2829
2832
|
}
|
|
2830
2833
|
//#endregion
|
|
2831
2834
|
//#region src/utils/ulid.ts
|
|
2832
|
-
var
|
|
2833
|
-
function
|
|
2835
|
+
var Mr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Nr = 32, Pr = 10, Fr = 16;
|
|
2836
|
+
function Ir(e) {
|
|
2834
2837
|
let t = "";
|
|
2835
|
-
for (let n =
|
|
2838
|
+
for (let n = Pr; n > 0; n--) t = Mr.charAt(e % Nr) + t, e = Math.floor(e / Nr);
|
|
2836
2839
|
return t;
|
|
2837
2840
|
}
|
|
2838
|
-
function
|
|
2839
|
-
let e = new Uint8Array(
|
|
2841
|
+
function Lr() {
|
|
2842
|
+
let e = new Uint8Array(Fr);
|
|
2840
2843
|
crypto.getRandomValues(e);
|
|
2841
2844
|
let t = "";
|
|
2842
|
-
for (let n = 0; n <
|
|
2845
|
+
for (let n = 0; n < Fr; n++) t += Mr.charAt(e[n] % Nr);
|
|
2843
2846
|
return t;
|
|
2844
2847
|
}
|
|
2845
|
-
function
|
|
2846
|
-
return
|
|
2848
|
+
function Rr() {
|
|
2849
|
+
return Ir(Date.now()) + Lr();
|
|
2847
2850
|
}
|
|
2848
2851
|
//#endregion
|
|
2849
2852
|
//#region src/loginSessions/create.ts
|
|
2850
|
-
function
|
|
2853
|
+
function zr(e) {
|
|
2851
2854
|
return async (t, n) => {
|
|
2852
2855
|
let r = c(), i = {
|
|
2853
|
-
id:
|
|
2856
|
+
id: Rr(),
|
|
2854
2857
|
...n,
|
|
2855
2858
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2856
2859
|
created_at: r,
|
|
@@ -2871,7 +2874,7 @@ function Mr(e) {
|
|
|
2871
2874
|
}
|
|
2872
2875
|
//#endregion
|
|
2873
2876
|
//#region src/loginSessions/update.ts
|
|
2874
|
-
function
|
|
2877
|
+
function Br(e) {
|
|
2875
2878
|
return async (t, n, r) => {
|
|
2876
2879
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2877
2880
|
if (c !== void 0) {
|
|
@@ -2892,22 +2895,22 @@ function Nr(e) {
|
|
|
2892
2895
|
}
|
|
2893
2896
|
//#endregion
|
|
2894
2897
|
//#region src/loginSessions/remove.ts
|
|
2895
|
-
function
|
|
2898
|
+
function Vr(e) {
|
|
2896
2899
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2897
2900
|
}
|
|
2898
2901
|
//#endregion
|
|
2899
2902
|
//#region src/loginSessions/index.ts
|
|
2900
|
-
function
|
|
2903
|
+
function Hr(e) {
|
|
2901
2904
|
return {
|
|
2902
|
-
create:
|
|
2903
|
-
get:
|
|
2904
|
-
update:
|
|
2905
|
-
remove:
|
|
2905
|
+
create: zr(e),
|
|
2906
|
+
get: jr(e),
|
|
2907
|
+
update: Br(e),
|
|
2908
|
+
remove: Vr(e)
|
|
2906
2909
|
};
|
|
2907
2910
|
}
|
|
2908
2911
|
//#endregion
|
|
2909
2912
|
//#region src/promptSettings/get.ts
|
|
2910
|
-
function
|
|
2913
|
+
function Ur(e) {
|
|
2911
2914
|
return async (t) => {
|
|
2912
2915
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2913
2916
|
return l({
|
|
@@ -2921,13 +2924,13 @@ function Ir(e) {
|
|
|
2921
2924
|
}
|
|
2922
2925
|
//#endregion
|
|
2923
2926
|
//#region src/promptSettings/set.ts
|
|
2924
|
-
function
|
|
2927
|
+
function Wr(e) {
|
|
2925
2928
|
let t = {};
|
|
2926
2929
|
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;
|
|
2927
2930
|
}
|
|
2928
|
-
function
|
|
2931
|
+
function Gr(e) {
|
|
2929
2932
|
return async (t, n) => {
|
|
2930
|
-
let r =
|
|
2933
|
+
let r = Wr(n);
|
|
2931
2934
|
try {
|
|
2932
2935
|
await e.insertInto("prompt_settings").values({
|
|
2933
2936
|
tenant_id: t,
|
|
@@ -2945,15 +2948,15 @@ function Rr(e) {
|
|
|
2945
2948
|
}
|
|
2946
2949
|
//#endregion
|
|
2947
2950
|
//#region src/promptSettings/index.ts
|
|
2948
|
-
function
|
|
2951
|
+
function Kr(e) {
|
|
2949
2952
|
return {
|
|
2950
|
-
get:
|
|
2951
|
-
set:
|
|
2953
|
+
get: Ur(e),
|
|
2954
|
+
set: Gr(e)
|
|
2952
2955
|
};
|
|
2953
2956
|
}
|
|
2954
2957
|
//#endregion
|
|
2955
2958
|
//#region src/emailProvideres/get.ts
|
|
2956
|
-
function
|
|
2959
|
+
function qr(e) {
|
|
2957
2960
|
return async (t) => {
|
|
2958
2961
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2959
2962
|
if (!n) return null;
|
|
@@ -2968,7 +2971,7 @@ function Br(e) {
|
|
|
2968
2971
|
}
|
|
2969
2972
|
//#endregion
|
|
2970
2973
|
//#region src/emailProvideres/update.ts
|
|
2971
|
-
function
|
|
2974
|
+
function Jr(e) {
|
|
2972
2975
|
return async (t, n) => {
|
|
2973
2976
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2974
2977
|
await e.updateTable("email_providers").set({
|
|
@@ -2981,7 +2984,7 @@ function Vr(e) {
|
|
|
2981
2984
|
}
|
|
2982
2985
|
//#endregion
|
|
2983
2986
|
//#region src/emailProvideres/create.ts
|
|
2984
|
-
function
|
|
2987
|
+
function Yr(e) {
|
|
2985
2988
|
return async (t, n, r) => {
|
|
2986
2989
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2987
2990
|
await e.insertInto("email_providers").values({
|
|
@@ -2997,24 +3000,24 @@ function Hr(e) {
|
|
|
2997
3000
|
}
|
|
2998
3001
|
//#endregion
|
|
2999
3002
|
//#region src/emailProvideres/remove.ts
|
|
3000
|
-
function
|
|
3003
|
+
function Xr(e) {
|
|
3001
3004
|
return async (t) => {
|
|
3002
3005
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3003
3006
|
};
|
|
3004
3007
|
}
|
|
3005
3008
|
//#endregion
|
|
3006
3009
|
//#region src/emailProvideres/index.ts
|
|
3007
|
-
function
|
|
3010
|
+
function Zr(e) {
|
|
3008
3011
|
return {
|
|
3009
|
-
get:
|
|
3010
|
-
create:
|
|
3011
|
-
update:
|
|
3012
|
-
remove:
|
|
3012
|
+
get: qr(e),
|
|
3013
|
+
create: Yr(e),
|
|
3014
|
+
update: Jr(e),
|
|
3015
|
+
remove: Xr(e)
|
|
3013
3016
|
};
|
|
3014
3017
|
}
|
|
3015
3018
|
//#endregion
|
|
3016
3019
|
//#region src/emailTemplates/row.ts
|
|
3017
|
-
function
|
|
3020
|
+
function Qr(e) {
|
|
3018
3021
|
let t = {
|
|
3019
3022
|
template: e.template,
|
|
3020
3023
|
body: e.body,
|
|
@@ -3028,20 +3031,20 @@ function Gr(e) {
|
|
|
3028
3031
|
}
|
|
3029
3032
|
//#endregion
|
|
3030
3033
|
//#region src/emailTemplates/get.ts
|
|
3031
|
-
function
|
|
3034
|
+
function $r(e) {
|
|
3032
3035
|
return async (t, n) => {
|
|
3033
3036
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3034
|
-
return r ? ne.parse(
|
|
3037
|
+
return r ? ne.parse(Qr(r)) : null;
|
|
3035
3038
|
};
|
|
3036
3039
|
}
|
|
3037
3040
|
//#endregion
|
|
3038
3041
|
//#region src/emailTemplates/list.ts
|
|
3039
|
-
function
|
|
3040
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(
|
|
3042
|
+
function ei(e) {
|
|
3043
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(Qr(e)));
|
|
3041
3044
|
}
|
|
3042
3045
|
//#endregion
|
|
3043
3046
|
//#region src/emailTemplates/create.ts
|
|
3044
|
-
function
|
|
3047
|
+
function ti(e) {
|
|
3045
3048
|
return async (t, n, r) => {
|
|
3046
3049
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3047
3050
|
return await e.insertInto("email_templates").values({
|
|
@@ -3062,7 +3065,7 @@ function Jr(e) {
|
|
|
3062
3065
|
}
|
|
3063
3066
|
//#endregion
|
|
3064
3067
|
//#region src/emailTemplates/update.ts
|
|
3065
|
-
function
|
|
3068
|
+
function ni(e) {
|
|
3066
3069
|
return async (t, n, r) => {
|
|
3067
3070
|
let i = {};
|
|
3068
3071
|
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;
|
|
@@ -3073,7 +3076,7 @@ function Yr(e) {
|
|
|
3073
3076
|
}
|
|
3074
3077
|
//#endregion
|
|
3075
3078
|
//#region src/emailTemplates/remove.ts
|
|
3076
|
-
function
|
|
3079
|
+
function ri(e) {
|
|
3077
3080
|
return async (t, n) => {
|
|
3078
3081
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3079
3082
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3081,18 +3084,18 @@ function Xr(e) {
|
|
|
3081
3084
|
}
|
|
3082
3085
|
//#endregion
|
|
3083
3086
|
//#region src/emailTemplates/index.ts
|
|
3084
|
-
function
|
|
3087
|
+
function ii(e) {
|
|
3085
3088
|
return {
|
|
3086
|
-
get:
|
|
3087
|
-
list:
|
|
3088
|
-
create:
|
|
3089
|
-
update:
|
|
3090
|
-
remove:
|
|
3089
|
+
get: $r(e),
|
|
3090
|
+
list: ei(e),
|
|
3091
|
+
create: ti(e),
|
|
3092
|
+
update: ni(e),
|
|
3093
|
+
remove: ri(e)
|
|
3091
3094
|
};
|
|
3092
3095
|
}
|
|
3093
3096
|
//#endregion
|
|
3094
3097
|
//#region src/refreshTokens/to-refresh-token.ts
|
|
3095
|
-
function
|
|
3098
|
+
function L(e) {
|
|
3096
3099
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: i, idle_expires_at_ts: a, last_exchanged_at_ts: o, revoked_at_ts: s, rotated_at_ts: c, auth_strategy_strategy: u, auth_strategy_strategy_type: d, ...f } = e, p = r({
|
|
3097
3100
|
created_at_ts: n,
|
|
3098
3101
|
expires_at_ts: i,
|
|
@@ -3121,23 +3124,23 @@ function B(e) {
|
|
|
3121
3124
|
}
|
|
3122
3125
|
//#endregion
|
|
3123
3126
|
//#region src/refreshTokens/get.ts
|
|
3124
|
-
function
|
|
3127
|
+
function ai(e) {
|
|
3125
3128
|
return async (t, n) => {
|
|
3126
3129
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3127
|
-
return r ?
|
|
3130
|
+
return r ? L(r) : null;
|
|
3128
3131
|
};
|
|
3129
3132
|
}
|
|
3130
3133
|
//#endregion
|
|
3131
3134
|
//#region src/refreshTokens/getByLookup.ts
|
|
3132
|
-
function
|
|
3135
|
+
function oi(e) {
|
|
3133
3136
|
return async (t, n) => {
|
|
3134
3137
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3135
|
-
return r ?
|
|
3138
|
+
return r ? L(r) : null;
|
|
3136
3139
|
};
|
|
3137
3140
|
}
|
|
3138
3141
|
//#endregion
|
|
3139
3142
|
//#region src/refreshTokens/create.ts
|
|
3140
|
-
function
|
|
3143
|
+
function si(e) {
|
|
3141
3144
|
return async (t, n) => {
|
|
3142
3145
|
let r = c(), i = {
|
|
3143
3146
|
...n,
|
|
@@ -3169,20 +3172,28 @@ function ei(e) {
|
|
|
3169
3172
|
}
|
|
3170
3173
|
//#endregion
|
|
3171
3174
|
//#region src/refreshTokens/remove.ts
|
|
3172
|
-
function
|
|
3175
|
+
function ci(e) {
|
|
3173
3176
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3174
3177
|
}
|
|
3175
3178
|
//#endregion
|
|
3176
3179
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3177
|
-
function
|
|
3180
|
+
function li(e) {
|
|
3178
3181
|
return async (t, n, r) => {
|
|
3179
3182
|
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();
|
|
3180
3183
|
return Number(a.numUpdatedRows ?? 0);
|
|
3181
3184
|
};
|
|
3182
3185
|
}
|
|
3183
3186
|
//#endregion
|
|
3187
|
+
//#region src/refreshTokens/revokeBySession.ts
|
|
3188
|
+
function ui(e) {
|
|
3189
|
+
return async (t, n, r) => {
|
|
3190
|
+
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("session_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3191
|
+
return Number(i.numUpdatedRows ?? 0);
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
//#endregion
|
|
3184
3195
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3185
|
-
function
|
|
3196
|
+
function di(e) {
|
|
3186
3197
|
return async (t, n, r) => {
|
|
3187
3198
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("user_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3188
3199
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3190,7 +3201,7 @@ function ri(e) {
|
|
|
3190
3201
|
}
|
|
3191
3202
|
//#endregion
|
|
3192
3203
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3193
|
-
function
|
|
3204
|
+
function fi(e) {
|
|
3194
3205
|
return async (t, n, r) => {
|
|
3195
3206
|
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();
|
|
3196
3207
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3198,7 +3209,7 @@ function ii(e) {
|
|
|
3198
3209
|
}
|
|
3199
3210
|
//#endregion
|
|
3200
3211
|
//#region src/refreshTokens/update.ts
|
|
3201
|
-
function
|
|
3212
|
+
function pi(e) {
|
|
3202
3213
|
return async (t, n, r, i) => {
|
|
3203
3214
|
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 = {
|
|
3204
3215
|
...h,
|
|
@@ -3219,14 +3230,14 @@ function ai(e) {
|
|
|
3219
3230
|
}
|
|
3220
3231
|
//#endregion
|
|
3221
3232
|
//#region src/refreshTokens/list.ts
|
|
3222
|
-
function
|
|
3233
|
+
function mi(e) {
|
|
3223
3234
|
return async (t, n = {}) => {
|
|
3224
3235
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, user_id: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3225
3236
|
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = D(e, u, c, ["token", "login_id"])), M(n)) {
|
|
3226
3237
|
let { rows: e, limit: t, next: r } = await N(u.selectAll(), n, {
|
|
3227
3238
|
sortColumn: "created_at_ts",
|
|
3228
3239
|
sortOrder: "desc"
|
|
3229
|
-
}), i = e.map(
|
|
3240
|
+
}), i = e.map(L);
|
|
3230
3241
|
return {
|
|
3231
3242
|
refresh_tokens: i,
|
|
3232
3243
|
start: 0,
|
|
@@ -3241,7 +3252,7 @@ function oi(e) {
|
|
|
3241
3252
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3242
3253
|
}
|
|
3243
3254
|
d = d.offset(r * i).limit(i);
|
|
3244
|
-
let f = (await d.selectAll().execute()).map(
|
|
3255
|
+
let f = (await d.selectAll().execute()).map(L);
|
|
3245
3256
|
if (!a) return {
|
|
3246
3257
|
refresh_tokens: f,
|
|
3247
3258
|
start: 0,
|
|
@@ -3259,25 +3270,26 @@ function oi(e) {
|
|
|
3259
3270
|
}
|
|
3260
3271
|
//#endregion
|
|
3261
3272
|
//#region src/refreshTokens/index.ts
|
|
3262
|
-
function
|
|
3273
|
+
function hi(e) {
|
|
3263
3274
|
return {
|
|
3264
|
-
create:
|
|
3265
|
-
get:
|
|
3266
|
-
getByLookup:
|
|
3267
|
-
list:
|
|
3268
|
-
remove:
|
|
3269
|
-
revokeByLoginSession:
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3275
|
+
create: si(e),
|
|
3276
|
+
get: ai(e),
|
|
3277
|
+
getByLookup: oi(e),
|
|
3278
|
+
list: mi(e),
|
|
3279
|
+
remove: ci(e),
|
|
3280
|
+
revokeByLoginSession: li(e),
|
|
3281
|
+
revokeBySession: ui(e),
|
|
3282
|
+
revokeByUser: di(e),
|
|
3283
|
+
revokeFamily: fi(e),
|
|
3284
|
+
update: pi(e)
|
|
3273
3285
|
};
|
|
3274
3286
|
}
|
|
3275
3287
|
//#endregion
|
|
3276
3288
|
//#region src/cleanup.ts
|
|
3277
|
-
var
|
|
3278
|
-
function
|
|
3289
|
+
var gi = 10080 * 60 * 1e3;
|
|
3290
|
+
function _i(e) {
|
|
3279
3291
|
return async (t) => {
|
|
3280
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3292
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - gi, a = 1e3;
|
|
3281
3293
|
try {
|
|
3282
3294
|
let t = 0;
|
|
3283
3295
|
for (;;) {
|
|
@@ -3308,7 +3320,7 @@ function li(e) {
|
|
|
3308
3320
|
}
|
|
3309
3321
|
//#endregion
|
|
3310
3322
|
//#region src/forms/create.ts
|
|
3311
|
-
function
|
|
3323
|
+
function vi(e) {
|
|
3312
3324
|
return async (n, r, i) => {
|
|
3313
3325
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3314
3326
|
id: a?.id ?? t(),
|
|
@@ -3327,7 +3339,7 @@ function ui(e) {
|
|
|
3327
3339
|
}
|
|
3328
3340
|
//#endregion
|
|
3329
3341
|
//#region src/forms/list.ts
|
|
3330
|
-
function
|
|
3342
|
+
function yi(e) {
|
|
3331
3343
|
return async (t, n = {}) => {
|
|
3332
3344
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3333
3345
|
s && (c = D(e, c, s, []));
|
|
@@ -3361,7 +3373,7 @@ function di(e) {
|
|
|
3361
3373
|
}
|
|
3362
3374
|
//#endregion
|
|
3363
3375
|
//#region src/forms/remove.ts
|
|
3364
|
-
function
|
|
3376
|
+
function bi(e) {
|
|
3365
3377
|
return async (t, n) => {
|
|
3366
3378
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3367
3379
|
return r > 0;
|
|
@@ -3369,7 +3381,7 @@ function fi(e) {
|
|
|
3369
3381
|
}
|
|
3370
3382
|
//#endregion
|
|
3371
3383
|
//#region src/forms/get.ts
|
|
3372
|
-
function
|
|
3384
|
+
function xi(e) {
|
|
3373
3385
|
return async (t, n) => {
|
|
3374
3386
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3375
3387
|
if (!r) return null;
|
|
@@ -3388,7 +3400,7 @@ function pi(e) {
|
|
|
3388
3400
|
}
|
|
3389
3401
|
//#endregion
|
|
3390
3402
|
//#region src/forms/update.ts
|
|
3391
|
-
function
|
|
3403
|
+
function Si(e) {
|
|
3392
3404
|
return async (t, n, r) => {
|
|
3393
3405
|
let i = {
|
|
3394
3406
|
...r,
|
|
@@ -3405,22 +3417,22 @@ function mi(e) {
|
|
|
3405
3417
|
}
|
|
3406
3418
|
//#endregion
|
|
3407
3419
|
//#region src/forms/index.ts
|
|
3408
|
-
function
|
|
3420
|
+
function Ci(e) {
|
|
3409
3421
|
return {
|
|
3410
|
-
create:
|
|
3411
|
-
get:
|
|
3412
|
-
list:
|
|
3413
|
-
remove:
|
|
3414
|
-
update:
|
|
3422
|
+
create: vi(e),
|
|
3423
|
+
get: xi(e),
|
|
3424
|
+
list: yi(e),
|
|
3425
|
+
remove: bi(e),
|
|
3426
|
+
update: Si(e)
|
|
3415
3427
|
};
|
|
3416
3428
|
}
|
|
3417
3429
|
//#endregion
|
|
3418
3430
|
//#region src/resourceServers/create.ts
|
|
3419
|
-
function
|
|
3431
|
+
function wi(e) {
|
|
3420
3432
|
return async (t, n, r) => {
|
|
3421
3433
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3422
3434
|
...n,
|
|
3423
|
-
id: i?.id ?? n.id ??
|
|
3435
|
+
id: i?.id ?? n.id ?? Ne(),
|
|
3424
3436
|
created_at: o,
|
|
3425
3437
|
updated_at: s
|
|
3426
3438
|
}, u = de.parse(c), { verificationKey: d, scopes: f, options: p, skip_consent_for_verifiable_first_party_clients: m, allow_offline_access: h, is_system: g, metadata: _, ...v } = u, y = {
|
|
@@ -3441,7 +3453,7 @@ function gi(e) {
|
|
|
3441
3453
|
}
|
|
3442
3454
|
//#endregion
|
|
3443
3455
|
//#region src/resourceServers/get.ts
|
|
3444
|
-
function
|
|
3456
|
+
function Ti(e) {
|
|
3445
3457
|
return async (t, n) => {
|
|
3446
3458
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3447
3459
|
if (!r) return null;
|
|
@@ -3460,7 +3472,7 @@ function _i(e) {
|
|
|
3460
3472
|
}
|
|
3461
3473
|
//#endregion
|
|
3462
3474
|
//#region src/resourceServers/list.ts
|
|
3463
|
-
function
|
|
3475
|
+
function Ei(e) {
|
|
3464
3476
|
return async (t, n = {}) => {
|
|
3465
3477
|
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);
|
|
3466
3478
|
if (s) {
|
|
@@ -3500,7 +3512,7 @@ function vi(e) {
|
|
|
3500
3512
|
}
|
|
3501
3513
|
//#endregion
|
|
3502
3514
|
//#region src/resourceServers/remove.ts
|
|
3503
|
-
function
|
|
3515
|
+
function Di(e) {
|
|
3504
3516
|
return async (t, n) => {
|
|
3505
3517
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3506
3518
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3508,7 +3520,7 @@ function yi(e) {
|
|
|
3508
3520
|
}
|
|
3509
3521
|
//#endregion
|
|
3510
3522
|
//#region src/resourceServers/update.ts
|
|
3511
|
-
function
|
|
3523
|
+
function Oi(e) {
|
|
3512
3524
|
return async (t, n, r) => {
|
|
3513
3525
|
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 = {
|
|
3514
3526
|
...d,
|
|
@@ -3528,18 +3540,18 @@ function bi(e) {
|
|
|
3528
3540
|
}
|
|
3529
3541
|
//#endregion
|
|
3530
3542
|
//#region src/resourceServers/index.ts
|
|
3531
|
-
function
|
|
3543
|
+
function ki(e) {
|
|
3532
3544
|
return {
|
|
3533
|
-
create:
|
|
3534
|
-
get:
|
|
3535
|
-
list:
|
|
3536
|
-
remove:
|
|
3537
|
-
update:
|
|
3545
|
+
create: wi(e),
|
|
3546
|
+
get: Ti(e),
|
|
3547
|
+
list: Ei(e),
|
|
3548
|
+
remove: Di(e),
|
|
3549
|
+
update: Oi(e)
|
|
3538
3550
|
};
|
|
3539
3551
|
}
|
|
3540
3552
|
//#endregion
|
|
3541
3553
|
//#region src/roles/create.ts
|
|
3542
|
-
function
|
|
3554
|
+
function Ai(e) {
|
|
3543
3555
|
return async (n, r, i) => {
|
|
3544
3556
|
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 = {
|
|
3545
3557
|
id: l,
|
|
@@ -3562,7 +3574,7 @@ function Si(e) {
|
|
|
3562
3574
|
}
|
|
3563
3575
|
//#endregion
|
|
3564
3576
|
//#region src/roles/get.ts
|
|
3565
|
-
function
|
|
3577
|
+
function ji(e) {
|
|
3566
3578
|
return async (t, n) => {
|
|
3567
3579
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3568
3580
|
if (!r) return null;
|
|
@@ -3576,7 +3588,7 @@ function Ci(e) {
|
|
|
3576
3588
|
}
|
|
3577
3589
|
//#endregion
|
|
3578
3590
|
//#region src/roles/list.ts
|
|
3579
|
-
function
|
|
3591
|
+
function Mi(e) {
|
|
3580
3592
|
return async (t, n) => {
|
|
3581
3593
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3582
3594
|
n.q && (r = D(e, r, n.q, ["name"]));
|
|
@@ -3605,7 +3617,7 @@ function wi(e) {
|
|
|
3605
3617
|
}
|
|
3606
3618
|
//#endregion
|
|
3607
3619
|
//#region src/roles/update.ts
|
|
3608
|
-
function
|
|
3620
|
+
function Ni(e) {
|
|
3609
3621
|
return async (t, n, r) => {
|
|
3610
3622
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3611
3623
|
...o,
|
|
@@ -3618,7 +3630,7 @@ function Ti(e) {
|
|
|
3618
3630
|
}
|
|
3619
3631
|
//#endregion
|
|
3620
3632
|
//#region src/roles/remove.ts
|
|
3621
|
-
function
|
|
3633
|
+
function Pi(e) {
|
|
3622
3634
|
return async (t, n) => {
|
|
3623
3635
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3624
3636
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3626,23 +3638,23 @@ function Ei(e) {
|
|
|
3626
3638
|
}
|
|
3627
3639
|
//#endregion
|
|
3628
3640
|
//#region src/roles/index.ts
|
|
3629
|
-
function
|
|
3641
|
+
function Fi(e) {
|
|
3630
3642
|
return {
|
|
3631
|
-
create:
|
|
3632
|
-
get:
|
|
3633
|
-
list:
|
|
3634
|
-
update:
|
|
3635
|
-
remove:
|
|
3643
|
+
create: Ai(e),
|
|
3644
|
+
get: ji(e),
|
|
3645
|
+
list: Mi(e),
|
|
3646
|
+
update: Ni(e),
|
|
3647
|
+
remove: Pi(e)
|
|
3636
3648
|
};
|
|
3637
3649
|
}
|
|
3638
3650
|
//#endregion
|
|
3639
3651
|
//#region src/role-permissions/assign.ts
|
|
3640
|
-
function
|
|
3652
|
+
function Ii(e) {
|
|
3641
3653
|
if (typeof e != "object" || !e) return !1;
|
|
3642
3654
|
let { code: t, message: n } = e;
|
|
3643
3655
|
return t === "SQLITE_CONSTRAINT" || t === "SQLITE_CONSTRAINT_PRIMARYKEY" || t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || t === "23505" ? !0 : typeof n == "string" && (n.includes("UNIQUE constraint failed") || n.includes("Duplicate entry") || n.includes("duplicate key") || n.includes("AlreadyExists"));
|
|
3644
3656
|
}
|
|
3645
|
-
function
|
|
3657
|
+
function Li(e) {
|
|
3646
3658
|
return async (t, n, r, i) => {
|
|
3647
3659
|
if (r.length === 0) return !0;
|
|
3648
3660
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3659,7 +3671,7 @@ function ki(e) {
|
|
|
3659
3671
|
try {
|
|
3660
3672
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3661
3673
|
} catch (e) {
|
|
3662
|
-
if (
|
|
3674
|
+
if (Ii(e)) continue;
|
|
3663
3675
|
throw e;
|
|
3664
3676
|
}
|
|
3665
3677
|
}
|
|
@@ -3671,7 +3683,7 @@ function ki(e) {
|
|
|
3671
3683
|
}
|
|
3672
3684
|
//#endregion
|
|
3673
3685
|
//#region src/role-permissions/remove.ts
|
|
3674
|
-
function
|
|
3686
|
+
function Ri(e) {
|
|
3675
3687
|
return async (t, n, r) => {
|
|
3676
3688
|
if (r.length === 0) return !0;
|
|
3677
3689
|
try {
|
|
@@ -3683,7 +3695,7 @@ function Ai(e) {
|
|
|
3683
3695
|
}
|
|
3684
3696
|
//#endregion
|
|
3685
3697
|
//#region src/role-permissions/list.ts
|
|
3686
|
-
function
|
|
3698
|
+
function zi(e) {
|
|
3687
3699
|
return async (t, n, r = {}) => {
|
|
3688
3700
|
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([
|
|
3689
3701
|
"role_permissions.role_id",
|
|
@@ -3704,16 +3716,16 @@ function ji(e) {
|
|
|
3704
3716
|
}
|
|
3705
3717
|
//#endregion
|
|
3706
3718
|
//#region src/role-permissions/index.ts
|
|
3707
|
-
function
|
|
3719
|
+
function Bi(e) {
|
|
3708
3720
|
return {
|
|
3709
|
-
assign:
|
|
3710
|
-
remove:
|
|
3711
|
-
list:
|
|
3721
|
+
assign: Li(e),
|
|
3722
|
+
remove: Ri(e),
|
|
3723
|
+
list: zi(e)
|
|
3712
3724
|
};
|
|
3713
3725
|
}
|
|
3714
3726
|
//#endregion
|
|
3715
3727
|
//#region src/grants/create.ts
|
|
3716
|
-
function
|
|
3728
|
+
function Vi(e) {
|
|
3717
3729
|
return async (n, r) => {
|
|
3718
3730
|
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();
|
|
3719
3731
|
if (s) {
|
|
@@ -3750,7 +3762,7 @@ function Ni(e) {
|
|
|
3750
3762
|
}
|
|
3751
3763
|
//#endregion
|
|
3752
3764
|
//#region src/grants/get.ts
|
|
3753
|
-
function
|
|
3765
|
+
function Hi(e) {
|
|
3754
3766
|
return async (t, n, r, i) => {
|
|
3755
3767
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3756
3768
|
return a ? {
|
|
@@ -3764,7 +3776,7 @@ function Pi(e) {
|
|
|
3764
3776
|
}
|
|
3765
3777
|
//#endregion
|
|
3766
3778
|
//#region src/grants/list.ts
|
|
3767
|
-
function
|
|
3779
|
+
function Ui(e) {
|
|
3768
3780
|
return async (t, n = {}) => {
|
|
3769
3781
|
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);
|
|
3770
3782
|
c && (l = D(e, l, c, [
|
|
@@ -3802,26 +3814,26 @@ function Fi(e) {
|
|
|
3802
3814
|
}
|
|
3803
3815
|
//#endregion
|
|
3804
3816
|
//#region src/grants/remove.ts
|
|
3805
|
-
function
|
|
3817
|
+
function Wi(e) {
|
|
3806
3818
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3807
3819
|
}
|
|
3808
|
-
function
|
|
3820
|
+
function Gi(e) {
|
|
3809
3821
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3810
3822
|
}
|
|
3811
3823
|
//#endregion
|
|
3812
3824
|
//#region src/grants/index.ts
|
|
3813
|
-
function
|
|
3825
|
+
function Ki(e) {
|
|
3814
3826
|
return {
|
|
3815
|
-
create:
|
|
3816
|
-
get:
|
|
3817
|
-
list:
|
|
3818
|
-
remove:
|
|
3819
|
-
removeByUser:
|
|
3827
|
+
create: Vi(e),
|
|
3828
|
+
get: Hi(e),
|
|
3829
|
+
list: Ui(e),
|
|
3830
|
+
remove: Wi(e),
|
|
3831
|
+
removeByUser: Gi(e)
|
|
3820
3832
|
};
|
|
3821
3833
|
}
|
|
3822
3834
|
//#endregion
|
|
3823
3835
|
//#region src/user-permissions/create.ts
|
|
3824
|
-
function
|
|
3836
|
+
function qi(e) {
|
|
3825
3837
|
return async (t, n, r, i, a) => {
|
|
3826
3838
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3827
3839
|
try {
|
|
@@ -3841,7 +3853,7 @@ function zi(e) {
|
|
|
3841
3853
|
}
|
|
3842
3854
|
//#endregion
|
|
3843
3855
|
//#region src/user-permissions/remove.ts
|
|
3844
|
-
function
|
|
3856
|
+
function Ji(e) {
|
|
3845
3857
|
return async (t, n, r, i) => {
|
|
3846
3858
|
try {
|
|
3847
3859
|
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);
|
|
@@ -3853,7 +3865,7 @@ function Bi(e) {
|
|
|
3853
3865
|
}
|
|
3854
3866
|
//#endregion
|
|
3855
3867
|
//#region src/user-permissions/list.ts
|
|
3856
|
-
function
|
|
3868
|
+
function Yi(e) {
|
|
3857
3869
|
return async (t, n, r, i) => {
|
|
3858
3870
|
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([
|
|
3859
3871
|
"user_permissions.resource_server_identifier",
|
|
@@ -3876,17 +3888,17 @@ function Vi(e) {
|
|
|
3876
3888
|
}
|
|
3877
3889
|
//#endregion
|
|
3878
3890
|
//#region src/user-permissions/index.ts
|
|
3879
|
-
function
|
|
3891
|
+
function Xi(e) {
|
|
3880
3892
|
return {
|
|
3881
|
-
create:
|
|
3882
|
-
remove:
|
|
3883
|
-
list:
|
|
3893
|
+
create: qi(e),
|
|
3894
|
+
remove: Ji(e),
|
|
3895
|
+
list: Yi(e)
|
|
3884
3896
|
};
|
|
3885
3897
|
}
|
|
3886
3898
|
//#endregion
|
|
3887
3899
|
//#region src/user-permissions/adapter.ts
|
|
3888
|
-
function
|
|
3889
|
-
let t =
|
|
3900
|
+
function Zi(e) {
|
|
3901
|
+
let t = Xi(e);
|
|
3890
3902
|
return {
|
|
3891
3903
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3892
3904
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3895,7 +3907,7 @@ function Ui(e) {
|
|
|
3895
3907
|
}
|
|
3896
3908
|
//#endregion
|
|
3897
3909
|
//#region src/user-roles/list.ts
|
|
3898
|
-
function
|
|
3910
|
+
function Qi(e) {
|
|
3899
3911
|
return async (t, n, r, i) => {
|
|
3900
3912
|
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([
|
|
3901
3913
|
"r.id",
|
|
@@ -3909,7 +3921,7 @@ function Wi(e) {
|
|
|
3909
3921
|
}
|
|
3910
3922
|
//#endregion
|
|
3911
3923
|
//#region src/user-roles/list-users.ts
|
|
3912
|
-
function
|
|
3924
|
+
function $i(e) {
|
|
3913
3925
|
return async (t, n, r) => {
|
|
3914
3926
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3915
3927
|
if (M(r)) {
|
|
@@ -3937,7 +3949,7 @@ function Gi(e) {
|
|
|
3937
3949
|
}
|
|
3938
3950
|
//#endregion
|
|
3939
3951
|
//#region src/user-roles/create.ts
|
|
3940
|
-
function
|
|
3952
|
+
function ea(e) {
|
|
3941
3953
|
return async (t, n, r, i, a) => {
|
|
3942
3954
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3943
3955
|
try {
|
|
@@ -3955,7 +3967,7 @@ function Ki(e) {
|
|
|
3955
3967
|
}
|
|
3956
3968
|
//#endregion
|
|
3957
3969
|
//#region src/user-roles/remove.ts
|
|
3958
|
-
function
|
|
3970
|
+
function ta(e) {
|
|
3959
3971
|
return async (t, n, r, i) => {
|
|
3960
3972
|
try {
|
|
3961
3973
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3967,18 +3979,18 @@ function qi(e) {
|
|
|
3967
3979
|
}
|
|
3968
3980
|
//#endregion
|
|
3969
3981
|
//#region src/user-roles/index.ts
|
|
3970
|
-
function
|
|
3982
|
+
function na(e) {
|
|
3971
3983
|
return {
|
|
3972
|
-
list:
|
|
3973
|
-
listUsers:
|
|
3974
|
-
create:
|
|
3975
|
-
remove:
|
|
3984
|
+
list: Qi(e),
|
|
3985
|
+
listUsers: $i(e),
|
|
3986
|
+
create: ea(e),
|
|
3987
|
+
remove: ta(e)
|
|
3976
3988
|
};
|
|
3977
3989
|
}
|
|
3978
3990
|
//#endregion
|
|
3979
3991
|
//#region src/user-roles/adapter.ts
|
|
3980
|
-
function
|
|
3981
|
-
let t =
|
|
3992
|
+
function ra(e) {
|
|
3993
|
+
let t = na(e);
|
|
3982
3994
|
return {
|
|
3983
3995
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3984
3996
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3988,11 +4000,11 @@ function Yi(e) {
|
|
|
3988
4000
|
}
|
|
3989
4001
|
//#endregion
|
|
3990
4002
|
//#region src/organizations/create.ts
|
|
3991
|
-
function
|
|
4003
|
+
function ia(e) {
|
|
3992
4004
|
return async (t, n, r) => {
|
|
3993
4005
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3994
4006
|
...n,
|
|
3995
|
-
id: i?.id || n.id ||
|
|
4007
|
+
id: i?.id || n.id || Oe(),
|
|
3996
4008
|
tenant_id: t,
|
|
3997
4009
|
created_at: i?.created_at ?? a,
|
|
3998
4010
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4016,7 +4028,7 @@ function Xi(e) {
|
|
|
4016
4028
|
}
|
|
4017
4029
|
//#endregion
|
|
4018
4030
|
//#region src/organizations/get.ts
|
|
4019
|
-
function
|
|
4031
|
+
function aa(e) {
|
|
4020
4032
|
return async (t, n) => {
|
|
4021
4033
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4022
4034
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4030,13 +4042,13 @@ function Zi(e) {
|
|
|
4030
4042
|
}
|
|
4031
4043
|
//#endregion
|
|
4032
4044
|
//#region src/organizations/list.ts
|
|
4033
|
-
var
|
|
4034
|
-
function
|
|
4045
|
+
var R = ["name", "display_name"];
|
|
4046
|
+
function oa(e) {
|
|
4035
4047
|
return async (t, n) => {
|
|
4036
4048
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4037
4049
|
if (n?.q) {
|
|
4038
|
-
let t = S(n.q,
|
|
4039
|
-
t && (r = D(e, r, t,
|
|
4050
|
+
let t = S(n.q, R);
|
|
4051
|
+
t && (r = D(e, r, t, R));
|
|
4040
4052
|
}
|
|
4041
4053
|
if (M(n)) {
|
|
4042
4054
|
let { rows: e, limit: t, next: i } = await N(r.selectAll(), n, {
|
|
@@ -4072,8 +4084,8 @@ function Qi(e) {
|
|
|
4072
4084
|
if (n?.include_totals) {
|
|
4073
4085
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4074
4086
|
if (n?.q) {
|
|
4075
|
-
let t = S(n.q,
|
|
4076
|
-
t && (r = D(e, r, t,
|
|
4087
|
+
let t = S(n.q, R);
|
|
4088
|
+
t && (r = D(e, r, t, R));
|
|
4077
4089
|
}
|
|
4078
4090
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4079
4091
|
u = Number(i?.count || 0);
|
|
@@ -4096,12 +4108,12 @@ function Qi(e) {
|
|
|
4096
4108
|
}
|
|
4097
4109
|
//#endregion
|
|
4098
4110
|
//#region src/organizations/remove.ts
|
|
4099
|
-
function
|
|
4111
|
+
function sa(e) {
|
|
4100
4112
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4101
4113
|
}
|
|
4102
4114
|
//#endregion
|
|
4103
4115
|
//#region src/organizations/update.ts
|
|
4104
|
-
function
|
|
4116
|
+
function ca(e) {
|
|
4105
4117
|
return async (t, n, r) => {
|
|
4106
4118
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4107
4119
|
...c,
|
|
@@ -4117,18 +4129,18 @@ function ea(e) {
|
|
|
4117
4129
|
}
|
|
4118
4130
|
//#endregion
|
|
4119
4131
|
//#region src/organizations/index.ts
|
|
4120
|
-
function
|
|
4132
|
+
function la(e) {
|
|
4121
4133
|
return {
|
|
4122
|
-
create:
|
|
4123
|
-
get:
|
|
4124
|
-
list:
|
|
4125
|
-
remove:
|
|
4126
|
-
update:
|
|
4134
|
+
create: ia(e),
|
|
4135
|
+
get: aa(e),
|
|
4136
|
+
list: oa(e),
|
|
4137
|
+
remove: sa(e),
|
|
4138
|
+
update: ca(e)
|
|
4127
4139
|
};
|
|
4128
4140
|
}
|
|
4129
4141
|
//#endregion
|
|
4130
4142
|
//#region src/organization-connections/index.ts
|
|
4131
|
-
function
|
|
4143
|
+
function z(e, t) {
|
|
4132
4144
|
return {
|
|
4133
4145
|
connection_id: e.connection_id,
|
|
4134
4146
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4142,14 +4154,14 @@ function H(e, t) {
|
|
|
4142
4154
|
updated_at: e.updated_at
|
|
4143
4155
|
};
|
|
4144
4156
|
}
|
|
4145
|
-
async function
|
|
4157
|
+
async function B(e, t, n) {
|
|
4146
4158
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4147
4159
|
if (r) return {
|
|
4148
4160
|
name: r.name,
|
|
4149
4161
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4150
4162
|
};
|
|
4151
4163
|
}
|
|
4152
|
-
function
|
|
4164
|
+
function ua(e) {
|
|
4153
4165
|
return {
|
|
4154
4166
|
async create(t, n, r, i) {
|
|
4155
4167
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4162,19 +4174,19 @@ function na(e) {
|
|
|
4162
4174
|
created_at: a?.created_at ?? o,
|
|
4163
4175
|
updated_at: a?.updated_at ?? o
|
|
4164
4176
|
};
|
|
4165
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4177
|
+
return await e.insertInto("organization_connections").values(s).execute(), z(s, await B(e, t, r.connection_id));
|
|
4166
4178
|
},
|
|
4167
4179
|
async list(t, n) {
|
|
4168
4180
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4169
4181
|
for (let n of r) {
|
|
4170
|
-
let r = await
|
|
4171
|
-
i.push(
|
|
4182
|
+
let r = await B(e, t, n.connection_id);
|
|
4183
|
+
i.push(z(n, r));
|
|
4172
4184
|
}
|
|
4173
4185
|
return i;
|
|
4174
4186
|
},
|
|
4175
4187
|
async get(t, n, r) {
|
|
4176
4188
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4177
|
-
return i ?
|
|
4189
|
+
return i ? z(i, await B(e, t, r)) : null;
|
|
4178
4190
|
},
|
|
4179
4191
|
async update(t, n, r, i) {
|
|
4180
4192
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4182,7 +4194,7 @@ function na(e) {
|
|
|
4182
4194
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4183
4195
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4184
4196
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4185
|
-
return s ?
|
|
4197
|
+
return s ? z(s, await B(e, t, r)) : null;
|
|
4186
4198
|
},
|
|
4187
4199
|
async remove(t, n, r) {
|
|
4188
4200
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4192,7 +4204,7 @@ function na(e) {
|
|
|
4192
4204
|
}
|
|
4193
4205
|
//#endregion
|
|
4194
4206
|
//#region src/user-organizations/create.ts
|
|
4195
|
-
function
|
|
4207
|
+
function da(e) {
|
|
4196
4208
|
return async (n, r, i) => {
|
|
4197
4209
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4198
4210
|
id: a?.id ?? t(),
|
|
@@ -4212,7 +4224,7 @@ function ra(e) {
|
|
|
4212
4224
|
}
|
|
4213
4225
|
//#endregion
|
|
4214
4226
|
//#region src/user-organizations/get.ts
|
|
4215
|
-
function
|
|
4227
|
+
function fa(e) {
|
|
4216
4228
|
return async (t, n) => {
|
|
4217
4229
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4218
4230
|
return r ? {
|
|
@@ -4226,18 +4238,13 @@ function ia(e) {
|
|
|
4226
4238
|
}
|
|
4227
4239
|
//#endregion
|
|
4228
4240
|
//#region src/user-organizations/list.ts
|
|
4229
|
-
function
|
|
4241
|
+
function V(e, t) {
|
|
4242
|
+
return Ce(e.slice(t.length + 1));
|
|
4243
|
+
}
|
|
4244
|
+
function pa(e) {
|
|
4230
4245
|
return async (t, n) => {
|
|
4231
4246
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4232
|
-
|
|
4233
|
-
if (n.q.startsWith("user_id:")) {
|
|
4234
|
-
let e = n.q.replace("user_id:", "");
|
|
4235
|
-
r = r.where("user_id", "=", e);
|
|
4236
|
-
} else if (n.q.startsWith("organization_id:")) {
|
|
4237
|
-
let e = n.q.replace("organization_id:", "");
|
|
4238
|
-
r = r.where("organization_id", "=", e);
|
|
4239
|
-
}
|
|
4240
|
-
}
|
|
4247
|
+
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", V(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", V(n.q, "organization_id"))));
|
|
4241
4248
|
let i = (e) => ({
|
|
4242
4249
|
id: e.id,
|
|
4243
4250
|
user_id: e.user_id,
|
|
@@ -4259,15 +4266,7 @@ function aa(e) {
|
|
|
4259
4266
|
};
|
|
4260
4267
|
}
|
|
4261
4268
|
let a = n?.page || 0, o = n?.per_page || 50, s = a * o, c = await r.orderBy("created_at", "desc").limit(o).offset(s).execute(), l = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
|
|
4262
|
-
|
|
4263
|
-
if (n.q.startsWith("user_id:")) {
|
|
4264
|
-
let e = n.q.replace("user_id:", "");
|
|
4265
|
-
l = l.where("user_id", "=", e);
|
|
4266
|
-
} else if (n.q.startsWith("organization_id:")) {
|
|
4267
|
-
let e = n.q.replace("organization_id:", "");
|
|
4268
|
-
l = l.where("organization_id", "=", e);
|
|
4269
|
-
}
|
|
4270
|
-
}
|
|
4269
|
+
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=", V(n.q, "user_id")) : n.q.startsWith("organization_id:") && (l = l.where("organization_id", "=", V(n.q, "organization_id"))));
|
|
4271
4270
|
let u = await l.executeTakeFirst();
|
|
4272
4271
|
return {
|
|
4273
4272
|
userOrganizations: c.map(i),
|
|
@@ -4279,7 +4278,7 @@ function aa(e) {
|
|
|
4279
4278
|
}
|
|
4280
4279
|
//#endregion
|
|
4281
4280
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4282
|
-
function
|
|
4281
|
+
function ma(e) {
|
|
4283
4282
|
return async (t, n, r) => {
|
|
4284
4283
|
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([
|
|
4285
4284
|
"organizations.id",
|
|
@@ -4316,12 +4315,12 @@ function oa(e) {
|
|
|
4316
4315
|
}
|
|
4317
4316
|
//#endregion
|
|
4318
4317
|
//#region src/user-organizations/remove.ts
|
|
4319
|
-
function
|
|
4318
|
+
function ha(e) {
|
|
4320
4319
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4321
4320
|
}
|
|
4322
4321
|
//#endregion
|
|
4323
4322
|
//#region src/user-organizations/update.ts
|
|
4324
|
-
function
|
|
4323
|
+
function ga(e) {
|
|
4325
4324
|
return async (t, n, r) => {
|
|
4326
4325
|
let i = {
|
|
4327
4326
|
...r,
|
|
@@ -4332,21 +4331,21 @@ function ca(e) {
|
|
|
4332
4331
|
}
|
|
4333
4332
|
//#endregion
|
|
4334
4333
|
//#region src/user-organizations/index.ts
|
|
4335
|
-
function
|
|
4334
|
+
function _a(e) {
|
|
4336
4335
|
return {
|
|
4337
|
-
create:
|
|
4338
|
-
get:
|
|
4339
|
-
list:
|
|
4340
|
-
listUserOrganizations:
|
|
4341
|
-
remove:
|
|
4342
|
-
update:
|
|
4336
|
+
create: da(e),
|
|
4337
|
+
get: fa(e),
|
|
4338
|
+
list: pa(e),
|
|
4339
|
+
listUserOrganizations: ma(e),
|
|
4340
|
+
remove: ha(e),
|
|
4341
|
+
update: ga(e)
|
|
4343
4342
|
};
|
|
4344
4343
|
}
|
|
4345
4344
|
//#endregion
|
|
4346
4345
|
//#region src/invites/create.ts
|
|
4347
|
-
function
|
|
4346
|
+
function va(e) {
|
|
4348
4347
|
return async (t, n, r) => {
|
|
4349
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4348
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Fe(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4350
4349
|
id: a,
|
|
4351
4350
|
tenant_id: t,
|
|
4352
4351
|
organization_id: n.organization_id,
|
|
@@ -4390,11 +4389,11 @@ function ua(e) {
|
|
|
4390
4389
|
}
|
|
4391
4390
|
//#endregion
|
|
4392
4391
|
//#region src/invites/get.ts
|
|
4393
|
-
function
|
|
4392
|
+
function ya(e) {
|
|
4394
4393
|
return async (t, n) => {
|
|
4395
4394
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4396
4395
|
return r ? l({
|
|
4397
|
-
...
|
|
4396
|
+
...bt(r, {
|
|
4398
4397
|
inviter: {},
|
|
4399
4398
|
invitee: {},
|
|
4400
4399
|
app_metadata: {},
|
|
@@ -4407,7 +4406,7 @@ function da(e) {
|
|
|
4407
4406
|
}
|
|
4408
4407
|
//#endregion
|
|
4409
4408
|
//#region src/invites/list.ts
|
|
4410
|
-
function
|
|
4409
|
+
function ba(e) {
|
|
4411
4410
|
return async (t, n) => {
|
|
4412
4411
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4413
4412
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4415,7 +4414,7 @@ function fa(e) {
|
|
|
4415
4414
|
r = r.offset(e);
|
|
4416
4415
|
}
|
|
4417
4416
|
let i = (await r.execute()).map((e) => l({
|
|
4418
|
-
...
|
|
4417
|
+
...bt(e, {
|
|
4419
4418
|
inviter: {},
|
|
4420
4419
|
invitee: {},
|
|
4421
4420
|
app_metadata: {},
|
|
@@ -4434,12 +4433,12 @@ function fa(e) {
|
|
|
4434
4433
|
}
|
|
4435
4434
|
//#endregion
|
|
4436
4435
|
//#region src/invites/remove.ts
|
|
4437
|
-
function
|
|
4436
|
+
function xa(e) {
|
|
4438
4437
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4439
4438
|
}
|
|
4440
4439
|
//#endregion
|
|
4441
4440
|
//#region src/invites/update.ts
|
|
4442
|
-
function
|
|
4441
|
+
function Sa(e) {
|
|
4443
4442
|
return async (t, n, r) => {
|
|
4444
4443
|
let i = {};
|
|
4445
4444
|
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;
|
|
@@ -4447,35 +4446,35 @@ function ma(e) {
|
|
|
4447
4446
|
}
|
|
4448
4447
|
//#endregion
|
|
4449
4448
|
//#region src/invites/index.ts
|
|
4450
|
-
function
|
|
4449
|
+
function Ca(e) {
|
|
4451
4450
|
return {
|
|
4452
|
-
create:
|
|
4453
|
-
get:
|
|
4454
|
-
list:
|
|
4455
|
-
remove:
|
|
4456
|
-
update:
|
|
4451
|
+
create: va(e),
|
|
4452
|
+
get: ya(e),
|
|
4453
|
+
list: ba(e),
|
|
4454
|
+
remove: xa(e),
|
|
4455
|
+
update: Sa(e)
|
|
4457
4456
|
};
|
|
4458
4457
|
}
|
|
4459
4458
|
//#endregion
|
|
4460
4459
|
//#region src/stats/index.ts
|
|
4461
|
-
var
|
|
4462
|
-
function
|
|
4460
|
+
var wa = ["s"], Ta = ["pwd_leak"];
|
|
4461
|
+
function Ea(e) {
|
|
4463
4462
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4464
4463
|
}
|
|
4465
|
-
function
|
|
4464
|
+
function Da(e) {
|
|
4466
4465
|
return e.toISOString().split("T")[0];
|
|
4467
4466
|
}
|
|
4468
|
-
function
|
|
4467
|
+
function Oa(e) {
|
|
4469
4468
|
return {
|
|
4470
4469
|
async getDaily(t, n = {}) {
|
|
4471
4470
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4472
4471
|
o.setDate(o.getDate() - 30);
|
|
4473
|
-
let s = r ?
|
|
4472
|
+
let s = r ? Ea(r) : Da(o), c = i ? Ea(i) : Da(a), l = f`DATE(logs.date)`;
|
|
4474
4473
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4475
4474
|
l.as("date"),
|
|
4476
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4475
|
+
e.fn.sum(e.case().when("type", "in", wa).then(1).else(0).end()).as("logins"),
|
|
4477
4476
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4478
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4477
|
+
e.fn.sum(e.case().when("type", "in", Ta).then(1).else(0).end()).as("leaked_passwords"),
|
|
4479
4478
|
e.fn.min("date").as("first_event"),
|
|
4480
4479
|
e.fn.max("date").as("last_event")
|
|
4481
4480
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4489,13 +4488,13 @@ function ba(e) {
|
|
|
4489
4488
|
},
|
|
4490
4489
|
async getActiveUsers(t) {
|
|
4491
4490
|
let n = /* @__PURE__ */ new Date();
|
|
4492
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4491
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", wa).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4493
4492
|
}
|
|
4494
4493
|
};
|
|
4495
4494
|
}
|
|
4496
4495
|
//#endregion
|
|
4497
4496
|
//#region src/analytics/index.ts
|
|
4498
|
-
var
|
|
4497
|
+
var ka = {
|
|
4499
4498
|
"active-users": ["s", "seacft"],
|
|
4500
4499
|
logins: [
|
|
4501
4500
|
"s",
|
|
@@ -4525,7 +4524,7 @@ var xa = {
|
|
|
4525
4524
|
"fvr"
|
|
4526
4525
|
],
|
|
4527
4526
|
"codes-sent": ["cls", "cs"]
|
|
4528
|
-
},
|
|
4527
|
+
}, Aa = {
|
|
4529
4528
|
"active-users": {
|
|
4530
4529
|
alias: "active_users",
|
|
4531
4530
|
type: "UInt64",
|
|
@@ -4582,14 +4581,14 @@ var xa = {
|
|
|
4582
4581
|
agg: "count"
|
|
4583
4582
|
}
|
|
4584
4583
|
};
|
|
4585
|
-
async function
|
|
4584
|
+
async function ja(e) {
|
|
4586
4585
|
try {
|
|
4587
4586
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4588
4587
|
} catch {
|
|
4589
4588
|
return "sqlite";
|
|
4590
4589
|
}
|
|
4591
4590
|
}
|
|
4592
|
-
function
|
|
4591
|
+
function H(e, t) {
|
|
4593
4592
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4594
4593
|
timeZone: e,
|
|
4595
4594
|
year: "numeric",
|
|
@@ -4604,7 +4603,7 @@ function W(e, t) {
|
|
|
4604
4603
|
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);
|
|
4605
4604
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4606
4605
|
}
|
|
4607
|
-
var
|
|
4606
|
+
var Ma = [
|
|
4608
4607
|
"January",
|
|
4609
4608
|
"February",
|
|
4610
4609
|
"March",
|
|
@@ -4618,22 +4617,22 @@ var wa = [
|
|
|
4618
4617
|
"November",
|
|
4619
4618
|
"December"
|
|
4620
4619
|
];
|
|
4621
|
-
function
|
|
4622
|
-
let n = t.getUTCFullYear(), r =
|
|
4620
|
+
function Na(e, t) {
|
|
4621
|
+
let n = t.getUTCFullYear(), r = H(e, new Date(Date.UTC(n, 0, 1)));
|
|
4623
4622
|
for (let t = 1; t < 12; t++) {
|
|
4624
|
-
let i =
|
|
4625
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4623
|
+
let i = H(e, new Date(Date.UTC(n, t, 1)));
|
|
4624
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ma[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').`);
|
|
4626
4625
|
}
|
|
4627
4626
|
}
|
|
4628
|
-
function
|
|
4627
|
+
function Pa(e) {
|
|
4629
4628
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4630
4629
|
return t * (Number(n) * 60 + Number(r));
|
|
4631
4630
|
}
|
|
4632
|
-
function
|
|
4631
|
+
function Fa(e, t) {
|
|
4633
4632
|
let n;
|
|
4634
4633
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4635
4634
|
else {
|
|
4636
|
-
let e =
|
|
4635
|
+
let e = Pa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4637
4636
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4638
4637
|
}
|
|
4639
4638
|
switch (e) {
|
|
@@ -4644,7 +4643,7 @@ function Da(e, t) {
|
|
|
4644
4643
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4645
4644
|
}
|
|
4646
4645
|
}
|
|
4647
|
-
function
|
|
4646
|
+
function Ia(e, t) {
|
|
4648
4647
|
if (t === "+00:00") switch (e) {
|
|
4649
4648
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4650
4649
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4655,7 +4654,7 @@ function Oa(e, t) {
|
|
|
4655
4654
|
}
|
|
4656
4655
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4657
4656
|
}
|
|
4658
|
-
let n =
|
|
4657
|
+
let n = Pa(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)`;
|
|
4659
4658
|
switch (e) {
|
|
4660
4659
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4661
4660
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4664,12 +4663,12 @@ function Oa(e, t) {
|
|
|
4664
4663
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4665
4664
|
}
|
|
4666
4665
|
}
|
|
4667
|
-
function
|
|
4668
|
-
|
|
4669
|
-
let i =
|
|
4670
|
-
return r === "mysql" ?
|
|
4666
|
+
function La(e, t, n, r) {
|
|
4667
|
+
Na(t, n);
|
|
4668
|
+
let i = H(t, n);
|
|
4669
|
+
return r === "mysql" ? Ia(e, i) : Fa(e, i);
|
|
4671
4670
|
}
|
|
4672
|
-
function
|
|
4671
|
+
function Ra(e) {
|
|
4673
4672
|
switch (e) {
|
|
4674
4673
|
case "connection": return "logs.connection";
|
|
4675
4674
|
case "client_id": return "logs.client_id";
|
|
@@ -4678,15 +4677,15 @@ function Aa(e) {
|
|
|
4678
4677
|
case "time": throw Error("time dimension is handled separately");
|
|
4679
4678
|
}
|
|
4680
4679
|
}
|
|
4681
|
-
function
|
|
4682
|
-
let t = null, n = () => (t ||=
|
|
4680
|
+
function za(e) {
|
|
4681
|
+
let t = null, n = () => (t ||= ja(e), t);
|
|
4683
4682
|
return {
|
|
4684
4683
|
async query(t, r, i) {
|
|
4685
|
-
let a = Date.now(), o =
|
|
4684
|
+
let a = Date.now(), o = ka[r], s = Aa[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4686
4685
|
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));
|
|
4687
4686
|
let d = [], p = [];
|
|
4688
4687
|
for (let e of i.group_by) if (e === "time") {
|
|
4689
|
-
let e =
|
|
4688
|
+
let e = La(i.interval, i.tz, new Date(i.from), c);
|
|
4690
4689
|
p.push({
|
|
4691
4690
|
alias: "time",
|
|
4692
4691
|
expr: e
|
|
@@ -4695,7 +4694,7 @@ function ja(e) {
|
|
|
4695
4694
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4696
4695
|
});
|
|
4697
4696
|
} else {
|
|
4698
|
-
let t =
|
|
4697
|
+
let t = Ra(e);
|
|
4699
4698
|
p.push({
|
|
4700
4699
|
alias: e,
|
|
4701
4700
|
expr: f`${f.ref(t)}`
|
|
@@ -4770,7 +4769,7 @@ function ja(e) {
|
|
|
4770
4769
|
}
|
|
4771
4770
|
//#endregion
|
|
4772
4771
|
//#region src/customText/index.ts
|
|
4773
|
-
function
|
|
4772
|
+
function Ba(e) {
|
|
4774
4773
|
return {
|
|
4775
4774
|
async get(t, n, r) {
|
|
4776
4775
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4809,9 +4808,9 @@ function Ma(e) {
|
|
|
4809
4808
|
}
|
|
4810
4809
|
//#endregion
|
|
4811
4810
|
//#region src/authenticationMethods/create.ts
|
|
4812
|
-
function
|
|
4811
|
+
function Va(e) {
|
|
4813
4812
|
return async (t, n, r) => {
|
|
4814
|
-
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 ??
|
|
4813
|
+
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 ?? Rr();
|
|
4815
4814
|
return await e.insertInto("authentication_methods").values({
|
|
4816
4815
|
id: s,
|
|
4817
4816
|
tenant_id: t,
|
|
@@ -4848,7 +4847,7 @@ function Na(e) {
|
|
|
4848
4847
|
}
|
|
4849
4848
|
//#endregion
|
|
4850
4849
|
//#region src/authenticationMethods/get.ts
|
|
4851
|
-
function
|
|
4850
|
+
function Ha(e) {
|
|
4852
4851
|
return async (t, n) => {
|
|
4853
4852
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4854
4853
|
return r ? {
|
|
@@ -4871,7 +4870,7 @@ function Pa(e) {
|
|
|
4871
4870
|
}
|
|
4872
4871
|
//#endregion
|
|
4873
4872
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4874
|
-
function
|
|
4873
|
+
function Ua(e) {
|
|
4875
4874
|
return async (t, n) => {
|
|
4876
4875
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4877
4876
|
return r ? {
|
|
@@ -4894,7 +4893,7 @@ function Fa(e) {
|
|
|
4894
4893
|
}
|
|
4895
4894
|
//#endregion
|
|
4896
4895
|
//#region src/authenticationMethods/list.ts
|
|
4897
|
-
function
|
|
4896
|
+
function Wa(e) {
|
|
4898
4897
|
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) => ({
|
|
4899
4898
|
id: e.id,
|
|
4900
4899
|
user_id: e.user_id,
|
|
@@ -4914,35 +4913,35 @@ function Ia(e) {
|
|
|
4914
4913
|
}
|
|
4915
4914
|
//#endregion
|
|
4916
4915
|
//#region src/authenticationMethods/update.ts
|
|
4917
|
-
function
|
|
4916
|
+
function Ga(e) {
|
|
4918
4917
|
return async (t, n, r) => {
|
|
4919
4918
|
let i = { updated_at_ts: Date.now() };
|
|
4920
4919
|
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();
|
|
4921
|
-
let a = await
|
|
4920
|
+
let a = await Ha(e)(t, n);
|
|
4922
4921
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4923
4922
|
return a;
|
|
4924
4923
|
};
|
|
4925
4924
|
}
|
|
4926
4925
|
//#endregion
|
|
4927
4926
|
//#region src/authenticationMethods/remove.ts
|
|
4928
|
-
function
|
|
4927
|
+
function Ka(e) {
|
|
4929
4928
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4930
4929
|
}
|
|
4931
4930
|
//#endregion
|
|
4932
4931
|
//#region src/authenticationMethods/index.ts
|
|
4933
|
-
function
|
|
4932
|
+
function qa(e) {
|
|
4934
4933
|
return {
|
|
4935
|
-
create:
|
|
4936
|
-
get:
|
|
4937
|
-
getByCredentialId:
|
|
4938
|
-
list:
|
|
4939
|
-
update:
|
|
4940
|
-
remove:
|
|
4934
|
+
create: Va(e),
|
|
4935
|
+
get: Ha(e),
|
|
4936
|
+
getByCredentialId: Ua(e),
|
|
4937
|
+
list: Wa(e),
|
|
4938
|
+
update: Ga(e),
|
|
4939
|
+
remove: Ka(e)
|
|
4941
4940
|
};
|
|
4942
4941
|
}
|
|
4943
4942
|
//#endregion
|
|
4944
4943
|
//#region src/outbox/getByIds.ts
|
|
4945
|
-
function
|
|
4944
|
+
function Ja(e) {
|
|
4946
4945
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4947
4946
|
...JSON.parse(e.payload),
|
|
4948
4947
|
id: e.id,
|
|
@@ -4955,7 +4954,7 @@ function Ba(e) {
|
|
|
4955
4954
|
}
|
|
4956
4955
|
//#endregion
|
|
4957
4956
|
//#region src/outbox/getUnprocessed.ts
|
|
4958
|
-
function
|
|
4957
|
+
function Ya(e) {
|
|
4959
4958
|
return async (t) => {
|
|
4960
4959
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4961
4960
|
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) => ({
|
|
@@ -4971,7 +4970,7 @@ function Va(e) {
|
|
|
4971
4970
|
}
|
|
4972
4971
|
//#endregion
|
|
4973
4972
|
//#region src/outbox/claimEvents.ts
|
|
4974
|
-
function
|
|
4973
|
+
function Xa(e) {
|
|
4975
4974
|
return async (t, n, r) => {
|
|
4976
4975
|
if (t.length === 0) return [];
|
|
4977
4976
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4983,7 +4982,7 @@ function Ha(e) {
|
|
|
4983
4982
|
}
|
|
4984
4983
|
//#endregion
|
|
4985
4984
|
//#region src/outbox/markProcessed.ts
|
|
4986
|
-
function
|
|
4985
|
+
function Za(e) {
|
|
4987
4986
|
return async (t) => {
|
|
4988
4987
|
if (t.length === 0) return;
|
|
4989
4988
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4992,7 +4991,7 @@ function Ua(e) {
|
|
|
4992
4991
|
}
|
|
4993
4992
|
//#endregion
|
|
4994
4993
|
//#region src/outbox/markRetry.ts
|
|
4995
|
-
function
|
|
4994
|
+
function Qa(e) {
|
|
4996
4995
|
return async (t, n, r) => {
|
|
4997
4996
|
await e.updateTable("outbox_events").set({
|
|
4998
4997
|
error: n,
|
|
@@ -5005,7 +5004,7 @@ function Wa(e) {
|
|
|
5005
5004
|
}
|
|
5006
5005
|
//#endregion
|
|
5007
5006
|
//#region src/outbox/deadLetter.ts
|
|
5008
|
-
function
|
|
5007
|
+
function $a(e) {
|
|
5009
5008
|
return async (t, n) => {
|
|
5010
5009
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5011
5010
|
await e.updateTable("outbox_events").set({
|
|
@@ -5017,7 +5016,7 @@ function Ga(e) {
|
|
|
5017
5016
|
}
|
|
5018
5017
|
//#endregion
|
|
5019
5018
|
//#region src/outbox/listFailed.ts
|
|
5020
|
-
function
|
|
5019
|
+
function eo(e) {
|
|
5021
5020
|
return async (t, n = {}) => {
|
|
5022
5021
|
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) => {
|
|
5023
5022
|
let t;
|
|
@@ -5052,7 +5051,7 @@ function Ka(e) {
|
|
|
5052
5051
|
}
|
|
5053
5052
|
//#endregion
|
|
5054
5053
|
//#region src/outbox/replay.ts
|
|
5055
|
-
function
|
|
5054
|
+
function to(e) {
|
|
5056
5055
|
return async (t, n) => {
|
|
5057
5056
|
let r = await e.updateTable("outbox_events").set({
|
|
5058
5057
|
processed_at: null,
|
|
@@ -5067,7 +5066,7 @@ function qa(e) {
|
|
|
5067
5066
|
}
|
|
5068
5067
|
//#endregion
|
|
5069
5068
|
//#region src/outbox/cleanup.ts
|
|
5070
|
-
function
|
|
5069
|
+
function no(e) {
|
|
5071
5070
|
return async (t) => {
|
|
5072
5071
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5073
5072
|
return Number(n.numDeletedRows);
|
|
@@ -5075,23 +5074,23 @@ function Ja(e) {
|
|
|
5075
5074
|
}
|
|
5076
5075
|
//#endregion
|
|
5077
5076
|
//#region src/outbox/index.ts
|
|
5078
|
-
function
|
|
5077
|
+
function ro(e) {
|
|
5079
5078
|
return {
|
|
5080
|
-
create:
|
|
5081
|
-
getByIds:
|
|
5082
|
-
getUnprocessed:
|
|
5083
|
-
claimEvents:
|
|
5084
|
-
markProcessed:
|
|
5085
|
-
markRetry:
|
|
5086
|
-
deadLetter:
|
|
5087
|
-
listFailed:
|
|
5088
|
-
replay:
|
|
5089
|
-
cleanup:
|
|
5079
|
+
create: $e(e),
|
|
5080
|
+
getByIds: Ja(e),
|
|
5081
|
+
getUnprocessed: Ya(e),
|
|
5082
|
+
claimEvents: Xa(e),
|
|
5083
|
+
markProcessed: Za(e),
|
|
5084
|
+
markRetry: Qa(e),
|
|
5085
|
+
deadLetter: $a(e),
|
|
5086
|
+
listFailed: eo(e),
|
|
5087
|
+
replay: to(e),
|
|
5088
|
+
cleanup: no(e)
|
|
5090
5089
|
};
|
|
5091
5090
|
}
|
|
5092
5091
|
//#endregion
|
|
5093
5092
|
//#region src/log-streams/index.ts
|
|
5094
|
-
function
|
|
5093
|
+
function U(e) {
|
|
5095
5094
|
return {
|
|
5096
5095
|
id: e.id,
|
|
5097
5096
|
name: e.name,
|
|
@@ -5104,7 +5103,7 @@ function G(e) {
|
|
|
5104
5103
|
updated_at: e.updated_at
|
|
5105
5104
|
};
|
|
5106
5105
|
}
|
|
5107
|
-
function
|
|
5106
|
+
function io(e) {
|
|
5108
5107
|
return {
|
|
5109
5108
|
async create(n, r, i) {
|
|
5110
5109
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5119,14 +5118,14 @@ function Xa(e) {
|
|
|
5119
5118
|
created_at: a?.created_at ?? o,
|
|
5120
5119
|
updated_at: a?.updated_at ?? o
|
|
5121
5120
|
};
|
|
5122
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5121
|
+
return await e.insertInto("log_streams").values(s).execute(), U(s);
|
|
5123
5122
|
},
|
|
5124
5123
|
async get(t, n) {
|
|
5125
5124
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5126
|
-
return r ?
|
|
5125
|
+
return r ? U(r) : null;
|
|
5127
5126
|
},
|
|
5128
5127
|
async list(t) {
|
|
5129
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5128
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(U);
|
|
5130
5129
|
},
|
|
5131
5130
|
async update(t, n, r) {
|
|
5132
5131
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5139,7 +5138,7 @@ function Xa(e) {
|
|
|
5139
5138
|
}
|
|
5140
5139
|
//#endregion
|
|
5141
5140
|
//#region src/migrationSources/index.ts
|
|
5142
|
-
function
|
|
5141
|
+
function W(e) {
|
|
5143
5142
|
return {
|
|
5144
5143
|
id: e.id,
|
|
5145
5144
|
name: e.name,
|
|
@@ -5151,7 +5150,7 @@ function K(e) {
|
|
|
5151
5150
|
updated_at: e.updated_at
|
|
5152
5151
|
};
|
|
5153
5152
|
}
|
|
5154
|
-
function
|
|
5153
|
+
function ao(e) {
|
|
5155
5154
|
return {
|
|
5156
5155
|
async create(n, r, i) {
|
|
5157
5156
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5165,14 +5164,14 @@ function Za(e) {
|
|
|
5165
5164
|
created_at: a?.created_at ?? o,
|
|
5166
5165
|
updated_at: a?.updated_at ?? o
|
|
5167
5166
|
};
|
|
5168
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5167
|
+
return await e.insertInto("migration_sources").values(l).execute(), W(l);
|
|
5169
5168
|
},
|
|
5170
5169
|
async get(t, n) {
|
|
5171
5170
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5172
|
-
return r ?
|
|
5171
|
+
return r ? W(r) : null;
|
|
5173
5172
|
},
|
|
5174
5173
|
async list(t) {
|
|
5175
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5174
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(W);
|
|
5176
5175
|
},
|
|
5177
5176
|
async update(t, n, r) {
|
|
5178
5177
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5185,19 +5184,19 @@ function Za(e) {
|
|
|
5185
5184
|
}
|
|
5186
5185
|
//#endregion
|
|
5187
5186
|
//#region src/proxyRoutes/serialize.ts
|
|
5188
|
-
function
|
|
5187
|
+
function G(e) {
|
|
5189
5188
|
return {
|
|
5190
5189
|
id: e.id,
|
|
5191
5190
|
tenant_id: e.tenant_id,
|
|
5192
5191
|
custom_domain_id: e.custom_domain_id,
|
|
5193
5192
|
priority: e.priority,
|
|
5194
|
-
match:
|
|
5195
|
-
handlers:
|
|
5193
|
+
match: oo(e.match),
|
|
5194
|
+
handlers: so(e.handlers),
|
|
5196
5195
|
created_at: e.created_at,
|
|
5197
5196
|
updated_at: e.updated_at
|
|
5198
5197
|
};
|
|
5199
5198
|
}
|
|
5200
|
-
function
|
|
5199
|
+
function oo(e) {
|
|
5201
5200
|
if (!e) return { path: "/*" };
|
|
5202
5201
|
try {
|
|
5203
5202
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5205,7 +5204,7 @@ function Qa(e) {
|
|
|
5205
5204
|
} catch {}
|
|
5206
5205
|
return { path: "/*" };
|
|
5207
5206
|
}
|
|
5208
|
-
function
|
|
5207
|
+
function so(e) {
|
|
5209
5208
|
if (!e) return [];
|
|
5210
5209
|
try {
|
|
5211
5210
|
let t = JSON.parse(e);
|
|
@@ -5222,7 +5221,7 @@ function $a(e) {
|
|
|
5222
5221
|
}
|
|
5223
5222
|
//#endregion
|
|
5224
5223
|
//#region src/proxyRoutes/adapter.ts
|
|
5225
|
-
function
|
|
5224
|
+
function K(e) {
|
|
5226
5225
|
return {
|
|
5227
5226
|
async create(n, r, i) {
|
|
5228
5227
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5248,14 +5247,14 @@ function J(e) {
|
|
|
5248
5247
|
},
|
|
5249
5248
|
async get(t, n) {
|
|
5250
5249
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5251
|
-
return r ?
|
|
5250
|
+
return r ? G(r) : null;
|
|
5252
5251
|
},
|
|
5253
5252
|
async list(t, n = {}) {
|
|
5254
5253
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5255
5254
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5256
5255
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5257
5256
|
return {
|
|
5258
|
-
proxy_routes: o.map(
|
|
5257
|
+
proxy_routes: o.map(G),
|
|
5259
5258
|
start: r * i,
|
|
5260
5259
|
limit: i,
|
|
5261
5260
|
length: o.length
|
|
@@ -5275,7 +5274,7 @@ function J(e) {
|
|
|
5275
5274
|
}
|
|
5276
5275
|
//#endregion
|
|
5277
5276
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5278
|
-
async function
|
|
5277
|
+
async function co(e, t) {
|
|
5279
5278
|
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([
|
|
5280
5279
|
"custom_domain_id",
|
|
5281
5280
|
"tenant_id",
|
|
@@ -5287,20 +5286,20 @@ async function eo(e, t) {
|
|
|
5287
5286
|
tenant_id: a.tenant_id,
|
|
5288
5287
|
custom_domain_id: a.custom_domain_id,
|
|
5289
5288
|
domain: a.domain,
|
|
5290
|
-
routes: o.map(
|
|
5289
|
+
routes: o.map(G)
|
|
5291
5290
|
};
|
|
5292
5291
|
}
|
|
5293
5292
|
//#endregion
|
|
5294
5293
|
//#region src/proxyRoutes/index.ts
|
|
5295
|
-
function
|
|
5294
|
+
function lo(e) {
|
|
5296
5295
|
return {
|
|
5297
|
-
proxyRoutes:
|
|
5298
|
-
resolveHost: (t) =>
|
|
5296
|
+
proxyRoutes: K(e),
|
|
5297
|
+
resolveHost: (t) => co(e, t)
|
|
5299
5298
|
};
|
|
5300
5299
|
}
|
|
5301
5300
|
//#endregion
|
|
5302
5301
|
//#region src/scim/adapter.ts
|
|
5303
|
-
function
|
|
5302
|
+
function uo(e) {
|
|
5304
5303
|
if (!e) return [];
|
|
5305
5304
|
try {
|
|
5306
5305
|
let t = JSON.parse(e);
|
|
@@ -5315,7 +5314,7 @@ function no(e) {
|
|
|
5315
5314
|
return [];
|
|
5316
5315
|
}
|
|
5317
5316
|
}
|
|
5318
|
-
function
|
|
5317
|
+
function fo(e) {
|
|
5319
5318
|
if (!e) return [];
|
|
5320
5319
|
try {
|
|
5321
5320
|
let t = JSON.parse(e);
|
|
@@ -5324,16 +5323,16 @@ function ro(e) {
|
|
|
5324
5323
|
return [];
|
|
5325
5324
|
}
|
|
5326
5325
|
}
|
|
5327
|
-
function
|
|
5326
|
+
function po(e) {
|
|
5328
5327
|
return {
|
|
5329
5328
|
connection_id: e.connection_id,
|
|
5330
5329
|
user_id_attribute: e.user_id_attribute,
|
|
5331
|
-
mapping:
|
|
5330
|
+
mapping: uo(e.mapping),
|
|
5332
5331
|
created_at: e.created_at,
|
|
5333
5332
|
updated_at: e.updated_at
|
|
5334
5333
|
};
|
|
5335
5334
|
}
|
|
5336
|
-
function
|
|
5335
|
+
function mo(e) {
|
|
5337
5336
|
return {
|
|
5338
5337
|
async create(t, n) {
|
|
5339
5338
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5354,7 +5353,7 @@ function ao(e) {
|
|
|
5354
5353
|
},
|
|
5355
5354
|
async get(t, n) {
|
|
5356
5355
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5357
|
-
return r ?
|
|
5356
|
+
return r ? po(r) : null;
|
|
5358
5357
|
},
|
|
5359
5358
|
async update(t, n, r) {
|
|
5360
5359
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5368,18 +5367,18 @@ function ao(e) {
|
|
|
5368
5367
|
}
|
|
5369
5368
|
};
|
|
5370
5369
|
}
|
|
5371
|
-
function
|
|
5370
|
+
function q(e) {
|
|
5372
5371
|
return {
|
|
5373
5372
|
token_id: e.token_id,
|
|
5374
5373
|
connection_id: e.connection_id,
|
|
5375
5374
|
token_hash: e.token_hash,
|
|
5376
|
-
scopes:
|
|
5375
|
+
scopes: fo(e.scopes),
|
|
5377
5376
|
valid_until: e.valid_until ?? void 0,
|
|
5378
5377
|
created_at: e.created_at,
|
|
5379
5378
|
last_used_at: e.last_used_at ?? void 0
|
|
5380
5379
|
};
|
|
5381
5380
|
}
|
|
5382
|
-
function
|
|
5381
|
+
function ho(e) {
|
|
5383
5382
|
return {
|
|
5384
5383
|
async create(t, n) {
|
|
5385
5384
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5403,14 +5402,14 @@ function so(e) {
|
|
|
5403
5402
|
},
|
|
5404
5403
|
async get(t, n) {
|
|
5405
5404
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5406
|
-
return r ?
|
|
5405
|
+
return r ? q(r) : null;
|
|
5407
5406
|
},
|
|
5408
5407
|
async getByHash(t, n) {
|
|
5409
5408
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5410
|
-
return r ?
|
|
5409
|
+
return r ? q(r) : null;
|
|
5411
5410
|
},
|
|
5412
5411
|
async listByConnection(t, n) {
|
|
5413
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5412
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(q);
|
|
5414
5413
|
},
|
|
5415
5414
|
async markUsed(t, n, r) {
|
|
5416
5415
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5422,7 +5421,7 @@ function so(e) {
|
|
|
5422
5421
|
}
|
|
5423
5422
|
};
|
|
5424
5423
|
}
|
|
5425
|
-
function
|
|
5424
|
+
function go(e) {
|
|
5426
5425
|
return {
|
|
5427
5426
|
connection_id: e.connection_id,
|
|
5428
5427
|
external_id: e.external_id,
|
|
@@ -5430,7 +5429,7 @@ function co(e) {
|
|
|
5430
5429
|
created_at: e.created_at
|
|
5431
5430
|
};
|
|
5432
5431
|
}
|
|
5433
|
-
function
|
|
5432
|
+
function _o(e) {
|
|
5434
5433
|
return {
|
|
5435
5434
|
async create(t, n) {
|
|
5436
5435
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5449,11 +5448,11 @@ function lo(e) {
|
|
|
5449
5448
|
},
|
|
5450
5449
|
async getByExternalId(t, n, r) {
|
|
5451
5450
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5452
|
-
return i ?
|
|
5451
|
+
return i ? go(i) : null;
|
|
5453
5452
|
},
|
|
5454
5453
|
async getByUserId(t, n, r) {
|
|
5455
5454
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5456
|
-
return i ?
|
|
5455
|
+
return i ? go(i) : null;
|
|
5457
5456
|
},
|
|
5458
5457
|
async remove(t, n, r) {
|
|
5459
5458
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5463,8 +5462,8 @@ function lo(e) {
|
|
|
5463
5462
|
}
|
|
5464
5463
|
//#endregion
|
|
5465
5464
|
//#region src/tenantOperations/index.ts
|
|
5466
|
-
function
|
|
5467
|
-
return
|
|
5465
|
+
function J(e) {
|
|
5466
|
+
return be.parse({
|
|
5468
5467
|
id: e.id,
|
|
5469
5468
|
tenant_id: e.tenant_id,
|
|
5470
5469
|
rollout_id: e.rollout_id,
|
|
@@ -5482,10 +5481,10 @@ function uo(e) {
|
|
|
5482
5481
|
finished_at: e.finished_at
|
|
5483
5482
|
});
|
|
5484
5483
|
}
|
|
5485
|
-
function
|
|
5484
|
+
function vo(e) {
|
|
5486
5485
|
return {
|
|
5487
5486
|
async create(n) {
|
|
5488
|
-
let r =
|
|
5487
|
+
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5489
5488
|
id: `op_${t()}`,
|
|
5490
5489
|
tenant_id: r.tenant_id,
|
|
5491
5490
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5502,11 +5501,11 @@ function fo(e) {
|
|
|
5502
5501
|
updated_at: i,
|
|
5503
5502
|
finished_at: null
|
|
5504
5503
|
};
|
|
5505
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5504
|
+
return await e.insertInto("tenant_operations").values(a).execute(), J(a);
|
|
5506
5505
|
},
|
|
5507
5506
|
async get(t) {
|
|
5508
5507
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5509
|
-
return n ?
|
|
5508
|
+
return n ? J(n) : null;
|
|
5510
5509
|
},
|
|
5511
5510
|
async list(t = {}) {
|
|
5512
5511
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5517,7 +5516,7 @@ function fo(e) {
|
|
|
5517
5516
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5518
5517
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5519
5518
|
return {
|
|
5520
|
-
operations: a.map(
|
|
5519
|
+
operations: a.map(J),
|
|
5521
5520
|
start: n * r,
|
|
5522
5521
|
limit: r,
|
|
5523
5522
|
length: a.length
|
|
@@ -5537,27 +5536,27 @@ function fo(e) {
|
|
|
5537
5536
|
}
|
|
5538
5537
|
//#endregion
|
|
5539
5538
|
//#region src/utils/monotonic-id.ts
|
|
5540
|
-
var
|
|
5541
|
-
function
|
|
5539
|
+
var yo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Y = 32, bo = 10, xo = 4, So = 10;
|
|
5540
|
+
function Co(e, t) {
|
|
5542
5541
|
let n = "";
|
|
5543
|
-
for (let r = t; r > 0; r--) n =
|
|
5542
|
+
for (let r = t; r > 0; r--) n = yo.charAt(e % Y) + n, e = Math.floor(e / Y);
|
|
5544
5543
|
return n;
|
|
5545
5544
|
}
|
|
5546
|
-
function
|
|
5547
|
-
let e = new Uint8Array(
|
|
5545
|
+
function wo() {
|
|
5546
|
+
let e = new Uint8Array(So);
|
|
5548
5547
|
crypto.getRandomValues(e);
|
|
5549
5548
|
let t = "";
|
|
5550
|
-
for (let n = 0; n <
|
|
5549
|
+
for (let n = 0; n < So; n++) t += yo.charAt(e[n] % Y);
|
|
5551
5550
|
return t;
|
|
5552
5551
|
}
|
|
5553
|
-
var
|
|
5554
|
-
function
|
|
5552
|
+
var To = 0, X = 0;
|
|
5553
|
+
function Eo() {
|
|
5555
5554
|
let e = Date.now();
|
|
5556
|
-
return e ===
|
|
5555
|
+
return e === To ? X++ : (To = e, X = 0), Co(e, bo) + Co(X, xo) + wo();
|
|
5557
5556
|
}
|
|
5558
5557
|
//#endregion
|
|
5559
5558
|
//#region src/tenantOperationEvents/index.ts
|
|
5560
|
-
function
|
|
5559
|
+
function Do(e) {
|
|
5561
5560
|
if (!e) return null;
|
|
5562
5561
|
try {
|
|
5563
5562
|
let t = JSON.parse(e);
|
|
@@ -5565,22 +5564,22 @@ function Co(e) {
|
|
|
5565
5564
|
} catch {}
|
|
5566
5565
|
return null;
|
|
5567
5566
|
}
|
|
5568
|
-
function
|
|
5569
|
-
return
|
|
5567
|
+
function Oo(e) {
|
|
5568
|
+
return ve.parse({
|
|
5570
5569
|
id: e.id,
|
|
5571
5570
|
operation_id: e.operation_id,
|
|
5572
5571
|
step: e.step,
|
|
5573
5572
|
outcome: e.outcome,
|
|
5574
|
-
detail:
|
|
5573
|
+
detail: Do(e.detail),
|
|
5575
5574
|
attempt: e.attempt,
|
|
5576
5575
|
created_at: e.created_at
|
|
5577
5576
|
});
|
|
5578
5577
|
}
|
|
5579
|
-
function
|
|
5578
|
+
function ko(e) {
|
|
5580
5579
|
return {
|
|
5581
5580
|
async create(t) {
|
|
5582
|
-
let n =
|
|
5583
|
-
id: `evt_${
|
|
5581
|
+
let n = _e.parse(t), r = {
|
|
5582
|
+
id: `evt_${Eo()}`,
|
|
5584
5583
|
operation_id: n.operation_id,
|
|
5585
5584
|
step: n.step,
|
|
5586
5585
|
outcome: n.outcome,
|
|
@@ -5588,12 +5587,12 @@ function To(e) {
|
|
|
5588
5587
|
attempt: n.attempt,
|
|
5589
5588
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5590
5589
|
};
|
|
5591
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5590
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Oo(r);
|
|
5592
5591
|
},
|
|
5593
5592
|
async listByOperation(t, n = {}) {
|
|
5594
5593
|
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();
|
|
5595
5594
|
return {
|
|
5596
|
-
events: a.map(
|
|
5595
|
+
events: a.map(Oo),
|
|
5597
5596
|
start: r * i,
|
|
5598
5597
|
limit: i,
|
|
5599
5598
|
length: a.length
|
|
@@ -5603,7 +5602,7 @@ function To(e) {
|
|
|
5603
5602
|
}
|
|
5604
5603
|
//#endregion
|
|
5605
5604
|
//#region src/rollouts/index.ts
|
|
5606
|
-
function
|
|
5605
|
+
function Ao(e) {
|
|
5607
5606
|
if (!e) return null;
|
|
5608
5607
|
try {
|
|
5609
5608
|
return JSON.parse(e);
|
|
@@ -5611,7 +5610,7 @@ function Eo(e) {
|
|
|
5611
5610
|
return null;
|
|
5612
5611
|
}
|
|
5613
5612
|
}
|
|
5614
|
-
function
|
|
5613
|
+
function jo(e) {
|
|
5615
5614
|
return pe.parse({
|
|
5616
5615
|
id: e.id,
|
|
5617
5616
|
kind: e.kind,
|
|
@@ -5619,15 +5618,15 @@ function Y(e) {
|
|
|
5619
5618
|
target_worker_version: e.target_worker_version,
|
|
5620
5619
|
target_database_version: e.target_database_version,
|
|
5621
5620
|
wave_size: e.wave_size,
|
|
5622
|
-
canary_tenant_ids:
|
|
5623
|
-
filter:
|
|
5621
|
+
canary_tenant_ids: Ao(e.canary_tenant_ids),
|
|
5622
|
+
filter: Ao(e.filter),
|
|
5624
5623
|
initiated_by: e.initiated_by,
|
|
5625
5624
|
created_at: e.created_at,
|
|
5626
5625
|
updated_at: e.updated_at,
|
|
5627
5626
|
finished_at: e.finished_at
|
|
5628
5627
|
});
|
|
5629
5628
|
}
|
|
5630
|
-
function
|
|
5629
|
+
function Mo(e) {
|
|
5631
5630
|
return {
|
|
5632
5631
|
async create(n) {
|
|
5633
5632
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5644,16 +5643,16 @@ function Do(e) {
|
|
|
5644
5643
|
updated_at: i,
|
|
5645
5644
|
finished_at: null
|
|
5646
5645
|
};
|
|
5647
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5646
|
+
return await e.insertInto("rollouts").values(a).execute(), jo(a);
|
|
5648
5647
|
},
|
|
5649
5648
|
async get(t) {
|
|
5650
5649
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5651
|
-
return n ?
|
|
5650
|
+
return n ? jo(n) : null;
|
|
5652
5651
|
},
|
|
5653
5652
|
async list(t = {}) {
|
|
5654
5653
|
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();
|
|
5655
5654
|
return {
|
|
5656
|
-
rollouts: i.map(
|
|
5655
|
+
rollouts: i.map(jo),
|
|
5657
5656
|
start: n * r,
|
|
5658
5657
|
limit: r,
|
|
5659
5658
|
length: i.length
|
|
@@ -5673,7 +5672,7 @@ function Do(e) {
|
|
|
5673
5672
|
}
|
|
5674
5673
|
//#endregion
|
|
5675
5674
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5676
|
-
var
|
|
5675
|
+
var No = class {
|
|
5677
5676
|
migrations;
|
|
5678
5677
|
constructor(e) {
|
|
5679
5678
|
this.migrations = e;
|
|
@@ -5681,10 +5680,10 @@ var Oo = class {
|
|
|
5681
5680
|
async getMigrations() {
|
|
5682
5681
|
return this.migrations;
|
|
5683
5682
|
}
|
|
5684
|
-
},
|
|
5685
|
-
down: () =>
|
|
5686
|
-
up: () =>
|
|
5687
|
-
}),
|
|
5683
|
+
}, Po = /* @__PURE__ */ w({
|
|
5684
|
+
down: () => Ro,
|
|
5685
|
+
up: () => Lo
|
|
5686
|
+
}), Fo = [
|
|
5688
5687
|
{
|
|
5689
5688
|
table: "authentication_methods",
|
|
5690
5689
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5950,47 +5949,47 @@ var Oo = class {
|
|
|
5950
5949
|
onDelete: "cascade"
|
|
5951
5950
|
}
|
|
5952
5951
|
];
|
|
5953
|
-
async function
|
|
5952
|
+
async function Io(e) {
|
|
5954
5953
|
try {
|
|
5955
5954
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5956
5955
|
} catch {
|
|
5957
5956
|
return !1;
|
|
5958
5957
|
}
|
|
5959
5958
|
}
|
|
5960
|
-
function
|
|
5959
|
+
function Z(e, t) {
|
|
5961
5960
|
let n = e;
|
|
5962
|
-
for (let e of
|
|
5961
|
+
for (let e of Fo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5963
5962
|
let n = t;
|
|
5964
5963
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5965
5964
|
}));
|
|
5966
5965
|
return n;
|
|
5967
5966
|
}
|
|
5968
|
-
async function
|
|
5969
|
-
let t = await
|
|
5967
|
+
async function Lo(e) {
|
|
5968
|
+
let t = await Io(e);
|
|
5970
5969
|
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();
|
|
5971
5970
|
{
|
|
5972
5971
|
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"]);
|
|
5973
|
-
t && (n =
|
|
5972
|
+
t && (n = Z(n, "authentication_methods")), await n.execute();
|
|
5974
5973
|
}
|
|
5975
5974
|
{
|
|
5976
5975
|
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"]);
|
|
5977
|
-
t && (n =
|
|
5976
|
+
t && (n = Z(n, "branding")), await n.execute();
|
|
5978
5977
|
}
|
|
5979
5978
|
{
|
|
5980
5979
|
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"]);
|
|
5981
|
-
t && (n =
|
|
5980
|
+
t && (n = Z(n, "clients")), await n.execute();
|
|
5982
5981
|
}
|
|
5983
5982
|
{
|
|
5984
5983
|
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"]);
|
|
5985
|
-
t && (n =
|
|
5984
|
+
t && (n = Z(n, "client_grants")), await n.execute();
|
|
5986
5985
|
}
|
|
5987
5986
|
{
|
|
5988
5987
|
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"]);
|
|
5989
|
-
t && (n =
|
|
5988
|
+
t && (n = Z(n, "client_registration_tokens")), await n.execute();
|
|
5990
5989
|
}
|
|
5991
5990
|
{
|
|
5992
5991
|
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"]);
|
|
5993
|
-
t && (n =
|
|
5992
|
+
t && (n = Z(n, "users")), await n.execute();
|
|
5994
5993
|
}
|
|
5995
5994
|
{
|
|
5996
5995
|
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", [
|
|
@@ -5998,16 +5997,16 @@ async function Mo(e) {
|
|
|
5998
5997
|
"code_type",
|
|
5999
5998
|
"tenant_id"
|
|
6000
5999
|
]);
|
|
6001
|
-
t && (n =
|
|
6000
|
+
t && (n = Z(n, "codes")), await n.execute();
|
|
6002
6001
|
}
|
|
6003
6002
|
{
|
|
6004
6003
|
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"]);
|
|
6005
|
-
t && (n =
|
|
6004
|
+
t && (n = Z(n, "connections")), await n.execute();
|
|
6006
6005
|
}
|
|
6007
6006
|
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();
|
|
6008
6007
|
{
|
|
6009
6008
|
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"]);
|
|
6010
|
-
t && (n =
|
|
6009
|
+
t && (n = Z(n, "custom_domains")), await n.execute();
|
|
6011
6010
|
}
|
|
6012
6011
|
{
|
|
6013
6012
|
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", [
|
|
@@ -6015,56 +6014,56 @@ async function Mo(e) {
|
|
|
6015
6014
|
"prompt",
|
|
6016
6015
|
"language"
|
|
6017
6016
|
]);
|
|
6018
|
-
t && (n =
|
|
6017
|
+
t && (n = Z(n, "custom_text")), await n.execute();
|
|
6019
6018
|
}
|
|
6020
6019
|
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();
|
|
6021
6020
|
{
|
|
6022
6021
|
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"]);
|
|
6023
|
-
t && (n =
|
|
6022
|
+
t && (n = Z(n, "email_templates")), await n.execute();
|
|
6024
6023
|
}
|
|
6025
6024
|
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();
|
|
6026
6025
|
{
|
|
6027
6026
|
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"]);
|
|
6028
|
-
t && (n =
|
|
6027
|
+
t && (n = Z(n, "grants")), await n.execute();
|
|
6029
6028
|
}
|
|
6030
6029
|
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();
|
|
6031
6030
|
{
|
|
6032
6031
|
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"]);
|
|
6033
|
-
t && (n =
|
|
6032
|
+
t && (n = Z(n, "hooks")), await n.execute();
|
|
6034
6033
|
}
|
|
6035
6034
|
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();
|
|
6036
6035
|
{
|
|
6037
6036
|
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"]);
|
|
6038
|
-
t && (n =
|
|
6037
|
+
t && (n = Z(n, "keys")), await n.execute();
|
|
6039
6038
|
}
|
|
6040
6039
|
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();
|
|
6041
6040
|
{
|
|
6042
6041
|
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"]);
|
|
6043
|
-
t && (n =
|
|
6042
|
+
t && (n = Z(n, "sessions")), await n.execute();
|
|
6044
6043
|
}
|
|
6045
6044
|
{
|
|
6046
6045
|
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"]);
|
|
6047
|
-
t && (n =
|
|
6046
|
+
t && (n = Z(n, "login_sessions")), await n.execute();
|
|
6048
6047
|
}
|
|
6049
6048
|
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();
|
|
6050
6049
|
{
|
|
6051
6050
|
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"]);
|
|
6052
|
-
t && (n =
|
|
6051
|
+
t && (n = Z(n, "migrations")), await n.execute();
|
|
6053
6052
|
}
|
|
6054
6053
|
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();
|
|
6055
6054
|
{
|
|
6056
6055
|
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());
|
|
6057
|
-
t && (n =
|
|
6056
|
+
t && (n = Z(n, "organization_connections")), await n.execute();
|
|
6058
6057
|
}
|
|
6059
6058
|
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();
|
|
6060
6059
|
{
|
|
6061
6060
|
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"]);
|
|
6062
|
-
t && (n =
|
|
6061
|
+
t && (n = Z(n, "passwords")), await n.execute();
|
|
6063
6062
|
}
|
|
6064
6063
|
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();
|
|
6065
6064
|
{
|
|
6066
6065
|
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"]);
|
|
6067
|
-
t && (n =
|
|
6066
|
+
t && (n = Z(n, "refresh_tokens")), await n.execute();
|
|
6068
6067
|
}
|
|
6069
6068
|
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", [
|
|
6070
6069
|
"tenant_id",
|
|
@@ -6074,23 +6073,23 @@ async function Mo(e) {
|
|
|
6074
6073
|
]).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();
|
|
6075
6074
|
{
|
|
6076
6075
|
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"]);
|
|
6077
|
-
t && (n =
|
|
6076
|
+
t && (n = Z(n, "tenant_operation_events")), await n.execute();
|
|
6078
6077
|
}
|
|
6079
6078
|
{
|
|
6080
6079
|
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"]);
|
|
6081
|
-
t && (n =
|
|
6080
|
+
t && (n = Z(n, "themes")), await n.execute();
|
|
6082
6081
|
}
|
|
6083
6082
|
{
|
|
6084
6083
|
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"]);
|
|
6085
|
-
t && (n =
|
|
6084
|
+
t && (n = Z(n, "universal_login_templates")), await n.execute();
|
|
6086
6085
|
}
|
|
6087
6086
|
{
|
|
6088
6087
|
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"]);
|
|
6089
|
-
t && (n =
|
|
6088
|
+
t && (n = Z(n, "user_activity")), await n.execute();
|
|
6090
6089
|
}
|
|
6091
6090
|
{
|
|
6092
6091
|
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"]);
|
|
6093
|
-
t && (n =
|
|
6092
|
+
t && (n = Z(n, "user_organizations")), await n.execute();
|
|
6094
6093
|
}
|
|
6095
6094
|
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", [
|
|
6096
6095
|
"tenant_id",
|
|
@@ -6153,76 +6152,76 @@ async function Mo(e) {
|
|
|
6153
6152
|
"tenant_id",
|
|
6154
6153
|
"phone_number",
|
|
6155
6154
|
"provider"
|
|
6156
|
-
]).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
|
|
6155
|
+
]).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 Fo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6157
6156
|
let n = e;
|
|
6158
6157
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6159
6158
|
}).execute();
|
|
6160
6159
|
}
|
|
6161
|
-
async function
|
|
6160
|
+
async function Ro(e) {
|
|
6162
6161
|
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();
|
|
6163
6162
|
}
|
|
6164
6163
|
//#endregion
|
|
6165
6164
|
//#region migrate/log.ts
|
|
6166
|
-
var
|
|
6167
|
-
function
|
|
6168
|
-
|
|
6169
|
-
}
|
|
6170
|
-
function Z(...e) {
|
|
6171
|
-
Po && console.log(...e);
|
|
6165
|
+
var zo = !1;
|
|
6166
|
+
function Bo(e) {
|
|
6167
|
+
zo = e;
|
|
6172
6168
|
}
|
|
6173
6169
|
function Q(...e) {
|
|
6170
|
+
zo && console.log(...e);
|
|
6171
|
+
}
|
|
6172
|
+
function $(...e) {
|
|
6174
6173
|
console.warn(...e);
|
|
6175
6174
|
}
|
|
6176
6175
|
//#endregion
|
|
6177
6176
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6178
|
-
var
|
|
6179
|
-
down: () =>
|
|
6180
|
-
up: () =>
|
|
6181
|
-
}),
|
|
6182
|
-
async function
|
|
6177
|
+
var Vo = /* @__PURE__ */ w({
|
|
6178
|
+
down: () => Qo,
|
|
6179
|
+
up: () => Yo
|
|
6180
|
+
}), Ho = 5e4, Uo = 500;
|
|
6181
|
+
async function Wo(e) {
|
|
6183
6182
|
try {
|
|
6184
6183
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6185
6184
|
} catch {
|
|
6186
6185
|
return "sqlite";
|
|
6187
6186
|
}
|
|
6188
6187
|
}
|
|
6189
|
-
async function
|
|
6188
|
+
async function Go(e, t, n) {
|
|
6190
6189
|
try {
|
|
6191
6190
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6192
6191
|
} catch (e) {
|
|
6193
6192
|
if (e instanceof Error && (e.message.includes("1060") || e.message.includes("duplicate column"))) {
|
|
6194
|
-
|
|
6193
|
+
Q(` Column ${t}.${n} already exists, skipping`);
|
|
6195
6194
|
return;
|
|
6196
6195
|
}
|
|
6197
6196
|
throw e;
|
|
6198
6197
|
}
|
|
6199
6198
|
}
|
|
6200
|
-
async function
|
|
6199
|
+
async function Ko(e, t, n, r) {
|
|
6201
6200
|
try {
|
|
6202
6201
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6203
6202
|
} catch (e) {
|
|
6204
6203
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6205
|
-
|
|
6204
|
+
Q(` Index ${t} already exists, skipping`);
|
|
6206
6205
|
return;
|
|
6207
6206
|
}
|
|
6208
6207
|
throw e;
|
|
6209
6208
|
}
|
|
6210
6209
|
}
|
|
6211
|
-
async function
|
|
6210
|
+
async function qo(e, t) {
|
|
6212
6211
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6213
6212
|
if (t === "sqlite") {
|
|
6214
6213
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6215
6214
|
r = Number(t.numDeletedRows);
|
|
6216
6215
|
} else {
|
|
6217
|
-
let t =
|
|
6218
|
-
for (; t >=
|
|
6219
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6220
|
-
t = Number(i.numDeletedRows), r += t, t > 0 &&
|
|
6216
|
+
let t = Ho;
|
|
6217
|
+
for (; t >= Ho;) {
|
|
6218
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(Ho).executeTakeFirst();
|
|
6219
|
+
t = Number(i.numDeletedRows), r += t, t > 0 && Q(` Pruned ${r} expired codes row(s)...`);
|
|
6221
6220
|
}
|
|
6222
6221
|
}
|
|
6223
6222
|
return r;
|
|
6224
6223
|
}
|
|
6225
|
-
async function
|
|
6224
|
+
async function Jo(e) {
|
|
6226
6225
|
let t = 0;
|
|
6227
6226
|
for (;;) {
|
|
6228
6227
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6230,33 +6229,33 @@ async function Ho(e) {
|
|
|
6230
6229
|
"code_type",
|
|
6231
6230
|
"tenant_id",
|
|
6232
6231
|
"expires_at"
|
|
6233
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6232
|
+
]).where("expires_at_ts", "is", null).limit(Uo).execute();
|
|
6234
6233
|
if (n.length === 0) break;
|
|
6235
6234
|
for (let t of n) {
|
|
6236
6235
|
let n = Date.parse(t.expires_at);
|
|
6237
6236
|
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();
|
|
6238
6237
|
}
|
|
6239
|
-
if (t += n.length, n.length <
|
|
6238
|
+
if (t += n.length, n.length < Uo) break;
|
|
6240
6239
|
}
|
|
6241
6240
|
return t;
|
|
6242
6241
|
}
|
|
6243
|
-
async function
|
|
6244
|
-
let t = await
|
|
6242
|
+
async function Yo(e) {
|
|
6243
|
+
let t = await Wo(e);
|
|
6245
6244
|
try {
|
|
6246
|
-
let n = await
|
|
6247
|
-
|
|
6245
|
+
let n = await qo(e, t);
|
|
6246
|
+
Q(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6248
6247
|
} catch (e) {
|
|
6249
|
-
|
|
6248
|
+
$(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6250
6249
|
}
|
|
6251
|
-
await
|
|
6250
|
+
await Go(e, "codes", "expires_at_ts"), await Ko(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6252
6251
|
try {
|
|
6253
|
-
let t = await
|
|
6254
|
-
|
|
6252
|
+
let t = await Jo(e);
|
|
6253
|
+
Q(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6255
6254
|
} catch (e) {
|
|
6256
|
-
|
|
6255
|
+
$(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6257
6256
|
}
|
|
6258
6257
|
}
|
|
6259
|
-
async function
|
|
6258
|
+
async function Xo(e, t, n) {
|
|
6260
6259
|
try {
|
|
6261
6260
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6262
6261
|
} catch (e) {
|
|
@@ -6264,7 +6263,7 @@ async function Wo(e, t, n) {
|
|
|
6264
6263
|
throw e;
|
|
6265
6264
|
}
|
|
6266
6265
|
}
|
|
6267
|
-
async function
|
|
6266
|
+
async function Zo(e, t, n) {
|
|
6268
6267
|
try {
|
|
6269
6268
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6270
6269
|
} catch (e) {
|
|
@@ -6272,16 +6271,16 @@ async function Go(e, t, n) {
|
|
|
6272
6271
|
throw e;
|
|
6273
6272
|
}
|
|
6274
6273
|
}
|
|
6275
|
-
async function
|
|
6276
|
-
await
|
|
6274
|
+
async function Qo(e) {
|
|
6275
|
+
await Xo(e, "idx_codes_expires_at_ts", "codes"), await Zo(e, "codes", "expires_at_ts");
|
|
6277
6276
|
}
|
|
6278
6277
|
//#endregion
|
|
6279
6278
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6280
|
-
var
|
|
6281
|
-
down: () =>
|
|
6282
|
-
up: () =>
|
|
6279
|
+
var $o = /* @__PURE__ */ w({
|
|
6280
|
+
down: () => ts,
|
|
6281
|
+
up: () => es
|
|
6283
6282
|
});
|
|
6284
|
-
async function
|
|
6283
|
+
async function es(e) {
|
|
6285
6284
|
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", [
|
|
6286
6285
|
"tenant_id",
|
|
6287
6286
|
"connection_id",
|
|
@@ -6292,16 +6291,16 @@ async function Jo(e) {
|
|
|
6292
6291
|
"external_id"
|
|
6293
6292
|
]).unique().execute();
|
|
6294
6293
|
}
|
|
6295
|
-
async function
|
|
6294
|
+
async function ts(e) {
|
|
6296
6295
|
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();
|
|
6297
6296
|
}
|
|
6298
6297
|
//#endregion
|
|
6299
6298
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6300
|
-
var
|
|
6301
|
-
down: () =>
|
|
6302
|
-
up: () =>
|
|
6299
|
+
var ns = /* @__PURE__ */ w({
|
|
6300
|
+
down: () => os,
|
|
6301
|
+
up: () => is
|
|
6303
6302
|
});
|
|
6304
|
-
async function
|
|
6303
|
+
async function rs(e, t, n) {
|
|
6305
6304
|
try {
|
|
6306
6305
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6307
6306
|
} catch (e) {
|
|
@@ -6309,10 +6308,10 @@ async function Zo(e, t, n) {
|
|
|
6309
6308
|
throw e;
|
|
6310
6309
|
}
|
|
6311
6310
|
}
|
|
6312
|
-
async function
|
|
6313
|
-
await
|
|
6311
|
+
async function is(e) {
|
|
6312
|
+
await rs(e, "users", "blocked");
|
|
6314
6313
|
}
|
|
6315
|
-
async function
|
|
6314
|
+
async function as(e, t, n) {
|
|
6316
6315
|
try {
|
|
6317
6316
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6318
6317
|
} catch (e) {
|
|
@@ -6320,16 +6319,16 @@ async function $o(e, t, n) {
|
|
|
6320
6319
|
throw e;
|
|
6321
6320
|
}
|
|
6322
6321
|
}
|
|
6323
|
-
async function
|
|
6324
|
-
await
|
|
6322
|
+
async function os(e) {
|
|
6323
|
+
await as(e, "users", "blocked");
|
|
6325
6324
|
}
|
|
6326
6325
|
//#endregion
|
|
6327
6326
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6328
|
-
var
|
|
6329
|
-
down: () =>
|
|
6330
|
-
up: () =>
|
|
6327
|
+
var ss = /* @__PURE__ */ w({
|
|
6328
|
+
down: () => ds,
|
|
6329
|
+
up: () => ls
|
|
6331
6330
|
});
|
|
6332
|
-
async function
|
|
6331
|
+
async function cs(e, t, n) {
|
|
6333
6332
|
try {
|
|
6334
6333
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6335
6334
|
} catch (e) {
|
|
@@ -6337,10 +6336,10 @@ async function ns(e, t, n) {
|
|
|
6337
6336
|
throw e;
|
|
6338
6337
|
}
|
|
6339
6338
|
}
|
|
6340
|
-
async function
|
|
6341
|
-
await
|
|
6339
|
+
async function ls(e) {
|
|
6340
|
+
await cs(e, "prompt_settings", "show_last_used_connection");
|
|
6342
6341
|
}
|
|
6343
|
-
async function
|
|
6342
|
+
async function us(e, t, n) {
|
|
6344
6343
|
try {
|
|
6345
6344
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6346
6345
|
} catch (e) {
|
|
@@ -6348,30 +6347,30 @@ async function is(e, t, n) {
|
|
|
6348
6347
|
throw e;
|
|
6349
6348
|
}
|
|
6350
6349
|
}
|
|
6351
|
-
async function
|
|
6352
|
-
await
|
|
6350
|
+
async function ds(e) {
|
|
6351
|
+
await us(e, "prompt_settings", "show_last_used_connection");
|
|
6353
6352
|
}
|
|
6354
6353
|
//#endregion
|
|
6355
6354
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6356
|
-
var
|
|
6357
|
-
down: () =>
|
|
6358
|
-
up: () =>
|
|
6355
|
+
var fs = /* @__PURE__ */ w({
|
|
6356
|
+
down: () => hs,
|
|
6357
|
+
up: () => ms
|
|
6359
6358
|
});
|
|
6360
|
-
async function
|
|
6359
|
+
async function ps(e, t, n, r) {
|
|
6361
6360
|
try {
|
|
6362
6361
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6363
6362
|
} catch (e) {
|
|
6364
6363
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6365
|
-
|
|
6364
|
+
Q(` Index ${t} already exists, skipping`);
|
|
6366
6365
|
return;
|
|
6367
6366
|
}
|
|
6368
6367
|
throw e;
|
|
6369
6368
|
}
|
|
6370
6369
|
}
|
|
6371
|
-
async function
|
|
6372
|
-
await
|
|
6370
|
+
async function ms(e) {
|
|
6371
|
+
await ps(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6373
6372
|
}
|
|
6374
|
-
async function
|
|
6373
|
+
async function hs(e) {
|
|
6375
6374
|
try {
|
|
6376
6375
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6377
6376
|
} catch (e) {
|
|
@@ -6381,11 +6380,11 @@ async function ls(e) {
|
|
|
6381
6380
|
}
|
|
6382
6381
|
//#endregion
|
|
6383
6382
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6384
|
-
var
|
|
6385
|
-
down: () =>
|
|
6386
|
-
up: () =>
|
|
6383
|
+
var gs = /* @__PURE__ */ w({
|
|
6384
|
+
down: () => bs,
|
|
6385
|
+
up: () => vs
|
|
6387
6386
|
});
|
|
6388
|
-
async function
|
|
6387
|
+
async function _s(e, t, n, r) {
|
|
6389
6388
|
try {
|
|
6390
6389
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6391
6390
|
} catch (e) {
|
|
@@ -6393,10 +6392,10 @@ async function ds(e, t, n, r) {
|
|
|
6393
6392
|
throw e;
|
|
6394
6393
|
}
|
|
6395
6394
|
}
|
|
6396
|
-
async function
|
|
6397
|
-
await
|
|
6395
|
+
async function vs(e) {
|
|
6396
|
+
await _s(e, "hooks", "page_id", f`varchar(64)`), await _s(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6398
6397
|
}
|
|
6399
|
-
async function
|
|
6398
|
+
async function ys(e, t, n) {
|
|
6400
6399
|
try {
|
|
6401
6400
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6402
6401
|
} catch (e) {
|
|
@@ -6404,22 +6403,22 @@ async function ps(e, t, n) {
|
|
|
6404
6403
|
throw e;
|
|
6405
6404
|
}
|
|
6406
6405
|
}
|
|
6407
|
-
async function
|
|
6408
|
-
await
|
|
6406
|
+
async function bs(e) {
|
|
6407
|
+
await ys(e, "hooks", "permission_required"), await ys(e, "hooks", "page_id");
|
|
6409
6408
|
}
|
|
6410
6409
|
//#endregion
|
|
6411
6410
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6412
|
-
var
|
|
6413
|
-
down: () =>
|
|
6414
|
-
up: () =>
|
|
6415
|
-
}),
|
|
6411
|
+
var xs = /* @__PURE__ */ w({
|
|
6412
|
+
down: () => Ds,
|
|
6413
|
+
up: () => Ts
|
|
6414
|
+
}), Ss = [
|
|
6416
6415
|
["session_id", f`varchar(26)`],
|
|
6417
6416
|
["organization", f`varchar(191)`],
|
|
6418
6417
|
["auth_connection", f`varchar(255)`],
|
|
6419
6418
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6420
6419
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6421
6420
|
];
|
|
6422
|
-
async function
|
|
6421
|
+
async function Cs(e, t, n, r) {
|
|
6423
6422
|
try {
|
|
6424
6423
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6425
6424
|
} catch (e) {
|
|
@@ -6427,7 +6426,7 @@ async function _s(e, t, n, r) {
|
|
|
6427
6426
|
throw e;
|
|
6428
6427
|
}
|
|
6429
6428
|
}
|
|
6430
|
-
async function
|
|
6429
|
+
async function ws(e) {
|
|
6431
6430
|
try {
|
|
6432
6431
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6433
6432
|
} catch (e) {
|
|
@@ -6435,11 +6434,11 @@ async function vs(e) {
|
|
|
6435
6434
|
throw e;
|
|
6436
6435
|
}
|
|
6437
6436
|
}
|
|
6438
|
-
async function
|
|
6439
|
-
for (let [t, n] of
|
|
6440
|
-
await
|
|
6437
|
+
async function Ts(e) {
|
|
6438
|
+
for (let [t, n] of Ss) await Cs(e, "refresh_tokens", t, n);
|
|
6439
|
+
await ws(e);
|
|
6441
6440
|
}
|
|
6442
|
-
async function
|
|
6441
|
+
async function Es(e, t, n) {
|
|
6443
6442
|
try {
|
|
6444
6443
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6445
6444
|
} catch (e) {
|
|
@@ -6447,27 +6446,27 @@ async function bs(e, t, n) {
|
|
|
6447
6446
|
throw e;
|
|
6448
6447
|
}
|
|
6449
6448
|
}
|
|
6450
|
-
async function
|
|
6449
|
+
async function Ds(e) {
|
|
6451
6450
|
try {
|
|
6452
6451
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6453
6452
|
} catch {}
|
|
6454
|
-
for (let [t] of
|
|
6453
|
+
for (let [t] of Ss) await Es(e, "refresh_tokens", t);
|
|
6455
6454
|
}
|
|
6456
6455
|
//#endregion
|
|
6457
6456
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6458
|
-
var
|
|
6459
|
-
down: () =>
|
|
6460
|
-
up: () =>
|
|
6461
|
-
}),
|
|
6462
|
-
async function
|
|
6457
|
+
var Os = /* @__PURE__ */ w({
|
|
6458
|
+
down: () => Ps,
|
|
6459
|
+
up: () => Ns
|
|
6460
|
+
}), ks = 500, As = 20, js = 500, Ms = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6461
|
+
async function Ns(e) {
|
|
6463
6462
|
try {
|
|
6464
6463
|
let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select((e) => e.fn.countAll().as("count")).executeTakeFirst(), n = Number(t?.count ?? 0);
|
|
6465
|
-
if (n >
|
|
6466
|
-
|
|
6464
|
+
if (n > js) {
|
|
6465
|
+
$(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${js}. SKIPPING — run the bulk path instead: ${Ms}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6467
6466
|
return;
|
|
6468
6467
|
}
|
|
6469
6468
|
if (n === 0) {
|
|
6470
|
-
|
|
6469
|
+
Q("refresh_tokens backfill: nothing to do");
|
|
6471
6470
|
return;
|
|
6472
6471
|
}
|
|
6473
6472
|
let r = 0;
|
|
@@ -6480,16 +6479,16 @@ async function Ds(e) {
|
|
|
6480
6479
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6481
6480
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6482
6481
|
"login_sessions.auth_params as ls_auth_params"
|
|
6483
|
-
]).limit(
|
|
6482
|
+
]).limit(ks).execute();
|
|
6484
6483
|
if (t.length === 0) break;
|
|
6485
|
-
for (let n = 0; n < t.length; n +=
|
|
6486
|
-
let r = t.slice(n, n +
|
|
6484
|
+
for (let n = 0; n < t.length; n += As) {
|
|
6485
|
+
let r = t.slice(n, n + As);
|
|
6487
6486
|
await Promise.all(r.map(async (t) => {
|
|
6488
6487
|
let n = null;
|
|
6489
6488
|
if (t.ls_auth_params) try {
|
|
6490
6489
|
n = JSON.parse(t.ls_auth_params)?.organization ?? null;
|
|
6491
6490
|
} catch {
|
|
6492
|
-
|
|
6491
|
+
$(`refresh_tokens backfill: unparseable auth_params on login_session for token ${t.id}`);
|
|
6493
6492
|
}
|
|
6494
6493
|
await e.updateTable("refresh_tokens").set({
|
|
6495
6494
|
session_id: t.ls_session_id,
|
|
@@ -6500,44 +6499,44 @@ async function Ds(e) {
|
|
|
6500
6499
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6501
6500
|
}));
|
|
6502
6501
|
}
|
|
6503
|
-
if (r += t.length,
|
|
6502
|
+
if (r += t.length, Q(`refresh_tokens backfill: ${r} rows populated so far`), t.length < ks) break;
|
|
6504
6503
|
}
|
|
6505
|
-
|
|
6504
|
+
Q(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6506
6505
|
} catch (e) {
|
|
6507
|
-
throw
|
|
6506
|
+
throw $("refresh_tokens backfill failed:", e), e;
|
|
6508
6507
|
}
|
|
6509
6508
|
}
|
|
6510
|
-
async function
|
|
6509
|
+
async function Ps() {}
|
|
6511
6510
|
//#endregion
|
|
6512
6511
|
//#region migrate/migrations/index.ts
|
|
6513
|
-
var
|
|
6514
|
-
"2026-07-16T14:00:00_baseline":
|
|
6515
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6516
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6517
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6518
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6519
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6520
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6521
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6522
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6512
|
+
var Fs = {
|
|
6513
|
+
"2026-07-16T14:00:00_baseline": Po,
|
|
6514
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": Vo,
|
|
6515
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": $o,
|
|
6516
|
+
"2026-08-05T12:00:00_user_blocked": ns,
|
|
6517
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": ss,
|
|
6518
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": fs,
|
|
6519
|
+
"2026-08-11T12:00:00_page_hooks": gs,
|
|
6520
|
+
"2026-08-20T12:00:00_refresh_token_session_id": xs,
|
|
6521
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Os
|
|
6523
6522
|
};
|
|
6524
6523
|
//#endregion
|
|
6525
6524
|
//#region migrate/migrate.ts
|
|
6526
|
-
async function
|
|
6527
|
-
|
|
6528
|
-
let { error: n, results: r } = await new
|
|
6525
|
+
async function Is(e, t = !1) {
|
|
6526
|
+
Bo(t), t && console.log("migrating...");
|
|
6527
|
+
let { error: n, results: r } = await new we({
|
|
6529
6528
|
db: e,
|
|
6530
|
-
provider: new
|
|
6529
|
+
provider: new No(Fs)
|
|
6531
6530
|
}).migrateToLatest();
|
|
6532
6531
|
if (r?.forEach((e) => {
|
|
6533
6532
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6534
6533
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6535
6534
|
}
|
|
6536
|
-
async function
|
|
6537
|
-
|
|
6538
|
-
let { error: n, results: r } = await new
|
|
6535
|
+
async function Ls(e, t = !1) {
|
|
6536
|
+
Bo(t), t && console.log("migrating...");
|
|
6537
|
+
let { error: n, results: r } = await new we({
|
|
6539
6538
|
db: e,
|
|
6540
|
-
provider: new
|
|
6539
|
+
provider: new No(Fs)
|
|
6541
6540
|
}).migrateDown();
|
|
6542
6541
|
if (r?.forEach((e) => {
|
|
6543
6542
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6545,64 +6544,64 @@ async function js(e, t = !1) {
|
|
|
6545
6544
|
}
|
|
6546
6545
|
//#endregion
|
|
6547
6546
|
//#region src/index.ts
|
|
6548
|
-
function
|
|
6547
|
+
function Rs(e, t = { useTransactions: !0 }) {
|
|
6549
6548
|
let n = {
|
|
6550
|
-
actions:
|
|
6551
|
-
actionExecutions:
|
|
6552
|
-
actionVersions:
|
|
6553
|
-
branding:
|
|
6554
|
-
clients:
|
|
6555
|
-
clientConnections:
|
|
6556
|
-
clientGrants:
|
|
6557
|
-
clientRegistrationTokens:
|
|
6558
|
-
codes:
|
|
6559
|
-
connections:
|
|
6560
|
-
emailProviders:
|
|
6561
|
-
emailTemplates:
|
|
6562
|
-
customDomains:
|
|
6563
|
-
flows:
|
|
6564
|
-
forms:
|
|
6565
|
-
hookCode:
|
|
6566
|
-
hooks:
|
|
6567
|
-
invites:
|
|
6568
|
-
keys:
|
|
6569
|
-
loginSessions:
|
|
6570
|
-
logs:
|
|
6571
|
-
logStreams:
|
|
6572
|
-
migrationSources:
|
|
6573
|
-
authenticationMethods:
|
|
6574
|
-
passwords:
|
|
6575
|
-
promptSettings:
|
|
6576
|
-
proxyRoutes:
|
|
6577
|
-
scimConfigurations:
|
|
6578
|
-
scimTokens:
|
|
6579
|
-
scimExternalIds:
|
|
6580
|
-
refreshTokens:
|
|
6581
|
-
resourceServers:
|
|
6582
|
-
rolePermissions:
|
|
6583
|
-
grants:
|
|
6584
|
-
userPermissions:
|
|
6585
|
-
userRoles:
|
|
6586
|
-
roles:
|
|
6587
|
-
sessions:
|
|
6588
|
-
sessionCleanup:
|
|
6589
|
-
tenants:
|
|
6590
|
-
tenantOperations:
|
|
6591
|
-
tenantOperationEvents:
|
|
6592
|
-
rollouts:
|
|
6593
|
-
themes:
|
|
6594
|
-
universalLoginTemplates:
|
|
6595
|
-
customText:
|
|
6596
|
-
users:
|
|
6597
|
-
userActivity:
|
|
6598
|
-
organizations:
|
|
6599
|
-
organizationConnections:
|
|
6600
|
-
userOrganizations:
|
|
6601
|
-
stats:
|
|
6602
|
-
analytics:
|
|
6603
|
-
outbox:
|
|
6549
|
+
actions: We(e),
|
|
6550
|
+
actionExecutions: Xe(e),
|
|
6551
|
+
actionVersions: Qe(e),
|
|
6552
|
+
branding: ur(e),
|
|
6553
|
+
clients: Tn(e),
|
|
6554
|
+
clientConnections: jn(e),
|
|
6555
|
+
clientGrants: Rn(e),
|
|
6556
|
+
clientRegistrationTokens: Xn(e),
|
|
6557
|
+
codes: cn(e),
|
|
6558
|
+
connections: gn(e),
|
|
6559
|
+
emailProviders: Zr(e),
|
|
6560
|
+
emailTemplates: ii(e),
|
|
6561
|
+
customDomains: sr(e),
|
|
6562
|
+
flows: Tt(e),
|
|
6563
|
+
forms: Ci(e),
|
|
6564
|
+
hookCode: Tr(e),
|
|
6565
|
+
hooks: br(e),
|
|
6566
|
+
invites: Ca(e),
|
|
6567
|
+
keys: er(e),
|
|
6568
|
+
loginSessions: Hr(e),
|
|
6569
|
+
logs: Vt(e),
|
|
6570
|
+
logStreams: io(e),
|
|
6571
|
+
migrationSources: ao(e),
|
|
6572
|
+
authenticationMethods: qa(e),
|
|
6573
|
+
passwords: Qt(e),
|
|
6574
|
+
promptSettings: Kr(e),
|
|
6575
|
+
proxyRoutes: K(e),
|
|
6576
|
+
scimConfigurations: mo(e),
|
|
6577
|
+
scimTokens: ho(e),
|
|
6578
|
+
scimExternalIds: _o(e),
|
|
6579
|
+
refreshTokens: hi(e),
|
|
6580
|
+
resourceServers: ki(e),
|
|
6581
|
+
rolePermissions: Bi(e),
|
|
6582
|
+
grants: Ki(e),
|
|
6583
|
+
userPermissions: Zi(e),
|
|
6584
|
+
userRoles: ra(e),
|
|
6585
|
+
roles: Fi(e),
|
|
6586
|
+
sessions: qt(e),
|
|
6587
|
+
sessionCleanup: _i(e),
|
|
6588
|
+
tenants: Nt(e),
|
|
6589
|
+
tenantOperations: vo(e),
|
|
6590
|
+
tenantOperationEvents: ko(e),
|
|
6591
|
+
rollouts: Mo(e),
|
|
6592
|
+
themes: Ar(e),
|
|
6593
|
+
universalLoginTemplates: mr(e),
|
|
6594
|
+
customText: Ba(e),
|
|
6595
|
+
users: _t(e),
|
|
6596
|
+
userActivity: mt(e),
|
|
6597
|
+
organizations: la(e),
|
|
6598
|
+
organizationConnections: ua(e),
|
|
6599
|
+
userOrganizations: _a(e),
|
|
6600
|
+
stats: Oa(e),
|
|
6601
|
+
analytics: za(e),
|
|
6602
|
+
outbox: ro(e),
|
|
6604
6603
|
async transaction(r) {
|
|
6605
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6604
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Rs(e, {
|
|
6606
6605
|
...t,
|
|
6607
6606
|
useTransactions: !1
|
|
6608
6607
|
})));
|
|
@@ -6611,4 +6610,4 @@ function Ms(e, t = { useTransactions: !0 }) {
|
|
|
6611
6610
|
return n;
|
|
6612
6611
|
}
|
|
6613
6612
|
//#endregion
|
|
6614
|
-
export {
|
|
6613
|
+
export { lo as createProxyDataAdapter, K as createProxyRoutesAdapter, Rs as default, Ls as migrateDown, Is as migrateToLatest };
|