@authhero/drizzle 0.54.1 → 0.54.2
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/drizzle-adapter.cjs +1 -1
- package/dist/drizzle-adapter.mjs +104 -81
- package/package.json +1 -1
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -18021,7 +18021,10 @@ function kx(e) {
|
|
|
18021
18021
|
clients: A(d, [])
|
|
18022
18022
|
});
|
|
18023
18023
|
}
|
|
18024
|
-
function Ax(e) {
|
|
18024
|
+
function Ax(e, t) {
|
|
18025
|
+
return Math.max(e ?? 0, t ?? 0);
|
|
18026
|
+
}
|
|
18027
|
+
function jx(e) {
|
|
18025
18028
|
return {
|
|
18026
18029
|
async create(t, n) {
|
|
18027
18030
|
let r = Date.now(), i = {
|
|
@@ -18040,7 +18043,18 @@ function Ax(e) {
|
|
|
18040
18043
|
used_at_ts: $(n.used_at),
|
|
18041
18044
|
revoked_at_ts: $(n.revoked_at)
|
|
18042
18045
|
};
|
|
18043
|
-
|
|
18046
|
+
await e.run(p`BEGIN`);
|
|
18047
|
+
try {
|
|
18048
|
+
await e.insert(Yt).values(i);
|
|
18049
|
+
let n = Ax(i.expires_at_ts, i.idle_expires_at_ts);
|
|
18050
|
+
n > 0 && i.login_session_id && await e.update(C).set({
|
|
18051
|
+
expires_at_ts: n,
|
|
18052
|
+
updated_at_ts: r
|
|
18053
|
+
}).where(h(m(C.tenant_id, t), m(C.id, i.login_session_id), je(C.expires_at_ts, n))), await e.run(p`COMMIT`);
|
|
18054
|
+
} catch (t) {
|
|
18055
|
+
throw await e.run(p`ROLLBACK`), t;
|
|
18056
|
+
}
|
|
18057
|
+
return kx({
|
|
18044
18058
|
...i,
|
|
18045
18059
|
tenant_id: t
|
|
18046
18060
|
});
|
|
@@ -18051,7 +18065,16 @@ function Ax(e) {
|
|
|
18051
18065
|
},
|
|
18052
18066
|
async update(t, n, r) {
|
|
18053
18067
|
let i = { updated_at_ts: Date.now() };
|
|
18054
|
-
|
|
18068
|
+
r.user_id !== void 0 && (i.user_id = r.user_id), r.login_session_id !== void 0 && (i.login_session_id = r.login_session_id), r.device !== void 0 && (i.device = JSON.stringify(r.device)), r.clients !== void 0 && (i.clients = JSON.stringify(r.clients)), r.expires_at !== void 0 && (i.expires_at_ts = $(r.expires_at)), r.idle_expires_at !== void 0 && (i.idle_expires_at_ts = $(r.idle_expires_at)), r.authenticated_at !== void 0 && (i.authenticated_at_ts = $(r.authenticated_at)), r.last_interaction_at !== void 0 && (i.last_interaction_at_ts = $(r.last_interaction_at)), r.used_at !== void 0 && (i.used_at_ts = $(r.used_at)), r.revoked_at !== void 0 && (i.revoked_at_ts = $(r.revoked_at));
|
|
18069
|
+
let a = await e.update(Yt).set(i).where(h(m(Yt.tenant_id, t), m(Yt.id, n))).returning(), o = Ax(i.expires_at_ts, i.idle_expires_at_ts), s = a[0];
|
|
18070
|
+
if (o > 0 && s) {
|
|
18071
|
+
let n = r.login_session_id ?? s.login_session_id;
|
|
18072
|
+
n && await e.update(C).set({
|
|
18073
|
+
expires_at_ts: o,
|
|
18074
|
+
updated_at_ts: Date.now()
|
|
18075
|
+
}).where(h(m(C.tenant_id, t), m(C.id, n), je(C.expires_at_ts, o))).catch(() => {});
|
|
18076
|
+
}
|
|
18077
|
+
return a.length > 0;
|
|
18055
18078
|
},
|
|
18056
18079
|
async list(t, n) {
|
|
18057
18080
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s } = n || {}, c = s ? Pn(Yt, s, ["user_id", "id"]) : void 0, l = c ? h(m(Yt.tenant_id, t), c) : m(Yt.tenant_id, t), u = e.select().from(Yt).where(l).$dynamic();
|
|
@@ -18077,7 +18100,7 @@ function Ax(e) {
|
|
|
18077
18100
|
//#endregion
|
|
18078
18101
|
//#region src/adapters/tenants.ts
|
|
18079
18102
|
Xe();
|
|
18080
|
-
var
|
|
18103
|
+
var Mx = [
|
|
18081
18104
|
"session_cookie",
|
|
18082
18105
|
"enabled_locales",
|
|
18083
18106
|
"error_page",
|
|
@@ -18093,25 +18116,25 @@ var jx = [
|
|
|
18093
18116
|
"acr_values_supported",
|
|
18094
18117
|
"mtls",
|
|
18095
18118
|
"mfa"
|
|
18096
|
-
],
|
|
18119
|
+
], Nx = [
|
|
18097
18120
|
"allow_organization_name_in_authentication_api",
|
|
18098
18121
|
"customize_mfa_in_postlogin_action",
|
|
18099
18122
|
"pushed_authorization_requests_supported",
|
|
18100
18123
|
"authorization_response_iss_parameter_supported"
|
|
18101
18124
|
];
|
|
18102
|
-
function
|
|
18125
|
+
function Px(e) {
|
|
18103
18126
|
let t = { ...e };
|
|
18104
|
-
for (let e of
|
|
18105
|
-
for (let e of
|
|
18127
|
+
for (let e of Mx) typeof t[e] == "string" && (t[e] = A(t[e]));
|
|
18128
|
+
for (let e of Nx) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
18106
18129
|
return k(t);
|
|
18107
18130
|
}
|
|
18108
|
-
function
|
|
18131
|
+
function Fx(e) {
|
|
18109
18132
|
let t = { ...e };
|
|
18110
|
-
Dn(e,
|
|
18111
|
-
for (let n of
|
|
18133
|
+
Dn(e, Mx, t);
|
|
18134
|
+
for (let n of Nx) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
18112
18135
|
return kn(t);
|
|
18113
18136
|
}
|
|
18114
|
-
function
|
|
18137
|
+
function Ix(e) {
|
|
18115
18138
|
return {
|
|
18116
18139
|
async create(t) {
|
|
18117
18140
|
let n = {
|
|
@@ -18119,7 +18142,7 @@ function Fx(e) {
|
|
|
18119
18142
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18120
18143
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18121
18144
|
...t
|
|
18122
|
-
}, r =
|
|
18145
|
+
}, r = Fx(n);
|
|
18123
18146
|
try {
|
|
18124
18147
|
await e.insert(b).values(r);
|
|
18125
18148
|
} catch (e) {
|
|
@@ -18130,7 +18153,7 @@ function Fx(e) {
|
|
|
18130
18153
|
},
|
|
18131
18154
|
async get(t) {
|
|
18132
18155
|
let n = await e.select().from(b).where(m(b.id, t)).get();
|
|
18133
|
-
return n ?
|
|
18156
|
+
return n ? Px(n) : null;
|
|
18134
18157
|
},
|
|
18135
18158
|
async list(t) {
|
|
18136
18159
|
let { page: n = 0, per_page: r = 50, include_totals: i = !1, sort: a, q: o } = t || {}, s = e.select().from(b).$dynamic();
|
|
@@ -18142,7 +18165,7 @@ function Fx(e) {
|
|
|
18142
18165
|
let e = b[a.sort_by];
|
|
18143
18166
|
e && (s = s.orderBy(a.sort_order === "desc" ? ze(e) : Re(e)));
|
|
18144
18167
|
}
|
|
18145
|
-
let c = (await s.offset(n * r).limit(r)).map(
|
|
18168
|
+
let c = (await s.offset(n * r).limit(r)).map(Px);
|
|
18146
18169
|
if (!i) return { tenants: c };
|
|
18147
18170
|
let [l] = await e.select({ count: Be() }).from(b);
|
|
18148
18171
|
return {
|
|
@@ -18153,7 +18176,7 @@ function Fx(e) {
|
|
|
18153
18176
|
};
|
|
18154
18177
|
},
|
|
18155
18178
|
async update(t, n) {
|
|
18156
|
-
let r =
|
|
18179
|
+
let r = Fx({
|
|
18157
18180
|
...n,
|
|
18158
18181
|
id: t,
|
|
18159
18182
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -18168,18 +18191,18 @@ function Fx(e) {
|
|
|
18168
18191
|
//#endregion
|
|
18169
18192
|
//#region src/adapters/themes.ts
|
|
18170
18193
|
Xe();
|
|
18171
|
-
var
|
|
18194
|
+
var Lx = [
|
|
18172
18195
|
"colors",
|
|
18173
18196
|
"borders",
|
|
18174
18197
|
"fonts",
|
|
18175
18198
|
"page_background",
|
|
18176
18199
|
"widget"
|
|
18177
18200
|
];
|
|
18178
|
-
function
|
|
18179
|
-
let { tenant_id: t, ...n } = e, r = jn(n,
|
|
18201
|
+
function Rx(e) {
|
|
18202
|
+
let { tenant_id: t, ...n } = e, r = jn(n, Lx);
|
|
18180
18203
|
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), k(r);
|
|
18181
18204
|
}
|
|
18182
|
-
function
|
|
18205
|
+
function zx(e) {
|
|
18183
18206
|
return {
|
|
18184
18207
|
async create(t, n, r) {
|
|
18185
18208
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = r || Ye(), o = {
|
|
@@ -18189,14 +18212,14 @@ function Rx(e) {
|
|
|
18189
18212
|
created_at: i,
|
|
18190
18213
|
updated_at: i
|
|
18191
18214
|
};
|
|
18192
|
-
return await e.insert(hn).values(o),
|
|
18215
|
+
return await e.insert(hn).values(o), Rx({
|
|
18193
18216
|
...o,
|
|
18194
18217
|
tenant_id: t
|
|
18195
18218
|
});
|
|
18196
18219
|
},
|
|
18197
18220
|
async get(t, n) {
|
|
18198
18221
|
let r = await e.select().from(hn).where(h(m(hn.tenant_id, t), m(hn.themeId, n))).get();
|
|
18199
|
-
return r ?
|
|
18222
|
+
return r ? Rx(r) : null;
|
|
18200
18223
|
},
|
|
18201
18224
|
async update(t, n, r) {
|
|
18202
18225
|
let i = An(r);
|
|
@@ -18209,7 +18232,7 @@ function Rx(e) {
|
|
|
18209
18232
|
}
|
|
18210
18233
|
//#endregion
|
|
18211
18234
|
//#region src/adapters/universalLoginTemplates.ts
|
|
18212
|
-
function
|
|
18235
|
+
function Bx(e) {
|
|
18213
18236
|
return {
|
|
18214
18237
|
async get(t) {
|
|
18215
18238
|
let n = await e.select({ body: mn.body }).from(mn).where(m(mn.tenant_id, t)).get();
|
|
@@ -18238,7 +18261,7 @@ function zx(e) {
|
|
|
18238
18261
|
//#endregion
|
|
18239
18262
|
//#region src/adapters/users.ts
|
|
18240
18263
|
Xe();
|
|
18241
|
-
var
|
|
18264
|
+
var Vx = [
|
|
18242
18265
|
"user_id",
|
|
18243
18266
|
"email",
|
|
18244
18267
|
"email_verified",
|
|
@@ -18260,13 +18283,13 @@ var Bx = [
|
|
|
18260
18283
|
"login_count",
|
|
18261
18284
|
"created_at",
|
|
18262
18285
|
"updated_at"
|
|
18263
|
-
],
|
|
18286
|
+
], Hx = [
|
|
18264
18287
|
"email",
|
|
18265
18288
|
"name",
|
|
18266
18289
|
"phone_number",
|
|
18267
18290
|
"user_id"
|
|
18268
18291
|
];
|
|
18269
|
-
function
|
|
18292
|
+
function Ux(e, t) {
|
|
18270
18293
|
let n = {
|
|
18271
18294
|
connection: e.connection,
|
|
18272
18295
|
provider: e.provider,
|
|
@@ -18279,8 +18302,8 @@ function Hx(e, t) {
|
|
|
18279
18302
|
...typeof e.profileData == "string" ? A(e.profileData, {}) : {}
|
|
18280
18303
|
}, n;
|
|
18281
18304
|
}
|
|
18282
|
-
function
|
|
18283
|
-
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, linked_to: l, profileData: u, ...d } = e, f =
|
|
18305
|
+
function Wx(e, t = []) {
|
|
18306
|
+
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, linked_to: l, profileData: u, ...d } = e, f = Ux(e, !0), ee = t.map((e) => Ux(e, !1));
|
|
18284
18307
|
return k({
|
|
18285
18308
|
...d,
|
|
18286
18309
|
email: e.email || "",
|
|
@@ -18293,7 +18316,7 @@ function Ux(e, t = []) {
|
|
|
18293
18316
|
identities: [f, ...ee]
|
|
18294
18317
|
});
|
|
18295
18318
|
}
|
|
18296
|
-
function
|
|
18319
|
+
function Gx(e) {
|
|
18297
18320
|
let t = async (t, n) => {
|
|
18298
18321
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
18299
18322
|
user_id: n.user_id,
|
|
@@ -18352,14 +18375,14 @@ function Wx(e) {
|
|
|
18352
18375
|
} catch (e) {
|
|
18353
18376
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Un(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Un(500, { message: "Internal server error" }));
|
|
18354
18377
|
}
|
|
18355
|
-
return
|
|
18378
|
+
return Wx(i);
|
|
18356
18379
|
};
|
|
18357
18380
|
return {
|
|
18358
18381
|
create: t,
|
|
18359
18382
|
rawCreate: t,
|
|
18360
18383
|
async get(t, n) {
|
|
18361
18384
|
let r = await e.select().from(x).where(h(m(x.tenant_id, t), m(x.user_id, n))).get();
|
|
18362
|
-
return r ?
|
|
18385
|
+
return r ? Wx(r, await e.select().from(x).where(h(m(x.tenant_id, t), m(x.linked_to, n))).all()) : null;
|
|
18363
18386
|
},
|
|
18364
18387
|
async update(t, n, r) {
|
|
18365
18388
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -18393,9 +18416,9 @@ function Wx(e) {
|
|
|
18393
18416
|
async list(t, n) {
|
|
18394
18417
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s } = n || {}, c = [m(x.tenant_id, t), Pe(x.linked_to)];
|
|
18395
18418
|
if (s) {
|
|
18396
|
-
let e = Nn(s,
|
|
18419
|
+
let e = Nn(s, Vx);
|
|
18397
18420
|
if (e) {
|
|
18398
|
-
let t = Pn(x, e,
|
|
18421
|
+
let t = Pn(x, e, Hx);
|
|
18399
18422
|
t && c.push(t);
|
|
18400
18423
|
}
|
|
18401
18424
|
}
|
|
@@ -18406,7 +18429,7 @@ function Wx(e) {
|
|
|
18406
18429
|
}
|
|
18407
18430
|
let d = await u.offset(r * i).limit(i), f = d.map((e) => e.user_id), ee = [];
|
|
18408
18431
|
f.length > 0 && (ee = await e.select().from(x).where(h(m(x.tenant_id, t), Ne(x.linked_to, f))));
|
|
18409
|
-
let te = d.map((e) =>
|
|
18432
|
+
let te = d.map((e) => Wx(e, ee.filter((t) => t.linked_to === e.user_id)));
|
|
18410
18433
|
if (!a) return { users: te };
|
|
18411
18434
|
let [ne] = await e.select({ count: Be() }).from(x).where(l);
|
|
18412
18435
|
return {
|
|
@@ -18435,7 +18458,7 @@ function Wx(e) {
|
|
|
18435
18458
|
}
|
|
18436
18459
|
//#endregion
|
|
18437
18460
|
//#region src/adapters/userRoles.ts
|
|
18438
|
-
function
|
|
18461
|
+
function Kx(e) {
|
|
18439
18462
|
return {
|
|
18440
18463
|
async create(t, n, r, i) {
|
|
18441
18464
|
try {
|
|
@@ -18475,7 +18498,7 @@ function Gx(e) {
|
|
|
18475
18498
|
//#endregion
|
|
18476
18499
|
//#region src/adapters/userOrganizations.ts
|
|
18477
18500
|
Xe();
|
|
18478
|
-
function
|
|
18501
|
+
function qx(e) {
|
|
18479
18502
|
return {
|
|
18480
18503
|
async create(t, n) {
|
|
18481
18504
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -18552,19 +18575,19 @@ function Kx(e) {
|
|
|
18552
18575
|
}
|
|
18553
18576
|
//#endregion
|
|
18554
18577
|
//#region src/adapters/stats.ts
|
|
18555
|
-
var
|
|
18556
|
-
function
|
|
18578
|
+
var Jx = ["s"], Yx = ["pwd_leak"];
|
|
18579
|
+
function Xx(e) {
|
|
18557
18580
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
18558
18581
|
}
|
|
18559
|
-
function
|
|
18582
|
+
function Zx(e) {
|
|
18560
18583
|
return {
|
|
18561
18584
|
async getDaily(t, n) {
|
|
18562
|
-
let r = /* @__PURE__ */ new Date(), i = n?.from ?
|
|
18585
|
+
let r = /* @__PURE__ */ new Date(), i = n?.from ? Xx(n.from) : (/* @__PURE__ */ new Date(r.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], a = n?.to ? Xx(n.to) : r.toISOString().split("T")[0];
|
|
18563
18586
|
return (await e.select({
|
|
18564
18587
|
date: p`substr(${E.date}, 1, 10)`.as("date"),
|
|
18565
|
-
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18588
|
+
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(Jx.map((e) => p`${e}`), p`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
18566
18589
|
signups: p`SUM(CASE WHEN ${E.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
18567
|
-
leaked_passwords: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18590
|
+
leaked_passwords: p`SUM(CASE WHEN ${E.type} IN (${p.join(Yx.map((e) => p`${e}`), p`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
18568
18591
|
}).from(E).where(h(m(E.tenant_id, t), Ae(E.date, i), Me(E.date, `${a}T23:59:59.999Z`))).groupBy(p`substr(${E.date}, 1, 10)`).orderBy(p`substr(${E.date}, 1, 10)`).all()).map((e) => ({
|
|
18569
18592
|
date: e.date,
|
|
18570
18593
|
logins: Number(e.logins) || 0,
|
|
@@ -18575,14 +18598,14 @@ function Xx(e) {
|
|
|
18575
18598
|
}));
|
|
18576
18599
|
},
|
|
18577
18600
|
async getActiveUsers(t) {
|
|
18578
|
-
let n = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [r] = await e.select({ count: p`COUNT(DISTINCT ${E.user_id})`.as("count") }).from(E).where(h(m(E.tenant_id, t), Ae(E.date, n), p`${E.type} IN (${p.join(
|
|
18601
|
+
let n = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [r] = await e.select({ count: p`COUNT(DISTINCT ${E.user_id})`.as("count") }).from(E).where(h(m(E.tenant_id, t), Ae(E.date, n), p`${E.type} IN (${p.join(Jx.map((e) => p`${e}`), p`, `)})`));
|
|
18579
18602
|
return Number(r?.count) || 0;
|
|
18580
18603
|
}
|
|
18581
18604
|
};
|
|
18582
18605
|
}
|
|
18583
18606
|
//#endregion
|
|
18584
18607
|
//#region src/adapters/analytics.ts
|
|
18585
|
-
var
|
|
18608
|
+
var Qx = {
|
|
18586
18609
|
"active-users": ["s", "seacft"],
|
|
18587
18610
|
logins: [
|
|
18588
18611
|
"s",
|
|
@@ -18592,7 +18615,7 @@ var Zx = {
|
|
|
18592
18615
|
signups: ["ss", "fs"],
|
|
18593
18616
|
"refresh-tokens": ["seacft", "fertft"],
|
|
18594
18617
|
sessions: ["slo"]
|
|
18595
|
-
},
|
|
18618
|
+
}, $x = {
|
|
18596
18619
|
"active-users": {
|
|
18597
18620
|
alias: "active_users",
|
|
18598
18621
|
type: "UInt64",
|
|
@@ -18619,7 +18642,7 @@ var Zx = {
|
|
|
18619
18642
|
agg: "count"
|
|
18620
18643
|
}
|
|
18621
18644
|
};
|
|
18622
|
-
function
|
|
18645
|
+
function eS(e) {
|
|
18623
18646
|
switch (e) {
|
|
18624
18647
|
case "hour": return p`substr(${E.date}, 1, 13)`;
|
|
18625
18648
|
case "month": return p`substr(${E.date}, 1, 7)`;
|
|
@@ -18628,10 +18651,10 @@ function $x(e) {
|
|
|
18628
18651
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
18629
18652
|
}
|
|
18630
18653
|
}
|
|
18631
|
-
function
|
|
18654
|
+
function tS(e) {
|
|
18632
18655
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
18633
18656
|
}
|
|
18634
|
-
function
|
|
18657
|
+
function nS(e) {
|
|
18635
18658
|
switch (e) {
|
|
18636
18659
|
case "connection": return E.connection;
|
|
18637
18660
|
case "client_id": return E.client_id;
|
|
@@ -18640,9 +18663,9 @@ function tS(e) {
|
|
|
18640
18663
|
case "time": throw Error("time dimension handled separately");
|
|
18641
18664
|
}
|
|
18642
18665
|
}
|
|
18643
|
-
function
|
|
18666
|
+
function rS(e) {
|
|
18644
18667
|
return { async query(t, n, r) {
|
|
18645
|
-
let i = Date.now(), a =
|
|
18668
|
+
let i = Date.now(), a = Qx[n], o = $x[n], s = [
|
|
18646
18669
|
m(E.tenant_id, t),
|
|
18647
18670
|
Ae(E.date, r.from),
|
|
18648
18671
|
je(E.date, r.to),
|
|
@@ -18651,13 +18674,13 @@ function nS(e) {
|
|
|
18651
18674
|
r.filters.connection?.length && s.push(Ne(E.connection, r.filters.connection)), r.filters.client_id?.length && s.push(Ne(E.client_id, r.filters.client_id)), r.filters.user_type?.length && s.push(Ne(E.strategy_type, r.filters.user_type)), r.filters.user_id?.length && s.push(Ne(E.user_id, r.filters.user_id));
|
|
18652
18675
|
let c = {}, l = [], u = [];
|
|
18653
18676
|
for (let e of r.group_by) if (e === "time") {
|
|
18654
|
-
let e =
|
|
18677
|
+
let e = eS(r.interval);
|
|
18655
18678
|
c.time = e, l.push(e), u.push({
|
|
18656
18679
|
name: "time",
|
|
18657
18680
|
type: r.interval === "hour" ? "DateTime" : "Date"
|
|
18658
18681
|
});
|
|
18659
18682
|
} else {
|
|
18660
|
-
let t =
|
|
18683
|
+
let t = nS(e);
|
|
18661
18684
|
c[e] = t, l.push(t), u.push({
|
|
18662
18685
|
name: e,
|
|
18663
18686
|
type: "String"
|
|
@@ -18673,9 +18696,9 @@ function nS(e) {
|
|
|
18673
18696
|
if (r.order_by) {
|
|
18674
18697
|
let e = r.order_by.startsWith("-"), t = e ? r.order_by.slice(1) : r.order_by;
|
|
18675
18698
|
if (!f.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
18676
|
-
let n =
|
|
18699
|
+
let n = tS(t);
|
|
18677
18700
|
d = d.orderBy(p.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
18678
|
-
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${
|
|
18701
|
+
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${tS("time")} ASC`)) : d.orderBy(p.raw(`${tS(o.alias)} DESC`));
|
|
18679
18702
|
d = d.limit(r.limit).offset(r.offset);
|
|
18680
18703
|
let ee = (await d.all()).map((e) => {
|
|
18681
18704
|
let t = {};
|
|
@@ -18697,13 +18720,13 @@ function nS(e) {
|
|
|
18697
18720
|
//#endregion
|
|
18698
18721
|
//#region src/adapters/outbox.ts
|
|
18699
18722
|
Xe();
|
|
18700
|
-
function
|
|
18723
|
+
function iS(e) {
|
|
18701
18724
|
return {
|
|
18702
18725
|
...e,
|
|
18703
18726
|
payload: A(e.payload, {})
|
|
18704
18727
|
};
|
|
18705
18728
|
}
|
|
18706
|
-
function
|
|
18729
|
+
function aS(e) {
|
|
18707
18730
|
return {
|
|
18708
18731
|
async create(t, n) {
|
|
18709
18732
|
let r = Ye(), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -18728,11 +18751,11 @@ function iS(e) {
|
|
|
18728
18751
|
}), r;
|
|
18729
18752
|
},
|
|
18730
18753
|
async getByIds(t) {
|
|
18731
|
-
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(
|
|
18754
|
+
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(iS);
|
|
18732
18755
|
},
|
|
18733
18756
|
async getUnprocessed(t) {
|
|
18734
18757
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
18735
|
-
return (await e.select().from(D).where(h(Pe(D.processed_at), Oe(Pe(D.next_retry_at), Me(D.next_retry_at, n)), Oe(Pe(D.claimed_by), Me(D.claim_expires_at, n)))).orderBy(D.created_at, D.id).limit(t).all()).map(
|
|
18758
|
+
return (await e.select().from(D).where(h(Pe(D.processed_at), Oe(Pe(D.next_retry_at), Me(D.next_retry_at, n)), Oe(Pe(D.claimed_by), Me(D.claim_expires_at, n)))).orderBy(D.created_at, D.id).limit(t).all()).map(iS);
|
|
18736
18759
|
},
|
|
18737
18760
|
async claimEvents(t, n, r) {
|
|
18738
18761
|
if (t.length === 0) return [];
|
|
@@ -18802,10 +18825,10 @@ function iS(e) {
|
|
|
18802
18825
|
}
|
|
18803
18826
|
//#endregion
|
|
18804
18827
|
//#region src/adapters/cleanup.ts
|
|
18805
|
-
var
|
|
18806
|
-
function
|
|
18828
|
+
var oS = 10080 * 60 * 1e3;
|
|
18829
|
+
function sS(e) {
|
|
18807
18830
|
return async (t) => {
|
|
18808
|
-
let n = Date.now() -
|
|
18831
|
+
let n = Date.now() - oS;
|
|
18809
18832
|
try {
|
|
18810
18833
|
let r = [Oe(je(S.expires_at_ts, n), je(S.idle_expires_at_ts, n))];
|
|
18811
18834
|
t?.tenant_id && r.push(m(S.tenant_id, t.tenant_id)), await e.delete(S).where(h(...r)), r = [Oe(je(Yt.expires_at_ts, n), je(Yt.idle_expires_at_ts, n))], t?.tenant_id && r.push(m(Yt.tenant_id, t.tenant_id)), t?.user_id && r.push(m(Yt.user_id, t.user_id)), await e.delete(Yt).where(h(...r)), r = [je(C.expires_at_ts, n)], t?.tenant_id && r.push(m(C.tenant_id, t.tenant_id)), await e.delete(C).where(h(...r));
|
|
@@ -18816,7 +18839,7 @@ function oS(e) {
|
|
|
18816
18839
|
}
|
|
18817
18840
|
//#endregion
|
|
18818
18841
|
//#region src/adapters/index.ts
|
|
18819
|
-
function
|
|
18842
|
+
function cS(e, t = { useTransactions: !0 }) {
|
|
18820
18843
|
let n = {
|
|
18821
18844
|
actions: Ln(e),
|
|
18822
18845
|
actionExecutions: Rn(e),
|
|
@@ -18850,17 +18873,17 @@ function sS(e, t = { useTransactions: !0 }) {
|
|
|
18850
18873
|
rolePermissions: Cx(e),
|
|
18851
18874
|
userPermissions: wx(e),
|
|
18852
18875
|
roles: Ex(e),
|
|
18853
|
-
sessions:
|
|
18854
|
-
sessionCleanup:
|
|
18855
|
-
tenants:
|
|
18856
|
-
themes:
|
|
18857
|
-
universalLoginTemplates:
|
|
18858
|
-
users:
|
|
18859
|
-
userRoles:
|
|
18860
|
-
userOrganizations:
|
|
18861
|
-
stats:
|
|
18862
|
-
analytics:
|
|
18863
|
-
outbox:
|
|
18876
|
+
sessions: jx(e),
|
|
18877
|
+
sessionCleanup: sS(e),
|
|
18878
|
+
tenants: Ix(e),
|
|
18879
|
+
themes: zx(e),
|
|
18880
|
+
universalLoginTemplates: Bx(e),
|
|
18881
|
+
users: Gx(e),
|
|
18882
|
+
userRoles: Kx(e),
|
|
18883
|
+
userOrganizations: qx(e),
|
|
18884
|
+
stats: Zx(e),
|
|
18885
|
+
analytics: rS(e),
|
|
18886
|
+
outbox: aS(e),
|
|
18864
18887
|
async transaction(r) {
|
|
18865
18888
|
if (t.useTransactions === !1) return r(n);
|
|
18866
18889
|
await e.run(p`BEGIN`);
|
|
@@ -18876,7 +18899,7 @@ function sS(e, t = { useTransactions: !0 }) {
|
|
|
18876
18899
|
}
|
|
18877
18900
|
//#endregion
|
|
18878
18901
|
//#region src/adapters/resolveHost.ts
|
|
18879
|
-
function
|
|
18902
|
+
function lS(e) {
|
|
18880
18903
|
if (!e) return { path: "/*" };
|
|
18881
18904
|
try {
|
|
18882
18905
|
let t = JSON.parse(e), n = Wy.safeParse(t);
|
|
@@ -18884,7 +18907,7 @@ function cS(e) {
|
|
|
18884
18907
|
} catch {}
|
|
18885
18908
|
return { path: "/*" };
|
|
18886
18909
|
}
|
|
18887
|
-
function
|
|
18910
|
+
function uS(e) {
|
|
18888
18911
|
if (!e) return [];
|
|
18889
18912
|
try {
|
|
18890
18913
|
let t = JSON.parse(e);
|
|
@@ -18899,7 +18922,7 @@ function lS(e) {
|
|
|
18899
18922
|
return [];
|
|
18900
18923
|
}
|
|
18901
18924
|
}
|
|
18902
|
-
async function
|
|
18925
|
+
async function dS(e, t) {
|
|
18903
18926
|
let n = t.toLowerCase(), r = (await e.select({
|
|
18904
18927
|
custom_domain_id: nn.custom_domain_id,
|
|
18905
18928
|
tenant_id: nn.tenant_id,
|
|
@@ -18911,8 +18934,8 @@ async function uS(e, t) {
|
|
|
18911
18934
|
tenant_id: e.tenant_id,
|
|
18912
18935
|
custom_domain_id: e.custom_domain_id,
|
|
18913
18936
|
priority: e.priority,
|
|
18914
|
-
match:
|
|
18915
|
-
handlers:
|
|
18937
|
+
match: lS(e.match),
|
|
18938
|
+
handlers: uS(e.handlers),
|
|
18916
18939
|
created_at: e.created_at,
|
|
18917
18940
|
updated_at: e.updated_at
|
|
18918
18941
|
}));
|
|
@@ -18925,11 +18948,11 @@ async function uS(e, t) {
|
|
|
18925
18948
|
}
|
|
18926
18949
|
//#endregion
|
|
18927
18950
|
//#region src/adapters/proxyData.ts
|
|
18928
|
-
function
|
|
18951
|
+
function fS(e) {
|
|
18929
18952
|
return {
|
|
18930
18953
|
proxyRoutes: px(e),
|
|
18931
|
-
resolveHost: (t) =>
|
|
18954
|
+
resolveHost: (t) => dS(e, t)
|
|
18932
18955
|
};
|
|
18933
18956
|
}
|
|
18934
18957
|
//#endregion
|
|
18935
|
-
export {
|
|
18958
|
+
export { fS as createProxyDataAdapter, px as createProxyRoutesAdapter, cS as default, En as sqlite };
|