@authhero/kysely-adapter 10.11.0 → 10.12.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 +945 -564
- package/dist/kysely-adapter.mjs +413 -397
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var ue = (t) => {
|
|
|
4
4
|
};
|
|
5
5
|
var Ee = (t, e, a) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
6
6
|
var j = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || ue("Cannot " + a);
|
|
7
|
-
var
|
|
7
|
+
var l = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
|
|
8
8
|
import { parseUserId as Z, codeSchema as Ke, connectionSchema as Re, loginSessionSchema as Ue, promptSettingSchema as Be, formSchema as K } from "@authhero/adapter-interfaces";
|
|
9
9
|
import "@hono/zod-openapi";
|
|
10
10
|
var V = class extends Error {
|
|
@@ -25,8 +25,8 @@ var V = class extends Error {
|
|
|
25
25
|
};
|
|
26
26
|
function Qe(t) {
|
|
27
27
|
return async (e, a) => {
|
|
28
|
-
const { identities: r, ...
|
|
29
|
-
...
|
|
28
|
+
const { identities: r, ...n } = a, o = {
|
|
29
|
+
...n,
|
|
30
30
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
31
31
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
32
32
|
login_count: 0,
|
|
@@ -37,23 +37,23 @@ function Qe(t) {
|
|
|
37
37
|
user_metadata: JSON.stringify(a.user_metadata)
|
|
38
38
|
};
|
|
39
39
|
try {
|
|
40
|
-
await t.insertInto("users").values(
|
|
40
|
+
await t.insertInto("users").values(o).execute();
|
|
41
41
|
} catch (s) {
|
|
42
42
|
throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new V(409, { message: "User already exists" }) : new V(500, { message: `${s.code}, ${s.message}` });
|
|
43
43
|
}
|
|
44
44
|
return {
|
|
45
|
-
...
|
|
45
|
+
...o,
|
|
46
46
|
// TODO: check if this is correct. Should it be optional?
|
|
47
|
-
email:
|
|
48
|
-
email_verified:
|
|
49
|
-
is_social:
|
|
47
|
+
email: o.email || "",
|
|
48
|
+
email_verified: o.email_verified === 1,
|
|
49
|
+
is_social: o.is_social === 1
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function f(t) {
|
|
54
54
|
const e = { ...t };
|
|
55
55
|
for (const a in e)
|
|
56
|
-
e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(
|
|
56
|
+
e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
|
|
57
57
|
return e;
|
|
58
58
|
}
|
|
59
59
|
function pe(t) {
|
|
@@ -77,13 +77,13 @@ function pe(t) {
|
|
|
77
77
|
}
|
|
78
78
|
function qe(t) {
|
|
79
79
|
return async (e, a) => {
|
|
80
|
-
const [r,
|
|
80
|
+
const [r, n] = await Promise.all([
|
|
81
81
|
t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
|
|
82
82
|
t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
|
|
83
83
|
]);
|
|
84
84
|
if (!r)
|
|
85
85
|
return null;
|
|
86
|
-
const { tenant_id:
|
|
86
|
+
const { tenant_id: o, ...s } = r, c = {
|
|
87
87
|
...s,
|
|
88
88
|
email: r.email || "",
|
|
89
89
|
email_verified: r.email_verified === 1,
|
|
@@ -97,39 +97,39 @@ function qe(t) {
|
|
|
97
97
|
user_id: Z(r.user_id).id,
|
|
98
98
|
isSocial: !!r.is_social
|
|
99
99
|
},
|
|
100
|
-
...
|
|
100
|
+
...n.map(pe)
|
|
101
101
|
]
|
|
102
102
|
};
|
|
103
|
-
return
|
|
103
|
+
return f(c);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
function T(t, e, a, r) {
|
|
107
|
-
return a.split(/\s+/).map((
|
|
108
|
-
let s =
|
|
109
|
-
return
|
|
110
|
-
}).forEach(({ key:
|
|
111
|
-
if (
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
else if (
|
|
115
|
-
switch (
|
|
107
|
+
return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
|
|
108
|
+
let s = o.startsWith("-"), c, d, h, m;
|
|
109
|
+
return o.startsWith("-_exists_:") ? (c = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (c = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [c, d] = s ? o.substring(1).split(":") : o.split(":"), h = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (c = null, d = o, h = !1), { key: c, value: d, isNegation: s, isExistsQuery: h, operator: m };
|
|
110
|
+
}).forEach(({ key: o, value: s, isNegation: c, isExistsQuery: d, operator: h }) => {
|
|
111
|
+
if (o)
|
|
112
|
+
if (d)
|
|
113
|
+
c ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
|
|
114
|
+
else if (c)
|
|
115
|
+
switch (h) {
|
|
116
116
|
case ">":
|
|
117
|
-
e = e.where(
|
|
117
|
+
e = e.where(o, "<=", s);
|
|
118
118
|
break;
|
|
119
119
|
case ">=":
|
|
120
|
-
e = e.where(
|
|
120
|
+
e = e.where(o, "<", s);
|
|
121
121
|
break;
|
|
122
122
|
case "<":
|
|
123
|
-
e = e.where(
|
|
123
|
+
e = e.where(o, ">=", s);
|
|
124
124
|
break;
|
|
125
125
|
case "<=":
|
|
126
|
-
e = e.where(
|
|
126
|
+
e = e.where(o, ">", s);
|
|
127
127
|
break;
|
|
128
128
|
default:
|
|
129
|
-
e = e.where(
|
|
129
|
+
e = e.where(o, "!=", s);
|
|
130
130
|
}
|
|
131
131
|
else
|
|
132
|
-
e = e.where(
|
|
132
|
+
e = e.where(o, h, s);
|
|
133
133
|
else {
|
|
134
134
|
const { ref: m } = t.dynamic;
|
|
135
135
|
e = e.where(
|
|
@@ -154,11 +154,11 @@ function Ve(t) {
|
|
|
154
154
|
const { ref: m } = t.dynamic;
|
|
155
155
|
r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
const w =
|
|
157
|
+
const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.map((m) => m.user_id), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = o.map((m) => {
|
|
158
|
+
const w = c.filter(
|
|
159
159
|
(x) => x.linked_to === m.user_id
|
|
160
160
|
);
|
|
161
|
-
return
|
|
161
|
+
return f({
|
|
162
162
|
...m,
|
|
163
163
|
email_verified: m.email_verified === 1,
|
|
164
164
|
is_social: m.is_social === 1,
|
|
@@ -174,12 +174,12 @@ function Ve(t) {
|
|
|
174
174
|
...w.map(pe)
|
|
175
175
|
]
|
|
176
176
|
});
|
|
177
|
-
}), { count:
|
|
177
|
+
}), { count: h } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
178
178
|
return {
|
|
179
|
-
users:
|
|
179
|
+
users: d,
|
|
180
180
|
start: a.page * a.per_page,
|
|
181
181
|
limit: a.per_page,
|
|
182
|
-
length: b(
|
|
182
|
+
length: b(h)
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
}
|
|
@@ -192,18 +192,18 @@ function Ge(t) {
|
|
|
192
192
|
}
|
|
193
193
|
function He(t) {
|
|
194
194
|
return async (e, a, r) => {
|
|
195
|
-
const
|
|
195
|
+
const n = {
|
|
196
196
|
...r,
|
|
197
197
|
email_verified: Ge(r),
|
|
198
198
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
199
199
|
};
|
|
200
|
-
return r.app_metadata && (
|
|
200
|
+
return r.app_metadata && (n.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (n.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
function Xe(t) {
|
|
204
|
-
return async (e, a, r,
|
|
205
|
-
const
|
|
206
|
-
return (await t.updateTable("users").set(
|
|
204
|
+
return async (e, a, r, n) => {
|
|
205
|
+
const o = { linked_to: null };
|
|
206
|
+
return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${n}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
function Ye(t) {
|
|
@@ -238,7 +238,7 @@ function et(t) {
|
|
|
238
238
|
function tt(t) {
|
|
239
239
|
return async (e) => {
|
|
240
240
|
const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
|
|
241
|
-
return a ?
|
|
241
|
+
return a ? f(a) : null;
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
function at(t) {
|
|
@@ -249,18 +249,18 @@ function at(t) {
|
|
|
249
249
|
}) => {
|
|
250
250
|
let a = t.selectFrom("tenants");
|
|
251
251
|
if (e.sort && e.sort.sort_by) {
|
|
252
|
-
const { ref:
|
|
253
|
-
a = a.orderBy(
|
|
252
|
+
const { ref: c } = t.dynamic;
|
|
253
|
+
a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
|
|
254
254
|
}
|
|
255
|
-
e.q && (a = a.where((
|
|
256
|
-
const
|
|
255
|
+
e.q && (a = a.where((c) => c.or([c("name", "like", `%${e.q}%`)])));
|
|
256
|
+
const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
|
|
257
257
|
if (!e.include_totals)
|
|
258
258
|
return {
|
|
259
|
-
tenants:
|
|
259
|
+
tenants: n
|
|
260
260
|
};
|
|
261
|
-
const { count:
|
|
261
|
+
const { count: o } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
|
|
262
262
|
return {
|
|
263
|
-
tenants:
|
|
263
|
+
tenants: n.map(f),
|
|
264
264
|
start: (e.page - 1) * e.per_page,
|
|
265
265
|
limit: e.per_page,
|
|
266
266
|
length: s
|
|
@@ -295,7 +295,7 @@ function me(t) {
|
|
|
295
295
|
const st = 1024;
|
|
296
296
|
function it(t) {
|
|
297
297
|
return async (e, a) => {
|
|
298
|
-
var
|
|
298
|
+
var n, o, s;
|
|
299
299
|
const r = {
|
|
300
300
|
id: S(),
|
|
301
301
|
...a,
|
|
@@ -304,10 +304,10 @@ function it(t) {
|
|
|
304
304
|
return await t.insertInto("logs").values({
|
|
305
305
|
...r,
|
|
306
306
|
// Truncate long strings to avoid database errors
|
|
307
|
-
description: (
|
|
307
|
+
description: (n = r.description) == null ? void 0 : n.substring(0, 256),
|
|
308
308
|
isMobile: a.isMobile ? 1 : 0,
|
|
309
309
|
tenant_id: e,
|
|
310
|
-
scope: (
|
|
310
|
+
scope: (o = a.scope) == null ? void 0 : o.join(","),
|
|
311
311
|
auth0_client: me(a.auth0_client),
|
|
312
312
|
details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
|
|
313
313
|
}).execute(), r;
|
|
@@ -335,7 +335,7 @@ function ge(t) {
|
|
|
335
335
|
_id: t.id
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function dt(t) {
|
|
339
339
|
return async (e, a = {
|
|
340
340
|
page: 0,
|
|
341
341
|
per_page: 50,
|
|
@@ -343,35 +343,35 @@ function ct(t) {
|
|
|
343
343
|
}) => {
|
|
344
344
|
let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
|
|
345
345
|
a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
|
|
346
|
-
let
|
|
346
|
+
let n = r;
|
|
347
347
|
if (a.sort && a.sort.sort_by) {
|
|
348
|
-
const { ref:
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
const { ref: c } = t.dynamic;
|
|
349
|
+
n = n.orderBy(
|
|
350
|
+
c(a.sort.sort_by),
|
|
351
351
|
a.sort.sort_order
|
|
352
352
|
);
|
|
353
353
|
}
|
|
354
|
-
|
|
355
|
-
const
|
|
354
|
+
n = n.offset(a.page * a.per_page).limit(a.per_page);
|
|
355
|
+
const o = await n.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
356
356
|
return {
|
|
357
|
-
logs:
|
|
357
|
+
logs: o.map(ge),
|
|
358
358
|
start: a.page * a.per_page,
|
|
359
359
|
limit: a.per_page,
|
|
360
360
|
length: b(s)
|
|
361
361
|
};
|
|
362
362
|
};
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function ct(t) {
|
|
365
365
|
return async (e, a) => {
|
|
366
366
|
const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
|
|
367
367
|
return r ? ge(r) : null;
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function lt(t) {
|
|
371
371
|
return {
|
|
372
372
|
create: it(t),
|
|
373
|
-
list:
|
|
374
|
-
get:
|
|
373
|
+
list: dt(t),
|
|
374
|
+
get: ct(t)
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
function ut(t) {
|
|
@@ -379,10 +379,10 @@ function ut(t) {
|
|
|
379
379
|
const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
|
|
380
380
|
if (!r)
|
|
381
381
|
return null;
|
|
382
|
-
const { tenant_id:
|
|
382
|
+
const { tenant_id: n, device: o, clients: s, ...c } = r;
|
|
383
383
|
return {
|
|
384
|
-
...
|
|
385
|
-
device: JSON.parse(
|
|
384
|
+
...c,
|
|
385
|
+
device: JSON.parse(o),
|
|
386
386
|
clients: JSON.parse(s)
|
|
387
387
|
};
|
|
388
388
|
};
|
|
@@ -409,13 +409,13 @@ function ht(t) {
|
|
|
409
409
|
}
|
|
410
410
|
function _t(t) {
|
|
411
411
|
return async (e, a, r) => {
|
|
412
|
-
const
|
|
412
|
+
const n = {
|
|
413
413
|
...r,
|
|
414
414
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
415
415
|
device: r.device ? JSON.stringify(r.device) : void 0,
|
|
416
416
|
clients: r.clients ? JSON.stringify(r.clients) : void 0
|
|
417
417
|
};
|
|
418
|
-
return !!(await t.updateTable("sessions").set(
|
|
418
|
+
return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
|
|
419
419
|
};
|
|
420
420
|
}
|
|
421
421
|
function ft(t) {
|
|
@@ -426,25 +426,25 @@ function ft(t) {
|
|
|
426
426
|
}) => {
|
|
427
427
|
let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
|
|
428
428
|
a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
|
|
429
|
-
let
|
|
429
|
+
let n = r;
|
|
430
430
|
if (a.sort && a.sort.sort_by) {
|
|
431
|
-
const { ref:
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
const { ref: d } = t.dynamic;
|
|
432
|
+
n = n.orderBy(
|
|
433
|
+
d(a.sort.sort_by),
|
|
434
434
|
a.sort.sort_order
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
|
-
|
|
438
|
-
const
|
|
437
|
+
n = n.offset(a.page * a.per_page).limit(a.per_page);
|
|
438
|
+
const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
439
439
|
return {
|
|
440
|
-
sessions:
|
|
441
|
-
...
|
|
442
|
-
device: JSON.parse(
|
|
443
|
-
clients: JSON.parse(
|
|
440
|
+
sessions: o.map((d) => ({
|
|
441
|
+
...d,
|
|
442
|
+
device: JSON.parse(d.device),
|
|
443
|
+
clients: JSON.parse(d.clients)
|
|
444
444
|
})),
|
|
445
445
|
start: a.page * a.per_page,
|
|
446
446
|
limit: a.per_page,
|
|
447
|
-
length:
|
|
447
|
+
length: c
|
|
448
448
|
};
|
|
449
449
|
};
|
|
450
450
|
}
|
|
@@ -462,8 +462,8 @@ function gt(t) {
|
|
|
462
462
|
const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
|
|
463
463
|
if (!r)
|
|
464
464
|
return null;
|
|
465
|
-
const { tenant_id:
|
|
466
|
-
return
|
|
465
|
+
const { tenant_id: n, ...o } = r;
|
|
466
|
+
return o;
|
|
467
467
|
};
|
|
468
468
|
}
|
|
469
469
|
function yt(t) {
|
|
@@ -500,11 +500,11 @@ function Nt(t) {
|
|
|
500
500
|
}) => {
|
|
501
501
|
let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
|
|
502
502
|
a.q && (r = T(t, r, a.q, ["code", "login_id"]));
|
|
503
|
-
const
|
|
503
|
+
const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
504
504
|
return {
|
|
505
|
-
codes:
|
|
506
|
-
const { tenant_id:
|
|
507
|
-
return Ke.parse(
|
|
505
|
+
codes: o.map((d) => {
|
|
506
|
+
const { tenant_id: h, ...m } = d;
|
|
507
|
+
return Ke.parse(f(m));
|
|
508
508
|
}),
|
|
509
509
|
start: a.page * a.per_page,
|
|
510
510
|
limit: a.per_page,
|
|
@@ -529,10 +529,10 @@ function bt(t) {
|
|
|
529
529
|
}
|
|
530
530
|
function xt(t) {
|
|
531
531
|
return async (e, a, r) => {
|
|
532
|
-
let
|
|
533
|
-
e.length && (
|
|
534
|
-
const
|
|
535
|
-
return
|
|
532
|
+
let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
|
|
533
|
+
e.length && (n = n.where("codes.tenant_id", "=", e));
|
|
534
|
+
const o = await n.selectAll().executeTakeFirst();
|
|
535
|
+
return o ? f(o) : null;
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
538
|
function Tt(t) {
|
|
@@ -553,38 +553,38 @@ function Ot(t) {
|
|
|
553
553
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
554
554
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
555
555
|
...a
|
|
556
|
-
},
|
|
556
|
+
}, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
|
|
557
557
|
return await t.insertInto("applications").values({
|
|
558
558
|
...r,
|
|
559
559
|
tenant_id: e,
|
|
560
560
|
disable_sign_ups: a.disable_sign_ups ? 1 : 0,
|
|
561
561
|
addons: a.addons ? JSON.stringify(a.addons) : "{}",
|
|
562
|
-
callbacks:
|
|
563
|
-
allowed_origins:
|
|
562
|
+
callbacks: o,
|
|
563
|
+
allowed_origins: n,
|
|
564
564
|
web_origins: s,
|
|
565
|
-
allowed_logout_urls:
|
|
566
|
-
allowed_clients:
|
|
565
|
+
allowed_logout_urls: c,
|
|
566
|
+
allowed_clients: d
|
|
567
567
|
}).execute(), r;
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
570
|
function kt(t) {
|
|
571
571
|
return async (e) => ({
|
|
572
|
-
applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((
|
|
573
|
-
...
|
|
574
|
-
disable_sign_ups: !!
|
|
575
|
-
addons:
|
|
576
|
-
callbacks:
|
|
577
|
-
allowed_origins:
|
|
578
|
-
web_origins:
|
|
579
|
-
allowed_logout_urls:
|
|
580
|
-
allowed_clients:
|
|
572
|
+
applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
|
|
573
|
+
...o,
|
|
574
|
+
disable_sign_ups: !!o.disable_sign_ups,
|
|
575
|
+
addons: o.addons ? JSON.parse(o.addons) : {},
|
|
576
|
+
callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
|
|
577
|
+
allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
|
|
578
|
+
web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
|
|
579
|
+
allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
|
|
580
|
+
allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
|
|
581
581
|
}))
|
|
582
582
|
});
|
|
583
583
|
}
|
|
584
584
|
function $t(t) {
|
|
585
585
|
return async (e, a) => {
|
|
586
586
|
const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
|
|
587
|
-
return r ?
|
|
587
|
+
return r ? f({
|
|
588
588
|
...r,
|
|
589
589
|
disable_sign_ups: !!r.disable_sign_ups,
|
|
590
590
|
addons: JSON.parse(r.addons),
|
|
@@ -600,7 +600,7 @@ function Dt(t) {
|
|
|
600
600
|
}
|
|
601
601
|
function It(t) {
|
|
602
602
|
return async (e, a, r) => {
|
|
603
|
-
const
|
|
603
|
+
const n = {
|
|
604
604
|
...r,
|
|
605
605
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
606
606
|
allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
|
|
@@ -611,7 +611,7 @@ function It(t) {
|
|
|
611
611
|
addons: r.addons ? JSON.stringify(r.addons) : "{}",
|
|
612
612
|
disable_sign_ups: r.disable_sign_ups ? 1 : 0
|
|
613
613
|
};
|
|
614
|
-
return await t.updateTable("applications").set(
|
|
614
|
+
return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
function Pt(t) {
|
|
@@ -648,16 +648,16 @@ function Mt(t) {
|
|
|
648
648
|
let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
|
|
649
649
|
a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
|
|
650
650
|
const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
|
|
651
|
-
(
|
|
652
|
-
...
|
|
653
|
-
options: JSON.parse(
|
|
651
|
+
(d) => f({
|
|
652
|
+
...d,
|
|
653
|
+
options: JSON.parse(d.options)
|
|
654
654
|
})
|
|
655
|
-
), { count:
|
|
655
|
+
), { count: c } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
656
656
|
return {
|
|
657
657
|
connections: s,
|
|
658
658
|
start: a.page * a.per_page,
|
|
659
659
|
limit: a.per_page,
|
|
660
|
-
length: b(
|
|
660
|
+
length: b(c)
|
|
661
661
|
};
|
|
662
662
|
};
|
|
663
663
|
}
|
|
@@ -667,7 +667,7 @@ function Ft(t) {
|
|
|
667
667
|
function At(t) {
|
|
668
668
|
return async (e, a) => {
|
|
669
669
|
const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
|
|
670
|
-
return r ?
|
|
670
|
+
return r ? f({
|
|
671
671
|
...r,
|
|
672
672
|
options: JSON.parse(r.options)
|
|
673
673
|
}) : null;
|
|
@@ -675,13 +675,13 @@ function At(t) {
|
|
|
675
675
|
}
|
|
676
676
|
function Lt(t) {
|
|
677
677
|
return async (e, a, r) => {
|
|
678
|
-
const
|
|
678
|
+
const n = {
|
|
679
679
|
...r,
|
|
680
680
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
681
681
|
};
|
|
682
682
|
return await t.updateTable("connections").set({
|
|
683
|
-
...
|
|
684
|
-
options:
|
|
683
|
+
...n,
|
|
684
|
+
options: n.options ? JSON.stringify(n.options) : void 0
|
|
685
685
|
}).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
|
|
686
686
|
};
|
|
687
687
|
}
|
|
@@ -703,12 +703,12 @@ function Jt(t) {
|
|
|
703
703
|
const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
|
|
704
704
|
if (!r)
|
|
705
705
|
throw new V(404, { message: "Tenant not found" });
|
|
706
|
-
const
|
|
706
|
+
const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
|
|
707
707
|
return {
|
|
708
708
|
...a,
|
|
709
|
-
connections:
|
|
709
|
+
connections: n.map(
|
|
710
710
|
(s) => Re.parse(
|
|
711
|
-
|
|
711
|
+
f({
|
|
712
712
|
...s,
|
|
713
713
|
options: s.options ? JSON.parse(s.options) : {}
|
|
714
714
|
})
|
|
@@ -720,7 +720,7 @@ function Jt(t) {
|
|
|
720
720
|
web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
|
|
721
721
|
allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
|
|
722
722
|
allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
|
|
723
|
-
tenant:
|
|
723
|
+
tenant: f(r),
|
|
724
724
|
// this is really an integer in the database
|
|
725
725
|
disable_sign_ups: !!a.disable_sign_ups
|
|
726
726
|
};
|
|
@@ -787,12 +787,12 @@ function Vt(t) {
|
|
|
787
787
|
}
|
|
788
788
|
function Wt(t) {
|
|
789
789
|
return async (e, a, r) => {
|
|
790
|
-
const
|
|
790
|
+
const n = {
|
|
791
791
|
...r,
|
|
792
792
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
793
793
|
primary: r.primary ? 1 : 0
|
|
794
794
|
};
|
|
795
|
-
return (await t.updateTable("custom_domains").set(
|
|
795
|
+
return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
|
|
796
796
|
};
|
|
797
797
|
}
|
|
798
798
|
function Gt(t) {
|
|
@@ -821,39 +821,39 @@ function Xt(t) {
|
|
|
821
821
|
return null;
|
|
822
822
|
const {
|
|
823
823
|
tenant_id: r,
|
|
824
|
-
colors_primary:
|
|
825
|
-
colors_page_background_type:
|
|
824
|
+
colors_primary: n,
|
|
825
|
+
colors_page_background_type: o,
|
|
826
826
|
colors_page_background_start: s,
|
|
827
|
-
colors_page_background_end:
|
|
828
|
-
colors_page_background_angle_dev:
|
|
829
|
-
font_url:
|
|
827
|
+
colors_page_background_end: c,
|
|
828
|
+
colors_page_background_angle_dev: d,
|
|
829
|
+
font_url: h,
|
|
830
830
|
...m
|
|
831
831
|
} = a;
|
|
832
|
-
return
|
|
832
|
+
return f({
|
|
833
833
|
...m,
|
|
834
834
|
colors: {
|
|
835
|
-
primary:
|
|
835
|
+
primary: n,
|
|
836
836
|
page_background: {
|
|
837
|
-
type:
|
|
837
|
+
type: o,
|
|
838
838
|
start: s,
|
|
839
|
-
end:
|
|
840
|
-
angle_deg:
|
|
839
|
+
end: c,
|
|
840
|
+
angle_deg: d
|
|
841
841
|
}
|
|
842
842
|
},
|
|
843
|
-
font:
|
|
843
|
+
font: h ? { url: h } : void 0
|
|
844
844
|
});
|
|
845
845
|
};
|
|
846
846
|
}
|
|
847
847
|
function Yt(t) {
|
|
848
848
|
return async (e, a) => {
|
|
849
|
-
var s,
|
|
850
|
-
const { colors: r, font:
|
|
849
|
+
var s, c, d, h, m, w, x, ee, te, ae, re, ne, oe, se, ie, de, ce, le;
|
|
850
|
+
const { colors: r, font: n, ...o } = a;
|
|
851
851
|
try {
|
|
852
852
|
await t.insertInto("branding").values({
|
|
853
|
-
...
|
|
853
|
+
...o,
|
|
854
854
|
colors_primary: r == null ? void 0 : r.primary,
|
|
855
|
-
colors_page_background_type: (
|
|
856
|
-
colors_page_background_start: (
|
|
855
|
+
colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
|
|
856
|
+
colors_page_background_start: (h = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : h.start,
|
|
857
857
|
colors_page_background_end: (w = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
|
|
858
858
|
colors_page_background_angle_dev: (ee = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : ee.angle_deg,
|
|
859
859
|
font_url: (te = a.font) == null ? void 0 : te.url,
|
|
@@ -861,13 +861,13 @@ function Yt(t) {
|
|
|
861
861
|
}).execute();
|
|
862
862
|
} catch {
|
|
863
863
|
await t.updateTable("branding").set({
|
|
864
|
-
...
|
|
864
|
+
...o,
|
|
865
865
|
colors_primary: r == null ? void 0 : r.primary,
|
|
866
866
|
colors_page_background_type: (re = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : re.type,
|
|
867
867
|
colors_page_background_start: (oe = (ne = a.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
|
|
868
868
|
colors_page_background_end: (ie = (se = a.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
|
|
869
|
-
colors_page_background_angle_dev: (
|
|
870
|
-
font_url: (
|
|
869
|
+
colors_page_background_angle_dev: (ce = (de = a.colors) == null ? void 0 : de.page_background) == null ? void 0 : ce.angle_deg,
|
|
870
|
+
font_url: (le = a.font) == null ? void 0 : le.url
|
|
871
871
|
}).where("tenant_id", "=", e).execute();
|
|
872
872
|
}
|
|
873
873
|
};
|
|
@@ -886,11 +886,11 @@ function ea(t) {
|
|
|
886
886
|
}) => {
|
|
887
887
|
let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
|
|
888
888
|
a.q && (r = T(t, r, a.q, ["url"]));
|
|
889
|
-
const
|
|
889
|
+
const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
890
890
|
return {
|
|
891
|
-
hooks:
|
|
892
|
-
const { tenant_id:
|
|
893
|
-
return
|
|
891
|
+
hooks: o.map((d) => {
|
|
892
|
+
const { tenant_id: h, enabled: m, synchronous: w, ...x } = d;
|
|
893
|
+
return f({
|
|
894
894
|
...x,
|
|
895
895
|
enabled: !!m,
|
|
896
896
|
synchronous: !!w
|
|
@@ -905,7 +905,7 @@ function ea(t) {
|
|
|
905
905
|
function ta(t) {
|
|
906
906
|
return async (e, a) => {
|
|
907
907
|
const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
|
|
908
|
-
return r ?
|
|
908
|
+
return r ? f({
|
|
909
909
|
...r,
|
|
910
910
|
enabled: !!r.enabled,
|
|
911
911
|
synchronous: !!r.synchronous
|
|
@@ -933,13 +933,13 @@ function ra(t) {
|
|
|
933
933
|
}
|
|
934
934
|
function na(t) {
|
|
935
935
|
return async (e, a, r) => {
|
|
936
|
-
const
|
|
936
|
+
const n = {
|
|
937
937
|
...r,
|
|
938
938
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
939
939
|
enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
|
|
940
940
|
synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
|
|
941
941
|
};
|
|
942
|
-
return await t.updateTable("hooks").set(
|
|
942
|
+
return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
945
|
function oa(t) {
|
|
@@ -954,24 +954,24 @@ function oa(t) {
|
|
|
954
954
|
function J(t, e = "", a = {}) {
|
|
955
955
|
for (let r in t)
|
|
956
956
|
if (Object.prototype.hasOwnProperty.call(t, r)) {
|
|
957
|
-
const
|
|
958
|
-
typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r],
|
|
957
|
+
const n = e ? `${e}_${r}` : r;
|
|
958
|
+
typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r], n, a) : a[n] = t[r];
|
|
959
959
|
}
|
|
960
960
|
return a;
|
|
961
961
|
}
|
|
962
962
|
function sa(t, e) {
|
|
963
963
|
const a = {};
|
|
964
|
-
for (const [r,
|
|
965
|
-
const
|
|
964
|
+
for (const [r, n] of Object.entries(t)) {
|
|
965
|
+
const o = e.find(
|
|
966
966
|
(s) => r.startsWith(`${s}_`)
|
|
967
967
|
);
|
|
968
|
-
if (!
|
|
969
|
-
a[r] =
|
|
968
|
+
if (!o)
|
|
969
|
+
a[r] = n;
|
|
970
970
|
else {
|
|
971
|
-
const s = r.slice(
|
|
972
|
-
a[
|
|
973
|
-
...a[
|
|
974
|
-
[s]:
|
|
971
|
+
const s = r.slice(o.length + 1);
|
|
972
|
+
a[o] = {
|
|
973
|
+
...a[o],
|
|
974
|
+
[s]: n
|
|
975
975
|
};
|
|
976
976
|
}
|
|
977
977
|
}
|
|
@@ -988,47 +988,47 @@ function ia(t) {
|
|
|
988
988
|
return await t.insertInto("themes").values({ ...J(r), tenant_id: e }).execute(), r;
|
|
989
989
|
};
|
|
990
990
|
}
|
|
991
|
-
function
|
|
991
|
+
function da(t) {
|
|
992
992
|
return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function ca(t) {
|
|
995
995
|
return async (e, a) => {
|
|
996
996
|
const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
|
|
997
|
-
return r ?
|
|
997
|
+
return r ? f(r) : null;
|
|
998
998
|
};
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1000
|
+
function la(t) {
|
|
1001
1001
|
return async (e, a, r) => {
|
|
1002
|
-
const
|
|
1002
|
+
const n = J({
|
|
1003
1003
|
...r,
|
|
1004
1004
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1005
1005
|
});
|
|
1006
|
-
return await t.updateTable("themes").set(
|
|
1006
|
+
return await t.updateTable("themes").set(n).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
|
|
1007
1007
|
};
|
|
1008
1008
|
}
|
|
1009
1009
|
function ua(t) {
|
|
1010
1010
|
return {
|
|
1011
1011
|
create: ia(t),
|
|
1012
|
-
get:
|
|
1013
|
-
remove:
|
|
1014
|
-
update:
|
|
1012
|
+
get: ca(t),
|
|
1013
|
+
remove: da(t),
|
|
1014
|
+
update: la(t)
|
|
1015
1015
|
};
|
|
1016
1016
|
}
|
|
1017
1017
|
function ma(t) {
|
|
1018
1018
|
return async (e, a) => {
|
|
1019
|
-
const r = (/* @__PURE__ */ new Date()).toISOString(),
|
|
1020
|
-
return
|
|
1021
|
-
sa(
|
|
1019
|
+
const r = (/* @__PURE__ */ new Date()).toISOString(), n = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
|
|
1020
|
+
return n ? Ue.parse(
|
|
1021
|
+
sa(f(n), ["authParams"])
|
|
1022
1022
|
) : null;
|
|
1023
1023
|
};
|
|
1024
1024
|
}
|
|
1025
1025
|
function ha(t) {
|
|
1026
1026
|
return async (e, a) => {
|
|
1027
|
-
var
|
|
1027
|
+
var n;
|
|
1028
1028
|
const r = {
|
|
1029
1029
|
id: S(),
|
|
1030
1030
|
...a,
|
|
1031
|
-
authorization_url: (
|
|
1031
|
+
authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
|
|
1032
1032
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1033
1033
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1034
1034
|
};
|
|
@@ -1052,7 +1052,7 @@ function pa(t) {
|
|
|
1052
1052
|
function ga(t) {
|
|
1053
1053
|
return async (e) => {
|
|
1054
1054
|
const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
|
|
1055
|
-
return
|
|
1055
|
+
return f({
|
|
1056
1056
|
identifier_first: !!(a != null && a.identifier_first),
|
|
1057
1057
|
password_first: !!(a != null && a.password_first),
|
|
1058
1058
|
webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
|
|
@@ -1061,7 +1061,7 @@ function ga(t) {
|
|
|
1061
1061
|
};
|
|
1062
1062
|
}
|
|
1063
1063
|
function _e(t) {
|
|
1064
|
-
return
|
|
1064
|
+
return f({
|
|
1065
1065
|
...t,
|
|
1066
1066
|
webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
|
|
1067
1067
|
identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
|
|
@@ -1095,38 +1095,38 @@ function va(t) {
|
|
|
1095
1095
|
return null;
|
|
1096
1096
|
const {
|
|
1097
1097
|
tenant_id: r,
|
|
1098
|
-
credentials:
|
|
1099
|
-
settings:
|
|
1098
|
+
credentials: n,
|
|
1099
|
+
settings: o,
|
|
1100
1100
|
enabled: s,
|
|
1101
|
-
...
|
|
1101
|
+
...c
|
|
1102
1102
|
} = a;
|
|
1103
|
-
return
|
|
1104
|
-
...
|
|
1105
|
-
credentials: JSON.parse(
|
|
1106
|
-
settings: JSON.parse(
|
|
1103
|
+
return f({
|
|
1104
|
+
...c,
|
|
1105
|
+
credentials: JSON.parse(n),
|
|
1106
|
+
settings: JSON.parse(o),
|
|
1107
1107
|
enabled: !!s
|
|
1108
1108
|
});
|
|
1109
1109
|
};
|
|
1110
1110
|
}
|
|
1111
1111
|
function Na(t) {
|
|
1112
1112
|
return async (e, a) => {
|
|
1113
|
-
const { credentials: r, settings:
|
|
1113
|
+
const { credentials: r, settings: n, enabled: o, ...s } = a;
|
|
1114
1114
|
await t.updateTable("email_providers").set({
|
|
1115
1115
|
...s,
|
|
1116
1116
|
credentials: r ? JSON.stringify(r) : void 0,
|
|
1117
|
-
settings:
|
|
1118
|
-
enabled:
|
|
1117
|
+
settings: n ? JSON.stringify(n) : void 0,
|
|
1118
|
+
enabled: o !== void 0 ? o ? 1 : 0 : void 0
|
|
1119
1119
|
}).where("tenant_id", "=", e).execute();
|
|
1120
1120
|
};
|
|
1121
1121
|
}
|
|
1122
1122
|
function Ca(t) {
|
|
1123
1123
|
return async (e, a) => {
|
|
1124
|
-
const { credentials: r, settings:
|
|
1124
|
+
const { credentials: r, settings: n, enabled: o, ...s } = a;
|
|
1125
1125
|
await t.insertInto("email_providers").values({
|
|
1126
1126
|
...s,
|
|
1127
|
-
enabled:
|
|
1127
|
+
enabled: o ? 1 : 0,
|
|
1128
1128
|
credentials: JSON.stringify(r),
|
|
1129
|
-
settings: JSON.stringify(
|
|
1129
|
+
settings: JSON.stringify(n),
|
|
1130
1130
|
tenant_id: e,
|
|
1131
1131
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1132
1132
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1171,13 +1171,13 @@ function Sa(t) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
function Oa(t) {
|
|
1173
1173
|
return async (e, a, r) => {
|
|
1174
|
-
const
|
|
1174
|
+
const n = {
|
|
1175
1175
|
...r,
|
|
1176
1176
|
device: r.device ? JSON.stringify(r.device) : void 0,
|
|
1177
1177
|
resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
|
|
1178
1178
|
rotating: r.rotating ? 1 : 0
|
|
1179
1179
|
};
|
|
1180
|
-
return !!(await t.updateTable("refresh_tokens").set(
|
|
1180
|
+
return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
|
|
1181
1181
|
};
|
|
1182
1182
|
}
|
|
1183
1183
|
function ka(t) {
|
|
@@ -1188,26 +1188,26 @@ function ka(t) {
|
|
|
1188
1188
|
}) => {
|
|
1189
1189
|
let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
|
|
1190
1190
|
a.q && (r = T(t, r, a.q, ["token", "session_id"]));
|
|
1191
|
-
let
|
|
1191
|
+
let n = r;
|
|
1192
1192
|
if (a.sort && a.sort.sort_by) {
|
|
1193
|
-
const { ref:
|
|
1194
|
-
|
|
1195
|
-
|
|
1193
|
+
const { ref: d } = t.dynamic;
|
|
1194
|
+
n = n.orderBy(
|
|
1195
|
+
d(a.sort.sort_by),
|
|
1196
1196
|
a.sort.sort_order
|
|
1197
1197
|
);
|
|
1198
1198
|
}
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
return {
|
|
1202
|
-
refresh_tokens:
|
|
1203
|
-
...
|
|
1204
|
-
rotating: !!
|
|
1205
|
-
device:
|
|
1206
|
-
resource_servers:
|
|
1199
|
+
n = n.offset(a.page * a.per_page).limit(a.per_page);
|
|
1200
|
+
const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
1201
|
+
return {
|
|
1202
|
+
refresh_tokens: o.map((d) => ({
|
|
1203
|
+
...d,
|
|
1204
|
+
rotating: !!d.rotating,
|
|
1205
|
+
device: d.device ? JSON.parse(d.device) : {},
|
|
1206
|
+
resource_servers: d.resource_servers ? JSON.parse(d.resource_servers) : []
|
|
1207
1207
|
})),
|
|
1208
1208
|
start: a.page * a.per_page,
|
|
1209
1209
|
limit: a.per_page,
|
|
1210
|
-
length:
|
|
1210
|
+
length: c
|
|
1211
1211
|
};
|
|
1212
1212
|
};
|
|
1213
1213
|
}
|
|
@@ -1228,20 +1228,20 @@ function Da(t) {
|
|
|
1228
1228
|
Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
|
|
1229
1229
|
).toISOString();
|
|
1230
1230
|
console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", r).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where("expires_at", "<", a).limit(1e5).execute(), console.log("delete sessions");
|
|
1231
|
-
const
|
|
1232
|
-
(
|
|
1233
|
-
|
|
1234
|
-
|
|
1231
|
+
const n = await t.selectFrom("sessions").select("id").where(
|
|
1232
|
+
(o) => o.or([
|
|
1233
|
+
o("expires_at", "<", a),
|
|
1234
|
+
o("idle_expires_at", "<", a)
|
|
1235
1235
|
])
|
|
1236
1236
|
).where(
|
|
1237
1237
|
"id",
|
|
1238
1238
|
"not in",
|
|
1239
1239
|
t.selectFrom("refresh_tokens").select("session_id")
|
|
1240
1240
|
).limit(1e5).execute();
|
|
1241
|
-
|
|
1241
|
+
n.length > 0 && await t.deleteFrom("sessions").where(
|
|
1242
1242
|
"id",
|
|
1243
1243
|
"in",
|
|
1244
|
-
|
|
1244
|
+
n.map((o) => o.id)
|
|
1245
1245
|
).execute(), console.log("cleanup complete");
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
@@ -1256,11 +1256,10 @@ function Ia(t) {
|
|
|
1256
1256
|
return await t.insertInto("forms").values({
|
|
1257
1257
|
...r,
|
|
1258
1258
|
// Store complex objects as JSON strings
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
tenant_id: e
|
|
1263
|
-
active: r.active ? 1 : 0
|
|
1259
|
+
nodes: JSON.stringify(r.nodes || []),
|
|
1260
|
+
start: JSON.stringify(r.start || {}),
|
|
1261
|
+
ending: JSON.stringify(r.ending || {}),
|
|
1262
|
+
tenant_id: e
|
|
1264
1263
|
}).execute(), K.parse(r);
|
|
1265
1264
|
};
|
|
1266
1265
|
}
|
|
@@ -1272,22 +1271,30 @@ function Pa(t) {
|
|
|
1272
1271
|
}) => {
|
|
1273
1272
|
let r = t.selectFrom("forms").where("tenant_id", "=", e);
|
|
1274
1273
|
a != null && a.q && (r = T(t, r, a.q, []));
|
|
1275
|
-
const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1274
|
+
const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((d) => {
|
|
1275
|
+
const h = { ...d };
|
|
1276
|
+
if (typeof h.nodes == "string")
|
|
1277
|
+
try {
|
|
1278
|
+
h.nodes = JSON.parse(h.nodes);
|
|
1279
|
+
} catch {
|
|
1280
|
+
}
|
|
1281
|
+
if (typeof h.start == "string")
|
|
1282
|
+
try {
|
|
1283
|
+
h.start = JSON.parse(h.start);
|
|
1284
|
+
} catch {
|
|
1285
|
+
}
|
|
1286
|
+
if (typeof h.ending == "string")
|
|
1287
|
+
try {
|
|
1288
|
+
h.ending = JSON.parse(h.ending);
|
|
1289
|
+
} catch {
|
|
1290
|
+
}
|
|
1291
|
+
return K.parse(f(h));
|
|
1292
|
+
}), { count: c } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1286
1293
|
return {
|
|
1287
1294
|
forms: s,
|
|
1288
1295
|
start: a.page * a.per_page,
|
|
1289
1296
|
limit: a.per_page,
|
|
1290
|
-
length: b(
|
|
1297
|
+
length: b(c)
|
|
1291
1298
|
};
|
|
1292
1299
|
};
|
|
1293
1300
|
}
|
|
@@ -1300,26 +1307,35 @@ function ja(t) {
|
|
|
1300
1307
|
function Ma(t) {
|
|
1301
1308
|
return async (e, a) => {
|
|
1302
1309
|
const r = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1310
|
+
if (!r) return null;
|
|
1311
|
+
const n = { ...r };
|
|
1312
|
+
if (typeof n.nodes == "string")
|
|
1313
|
+
try {
|
|
1314
|
+
n.nodes = JSON.parse(n.nodes);
|
|
1315
|
+
} catch {
|
|
1316
|
+
}
|
|
1317
|
+
if (typeof n.start == "string")
|
|
1318
|
+
try {
|
|
1319
|
+
n.start = JSON.parse(n.start);
|
|
1320
|
+
} catch {
|
|
1321
|
+
}
|
|
1322
|
+
if (typeof n.ending == "string")
|
|
1323
|
+
try {
|
|
1324
|
+
n.ending = JSON.parse(n.ending);
|
|
1325
|
+
} catch {
|
|
1326
|
+
}
|
|
1327
|
+
return K.parse(f(n));
|
|
1312
1328
|
};
|
|
1313
1329
|
}
|
|
1314
1330
|
function Fa(t) {
|
|
1315
1331
|
return async (e, a, r) => {
|
|
1316
|
-
const
|
|
1332
|
+
const n = {
|
|
1317
1333
|
...r,
|
|
1318
1334
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1319
1335
|
};
|
|
1320
|
-
r.
|
|
1321
|
-
const { numUpdatedRows:
|
|
1322
|
-
return
|
|
1336
|
+
r.nodes && (n.fields = JSON.stringify(r.nodes)), r.start && (n.controls = JSON.stringify(r.start)), r.ending && (n.layout = JSON.stringify(r.ending));
|
|
1337
|
+
const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
|
|
1338
|
+
return o > 0;
|
|
1323
1339
|
};
|
|
1324
1340
|
}
|
|
1325
1341
|
function Aa(t) {
|
|
@@ -1334,59 +1350,59 @@ function Aa(t) {
|
|
|
1334
1350
|
function La(t) {
|
|
1335
1351
|
return t[t.length - 1];
|
|
1336
1352
|
}
|
|
1337
|
-
function
|
|
1353
|
+
function g(t) {
|
|
1338
1354
|
return Object.freeze(t);
|
|
1339
1355
|
}
|
|
1340
|
-
const E =
|
|
1356
|
+
const E = g({
|
|
1341
1357
|
is(t) {
|
|
1342
1358
|
return t.kind === "IdentifierNode";
|
|
1343
1359
|
},
|
|
1344
1360
|
create(t) {
|
|
1345
|
-
return
|
|
1361
|
+
return g({
|
|
1346
1362
|
kind: "IdentifierNode",
|
|
1347
1363
|
name: t
|
|
1348
1364
|
});
|
|
1349
1365
|
}
|
|
1350
|
-
}), W =
|
|
1366
|
+
}), W = g({
|
|
1351
1367
|
is(t) {
|
|
1352
1368
|
return t.kind === "SchemableIdentifierNode";
|
|
1353
1369
|
},
|
|
1354
1370
|
create(t) {
|
|
1355
|
-
return
|
|
1371
|
+
return g({
|
|
1356
1372
|
kind: "SchemableIdentifierNode",
|
|
1357
1373
|
identifier: E.create(t)
|
|
1358
1374
|
});
|
|
1359
1375
|
},
|
|
1360
1376
|
createWithSchema(t, e) {
|
|
1361
|
-
return
|
|
1377
|
+
return g({
|
|
1362
1378
|
kind: "SchemableIdentifierNode",
|
|
1363
1379
|
schema: E.create(t),
|
|
1364
1380
|
identifier: E.create(e)
|
|
1365
1381
|
});
|
|
1366
1382
|
}
|
|
1367
|
-
}), za =
|
|
1383
|
+
}), za = g({
|
|
1368
1384
|
is(t) {
|
|
1369
1385
|
return t.kind === "AliasNode";
|
|
1370
1386
|
},
|
|
1371
1387
|
create(t, e) {
|
|
1372
|
-
return
|
|
1388
|
+
return g({
|
|
1373
1389
|
kind: "AliasNode",
|
|
1374
1390
|
node: t,
|
|
1375
1391
|
alias: e
|
|
1376
1392
|
});
|
|
1377
1393
|
}
|
|
1378
|
-
}), B =
|
|
1394
|
+
}), B = g({
|
|
1379
1395
|
is(t) {
|
|
1380
1396
|
return t.kind === "TableNode";
|
|
1381
1397
|
},
|
|
1382
1398
|
create(t) {
|
|
1383
|
-
return
|
|
1399
|
+
return g({
|
|
1384
1400
|
kind: "TableNode",
|
|
1385
1401
|
table: W.create(t)
|
|
1386
1402
|
});
|
|
1387
1403
|
},
|
|
1388
1404
|
createWithSchema(t, e) {
|
|
1389
|
-
return
|
|
1405
|
+
return g({
|
|
1390
1406
|
kind: "TableNode",
|
|
1391
1407
|
table: W.createWithSchema(t, e)
|
|
1392
1408
|
});
|
|
@@ -1396,7 +1412,7 @@ var R;
|
|
|
1396
1412
|
class Ja {
|
|
1397
1413
|
constructor() {
|
|
1398
1414
|
j(this, "nodeStack", []);
|
|
1399
|
-
y(this, R,
|
|
1415
|
+
y(this, R, g({
|
|
1400
1416
|
AliasNode: this.transformAlias.bind(this),
|
|
1401
1417
|
ColumnNode: this.transformColumn.bind(this),
|
|
1402
1418
|
IdentifierNode: this.transformIdentifier.bind(this),
|
|
@@ -1497,13 +1513,13 @@ class Ja {
|
|
|
1497
1513
|
return e;
|
|
1498
1514
|
this.nodeStack.push(e);
|
|
1499
1515
|
const a = this.transformNodeImpl(e);
|
|
1500
|
-
return this.nodeStack.pop(),
|
|
1516
|
+
return this.nodeStack.pop(), g(a);
|
|
1501
1517
|
}
|
|
1502
1518
|
transformNodeImpl(e) {
|
|
1503
|
-
return
|
|
1519
|
+
return l(this, R)[e.kind](e);
|
|
1504
1520
|
}
|
|
1505
1521
|
transformNodeList(e) {
|
|
1506
|
-
return e &&
|
|
1522
|
+
return e && g(e.map((a) => this.transformNode(a)));
|
|
1507
1523
|
}
|
|
1508
1524
|
transformSelectQuery(e) {
|
|
1509
1525
|
return {
|
|
@@ -1602,7 +1618,7 @@ class Ja {
|
|
|
1602
1618
|
transformRaw(e) {
|
|
1603
1619
|
return {
|
|
1604
1620
|
kind: "RawNode",
|
|
1605
|
-
sqlFragments:
|
|
1621
|
+
sqlFragments: g([...e.sqlFragments]),
|
|
1606
1622
|
parameters: this.transformNodeList(e.parameters)
|
|
1607
1623
|
};
|
|
1608
1624
|
}
|
|
@@ -2227,7 +2243,7 @@ class Ja {
|
|
|
2227
2243
|
}
|
|
2228
2244
|
}
|
|
2229
2245
|
R = new WeakMap();
|
|
2230
|
-
const Ea =
|
|
2246
|
+
const Ea = g({
|
|
2231
2247
|
AlterTableNode: !0,
|
|
2232
2248
|
CreateIndexNode: !0,
|
|
2233
2249
|
CreateSchemaNode: !0,
|
|
@@ -2246,71 +2262,71 @@ const Ea = p({
|
|
|
2246
2262
|
UpdateQueryNode: !0,
|
|
2247
2263
|
MergeQueryNode: !0
|
|
2248
2264
|
});
|
|
2249
|
-
var P, O, k,
|
|
2265
|
+
var P, O, k, p, ye, we, ve, $, G, Ne;
|
|
2250
2266
|
class Ka extends Ja {
|
|
2251
2267
|
constructor(a) {
|
|
2252
2268
|
super();
|
|
2253
|
-
y(this,
|
|
2269
|
+
y(this, p);
|
|
2254
2270
|
y(this, P);
|
|
2255
2271
|
y(this, O, /* @__PURE__ */ new Set());
|
|
2256
2272
|
y(this, k, /* @__PURE__ */ new Set());
|
|
2257
2273
|
M(this, P, a);
|
|
2258
2274
|
}
|
|
2259
2275
|
transformNodeImpl(a) {
|
|
2260
|
-
if (!u(this,
|
|
2276
|
+
if (!u(this, p, ye).call(this, a))
|
|
2261
2277
|
return super.transformNodeImpl(a);
|
|
2262
|
-
const r = u(this,
|
|
2278
|
+
const r = u(this, p, ve).call(this, a);
|
|
2263
2279
|
for (const s of r)
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
for (const s of
|
|
2267
|
-
|
|
2268
|
-
const
|
|
2269
|
-
for (const s of
|
|
2270
|
-
|
|
2280
|
+
l(this, k).add(s);
|
|
2281
|
+
const n = u(this, p, we).call(this, a);
|
|
2282
|
+
for (const s of n)
|
|
2283
|
+
l(this, O).add(s);
|
|
2284
|
+
const o = super.transformNodeImpl(a);
|
|
2285
|
+
for (const s of n)
|
|
2286
|
+
l(this, O).delete(s);
|
|
2271
2287
|
for (const s of r)
|
|
2272
|
-
|
|
2273
|
-
return
|
|
2288
|
+
l(this, k).delete(s);
|
|
2289
|
+
return o;
|
|
2274
2290
|
}
|
|
2275
2291
|
transformSchemableIdentifier(a) {
|
|
2276
2292
|
const r = super.transformSchemableIdentifier(a);
|
|
2277
|
-
return r.schema || !
|
|
2293
|
+
return r.schema || !l(this, O).has(a.identifier.name) ? r : {
|
|
2278
2294
|
...r,
|
|
2279
|
-
schema: E.create(
|
|
2295
|
+
schema: E.create(l(this, P))
|
|
2280
2296
|
};
|
|
2281
2297
|
}
|
|
2282
2298
|
transformReferences(a) {
|
|
2283
2299
|
const r = super.transformReferences(a);
|
|
2284
2300
|
return r.table.table.schema ? r : {
|
|
2285
2301
|
...r,
|
|
2286
|
-
table: B.createWithSchema(
|
|
2302
|
+
table: B.createWithSchema(l(this, P), r.table.table.identifier.name)
|
|
2287
2303
|
};
|
|
2288
2304
|
}
|
|
2289
2305
|
}
|
|
2290
|
-
P = new WeakMap(), O = new WeakMap(), k = new WeakMap(),
|
|
2306
|
+
P = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye = function(a) {
|
|
2291
2307
|
return a.kind in Ea;
|
|
2292
2308
|
}, we = function(a) {
|
|
2293
2309
|
const r = /* @__PURE__ */ new Set();
|
|
2294
|
-
if ("name" in a && a.name && W.is(a.name) && u(this,
|
|
2295
|
-
for (const
|
|
2296
|
-
u(this,
|
|
2297
|
-
if ("into" in a && a.into && u(this,
|
|
2298
|
-
for (const
|
|
2299
|
-
u(this,
|
|
2300
|
-
return "using" in a && a.using && u(this,
|
|
2310
|
+
if ("name" in a && a.name && W.is(a.name) && u(this, p, G).call(this, a.name, r), "from" in a && a.from)
|
|
2311
|
+
for (const n of a.from.froms)
|
|
2312
|
+
u(this, p, $).call(this, n, r);
|
|
2313
|
+
if ("into" in a && a.into && u(this, p, $).call(this, a.into, r), "table" in a && a.table && u(this, p, $).call(this, a.table, r), "joins" in a && a.joins)
|
|
2314
|
+
for (const n of a.joins)
|
|
2315
|
+
u(this, p, $).call(this, n.table, r);
|
|
2316
|
+
return "using" in a && a.using && u(this, p, $).call(this, a.using, r), r;
|
|
2301
2317
|
}, ve = function(a) {
|
|
2302
2318
|
const r = /* @__PURE__ */ new Set();
|
|
2303
|
-
return "with" in a && a.with && u(this,
|
|
2319
|
+
return "with" in a && a.with && u(this, p, Ne).call(this, a.with, r), r;
|
|
2304
2320
|
}, $ = function(a, r) {
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2321
|
+
const n = B.is(a) ? a : za.is(a) && B.is(a.node) ? a.node : null;
|
|
2322
|
+
n && u(this, p, G).call(this, n.table, r);
|
|
2307
2323
|
}, G = function(a, r) {
|
|
2308
|
-
const
|
|
2309
|
-
!
|
|
2324
|
+
const n = a.identifier.name;
|
|
2325
|
+
!l(this, O).has(n) && !l(this, k).has(n) && r.add(n);
|
|
2310
2326
|
}, Ne = function(a, r) {
|
|
2311
|
-
for (const
|
|
2312
|
-
const
|
|
2313
|
-
|
|
2327
|
+
for (const n of a.expressions) {
|
|
2328
|
+
const o = n.name.table.table.identifier.name;
|
|
2329
|
+
l(this, k).has(o) || r.add(o);
|
|
2314
2330
|
}
|
|
2315
2331
|
};
|
|
2316
2332
|
var L;
|
|
@@ -2320,7 +2336,7 @@ class Ra {
|
|
|
2320
2336
|
M(this, L, new Ka(e));
|
|
2321
2337
|
}
|
|
2322
2338
|
transformQuery(e) {
|
|
2323
|
-
return
|
|
2339
|
+
return l(this, L).transformNode(e.node);
|
|
2324
2340
|
}
|
|
2325
2341
|
async transformResult(e) {
|
|
2326
2342
|
return e.result;
|
|
@@ -2335,13 +2351,13 @@ class Ua {
|
|
|
2335
2351
|
return e.result;
|
|
2336
2352
|
}
|
|
2337
2353
|
}
|
|
2338
|
-
const Ba = "kysely_migration", fe = "kysely_migration_lock", Qa = !1, Q = "migration_lock", qa =
|
|
2339
|
-
var
|
|
2354
|
+
const Ba = "kysely_migration", fe = "kysely_migration_lock", Qa = !1, Q = "migration_lock", qa = g({ __noMigrations__: !0 });
|
|
2355
|
+
var _, i, F, v, N, D, be, C, xe, Te, Se, Oe, ke, H, I, X, $e, De, Ie, Y, Pe, je, Me, Fe, Ae, A;
|
|
2340
2356
|
class Ce {
|
|
2341
2357
|
constructor(e) {
|
|
2342
2358
|
y(this, i);
|
|
2343
|
-
y(this,
|
|
2344
|
-
M(this,
|
|
2359
|
+
y(this, _);
|
|
2360
|
+
M(this, _, g(e));
|
|
2345
2361
|
}
|
|
2346
2362
|
/**
|
|
2347
2363
|
* Returns a {@link MigrationInfo} object for each migration.
|
|
@@ -2349,13 +2365,13 @@ class Ce {
|
|
|
2349
2365
|
* The returned array is sorted by migration name.
|
|
2350
2366
|
*/
|
|
2351
2367
|
async getMigrations() {
|
|
2352
|
-
const e = await u(this, i, I).call(this,
|
|
2353
|
-
return (await u(this, i, Y).call(this)).map(({ name: r, ...
|
|
2354
|
-
const
|
|
2368
|
+
const e = await u(this, i, I).call(this, l(this, i, N)) ? await l(this, _).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, N)).select(["name", "timestamp"]).execute() : [];
|
|
2369
|
+
return (await u(this, i, Y).call(this)).map(({ name: r, ...n }) => {
|
|
2370
|
+
const o = e.find((s) => s.name === r);
|
|
2355
2371
|
return {
|
|
2356
2372
|
name: r,
|
|
2357
|
-
migration:
|
|
2358
|
-
executedAt:
|
|
2373
|
+
migration: n,
|
|
2374
|
+
executedAt: o ? new Date(o.timestamp) : void 0
|
|
2359
2375
|
};
|
|
2360
2376
|
});
|
|
2361
2377
|
}
|
|
@@ -2433,16 +2449,16 @@ class Ce {
|
|
|
2433
2449
|
* ```
|
|
2434
2450
|
*/
|
|
2435
2451
|
async migrateTo(e) {
|
|
2436
|
-
return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations:
|
|
2452
|
+
return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
|
|
2437
2453
|
if (e === qa)
|
|
2438
2454
|
return { direction: "Down", step: 1 / 0 };
|
|
2439
|
-
if (!a.find((
|
|
2455
|
+
if (!a.find((c) => c.name === e))
|
|
2440
2456
|
throw new Error(`migration "${e}" doesn't exist`);
|
|
2441
|
-
const
|
|
2442
|
-
if (
|
|
2457
|
+
const o = r.indexOf(e), s = n.findIndex((c) => c.name === e);
|
|
2458
|
+
if (o !== -1)
|
|
2443
2459
|
return {
|
|
2444
2460
|
direction: "Down",
|
|
2445
|
-
step: r.length -
|
|
2461
|
+
step: r.length - o - 1
|
|
2446
2462
|
};
|
|
2447
2463
|
if (s !== -1)
|
|
2448
2464
|
return { direction: "Up", step: s + 1 };
|
|
@@ -2484,168 +2500,168 @@ class Ce {
|
|
|
2484
2500
|
return u(this, i, F).call(this, () => ({ direction: "Down", step: 1 }));
|
|
2485
2501
|
}
|
|
2486
2502
|
}
|
|
2487
|
-
|
|
2503
|
+
_ = new WeakMap(), i = new WeakSet(), F = async function(e) {
|
|
2488
2504
|
try {
|
|
2489
2505
|
return await u(this, i, xe).call(this), await u(this, i, $e).call(this, e);
|
|
2490
2506
|
} catch (a) {
|
|
2491
2507
|
return a instanceof q ? a.resultSet : { error: a };
|
|
2492
2508
|
}
|
|
2493
2509
|
}, v = function() {
|
|
2494
|
-
return
|
|
2510
|
+
return l(this, _).migrationTableSchema;
|
|
2495
2511
|
}, N = function() {
|
|
2496
|
-
return
|
|
2512
|
+
return l(this, _).migrationTableName ?? Ba;
|
|
2497
2513
|
}, D = function() {
|
|
2498
|
-
return
|
|
2514
|
+
return l(this, _).migrationLockTableName ?? fe;
|
|
2499
2515
|
}, be = function() {
|
|
2500
|
-
return
|
|
2516
|
+
return l(this, _).allowUnorderedMigrations ?? Qa;
|
|
2501
2517
|
}, C = function() {
|
|
2502
|
-
return
|
|
2518
|
+
return l(this, i, v) ? new Ra(l(this, i, v)) : new Ua();
|
|
2503
2519
|
}, xe = async function() {
|
|
2504
2520
|
await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this), await u(this, i, ke).call(this);
|
|
2505
2521
|
}, Te = async function() {
|
|
2506
|
-
if (
|
|
2522
|
+
if (l(this, i, v) && !await u(this, i, H).call(this))
|
|
2507
2523
|
try {
|
|
2508
|
-
await u(this, i, A).call(this,
|
|
2524
|
+
await u(this, i, A).call(this, l(this, _).db.schema.createSchema(l(this, i, v)));
|
|
2509
2525
|
} catch (e) {
|
|
2510
2526
|
if (!await u(this, i, H).call(this))
|
|
2511
2527
|
throw e;
|
|
2512
2528
|
}
|
|
2513
2529
|
}, Se = async function() {
|
|
2514
|
-
if (!await u(this, i, I).call(this,
|
|
2530
|
+
if (!await u(this, i, I).call(this, l(this, i, N)))
|
|
2515
2531
|
try {
|
|
2516
|
-
|
|
2532
|
+
l(this, i, v) && await u(this, i, A).call(this, l(this, _).db.schema.createSchema(l(this, i, v))), await u(this, i, A).call(this, l(this, _).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, N)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
|
|
2517
2533
|
} catch (e) {
|
|
2518
|
-
if (!await u(this, i, I).call(this,
|
|
2534
|
+
if (!await u(this, i, I).call(this, l(this, i, N)))
|
|
2519
2535
|
throw e;
|
|
2520
2536
|
}
|
|
2521
2537
|
}, Oe = async function() {
|
|
2522
|
-
if (!await u(this, i, I).call(this,
|
|
2538
|
+
if (!await u(this, i, I).call(this, l(this, i, D)))
|
|
2523
2539
|
try {
|
|
2524
|
-
await u(this, i, A).call(this,
|
|
2540
|
+
await u(this, i, A).call(this, l(this, _).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
|
|
2525
2541
|
} catch (e) {
|
|
2526
|
-
if (!await u(this, i, I).call(this,
|
|
2542
|
+
if (!await u(this, i, I).call(this, l(this, i, D)))
|
|
2527
2543
|
throw e;
|
|
2528
2544
|
}
|
|
2529
2545
|
}, ke = async function() {
|
|
2530
2546
|
if (!await u(this, i, X).call(this))
|
|
2531
2547
|
try {
|
|
2532
|
-
await
|
|
2548
|
+
await l(this, _).db.withPlugin(l(this, i, C)).insertInto(l(this, i, D)).values({ id: Q, is_locked: 0 }).execute();
|
|
2533
2549
|
} catch (e) {
|
|
2534
2550
|
if (!await u(this, i, X).call(this))
|
|
2535
2551
|
throw e;
|
|
2536
2552
|
}
|
|
2537
2553
|
}, H = async function() {
|
|
2538
|
-
return (await
|
|
2554
|
+
return (await l(this, _).db.introspection.getSchemas()).some((a) => a.name === l(this, i, v));
|
|
2539
2555
|
}, I = async function(e) {
|
|
2540
|
-
const a =
|
|
2541
|
-
return (await
|
|
2556
|
+
const a = l(this, i, v);
|
|
2557
|
+
return (await l(this, _).db.introspection.getTables({
|
|
2542
2558
|
withInternalKyselyTables: !0
|
|
2543
|
-
})).some((
|
|
2559
|
+
})).some((n) => n.name === e && (!a || n.schema === a));
|
|
2544
2560
|
}, X = async function() {
|
|
2545
|
-
return !!await
|
|
2561
|
+
return !!await l(this, _).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, D)).where("id", "=", Q).select("id").executeTakeFirst();
|
|
2546
2562
|
}, $e = async function(e) {
|
|
2547
|
-
const a =
|
|
2548
|
-
lockTable:
|
|
2563
|
+
const a = l(this, _).db.getExecutor().adapter, r = g({
|
|
2564
|
+
lockTable: l(this, _).migrationLockTableName ?? fe,
|
|
2549
2565
|
lockRowId: Q,
|
|
2550
|
-
lockTableSchema:
|
|
2551
|
-
}),
|
|
2566
|
+
lockTableSchema: l(this, _).migrationTableSchema
|
|
2567
|
+
}), n = async (o) => {
|
|
2552
2568
|
try {
|
|
2553
|
-
await a.acquireMigrationLock(
|
|
2554
|
-
const s = await u(this, i, De).call(this,
|
|
2569
|
+
await a.acquireMigrationLock(o, r);
|
|
2570
|
+
const s = await u(this, i, De).call(this, o);
|
|
2555
2571
|
if (s.migrations.length === 0)
|
|
2556
2572
|
return { results: [] };
|
|
2557
|
-
const { direction:
|
|
2558
|
-
return
|
|
2573
|
+
const { direction: c, step: d } = e(s);
|
|
2574
|
+
return d <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Fe).call(this, o, s, d) : c === "Up" ? await u(this, i, Ae).call(this, o, s, d) : { results: [] };
|
|
2559
2575
|
} finally {
|
|
2560
|
-
await a.releaseMigrationLock(
|
|
2576
|
+
await a.releaseMigrationLock(o, r);
|
|
2561
2577
|
}
|
|
2562
2578
|
};
|
|
2563
|
-
return a.supportsTransactionalDdl ?
|
|
2579
|
+
return a.supportsTransactionalDdl ? l(this, _).db.transaction().execute(n) : l(this, _).db.connection().execute(n);
|
|
2564
2580
|
}, De = async function(e) {
|
|
2565
2581
|
const a = await u(this, i, Y).call(this), r = await u(this, i, Pe).call(this, e);
|
|
2566
|
-
u(this, i, je).call(this, a, r),
|
|
2567
|
-
const
|
|
2568
|
-
return
|
|
2582
|
+
u(this, i, je).call(this, a, r), l(this, i, be) || u(this, i, Me).call(this, a, r);
|
|
2583
|
+
const n = u(this, i, Ie).call(this, a, r);
|
|
2584
|
+
return g({
|
|
2569
2585
|
migrations: a,
|
|
2570
2586
|
executedMigrations: r,
|
|
2571
2587
|
lastMigration: La(r),
|
|
2572
|
-
pendingMigrations:
|
|
2588
|
+
pendingMigrations: n
|
|
2573
2589
|
});
|
|
2574
2590
|
}, Ie = function(e, a) {
|
|
2575
2591
|
return e.filter((r) => !a.includes(r.name));
|
|
2576
2592
|
}, Y = async function() {
|
|
2577
|
-
const e = await
|
|
2593
|
+
const e = await l(this, _).provider.getMigrations();
|
|
2578
2594
|
return Object.keys(e).sort().map((a) => ({
|
|
2579
2595
|
...e[a],
|
|
2580
2596
|
name: a
|
|
2581
2597
|
}));
|
|
2582
2598
|
}, Pe = async function(e) {
|
|
2583
|
-
return (await e.withPlugin(
|
|
2599
|
+
return (await e.withPlugin(l(this, i, C)).selectFrom(l(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
|
|
2584
2600
|
}, je = function(e, a) {
|
|
2585
2601
|
for (const r of a)
|
|
2586
|
-
if (!e.some((
|
|
2602
|
+
if (!e.some((n) => n.name === r))
|
|
2587
2603
|
throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
|
|
2588
2604
|
}, Me = function(e, a) {
|
|
2589
2605
|
for (let r = 0; r < a.length; ++r)
|
|
2590
2606
|
if (e[r].name !== a[r])
|
|
2591
2607
|
throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
|
|
2592
2608
|
}, Fe = async function(e, a, r) {
|
|
2593
|
-
const
|
|
2609
|
+
const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((c) => c.name === s)), o = n.map((s) => ({
|
|
2594
2610
|
migrationName: s.name,
|
|
2595
2611
|
direction: "Down",
|
|
2596
2612
|
status: "NotExecuted"
|
|
2597
2613
|
}));
|
|
2598
|
-
for (let s = 0; s <
|
|
2599
|
-
const
|
|
2614
|
+
for (let s = 0; s < o.length; ++s) {
|
|
2615
|
+
const c = n[s];
|
|
2600
2616
|
try {
|
|
2601
|
-
|
|
2602
|
-
migrationName:
|
|
2617
|
+
c.down && (await c.down(e), await e.withPlugin(l(this, i, C)).deleteFrom(l(this, i, N)).where("name", "=", c.name).execute(), o[s] = {
|
|
2618
|
+
migrationName: c.name,
|
|
2603
2619
|
direction: "Down",
|
|
2604
2620
|
status: "Success"
|
|
2605
2621
|
});
|
|
2606
|
-
} catch (
|
|
2607
|
-
throw
|
|
2608
|
-
migrationName:
|
|
2622
|
+
} catch (d) {
|
|
2623
|
+
throw o[s] = {
|
|
2624
|
+
migrationName: c.name,
|
|
2609
2625
|
direction: "Down",
|
|
2610
2626
|
status: "Error"
|
|
2611
2627
|
}, new q({
|
|
2612
|
-
error:
|
|
2613
|
-
results:
|
|
2628
|
+
error: d,
|
|
2629
|
+
results: o
|
|
2614
2630
|
});
|
|
2615
2631
|
}
|
|
2616
2632
|
}
|
|
2617
|
-
return { results:
|
|
2633
|
+
return { results: o };
|
|
2618
2634
|
}, Ae = async function(e, a, r) {
|
|
2619
|
-
const
|
|
2635
|
+
const o = a.pendingMigrations.slice(0, r).map((s) => ({
|
|
2620
2636
|
migrationName: s.name,
|
|
2621
2637
|
direction: "Up",
|
|
2622
2638
|
status: "NotExecuted"
|
|
2623
2639
|
}));
|
|
2624
|
-
for (let s = 0; s <
|
|
2625
|
-
const
|
|
2640
|
+
for (let s = 0; s < o.length; s++) {
|
|
2641
|
+
const c = a.pendingMigrations[s];
|
|
2626
2642
|
try {
|
|
2627
|
-
await
|
|
2628
|
-
name:
|
|
2643
|
+
await c.up(e), await e.withPlugin(l(this, i, C)).insertInto(l(this, i, N)).values({
|
|
2644
|
+
name: c.name,
|
|
2629
2645
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2630
|
-
}).execute(),
|
|
2631
|
-
migrationName:
|
|
2646
|
+
}).execute(), o[s] = {
|
|
2647
|
+
migrationName: c.name,
|
|
2632
2648
|
direction: "Up",
|
|
2633
2649
|
status: "Success"
|
|
2634
2650
|
};
|
|
2635
|
-
} catch (
|
|
2636
|
-
throw
|
|
2637
|
-
migrationName:
|
|
2651
|
+
} catch (d) {
|
|
2652
|
+
throw o[s] = {
|
|
2653
|
+
migrationName: c.name,
|
|
2638
2654
|
direction: "Up",
|
|
2639
2655
|
status: "Error"
|
|
2640
2656
|
}, new q({
|
|
2641
|
-
error:
|
|
2642
|
-
results:
|
|
2657
|
+
error: d,
|
|
2658
|
+
results: o
|
|
2643
2659
|
});
|
|
2644
2660
|
}
|
|
2645
2661
|
}
|
|
2646
|
-
return { results:
|
|
2662
|
+
return { results: o };
|
|
2647
2663
|
}, A = async function(e) {
|
|
2648
|
-
|
|
2664
|
+
l(this, _).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
|
|
2649
2665
|
};
|
|
2650
2666
|
var z;
|
|
2651
2667
|
class q extends Error {
|
|
@@ -2655,7 +2671,7 @@ class q extends Error {
|
|
|
2655
2671
|
M(this, z, a);
|
|
2656
2672
|
}
|
|
2657
2673
|
get resultSet() {
|
|
2658
|
-
return
|
|
2674
|
+
return l(this, z);
|
|
2659
2675
|
}
|
|
2660
2676
|
}
|
|
2661
2677
|
z = new WeakMap();
|
|
@@ -2794,7 +2810,7 @@ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2794
2810
|
down: sr,
|
|
2795
2811
|
up: or
|
|
2796
2812
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2797
|
-
async function
|
|
2813
|
+
async function dr(t) {
|
|
2798
2814
|
await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
|
|
2799
2815
|
"user_id_constraint",
|
|
2800
2816
|
["user_id", "tenant_id"],
|
|
@@ -2819,13 +2835,13 @@ async function cr(t) {
|
|
|
2819
2835
|
(e) => e.references("applications.id").onDelete("cascade").notNull()
|
|
2820
2836
|
).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("email", "varchar(255)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addColumn("send", "varchar(255)").addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute(), await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(), await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute();
|
|
2821
2837
|
}
|
|
2822
|
-
async function
|
|
2838
|
+
async function cr(t) {
|
|
2823
2839
|
await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
|
|
2824
2840
|
}
|
|
2825
|
-
const
|
|
2841
|
+
const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2826
2842
|
__proto__: null,
|
|
2827
|
-
down:
|
|
2828
|
-
up:
|
|
2843
|
+
down: cr,
|
|
2844
|
+
up: dr
|
|
2829
2845
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2830
2846
|
async function ur(t) {
|
|
2831
2847
|
await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
|
|
@@ -3016,21 +3032,21 @@ async function on(t) {
|
|
|
3016
3032
|
async function sn(t) {
|
|
3017
3033
|
await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
|
|
3018
3034
|
}
|
|
3019
|
-
const
|
|
3035
|
+
const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3020
3036
|
__proto__: null,
|
|
3021
3037
|
down: sn,
|
|
3022
3038
|
up: on
|
|
3023
3039
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3024
|
-
async function
|
|
3040
|
+
async function cn(t) {
|
|
3025
3041
|
await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
|
|
3026
3042
|
}
|
|
3027
|
-
async function
|
|
3043
|
+
async function ln(t) {
|
|
3028
3044
|
await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
|
|
3029
3045
|
}
|
|
3030
3046
|
const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3031
3047
|
__proto__: null,
|
|
3032
|
-
down:
|
|
3033
|
-
up:
|
|
3048
|
+
down: ln,
|
|
3049
|
+
up: cn
|
|
3034
3050
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3035
3051
|
async function mn(t) {
|
|
3036
3052
|
await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
|
|
@@ -3472,21 +3488,21 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3472
3488
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3473
3489
|
async function is(t) {
|
|
3474
3490
|
}
|
|
3475
|
-
async function
|
|
3491
|
+
async function ds(t) {
|
|
3476
3492
|
}
|
|
3477
|
-
const
|
|
3493
|
+
const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3478
3494
|
__proto__: null,
|
|
3479
|
-
down:
|
|
3495
|
+
down: ds,
|
|
3480
3496
|
up: is
|
|
3481
3497
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3482
|
-
async function
|
|
3498
|
+
async function ls(t) {
|
|
3483
3499
|
}
|
|
3484
3500
|
async function us(t) {
|
|
3485
3501
|
}
|
|
3486
3502
|
const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3487
3503
|
__proto__: null,
|
|
3488
3504
|
down: us,
|
|
3489
|
-
up:
|
|
3505
|
+
up: ls
|
|
3490
3506
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3491
3507
|
async function hs(t) {
|
|
3492
3508
|
await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
|
|
@@ -3753,15 +3769,15 @@ async function ii(t) {
|
|
|
3753
3769
|
(e) => e.onDelete("cascade")
|
|
3754
3770
|
).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
|
|
3755
3771
|
}
|
|
3756
|
-
async function
|
|
3772
|
+
async function di(t) {
|
|
3757
3773
|
await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
|
|
3758
3774
|
}
|
|
3759
|
-
const
|
|
3775
|
+
const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3760
3776
|
__proto__: null,
|
|
3761
|
-
down:
|
|
3777
|
+
down: di,
|
|
3762
3778
|
up: ii
|
|
3763
3779
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3764
|
-
async function
|
|
3780
|
+
async function li(t) {
|
|
3765
3781
|
await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
|
|
3766
3782
|
}
|
|
3767
3783
|
async function ui(t) {
|
|
@@ -3769,7 +3785,7 @@ async function ui(t) {
|
|
|
3769
3785
|
const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3770
3786
|
__proto__: null,
|
|
3771
3787
|
down: ui,
|
|
3772
|
-
up:
|
|
3788
|
+
up: li
|
|
3773
3789
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3774
3790
|
async function hi(t) {
|
|
3775
3791
|
await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
|
|
@@ -3800,7 +3816,7 @@ const yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3800
3816
|
up: pi
|
|
3801
3817
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3802
3818
|
async function wi(t) {
|
|
3803
|
-
await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("
|
|
3819
|
+
await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(255)", (e) => e.notNull()).addColumn("messages", "jsonb").addColumn("languages", "jsonb").addColumn("translations", "jsonb").addColumn("nodes", "jsonb").addColumn("start", "jsonb").addColumn("ending", "jsonb").addColumn("style", "jsonb").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
|
|
3804
3820
|
}
|
|
3805
3821
|
async function vi(t) {
|
|
3806
3822
|
await t.schema.dropTable("forms").execute();
|
|
@@ -3815,7 +3831,7 @@ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3815
3831
|
m3_updateAt: tr,
|
|
3816
3832
|
m4_logTable: nr,
|
|
3817
3833
|
m5_userProfile: ir,
|
|
3818
|
-
m6_sessions:
|
|
3834
|
+
m6_sessions: lr,
|
|
3819
3835
|
m7_passwords: hr,
|
|
3820
3836
|
m8_logsTableNewFields: pr,
|
|
3821
3837
|
m9_passwordTableNewField: wr,
|
|
@@ -3832,7 +3848,7 @@ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3832
3848
|
n20_missingFields: Yr,
|
|
3833
3849
|
n21_sessionDeletedAt: tn,
|
|
3834
3850
|
n22_dropLogsFields: nn,
|
|
3835
|
-
n23_dropUsersFields:
|
|
3851
|
+
n23_dropUsersFields: dn,
|
|
3836
3852
|
n24_logsIndexes: un,
|
|
3837
3853
|
n25_logDescMaxLength: _n,
|
|
3838
3854
|
n26_logsTableExtraFields: gn,
|
|
@@ -3868,7 +3884,7 @@ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3868
3884
|
n56_application_fields: es,
|
|
3869
3885
|
n57_prompt_settings: rs,
|
|
3870
3886
|
n58_connection_client_id: ss,
|
|
3871
|
-
n59_connection_options:
|
|
3887
|
+
n59_connection_options: cs,
|
|
3872
3888
|
n60_users_metadata: ms,
|
|
3873
3889
|
n61_userLocales: fs,
|
|
3874
3890
|
n62_prompt: ys,
|
|
@@ -3886,7 +3902,7 @@ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3886
3902
|
n75_organizations: ei,
|
|
3887
3903
|
n76_authorization_url_length: ri,
|
|
3888
3904
|
n77_drop_sessions: si,
|
|
3889
|
-
n78_login_sessions:
|
|
3905
|
+
n78_login_sessions: ci,
|
|
3890
3906
|
n79_drop_sessions_2: mi,
|
|
3891
3907
|
n80_recreate_custom_domains: fi,
|
|
3892
3908
|
n81_phone: yi,
|
|
@@ -3897,22 +3913,22 @@ async function Si(t, e = !1) {
|
|
|
3897
3913
|
const a = new Le(ze), r = new Ce({
|
|
3898
3914
|
db: t,
|
|
3899
3915
|
provider: a
|
|
3900
|
-
}), { error:
|
|
3901
|
-
if (
|
|
3916
|
+
}), { error: n, results: o } = await r.migrateToLatest();
|
|
3917
|
+
if (o == null || o.forEach((s) => {
|
|
3902
3918
|
s.status === "Success" ? e && console.log(
|
|
3903
3919
|
`migration "${s.migrationName}" was executed successfully`
|
|
3904
3920
|
) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
|
|
3905
|
-
}),
|
|
3906
|
-
throw console.error("failed to migrate"), console.error(
|
|
3921
|
+
}), n)
|
|
3922
|
+
throw console.error("failed to migrate"), console.error(n), n;
|
|
3907
3923
|
}
|
|
3908
3924
|
async function Oi(t) {
|
|
3909
3925
|
console.log("migrating...");
|
|
3910
3926
|
const e = new Le(ze), a = new Ce({
|
|
3911
3927
|
db: t,
|
|
3912
3928
|
provider: e
|
|
3913
|
-
}), { error: r, results:
|
|
3914
|
-
if (
|
|
3915
|
-
|
|
3929
|
+
}), { error: r, results: n } = await a.migrateDown();
|
|
3930
|
+
if (n == null || n.forEach((o) => {
|
|
3931
|
+
o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
|
|
3916
3932
|
}), r)
|
|
3917
3933
|
throw console.error("failed to migrate"), console.error(r), r;
|
|
3918
3934
|
}
|
|
@@ -3930,7 +3946,7 @@ function ki(t) {
|
|
|
3930
3946
|
hooks: oa(t),
|
|
3931
3947
|
keys: Ut(t),
|
|
3932
3948
|
loginSessions: pa(t),
|
|
3933
|
-
logs:
|
|
3949
|
+
logs: lt(t),
|
|
3934
3950
|
passwords: vt(t),
|
|
3935
3951
|
promptSettings: wa(t),
|
|
3936
3952
|
refreshTokens: $a(t),
|