@authhero/drizzle 0.54.2 → 0.56.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/drizzle-adapter.mjs
CHANGED
|
@@ -1067,6 +1067,7 @@ var b = y("tenants", {
|
|
|
1067
1067
|
provisioning_state_changed_at: _("provisioning_state_changed_at", { length: 35 }),
|
|
1068
1068
|
bundle_configuration: _("bundle_configuration", { length: 64 }),
|
|
1069
1069
|
worker_version: _("worker_version", { length: 64 }),
|
|
1070
|
+
database_version: _("database_version", { length: 64 }),
|
|
1070
1071
|
worker_script_name: _("worker_script_name", { length: 255 }),
|
|
1071
1072
|
storage_kind: _("storage_kind", { length: 32 }),
|
|
1072
1073
|
d1_database_id: _("d1_database_id", { length: 64 })
|
|
@@ -15774,6 +15775,7 @@ var Ly = q({
|
|
|
15774
15775
|
provisioning_state_changed_at: V().optional(),
|
|
15775
15776
|
bundle_configuration: V().max(64).optional(),
|
|
15776
15777
|
worker_version: V().max(64).optional(),
|
|
15778
|
+
database_version: V().max(64).optional(),
|
|
15777
15779
|
worker_script_name: V().max(255).optional(),
|
|
15778
15780
|
storage_kind: Y([
|
|
15779
15781
|
"own_d1",
|
|
@@ -16326,7 +16328,11 @@ rb.superRefine(ib), rb.extend({
|
|
|
16326
16328
|
id: V(),
|
|
16327
16329
|
created_at: V(),
|
|
16328
16330
|
updated_at: V()
|
|
16329
|
-
}).superRefine(ib)
|
|
16331
|
+
}).superRefine(ib), q({
|
|
16332
|
+
id: V().optional(),
|
|
16333
|
+
created_at: V().datetime({ offset: !0 }).optional(),
|
|
16334
|
+
updated_at: V().datetime({ offset: !0 }).optional()
|
|
16335
|
+
});
|
|
16330
16336
|
function ab(e) {
|
|
16331
16337
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
16332
16338
|
}
|
|
@@ -17643,9 +17649,31 @@ function px(e) {
|
|
|
17643
17649
|
};
|
|
17644
17650
|
}
|
|
17645
17651
|
//#endregion
|
|
17652
|
+
//#region src/adapters/atomic.ts
|
|
17653
|
+
function mx(e) {
|
|
17654
|
+
let t = e;
|
|
17655
|
+
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
17656
|
+
}
|
|
17657
|
+
async function hx(e, t) {
|
|
17658
|
+
if (mx(e)) return e.batch(t);
|
|
17659
|
+
await e.run(p`BEGIN`);
|
|
17660
|
+
try {
|
|
17661
|
+
let n = [];
|
|
17662
|
+
for (let e of t) n.push(await e);
|
|
17663
|
+
return await e.run(p`COMMIT`), n;
|
|
17664
|
+
} catch (t) {
|
|
17665
|
+
try {
|
|
17666
|
+
await e.run(p`ROLLBACK`);
|
|
17667
|
+
} catch (e) {
|
|
17668
|
+
console.error("runAtomic rollback failed", e);
|
|
17669
|
+
}
|
|
17670
|
+
throw t;
|
|
17671
|
+
}
|
|
17672
|
+
}
|
|
17673
|
+
//#endregion
|
|
17646
17674
|
//#region src/adapters/refreshTokens.ts
|
|
17647
17675
|
Xe();
|
|
17648
|
-
function
|
|
17676
|
+
function gx(e) {
|
|
17649
17677
|
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({
|
|
17650
17678
|
created_at_ts: n,
|
|
17651
17679
|
expires_at_ts: r,
|
|
@@ -17668,10 +17696,10 @@ function mx(e) {
|
|
|
17668
17696
|
resource_servers: A(l, [])
|
|
17669
17697
|
});
|
|
17670
17698
|
}
|
|
17671
|
-
function
|
|
17699
|
+
function _x(e, t) {
|
|
17672
17700
|
return Math.max(e ?? 0, t ?? 0);
|
|
17673
17701
|
}
|
|
17674
|
-
function
|
|
17702
|
+
function vx(e) {
|
|
17675
17703
|
return {
|
|
17676
17704
|
async create(t, n) {
|
|
17677
17705
|
let r = Date.now(), i = {
|
|
@@ -17692,30 +17720,22 @@ function gx(e) {
|
|
|
17692
17720
|
expires_at_ts: $(n.expires_at),
|
|
17693
17721
|
idle_expires_at_ts: $(n.idle_expires_at),
|
|
17694
17722
|
last_exchanged_at_ts: $(n.last_exchanged_at)
|
|
17695
|
-
};
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
n > 0 && i.login_id && await e.update(C).set({
|
|
17701
|
-
expires_at_ts: n,
|
|
17702
|
-
updated_at_ts: r
|
|
17703
|
-
}).where(h(m(C.tenant_id, t), m(C.id, i.login_id), je(C.expires_at_ts, n))), await e.run(p`COMMIT`);
|
|
17704
|
-
} catch (t) {
|
|
17705
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
17706
|
-
}
|
|
17707
|
-
return mx({
|
|
17723
|
+
}, a = [e.insert(S).values(i)], o = _x(i.expires_at_ts, i.idle_expires_at_ts);
|
|
17724
|
+
return o > 0 && i.login_id && a.push(e.update(C).set({
|
|
17725
|
+
expires_at_ts: o,
|
|
17726
|
+
updated_at_ts: r
|
|
17727
|
+
}).where(h(m(C.tenant_id, t), m(C.id, i.login_id), je(C.expires_at_ts, o)))), await hx(e, a), gx({
|
|
17708
17728
|
...i,
|
|
17709
17729
|
tenant_id: t
|
|
17710
17730
|
});
|
|
17711
17731
|
},
|
|
17712
17732
|
async get(t, n) {
|
|
17713
17733
|
let r = await e.select().from(S).where(h(m(S.tenant_id, t), m(S.id, n))).get();
|
|
17714
|
-
return r ?
|
|
17734
|
+
return r ? gx(r) : null;
|
|
17715
17735
|
},
|
|
17716
17736
|
async getByLookup(t, n) {
|
|
17717
17737
|
let r = await e.select().from(S).where(h(m(S.tenant_id, t), m(S.token_lookup, n))).get();
|
|
17718
|
-
return r ?
|
|
17738
|
+
return r ? gx(r) : null;
|
|
17719
17739
|
},
|
|
17720
17740
|
async update(t, n, r, i) {
|
|
17721
17741
|
let a = {};
|
|
@@ -17736,7 +17756,7 @@ function gx(e) {
|
|
|
17736
17756
|
let e = S[o.sort_by];
|
|
17737
17757
|
e && (c = c.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
17738
17758
|
}
|
|
17739
|
-
let l = (await c.offset(r * i).limit(i)).map(
|
|
17759
|
+
let l = (await c.offset(r * i).limit(i)).map(gx);
|
|
17740
17760
|
if (!a) return { refresh_tokens: l };
|
|
17741
17761
|
let [u] = await e.select({ count: Be() }).from(S).where(m(S.tenant_id, t));
|
|
17742
17762
|
return {
|
|
@@ -17759,16 +17779,16 @@ function gx(e) {
|
|
|
17759
17779
|
}
|
|
17760
17780
|
//#endregion
|
|
17761
17781
|
//#region src/adapters/resourceServers.ts
|
|
17762
|
-
var
|
|
17763
|
-
function
|
|
17782
|
+
var yx = ["name", "identifier"];
|
|
17783
|
+
function bx() {
|
|
17764
17784
|
let { customAlphabet: e } = (Xe(), s(Ge));
|
|
17765
17785
|
return `api_${e("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
17766
17786
|
}
|
|
17767
|
-
var
|
|
17787
|
+
var xx = [
|
|
17768
17788
|
"skip_consent_for_verifiable_first_party_clients",
|
|
17769
17789
|
"allow_offline_access",
|
|
17770
17790
|
"is_system"
|
|
17771
|
-
],
|
|
17791
|
+
], Sx = /* @__PURE__ */ new Set([
|
|
17772
17792
|
"id",
|
|
17773
17793
|
"tenant_id",
|
|
17774
17794
|
"identifier",
|
|
@@ -17787,17 +17807,17 @@ var yx = [
|
|
|
17787
17807
|
"created_at",
|
|
17788
17808
|
"updated_at"
|
|
17789
17809
|
]);
|
|
17790
|
-
function
|
|
17810
|
+
function Cx(e) {
|
|
17791
17811
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
17792
17812
|
s.scopes = A(r, []), s.options = A(i, {}), s.metadata = A(a), n !== void 0 && (s.verificationKey = n);
|
|
17793
|
-
for (let e of
|
|
17813
|
+
for (let e of xx) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
17794
17814
|
return k(s);
|
|
17795
17815
|
}
|
|
17796
|
-
function
|
|
17816
|
+
function wx(e) {
|
|
17797
17817
|
return {
|
|
17798
17818
|
async create(t, n) {
|
|
17799
17819
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
17800
|
-
id: n.id ||
|
|
17820
|
+
id: n.id || bx(),
|
|
17801
17821
|
tenant_id: t,
|
|
17802
17822
|
identifier: n.identifier,
|
|
17803
17823
|
name: n.name,
|
|
@@ -17812,37 +17832,37 @@ function Sx(e) {
|
|
|
17812
17832
|
created_at: r,
|
|
17813
17833
|
updated_at: r
|
|
17814
17834
|
};
|
|
17815
|
-
for (let e of
|
|
17816
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(fn).values(i),
|
|
17835
|
+
for (let e of xx) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
17836
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(fn).values(i), Cx({
|
|
17817
17837
|
...i,
|
|
17818
17838
|
tenant_id: t
|
|
17819
17839
|
});
|
|
17820
17840
|
},
|
|
17821
17841
|
async get(t, n) {
|
|
17822
17842
|
let r = await e.select().from(fn).where(h(m(fn.tenant_id, t), m(fn.id, n))).get();
|
|
17823
|
-
return r ?
|
|
17843
|
+
return r ? Cx(r) : null;
|
|
17824
17844
|
},
|
|
17825
17845
|
async update(t, n, r) {
|
|
17826
17846
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
17827
17847
|
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);
|
|
17828
|
-
for (let e of
|
|
17848
|
+
for (let e of xx) r[e] !== void 0 && (i[e] = +!!r[e]);
|
|
17829
17849
|
return (await e.update(fn).set(i).where(h(m(fn.tenant_id, t), m(fn.id, n))).returning()).length > 0;
|
|
17830
17850
|
},
|
|
17831
17851
|
async list(t, n) {
|
|
17832
17852
|
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)];
|
|
17833
17853
|
if (s) {
|
|
17834
|
-
let e = Nn(s,
|
|
17854
|
+
let e = Nn(s, yx);
|
|
17835
17855
|
if (e) {
|
|
17836
|
-
let t = Pn(fn, e,
|
|
17856
|
+
let t = Pn(fn, e, yx, ["name", "identifier"]);
|
|
17837
17857
|
t && u.push(t);
|
|
17838
17858
|
}
|
|
17839
17859
|
}
|
|
17840
17860
|
let d = e.select().from(fn).where(h(...u)).$dynamic();
|
|
17841
|
-
if (o?.sort_by &&
|
|
17861
|
+
if (o?.sort_by && Sx.has(o.sort_by)) {
|
|
17842
17862
|
let e = fn[o.sort_by];
|
|
17843
17863
|
d = d.orderBy(o.sort_order === "desc" ? ze(e) : Re(e));
|
|
17844
17864
|
}
|
|
17845
|
-
let f = (await d.offset(c * l).limit(l)).map(
|
|
17865
|
+
let f = (await d.offset(c * l).limit(l)).map(Cx);
|
|
17846
17866
|
if (!a) return { resource_servers: f };
|
|
17847
17867
|
let [ee] = await e.select({ count: Be() }).from(fn).where(h(...u));
|
|
17848
17868
|
return {
|
|
@@ -17859,7 +17879,7 @@ function Sx(e) {
|
|
|
17859
17879
|
}
|
|
17860
17880
|
//#endregion
|
|
17861
17881
|
//#region src/adapters/rolePermissions.ts
|
|
17862
|
-
function
|
|
17882
|
+
function Tx(e) {
|
|
17863
17883
|
return {
|
|
17864
17884
|
async assign(t, n, r) {
|
|
17865
17885
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -17897,7 +17917,7 @@ function Cx(e) {
|
|
|
17897
17917
|
}
|
|
17898
17918
|
//#endregion
|
|
17899
17919
|
//#region src/adapters/userPermissions.ts
|
|
17900
|
-
function
|
|
17920
|
+
function Ex(e) {
|
|
17901
17921
|
return {
|
|
17902
17922
|
async create(t, n, r, i) {
|
|
17903
17923
|
try {
|
|
@@ -17937,7 +17957,7 @@ function wx(e) {
|
|
|
17937
17957
|
//#endregion
|
|
17938
17958
|
//#region src/adapters/roles.ts
|
|
17939
17959
|
Xe();
|
|
17940
|
-
function
|
|
17960
|
+
function Dx(e) {
|
|
17941
17961
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
17942
17962
|
return k({
|
|
17943
17963
|
...i,
|
|
@@ -17945,7 +17965,7 @@ function Tx(e) {
|
|
|
17945
17965
|
metadata: A(r)
|
|
17946
17966
|
});
|
|
17947
17967
|
}
|
|
17948
|
-
function
|
|
17968
|
+
function Ox(e) {
|
|
17949
17969
|
return {
|
|
17950
17970
|
async create(t, n) {
|
|
17951
17971
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -17958,14 +17978,14 @@ function Ex(e) {
|
|
|
17958
17978
|
created_at: r,
|
|
17959
17979
|
updated_at: r
|
|
17960
17980
|
};
|
|
17961
|
-
return await e.insert(cn).values(i),
|
|
17981
|
+
return await e.insert(cn).values(i), Dx({
|
|
17962
17982
|
...i,
|
|
17963
17983
|
tenant_id: t
|
|
17964
17984
|
});
|
|
17965
17985
|
},
|
|
17966
17986
|
async get(t, n) {
|
|
17967
17987
|
let r = await e.select().from(cn).where(h(m(cn.tenant_id, t), m(cn.id, n))).get();
|
|
17968
|
-
return r ?
|
|
17988
|
+
return r ? Dx(r) : null;
|
|
17969
17989
|
},
|
|
17970
17990
|
async update(t, n, r) {
|
|
17971
17991
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -17977,7 +17997,7 @@ function Ex(e) {
|
|
|
17977
17997
|
let e = cn[o.sort_by];
|
|
17978
17998
|
e && (u = u.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
17979
17999
|
}
|
|
17980
|
-
let d = (await u.offset(r * i).limit(i)).map(
|
|
18000
|
+
let d = (await u.offset(r * i).limit(i)).map(Dx);
|
|
17981
18001
|
if (!a) return { roles: d };
|
|
17982
18002
|
let [f] = await e.select({ count: Be() }).from(cn).where(l);
|
|
17983
18003
|
return {
|
|
@@ -17995,7 +18015,7 @@ function Ex(e) {
|
|
|
17995
18015
|
//#endregion
|
|
17996
18016
|
//#region src/adapters/sessions.ts
|
|
17997
18017
|
Xe();
|
|
17998
|
-
var
|
|
18018
|
+
var kx = ["created_at_ts", "updated_at_ts"], Ax = [
|
|
17999
18019
|
"expires_at_ts",
|
|
18000
18020
|
"idle_expires_at_ts",
|
|
18001
18021
|
"authenticated_at_ts",
|
|
@@ -18003,7 +18023,7 @@ var Dx = ["created_at_ts", "updated_at_ts"], Ox = [
|
|
|
18003
18023
|
"used_at_ts",
|
|
18004
18024
|
"revoked_at_ts"
|
|
18005
18025
|
];
|
|
18006
|
-
function
|
|
18026
|
+
function jx(e) {
|
|
18007
18027
|
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({
|
|
18008
18028
|
created_at_ts: n,
|
|
18009
18029
|
updated_at_ts: r,
|
|
@@ -18013,7 +18033,7 @@ function kx(e) {
|
|
|
18013
18033
|
last_interaction_at_ts: s,
|
|
18014
18034
|
used_at_ts: c,
|
|
18015
18035
|
revoked_at_ts: l
|
|
18016
|
-
}, [...
|
|
18036
|
+
}, [...kx], [...Ax]);
|
|
18017
18037
|
return k({
|
|
18018
18038
|
...f,
|
|
18019
18039
|
...ee,
|
|
@@ -18021,10 +18041,10 @@ function kx(e) {
|
|
|
18021
18041
|
clients: A(d, [])
|
|
18022
18042
|
});
|
|
18023
18043
|
}
|
|
18024
|
-
function
|
|
18044
|
+
function Mx(e, t) {
|
|
18025
18045
|
return Math.max(e ?? 0, t ?? 0);
|
|
18026
18046
|
}
|
|
18027
|
-
function
|
|
18047
|
+
function Nx(e) {
|
|
18028
18048
|
return {
|
|
18029
18049
|
async create(t, n) {
|
|
18030
18050
|
let r = Date.now(), i = {
|
|
@@ -18042,31 +18062,23 @@ function jx(e) {
|
|
|
18042
18062
|
last_interaction_at_ts: n.last_interaction_at ? $(n.last_interaction_at) : r,
|
|
18043
18063
|
used_at_ts: $(n.used_at),
|
|
18044
18064
|
revoked_at_ts: $(n.revoked_at)
|
|
18045
|
-
};
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
|
|
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({
|
|
18065
|
+
}, a = [e.insert(Yt).values(i)], o = Mx(i.expires_at_ts, i.idle_expires_at_ts);
|
|
18066
|
+
return o > 0 && i.login_session_id && a.push(e.update(C).set({
|
|
18067
|
+
expires_at_ts: o,
|
|
18068
|
+
updated_at_ts: r
|
|
18069
|
+
}).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({
|
|
18058
18070
|
...i,
|
|
18059
18071
|
tenant_id: t
|
|
18060
18072
|
});
|
|
18061
18073
|
},
|
|
18062
18074
|
async get(t, n) {
|
|
18063
18075
|
let r = await e.select().from(Yt).where(h(m(Yt.tenant_id, t), m(Yt.id, n))).get();
|
|
18064
|
-
return r ?
|
|
18076
|
+
return r ? jx(r) : null;
|
|
18065
18077
|
},
|
|
18066
18078
|
async update(t, n, r) {
|
|
18067
18079
|
let i = { updated_at_ts: Date.now() };
|
|
18068
18080
|
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 =
|
|
18081
|
+
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];
|
|
18070
18082
|
if (o > 0 && s) {
|
|
18071
18083
|
let n = r.login_session_id ?? s.login_session_id;
|
|
18072
18084
|
n && await e.update(C).set({
|
|
@@ -18082,7 +18094,7 @@ function jx(e) {
|
|
|
18082
18094
|
let e = Yt[o.sort_by];
|
|
18083
18095
|
e && (u = u.orderBy(o.sort_order === "desc" ? ze(e) : Re(e)));
|
|
18084
18096
|
}
|
|
18085
|
-
let d = (await u.offset(r * i).limit(i)).map(
|
|
18097
|
+
let d = (await u.offset(r * i).limit(i)).map(jx);
|
|
18086
18098
|
if (!a) return { sessions: d };
|
|
18087
18099
|
let [f] = await e.select({ count: Be() }).from(Yt).where(l);
|
|
18088
18100
|
return {
|
|
@@ -18100,7 +18112,7 @@ function jx(e) {
|
|
|
18100
18112
|
//#endregion
|
|
18101
18113
|
//#region src/adapters/tenants.ts
|
|
18102
18114
|
Xe();
|
|
18103
|
-
var
|
|
18115
|
+
var Px = [
|
|
18104
18116
|
"session_cookie",
|
|
18105
18117
|
"enabled_locales",
|
|
18106
18118
|
"error_page",
|
|
@@ -18116,25 +18128,25 @@ var Mx = [
|
|
|
18116
18128
|
"acr_values_supported",
|
|
18117
18129
|
"mtls",
|
|
18118
18130
|
"mfa"
|
|
18119
|
-
],
|
|
18131
|
+
], Fx = [
|
|
18120
18132
|
"allow_organization_name_in_authentication_api",
|
|
18121
18133
|
"customize_mfa_in_postlogin_action",
|
|
18122
18134
|
"pushed_authorization_requests_supported",
|
|
18123
18135
|
"authorization_response_iss_parameter_supported"
|
|
18124
18136
|
];
|
|
18125
|
-
function
|
|
18137
|
+
function Ix(e) {
|
|
18126
18138
|
let t = { ...e };
|
|
18127
|
-
for (let e of
|
|
18128
|
-
for (let e of
|
|
18139
|
+
for (let e of Px) typeof t[e] == "string" && (t[e] = A(t[e]));
|
|
18140
|
+
for (let e of Fx) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
18129
18141
|
return k(t);
|
|
18130
18142
|
}
|
|
18131
|
-
function
|
|
18143
|
+
function Lx(e) {
|
|
18132
18144
|
let t = { ...e };
|
|
18133
|
-
Dn(e,
|
|
18134
|
-
for (let n of
|
|
18145
|
+
Dn(e, Px, t);
|
|
18146
|
+
for (let n of Fx) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
18135
18147
|
return kn(t);
|
|
18136
18148
|
}
|
|
18137
|
-
function
|
|
18149
|
+
function Rx(e) {
|
|
18138
18150
|
return {
|
|
18139
18151
|
async create(t) {
|
|
18140
18152
|
let n = {
|
|
@@ -18142,7 +18154,7 @@ function Ix(e) {
|
|
|
18142
18154
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18143
18155
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18144
18156
|
...t
|
|
18145
|
-
}, r =
|
|
18157
|
+
}, r = Lx(n);
|
|
18146
18158
|
try {
|
|
18147
18159
|
await e.insert(b).values(r);
|
|
18148
18160
|
} catch (e) {
|
|
@@ -18153,7 +18165,7 @@ function Ix(e) {
|
|
|
18153
18165
|
},
|
|
18154
18166
|
async get(t) {
|
|
18155
18167
|
let n = await e.select().from(b).where(m(b.id, t)).get();
|
|
18156
|
-
return n ?
|
|
18168
|
+
return n ? Ix(n) : null;
|
|
18157
18169
|
},
|
|
18158
18170
|
async list(t) {
|
|
18159
18171
|
let { page: n = 0, per_page: r = 50, include_totals: i = !1, sort: a, q: o } = t || {}, s = e.select().from(b).$dynamic();
|
|
@@ -18165,7 +18177,7 @@ function Ix(e) {
|
|
|
18165
18177
|
let e = b[a.sort_by];
|
|
18166
18178
|
e && (s = s.orderBy(a.sort_order === "desc" ? ze(e) : Re(e)));
|
|
18167
18179
|
}
|
|
18168
|
-
let c = (await s.offset(n * r).limit(r)).map(
|
|
18180
|
+
let c = (await s.offset(n * r).limit(r)).map(Ix);
|
|
18169
18181
|
if (!i) return { tenants: c };
|
|
18170
18182
|
let [l] = await e.select({ count: Be() }).from(b);
|
|
18171
18183
|
return {
|
|
@@ -18176,7 +18188,7 @@ function Ix(e) {
|
|
|
18176
18188
|
};
|
|
18177
18189
|
},
|
|
18178
18190
|
async update(t, n) {
|
|
18179
|
-
let r =
|
|
18191
|
+
let r = Lx({
|
|
18180
18192
|
...n,
|
|
18181
18193
|
id: t,
|
|
18182
18194
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -18191,35 +18203,38 @@ function Ix(e) {
|
|
|
18191
18203
|
//#endregion
|
|
18192
18204
|
//#region src/adapters/themes.ts
|
|
18193
18205
|
Xe();
|
|
18194
|
-
var
|
|
18206
|
+
var zx = [
|
|
18195
18207
|
"colors",
|
|
18196
18208
|
"borders",
|
|
18197
18209
|
"fonts",
|
|
18198
18210
|
"page_background",
|
|
18199
18211
|
"widget"
|
|
18200
18212
|
];
|
|
18201
|
-
function
|
|
18202
|
-
let { tenant_id: t, ...n } = e, r = jn(n,
|
|
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);
|
|
18213
|
+
function Bx(e) {
|
|
18214
|
+
let { tenant_id: t, ...n } = e, r = jn(n, zx);
|
|
18215
|
+
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);
|
|
18204
18216
|
}
|
|
18205
|
-
function
|
|
18217
|
+
function Vx(e) {
|
|
18206
18218
|
return {
|
|
18207
|
-
async create(t, n, r) {
|
|
18208
|
-
let i = (/* @__PURE__ */ new Date()).toISOString(),
|
|
18219
|
+
async create(t, n, r, i) {
|
|
18220
|
+
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || Ye(), c = {
|
|
18209
18221
|
...An(n),
|
|
18210
18222
|
tenant_id: t,
|
|
18211
|
-
themeId:
|
|
18212
|
-
created_at:
|
|
18213
|
-
updated_at:
|
|
18223
|
+
themeId: s,
|
|
18224
|
+
created_at: a?.created_at ?? o,
|
|
18225
|
+
updated_at: a?.updated_at ?? o
|
|
18214
18226
|
};
|
|
18215
|
-
return await e.insert(hn).values(
|
|
18216
|
-
...
|
|
18227
|
+
return await e.insert(hn).values(c), Bx({
|
|
18228
|
+
...c,
|
|
18217
18229
|
tenant_id: t
|
|
18218
18230
|
});
|
|
18219
18231
|
},
|
|
18220
18232
|
async get(t, n) {
|
|
18221
18233
|
let r = await e.select().from(hn).where(h(m(hn.tenant_id, t), m(hn.themeId, n))).get();
|
|
18222
|
-
return r ?
|
|
18234
|
+
return r ? Bx(r) : null;
|
|
18235
|
+
},
|
|
18236
|
+
async list(t) {
|
|
18237
|
+
return (await e.select().from(hn).where(m(hn.tenant_id, t)).all()).map(Bx);
|
|
18223
18238
|
},
|
|
18224
18239
|
async update(t, n, r) {
|
|
18225
18240
|
let i = An(r);
|
|
@@ -18232,7 +18247,7 @@ function zx(e) {
|
|
|
18232
18247
|
}
|
|
18233
18248
|
//#endregion
|
|
18234
18249
|
//#region src/adapters/universalLoginTemplates.ts
|
|
18235
|
-
function
|
|
18250
|
+
function Hx(e) {
|
|
18236
18251
|
return {
|
|
18237
18252
|
async get(t) {
|
|
18238
18253
|
let n = await e.select({ body: mn.body }).from(mn).where(m(mn.tenant_id, t)).get();
|
|
@@ -18261,7 +18276,7 @@ function Bx(e) {
|
|
|
18261
18276
|
//#endregion
|
|
18262
18277
|
//#region src/adapters/users.ts
|
|
18263
18278
|
Xe();
|
|
18264
|
-
var
|
|
18279
|
+
var Ux = [
|
|
18265
18280
|
"user_id",
|
|
18266
18281
|
"email",
|
|
18267
18282
|
"email_verified",
|
|
@@ -18283,13 +18298,13 @@ var Vx = [
|
|
|
18283
18298
|
"login_count",
|
|
18284
18299
|
"created_at",
|
|
18285
18300
|
"updated_at"
|
|
18286
|
-
],
|
|
18301
|
+
], Wx = [
|
|
18287
18302
|
"email",
|
|
18288
18303
|
"name",
|
|
18289
18304
|
"phone_number",
|
|
18290
18305
|
"user_id"
|
|
18291
18306
|
];
|
|
18292
|
-
function
|
|
18307
|
+
function Gx(e, t) {
|
|
18293
18308
|
let n = {
|
|
18294
18309
|
connection: e.connection,
|
|
18295
18310
|
provider: e.provider,
|
|
@@ -18302,8 +18317,8 @@ function Ux(e, t) {
|
|
|
18302
18317
|
...typeof e.profileData == "string" ? A(e.profileData, {}) : {}
|
|
18303
18318
|
}, n;
|
|
18304
18319
|
}
|
|
18305
|
-
function
|
|
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 =
|
|
18320
|
+
function Kx(e, t = []) {
|
|
18321
|
+
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));
|
|
18307
18322
|
return k({
|
|
18308
18323
|
...d,
|
|
18309
18324
|
email: e.email || "",
|
|
@@ -18316,7 +18331,7 @@ function Wx(e, t = []) {
|
|
|
18316
18331
|
identities: [f, ...ee]
|
|
18317
18332
|
});
|
|
18318
18333
|
}
|
|
18319
|
-
function
|
|
18334
|
+
function qx(e) {
|
|
18320
18335
|
let t = async (t, n) => {
|
|
18321
18336
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
18322
18337
|
user_id: n.user_id,
|
|
@@ -18355,34 +18370,27 @@ function Gx(e) {
|
|
|
18355
18370
|
updated_at: n.updated_at || r
|
|
18356
18371
|
}, a = n.password ? Ye() : void 0;
|
|
18357
18372
|
try {
|
|
18358
|
-
|
|
18359
|
-
|
|
18360
|
-
|
|
18361
|
-
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
created_at: r,
|
|
18369
|
-
updated_at: r
|
|
18370
|
-
}), await e.run(p`COMMIT`);
|
|
18371
|
-
} catch (t) {
|
|
18372
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
18373
|
-
}
|
|
18374
|
-
} else await e.insert(x).values(i);
|
|
18373
|
+
n.password && a ? await hx(e, [e.insert(x).values(i), e.insert(Jt).values({
|
|
18374
|
+
id: a,
|
|
18375
|
+
tenant_id: t,
|
|
18376
|
+
user_id: n.user_id,
|
|
18377
|
+
password: n.password.hash || n.password,
|
|
18378
|
+
algorithm: n.password.algorithm || "bcrypt",
|
|
18379
|
+
is_current: 1,
|
|
18380
|
+
created_at: r,
|
|
18381
|
+
updated_at: r
|
|
18382
|
+
})]) : await e.insert(x).values(i);
|
|
18375
18383
|
} catch (e) {
|
|
18376
18384
|
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" }));
|
|
18377
18385
|
}
|
|
18378
|
-
return
|
|
18386
|
+
return Kx(i);
|
|
18379
18387
|
};
|
|
18380
18388
|
return {
|
|
18381
18389
|
create: t,
|
|
18382
18390
|
rawCreate: t,
|
|
18383
18391
|
async get(t, n) {
|
|
18384
18392
|
let r = await e.select().from(x).where(h(m(x.tenant_id, t), m(x.user_id, n))).get();
|
|
18385
|
-
return r ?
|
|
18393
|
+
return r ? Kx(r, await e.select().from(x).where(h(m(x.tenant_id, t), m(x.linked_to, n))).all()) : null;
|
|
18386
18394
|
},
|
|
18387
18395
|
async update(t, n, r) {
|
|
18388
18396
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -18416,9 +18424,9 @@ function Gx(e) {
|
|
|
18416
18424
|
async list(t, n) {
|
|
18417
18425
|
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)];
|
|
18418
18426
|
if (s) {
|
|
18419
|
-
let e = Nn(s,
|
|
18427
|
+
let e = Nn(s, Ux);
|
|
18420
18428
|
if (e) {
|
|
18421
|
-
let t = Pn(x, e,
|
|
18429
|
+
let t = Pn(x, e, Wx);
|
|
18422
18430
|
t && c.push(t);
|
|
18423
18431
|
}
|
|
18424
18432
|
}
|
|
@@ -18429,7 +18437,7 @@ function Gx(e) {
|
|
|
18429
18437
|
}
|
|
18430
18438
|
let d = await u.offset(r * i).limit(i), f = d.map((e) => e.user_id), ee = [];
|
|
18431
18439
|
f.length > 0 && (ee = await e.select().from(x).where(h(m(x.tenant_id, t), Ne(x.linked_to, f))));
|
|
18432
|
-
let te = d.map((e) =>
|
|
18440
|
+
let te = d.map((e) => Kx(e, ee.filter((t) => t.linked_to === e.user_id)));
|
|
18433
18441
|
if (!a) return { users: te };
|
|
18434
18442
|
let [ne] = await e.select({ count: Be() }).from(x).where(l);
|
|
18435
18443
|
return {
|
|
@@ -18440,15 +18448,13 @@ function Gx(e) {
|
|
|
18440
18448
|
};
|
|
18441
18449
|
},
|
|
18442
18450
|
async remove(t, n) {
|
|
18443
|
-
await e.
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
throw await e.run(p`ROLLBACK`), t;
|
|
18451
|
-
}
|
|
18451
|
+
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, [
|
|
18452
|
+
e.delete(Tn).where(h(m(Tn.tenant_id, t), Ne(Tn.user_id, i))),
|
|
18453
|
+
e.delete(Jt).where(h(m(Jt.tenant_id, t), Ne(Jt.user_id, i))),
|
|
18454
|
+
e.delete(x).where(h(m(x.tenant_id, t), Ne(x.user_id, r))),
|
|
18455
|
+
e.delete(x).where(h(m(x.tenant_id, t), m(x.user_id, n))).returning()
|
|
18456
|
+
]), o = a[a.length - 1];
|
|
18457
|
+
return Array.isArray(o) && o.length > 0;
|
|
18452
18458
|
},
|
|
18453
18459
|
async unlink(t, n, r, i) {
|
|
18454
18460
|
let a = `${r}|${i}`;
|
|
@@ -18458,7 +18464,7 @@ function Gx(e) {
|
|
|
18458
18464
|
}
|
|
18459
18465
|
//#endregion
|
|
18460
18466
|
//#region src/adapters/userRoles.ts
|
|
18461
|
-
function
|
|
18467
|
+
function Jx(e) {
|
|
18462
18468
|
return {
|
|
18463
18469
|
async create(t, n, r, i) {
|
|
18464
18470
|
try {
|
|
@@ -18498,7 +18504,7 @@ function Kx(e) {
|
|
|
18498
18504
|
//#endregion
|
|
18499
18505
|
//#region src/adapters/userOrganizations.ts
|
|
18500
18506
|
Xe();
|
|
18501
|
-
function
|
|
18507
|
+
function Yx(e) {
|
|
18502
18508
|
return {
|
|
18503
18509
|
async create(t, n) {
|
|
18504
18510
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -18575,19 +18581,19 @@ function qx(e) {
|
|
|
18575
18581
|
}
|
|
18576
18582
|
//#endregion
|
|
18577
18583
|
//#region src/adapters/stats.ts
|
|
18578
|
-
var
|
|
18579
|
-
function
|
|
18584
|
+
var Xx = ["s"], Zx = ["pwd_leak"];
|
|
18585
|
+
function Qx(e) {
|
|
18580
18586
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
18581
18587
|
}
|
|
18582
|
-
function
|
|
18588
|
+
function $x(e) {
|
|
18583
18589
|
return {
|
|
18584
18590
|
async getDaily(t, n) {
|
|
18585
|
-
let r = /* @__PURE__ */ new Date(), i = n?.from ?
|
|
18591
|
+
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];
|
|
18586
18592
|
return (await e.select({
|
|
18587
18593
|
date: p`substr(${E.date}, 1, 10)`.as("date"),
|
|
18588
|
-
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18594
|
+
logins: p`SUM(CASE WHEN ${E.type} IN (${p.join(Xx.map((e) => p`${e}`), p`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
18589
18595
|
signups: p`SUM(CASE WHEN ${E.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
18590
|
-
leaked_passwords: p`SUM(CASE WHEN ${E.type} IN (${p.join(
|
|
18596
|
+
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")
|
|
18591
18597
|
}).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) => ({
|
|
18592
18598
|
date: e.date,
|
|
18593
18599
|
logins: Number(e.logins) || 0,
|
|
@@ -18598,14 +18604,14 @@ function Zx(e) {
|
|
|
18598
18604
|
}));
|
|
18599
18605
|
},
|
|
18600
18606
|
async getActiveUsers(t) {
|
|
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(
|
|
18607
|
+
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`, `)})`));
|
|
18602
18608
|
return Number(r?.count) || 0;
|
|
18603
18609
|
}
|
|
18604
18610
|
};
|
|
18605
18611
|
}
|
|
18606
18612
|
//#endregion
|
|
18607
18613
|
//#region src/adapters/analytics.ts
|
|
18608
|
-
var
|
|
18614
|
+
var eS = {
|
|
18609
18615
|
"active-users": ["s", "seacft"],
|
|
18610
18616
|
logins: [
|
|
18611
18617
|
"s",
|
|
@@ -18615,7 +18621,7 @@ var Qx = {
|
|
|
18615
18621
|
signups: ["ss", "fs"],
|
|
18616
18622
|
"refresh-tokens": ["seacft", "fertft"],
|
|
18617
18623
|
sessions: ["slo"]
|
|
18618
|
-
},
|
|
18624
|
+
}, tS = {
|
|
18619
18625
|
"active-users": {
|
|
18620
18626
|
alias: "active_users",
|
|
18621
18627
|
type: "UInt64",
|
|
@@ -18642,7 +18648,7 @@ var Qx = {
|
|
|
18642
18648
|
agg: "count"
|
|
18643
18649
|
}
|
|
18644
18650
|
};
|
|
18645
|
-
function
|
|
18651
|
+
function nS(e) {
|
|
18646
18652
|
switch (e) {
|
|
18647
18653
|
case "hour": return p`substr(${E.date}, 1, 13)`;
|
|
18648
18654
|
case "month": return p`substr(${E.date}, 1, 7)`;
|
|
@@ -18651,10 +18657,10 @@ function eS(e) {
|
|
|
18651
18657
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
18652
18658
|
}
|
|
18653
18659
|
}
|
|
18654
|
-
function
|
|
18660
|
+
function rS(e) {
|
|
18655
18661
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
18656
18662
|
}
|
|
18657
|
-
function
|
|
18663
|
+
function iS(e) {
|
|
18658
18664
|
switch (e) {
|
|
18659
18665
|
case "connection": return E.connection;
|
|
18660
18666
|
case "client_id": return E.client_id;
|
|
@@ -18663,9 +18669,9 @@ function nS(e) {
|
|
|
18663
18669
|
case "time": throw Error("time dimension handled separately");
|
|
18664
18670
|
}
|
|
18665
18671
|
}
|
|
18666
|
-
function
|
|
18672
|
+
function aS(e) {
|
|
18667
18673
|
return { async query(t, n, r) {
|
|
18668
|
-
let i = Date.now(), a =
|
|
18674
|
+
let i = Date.now(), a = eS[n], o = tS[n], s = [
|
|
18669
18675
|
m(E.tenant_id, t),
|
|
18670
18676
|
Ae(E.date, r.from),
|
|
18671
18677
|
je(E.date, r.to),
|
|
@@ -18674,13 +18680,13 @@ function rS(e) {
|
|
|
18674
18680
|
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));
|
|
18675
18681
|
let c = {}, l = [], u = [];
|
|
18676
18682
|
for (let e of r.group_by) if (e === "time") {
|
|
18677
|
-
let e =
|
|
18683
|
+
let e = nS(r.interval);
|
|
18678
18684
|
c.time = e, l.push(e), u.push({
|
|
18679
18685
|
name: "time",
|
|
18680
18686
|
type: r.interval === "hour" ? "DateTime" : "Date"
|
|
18681
18687
|
});
|
|
18682
18688
|
} else {
|
|
18683
|
-
let t =
|
|
18689
|
+
let t = iS(e);
|
|
18684
18690
|
c[e] = t, l.push(t), u.push({
|
|
18685
18691
|
name: e,
|
|
18686
18692
|
type: "String"
|
|
@@ -18696,9 +18702,9 @@ function rS(e) {
|
|
|
18696
18702
|
if (r.order_by) {
|
|
18697
18703
|
let e = r.order_by.startsWith("-"), t = e ? r.order_by.slice(1) : r.order_by;
|
|
18698
18704
|
if (!f.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
18699
|
-
let n =
|
|
18705
|
+
let n = rS(t);
|
|
18700
18706
|
d = d.orderBy(p.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
18701
|
-
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${
|
|
18707
|
+
} else d = r.group_by[0] === "time" ? d.orderBy(p.raw(`${rS("time")} ASC`)) : d.orderBy(p.raw(`${rS(o.alias)} DESC`));
|
|
18702
18708
|
d = d.limit(r.limit).offset(r.offset);
|
|
18703
18709
|
let ee = (await d.all()).map((e) => {
|
|
18704
18710
|
let t = {};
|
|
@@ -18720,13 +18726,13 @@ function rS(e) {
|
|
|
18720
18726
|
//#endregion
|
|
18721
18727
|
//#region src/adapters/outbox.ts
|
|
18722
18728
|
Xe();
|
|
18723
|
-
function
|
|
18729
|
+
function oS(e) {
|
|
18724
18730
|
return {
|
|
18725
18731
|
...e,
|
|
18726
18732
|
payload: A(e.payload, {})
|
|
18727
18733
|
};
|
|
18728
18734
|
}
|
|
18729
|
-
function
|
|
18735
|
+
function sS(e) {
|
|
18730
18736
|
return {
|
|
18731
18737
|
async create(t, n) {
|
|
18732
18738
|
let r = Ye(), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -18751,11 +18757,11 @@ function aS(e) {
|
|
|
18751
18757
|
}), r;
|
|
18752
18758
|
},
|
|
18753
18759
|
async getByIds(t) {
|
|
18754
|
-
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(
|
|
18760
|
+
return t.length === 0 ? [] : (await e.select().from(D).where(Ne(D.id, t)).all()).map(oS);
|
|
18755
18761
|
},
|
|
18756
18762
|
async getUnprocessed(t) {
|
|
18757
18763
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
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(
|
|
18764
|
+
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);
|
|
18759
18765
|
},
|
|
18760
18766
|
async claimEvents(t, n, r) {
|
|
18761
18767
|
if (t.length === 0) return [];
|
|
@@ -18825,10 +18831,10 @@ function aS(e) {
|
|
|
18825
18831
|
}
|
|
18826
18832
|
//#endregion
|
|
18827
18833
|
//#region src/adapters/cleanup.ts
|
|
18828
|
-
var
|
|
18829
|
-
function
|
|
18834
|
+
var cS = 10080 * 60 * 1e3;
|
|
18835
|
+
function lS(e) {
|
|
18830
18836
|
return async (t) => {
|
|
18831
|
-
let n = Date.now() -
|
|
18837
|
+
let n = Date.now() - cS;
|
|
18832
18838
|
try {
|
|
18833
18839
|
let r = [Oe(je(S.expires_at_ts, n), je(S.idle_expires_at_ts, n))];
|
|
18834
18840
|
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));
|
|
@@ -18839,7 +18845,7 @@ function sS(e) {
|
|
|
18839
18845
|
}
|
|
18840
18846
|
//#endregion
|
|
18841
18847
|
//#region src/adapters/index.ts
|
|
18842
|
-
function
|
|
18848
|
+
function uS(e, t = { useTransactions: !0 }) {
|
|
18843
18849
|
let n = {
|
|
18844
18850
|
actions: Ln(e),
|
|
18845
18851
|
actionExecutions: Rn(e),
|
|
@@ -18868,22 +18874,22 @@ function cS(e, t = { useTransactions: !0 }) {
|
|
|
18868
18874
|
passwords: cx(e),
|
|
18869
18875
|
promptSettings: lx(e),
|
|
18870
18876
|
proxyRoutes: px(e),
|
|
18871
|
-
refreshTokens:
|
|
18872
|
-
resourceServers:
|
|
18873
|
-
rolePermissions:
|
|
18874
|
-
userPermissions:
|
|
18875
|
-
roles:
|
|
18876
|
-
sessions:
|
|
18877
|
-
sessionCleanup:
|
|
18878
|
-
tenants:
|
|
18879
|
-
themes:
|
|
18880
|
-
universalLoginTemplates:
|
|
18881
|
-
users:
|
|
18882
|
-
userRoles:
|
|
18883
|
-
userOrganizations:
|
|
18884
|
-
stats:
|
|
18885
|
-
analytics:
|
|
18886
|
-
outbox:
|
|
18877
|
+
refreshTokens: vx(e),
|
|
18878
|
+
resourceServers: wx(e),
|
|
18879
|
+
rolePermissions: Tx(e),
|
|
18880
|
+
userPermissions: Ex(e),
|
|
18881
|
+
roles: Ox(e),
|
|
18882
|
+
sessions: Nx(e),
|
|
18883
|
+
sessionCleanup: lS(e),
|
|
18884
|
+
tenants: Rx(e),
|
|
18885
|
+
themes: Vx(e),
|
|
18886
|
+
universalLoginTemplates: Hx(e),
|
|
18887
|
+
users: qx(e),
|
|
18888
|
+
userRoles: Jx(e),
|
|
18889
|
+
userOrganizations: Yx(e),
|
|
18890
|
+
stats: $x(e),
|
|
18891
|
+
analytics: aS(e),
|
|
18892
|
+
outbox: sS(e),
|
|
18887
18893
|
async transaction(r) {
|
|
18888
18894
|
if (t.useTransactions === !1) return r(n);
|
|
18889
18895
|
await e.run(p`BEGIN`);
|
|
@@ -18899,7 +18905,7 @@ function cS(e, t = { useTransactions: !0 }) {
|
|
|
18899
18905
|
}
|
|
18900
18906
|
//#endregion
|
|
18901
18907
|
//#region src/adapters/resolveHost.ts
|
|
18902
|
-
function
|
|
18908
|
+
function dS(e) {
|
|
18903
18909
|
if (!e) return { path: "/*" };
|
|
18904
18910
|
try {
|
|
18905
18911
|
let t = JSON.parse(e), n = Wy.safeParse(t);
|
|
@@ -18907,7 +18913,7 @@ function lS(e) {
|
|
|
18907
18913
|
} catch {}
|
|
18908
18914
|
return { path: "/*" };
|
|
18909
18915
|
}
|
|
18910
|
-
function
|
|
18916
|
+
function fS(e) {
|
|
18911
18917
|
if (!e) return [];
|
|
18912
18918
|
try {
|
|
18913
18919
|
let t = JSON.parse(e);
|
|
@@ -18922,7 +18928,7 @@ function uS(e) {
|
|
|
18922
18928
|
return [];
|
|
18923
18929
|
}
|
|
18924
18930
|
}
|
|
18925
|
-
async function
|
|
18931
|
+
async function pS(e, t) {
|
|
18926
18932
|
let n = t.toLowerCase(), r = (await e.select({
|
|
18927
18933
|
custom_domain_id: nn.custom_domain_id,
|
|
18928
18934
|
tenant_id: nn.tenant_id,
|
|
@@ -18934,8 +18940,8 @@ async function dS(e, t) {
|
|
|
18934
18940
|
tenant_id: e.tenant_id,
|
|
18935
18941
|
custom_domain_id: e.custom_domain_id,
|
|
18936
18942
|
priority: e.priority,
|
|
18937
|
-
match:
|
|
18938
|
-
handlers:
|
|
18943
|
+
match: dS(e.match),
|
|
18944
|
+
handlers: fS(e.handlers),
|
|
18939
18945
|
created_at: e.created_at,
|
|
18940
18946
|
updated_at: e.updated_at
|
|
18941
18947
|
}));
|
|
@@ -18948,11 +18954,11 @@ async function dS(e, t) {
|
|
|
18948
18954
|
}
|
|
18949
18955
|
//#endregion
|
|
18950
18956
|
//#region src/adapters/proxyData.ts
|
|
18951
|
-
function
|
|
18957
|
+
function mS(e) {
|
|
18952
18958
|
return {
|
|
18953
18959
|
proxyRoutes: px(e),
|
|
18954
|
-
resolveHost: (t) =>
|
|
18960
|
+
resolveHost: (t) => pS(e, t)
|
|
18955
18961
|
};
|
|
18956
18962
|
}
|
|
18957
18963
|
//#endregion
|
|
18958
|
-
export {
|
|
18964
|
+
export { mS as createProxyDataAdapter, px as createProxyRoutesAdapter, uS as default, En as sqlite };
|