@authhero/kysely-adapter 12.6.0 → 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,12 +3172,12 @@ 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);
|
|
@@ -3182,7 +3185,7 @@ function ni(e) {
|
|
|
3182
3185
|
}
|
|
3183
3186
|
//#endregion
|
|
3184
3187
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3185
|
-
function
|
|
3188
|
+
function ui(e) {
|
|
3186
3189
|
return async (t, n, r) => {
|
|
3187
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();
|
|
3188
3191
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3190,7 +3193,7 @@ function ri(e) {
|
|
|
3190
3193
|
}
|
|
3191
3194
|
//#endregion
|
|
3192
3195
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3193
|
-
function
|
|
3196
|
+
function di(e) {
|
|
3194
3197
|
return async (t, n, r) => {
|
|
3195
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();
|
|
3196
3199
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3198,7 +3201,7 @@ function ii(e) {
|
|
|
3198
3201
|
}
|
|
3199
3202
|
//#endregion
|
|
3200
3203
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3201
|
-
function
|
|
3204
|
+
function fi(e) {
|
|
3202
3205
|
return async (t, n, r) => {
|
|
3203
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();
|
|
3204
3207
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3206,7 +3209,7 @@ function ai(e) {
|
|
|
3206
3209
|
}
|
|
3207
3210
|
//#endregion
|
|
3208
3211
|
//#region src/refreshTokens/update.ts
|
|
3209
|
-
function
|
|
3212
|
+
function pi(e) {
|
|
3210
3213
|
return async (t, n, r, i) => {
|
|
3211
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 = {
|
|
3212
3215
|
...h,
|
|
@@ -3227,14 +3230,14 @@ function oi(e) {
|
|
|
3227
3230
|
}
|
|
3228
3231
|
//#endregion
|
|
3229
3232
|
//#region src/refreshTokens/list.ts
|
|
3230
|
-
function
|
|
3233
|
+
function mi(e) {
|
|
3231
3234
|
return async (t, n = {}) => {
|
|
3232
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);
|
|
3233
3236
|
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = D(e, u, c, ["token", "login_id"])), M(n)) {
|
|
3234
3237
|
let { rows: e, limit: t, next: r } = await N(u.selectAll(), n, {
|
|
3235
3238
|
sortColumn: "created_at_ts",
|
|
3236
3239
|
sortOrder: "desc"
|
|
3237
|
-
}), i = e.map(
|
|
3240
|
+
}), i = e.map(L);
|
|
3238
3241
|
return {
|
|
3239
3242
|
refresh_tokens: i,
|
|
3240
3243
|
start: 0,
|
|
@@ -3249,7 +3252,7 @@ function si(e) {
|
|
|
3249
3252
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3250
3253
|
}
|
|
3251
3254
|
d = d.offset(r * i).limit(i);
|
|
3252
|
-
let f = (await d.selectAll().execute()).map(
|
|
3255
|
+
let f = (await d.selectAll().execute()).map(L);
|
|
3253
3256
|
if (!a) return {
|
|
3254
3257
|
refresh_tokens: f,
|
|
3255
3258
|
start: 0,
|
|
@@ -3267,26 +3270,26 @@ function si(e) {
|
|
|
3267
3270
|
}
|
|
3268
3271
|
//#endregion
|
|
3269
3272
|
//#region src/refreshTokens/index.ts
|
|
3270
|
-
function
|
|
3273
|
+
function hi(e) {
|
|
3271
3274
|
return {
|
|
3272
|
-
create:
|
|
3273
|
-
get:
|
|
3274
|
-
getByLookup:
|
|
3275
|
-
list:
|
|
3276
|
-
remove:
|
|
3277
|
-
revokeByLoginSession:
|
|
3278
|
-
revokeBySession:
|
|
3279
|
-
revokeByUser:
|
|
3280
|
-
revokeFamily:
|
|
3281
|
-
update:
|
|
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)
|
|
3282
3285
|
};
|
|
3283
3286
|
}
|
|
3284
3287
|
//#endregion
|
|
3285
3288
|
//#region src/cleanup.ts
|
|
3286
|
-
var
|
|
3287
|
-
function
|
|
3289
|
+
var gi = 10080 * 60 * 1e3;
|
|
3290
|
+
function _i(e) {
|
|
3288
3291
|
return async (t) => {
|
|
3289
|
-
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;
|
|
3290
3293
|
try {
|
|
3291
3294
|
let t = 0;
|
|
3292
3295
|
for (;;) {
|
|
@@ -3317,7 +3320,7 @@ function ui(e) {
|
|
|
3317
3320
|
}
|
|
3318
3321
|
//#endregion
|
|
3319
3322
|
//#region src/forms/create.ts
|
|
3320
|
-
function
|
|
3323
|
+
function vi(e) {
|
|
3321
3324
|
return async (n, r, i) => {
|
|
3322
3325
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3323
3326
|
id: a?.id ?? t(),
|
|
@@ -3336,7 +3339,7 @@ function di(e) {
|
|
|
3336
3339
|
}
|
|
3337
3340
|
//#endregion
|
|
3338
3341
|
//#region src/forms/list.ts
|
|
3339
|
-
function
|
|
3342
|
+
function yi(e) {
|
|
3340
3343
|
return async (t, n = {}) => {
|
|
3341
3344
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3342
3345
|
s && (c = D(e, c, s, []));
|
|
@@ -3370,7 +3373,7 @@ function fi(e) {
|
|
|
3370
3373
|
}
|
|
3371
3374
|
//#endregion
|
|
3372
3375
|
//#region src/forms/remove.ts
|
|
3373
|
-
function
|
|
3376
|
+
function bi(e) {
|
|
3374
3377
|
return async (t, n) => {
|
|
3375
3378
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3376
3379
|
return r > 0;
|
|
@@ -3378,7 +3381,7 @@ function pi(e) {
|
|
|
3378
3381
|
}
|
|
3379
3382
|
//#endregion
|
|
3380
3383
|
//#region src/forms/get.ts
|
|
3381
|
-
function
|
|
3384
|
+
function xi(e) {
|
|
3382
3385
|
return async (t, n) => {
|
|
3383
3386
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3384
3387
|
if (!r) return null;
|
|
@@ -3397,7 +3400,7 @@ function mi(e) {
|
|
|
3397
3400
|
}
|
|
3398
3401
|
//#endregion
|
|
3399
3402
|
//#region src/forms/update.ts
|
|
3400
|
-
function
|
|
3403
|
+
function Si(e) {
|
|
3401
3404
|
return async (t, n, r) => {
|
|
3402
3405
|
let i = {
|
|
3403
3406
|
...r,
|
|
@@ -3414,22 +3417,22 @@ function hi(e) {
|
|
|
3414
3417
|
}
|
|
3415
3418
|
//#endregion
|
|
3416
3419
|
//#region src/forms/index.ts
|
|
3417
|
-
function
|
|
3420
|
+
function Ci(e) {
|
|
3418
3421
|
return {
|
|
3419
|
-
create:
|
|
3420
|
-
get:
|
|
3421
|
-
list:
|
|
3422
|
-
remove:
|
|
3423
|
-
update:
|
|
3422
|
+
create: vi(e),
|
|
3423
|
+
get: xi(e),
|
|
3424
|
+
list: yi(e),
|
|
3425
|
+
remove: bi(e),
|
|
3426
|
+
update: Si(e)
|
|
3424
3427
|
};
|
|
3425
3428
|
}
|
|
3426
3429
|
//#endregion
|
|
3427
3430
|
//#region src/resourceServers/create.ts
|
|
3428
|
-
function
|
|
3431
|
+
function wi(e) {
|
|
3429
3432
|
return async (t, n, r) => {
|
|
3430
3433
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3431
3434
|
...n,
|
|
3432
|
-
id: i?.id ?? n.id ??
|
|
3435
|
+
id: i?.id ?? n.id ?? Ne(),
|
|
3433
3436
|
created_at: o,
|
|
3434
3437
|
updated_at: s
|
|
3435
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 = {
|
|
@@ -3450,7 +3453,7 @@ function _i(e) {
|
|
|
3450
3453
|
}
|
|
3451
3454
|
//#endregion
|
|
3452
3455
|
//#region src/resourceServers/get.ts
|
|
3453
|
-
function
|
|
3456
|
+
function Ti(e) {
|
|
3454
3457
|
return async (t, n) => {
|
|
3455
3458
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3456
3459
|
if (!r) return null;
|
|
@@ -3469,7 +3472,7 @@ function vi(e) {
|
|
|
3469
3472
|
}
|
|
3470
3473
|
//#endregion
|
|
3471
3474
|
//#region src/resourceServers/list.ts
|
|
3472
|
-
function
|
|
3475
|
+
function Ei(e) {
|
|
3473
3476
|
return async (t, n = {}) => {
|
|
3474
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);
|
|
3475
3478
|
if (s) {
|
|
@@ -3509,7 +3512,7 @@ function yi(e) {
|
|
|
3509
3512
|
}
|
|
3510
3513
|
//#endregion
|
|
3511
3514
|
//#region src/resourceServers/remove.ts
|
|
3512
|
-
function
|
|
3515
|
+
function Di(e) {
|
|
3513
3516
|
return async (t, n) => {
|
|
3514
3517
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3515
3518
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3517,7 +3520,7 @@ function bi(e) {
|
|
|
3517
3520
|
}
|
|
3518
3521
|
//#endregion
|
|
3519
3522
|
//#region src/resourceServers/update.ts
|
|
3520
|
-
function
|
|
3523
|
+
function Oi(e) {
|
|
3521
3524
|
return async (t, n, r) => {
|
|
3522
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 = {
|
|
3523
3526
|
...d,
|
|
@@ -3537,18 +3540,18 @@ function xi(e) {
|
|
|
3537
3540
|
}
|
|
3538
3541
|
//#endregion
|
|
3539
3542
|
//#region src/resourceServers/index.ts
|
|
3540
|
-
function
|
|
3543
|
+
function ki(e) {
|
|
3541
3544
|
return {
|
|
3542
|
-
create:
|
|
3543
|
-
get:
|
|
3544
|
-
list:
|
|
3545
|
-
remove:
|
|
3546
|
-
update:
|
|
3545
|
+
create: wi(e),
|
|
3546
|
+
get: Ti(e),
|
|
3547
|
+
list: Ei(e),
|
|
3548
|
+
remove: Di(e),
|
|
3549
|
+
update: Oi(e)
|
|
3547
3550
|
};
|
|
3548
3551
|
}
|
|
3549
3552
|
//#endregion
|
|
3550
3553
|
//#region src/roles/create.ts
|
|
3551
|
-
function
|
|
3554
|
+
function Ai(e) {
|
|
3552
3555
|
return async (n, r, i) => {
|
|
3553
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 = {
|
|
3554
3557
|
id: l,
|
|
@@ -3571,7 +3574,7 @@ function Ci(e) {
|
|
|
3571
3574
|
}
|
|
3572
3575
|
//#endregion
|
|
3573
3576
|
//#region src/roles/get.ts
|
|
3574
|
-
function
|
|
3577
|
+
function ji(e) {
|
|
3575
3578
|
return async (t, n) => {
|
|
3576
3579
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3577
3580
|
if (!r) return null;
|
|
@@ -3585,7 +3588,7 @@ function wi(e) {
|
|
|
3585
3588
|
}
|
|
3586
3589
|
//#endregion
|
|
3587
3590
|
//#region src/roles/list.ts
|
|
3588
|
-
function
|
|
3591
|
+
function Mi(e) {
|
|
3589
3592
|
return async (t, n) => {
|
|
3590
3593
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3591
3594
|
n.q && (r = D(e, r, n.q, ["name"]));
|
|
@@ -3614,7 +3617,7 @@ function Ti(e) {
|
|
|
3614
3617
|
}
|
|
3615
3618
|
//#endregion
|
|
3616
3619
|
//#region src/roles/update.ts
|
|
3617
|
-
function
|
|
3620
|
+
function Ni(e) {
|
|
3618
3621
|
return async (t, n, r) => {
|
|
3619
3622
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3620
3623
|
...o,
|
|
@@ -3627,7 +3630,7 @@ function Ei(e) {
|
|
|
3627
3630
|
}
|
|
3628
3631
|
//#endregion
|
|
3629
3632
|
//#region src/roles/remove.ts
|
|
3630
|
-
function
|
|
3633
|
+
function Pi(e) {
|
|
3631
3634
|
return async (t, n) => {
|
|
3632
3635
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3633
3636
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3635,23 +3638,23 @@ function Di(e) {
|
|
|
3635
3638
|
}
|
|
3636
3639
|
//#endregion
|
|
3637
3640
|
//#region src/roles/index.ts
|
|
3638
|
-
function
|
|
3641
|
+
function Fi(e) {
|
|
3639
3642
|
return {
|
|
3640
|
-
create:
|
|
3641
|
-
get:
|
|
3642
|
-
list:
|
|
3643
|
-
update:
|
|
3644
|
-
remove:
|
|
3643
|
+
create: Ai(e),
|
|
3644
|
+
get: ji(e),
|
|
3645
|
+
list: Mi(e),
|
|
3646
|
+
update: Ni(e),
|
|
3647
|
+
remove: Pi(e)
|
|
3645
3648
|
};
|
|
3646
3649
|
}
|
|
3647
3650
|
//#endregion
|
|
3648
3651
|
//#region src/role-permissions/assign.ts
|
|
3649
|
-
function
|
|
3652
|
+
function Ii(e) {
|
|
3650
3653
|
if (typeof e != "object" || !e) return !1;
|
|
3651
3654
|
let { code: t, message: n } = e;
|
|
3652
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"));
|
|
3653
3656
|
}
|
|
3654
|
-
function
|
|
3657
|
+
function Li(e) {
|
|
3655
3658
|
return async (t, n, r, i) => {
|
|
3656
3659
|
if (r.length === 0) return !0;
|
|
3657
3660
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3668,7 +3671,7 @@ function Ai(e) {
|
|
|
3668
3671
|
try {
|
|
3669
3672
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3670
3673
|
} catch (e) {
|
|
3671
|
-
if (
|
|
3674
|
+
if (Ii(e)) continue;
|
|
3672
3675
|
throw e;
|
|
3673
3676
|
}
|
|
3674
3677
|
}
|
|
@@ -3680,7 +3683,7 @@ function Ai(e) {
|
|
|
3680
3683
|
}
|
|
3681
3684
|
//#endregion
|
|
3682
3685
|
//#region src/role-permissions/remove.ts
|
|
3683
|
-
function
|
|
3686
|
+
function Ri(e) {
|
|
3684
3687
|
return async (t, n, r) => {
|
|
3685
3688
|
if (r.length === 0) return !0;
|
|
3686
3689
|
try {
|
|
@@ -3692,7 +3695,7 @@ function ji(e) {
|
|
|
3692
3695
|
}
|
|
3693
3696
|
//#endregion
|
|
3694
3697
|
//#region src/role-permissions/list.ts
|
|
3695
|
-
function
|
|
3698
|
+
function zi(e) {
|
|
3696
3699
|
return async (t, n, r = {}) => {
|
|
3697
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([
|
|
3698
3701
|
"role_permissions.role_id",
|
|
@@ -3713,16 +3716,16 @@ function Mi(e) {
|
|
|
3713
3716
|
}
|
|
3714
3717
|
//#endregion
|
|
3715
3718
|
//#region src/role-permissions/index.ts
|
|
3716
|
-
function
|
|
3719
|
+
function Bi(e) {
|
|
3717
3720
|
return {
|
|
3718
|
-
assign:
|
|
3719
|
-
remove:
|
|
3720
|
-
list:
|
|
3721
|
+
assign: Li(e),
|
|
3722
|
+
remove: Ri(e),
|
|
3723
|
+
list: zi(e)
|
|
3721
3724
|
};
|
|
3722
3725
|
}
|
|
3723
3726
|
//#endregion
|
|
3724
3727
|
//#region src/grants/create.ts
|
|
3725
|
-
function
|
|
3728
|
+
function Vi(e) {
|
|
3726
3729
|
return async (n, r) => {
|
|
3727
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();
|
|
3728
3731
|
if (s) {
|
|
@@ -3759,7 +3762,7 @@ function Pi(e) {
|
|
|
3759
3762
|
}
|
|
3760
3763
|
//#endregion
|
|
3761
3764
|
//#region src/grants/get.ts
|
|
3762
|
-
function
|
|
3765
|
+
function Hi(e) {
|
|
3763
3766
|
return async (t, n, r, i) => {
|
|
3764
3767
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3765
3768
|
return a ? {
|
|
@@ -3773,7 +3776,7 @@ function Fi(e) {
|
|
|
3773
3776
|
}
|
|
3774
3777
|
//#endregion
|
|
3775
3778
|
//#region src/grants/list.ts
|
|
3776
|
-
function
|
|
3779
|
+
function Ui(e) {
|
|
3777
3780
|
return async (t, n = {}) => {
|
|
3778
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);
|
|
3779
3782
|
c && (l = D(e, l, c, [
|
|
@@ -3811,26 +3814,26 @@ function Ii(e) {
|
|
|
3811
3814
|
}
|
|
3812
3815
|
//#endregion
|
|
3813
3816
|
//#region src/grants/remove.ts
|
|
3814
|
-
function
|
|
3817
|
+
function Wi(e) {
|
|
3815
3818
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3816
3819
|
}
|
|
3817
|
-
function
|
|
3820
|
+
function Gi(e) {
|
|
3818
3821
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3819
3822
|
}
|
|
3820
3823
|
//#endregion
|
|
3821
3824
|
//#region src/grants/index.ts
|
|
3822
|
-
function
|
|
3825
|
+
function Ki(e) {
|
|
3823
3826
|
return {
|
|
3824
|
-
create:
|
|
3825
|
-
get:
|
|
3826
|
-
list:
|
|
3827
|
-
remove:
|
|
3828
|
-
removeByUser:
|
|
3827
|
+
create: Vi(e),
|
|
3828
|
+
get: Hi(e),
|
|
3829
|
+
list: Ui(e),
|
|
3830
|
+
remove: Wi(e),
|
|
3831
|
+
removeByUser: Gi(e)
|
|
3829
3832
|
};
|
|
3830
3833
|
}
|
|
3831
3834
|
//#endregion
|
|
3832
3835
|
//#region src/user-permissions/create.ts
|
|
3833
|
-
function
|
|
3836
|
+
function qi(e) {
|
|
3834
3837
|
return async (t, n, r, i, a) => {
|
|
3835
3838
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3836
3839
|
try {
|
|
@@ -3850,7 +3853,7 @@ function Bi(e) {
|
|
|
3850
3853
|
}
|
|
3851
3854
|
//#endregion
|
|
3852
3855
|
//#region src/user-permissions/remove.ts
|
|
3853
|
-
function
|
|
3856
|
+
function Ji(e) {
|
|
3854
3857
|
return async (t, n, r, i) => {
|
|
3855
3858
|
try {
|
|
3856
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);
|
|
@@ -3862,7 +3865,7 @@ function Vi(e) {
|
|
|
3862
3865
|
}
|
|
3863
3866
|
//#endregion
|
|
3864
3867
|
//#region src/user-permissions/list.ts
|
|
3865
|
-
function
|
|
3868
|
+
function Yi(e) {
|
|
3866
3869
|
return async (t, n, r, i) => {
|
|
3867
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([
|
|
3868
3871
|
"user_permissions.resource_server_identifier",
|
|
@@ -3885,17 +3888,17 @@ function Hi(e) {
|
|
|
3885
3888
|
}
|
|
3886
3889
|
//#endregion
|
|
3887
3890
|
//#region src/user-permissions/index.ts
|
|
3888
|
-
function
|
|
3891
|
+
function Xi(e) {
|
|
3889
3892
|
return {
|
|
3890
|
-
create:
|
|
3891
|
-
remove:
|
|
3892
|
-
list:
|
|
3893
|
+
create: qi(e),
|
|
3894
|
+
remove: Ji(e),
|
|
3895
|
+
list: Yi(e)
|
|
3893
3896
|
};
|
|
3894
3897
|
}
|
|
3895
3898
|
//#endregion
|
|
3896
3899
|
//#region src/user-permissions/adapter.ts
|
|
3897
|
-
function
|
|
3898
|
-
let t =
|
|
3900
|
+
function Zi(e) {
|
|
3901
|
+
let t = Xi(e);
|
|
3899
3902
|
return {
|
|
3900
3903
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3901
3904
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3904,7 +3907,7 @@ function Wi(e) {
|
|
|
3904
3907
|
}
|
|
3905
3908
|
//#endregion
|
|
3906
3909
|
//#region src/user-roles/list.ts
|
|
3907
|
-
function
|
|
3910
|
+
function Qi(e) {
|
|
3908
3911
|
return async (t, n, r, i) => {
|
|
3909
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([
|
|
3910
3913
|
"r.id",
|
|
@@ -3918,7 +3921,7 @@ function Gi(e) {
|
|
|
3918
3921
|
}
|
|
3919
3922
|
//#endregion
|
|
3920
3923
|
//#region src/user-roles/list-users.ts
|
|
3921
|
-
function
|
|
3924
|
+
function $i(e) {
|
|
3922
3925
|
return async (t, n, r) => {
|
|
3923
3926
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3924
3927
|
if (M(r)) {
|
|
@@ -3946,7 +3949,7 @@ function Ki(e) {
|
|
|
3946
3949
|
}
|
|
3947
3950
|
//#endregion
|
|
3948
3951
|
//#region src/user-roles/create.ts
|
|
3949
|
-
function
|
|
3952
|
+
function ea(e) {
|
|
3950
3953
|
return async (t, n, r, i, a) => {
|
|
3951
3954
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3952
3955
|
try {
|
|
@@ -3964,7 +3967,7 @@ function qi(e) {
|
|
|
3964
3967
|
}
|
|
3965
3968
|
//#endregion
|
|
3966
3969
|
//#region src/user-roles/remove.ts
|
|
3967
|
-
function
|
|
3970
|
+
function ta(e) {
|
|
3968
3971
|
return async (t, n, r, i) => {
|
|
3969
3972
|
try {
|
|
3970
3973
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3976,18 +3979,18 @@ function Ji(e) {
|
|
|
3976
3979
|
}
|
|
3977
3980
|
//#endregion
|
|
3978
3981
|
//#region src/user-roles/index.ts
|
|
3979
|
-
function
|
|
3982
|
+
function na(e) {
|
|
3980
3983
|
return {
|
|
3981
|
-
list:
|
|
3982
|
-
listUsers:
|
|
3983
|
-
create:
|
|
3984
|
-
remove:
|
|
3984
|
+
list: Qi(e),
|
|
3985
|
+
listUsers: $i(e),
|
|
3986
|
+
create: ea(e),
|
|
3987
|
+
remove: ta(e)
|
|
3985
3988
|
};
|
|
3986
3989
|
}
|
|
3987
3990
|
//#endregion
|
|
3988
3991
|
//#region src/user-roles/adapter.ts
|
|
3989
|
-
function
|
|
3990
|
-
let t =
|
|
3992
|
+
function ra(e) {
|
|
3993
|
+
let t = na(e);
|
|
3991
3994
|
return {
|
|
3992
3995
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3993
3996
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3997,11 +4000,11 @@ function Xi(e) {
|
|
|
3997
4000
|
}
|
|
3998
4001
|
//#endregion
|
|
3999
4002
|
//#region src/organizations/create.ts
|
|
4000
|
-
function
|
|
4003
|
+
function ia(e) {
|
|
4001
4004
|
return async (t, n, r) => {
|
|
4002
4005
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4003
4006
|
...n,
|
|
4004
|
-
id: i?.id || n.id ||
|
|
4007
|
+
id: i?.id || n.id || Oe(),
|
|
4005
4008
|
tenant_id: t,
|
|
4006
4009
|
created_at: i?.created_at ?? a,
|
|
4007
4010
|
updated_at: i?.updated_at ?? a,
|
|
@@ -4025,7 +4028,7 @@ function Zi(e) {
|
|
|
4025
4028
|
}
|
|
4026
4029
|
//#endregion
|
|
4027
4030
|
//#region src/organizations/get.ts
|
|
4028
|
-
function
|
|
4031
|
+
function aa(e) {
|
|
4029
4032
|
return async (t, n) => {
|
|
4030
4033
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4031
4034
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4039,13 +4042,13 @@ function Qi(e) {
|
|
|
4039
4042
|
}
|
|
4040
4043
|
//#endregion
|
|
4041
4044
|
//#region src/organizations/list.ts
|
|
4042
|
-
var
|
|
4043
|
-
function
|
|
4045
|
+
var R = ["name", "display_name"];
|
|
4046
|
+
function oa(e) {
|
|
4044
4047
|
return async (t, n) => {
|
|
4045
4048
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4046
4049
|
if (n?.q) {
|
|
4047
|
-
let t = S(n.q,
|
|
4048
|
-
t && (r = D(e, r, t,
|
|
4050
|
+
let t = S(n.q, R);
|
|
4051
|
+
t && (r = D(e, r, t, R));
|
|
4049
4052
|
}
|
|
4050
4053
|
if (M(n)) {
|
|
4051
4054
|
let { rows: e, limit: t, next: i } = await N(r.selectAll(), n, {
|
|
@@ -4081,8 +4084,8 @@ function $i(e) {
|
|
|
4081
4084
|
if (n?.include_totals) {
|
|
4082
4085
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4083
4086
|
if (n?.q) {
|
|
4084
|
-
let t = S(n.q,
|
|
4085
|
-
t && (r = D(e, r, t,
|
|
4087
|
+
let t = S(n.q, R);
|
|
4088
|
+
t && (r = D(e, r, t, R));
|
|
4086
4089
|
}
|
|
4087
4090
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4088
4091
|
u = Number(i?.count || 0);
|
|
@@ -4105,12 +4108,12 @@ function $i(e) {
|
|
|
4105
4108
|
}
|
|
4106
4109
|
//#endregion
|
|
4107
4110
|
//#region src/organizations/remove.ts
|
|
4108
|
-
function
|
|
4111
|
+
function sa(e) {
|
|
4109
4112
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4110
4113
|
}
|
|
4111
4114
|
//#endregion
|
|
4112
4115
|
//#region src/organizations/update.ts
|
|
4113
|
-
function
|
|
4116
|
+
function ca(e) {
|
|
4114
4117
|
return async (t, n, r) => {
|
|
4115
4118
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4116
4119
|
...c,
|
|
@@ -4126,18 +4129,18 @@ function ta(e) {
|
|
|
4126
4129
|
}
|
|
4127
4130
|
//#endregion
|
|
4128
4131
|
//#region src/organizations/index.ts
|
|
4129
|
-
function
|
|
4132
|
+
function la(e) {
|
|
4130
4133
|
return {
|
|
4131
|
-
create:
|
|
4132
|
-
get:
|
|
4133
|
-
list:
|
|
4134
|
-
remove:
|
|
4135
|
-
update:
|
|
4134
|
+
create: ia(e),
|
|
4135
|
+
get: aa(e),
|
|
4136
|
+
list: oa(e),
|
|
4137
|
+
remove: sa(e),
|
|
4138
|
+
update: ca(e)
|
|
4136
4139
|
};
|
|
4137
4140
|
}
|
|
4138
4141
|
//#endregion
|
|
4139
4142
|
//#region src/organization-connections/index.ts
|
|
4140
|
-
function
|
|
4143
|
+
function z(e, t) {
|
|
4141
4144
|
return {
|
|
4142
4145
|
connection_id: e.connection_id,
|
|
4143
4146
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4151,14 +4154,14 @@ function H(e, t) {
|
|
|
4151
4154
|
updated_at: e.updated_at
|
|
4152
4155
|
};
|
|
4153
4156
|
}
|
|
4154
|
-
async function
|
|
4157
|
+
async function B(e, t, n) {
|
|
4155
4158
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4156
4159
|
if (r) return {
|
|
4157
4160
|
name: r.name,
|
|
4158
4161
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4159
4162
|
};
|
|
4160
4163
|
}
|
|
4161
|
-
function
|
|
4164
|
+
function ua(e) {
|
|
4162
4165
|
return {
|
|
4163
4166
|
async create(t, n, r, i) {
|
|
4164
4167
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4171,19 +4174,19 @@ function ra(e) {
|
|
|
4171
4174
|
created_at: a?.created_at ?? o,
|
|
4172
4175
|
updated_at: a?.updated_at ?? o
|
|
4173
4176
|
};
|
|
4174
|
-
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));
|
|
4175
4178
|
},
|
|
4176
4179
|
async list(t, n) {
|
|
4177
4180
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4178
4181
|
for (let n of r) {
|
|
4179
|
-
let r = await
|
|
4180
|
-
i.push(
|
|
4182
|
+
let r = await B(e, t, n.connection_id);
|
|
4183
|
+
i.push(z(n, r));
|
|
4181
4184
|
}
|
|
4182
4185
|
return i;
|
|
4183
4186
|
},
|
|
4184
4187
|
async get(t, n, r) {
|
|
4185
4188
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4186
|
-
return i ?
|
|
4189
|
+
return i ? z(i, await B(e, t, r)) : null;
|
|
4187
4190
|
},
|
|
4188
4191
|
async update(t, n, r, i) {
|
|
4189
4192
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4191,7 +4194,7 @@ function ra(e) {
|
|
|
4191
4194
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4192
4195
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4193
4196
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4194
|
-
return s ?
|
|
4197
|
+
return s ? z(s, await B(e, t, r)) : null;
|
|
4195
4198
|
},
|
|
4196
4199
|
async remove(t, n, r) {
|
|
4197
4200
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4201,7 +4204,7 @@ function ra(e) {
|
|
|
4201
4204
|
}
|
|
4202
4205
|
//#endregion
|
|
4203
4206
|
//#region src/user-organizations/create.ts
|
|
4204
|
-
function
|
|
4207
|
+
function da(e) {
|
|
4205
4208
|
return async (n, r, i) => {
|
|
4206
4209
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4207
4210
|
id: a?.id ?? t(),
|
|
@@ -4221,7 +4224,7 @@ function ia(e) {
|
|
|
4221
4224
|
}
|
|
4222
4225
|
//#endregion
|
|
4223
4226
|
//#region src/user-organizations/get.ts
|
|
4224
|
-
function
|
|
4227
|
+
function fa(e) {
|
|
4225
4228
|
return async (t, n) => {
|
|
4226
4229
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4227
4230
|
return r ? {
|
|
@@ -4235,18 +4238,13 @@ function aa(e) {
|
|
|
4235
4238
|
}
|
|
4236
4239
|
//#endregion
|
|
4237
4240
|
//#region src/user-organizations/list.ts
|
|
4238
|
-
function
|
|
4241
|
+
function V(e, t) {
|
|
4242
|
+
return Ce(e.slice(t.length + 1));
|
|
4243
|
+
}
|
|
4244
|
+
function pa(e) {
|
|
4239
4245
|
return async (t, n) => {
|
|
4240
4246
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4241
|
-
|
|
4242
|
-
if (n.q.startsWith("user_id:")) {
|
|
4243
|
-
let e = n.q.replace("user_id:", "");
|
|
4244
|
-
r = r.where("user_id", "=", e);
|
|
4245
|
-
} else if (n.q.startsWith("organization_id:")) {
|
|
4246
|
-
let e = n.q.replace("organization_id:", "");
|
|
4247
|
-
r = r.where("organization_id", "=", e);
|
|
4248
|
-
}
|
|
4249
|
-
}
|
|
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"))));
|
|
4250
4248
|
let i = (e) => ({
|
|
4251
4249
|
id: e.id,
|
|
4252
4250
|
user_id: e.user_id,
|
|
@@ -4268,15 +4266,7 @@ function oa(e) {
|
|
|
4268
4266
|
};
|
|
4269
4267
|
}
|
|
4270
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);
|
|
4271
|
-
|
|
4272
|
-
if (n.q.startsWith("user_id:")) {
|
|
4273
|
-
let e = n.q.replace("user_id:", "");
|
|
4274
|
-
l = l.where("user_id", "=", e);
|
|
4275
|
-
} else if (n.q.startsWith("organization_id:")) {
|
|
4276
|
-
let e = n.q.replace("organization_id:", "");
|
|
4277
|
-
l = l.where("organization_id", "=", e);
|
|
4278
|
-
}
|
|
4279
|
-
}
|
|
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"))));
|
|
4280
4270
|
let u = await l.executeTakeFirst();
|
|
4281
4271
|
return {
|
|
4282
4272
|
userOrganizations: c.map(i),
|
|
@@ -4288,7 +4278,7 @@ function oa(e) {
|
|
|
4288
4278
|
}
|
|
4289
4279
|
//#endregion
|
|
4290
4280
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4291
|
-
function
|
|
4281
|
+
function ma(e) {
|
|
4292
4282
|
return async (t, n, r) => {
|
|
4293
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([
|
|
4294
4284
|
"organizations.id",
|
|
@@ -4325,12 +4315,12 @@ function sa(e) {
|
|
|
4325
4315
|
}
|
|
4326
4316
|
//#endregion
|
|
4327
4317
|
//#region src/user-organizations/remove.ts
|
|
4328
|
-
function
|
|
4318
|
+
function ha(e) {
|
|
4329
4319
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4330
4320
|
}
|
|
4331
4321
|
//#endregion
|
|
4332
4322
|
//#region src/user-organizations/update.ts
|
|
4333
|
-
function
|
|
4323
|
+
function ga(e) {
|
|
4334
4324
|
return async (t, n, r) => {
|
|
4335
4325
|
let i = {
|
|
4336
4326
|
...r,
|
|
@@ -4341,21 +4331,21 @@ function la(e) {
|
|
|
4341
4331
|
}
|
|
4342
4332
|
//#endregion
|
|
4343
4333
|
//#region src/user-organizations/index.ts
|
|
4344
|
-
function
|
|
4334
|
+
function _a(e) {
|
|
4345
4335
|
return {
|
|
4346
|
-
create:
|
|
4347
|
-
get:
|
|
4348
|
-
list:
|
|
4349
|
-
listUserOrganizations:
|
|
4350
|
-
remove:
|
|
4351
|
-
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)
|
|
4352
4342
|
};
|
|
4353
4343
|
}
|
|
4354
4344
|
//#endregion
|
|
4355
4345
|
//#region src/invites/create.ts
|
|
4356
|
-
function
|
|
4346
|
+
function va(e) {
|
|
4357
4347
|
return async (t, n, r) => {
|
|
4358
|
-
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 = {
|
|
4359
4349
|
id: a,
|
|
4360
4350
|
tenant_id: t,
|
|
4361
4351
|
organization_id: n.organization_id,
|
|
@@ -4399,11 +4389,11 @@ function da(e) {
|
|
|
4399
4389
|
}
|
|
4400
4390
|
//#endregion
|
|
4401
4391
|
//#region src/invites/get.ts
|
|
4402
|
-
function
|
|
4392
|
+
function ya(e) {
|
|
4403
4393
|
return async (t, n) => {
|
|
4404
4394
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4405
4395
|
return r ? l({
|
|
4406
|
-
...
|
|
4396
|
+
...bt(r, {
|
|
4407
4397
|
inviter: {},
|
|
4408
4398
|
invitee: {},
|
|
4409
4399
|
app_metadata: {},
|
|
@@ -4416,7 +4406,7 @@ function fa(e) {
|
|
|
4416
4406
|
}
|
|
4417
4407
|
//#endregion
|
|
4418
4408
|
//#region src/invites/list.ts
|
|
4419
|
-
function
|
|
4409
|
+
function ba(e) {
|
|
4420
4410
|
return async (t, n) => {
|
|
4421
4411
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4422
4412
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4424,7 +4414,7 @@ function pa(e) {
|
|
|
4424
4414
|
r = r.offset(e);
|
|
4425
4415
|
}
|
|
4426
4416
|
let i = (await r.execute()).map((e) => l({
|
|
4427
|
-
...
|
|
4417
|
+
...bt(e, {
|
|
4428
4418
|
inviter: {},
|
|
4429
4419
|
invitee: {},
|
|
4430
4420
|
app_metadata: {},
|
|
@@ -4443,12 +4433,12 @@ function pa(e) {
|
|
|
4443
4433
|
}
|
|
4444
4434
|
//#endregion
|
|
4445
4435
|
//#region src/invites/remove.ts
|
|
4446
|
-
function
|
|
4436
|
+
function xa(e) {
|
|
4447
4437
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4448
4438
|
}
|
|
4449
4439
|
//#endregion
|
|
4450
4440
|
//#region src/invites/update.ts
|
|
4451
|
-
function
|
|
4441
|
+
function Sa(e) {
|
|
4452
4442
|
return async (t, n, r) => {
|
|
4453
4443
|
let i = {};
|
|
4454
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;
|
|
@@ -4456,35 +4446,35 @@ function ha(e) {
|
|
|
4456
4446
|
}
|
|
4457
4447
|
//#endregion
|
|
4458
4448
|
//#region src/invites/index.ts
|
|
4459
|
-
function
|
|
4449
|
+
function Ca(e) {
|
|
4460
4450
|
return {
|
|
4461
|
-
create:
|
|
4462
|
-
get:
|
|
4463
|
-
list:
|
|
4464
|
-
remove:
|
|
4465
|
-
update:
|
|
4451
|
+
create: va(e),
|
|
4452
|
+
get: ya(e),
|
|
4453
|
+
list: ba(e),
|
|
4454
|
+
remove: xa(e),
|
|
4455
|
+
update: Sa(e)
|
|
4466
4456
|
};
|
|
4467
4457
|
}
|
|
4468
4458
|
//#endregion
|
|
4469
4459
|
//#region src/stats/index.ts
|
|
4470
|
-
var
|
|
4471
|
-
function
|
|
4460
|
+
var wa = ["s"], Ta = ["pwd_leak"];
|
|
4461
|
+
function Ea(e) {
|
|
4472
4462
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4473
4463
|
}
|
|
4474
|
-
function
|
|
4464
|
+
function Da(e) {
|
|
4475
4465
|
return e.toISOString().split("T")[0];
|
|
4476
4466
|
}
|
|
4477
|
-
function
|
|
4467
|
+
function Oa(e) {
|
|
4478
4468
|
return {
|
|
4479
4469
|
async getDaily(t, n = {}) {
|
|
4480
4470
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4481
4471
|
o.setDate(o.getDate() - 30);
|
|
4482
|
-
let s = r ?
|
|
4472
|
+
let s = r ? Ea(r) : Da(o), c = i ? Ea(i) : Da(a), l = f`DATE(logs.date)`;
|
|
4483
4473
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4484
4474
|
l.as("date"),
|
|
4485
|
-
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"),
|
|
4486
4476
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4487
|
-
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"),
|
|
4488
4478
|
e.fn.min("date").as("first_event"),
|
|
4489
4479
|
e.fn.max("date").as("last_event")
|
|
4490
4480
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4498,13 +4488,13 @@ function xa(e) {
|
|
|
4498
4488
|
},
|
|
4499
4489
|
async getActiveUsers(t) {
|
|
4500
4490
|
let n = /* @__PURE__ */ new Date();
|
|
4501
|
-
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;
|
|
4502
4492
|
}
|
|
4503
4493
|
};
|
|
4504
4494
|
}
|
|
4505
4495
|
//#endregion
|
|
4506
4496
|
//#region src/analytics/index.ts
|
|
4507
|
-
var
|
|
4497
|
+
var ka = {
|
|
4508
4498
|
"active-users": ["s", "seacft"],
|
|
4509
4499
|
logins: [
|
|
4510
4500
|
"s",
|
|
@@ -4534,7 +4524,7 @@ var Sa = {
|
|
|
4534
4524
|
"fvr"
|
|
4535
4525
|
],
|
|
4536
4526
|
"codes-sent": ["cls", "cs"]
|
|
4537
|
-
},
|
|
4527
|
+
}, Aa = {
|
|
4538
4528
|
"active-users": {
|
|
4539
4529
|
alias: "active_users",
|
|
4540
4530
|
type: "UInt64",
|
|
@@ -4591,14 +4581,14 @@ var Sa = {
|
|
|
4591
4581
|
agg: "count"
|
|
4592
4582
|
}
|
|
4593
4583
|
};
|
|
4594
|
-
async function
|
|
4584
|
+
async function ja(e) {
|
|
4595
4585
|
try {
|
|
4596
4586
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4597
4587
|
} catch {
|
|
4598
4588
|
return "sqlite";
|
|
4599
4589
|
}
|
|
4600
4590
|
}
|
|
4601
|
-
function
|
|
4591
|
+
function H(e, t) {
|
|
4602
4592
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4603
4593
|
timeZone: e,
|
|
4604
4594
|
year: "numeric",
|
|
@@ -4613,7 +4603,7 @@ function W(e, t) {
|
|
|
4613
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);
|
|
4614
4604
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4615
4605
|
}
|
|
4616
|
-
var
|
|
4606
|
+
var Ma = [
|
|
4617
4607
|
"January",
|
|
4618
4608
|
"February",
|
|
4619
4609
|
"March",
|
|
@@ -4627,22 +4617,22 @@ var Ta = [
|
|
|
4627
4617
|
"November",
|
|
4628
4618
|
"December"
|
|
4629
4619
|
];
|
|
4630
|
-
function
|
|
4631
|
-
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)));
|
|
4632
4622
|
for (let t = 1; t < 12; t++) {
|
|
4633
|
-
let i =
|
|
4634
|
-
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').`);
|
|
4635
4625
|
}
|
|
4636
4626
|
}
|
|
4637
|
-
function
|
|
4627
|
+
function Pa(e) {
|
|
4638
4628
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4639
4629
|
return t * (Number(n) * 60 + Number(r));
|
|
4640
4630
|
}
|
|
4641
|
-
function
|
|
4631
|
+
function Fa(e, t) {
|
|
4642
4632
|
let n;
|
|
4643
4633
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4644
4634
|
else {
|
|
4645
|
-
let e =
|
|
4635
|
+
let e = Pa(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4646
4636
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4647
4637
|
}
|
|
4648
4638
|
switch (e) {
|
|
@@ -4653,7 +4643,7 @@ function Oa(e, t) {
|
|
|
4653
4643
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4654
4644
|
}
|
|
4655
4645
|
}
|
|
4656
|
-
function
|
|
4646
|
+
function Ia(e, t) {
|
|
4657
4647
|
if (t === "+00:00") switch (e) {
|
|
4658
4648
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4659
4649
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4664,7 +4654,7 @@ function ka(e, t) {
|
|
|
4664
4654
|
}
|
|
4665
4655
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4666
4656
|
}
|
|
4667
|
-
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)`;
|
|
4668
4658
|
switch (e) {
|
|
4669
4659
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4670
4660
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4673,12 +4663,12 @@ function ka(e, t) {
|
|
|
4673
4663
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4674
4664
|
}
|
|
4675
4665
|
}
|
|
4676
|
-
function
|
|
4677
|
-
|
|
4678
|
-
let i =
|
|
4679
|
-
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);
|
|
4680
4670
|
}
|
|
4681
|
-
function
|
|
4671
|
+
function Ra(e) {
|
|
4682
4672
|
switch (e) {
|
|
4683
4673
|
case "connection": return "logs.connection";
|
|
4684
4674
|
case "client_id": return "logs.client_id";
|
|
@@ -4687,15 +4677,15 @@ function ja(e) {
|
|
|
4687
4677
|
case "time": throw Error("time dimension is handled separately");
|
|
4688
4678
|
}
|
|
4689
4679
|
}
|
|
4690
|
-
function
|
|
4691
|
-
let t = null, n = () => (t ||=
|
|
4680
|
+
function za(e) {
|
|
4681
|
+
let t = null, n = () => (t ||= ja(e), t);
|
|
4692
4682
|
return {
|
|
4693
4683
|
async query(t, r, i) {
|
|
4694
|
-
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);
|
|
4695
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));
|
|
4696
4686
|
let d = [], p = [];
|
|
4697
4687
|
for (let e of i.group_by) if (e === "time") {
|
|
4698
|
-
let e =
|
|
4688
|
+
let e = La(i.interval, i.tz, new Date(i.from), c);
|
|
4699
4689
|
p.push({
|
|
4700
4690
|
alias: "time",
|
|
4701
4691
|
expr: e
|
|
@@ -4704,7 +4694,7 @@ function Ma(e) {
|
|
|
4704
4694
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4705
4695
|
});
|
|
4706
4696
|
} else {
|
|
4707
|
-
let t =
|
|
4697
|
+
let t = Ra(e);
|
|
4708
4698
|
p.push({
|
|
4709
4699
|
alias: e,
|
|
4710
4700
|
expr: f`${f.ref(t)}`
|
|
@@ -4779,7 +4769,7 @@ function Ma(e) {
|
|
|
4779
4769
|
}
|
|
4780
4770
|
//#endregion
|
|
4781
4771
|
//#region src/customText/index.ts
|
|
4782
|
-
function
|
|
4772
|
+
function Ba(e) {
|
|
4783
4773
|
return {
|
|
4784
4774
|
async get(t, n, r) {
|
|
4785
4775
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4818,9 +4808,9 @@ function Na(e) {
|
|
|
4818
4808
|
}
|
|
4819
4809
|
//#endregion
|
|
4820
4810
|
//#region src/authenticationMethods/create.ts
|
|
4821
|
-
function
|
|
4811
|
+
function Va(e) {
|
|
4822
4812
|
return async (t, n, r) => {
|
|
4823
|
-
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();
|
|
4824
4814
|
return await e.insertInto("authentication_methods").values({
|
|
4825
4815
|
id: s,
|
|
4826
4816
|
tenant_id: t,
|
|
@@ -4857,7 +4847,7 @@ function Pa(e) {
|
|
|
4857
4847
|
}
|
|
4858
4848
|
//#endregion
|
|
4859
4849
|
//#region src/authenticationMethods/get.ts
|
|
4860
|
-
function
|
|
4850
|
+
function Ha(e) {
|
|
4861
4851
|
return async (t, n) => {
|
|
4862
4852
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4863
4853
|
return r ? {
|
|
@@ -4880,7 +4870,7 @@ function Fa(e) {
|
|
|
4880
4870
|
}
|
|
4881
4871
|
//#endregion
|
|
4882
4872
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4883
|
-
function
|
|
4873
|
+
function Ua(e) {
|
|
4884
4874
|
return async (t, n) => {
|
|
4885
4875
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4886
4876
|
return r ? {
|
|
@@ -4903,7 +4893,7 @@ function Ia(e) {
|
|
|
4903
4893
|
}
|
|
4904
4894
|
//#endregion
|
|
4905
4895
|
//#region src/authenticationMethods/list.ts
|
|
4906
|
-
function
|
|
4896
|
+
function Wa(e) {
|
|
4907
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) => ({
|
|
4908
4898
|
id: e.id,
|
|
4909
4899
|
user_id: e.user_id,
|
|
@@ -4923,35 +4913,35 @@ function La(e) {
|
|
|
4923
4913
|
}
|
|
4924
4914
|
//#endregion
|
|
4925
4915
|
//#region src/authenticationMethods/update.ts
|
|
4926
|
-
function
|
|
4916
|
+
function Ga(e) {
|
|
4927
4917
|
return async (t, n, r) => {
|
|
4928
4918
|
let i = { updated_at_ts: Date.now() };
|
|
4929
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();
|
|
4930
|
-
let a = await
|
|
4920
|
+
let a = await Ha(e)(t, n);
|
|
4931
4921
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4932
4922
|
return a;
|
|
4933
4923
|
};
|
|
4934
4924
|
}
|
|
4935
4925
|
//#endregion
|
|
4936
4926
|
//#region src/authenticationMethods/remove.ts
|
|
4937
|
-
function
|
|
4927
|
+
function Ka(e) {
|
|
4938
4928
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4939
4929
|
}
|
|
4940
4930
|
//#endregion
|
|
4941
4931
|
//#region src/authenticationMethods/index.ts
|
|
4942
|
-
function
|
|
4932
|
+
function qa(e) {
|
|
4943
4933
|
return {
|
|
4944
|
-
create:
|
|
4945
|
-
get:
|
|
4946
|
-
getByCredentialId:
|
|
4947
|
-
list:
|
|
4948
|
-
update:
|
|
4949
|
-
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)
|
|
4950
4940
|
};
|
|
4951
4941
|
}
|
|
4952
4942
|
//#endregion
|
|
4953
4943
|
//#region src/outbox/getByIds.ts
|
|
4954
|
-
function
|
|
4944
|
+
function Ja(e) {
|
|
4955
4945
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4956
4946
|
...JSON.parse(e.payload),
|
|
4957
4947
|
id: e.id,
|
|
@@ -4964,7 +4954,7 @@ function Va(e) {
|
|
|
4964
4954
|
}
|
|
4965
4955
|
//#endregion
|
|
4966
4956
|
//#region src/outbox/getUnprocessed.ts
|
|
4967
|
-
function
|
|
4957
|
+
function Ya(e) {
|
|
4968
4958
|
return async (t) => {
|
|
4969
4959
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4970
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) => ({
|
|
@@ -4980,7 +4970,7 @@ function Ha(e) {
|
|
|
4980
4970
|
}
|
|
4981
4971
|
//#endregion
|
|
4982
4972
|
//#region src/outbox/claimEvents.ts
|
|
4983
|
-
function
|
|
4973
|
+
function Xa(e) {
|
|
4984
4974
|
return async (t, n, r) => {
|
|
4985
4975
|
if (t.length === 0) return [];
|
|
4986
4976
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4992,7 +4982,7 @@ function Ua(e) {
|
|
|
4992
4982
|
}
|
|
4993
4983
|
//#endregion
|
|
4994
4984
|
//#region src/outbox/markProcessed.ts
|
|
4995
|
-
function
|
|
4985
|
+
function Za(e) {
|
|
4996
4986
|
return async (t) => {
|
|
4997
4987
|
if (t.length === 0) return;
|
|
4998
4988
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5001,7 +4991,7 @@ function Wa(e) {
|
|
|
5001
4991
|
}
|
|
5002
4992
|
//#endregion
|
|
5003
4993
|
//#region src/outbox/markRetry.ts
|
|
5004
|
-
function
|
|
4994
|
+
function Qa(e) {
|
|
5005
4995
|
return async (t, n, r) => {
|
|
5006
4996
|
await e.updateTable("outbox_events").set({
|
|
5007
4997
|
error: n,
|
|
@@ -5014,7 +5004,7 @@ function Ga(e) {
|
|
|
5014
5004
|
}
|
|
5015
5005
|
//#endregion
|
|
5016
5006
|
//#region src/outbox/deadLetter.ts
|
|
5017
|
-
function
|
|
5007
|
+
function $a(e) {
|
|
5018
5008
|
return async (t, n) => {
|
|
5019
5009
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5020
5010
|
await e.updateTable("outbox_events").set({
|
|
@@ -5026,7 +5016,7 @@ function Ka(e) {
|
|
|
5026
5016
|
}
|
|
5027
5017
|
//#endregion
|
|
5028
5018
|
//#region src/outbox/listFailed.ts
|
|
5029
|
-
function
|
|
5019
|
+
function eo(e) {
|
|
5030
5020
|
return async (t, n = {}) => {
|
|
5031
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) => {
|
|
5032
5022
|
let t;
|
|
@@ -5061,7 +5051,7 @@ function qa(e) {
|
|
|
5061
5051
|
}
|
|
5062
5052
|
//#endregion
|
|
5063
5053
|
//#region src/outbox/replay.ts
|
|
5064
|
-
function
|
|
5054
|
+
function to(e) {
|
|
5065
5055
|
return async (t, n) => {
|
|
5066
5056
|
let r = await e.updateTable("outbox_events").set({
|
|
5067
5057
|
processed_at: null,
|
|
@@ -5076,7 +5066,7 @@ function Ja(e) {
|
|
|
5076
5066
|
}
|
|
5077
5067
|
//#endregion
|
|
5078
5068
|
//#region src/outbox/cleanup.ts
|
|
5079
|
-
function
|
|
5069
|
+
function no(e) {
|
|
5080
5070
|
return async (t) => {
|
|
5081
5071
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5082
5072
|
return Number(n.numDeletedRows);
|
|
@@ -5084,23 +5074,23 @@ function Ya(e) {
|
|
|
5084
5074
|
}
|
|
5085
5075
|
//#endregion
|
|
5086
5076
|
//#region src/outbox/index.ts
|
|
5087
|
-
function
|
|
5077
|
+
function ro(e) {
|
|
5088
5078
|
return {
|
|
5089
|
-
create:
|
|
5090
|
-
getByIds:
|
|
5091
|
-
getUnprocessed:
|
|
5092
|
-
claimEvents:
|
|
5093
|
-
markProcessed:
|
|
5094
|
-
markRetry:
|
|
5095
|
-
deadLetter:
|
|
5096
|
-
listFailed:
|
|
5097
|
-
replay:
|
|
5098
|
-
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)
|
|
5099
5089
|
};
|
|
5100
5090
|
}
|
|
5101
5091
|
//#endregion
|
|
5102
5092
|
//#region src/log-streams/index.ts
|
|
5103
|
-
function
|
|
5093
|
+
function U(e) {
|
|
5104
5094
|
return {
|
|
5105
5095
|
id: e.id,
|
|
5106
5096
|
name: e.name,
|
|
@@ -5113,7 +5103,7 @@ function G(e) {
|
|
|
5113
5103
|
updated_at: e.updated_at
|
|
5114
5104
|
};
|
|
5115
5105
|
}
|
|
5116
|
-
function
|
|
5106
|
+
function io(e) {
|
|
5117
5107
|
return {
|
|
5118
5108
|
async create(n, r, i) {
|
|
5119
5109
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5128,14 +5118,14 @@ function Za(e) {
|
|
|
5128
5118
|
created_at: a?.created_at ?? o,
|
|
5129
5119
|
updated_at: a?.updated_at ?? o
|
|
5130
5120
|
};
|
|
5131
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5121
|
+
return await e.insertInto("log_streams").values(s).execute(), U(s);
|
|
5132
5122
|
},
|
|
5133
5123
|
async get(t, n) {
|
|
5134
5124
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5135
|
-
return r ?
|
|
5125
|
+
return r ? U(r) : null;
|
|
5136
5126
|
},
|
|
5137
5127
|
async list(t) {
|
|
5138
|
-
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);
|
|
5139
5129
|
},
|
|
5140
5130
|
async update(t, n, r) {
|
|
5141
5131
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5148,7 +5138,7 @@ function Za(e) {
|
|
|
5148
5138
|
}
|
|
5149
5139
|
//#endregion
|
|
5150
5140
|
//#region src/migrationSources/index.ts
|
|
5151
|
-
function
|
|
5141
|
+
function W(e) {
|
|
5152
5142
|
return {
|
|
5153
5143
|
id: e.id,
|
|
5154
5144
|
name: e.name,
|
|
@@ -5160,7 +5150,7 @@ function K(e) {
|
|
|
5160
5150
|
updated_at: e.updated_at
|
|
5161
5151
|
};
|
|
5162
5152
|
}
|
|
5163
|
-
function
|
|
5153
|
+
function ao(e) {
|
|
5164
5154
|
return {
|
|
5165
5155
|
async create(n, r, i) {
|
|
5166
5156
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5174,14 +5164,14 @@ function Qa(e) {
|
|
|
5174
5164
|
created_at: a?.created_at ?? o,
|
|
5175
5165
|
updated_at: a?.updated_at ?? o
|
|
5176
5166
|
};
|
|
5177
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5167
|
+
return await e.insertInto("migration_sources").values(l).execute(), W(l);
|
|
5178
5168
|
},
|
|
5179
5169
|
async get(t, n) {
|
|
5180
5170
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5181
|
-
return r ?
|
|
5171
|
+
return r ? W(r) : null;
|
|
5182
5172
|
},
|
|
5183
5173
|
async list(t) {
|
|
5184
|
-
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);
|
|
5185
5175
|
},
|
|
5186
5176
|
async update(t, n, r) {
|
|
5187
5177
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5194,19 +5184,19 @@ function Qa(e) {
|
|
|
5194
5184
|
}
|
|
5195
5185
|
//#endregion
|
|
5196
5186
|
//#region src/proxyRoutes/serialize.ts
|
|
5197
|
-
function
|
|
5187
|
+
function G(e) {
|
|
5198
5188
|
return {
|
|
5199
5189
|
id: e.id,
|
|
5200
5190
|
tenant_id: e.tenant_id,
|
|
5201
5191
|
custom_domain_id: e.custom_domain_id,
|
|
5202
5192
|
priority: e.priority,
|
|
5203
|
-
match:
|
|
5204
|
-
handlers:
|
|
5193
|
+
match: oo(e.match),
|
|
5194
|
+
handlers: so(e.handlers),
|
|
5205
5195
|
created_at: e.created_at,
|
|
5206
5196
|
updated_at: e.updated_at
|
|
5207
5197
|
};
|
|
5208
5198
|
}
|
|
5209
|
-
function
|
|
5199
|
+
function oo(e) {
|
|
5210
5200
|
if (!e) return { path: "/*" };
|
|
5211
5201
|
try {
|
|
5212
5202
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5214,7 +5204,7 @@ function $a(e) {
|
|
|
5214
5204
|
} catch {}
|
|
5215
5205
|
return { path: "/*" };
|
|
5216
5206
|
}
|
|
5217
|
-
function
|
|
5207
|
+
function so(e) {
|
|
5218
5208
|
if (!e) return [];
|
|
5219
5209
|
try {
|
|
5220
5210
|
let t = JSON.parse(e);
|
|
@@ -5231,7 +5221,7 @@ function eo(e) {
|
|
|
5231
5221
|
}
|
|
5232
5222
|
//#endregion
|
|
5233
5223
|
//#region src/proxyRoutes/adapter.ts
|
|
5234
|
-
function
|
|
5224
|
+
function K(e) {
|
|
5235
5225
|
return {
|
|
5236
5226
|
async create(n, r, i) {
|
|
5237
5227
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5257,14 +5247,14 @@ function J(e) {
|
|
|
5257
5247
|
},
|
|
5258
5248
|
async get(t, n) {
|
|
5259
5249
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5260
|
-
return r ?
|
|
5250
|
+
return r ? G(r) : null;
|
|
5261
5251
|
},
|
|
5262
5252
|
async list(t, n = {}) {
|
|
5263
5253
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5264
5254
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5265
5255
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5266
5256
|
return {
|
|
5267
|
-
proxy_routes: o.map(
|
|
5257
|
+
proxy_routes: o.map(G),
|
|
5268
5258
|
start: r * i,
|
|
5269
5259
|
limit: i,
|
|
5270
5260
|
length: o.length
|
|
@@ -5284,7 +5274,7 @@ function J(e) {
|
|
|
5284
5274
|
}
|
|
5285
5275
|
//#endregion
|
|
5286
5276
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5287
|
-
async function
|
|
5277
|
+
async function co(e, t) {
|
|
5288
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([
|
|
5289
5279
|
"custom_domain_id",
|
|
5290
5280
|
"tenant_id",
|
|
@@ -5296,20 +5286,20 @@ async function to(e, t) {
|
|
|
5296
5286
|
tenant_id: a.tenant_id,
|
|
5297
5287
|
custom_domain_id: a.custom_domain_id,
|
|
5298
5288
|
domain: a.domain,
|
|
5299
|
-
routes: o.map(
|
|
5289
|
+
routes: o.map(G)
|
|
5300
5290
|
};
|
|
5301
5291
|
}
|
|
5302
5292
|
//#endregion
|
|
5303
5293
|
//#region src/proxyRoutes/index.ts
|
|
5304
|
-
function
|
|
5294
|
+
function lo(e) {
|
|
5305
5295
|
return {
|
|
5306
|
-
proxyRoutes:
|
|
5307
|
-
resolveHost: (t) =>
|
|
5296
|
+
proxyRoutes: K(e),
|
|
5297
|
+
resolveHost: (t) => co(e, t)
|
|
5308
5298
|
};
|
|
5309
5299
|
}
|
|
5310
5300
|
//#endregion
|
|
5311
5301
|
//#region src/scim/adapter.ts
|
|
5312
|
-
function
|
|
5302
|
+
function uo(e) {
|
|
5313
5303
|
if (!e) return [];
|
|
5314
5304
|
try {
|
|
5315
5305
|
let t = JSON.parse(e);
|
|
@@ -5324,7 +5314,7 @@ function ro(e) {
|
|
|
5324
5314
|
return [];
|
|
5325
5315
|
}
|
|
5326
5316
|
}
|
|
5327
|
-
function
|
|
5317
|
+
function fo(e) {
|
|
5328
5318
|
if (!e) return [];
|
|
5329
5319
|
try {
|
|
5330
5320
|
let t = JSON.parse(e);
|
|
@@ -5333,16 +5323,16 @@ function io(e) {
|
|
|
5333
5323
|
return [];
|
|
5334
5324
|
}
|
|
5335
5325
|
}
|
|
5336
|
-
function
|
|
5326
|
+
function po(e) {
|
|
5337
5327
|
return {
|
|
5338
5328
|
connection_id: e.connection_id,
|
|
5339
5329
|
user_id_attribute: e.user_id_attribute,
|
|
5340
|
-
mapping:
|
|
5330
|
+
mapping: uo(e.mapping),
|
|
5341
5331
|
created_at: e.created_at,
|
|
5342
5332
|
updated_at: e.updated_at
|
|
5343
5333
|
};
|
|
5344
5334
|
}
|
|
5345
|
-
function
|
|
5335
|
+
function mo(e) {
|
|
5346
5336
|
return {
|
|
5347
5337
|
async create(t, n) {
|
|
5348
5338
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5363,7 +5353,7 @@ function oo(e) {
|
|
|
5363
5353
|
},
|
|
5364
5354
|
async get(t, n) {
|
|
5365
5355
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5366
|
-
return r ?
|
|
5356
|
+
return r ? po(r) : null;
|
|
5367
5357
|
},
|
|
5368
5358
|
async update(t, n, r) {
|
|
5369
5359
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5377,18 +5367,18 @@ function oo(e) {
|
|
|
5377
5367
|
}
|
|
5378
5368
|
};
|
|
5379
5369
|
}
|
|
5380
|
-
function
|
|
5370
|
+
function q(e) {
|
|
5381
5371
|
return {
|
|
5382
5372
|
token_id: e.token_id,
|
|
5383
5373
|
connection_id: e.connection_id,
|
|
5384
5374
|
token_hash: e.token_hash,
|
|
5385
|
-
scopes:
|
|
5375
|
+
scopes: fo(e.scopes),
|
|
5386
5376
|
valid_until: e.valid_until ?? void 0,
|
|
5387
5377
|
created_at: e.created_at,
|
|
5388
5378
|
last_used_at: e.last_used_at ?? void 0
|
|
5389
5379
|
};
|
|
5390
5380
|
}
|
|
5391
|
-
function
|
|
5381
|
+
function ho(e) {
|
|
5392
5382
|
return {
|
|
5393
5383
|
async create(t, n) {
|
|
5394
5384
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5412,14 +5402,14 @@ function co(e) {
|
|
|
5412
5402
|
},
|
|
5413
5403
|
async get(t, n) {
|
|
5414
5404
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5415
|
-
return r ?
|
|
5405
|
+
return r ? q(r) : null;
|
|
5416
5406
|
},
|
|
5417
5407
|
async getByHash(t, n) {
|
|
5418
5408
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5419
|
-
return r ?
|
|
5409
|
+
return r ? q(r) : null;
|
|
5420
5410
|
},
|
|
5421
5411
|
async listByConnection(t, n) {
|
|
5422
|
-
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);
|
|
5423
5413
|
},
|
|
5424
5414
|
async markUsed(t, n, r) {
|
|
5425
5415
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5431,7 +5421,7 @@ function co(e) {
|
|
|
5431
5421
|
}
|
|
5432
5422
|
};
|
|
5433
5423
|
}
|
|
5434
|
-
function
|
|
5424
|
+
function go(e) {
|
|
5435
5425
|
return {
|
|
5436
5426
|
connection_id: e.connection_id,
|
|
5437
5427
|
external_id: e.external_id,
|
|
@@ -5439,7 +5429,7 @@ function lo(e) {
|
|
|
5439
5429
|
created_at: e.created_at
|
|
5440
5430
|
};
|
|
5441
5431
|
}
|
|
5442
|
-
function
|
|
5432
|
+
function _o(e) {
|
|
5443
5433
|
return {
|
|
5444
5434
|
async create(t, n) {
|
|
5445
5435
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5458,11 +5448,11 @@ function uo(e) {
|
|
|
5458
5448
|
},
|
|
5459
5449
|
async getByExternalId(t, n, r) {
|
|
5460
5450
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5461
|
-
return i ?
|
|
5451
|
+
return i ? go(i) : null;
|
|
5462
5452
|
},
|
|
5463
5453
|
async getByUserId(t, n, r) {
|
|
5464
5454
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5465
|
-
return i ?
|
|
5455
|
+
return i ? go(i) : null;
|
|
5466
5456
|
},
|
|
5467
5457
|
async remove(t, n, r) {
|
|
5468
5458
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5472,8 +5462,8 @@ function uo(e) {
|
|
|
5472
5462
|
}
|
|
5473
5463
|
//#endregion
|
|
5474
5464
|
//#region src/tenantOperations/index.ts
|
|
5475
|
-
function
|
|
5476
|
-
return
|
|
5465
|
+
function J(e) {
|
|
5466
|
+
return be.parse({
|
|
5477
5467
|
id: e.id,
|
|
5478
5468
|
tenant_id: e.tenant_id,
|
|
5479
5469
|
rollout_id: e.rollout_id,
|
|
@@ -5491,10 +5481,10 @@ function fo(e) {
|
|
|
5491
5481
|
finished_at: e.finished_at
|
|
5492
5482
|
});
|
|
5493
5483
|
}
|
|
5494
|
-
function
|
|
5484
|
+
function vo(e) {
|
|
5495
5485
|
return {
|
|
5496
5486
|
async create(n) {
|
|
5497
|
-
let r =
|
|
5487
|
+
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5498
5488
|
id: `op_${t()}`,
|
|
5499
5489
|
tenant_id: r.tenant_id,
|
|
5500
5490
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5511,11 +5501,11 @@ function po(e) {
|
|
|
5511
5501
|
updated_at: i,
|
|
5512
5502
|
finished_at: null
|
|
5513
5503
|
};
|
|
5514
|
-
return await e.insertInto("tenant_operations").values(a).execute(),
|
|
5504
|
+
return await e.insertInto("tenant_operations").values(a).execute(), J(a);
|
|
5515
5505
|
},
|
|
5516
5506
|
async get(t) {
|
|
5517
5507
|
let n = await e.selectFrom("tenant_operations").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5518
|
-
return n ?
|
|
5508
|
+
return n ? J(n) : null;
|
|
5519
5509
|
},
|
|
5520
5510
|
async list(t = {}) {
|
|
5521
5511
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = e.selectFrom("tenant_operations");
|
|
@@ -5526,7 +5516,7 @@ function po(e) {
|
|
|
5526
5516
|
t.engine !== void 0 && (i = i.where("engine", "=", t.engine)), t.updated_before !== void 0 && (i = i.where("updated_at", "<", t.updated_before));
|
|
5527
5517
|
let a = await i.selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5528
5518
|
return {
|
|
5529
|
-
operations: a.map(
|
|
5519
|
+
operations: a.map(J),
|
|
5530
5520
|
start: n * r,
|
|
5531
5521
|
limit: r,
|
|
5532
5522
|
length: a.length
|
|
@@ -5546,27 +5536,27 @@ function po(e) {
|
|
|
5546
5536
|
}
|
|
5547
5537
|
//#endregion
|
|
5548
5538
|
//#region src/utils/monotonic-id.ts
|
|
5549
|
-
var
|
|
5550
|
-
function
|
|
5539
|
+
var yo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Y = 32, bo = 10, xo = 4, So = 10;
|
|
5540
|
+
function Co(e, t) {
|
|
5551
5541
|
let n = "";
|
|
5552
|
-
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);
|
|
5553
5543
|
return n;
|
|
5554
5544
|
}
|
|
5555
|
-
function
|
|
5556
|
-
let e = new Uint8Array(
|
|
5545
|
+
function wo() {
|
|
5546
|
+
let e = new Uint8Array(So);
|
|
5557
5547
|
crypto.getRandomValues(e);
|
|
5558
5548
|
let t = "";
|
|
5559
|
-
for (let n = 0; n <
|
|
5549
|
+
for (let n = 0; n < So; n++) t += yo.charAt(e[n] % Y);
|
|
5560
5550
|
return t;
|
|
5561
5551
|
}
|
|
5562
|
-
var
|
|
5563
|
-
function
|
|
5552
|
+
var To = 0, X = 0;
|
|
5553
|
+
function Eo() {
|
|
5564
5554
|
let e = Date.now();
|
|
5565
|
-
return e ===
|
|
5555
|
+
return e === To ? X++ : (To = e, X = 0), Co(e, bo) + Co(X, xo) + wo();
|
|
5566
5556
|
}
|
|
5567
5557
|
//#endregion
|
|
5568
5558
|
//#region src/tenantOperationEvents/index.ts
|
|
5569
|
-
function
|
|
5559
|
+
function Do(e) {
|
|
5570
5560
|
if (!e) return null;
|
|
5571
5561
|
try {
|
|
5572
5562
|
let t = JSON.parse(e);
|
|
@@ -5574,22 +5564,22 @@ function wo(e) {
|
|
|
5574
5564
|
} catch {}
|
|
5575
5565
|
return null;
|
|
5576
5566
|
}
|
|
5577
|
-
function
|
|
5578
|
-
return
|
|
5567
|
+
function Oo(e) {
|
|
5568
|
+
return ve.parse({
|
|
5579
5569
|
id: e.id,
|
|
5580
5570
|
operation_id: e.operation_id,
|
|
5581
5571
|
step: e.step,
|
|
5582
5572
|
outcome: e.outcome,
|
|
5583
|
-
detail:
|
|
5573
|
+
detail: Do(e.detail),
|
|
5584
5574
|
attempt: e.attempt,
|
|
5585
5575
|
created_at: e.created_at
|
|
5586
5576
|
});
|
|
5587
5577
|
}
|
|
5588
|
-
function
|
|
5578
|
+
function ko(e) {
|
|
5589
5579
|
return {
|
|
5590
5580
|
async create(t) {
|
|
5591
|
-
let n =
|
|
5592
|
-
id: `evt_${
|
|
5581
|
+
let n = _e.parse(t), r = {
|
|
5582
|
+
id: `evt_${Eo()}`,
|
|
5593
5583
|
operation_id: n.operation_id,
|
|
5594
5584
|
step: n.step,
|
|
5595
5585
|
outcome: n.outcome,
|
|
@@ -5597,12 +5587,12 @@ function Eo(e) {
|
|
|
5597
5587
|
attempt: n.attempt,
|
|
5598
5588
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5599
5589
|
};
|
|
5600
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5590
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Oo(r);
|
|
5601
5591
|
},
|
|
5602
5592
|
async listByOperation(t, n = {}) {
|
|
5603
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();
|
|
5604
5594
|
return {
|
|
5605
|
-
events: a.map(
|
|
5595
|
+
events: a.map(Oo),
|
|
5606
5596
|
start: r * i,
|
|
5607
5597
|
limit: i,
|
|
5608
5598
|
length: a.length
|
|
@@ -5612,7 +5602,7 @@ function Eo(e) {
|
|
|
5612
5602
|
}
|
|
5613
5603
|
//#endregion
|
|
5614
5604
|
//#region src/rollouts/index.ts
|
|
5615
|
-
function
|
|
5605
|
+
function Ao(e) {
|
|
5616
5606
|
if (!e) return null;
|
|
5617
5607
|
try {
|
|
5618
5608
|
return JSON.parse(e);
|
|
@@ -5620,7 +5610,7 @@ function Do(e) {
|
|
|
5620
5610
|
return null;
|
|
5621
5611
|
}
|
|
5622
5612
|
}
|
|
5623
|
-
function
|
|
5613
|
+
function jo(e) {
|
|
5624
5614
|
return pe.parse({
|
|
5625
5615
|
id: e.id,
|
|
5626
5616
|
kind: e.kind,
|
|
@@ -5628,15 +5618,15 @@ function Y(e) {
|
|
|
5628
5618
|
target_worker_version: e.target_worker_version,
|
|
5629
5619
|
target_database_version: e.target_database_version,
|
|
5630
5620
|
wave_size: e.wave_size,
|
|
5631
|
-
canary_tenant_ids:
|
|
5632
|
-
filter:
|
|
5621
|
+
canary_tenant_ids: Ao(e.canary_tenant_ids),
|
|
5622
|
+
filter: Ao(e.filter),
|
|
5633
5623
|
initiated_by: e.initiated_by,
|
|
5634
5624
|
created_at: e.created_at,
|
|
5635
5625
|
updated_at: e.updated_at,
|
|
5636
5626
|
finished_at: e.finished_at
|
|
5637
5627
|
});
|
|
5638
5628
|
}
|
|
5639
|
-
function
|
|
5629
|
+
function Mo(e) {
|
|
5640
5630
|
return {
|
|
5641
5631
|
async create(n) {
|
|
5642
5632
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5653,16 +5643,16 @@ function Oo(e) {
|
|
|
5653
5643
|
updated_at: i,
|
|
5654
5644
|
finished_at: null
|
|
5655
5645
|
};
|
|
5656
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5646
|
+
return await e.insertInto("rollouts").values(a).execute(), jo(a);
|
|
5657
5647
|
},
|
|
5658
5648
|
async get(t) {
|
|
5659
5649
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5660
|
-
return n ?
|
|
5650
|
+
return n ? jo(n) : null;
|
|
5661
5651
|
},
|
|
5662
5652
|
async list(t = {}) {
|
|
5663
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();
|
|
5664
5654
|
return {
|
|
5665
|
-
rollouts: i.map(
|
|
5655
|
+
rollouts: i.map(jo),
|
|
5666
5656
|
start: n * r,
|
|
5667
5657
|
limit: r,
|
|
5668
5658
|
length: i.length
|
|
@@ -5682,7 +5672,7 @@ function Oo(e) {
|
|
|
5682
5672
|
}
|
|
5683
5673
|
//#endregion
|
|
5684
5674
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5685
|
-
var
|
|
5675
|
+
var No = class {
|
|
5686
5676
|
migrations;
|
|
5687
5677
|
constructor(e) {
|
|
5688
5678
|
this.migrations = e;
|
|
@@ -5690,10 +5680,10 @@ var ko = class {
|
|
|
5690
5680
|
async getMigrations() {
|
|
5691
5681
|
return this.migrations;
|
|
5692
5682
|
}
|
|
5693
|
-
},
|
|
5694
|
-
down: () =>
|
|
5695
|
-
up: () =>
|
|
5696
|
-
}),
|
|
5683
|
+
}, Po = /* @__PURE__ */ w({
|
|
5684
|
+
down: () => Ro,
|
|
5685
|
+
up: () => Lo
|
|
5686
|
+
}), Fo = [
|
|
5697
5687
|
{
|
|
5698
5688
|
table: "authentication_methods",
|
|
5699
5689
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5959,47 +5949,47 @@ var ko = class {
|
|
|
5959
5949
|
onDelete: "cascade"
|
|
5960
5950
|
}
|
|
5961
5951
|
];
|
|
5962
|
-
async function
|
|
5952
|
+
async function Io(e) {
|
|
5963
5953
|
try {
|
|
5964
5954
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5965
5955
|
} catch {
|
|
5966
5956
|
return !1;
|
|
5967
5957
|
}
|
|
5968
5958
|
}
|
|
5969
|
-
function
|
|
5959
|
+
function Z(e, t) {
|
|
5970
5960
|
let n = e;
|
|
5971
|
-
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) => {
|
|
5972
5962
|
let n = t;
|
|
5973
5963
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5974
5964
|
}));
|
|
5975
5965
|
return n;
|
|
5976
5966
|
}
|
|
5977
|
-
async function
|
|
5978
|
-
let t = await
|
|
5967
|
+
async function Lo(e) {
|
|
5968
|
+
let t = await Io(e);
|
|
5979
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();
|
|
5980
5970
|
{
|
|
5981
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"]);
|
|
5982
|
-
t && (n =
|
|
5972
|
+
t && (n = Z(n, "authentication_methods")), await n.execute();
|
|
5983
5973
|
}
|
|
5984
5974
|
{
|
|
5985
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"]);
|
|
5986
|
-
t && (n =
|
|
5976
|
+
t && (n = Z(n, "branding")), await n.execute();
|
|
5987
5977
|
}
|
|
5988
5978
|
{
|
|
5989
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"]);
|
|
5990
|
-
t && (n =
|
|
5980
|
+
t && (n = Z(n, "clients")), await n.execute();
|
|
5991
5981
|
}
|
|
5992
5982
|
{
|
|
5993
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"]);
|
|
5994
|
-
t && (n =
|
|
5984
|
+
t && (n = Z(n, "client_grants")), await n.execute();
|
|
5995
5985
|
}
|
|
5996
5986
|
{
|
|
5997
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"]);
|
|
5998
|
-
t && (n =
|
|
5988
|
+
t && (n = Z(n, "client_registration_tokens")), await n.execute();
|
|
5999
5989
|
}
|
|
6000
5990
|
{
|
|
6001
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"]);
|
|
6002
|
-
t && (n =
|
|
5992
|
+
t && (n = Z(n, "users")), await n.execute();
|
|
6003
5993
|
}
|
|
6004
5994
|
{
|
|
6005
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", [
|
|
@@ -6007,16 +5997,16 @@ async function No(e) {
|
|
|
6007
5997
|
"code_type",
|
|
6008
5998
|
"tenant_id"
|
|
6009
5999
|
]);
|
|
6010
|
-
t && (n =
|
|
6000
|
+
t && (n = Z(n, "codes")), await n.execute();
|
|
6011
6001
|
}
|
|
6012
6002
|
{
|
|
6013
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"]);
|
|
6014
|
-
t && (n =
|
|
6004
|
+
t && (n = Z(n, "connections")), await n.execute();
|
|
6015
6005
|
}
|
|
6016
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();
|
|
6017
6007
|
{
|
|
6018
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"]);
|
|
6019
|
-
t && (n =
|
|
6009
|
+
t && (n = Z(n, "custom_domains")), await n.execute();
|
|
6020
6010
|
}
|
|
6021
6011
|
{
|
|
6022
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", [
|
|
@@ -6024,56 +6014,56 @@ async function No(e) {
|
|
|
6024
6014
|
"prompt",
|
|
6025
6015
|
"language"
|
|
6026
6016
|
]);
|
|
6027
|
-
t && (n =
|
|
6017
|
+
t && (n = Z(n, "custom_text")), await n.execute();
|
|
6028
6018
|
}
|
|
6029
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();
|
|
6030
6020
|
{
|
|
6031
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"]);
|
|
6032
|
-
t && (n =
|
|
6022
|
+
t && (n = Z(n, "email_templates")), await n.execute();
|
|
6033
6023
|
}
|
|
6034
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();
|
|
6035
6025
|
{
|
|
6036
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"]);
|
|
6037
|
-
t && (n =
|
|
6027
|
+
t && (n = Z(n, "grants")), await n.execute();
|
|
6038
6028
|
}
|
|
6039
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();
|
|
6040
6030
|
{
|
|
6041
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"]);
|
|
6042
|
-
t && (n =
|
|
6032
|
+
t && (n = Z(n, "hooks")), await n.execute();
|
|
6043
6033
|
}
|
|
6044
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();
|
|
6045
6035
|
{
|
|
6046
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"]);
|
|
6047
|
-
t && (n =
|
|
6037
|
+
t && (n = Z(n, "keys")), await n.execute();
|
|
6048
6038
|
}
|
|
6049
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();
|
|
6050
6040
|
{
|
|
6051
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"]);
|
|
6052
|
-
t && (n =
|
|
6042
|
+
t && (n = Z(n, "sessions")), await n.execute();
|
|
6053
6043
|
}
|
|
6054
6044
|
{
|
|
6055
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"]);
|
|
6056
|
-
t && (n =
|
|
6046
|
+
t && (n = Z(n, "login_sessions")), await n.execute();
|
|
6057
6047
|
}
|
|
6058
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();
|
|
6059
6049
|
{
|
|
6060
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"]);
|
|
6061
|
-
t && (n =
|
|
6051
|
+
t && (n = Z(n, "migrations")), await n.execute();
|
|
6062
6052
|
}
|
|
6063
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();
|
|
6064
6054
|
{
|
|
6065
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());
|
|
6066
|
-
t && (n =
|
|
6056
|
+
t && (n = Z(n, "organization_connections")), await n.execute();
|
|
6067
6057
|
}
|
|
6068
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();
|
|
6069
6059
|
{
|
|
6070
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"]);
|
|
6071
|
-
t && (n =
|
|
6061
|
+
t && (n = Z(n, "passwords")), await n.execute();
|
|
6072
6062
|
}
|
|
6073
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();
|
|
6074
6064
|
{
|
|
6075
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"]);
|
|
6076
|
-
t && (n =
|
|
6066
|
+
t && (n = Z(n, "refresh_tokens")), await n.execute();
|
|
6077
6067
|
}
|
|
6078
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", [
|
|
6079
6069
|
"tenant_id",
|
|
@@ -6083,23 +6073,23 @@ async function No(e) {
|
|
|
6083
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();
|
|
6084
6074
|
{
|
|
6085
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"]);
|
|
6086
|
-
t && (n =
|
|
6076
|
+
t && (n = Z(n, "tenant_operation_events")), await n.execute();
|
|
6087
6077
|
}
|
|
6088
6078
|
{
|
|
6089
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"]);
|
|
6090
|
-
t && (n =
|
|
6080
|
+
t && (n = Z(n, "themes")), await n.execute();
|
|
6091
6081
|
}
|
|
6092
6082
|
{
|
|
6093
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"]);
|
|
6094
|
-
t && (n =
|
|
6084
|
+
t && (n = Z(n, "universal_login_templates")), await n.execute();
|
|
6095
6085
|
}
|
|
6096
6086
|
{
|
|
6097
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"]);
|
|
6098
|
-
t && (n =
|
|
6088
|
+
t && (n = Z(n, "user_activity")), await n.execute();
|
|
6099
6089
|
}
|
|
6100
6090
|
{
|
|
6101
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"]);
|
|
6102
|
-
t && (n =
|
|
6092
|
+
t && (n = Z(n, "user_organizations")), await n.execute();
|
|
6103
6093
|
}
|
|
6104
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", [
|
|
6105
6095
|
"tenant_id",
|
|
@@ -6162,76 +6152,76 @@ async function No(e) {
|
|
|
6162
6152
|
"tenant_id",
|
|
6163
6153
|
"phone_number",
|
|
6164
6154
|
"provider"
|
|
6165
|
-
]).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) => {
|
|
6166
6156
|
let n = e;
|
|
6167
6157
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6168
6158
|
}).execute();
|
|
6169
6159
|
}
|
|
6170
|
-
async function
|
|
6160
|
+
async function Ro(e) {
|
|
6171
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();
|
|
6172
6162
|
}
|
|
6173
6163
|
//#endregion
|
|
6174
6164
|
//#region migrate/log.ts
|
|
6175
|
-
var
|
|
6176
|
-
function
|
|
6177
|
-
|
|
6178
|
-
}
|
|
6179
|
-
function Z(...e) {
|
|
6180
|
-
Fo && console.log(...e);
|
|
6165
|
+
var zo = !1;
|
|
6166
|
+
function Bo(e) {
|
|
6167
|
+
zo = e;
|
|
6181
6168
|
}
|
|
6182
6169
|
function Q(...e) {
|
|
6170
|
+
zo && console.log(...e);
|
|
6171
|
+
}
|
|
6172
|
+
function $(...e) {
|
|
6183
6173
|
console.warn(...e);
|
|
6184
6174
|
}
|
|
6185
6175
|
//#endregion
|
|
6186
6176
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6187
|
-
var
|
|
6188
|
-
down: () =>
|
|
6189
|
-
up: () =>
|
|
6190
|
-
}),
|
|
6191
|
-
async function
|
|
6177
|
+
var Vo = /* @__PURE__ */ w({
|
|
6178
|
+
down: () => Qo,
|
|
6179
|
+
up: () => Yo
|
|
6180
|
+
}), Ho = 5e4, Uo = 500;
|
|
6181
|
+
async function Wo(e) {
|
|
6192
6182
|
try {
|
|
6193
6183
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6194
6184
|
} catch {
|
|
6195
6185
|
return "sqlite";
|
|
6196
6186
|
}
|
|
6197
6187
|
}
|
|
6198
|
-
async function
|
|
6188
|
+
async function Go(e, t, n) {
|
|
6199
6189
|
try {
|
|
6200
6190
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6201
6191
|
} catch (e) {
|
|
6202
6192
|
if (e instanceof Error && (e.message.includes("1060") || e.message.includes("duplicate column"))) {
|
|
6203
|
-
|
|
6193
|
+
Q(` Column ${t}.${n} already exists, skipping`);
|
|
6204
6194
|
return;
|
|
6205
6195
|
}
|
|
6206
6196
|
throw e;
|
|
6207
6197
|
}
|
|
6208
6198
|
}
|
|
6209
|
-
async function
|
|
6199
|
+
async function Ko(e, t, n, r) {
|
|
6210
6200
|
try {
|
|
6211
6201
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6212
6202
|
} catch (e) {
|
|
6213
6203
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6214
|
-
|
|
6204
|
+
Q(` Index ${t} already exists, skipping`);
|
|
6215
6205
|
return;
|
|
6216
6206
|
}
|
|
6217
6207
|
throw e;
|
|
6218
6208
|
}
|
|
6219
6209
|
}
|
|
6220
|
-
async function
|
|
6210
|
+
async function qo(e, t) {
|
|
6221
6211
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6222
6212
|
if (t === "sqlite") {
|
|
6223
6213
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6224
6214
|
r = Number(t.numDeletedRows);
|
|
6225
6215
|
} else {
|
|
6226
|
-
let t =
|
|
6227
|
-
for (; t >=
|
|
6228
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6229
|
-
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)...`);
|
|
6230
6220
|
}
|
|
6231
6221
|
}
|
|
6232
6222
|
return r;
|
|
6233
6223
|
}
|
|
6234
|
-
async function
|
|
6224
|
+
async function Jo(e) {
|
|
6235
6225
|
let t = 0;
|
|
6236
6226
|
for (;;) {
|
|
6237
6227
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6239,33 +6229,33 @@ async function Uo(e) {
|
|
|
6239
6229
|
"code_type",
|
|
6240
6230
|
"tenant_id",
|
|
6241
6231
|
"expires_at"
|
|
6242
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6232
|
+
]).where("expires_at_ts", "is", null).limit(Uo).execute();
|
|
6243
6233
|
if (n.length === 0) break;
|
|
6244
6234
|
for (let t of n) {
|
|
6245
6235
|
let n = Date.parse(t.expires_at);
|
|
6246
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();
|
|
6247
6237
|
}
|
|
6248
|
-
if (t += n.length, n.length <
|
|
6238
|
+
if (t += n.length, n.length < Uo) break;
|
|
6249
6239
|
}
|
|
6250
6240
|
return t;
|
|
6251
6241
|
}
|
|
6252
|
-
async function
|
|
6253
|
-
let t = await
|
|
6242
|
+
async function Yo(e) {
|
|
6243
|
+
let t = await Wo(e);
|
|
6254
6244
|
try {
|
|
6255
|
-
let n = await
|
|
6256
|
-
|
|
6245
|
+
let n = await qo(e, t);
|
|
6246
|
+
Q(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6257
6247
|
} catch (e) {
|
|
6258
|
-
|
|
6248
|
+
$(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6259
6249
|
}
|
|
6260
|
-
await
|
|
6250
|
+
await Go(e, "codes", "expires_at_ts"), await Ko(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6261
6251
|
try {
|
|
6262
|
-
let t = await
|
|
6263
|
-
|
|
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)`);
|
|
6264
6254
|
} catch (e) {
|
|
6265
|
-
|
|
6255
|
+
$(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6266
6256
|
}
|
|
6267
6257
|
}
|
|
6268
|
-
async function
|
|
6258
|
+
async function Xo(e, t, n) {
|
|
6269
6259
|
try {
|
|
6270
6260
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6271
6261
|
} catch (e) {
|
|
@@ -6273,7 +6263,7 @@ async function Go(e, t, n) {
|
|
|
6273
6263
|
throw e;
|
|
6274
6264
|
}
|
|
6275
6265
|
}
|
|
6276
|
-
async function
|
|
6266
|
+
async function Zo(e, t, n) {
|
|
6277
6267
|
try {
|
|
6278
6268
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6279
6269
|
} catch (e) {
|
|
@@ -6281,16 +6271,16 @@ async function Ko(e, t, n) {
|
|
|
6281
6271
|
throw e;
|
|
6282
6272
|
}
|
|
6283
6273
|
}
|
|
6284
|
-
async function
|
|
6285
|
-
await
|
|
6274
|
+
async function Qo(e) {
|
|
6275
|
+
await Xo(e, "idx_codes_expires_at_ts", "codes"), await Zo(e, "codes", "expires_at_ts");
|
|
6286
6276
|
}
|
|
6287
6277
|
//#endregion
|
|
6288
6278
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6289
|
-
var
|
|
6290
|
-
down: () =>
|
|
6291
|
-
up: () =>
|
|
6279
|
+
var $o = /* @__PURE__ */ w({
|
|
6280
|
+
down: () => ts,
|
|
6281
|
+
up: () => es
|
|
6292
6282
|
});
|
|
6293
|
-
async function
|
|
6283
|
+
async function es(e) {
|
|
6294
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", [
|
|
6295
6285
|
"tenant_id",
|
|
6296
6286
|
"connection_id",
|
|
@@ -6301,16 +6291,16 @@ async function Yo(e) {
|
|
|
6301
6291
|
"external_id"
|
|
6302
6292
|
]).unique().execute();
|
|
6303
6293
|
}
|
|
6304
|
-
async function
|
|
6294
|
+
async function ts(e) {
|
|
6305
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();
|
|
6306
6296
|
}
|
|
6307
6297
|
//#endregion
|
|
6308
6298
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6309
|
-
var
|
|
6310
|
-
down: () =>
|
|
6311
|
-
up: () =>
|
|
6299
|
+
var ns = /* @__PURE__ */ w({
|
|
6300
|
+
down: () => os,
|
|
6301
|
+
up: () => is
|
|
6312
6302
|
});
|
|
6313
|
-
async function
|
|
6303
|
+
async function rs(e, t, n) {
|
|
6314
6304
|
try {
|
|
6315
6305
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6316
6306
|
} catch (e) {
|
|
@@ -6318,10 +6308,10 @@ async function Qo(e, t, n) {
|
|
|
6318
6308
|
throw e;
|
|
6319
6309
|
}
|
|
6320
6310
|
}
|
|
6321
|
-
async function
|
|
6322
|
-
await
|
|
6311
|
+
async function is(e) {
|
|
6312
|
+
await rs(e, "users", "blocked");
|
|
6323
6313
|
}
|
|
6324
|
-
async function
|
|
6314
|
+
async function as(e, t, n) {
|
|
6325
6315
|
try {
|
|
6326
6316
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6327
6317
|
} catch (e) {
|
|
@@ -6329,16 +6319,16 @@ async function es(e, t, n) {
|
|
|
6329
6319
|
throw e;
|
|
6330
6320
|
}
|
|
6331
6321
|
}
|
|
6332
|
-
async function
|
|
6333
|
-
await
|
|
6322
|
+
async function os(e) {
|
|
6323
|
+
await as(e, "users", "blocked");
|
|
6334
6324
|
}
|
|
6335
6325
|
//#endregion
|
|
6336
6326
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6337
|
-
var
|
|
6338
|
-
down: () =>
|
|
6339
|
-
up: () =>
|
|
6327
|
+
var ss = /* @__PURE__ */ w({
|
|
6328
|
+
down: () => ds,
|
|
6329
|
+
up: () => ls
|
|
6340
6330
|
});
|
|
6341
|
-
async function
|
|
6331
|
+
async function cs(e, t, n) {
|
|
6342
6332
|
try {
|
|
6343
6333
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6344
6334
|
} catch (e) {
|
|
@@ -6346,10 +6336,10 @@ async function rs(e, t, n) {
|
|
|
6346
6336
|
throw e;
|
|
6347
6337
|
}
|
|
6348
6338
|
}
|
|
6349
|
-
async function
|
|
6350
|
-
await
|
|
6339
|
+
async function ls(e) {
|
|
6340
|
+
await cs(e, "prompt_settings", "show_last_used_connection");
|
|
6351
6341
|
}
|
|
6352
|
-
async function
|
|
6342
|
+
async function us(e, t, n) {
|
|
6353
6343
|
try {
|
|
6354
6344
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6355
6345
|
} catch (e) {
|
|
@@ -6357,30 +6347,30 @@ async function as(e, t, n) {
|
|
|
6357
6347
|
throw e;
|
|
6358
6348
|
}
|
|
6359
6349
|
}
|
|
6360
|
-
async function
|
|
6361
|
-
await
|
|
6350
|
+
async function ds(e) {
|
|
6351
|
+
await us(e, "prompt_settings", "show_last_used_connection");
|
|
6362
6352
|
}
|
|
6363
6353
|
//#endregion
|
|
6364
6354
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6365
|
-
var
|
|
6366
|
-
down: () =>
|
|
6367
|
-
up: () =>
|
|
6355
|
+
var fs = /* @__PURE__ */ w({
|
|
6356
|
+
down: () => hs,
|
|
6357
|
+
up: () => ms
|
|
6368
6358
|
});
|
|
6369
|
-
async function
|
|
6359
|
+
async function ps(e, t, n, r) {
|
|
6370
6360
|
try {
|
|
6371
6361
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6372
6362
|
} catch (e) {
|
|
6373
6363
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
6374
|
-
|
|
6364
|
+
Q(` Index ${t} already exists, skipping`);
|
|
6375
6365
|
return;
|
|
6376
6366
|
}
|
|
6377
6367
|
throw e;
|
|
6378
6368
|
}
|
|
6379
6369
|
}
|
|
6380
|
-
async function
|
|
6381
|
-
await
|
|
6370
|
+
async function ms(e) {
|
|
6371
|
+
await ps(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6382
6372
|
}
|
|
6383
|
-
async function
|
|
6373
|
+
async function hs(e) {
|
|
6384
6374
|
try {
|
|
6385
6375
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6386
6376
|
} catch (e) {
|
|
@@ -6390,11 +6380,11 @@ async function us(e) {
|
|
|
6390
6380
|
}
|
|
6391
6381
|
//#endregion
|
|
6392
6382
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6393
|
-
var
|
|
6394
|
-
down: () =>
|
|
6395
|
-
up: () =>
|
|
6383
|
+
var gs = /* @__PURE__ */ w({
|
|
6384
|
+
down: () => bs,
|
|
6385
|
+
up: () => vs
|
|
6396
6386
|
});
|
|
6397
|
-
async function
|
|
6387
|
+
async function _s(e, t, n, r) {
|
|
6398
6388
|
try {
|
|
6399
6389
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6400
6390
|
} catch (e) {
|
|
@@ -6402,10 +6392,10 @@ async function fs(e, t, n, r) {
|
|
|
6402
6392
|
throw e;
|
|
6403
6393
|
}
|
|
6404
6394
|
}
|
|
6405
|
-
async function
|
|
6406
|
-
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)`);
|
|
6407
6397
|
}
|
|
6408
|
-
async function
|
|
6398
|
+
async function ys(e, t, n) {
|
|
6409
6399
|
try {
|
|
6410
6400
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6411
6401
|
} catch (e) {
|
|
@@ -6413,22 +6403,22 @@ async function ms(e, t, n) {
|
|
|
6413
6403
|
throw e;
|
|
6414
6404
|
}
|
|
6415
6405
|
}
|
|
6416
|
-
async function
|
|
6417
|
-
await
|
|
6406
|
+
async function bs(e) {
|
|
6407
|
+
await ys(e, "hooks", "permission_required"), await ys(e, "hooks", "page_id");
|
|
6418
6408
|
}
|
|
6419
6409
|
//#endregion
|
|
6420
6410
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6421
|
-
var
|
|
6422
|
-
down: () =>
|
|
6423
|
-
up: () =>
|
|
6424
|
-
}),
|
|
6411
|
+
var xs = /* @__PURE__ */ w({
|
|
6412
|
+
down: () => Ds,
|
|
6413
|
+
up: () => Ts
|
|
6414
|
+
}), Ss = [
|
|
6425
6415
|
["session_id", f`varchar(26)`],
|
|
6426
6416
|
["organization", f`varchar(191)`],
|
|
6427
6417
|
["auth_connection", f`varchar(255)`],
|
|
6428
6418
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6429
6419
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6430
6420
|
];
|
|
6431
|
-
async function
|
|
6421
|
+
async function Cs(e, t, n, r) {
|
|
6432
6422
|
try {
|
|
6433
6423
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6434
6424
|
} catch (e) {
|
|
@@ -6436,7 +6426,7 @@ async function vs(e, t, n, r) {
|
|
|
6436
6426
|
throw e;
|
|
6437
6427
|
}
|
|
6438
6428
|
}
|
|
6439
|
-
async function
|
|
6429
|
+
async function ws(e) {
|
|
6440
6430
|
try {
|
|
6441
6431
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6442
6432
|
} catch (e) {
|
|
@@ -6444,11 +6434,11 @@ async function ys(e) {
|
|
|
6444
6434
|
throw e;
|
|
6445
6435
|
}
|
|
6446
6436
|
}
|
|
6447
|
-
async function
|
|
6448
|
-
for (let [t, n] of
|
|
6449
|
-
await
|
|
6437
|
+
async function Ts(e) {
|
|
6438
|
+
for (let [t, n] of Ss) await Cs(e, "refresh_tokens", t, n);
|
|
6439
|
+
await ws(e);
|
|
6450
6440
|
}
|
|
6451
|
-
async function
|
|
6441
|
+
async function Es(e, t, n) {
|
|
6452
6442
|
try {
|
|
6453
6443
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6454
6444
|
} catch (e) {
|
|
@@ -6456,27 +6446,27 @@ async function xs(e, t, n) {
|
|
|
6456
6446
|
throw e;
|
|
6457
6447
|
}
|
|
6458
6448
|
}
|
|
6459
|
-
async function
|
|
6449
|
+
async function Ds(e) {
|
|
6460
6450
|
try {
|
|
6461
6451
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6462
6452
|
} catch {}
|
|
6463
|
-
for (let [t] of
|
|
6453
|
+
for (let [t] of Ss) await Es(e, "refresh_tokens", t);
|
|
6464
6454
|
}
|
|
6465
6455
|
//#endregion
|
|
6466
6456
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6467
|
-
var
|
|
6468
|
-
down: () =>
|
|
6469
|
-
up: () =>
|
|
6470
|
-
}),
|
|
6471
|
-
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) {
|
|
6472
6462
|
try {
|
|
6473
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);
|
|
6474
|
-
if (n >
|
|
6475
|
-
|
|
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.`);
|
|
6476
6466
|
return;
|
|
6477
6467
|
}
|
|
6478
6468
|
if (n === 0) {
|
|
6479
|
-
|
|
6469
|
+
Q("refresh_tokens backfill: nothing to do");
|
|
6480
6470
|
return;
|
|
6481
6471
|
}
|
|
6482
6472
|
let r = 0;
|
|
@@ -6489,16 +6479,16 @@ async function Os(e) {
|
|
|
6489
6479
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6490
6480
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6491
6481
|
"login_sessions.auth_params as ls_auth_params"
|
|
6492
|
-
]).limit(
|
|
6482
|
+
]).limit(ks).execute();
|
|
6493
6483
|
if (t.length === 0) break;
|
|
6494
|
-
for (let n = 0; n < t.length; n +=
|
|
6495
|
-
let r = t.slice(n, n +
|
|
6484
|
+
for (let n = 0; n < t.length; n += As) {
|
|
6485
|
+
let r = t.slice(n, n + As);
|
|
6496
6486
|
await Promise.all(r.map(async (t) => {
|
|
6497
6487
|
let n = null;
|
|
6498
6488
|
if (t.ls_auth_params) try {
|
|
6499
6489
|
n = JSON.parse(t.ls_auth_params)?.organization ?? null;
|
|
6500
6490
|
} catch {
|
|
6501
|
-
|
|
6491
|
+
$(`refresh_tokens backfill: unparseable auth_params on login_session for token ${t.id}`);
|
|
6502
6492
|
}
|
|
6503
6493
|
await e.updateTable("refresh_tokens").set({
|
|
6504
6494
|
session_id: t.ls_session_id,
|
|
@@ -6509,44 +6499,44 @@ async function Os(e) {
|
|
|
6509
6499
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6510
6500
|
}));
|
|
6511
6501
|
}
|
|
6512
|
-
if (r += t.length,
|
|
6502
|
+
if (r += t.length, Q(`refresh_tokens backfill: ${r} rows populated so far`), t.length < ks) break;
|
|
6513
6503
|
}
|
|
6514
|
-
|
|
6504
|
+
Q(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6515
6505
|
} catch (e) {
|
|
6516
|
-
throw
|
|
6506
|
+
throw $("refresh_tokens backfill failed:", e), e;
|
|
6517
6507
|
}
|
|
6518
6508
|
}
|
|
6519
|
-
async function
|
|
6509
|
+
async function Ps() {}
|
|
6520
6510
|
//#endregion
|
|
6521
6511
|
//#region migrate/migrations/index.ts
|
|
6522
|
-
var
|
|
6523
|
-
"2026-07-16T14:00:00_baseline":
|
|
6524
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6525
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6526
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6527
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6528
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6529
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6530
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6531
|
-
"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
|
|
6532
6522
|
};
|
|
6533
6523
|
//#endregion
|
|
6534
6524
|
//#region migrate/migrate.ts
|
|
6535
|
-
async function
|
|
6536
|
-
|
|
6537
|
-
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({
|
|
6538
6528
|
db: e,
|
|
6539
|
-
provider: new
|
|
6529
|
+
provider: new No(Fs)
|
|
6540
6530
|
}).migrateToLatest();
|
|
6541
6531
|
if (r?.forEach((e) => {
|
|
6542
6532
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6543
6533
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6544
6534
|
}
|
|
6545
|
-
async function
|
|
6546
|
-
|
|
6547
|
-
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({
|
|
6548
6538
|
db: e,
|
|
6549
|
-
provider: new
|
|
6539
|
+
provider: new No(Fs)
|
|
6550
6540
|
}).migrateDown();
|
|
6551
6541
|
if (r?.forEach((e) => {
|
|
6552
6542
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6554,64 +6544,64 @@ async function Ms(e, t = !1) {
|
|
|
6554
6544
|
}
|
|
6555
6545
|
//#endregion
|
|
6556
6546
|
//#region src/index.ts
|
|
6557
|
-
function
|
|
6547
|
+
function Rs(e, t = { useTransactions: !0 }) {
|
|
6558
6548
|
let n = {
|
|
6559
|
-
actions:
|
|
6560
|
-
actionExecutions:
|
|
6561
|
-
actionVersions:
|
|
6562
|
-
branding:
|
|
6563
|
-
clients:
|
|
6564
|
-
clientConnections:
|
|
6565
|
-
clientGrants:
|
|
6566
|
-
clientRegistrationTokens:
|
|
6567
|
-
codes:
|
|
6568
|
-
connections:
|
|
6569
|
-
emailProviders:
|
|
6570
|
-
emailTemplates:
|
|
6571
|
-
customDomains:
|
|
6572
|
-
flows:
|
|
6573
|
-
forms:
|
|
6574
|
-
hookCode:
|
|
6575
|
-
hooks:
|
|
6576
|
-
invites:
|
|
6577
|
-
keys:
|
|
6578
|
-
loginSessions:
|
|
6579
|
-
logs:
|
|
6580
|
-
logStreams:
|
|
6581
|
-
migrationSources:
|
|
6582
|
-
authenticationMethods:
|
|
6583
|
-
passwords:
|
|
6584
|
-
promptSettings:
|
|
6585
|
-
proxyRoutes:
|
|
6586
|
-
scimConfigurations:
|
|
6587
|
-
scimTokens:
|
|
6588
|
-
scimExternalIds:
|
|
6589
|
-
refreshTokens:
|
|
6590
|
-
resourceServers:
|
|
6591
|
-
rolePermissions:
|
|
6592
|
-
grants:
|
|
6593
|
-
userPermissions:
|
|
6594
|
-
userRoles:
|
|
6595
|
-
roles:
|
|
6596
|
-
sessions:
|
|
6597
|
-
sessionCleanup:
|
|
6598
|
-
tenants:
|
|
6599
|
-
tenantOperations:
|
|
6600
|
-
tenantOperationEvents:
|
|
6601
|
-
rollouts:
|
|
6602
|
-
themes:
|
|
6603
|
-
universalLoginTemplates:
|
|
6604
|
-
customText:
|
|
6605
|
-
users:
|
|
6606
|
-
userActivity:
|
|
6607
|
-
organizations:
|
|
6608
|
-
organizationConnections:
|
|
6609
|
-
userOrganizations:
|
|
6610
|
-
stats:
|
|
6611
|
-
analytics:
|
|
6612
|
-
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),
|
|
6613
6603
|
async transaction(r) {
|
|
6614
|
-
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, {
|
|
6615
6605
|
...t,
|
|
6616
6606
|
useTransactions: !1
|
|
6617
6607
|
})));
|
|
@@ -6620,4 +6610,4 @@ function Ns(e, t = { useTransactions: !0 }) {
|
|
|
6620
6610
|
return n;
|
|
6621
6611
|
}
|
|
6622
6612
|
//#endregion
|
|
6623
|
-
export {
|
|
6613
|
+
export { lo as createProxyDataAdapter, K as createProxyRoutesAdapter, Rs as default, Ls as migrateDown, Is as migrateToLatest };
|