@authhero/drizzle 0.63.1 → 0.65.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.cjs +2 -2
- package/dist/drizzle-adapter.mjs +366 -340
- package/package.json +3 -3
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -1753,12 +1753,12 @@ function Ot(e) {
|
|
|
1753
1753
|
}
|
|
1754
1754
|
//#endregion
|
|
1755
1755
|
//#region src/adapters/codes.ts
|
|
1756
|
-
var kt = ["code_id", "login_id"];
|
|
1757
|
-
function
|
|
1756
|
+
var kt = ["code_id", "login_id"], At = 500;
|
|
1757
|
+
function jt(e) {
|
|
1758
1758
|
let { tenant_id: t, ...n } = e;
|
|
1759
1759
|
return O(n);
|
|
1760
1760
|
}
|
|
1761
|
-
function
|
|
1761
|
+
function Mt(e) {
|
|
1762
1762
|
return {
|
|
1763
1763
|
async create(t, n) {
|
|
1764
1764
|
let r = {
|
|
@@ -1767,11 +1767,11 @@ function jt(e) {
|
|
|
1767
1767
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1768
1768
|
expires_at: n.expires_at
|
|
1769
1769
|
};
|
|
1770
|
-
return await e.insert(I).values(r),
|
|
1770
|
+
return await e.insert(I).values(r), jt(r);
|
|
1771
1771
|
},
|
|
1772
1772
|
async get(n, r, i) {
|
|
1773
1773
|
let o = n ? t(a(I.tenant_id, n), a(I.code_id, r), a(I.code_type, i)) : t(a(I.code_id, r), a(I.code_type, i)), s = await e.select().from(I).where(o).get();
|
|
1774
|
-
return s ?
|
|
1774
|
+
return s ? jt(s) : null;
|
|
1775
1775
|
},
|
|
1776
1776
|
async list(o, s) {
|
|
1777
1777
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(I.tenant_id, o)];
|
|
@@ -1787,7 +1787,7 @@ function jt(e) {
|
|
|
1787
1787
|
let e = I[d.sort_by];
|
|
1788
1788
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1789
1789
|
}
|
|
1790
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1790
|
+
let g = (await h.offset(c * l).limit(l)).map(jt);
|
|
1791
1791
|
if (!u) return { codes: g };
|
|
1792
1792
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1793
1793
|
return {
|
|
@@ -1805,15 +1805,23 @@ function jt(e) {
|
|
|
1805
1805
|
},
|
|
1806
1806
|
async remove(n, r) {
|
|
1807
1807
|
return (await e.delete(I).where(t(a(I.tenant_id, n), a(I.code_id, r))).returning()).length > 0;
|
|
1808
|
+
},
|
|
1809
|
+
async cleanup(t) {
|
|
1810
|
+
let n = 0;
|
|
1811
|
+
for (;;) {
|
|
1812
|
+
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${At})`).returning({ code_id: I.code_id });
|
|
1813
|
+
if (n += r.length, r.length < At) break;
|
|
1814
|
+
}
|
|
1815
|
+
return n;
|
|
1808
1816
|
}
|
|
1809
1817
|
};
|
|
1810
1818
|
}
|
|
1811
1819
|
//#endregion
|
|
1812
1820
|
//#region src/adapters/connections.ts
|
|
1813
|
-
function
|
|
1821
|
+
function Nt() {
|
|
1814
1822
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1815
1823
|
}
|
|
1816
|
-
function
|
|
1824
|
+
function Pt(e) {
|
|
1817
1825
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1818
1826
|
return O({
|
|
1819
1827
|
...a,
|
|
@@ -1822,11 +1830,11 @@ function Nt(e) {
|
|
|
1822
1830
|
is_system: n ? !0 : void 0
|
|
1823
1831
|
});
|
|
1824
1832
|
}
|
|
1825
|
-
function
|
|
1833
|
+
function Ft(e) {
|
|
1826
1834
|
return {
|
|
1827
1835
|
async create(t, n) {
|
|
1828
1836
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1829
|
-
id: n.id ||
|
|
1837
|
+
id: n.id || Nt(),
|
|
1830
1838
|
...n,
|
|
1831
1839
|
tenant_id: t,
|
|
1832
1840
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1840,11 +1848,11 @@ function Pt(e) {
|
|
|
1840
1848
|
} catch (e) {
|
|
1841
1849
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Se(409, { message: "Connection already exists" }) : e;
|
|
1842
1850
|
}
|
|
1843
|
-
return
|
|
1851
|
+
return Pt(i);
|
|
1844
1852
|
},
|
|
1845
1853
|
async get(n, r) {
|
|
1846
1854
|
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
1847
|
-
return i ?
|
|
1855
|
+
return i ? Pt(i) : null;
|
|
1848
1856
|
},
|
|
1849
1857
|
async update(n, r, i) {
|
|
1850
1858
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1861,7 +1869,7 @@ function Pt(e) {
|
|
|
1861
1869
|
let e = V[d.sort_by];
|
|
1862
1870
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1863
1871
|
}
|
|
1864
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1872
|
+
let h = (await m.offset(c * l).limit(l)).map(Pt);
|
|
1865
1873
|
if (!u) return { connections: h };
|
|
1866
1874
|
let [g] = await e.select({ count: r() }).from(V).where(p);
|
|
1867
1875
|
return {
|
|
@@ -1878,7 +1886,7 @@ function Pt(e) {
|
|
|
1878
1886
|
}
|
|
1879
1887
|
//#endregion
|
|
1880
1888
|
//#region src/adapters/customDomains.ts
|
|
1881
|
-
function
|
|
1889
|
+
function It(e) {
|
|
1882
1890
|
let { tenant_id: t, domain_metadata: n, ...r } = e;
|
|
1883
1891
|
return O({
|
|
1884
1892
|
...r,
|
|
@@ -1886,7 +1894,7 @@ function Ft(e) {
|
|
|
1886
1894
|
domain_metadata: Q(n)
|
|
1887
1895
|
});
|
|
1888
1896
|
}
|
|
1889
|
-
function
|
|
1897
|
+
function Lt(e) {
|
|
1890
1898
|
return {
|
|
1891
1899
|
async create(t, n) {
|
|
1892
1900
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1904,24 +1912,24 @@ function It(e) {
|
|
|
1904
1912
|
created_at: r,
|
|
1905
1913
|
updated_at: r
|
|
1906
1914
|
};
|
|
1907
|
-
return await e.insert(H).values(i),
|
|
1915
|
+
return await e.insert(H).values(i), It({
|
|
1908
1916
|
...i,
|
|
1909
1917
|
tenant_id: t
|
|
1910
1918
|
});
|
|
1911
1919
|
},
|
|
1912
1920
|
async get(n, r) {
|
|
1913
1921
|
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.custom_domain_id, r))).get();
|
|
1914
|
-
return i ?
|
|
1922
|
+
return i ? It(i) : null;
|
|
1915
1923
|
},
|
|
1916
1924
|
async getByDomain(t) {
|
|
1917
1925
|
let n = await e.select().from(H).where(a(H.domain, t)).get();
|
|
1918
1926
|
return n ? {
|
|
1919
|
-
...
|
|
1927
|
+
...It(n),
|
|
1920
1928
|
tenant_id: n.tenant_id
|
|
1921
1929
|
} : null;
|
|
1922
1930
|
},
|
|
1923
1931
|
async list(t) {
|
|
1924
|
-
return (await e.select().from(H).where(a(H.tenant_id, t)).all()).map(
|
|
1932
|
+
return (await e.select().from(H).where(a(H.tenant_id, t)).all()).map(It);
|
|
1925
1933
|
},
|
|
1926
1934
|
async update(n, r, i) {
|
|
1927
1935
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1934,7 +1942,7 @@ function It(e) {
|
|
|
1934
1942
|
}
|
|
1935
1943
|
//#endregion
|
|
1936
1944
|
//#region src/adapters/customText.ts
|
|
1937
|
-
function
|
|
1945
|
+
function Rt(e) {
|
|
1938
1946
|
return {
|
|
1939
1947
|
async get(n, r, i) {
|
|
1940
1948
|
let o = await e.select().from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.prompt, r), a(Ke.language, i))).get();
|
|
@@ -1979,7 +1987,7 @@ function Lt(e) {
|
|
|
1979
1987
|
}
|
|
1980
1988
|
//#endregion
|
|
1981
1989
|
//#region src/adapters/emailProviders.ts
|
|
1982
|
-
function
|
|
1990
|
+
function zt(e) {
|
|
1983
1991
|
return {
|
|
1984
1992
|
async create(t, n) {
|
|
1985
1993
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2016,7 +2024,7 @@ function Rt(e) {
|
|
|
2016
2024
|
}
|
|
2017
2025
|
//#endregion
|
|
2018
2026
|
//#region src/adapters/emailTemplates.ts
|
|
2019
|
-
function
|
|
2027
|
+
function Bt(e) {
|
|
2020
2028
|
return O({
|
|
2021
2029
|
template: e.template,
|
|
2022
2030
|
body: e.body,
|
|
@@ -2029,14 +2037,14 @@ function zt(e) {
|
|
|
2029
2037
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2030
2038
|
});
|
|
2031
2039
|
}
|
|
2032
|
-
function
|
|
2040
|
+
function Vt(e) {
|
|
2033
2041
|
return {
|
|
2034
2042
|
async get(n, r) {
|
|
2035
2043
|
let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.template, r))).get();
|
|
2036
|
-
return i ?
|
|
2044
|
+
return i ? Bt(i) : null;
|
|
2037
2045
|
},
|
|
2038
2046
|
async list(t) {
|
|
2039
|
-
return (await e.select().from(He).where(a(He.tenant_id, t)).all()).map(
|
|
2047
|
+
return (await e.select().from(He).where(a(He.tenant_id, t)).all()).map(Bt);
|
|
2040
2048
|
},
|
|
2041
2049
|
async create(t, n) {
|
|
2042
2050
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2069,8 +2077,8 @@ function Bt(e) {
|
|
|
2069
2077
|
}
|
|
2070
2078
|
//#endregion
|
|
2071
2079
|
//#region src/adapters/flows.ts
|
|
2072
|
-
var
|
|
2073
|
-
function
|
|
2080
|
+
var Ht = ["id", "name"];
|
|
2081
|
+
function Ut(e) {
|
|
2074
2082
|
return {
|
|
2075
2083
|
async create(t, n) {
|
|
2076
2084
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
@@ -2105,7 +2113,7 @@ function Ht(e) {
|
|
|
2105
2113
|
async list(o, s) {
|
|
2106
2114
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(ze.tenant_id, o)];
|
|
2107
2115
|
if (f) {
|
|
2108
|
-
let e = _e(f,
|
|
2116
|
+
let e = _e(f, Ht);
|
|
2109
2117
|
if (e) {
|
|
2110
2118
|
let t = Qe(ze, e, []);
|
|
2111
2119
|
t && p.push(t);
|
|
@@ -2139,12 +2147,12 @@ function Ht(e) {
|
|
|
2139
2147
|
}
|
|
2140
2148
|
//#endregion
|
|
2141
2149
|
//#region src/adapters/forms.ts
|
|
2142
|
-
var
|
|
2150
|
+
var Wt = [
|
|
2143
2151
|
"nodes",
|
|
2144
2152
|
"start",
|
|
2145
2153
|
"ending"
|
|
2146
|
-
],
|
|
2147
|
-
function
|
|
2154
|
+
], Gt = ["name"];
|
|
2155
|
+
function Kt(e) {
|
|
2148
2156
|
return {
|
|
2149
2157
|
async create(t, n) {
|
|
2150
2158
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2158,7 +2166,7 @@ function Gt(e) {
|
|
|
2158
2166
|
created_at: r,
|
|
2159
2167
|
updated_at: r
|
|
2160
2168
|
};
|
|
2161
|
-
for (let e of
|
|
2169
|
+
for (let e of Wt) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2162
2170
|
return await e.insert(Re).values(a), {
|
|
2163
2171
|
id: i,
|
|
2164
2172
|
...n,
|
|
@@ -2170,20 +2178,20 @@ function Gt(e) {
|
|
|
2170
2178
|
let i = await e.select().from(Re).where(t(a(Re.tenant_id, n), a(Re.id, r))).get();
|
|
2171
2179
|
if (!i) return null;
|
|
2172
2180
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2173
|
-
for (let e of
|
|
2181
|
+
for (let e of Wt) c[e] = Q(s[e]);
|
|
2174
2182
|
return O(c);
|
|
2175
2183
|
},
|
|
2176
2184
|
async update(n, r, i) {
|
|
2177
2185
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2178
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2186
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (Wt.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2179
2187
|
return (await e.update(Re).set(o).where(t(a(Re.tenant_id, n), a(Re.id, r))).returning()).length > 0;
|
|
2180
2188
|
},
|
|
2181
2189
|
async list(o, s) {
|
|
2182
2190
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Re.tenant_id, o)];
|
|
2183
2191
|
if (f) {
|
|
2184
|
-
let e = _e(f,
|
|
2192
|
+
let e = _e(f, Gt);
|
|
2185
2193
|
if (e) {
|
|
2186
|
-
let t = Qe(Re, e,
|
|
2194
|
+
let t = Qe(Re, e, Gt);
|
|
2187
2195
|
t && p.push(t);
|
|
2188
2196
|
}
|
|
2189
2197
|
}
|
|
@@ -2194,7 +2202,7 @@ function Gt(e) {
|
|
|
2194
2202
|
}
|
|
2195
2203
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2196
2204
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2197
|
-
for (let e of
|
|
2205
|
+
for (let e of Wt) r[e] = Q(n[e]);
|
|
2198
2206
|
return O(r);
|
|
2199
2207
|
});
|
|
2200
2208
|
if (!u) return { forms: g };
|
|
@@ -2213,7 +2221,7 @@ function Gt(e) {
|
|
|
2213
2221
|
}
|
|
2214
2222
|
//#endregion
|
|
2215
2223
|
//#region src/adapters/grants.ts
|
|
2216
|
-
function
|
|
2224
|
+
function qt(e) {
|
|
2217
2225
|
return {
|
|
2218
2226
|
id: e.id,
|
|
2219
2227
|
user_id: e.user_id,
|
|
@@ -2222,17 +2230,17 @@ function Kt(e) {
|
|
|
2222
2230
|
scope: Q(e.scope, []) ?? []
|
|
2223
2231
|
};
|
|
2224
2232
|
}
|
|
2225
|
-
var
|
|
2233
|
+
var Jt = {
|
|
2226
2234
|
user_id: B.user_id,
|
|
2227
2235
|
client_id: B.client_id,
|
|
2228
2236
|
audience: B.audience,
|
|
2229
2237
|
created_at: B.created_at,
|
|
2230
2238
|
updated_at: B.updated_at
|
|
2231
2239
|
};
|
|
2232
|
-
function Jt(e) {
|
|
2233
|
-
return Object.hasOwn(qt, e) ? qt[e] : void 0;
|
|
2234
|
-
}
|
|
2235
2240
|
function Yt(e) {
|
|
2241
|
+
return Object.hasOwn(Jt, e) ? Jt[e] : void 0;
|
|
2242
|
+
}
|
|
2243
|
+
function Xt(e) {
|
|
2236
2244
|
return {
|
|
2237
2245
|
async create(n, r) {
|
|
2238
2246
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r.user_id), a(B.client_id, r.clientID), a(B.audience, s))).get();
|
|
@@ -2241,7 +2249,7 @@ function Yt(e) {
|
|
|
2241
2249
|
return await e.update(B).set({
|
|
2242
2250
|
scope: JSON.stringify(s),
|
|
2243
2251
|
updated_at: i
|
|
2244
|
-
}).where(t(a(B.tenant_id, n), a(B.id, c.id))),
|
|
2252
|
+
}).where(t(a(B.tenant_id, n), a(B.id, c.id))), qt({
|
|
2245
2253
|
...c,
|
|
2246
2254
|
scope: JSON.stringify(s)
|
|
2247
2255
|
});
|
|
@@ -2266,16 +2274,16 @@ function Yt(e) {
|
|
|
2266
2274
|
},
|
|
2267
2275
|
async get(n, r, i, o) {
|
|
2268
2276
|
let s = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r), a(B.client_id, i), a(B.audience, o ?? ""))).get();
|
|
2269
|
-
return s ?
|
|
2277
|
+
return s ? qt(s) : null;
|
|
2270
2278
|
},
|
|
2271
2279
|
async list(o, s) {
|
|
2272
2280
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Qe(B, f, [
|
|
2273
2281
|
"user_id",
|
|
2274
2282
|
"client_id",
|
|
2275
2283
|
"audience"
|
|
2276
|
-
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ?
|
|
2284
|
+
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ? Yt(d.sort_by) : void 0;
|
|
2277
2285
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(B.created_at));
|
|
2278
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2286
|
+
let _ = (await h.offset(c * l).limit(l)).map(qt);
|
|
2279
2287
|
if (!u) return {
|
|
2280
2288
|
grants: _,
|
|
2281
2289
|
start: 0,
|
|
@@ -2300,11 +2308,11 @@ function Yt(e) {
|
|
|
2300
2308
|
}
|
|
2301
2309
|
//#endregion
|
|
2302
2310
|
//#region src/adapters/hookCode.ts
|
|
2303
|
-
var
|
|
2304
|
-
function
|
|
2305
|
-
return `hc_${
|
|
2311
|
+
var Zt = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2312
|
+
function Qt() {
|
|
2313
|
+
return `hc_${Zt()}`;
|
|
2306
2314
|
}
|
|
2307
|
-
function
|
|
2315
|
+
function $t(e) {
|
|
2308
2316
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ie({
|
|
2309
2317
|
created_at_ts: t,
|
|
2310
2318
|
updated_at_ts: n
|
|
@@ -2315,25 +2323,25 @@ function Qt(e) {
|
|
|
2315
2323
|
secrets: r ? JSON.parse(r) : void 0
|
|
2316
2324
|
};
|
|
2317
2325
|
}
|
|
2318
|
-
function
|
|
2326
|
+
function en(e) {
|
|
2319
2327
|
return {
|
|
2320
2328
|
async create(t, n) {
|
|
2321
2329
|
let r = Date.now(), i = {
|
|
2322
|
-
id:
|
|
2330
|
+
id: Qt(),
|
|
2323
2331
|
tenant_id: t,
|
|
2324
2332
|
code: n.code,
|
|
2325
2333
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2326
2334
|
created_at_ts: r,
|
|
2327
2335
|
updated_at_ts: r
|
|
2328
2336
|
};
|
|
2329
|
-
return await e.insert(We).values(i),
|
|
2337
|
+
return await e.insert(We).values(i), $t({
|
|
2330
2338
|
...i,
|
|
2331
2339
|
tenant_id: t
|
|
2332
2340
|
});
|
|
2333
2341
|
},
|
|
2334
2342
|
async get(n, r) {
|
|
2335
2343
|
let i = await e.select().from(We).where(t(a(We.tenant_id, n), a(We.id, r))).get();
|
|
2336
|
-
return i ?
|
|
2344
|
+
return i ? $t(i) : null;
|
|
2337
2345
|
},
|
|
2338
2346
|
async update(n, r, i) {
|
|
2339
2347
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2346,10 +2354,10 @@ function $t(e) {
|
|
|
2346
2354
|
}
|
|
2347
2355
|
//#endregion
|
|
2348
2356
|
//#region src/adapters/hooks.ts
|
|
2349
|
-
function
|
|
2357
|
+
function tn() {
|
|
2350
2358
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2351
2359
|
}
|
|
2352
|
-
function
|
|
2360
|
+
function nn(e) {
|
|
2353
2361
|
if (!(typeof e != "string" || !e)) try {
|
|
2354
2362
|
let t = JSON.parse(e);
|
|
2355
2363
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2357,7 +2365,7 @@ function tn(e) {
|
|
|
2357
2365
|
return;
|
|
2358
2366
|
}
|
|
2359
2367
|
}
|
|
2360
|
-
function
|
|
2368
|
+
function rn(e) {
|
|
2361
2369
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ie({
|
|
2362
2370
|
created_at_ts: n,
|
|
2363
2371
|
updated_at_ts: r
|
|
@@ -2366,15 +2374,15 @@ function nn(e) {
|
|
|
2366
2374
|
...a,
|
|
2367
2375
|
enabled: !!a.enabled,
|
|
2368
2376
|
synchronous: !!a.synchronous,
|
|
2369
|
-
metadata:
|
|
2377
|
+
metadata: nn(i),
|
|
2370
2378
|
...o
|
|
2371
2379
|
});
|
|
2372
2380
|
}
|
|
2373
|
-
function
|
|
2381
|
+
function an(e) {
|
|
2374
2382
|
return {
|
|
2375
2383
|
async create(t, n) {
|
|
2376
2384
|
let r = Date.now(), i = {
|
|
2377
|
-
hook_id: n.hook_id ||
|
|
2385
|
+
hook_id: n.hook_id || tn(),
|
|
2378
2386
|
tenant_id: t,
|
|
2379
2387
|
trigger_id: n.trigger_id,
|
|
2380
2388
|
url: n.url,
|
|
@@ -2388,14 +2396,14 @@ function rn(e) {
|
|
|
2388
2396
|
created_at_ts: r,
|
|
2389
2397
|
updated_at_ts: r
|
|
2390
2398
|
};
|
|
2391
|
-
return await e.insert(Ue).values(i),
|
|
2399
|
+
return await e.insert(Ue).values(i), rn({
|
|
2392
2400
|
...i,
|
|
2393
2401
|
tenant_id: t
|
|
2394
2402
|
});
|
|
2395
2403
|
},
|
|
2396
2404
|
async get(n, r) {
|
|
2397
2405
|
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.hook_id, r))).get();
|
|
2398
|
-
return i ?
|
|
2406
|
+
return i ? rn(i) : null;
|
|
2399
2407
|
},
|
|
2400
2408
|
async update(n, r, i) {
|
|
2401
2409
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2409,7 +2417,7 @@ function rn(e) {
|
|
|
2409
2417
|
"code_id"
|
|
2410
2418
|
]) : void 0, m = p ? t(a(Ue.tenant_id, o), p) : a(Ue.tenant_id, o), h = e.select().from(Ue).where(m).$dynamic(), g = d?.sort_by ? Ue[d.sort_by] : void 0;
|
|
2411
2419
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(Ue.priority), n(Ue.created_at_ts));
|
|
2412
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2420
|
+
let _ = (await h.offset(c * l).limit(l)).map(rn);
|
|
2413
2421
|
if (!u) return { hooks: _ };
|
|
2414
2422
|
let [v] = await e.select({ count: r() }).from(Ue).where(m);
|
|
2415
2423
|
return {
|
|
@@ -2426,25 +2434,25 @@ function rn(e) {
|
|
|
2426
2434
|
}
|
|
2427
2435
|
//#endregion
|
|
2428
2436
|
//#region src/adapters/invites.ts
|
|
2429
|
-
function
|
|
2437
|
+
function on() {
|
|
2430
2438
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2431
2439
|
}
|
|
2432
|
-
var
|
|
2440
|
+
var sn = [
|
|
2433
2441
|
"inviter",
|
|
2434
2442
|
"invitee",
|
|
2435
2443
|
"app_metadata",
|
|
2436
2444
|
"user_metadata",
|
|
2437
2445
|
"roles"
|
|
2438
2446
|
];
|
|
2439
|
-
function
|
|
2447
|
+
function cn(e) {
|
|
2440
2448
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2441
|
-
for (let e of
|
|
2449
|
+
for (let e of sn) i[e] = Q(r[e], e === "roles" ? [] : {});
|
|
2442
2450
|
return i.send_invitation_email = !!n, O(i);
|
|
2443
2451
|
}
|
|
2444
|
-
function
|
|
2452
|
+
function ln(e) {
|
|
2445
2453
|
return {
|
|
2446
2454
|
async create(t, n) {
|
|
2447
|
-
let r = n.id ||
|
|
2455
|
+
let r = n.id || on(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2448
2456
|
id: r,
|
|
2449
2457
|
tenant_id: t,
|
|
2450
2458
|
organization_id: n.organization_id,
|
|
@@ -2457,24 +2465,24 @@ function cn(e) {
|
|
|
2457
2465
|
created_at: a.toISOString(),
|
|
2458
2466
|
expires_at: o
|
|
2459
2467
|
};
|
|
2460
|
-
for (let e of
|
|
2468
|
+
for (let e of sn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2461
2469
|
try {
|
|
2462
2470
|
await e.insert(Me).values(s);
|
|
2463
2471
|
} catch (e) {
|
|
2464
2472
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Se(409, { message: "Invite already exists" }) : e;
|
|
2465
2473
|
}
|
|
2466
|
-
return
|
|
2474
|
+
return cn({
|
|
2467
2475
|
...s,
|
|
2468
2476
|
tenant_id: t
|
|
2469
2477
|
});
|
|
2470
2478
|
},
|
|
2471
2479
|
async get(n, r) {
|
|
2472
2480
|
let i = await e.select().from(Me).where(t(a(Me.tenant_id, n), a(Me.id, r))).get();
|
|
2473
|
-
return i ?
|
|
2481
|
+
return i ? cn(i) : null;
|
|
2474
2482
|
},
|
|
2475
2483
|
async update(n, r, i) {
|
|
2476
2484
|
let o = {};
|
|
2477
|
-
for (let e of
|
|
2485
|
+
for (let e of sn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2478
2486
|
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Me).set(o).where(t(a(Me.tenant_id, n), a(Me.id, r))).returning()).length > 0;
|
|
2479
2487
|
},
|
|
2480
2488
|
async list(t, o) {
|
|
@@ -2483,7 +2491,7 @@ function cn(e) {
|
|
|
2483
2491
|
let e = Me[u.sort_by];
|
|
2484
2492
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2485
2493
|
}
|
|
2486
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2494
|
+
let f = (await d.offset(s * c).limit(c)).map(cn);
|
|
2487
2495
|
if (!l) return { invites: f };
|
|
2488
2496
|
let [p] = await e.select({ count: r() }).from(Me).where(a(Me.tenant_id, t));
|
|
2489
2497
|
return {
|
|
@@ -2500,14 +2508,14 @@ function cn(e) {
|
|
|
2500
2508
|
}
|
|
2501
2509
|
//#endregion
|
|
2502
2510
|
//#region src/adapters/keys.ts
|
|
2503
|
-
var
|
|
2511
|
+
var un = [
|
|
2504
2512
|
"kid",
|
|
2505
2513
|
"connection",
|
|
2506
2514
|
"fingerprint",
|
|
2507
2515
|
"thumbprint",
|
|
2508
2516
|
"type"
|
|
2509
2517
|
];
|
|
2510
|
-
function
|
|
2518
|
+
function dn(e) {
|
|
2511
2519
|
return {
|
|
2512
2520
|
async create(t) {
|
|
2513
2521
|
await e.insert(Ge).values({
|
|
@@ -2518,9 +2526,9 @@ function un(e) {
|
|
|
2518
2526
|
async list(a) {
|
|
2519
2527
|
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(Ge.revoked_at, p), f(Ge.revoked_at))];
|
|
2520
2528
|
if (d) {
|
|
2521
|
-
let e = _e(d,
|
|
2529
|
+
let e = _e(d, un);
|
|
2522
2530
|
if (e) {
|
|
2523
|
-
let t = Qe(Ge, e,
|
|
2531
|
+
let t = Qe(Ge, e, un);
|
|
2524
2532
|
t && m.push(t);
|
|
2525
2533
|
}
|
|
2526
2534
|
}
|
|
@@ -2549,16 +2557,16 @@ function un(e) {
|
|
|
2549
2557
|
}
|
|
2550
2558
|
//#endregion
|
|
2551
2559
|
//#region src/adapters/loginSessions.ts
|
|
2552
|
-
var
|
|
2553
|
-
function
|
|
2560
|
+
var fn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", pn = 32;
|
|
2561
|
+
function mn() {
|
|
2554
2562
|
let e = Date.now(), t = "";
|
|
2555
|
-
for (let n = 10; n > 0; n--) t =
|
|
2563
|
+
for (let n = 10; n > 0; n--) t = fn.charAt(e % pn) + t, e = Math.floor(e / pn);
|
|
2556
2564
|
let n = /* @__PURE__ */ new Uint8Array(16);
|
|
2557
2565
|
crypto.getRandomValues(n);
|
|
2558
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2566
|
+
for (let e = 0; e < 16; e++) t += fn.charAt(n[e] % pn);
|
|
2559
2567
|
return t;
|
|
2560
2568
|
}
|
|
2561
|
-
function
|
|
2569
|
+
function hn(e) {
|
|
2562
2570
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, state_data: a, auth_params: o, ...s } = e, c = ie({
|
|
2563
2571
|
created_at_ts: n,
|
|
2564
2572
|
updated_at_ts: r,
|
|
@@ -2576,11 +2584,11 @@ function mn(e) {
|
|
|
2576
2584
|
state_data: Q(a)
|
|
2577
2585
|
});
|
|
2578
2586
|
}
|
|
2579
|
-
function
|
|
2587
|
+
function gn(e) {
|
|
2580
2588
|
return {
|
|
2581
2589
|
async create(t, n) {
|
|
2582
2590
|
let r = Date.now(), i = {
|
|
2583
|
-
id:
|
|
2591
|
+
id: mn(),
|
|
2584
2592
|
tenant_id: t,
|
|
2585
2593
|
session_id: n.session_id,
|
|
2586
2594
|
csrf_token: n.csrf_token,
|
|
@@ -2601,14 +2609,14 @@ function hn(e) {
|
|
|
2601
2609
|
updated_at_ts: r,
|
|
2602
2610
|
expires_at_ts: n.expires_at ? D(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2603
2611
|
};
|
|
2604
|
-
return await e.insert(F).values(i),
|
|
2612
|
+
return await e.insert(F).values(i), hn({
|
|
2605
2613
|
...i,
|
|
2606
2614
|
tenant_id: t
|
|
2607
2615
|
});
|
|
2608
2616
|
},
|
|
2609
2617
|
async get(n, r) {
|
|
2610
2618
|
let i = n ? t(a(F.tenant_id, n), a(F.id, r)) : a(F.id, r), o = await e.select().from(F).where(i).get();
|
|
2611
|
-
return o ?
|
|
2619
|
+
return o ? hn(o) : null;
|
|
2612
2620
|
},
|
|
2613
2621
|
async update(n, r, i) {
|
|
2614
2622
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2628,7 +2636,7 @@ function hn(e) {
|
|
|
2628
2636
|
}
|
|
2629
2637
|
//#endregion
|
|
2630
2638
|
//#region src/adapters/logs.ts
|
|
2631
|
-
function
|
|
2639
|
+
function _n(e) {
|
|
2632
2640
|
let { tenant_id: t, isMobile: n, auth0_client: r, details: i, country_code: a, city_name: o, latitude: s, longitude: c, time_zone: l, continent_code: u, scope: d, ...f } = e, p = {
|
|
2633
2641
|
...f,
|
|
2634
2642
|
isMobile: !!n,
|
|
@@ -2645,7 +2653,7 @@ function gn(e) {
|
|
|
2645
2653
|
continent_code: u
|
|
2646
2654
|
})), O(p);
|
|
2647
2655
|
}
|
|
2648
|
-
function
|
|
2656
|
+
function vn(e) {
|
|
2649
2657
|
return {
|
|
2650
2658
|
async create(t, n) {
|
|
2651
2659
|
let r = {
|
|
@@ -2671,7 +2679,7 @@ function _n(e) {
|
|
|
2671
2679
|
hostname: n.hostname,
|
|
2672
2680
|
session_connection: n.session_connection
|
|
2673
2681
|
};
|
|
2674
|
-
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(Y).values(r),
|
|
2682
|
+
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(Y).values(r), _n({
|
|
2675
2683
|
...r,
|
|
2676
2684
|
tenant_id: t
|
|
2677
2685
|
});
|
|
@@ -2696,7 +2704,7 @@ function _n(e) {
|
|
|
2696
2704
|
idColumn: Y.log_id,
|
|
2697
2705
|
sortOrder: n,
|
|
2698
2706
|
sortKey: `date:${n}`
|
|
2699
|
-
}, i = ft(s, r), a = ut(s), { rows: o, next: c } = pt(await e.select().from(Y).where(i ? t(v, i) : v).orderBy(...dt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(
|
|
2707
|
+
}, i = ft(s, r), a = ut(s), { rows: o, next: c } = pt(await e.select().from(Y).where(i ? t(v, i) : v).orderBy(...dt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(_n);
|
|
2700
2708
|
return {
|
|
2701
2709
|
logs: l,
|
|
2702
2710
|
start: 0,
|
|
@@ -2710,7 +2718,7 @@ function _n(e) {
|
|
|
2710
2718
|
let e = Y[f.sort_by];
|
|
2711
2719
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2712
2720
|
} else y = y.orderBy(i(Y.date));
|
|
2713
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2721
|
+
let ee = (await y.offset(l * u).limit(u)).map(_n);
|
|
2714
2722
|
if (!d) return { logs: ee };
|
|
2715
2723
|
let [b] = await e.select({ count: r() }).from(Y).where(v);
|
|
2716
2724
|
return {
|
|
@@ -2722,22 +2730,22 @@ function _n(e) {
|
|
|
2722
2730
|
},
|
|
2723
2731
|
async get(n, r) {
|
|
2724
2732
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.log_id, r))).get();
|
|
2725
|
-
return i ?
|
|
2733
|
+
return i ? _n(i) : null;
|
|
2726
2734
|
}
|
|
2727
2735
|
};
|
|
2728
2736
|
}
|
|
2729
2737
|
//#endregion
|
|
2730
2738
|
//#region src/adapters/authenticationMethods.ts
|
|
2731
|
-
var
|
|
2732
|
-
function
|
|
2739
|
+
var yn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", bn = 32;
|
|
2740
|
+
function xn() {
|
|
2733
2741
|
let e = Date.now(), t = "";
|
|
2734
|
-
for (let n = 10; n > 0; n--) t =
|
|
2742
|
+
for (let n = 10; n > 0; n--) t = yn.charAt(e % bn) + t, e = Math.floor(e / bn);
|
|
2735
2743
|
let n = /* @__PURE__ */ new Uint8Array(16);
|
|
2736
2744
|
crypto.getRandomValues(n);
|
|
2737
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2745
|
+
for (let e = 0; e < 16; e++) t += yn.charAt(n[e] % bn);
|
|
2738
2746
|
return t;
|
|
2739
2747
|
}
|
|
2740
|
-
function
|
|
2748
|
+
function Sn(e) {
|
|
2741
2749
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2742
2750
|
return O({
|
|
2743
2751
|
...s,
|
|
@@ -2748,11 +2756,11 @@ function xn(e) {
|
|
|
2748
2756
|
updated_at: ae(r)
|
|
2749
2757
|
});
|
|
2750
2758
|
}
|
|
2751
|
-
function
|
|
2759
|
+
function Cn(e) {
|
|
2752
2760
|
return {
|
|
2753
2761
|
async create(t, n) {
|
|
2754
2762
|
let r = Date.now(), i = {
|
|
2755
|
-
id: n.id ||
|
|
2763
|
+
id: n.id || xn(),
|
|
2756
2764
|
tenant_id: t,
|
|
2757
2765
|
user_id: n.user_id,
|
|
2758
2766
|
type: n.type,
|
|
@@ -2768,21 +2776,21 @@ function Sn(e) {
|
|
|
2768
2776
|
created_at_ts: r,
|
|
2769
2777
|
updated_at_ts: r
|
|
2770
2778
|
};
|
|
2771
|
-
return await e.insert(J).values(i),
|
|
2779
|
+
return await e.insert(J).values(i), Sn({
|
|
2772
2780
|
...i,
|
|
2773
2781
|
tenant_id: t
|
|
2774
2782
|
});
|
|
2775
2783
|
},
|
|
2776
2784
|
async get(n, r) {
|
|
2777
2785
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.id, r))).get();
|
|
2778
|
-
return i ?
|
|
2786
|
+
return i ? Sn(i) : null;
|
|
2779
2787
|
},
|
|
2780
2788
|
async getByCredentialId(n, r) {
|
|
2781
2789
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.credential_id, r))).get();
|
|
2782
|
-
return i ?
|
|
2790
|
+
return i ? Sn(i) : null;
|
|
2783
2791
|
},
|
|
2784
2792
|
async list(n, r) {
|
|
2785
|
-
return (await e.select().from(J).where(t(a(J.tenant_id, n), a(J.user_id, r))).all()).map(
|
|
2793
|
+
return (await e.select().from(J).where(t(a(J.tenant_id, n), a(J.user_id, r))).all()).map(Sn);
|
|
2786
2794
|
},
|
|
2787
2795
|
async update(n, r, i) {
|
|
2788
2796
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2798,11 +2806,11 @@ function Sn(e) {
|
|
|
2798
2806
|
}
|
|
2799
2807
|
//#endregion
|
|
2800
2808
|
//#region src/adapters/organizations.ts
|
|
2801
|
-
var
|
|
2802
|
-
function
|
|
2809
|
+
var wn = ["name", "display_name"];
|
|
2810
|
+
function Tn() {
|
|
2803
2811
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2804
2812
|
}
|
|
2805
|
-
function
|
|
2813
|
+
function En(e) {
|
|
2806
2814
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2807
2815
|
return O({
|
|
2808
2816
|
...o,
|
|
@@ -2812,11 +2820,11 @@ function Tn(e) {
|
|
|
2812
2820
|
token_quota: Q(a, {})
|
|
2813
2821
|
});
|
|
2814
2822
|
}
|
|
2815
|
-
function
|
|
2823
|
+
function Dn(e) {
|
|
2816
2824
|
return {
|
|
2817
2825
|
async create(t, n) {
|
|
2818
2826
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2819
|
-
id: n.id ||
|
|
2827
|
+
id: n.id || Tn(),
|
|
2820
2828
|
tenant_id: t,
|
|
2821
2829
|
name: n.name,
|
|
2822
2830
|
display_name: n.display_name,
|
|
@@ -2832,14 +2840,14 @@ function En(e) {
|
|
|
2832
2840
|
} catch (e) {
|
|
2833
2841
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Se(409, { message: "Organization already exists" }) : e;
|
|
2834
2842
|
}
|
|
2835
|
-
return
|
|
2843
|
+
return En({
|
|
2836
2844
|
...i,
|
|
2837
2845
|
tenant_id: t
|
|
2838
2846
|
});
|
|
2839
2847
|
},
|
|
2840
2848
|
async get(n, r) {
|
|
2841
2849
|
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
2842
|
-
return i ||= await e.select().from(U).where(t(a(U.tenant_id, n), a(U.name, r))).get(), i ?
|
|
2850
|
+
return i ||= await e.select().from(U).where(t(a(U.tenant_id, n), a(U.name, r))).get(), i ? En(i) : null;
|
|
2843
2851
|
},
|
|
2844
2852
|
async update(n, r, i) {
|
|
2845
2853
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2848,9 +2856,9 @@ function En(e) {
|
|
|
2848
2856
|
async list(o, s) {
|
|
2849
2857
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(U.tenant_id, o)];
|
|
2850
2858
|
if (f) {
|
|
2851
|
-
let e = _e(f,
|
|
2859
|
+
let e = _e(f, wn);
|
|
2852
2860
|
if (e) {
|
|
2853
|
-
let t = Qe(U, e,
|
|
2861
|
+
let t = Qe(U, e, wn);
|
|
2854
2862
|
t && p.push(t);
|
|
2855
2863
|
}
|
|
2856
2864
|
}
|
|
@@ -2860,7 +2868,7 @@ function En(e) {
|
|
|
2860
2868
|
sortColumn: U.created_at,
|
|
2861
2869
|
idColumn: U.id,
|
|
2862
2870
|
sortOrder: "desc"
|
|
2863
|
-
}, r = ft(s, n), i = ut(s), { rows: a, next: o } = pt(await e.select().from(U).where(r ? t(m, r) : m).orderBy(...dt(n)).limit(i + 1), i, "created_at"), c = a.map(
|
|
2871
|
+
}, r = ft(s, n), i = ut(s), { rows: a, next: o } = pt(await e.select().from(U).where(r ? t(m, r) : m).orderBy(...dt(n)).limit(i + 1), i, "created_at"), c = a.map(En);
|
|
2864
2872
|
return {
|
|
2865
2873
|
organizations: c,
|
|
2866
2874
|
start: 0,
|
|
@@ -2875,7 +2883,7 @@ function En(e) {
|
|
|
2875
2883
|
let e = U[d.sort_by];
|
|
2876
2884
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2877
2885
|
}
|
|
2878
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2886
|
+
let g = (await h.offset(c * l).limit(l)).map(En);
|
|
2879
2887
|
if (!u) return { organizations: g };
|
|
2880
2888
|
let [_] = await e.select({ count: r() }).from(U).where(m);
|
|
2881
2889
|
return {
|
|
@@ -2892,14 +2900,14 @@ function En(e) {
|
|
|
2892
2900
|
}
|
|
2893
2901
|
//#endregion
|
|
2894
2902
|
//#region src/adapters/passwords.ts
|
|
2895
|
-
function
|
|
2903
|
+
function On(e) {
|
|
2896
2904
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2897
2905
|
return {
|
|
2898
2906
|
...r,
|
|
2899
2907
|
is_current: !!n
|
|
2900
2908
|
};
|
|
2901
2909
|
}
|
|
2902
|
-
function
|
|
2910
|
+
function kn(e) {
|
|
2903
2911
|
return {
|
|
2904
2912
|
async create(n, r) {
|
|
2905
2913
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2914,18 +2922,18 @@ function On(e) {
|
|
|
2914
2922
|
created_at: i,
|
|
2915
2923
|
updated_at: i
|
|
2916
2924
|
};
|
|
2917
|
-
return await e.insert(M).values(s),
|
|
2925
|
+
return await e.insert(M).values(s), On({
|
|
2918
2926
|
...s,
|
|
2919
2927
|
tenant_id: n
|
|
2920
2928
|
});
|
|
2921
2929
|
},
|
|
2922
2930
|
async get(n, r) {
|
|
2923
2931
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r), a(M.is_current, 1))).get();
|
|
2924
|
-
return i ?
|
|
2932
|
+
return i ? On(i) : null;
|
|
2925
2933
|
},
|
|
2926
2934
|
async list(n, r, o) {
|
|
2927
2935
|
let s = e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r))).orderBy(i(M.created_at)).$dynamic();
|
|
2928
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
2936
|
+
return o && (s = s.limit(o)), (await s).map(On);
|
|
2929
2937
|
},
|
|
2930
2938
|
async update(n, r) {
|
|
2931
2939
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -2935,7 +2943,7 @@ function On(e) {
|
|
|
2935
2943
|
}
|
|
2936
2944
|
//#endregion
|
|
2937
2945
|
//#region src/adapters/promptSettings.ts
|
|
2938
|
-
function
|
|
2946
|
+
function An(e) {
|
|
2939
2947
|
return {
|
|
2940
2948
|
async get(t) {
|
|
2941
2949
|
let n = await e.select().from(Be).where(a(Be.tenant_id, t)).get();
|
|
@@ -2972,7 +2980,7 @@ function kn(e) {
|
|
|
2972
2980
|
}
|
|
2973
2981
|
//#endregion
|
|
2974
2982
|
//#region src/adapters/proxyRoutes.ts
|
|
2975
|
-
function
|
|
2983
|
+
function jn(e) {
|
|
2976
2984
|
if (!e) return { path: "/*" };
|
|
2977
2985
|
try {
|
|
2978
2986
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -2980,7 +2988,7 @@ function An(e) {
|
|
|
2980
2988
|
} catch {}
|
|
2981
2989
|
return { path: "/*" };
|
|
2982
2990
|
}
|
|
2983
|
-
function
|
|
2991
|
+
function Mn(e) {
|
|
2984
2992
|
if (!e) return [];
|
|
2985
2993
|
try {
|
|
2986
2994
|
let t = JSON.parse(e);
|
|
@@ -2995,19 +3003,19 @@ function jn(e) {
|
|
|
2995
3003
|
return [];
|
|
2996
3004
|
}
|
|
2997
3005
|
}
|
|
2998
|
-
function
|
|
3006
|
+
function Nn(e) {
|
|
2999
3007
|
return {
|
|
3000
3008
|
id: e.id,
|
|
3001
3009
|
tenant_id: e.tenant_id,
|
|
3002
3010
|
custom_domain_id: e.custom_domain_id,
|
|
3003
3011
|
priority: e.priority,
|
|
3004
|
-
match:
|
|
3005
|
-
handlers:
|
|
3012
|
+
match: jn(e.match),
|
|
3013
|
+
handlers: Mn(e.handlers),
|
|
3006
3014
|
created_at: e.created_at,
|
|
3007
3015
|
updated_at: e.updated_at
|
|
3008
3016
|
};
|
|
3009
3017
|
}
|
|
3010
|
-
function
|
|
3018
|
+
function Pn(e) {
|
|
3011
3019
|
return {
|
|
3012
3020
|
async create(t, n) {
|
|
3013
3021
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3033,14 +3041,14 @@ function Nn(e) {
|
|
|
3033
3041
|
},
|
|
3034
3042
|
async get(n, r) {
|
|
3035
3043
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.id, r))).limit(1);
|
|
3036
|
-
return i[0] ?
|
|
3044
|
+
return i[0] ? Nn(i[0]) : null;
|
|
3037
3045
|
},
|
|
3038
3046
|
async list(r, i = {}) {
|
|
3039
3047
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(Z.tenant_id, r)];
|
|
3040
3048
|
i.custom_domain_id && c.push(a(Z.custom_domain_id, i.custom_domain_id));
|
|
3041
3049
|
let l = await e.select().from(Z).where(t(...c)).orderBy(n(Z.priority), n(Z.created_at)).offset(o * s).limit(s);
|
|
3042
3050
|
return {
|
|
3043
|
-
proxy_routes: l.map(
|
|
3051
|
+
proxy_routes: l.map(Nn),
|
|
3044
3052
|
start: o * s,
|
|
3045
3053
|
limit: s,
|
|
3046
3054
|
length: l.length
|
|
@@ -3059,7 +3067,7 @@ function Nn(e) {
|
|
|
3059
3067
|
}
|
|
3060
3068
|
//#endregion
|
|
3061
3069
|
//#region src/adapters/refreshTokens.ts
|
|
3062
|
-
function
|
|
3070
|
+
function Fn(e) {
|
|
3063
3071
|
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 = ie({
|
|
3064
3072
|
created_at_ts: n,
|
|
3065
3073
|
expires_at_ts: r,
|
|
@@ -3082,10 +3090,10 @@ function Pn(e) {
|
|
|
3082
3090
|
resource_servers: Q(l, [])
|
|
3083
3091
|
});
|
|
3084
3092
|
}
|
|
3085
|
-
function
|
|
3093
|
+
function In(e, t) {
|
|
3086
3094
|
return Math.max(e ?? 0, t ?? 0);
|
|
3087
3095
|
}
|
|
3088
|
-
function
|
|
3096
|
+
function Ln(e) {
|
|
3089
3097
|
return {
|
|
3090
3098
|
async create(n, r) {
|
|
3091
3099
|
let i = Date.now(), o = {
|
|
@@ -3106,22 +3114,22 @@ function In(e) {
|
|
|
3106
3114
|
expires_at_ts: D(r.expires_at),
|
|
3107
3115
|
idle_expires_at_ts: D(r.idle_expires_at),
|
|
3108
3116
|
last_exchanged_at_ts: D(r.last_exchanged_at)
|
|
3109
|
-
}, s = [e.insert(P).values(o)], c =
|
|
3117
|
+
}, s = [e.insert(P).values(o)], c = In(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3110
3118
|
return c > 0 && o.login_id && s.push(e.update(F).set({
|
|
3111
3119
|
expires_at_ts: c,
|
|
3112
3120
|
updated_at_ts: i
|
|
3113
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await it(e, s),
|
|
3121
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await it(e, s), Fn({
|
|
3114
3122
|
...o,
|
|
3115
3123
|
tenant_id: n
|
|
3116
3124
|
});
|
|
3117
3125
|
},
|
|
3118
3126
|
async get(n, r) {
|
|
3119
3127
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.id, r))).get();
|
|
3120
|
-
return i ?
|
|
3128
|
+
return i ? Fn(i) : null;
|
|
3121
3129
|
},
|
|
3122
3130
|
async getByLookup(n, r) {
|
|
3123
3131
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.token_lookup, r))).get();
|
|
3124
|
-
return i ?
|
|
3132
|
+
return i ? Fn(i) : null;
|
|
3125
3133
|
},
|
|
3126
3134
|
async update(n, r, i, o) {
|
|
3127
3135
|
let s = {};
|
|
@@ -3142,7 +3150,7 @@ function In(e) {
|
|
|
3142
3150
|
let e = P[d.sort_by];
|
|
3143
3151
|
e && (p = p.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3144
3152
|
}
|
|
3145
|
-
let m = (await p.offset(c * l).limit(l)).map(
|
|
3153
|
+
let m = (await p.offset(c * l).limit(l)).map(Fn);
|
|
3146
3154
|
if (!u) return { refresh_tokens: m };
|
|
3147
3155
|
let [h] = await e.select({ count: r() }).from(P).where(a(P.tenant_id, o));
|
|
3148
3156
|
return {
|
|
@@ -3165,15 +3173,15 @@ function In(e) {
|
|
|
3165
3173
|
}
|
|
3166
3174
|
//#endregion
|
|
3167
3175
|
//#region src/adapters/resourceServers.ts
|
|
3168
|
-
var
|
|
3169
|
-
function
|
|
3176
|
+
var Rn = ["name", "identifier"];
|
|
3177
|
+
function zn() {
|
|
3170
3178
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3171
3179
|
}
|
|
3172
|
-
var
|
|
3180
|
+
var Bn = [
|
|
3173
3181
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3174
3182
|
"allow_offline_access",
|
|
3175
3183
|
"is_system"
|
|
3176
|
-
],
|
|
3184
|
+
], Vn = /* @__PURE__ */ new Set([
|
|
3177
3185
|
"id",
|
|
3178
3186
|
"tenant_id",
|
|
3179
3187
|
"identifier",
|
|
@@ -3192,17 +3200,17 @@ var zn = [
|
|
|
3192
3200
|
"created_at",
|
|
3193
3201
|
"updated_at"
|
|
3194
3202
|
]);
|
|
3195
|
-
function
|
|
3203
|
+
function Hn(e) {
|
|
3196
3204
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3197
3205
|
s.scopes = Q(r, []), s.options = Q(i, {}), s.metadata = Q(a), n !== void 0 && (s.verificationKey = n);
|
|
3198
|
-
for (let e of
|
|
3206
|
+
for (let e of Bn) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3199
3207
|
return O(s);
|
|
3200
3208
|
}
|
|
3201
|
-
function
|
|
3209
|
+
function Un(e) {
|
|
3202
3210
|
return {
|
|
3203
3211
|
async create(t, n) {
|
|
3204
3212
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3205
|
-
id: n.id ||
|
|
3213
|
+
id: n.id || zn(),
|
|
3206
3214
|
tenant_id: t,
|
|
3207
3215
|
identifier: n.identifier,
|
|
3208
3216
|
name: n.name,
|
|
@@ -3217,37 +3225,37 @@ function Hn(e) {
|
|
|
3217
3225
|
created_at: r,
|
|
3218
3226
|
updated_at: r
|
|
3219
3227
|
};
|
|
3220
|
-
for (let e of
|
|
3221
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(q).values(i),
|
|
3228
|
+
for (let e of Bn) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3229
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(q).values(i), Hn({
|
|
3222
3230
|
...i,
|
|
3223
3231
|
tenant_id: t
|
|
3224
3232
|
});
|
|
3225
3233
|
},
|
|
3226
3234
|
async get(n, r) {
|
|
3227
3235
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.id, r))).get();
|
|
3228
|
-
return i ?
|
|
3236
|
+
return i ? Hn(i) : null;
|
|
3229
3237
|
},
|
|
3230
3238
|
async update(n, r, i) {
|
|
3231
3239
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3232
3240
|
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${q.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3233
|
-
for (let e of
|
|
3241
|
+
for (let e of Bn) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3234
3242
|
return (await e.update(q).set(o).where(t(a(q.tenant_id, n), a(q.id, r))).returning()).length > 0;
|
|
3235
3243
|
},
|
|
3236
3244
|
async list(o, s) {
|
|
3237
3245
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(q.tenant_id, o)];
|
|
3238
3246
|
if (f) {
|
|
3239
|
-
let e = _e(f,
|
|
3247
|
+
let e = _e(f, Rn);
|
|
3240
3248
|
if (e) {
|
|
3241
|
-
let t = Qe(q, e,
|
|
3249
|
+
let t = Qe(q, e, Rn, ["name", "identifier"]);
|
|
3242
3250
|
t && h.push(t);
|
|
3243
3251
|
}
|
|
3244
3252
|
}
|
|
3245
3253
|
let g = e.select().from(q).where(t(...h)).$dynamic();
|
|
3246
|
-
if (d?.sort_by &&
|
|
3254
|
+
if (d?.sort_by && Vn.has(d.sort_by)) {
|
|
3247
3255
|
let e = q[d.sort_by];
|
|
3248
3256
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3249
3257
|
}
|
|
3250
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3258
|
+
let _ = (await g.offset(p * m).limit(m)).map(Hn);
|
|
3251
3259
|
if (!u) return { resource_servers: _ };
|
|
3252
3260
|
let [v] = await e.select({ count: r() }).from(q).where(t(...h));
|
|
3253
3261
|
return {
|
|
@@ -3264,7 +3272,7 @@ function Hn(e) {
|
|
|
3264
3272
|
}
|
|
3265
3273
|
//#endregion
|
|
3266
3274
|
//#region src/adapters/rolePermissions.ts
|
|
3267
|
-
function
|
|
3275
|
+
function Wn(e) {
|
|
3268
3276
|
return {
|
|
3269
3277
|
async assign(t, n, r) {
|
|
3270
3278
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3302,7 +3310,7 @@ function Un(e) {
|
|
|
3302
3310
|
}
|
|
3303
3311
|
//#endregion
|
|
3304
3312
|
//#region src/adapters/userPermissions.ts
|
|
3305
|
-
function
|
|
3313
|
+
function Gn(e) {
|
|
3306
3314
|
return {
|
|
3307
3315
|
async create(t, n, r, i) {
|
|
3308
3316
|
try {
|
|
@@ -3341,7 +3349,7 @@ function Wn(e) {
|
|
|
3341
3349
|
}
|
|
3342
3350
|
//#endregion
|
|
3343
3351
|
//#region src/adapters/roles.ts
|
|
3344
|
-
function
|
|
3352
|
+
function Kn(e) {
|
|
3345
3353
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3346
3354
|
return O({
|
|
3347
3355
|
...i,
|
|
@@ -3349,7 +3357,7 @@ function Gn(e) {
|
|
|
3349
3357
|
metadata: Q(r)
|
|
3350
3358
|
});
|
|
3351
3359
|
}
|
|
3352
|
-
function
|
|
3360
|
+
function qn(e) {
|
|
3353
3361
|
return {
|
|
3354
3362
|
async create(t, n) {
|
|
3355
3363
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3362,14 +3370,14 @@ function Kn(e) {
|
|
|
3362
3370
|
created_at: r,
|
|
3363
3371
|
updated_at: r
|
|
3364
3372
|
};
|
|
3365
|
-
return await e.insert(G).values(i),
|
|
3373
|
+
return await e.insert(G).values(i), Kn({
|
|
3366
3374
|
...i,
|
|
3367
3375
|
tenant_id: t
|
|
3368
3376
|
});
|
|
3369
3377
|
},
|
|
3370
3378
|
async get(n, r) {
|
|
3371
3379
|
let i = await e.select().from(G).where(t(a(G.tenant_id, n), a(G.id, r))).get();
|
|
3372
|
-
return i ?
|
|
3380
|
+
return i ? Kn(i) : null;
|
|
3373
3381
|
},
|
|
3374
3382
|
async update(n, r, i) {
|
|
3375
3383
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3381,7 +3389,7 @@ function Kn(e) {
|
|
|
3381
3389
|
let e = G[d.sort_by];
|
|
3382
3390
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3383
3391
|
}
|
|
3384
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3392
|
+
let g = (await h.offset(c * l).limit(l)).map(Kn);
|
|
3385
3393
|
if (!u) return { roles: g };
|
|
3386
3394
|
let [_] = await e.select({ count: r() }).from(G).where(m);
|
|
3387
3395
|
return {
|
|
@@ -3398,7 +3406,7 @@ function Kn(e) {
|
|
|
3398
3406
|
}
|
|
3399
3407
|
//#endregion
|
|
3400
3408
|
//#region src/adapters/sessions.ts
|
|
3401
|
-
var
|
|
3409
|
+
var Jn = ["created_at_ts", "updated_at_ts"], Yn = [
|
|
3402
3410
|
"expires_at_ts",
|
|
3403
3411
|
"idle_expires_at_ts",
|
|
3404
3412
|
"authenticated_at_ts",
|
|
@@ -3406,7 +3414,7 @@ var qn = ["created_at_ts", "updated_at_ts"], Jn = [
|
|
|
3406
3414
|
"used_at_ts",
|
|
3407
3415
|
"revoked_at_ts"
|
|
3408
3416
|
];
|
|
3409
|
-
function
|
|
3417
|
+
function Xn(e) {
|
|
3410
3418
|
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, p = ie({
|
|
3411
3419
|
created_at_ts: n,
|
|
3412
3420
|
updated_at_ts: r,
|
|
@@ -3416,7 +3424,7 @@ function Yn(e) {
|
|
|
3416
3424
|
last_interaction_at_ts: s,
|
|
3417
3425
|
used_at_ts: c,
|
|
3418
3426
|
revoked_at_ts: l
|
|
3419
|
-
}, [...
|
|
3427
|
+
}, [...Jn], [...Yn]);
|
|
3420
3428
|
return O({
|
|
3421
3429
|
...f,
|
|
3422
3430
|
...p,
|
|
@@ -3424,10 +3432,10 @@ function Yn(e) {
|
|
|
3424
3432
|
clients: Q(d, [])
|
|
3425
3433
|
});
|
|
3426
3434
|
}
|
|
3427
|
-
function
|
|
3435
|
+
function Zn(e, t) {
|
|
3428
3436
|
return Math.max(e ?? 0, t ?? 0);
|
|
3429
3437
|
}
|
|
3430
|
-
function
|
|
3438
|
+
function Qn(e) {
|
|
3431
3439
|
return {
|
|
3432
3440
|
async create(n, r) {
|
|
3433
3441
|
let i = Date.now(), o = {
|
|
@@ -3445,23 +3453,23 @@ function Zn(e) {
|
|
|
3445
3453
|
last_interaction_at_ts: r.last_interaction_at ? D(r.last_interaction_at) : i,
|
|
3446
3454
|
used_at_ts: D(r.used_at),
|
|
3447
3455
|
revoked_at_ts: D(r.revoked_at)
|
|
3448
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3456
|
+
}, s = [e.insert(N).values(o)], c = Zn(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3449
3457
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3450
3458
|
expires_at_ts: c,
|
|
3451
3459
|
updated_at_ts: i
|
|
3452
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await it(e, s),
|
|
3460
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await it(e, s), Xn({
|
|
3453
3461
|
...o,
|
|
3454
3462
|
tenant_id: n
|
|
3455
3463
|
});
|
|
3456
3464
|
},
|
|
3457
3465
|
async get(n, r) {
|
|
3458
3466
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3459
|
-
return i ?
|
|
3467
|
+
return i ? Xn(i) : null;
|
|
3460
3468
|
},
|
|
3461
3469
|
async update(n, r, i) {
|
|
3462
3470
|
let o = { updated_at_ts: Date.now() };
|
|
3463
3471
|
i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = D(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = D(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = D(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = D(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = D(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = D(i.revoked_at));
|
|
3464
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3472
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = Zn(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3465
3473
|
if (c > 0 && l) {
|
|
3466
3474
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3467
3475
|
r && await e.update(F).set({
|
|
@@ -3477,7 +3485,7 @@ function Zn(e) {
|
|
|
3477
3485
|
let e = N[d.sort_by];
|
|
3478
3486
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3479
3487
|
}
|
|
3480
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3488
|
+
let g = (await h.offset(c * l).limit(l)).map(Xn);
|
|
3481
3489
|
if (!u) return { sessions: g };
|
|
3482
3490
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3483
3491
|
return {
|
|
@@ -3494,7 +3502,7 @@ function Zn(e) {
|
|
|
3494
3502
|
}
|
|
3495
3503
|
//#endregion
|
|
3496
3504
|
//#region src/adapters/tenants.ts
|
|
3497
|
-
var
|
|
3505
|
+
var $n = [
|
|
3498
3506
|
"session_cookie",
|
|
3499
3507
|
"enabled_locales",
|
|
3500
3508
|
"error_page",
|
|
@@ -3510,25 +3518,25 @@ var Qn = [
|
|
|
3510
3518
|
"acr_values_supported",
|
|
3511
3519
|
"mtls",
|
|
3512
3520
|
"mfa"
|
|
3513
|
-
],
|
|
3521
|
+
], er = [
|
|
3514
3522
|
"allow_organization_name_in_authentication_api",
|
|
3515
3523
|
"customize_mfa_in_postlogin_action",
|
|
3516
3524
|
"pushed_authorization_requests_supported",
|
|
3517
3525
|
"authorization_response_iss_parameter_supported"
|
|
3518
3526
|
];
|
|
3519
|
-
function
|
|
3527
|
+
function tr(e) {
|
|
3520
3528
|
let t = { ...e };
|
|
3521
|
-
for (let e of
|
|
3522
|
-
for (let e of
|
|
3529
|
+
for (let e of $n) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3530
|
+
for (let e of er) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3523
3531
|
return O(t);
|
|
3524
3532
|
}
|
|
3525
|
-
function
|
|
3533
|
+
function nr(e) {
|
|
3526
3534
|
let t = { ...e };
|
|
3527
|
-
ce(e,
|
|
3528
|
-
for (let n of
|
|
3535
|
+
ce(e, $n, t);
|
|
3536
|
+
for (let n of er) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3529
3537
|
return se(t);
|
|
3530
3538
|
}
|
|
3531
|
-
function
|
|
3539
|
+
function rr(e) {
|
|
3532
3540
|
return {
|
|
3533
3541
|
async create(t) {
|
|
3534
3542
|
let n = {
|
|
@@ -3536,7 +3544,7 @@ function nr(e) {
|
|
|
3536
3544
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3537
3545
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3538
3546
|
...t
|
|
3539
|
-
}, r =
|
|
3547
|
+
}, r = nr(n);
|
|
3540
3548
|
try {
|
|
3541
3549
|
await e.insert(k).values(r);
|
|
3542
3550
|
} catch (e) {
|
|
@@ -3547,7 +3555,7 @@ function nr(e) {
|
|
|
3547
3555
|
},
|
|
3548
3556
|
async get(t) {
|
|
3549
3557
|
let n = await e.select().from(k).where(a(k.id, t)).get();
|
|
3550
|
-
return n ?
|
|
3558
|
+
return n ? tr(n) : null;
|
|
3551
3559
|
},
|
|
3552
3560
|
async list(t) {
|
|
3553
3561
|
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? Qe(k, l, ["friendly_name"]) : void 0, d = e.select().from(k).$dynamic();
|
|
@@ -3555,7 +3563,7 @@ function nr(e) {
|
|
|
3555
3563
|
let e = k[c.sort_by];
|
|
3556
3564
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3557
3565
|
}
|
|
3558
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3566
|
+
let f = (await d.offset(a * o).limit(o)).map(tr);
|
|
3559
3567
|
if (!s) return { tenants: f };
|
|
3560
3568
|
let p = e.select({ count: r() }).from(k).$dynamic();
|
|
3561
3569
|
u && (p = p.where(u));
|
|
@@ -3568,7 +3576,7 @@ function nr(e) {
|
|
|
3568
3576
|
};
|
|
3569
3577
|
},
|
|
3570
3578
|
async update(t, n) {
|
|
3571
|
-
let r =
|
|
3579
|
+
let r = nr({
|
|
3572
3580
|
...n,
|
|
3573
3581
|
id: t,
|
|
3574
3582
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3582,18 +3590,18 @@ function nr(e) {
|
|
|
3582
3590
|
}
|
|
3583
3591
|
//#endregion
|
|
3584
3592
|
//#region src/adapters/themes.ts
|
|
3585
|
-
var
|
|
3593
|
+
var ir = [
|
|
3586
3594
|
"colors",
|
|
3587
3595
|
"borders",
|
|
3588
3596
|
"fonts",
|
|
3589
3597
|
"page_background",
|
|
3590
3598
|
"widget"
|
|
3591
3599
|
];
|
|
3592
|
-
function
|
|
3593
|
-
let { tenant_id: t, ...n } = e, r = Ye(n,
|
|
3600
|
+
function ar(e) {
|
|
3601
|
+
let { tenant_id: t, ...n } = e, r = Ye(n, ir);
|
|
3594
3602
|
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), O(r);
|
|
3595
3603
|
}
|
|
3596
|
-
function
|
|
3604
|
+
function or(e) {
|
|
3597
3605
|
return {
|
|
3598
3606
|
async create(t, n, r, i) {
|
|
3599
3607
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
@@ -3603,14 +3611,14 @@ function ar(e) {
|
|
|
3603
3611
|
created_at: a?.created_at ?? o,
|
|
3604
3612
|
updated_at: a?.updated_at ?? o
|
|
3605
3613
|
};
|
|
3606
|
-
return await e.insert(Le).values(c),
|
|
3614
|
+
return await e.insert(Le).values(c), ar({
|
|
3607
3615
|
...c,
|
|
3608
3616
|
tenant_id: t
|
|
3609
3617
|
});
|
|
3610
3618
|
},
|
|
3611
3619
|
async get(n, r) {
|
|
3612
3620
|
let i = await e.select().from(Le).where(t(a(Le.tenant_id, n), a(Le.themeId, r))).get();
|
|
3613
|
-
return i ?
|
|
3621
|
+
return i ? ar(i) : null;
|
|
3614
3622
|
},
|
|
3615
3623
|
async update(n, r, i) {
|
|
3616
3624
|
let o = Je(i);
|
|
@@ -3623,7 +3631,7 @@ function ar(e) {
|
|
|
3623
3631
|
}
|
|
3624
3632
|
//#endregion
|
|
3625
3633
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3626
|
-
function
|
|
3634
|
+
function sr(e) {
|
|
3627
3635
|
return {
|
|
3628
3636
|
async get(t) {
|
|
3629
3637
|
let n = await e.select({ body: Ie.body }).from(Ie).where(a(Ie.tenant_id, t)).get();
|
|
@@ -3651,11 +3659,11 @@ function or(e) {
|
|
|
3651
3659
|
}
|
|
3652
3660
|
//#endregion
|
|
3653
3661
|
//#region src/adapters/userActivity.ts
|
|
3654
|
-
function
|
|
3662
|
+
function cr(e) {
|
|
3655
3663
|
let t = {};
|
|
3656
3664
|
return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
|
|
3657
3665
|
}
|
|
3658
|
-
function
|
|
3666
|
+
function lr(e) {
|
|
3659
3667
|
return {
|
|
3660
3668
|
async get(n, r) {
|
|
3661
3669
|
let i = await e.select().from(De).where(t(a(De.tenant_id, n), a(De.user_id, r))).get();
|
|
@@ -3669,7 +3677,7 @@ function cr(e) {
|
|
|
3669
3677
|
} : null;
|
|
3670
3678
|
},
|
|
3671
3679
|
async upsert(t, n, r) {
|
|
3672
|
-
let i =
|
|
3680
|
+
let i = cr(r), a = e.insert(De).values({
|
|
3673
3681
|
tenant_id: t,
|
|
3674
3682
|
user_id: n,
|
|
3675
3683
|
login_count: 0,
|
|
@@ -3688,13 +3696,13 @@ function cr(e) {
|
|
|
3688
3696
|
}
|
|
3689
3697
|
//#endregion
|
|
3690
3698
|
//#region src/adapters/outbox.ts
|
|
3691
|
-
function
|
|
3699
|
+
function ur(e) {
|
|
3692
3700
|
return {
|
|
3693
3701
|
...e,
|
|
3694
3702
|
payload: Q(e.payload, {})
|
|
3695
3703
|
};
|
|
3696
3704
|
}
|
|
3697
|
-
function
|
|
3705
|
+
function dr(e, t, n, r) {
|
|
3698
3706
|
return e.insert(X).values({
|
|
3699
3707
|
id: t,
|
|
3700
3708
|
tenant_id: n,
|
|
@@ -3715,18 +3723,18 @@ function ur(e, t, n, r) {
|
|
|
3715
3723
|
claim_expires_at: null
|
|
3716
3724
|
});
|
|
3717
3725
|
}
|
|
3718
|
-
function
|
|
3726
|
+
function fr(e) {
|
|
3719
3727
|
return {
|
|
3720
3728
|
async create(t, n) {
|
|
3721
3729
|
let r = b();
|
|
3722
|
-
return await
|
|
3730
|
+
return await dr(e, r, t, n), r;
|
|
3723
3731
|
},
|
|
3724
3732
|
async getByIds(t) {
|
|
3725
|
-
return t.length === 0 ? [] : (await e.select().from(X).where(l(X.id, t)).all()).map(
|
|
3733
|
+
return t.length === 0 ? [] : (await e.select().from(X).where(l(X.id, t)).all()).map(ur);
|
|
3726
3734
|
},
|
|
3727
3735
|
async getUnprocessed(n) {
|
|
3728
3736
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3729
|
-
return (await e.select().from(X).where(t(f(X.processed_at), v(f(X.next_retry_at), h(X.next_retry_at, r)), v(f(X.claimed_by), h(X.claim_expires_at, r)))).orderBy(X.created_at, X.id).limit(n).all()).map(
|
|
3737
|
+
return (await e.select().from(X).where(t(f(X.processed_at), v(f(X.next_retry_at), h(X.next_retry_at, r)), v(f(X.claimed_by), h(X.claim_expires_at, r)))).orderBy(X.created_at, X.id).limit(n).all()).map(ur);
|
|
3730
3738
|
},
|
|
3731
3739
|
async claimEvents(n, r, i) {
|
|
3732
3740
|
if (n.length === 0) return [];
|
|
@@ -3796,10 +3804,10 @@ function dr(e) {
|
|
|
3796
3804
|
}
|
|
3797
3805
|
//#endregion
|
|
3798
3806
|
//#region src/adapters/users.ts
|
|
3799
|
-
function
|
|
3800
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
3807
|
+
function pr(e, t, n) {
|
|
3808
|
+
return (n?.outboxEvents ?? []).map((n) => dr(e, n.id, t, n));
|
|
3801
3809
|
}
|
|
3802
|
-
var
|
|
3810
|
+
var mr = [
|
|
3803
3811
|
"user_id",
|
|
3804
3812
|
"email",
|
|
3805
3813
|
"email_verified",
|
|
@@ -3821,23 +3829,23 @@ var pr = [
|
|
|
3821
3829
|
"login_count",
|
|
3822
3830
|
"created_at",
|
|
3823
3831
|
"updated_at"
|
|
3824
|
-
],
|
|
3832
|
+
], hr = [
|
|
3825
3833
|
"email",
|
|
3826
3834
|
"name",
|
|
3827
3835
|
"phone_number",
|
|
3828
3836
|
"user_id"
|
|
3829
|
-
],
|
|
3837
|
+
], gr = /* @__PURE__ */ new Set([
|
|
3830
3838
|
"last_login",
|
|
3831
3839
|
"last_ip",
|
|
3832
3840
|
"login_count"
|
|
3833
|
-
]),
|
|
3841
|
+
]), _r = o(j), vr = o(De), yr = Object.fromEntries(mr.map((e) => [e, e === "login_count" ? {
|
|
3834
3842
|
coalesce: De.login_count,
|
|
3835
3843
|
defaultValue: 0
|
|
3836
|
-
} :
|
|
3837
|
-
function
|
|
3844
|
+
} : gr.has(e) ? vr[e] : _r[e]]));
|
|
3845
|
+
function br() {
|
|
3838
3846
|
return t(a(De.tenant_id, j.tenant_id), a(De.user_id, j.user_id));
|
|
3839
3847
|
}
|
|
3840
|
-
function
|
|
3848
|
+
function xr(e, t) {
|
|
3841
3849
|
return {
|
|
3842
3850
|
...e,
|
|
3843
3851
|
last_login: t?.last_login,
|
|
@@ -3845,7 +3853,7 @@ function br(e, t) {
|
|
|
3845
3853
|
login_count: t?.login_count ?? 0
|
|
3846
3854
|
};
|
|
3847
3855
|
}
|
|
3848
|
-
function
|
|
3856
|
+
function Sr(e, t) {
|
|
3849
3857
|
let n = {
|
|
3850
3858
|
connection: e.connection,
|
|
3851
3859
|
provider: e.provider,
|
|
@@ -3858,8 +3866,8 @@ function xr(e, t) {
|
|
|
3858
3866
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
3859
3867
|
}, n;
|
|
3860
3868
|
}
|
|
3861
|
-
function
|
|
3862
|
-
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 =
|
|
3869
|
+
function Cr(e, t = []) {
|
|
3870
|
+
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 = Sr(e, !0), p = t.map((e) => Sr(e, !1));
|
|
3863
3871
|
return O({
|
|
3864
3872
|
...d,
|
|
3865
3873
|
email: e.email || "",
|
|
@@ -3872,7 +3880,7 @@ function Sr(e, t = []) {
|
|
|
3872
3880
|
identities: [f, ...p]
|
|
3873
3881
|
});
|
|
3874
3882
|
}
|
|
3875
|
-
function
|
|
3883
|
+
function wr(e) {
|
|
3876
3884
|
let o = async (t, n, r) => {
|
|
3877
3885
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
3878
3886
|
user_id: n.user_id,
|
|
@@ -3925,12 +3933,12 @@ function Cr(e) {
|
|
|
3925
3933
|
created_at: i,
|
|
3926
3934
|
updated_at: i
|
|
3927
3935
|
}));
|
|
3928
|
-
for (let n of
|
|
3936
|
+
for (let n of pr(e, t, r)) c.push(n);
|
|
3929
3937
|
c.length > 1 ? await it(e, c) : await e.insert(j).values(a);
|
|
3930
3938
|
} catch (e) {
|
|
3931
3939
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Se(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Se(500, { message: "Internal server error" }));
|
|
3932
3940
|
}
|
|
3933
|
-
return
|
|
3941
|
+
return Cr({
|
|
3934
3942
|
...a,
|
|
3935
3943
|
last_login: n.last_login,
|
|
3936
3944
|
last_ip: n.last_ip,
|
|
@@ -3941,10 +3949,10 @@ function Cr(e) {
|
|
|
3941
3949
|
create: o,
|
|
3942
3950
|
rawCreate: o,
|
|
3943
3951
|
async get(n, r) {
|
|
3944
|
-
let i = await e.select().from(j).leftJoin(De,
|
|
3952
|
+
let i = await e.select().from(j).leftJoin(De, br()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
3945
3953
|
if (!i) return null;
|
|
3946
3954
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
3947
|
-
return
|
|
3955
|
+
return Cr(xr(i.users, i.user_activity), o);
|
|
3948
3956
|
},
|
|
3949
3957
|
async update(n, r, i, o) {
|
|
3950
3958
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3971,8 +3979,8 @@ function Cr(e) {
|
|
|
3971
3979
|
"zoneinfo"
|
|
3972
3980
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
3973
3981
|
i.email_verified !== void 0 && (s.email_verified = i.email_verified), i.phone_verified !== void 0 && (s.phone_verified = i.phone_verified), i.is_social !== void 0 && (s.is_social = i.is_social), i.app_metadata !== void 0 && (s.app_metadata = JSON.stringify(i.app_metadata)), i.user_metadata !== void 0 && (s.user_metadata = JSON.stringify(i.user_metadata)), i.address !== void 0 && (s.address = JSON.stringify(i.address)), i.profileData !== void 0 && (s.profileData = JSON.stringify(i.profileData));
|
|
3974
|
-
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l =
|
|
3975
|
-
return u = l.length > 0 ? (await it(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await
|
|
3982
|
+
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l = pr(e, n, o), u;
|
|
3983
|
+
return u = l.length > 0 ? (await it(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await lr(e).upsert(n, r, {
|
|
3976
3984
|
last_login: i.last_login,
|
|
3977
3985
|
last_ip: i.last_ip,
|
|
3978
3986
|
login_count: i.login_count
|
|
@@ -3981,30 +3989,48 @@ function Cr(e) {
|
|
|
3981
3989
|
async list(o, s) {
|
|
3982
3990
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(j.tenant_id, o), f(j.linked_to)];
|
|
3983
3991
|
if (m) {
|
|
3984
|
-
let e = _e(m,
|
|
3992
|
+
let e = _e(m, mr);
|
|
3985
3993
|
if (e) {
|
|
3986
|
-
let t = Qe(
|
|
3994
|
+
let t = Qe(yr, e, hr);
|
|
3987
3995
|
t && h.push(t);
|
|
3988
3996
|
}
|
|
3989
3997
|
}
|
|
3990
|
-
let g = t(...h), _ =
|
|
3998
|
+
let g = t(...h), _ = async (n) => {
|
|
3999
|
+
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(j).where(t(a(j.tenant_id, o), l(j.linked_to, r))) : [];
|
|
4000
|
+
return n.map((e) => Cr(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4001
|
+
};
|
|
4002
|
+
if (lt(s)) {
|
|
4003
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Se(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4004
|
+
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4005
|
+
sortColumn: j.created_at,
|
|
4006
|
+
idColumn: j.user_id,
|
|
4007
|
+
sortOrder: n,
|
|
4008
|
+
sortKey: `created_at:${n}`
|
|
4009
|
+
}, i = ut(s), a = ft(s, r), { rows: o, next: c } = pt((await e.select().from(j).leftJoin(De, br()).where(a ? t(g, a) : g).orderBy(...dt(r)).limit(i + 1)).map((e) => xr(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4010
|
+
return {
|
|
4011
|
+
users: l,
|
|
4012
|
+
start: 0,
|
|
4013
|
+
limit: i,
|
|
4014
|
+
length: l.length,
|
|
4015
|
+
next: c
|
|
4016
|
+
};
|
|
4017
|
+
}
|
|
4018
|
+
let v = e.select().from(j).leftJoin(De, br()).where(g).$dynamic();
|
|
3991
4019
|
if (p?.sort_by) {
|
|
3992
|
-
let e =
|
|
4020
|
+
let e = yr[p.sort_by];
|
|
3993
4021
|
if (e) {
|
|
3994
4022
|
let t = Xe(e) ? Ze(e) : e;
|
|
3995
|
-
|
|
4023
|
+
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
3996
4024
|
}
|
|
3997
4025
|
}
|
|
3998
|
-
let
|
|
3999
|
-
|
|
4000
|
-
let
|
|
4001
|
-
if (!d) return { users: b };
|
|
4002
|
-
let [te] = await e.select({ count: r() }).from(j).leftJoin(De, yr()).where(g);
|
|
4026
|
+
let y = await _((await v.offset(c * u).limit(u)).map((e) => xr(e.users, e.user_activity)));
|
|
4027
|
+
if (!d) return { users: y };
|
|
4028
|
+
let [ee] = await e.select({ count: r() }).from(j).leftJoin(De, br()).where(g);
|
|
4003
4029
|
return {
|
|
4004
|
-
users:
|
|
4030
|
+
users: y,
|
|
4005
4031
|
start: c * u,
|
|
4006
4032
|
limit: u,
|
|
4007
|
-
length: Number(
|
|
4033
|
+
length: Number(ee?.count ?? 0)
|
|
4008
4034
|
};
|
|
4009
4035
|
},
|
|
4010
4036
|
async remove(n, r, i) {
|
|
@@ -4015,7 +4041,7 @@ function Cr(e) {
|
|
|
4015
4041
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4016
4042
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4017
4043
|
], f = d.length - 1;
|
|
4018
|
-
if (s) for (let t of
|
|
4044
|
+
if (s) for (let t of pr(e, n, i)) d.push(t);
|
|
4019
4045
|
let p = (await it(e, d))[f];
|
|
4020
4046
|
return Array.isArray(p) && p.length > 0;
|
|
4021
4047
|
},
|
|
@@ -4027,7 +4053,7 @@ function Cr(e) {
|
|
|
4027
4053
|
}
|
|
4028
4054
|
//#endregion
|
|
4029
4055
|
//#region src/adapters/userRoles.ts
|
|
4030
|
-
function
|
|
4056
|
+
function Tr(e) {
|
|
4031
4057
|
return {
|
|
4032
4058
|
async create(t, n, r, i) {
|
|
4033
4059
|
try {
|
|
@@ -4090,7 +4116,7 @@ function wr(e) {
|
|
|
4090
4116
|
}
|
|
4091
4117
|
//#endregion
|
|
4092
4118
|
//#region src/adapters/userOrganizations.ts
|
|
4093
|
-
function
|
|
4119
|
+
function Er(e) {
|
|
4094
4120
|
return {
|
|
4095
4121
|
async create(t, n) {
|
|
4096
4122
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4182,19 +4208,19 @@ function Tr(e) {
|
|
|
4182
4208
|
}
|
|
4183
4209
|
//#endregion
|
|
4184
4210
|
//#region src/adapters/stats.ts
|
|
4185
|
-
var
|
|
4186
|
-
function
|
|
4211
|
+
var Dr = ["s"], Or = ["pwd_leak"];
|
|
4212
|
+
function kr(e) {
|
|
4187
4213
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4188
4214
|
}
|
|
4189
|
-
function
|
|
4215
|
+
function Ar(e) {
|
|
4190
4216
|
return {
|
|
4191
4217
|
async getDaily(n, r) {
|
|
4192
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4218
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? kr(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? kr(r.to) : i.toISOString().split("T")[0];
|
|
4193
4219
|
return (await e.select({
|
|
4194
4220
|
date: y`substr(${Y.date}, 1, 10)`.as("date"),
|
|
4195
|
-
logins: y`SUM(CASE WHEN ${Y.type} IN (${y.join(
|
|
4221
|
+
logins: y`SUM(CASE WHEN ${Y.type} IN (${y.join(Dr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4196
4222
|
signups: y`SUM(CASE WHEN ${Y.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4197
|
-
leaked_passwords: y`SUM(CASE WHEN ${Y.type} IN (${y.join(
|
|
4223
|
+
leaked_passwords: y`SUM(CASE WHEN ${Y.type} IN (${y.join(Or.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4198
4224
|
}).from(Y).where(t(a(Y.tenant_id, n), c(Y.date, o), h(Y.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${Y.date}, 1, 10)`).orderBy(y`substr(${Y.date}, 1, 10)`).all()).map((e) => ({
|
|
4199
4225
|
date: e.date,
|
|
4200
4226
|
logins: Number(e.logins) || 0,
|
|
@@ -4205,14 +4231,14 @@ function kr(e) {
|
|
|
4205
4231
|
}));
|
|
4206
4232
|
},
|
|
4207
4233
|
async getActiveUsers(n) {
|
|
4208
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${Y.user_id})`.as("count") }).from(Y).where(t(a(Y.tenant_id, n), c(Y.date, r), y`${Y.type} IN (${y.join(
|
|
4234
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${Y.user_id})`.as("count") }).from(Y).where(t(a(Y.tenant_id, n), c(Y.date, r), y`${Y.type} IN (${y.join(Dr.map((e) => y`${e}`), y`, `)})`));
|
|
4209
4235
|
return Number(i?.count) || 0;
|
|
4210
4236
|
}
|
|
4211
4237
|
};
|
|
4212
4238
|
}
|
|
4213
4239
|
//#endregion
|
|
4214
4240
|
//#region src/adapters/analytics.ts
|
|
4215
|
-
var
|
|
4241
|
+
var jr = {
|
|
4216
4242
|
"active-users": ["s", "seacft"],
|
|
4217
4243
|
logins: [
|
|
4218
4244
|
"s",
|
|
@@ -4242,7 +4268,7 @@ var Ar = {
|
|
|
4242
4268
|
"fvr"
|
|
4243
4269
|
],
|
|
4244
4270
|
"codes-sent": ["cls", "cs"]
|
|
4245
|
-
},
|
|
4271
|
+
}, Mr = {
|
|
4246
4272
|
"active-users": {
|
|
4247
4273
|
alias: "active_users",
|
|
4248
4274
|
type: "UInt64",
|
|
@@ -4299,7 +4325,7 @@ var Ar = {
|
|
|
4299
4325
|
agg: "count"
|
|
4300
4326
|
}
|
|
4301
4327
|
};
|
|
4302
|
-
function
|
|
4328
|
+
function Nr(e) {
|
|
4303
4329
|
switch (e) {
|
|
4304
4330
|
case "hour": return y`substr(${Y.date}, 1, 13)`;
|
|
4305
4331
|
case "month": return y`substr(${Y.date}, 1, 7)`;
|
|
@@ -4308,10 +4334,10 @@ function Mr(e) {
|
|
|
4308
4334
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4309
4335
|
}
|
|
4310
4336
|
}
|
|
4311
|
-
function
|
|
4337
|
+
function Pr(e) {
|
|
4312
4338
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4313
4339
|
}
|
|
4314
|
-
function
|
|
4340
|
+
function Fr(e) {
|
|
4315
4341
|
switch (e) {
|
|
4316
4342
|
case "connection": return Y.connection;
|
|
4317
4343
|
case "client_id": return Y.client_id;
|
|
@@ -4320,9 +4346,9 @@ function Pr(e) {
|
|
|
4320
4346
|
case "time": throw Error("time dimension handled separately");
|
|
4321
4347
|
}
|
|
4322
4348
|
}
|
|
4323
|
-
function
|
|
4349
|
+
function Ir(e) {
|
|
4324
4350
|
return { async query(n, r, i) {
|
|
4325
|
-
let o = Date.now(), s =
|
|
4351
|
+
let o = Date.now(), s = jr[r], u = Mr[r], d = [
|
|
4326
4352
|
a(Y.tenant_id, n),
|
|
4327
4353
|
c(Y.date, i.from),
|
|
4328
4354
|
m(Y.date, i.to),
|
|
@@ -4331,13 +4357,13 @@ function Fr(e) {
|
|
|
4331
4357
|
i.filters.connection?.length && d.push(l(Y.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(Y.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(Y.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(Y.user_id, i.filters.user_id));
|
|
4332
4358
|
let f = {}, p = [], h = [];
|
|
4333
4359
|
for (let e of i.group_by) if (e === "time") {
|
|
4334
|
-
let e =
|
|
4360
|
+
let e = Nr(i.interval);
|
|
4335
4361
|
f.time = e, p.push(e), h.push({
|
|
4336
4362
|
name: "time",
|
|
4337
4363
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4338
4364
|
});
|
|
4339
4365
|
} else {
|
|
4340
|
-
let t =
|
|
4366
|
+
let t = Fr(e);
|
|
4341
4367
|
f[e] = t, p.push(t), h.push({
|
|
4342
4368
|
name: e,
|
|
4343
4369
|
type: "String"
|
|
@@ -4353,9 +4379,9 @@ function Fr(e) {
|
|
|
4353
4379
|
if (i.order_by) {
|
|
4354
4380
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4355
4381
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4356
|
-
let n =
|
|
4382
|
+
let n = Pr(t);
|
|
4357
4383
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4358
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4384
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Pr("time")} ASC`)) : g.orderBy(y.raw(`${Pr(u.alias)} DESC`));
|
|
4359
4385
|
g = g.limit(i.limit).offset(i.offset);
|
|
4360
4386
|
let v = (await g.all()).map((e) => {
|
|
4361
4387
|
let t = {};
|
|
@@ -4376,10 +4402,10 @@ function Fr(e) {
|
|
|
4376
4402
|
}
|
|
4377
4403
|
//#endregion
|
|
4378
4404
|
//#region src/adapters/cleanup.ts
|
|
4379
|
-
var
|
|
4380
|
-
function
|
|
4405
|
+
var Lr = 10080 * 60 * 1e3;
|
|
4406
|
+
function Rr(e) {
|
|
4381
4407
|
return async (n) => {
|
|
4382
|
-
let r = Date.now() -
|
|
4408
|
+
let r = Date.now() - Lr;
|
|
4383
4409
|
try {
|
|
4384
4410
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4385
4411
|
n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i)), i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), n?.user_id && i.push(a(N.user_id, n.user_id)), await e.delete(N).where(t(...i)), i = [m(F.expires_at_ts, r)], n?.tenant_id && i.push(a(F.tenant_id, n.tenant_id)), await e.delete(F).where(t(...i));
|
|
@@ -4410,7 +4436,7 @@ var $ = w("tenant_operations", {
|
|
|
4410
4436
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4411
4437
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4412
4438
|
x("tenant_operations_status_idx").on(e.status)
|
|
4413
|
-
]),
|
|
4439
|
+
]), zr = w("tenant_operation_events", {
|
|
4414
4440
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4415
4441
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4416
4442
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4422,7 +4448,7 @@ var $ = w("tenant_operations", {
|
|
|
4422
4448
|
columns: [e.operation_id],
|
|
4423
4449
|
foreignColumns: [$.id],
|
|
4424
4450
|
name: "tenant_operation_events_operation_id_constraint"
|
|
4425
|
-
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]),
|
|
4451
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), Br = w("rollouts", {
|
|
4426
4452
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4427
4453
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4428
4454
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4438,7 +4464,7 @@ var $ = w("tenant_operations", {
|
|
|
4438
4464
|
});
|
|
4439
4465
|
//#endregion
|
|
4440
4466
|
//#region src/adapters/tenantOperations.ts
|
|
4441
|
-
function
|
|
4467
|
+
function Vr(e) {
|
|
4442
4468
|
return xe.parse({
|
|
4443
4469
|
id: e.id,
|
|
4444
4470
|
tenant_id: e.tenant_id,
|
|
@@ -4457,7 +4483,7 @@ function Br(e) {
|
|
|
4457
4483
|
finished_at: e.finished_at
|
|
4458
4484
|
});
|
|
4459
4485
|
}
|
|
4460
|
-
function
|
|
4486
|
+
function Hr(e) {
|
|
4461
4487
|
return {
|
|
4462
4488
|
async create(t) {
|
|
4463
4489
|
let n = be.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4484,7 +4510,7 @@ function Vr(e) {
|
|
|
4484
4510
|
},
|
|
4485
4511
|
async get(t) {
|
|
4486
4512
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4487
|
-
return n[0] ?
|
|
4513
|
+
return n[0] ? Vr(n[0]) : null;
|
|
4488
4514
|
},
|
|
4489
4515
|
async list(n = {}) {
|
|
4490
4516
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4495,7 +4521,7 @@ function Vr(e) {
|
|
|
4495
4521
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4496
4522
|
let c = await e.select().from($).where(s.length ? t(...s) : void 0).orderBy(i($.created_at), i($.id)).offset(r * o).limit(o);
|
|
4497
4523
|
return {
|
|
4498
|
-
operations: c.map(
|
|
4524
|
+
operations: c.map(Vr),
|
|
4499
4525
|
start: r * o,
|
|
4500
4526
|
limit: o,
|
|
4501
4527
|
length: c.length
|
|
@@ -4513,27 +4539,27 @@ function Vr(e) {
|
|
|
4513
4539
|
}
|
|
4514
4540
|
//#endregion
|
|
4515
4541
|
//#region src/helpers/monotonic-id.ts
|
|
4516
|
-
var
|
|
4517
|
-
function
|
|
4542
|
+
var Ur = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Wr = 32, Gr = 10, Kr = 4, qr = 10;
|
|
4543
|
+
function Jr(e, t) {
|
|
4518
4544
|
let n = "";
|
|
4519
|
-
for (let r = t; r > 0; r--) n =
|
|
4545
|
+
for (let r = t; r > 0; r--) n = Ur.charAt(e % Wr) + n, e = Math.floor(e / Wr);
|
|
4520
4546
|
return n;
|
|
4521
4547
|
}
|
|
4522
|
-
function
|
|
4523
|
-
let e = new Uint8Array(
|
|
4548
|
+
function Yr() {
|
|
4549
|
+
let e = new Uint8Array(qr);
|
|
4524
4550
|
crypto.getRandomValues(e);
|
|
4525
4551
|
let t = "";
|
|
4526
|
-
for (let n = 0; n <
|
|
4552
|
+
for (let n = 0; n < qr; n++) t += Ur.charAt(e[n] % Wr);
|
|
4527
4553
|
return t;
|
|
4528
4554
|
}
|
|
4529
|
-
var
|
|
4530
|
-
function
|
|
4555
|
+
var Xr = 0, Zr = 0;
|
|
4556
|
+
function Qr() {
|
|
4531
4557
|
let e = Date.now();
|
|
4532
|
-
return e ===
|
|
4558
|
+
return e === Xr ? Zr++ : (Xr = e, Zr = 0), Jr(e, Gr) + Jr(Zr, Kr) + Yr();
|
|
4533
4559
|
}
|
|
4534
4560
|
//#endregion
|
|
4535
4561
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4536
|
-
function
|
|
4562
|
+
function $r(e) {
|
|
4537
4563
|
if (!e) return null;
|
|
4538
4564
|
try {
|
|
4539
4565
|
let t = JSON.parse(e);
|
|
@@ -4541,22 +4567,22 @@ function Qr(e) {
|
|
|
4541
4567
|
} catch {}
|
|
4542
4568
|
return null;
|
|
4543
4569
|
}
|
|
4544
|
-
function
|
|
4570
|
+
function ei(e) {
|
|
4545
4571
|
return ye.parse({
|
|
4546
4572
|
id: e.id,
|
|
4547
4573
|
operation_id: e.operation_id,
|
|
4548
4574
|
step: e.step,
|
|
4549
4575
|
outcome: e.outcome,
|
|
4550
|
-
detail:
|
|
4576
|
+
detail: $r(e.detail),
|
|
4551
4577
|
attempt: e.attempt,
|
|
4552
4578
|
created_at: e.created_at
|
|
4553
4579
|
});
|
|
4554
4580
|
}
|
|
4555
|
-
function
|
|
4581
|
+
function ti(e) {
|
|
4556
4582
|
return {
|
|
4557
4583
|
async create(t) {
|
|
4558
4584
|
let n = ve.parse(t), r = {
|
|
4559
|
-
id: `evt_${
|
|
4585
|
+
id: `evt_${Qr()}`,
|
|
4560
4586
|
operation_id: n.operation_id,
|
|
4561
4587
|
step: n.step,
|
|
4562
4588
|
outcome: n.outcome,
|
|
@@ -4564,7 +4590,7 @@ function ei(e) {
|
|
|
4564
4590
|
attempt: n.attempt,
|
|
4565
4591
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4566
4592
|
};
|
|
4567
|
-
return await e.insert(
|
|
4593
|
+
return await e.insert(zr).values(r), ye.parse({
|
|
4568
4594
|
id: r.id,
|
|
4569
4595
|
operation_id: r.operation_id,
|
|
4570
4596
|
step: r.step,
|
|
@@ -4575,9 +4601,9 @@ function ei(e) {
|
|
|
4575
4601
|
});
|
|
4576
4602
|
},
|
|
4577
4603
|
async listByOperation(t, r = {}) {
|
|
4578
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4604
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(zr).where(a(zr.operation_id, t)).orderBy(n(zr.created_at), n(zr.id)).offset(i * o).limit(o);
|
|
4579
4605
|
return {
|
|
4580
|
-
events: s.map(
|
|
4606
|
+
events: s.map(ei),
|
|
4581
4607
|
start: i * o,
|
|
4582
4608
|
limit: o,
|
|
4583
4609
|
length: s.length
|
|
@@ -4587,7 +4613,7 @@ function ei(e) {
|
|
|
4587
4613
|
}
|
|
4588
4614
|
//#endregion
|
|
4589
4615
|
//#region src/adapters/rollouts.ts
|
|
4590
|
-
function
|
|
4616
|
+
function ni(e) {
|
|
4591
4617
|
if (!e) return null;
|
|
4592
4618
|
try {
|
|
4593
4619
|
return JSON.parse(e);
|
|
@@ -4595,7 +4621,7 @@ function ti(e) {
|
|
|
4595
4621
|
return null;
|
|
4596
4622
|
}
|
|
4597
4623
|
}
|
|
4598
|
-
function
|
|
4624
|
+
function ri(e) {
|
|
4599
4625
|
return ge.parse({
|
|
4600
4626
|
id: e.id,
|
|
4601
4627
|
kind: e.kind,
|
|
@@ -4603,15 +4629,15 @@ function ni(e) {
|
|
|
4603
4629
|
target_worker_version: e.target_worker_version,
|
|
4604
4630
|
target_database_version: e.target_database_version,
|
|
4605
4631
|
wave_size: e.wave_size,
|
|
4606
|
-
canary_tenant_ids:
|
|
4607
|
-
filter:
|
|
4632
|
+
canary_tenant_ids: ni(e.canary_tenant_ids),
|
|
4633
|
+
filter: ni(e.filter),
|
|
4608
4634
|
initiated_by: e.initiated_by,
|
|
4609
4635
|
created_at: e.created_at,
|
|
4610
4636
|
updated_at: e.updated_at,
|
|
4611
4637
|
finished_at: e.finished_at
|
|
4612
4638
|
});
|
|
4613
4639
|
}
|
|
4614
|
-
function
|
|
4640
|
+
function ii(e) {
|
|
4615
4641
|
return {
|
|
4616
4642
|
async create(t) {
|
|
4617
4643
|
let n = he.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4628,37 +4654,37 @@ function ri(e) {
|
|
|
4628
4654
|
updated_at: r,
|
|
4629
4655
|
finished_at: null
|
|
4630
4656
|
};
|
|
4631
|
-
await e.insert(
|
|
4657
|
+
await e.insert(Br).values(i);
|
|
4632
4658
|
let a = await this.get(i.id);
|
|
4633
4659
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4634
4660
|
return a;
|
|
4635
4661
|
},
|
|
4636
4662
|
async get(t) {
|
|
4637
|
-
let n = await e.select().from(
|
|
4638
|
-
return n[0] ?
|
|
4663
|
+
let n = await e.select().from(Br).where(a(Br.id, t)).limit(1);
|
|
4664
|
+
return n[0] ? ri(n[0]) : null;
|
|
4639
4665
|
},
|
|
4640
4666
|
async list(t = {}) {
|
|
4641
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4667
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(Br).orderBy(i(Br.created_at), i(Br.id)).offset(n * r).limit(r);
|
|
4642
4668
|
return {
|
|
4643
|
-
rollouts: a.map(
|
|
4669
|
+
rollouts: a.map(ri),
|
|
4644
4670
|
start: n * r,
|
|
4645
4671
|
limit: r,
|
|
4646
4672
|
length: a.length
|
|
4647
4673
|
};
|
|
4648
4674
|
},
|
|
4649
4675
|
async update(t, n) {
|
|
4650
|
-
if ((await e.select({ id:
|
|
4676
|
+
if ((await e.select({ id: Br.id }).from(Br).where(a(Br.id, t)).limit(1)).length === 0) return !1;
|
|
4651
4677
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4652
|
-
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(
|
|
4678
|
+
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(Br).set(r).where(a(Br.id, t)), !0;
|
|
4653
4679
|
},
|
|
4654
4680
|
async remove(t) {
|
|
4655
|
-
return (await e.select({ id:
|
|
4681
|
+
return (await e.select({ id: Br.id }).from(Br).where(a(Br.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Br).where(a(Br.id, t)), !0);
|
|
4656
4682
|
}
|
|
4657
4683
|
};
|
|
4658
4684
|
}
|
|
4659
4685
|
//#endregion
|
|
4660
4686
|
//#region src/adapters/index.ts
|
|
4661
|
-
function
|
|
4687
|
+
function ai(e, t = { useTransactions: !0 }) {
|
|
4662
4688
|
let n = {
|
|
4663
4689
|
actions: tt(e),
|
|
4664
4690
|
actionExecutions: nt(e),
|
|
@@ -4668,48 +4694,48 @@ function ii(e, t = { useTransactions: !0 }) {
|
|
|
4668
4694
|
clientConnections: xt(e),
|
|
4669
4695
|
clientGrants: Ct(e),
|
|
4670
4696
|
clientRegistrationTokens: Ot(e),
|
|
4671
|
-
codes:
|
|
4672
|
-
connections:
|
|
4673
|
-
customDomains:
|
|
4674
|
-
customText:
|
|
4675
|
-
emailProviders:
|
|
4676
|
-
emailTemplates:
|
|
4677
|
-
flows:
|
|
4678
|
-
forms:
|
|
4679
|
-
grants:
|
|
4680
|
-
hookCode:
|
|
4681
|
-
hooks:
|
|
4682
|
-
invites:
|
|
4683
|
-
keys:
|
|
4684
|
-
loginSessions:
|
|
4685
|
-
logs:
|
|
4686
|
-
authenticationMethods:
|
|
4687
|
-
organizations:
|
|
4688
|
-
passwords:
|
|
4689
|
-
promptSettings:
|
|
4690
|
-
proxyRoutes:
|
|
4691
|
-
refreshTokens:
|
|
4692
|
-
resourceServers:
|
|
4693
|
-
rolePermissions:
|
|
4694
|
-
userPermissions:
|
|
4695
|
-
roles:
|
|
4696
|
-
sessions:
|
|
4697
|
-
sessionCleanup:
|
|
4698
|
-
tenants:
|
|
4697
|
+
codes: Mt(e),
|
|
4698
|
+
connections: Ft(e),
|
|
4699
|
+
customDomains: Lt(e),
|
|
4700
|
+
customText: Rt(e),
|
|
4701
|
+
emailProviders: zt(e),
|
|
4702
|
+
emailTemplates: Vt(e),
|
|
4703
|
+
flows: Ut(e),
|
|
4704
|
+
forms: Kt(e),
|
|
4705
|
+
grants: Xt(e),
|
|
4706
|
+
hookCode: en(e),
|
|
4707
|
+
hooks: an(e),
|
|
4708
|
+
invites: ln(e),
|
|
4709
|
+
keys: dn(e),
|
|
4710
|
+
loginSessions: gn(e),
|
|
4711
|
+
logs: vn(e),
|
|
4712
|
+
authenticationMethods: Cn(e),
|
|
4713
|
+
organizations: Dn(e),
|
|
4714
|
+
passwords: kn(e),
|
|
4715
|
+
promptSettings: An(e),
|
|
4716
|
+
proxyRoutes: Pn(e),
|
|
4717
|
+
refreshTokens: Ln(e),
|
|
4718
|
+
resourceServers: Un(e),
|
|
4719
|
+
rolePermissions: Wn(e),
|
|
4720
|
+
userPermissions: Gn(e),
|
|
4721
|
+
roles: qn(e),
|
|
4722
|
+
sessions: Qn(e),
|
|
4723
|
+
sessionCleanup: Rr(e),
|
|
4724
|
+
tenants: rr(e),
|
|
4699
4725
|
...t.controlPlane ? {
|
|
4700
|
-
tenantOperations:
|
|
4701
|
-
tenantOperationEvents:
|
|
4702
|
-
rollouts:
|
|
4726
|
+
tenantOperations: Hr(e),
|
|
4727
|
+
tenantOperationEvents: ti(e),
|
|
4728
|
+
rollouts: ii(e)
|
|
4703
4729
|
} : {},
|
|
4704
|
-
themes:
|
|
4705
|
-
universalLoginTemplates:
|
|
4706
|
-
users:
|
|
4707
|
-
userActivity:
|
|
4708
|
-
userRoles:
|
|
4709
|
-
userOrganizations:
|
|
4710
|
-
stats:
|
|
4711
|
-
analytics:
|
|
4712
|
-
outbox:
|
|
4730
|
+
themes: or(e),
|
|
4731
|
+
universalLoginTemplates: sr(e),
|
|
4732
|
+
users: wr(e),
|
|
4733
|
+
userActivity: lr(e),
|
|
4734
|
+
userRoles: Tr(e),
|
|
4735
|
+
userOrganizations: Er(e),
|
|
4736
|
+
stats: Ar(e),
|
|
4737
|
+
analytics: Ir(e),
|
|
4738
|
+
outbox: fr(e),
|
|
4713
4739
|
async transaction(r) {
|
|
4714
4740
|
if (t.useTransactions === !1 || rt(e)) return r(n);
|
|
4715
4741
|
await e.run(y`BEGIN`);
|
|
@@ -4725,7 +4751,7 @@ function ii(e, t = { useTransactions: !0 }) {
|
|
|
4725
4751
|
}
|
|
4726
4752
|
//#endregion
|
|
4727
4753
|
//#region src/adapters/resolveHost.ts
|
|
4728
|
-
function
|
|
4754
|
+
function oi(e) {
|
|
4729
4755
|
if (!e) return { path: "/*" };
|
|
4730
4756
|
try {
|
|
4731
4757
|
let t = JSON.parse(e), n = me.safeParse(t);
|
|
@@ -4733,7 +4759,7 @@ function ai(e) {
|
|
|
4733
4759
|
} catch {}
|
|
4734
4760
|
return { path: "/*" };
|
|
4735
4761
|
}
|
|
4736
|
-
function
|
|
4762
|
+
function si(e) {
|
|
4737
4763
|
if (!e) return [];
|
|
4738
4764
|
try {
|
|
4739
4765
|
let t = JSON.parse(e);
|
|
@@ -4748,7 +4774,7 @@ function oi(e) {
|
|
|
4748
4774
|
return [];
|
|
4749
4775
|
}
|
|
4750
4776
|
}
|
|
4751
|
-
async function
|
|
4777
|
+
async function ci(e, r) {
|
|
4752
4778
|
let i = r.toLowerCase(), o = (await e.select({
|
|
4753
4779
|
custom_domain_id: H.custom_domain_id,
|
|
4754
4780
|
tenant_id: H.tenant_id,
|
|
@@ -4760,8 +4786,8 @@ async function si(e, r) {
|
|
|
4760
4786
|
tenant_id: e.tenant_id,
|
|
4761
4787
|
custom_domain_id: e.custom_domain_id,
|
|
4762
4788
|
priority: e.priority,
|
|
4763
|
-
match:
|
|
4764
|
-
handlers:
|
|
4789
|
+
match: oi(e.match),
|
|
4790
|
+
handlers: si(e.handlers),
|
|
4765
4791
|
created_at: e.created_at,
|
|
4766
4792
|
updated_at: e.updated_at
|
|
4767
4793
|
}));
|
|
@@ -4774,11 +4800,11 @@ async function si(e, r) {
|
|
|
4774
4800
|
}
|
|
4775
4801
|
//#endregion
|
|
4776
4802
|
//#region src/adapters/proxyData.ts
|
|
4777
|
-
function
|
|
4803
|
+
function li(e) {
|
|
4778
4804
|
return {
|
|
4779
|
-
proxyRoutes:
|
|
4780
|
-
resolveHost: (t) =>
|
|
4805
|
+
proxyRoutes: Pn(e),
|
|
4806
|
+
resolveHost: (t) => ci(e, t)
|
|
4781
4807
|
};
|
|
4782
4808
|
}
|
|
4783
4809
|
//#endregion
|
|
4784
|
-
export {
|
|
4810
|
+
export { li as createProxyDataAdapter, Pn as createProxyRoutesAdapter, ai as default, qe as sqlite };
|