@authhero/kysely-adapter 12.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.d.ts +27 -0
- package/dist/kysely-adapter.mjs +1128 -875
- package/dist/types/migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.d.ts +21 -0
- package/dist/types/migrate/migrations/2026-08-05T12:00:00_user_blocked.d.ts +4 -0
- package/dist/types/migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.d.ts +4 -0
- package/dist/types/migrate/migrations/index.d.ts +6 -0
- package/dist/types/src/db.d.ts +27 -0
- package/dist/types/src/scim/adapter.d.ts +6 -0
- package/dist/types/src/scim/index.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { customAlphabet as e, nanoid as t } from "nanoid";
|
|
2
2
|
import { booleanToInt as n, convertDatesToAdapter as r, dbDateToIso as i, dbDateToIsoRequired as a, getCountAsInt as o, isoToDbDate as s, nowIso as c, removeNullProperties as l, removeUndefinedAndNull as u, stringifyProperties as d } from "@authhero/adapter-interfaces/sql";
|
|
3
3
|
import { sql as f } from "kysely";
|
|
4
|
-
import { LoginSessionState as p, clientGrantSchema as m, clientRegistrationTokenTypeSchema as h, codeSchema as g, decodeCursor as _, emailTemplateSchema as v, encodeCursor as
|
|
5
|
-
import { HTTPException as
|
|
4
|
+
import { LoginSessionState as p, clientGrantSchema as m, clientRegistrationTokenTypeSchema as h, codeSchema as g, decodeCursor as _, emailTemplateSchema as v, encodeCursor as ee, flowSchema as y, formSchema as b, handlerConfigSchema as te, isPlainObject as ne, loginSessionSchema as re, matchSchema as ie, migrationProviderTypeSchema as ae, parseUserId as oe, resourceServerSchema as se, rolloutInsertSchema as ce, rolloutSchema as le, sanitizeLuceneQuery as x, scimMappingEntrySchema as ue, tenantOperationEventInsertSchema as de, tenantOperationEventSchema as fe, tenantOperationInsertSchema as pe, tenantOperationSchema as me } from "@authhero/adapter-interfaces";
|
|
5
|
+
import { HTTPException as S } from "hono/http-exception";
|
|
6
6
|
import "@hono/zod-openapi";
|
|
7
|
-
import { Migrator as
|
|
7
|
+
import { Migrator as he } from "kysely/migration";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
9
|
+
var ge = Object.defineProperty, C = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) ge(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
16
|
-
},
|
|
15
|
+
return t || ge(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, _e = 17, ve = {
|
|
17
17
|
organization: "org_",
|
|
18
18
|
connection: "con_",
|
|
19
19
|
action: "act_",
|
|
@@ -26,38 +26,38 @@ var me = Object.defineProperty, he = (e, t) => {
|
|
|
26
26
|
invite: "inv_"
|
|
27
27
|
};
|
|
28
28
|
function w(t) {
|
|
29
|
-
let n = e("0123456789abcdefghijklmnopqrstuvwxyz",
|
|
30
|
-
return `${
|
|
29
|
+
let n = e("0123456789abcdefghijklmnopqrstuvwxyz", _e)();
|
|
30
|
+
return `${ve[t]}${n}`;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ye() {
|
|
33
33
|
return w("organization");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function be() {
|
|
36
36
|
return w("connection");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function xe() {
|
|
39
39
|
return w("action");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function Se() {
|
|
42
42
|
return w("action_version");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Ce() {
|
|
45
45
|
return w("hook");
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function we() {
|
|
48
48
|
return w("resource_server");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Te() {
|
|
51
51
|
return w("hook_code");
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Ee() {
|
|
54
54
|
return w("invite");
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/actions/create.ts
|
|
58
|
-
function
|
|
58
|
+
function De(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 ?? xe();
|
|
61
61
|
return await e.insertInto("actions").values({
|
|
62
62
|
id: c,
|
|
63
63
|
tenant_id: t,
|
|
@@ -91,14 +91,14 @@ function Ee(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function Oe(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 ke(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 De(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: Oe(c),
|
|
117
|
+
dependencies: Oe(l),
|
|
118
|
+
supported_triggers: Oe(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -123,19 +123,19 @@ function De(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function Ae(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function T(e) {
|
|
130
130
|
return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function E(e, t, n, r, i = [], a = {}) {
|
|
133
133
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
134
134
|
let t = a[e];
|
|
135
135
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
136
136
|
}, l = (e) => {
|
|
137
137
|
let t = a[e];
|
|
138
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
138
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : Ae(t);
|
|
139
139
|
}, u = (e, t) => {
|
|
140
140
|
let n = a[e];
|
|
141
141
|
if (n === void 0 || typeof n == "string") return t;
|
|
@@ -148,7 +148,7 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
148
148
|
if (n) {
|
|
149
149
|
let [, t, r] = n;
|
|
150
150
|
if (!t || !r) return null;
|
|
151
|
-
let i = t.trim(), a =
|
|
151
|
+
let i = t.trim(), a = T(r.replace(/^"(.*)"$/, "$1").trim());
|
|
152
152
|
return o.has(i) ? e(s(c(i)), "like", `%${a}%`) : e(l(i), "=", u(i, a));
|
|
153
153
|
}
|
|
154
154
|
return null;
|
|
@@ -166,8 +166,8 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
166
166
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
167
167
|
else if (e.includes(":")) {
|
|
168
168
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
169
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r =
|
|
170
|
-
} else n = null, r =
|
|
169
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = T(r);
|
|
170
|
+
} else n = null, r = T(e), i = !1;
|
|
171
171
|
return {
|
|
172
172
|
key: n,
|
|
173
173
|
value: r,
|
|
@@ -201,17 +201,17 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/actions/list.ts
|
|
204
|
-
function
|
|
204
|
+
function D(e) {
|
|
205
205
|
if (e) try {
|
|
206
206
|
return JSON.parse(e);
|
|
207
207
|
} catch {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function je(e) {
|
|
212
212
|
return async (t, n = {}) => {
|
|
213
213
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
214
|
-
c && (l =
|
|
214
|
+
c && (l = E(e, l, c, ["name"]));
|
|
215
215
|
let u = (await l.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
216
216
|
let { created_at_ts: n, updated_at_ts: i, deployed_at_ts: a, secrets: o, dependencies: s, supported_triggers: c, is_system: l, inherit: u, tenant_id: d, ...f } = e, p = r({
|
|
217
217
|
created_at_ts: n,
|
|
@@ -224,9 +224,9 @@ function ke(e) {
|
|
|
224
224
|
runtime: f.runtime ?? void 0,
|
|
225
225
|
status: f.status || "built",
|
|
226
226
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
227
|
-
secrets:
|
|
228
|
-
dependencies:
|
|
229
|
-
supported_triggers:
|
|
227
|
+
secrets: D(o),
|
|
228
|
+
dependencies: D(s),
|
|
229
|
+
supported_triggers: D(c),
|
|
230
230
|
is_system: !!l,
|
|
231
231
|
inherit: !!u
|
|
232
232
|
};
|
|
@@ -248,7 +248,7 @@ function ke(e) {
|
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/actions/update.ts
|
|
251
|
-
function
|
|
251
|
+
function Me(e) {
|
|
252
252
|
if (!e) return [];
|
|
253
253
|
try {
|
|
254
254
|
let t = JSON.parse(e);
|
|
@@ -257,11 +257,11 @@ function Ae(e) {
|
|
|
257
257
|
return [];
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ne(e) {
|
|
261
261
|
return async (t, n, r) => {
|
|
262
262
|
let i = { updated_at_ts: Date.now() };
|
|
263
263
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
264
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
264
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Me(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
265
265
|
name: e.name,
|
|
266
266
|
value: o.get(e.name)?.value
|
|
267
267
|
} : e);
|
|
@@ -276,23 +276,23 @@ function je(e) {
|
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/actions/remove.ts
|
|
279
|
-
function
|
|
279
|
+
function Pe(e) {
|
|
280
280
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/actions/index.ts
|
|
284
|
-
function
|
|
284
|
+
function Fe(e) {
|
|
285
285
|
return {
|
|
286
|
-
create:
|
|
287
|
-
get:
|
|
288
|
-
list:
|
|
289
|
-
update:
|
|
290
|
-
remove:
|
|
286
|
+
create: De(e),
|
|
287
|
+
get: ke(e),
|
|
288
|
+
list: je(e),
|
|
289
|
+
update: Ne(e),
|
|
290
|
+
remove: Pe(e)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/actionExecutions/create.ts
|
|
295
|
-
function
|
|
295
|
+
function Ie(e) {
|
|
296
296
|
return async (t, n) => {
|
|
297
297
|
let r = Date.now();
|
|
298
298
|
return await e.insertInto("action_executions").values({
|
|
@@ -318,14 +318,14 @@ function Pe(e) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/actionExecutions/get.ts
|
|
321
|
-
function
|
|
321
|
+
function Le(e) {
|
|
322
322
|
if (e) try {
|
|
323
323
|
return JSON.parse(e);
|
|
324
324
|
} catch {
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function Re(e) {
|
|
329
329
|
return async (t, n) => {
|
|
330
330
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
331
331
|
return r ? {
|
|
@@ -333,8 +333,8 @@ function Ie(e) {
|
|
|
333
333
|
tenant_id: r.tenant_id,
|
|
334
334
|
trigger_id: r.trigger_id,
|
|
335
335
|
status: r.status,
|
|
336
|
-
results:
|
|
337
|
-
logs:
|
|
336
|
+
results: Le(r.results) ?? [],
|
|
337
|
+
logs: Le(r.logs),
|
|
338
338
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
339
339
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
340
340
|
} : null;
|
|
@@ -342,38 +342,38 @@ function Ie(e) {
|
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
344
|
//#region src/actionExecutions/index.ts
|
|
345
|
-
function
|
|
345
|
+
function ze(e) {
|
|
346
346
|
return {
|
|
347
|
-
create:
|
|
348
|
-
get:
|
|
347
|
+
create: Ie(e),
|
|
348
|
+
get: Re(e)
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
//#endregion
|
|
352
352
|
//#region src/actionVersions/index.ts
|
|
353
|
-
function
|
|
353
|
+
function O(e) {
|
|
354
354
|
if (e) try {
|
|
355
355
|
return JSON.parse(e);
|
|
356
356
|
} catch {
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function Be(e) {
|
|
361
361
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
362
362
|
return {
|
|
363
363
|
...c,
|
|
364
364
|
runtime: s ?? void 0,
|
|
365
365
|
deployed: !!o,
|
|
366
|
-
secrets:
|
|
367
|
-
dependencies:
|
|
368
|
-
supported_triggers:
|
|
366
|
+
secrets: O(r),
|
|
367
|
+
dependencies: O(i),
|
|
368
|
+
supported_triggers: O(a),
|
|
369
369
|
created_at: new Date(Number(t)).toISOString(),
|
|
370
370
|
updated_at: new Date(Number(n)).toISOString()
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
function Ve(e) {
|
|
374
374
|
return {
|
|
375
375
|
async create(t, n, r) {
|
|
376
|
-
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ??
|
|
376
|
+
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? Se(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
377
377
|
let r = ((await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n.action_id).select("number").orderBy("number", "desc").limit(1).executeTakeFirst())?.number ?? 0) + 1;
|
|
378
378
|
return l && await e.updateTable("action_versions").set(i ? { deployed: 0 } : {
|
|
379
379
|
deployed: 0,
|
|
@@ -410,10 +410,10 @@ function ze(e) {
|
|
|
410
410
|
},
|
|
411
411
|
async get(t, n, r) {
|
|
412
412
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
413
|
-
return i ?
|
|
413
|
+
return i ? Be(i) : null;
|
|
414
414
|
},
|
|
415
415
|
async list(t, n, r = {}) {
|
|
416
|
-
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(
|
|
416
|
+
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(Be);
|
|
417
417
|
if (!s) return {
|
|
418
418
|
versions: l,
|
|
419
419
|
start: 0,
|
|
@@ -436,7 +436,7 @@ function ze(e) {
|
|
|
436
436
|
}
|
|
437
437
|
//#endregion
|
|
438
438
|
//#region src/outbox/create.ts
|
|
439
|
-
async function
|
|
439
|
+
async function k(e, t, n, r) {
|
|
440
440
|
await e.insertInto("outbox_events").values({
|
|
441
441
|
id: n,
|
|
442
442
|
tenant_id: t,
|
|
@@ -455,15 +455,15 @@ async function A(e, t, n, r) {
|
|
|
455
455
|
error: null
|
|
456
456
|
}).execute();
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function He(e) {
|
|
459
459
|
return async (n, r) => {
|
|
460
460
|
let i = t();
|
|
461
|
-
return await
|
|
461
|
+
return await k(e, n, i, r), i;
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
//#endregion
|
|
465
465
|
//#region src/users/create.ts
|
|
466
|
-
function
|
|
466
|
+
function Ue(e) {
|
|
467
467
|
return async (n, r, i) => {
|
|
468
468
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
469
469
|
...f,
|
|
@@ -474,6 +474,7 @@ function Ve(e) {
|
|
|
474
474
|
email_verified: +!!r.email_verified,
|
|
475
475
|
phone_verified: s === void 0 ? null : +!!s,
|
|
476
476
|
is_social: +!!r.is_social,
|
|
477
|
+
blocked: +!!r.blocked,
|
|
477
478
|
app_metadata: JSON.stringify(r.app_metadata),
|
|
478
479
|
user_metadata: JSON.stringify(r.user_metadata),
|
|
479
480
|
address: r.address ? JSON.stringify(r.address) : null
|
|
@@ -497,12 +498,12 @@ function Ve(e) {
|
|
|
497
498
|
};
|
|
498
499
|
await e.insertInto("passwords").values(r).execute();
|
|
499
500
|
}
|
|
500
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
501
|
+
for (let t of i?.outboxEvents ?? []) await k(e, n, t.id, t);
|
|
501
502
|
};
|
|
502
503
|
try {
|
|
503
504
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
504
505
|
} catch (e) {
|
|
505
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
506
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new S(409, { message: "User already exists" }) : new S(500, { message: `${e.code}, ${e.message}` });
|
|
506
507
|
}
|
|
507
508
|
return {
|
|
508
509
|
...m,
|
|
@@ -513,6 +514,7 @@ function Ve(e) {
|
|
|
513
514
|
email_verified: m.email_verified === 1,
|
|
514
515
|
phone_verified: m.phone_verified === null ? void 0 : m.phone_verified === 1,
|
|
515
516
|
is_social: m.is_social === 1,
|
|
517
|
+
blocked: m.blocked == null ? void 0 : m.blocked === 1,
|
|
516
518
|
app_metadata: r.app_metadata,
|
|
517
519
|
user_metadata: r.user_metadata,
|
|
518
520
|
address: r.address
|
|
@@ -521,21 +523,21 @@ function Ve(e) {
|
|
|
521
523
|
}
|
|
522
524
|
//#endregion
|
|
523
525
|
//#region src/users/user-to-identity.ts
|
|
524
|
-
var
|
|
526
|
+
var We = [
|
|
525
527
|
"email",
|
|
526
528
|
"email_verified",
|
|
527
529
|
"phone_number",
|
|
528
530
|
"phone_verified",
|
|
529
531
|
"username"
|
|
530
532
|
];
|
|
531
|
-
function
|
|
533
|
+
function A(e, t = !1) {
|
|
532
534
|
let n = {
|
|
533
535
|
connection: e.connection,
|
|
534
536
|
provider: e.provider,
|
|
535
|
-
user_id:
|
|
537
|
+
user_id: oe(e.user_id).id,
|
|
536
538
|
isSocial: !!e.is_social
|
|
537
539
|
};
|
|
538
|
-
for (let t of
|
|
540
|
+
for (let t of We) e[t] !== void 0 && e[t] !== null && (n[t] = t.endsWith("_verified") ? !!e[t] : e[t]);
|
|
539
541
|
if (!t) {
|
|
540
542
|
let t = {};
|
|
541
543
|
try {
|
|
@@ -553,7 +555,7 @@ function j(e, t = !1) {
|
|
|
553
555
|
}
|
|
554
556
|
//#endregion
|
|
555
557
|
//#region src/users/get.ts
|
|
556
|
-
function
|
|
558
|
+
function Ge(e) {
|
|
557
559
|
return async (t, n) => {
|
|
558
560
|
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([
|
|
559
561
|
"user_activity.last_login",
|
|
@@ -568,28 +570,29 @@ function Ue(e) {
|
|
|
568
570
|
email_verified: r.email_verified === 1,
|
|
569
571
|
phone_verified: r.phone_verified === null ? void 0 : r.phone_verified === 1,
|
|
570
572
|
is_social: r.is_social === 1,
|
|
573
|
+
blocked: r.blocked == null ? void 0 : r.blocked === 1,
|
|
571
574
|
last_login: r.last_login ?? void 0,
|
|
572
575
|
last_ip: r.last_ip ?? void 0,
|
|
573
576
|
login_count: r.login_count ?? 0,
|
|
574
577
|
app_metadata: JSON.parse(r.app_metadata),
|
|
575
578
|
user_metadata: JSON.parse(r.user_metadata),
|
|
576
579
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
577
|
-
identities: [
|
|
580
|
+
identities: [A(r, !0), ...i.map((e) => A(e))]
|
|
578
581
|
});
|
|
579
582
|
};
|
|
580
583
|
}
|
|
581
584
|
//#endregion
|
|
582
585
|
//#region src/helpers/paginate.ts
|
|
583
|
-
function
|
|
586
|
+
function j(e) {
|
|
584
587
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
585
588
|
}
|
|
586
|
-
function
|
|
589
|
+
function Ke(e, t) {
|
|
587
590
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
588
591
|
return n >= 1 ? n : t;
|
|
589
592
|
}
|
|
590
|
-
async function
|
|
591
|
-
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o =
|
|
592
|
-
if (c && c.k !== n.sortKey) throw new
|
|
593
|
+
async function M(e, t, n) {
|
|
594
|
+
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = Ke(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? _(t.from) : null;
|
|
595
|
+
if (c && c.k !== n.sortKey) throw new S(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
593
596
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
594
597
|
else {
|
|
595
598
|
let e = i === "asc" ? f.raw(">") : f.raw("<");
|
|
@@ -598,7 +601,7 @@ async function N(e, t, n) {
|
|
|
598
601
|
let l = await s.limit(o + 1).execute(), u = l.length > o, d = u ? l.slice(0, o) : l, p;
|
|
599
602
|
if (u && d.length > 0) {
|
|
600
603
|
let e = d[d.length - 1], t = r.split(".").pop(), i = a.split(".").pop(), o = e[t];
|
|
601
|
-
p =
|
|
604
|
+
p = ee({
|
|
602
605
|
s: typeof o == "string" || typeof o == "number" || o === null ? o : String(o),
|
|
603
606
|
i: String(e[i]),
|
|
604
607
|
...n.sortKey !== void 0 && { k: n.sortKey }
|
|
@@ -612,7 +615,7 @@ async function N(e, t, n) {
|
|
|
612
615
|
}
|
|
613
616
|
//#endregion
|
|
614
617
|
//#region src/users/list.ts
|
|
615
|
-
var
|
|
618
|
+
var qe = [
|
|
616
619
|
"user_id",
|
|
617
620
|
"email",
|
|
618
621
|
"email_verified",
|
|
@@ -629,25 +632,26 @@ var Ge = [
|
|
|
629
632
|
"provider",
|
|
630
633
|
"connection",
|
|
631
634
|
"is_social",
|
|
635
|
+
"blocked",
|
|
632
636
|
"last_ip",
|
|
633
637
|
"last_login",
|
|
634
638
|
"login_count",
|
|
635
639
|
"created_at",
|
|
636
640
|
"updated_at"
|
|
637
|
-
],
|
|
641
|
+
], Je = new Set([
|
|
638
642
|
"last_login",
|
|
639
643
|
"last_ip",
|
|
640
644
|
"login_count"
|
|
641
|
-
]),
|
|
645
|
+
]), Ye = Object.fromEntries(qe.map((e) => [e, e === "login_count" ? {
|
|
642
646
|
column: "user_activity.login_count",
|
|
643
647
|
defaultValue: 0
|
|
644
|
-
} :
|
|
648
|
+
} : Je.has(e) ? `user_activity.${e}` : `users.${e}`])), Xe = [
|
|
645
649
|
"email",
|
|
646
650
|
"name",
|
|
647
651
|
"phone_number",
|
|
648
652
|
"user_id"
|
|
649
653
|
];
|
|
650
|
-
async function
|
|
654
|
+
async function Ze(e, t, n) {
|
|
651
655
|
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() : [];
|
|
652
656
|
return n.map((e) => {
|
|
653
657
|
let t = i.filter((t) => t.linked_to === e.user_id);
|
|
@@ -656,24 +660,25 @@ async function Ye(e, t, n) {
|
|
|
656
660
|
email_verified: e.email_verified === 1,
|
|
657
661
|
phone_verified: e.phone_verified === null ? void 0 : e.phone_verified === 1,
|
|
658
662
|
is_social: e.is_social === 1,
|
|
663
|
+
blocked: e.blocked == null ? void 0 : e.blocked === 1,
|
|
659
664
|
login_count: e.login_count ?? 0,
|
|
660
665
|
app_metadata: JSON.parse(e.app_metadata),
|
|
661
666
|
user_metadata: JSON.parse(e.user_metadata),
|
|
662
667
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
663
|
-
identities: [
|
|
668
|
+
identities: [A(e, !0), ...t.map((e) => A(e))]
|
|
664
669
|
});
|
|
665
670
|
});
|
|
666
671
|
}
|
|
667
|
-
function
|
|
672
|
+
function Qe(e) {
|
|
668
673
|
return async (t, n = {}) => {
|
|
669
674
|
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);
|
|
670
675
|
if (c) {
|
|
671
|
-
let t =
|
|
672
|
-
t && (l =
|
|
676
|
+
let t = x(c, qe);
|
|
677
|
+
t && (l = E(e, l, t, Xe, [], Ye));
|
|
673
678
|
}
|
|
674
|
-
if (
|
|
675
|
-
if (s?.sort_by && s.sort_by !== "created_at") throw new
|
|
676
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
679
|
+
if (j(n)) {
|
|
680
|
+
if (s?.sort_by && s.sort_by !== "created_at") throw new S(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
681
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await M(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
677
682
|
"user_activity.last_login",
|
|
678
683
|
"user_activity.last_ip",
|
|
679
684
|
"user_activity.login_count"
|
|
@@ -682,7 +687,7 @@ function Xe(e) {
|
|
|
682
687
|
sortOrder: r,
|
|
683
688
|
idColumn: "users.user_id",
|
|
684
689
|
sortKey: `created_at:${r}`
|
|
685
|
-
}), c = await
|
|
690
|
+
}), c = await Ze(e, t, i);
|
|
686
691
|
return {
|
|
687
692
|
users: c,
|
|
688
693
|
start: 0,
|
|
@@ -692,13 +697,13 @@ function Xe(e) {
|
|
|
692
697
|
};
|
|
693
698
|
}
|
|
694
699
|
if (s && s.sort_by) {
|
|
695
|
-
let t =
|
|
700
|
+
let t = Ye[s.sort_by];
|
|
696
701
|
if (t) {
|
|
697
702
|
let { ref: n } = e.dynamic;
|
|
698
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
703
|
+
l = l.orderBy(typeof t == "string" ? n(t) : Ae(t), s.sort_order);
|
|
699
704
|
}
|
|
700
705
|
}
|
|
701
|
-
let u = await
|
|
706
|
+
let u = await Ze(e, t, await l.offset(r * i).limit(i).selectAll("users").select([
|
|
702
707
|
"user_activity.last_login",
|
|
703
708
|
"user_activity.last_ip",
|
|
704
709
|
"user_activity.login_count"
|
|
@@ -720,12 +725,12 @@ function Xe(e) {
|
|
|
720
725
|
}
|
|
721
726
|
//#endregion
|
|
722
727
|
//#region src/users/remove.ts
|
|
723
|
-
function
|
|
728
|
+
function $e(e) {
|
|
724
729
|
return async (t, n, r) => {
|
|
725
730
|
let i = async (e) => {
|
|
726
731
|
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();
|
|
727
732
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
728
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
733
|
+
for (let n of r?.outboxEvents ?? []) await k(e, t, n.id, n);
|
|
729
734
|
return i.length === 1;
|
|
730
735
|
};
|
|
731
736
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -733,14 +738,14 @@ function Ze(e) {
|
|
|
733
738
|
}
|
|
734
739
|
//#endregion
|
|
735
740
|
//#region src/utils/flatten.ts
|
|
736
|
-
function
|
|
741
|
+
function N(e, t = "", n = {}) {
|
|
737
742
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
738
743
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
739
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
744
|
+
typeof a == "object" && a && !Array.isArray(a) ? N(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
740
745
|
}
|
|
741
746
|
return n;
|
|
742
747
|
}
|
|
743
|
-
function
|
|
748
|
+
function et(e, t) {
|
|
744
749
|
let n = {};
|
|
745
750
|
for (let [r, i] of Object.entries(e)) {
|
|
746
751
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -757,7 +762,7 @@ function Qe(e, t) {
|
|
|
757
762
|
}
|
|
758
763
|
//#endregion
|
|
759
764
|
//#region src/userActivity/index.ts
|
|
760
|
-
function
|
|
765
|
+
function tt(e) {
|
|
761
766
|
return {
|
|
762
767
|
user_id: e.user_id,
|
|
763
768
|
last_login: e.last_login ?? void 0,
|
|
@@ -767,18 +772,18 @@ function $e(e) {
|
|
|
767
772
|
last_password_reset: e.last_password_reset ?? void 0
|
|
768
773
|
};
|
|
769
774
|
}
|
|
770
|
-
function
|
|
775
|
+
function nt(e) {
|
|
771
776
|
let t = {};
|
|
772
777
|
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;
|
|
773
778
|
}
|
|
774
|
-
function
|
|
779
|
+
function rt(e) {
|
|
775
780
|
return {
|
|
776
781
|
async get(t, n) {
|
|
777
782
|
let r = await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).selectAll().executeTakeFirst();
|
|
778
|
-
return r ?
|
|
783
|
+
return r ? tt(r) : null;
|
|
779
784
|
},
|
|
780
785
|
async upsert(t, n, r) {
|
|
781
|
-
let i =
|
|
786
|
+
let i = nt(r);
|
|
782
787
|
if (await e.selectFrom("user_activity").where("tenant_id", "=", t).where("user_id", "=", n).select("user_id").executeTakeFirst()) {
|
|
783
788
|
if (Object.keys(i).length === 0) return;
|
|
784
789
|
await e.updateTable("user_activity").set(i).where("tenant_id", "=", t).where("user_id", "=", n).execute();
|
|
@@ -800,24 +805,25 @@ function tt(e) {
|
|
|
800
805
|
}
|
|
801
806
|
//#endregion
|
|
802
807
|
//#region src/users/update.ts
|
|
803
|
-
function
|
|
808
|
+
function it(e) {
|
|
804
809
|
return async (t, n, r, i) => {
|
|
805
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
810
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = N({
|
|
806
811
|
...c,
|
|
807
812
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
808
813
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
809
814
|
user_metadata: r.user_metadata ? JSON.stringify(r.user_metadata) : void 0,
|
|
810
815
|
address: r.address ? JSON.stringify(r.address) : void 0,
|
|
811
|
-
phone_verified: r.phone_verified === void 0 ? void 0 : +!!r.phone_verified
|
|
816
|
+
phone_verified: r.phone_verified === void 0 ? void 0 : +!!r.phone_verified,
|
|
817
|
+
blocked: r.blocked === void 0 ? void 0 : +!!r.blocked
|
|
812
818
|
}), u = async (e) => {
|
|
813
819
|
let [r] = await e.updateTable("users").set(l).where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
814
820
|
if (!r || r.numUpdatedRows === 0n) return !1;
|
|
815
|
-
(a !== void 0 || o !== void 0 || s !== void 0) && await
|
|
821
|
+
(a !== void 0 || o !== void 0 || s !== void 0) && await rt(e).upsert(t, n, {
|
|
816
822
|
last_login: a,
|
|
817
823
|
last_ip: o,
|
|
818
824
|
login_count: s
|
|
819
825
|
});
|
|
820
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
826
|
+
for (let n of i?.outboxEvents ?? []) await k(e, t, n.id, n);
|
|
821
827
|
return !0;
|
|
822
828
|
};
|
|
823
829
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -825,28 +831,28 @@ function nt(e) {
|
|
|
825
831
|
}
|
|
826
832
|
//#endregion
|
|
827
833
|
//#region src/users/unlink.ts
|
|
828
|
-
function
|
|
834
|
+
function at(e) {
|
|
829
835
|
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;
|
|
830
836
|
}
|
|
831
837
|
//#endregion
|
|
832
838
|
//#region src/users/index.ts
|
|
833
|
-
function
|
|
834
|
-
let t =
|
|
839
|
+
function ot(e) {
|
|
840
|
+
let t = Ue(e);
|
|
835
841
|
return {
|
|
836
842
|
create: t,
|
|
837
843
|
rawCreate: t,
|
|
838
|
-
remove:
|
|
839
|
-
get:
|
|
840
|
-
list:
|
|
841
|
-
update:
|
|
842
|
-
unlink:
|
|
844
|
+
remove: $e(e),
|
|
845
|
+
get: Ge(e),
|
|
846
|
+
list: Qe(e),
|
|
847
|
+
update: it(e),
|
|
848
|
+
unlink: at(e)
|
|
843
849
|
};
|
|
844
850
|
}
|
|
845
851
|
//#endregion
|
|
846
852
|
//#region src/flows/create.ts
|
|
847
|
-
function
|
|
853
|
+
function st(e) {
|
|
848
854
|
return async (n, r, i) => {
|
|
849
|
-
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
855
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = y.parse({
|
|
850
856
|
id: a?.id ?? `af_${t()}`,
|
|
851
857
|
...r,
|
|
852
858
|
actions: r.actions || [],
|
|
@@ -862,7 +868,7 @@ function at(e) {
|
|
|
862
868
|
}
|
|
863
869
|
//#endregion
|
|
864
870
|
//#region src/helpers/parse.ts
|
|
865
|
-
function
|
|
871
|
+
function P(e, t) {
|
|
866
872
|
if (!e) return t;
|
|
867
873
|
try {
|
|
868
874
|
return JSON.parse(e);
|
|
@@ -870,7 +876,7 @@ function F(e, t) {
|
|
|
870
876
|
return t;
|
|
871
877
|
}
|
|
872
878
|
}
|
|
873
|
-
function
|
|
879
|
+
function ct(e) {
|
|
874
880
|
if (e) try {
|
|
875
881
|
let t = JSON.parse(e);
|
|
876
882
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -878,35 +884,35 @@ function ot(e) {
|
|
|
878
884
|
return;
|
|
879
885
|
}
|
|
880
886
|
}
|
|
881
|
-
function
|
|
882
|
-
for (let r in t) r in e && (n[r] =
|
|
887
|
+
function lt(e, t, n = { ...e }) {
|
|
888
|
+
for (let r in t) r in e && (n[r] = P(e[r], t[r]));
|
|
883
889
|
return n;
|
|
884
890
|
}
|
|
885
891
|
//#endregion
|
|
886
892
|
//#region src/flows/get.ts
|
|
887
|
-
function
|
|
893
|
+
function ut(e) {
|
|
888
894
|
return async (t, n) => {
|
|
889
895
|
let r = await e.selectFrom("flows").selectAll().where("flows.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
890
896
|
if (!r) return null;
|
|
891
897
|
let i = {
|
|
892
898
|
...r,
|
|
893
|
-
actions:
|
|
899
|
+
actions: P(r.actions, [])
|
|
894
900
|
};
|
|
895
|
-
return
|
|
901
|
+
return y.parse(l(i));
|
|
896
902
|
};
|
|
897
903
|
}
|
|
898
904
|
//#endregion
|
|
899
905
|
//#region src/flows/list.ts
|
|
900
|
-
function
|
|
906
|
+
function dt(e) {
|
|
901
907
|
return async (t, n = {}) => {
|
|
902
908
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
903
|
-
s && (c =
|
|
909
|
+
s && (c = E(e, c, s, []));
|
|
904
910
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
905
911
|
let t = {
|
|
906
912
|
...e,
|
|
907
|
-
actions:
|
|
913
|
+
actions: P(e.actions, [])
|
|
908
914
|
};
|
|
909
|
-
return
|
|
915
|
+
return y.parse(l(t));
|
|
910
916
|
});
|
|
911
917
|
if (!a) return {
|
|
912
918
|
flows: u,
|
|
@@ -925,7 +931,7 @@ function lt(e) {
|
|
|
925
931
|
}
|
|
926
932
|
//#endregion
|
|
927
933
|
//#region src/flows/update.ts
|
|
928
|
-
function
|
|
934
|
+
function ft(e) {
|
|
929
935
|
return async (t, n, r) => {
|
|
930
936
|
let i = {
|
|
931
937
|
...r,
|
|
@@ -935,7 +941,7 @@ function ut(e) {
|
|
|
935
941
|
let { numUpdatedRows: a } = await e.updateTable("flows").set(i).where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
936
942
|
if (a === 0n) return null;
|
|
937
943
|
let o = await e.selectFrom("flows").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
938
|
-
return o ?
|
|
944
|
+
return o ? y.parse({
|
|
939
945
|
...o,
|
|
940
946
|
actions: o.actions ? JSON.parse(o.actions) : []
|
|
941
947
|
}) : null;
|
|
@@ -943,27 +949,27 @@ function ut(e) {
|
|
|
943
949
|
}
|
|
944
950
|
//#endregion
|
|
945
951
|
//#region src/flows/remove.ts
|
|
946
|
-
function
|
|
952
|
+
function pt(e) {
|
|
947
953
|
return async (t, n) => ((await e.deleteFrom("flows").where("id", "=", n).where("tenant_id", "=", t).execute())[0]?.numDeletedRows ?? 0n) > 0n;
|
|
948
954
|
}
|
|
949
955
|
//#endregion
|
|
950
956
|
//#region src/flows/index.ts
|
|
951
|
-
function
|
|
957
|
+
function mt(e) {
|
|
952
958
|
return {
|
|
953
|
-
create:
|
|
954
|
-
get:
|
|
955
|
-
list:
|
|
956
|
-
update:
|
|
957
|
-
remove:
|
|
959
|
+
create: st(e),
|
|
960
|
+
get: ut(e),
|
|
961
|
+
list: dt(e),
|
|
962
|
+
update: ft(e),
|
|
963
|
+
remove: pt(e)
|
|
958
964
|
};
|
|
959
965
|
}
|
|
960
966
|
//#endregion
|
|
961
967
|
//#region src/tenants/utils.ts
|
|
962
|
-
function
|
|
968
|
+
function ht(e) {
|
|
963
969
|
let t = { ...e };
|
|
964
970
|
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);
|
|
965
971
|
}
|
|
966
|
-
function
|
|
972
|
+
function gt(e) {
|
|
967
973
|
let t = { ...e };
|
|
968
974
|
return d(e, [
|
|
969
975
|
"session_cookie",
|
|
@@ -986,42 +992,42 @@ function mt(e) {
|
|
|
986
992
|
}
|
|
987
993
|
//#endregion
|
|
988
994
|
//#region src/tenants/create.ts
|
|
989
|
-
function
|
|
995
|
+
function _t(e) {
|
|
990
996
|
return async (n, r) => {
|
|
991
997
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
992
998
|
...n,
|
|
993
999
|
id: i?.id ?? n.id ?? t(),
|
|
994
1000
|
created_at: i?.created_at ?? a,
|
|
995
1001
|
updated_at: i?.updated_at ?? a
|
|
996
|
-
}, s =
|
|
1002
|
+
}, s = gt(o);
|
|
997
1003
|
try {
|
|
998
1004
|
await e.insertInto("tenants").values(s).execute();
|
|
999
1005
|
} catch (e) {
|
|
1000
1006
|
let t = e?.message ?? "";
|
|
1001
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
1007
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new S(409, { message: `Tenant with ID '${o.id}' already exists` }) : e;
|
|
1002
1008
|
}
|
|
1003
1009
|
return o;
|
|
1004
1010
|
};
|
|
1005
1011
|
}
|
|
1006
1012
|
//#endregion
|
|
1007
1013
|
//#region src/tenants/get.ts
|
|
1008
|
-
function
|
|
1014
|
+
function vt(e) {
|
|
1009
1015
|
return async (t) => {
|
|
1010
1016
|
let n = await e.selectFrom("tenants").where("tenants.id", "=", t).selectAll().executeTakeFirst();
|
|
1011
|
-
return n ?
|
|
1017
|
+
return n ? ht(n) : null;
|
|
1012
1018
|
};
|
|
1013
1019
|
}
|
|
1014
1020
|
//#endregion
|
|
1015
1021
|
//#region src/tenants/list.ts
|
|
1016
|
-
function
|
|
1022
|
+
function yt(e) {
|
|
1017
1023
|
return async (t) => {
|
|
1018
1024
|
let n = e.selectFrom("tenants"), { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = t || {};
|
|
1019
1025
|
if (s && s.sort_by) {
|
|
1020
1026
|
let { ref: t } = e.dynamic;
|
|
1021
1027
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1022
1028
|
}
|
|
1023
|
-
c && (n =
|
|
1024
|
-
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(
|
|
1029
|
+
c && (n = E(e, n, c, ["friendly_name"]));
|
|
1030
|
+
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(ht);
|
|
1025
1031
|
if (!a) return { tenants: l };
|
|
1026
1032
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
1027
1033
|
return {
|
|
@@ -1034,10 +1040,10 @@ function _t(e) {
|
|
|
1034
1040
|
}
|
|
1035
1041
|
//#endregion
|
|
1036
1042
|
//#region src/tenants/update.ts
|
|
1037
|
-
function
|
|
1043
|
+
function bt(e) {
|
|
1038
1044
|
return async (t, n) => {
|
|
1039
1045
|
let r = {
|
|
1040
|
-
...
|
|
1046
|
+
...gt(n),
|
|
1041
1047
|
id: t,
|
|
1042
1048
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1043
1049
|
};
|
|
@@ -1046,29 +1052,29 @@ function vt(e) {
|
|
|
1046
1052
|
}
|
|
1047
1053
|
//#endregion
|
|
1048
1054
|
//#region src/tenants/remove.ts
|
|
1049
|
-
function
|
|
1055
|
+
function xt(e) {
|
|
1050
1056
|
return async (t) => (await e.deleteFrom("tenants").where("tenants.id", "=", t).execute()).length === 1;
|
|
1051
1057
|
}
|
|
1052
1058
|
//#endregion
|
|
1053
1059
|
//#region src/tenants/index.ts
|
|
1054
|
-
function
|
|
1060
|
+
function St(e) {
|
|
1055
1061
|
return {
|
|
1056
|
-
create:
|
|
1057
|
-
get:
|
|
1058
|
-
list:
|
|
1059
|
-
update:
|
|
1060
|
-
remove:
|
|
1062
|
+
create: _t(e),
|
|
1063
|
+
get: vt(e),
|
|
1064
|
+
list: yt(e),
|
|
1065
|
+
update: bt(e),
|
|
1066
|
+
remove: xt(e)
|
|
1061
1067
|
};
|
|
1062
1068
|
}
|
|
1063
1069
|
//#endregion
|
|
1064
1070
|
//#region src/logs/create.ts
|
|
1065
|
-
function
|
|
1071
|
+
function Ct(e) {
|
|
1066
1072
|
return e ? JSON.stringify(e) : void 0;
|
|
1067
1073
|
}
|
|
1068
|
-
var
|
|
1069
|
-
function
|
|
1074
|
+
var wt = 256;
|
|
1075
|
+
function Tt(e) {
|
|
1070
1076
|
return async (n, r) => {
|
|
1071
|
-
let i = r.user_agent?.slice(0,
|
|
1077
|
+
let i = r.user_agent?.slice(0, wt), a = r.log_id || t(), { location_info: o, ...s } = r;
|
|
1072
1078
|
return await e.insertInto("logs").values({
|
|
1073
1079
|
...s,
|
|
1074
1080
|
log_id: a,
|
|
@@ -1077,8 +1083,8 @@ function Ct(e) {
|
|
|
1077
1083
|
description: r.description?.substring(0, 256),
|
|
1078
1084
|
isMobile: +!!r.isMobile,
|
|
1079
1085
|
scope: r.scope,
|
|
1080
|
-
auth0_client:
|
|
1081
|
-
details:
|
|
1086
|
+
auth0_client: Ct(r.auth0_client),
|
|
1087
|
+
details: Ct(r.details)?.substring(0, 8192),
|
|
1082
1088
|
country_code: o?.country_code,
|
|
1083
1089
|
city_name: o?.city_name,
|
|
1084
1090
|
latitude: o?.latitude,
|
|
@@ -1094,7 +1100,7 @@ function Ct(e) {
|
|
|
1094
1100
|
}
|
|
1095
1101
|
//#endregion
|
|
1096
1102
|
//#region src/logs/logs.ts
|
|
1097
|
-
function
|
|
1103
|
+
function Et(e) {
|
|
1098
1104
|
if (!e) return "";
|
|
1099
1105
|
try {
|
|
1100
1106
|
return JSON.parse(e);
|
|
@@ -1102,13 +1108,13 @@ function wt(e) {
|
|
|
1102
1108
|
return e;
|
|
1103
1109
|
}
|
|
1104
1110
|
}
|
|
1105
|
-
function
|
|
1111
|
+
function F(e) {
|
|
1106
1112
|
return {
|
|
1107
1113
|
...e,
|
|
1108
1114
|
client_id: e.client_id,
|
|
1109
1115
|
client_name: e.client_name || "",
|
|
1110
|
-
auth0_client:
|
|
1111
|
-
details:
|
|
1116
|
+
auth0_client: Et(e.auth0_client),
|
|
1117
|
+
details: Et(e.details),
|
|
1112
1118
|
isMobile: !!e.isMobile,
|
|
1113
1119
|
scope: e.scope || void 0,
|
|
1114
1120
|
log_id: e.log_id,
|
|
@@ -1124,7 +1130,7 @@ function I(e) {
|
|
|
1124
1130
|
}
|
|
1125
1131
|
//#endregion
|
|
1126
1132
|
//#region src/logs/list.ts
|
|
1127
|
-
var
|
|
1133
|
+
var Dt = [
|
|
1128
1134
|
"user_id",
|
|
1129
1135
|
"ip",
|
|
1130
1136
|
"type",
|
|
@@ -1150,25 +1156,25 @@ var Tt = [
|
|
|
1150
1156
|
"time_zone",
|
|
1151
1157
|
"continent_code"
|
|
1152
1158
|
];
|
|
1153
|
-
function
|
|
1159
|
+
function Ot(e) {
|
|
1154
1160
|
return async (t, n = {}) => {
|
|
1155
1161
|
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);
|
|
1156
1162
|
if (c) {
|
|
1157
|
-
let t =
|
|
1158
|
-
t && (d =
|
|
1163
|
+
let t = x(c, Dt);
|
|
1164
|
+
t && (d = E(e, d, t, [
|
|
1159
1165
|
"user_id",
|
|
1160
1166
|
"ip",
|
|
1161
1167
|
"description"
|
|
1162
1168
|
], ["description"]));
|
|
1163
1169
|
}
|
|
1164
|
-
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())),
|
|
1165
|
-
if (s?.sort_by && s.sort_by !== "date") throw new
|
|
1166
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1170
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), j(n)) {
|
|
1171
|
+
if (s?.sort_by && s.sort_by !== "date") throw new S(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1172
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await M(d.selectAll(), n, {
|
|
1167
1173
|
sortColumn: "date",
|
|
1168
1174
|
sortOrder: e,
|
|
1169
1175
|
idColumn: "log_id",
|
|
1170
1176
|
sortKey: `date:${e}`
|
|
1171
|
-
}), a = t.map(
|
|
1177
|
+
}), a = t.map(F);
|
|
1172
1178
|
return {
|
|
1173
1179
|
logs: a,
|
|
1174
1180
|
start: 0,
|
|
@@ -1183,7 +1189,7 @@ function Et(e) {
|
|
|
1183
1189
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1184
1190
|
}
|
|
1185
1191
|
f = f.offset(r * i).limit(i);
|
|
1186
|
-
let p = (await f.selectAll().execute()).map(
|
|
1192
|
+
let p = (await f.selectAll().execute()).map(F);
|
|
1187
1193
|
if (!a) return {
|
|
1188
1194
|
logs: p,
|
|
1189
1195
|
start: 0,
|
|
@@ -1201,24 +1207,24 @@ function Et(e) {
|
|
|
1201
1207
|
}
|
|
1202
1208
|
//#endregion
|
|
1203
1209
|
//#region src/logs/get.ts
|
|
1204
|
-
function
|
|
1210
|
+
function kt(e) {
|
|
1205
1211
|
return async (t, n) => {
|
|
1206
1212
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1207
|
-
return r ?
|
|
1213
|
+
return r ? F(r) : null;
|
|
1208
1214
|
};
|
|
1209
1215
|
}
|
|
1210
1216
|
//#endregion
|
|
1211
1217
|
//#region src/logs/index.ts
|
|
1212
|
-
function
|
|
1218
|
+
function At(e) {
|
|
1213
1219
|
return {
|
|
1214
|
-
create:
|
|
1215
|
-
list:
|
|
1216
|
-
get:
|
|
1220
|
+
create: Tt(e),
|
|
1221
|
+
list: Ot(e),
|
|
1222
|
+
get: kt(e)
|
|
1217
1223
|
};
|
|
1218
1224
|
}
|
|
1219
1225
|
//#endregion
|
|
1220
1226
|
//#region src/sessions/get.ts
|
|
1221
|
-
function
|
|
1227
|
+
function jt(e) {
|
|
1222
1228
|
return async (t, n) => {
|
|
1223
1229
|
let i = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
1224
1230
|
if (!i) return null;
|
|
@@ -1252,7 +1258,7 @@ function kt(e) {
|
|
|
1252
1258
|
}
|
|
1253
1259
|
//#endregion
|
|
1254
1260
|
//#region src/sessions/create.ts
|
|
1255
|
-
function
|
|
1261
|
+
function Mt(e) {
|
|
1256
1262
|
return async (t, n) => {
|
|
1257
1263
|
let r = Date.now(), i = c(), a = {
|
|
1258
1264
|
...n,
|
|
@@ -1284,12 +1290,12 @@ function At(e) {
|
|
|
1284
1290
|
}
|
|
1285
1291
|
//#endregion
|
|
1286
1292
|
//#region src/sessions/remove.ts
|
|
1287
|
-
function
|
|
1293
|
+
function Nt(e) {
|
|
1288
1294
|
return async (t, n) => !!(await e.deleteFrom("sessions").where("tenant_id", "=", t).where("sessions.id", "=", n).execute()).length;
|
|
1289
1295
|
}
|
|
1290
1296
|
//#endregion
|
|
1291
1297
|
//#region src/sessions/update.ts
|
|
1292
|
-
function
|
|
1298
|
+
function Pt(e) {
|
|
1293
1299
|
return async (t, n, r) => {
|
|
1294
1300
|
let i = Date.now(), a = {
|
|
1295
1301
|
updated_at_ts: i,
|
|
@@ -1310,10 +1316,10 @@ function Mt(e) {
|
|
|
1310
1316
|
}
|
|
1311
1317
|
//#endregion
|
|
1312
1318
|
//#region src/sessions/list.ts
|
|
1313
|
-
function
|
|
1319
|
+
function Ft(e) {
|
|
1314
1320
|
return async (t, n = {}) => {
|
|
1315
1321
|
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);
|
|
1316
|
-
l && (u =
|
|
1322
|
+
l && (u = E(e, u, l, ["user_id", "session_id"]));
|
|
1317
1323
|
let d = u;
|
|
1318
1324
|
if (c && c.sort_by) {
|
|
1319
1325
|
let { ref: t } = e.dynamic;
|
|
@@ -1365,18 +1371,18 @@ function Nt(e) {
|
|
|
1365
1371
|
}
|
|
1366
1372
|
//#endregion
|
|
1367
1373
|
//#region src/sessions/index.ts
|
|
1368
|
-
function
|
|
1374
|
+
function It(e) {
|
|
1369
1375
|
return {
|
|
1370
|
-
create:
|
|
1371
|
-
get:
|
|
1372
|
-
list:
|
|
1373
|
-
remove:
|
|
1374
|
-
update:
|
|
1376
|
+
create: Mt(e),
|
|
1377
|
+
get: jt(e),
|
|
1378
|
+
list: Ft(e),
|
|
1379
|
+
remove: Nt(e),
|
|
1380
|
+
update: Pt(e)
|
|
1375
1381
|
};
|
|
1376
1382
|
}
|
|
1377
1383
|
//#endregion
|
|
1378
1384
|
//#region src/passwords/get.ts
|
|
1379
|
-
function
|
|
1385
|
+
function Lt(e) {
|
|
1380
1386
|
return async (t, n) => {
|
|
1381
1387
|
let r = await e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).where("passwords.is_current", "=", 1).selectAll().executeTakeFirst();
|
|
1382
1388
|
if (!r) return null;
|
|
@@ -1389,7 +1395,7 @@ function Ft(e) {
|
|
|
1389
1395
|
}
|
|
1390
1396
|
//#endregion
|
|
1391
1397
|
//#region src/passwords/create.ts
|
|
1392
|
-
function
|
|
1398
|
+
function Rt(e) {
|
|
1393
1399
|
return async (n, r, i) => {
|
|
1394
1400
|
let a = i?.importMetadata, o = a?.id || r.id || t(), s = r.is_current ?? !0, c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1395
1401
|
...r,
|
|
@@ -1407,7 +1413,7 @@ function It(e) {
|
|
|
1407
1413
|
}
|
|
1408
1414
|
//#endregion
|
|
1409
1415
|
//#region src/passwords/update.ts
|
|
1410
|
-
function
|
|
1416
|
+
function zt(e) {
|
|
1411
1417
|
return async (t, n) => {
|
|
1412
1418
|
let r = e.updateTable("passwords").set({
|
|
1413
1419
|
password: n.password,
|
|
@@ -1420,7 +1426,7 @@ function Lt(e) {
|
|
|
1420
1426
|
}
|
|
1421
1427
|
//#endregion
|
|
1422
1428
|
//#region src/passwords/list.ts
|
|
1423
|
-
function
|
|
1429
|
+
function Bt(e) {
|
|
1424
1430
|
return async (t, n, r) => {
|
|
1425
1431
|
let i = e.selectFrom("passwords").where("passwords.tenant_id", "=", t).where("passwords.user_id", "=", n).orderBy("created_at", "desc");
|
|
1426
1432
|
return r && (i = i.limit(r)), (await i.selectAll().execute()).map(({ tenant_id: e, ...t }) => ({
|
|
@@ -1431,20 +1437,20 @@ function Rt(e) {
|
|
|
1431
1437
|
}
|
|
1432
1438
|
//#endregion
|
|
1433
1439
|
//#region src/passwords/index.ts
|
|
1434
|
-
function
|
|
1440
|
+
function Vt(e) {
|
|
1435
1441
|
return {
|
|
1436
|
-
create:
|
|
1437
|
-
update:
|
|
1438
|
-
get:
|
|
1439
|
-
list:
|
|
1442
|
+
create: Rt(e),
|
|
1443
|
+
update: zt(e),
|
|
1444
|
+
get: Lt(e),
|
|
1445
|
+
list: Bt(e)
|
|
1440
1446
|
};
|
|
1441
1447
|
}
|
|
1442
1448
|
//#endregion
|
|
1443
1449
|
//#region src/codes/list.ts
|
|
1444
|
-
function
|
|
1450
|
+
function Ht(e) {
|
|
1445
1451
|
return async (t, n = {}) => {
|
|
1446
1452
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1447
|
-
s && (c =
|
|
1453
|
+
s && (c = E(e, c, s, ["code", "login_id"]));
|
|
1448
1454
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1449
1455
|
let { tenant_id: t, ...n } = e;
|
|
1450
1456
|
return g.parse(l(n));
|
|
@@ -1466,13 +1472,13 @@ function Bt(e) {
|
|
|
1466
1472
|
}
|
|
1467
1473
|
//#endregion
|
|
1468
1474
|
//#region src/codes/expires-at-ts.ts
|
|
1469
|
-
function
|
|
1475
|
+
function Ut(e) {
|
|
1470
1476
|
let t = new Date(e).getTime();
|
|
1471
1477
|
return Number.isNaN(t) ? 0 : t;
|
|
1472
1478
|
}
|
|
1473
1479
|
//#endregion
|
|
1474
1480
|
//#region src/codes/create.ts
|
|
1475
|
-
function
|
|
1481
|
+
function Wt(e) {
|
|
1476
1482
|
return async (t, n) => {
|
|
1477
1483
|
let r = {
|
|
1478
1484
|
...n,
|
|
@@ -1481,18 +1487,18 @@ function Ht(e) {
|
|
|
1481
1487
|
return await e.insertInto("codes").values({
|
|
1482
1488
|
...r,
|
|
1483
1489
|
tenant_id: t,
|
|
1484
|
-
expires_at_ts:
|
|
1490
|
+
expires_at_ts: Ut(r.expires_at)
|
|
1485
1491
|
}).execute(), r;
|
|
1486
1492
|
};
|
|
1487
1493
|
}
|
|
1488
1494
|
//#endregion
|
|
1489
1495
|
//#region src/codes/remove.ts
|
|
1490
|
-
function
|
|
1496
|
+
function Gt(e) {
|
|
1491
1497
|
return async (t, n) => (await e.deleteFrom("codes").where("codes.tenant_id", "=", t).where("codes.code_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1492
1498
|
}
|
|
1493
1499
|
//#endregion
|
|
1494
1500
|
//#region src/codes/get.ts
|
|
1495
|
-
function
|
|
1501
|
+
function Kt(e) {
|
|
1496
1502
|
return async (t, n, r) => {
|
|
1497
1503
|
let i = e.selectFrom("codes").where("codes.code_id", "=", n).where("codes.code_type", "=", r);
|
|
1498
1504
|
t.length && (i = i.where("codes.tenant_id", "=", t));
|
|
@@ -1502,44 +1508,44 @@ function Wt(e) {
|
|
|
1502
1508
|
}
|
|
1503
1509
|
//#endregion
|
|
1504
1510
|
//#region src/codes/used.ts
|
|
1505
|
-
function
|
|
1511
|
+
function qt(e) {
|
|
1506
1512
|
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;
|
|
1507
1513
|
}
|
|
1508
1514
|
//#endregion
|
|
1509
1515
|
//#region src/codes/consume.ts
|
|
1510
|
-
function
|
|
1516
|
+
function Jt(e) {
|
|
1511
1517
|
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;
|
|
1512
1518
|
}
|
|
1513
1519
|
//#endregion
|
|
1514
1520
|
//#region src/codes/cleanup.ts
|
|
1515
|
-
function
|
|
1521
|
+
function Yt(e) {
|
|
1516
1522
|
return async (t) => {
|
|
1517
|
-
let n = await e.deleteFrom("codes").where("expires_at_ts", "<",
|
|
1523
|
+
let n = await e.deleteFrom("codes").where("expires_at_ts", "<", Ut(t)).executeTakeFirst(), r = await e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", t).executeTakeFirst();
|
|
1518
1524
|
return Number(n.numDeletedRows) + Number(r.numDeletedRows);
|
|
1519
1525
|
};
|
|
1520
1526
|
}
|
|
1521
1527
|
//#endregion
|
|
1522
1528
|
//#region src/codes/index.ts
|
|
1523
|
-
function
|
|
1529
|
+
function Xt(e) {
|
|
1524
1530
|
return {
|
|
1525
|
-
create:
|
|
1526
|
-
list:
|
|
1527
|
-
remove:
|
|
1528
|
-
used:
|
|
1529
|
-
consume:
|
|
1530
|
-
get:
|
|
1531
|
-
cleanup:
|
|
1531
|
+
create: Wt(e),
|
|
1532
|
+
list: Ht(e),
|
|
1533
|
+
remove: Gt(e),
|
|
1534
|
+
used: qt(e),
|
|
1535
|
+
consume: Jt(e),
|
|
1536
|
+
get: Kt(e),
|
|
1537
|
+
cleanup: Yt(e)
|
|
1532
1538
|
};
|
|
1533
1539
|
}
|
|
1534
1540
|
//#endregion
|
|
1535
1541
|
//#region src/connections/create.ts
|
|
1536
|
-
function
|
|
1542
|
+
function Zt(e) {
|
|
1537
1543
|
return async (t, n, r) => {
|
|
1538
1544
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1539
1545
|
delete o.enabled_clients;
|
|
1540
1546
|
let s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
1541
1547
|
...o,
|
|
1542
|
-
id: i?.id ?? o.id ??
|
|
1548
|
+
id: i?.id ?? o.id ?? be(),
|
|
1543
1549
|
is_system: a ? !0 : void 0,
|
|
1544
1550
|
created_at: i?.created_at ?? s,
|
|
1545
1551
|
updated_at: i?.updated_at ?? s
|
|
@@ -1554,7 +1560,7 @@ function Yt(e) {
|
|
|
1554
1560
|
}
|
|
1555
1561
|
//#endregion
|
|
1556
1562
|
//#region src/connections/transform.ts
|
|
1557
|
-
function
|
|
1563
|
+
function I(e) {
|
|
1558
1564
|
let { is_system: t, ...n } = e;
|
|
1559
1565
|
return l({
|
|
1560
1566
|
...n,
|
|
@@ -1562,16 +1568,16 @@ function L(e) {
|
|
|
1562
1568
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1563
1569
|
});
|
|
1564
1570
|
}
|
|
1565
|
-
function
|
|
1566
|
-
return e.map(
|
|
1571
|
+
function Qt(e) {
|
|
1572
|
+
return e.map(I);
|
|
1567
1573
|
}
|
|
1568
1574
|
//#endregion
|
|
1569
1575
|
//#region src/connections/list.ts
|
|
1570
|
-
function
|
|
1576
|
+
function $t(e) {
|
|
1571
1577
|
return async (t, n = {}) => {
|
|
1572
1578
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1573
|
-
s && (c =
|
|
1574
|
-
let l =
|
|
1579
|
+
s && (c = E(e, c, s, ["user_id", "ip"]));
|
|
1580
|
+
let l = Qt(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1575
1581
|
if (!a) return {
|
|
1576
1582
|
connections: l,
|
|
1577
1583
|
start: 0,
|
|
@@ -1589,20 +1595,20 @@ function Zt(e) {
|
|
|
1589
1595
|
}
|
|
1590
1596
|
//#endregion
|
|
1591
1597
|
//#region src/connections/remove.ts
|
|
1592
|
-
function
|
|
1598
|
+
function en(e) {
|
|
1593
1599
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1594
1600
|
}
|
|
1595
1601
|
//#endregion
|
|
1596
1602
|
//#region src/connections/get.ts
|
|
1597
|
-
function
|
|
1603
|
+
function tn(e) {
|
|
1598
1604
|
return async (t, n) => {
|
|
1599
1605
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1600
|
-
return r ?
|
|
1606
|
+
return r ? I(r) : null;
|
|
1601
1607
|
};
|
|
1602
1608
|
}
|
|
1603
1609
|
//#endregion
|
|
1604
1610
|
//#region src/connections/update.ts
|
|
1605
|
-
function
|
|
1611
|
+
function nn(e) {
|
|
1606
1612
|
return async (t, n, r) => {
|
|
1607
1613
|
let { is_system: i, ...a } = r;
|
|
1608
1614
|
delete a.enabled_clients;
|
|
@@ -1619,18 +1625,18 @@ function en(e) {
|
|
|
1619
1625
|
}
|
|
1620
1626
|
//#endregion
|
|
1621
1627
|
//#region src/connections/index.ts
|
|
1622
|
-
function
|
|
1628
|
+
function rn(e) {
|
|
1623
1629
|
return {
|
|
1624
|
-
create:
|
|
1625
|
-
get:
|
|
1626
|
-
list:
|
|
1627
|
-
remove:
|
|
1628
|
-
update:
|
|
1630
|
+
create: Zt(e),
|
|
1631
|
+
get: tn(e),
|
|
1632
|
+
list: $t(e),
|
|
1633
|
+
remove: en(e),
|
|
1634
|
+
update: nn(e)
|
|
1629
1635
|
};
|
|
1630
1636
|
}
|
|
1631
1637
|
//#endregion
|
|
1632
1638
|
//#region src/clients/create.ts
|
|
1633
|
-
function
|
|
1639
|
+
function an(e) {
|
|
1634
1640
|
return async (r, i, a) => {
|
|
1635
1641
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1636
1642
|
...i,
|
|
@@ -1695,7 +1701,7 @@ function nn(e) {
|
|
|
1695
1701
|
}
|
|
1696
1702
|
//#endregion
|
|
1697
1703
|
//#region src/clients/get.ts
|
|
1698
|
-
function
|
|
1704
|
+
function on(e) {
|
|
1699
1705
|
return async (t, n) => {
|
|
1700
1706
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1701
1707
|
if (!r) return null;
|
|
@@ -1741,7 +1747,7 @@ function rn(e) {
|
|
|
1741
1747
|
}
|
|
1742
1748
|
//#endregion
|
|
1743
1749
|
//#region src/clients/getByClientId.ts
|
|
1744
|
-
function
|
|
1750
|
+
function sn(e) {
|
|
1745
1751
|
return async (t) => {
|
|
1746
1752
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1747
1753
|
return n ? l({
|
|
@@ -1785,7 +1791,7 @@ function an(e) {
|
|
|
1785
1791
|
}
|
|
1786
1792
|
//#endregion
|
|
1787
1793
|
//#region src/clients/list.ts
|
|
1788
|
-
function
|
|
1794
|
+
function cn(e) {
|
|
1789
1795
|
return l({
|
|
1790
1796
|
...e,
|
|
1791
1797
|
global: !!e.global,
|
|
@@ -1824,7 +1830,7 @@ function on(e) {
|
|
|
1824
1830
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1825
1831
|
});
|
|
1826
1832
|
}
|
|
1827
|
-
function
|
|
1833
|
+
function ln(e) {
|
|
1828
1834
|
return async (t, n) => {
|
|
1829
1835
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1830
1836
|
if (n?.q) {
|
|
@@ -1834,12 +1840,12 @@ function sn(e) {
|
|
|
1834
1840
|
r = r.where(t, "=", e[2]);
|
|
1835
1841
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1836
1842
|
}
|
|
1837
|
-
if (
|
|
1838
|
-
let { rows: e, limit: t, next: i } = await
|
|
1843
|
+
if (j(n)) {
|
|
1844
|
+
let { rows: e, limit: t, next: i } = await M(r.selectAll(), n, {
|
|
1839
1845
|
sortColumn: "created_at",
|
|
1840
1846
|
sortOrder: "desc",
|
|
1841
1847
|
idColumn: "client_id"
|
|
1842
|
-
}), a = e.map(
|
|
1848
|
+
}), a = e.map(cn);
|
|
1843
1849
|
return {
|
|
1844
1850
|
clients: a,
|
|
1845
1851
|
totals: {
|
|
@@ -1872,7 +1878,7 @@ function sn(e) {
|
|
|
1872
1878
|
let a = await r.executeTakeFirst();
|
|
1873
1879
|
c = Number(a?.count || 0);
|
|
1874
1880
|
}
|
|
1875
|
-
let l = s.map(
|
|
1881
|
+
let l = s.map(cn);
|
|
1876
1882
|
return {
|
|
1877
1883
|
clients: l,
|
|
1878
1884
|
totals: {
|
|
@@ -1886,12 +1892,12 @@ function sn(e) {
|
|
|
1886
1892
|
}
|
|
1887
1893
|
//#endregion
|
|
1888
1894
|
//#region src/clients/remove.ts
|
|
1889
|
-
function
|
|
1895
|
+
function un(e) {
|
|
1890
1896
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1891
1897
|
}
|
|
1892
1898
|
//#endregion
|
|
1893
1899
|
//#region src/clients/update.ts
|
|
1894
|
-
function
|
|
1900
|
+
function dn(e) {
|
|
1895
1901
|
return async (t, r, i) => {
|
|
1896
1902
|
let a = {
|
|
1897
1903
|
...i,
|
|
@@ -1938,31 +1944,31 @@ function ln(e) {
|
|
|
1938
1944
|
}
|
|
1939
1945
|
//#endregion
|
|
1940
1946
|
//#region src/clients/index.ts
|
|
1941
|
-
function
|
|
1947
|
+
function fn(e) {
|
|
1942
1948
|
return {
|
|
1943
|
-
create:
|
|
1944
|
-
get:
|
|
1945
|
-
getByClientId:
|
|
1946
|
-
list:
|
|
1947
|
-
remove:
|
|
1948
|
-
update:
|
|
1949
|
+
create: an(e),
|
|
1950
|
+
get: on(e),
|
|
1951
|
+
getByClientId: sn(e),
|
|
1952
|
+
list: ln(e),
|
|
1953
|
+
remove: un(e),
|
|
1954
|
+
update: dn(e)
|
|
1949
1955
|
};
|
|
1950
1956
|
}
|
|
1951
1957
|
//#endregion
|
|
1952
1958
|
//#region src/clientConnections/listByClient.ts
|
|
1953
|
-
function
|
|
1959
|
+
function pn(e) {
|
|
1954
1960
|
return async (t, n) => {
|
|
1955
1961
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1956
1962
|
if (!r) return [];
|
|
1957
1963
|
let i = JSON.parse(r.connections || "[]");
|
|
1958
1964
|
if (i.length === 0) return [];
|
|
1959
|
-
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,
|
|
1965
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, I(e)]));
|
|
1960
1966
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
1961
1967
|
};
|
|
1962
1968
|
}
|
|
1963
1969
|
//#endregion
|
|
1964
1970
|
//#region src/clientConnections/updateByClient.ts
|
|
1965
|
-
function
|
|
1971
|
+
function mn(e) {
|
|
1966
1972
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
1967
1973
|
connections: JSON.stringify(r),
|
|
1968
1974
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1970,7 +1976,7 @@ function fn(e) {
|
|
|
1970
1976
|
}
|
|
1971
1977
|
//#endregion
|
|
1972
1978
|
//#region src/clientConnections/listByConnection.ts
|
|
1973
|
-
function
|
|
1979
|
+
function hn(e) {
|
|
1974
1980
|
return async (t, n) => {
|
|
1975
1981
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
1976
1982
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -1979,7 +1985,7 @@ function pn(e) {
|
|
|
1979
1985
|
}
|
|
1980
1986
|
//#endregion
|
|
1981
1987
|
//#region src/clientConnections/addClientToConnection.ts
|
|
1982
|
-
function
|
|
1988
|
+
function gn(e) {
|
|
1983
1989
|
return async (t, n, r) => {
|
|
1984
1990
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
1985
1991
|
if (!i) return !1;
|
|
@@ -1992,7 +1998,7 @@ function mn(e) {
|
|
|
1992
1998
|
}
|
|
1993
1999
|
//#endregion
|
|
1994
2000
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
1995
|
-
function
|
|
2001
|
+
function _n(e) {
|
|
1996
2002
|
return async (t, n, r) => {
|
|
1997
2003
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
1998
2004
|
if (!i) return !1;
|
|
@@ -2005,18 +2011,18 @@ function hn(e) {
|
|
|
2005
2011
|
}
|
|
2006
2012
|
//#endregion
|
|
2007
2013
|
//#region src/clientConnections/index.ts
|
|
2008
|
-
function
|
|
2014
|
+
function vn(e) {
|
|
2009
2015
|
return {
|
|
2010
|
-
listByClient:
|
|
2011
|
-
updateByClient:
|
|
2012
|
-
listByConnection:
|
|
2013
|
-
addClientToConnection:
|
|
2014
|
-
removeClientFromConnection:
|
|
2016
|
+
listByClient: pn(e),
|
|
2017
|
+
updateByClient: mn(e),
|
|
2018
|
+
listByConnection: hn(e),
|
|
2019
|
+
addClientToConnection: gn(e),
|
|
2020
|
+
removeClientFromConnection: _n(e)
|
|
2015
2021
|
};
|
|
2016
2022
|
}
|
|
2017
2023
|
//#endregion
|
|
2018
2024
|
//#region src/clientGrants/create.ts
|
|
2019
|
-
function
|
|
2025
|
+
function yn(e) {
|
|
2020
2026
|
return async (n, r, i) => {
|
|
2021
2027
|
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 = {
|
|
2022
2028
|
id: s,
|
|
@@ -2044,7 +2050,7 @@ function _n(e) {
|
|
|
2044
2050
|
}
|
|
2045
2051
|
//#endregion
|
|
2046
2052
|
//#region src/clientGrants/get.ts
|
|
2047
|
-
function
|
|
2053
|
+
function bn(e) {
|
|
2048
2054
|
return async (t, n) => {
|
|
2049
2055
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2050
2056
|
return r ? l({
|
|
@@ -2064,7 +2070,7 @@ function vn(e) {
|
|
|
2064
2070
|
}
|
|
2065
2071
|
//#endregion
|
|
2066
2072
|
//#region src/clientGrants/list.ts
|
|
2067
|
-
function
|
|
2073
|
+
function xn(e) {
|
|
2068
2074
|
return m.parse(l({
|
|
2069
2075
|
...e,
|
|
2070
2076
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2073,7 +2079,7 @@ function yn(e) {
|
|
|
2073
2079
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2074
2080
|
}));
|
|
2075
2081
|
}
|
|
2076
|
-
function
|
|
2082
|
+
function Sn(e) {
|
|
2077
2083
|
return async (t, n = {}) => {
|
|
2078
2084
|
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);
|
|
2079
2085
|
if (s) {
|
|
@@ -2084,13 +2090,13 @@ function bn(e) {
|
|
|
2084
2090
|
let e = +(a === "true");
|
|
2085
2091
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2086
2092
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2087
|
-
} else l =
|
|
2093
|
+
} else l = E(e, l, t, []);
|
|
2088
2094
|
}
|
|
2089
|
-
if (
|
|
2090
|
-
let { rows: e, limit: t, next: r } = await
|
|
2095
|
+
if (j(n)) {
|
|
2096
|
+
let { rows: e, limit: t, next: r } = await M(l.selectAll(), n, {
|
|
2091
2097
|
sortColumn: "created_at",
|
|
2092
2098
|
sortOrder: "desc"
|
|
2093
|
-
}), i = e.map(
|
|
2099
|
+
}), i = e.map(xn);
|
|
2094
2100
|
return {
|
|
2095
2101
|
client_grants: i,
|
|
2096
2102
|
start: 0,
|
|
@@ -2104,7 +2110,7 @@ function bn(e) {
|
|
|
2104
2110
|
let { ref: t } = e.dynamic;
|
|
2105
2111
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2106
2112
|
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2107
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2113
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(xn);
|
|
2108
2114
|
if (!a) return {
|
|
2109
2115
|
client_grants: d,
|
|
2110
2116
|
start: 0,
|
|
@@ -2122,12 +2128,12 @@ function bn(e) {
|
|
|
2122
2128
|
}
|
|
2123
2129
|
//#endregion
|
|
2124
2130
|
//#region src/clientGrants/remove.ts
|
|
2125
|
-
function
|
|
2131
|
+
function Cn(e) {
|
|
2126
2132
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2127
2133
|
}
|
|
2128
2134
|
//#endregion
|
|
2129
2135
|
//#region src/clientGrants/update.ts
|
|
2130
|
-
function
|
|
2136
|
+
function wn(e) {
|
|
2131
2137
|
return async (t, n, r) => {
|
|
2132
2138
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2133
2139
|
...s,
|
|
@@ -2138,18 +2144,18 @@ function Sn(e) {
|
|
|
2138
2144
|
}
|
|
2139
2145
|
//#endregion
|
|
2140
2146
|
//#region src/clientGrants/index.ts
|
|
2141
|
-
function
|
|
2147
|
+
function Tn(e) {
|
|
2142
2148
|
return {
|
|
2143
|
-
create:
|
|
2144
|
-
get:
|
|
2145
|
-
list:
|
|
2146
|
-
remove:
|
|
2147
|
-
update:
|
|
2149
|
+
create: yn(e),
|
|
2150
|
+
get: bn(e),
|
|
2151
|
+
list: Sn(e),
|
|
2152
|
+
remove: Cn(e),
|
|
2153
|
+
update: wn(e)
|
|
2148
2154
|
};
|
|
2149
2155
|
}
|
|
2150
2156
|
//#endregion
|
|
2151
2157
|
//#region src/clientRegistrationTokens/create.ts
|
|
2152
|
-
function
|
|
2158
|
+
function En(e) {
|
|
2153
2159
|
return async (t, n) => {
|
|
2154
2160
|
let r = Date.now();
|
|
2155
2161
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2180,12 +2186,12 @@ function wn(e) {
|
|
|
2180
2186
|
}
|
|
2181
2187
|
//#endregion
|
|
2182
2188
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2183
|
-
function
|
|
2189
|
+
function Dn(e) {
|
|
2184
2190
|
let t = h.safeParse(e);
|
|
2185
2191
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2186
2192
|
return t.data;
|
|
2187
2193
|
}
|
|
2188
|
-
function
|
|
2194
|
+
function On(e) {
|
|
2189
2195
|
if (!e) return;
|
|
2190
2196
|
let t;
|
|
2191
2197
|
try {
|
|
@@ -2193,16 +2199,16 @@ function En(e) {
|
|
|
2193
2199
|
} catch {
|
|
2194
2200
|
return;
|
|
2195
2201
|
}
|
|
2196
|
-
return
|
|
2202
|
+
return ne(t) ? t : void 0;
|
|
2197
2203
|
}
|
|
2198
|
-
function
|
|
2204
|
+
function L(e) {
|
|
2199
2205
|
return {
|
|
2200
2206
|
id: e.id,
|
|
2201
2207
|
token_hash: e.token_hash,
|
|
2202
|
-
type:
|
|
2208
|
+
type: Dn(e.type),
|
|
2203
2209
|
client_id: e.client_id ?? void 0,
|
|
2204
2210
|
sub: e.sub ?? void 0,
|
|
2205
|
-
constraints:
|
|
2211
|
+
constraints: On(e.constraints),
|
|
2206
2212
|
single_use: !!e.single_use,
|
|
2207
2213
|
expires_at: i(e.expires_at_ts),
|
|
2208
2214
|
used_at: i(e.used_at_ts),
|
|
@@ -2212,38 +2218,38 @@ function R(e) {
|
|
|
2212
2218
|
}
|
|
2213
2219
|
//#endregion
|
|
2214
2220
|
//#region src/clientRegistrationTokens/get.ts
|
|
2215
|
-
function
|
|
2221
|
+
function kn(e) {
|
|
2216
2222
|
return async (t, n) => {
|
|
2217
2223
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2218
|
-
return r ?
|
|
2224
|
+
return r ? L(r) : null;
|
|
2219
2225
|
};
|
|
2220
2226
|
}
|
|
2221
2227
|
//#endregion
|
|
2222
2228
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2223
|
-
function
|
|
2229
|
+
function An(e) {
|
|
2224
2230
|
return async (t, n) => {
|
|
2225
2231
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2226
|
-
return r ?
|
|
2232
|
+
return r ? L(r) : null;
|
|
2227
2233
|
};
|
|
2228
2234
|
}
|
|
2229
2235
|
//#endregion
|
|
2230
2236
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2231
|
-
function
|
|
2232
|
-
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(
|
|
2237
|
+
function jn(e) {
|
|
2238
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(L);
|
|
2233
2239
|
}
|
|
2234
2240
|
//#endregion
|
|
2235
2241
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2236
|
-
function
|
|
2242
|
+
function Mn(e) {
|
|
2237
2243
|
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;
|
|
2238
2244
|
}
|
|
2239
2245
|
//#endregion
|
|
2240
2246
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2241
|
-
function
|
|
2247
|
+
function Nn(e) {
|
|
2242
2248
|
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;
|
|
2243
2249
|
}
|
|
2244
2250
|
//#endregion
|
|
2245
2251
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2246
|
-
function
|
|
2252
|
+
function Pn(e) {
|
|
2247
2253
|
return async (t, n, r) => {
|
|
2248
2254
|
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();
|
|
2249
2255
|
return Number(i.numUpdatedRows);
|
|
@@ -2251,29 +2257,29 @@ function Mn(e) {
|
|
|
2251
2257
|
}
|
|
2252
2258
|
//#endregion
|
|
2253
2259
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2254
|
-
function
|
|
2260
|
+
function Fn(e) {
|
|
2255
2261
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2256
2262
|
}
|
|
2257
2263
|
//#endregion
|
|
2258
2264
|
//#region src/clientRegistrationTokens/index.ts
|
|
2259
|
-
function
|
|
2265
|
+
function In(e) {
|
|
2260
2266
|
return {
|
|
2261
|
-
create:
|
|
2262
|
-
get:
|
|
2263
|
-
getByHash:
|
|
2264
|
-
listByClient:
|
|
2265
|
-
markUsed:
|
|
2266
|
-
revoke:
|
|
2267
|
-
revokeByClient:
|
|
2268
|
-
remove:
|
|
2267
|
+
create: En(e),
|
|
2268
|
+
get: kn(e),
|
|
2269
|
+
getByHash: An(e),
|
|
2270
|
+
listByClient: jn(e),
|
|
2271
|
+
markUsed: Mn(e),
|
|
2272
|
+
revoke: Nn(e),
|
|
2273
|
+
revokeByClient: Pn(e),
|
|
2274
|
+
remove: Fn(e)
|
|
2269
2275
|
};
|
|
2270
2276
|
}
|
|
2271
2277
|
//#endregion
|
|
2272
2278
|
//#region src/keys/list.ts
|
|
2273
|
-
function
|
|
2279
|
+
function Ln(e) {
|
|
2274
2280
|
return async (t = {}) => {
|
|
2275
2281
|
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)]));
|
|
2276
|
-
s && (c =
|
|
2282
|
+
s && (c = E(e, c, s, [
|
|
2277
2283
|
"kid",
|
|
2278
2284
|
"tenant_id",
|
|
2279
2285
|
"connection",
|
|
@@ -2299,7 +2305,7 @@ function Fn(e) {
|
|
|
2299
2305
|
}
|
|
2300
2306
|
//#endregion
|
|
2301
2307
|
//#region src/keys/create.ts
|
|
2302
|
-
function
|
|
2308
|
+
function Rn(e) {
|
|
2303
2309
|
return async (t, n) => {
|
|
2304
2310
|
let r = n?.importMetadata;
|
|
2305
2311
|
await e.insertInto("keys").values({
|
|
@@ -2311,21 +2317,21 @@ function In(e) {
|
|
|
2311
2317
|
}
|
|
2312
2318
|
//#endregion
|
|
2313
2319
|
//#region src/keys/update.ts
|
|
2314
|
-
function
|
|
2320
|
+
function zn(e) {
|
|
2315
2321
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2316
2322
|
}
|
|
2317
2323
|
//#endregion
|
|
2318
2324
|
//#region src/keys/index.ts
|
|
2319
|
-
function
|
|
2325
|
+
function Bn(e) {
|
|
2320
2326
|
return {
|
|
2321
|
-
create:
|
|
2322
|
-
list:
|
|
2323
|
-
update:
|
|
2327
|
+
create: Rn(e),
|
|
2328
|
+
list: Ln(e),
|
|
2329
|
+
update: zn(e)
|
|
2324
2330
|
};
|
|
2325
2331
|
}
|
|
2326
2332
|
//#endregion
|
|
2327
2333
|
//#region src/customDomains/create.ts
|
|
2328
|
-
function
|
|
2334
|
+
function Vn(e) {
|
|
2329
2335
|
return async (n, r, i) => {
|
|
2330
2336
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2331
2337
|
status: "pending",
|
|
@@ -2345,35 +2351,35 @@ function zn(e) {
|
|
|
2345
2351
|
}
|
|
2346
2352
|
//#endregion
|
|
2347
2353
|
//#region src/customDomains/list.ts
|
|
2348
|
-
function
|
|
2354
|
+
function Hn(e) {
|
|
2349
2355
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2350
2356
|
...e,
|
|
2351
2357
|
primary: e.primary === 1,
|
|
2352
|
-
domain_metadata:
|
|
2353
|
-
verification:
|
|
2358
|
+
domain_metadata: P(e.domain_metadata, void 0),
|
|
2359
|
+
verification: P(e.verification, void 0)
|
|
2354
2360
|
}));
|
|
2355
2361
|
}
|
|
2356
2362
|
//#endregion
|
|
2357
2363
|
//#region src/customDomains/remove.ts
|
|
2358
|
-
function
|
|
2364
|
+
function Un(e) {
|
|
2359
2365
|
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;
|
|
2360
2366
|
}
|
|
2361
2367
|
//#endregion
|
|
2362
2368
|
//#region src/customDomains/get.ts
|
|
2363
|
-
function
|
|
2369
|
+
function Wn(e) {
|
|
2364
2370
|
return async (t, n) => {
|
|
2365
2371
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2366
2372
|
return r ? {
|
|
2367
2373
|
...r,
|
|
2368
2374
|
primary: r.primary === 1,
|
|
2369
|
-
domain_metadata:
|
|
2370
|
-
verification:
|
|
2375
|
+
domain_metadata: P(r.domain_metadata, void 0),
|
|
2376
|
+
verification: P(r.verification, void 0)
|
|
2371
2377
|
} : null;
|
|
2372
2378
|
};
|
|
2373
2379
|
}
|
|
2374
2380
|
//#endregion
|
|
2375
2381
|
//#region src/customDomains/update.ts
|
|
2376
|
-
function
|
|
2382
|
+
function Gn(e) {
|
|
2377
2383
|
return async (t, n, r) => {
|
|
2378
2384
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2379
2385
|
...s,
|
|
@@ -2387,31 +2393,31 @@ function Un(e) {
|
|
|
2387
2393
|
}
|
|
2388
2394
|
//#endregion
|
|
2389
2395
|
//#region src/customDomains/getByDomain.ts
|
|
2390
|
-
function
|
|
2396
|
+
function Kn(e) {
|
|
2391
2397
|
return async (t) => {
|
|
2392
2398
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2393
2399
|
return n ? {
|
|
2394
2400
|
...n,
|
|
2395
2401
|
primary: n.primary === 1,
|
|
2396
|
-
domain_metadata:
|
|
2402
|
+
domain_metadata: P(n.domain_metadata, void 0)
|
|
2397
2403
|
} : null;
|
|
2398
2404
|
};
|
|
2399
2405
|
}
|
|
2400
2406
|
//#endregion
|
|
2401
2407
|
//#region src/customDomains/index.ts
|
|
2402
|
-
function
|
|
2408
|
+
function qn(e) {
|
|
2403
2409
|
return {
|
|
2404
|
-
create:
|
|
2405
|
-
get:
|
|
2406
|
-
getByDomain:
|
|
2407
|
-
list:
|
|
2408
|
-
remove:
|
|
2409
|
-
update:
|
|
2410
|
+
create: Vn(e),
|
|
2411
|
+
get: Wn(e),
|
|
2412
|
+
getByDomain: Kn(e),
|
|
2413
|
+
list: Hn(e),
|
|
2414
|
+
remove: Un(e),
|
|
2415
|
+
update: Gn(e)
|
|
2410
2416
|
};
|
|
2411
2417
|
}
|
|
2412
2418
|
//#endregion
|
|
2413
2419
|
//#region src/branding/get.ts
|
|
2414
|
-
function
|
|
2420
|
+
function Jn(e) {
|
|
2415
2421
|
return async (t) => {
|
|
2416
2422
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2417
2423
|
if (!n) return null;
|
|
@@ -2433,7 +2439,7 @@ function Kn(e) {
|
|
|
2433
2439
|
}
|
|
2434
2440
|
//#endregion
|
|
2435
2441
|
//#region src/branding/set.ts
|
|
2436
|
-
function
|
|
2442
|
+
function Yn(e) {
|
|
2437
2443
|
return async (t, n) => {
|
|
2438
2444
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2439
2445
|
try {
|
|
@@ -2462,15 +2468,15 @@ function qn(e) {
|
|
|
2462
2468
|
}
|
|
2463
2469
|
//#endregion
|
|
2464
2470
|
//#region src/branding/index.ts
|
|
2465
|
-
function
|
|
2471
|
+
function Xn(e) {
|
|
2466
2472
|
return {
|
|
2467
|
-
get:
|
|
2468
|
-
set:
|
|
2473
|
+
get: Jn(e),
|
|
2474
|
+
set: Yn(e)
|
|
2469
2475
|
};
|
|
2470
2476
|
}
|
|
2471
2477
|
//#endregion
|
|
2472
2478
|
//#region src/universalLoginTemplates/get.ts
|
|
2473
|
-
function
|
|
2479
|
+
function Zn(e) {
|
|
2474
2480
|
return async (t) => {
|
|
2475
2481
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2476
2482
|
return n ? { body: n.body } : null;
|
|
@@ -2478,7 +2484,7 @@ function Yn(e) {
|
|
|
2478
2484
|
}
|
|
2479
2485
|
//#endregion
|
|
2480
2486
|
//#region src/universalLoginTemplates/set.ts
|
|
2481
|
-
function
|
|
2487
|
+
function Qn(e) {
|
|
2482
2488
|
return async (t, n, r) => {
|
|
2483
2489
|
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;
|
|
2484
2490
|
try {
|
|
@@ -2499,26 +2505,26 @@ function Xn(e) {
|
|
|
2499
2505
|
}
|
|
2500
2506
|
//#endregion
|
|
2501
2507
|
//#region src/universalLoginTemplates/delete.ts
|
|
2502
|
-
function
|
|
2508
|
+
function $n(e) {
|
|
2503
2509
|
return async (t) => {
|
|
2504
2510
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2505
2511
|
};
|
|
2506
2512
|
}
|
|
2507
2513
|
//#endregion
|
|
2508
2514
|
//#region src/universalLoginTemplates/index.ts
|
|
2509
|
-
function
|
|
2515
|
+
function er(e) {
|
|
2510
2516
|
return {
|
|
2511
|
-
get:
|
|
2512
|
-
set:
|
|
2513
|
-
delete:
|
|
2517
|
+
get: Zn(e),
|
|
2518
|
+
set: Qn(e),
|
|
2519
|
+
delete: $n(e)
|
|
2514
2520
|
};
|
|
2515
2521
|
}
|
|
2516
2522
|
//#endregion
|
|
2517
2523
|
//#region src/hooks/list.ts
|
|
2518
|
-
function
|
|
2524
|
+
function tr(e) {
|
|
2519
2525
|
return async (t, n = {}) => {
|
|
2520
2526
|
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);
|
|
2521
|
-
if (u && (d =
|
|
2527
|
+
if (u && (d = E(e, d, u, [
|
|
2522
2528
|
"url",
|
|
2523
2529
|
"form_id",
|
|
2524
2530
|
"template_id",
|
|
@@ -2537,7 +2543,7 @@ function $n(e) {
|
|
|
2537
2543
|
...u,
|
|
2538
2544
|
enabled: !!n,
|
|
2539
2545
|
synchronous: !!i,
|
|
2540
|
-
metadata:
|
|
2546
|
+
metadata: ct(s)
|
|
2541
2547
|
});
|
|
2542
2548
|
});
|
|
2543
2549
|
if (!s) return {
|
|
@@ -2557,7 +2563,7 @@ function $n(e) {
|
|
|
2557
2563
|
}
|
|
2558
2564
|
//#endregion
|
|
2559
2565
|
//#region src/hooks/get.ts
|
|
2560
|
-
function
|
|
2566
|
+
function nr(e) {
|
|
2561
2567
|
return async (t, n) => {
|
|
2562
2568
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2563
2569
|
if (!i) return null;
|
|
@@ -2570,20 +2576,20 @@ function er(e) {
|
|
|
2570
2576
|
...d,
|
|
2571
2577
|
enabled: !!u.enabled,
|
|
2572
2578
|
synchronous: !!u.synchronous,
|
|
2573
|
-
metadata:
|
|
2579
|
+
metadata: ct(c)
|
|
2574
2580
|
});
|
|
2575
2581
|
};
|
|
2576
2582
|
}
|
|
2577
2583
|
//#endregion
|
|
2578
2584
|
//#region src/hooks/remove.ts
|
|
2579
|
-
function
|
|
2585
|
+
function rr(e) {
|
|
2580
2586
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2581
2587
|
}
|
|
2582
2588
|
//#endregion
|
|
2583
2589
|
//#region src/hooks/create.ts
|
|
2584
|
-
function
|
|
2590
|
+
function ir(e) {
|
|
2585
2591
|
return async (t, n, r) => {
|
|
2586
|
-
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 ||
|
|
2592
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Ce()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2587
2593
|
return await e.insertInto("hooks").values({
|
|
2588
2594
|
...p,
|
|
2589
2595
|
hook_id: c,
|
|
@@ -2606,7 +2612,7 @@ function nr(e) {
|
|
|
2606
2612
|
}
|
|
2607
2613
|
//#endregion
|
|
2608
2614
|
//#region src/hooks/update.ts
|
|
2609
|
-
function
|
|
2615
|
+
function ar(e) {
|
|
2610
2616
|
return async (t, n, r) => {
|
|
2611
2617
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2612
2618
|
...o,
|
|
@@ -2620,20 +2626,20 @@ function rr(e) {
|
|
|
2620
2626
|
}
|
|
2621
2627
|
//#endregion
|
|
2622
2628
|
//#region src/hooks/index.ts
|
|
2623
|
-
function
|
|
2629
|
+
function or(e) {
|
|
2624
2630
|
return {
|
|
2625
|
-
create:
|
|
2626
|
-
get:
|
|
2627
|
-
list:
|
|
2628
|
-
update:
|
|
2629
|
-
remove:
|
|
2631
|
+
create: ir(e),
|
|
2632
|
+
get: nr(e),
|
|
2633
|
+
list: tr(e),
|
|
2634
|
+
update: ar(e),
|
|
2635
|
+
remove: rr(e)
|
|
2630
2636
|
};
|
|
2631
2637
|
}
|
|
2632
2638
|
//#endregion
|
|
2633
2639
|
//#region src/hook-code/create.ts
|
|
2634
|
-
function
|
|
2640
|
+
function sr(e) {
|
|
2635
2641
|
return async (t, n, r) => {
|
|
2636
|
-
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ??
|
|
2642
|
+
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Te();
|
|
2637
2643
|
return await e.insertInto("hook_code").values({
|
|
2638
2644
|
id: c,
|
|
2639
2645
|
tenant_id: t,
|
|
@@ -2653,7 +2659,7 @@ function ar(e) {
|
|
|
2653
2659
|
}
|
|
2654
2660
|
//#endregion
|
|
2655
2661
|
//#region src/hook-code/get.ts
|
|
2656
|
-
function
|
|
2662
|
+
function cr(e) {
|
|
2657
2663
|
return async (t, n) => {
|
|
2658
2664
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2659
2665
|
if (!i) return null;
|
|
@@ -2677,7 +2683,7 @@ function or(e) {
|
|
|
2677
2683
|
}
|
|
2678
2684
|
//#endregion
|
|
2679
2685
|
//#region src/hook-code/update.ts
|
|
2680
|
-
function
|
|
2686
|
+
function lr(e) {
|
|
2681
2687
|
return async (t, n, r) => {
|
|
2682
2688
|
let i = { updated_at_ts: Date.now() };
|
|
2683
2689
|
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;
|
|
@@ -2685,22 +2691,22 @@ function sr(e) {
|
|
|
2685
2691
|
}
|
|
2686
2692
|
//#endregion
|
|
2687
2693
|
//#region src/hook-code/remove.ts
|
|
2688
|
-
function
|
|
2694
|
+
function ur(e) {
|
|
2689
2695
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2690
2696
|
}
|
|
2691
2697
|
//#endregion
|
|
2692
2698
|
//#region src/hook-code/index.ts
|
|
2693
|
-
function
|
|
2699
|
+
function dr(e) {
|
|
2694
2700
|
return {
|
|
2695
|
-
create:
|
|
2696
|
-
get:
|
|
2697
|
-
update:
|
|
2698
|
-
remove:
|
|
2701
|
+
create: sr(e),
|
|
2702
|
+
get: cr(e),
|
|
2703
|
+
update: lr(e),
|
|
2704
|
+
remove: ur(e)
|
|
2699
2705
|
};
|
|
2700
2706
|
}
|
|
2701
2707
|
//#endregion
|
|
2702
2708
|
//#region src/themes/create.ts
|
|
2703
|
-
function
|
|
2709
|
+
function fr(e) {
|
|
2704
2710
|
return async (n, r, i, a) => {
|
|
2705
2711
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2706
2712
|
themeId: o?.id || i || t(),
|
|
@@ -2711,20 +2717,20 @@ function ur(e) {
|
|
|
2711
2717
|
...c,
|
|
2712
2718
|
tenant_id: n
|
|
2713
2719
|
};
|
|
2714
|
-
return await e.insertInto("themes").values(
|
|
2720
|
+
return await e.insertInto("themes").values(N(l)).execute(), c;
|
|
2715
2721
|
};
|
|
2716
2722
|
}
|
|
2717
2723
|
//#endregion
|
|
2718
2724
|
//#region src/themes/remove.ts
|
|
2719
|
-
function
|
|
2725
|
+
function pr(e) {
|
|
2720
2726
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2721
2727
|
}
|
|
2722
2728
|
//#endregion
|
|
2723
2729
|
//#region src/themes/get.ts
|
|
2724
|
-
function
|
|
2730
|
+
function mr(e) {
|
|
2725
2731
|
return async (t, n) => {
|
|
2726
2732
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2727
|
-
return r ? l(
|
|
2733
|
+
return r ? l(et({
|
|
2728
2734
|
...r,
|
|
2729
2735
|
borders_show_widget_shadow: !!r.borders_show_widget_shadow,
|
|
2730
2736
|
fonts_body_text_bold: !!r.fonts_body_text_bold,
|
|
@@ -2744,9 +2750,9 @@ function fr(e) {
|
|
|
2744
2750
|
}
|
|
2745
2751
|
//#endregion
|
|
2746
2752
|
//#region src/themes/update.ts
|
|
2747
|
-
function
|
|
2753
|
+
function hr(e) {
|
|
2748
2754
|
return async (t, n, r) => {
|
|
2749
|
-
let { themeId: i, ...a } = r, o =
|
|
2755
|
+
let { themeId: i, ...a } = r, o = N({
|
|
2750
2756
|
...a,
|
|
2751
2757
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2752
2758
|
});
|
|
@@ -2755,17 +2761,17 @@ function pr(e) {
|
|
|
2755
2761
|
}
|
|
2756
2762
|
//#endregion
|
|
2757
2763
|
//#region src/themes/index.ts
|
|
2758
|
-
function
|
|
2764
|
+
function gr(e) {
|
|
2759
2765
|
return {
|
|
2760
|
-
create:
|
|
2761
|
-
get:
|
|
2762
|
-
remove:
|
|
2763
|
-
update:
|
|
2766
|
+
create: fr(e),
|
|
2767
|
+
get: mr(e),
|
|
2768
|
+
remove: pr(e),
|
|
2769
|
+
update: hr(e)
|
|
2764
2770
|
};
|
|
2765
2771
|
}
|
|
2766
2772
|
//#endregion
|
|
2767
2773
|
//#region src/loginSessions/get.ts
|
|
2768
|
-
function
|
|
2774
|
+
function _r(e) {
|
|
2769
2775
|
return async (t, n) => {
|
|
2770
2776
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2771
2777
|
if (!i) return null;
|
|
@@ -2777,40 +2783,40 @@ function hr(e) {
|
|
|
2777
2783
|
"created_at_ts",
|
|
2778
2784
|
"updated_at_ts",
|
|
2779
2785
|
"expires_at_ts"
|
|
2780
|
-
]), f =
|
|
2786
|
+
]), f = et(l({
|
|
2781
2787
|
...u,
|
|
2782
2788
|
...d,
|
|
2783
2789
|
state: i.state || p.PENDING,
|
|
2784
2790
|
state_data: i.state_data,
|
|
2785
2791
|
failure_reason: i.failure_reason
|
|
2786
2792
|
}), ["auth_strategy"]);
|
|
2787
|
-
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {},
|
|
2793
|
+
return f.authParams = typeof c == "string" && c.length > 0 ? JSON.parse(c) : {}, re.parse(f);
|
|
2788
2794
|
};
|
|
2789
2795
|
}
|
|
2790
2796
|
//#endregion
|
|
2791
2797
|
//#region src/utils/ulid.ts
|
|
2792
|
-
var
|
|
2793
|
-
function
|
|
2798
|
+
var vr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", R = 32, yr = 10, br = 16;
|
|
2799
|
+
function xr(e) {
|
|
2794
2800
|
let t = "";
|
|
2795
|
-
for (let n =
|
|
2801
|
+
for (let n = yr; n > 0; n--) t = vr.charAt(e % R) + t, e = Math.floor(e / R);
|
|
2796
2802
|
return t;
|
|
2797
2803
|
}
|
|
2798
|
-
function
|
|
2799
|
-
let e = new Uint8Array(
|
|
2804
|
+
function Sr() {
|
|
2805
|
+
let e = new Uint8Array(br);
|
|
2800
2806
|
crypto.getRandomValues(e);
|
|
2801
2807
|
let t = "";
|
|
2802
|
-
for (let n = 0; n <
|
|
2808
|
+
for (let n = 0; n < br; n++) t += vr.charAt(e[n] % R);
|
|
2803
2809
|
return t;
|
|
2804
2810
|
}
|
|
2805
|
-
function
|
|
2806
|
-
return
|
|
2811
|
+
function Cr() {
|
|
2812
|
+
return xr(Date.now()) + Sr();
|
|
2807
2813
|
}
|
|
2808
2814
|
//#endregion
|
|
2809
2815
|
//#region src/loginSessions/create.ts
|
|
2810
|
-
function
|
|
2816
|
+
function wr(e) {
|
|
2811
2817
|
return async (t, n) => {
|
|
2812
2818
|
let r = c(), i = {
|
|
2813
|
-
id:
|
|
2819
|
+
id: Cr(),
|
|
2814
2820
|
...n,
|
|
2815
2821
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2816
2822
|
created_at: r,
|
|
@@ -2818,7 +2824,7 @@ function Sr(e) {
|
|
|
2818
2824
|
state: n.state || p.PENDING,
|
|
2819
2825
|
state_data: n.state_data,
|
|
2820
2826
|
failure_reason: n.failure_reason
|
|
2821
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2827
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = N(o);
|
|
2822
2828
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2823
2829
|
...l,
|
|
2824
2830
|
tenant_id: t,
|
|
@@ -2831,7 +2837,7 @@ function Sr(e) {
|
|
|
2831
2837
|
}
|
|
2832
2838
|
//#endregion
|
|
2833
2839
|
//#region src/loginSessions/update.ts
|
|
2834
|
-
function
|
|
2840
|
+
function Tr(e) {
|
|
2835
2841
|
return async (t, n, r) => {
|
|
2836
2842
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2837
2843
|
if (c !== void 0) {
|
|
@@ -2841,7 +2847,7 @@ function Cr(e) {
|
|
|
2841
2847
|
...c
|
|
2842
2848
|
}) };
|
|
2843
2849
|
}
|
|
2844
|
-
let d =
|
|
2850
|
+
let d = N(l);
|
|
2845
2851
|
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2846
2852
|
...d,
|
|
2847
2853
|
...u,
|
|
@@ -2852,47 +2858,49 @@ function Cr(e) {
|
|
|
2852
2858
|
}
|
|
2853
2859
|
//#endregion
|
|
2854
2860
|
//#region src/loginSessions/remove.ts
|
|
2855
|
-
function
|
|
2861
|
+
function Er(e) {
|
|
2856
2862
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2857
2863
|
}
|
|
2858
2864
|
//#endregion
|
|
2859
2865
|
//#region src/loginSessions/index.ts
|
|
2860
|
-
function
|
|
2866
|
+
function Dr(e) {
|
|
2861
2867
|
return {
|
|
2862
|
-
create:
|
|
2863
|
-
get:
|
|
2864
|
-
update:
|
|
2865
|
-
remove:
|
|
2868
|
+
create: wr(e),
|
|
2869
|
+
get: _r(e),
|
|
2870
|
+
update: Tr(e),
|
|
2871
|
+
remove: Er(e)
|
|
2866
2872
|
};
|
|
2867
2873
|
}
|
|
2868
2874
|
//#endregion
|
|
2869
2875
|
//#region src/promptSettings/get.ts
|
|
2870
|
-
function
|
|
2876
|
+
function Or(e) {
|
|
2871
2877
|
return async (t) => {
|
|
2872
2878
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2873
2879
|
return l({
|
|
2874
2880
|
identifier_first: !!n?.identifier_first,
|
|
2875
2881
|
password_first: !!n?.password_first,
|
|
2876
2882
|
webauthn_platform_first_factor: !!n?.webauthn_platform_first_factor,
|
|
2883
|
+
show_last_used_connection: !!n?.show_last_used_connection,
|
|
2877
2884
|
universal_login_experience: n?.universal_login_experience || "new"
|
|
2878
2885
|
});
|
|
2879
2886
|
};
|
|
2880
2887
|
}
|
|
2881
2888
|
//#endregion
|
|
2882
2889
|
//#region src/promptSettings/set.ts
|
|
2883
|
-
function
|
|
2890
|
+
function kr(e) {
|
|
2884
2891
|
let t = {};
|
|
2885
|
-
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), e.universal_login_experience && (t.universal_login_experience = e.universal_login_experience), t;
|
|
2892
|
+
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;
|
|
2886
2893
|
}
|
|
2887
|
-
function
|
|
2894
|
+
function Ar(e) {
|
|
2888
2895
|
return async (t, n) => {
|
|
2889
|
-
let r =
|
|
2896
|
+
let r = kr(n);
|
|
2890
2897
|
try {
|
|
2891
2898
|
await e.insertInto("prompt_settings").values({
|
|
2892
2899
|
tenant_id: t,
|
|
2893
2900
|
identifier_first: r.identifier_first ?? 1,
|
|
2894
2901
|
password_first: r.password_first ?? 0,
|
|
2895
2902
|
webauthn_platform_first_factor: r.webauthn_platform_first_factor ?? 0,
|
|
2903
|
+
show_last_used_connection: r.show_last_used_connection ?? 0,
|
|
2896
2904
|
universal_login_experience: r.universal_login_experience ?? "new"
|
|
2897
2905
|
}).execute();
|
|
2898
2906
|
} catch {
|
|
@@ -2903,15 +2911,15 @@ function Or(e) {
|
|
|
2903
2911
|
}
|
|
2904
2912
|
//#endregion
|
|
2905
2913
|
//#region src/promptSettings/index.ts
|
|
2906
|
-
function
|
|
2914
|
+
function jr(e) {
|
|
2907
2915
|
return {
|
|
2908
|
-
get:
|
|
2909
|
-
set:
|
|
2916
|
+
get: Or(e),
|
|
2917
|
+
set: Ar(e)
|
|
2910
2918
|
};
|
|
2911
2919
|
}
|
|
2912
2920
|
//#endregion
|
|
2913
2921
|
//#region src/emailProvideres/get.ts
|
|
2914
|
-
function
|
|
2922
|
+
function Mr(e) {
|
|
2915
2923
|
return async (t) => {
|
|
2916
2924
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2917
2925
|
if (!n) return null;
|
|
@@ -2926,7 +2934,7 @@ function Ar(e) {
|
|
|
2926
2934
|
}
|
|
2927
2935
|
//#endregion
|
|
2928
2936
|
//#region src/emailProvideres/update.ts
|
|
2929
|
-
function
|
|
2937
|
+
function Nr(e) {
|
|
2930
2938
|
return async (t, n) => {
|
|
2931
2939
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2932
2940
|
await e.updateTable("email_providers").set({
|
|
@@ -2939,7 +2947,7 @@ function jr(e) {
|
|
|
2939
2947
|
}
|
|
2940
2948
|
//#endregion
|
|
2941
2949
|
//#region src/emailProvideres/create.ts
|
|
2942
|
-
function
|
|
2950
|
+
function Pr(e) {
|
|
2943
2951
|
return async (t, n, r) => {
|
|
2944
2952
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2945
2953
|
await e.insertInto("email_providers").values({
|
|
@@ -2955,24 +2963,24 @@ function Mr(e) {
|
|
|
2955
2963
|
}
|
|
2956
2964
|
//#endregion
|
|
2957
2965
|
//#region src/emailProvideres/remove.ts
|
|
2958
|
-
function
|
|
2966
|
+
function Fr(e) {
|
|
2959
2967
|
return async (t) => {
|
|
2960
2968
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
2961
2969
|
};
|
|
2962
2970
|
}
|
|
2963
2971
|
//#endregion
|
|
2964
2972
|
//#region src/emailProvideres/index.ts
|
|
2965
|
-
function
|
|
2973
|
+
function Ir(e) {
|
|
2966
2974
|
return {
|
|
2967
|
-
get:
|
|
2968
|
-
create:
|
|
2969
|
-
update:
|
|
2970
|
-
remove:
|
|
2975
|
+
get: Mr(e),
|
|
2976
|
+
create: Pr(e),
|
|
2977
|
+
update: Nr(e),
|
|
2978
|
+
remove: Fr(e)
|
|
2971
2979
|
};
|
|
2972
2980
|
}
|
|
2973
2981
|
//#endregion
|
|
2974
2982
|
//#region src/emailTemplates/row.ts
|
|
2975
|
-
function
|
|
2983
|
+
function Lr(e) {
|
|
2976
2984
|
let t = {
|
|
2977
2985
|
template: e.template,
|
|
2978
2986
|
body: e.body,
|
|
@@ -2986,20 +2994,20 @@ function Fr(e) {
|
|
|
2986
2994
|
}
|
|
2987
2995
|
//#endregion
|
|
2988
2996
|
//#region src/emailTemplates/get.ts
|
|
2989
|
-
function
|
|
2997
|
+
function Rr(e) {
|
|
2990
2998
|
return async (t, n) => {
|
|
2991
2999
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
2992
|
-
return r ? v.parse(
|
|
3000
|
+
return r ? v.parse(Lr(r)) : null;
|
|
2993
3001
|
};
|
|
2994
3002
|
}
|
|
2995
3003
|
//#endregion
|
|
2996
3004
|
//#region src/emailTemplates/list.ts
|
|
2997
|
-
function
|
|
2998
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => v.parse(
|
|
3005
|
+
function zr(e) {
|
|
3006
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => v.parse(Lr(e)));
|
|
2999
3007
|
}
|
|
3000
3008
|
//#endregion
|
|
3001
3009
|
//#region src/emailTemplates/create.ts
|
|
3002
|
-
function
|
|
3010
|
+
function Br(e) {
|
|
3003
3011
|
return async (t, n, r) => {
|
|
3004
3012
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3005
3013
|
return await e.insertInto("email_templates").values({
|
|
@@ -3020,7 +3028,7 @@ function Rr(e) {
|
|
|
3020
3028
|
}
|
|
3021
3029
|
//#endregion
|
|
3022
3030
|
//#region src/emailTemplates/update.ts
|
|
3023
|
-
function
|
|
3031
|
+
function Vr(e) {
|
|
3024
3032
|
return async (t, n, r) => {
|
|
3025
3033
|
let i = {};
|
|
3026
3034
|
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;
|
|
@@ -3031,7 +3039,7 @@ function zr(e) {
|
|
|
3031
3039
|
}
|
|
3032
3040
|
//#endregion
|
|
3033
3041
|
//#region src/emailTemplates/remove.ts
|
|
3034
|
-
function
|
|
3042
|
+
function Hr(e) {
|
|
3035
3043
|
return async (t, n) => {
|
|
3036
3044
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3037
3045
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3039,18 +3047,18 @@ function Br(e) {
|
|
|
3039
3047
|
}
|
|
3040
3048
|
//#endregion
|
|
3041
3049
|
//#region src/emailTemplates/index.ts
|
|
3042
|
-
function
|
|
3050
|
+
function Ur(e) {
|
|
3043
3051
|
return {
|
|
3044
|
-
get:
|
|
3045
|
-
list:
|
|
3046
|
-
create:
|
|
3047
|
-
update:
|
|
3048
|
-
remove:
|
|
3052
|
+
get: Rr(e),
|
|
3053
|
+
list: zr(e),
|
|
3054
|
+
create: Br(e),
|
|
3055
|
+
update: Vr(e),
|
|
3056
|
+
remove: Hr(e)
|
|
3049
3057
|
};
|
|
3050
3058
|
}
|
|
3051
3059
|
//#endregion
|
|
3052
3060
|
//#region src/refreshTokens/get.ts
|
|
3053
|
-
function
|
|
3061
|
+
function Wr(e) {
|
|
3054
3062
|
return async (t, n) => {
|
|
3055
3063
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3056
3064
|
if (!i) return null;
|
|
@@ -3079,7 +3087,7 @@ function Hr(e) {
|
|
|
3079
3087
|
}
|
|
3080
3088
|
//#endregion
|
|
3081
3089
|
//#region src/refreshTokens/getByLookup.ts
|
|
3082
|
-
function
|
|
3090
|
+
function Gr(e) {
|
|
3083
3091
|
return async (t, n) => {
|
|
3084
3092
|
let i = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3085
3093
|
if (!i) return null;
|
|
@@ -3108,7 +3116,7 @@ function Ur(e) {
|
|
|
3108
3116
|
}
|
|
3109
3117
|
//#endregion
|
|
3110
3118
|
//#region src/refreshTokens/create.ts
|
|
3111
|
-
function
|
|
3119
|
+
function Kr(e) {
|
|
3112
3120
|
return async (t, n) => {
|
|
3113
3121
|
let r = c(), i = {
|
|
3114
3122
|
...n,
|
|
@@ -3138,12 +3146,12 @@ function Wr(e) {
|
|
|
3138
3146
|
}
|
|
3139
3147
|
//#endregion
|
|
3140
3148
|
//#region src/refreshTokens/remove.ts
|
|
3141
|
-
function
|
|
3149
|
+
function qr(e) {
|
|
3142
3150
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3143
3151
|
}
|
|
3144
3152
|
//#endregion
|
|
3145
3153
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3146
|
-
function
|
|
3154
|
+
function Jr(e) {
|
|
3147
3155
|
return async (t, n, r) => {
|
|
3148
3156
|
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();
|
|
3149
3157
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3151,7 +3159,7 @@ function Kr(e) {
|
|
|
3151
3159
|
}
|
|
3152
3160
|
//#endregion
|
|
3153
3161
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3154
|
-
function
|
|
3162
|
+
function Yr(e) {
|
|
3155
3163
|
return async (t, n, r) => {
|
|
3156
3164
|
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();
|
|
3157
3165
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3159,7 +3167,7 @@ function qr(e) {
|
|
|
3159
3167
|
}
|
|
3160
3168
|
//#endregion
|
|
3161
3169
|
//#region src/refreshTokens/update.ts
|
|
3162
|
-
function
|
|
3170
|
+
function Xr(e) {
|
|
3163
3171
|
return async (t, n, r, i) => {
|
|
3164
3172
|
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 = {
|
|
3165
3173
|
...h,
|
|
@@ -3171,19 +3179,19 @@ function Jr(e) {
|
|
|
3171
3179
|
last_exchanged_at_ts: l === void 0 ? void 0 : s(l),
|
|
3172
3180
|
revoked_at_ts: u === void 0 ? void 0 : s(u),
|
|
3173
3181
|
rotated_at_ts: d === void 0 ? void 0 : s(d)
|
|
3174
|
-
}, _ = i?.loginSessionBump, v = _ ? s(_.expires_at) : null,
|
|
3182
|
+
}, _ = i?.loginSessionBump, v = _ ? s(_.expires_at) : null, ee = await e.updateTable("refresh_tokens").set(g).where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).executeTakeFirst();
|
|
3175
3183
|
return _?.login_id && v && v > 0 && await e.updateTable("login_sessions").set({
|
|
3176
3184
|
expires_at_ts: v,
|
|
3177
3185
|
updated_at_ts: Date.now()
|
|
3178
|
-
}).where("tenant_id", "=", t).where("id", "=", _.login_id).where("expires_at_ts", "<", v).execute().catch(() => {}), (
|
|
3186
|
+
}).where("tenant_id", "=", t).where("id", "=", _.login_id).where("expires_at_ts", "<", v).execute().catch(() => {}), (ee?.numUpdatedRows ?? 0n) > 0n;
|
|
3179
3187
|
};
|
|
3180
3188
|
}
|
|
3181
3189
|
//#endregion
|
|
3182
3190
|
//#region src/refreshTokens/list.ts
|
|
3183
|
-
function
|
|
3191
|
+
function Zr(e) {
|
|
3184
3192
|
return async (t, n = {}) => {
|
|
3185
3193
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3186
|
-
l && (u =
|
|
3194
|
+
l && (u = E(e, u, l, ["token", "login_id"]));
|
|
3187
3195
|
let d = u;
|
|
3188
3196
|
if (c && c.sort_by) {
|
|
3189
3197
|
let { ref: t } = e.dynamic;
|
|
@@ -3230,24 +3238,24 @@ function Yr(e) {
|
|
|
3230
3238
|
}
|
|
3231
3239
|
//#endregion
|
|
3232
3240
|
//#region src/refreshTokens/index.ts
|
|
3233
|
-
function
|
|
3241
|
+
function Qr(e) {
|
|
3234
3242
|
return {
|
|
3235
|
-
create:
|
|
3236
|
-
get:
|
|
3237
|
-
getByLookup:
|
|
3238
|
-
list:
|
|
3239
|
-
remove:
|
|
3240
|
-
revokeByLoginSession:
|
|
3241
|
-
revokeFamily:
|
|
3242
|
-
update:
|
|
3243
|
+
create: Kr(e),
|
|
3244
|
+
get: Wr(e),
|
|
3245
|
+
getByLookup: Gr(e),
|
|
3246
|
+
list: Zr(e),
|
|
3247
|
+
remove: qr(e),
|
|
3248
|
+
revokeByLoginSession: Jr(e),
|
|
3249
|
+
revokeFamily: Yr(e),
|
|
3250
|
+
update: Xr(e)
|
|
3243
3251
|
};
|
|
3244
3252
|
}
|
|
3245
3253
|
//#endregion
|
|
3246
3254
|
//#region src/cleanup.ts
|
|
3247
|
-
var
|
|
3248
|
-
function
|
|
3255
|
+
var $r = 10080 * 60 * 1e3;
|
|
3256
|
+
function ei(e) {
|
|
3249
3257
|
return async (t) => {
|
|
3250
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3258
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - $r, a = 1e3;
|
|
3251
3259
|
try {
|
|
3252
3260
|
let t = 0;
|
|
3253
3261
|
for (;;) {
|
|
@@ -3278,9 +3286,9 @@ function Qr(e) {
|
|
|
3278
3286
|
}
|
|
3279
3287
|
//#endregion
|
|
3280
3288
|
//#region src/forms/create.ts
|
|
3281
|
-
function
|
|
3289
|
+
function ti(e) {
|
|
3282
3290
|
return async (n, r, i) => {
|
|
3283
|
-
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
3291
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = b.parse({
|
|
3284
3292
|
id: a?.id ?? t(),
|
|
3285
3293
|
...r,
|
|
3286
3294
|
created_at: a?.created_at ?? o,
|
|
@@ -3292,15 +3300,15 @@ function $r(e) {
|
|
|
3292
3300
|
start: JSON.stringify(s.start || {}),
|
|
3293
3301
|
ending: JSON.stringify(s.ending || {}),
|
|
3294
3302
|
tenant_id: n
|
|
3295
|
-
}).execute(),
|
|
3303
|
+
}).execute(), b.parse(s);
|
|
3296
3304
|
};
|
|
3297
3305
|
}
|
|
3298
3306
|
//#endregion
|
|
3299
3307
|
//#region src/forms/list.ts
|
|
3300
|
-
function
|
|
3308
|
+
function ni(e) {
|
|
3301
3309
|
return async (t, n = {}) => {
|
|
3302
3310
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3303
|
-
s && (c =
|
|
3311
|
+
s && (c = E(e, c, s, []));
|
|
3304
3312
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3305
3313
|
let t = { ...e };
|
|
3306
3314
|
if (typeof t.nodes == "string") try {
|
|
@@ -3312,7 +3320,7 @@ function ei(e) {
|
|
|
3312
3320
|
if (typeof t.ending == "string") try {
|
|
3313
3321
|
t.ending = JSON.parse(t.ending);
|
|
3314
3322
|
} catch {}
|
|
3315
|
-
return
|
|
3323
|
+
return b.parse(l(t));
|
|
3316
3324
|
});
|
|
3317
3325
|
if (!a) return {
|
|
3318
3326
|
forms: u,
|
|
@@ -3331,7 +3339,7 @@ function ei(e) {
|
|
|
3331
3339
|
}
|
|
3332
3340
|
//#endregion
|
|
3333
3341
|
//#region src/forms/remove.ts
|
|
3334
|
-
function
|
|
3342
|
+
function ri(e) {
|
|
3335
3343
|
return async (t, n) => {
|
|
3336
3344
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3337
3345
|
return r > 0;
|
|
@@ -3339,7 +3347,7 @@ function ti(e) {
|
|
|
3339
3347
|
}
|
|
3340
3348
|
//#endregion
|
|
3341
3349
|
//#region src/forms/get.ts
|
|
3342
|
-
function
|
|
3350
|
+
function ii(e) {
|
|
3343
3351
|
return async (t, n) => {
|
|
3344
3352
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3345
3353
|
if (!r) return null;
|
|
@@ -3353,12 +3361,12 @@ function ni(e) {
|
|
|
3353
3361
|
if (typeof i.ending == "string") try {
|
|
3354
3362
|
i.ending = JSON.parse(i.ending);
|
|
3355
3363
|
} catch {}
|
|
3356
|
-
return
|
|
3364
|
+
return b.parse(l(i));
|
|
3357
3365
|
};
|
|
3358
3366
|
}
|
|
3359
3367
|
//#endregion
|
|
3360
3368
|
//#region src/forms/update.ts
|
|
3361
|
-
function
|
|
3369
|
+
function ai(e) {
|
|
3362
3370
|
return async (t, n, r) => {
|
|
3363
3371
|
let i = {
|
|
3364
3372
|
...r,
|
|
@@ -3375,25 +3383,25 @@ function ri(e) {
|
|
|
3375
3383
|
}
|
|
3376
3384
|
//#endregion
|
|
3377
3385
|
//#region src/forms/index.ts
|
|
3378
|
-
function
|
|
3386
|
+
function oi(e) {
|
|
3379
3387
|
return {
|
|
3380
|
-
create:
|
|
3381
|
-
get:
|
|
3382
|
-
list:
|
|
3383
|
-
remove:
|
|
3384
|
-
update:
|
|
3388
|
+
create: ti(e),
|
|
3389
|
+
get: ii(e),
|
|
3390
|
+
list: ni(e),
|
|
3391
|
+
remove: ri(e),
|
|
3392
|
+
update: ai(e)
|
|
3385
3393
|
};
|
|
3386
3394
|
}
|
|
3387
3395
|
//#endregion
|
|
3388
3396
|
//#region src/resourceServers/create.ts
|
|
3389
|
-
function
|
|
3397
|
+
function si(e) {
|
|
3390
3398
|
return async (t, n, r) => {
|
|
3391
3399
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3392
3400
|
...n,
|
|
3393
|
-
id: i?.id ?? n.id ??
|
|
3401
|
+
id: i?.id ?? n.id ?? we(),
|
|
3394
3402
|
created_at: o,
|
|
3395
3403
|
updated_at: s
|
|
3396
|
-
}, u =
|
|
3404
|
+
}, u = se.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, ee = {
|
|
3397
3405
|
...v,
|
|
3398
3406
|
tenant_id: t,
|
|
3399
3407
|
scopes: f ? JSON.stringify(f) : "[]",
|
|
@@ -3406,12 +3414,12 @@ function ai(e) {
|
|
|
3406
3414
|
created_at: o,
|
|
3407
3415
|
updated_at: s
|
|
3408
3416
|
};
|
|
3409
|
-
return await e.insertInto("resource_servers").values(
|
|
3417
|
+
return await e.insertInto("resource_servers").values(ee).execute(), l(u);
|
|
3410
3418
|
};
|
|
3411
3419
|
}
|
|
3412
3420
|
//#endregion
|
|
3413
3421
|
//#region src/resourceServers/get.ts
|
|
3414
|
-
function
|
|
3422
|
+
function ci(e) {
|
|
3415
3423
|
return async (t, n) => {
|
|
3416
3424
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3417
3425
|
if (!r) return null;
|
|
@@ -3430,7 +3438,7 @@ function oi(e) {
|
|
|
3430
3438
|
}
|
|
3431
3439
|
//#endregion
|
|
3432
3440
|
//#region src/resourceServers/list.ts
|
|
3433
|
-
function
|
|
3441
|
+
function li(e) {
|
|
3434
3442
|
return async (t, n = {}) => {
|
|
3435
3443
|
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);
|
|
3436
3444
|
if (s) {
|
|
@@ -3438,7 +3446,7 @@ function si(e) {
|
|
|
3438
3446
|
if (i && !o) {
|
|
3439
3447
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3440
3448
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3441
|
-
} else c =
|
|
3449
|
+
} else c = E(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3442
3450
|
}
|
|
3443
3451
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3444
3452
|
let { verification_key: t, scopes: n, options: r, skip_consent_for_verifiable_first_party_clients: i, allow_offline_access: a, is_system: o, metadata: s, ...c } = e, u = l({
|
|
@@ -3470,7 +3478,7 @@ function si(e) {
|
|
|
3470
3478
|
}
|
|
3471
3479
|
//#endregion
|
|
3472
3480
|
//#region src/resourceServers/remove.ts
|
|
3473
|
-
function
|
|
3481
|
+
function ui(e) {
|
|
3474
3482
|
return async (t, n) => {
|
|
3475
3483
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3476
3484
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3478,7 +3486,7 @@ function ci(e) {
|
|
|
3478
3486
|
}
|
|
3479
3487
|
//#endregion
|
|
3480
3488
|
//#region src/resourceServers/update.ts
|
|
3481
|
-
function
|
|
3489
|
+
function di(e) {
|
|
3482
3490
|
return async (t, n, r) => {
|
|
3483
3491
|
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 = {
|
|
3484
3492
|
...d,
|
|
@@ -3498,18 +3506,18 @@ function li(e) {
|
|
|
3498
3506
|
}
|
|
3499
3507
|
//#endregion
|
|
3500
3508
|
//#region src/resourceServers/index.ts
|
|
3501
|
-
function
|
|
3509
|
+
function fi(e) {
|
|
3502
3510
|
return {
|
|
3503
|
-
create:
|
|
3504
|
-
get:
|
|
3505
|
-
list:
|
|
3506
|
-
remove:
|
|
3507
|
-
update:
|
|
3511
|
+
create: si(e),
|
|
3512
|
+
get: ci(e),
|
|
3513
|
+
list: li(e),
|
|
3514
|
+
remove: ui(e),
|
|
3515
|
+
update: di(e)
|
|
3508
3516
|
};
|
|
3509
3517
|
}
|
|
3510
3518
|
//#endregion
|
|
3511
3519
|
//#region src/roles/create.ts
|
|
3512
|
-
function
|
|
3520
|
+
function pi(e) {
|
|
3513
3521
|
return async (n, r, i) => {
|
|
3514
3522
|
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 = {
|
|
3515
3523
|
id: l,
|
|
@@ -3532,7 +3540,7 @@ function di(e) {
|
|
|
3532
3540
|
}
|
|
3533
3541
|
//#endregion
|
|
3534
3542
|
//#region src/roles/get.ts
|
|
3535
|
-
function
|
|
3543
|
+
function mi(e) {
|
|
3536
3544
|
return async (t, n) => {
|
|
3537
3545
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3538
3546
|
if (!r) return null;
|
|
@@ -3546,10 +3554,10 @@ function fi(e) {
|
|
|
3546
3554
|
}
|
|
3547
3555
|
//#endregion
|
|
3548
3556
|
//#region src/roles/list.ts
|
|
3549
|
-
function
|
|
3557
|
+
function hi(e) {
|
|
3550
3558
|
return async (t, n) => {
|
|
3551
3559
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3552
|
-
n.q && (r =
|
|
3560
|
+
n.q && (r = E(e, r, n.q, ["name"]));
|
|
3553
3561
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3554
3562
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3555
3563
|
return {
|
|
@@ -3575,7 +3583,7 @@ function pi(e) {
|
|
|
3575
3583
|
}
|
|
3576
3584
|
//#endregion
|
|
3577
3585
|
//#region src/roles/update.ts
|
|
3578
|
-
function
|
|
3586
|
+
function gi(e) {
|
|
3579
3587
|
return async (t, n, r) => {
|
|
3580
3588
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3581
3589
|
...o,
|
|
@@ -3588,7 +3596,7 @@ function mi(e) {
|
|
|
3588
3596
|
}
|
|
3589
3597
|
//#endregion
|
|
3590
3598
|
//#region src/roles/remove.ts
|
|
3591
|
-
function
|
|
3599
|
+
function _i(e) {
|
|
3592
3600
|
return async (t, n) => {
|
|
3593
3601
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3594
3602
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3596,18 +3604,18 @@ function hi(e) {
|
|
|
3596
3604
|
}
|
|
3597
3605
|
//#endregion
|
|
3598
3606
|
//#region src/roles/index.ts
|
|
3599
|
-
function
|
|
3607
|
+
function vi(e) {
|
|
3600
3608
|
return {
|
|
3601
|
-
create:
|
|
3602
|
-
get:
|
|
3603
|
-
list:
|
|
3604
|
-
update:
|
|
3605
|
-
remove:
|
|
3609
|
+
create: pi(e),
|
|
3610
|
+
get: mi(e),
|
|
3611
|
+
list: hi(e),
|
|
3612
|
+
update: gi(e),
|
|
3613
|
+
remove: _i(e)
|
|
3606
3614
|
};
|
|
3607
3615
|
}
|
|
3608
3616
|
//#endregion
|
|
3609
3617
|
//#region src/role-permissions/assign.ts
|
|
3610
|
-
function
|
|
3618
|
+
function yi(e) {
|
|
3611
3619
|
return async (t, n, r, i) => {
|
|
3612
3620
|
if (r.length === 0) return !0;
|
|
3613
3621
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3636,7 +3644,7 @@ function _i(e) {
|
|
|
3636
3644
|
}
|
|
3637
3645
|
//#endregion
|
|
3638
3646
|
//#region src/role-permissions/remove.ts
|
|
3639
|
-
function
|
|
3647
|
+
function bi(e) {
|
|
3640
3648
|
return async (t, n, r) => {
|
|
3641
3649
|
if (r.length === 0) return !0;
|
|
3642
3650
|
try {
|
|
@@ -3648,7 +3656,7 @@ function vi(e) {
|
|
|
3648
3656
|
}
|
|
3649
3657
|
//#endregion
|
|
3650
3658
|
//#region src/role-permissions/list.ts
|
|
3651
|
-
function
|
|
3659
|
+
function xi(e) {
|
|
3652
3660
|
return async (t, n, r = {}) => {
|
|
3653
3661
|
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([
|
|
3654
3662
|
"role_permissions.role_id",
|
|
@@ -3669,16 +3677,16 @@ function yi(e) {
|
|
|
3669
3677
|
}
|
|
3670
3678
|
//#endregion
|
|
3671
3679
|
//#region src/role-permissions/index.ts
|
|
3672
|
-
function
|
|
3680
|
+
function Si(e) {
|
|
3673
3681
|
return {
|
|
3674
|
-
assign:
|
|
3675
|
-
remove:
|
|
3676
|
-
list:
|
|
3682
|
+
assign: yi(e),
|
|
3683
|
+
remove: bi(e),
|
|
3684
|
+
list: xi(e)
|
|
3677
3685
|
};
|
|
3678
3686
|
}
|
|
3679
3687
|
//#endregion
|
|
3680
3688
|
//#region src/grants/create.ts
|
|
3681
|
-
function
|
|
3689
|
+
function Ci(e) {
|
|
3682
3690
|
return async (n, r) => {
|
|
3683
3691
|
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();
|
|
3684
3692
|
if (s) {
|
|
@@ -3715,7 +3723,7 @@ function xi(e) {
|
|
|
3715
3723
|
}
|
|
3716
3724
|
//#endregion
|
|
3717
3725
|
//#region src/grants/get.ts
|
|
3718
|
-
function
|
|
3726
|
+
function wi(e) {
|
|
3719
3727
|
return async (t, n, r, i) => {
|
|
3720
3728
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3721
3729
|
return a ? {
|
|
@@ -3729,10 +3737,10 @@ function Si(e) {
|
|
|
3729
3737
|
}
|
|
3730
3738
|
//#endregion
|
|
3731
3739
|
//#region src/grants/list.ts
|
|
3732
|
-
function
|
|
3740
|
+
function Ti(e) {
|
|
3733
3741
|
return async (t, n = {}) => {
|
|
3734
3742
|
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);
|
|
3735
|
-
c && (l =
|
|
3743
|
+
c && (l = E(e, l, c, [
|
|
3736
3744
|
"user_id",
|
|
3737
3745
|
"client_id",
|
|
3738
3746
|
"audience"
|
|
@@ -3767,26 +3775,26 @@ function Ci(e) {
|
|
|
3767
3775
|
}
|
|
3768
3776
|
//#endregion
|
|
3769
3777
|
//#region src/grants/remove.ts
|
|
3770
|
-
function
|
|
3778
|
+
function Ei(e) {
|
|
3771
3779
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3772
3780
|
}
|
|
3773
|
-
function
|
|
3781
|
+
function Di(e) {
|
|
3774
3782
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3775
3783
|
}
|
|
3776
3784
|
//#endregion
|
|
3777
3785
|
//#region src/grants/index.ts
|
|
3778
|
-
function
|
|
3786
|
+
function Oi(e) {
|
|
3779
3787
|
return {
|
|
3780
|
-
create:
|
|
3781
|
-
get:
|
|
3782
|
-
list:
|
|
3783
|
-
remove:
|
|
3784
|
-
removeByUser:
|
|
3788
|
+
create: Ci(e),
|
|
3789
|
+
get: wi(e),
|
|
3790
|
+
list: Ti(e),
|
|
3791
|
+
remove: Ei(e),
|
|
3792
|
+
removeByUser: Di(e)
|
|
3785
3793
|
};
|
|
3786
3794
|
}
|
|
3787
3795
|
//#endregion
|
|
3788
3796
|
//#region src/user-permissions/create.ts
|
|
3789
|
-
function
|
|
3797
|
+
function ki(e) {
|
|
3790
3798
|
return async (t, n, r, i, a) => {
|
|
3791
3799
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3792
3800
|
try {
|
|
@@ -3806,7 +3814,7 @@ function Di(e) {
|
|
|
3806
3814
|
}
|
|
3807
3815
|
//#endregion
|
|
3808
3816
|
//#region src/user-permissions/remove.ts
|
|
3809
|
-
function
|
|
3817
|
+
function Ai(e) {
|
|
3810
3818
|
return async (t, n, r, i) => {
|
|
3811
3819
|
try {
|
|
3812
3820
|
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);
|
|
@@ -3818,7 +3826,7 @@ function Oi(e) {
|
|
|
3818
3826
|
}
|
|
3819
3827
|
//#endregion
|
|
3820
3828
|
//#region src/user-permissions/list.ts
|
|
3821
|
-
function
|
|
3829
|
+
function ji(e) {
|
|
3822
3830
|
return async (t, n, r, i) => {
|
|
3823
3831
|
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([
|
|
3824
3832
|
"user_permissions.resource_server_identifier",
|
|
@@ -3841,17 +3849,17 @@ function ki(e) {
|
|
|
3841
3849
|
}
|
|
3842
3850
|
//#endregion
|
|
3843
3851
|
//#region src/user-permissions/index.ts
|
|
3844
|
-
function
|
|
3852
|
+
function Mi(e) {
|
|
3845
3853
|
return {
|
|
3846
|
-
create:
|
|
3847
|
-
remove:
|
|
3848
|
-
list:
|
|
3854
|
+
create: ki(e),
|
|
3855
|
+
remove: Ai(e),
|
|
3856
|
+
list: ji(e)
|
|
3849
3857
|
};
|
|
3850
3858
|
}
|
|
3851
3859
|
//#endregion
|
|
3852
3860
|
//#region src/user-permissions/adapter.ts
|
|
3853
|
-
function
|
|
3854
|
-
let t =
|
|
3861
|
+
function Ni(e) {
|
|
3862
|
+
let t = Mi(e);
|
|
3855
3863
|
return {
|
|
3856
3864
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3857
3865
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3860,7 +3868,7 @@ function ji(e) {
|
|
|
3860
3868
|
}
|
|
3861
3869
|
//#endregion
|
|
3862
3870
|
//#region src/user-roles/list.ts
|
|
3863
|
-
function
|
|
3871
|
+
function Pi(e) {
|
|
3864
3872
|
return async (t, n, r, i) => {
|
|
3865
3873
|
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([
|
|
3866
3874
|
"r.id",
|
|
@@ -3874,11 +3882,11 @@ function Mi(e) {
|
|
|
3874
3882
|
}
|
|
3875
3883
|
//#endregion
|
|
3876
3884
|
//#region src/user-roles/list-users.ts
|
|
3877
|
-
function
|
|
3885
|
+
function Fi(e) {
|
|
3878
3886
|
return async (t, n, r) => {
|
|
3879
3887
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3880
|
-
if (
|
|
3881
|
-
let { rows: e, limit: t, next: n } = await
|
|
3888
|
+
if (j(r)) {
|
|
3889
|
+
let { rows: e, limit: t, next: n } = await M(i, r, {
|
|
3882
3890
|
sortColumn: "user_id",
|
|
3883
3891
|
sortOrder: "asc",
|
|
3884
3892
|
idColumn: "user_id"
|
|
@@ -3902,7 +3910,7 @@ function Ni(e) {
|
|
|
3902
3910
|
}
|
|
3903
3911
|
//#endregion
|
|
3904
3912
|
//#region src/user-roles/create.ts
|
|
3905
|
-
function
|
|
3913
|
+
function Ii(e) {
|
|
3906
3914
|
return async (t, n, r, i, a) => {
|
|
3907
3915
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3908
3916
|
try {
|
|
@@ -3920,7 +3928,7 @@ function Pi(e) {
|
|
|
3920
3928
|
}
|
|
3921
3929
|
//#endregion
|
|
3922
3930
|
//#region src/user-roles/remove.ts
|
|
3923
|
-
function
|
|
3931
|
+
function Li(e) {
|
|
3924
3932
|
return async (t, n, r, i) => {
|
|
3925
3933
|
try {
|
|
3926
3934
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3932,18 +3940,18 @@ function Fi(e) {
|
|
|
3932
3940
|
}
|
|
3933
3941
|
//#endregion
|
|
3934
3942
|
//#region src/user-roles/index.ts
|
|
3935
|
-
function
|
|
3943
|
+
function Ri(e) {
|
|
3936
3944
|
return {
|
|
3937
|
-
list:
|
|
3938
|
-
listUsers:
|
|
3939
|
-
create:
|
|
3940
|
-
remove:
|
|
3945
|
+
list: Pi(e),
|
|
3946
|
+
listUsers: Fi(e),
|
|
3947
|
+
create: Ii(e),
|
|
3948
|
+
remove: Li(e)
|
|
3941
3949
|
};
|
|
3942
3950
|
}
|
|
3943
3951
|
//#endregion
|
|
3944
3952
|
//#region src/user-roles/adapter.ts
|
|
3945
|
-
function
|
|
3946
|
-
let t =
|
|
3953
|
+
function zi(e) {
|
|
3954
|
+
let t = Ri(e);
|
|
3947
3955
|
return {
|
|
3948
3956
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3949
3957
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -3953,11 +3961,11 @@ function Li(e) {
|
|
|
3953
3961
|
}
|
|
3954
3962
|
//#endregion
|
|
3955
3963
|
//#region src/organizations/create.ts
|
|
3956
|
-
function
|
|
3964
|
+
function Bi(e) {
|
|
3957
3965
|
return async (t, n, r) => {
|
|
3958
3966
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3959
3967
|
...n,
|
|
3960
|
-
id: i?.id || n.id ||
|
|
3968
|
+
id: i?.id || n.id || ye(),
|
|
3961
3969
|
tenant_id: t,
|
|
3962
3970
|
created_at: i?.created_at ?? a,
|
|
3963
3971
|
updated_at: i?.updated_at ?? a,
|
|
@@ -3969,7 +3977,7 @@ function Ri(e) {
|
|
|
3969
3977
|
try {
|
|
3970
3978
|
await e.insertInto("organizations").values(o).execute();
|
|
3971
3979
|
} catch (e) {
|
|
3972
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
3980
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new S(409, { message: "Organization already exists" }) : e;
|
|
3973
3981
|
}
|
|
3974
3982
|
return {
|
|
3975
3983
|
...n,
|
|
@@ -3981,7 +3989,7 @@ function Ri(e) {
|
|
|
3981
3989
|
}
|
|
3982
3990
|
//#endregion
|
|
3983
3991
|
//#region src/organizations/get.ts
|
|
3984
|
-
function
|
|
3992
|
+
function Vi(e) {
|
|
3985
3993
|
return async (t, n) => {
|
|
3986
3994
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3987
3995
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -3995,16 +4003,16 @@ function zi(e) {
|
|
|
3995
4003
|
}
|
|
3996
4004
|
//#endregion
|
|
3997
4005
|
//#region src/organizations/list.ts
|
|
3998
|
-
var
|
|
3999
|
-
function
|
|
4006
|
+
var z = ["name", "display_name"];
|
|
4007
|
+
function Hi(e) {
|
|
4000
4008
|
return async (t, n) => {
|
|
4001
4009
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4002
4010
|
if (n?.q) {
|
|
4003
|
-
let t =
|
|
4004
|
-
t && (r =
|
|
4011
|
+
let t = x(n.q, z);
|
|
4012
|
+
t && (r = E(e, r, t, z));
|
|
4005
4013
|
}
|
|
4006
|
-
if (
|
|
4007
|
-
let { rows: e, limit: t, next: i } = await
|
|
4014
|
+
if (j(n)) {
|
|
4015
|
+
let { rows: e, limit: t, next: i } = await M(r.selectAll(), n, {
|
|
4008
4016
|
sortColumn: "created_at",
|
|
4009
4017
|
sortOrder: "desc"
|
|
4010
4018
|
}), a = e.map((e) => l({
|
|
@@ -4037,8 +4045,8 @@ function Bi(e) {
|
|
|
4037
4045
|
if (n?.include_totals) {
|
|
4038
4046
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4039
4047
|
if (n?.q) {
|
|
4040
|
-
let t =
|
|
4041
|
-
t && (r =
|
|
4048
|
+
let t = x(n.q, z);
|
|
4049
|
+
t && (r = E(e, r, t, z));
|
|
4042
4050
|
}
|
|
4043
4051
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4044
4052
|
u = Number(i?.count || 0);
|
|
@@ -4061,12 +4069,12 @@ function Bi(e) {
|
|
|
4061
4069
|
}
|
|
4062
4070
|
//#endregion
|
|
4063
4071
|
//#region src/organizations/remove.ts
|
|
4064
|
-
function
|
|
4072
|
+
function Ui(e) {
|
|
4065
4073
|
return async (t, n) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).execute()).length > 0;
|
|
4066
4074
|
}
|
|
4067
4075
|
//#endregion
|
|
4068
4076
|
//#region src/organizations/update.ts
|
|
4069
|
-
function
|
|
4077
|
+
function Wi(e) {
|
|
4070
4078
|
return async (t, n, r) => {
|
|
4071
4079
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4072
4080
|
...c,
|
|
@@ -4082,18 +4090,18 @@ function Hi(e) {
|
|
|
4082
4090
|
}
|
|
4083
4091
|
//#endregion
|
|
4084
4092
|
//#region src/organizations/index.ts
|
|
4085
|
-
function
|
|
4093
|
+
function Gi(e) {
|
|
4086
4094
|
return {
|
|
4087
|
-
create:
|
|
4088
|
-
get:
|
|
4089
|
-
list:
|
|
4090
|
-
remove:
|
|
4091
|
-
update:
|
|
4095
|
+
create: Bi(e),
|
|
4096
|
+
get: Vi(e),
|
|
4097
|
+
list: Hi(e),
|
|
4098
|
+
remove: Ui(e),
|
|
4099
|
+
update: Wi(e)
|
|
4092
4100
|
};
|
|
4093
4101
|
}
|
|
4094
4102
|
//#endregion
|
|
4095
4103
|
//#region src/organization-connections/index.ts
|
|
4096
|
-
function
|
|
4104
|
+
function B(e, t) {
|
|
4097
4105
|
return {
|
|
4098
4106
|
connection_id: e.connection_id,
|
|
4099
4107
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4107,14 +4115,14 @@ function V(e, t) {
|
|
|
4107
4115
|
updated_at: e.updated_at
|
|
4108
4116
|
};
|
|
4109
4117
|
}
|
|
4110
|
-
async function
|
|
4118
|
+
async function V(e, t, n) {
|
|
4111
4119
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4112
4120
|
if (r) return {
|
|
4113
4121
|
name: r.name,
|
|
4114
4122
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4115
4123
|
};
|
|
4116
4124
|
}
|
|
4117
|
-
function
|
|
4125
|
+
function Ki(e) {
|
|
4118
4126
|
return {
|
|
4119
4127
|
async create(t, n, r, i) {
|
|
4120
4128
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4127,19 +4135,19 @@ function Wi(e) {
|
|
|
4127
4135
|
created_at: a?.created_at ?? o,
|
|
4128
4136
|
updated_at: a?.updated_at ?? o
|
|
4129
4137
|
};
|
|
4130
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4138
|
+
return await e.insertInto("organization_connections").values(s).execute(), B(s, await V(e, t, r.connection_id));
|
|
4131
4139
|
},
|
|
4132
4140
|
async list(t, n) {
|
|
4133
4141
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4134
4142
|
for (let n of r) {
|
|
4135
|
-
let r = await
|
|
4136
|
-
i.push(
|
|
4143
|
+
let r = await V(e, t, n.connection_id);
|
|
4144
|
+
i.push(B(n, r));
|
|
4137
4145
|
}
|
|
4138
4146
|
return i;
|
|
4139
4147
|
},
|
|
4140
4148
|
async get(t, n, r) {
|
|
4141
4149
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4142
|
-
return i ?
|
|
4150
|
+
return i ? B(i, await V(e, t, r)) : null;
|
|
4143
4151
|
},
|
|
4144
4152
|
async update(t, n, r, i) {
|
|
4145
4153
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4147,7 +4155,7 @@ function Wi(e) {
|
|
|
4147
4155
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4148
4156
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4149
4157
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4150
|
-
return s ?
|
|
4158
|
+
return s ? B(s, await V(e, t, r)) : null;
|
|
4151
4159
|
},
|
|
4152
4160
|
async remove(t, n, r) {
|
|
4153
4161
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4157,7 +4165,7 @@ function Wi(e) {
|
|
|
4157
4165
|
}
|
|
4158
4166
|
//#endregion
|
|
4159
4167
|
//#region src/user-organizations/create.ts
|
|
4160
|
-
function
|
|
4168
|
+
function qi(e) {
|
|
4161
4169
|
return async (n, r, i) => {
|
|
4162
4170
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4163
4171
|
id: a?.id ?? t(),
|
|
@@ -4170,14 +4178,14 @@ function Gi(e) {
|
|
|
4170
4178
|
try {
|
|
4171
4179
|
await e.insertInto("user_organizations").values(s).execute();
|
|
4172
4180
|
} catch (e) {
|
|
4173
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new
|
|
4181
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" ? new S(409, { message: "User is already a member of this organization" }) : e;
|
|
4174
4182
|
}
|
|
4175
4183
|
return { ...s };
|
|
4176
4184
|
};
|
|
4177
4185
|
}
|
|
4178
4186
|
//#endregion
|
|
4179
4187
|
//#region src/user-organizations/get.ts
|
|
4180
|
-
function
|
|
4188
|
+
function Ji(e) {
|
|
4181
4189
|
return async (t, n) => {
|
|
4182
4190
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4183
4191
|
return r ? {
|
|
@@ -4191,7 +4199,7 @@ function Ki(e) {
|
|
|
4191
4199
|
}
|
|
4192
4200
|
//#endregion
|
|
4193
4201
|
//#region src/user-organizations/list.ts
|
|
4194
|
-
function
|
|
4202
|
+
function Yi(e) {
|
|
4195
4203
|
return async (t, n) => {
|
|
4196
4204
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4197
4205
|
if (n?.q) {
|
|
@@ -4210,8 +4218,8 @@ function qi(e) {
|
|
|
4210
4218
|
created_at: e.created_at,
|
|
4211
4219
|
updated_at: e.updated_at
|
|
4212
4220
|
});
|
|
4213
|
-
if (
|
|
4214
|
-
let { rows: e, limit: t, next: a } = await
|
|
4221
|
+
if (j(n)) {
|
|
4222
|
+
let { rows: e, limit: t, next: a } = await M(r, n, {
|
|
4215
4223
|
sortColumn: "created_at",
|
|
4216
4224
|
sortOrder: "desc"
|
|
4217
4225
|
});
|
|
@@ -4244,7 +4252,7 @@ function qi(e) {
|
|
|
4244
4252
|
}
|
|
4245
4253
|
//#endregion
|
|
4246
4254
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4247
|
-
function
|
|
4255
|
+
function Xi(e) {
|
|
4248
4256
|
return async (t, n, r) => {
|
|
4249
4257
|
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([
|
|
4250
4258
|
"organizations.id",
|
|
@@ -4281,12 +4289,12 @@ function Ji(e) {
|
|
|
4281
4289
|
}
|
|
4282
4290
|
//#endregion
|
|
4283
4291
|
//#region src/user-organizations/remove.ts
|
|
4284
|
-
function
|
|
4292
|
+
function Zi(e) {
|
|
4285
4293
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4286
4294
|
}
|
|
4287
4295
|
//#endregion
|
|
4288
4296
|
//#region src/user-organizations/update.ts
|
|
4289
|
-
function
|
|
4297
|
+
function Qi(e) {
|
|
4290
4298
|
return async (t, n, r) => {
|
|
4291
4299
|
let i = {
|
|
4292
4300
|
...r,
|
|
@@ -4297,21 +4305,21 @@ function Xi(e) {
|
|
|
4297
4305
|
}
|
|
4298
4306
|
//#endregion
|
|
4299
4307
|
//#region src/user-organizations/index.ts
|
|
4300
|
-
function
|
|
4308
|
+
function $i(e) {
|
|
4301
4309
|
return {
|
|
4302
|
-
create:
|
|
4303
|
-
get:
|
|
4304
|
-
list:
|
|
4305
|
-
listUserOrganizations:
|
|
4306
|
-
remove:
|
|
4307
|
-
update:
|
|
4310
|
+
create: qi(e),
|
|
4311
|
+
get: Ji(e),
|
|
4312
|
+
list: Yi(e),
|
|
4313
|
+
listUserOrganizations: Xi(e),
|
|
4314
|
+
remove: Zi(e),
|
|
4315
|
+
update: Qi(e)
|
|
4308
4316
|
};
|
|
4309
4317
|
}
|
|
4310
4318
|
//#endregion
|
|
4311
4319
|
//#region src/invites/create.ts
|
|
4312
|
-
function
|
|
4320
|
+
function ea(e) {
|
|
4313
4321
|
return async (t, n, r) => {
|
|
4314
|
-
let i = r?.importMetadata, a = i?.id ?? n.id ??
|
|
4322
|
+
let i = r?.importMetadata, a = i?.id ?? n.id ?? Ee(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4315
4323
|
id: a,
|
|
4316
4324
|
tenant_id: t,
|
|
4317
4325
|
organization_id: n.organization_id,
|
|
@@ -4332,7 +4340,7 @@ function Qi(e) {
|
|
|
4332
4340
|
try {
|
|
4333
4341
|
await e.insertInto("invites").values(l).execute();
|
|
4334
4342
|
} catch (e) {
|
|
4335
|
-
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new
|
|
4343
|
+
throw e.code === "SQLITE_CONSTRAINT_UNIQUE" || e.code === "ER_DUP_ENTRY" || e.message.includes("AlreadyExists") ? new S(409, { message: "Invite already exists" }) : e;
|
|
4336
4344
|
}
|
|
4337
4345
|
return {
|
|
4338
4346
|
id: a,
|
|
@@ -4355,11 +4363,11 @@ function Qi(e) {
|
|
|
4355
4363
|
}
|
|
4356
4364
|
//#endregion
|
|
4357
4365
|
//#region src/invites/get.ts
|
|
4358
|
-
function
|
|
4366
|
+
function ta(e) {
|
|
4359
4367
|
return async (t, n) => {
|
|
4360
4368
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4361
4369
|
return r ? l({
|
|
4362
|
-
...
|
|
4370
|
+
...lt(r, {
|
|
4363
4371
|
inviter: {},
|
|
4364
4372
|
invitee: {},
|
|
4365
4373
|
app_metadata: {},
|
|
@@ -4372,7 +4380,7 @@ function $i(e) {
|
|
|
4372
4380
|
}
|
|
4373
4381
|
//#endregion
|
|
4374
4382
|
//#region src/invites/list.ts
|
|
4375
|
-
function
|
|
4383
|
+
function na(e) {
|
|
4376
4384
|
return async (t, n) => {
|
|
4377
4385
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4378
4386
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4380,7 +4388,7 @@ function ea(e) {
|
|
|
4380
4388
|
r = r.offset(e);
|
|
4381
4389
|
}
|
|
4382
4390
|
let i = (await r.execute()).map((e) => l({
|
|
4383
|
-
...
|
|
4391
|
+
...lt(e, {
|
|
4384
4392
|
inviter: {},
|
|
4385
4393
|
invitee: {},
|
|
4386
4394
|
app_metadata: {},
|
|
@@ -4399,12 +4407,12 @@ function ea(e) {
|
|
|
4399
4407
|
}
|
|
4400
4408
|
//#endregion
|
|
4401
4409
|
//#region src/invites/remove.ts
|
|
4402
|
-
function
|
|
4410
|
+
function ra(e) {
|
|
4403
4411
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4404
4412
|
}
|
|
4405
4413
|
//#endregion
|
|
4406
4414
|
//#region src/invites/update.ts
|
|
4407
|
-
function
|
|
4415
|
+
function ia(e) {
|
|
4408
4416
|
return async (t, n, r) => {
|
|
4409
4417
|
let i = {};
|
|
4410
4418
|
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;
|
|
@@ -4412,35 +4420,35 @@ function na(e) {
|
|
|
4412
4420
|
}
|
|
4413
4421
|
//#endregion
|
|
4414
4422
|
//#region src/invites/index.ts
|
|
4415
|
-
function
|
|
4423
|
+
function aa(e) {
|
|
4416
4424
|
return {
|
|
4417
|
-
create:
|
|
4418
|
-
get:
|
|
4419
|
-
list:
|
|
4420
|
-
remove:
|
|
4421
|
-
update:
|
|
4425
|
+
create: ea(e),
|
|
4426
|
+
get: ta(e),
|
|
4427
|
+
list: na(e),
|
|
4428
|
+
remove: ra(e),
|
|
4429
|
+
update: ia(e)
|
|
4422
4430
|
};
|
|
4423
4431
|
}
|
|
4424
4432
|
//#endregion
|
|
4425
4433
|
//#region src/stats/index.ts
|
|
4426
|
-
var
|
|
4427
|
-
function
|
|
4434
|
+
var oa = ["s"], sa = ["pwd_leak"];
|
|
4435
|
+
function ca(e) {
|
|
4428
4436
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4429
4437
|
}
|
|
4430
|
-
function
|
|
4438
|
+
function la(e) {
|
|
4431
4439
|
return e.toISOString().split("T")[0];
|
|
4432
4440
|
}
|
|
4433
|
-
function
|
|
4441
|
+
function ua(e) {
|
|
4434
4442
|
return {
|
|
4435
4443
|
async getDaily(t, n = {}) {
|
|
4436
4444
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4437
4445
|
o.setDate(o.getDate() - 30);
|
|
4438
|
-
let s = r ?
|
|
4446
|
+
let s = r ? ca(r) : la(o), c = i ? ca(i) : la(a), l = f`DATE(logs.date)`;
|
|
4439
4447
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4440
4448
|
l.as("date"),
|
|
4441
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4449
|
+
e.fn.sum(e.case().when("type", "in", oa).then(1).else(0).end()).as("logins"),
|
|
4442
4450
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4443
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4451
|
+
e.fn.sum(e.case().when("type", "in", sa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4444
4452
|
e.fn.min("date").as("first_event"),
|
|
4445
4453
|
e.fn.max("date").as("last_event")
|
|
4446
4454
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4454,13 +4462,13 @@ function ca(e) {
|
|
|
4454
4462
|
},
|
|
4455
4463
|
async getActiveUsers(t) {
|
|
4456
4464
|
let n = /* @__PURE__ */ new Date();
|
|
4457
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4465
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", oa).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4458
4466
|
}
|
|
4459
4467
|
};
|
|
4460
4468
|
}
|
|
4461
4469
|
//#endregion
|
|
4462
4470
|
//#region src/analytics/index.ts
|
|
4463
|
-
var
|
|
4471
|
+
var da = {
|
|
4464
4472
|
"active-users": ["s", "seacft"],
|
|
4465
4473
|
logins: [
|
|
4466
4474
|
"s",
|
|
@@ -4490,7 +4498,7 @@ var la = {
|
|
|
4490
4498
|
"fvr"
|
|
4491
4499
|
],
|
|
4492
4500
|
"codes-sent": ["cls", "cs"]
|
|
4493
|
-
},
|
|
4501
|
+
}, fa = {
|
|
4494
4502
|
"active-users": {
|
|
4495
4503
|
alias: "active_users",
|
|
4496
4504
|
type: "UInt64",
|
|
@@ -4547,14 +4555,14 @@ var la = {
|
|
|
4547
4555
|
agg: "count"
|
|
4548
4556
|
}
|
|
4549
4557
|
};
|
|
4550
|
-
async function
|
|
4558
|
+
async function pa(e) {
|
|
4551
4559
|
try {
|
|
4552
4560
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4553
4561
|
} catch {
|
|
4554
4562
|
return "sqlite";
|
|
4555
4563
|
}
|
|
4556
4564
|
}
|
|
4557
|
-
function
|
|
4565
|
+
function H(e, t) {
|
|
4558
4566
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4559
4567
|
timeZone: e,
|
|
4560
4568
|
year: "numeric",
|
|
@@ -4569,7 +4577,7 @@ function U(e, t) {
|
|
|
4569
4577
|
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);
|
|
4570
4578
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4571
4579
|
}
|
|
4572
|
-
var
|
|
4580
|
+
var ma = [
|
|
4573
4581
|
"January",
|
|
4574
4582
|
"February",
|
|
4575
4583
|
"March",
|
|
@@ -4583,22 +4591,22 @@ var fa = [
|
|
|
4583
4591
|
"November",
|
|
4584
4592
|
"December"
|
|
4585
4593
|
];
|
|
4586
|
-
function
|
|
4587
|
-
let n = t.getUTCFullYear(), r =
|
|
4594
|
+
function ha(e, t) {
|
|
4595
|
+
let n = t.getUTCFullYear(), r = H(e, new Date(Date.UTC(n, 0, 1)));
|
|
4588
4596
|
for (let t = 1; t < 12; t++) {
|
|
4589
|
-
let i =
|
|
4590
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4597
|
+
let i = H(e, new Date(Date.UTC(n, t, 1)));
|
|
4598
|
+
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').`);
|
|
4591
4599
|
}
|
|
4592
4600
|
}
|
|
4593
|
-
function
|
|
4601
|
+
function ga(e) {
|
|
4594
4602
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4595
4603
|
return t * (Number(n) * 60 + Number(r));
|
|
4596
4604
|
}
|
|
4597
|
-
function
|
|
4605
|
+
function _a(e, t) {
|
|
4598
4606
|
let n;
|
|
4599
4607
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4600
4608
|
else {
|
|
4601
|
-
let e =
|
|
4609
|
+
let e = ga(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4602
4610
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4603
4611
|
}
|
|
4604
4612
|
switch (e) {
|
|
@@ -4609,7 +4617,7 @@ function ha(e, t) {
|
|
|
4609
4617
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4610
4618
|
}
|
|
4611
4619
|
}
|
|
4612
|
-
function
|
|
4620
|
+
function va(e, t) {
|
|
4613
4621
|
if (t === "+00:00") switch (e) {
|
|
4614
4622
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4615
4623
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4620,7 +4628,7 @@ function ga(e, t) {
|
|
|
4620
4628
|
}
|
|
4621
4629
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4622
4630
|
}
|
|
4623
|
-
let n =
|
|
4631
|
+
let n = ga(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)`;
|
|
4624
4632
|
switch (e) {
|
|
4625
4633
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4626
4634
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4629,12 +4637,12 @@ function ga(e, t) {
|
|
|
4629
4637
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4630
4638
|
}
|
|
4631
4639
|
}
|
|
4632
|
-
function
|
|
4633
|
-
|
|
4634
|
-
let i =
|
|
4635
|
-
return r === "mysql" ?
|
|
4640
|
+
function ya(e, t, n, r) {
|
|
4641
|
+
ha(t, n);
|
|
4642
|
+
let i = H(t, n);
|
|
4643
|
+
return r === "mysql" ? va(e, i) : _a(e, i);
|
|
4636
4644
|
}
|
|
4637
|
-
function
|
|
4645
|
+
function ba(e) {
|
|
4638
4646
|
switch (e) {
|
|
4639
4647
|
case "connection": return "logs.connection";
|
|
4640
4648
|
case "client_id": return "logs.client_id";
|
|
@@ -4643,14 +4651,14 @@ function va(e) {
|
|
|
4643
4651
|
case "time": throw Error("time dimension is handled separately");
|
|
4644
4652
|
}
|
|
4645
4653
|
}
|
|
4646
|
-
function
|
|
4647
|
-
let t = null, n = () => (t ||=
|
|
4654
|
+
function xa(e) {
|
|
4655
|
+
let t = null, n = () => (t ||= pa(e), t);
|
|
4648
4656
|
return { async query(t, r, i) {
|
|
4649
|
-
let a = Date.now(), o =
|
|
4657
|
+
let a = Date.now(), o = da[r], s = fa[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4650
4658
|
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));
|
|
4651
4659
|
let d = [], p = [];
|
|
4652
4660
|
for (let e of i.group_by) if (e === "time") {
|
|
4653
|
-
let e =
|
|
4661
|
+
let e = ya(i.interval, i.tz, new Date(i.from), c);
|
|
4654
4662
|
p.push({
|
|
4655
4663
|
alias: "time",
|
|
4656
4664
|
expr: e
|
|
@@ -4659,7 +4667,7 @@ function ya(e) {
|
|
|
4659
4667
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4660
4668
|
});
|
|
4661
4669
|
} else {
|
|
4662
|
-
let t =
|
|
4670
|
+
let t = ba(e);
|
|
4663
4671
|
p.push({
|
|
4664
4672
|
alias: e,
|
|
4665
4673
|
expr: f`${f.ref(t)}`
|
|
@@ -4701,7 +4709,7 @@ function ya(e) {
|
|
|
4701
4709
|
}
|
|
4702
4710
|
//#endregion
|
|
4703
4711
|
//#region src/customText/index.ts
|
|
4704
|
-
function
|
|
4712
|
+
function Sa(e) {
|
|
4705
4713
|
return {
|
|
4706
4714
|
async get(t, n, r) {
|
|
4707
4715
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4740,9 +4748,9 @@ function ba(e) {
|
|
|
4740
4748
|
}
|
|
4741
4749
|
//#endregion
|
|
4742
4750
|
//#region src/authenticationMethods/create.ts
|
|
4743
|
-
function
|
|
4751
|
+
function Ca(e) {
|
|
4744
4752
|
return async (t, n, r) => {
|
|
4745
|
-
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 ??
|
|
4753
|
+
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ?? Cr();
|
|
4746
4754
|
return await e.insertInto("authentication_methods").values({
|
|
4747
4755
|
id: s,
|
|
4748
4756
|
tenant_id: t,
|
|
@@ -4779,7 +4787,7 @@ function xa(e) {
|
|
|
4779
4787
|
}
|
|
4780
4788
|
//#endregion
|
|
4781
4789
|
//#region src/authenticationMethods/get.ts
|
|
4782
|
-
function
|
|
4790
|
+
function wa(e) {
|
|
4783
4791
|
return async (t, n) => {
|
|
4784
4792
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4785
4793
|
return r ? {
|
|
@@ -4802,7 +4810,7 @@ function Sa(e) {
|
|
|
4802
4810
|
}
|
|
4803
4811
|
//#endregion
|
|
4804
4812
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4805
|
-
function
|
|
4813
|
+
function Ta(e) {
|
|
4806
4814
|
return async (t, n) => {
|
|
4807
4815
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4808
4816
|
return r ? {
|
|
@@ -4825,7 +4833,7 @@ function Ca(e) {
|
|
|
4825
4833
|
}
|
|
4826
4834
|
//#endregion
|
|
4827
4835
|
//#region src/authenticationMethods/list.ts
|
|
4828
|
-
function
|
|
4836
|
+
function Ea(e) {
|
|
4829
4837
|
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) => ({
|
|
4830
4838
|
id: e.id,
|
|
4831
4839
|
user_id: e.user_id,
|
|
@@ -4845,35 +4853,35 @@ function wa(e) {
|
|
|
4845
4853
|
}
|
|
4846
4854
|
//#endregion
|
|
4847
4855
|
//#region src/authenticationMethods/update.ts
|
|
4848
|
-
function
|
|
4856
|
+
function Da(e) {
|
|
4849
4857
|
return async (t, n, r) => {
|
|
4850
4858
|
let i = { updated_at_ts: Date.now() };
|
|
4851
4859
|
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();
|
|
4852
|
-
let a = await
|
|
4860
|
+
let a = await wa(e)(t, n);
|
|
4853
4861
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4854
4862
|
return a;
|
|
4855
4863
|
};
|
|
4856
4864
|
}
|
|
4857
4865
|
//#endregion
|
|
4858
4866
|
//#region src/authenticationMethods/remove.ts
|
|
4859
|
-
function
|
|
4867
|
+
function Oa(e) {
|
|
4860
4868
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4861
4869
|
}
|
|
4862
4870
|
//#endregion
|
|
4863
4871
|
//#region src/authenticationMethods/index.ts
|
|
4864
|
-
function
|
|
4872
|
+
function ka(e) {
|
|
4865
4873
|
return {
|
|
4866
|
-
create:
|
|
4867
|
-
get:
|
|
4868
|
-
getByCredentialId:
|
|
4869
|
-
list:
|
|
4870
|
-
update:
|
|
4871
|
-
remove:
|
|
4874
|
+
create: Ca(e),
|
|
4875
|
+
get: wa(e),
|
|
4876
|
+
getByCredentialId: Ta(e),
|
|
4877
|
+
list: Ea(e),
|
|
4878
|
+
update: Da(e),
|
|
4879
|
+
remove: Oa(e)
|
|
4872
4880
|
};
|
|
4873
4881
|
}
|
|
4874
4882
|
//#endregion
|
|
4875
4883
|
//#region src/outbox/getByIds.ts
|
|
4876
|
-
function
|
|
4884
|
+
function Aa(e) {
|
|
4877
4885
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4878
4886
|
...JSON.parse(e.payload),
|
|
4879
4887
|
id: e.id,
|
|
@@ -4886,7 +4894,7 @@ function Oa(e) {
|
|
|
4886
4894
|
}
|
|
4887
4895
|
//#endregion
|
|
4888
4896
|
//#region src/outbox/getUnprocessed.ts
|
|
4889
|
-
function
|
|
4897
|
+
function ja(e) {
|
|
4890
4898
|
return async (t) => {
|
|
4891
4899
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4892
4900
|
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) => ({
|
|
@@ -4902,7 +4910,7 @@ function ka(e) {
|
|
|
4902
4910
|
}
|
|
4903
4911
|
//#endregion
|
|
4904
4912
|
//#region src/outbox/claimEvents.ts
|
|
4905
|
-
function
|
|
4913
|
+
function Ma(e) {
|
|
4906
4914
|
return async (t, n, r) => {
|
|
4907
4915
|
if (t.length === 0) return [];
|
|
4908
4916
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4914,7 +4922,7 @@ function Aa(e) {
|
|
|
4914
4922
|
}
|
|
4915
4923
|
//#endregion
|
|
4916
4924
|
//#region src/outbox/markProcessed.ts
|
|
4917
|
-
function
|
|
4925
|
+
function Na(e) {
|
|
4918
4926
|
return async (t) => {
|
|
4919
4927
|
if (t.length === 0) return;
|
|
4920
4928
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4923,7 +4931,7 @@ function ja(e) {
|
|
|
4923
4931
|
}
|
|
4924
4932
|
//#endregion
|
|
4925
4933
|
//#region src/outbox/markRetry.ts
|
|
4926
|
-
function
|
|
4934
|
+
function Pa(e) {
|
|
4927
4935
|
return async (t, n, r) => {
|
|
4928
4936
|
await e.updateTable("outbox_events").set({
|
|
4929
4937
|
error: n,
|
|
@@ -4936,7 +4944,7 @@ function Ma(e) {
|
|
|
4936
4944
|
}
|
|
4937
4945
|
//#endregion
|
|
4938
4946
|
//#region src/outbox/deadLetter.ts
|
|
4939
|
-
function
|
|
4947
|
+
function Fa(e) {
|
|
4940
4948
|
return async (t, n) => {
|
|
4941
4949
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4942
4950
|
await e.updateTable("outbox_events").set({
|
|
@@ -4948,7 +4956,7 @@ function Na(e) {
|
|
|
4948
4956
|
}
|
|
4949
4957
|
//#endregion
|
|
4950
4958
|
//#region src/outbox/listFailed.ts
|
|
4951
|
-
function
|
|
4959
|
+
function Ia(e) {
|
|
4952
4960
|
return async (t, n = {}) => {
|
|
4953
4961
|
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) => {
|
|
4954
4962
|
let t;
|
|
@@ -4983,7 +4991,7 @@ function Pa(e) {
|
|
|
4983
4991
|
}
|
|
4984
4992
|
//#endregion
|
|
4985
4993
|
//#region src/outbox/replay.ts
|
|
4986
|
-
function
|
|
4994
|
+
function La(e) {
|
|
4987
4995
|
return async (t, n) => {
|
|
4988
4996
|
let r = await e.updateTable("outbox_events").set({
|
|
4989
4997
|
processed_at: null,
|
|
@@ -4998,7 +5006,7 @@ function Fa(e) {
|
|
|
4998
5006
|
}
|
|
4999
5007
|
//#endregion
|
|
5000
5008
|
//#region src/outbox/cleanup.ts
|
|
5001
|
-
function
|
|
5009
|
+
function Ra(e) {
|
|
5002
5010
|
return async (t) => {
|
|
5003
5011
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5004
5012
|
return Number(n.numDeletedRows);
|
|
@@ -5006,23 +5014,23 @@ function Ia(e) {
|
|
|
5006
5014
|
}
|
|
5007
5015
|
//#endregion
|
|
5008
5016
|
//#region src/outbox/index.ts
|
|
5009
|
-
function
|
|
5017
|
+
function za(e) {
|
|
5010
5018
|
return {
|
|
5011
|
-
create:
|
|
5012
|
-
getByIds:
|
|
5013
|
-
getUnprocessed:
|
|
5014
|
-
claimEvents:
|
|
5015
|
-
markProcessed:
|
|
5016
|
-
markRetry:
|
|
5017
|
-
deadLetter:
|
|
5018
|
-
listFailed:
|
|
5019
|
-
replay:
|
|
5020
|
-
cleanup:
|
|
5019
|
+
create: He(e),
|
|
5020
|
+
getByIds: Aa(e),
|
|
5021
|
+
getUnprocessed: ja(e),
|
|
5022
|
+
claimEvents: Ma(e),
|
|
5023
|
+
markProcessed: Na(e),
|
|
5024
|
+
markRetry: Pa(e),
|
|
5025
|
+
deadLetter: Fa(e),
|
|
5026
|
+
listFailed: Ia(e),
|
|
5027
|
+
replay: La(e),
|
|
5028
|
+
cleanup: Ra(e)
|
|
5021
5029
|
};
|
|
5022
5030
|
}
|
|
5023
5031
|
//#endregion
|
|
5024
5032
|
//#region src/log-streams/index.ts
|
|
5025
|
-
function
|
|
5033
|
+
function U(e) {
|
|
5026
5034
|
return {
|
|
5027
5035
|
id: e.id,
|
|
5028
5036
|
name: e.name,
|
|
@@ -5035,7 +5043,7 @@ function W(e) {
|
|
|
5035
5043
|
updated_at: e.updated_at
|
|
5036
5044
|
};
|
|
5037
5045
|
}
|
|
5038
|
-
function
|
|
5046
|
+
function Ba(e) {
|
|
5039
5047
|
return {
|
|
5040
5048
|
async create(n, r, i) {
|
|
5041
5049
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5050,14 +5058,14 @@ function Ra(e) {
|
|
|
5050
5058
|
created_at: a?.created_at ?? o,
|
|
5051
5059
|
updated_at: a?.updated_at ?? o
|
|
5052
5060
|
};
|
|
5053
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5061
|
+
return await e.insertInto("log_streams").values(s).execute(), U(s);
|
|
5054
5062
|
},
|
|
5055
5063
|
async get(t, n) {
|
|
5056
5064
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5057
|
-
return r ?
|
|
5065
|
+
return r ? U(r) : null;
|
|
5058
5066
|
},
|
|
5059
5067
|
async list(t) {
|
|
5060
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5068
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(U);
|
|
5061
5069
|
},
|
|
5062
5070
|
async update(t, n, r) {
|
|
5063
5071
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5070,11 +5078,11 @@ function Ra(e) {
|
|
|
5070
5078
|
}
|
|
5071
5079
|
//#endregion
|
|
5072
5080
|
//#region src/migrationSources/index.ts
|
|
5073
|
-
function
|
|
5081
|
+
function W(e) {
|
|
5074
5082
|
return {
|
|
5075
5083
|
id: e.id,
|
|
5076
5084
|
name: e.name,
|
|
5077
|
-
provider:
|
|
5085
|
+
provider: ae.parse(e.provider),
|
|
5078
5086
|
connection: e.connection,
|
|
5079
5087
|
enabled: e.enabled === 1,
|
|
5080
5088
|
credentials: JSON.parse(e.credentials),
|
|
@@ -5082,7 +5090,7 @@ function G(e) {
|
|
|
5082
5090
|
updated_at: e.updated_at
|
|
5083
5091
|
};
|
|
5084
5092
|
}
|
|
5085
|
-
function
|
|
5093
|
+
function Va(e) {
|
|
5086
5094
|
return {
|
|
5087
5095
|
async create(n, r, i) {
|
|
5088
5096
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5096,14 +5104,14 @@ function za(e) {
|
|
|
5096
5104
|
created_at: a?.created_at ?? o,
|
|
5097
5105
|
updated_at: a?.updated_at ?? o
|
|
5098
5106
|
};
|
|
5099
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5107
|
+
return await e.insertInto("migration_sources").values(l).execute(), W(l);
|
|
5100
5108
|
},
|
|
5101
5109
|
async get(t, n) {
|
|
5102
5110
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5103
|
-
return r ?
|
|
5111
|
+
return r ? W(r) : null;
|
|
5104
5112
|
},
|
|
5105
5113
|
async list(t) {
|
|
5106
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5114
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(W);
|
|
5107
5115
|
},
|
|
5108
5116
|
async update(t, n, r) {
|
|
5109
5117
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5116,34 +5124,34 @@ function za(e) {
|
|
|
5116
5124
|
}
|
|
5117
5125
|
//#endregion
|
|
5118
5126
|
//#region src/proxyRoutes/serialize.ts
|
|
5119
|
-
function
|
|
5127
|
+
function G(e) {
|
|
5120
5128
|
return {
|
|
5121
5129
|
id: e.id,
|
|
5122
5130
|
tenant_id: e.tenant_id,
|
|
5123
5131
|
custom_domain_id: e.custom_domain_id,
|
|
5124
5132
|
priority: e.priority,
|
|
5125
|
-
match:
|
|
5126
|
-
handlers:
|
|
5133
|
+
match: Ha(e.match),
|
|
5134
|
+
handlers: Ua(e.handlers),
|
|
5127
5135
|
created_at: e.created_at,
|
|
5128
5136
|
updated_at: e.updated_at
|
|
5129
5137
|
};
|
|
5130
5138
|
}
|
|
5131
|
-
function
|
|
5139
|
+
function Ha(e) {
|
|
5132
5140
|
if (!e) return { path: "/*" };
|
|
5133
5141
|
try {
|
|
5134
|
-
let t = JSON.parse(e), n =
|
|
5142
|
+
let t = JSON.parse(e), n = ie.safeParse(t);
|
|
5135
5143
|
if (n.success) return n.data;
|
|
5136
5144
|
} catch {}
|
|
5137
5145
|
return { path: "/*" };
|
|
5138
5146
|
}
|
|
5139
|
-
function
|
|
5147
|
+
function Ua(e) {
|
|
5140
5148
|
if (!e) return [];
|
|
5141
5149
|
try {
|
|
5142
5150
|
let t = JSON.parse(e);
|
|
5143
5151
|
if (!Array.isArray(t)) return [];
|
|
5144
5152
|
let n = [];
|
|
5145
5153
|
for (let e of t) {
|
|
5146
|
-
let t =
|
|
5154
|
+
let t = te.safeParse(e);
|
|
5147
5155
|
t.success && n.push(t.data);
|
|
5148
5156
|
}
|
|
5149
5157
|
return n;
|
|
@@ -5153,7 +5161,7 @@ function Va(e) {
|
|
|
5153
5161
|
}
|
|
5154
5162
|
//#endregion
|
|
5155
5163
|
//#region src/proxyRoutes/adapter.ts
|
|
5156
|
-
function
|
|
5164
|
+
function K(e) {
|
|
5157
5165
|
return {
|
|
5158
5166
|
async create(n, r, i) {
|
|
5159
5167
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5179,14 +5187,14 @@ function q(e) {
|
|
|
5179
5187
|
},
|
|
5180
5188
|
async get(t, n) {
|
|
5181
5189
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5182
|
-
return r ?
|
|
5190
|
+
return r ? G(r) : null;
|
|
5183
5191
|
},
|
|
5184
5192
|
async list(t, n = {}) {
|
|
5185
5193
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5186
5194
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5187
5195
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5188
5196
|
return {
|
|
5189
|
-
proxy_routes: o.map(
|
|
5197
|
+
proxy_routes: o.map(G),
|
|
5190
5198
|
start: r * i,
|
|
5191
5199
|
limit: i,
|
|
5192
5200
|
length: o.length
|
|
@@ -5206,7 +5214,7 @@ function q(e) {
|
|
|
5206
5214
|
}
|
|
5207
5215
|
//#endregion
|
|
5208
5216
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5209
|
-
async function
|
|
5217
|
+
async function Wa(e, t) {
|
|
5210
5218
|
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([
|
|
5211
5219
|
"custom_domain_id",
|
|
5212
5220
|
"tenant_id",
|
|
@@ -5218,21 +5226,184 @@ async function Ha(e, t) {
|
|
|
5218
5226
|
tenant_id: a.tenant_id,
|
|
5219
5227
|
custom_domain_id: a.custom_domain_id,
|
|
5220
5228
|
domain: a.domain,
|
|
5221
|
-
routes: o.map(
|
|
5229
|
+
routes: o.map(G)
|
|
5222
5230
|
};
|
|
5223
5231
|
}
|
|
5224
5232
|
//#endregion
|
|
5225
5233
|
//#region src/proxyRoutes/index.ts
|
|
5226
|
-
function
|
|
5234
|
+
function Ga(e) {
|
|
5235
|
+
return {
|
|
5236
|
+
proxyRoutes: K(e),
|
|
5237
|
+
resolveHost: (t) => Wa(e, t)
|
|
5238
|
+
};
|
|
5239
|
+
}
|
|
5240
|
+
//#endregion
|
|
5241
|
+
//#region src/scim/adapter.ts
|
|
5242
|
+
function Ka(e) {
|
|
5243
|
+
if (!e) return [];
|
|
5244
|
+
try {
|
|
5245
|
+
let t = JSON.parse(e);
|
|
5246
|
+
if (!Array.isArray(t)) return [];
|
|
5247
|
+
let n = [];
|
|
5248
|
+
for (let e of t) {
|
|
5249
|
+
let t = ue.safeParse(e);
|
|
5250
|
+
t.success && n.push(t.data);
|
|
5251
|
+
}
|
|
5252
|
+
return n;
|
|
5253
|
+
} catch {
|
|
5254
|
+
return [];
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
function qa(e) {
|
|
5258
|
+
if (!e) return [];
|
|
5259
|
+
try {
|
|
5260
|
+
let t = JSON.parse(e);
|
|
5261
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
5262
|
+
} catch {
|
|
5263
|
+
return [];
|
|
5264
|
+
}
|
|
5265
|
+
}
|
|
5266
|
+
function Ja(e) {
|
|
5267
|
+
return {
|
|
5268
|
+
connection_id: e.connection_id,
|
|
5269
|
+
user_id_attribute: e.user_id_attribute,
|
|
5270
|
+
mapping: Ka(e.mapping),
|
|
5271
|
+
created_at: e.created_at,
|
|
5272
|
+
updated_at: e.updated_at
|
|
5273
|
+
};
|
|
5274
|
+
}
|
|
5275
|
+
function Ya(e) {
|
|
5276
|
+
return {
|
|
5277
|
+
async create(t, n) {
|
|
5278
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5279
|
+
return await e.insertInto("scim_configurations").values({
|
|
5280
|
+
connection_id: n.connection_id,
|
|
5281
|
+
tenant_id: t,
|
|
5282
|
+
user_id_attribute: n.user_id_attribute,
|
|
5283
|
+
mapping: JSON.stringify(n.mapping),
|
|
5284
|
+
created_at: r,
|
|
5285
|
+
updated_at: r
|
|
5286
|
+
}).execute(), {
|
|
5287
|
+
connection_id: n.connection_id,
|
|
5288
|
+
user_id_attribute: n.user_id_attribute,
|
|
5289
|
+
mapping: n.mapping,
|
|
5290
|
+
created_at: r,
|
|
5291
|
+
updated_at: r
|
|
5292
|
+
};
|
|
5293
|
+
},
|
|
5294
|
+
async get(t, n) {
|
|
5295
|
+
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5296
|
+
return r ? Ja(r) : null;
|
|
5297
|
+
},
|
|
5298
|
+
async update(t, n, r) {
|
|
5299
|
+
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5300
|
+
r.user_id_attribute !== void 0 && (i.user_id_attribute = r.user_id_attribute), r.mapping !== void 0 && (i.mapping = JSON.stringify(r.mapping));
|
|
5301
|
+
let a = await e.updateTable("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).set(i).executeTakeFirst();
|
|
5302
|
+
return Number(a.numUpdatedRows) > 0;
|
|
5303
|
+
},
|
|
5304
|
+
async remove(t, n) {
|
|
5305
|
+
let r = await e.deleteFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).executeTakeFirst();
|
|
5306
|
+
return Number(r.numDeletedRows) > 0;
|
|
5307
|
+
}
|
|
5308
|
+
};
|
|
5309
|
+
}
|
|
5310
|
+
function q(e) {
|
|
5311
|
+
return {
|
|
5312
|
+
token_id: e.token_id,
|
|
5313
|
+
connection_id: e.connection_id,
|
|
5314
|
+
token_hash: e.token_hash,
|
|
5315
|
+
scopes: qa(e.scopes),
|
|
5316
|
+
valid_until: e.valid_until ?? void 0,
|
|
5317
|
+
created_at: e.created_at,
|
|
5318
|
+
last_used_at: e.last_used_at ?? void 0
|
|
5319
|
+
};
|
|
5320
|
+
}
|
|
5321
|
+
function Xa(e) {
|
|
5227
5322
|
return {
|
|
5228
|
-
|
|
5229
|
-
|
|
5323
|
+
async create(t, n) {
|
|
5324
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5325
|
+
return await e.insertInto("scim_tokens").values({
|
|
5326
|
+
token_id: n.token_id,
|
|
5327
|
+
tenant_id: t,
|
|
5328
|
+
connection_id: n.connection_id,
|
|
5329
|
+
token_hash: n.token_hash,
|
|
5330
|
+
scopes: JSON.stringify(n.scopes),
|
|
5331
|
+
valid_until: n.valid_until ?? null,
|
|
5332
|
+
created_at: r,
|
|
5333
|
+
last_used_at: null
|
|
5334
|
+
}).execute(), {
|
|
5335
|
+
token_id: n.token_id,
|
|
5336
|
+
connection_id: n.connection_id,
|
|
5337
|
+
token_hash: n.token_hash,
|
|
5338
|
+
scopes: n.scopes,
|
|
5339
|
+
valid_until: n.valid_until,
|
|
5340
|
+
created_at: r
|
|
5341
|
+
};
|
|
5342
|
+
},
|
|
5343
|
+
async get(t, n) {
|
|
5344
|
+
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5345
|
+
return r ? q(r) : null;
|
|
5346
|
+
},
|
|
5347
|
+
async getByHash(t, n) {
|
|
5348
|
+
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5349
|
+
return r ? q(r) : null;
|
|
5350
|
+
},
|
|
5351
|
+
async listByConnection(t, n) {
|
|
5352
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(q);
|
|
5353
|
+
},
|
|
5354
|
+
async markUsed(t, n, r) {
|
|
5355
|
+
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
5356
|
+
return Number(i.numUpdatedRows) > 0;
|
|
5357
|
+
},
|
|
5358
|
+
async remove(t, n) {
|
|
5359
|
+
let r = await e.deleteFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).executeTakeFirst();
|
|
5360
|
+
return Number(r.numDeletedRows) > 0;
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5363
|
+
}
|
|
5364
|
+
function Za(e) {
|
|
5365
|
+
return {
|
|
5366
|
+
connection_id: e.connection_id,
|
|
5367
|
+
external_id: e.external_id,
|
|
5368
|
+
user_id: e.user_id,
|
|
5369
|
+
created_at: e.created_at
|
|
5370
|
+
};
|
|
5371
|
+
}
|
|
5372
|
+
function Qa(e) {
|
|
5373
|
+
return {
|
|
5374
|
+
async create(t, n) {
|
|
5375
|
+
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5376
|
+
return await e.insertInto("scim_external_ids").values({
|
|
5377
|
+
tenant_id: t,
|
|
5378
|
+
connection_id: n.connection_id,
|
|
5379
|
+
external_id: n.external_id,
|
|
5380
|
+
user_id: n.user_id,
|
|
5381
|
+
created_at: r
|
|
5382
|
+
}).execute(), {
|
|
5383
|
+
connection_id: n.connection_id,
|
|
5384
|
+
external_id: n.external_id,
|
|
5385
|
+
user_id: n.user_id,
|
|
5386
|
+
created_at: r
|
|
5387
|
+
};
|
|
5388
|
+
},
|
|
5389
|
+
async getByExternalId(t, n, r) {
|
|
5390
|
+
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5391
|
+
return i ? Za(i) : null;
|
|
5392
|
+
},
|
|
5393
|
+
async getByUserId(t, n, r) {
|
|
5394
|
+
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5395
|
+
return i ? Za(i) : null;
|
|
5396
|
+
},
|
|
5397
|
+
async remove(t, n, r) {
|
|
5398
|
+
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
5399
|
+
return Number(i.numDeletedRows) > 0;
|
|
5400
|
+
}
|
|
5230
5401
|
};
|
|
5231
5402
|
}
|
|
5232
5403
|
//#endregion
|
|
5233
5404
|
//#region src/tenantOperations/index.ts
|
|
5234
5405
|
function J(e) {
|
|
5235
|
-
return
|
|
5406
|
+
return me.parse({
|
|
5236
5407
|
id: e.id,
|
|
5237
5408
|
tenant_id: e.tenant_id,
|
|
5238
5409
|
rollout_id: e.rollout_id,
|
|
@@ -5250,10 +5421,10 @@ function J(e) {
|
|
|
5250
5421
|
finished_at: e.finished_at
|
|
5251
5422
|
});
|
|
5252
5423
|
}
|
|
5253
|
-
function
|
|
5424
|
+
function $a(e) {
|
|
5254
5425
|
return {
|
|
5255
5426
|
async create(n) {
|
|
5256
|
-
let r =
|
|
5427
|
+
let r = pe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5257
5428
|
id: `op_${t()}`,
|
|
5258
5429
|
tenant_id: r.tenant_id,
|
|
5259
5430
|
rollout_id: r.rollout_id ?? null,
|
|
@@ -5305,27 +5476,27 @@ function Wa(e) {
|
|
|
5305
5476
|
}
|
|
5306
5477
|
//#endregion
|
|
5307
5478
|
//#region src/utils/monotonic-id.ts
|
|
5308
|
-
var
|
|
5309
|
-
function
|
|
5479
|
+
var eo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Y = 32, to = 10, no = 4, ro = 10;
|
|
5480
|
+
function io(e, t) {
|
|
5310
5481
|
let n = "";
|
|
5311
|
-
for (let r = t; r > 0; r--) n =
|
|
5482
|
+
for (let r = t; r > 0; r--) n = eo.charAt(e % Y) + n, e = Math.floor(e / Y);
|
|
5312
5483
|
return n;
|
|
5313
5484
|
}
|
|
5314
|
-
function
|
|
5315
|
-
let e = new Uint8Array(
|
|
5485
|
+
function ao() {
|
|
5486
|
+
let e = new Uint8Array(ro);
|
|
5316
5487
|
crypto.getRandomValues(e);
|
|
5317
5488
|
let t = "";
|
|
5318
|
-
for (let n = 0; n <
|
|
5489
|
+
for (let n = 0; n < ro; n++) t += eo.charAt(e[n] % Y);
|
|
5319
5490
|
return t;
|
|
5320
5491
|
}
|
|
5321
|
-
var
|
|
5322
|
-
function
|
|
5492
|
+
var oo = 0, so = 0;
|
|
5493
|
+
function co() {
|
|
5323
5494
|
let e = Date.now();
|
|
5324
|
-
return e ===
|
|
5495
|
+
return e === oo ? so++ : (oo = e, so = 0), io(e, to) + io(so, no) + ao();
|
|
5325
5496
|
}
|
|
5326
5497
|
//#endregion
|
|
5327
5498
|
//#region src/tenantOperationEvents/index.ts
|
|
5328
|
-
function
|
|
5499
|
+
function lo(e) {
|
|
5329
5500
|
if (!e) return null;
|
|
5330
5501
|
try {
|
|
5331
5502
|
let t = JSON.parse(e);
|
|
@@ -5333,22 +5504,22 @@ function $a(e) {
|
|
|
5333
5504
|
} catch {}
|
|
5334
5505
|
return null;
|
|
5335
5506
|
}
|
|
5336
|
-
function
|
|
5337
|
-
return
|
|
5507
|
+
function uo(e) {
|
|
5508
|
+
return fe.parse({
|
|
5338
5509
|
id: e.id,
|
|
5339
5510
|
operation_id: e.operation_id,
|
|
5340
5511
|
step: e.step,
|
|
5341
5512
|
outcome: e.outcome,
|
|
5342
|
-
detail:
|
|
5513
|
+
detail: lo(e.detail),
|
|
5343
5514
|
attempt: e.attempt,
|
|
5344
5515
|
created_at: e.created_at
|
|
5345
5516
|
});
|
|
5346
5517
|
}
|
|
5347
|
-
function
|
|
5518
|
+
function fo(e) {
|
|
5348
5519
|
return {
|
|
5349
5520
|
async create(t) {
|
|
5350
|
-
let n =
|
|
5351
|
-
id: `evt_${
|
|
5521
|
+
let n = de.parse(t), r = {
|
|
5522
|
+
id: `evt_${co()}`,
|
|
5352
5523
|
operation_id: n.operation_id,
|
|
5353
5524
|
step: n.step,
|
|
5354
5525
|
outcome: n.outcome,
|
|
@@ -5356,12 +5527,12 @@ function to(e) {
|
|
|
5356
5527
|
attempt: n.attempt,
|
|
5357
5528
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5358
5529
|
};
|
|
5359
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5530
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), uo(r);
|
|
5360
5531
|
},
|
|
5361
5532
|
async listByOperation(t, n = {}) {
|
|
5362
5533
|
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();
|
|
5363
5534
|
return {
|
|
5364
|
-
events: a.map(
|
|
5535
|
+
events: a.map(uo),
|
|
5365
5536
|
start: r * i,
|
|
5366
5537
|
limit: i,
|
|
5367
5538
|
length: a.length
|
|
@@ -5371,7 +5542,7 @@ function to(e) {
|
|
|
5371
5542
|
}
|
|
5372
5543
|
//#endregion
|
|
5373
5544
|
//#region src/rollouts/index.ts
|
|
5374
|
-
function
|
|
5545
|
+
function po(e) {
|
|
5375
5546
|
if (!e) return null;
|
|
5376
5547
|
try {
|
|
5377
5548
|
return JSON.parse(e);
|
|
@@ -5379,26 +5550,26 @@ function no(e) {
|
|
|
5379
5550
|
return null;
|
|
5380
5551
|
}
|
|
5381
5552
|
}
|
|
5382
|
-
function
|
|
5383
|
-
return
|
|
5553
|
+
function X(e) {
|
|
5554
|
+
return le.parse({
|
|
5384
5555
|
id: e.id,
|
|
5385
5556
|
kind: e.kind,
|
|
5386
5557
|
status: e.status,
|
|
5387
5558
|
target_worker_version: e.target_worker_version,
|
|
5388
5559
|
target_database_version: e.target_database_version,
|
|
5389
5560
|
wave_size: e.wave_size,
|
|
5390
|
-
canary_tenant_ids:
|
|
5391
|
-
filter:
|
|
5561
|
+
canary_tenant_ids: po(e.canary_tenant_ids),
|
|
5562
|
+
filter: po(e.filter),
|
|
5392
5563
|
initiated_by: e.initiated_by,
|
|
5393
5564
|
created_at: e.created_at,
|
|
5394
5565
|
updated_at: e.updated_at,
|
|
5395
5566
|
finished_at: e.finished_at
|
|
5396
5567
|
});
|
|
5397
5568
|
}
|
|
5398
|
-
function
|
|
5569
|
+
function mo(e) {
|
|
5399
5570
|
return {
|
|
5400
5571
|
async create(n) {
|
|
5401
|
-
let r =
|
|
5572
|
+
let r = ce.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
5402
5573
|
id: `rol_${t()}`,
|
|
5403
5574
|
kind: r.kind,
|
|
5404
5575
|
status: "pending",
|
|
@@ -5412,16 +5583,16 @@ function ro(e) {
|
|
|
5412
5583
|
updated_at: i,
|
|
5413
5584
|
finished_at: null
|
|
5414
5585
|
};
|
|
5415
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5586
|
+
return await e.insertInto("rollouts").values(a).execute(), X(a);
|
|
5416
5587
|
},
|
|
5417
5588
|
async get(t) {
|
|
5418
5589
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5419
|
-
return n ?
|
|
5590
|
+
return n ? X(n) : null;
|
|
5420
5591
|
},
|
|
5421
5592
|
async list(t = {}) {
|
|
5422
5593
|
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();
|
|
5423
5594
|
return {
|
|
5424
|
-
rollouts: i.map(
|
|
5595
|
+
rollouts: i.map(X),
|
|
5425
5596
|
start: n * r,
|
|
5426
5597
|
limit: r,
|
|
5427
5598
|
length: i.length
|
|
@@ -5441,7 +5612,7 @@ function ro(e) {
|
|
|
5441
5612
|
}
|
|
5442
5613
|
//#endregion
|
|
5443
5614
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5444
|
-
var
|
|
5615
|
+
var ho = class {
|
|
5445
5616
|
migrations;
|
|
5446
5617
|
constructor(e) {
|
|
5447
5618
|
this.migrations = e;
|
|
@@ -5449,10 +5620,10 @@ var io = class {
|
|
|
5449
5620
|
async getMigrations() {
|
|
5450
5621
|
return this.migrations;
|
|
5451
5622
|
}
|
|
5452
|
-
},
|
|
5453
|
-
down: () =>
|
|
5454
|
-
up: () =>
|
|
5455
|
-
}),
|
|
5623
|
+
}, go = /* @__PURE__ */ C({
|
|
5624
|
+
down: () => bo,
|
|
5625
|
+
up: () => yo
|
|
5626
|
+
}), _o = [
|
|
5456
5627
|
{
|
|
5457
5628
|
table: "authentication_methods",
|
|
5458
5629
|
name: "fk_authentication_methods_tenants",
|
|
@@ -5718,47 +5889,47 @@ var io = class {
|
|
|
5718
5889
|
onDelete: "cascade"
|
|
5719
5890
|
}
|
|
5720
5891
|
];
|
|
5721
|
-
async function
|
|
5892
|
+
async function vo(e) {
|
|
5722
5893
|
try {
|
|
5723
5894
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
5724
5895
|
} catch {
|
|
5725
5896
|
return !1;
|
|
5726
5897
|
}
|
|
5727
5898
|
}
|
|
5728
|
-
function
|
|
5899
|
+
function Z(e, t) {
|
|
5729
5900
|
let n = e;
|
|
5730
|
-
for (let e of
|
|
5901
|
+
for (let e of _o) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
5731
5902
|
let n = t;
|
|
5732
5903
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
5733
5904
|
}));
|
|
5734
5905
|
return n;
|
|
5735
5906
|
}
|
|
5736
|
-
async function
|
|
5737
|
-
let t = await
|
|
5907
|
+
async function yo(e) {
|
|
5908
|
+
let t = await vo(e);
|
|
5738
5909
|
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();
|
|
5739
5910
|
{
|
|
5740
5911
|
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"]);
|
|
5741
|
-
t && (n =
|
|
5912
|
+
t && (n = Z(n, "authentication_methods")), await n.execute();
|
|
5742
5913
|
}
|
|
5743
5914
|
{
|
|
5744
5915
|
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"]);
|
|
5745
|
-
t && (n =
|
|
5916
|
+
t && (n = Z(n, "branding")), await n.execute();
|
|
5746
5917
|
}
|
|
5747
5918
|
{
|
|
5748
5919
|
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"]);
|
|
5749
|
-
t && (n =
|
|
5920
|
+
t && (n = Z(n, "clients")), await n.execute();
|
|
5750
5921
|
}
|
|
5751
5922
|
{
|
|
5752
5923
|
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"]);
|
|
5753
|
-
t && (n =
|
|
5924
|
+
t && (n = Z(n, "client_grants")), await n.execute();
|
|
5754
5925
|
}
|
|
5755
5926
|
{
|
|
5756
5927
|
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"]);
|
|
5757
|
-
t && (n =
|
|
5928
|
+
t && (n = Z(n, "client_registration_tokens")), await n.execute();
|
|
5758
5929
|
}
|
|
5759
5930
|
{
|
|
5760
5931
|
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"]);
|
|
5761
|
-
t && (n =
|
|
5932
|
+
t && (n = Z(n, "users")), await n.execute();
|
|
5762
5933
|
}
|
|
5763
5934
|
{
|
|
5764
5935
|
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", [
|
|
@@ -5766,16 +5937,16 @@ async function co(e) {
|
|
|
5766
5937
|
"code_type",
|
|
5767
5938
|
"tenant_id"
|
|
5768
5939
|
]);
|
|
5769
|
-
t && (n =
|
|
5940
|
+
t && (n = Z(n, "codes")), await n.execute();
|
|
5770
5941
|
}
|
|
5771
5942
|
{
|
|
5772
5943
|
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"]);
|
|
5773
|
-
t && (n =
|
|
5944
|
+
t && (n = Z(n, "connections")), await n.execute();
|
|
5774
5945
|
}
|
|
5775
5946
|
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();
|
|
5776
5947
|
{
|
|
5777
5948
|
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"]);
|
|
5778
|
-
t && (n =
|
|
5949
|
+
t && (n = Z(n, "custom_domains")), await n.execute();
|
|
5779
5950
|
}
|
|
5780
5951
|
{
|
|
5781
5952
|
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", [
|
|
@@ -5783,56 +5954,56 @@ async function co(e) {
|
|
|
5783
5954
|
"prompt",
|
|
5784
5955
|
"language"
|
|
5785
5956
|
]);
|
|
5786
|
-
t && (n =
|
|
5957
|
+
t && (n = Z(n, "custom_text")), await n.execute();
|
|
5787
5958
|
}
|
|
5788
5959
|
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();
|
|
5789
5960
|
{
|
|
5790
5961
|
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"]);
|
|
5791
|
-
t && (n =
|
|
5962
|
+
t && (n = Z(n, "email_templates")), await n.execute();
|
|
5792
5963
|
}
|
|
5793
5964
|
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();
|
|
5794
5965
|
{
|
|
5795
5966
|
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"]);
|
|
5796
|
-
t && (n =
|
|
5967
|
+
t && (n = Z(n, "grants")), await n.execute();
|
|
5797
5968
|
}
|
|
5798
5969
|
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();
|
|
5799
5970
|
{
|
|
5800
5971
|
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"]);
|
|
5801
|
-
t && (n =
|
|
5972
|
+
t && (n = Z(n, "hooks")), await n.execute();
|
|
5802
5973
|
}
|
|
5803
5974
|
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();
|
|
5804
5975
|
{
|
|
5805
5976
|
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"]);
|
|
5806
|
-
t && (n =
|
|
5977
|
+
t && (n = Z(n, "keys")), await n.execute();
|
|
5807
5978
|
}
|
|
5808
5979
|
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();
|
|
5809
5980
|
{
|
|
5810
5981
|
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"]);
|
|
5811
|
-
t && (n =
|
|
5982
|
+
t && (n = Z(n, "sessions")), await n.execute();
|
|
5812
5983
|
}
|
|
5813
5984
|
{
|
|
5814
5985
|
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"]);
|
|
5815
|
-
t && (n =
|
|
5986
|
+
t && (n = Z(n, "login_sessions")), await n.execute();
|
|
5816
5987
|
}
|
|
5817
5988
|
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();
|
|
5818
5989
|
{
|
|
5819
5990
|
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"]);
|
|
5820
|
-
t && (n =
|
|
5991
|
+
t && (n = Z(n, "migrations")), await n.execute();
|
|
5821
5992
|
}
|
|
5822
5993
|
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();
|
|
5823
5994
|
{
|
|
5824
5995
|
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());
|
|
5825
|
-
t && (n =
|
|
5996
|
+
t && (n = Z(n, "organization_connections")), await n.execute();
|
|
5826
5997
|
}
|
|
5827
5998
|
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();
|
|
5828
5999
|
{
|
|
5829
6000
|
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"]);
|
|
5830
|
-
t && (n =
|
|
6001
|
+
t && (n = Z(n, "passwords")), await n.execute();
|
|
5831
6002
|
}
|
|
5832
6003
|
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();
|
|
5833
6004
|
{
|
|
5834
6005
|
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"]);
|
|
5835
|
-
t && (n =
|
|
6006
|
+
t && (n = Z(n, "refresh_tokens")), await n.execute();
|
|
5836
6007
|
}
|
|
5837
6008
|
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", [
|
|
5838
6009
|
"tenant_id",
|
|
@@ -5842,23 +6013,23 @@ async function co(e) {
|
|
|
5842
6013
|
]).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();
|
|
5843
6014
|
{
|
|
5844
6015
|
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"]);
|
|
5845
|
-
t && (n =
|
|
6016
|
+
t && (n = Z(n, "tenant_operation_events")), await n.execute();
|
|
5846
6017
|
}
|
|
5847
6018
|
{
|
|
5848
6019
|
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"]);
|
|
5849
|
-
t && (n =
|
|
6020
|
+
t && (n = Z(n, "themes")), await n.execute();
|
|
5850
6021
|
}
|
|
5851
6022
|
{
|
|
5852
6023
|
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"]);
|
|
5853
|
-
t && (n =
|
|
6024
|
+
t && (n = Z(n, "universal_login_templates")), await n.execute();
|
|
5854
6025
|
}
|
|
5855
6026
|
{
|
|
5856
6027
|
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"]);
|
|
5857
|
-
t && (n =
|
|
6028
|
+
t && (n = Z(n, "user_activity")), await n.execute();
|
|
5858
6029
|
}
|
|
5859
6030
|
{
|
|
5860
6031
|
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"]);
|
|
5861
|
-
t && (n =
|
|
6032
|
+
t && (n = Z(n, "user_organizations")), await n.execute();
|
|
5862
6033
|
}
|
|
5863
6034
|
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", [
|
|
5864
6035
|
"tenant_id",
|
|
@@ -5921,76 +6092,76 @@ async function co(e) {
|
|
|
5921
6092
|
"tenant_id",
|
|
5922
6093
|
"phone_number",
|
|
5923
6094
|
"provider"
|
|
5924
|
-
]).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
|
|
6095
|
+
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of _o) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
5925
6096
|
let n = e;
|
|
5926
6097
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
5927
6098
|
}).execute();
|
|
5928
6099
|
}
|
|
5929
|
-
async function
|
|
6100
|
+
async function bo(e) {
|
|
5930
6101
|
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();
|
|
5931
6102
|
}
|
|
5932
6103
|
//#endregion
|
|
5933
6104
|
//#region migrate/log.ts
|
|
5934
|
-
var
|
|
5935
|
-
function
|
|
5936
|
-
|
|
6105
|
+
var xo = !1;
|
|
6106
|
+
function So(e) {
|
|
6107
|
+
xo = e;
|
|
5937
6108
|
}
|
|
5938
|
-
function
|
|
5939
|
-
|
|
6109
|
+
function Q(...e) {
|
|
6110
|
+
xo && console.log(...e);
|
|
5940
6111
|
}
|
|
5941
|
-
function
|
|
6112
|
+
function Co(...e) {
|
|
5942
6113
|
console.warn(...e);
|
|
5943
6114
|
}
|
|
5944
6115
|
//#endregion
|
|
5945
6116
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
5946
|
-
var
|
|
5947
|
-
down: () =>
|
|
5948
|
-
up: () =>
|
|
5949
|
-
}),
|
|
5950
|
-
async function
|
|
6117
|
+
var wo = /* @__PURE__ */ C({
|
|
6118
|
+
down: () => Po,
|
|
6119
|
+
up: () => jo
|
|
6120
|
+
}), $ = 5e4, To = 500;
|
|
6121
|
+
async function Eo(e) {
|
|
5951
6122
|
try {
|
|
5952
6123
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
5953
6124
|
} catch {
|
|
5954
6125
|
return "sqlite";
|
|
5955
6126
|
}
|
|
5956
6127
|
}
|
|
5957
|
-
async function
|
|
6128
|
+
async function Do(e, t, n) {
|
|
5958
6129
|
try {
|
|
5959
6130
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
5960
6131
|
} catch (e) {
|
|
5961
6132
|
if (e instanceof Error && (e.message.includes("1060") || e.message.includes("duplicate column"))) {
|
|
5962
|
-
|
|
6133
|
+
Q(` Column ${t}.${n} already exists, skipping`);
|
|
5963
6134
|
return;
|
|
5964
6135
|
}
|
|
5965
6136
|
throw e;
|
|
5966
6137
|
}
|
|
5967
6138
|
}
|
|
5968
|
-
async function
|
|
6139
|
+
async function Oo(e, t, n, r) {
|
|
5969
6140
|
try {
|
|
5970
6141
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
5971
6142
|
} catch (e) {
|
|
5972
6143
|
if (e instanceof Error && (e.message.includes("1061") || e.message.toLowerCase().includes("already exists"))) {
|
|
5973
|
-
|
|
6144
|
+
Q(` Index ${t} already exists, skipping`);
|
|
5974
6145
|
return;
|
|
5975
6146
|
}
|
|
5976
6147
|
throw e;
|
|
5977
6148
|
}
|
|
5978
6149
|
}
|
|
5979
|
-
async function
|
|
6150
|
+
async function ko(e, t) {
|
|
5980
6151
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
5981
6152
|
if (t === "sqlite") {
|
|
5982
6153
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
5983
6154
|
r = Number(t.numDeletedRows);
|
|
5984
6155
|
} else {
|
|
5985
|
-
let t =
|
|
5986
|
-
for (; t >=
|
|
5987
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
5988
|
-
t = Number(i.numDeletedRows), r += t, t > 0 &&
|
|
6156
|
+
let t = $;
|
|
6157
|
+
for (; t >= $;) {
|
|
6158
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit($).executeTakeFirst();
|
|
6159
|
+
t = Number(i.numDeletedRows), r += t, t > 0 && Q(` Pruned ${r} expired codes row(s)...`);
|
|
5989
6160
|
}
|
|
5990
6161
|
}
|
|
5991
6162
|
return r;
|
|
5992
6163
|
}
|
|
5993
|
-
async function
|
|
6164
|
+
async function Ao(e) {
|
|
5994
6165
|
let t = 0;
|
|
5995
6166
|
for (;;) {
|
|
5996
6167
|
let n = await e.selectFrom("codes").select([
|
|
@@ -5998,33 +6169,33 @@ async function xo(e) {
|
|
|
5998
6169
|
"code_type",
|
|
5999
6170
|
"tenant_id",
|
|
6000
6171
|
"expires_at"
|
|
6001
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6172
|
+
]).where("expires_at_ts", "is", null).limit(To).execute();
|
|
6002
6173
|
if (n.length === 0) break;
|
|
6003
6174
|
for (let t of n) {
|
|
6004
6175
|
let n = Date.parse(t.expires_at);
|
|
6005
6176
|
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();
|
|
6006
6177
|
}
|
|
6007
|
-
if (t += n.length, n.length <
|
|
6178
|
+
if (t += n.length, n.length < To) break;
|
|
6008
6179
|
}
|
|
6009
6180
|
return t;
|
|
6010
6181
|
}
|
|
6011
|
-
async function
|
|
6012
|
-
let t = await
|
|
6182
|
+
async function jo(e) {
|
|
6183
|
+
let t = await Eo(e);
|
|
6013
6184
|
try {
|
|
6014
|
-
let n = await
|
|
6015
|
-
|
|
6185
|
+
let n = await ko(e, t);
|
|
6186
|
+
Q(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6016
6187
|
} catch (e) {
|
|
6017
|
-
|
|
6188
|
+
Co(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6018
6189
|
}
|
|
6019
|
-
await
|
|
6190
|
+
await Do(e, "codes", "expires_at_ts"), await Oo(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6020
6191
|
try {
|
|
6021
|
-
let t = await
|
|
6022
|
-
|
|
6192
|
+
let t = await Ao(e);
|
|
6193
|
+
Q(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6023
6194
|
} catch (e) {
|
|
6024
|
-
|
|
6195
|
+
Co(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6025
6196
|
}
|
|
6026
6197
|
}
|
|
6027
|
-
async function
|
|
6198
|
+
async function Mo(e, t, n) {
|
|
6028
6199
|
try {
|
|
6029
6200
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6030
6201
|
} catch (e) {
|
|
@@ -6032,7 +6203,83 @@ async function Co(e, t, n) {
|
|
|
6032
6203
|
throw e;
|
|
6033
6204
|
}
|
|
6034
6205
|
}
|
|
6035
|
-
async function
|
|
6206
|
+
async function No(e, t, n) {
|
|
6207
|
+
try {
|
|
6208
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6209
|
+
} catch (e) {
|
|
6210
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6211
|
+
throw e;
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6214
|
+
async function Po(e) {
|
|
6215
|
+
await Mo(e, "idx_codes_expires_at_ts", "codes"), await No(e, "codes", "expires_at_ts");
|
|
6216
|
+
}
|
|
6217
|
+
//#endregion
|
|
6218
|
+
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6219
|
+
var Fo = /* @__PURE__ */ C({
|
|
6220
|
+
down: () => Lo,
|
|
6221
|
+
up: () => Io
|
|
6222
|
+
});
|
|
6223
|
+
async function Io(e) {
|
|
6224
|
+
await e.schema.createTable("scim_configurations").addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", f`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(128)`, (e) => e.notNull()).addColumn("scopes", f`text`, (e) => e.notNull()).addColumn("valid_until", f`varchar(35)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", f`varchar(35)`).addPrimaryKeyConstraint("scim_tokens_pk", ["tenant_id", "token_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_connection_idx").on("scim_tokens").columns(["tenant_id", "connection_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_hash_idx").on("scim_tokens").columns(["tenant_id", "token_hash"]).unique().execute(), await e.schema.createTable("scim_external_ids").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("external_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6225
|
+
"tenant_id",
|
|
6226
|
+
"connection_id",
|
|
6227
|
+
"user_id"
|
|
6228
|
+
]).execute(), await e.schema.createIndex("scim_external_ids_connection_external_idx").on("scim_external_ids").columns([
|
|
6229
|
+
"tenant_id",
|
|
6230
|
+
"connection_id",
|
|
6231
|
+
"external_id"
|
|
6232
|
+
]).unique().execute();
|
|
6233
|
+
}
|
|
6234
|
+
async function Lo(e) {
|
|
6235
|
+
await e.schema.dropTable("scim_external_ids").ifExists().execute(), await e.schema.dropTable("scim_tokens").ifExists().execute(), await e.schema.dropTable("scim_configurations").ifExists().execute();
|
|
6236
|
+
}
|
|
6237
|
+
//#endregion
|
|
6238
|
+
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6239
|
+
var Ro = /* @__PURE__ */ C({
|
|
6240
|
+
down: () => Ho,
|
|
6241
|
+
up: () => Bo
|
|
6242
|
+
});
|
|
6243
|
+
async function zo(e, t, n) {
|
|
6244
|
+
try {
|
|
6245
|
+
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6246
|
+
} catch (e) {
|
|
6247
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6248
|
+
throw e;
|
|
6249
|
+
}
|
|
6250
|
+
}
|
|
6251
|
+
async function Bo(e) {
|
|
6252
|
+
await zo(e, "users", "blocked");
|
|
6253
|
+
}
|
|
6254
|
+
async function Vo(e, t, n) {
|
|
6255
|
+
try {
|
|
6256
|
+
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6257
|
+
} catch (e) {
|
|
6258
|
+
if (e instanceof Error && e.message.includes("1091")) return;
|
|
6259
|
+
throw e;
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
async function Ho(e) {
|
|
6263
|
+
await Vo(e, "users", "blocked");
|
|
6264
|
+
}
|
|
6265
|
+
//#endregion
|
|
6266
|
+
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6267
|
+
var Uo = /* @__PURE__ */ C({
|
|
6268
|
+
down: () => qo,
|
|
6269
|
+
up: () => Go
|
|
6270
|
+
});
|
|
6271
|
+
async function Wo(e, t, n) {
|
|
6272
|
+
try {
|
|
6273
|
+
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6274
|
+
} catch (e) {
|
|
6275
|
+
if (e instanceof Error && (e.message.includes("1060") || e.message.toLowerCase().includes("duplicate column"))) return;
|
|
6276
|
+
throw e;
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
async function Go(e) {
|
|
6280
|
+
await Wo(e, "prompt_settings", "show_last_used_connection");
|
|
6281
|
+
}
|
|
6282
|
+
async function Ko(e, t, n) {
|
|
6036
6283
|
try {
|
|
6037
6284
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6038
6285
|
} catch (e) {
|
|
@@ -6040,32 +6287,35 @@ async function wo(e, t, n) {
|
|
|
6040
6287
|
throw e;
|
|
6041
6288
|
}
|
|
6042
6289
|
}
|
|
6043
|
-
async function
|
|
6044
|
-
await
|
|
6290
|
+
async function qo(e) {
|
|
6291
|
+
await Ko(e, "prompt_settings", "show_last_used_connection");
|
|
6045
6292
|
}
|
|
6046
6293
|
//#endregion
|
|
6047
6294
|
//#region migrate/migrations/index.ts
|
|
6048
|
-
var
|
|
6049
|
-
"2026-07-16T14:00:00_baseline":
|
|
6050
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6295
|
+
var Jo = {
|
|
6296
|
+
"2026-07-16T14:00:00_baseline": go,
|
|
6297
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": wo,
|
|
6298
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Fo,
|
|
6299
|
+
"2026-08-05T12:00:00_user_blocked": Ro,
|
|
6300
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Uo
|
|
6051
6301
|
};
|
|
6052
6302
|
//#endregion
|
|
6053
6303
|
//#region migrate/migrate.ts
|
|
6054
|
-
async function
|
|
6055
|
-
|
|
6056
|
-
let { error: n, results: r } = await new
|
|
6304
|
+
async function Yo(e, t = !1) {
|
|
6305
|
+
So(t), t && console.log("migrating...");
|
|
6306
|
+
let { error: n, results: r } = await new he({
|
|
6057
6307
|
db: e,
|
|
6058
|
-
provider: new
|
|
6308
|
+
provider: new ho(Jo)
|
|
6059
6309
|
}).migrateToLatest();
|
|
6060
6310
|
if (r?.forEach((e) => {
|
|
6061
6311
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6062
6312
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6063
6313
|
}
|
|
6064
|
-
async function
|
|
6065
|
-
|
|
6066
|
-
let { error: n, results: r } = await new
|
|
6314
|
+
async function Xo(e, t = !1) {
|
|
6315
|
+
So(t), t && console.log("migrating...");
|
|
6316
|
+
let { error: n, results: r } = await new he({
|
|
6067
6317
|
db: e,
|
|
6068
|
-
provider: new
|
|
6318
|
+
provider: new ho(Jo)
|
|
6069
6319
|
}).migrateDown();
|
|
6070
6320
|
if (r?.forEach((e) => {
|
|
6071
6321
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6073,61 +6323,64 @@ async function Oo(e, t = !1) {
|
|
|
6073
6323
|
}
|
|
6074
6324
|
//#endregion
|
|
6075
6325
|
//#region src/index.ts
|
|
6076
|
-
function
|
|
6326
|
+
function Zo(e, t = { useTransactions: !0 }) {
|
|
6077
6327
|
let n = {
|
|
6078
|
-
actions:
|
|
6079
|
-
actionExecutions:
|
|
6080
|
-
actionVersions:
|
|
6081
|
-
branding:
|
|
6082
|
-
clients:
|
|
6083
|
-
clientConnections:
|
|
6084
|
-
clientGrants:
|
|
6085
|
-
clientRegistrationTokens:
|
|
6086
|
-
codes:
|
|
6087
|
-
connections:
|
|
6088
|
-
emailProviders:
|
|
6089
|
-
emailTemplates:
|
|
6090
|
-
customDomains:
|
|
6091
|
-
flows:
|
|
6092
|
-
forms:
|
|
6093
|
-
hookCode:
|
|
6094
|
-
hooks:
|
|
6095
|
-
invites:
|
|
6096
|
-
keys:
|
|
6097
|
-
loginSessions:
|
|
6098
|
-
logs:
|
|
6099
|
-
logStreams:
|
|
6100
|
-
migrationSources:
|
|
6101
|
-
authenticationMethods:
|
|
6102
|
-
passwords:
|
|
6103
|
-
promptSettings:
|
|
6104
|
-
proxyRoutes:
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6328
|
+
actions: Fe(e),
|
|
6329
|
+
actionExecutions: ze(e),
|
|
6330
|
+
actionVersions: Ve(e),
|
|
6331
|
+
branding: Xn(e),
|
|
6332
|
+
clients: fn(e),
|
|
6333
|
+
clientConnections: vn(e),
|
|
6334
|
+
clientGrants: Tn(e),
|
|
6335
|
+
clientRegistrationTokens: In(e),
|
|
6336
|
+
codes: Xt(e),
|
|
6337
|
+
connections: rn(e),
|
|
6338
|
+
emailProviders: Ir(e),
|
|
6339
|
+
emailTemplates: Ur(e),
|
|
6340
|
+
customDomains: qn(e),
|
|
6341
|
+
flows: mt(e),
|
|
6342
|
+
forms: oi(e),
|
|
6343
|
+
hookCode: dr(e),
|
|
6344
|
+
hooks: or(e),
|
|
6345
|
+
invites: aa(e),
|
|
6346
|
+
keys: Bn(e),
|
|
6347
|
+
loginSessions: Dr(e),
|
|
6348
|
+
logs: At(e),
|
|
6349
|
+
logStreams: Ba(e),
|
|
6350
|
+
migrationSources: Va(e),
|
|
6351
|
+
authenticationMethods: ka(e),
|
|
6352
|
+
passwords: Vt(e),
|
|
6353
|
+
promptSettings: jr(e),
|
|
6354
|
+
proxyRoutes: K(e),
|
|
6355
|
+
scimConfigurations: Ya(e),
|
|
6356
|
+
scimTokens: Xa(e),
|
|
6357
|
+
scimExternalIds: Qa(e),
|
|
6358
|
+
refreshTokens: Qr(e),
|
|
6359
|
+
resourceServers: fi(e),
|
|
6360
|
+
rolePermissions: Si(e),
|
|
6361
|
+
grants: Oi(e),
|
|
6362
|
+
userPermissions: Ni(e),
|
|
6363
|
+
userRoles: zi(e),
|
|
6364
|
+
roles: vi(e),
|
|
6365
|
+
sessions: It(e),
|
|
6366
|
+
sessionCleanup: ei(e),
|
|
6367
|
+
tenants: St(e),
|
|
6368
|
+
tenantOperations: $a(e),
|
|
6369
|
+
tenantOperationEvents: fo(e),
|
|
6370
|
+
rollouts: mo(e),
|
|
6371
|
+
themes: gr(e),
|
|
6372
|
+
universalLoginTemplates: er(e),
|
|
6373
|
+
customText: Sa(e),
|
|
6374
|
+
users: ot(e),
|
|
6375
|
+
userActivity: rt(e),
|
|
6376
|
+
organizations: Gi(e),
|
|
6377
|
+
organizationConnections: Ki(e),
|
|
6378
|
+
userOrganizations: $i(e),
|
|
6379
|
+
stats: ua(e),
|
|
6380
|
+
analytics: xa(e),
|
|
6381
|
+
outbox: za(e),
|
|
6129
6382
|
async transaction(r) {
|
|
6130
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6383
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Zo(e, {
|
|
6131
6384
|
...t,
|
|
6132
6385
|
useTransactions: !1
|
|
6133
6386
|
})));
|
|
@@ -6136,4 +6389,4 @@ function ko(e, t = { useTransactions: !0 }) {
|
|
|
6136
6389
|
return n;
|
|
6137
6390
|
}
|
|
6138
6391
|
//#endregion
|
|
6139
|
-
export {
|
|
6392
|
+
export { Ga as createProxyDataAdapter, K as createProxyRoutesAdapter, Zo as default, Xo as migrateDown, Yo as migrateToLatest };
|