@authhero/drizzle 0.55.0 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +1 -1
- package/dist/drizzle-adapter.mjs +235 -182
- package/package.json +3 -3
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -16235,7 +16235,12 @@ q({
|
|
|
16235
16235
|
"logins",
|
|
16236
16236
|
"signups",
|
|
16237
16237
|
"refresh-tokens",
|
|
16238
|
-
"sessions"
|
|
16238
|
+
"sessions",
|
|
16239
|
+
"logouts",
|
|
16240
|
+
"password-changes",
|
|
16241
|
+
"mfa",
|
|
16242
|
+
"email-verifications",
|
|
16243
|
+
"codes-sent"
|
|
16239
16244
|
]), Y([
|
|
16240
16245
|
"hour",
|
|
16241
16246
|
"day",
|
|
@@ -16328,7 +16333,11 @@ rb.superRefine(ib), rb.extend({
|
|
|
16328
16333
|
id: V(),
|
|
16329
16334
|
created_at: V(),
|
|
16330
16335
|
updated_at: V()
|
|
16331
|
-
}).superRefine(ib)
|
|
16336
|
+
}).superRefine(ib), q({
|
|
16337
|
+
id: V().optional(),
|
|
16338
|
+
created_at: V().datetime({ offset: !0 }).optional(),
|
|
16339
|
+
updated_at: V().datetime({ offset: !0 }).optional()
|
|
16340
|
+
});
|
|
16332
16341
|
function ab(e) {
|
|
16333
16342
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
16334
16343
|
}
|
|
@@ -17645,9 +17654,31 @@ function px(e) {
|
|
|
17645
17654
|
};
|
|
17646
17655
|
}
|
|
17647
17656
|
//#endregion
|
|
17657
|
+
//#region src/adapters/atomic.ts
|
|
17658
|
+
function mx(e) {
|
|
17659
|
+
let t = e;
|
|
17660
|
+
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
17661
|
+
}
|
|
17662
|
+
async function hx(e, t) {
|
|
17663
|
+
if (mx(e)) return e.batch(t);
|
|
17664
|
+
await e.run(p`BEGIN`);
|
|
17665
|
+
try {
|
|
17666
|
+
let n = [];
|
|
17667
|
+
for (let e of t) n.push(await e);
|
|
17668
|
+
return await e.run(p`COMMIT`), n;
|
|
17669
|
+
} catch (t) {
|
|
17670
|
+
try {
|
|
17671
|
+
await e.run(p`ROLLBACK`);
|
|
17672
|
+
} catch (e) {
|
|
17673
|
+
console.error("runAtomic rollback failed", e);
|
|
17674
|
+
}
|
|
17675
|
+
throw t;
|
|
17676
|
+
}
|
|
17677
|
+
}
|
|
17678
|
+
//#endregion
|
|
17648
17679
|
//#region src/adapters/refreshTokens.ts
|
|
17649
17680
|
Xe();
|
|
17650
|
-
function
|
|
17681
|
+
function gx(e) {
|
|
17651
17682
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: r, idle_expires_at_ts: i, last_exchanged_at_ts: a, revoked_at_ts: o, rotated_at_ts: s, device: c, resource_servers: l, rotating: u, ...d } = e, f = Ab({
|
|
17652
17683
|
created_at_ts: n,
|
|
17653
17684
|
expires_at_ts: r,
|
|
@@ -17670,10 +17701,10 @@ function mx(e) {
|
|
|
17670
17701
|
resource_servers: A(l, [])
|
|
17671
17702
|
});
|
|
17672
17703
|
}
|
|
17673
|
-
function
|
|
17704
|
+
function _x(e, t) {
|
|
17674
17705
|
return Math.max(e ?? 0, t ?? 0);
|
|
17675
17706
|
}
|
|
17676
|
-
function
|
|
17707
|
+
function vx(e) {
|
|
17677
17708
|
return {
|
|
17678
17709
|
async create(t, n) {
|
|
17679
17710
|
let r = Date.now(), i = {
|
|
@@ -17694,30 +17725,22 @@ function gx(e) {
|
|
|
17694
17725
|
expires_at_ts: $(n.expires_at),
|
|
17695
17726
|
idle_expires_at_ts: $(n.idle_expires_at),
|
|
17696
17727
|
last_exchanged_at_ts: $(n.last_exchanged_at)
|
|
17697
|
-
};
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
n > 0 && i.login_id && await e.update(C).set({
|
|
17703
|
-
expires_at_ts: n,
|
|
17704
|
-
updated_at_ts: r
|
|
17705
|
-
}).where(h(m(C.tenant_id, t), m(C.id, i.login_id), je(C.expires_at_ts, n))), await e.run(p`COMMIT`);
|
|
17706
|
-
} catch (t) {
|
|
17707
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
17708
|
-
}
|
|
17709
|
-
return mx({
|
|
17728
|
+
}, a = [e.insert(S).values(i)], o = _x(i.expires_at_ts, i.idle_expires_at_ts);
|
|
17729
|
+
return o > 0 && i.login_id && a.push(e.update(C).set({
|
|
17730
|
+
expires_at_ts: o,
|
|
17731
|
+
updated_at_ts: r
|
|
17732
|
+
}).where(h(m(C.tenant_id, t), m(C.id, i.login_id), je(C.expires_at_ts, o)))), await hx(e, a), gx({
|
|
17710
17733
|
...i,
|
|
17711
17734
|
tenant_id: t
|
|
17712
17735
|
});
|
|
17713
17736
|
},
|
|
17714
17737
|
async get(t, n) {
|
|
17715
17738
|
let r = await e.select().from(S).where(h(m(S.tenant_id, t), m(S.id, n))).get();
|
|
17716
|
-
return r ?
|
|
17739
|
+
return r ? gx(r) : null;
|
|
17717
17740
|
},
|
|
17718
17741
|
async getByLookup(t, n) {
|
|
17719
17742
|
let r = await e.select().from(S).where(h(m(S.tenant_id, t), m(S.token_lookup, n))).get();
|
|
17720
|
-
return r ?
|
|
17743
|
+
return r ? gx(r) : null;
|
|
17721
17744
|
},
|
|
17722
17745
|
async update(t, n, r, i) {
|
|
17723
17746
|
let a = {};
|
|
@@ -17738,7 +17761,7 @@ function gx(e) {
|
|
|
17738
17761
|
let e = S[o.sort_by];
|
|
17739
17762
|
e && (c = c.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
17740
17763
|
}
|
|
17741
|
-
let l = (await c.offset(r * i).limit(i)).map(
|
|
17764
|
+
let l = (await c.offset(r * i).limit(i)).map(gx);
|
|
17742
17765
|
if (!a) return { refresh_tokens: l };
|
|
17743
17766
|
let [u] = await e.select({ count: Be() }).from(S).where(m(S.tenant_id, t));
|
|
17744
17767
|
return {
|
|
@@ -17761,16 +17784,16 @@ function gx(e) {
|
|
|
17761
17784
|
}
|
|
17762
17785
|
//#endregion
|
|
17763
17786
|
//#region src/adapters/resourceServers.ts
|
|
17764
|
-
var
|
|
17765
|
-
function
|
|
17787
|
+
var yx = ["name", "identifier"];
|
|
17788
|
+
function bx() {
|
|
17766
17789
|
let { customAlphabet: e } = (Xe(), s(Ge));
|
|
17767
17790
|
return `api_${e("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
17768
17791
|
}
|
|
17769
|
-
var
|
|
17792
|
+
var xx = [
|
|
17770
17793
|
"skip_consent_for_verifiable_first_party_clients",
|
|
17771
17794
|
"allow_offline_access",
|
|
17772
17795
|
"is_system"
|
|
17773
|
-
],
|
|
17796
|
+
], Sx = /* @__PURE__ */ new Set([
|
|
17774
17797
|
"id",
|
|
17775
17798
|
"tenant_id",
|
|
17776
17799
|
"identifier",
|
|
@@ -17789,17 +17812,17 @@ var yx = [
|
|
|
17789
17812
|
"created_at",
|
|
17790
17813
|
"updated_at"
|
|
17791
17814
|
]);
|
|
17792
|
-
function
|
|
17815
|
+
function Cx(e) {
|
|
17793
17816
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
17794
17817
|
s.scopes = A(r, []), s.options = A(i, {}), s.metadata = A(a), n !== void 0 && (s.verificationKey = n);
|
|
17795
|
-
for (let e of
|
|
17818
|
+
for (let e of xx) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
17796
17819
|
return k(s);
|
|
17797
17820
|
}
|
|
17798
|
-
function
|
|
17821
|
+
function wx(e) {
|
|
17799
17822
|
return {
|
|
17800
17823
|
async create(t, n) {
|
|
17801
17824
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
17802
|
-
id: n.id ||
|
|
17825
|
+
id: n.id || bx(),
|
|
17803
17826
|
tenant_id: t,
|
|
17804
17827
|
identifier: n.identifier,
|
|
17805
17828
|
name: n.name,
|
|
@@ -17814,37 +17837,37 @@ function Sx(e) {
|
|
|
17814
17837
|
created_at: r,
|
|
17815
17838
|
updated_at: r
|
|
17816
17839
|
};
|
|
17817
|
-
for (let e of
|
|
17818
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(fn).values(i),
|
|
17840
|
+
for (let e of xx) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
17841
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(fn).values(i), Cx({
|
|
17819
17842
|
...i,
|
|
17820
17843
|
tenant_id: t
|
|
17821
17844
|
});
|
|
17822
17845
|
},
|
|
17823
17846
|
async get(t, n) {
|
|
17824
17847
|
let r = await e.select().from(fn).where(h(m(fn.tenant_id, t), m(fn.id, n))).get();
|
|
17825
|
-
return r ?
|
|
17848
|
+
return r ? Cx(r) : null;
|
|
17826
17849
|
},
|
|
17827
17850
|
async update(t, n, r) {
|
|
17828
17851
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
17829
17852
|
r.name !== void 0 && (i.name = r.name), r.identifier !== void 0 && (i.identifier = r.identifier), r.signing_alg !== void 0 && (i.signing_alg = r.signing_alg), r.signing_secret !== void 0 && (i.signing_secret = r.signing_secret), r.token_lifetime !== void 0 && (i.token_lifetime = r.token_lifetime), r.token_lifetime_for_web !== void 0 && (i.token_lifetime_for_web = r.token_lifetime_for_web), r.scopes !== void 0 && (i.scopes = JSON.stringify(r.scopes)), r.options !== void 0 && (i.options = p`json_patch(COALESCE(${fn.options}, '{}'), ${JSON.stringify(r.options)})`), r.metadata !== void 0 && (i.metadata = JSON.stringify(r.metadata)), r.verificationKey !== void 0 && (i.verification_key = r.verificationKey);
|
|
17830
|
-
for (let e of
|
|
17853
|
+
for (let e of xx) r[e] !== void 0 && (i[e] = +!!r[e]);
|
|
17831
17854
|
return (await e.update(fn).set(i).where(h(m(fn.tenant_id, t), m(fn.id, n))).returning()).length > 0;
|
|
17832
17855
|
},
|
|
17833
17856
|
async list(t, n) {
|
|
17834
17857
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s } = n || {}, c = Math.max(0, Math.floor(Number(r) || 0)), l = Math.min(Math.max(1, Math.floor(Number(i) || 50)), 500), u = [m(fn.tenant_id, t)];
|
|
17835
17858
|
if (s) {
|
|
17836
|
-
let e = Nn(s,
|
|
17859
|
+
let e = Nn(s, yx);
|
|
17837
17860
|
if (e) {
|
|
17838
|
-
let t = Pn(fn, e,
|
|
17861
|
+
let t = Pn(fn, e, yx, ["name", "identifier"]);
|
|
17839
17862
|
t && u.push(t);
|
|
17840
17863
|
}
|
|
17841
17864
|
}
|
|
17842
17865
|
let d = e.select().from(fn).where(h(...u)).$dynamic();
|
|
17843
|
-
if (o?.sort_by &&
|
|
17866
|
+
if (o?.sort_by && Sx.has(o.sort_by)) {
|
|
17844
17867
|
let e = fn[o.sort_by];
|
|
17845
17868
|
d = d.orderBy(o.sort_order === "desc" ? ze(e) : Re(e));
|
|
17846
17869
|
}
|
|
17847
|
-
let f = (await d.offset(c * l).limit(l)).map(
|
|
17870
|
+
let f = (await d.offset(c * l).limit(l)).map(Cx);
|
|
17848
17871
|
if (!a) return { resource_servers: f };
|
|
17849
17872
|
let [ee] = await e.select({ count: Be() }).from(fn).where(h(...u));
|
|
17850
17873
|
return {
|
|
@@ -17861,7 +17884,7 @@ function Sx(e) {
|
|
|
17861
17884
|
}
|
|
17862
17885
|
//#endregion
|
|
17863
17886
|
//#region src/adapters/rolePermissions.ts
|
|
17864
|
-
function
|
|
17887
|
+
function Tx(e) {
|
|
17865
17888
|
return {
|
|
17866
17889
|
async assign(t, n, r) {
|
|
17867
17890
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -17899,7 +17922,7 @@ function Cx(e) {
|
|
|
17899
17922
|
}
|
|
17900
17923
|
//#endregion
|
|
17901
17924
|
//#region src/adapters/userPermissions.ts
|
|
17902
|
-
function
|
|
17925
|
+
function Ex(e) {
|
|
17903
17926
|
return {
|
|
17904
17927
|
async create(t, n, r, i) {
|
|
17905
17928
|
try {
|
|
@@ -17939,7 +17962,7 @@ function wx(e) {
|
|
|
17939
17962
|
//#endregion
|
|
17940
17963
|
//#region src/adapters/roles.ts
|
|
17941
17964
|
Xe();
|
|
17942
|
-
function
|
|
17965
|
+
function Dx(e) {
|
|
17943
17966
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
17944
17967
|
return k({
|
|
17945
17968
|
...i,
|
|
@@ -17947,7 +17970,7 @@ function Tx(e) {
|
|
|
17947
17970
|
metadata: A(r)
|
|
17948
17971
|
});
|
|
17949
17972
|
}
|
|
17950
|
-
function
|
|
17973
|
+
function Ox(e) {
|
|
17951
17974
|
return {
|
|
17952
17975
|
async create(t, n) {
|
|
17953
17976
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -17960,14 +17983,14 @@ function Ex(e) {
|
|
|
17960
17983
|
created_at: r,
|
|
17961
17984
|
updated_at: r
|
|
17962
17985
|
};
|
|
17963
|
-
return await e.insert(cn).values(i),
|
|
17986
|
+
return await e.insert(cn).values(i), Dx({
|
|
17964
17987
|
...i,
|
|
17965
17988
|
tenant_id: t
|
|
17966
17989
|
});
|
|
17967
17990
|
},
|
|
17968
17991
|
async get(t, n) {
|
|
17969
17992
|
let r = await e.select().from(cn).where(h(m(cn.tenant_id, t), m(cn.id, n))).get();
|
|
17970
|
-
return r ?
|
|
17993
|
+
return r ? Dx(r) : null;
|
|
17971
17994
|
},
|
|
17972
17995
|
async update(t, n, r) {
|
|
17973
17996
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -17979,7 +18002,7 @@ function Ex(e) {
|
|
|
17979
18002
|
let e = cn[o.sort_by];
|
|
17980
18003
|
e && (u = u.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
17981
18004
|
}
|
|
17982
|
-
let d = (await u.offset(r * i).limit(i)).map(
|
|
18005
|
+
let d = (await u.offset(r * i).limit(i)).map(Dx);
|
|
17983
18006
|
if (!a) return { roles: d };
|
|
17984
18007
|
let [f] = await e.select({ count: Be() }).from(cn).where(l);
|
|
17985
18008
|
return {
|
|
@@ -17997,7 +18020,7 @@ function Ex(e) {
|
|
|
17997
18020
|
//#endregion
|
|
17998
18021
|
//#region src/adapters/sessions.ts
|
|
17999
18022
|
Xe();
|
|
18000
|
-
var
|
|
18023
|
+
var kx = ["created_at_ts", "updated_at_ts"], Ax = [
|
|
18001
18024
|
"expires_at_ts",
|
|
18002
18025
|
"idle_expires_at_ts",
|
|
18003
18026
|
"authenticated_at_ts",
|
|
@@ -18005,7 +18028,7 @@ var Dx = ["created_at_ts", "updated_at_ts"], Ox = [
|
|
|
18005
18028
|
"used_at_ts",
|
|
18006
18029
|
"revoked_at_ts"
|
|
18007
18030
|
];
|
|
18008
|
-
function
|
|
18031
|
+
function jx(e) {
|
|
18009
18032
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, ee = Ab({
|
|
18010
18033
|
created_at_ts: n,
|
|
18011
18034
|
updated_at_ts: r,
|
|
@@ -18015,7 +18038,7 @@ function kx(e) {
|
|
|
18015
18038
|
last_interaction_at_ts: s,
|
|
18016
18039
|
used_at_ts: c,
|
|
18017
18040
|
revoked_at_ts: l
|
|
18018
|
-
}, [...
|
|
18041
|
+
}, [...kx], [...Ax]);
|
|
18019
18042
|
return k({
|
|
18020
18043
|
...f,
|
|
18021
18044
|
...ee,
|
|
@@ -18023,10 +18046,10 @@ function kx(e) {
|
|
|
18023
18046
|
clients: A(d, [])
|
|
18024
18047
|
});
|
|
18025
18048
|
}
|
|
18026
|
-
function
|
|
18049
|
+
function Mx(e, t) {
|
|
18027
18050
|
return Math.max(e ?? 0, t ?? 0);
|
|
18028
18051
|
}
|
|
18029
|
-
function
|
|
18052
|
+
function Nx(e) {
|
|
18030
18053
|
return {
|
|
18031
18054
|
async create(t, n) {
|
|
18032
18055
|
let r = Date.now(), i = {
|
|
@@ -18044,31 +18067,23 @@ function jx(e) {
|
|
|
18044
18067
|
last_interaction_at_ts: n.last_interaction_at ? $(n.last_interaction_at) : r,
|
|
18045
18068
|
used_at_ts: $(n.used_at),
|
|
18046
18069
|
revoked_at_ts: $(n.revoked_at)
|
|
18047
|
-
};
|
|
18048
|
-
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
|
|
18052
|
-
n > 0 && i.login_session_id && await e.update(C).set({
|
|
18053
|
-
expires_at_ts: n,
|
|
18054
|
-
updated_at_ts: r
|
|
18055
|
-
}).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`);
|
|
18056
|
-
} catch (t) {
|
|
18057
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
18058
|
-
}
|
|
18059
|
-
return kx({
|
|
18070
|
+
}, a = [e.insert(Yt).values(i)], o = Mx(i.expires_at_ts, i.idle_expires_at_ts);
|
|
18071
|
+
return o > 0 && i.login_session_id && a.push(e.update(C).set({
|
|
18072
|
+
expires_at_ts: o,
|
|
18073
|
+
updated_at_ts: r
|
|
18074
|
+
}).where(h(m(C.tenant_id, t), m(C.id, i.login_session_id), je(C.expires_at_ts, o)))), await hx(e, a), jx({
|
|
18060
18075
|
...i,
|
|
18061
18076
|
tenant_id: t
|
|
18062
18077
|
});
|
|
18063
18078
|
},
|
|
18064
18079
|
async get(t, n) {
|
|
18065
18080
|
let r = await e.select().from(Yt).where(h(m(Yt.tenant_id, t), m(Yt.id, n))).get();
|
|
18066
|
-
return r ?
|
|
18081
|
+
return r ? jx(r) : null;
|
|
18067
18082
|
},
|
|
18068
18083
|
async update(t, n, r) {
|
|
18069
18084
|
let i = { updated_at_ts: Date.now() };
|
|
18070
18085
|
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));
|
|
18071
|
-
let a = await e.update(Yt).set(i).where(h(m(Yt.tenant_id, t), m(Yt.id, n))).returning(), o =
|
|
18086
|
+
let a = await e.update(Yt).set(i).where(h(m(Yt.tenant_id, t), m(Yt.id, n))).returning(), o = Mx(i.expires_at_ts, i.idle_expires_at_ts), s = a[0];
|
|
18072
18087
|
if (o > 0 && s) {
|
|
18073
18088
|
let n = r.login_session_id ?? s.login_session_id;
|
|
18074
18089
|
n && await e.update(C).set({
|
|
@@ -18084,7 +18099,7 @@ function jx(e) {
|
|
|
18084
18099
|
let e = Yt[o.sort_by];
|
|
18085
18100
|
e && (u = u.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
18086
18101
|
}
|
|
18087
|
-
let d = (await u.offset(r * i).limit(i)).map(
|
|
18102
|
+
let d = (await u.offset(r * i).limit(i)).map(jx);
|
|
18088
18103
|
if (!a) return { sessions: d };
|
|
18089
18104
|
let [f] = await e.select({ count: Be() }).from(Yt).where(l);
|
|
18090
18105
|
return {
|
|
@@ -18102,7 +18117,7 @@ function jx(e) {
|
|
|
18102
18117
|
//#endregion
|
|
18103
18118
|
//#region src/adapters/tenants.ts
|
|
18104
18119
|
Xe();
|
|
18105
|
-
var
|
|
18120
|
+
var Px = [
|
|
18106
18121
|
"session_cookie",
|
|
18107
18122
|
"enabled_locales",
|
|
18108
18123
|
"error_page",
|
|
@@ -18118,25 +18133,25 @@ var Mx = [
|
|
|
18118
18133
|
"acr_values_supported",
|
|
18119
18134
|
"mtls",
|
|
18120
18135
|
"mfa"
|
|
18121
|
-
],
|
|
18136
|
+
], Fx = [
|
|
18122
18137
|
"allow_organization_name_in_authentication_api",
|
|
18123
18138
|
"customize_mfa_in_postlogin_action",
|
|
18124
18139
|
"pushed_authorization_requests_supported",
|
|
18125
18140
|
"authorization_response_iss_parameter_supported"
|
|
18126
18141
|
];
|
|
18127
|
-
function
|
|
18142
|
+
function Ix(e) {
|
|
18128
18143
|
let t = { ...e };
|
|
18129
|
-
for (let e of
|
|
18130
|
-
for (let e of
|
|
18144
|
+
for (let e of Px) typeof t[e] == "string" && (t[e] = A(t[e]));
|
|
18145
|
+
for (let e of Fx) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
18131
18146
|
return k(t);
|
|
18132
18147
|
}
|
|
18133
|
-
function
|
|
18148
|
+
function Lx(e) {
|
|
18134
18149
|
let t = { ...e };
|
|
18135
|
-
Dn(e,
|
|
18136
|
-
for (let n of
|
|
18150
|
+
Dn(e, Px, t);
|
|
18151
|
+
for (let n of Fx) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
18137
18152
|
return kn(t);
|
|
18138
18153
|
}
|
|
18139
|
-
function
|
|
18154
|
+
function Rx(e) {
|
|
18140
18155
|
return {
|
|
18141
18156
|
async create(t) {
|
|
18142
18157
|
let n = {
|
|
@@ -18144,7 +18159,7 @@ function Ix(e) {
|
|
|
18144
18159
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18145
18160
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18146
18161
|
...t
|
|
18147
|
-
}, r =
|
|
18162
|
+
}, r = Lx(n);
|
|
18148
18163
|
try {
|
|
18149
18164
|
await e.insert(b).values(r);
|
|
18150
18165
|
} catch (e) {
|
|
@@ -18155,7 +18170,7 @@ function Ix(e) {
|
|
|
18155
18170
|
},
|
|
18156
18171
|
async get(t) {
|
|
18157
18172
|
let n = await e.select().from(b).where(m(b.id, t)).get();
|
|
18158
|
-
return n ?
|
|
18173
|
+
return n ? Ix(n) : null;
|
|
18159
18174
|
},
|
|
18160
18175
|
async list(t) {
|
|
18161
18176
|
let { page: n = 0, per_page: r = 50, include_totals: i = !1, sort: a, q: o } = t || {}, s = e.select().from(b).$dynamic();
|
|
@@ -18167,7 +18182,7 @@ function Ix(e) {
|
|
|
18167
18182
|
let e = b[a.sort_by];
|
|
18168
18183
|
e && (s = s.orderBy(a.sort_order === "desc" ? ze(e) : Re(e)));
|
|
18169
18184
|
}
|
|
18170
|
-
let c = (await s.offset(n * r).limit(r)).map(
|
|
18185
|
+
let c = (await s.offset(n * r).limit(r)).map(Ix);
|
|
18171
18186
|
if (!i) return { tenants: c };
|
|
18172
18187
|
let [l] = await e.select({ count: Be() }).from(b);
|
|
18173
18188
|
return {
|
|
@@ -18178,7 +18193,7 @@ function Ix(e) {
|
|
|
18178
18193
|
};
|
|
18179
18194
|
},
|
|
18180
18195
|
async update(t, n) {
|
|
18181
|
-
let r =
|
|
18196
|
+
let r = Lx({
|
|
18182
18197
|
...n,
|
|
18183
18198
|
id: t,
|
|
18184
18199
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -18193,35 +18208,38 @@ function Ix(e) {
|
|
|
18193
18208
|
//#endregion
|
|
18194
18209
|
//#region src/adapters/themes.ts
|
|
18195
18210
|
Xe();
|
|
18196
|
-
var
|
|
18211
|
+
var zx = [
|
|
18197
18212
|
"colors",
|
|
18198
18213
|
"borders",
|
|
18199
18214
|
"fonts",
|
|
18200
18215
|
"page_background",
|
|
18201
18216
|
"widget"
|
|
18202
18217
|
];
|
|
18203
|
-
function
|
|
18204
|
-
let { tenant_id: t, ...n } = e, r = jn(n,
|
|
18205
|
-
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);
|
|
18218
|
+
function Bx(e) {
|
|
18219
|
+
let { tenant_id: t, ...n } = e, r = jn(n, zx);
|
|
18220
|
+
return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, 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);
|
|
18206
18221
|
}
|
|
18207
|
-
function
|
|
18222
|
+
function Vx(e) {
|
|
18208
18223
|
return {
|
|
18209
|
-
async create(t, n, r) {
|
|
18210
|
-
let i = (/* @__PURE__ */ new Date()).toISOString(),
|
|
18224
|
+
async create(t, n, r, i) {
|
|
18225
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || Ye(), c = {
|
|
18211
18226
|
...An(n),
|
|
18212
18227
|
tenant_id: t,
|
|
18213
|
-
themeId:
|
|
18214
|
-
created_at:
|
|
18215
|
-
updated_at:
|
|
18228
|
+
themeId: s,
|
|
18229
|
+
created_at: a?.created_at ?? o,
|
|
18230
|
+
updated_at: a?.updated_at ?? o
|
|
18216
18231
|
};
|
|
18217
|
-
return await e.insert(hn).values(
|
|
18218
|
-
...
|
|
18232
|
+
return await e.insert(hn).values(c), Bx({
|
|
18233
|
+
...c,
|
|
18219
18234
|
tenant_id: t
|
|
18220
18235
|
});
|
|
18221
18236
|
},
|
|
18222
18237
|
async get(t, n) {
|
|
18223
18238
|
let r = await e.select().from(hn).where(h(m(hn.tenant_id, t), m(hn.themeId, n))).get();
|
|
18224
|
-
return r ?
|
|
18239
|
+
return r ? Bx(r) : null;
|
|
18240
|
+
},
|
|
18241
|
+
async list(t) {
|
|
18242
|
+
return (await e.select().from(hn).where(m(hn.tenant_id, t)).all()).map(Bx);
|
|
18225
18243
|
},
|
|
18226
18244
|
async update(t, n, r) {
|
|
18227
18245
|
let i = An(r);
|
|
@@ -18234,7 +18252,7 @@ function zx(e) {
|
|
|
18234
18252
|
}
|
|
18235
18253
|
//#endregion
|
|
18236
18254
|
//#region src/adapters/universalLoginTemplates.ts
|
|
18237
|
-
function
|
|
18255
|
+
function Hx(e) {
|
|
18238
18256
|
return {
|
|
18239
18257
|
async get(t) {
|
|
18240
18258
|
let n = await e.select({ body: mn.body }).from(mn).where(m(mn.tenant_id, t)).get();
|
|
@@ -18263,7 +18281,7 @@ function Bx(e) {
|
|
|
18263
18281
|
//#endregion
|
|
18264
18282
|
//#region src/adapters/users.ts
|
|
18265
18283
|
Xe();
|
|
18266
|
-
var
|
|
18284
|
+
var Ux = [
|
|
18267
18285
|
"user_id",
|
|
18268
18286
|
"email",
|
|
18269
18287
|
"email_verified",
|
|
@@ -18285,13 +18303,13 @@ var Vx = [
|
|
|
18285
18303
|
"login_count",
|
|
18286
18304
|
"created_at",
|
|
18287
18305
|
"updated_at"
|
|
18288
|
-
],
|
|
18306
|
+
], Wx = [
|
|
18289
18307
|
"email",
|
|
18290
18308
|
"name",
|
|
18291
18309
|
"phone_number",
|
|
18292
18310
|
"user_id"
|
|
18293
18311
|
];
|
|
18294
|
-
function
|
|
18312
|
+
function Gx(e, t) {
|
|
18295
18313
|
let n = {
|
|
18296
18314
|
connection: e.connection,
|
|
18297
18315
|
provider: e.provider,
|
|
@@ -18304,8 +18322,8 @@ function Ux(e, t) {
|
|
|
18304
18322
|
...typeof e.profileData == "string" ? A(e.profileData, {}) : {}
|
|
18305
18323
|
}, n;
|
|
18306
18324
|
}
|
|
18307
|
-
function
|
|
18308
|
-
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 =
|
|
18325
|
+
function Kx(e, t = []) {
|
|
18326
|
+
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 = Gx(e, !0), ee = t.map((e) => Gx(e, !1));
|
|
18309
18327
|
return k({
|
|
18310
18328
|
...d,
|
|
18311
18329
|
email: e.email || "",
|
|
@@ -18318,7 +18336,7 @@ function Wx(e, t = []) {
|
|
|
18318
18336
|
identities: [f, ...ee]
|
|
18319
18337
|
});
|
|
18320
18338
|
}
|
|
18321
|
-
function
|
|
18339
|
+
function qx(e) {
|
|
18322
18340
|
let t = async (t, n) => {
|
|
18323
18341
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
18324
18342
|
user_id: n.user_id,
|
|
@@ -18357,34 +18375,27 @@ function Gx(e) {
|
|
|
18357
18375
|
updated_at: n.updated_at || r
|
|
18358
18376
|
}, a = n.password ? Ye() : void 0;
|
|
18359
18377
|
try {
|
|
18360
|
-
|
|
18361
|
-
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
created_at: r,
|
|
18371
|
-
updated_at: r
|
|
18372
|
-
}), await e.run(p`COMMIT`);
|
|
18373
|
-
} catch (t) {
|
|
18374
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
18375
|
-
}
|
|
18376
|
-
} else await e.insert(x).values(i);
|
|
18378
|
+
n.password && a ? await hx(e, [e.insert(x).values(i), e.insert(Jt).values({
|
|
18379
|
+
id: a,
|
|
18380
|
+
tenant_id: t,
|
|
18381
|
+
user_id: n.user_id,
|
|
18382
|
+
password: n.password.hash || n.password,
|
|
18383
|
+
algorithm: n.password.algorithm || "bcrypt",
|
|
18384
|
+
is_current: 1,
|
|
18385
|
+
created_at: r,
|
|
18386
|
+
updated_at: r
|
|
18387
|
+
})]) : await e.insert(x).values(i);
|
|
18377
18388
|
} catch (e) {
|
|
18378
18389
|
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" }));
|
|
18379
18390
|
}
|
|
18380
|
-
return
|
|
18391
|
+
return Kx(i);
|
|
18381
18392
|
};
|
|
18382
18393
|
return {
|
|
18383
18394
|
create: t,
|
|
18384
18395
|
rawCreate: t,
|
|
18385
18396
|
async get(t, n) {
|
|
18386
18397
|
let r = await e.select().from(x).where(h(m(x.tenant_id, t), m(x.user_id, n))).get();
|
|
18387
|
-
return r ?
|
|
18398
|
+
return r ? Kx(r, await e.select().from(x).where(h(m(x.tenant_id, t), m(x.linked_to, n))).all()) : null;
|
|
18388
18399
|
},
|
|
18389
18400
|
async update(t, n, r) {
|
|
18390
18401
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -18418,9 +18429,9 @@ function Gx(e) {
|
|
|
18418
18429
|
async list(t, n) {
|
|
18419
18430
|
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)];
|
|
18420
18431
|
if (s) {
|
|
18421
|
-
let e = Nn(s,
|
|
18432
|
+
let e = Nn(s, Ux);
|
|
18422
18433
|
if (e) {
|
|
18423
|
-
let t = Pn(x, e,
|
|
18434
|
+
let t = Pn(x, e, Wx);
|
|
18424
18435
|
t && c.push(t);
|
|
18425
18436
|
}
|
|
18426
18437
|
}
|
|
@@ -18431,7 +18442,7 @@ function Gx(e) {
|
|
|
18431
18442
|
}
|
|
18432
18443
|
let d = await u.offset(r * i).limit(i), f = d.map((e) => e.user_id), ee = [];
|
|
18433
18444
|
f.length > 0 && (ee = await e.select().from(x).where(h(m(x.tenant_id, t), Ne(x.linked_to, f))));
|
|
18434
|
-
let te = d.map((e) =>
|
|
18445
|
+
let te = d.map((e) => Kx(e, ee.filter((t) => t.linked_to === e.user_id)));
|
|
18435
18446
|
if (!a) return { users: te };
|
|
18436
18447
|
let [ne] = await e.select({ count: Be() }).from(x).where(l);
|
|
18437
18448
|
return {
|
|
@@ -18442,15 +18453,13 @@ function Gx(e) {
|
|
|
18442
18453
|
};
|
|
18443
18454
|
},
|
|
18444
18455
|
async remove(t, n) {
|
|
18445
|
-
await e.
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
18453
|
-
}
|
|
18456
|
+
let r = (await e.select({ user_id: x.user_id }).from(x).where(h(m(x.tenant_id, t), m(x.linked_to, n)))).map((e) => e.user_id), i = [n, ...r], a = await hx(e, [
|
|
18457
|
+
e.delete(Tn).where(h(m(Tn.tenant_id, t), Ne(Tn.user_id, i))),
|
|
18458
|
+
e.delete(Jt).where(h(m(Jt.tenant_id, t), Ne(Jt.user_id, i))),
|
|
18459
|
+
e.delete(x).where(h(m(x.tenant_id, t), Ne(x.user_id, r))),
|
|
18460
|
+
e.delete(x).where(h(m(x.tenant_id, t), m(x.user_id, n))).returning()
|
|
18461
|
+
]), o = a[a.length - 1];
|
|
18462
|
+
return Array.isArray(o) && o.length > 0;
|
|
18454
18463
|
},
|
|
18455
18464
|
async unlink(t, n, r, i) {
|
|
18456
18465
|
let a = `${r}|${i}`;
|
|
@@ -18460,7 +18469,7 @@ function Gx(e) {
|
|
|
18460
18469
|
}
|
|
18461
18470
|
//#endregion
|
|
18462
18471
|
//#region src/adapters/userRoles.ts
|
|
18463
|
-
function
|
|
18472
|
+
function Jx(e) {
|
|
18464
18473
|
return {
|
|
18465
18474
|
async create(t, n, r, i) {
|
|
18466
18475
|
try {
|
|
@@ -18500,7 +18509,7 @@ function Kx(e) {
|
|
|
18500
18509
|
//#endregion
|
|
18501
18510
|
//#region src/adapters/userOrganizations.ts
|
|
18502
18511
|
Xe();
|
|
18503
|
-
function
|
|
18512
|
+
function Yx(e) {
|
|
18504
18513
|
return {
|
|
18505
18514
|
async create(t, n) {
|
|
18506
18515
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -18577,19 +18586,19 @@ function qx(e) {
|
|
|
18577
18586
|
}
|
|
18578
18587
|
//#endregion
|
|
18579
18588
|
//#region src/adapters/stats.ts
|
|
18580
|
-
var
|
|
18581
|
-
function
|
|
18589
|
+
var Xx = ["s"], Zx = ["pwd_leak"];
|
|
18590
|
+
function Qx(e) {
|
|
18582
18591
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
18583
18592
|
}
|
|
18584
|
-
function
|
|
18593
|
+
function $x(e) {
|
|
18585
18594
|
return {
|
|
18586
18595
|
async getDaily(t, n) {
|
|
18587
|
-
let r = /* @__PURE__ */ new Date(), i = n?.from ?
|
|
18596
|
+
let r = /* @__PURE__ */ new Date(), i = n?.from ? Qx(n.from) : (/* @__PURE__ */ new Date(r.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], a = n?.to ? Qx(n.to) : r.toISOString().split("T")[0];
|
|
18588
18597
|
return (await e.select({
|
|
18589
18598
|
date: p`substr(${E.date}, 1, 10)`.as("date"),
|
|
18590
|
-
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18599
|
+
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(Xx.map((e) => p`${e}`), p`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
18591
18600
|
signups: p`SUM(CASE WHEN ${E.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
18592
|
-
leaked_passwords: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18601
|
+
leaked_passwords: p`SUM(CASE WHEN ${E.type} IN (${p.join(Zx.map((e) => p`${e}`), p`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
18593
18602
|
}).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) => ({
|
|
18594
18603
|
date: e.date,
|
|
18595
18604
|
logins: Number(e.logins) || 0,
|
|
@@ -18600,14 +18609,14 @@ function Zx(e) {
|
|
|
18600
18609
|
}));
|
|
18601
18610
|
},
|
|
18602
18611
|
async getActiveUsers(t) {
|
|
18603
|
-
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(
|
|
18612
|
+
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(Xx.map((e) => p`${e}`), p`, `)})`));
|
|
18604
18613
|
return Number(r?.count) || 0;
|
|
18605
18614
|
}
|
|
18606
18615
|
};
|
|
18607
18616
|
}
|
|
18608
18617
|
//#endregion
|
|
18609
18618
|
//#region src/adapters/analytics.ts
|
|
18610
|
-
var
|
|
18619
|
+
var eS = {
|
|
18611
18620
|
"active-users": ["s", "seacft"],
|
|
18612
18621
|
logins: [
|
|
18613
18622
|
"s",
|
|
@@ -18616,8 +18625,27 @@ var Qx = {
|
|
|
18616
18625
|
],
|
|
18617
18626
|
signups: ["ss", "fs"],
|
|
18618
18627
|
"refresh-tokens": ["seacft", "fertft"],
|
|
18619
|
-
sessions: ["slo"]
|
|
18620
|
-
|
|
18628
|
+
sessions: ["slo"],
|
|
18629
|
+
logouts: ["slo", "flo"],
|
|
18630
|
+
"password-changes": [
|
|
18631
|
+
"scp",
|
|
18632
|
+
"fcp",
|
|
18633
|
+
"scpr",
|
|
18634
|
+
"fcpr"
|
|
18635
|
+
],
|
|
18636
|
+
mfa: [
|
|
18637
|
+
"gd_auth_succeed",
|
|
18638
|
+
"gd_auth_failed",
|
|
18639
|
+
"gd_auth_rejected"
|
|
18640
|
+
],
|
|
18641
|
+
"email-verifications": [
|
|
18642
|
+
"sv",
|
|
18643
|
+
"fv",
|
|
18644
|
+
"svr",
|
|
18645
|
+
"fvr"
|
|
18646
|
+
],
|
|
18647
|
+
"codes-sent": ["cls", "cs"]
|
|
18648
|
+
}, tS = {
|
|
18621
18649
|
"active-users": {
|
|
18622
18650
|
alias: "active_users",
|
|
18623
18651
|
type: "UInt64",
|
|
@@ -18642,9 +18670,34 @@ var Qx = {
|
|
|
18642
18670
|
alias: "sessions",
|
|
18643
18671
|
type: "UInt64",
|
|
18644
18672
|
agg: "count"
|
|
18673
|
+
},
|
|
18674
|
+
logouts: {
|
|
18675
|
+
alias: "logouts",
|
|
18676
|
+
type: "UInt64",
|
|
18677
|
+
agg: "count"
|
|
18678
|
+
},
|
|
18679
|
+
"password-changes": {
|
|
18680
|
+
alias: "password_changes",
|
|
18681
|
+
type: "UInt64",
|
|
18682
|
+
agg: "count"
|
|
18683
|
+
},
|
|
18684
|
+
mfa: {
|
|
18685
|
+
alias: "mfa",
|
|
18686
|
+
type: "UInt64",
|
|
18687
|
+
agg: "count"
|
|
18688
|
+
},
|
|
18689
|
+
"email-verifications": {
|
|
18690
|
+
alias: "email_verifications",
|
|
18691
|
+
type: "UInt64",
|
|
18692
|
+
agg: "count"
|
|
18693
|
+
},
|
|
18694
|
+
"codes-sent": {
|
|
18695
|
+
alias: "codes_sent",
|
|
18696
|
+
type: "UInt64",
|
|
18697
|
+
agg: "count"
|
|
18645
18698
|
}
|
|
18646
18699
|
};
|
|
18647
|
-
function
|
|
18700
|
+
function nS(e) {
|
|
18648
18701
|
switch (e) {
|
|
18649
18702
|
case "hour": return p`substr(${E.date}, 1, 13)`;
|
|
18650
18703
|
case "month": return p`substr(${E.date}, 1, 7)`;
|
|
@@ -18653,10 +18706,10 @@ function eS(e) {
|
|
|
18653
18706
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
18654
18707
|
}
|
|
18655
18708
|
}
|
|
18656
|
-
function
|
|
18709
|
+
function rS(e) {
|
|
18657
18710
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
18658
18711
|
}
|
|
18659
|
-
function
|
|
18712
|
+
function iS(e) {
|
|
18660
18713
|
switch (e) {
|
|
18661
18714
|
case "connection": return E.connection;
|
|
18662
18715
|
case "client_id": return E.client_id;
|
|
@@ -18665,9 +18718,9 @@ function nS(e) {
|
|
|
18665
18718
|
case "time": throw Error("time dimension handled separately");
|
|
18666
18719
|
}
|
|
18667
18720
|
}
|
|
18668
|
-
function
|
|
18721
|
+
function aS(e) {
|
|
18669
18722
|
return { async query(t, n, r) {
|
|
18670
|
-
let i = Date.now(), a =
|
|
18723
|
+
let i = Date.now(), a = eS[n], o = tS[n], s = [
|
|
18671
18724
|
m(E.tenant_id, t),
|
|
18672
18725
|
Ae(E.date, r.from),
|
|
18673
18726
|
je(E.date, r.to),
|
|
@@ -18676,13 +18729,13 @@ function rS(e) {
|
|
|
18676
18729
|
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));
|
|
18677
18730
|
let c = {}, l = [], u = [];
|
|
18678
18731
|
for (let e of r.group_by) if (e === "time") {
|
|
18679
|
-
let e =
|
|
18732
|
+
let e = nS(r.interval);
|
|
18680
18733
|
c.time = e, l.push(e), u.push({
|
|
18681
18734
|
name: "time",
|
|
18682
18735
|
type: r.interval === "hour" ? "DateTime" : "Date"
|
|
18683
18736
|
});
|
|
18684
18737
|
} else {
|
|
18685
|
-
let t =
|
|
18738
|
+
let t = iS(e);
|
|
18686
18739
|
c[e] = t, l.push(t), u.push({
|
|
18687
18740
|
name: e,
|
|
18688
18741
|
type: "String"
|
|
@@ -18698,9 +18751,9 @@ function rS(e) {
|
|
|
18698
18751
|
if (r.order_by) {
|
|
18699
18752
|
let e = r.order_by.startsWith("-"), t = e ? r.order_by.slice(1) : r.order_by;
|
|
18700
18753
|
if (!f.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
18701
|
-
let n =
|
|
18754
|
+
let n = rS(t);
|
|
18702
18755
|
d = d.orderBy(p.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
18703
|
-
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${
|
|
18756
|
+
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${rS("time")} ASC`)) : d.orderBy(p.raw(`${rS(o.alias)} DESC`));
|
|
18704
18757
|
d = d.limit(r.limit).offset(r.offset);
|
|
18705
18758
|
let ee = (await d.all()).map((e) => {
|
|
18706
18759
|
let t = {};
|
|
@@ -18722,13 +18775,13 @@ function rS(e) {
|
|
|
18722
18775
|
//#endregion
|
|
18723
18776
|
//#region src/adapters/outbox.ts
|
|
18724
18777
|
Xe();
|
|
18725
|
-
function
|
|
18778
|
+
function oS(e) {
|
|
18726
18779
|
return {
|
|
18727
18780
|
...e,
|
|
18728
18781
|
payload: A(e.payload, {})
|
|
18729
18782
|
};
|
|
18730
18783
|
}
|
|
18731
|
-
function
|
|
18784
|
+
function sS(e) {
|
|
18732
18785
|
return {
|
|
18733
18786
|
async create(t, n) {
|
|
18734
18787
|
let r = Ye(), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -18753,11 +18806,11 @@ function aS(e) {
|
|
|
18753
18806
|
}), r;
|
|
18754
18807
|
},
|
|
18755
18808
|
async getByIds(t) {
|
|
18756
|
-
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(
|
|
18809
|
+
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(oS);
|
|
18757
18810
|
},
|
|
18758
18811
|
async getUnprocessed(t) {
|
|
18759
18812
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
18760
|
-
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(
|
|
18813
|
+
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(oS);
|
|
18761
18814
|
},
|
|
18762
18815
|
async claimEvents(t, n, r) {
|
|
18763
18816
|
if (t.length === 0) return [];
|
|
@@ -18827,10 +18880,10 @@ function aS(e) {
|
|
|
18827
18880
|
}
|
|
18828
18881
|
//#endregion
|
|
18829
18882
|
//#region src/adapters/cleanup.ts
|
|
18830
|
-
var
|
|
18831
|
-
function
|
|
18883
|
+
var cS = 10080 * 60 * 1e3;
|
|
18884
|
+
function lS(e) {
|
|
18832
18885
|
return async (t) => {
|
|
18833
|
-
let n = Date.now() -
|
|
18886
|
+
let n = Date.now() - cS;
|
|
18834
18887
|
try {
|
|
18835
18888
|
let r = [Oe(je(S.expires_at_ts, n), je(S.idle_expires_at_ts, n))];
|
|
18836
18889
|
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));
|
|
@@ -18841,7 +18894,7 @@ function sS(e) {
|
|
|
18841
18894
|
}
|
|
18842
18895
|
//#endregion
|
|
18843
18896
|
//#region src/adapters/index.ts
|
|
18844
|
-
function
|
|
18897
|
+
function uS(e, t = { useTransactions: !0 }) {
|
|
18845
18898
|
let n = {
|
|
18846
18899
|
actions: Ln(e),
|
|
18847
18900
|
actionExecutions: Rn(e),
|
|
@@ -18870,22 +18923,22 @@ function cS(e, t = { useTransactions: !0 }) {
|
|
|
18870
18923
|
passwords: cx(e),
|
|
18871
18924
|
promptSettings: lx(e),
|
|
18872
18925
|
proxyRoutes: px(e),
|
|
18873
|
-
refreshTokens:
|
|
18874
|
-
resourceServers:
|
|
18875
|
-
rolePermissions:
|
|
18876
|
-
userPermissions:
|
|
18877
|
-
roles:
|
|
18878
|
-
sessions:
|
|
18879
|
-
sessionCleanup:
|
|
18880
|
-
tenants:
|
|
18881
|
-
themes:
|
|
18882
|
-
universalLoginTemplates:
|
|
18883
|
-
users:
|
|
18884
|
-
userRoles:
|
|
18885
|
-
userOrganizations:
|
|
18886
|
-
stats:
|
|
18887
|
-
analytics:
|
|
18888
|
-
outbox:
|
|
18926
|
+
refreshTokens: vx(e),
|
|
18927
|
+
resourceServers: wx(e),
|
|
18928
|
+
rolePermissions: Tx(e),
|
|
18929
|
+
userPermissions: Ex(e),
|
|
18930
|
+
roles: Ox(e),
|
|
18931
|
+
sessions: Nx(e),
|
|
18932
|
+
sessionCleanup: lS(e),
|
|
18933
|
+
tenants: Rx(e),
|
|
18934
|
+
themes: Vx(e),
|
|
18935
|
+
universalLoginTemplates: Hx(e),
|
|
18936
|
+
users: qx(e),
|
|
18937
|
+
userRoles: Jx(e),
|
|
18938
|
+
userOrganizations: Yx(e),
|
|
18939
|
+
stats: $x(e),
|
|
18940
|
+
analytics: aS(e),
|
|
18941
|
+
outbox: sS(e),
|
|
18889
18942
|
async transaction(r) {
|
|
18890
18943
|
if (t.useTransactions === !1) return r(n);
|
|
18891
18944
|
await e.run(p`BEGIN`);
|
|
@@ -18901,7 +18954,7 @@ function cS(e, t = { useTransactions: !0 }) {
|
|
|
18901
18954
|
}
|
|
18902
18955
|
//#endregion
|
|
18903
18956
|
//#region src/adapters/resolveHost.ts
|
|
18904
|
-
function
|
|
18957
|
+
function dS(e) {
|
|
18905
18958
|
if (!e) return { path: "/*" };
|
|
18906
18959
|
try {
|
|
18907
18960
|
let t = JSON.parse(e), n = Wy.safeParse(t);
|
|
@@ -18909,7 +18962,7 @@ function lS(e) {
|
|
|
18909
18962
|
} catch {}
|
|
18910
18963
|
return { path: "/*" };
|
|
18911
18964
|
}
|
|
18912
|
-
function
|
|
18965
|
+
function fS(e) {
|
|
18913
18966
|
if (!e) return [];
|
|
18914
18967
|
try {
|
|
18915
18968
|
let t = JSON.parse(e);
|
|
@@ -18924,7 +18977,7 @@ function uS(e) {
|
|
|
18924
18977
|
return [];
|
|
18925
18978
|
}
|
|
18926
18979
|
}
|
|
18927
|
-
async function
|
|
18980
|
+
async function pS(e, t) {
|
|
18928
18981
|
let n = t.toLowerCase(), r = (await e.select({
|
|
18929
18982
|
custom_domain_id: nn.custom_domain_id,
|
|
18930
18983
|
tenant_id: nn.tenant_id,
|
|
@@ -18936,8 +18989,8 @@ async function dS(e, t) {
|
|
|
18936
18989
|
tenant_id: e.tenant_id,
|
|
18937
18990
|
custom_domain_id: e.custom_domain_id,
|
|
18938
18991
|
priority: e.priority,
|
|
18939
|
-
match:
|
|
18940
|
-
handlers:
|
|
18992
|
+
match: dS(e.match),
|
|
18993
|
+
handlers: fS(e.handlers),
|
|
18941
18994
|
created_at: e.created_at,
|
|
18942
18995
|
updated_at: e.updated_at
|
|
18943
18996
|
}));
|
|
@@ -18950,11 +19003,11 @@ async function dS(e, t) {
|
|
|
18950
19003
|
}
|
|
18951
19004
|
//#endregion
|
|
18952
19005
|
//#region src/adapters/proxyData.ts
|
|
18953
|
-
function
|
|
19006
|
+
function mS(e) {
|
|
18954
19007
|
return {
|
|
18955
19008
|
proxyRoutes: px(e),
|
|
18956
|
-
resolveHost: (t) =>
|
|
19009
|
+
resolveHost: (t) => pS(e, t)
|
|
18957
19010
|
};
|
|
18958
19011
|
}
|
|
18959
19012
|
//#endregion
|
|
18960
|
-
export {
|
|
19013
|
+
export { mS as createProxyDataAdapter, px as createProxyRoutesAdapter, uS as default, En as sqlite };
|