@authhero/drizzle 0.41.0 → 0.42.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 +3 -3
- package/dist/drizzle-adapter.mjs +1056 -1080
- package/package.json +2 -2
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var yr = Object.defineProperty;
|
|
2
|
+
var wr = (n, i, e) => i in n ? yr(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var h = (n, i, e) => wr(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
const v = Symbol.for("drizzle:entityKind");
|
|
5
5
|
function X(n, i) {
|
|
6
6
|
if (!n || typeof n != "object")
|
|
@@ -20,27 +20,27 @@ function X(n, i) {
|
|
|
20
20
|
}
|
|
21
21
|
return !1;
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
|
|
23
|
+
var jt;
|
|
24
|
+
jt = v;
|
|
25
25
|
class Qe {
|
|
26
26
|
constructor(i, e) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
h(this, "name");
|
|
28
|
+
h(this, "keyAsName");
|
|
29
|
+
h(this, "primary");
|
|
30
|
+
h(this, "notNull");
|
|
31
|
+
h(this, "default");
|
|
32
|
+
h(this, "defaultFn");
|
|
33
|
+
h(this, "onUpdateFn");
|
|
34
|
+
h(this, "hasDefault");
|
|
35
|
+
h(this, "isUnique");
|
|
36
|
+
h(this, "uniqueName");
|
|
37
|
+
h(this, "uniqueType");
|
|
38
|
+
h(this, "dataType");
|
|
39
|
+
h(this, "columnType");
|
|
40
|
+
h(this, "enumValues");
|
|
41
|
+
h(this, "generated");
|
|
42
|
+
h(this, "generatedIdentity");
|
|
43
|
+
h(this, "config");
|
|
44
44
|
this.table = i, this.config = e, this.name = e.name, this.keyAsName = e.keyAsName, this.notNull = e.notNull, this.default = e.default, this.defaultFn = e.defaultFn, this.onUpdateFn = e.onUpdateFn, this.hasDefault = e.hasDefault, this.primary = e.primaryKey, this.isUnique = e.isUnique, this.uniqueName = e.uniqueName, this.uniqueType = e.uniqueType, this.dataType = e.dataType, this.columnType = e.columnType, this.generated = e.generated, this.generatedIdentity = e.generatedIdentity;
|
|
45
45
|
}
|
|
46
46
|
mapFromDriverValue(i) {
|
|
@@ -54,20 +54,20 @@ class Qe {
|
|
|
54
54
|
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
class
|
|
57
|
+
h(Qe, jt, "Column");
|
|
58
|
+
var Mt;
|
|
59
|
+
Mt = v;
|
|
60
|
+
class Ti {
|
|
61
61
|
constructor(i, e, t) {
|
|
62
|
-
|
|
62
|
+
h(this, "config");
|
|
63
63
|
/**
|
|
64
64
|
* Alias for {@link $defaultFn}.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
h(this, "$default", this.$defaultFn);
|
|
67
67
|
/**
|
|
68
68
|
* Alias for {@link $onUpdateFn}.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
h(this, "$onUpdate", this.$onUpdateFn);
|
|
71
71
|
this.config = {
|
|
72
72
|
name: i,
|
|
73
73
|
keyAsName: i === "",
|
|
@@ -147,14 +147,14 @@ class qi {
|
|
|
147
147
|
this.config.name === "" && (this.config.name = i);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
h(Ti, Mt, "ColumnBuilder");
|
|
151
151
|
const ze = Symbol.for("drizzle:Name"), Tt = Symbol.for("drizzle:isPgEnum");
|
|
152
|
-
function
|
|
152
|
+
function Nr(n) {
|
|
153
153
|
return !!n && typeof n == "function" && Tt in n && n[Tt] === !0;
|
|
154
154
|
}
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
class
|
|
155
|
+
var Vt;
|
|
156
|
+
Vt = v;
|
|
157
|
+
class xt {
|
|
158
158
|
constructor(i, e, t, r = !1, o = []) {
|
|
159
159
|
this._ = {
|
|
160
160
|
brand: "Subquery",
|
|
@@ -169,48 +169,48 @@ class bt {
|
|
|
169
169
|
// return new SQL([this]);
|
|
170
170
|
// }
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
const
|
|
172
|
+
h(xt, Vt, "Subquery");
|
|
173
|
+
const vr = {
|
|
174
174
|
startActiveSpan(n, i) {
|
|
175
175
|
return i();
|
|
176
176
|
}
|
|
177
|
-
},
|
|
178
|
-
var Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn
|
|
179
|
-
|
|
177
|
+
}, Ae = Symbol.for("drizzle:ViewBaseConfig"), Xe = Symbol.for("drizzle:Schema"), qt = Symbol.for("drizzle:Columns"), Lt = Symbol.for("drizzle:ExtraConfigColumns"), Ze = Symbol.for("drizzle:OriginalName"), et = Symbol.for("drizzle:BaseName"), Ve = Symbol.for("drizzle:IsAlias"), Et = Symbol.for("drizzle:ExtraConfigBuilder"), Sr = Symbol.for("drizzle:IsDrizzleTable");
|
|
178
|
+
var Rt, Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn;
|
|
179
|
+
nn = v, tn = ze, en = Ze, Zt = Xe, Xt = qt, Yt = Lt, Gt = et, Ht = Ve, Wt = Sr, Rt = Et;
|
|
180
180
|
class M {
|
|
181
181
|
constructor(i, e, t) {
|
|
182
182
|
/**
|
|
183
183
|
* @internal
|
|
184
184
|
* Can be changed if the table is aliased.
|
|
185
185
|
*/
|
|
186
|
-
|
|
186
|
+
h(this, tn);
|
|
187
187
|
/**
|
|
188
188
|
* @internal
|
|
189
189
|
* Used to store the original name of the table, before any aliasing.
|
|
190
190
|
*/
|
|
191
|
-
|
|
191
|
+
h(this, en);
|
|
192
192
|
/** @internal */
|
|
193
|
-
|
|
193
|
+
h(this, Zt);
|
|
194
194
|
/** @internal */
|
|
195
|
-
|
|
195
|
+
h(this, Xt);
|
|
196
196
|
/** @internal */
|
|
197
|
-
|
|
197
|
+
h(this, Yt);
|
|
198
198
|
/**
|
|
199
199
|
* @internal
|
|
200
200
|
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
201
201
|
*/
|
|
202
|
-
|
|
202
|
+
h(this, Gt);
|
|
203
203
|
/** @internal */
|
|
204
|
-
|
|
204
|
+
h(this, Ht, !1);
|
|
205
205
|
/** @internal */
|
|
206
|
-
|
|
206
|
+
h(this, Wt, !0);
|
|
207
207
|
/** @internal */
|
|
208
|
-
|
|
208
|
+
h(this, Rt);
|
|
209
209
|
this[ze] = this[Ze] = i, this[Xe] = e, this[et] = t;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
h(M, nn, "Table"), /** @internal */
|
|
213
|
+
h(M, "Symbol", {
|
|
214
214
|
Name: ze,
|
|
215
215
|
Schema: Xe,
|
|
216
216
|
OriginalName: Ze,
|
|
@@ -220,7 +220,7 @@ p(M, "Symbol", {
|
|
|
220
220
|
IsAlias: Ve,
|
|
221
221
|
ExtraConfigBuilder: Et
|
|
222
222
|
});
|
|
223
|
-
function
|
|
223
|
+
function qi(n) {
|
|
224
224
|
return n != null && typeof n.getSQL == "function";
|
|
225
225
|
}
|
|
226
226
|
function br(n) {
|
|
@@ -230,27 +230,27 @@ function br(n) {
|
|
|
230
230
|
i.sql += t.sql, i.params.push(...t.params), (e = t.typings) != null && e.length && (i.typings || (i.typings = []), i.typings.push(...t.typings));
|
|
231
231
|
return i;
|
|
232
232
|
}
|
|
233
|
-
var
|
|
234
|
-
|
|
233
|
+
var rn;
|
|
234
|
+
rn = v;
|
|
235
235
|
class Z {
|
|
236
236
|
constructor(i) {
|
|
237
|
-
|
|
237
|
+
h(this, "value");
|
|
238
238
|
this.value = Array.isArray(i) ? i : [i];
|
|
239
239
|
}
|
|
240
240
|
getSQL() {
|
|
241
241
|
return new F([this]);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
var
|
|
246
|
-
|
|
244
|
+
h(Z, rn, "StringChunk");
|
|
245
|
+
var sn;
|
|
246
|
+
sn = v;
|
|
247
247
|
const De = class De {
|
|
248
248
|
constructor(i) {
|
|
249
249
|
/** @internal */
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
h(this, "decoder", Li);
|
|
251
|
+
h(this, "shouldInlineParams", !1);
|
|
252
252
|
/** @internal */
|
|
253
|
-
|
|
253
|
+
h(this, "usedTables", []);
|
|
254
254
|
this.queryChunks = i;
|
|
255
255
|
for (const e of i)
|
|
256
256
|
if (X(e, M)) {
|
|
@@ -264,7 +264,7 @@ const De = class De {
|
|
|
264
264
|
return this.queryChunks.push(...i.queryChunks), this;
|
|
265
265
|
}
|
|
266
266
|
toQuery(i) {
|
|
267
|
-
return
|
|
267
|
+
return vr.startActiveSpan("drizzle.buildSQL", (e) => {
|
|
268
268
|
const t = this.buildQueryFromSourceParams(this.queryChunks, i);
|
|
269
269
|
return e == null || e.setAttributes({
|
|
270
270
|
"drizzle.query.text": t.sql,
|
|
@@ -281,73 +281,73 @@ const De = class De {
|
|
|
281
281
|
escapeName: o,
|
|
282
282
|
escapeParam: l,
|
|
283
283
|
prepareTyping: _,
|
|
284
|
-
inlineParams:
|
|
284
|
+
inlineParams: d,
|
|
285
285
|
paramStartIndex: c
|
|
286
286
|
} = t;
|
|
287
|
-
return br(i.map((
|
|
288
|
-
var
|
|
289
|
-
if (X(
|
|
290
|
-
return { sql:
|
|
291
|
-
if (X(
|
|
292
|
-
return { sql: o(
|
|
293
|
-
if (
|
|
287
|
+
return br(i.map((u) => {
|
|
288
|
+
var p;
|
|
289
|
+
if (X(u, Z))
|
|
290
|
+
return { sql: u.value.join(""), params: [] };
|
|
291
|
+
if (X(u, Re))
|
|
292
|
+
return { sql: o(u.value), params: [] };
|
|
293
|
+
if (u === void 0)
|
|
294
294
|
return { sql: "", params: [] };
|
|
295
|
-
if (Array.isArray(
|
|
295
|
+
if (Array.isArray(u)) {
|
|
296
296
|
const f = [new Z("(")];
|
|
297
|
-
for (const [y,
|
|
298
|
-
f.push(
|
|
297
|
+
for (const [y, w] of u.entries())
|
|
298
|
+
f.push(w), y < u.length - 1 && f.push(new Z(", "));
|
|
299
299
|
return f.push(new Z(")")), this.buildQueryFromSourceParams(f, t);
|
|
300
300
|
}
|
|
301
|
-
if (X(
|
|
302
|
-
return this.buildQueryFromSourceParams(
|
|
301
|
+
if (X(u, De))
|
|
302
|
+
return this.buildQueryFromSourceParams(u.queryChunks, {
|
|
303
303
|
...t,
|
|
304
|
-
inlineParams:
|
|
304
|
+
inlineParams: d || u.shouldInlineParams
|
|
305
305
|
});
|
|
306
|
-
if (X(
|
|
307
|
-
const f =
|
|
306
|
+
if (X(u, M)) {
|
|
307
|
+
const f = u[M.Symbol.Schema], y = u[M.Symbol.Name];
|
|
308
308
|
return {
|
|
309
|
-
sql: f === void 0 ||
|
|
309
|
+
sql: f === void 0 || u[Ve] ? o(y) : o(f) + "." + o(y),
|
|
310
310
|
params: []
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
if (X(
|
|
314
|
-
const f = r.getColumnCasing(
|
|
313
|
+
if (X(u, Qe)) {
|
|
314
|
+
const f = r.getColumnCasing(u);
|
|
315
315
|
if (e.invokeSource === "indexes")
|
|
316
316
|
return { sql: o(f), params: [] };
|
|
317
|
-
const y =
|
|
317
|
+
const y = u.table[M.Symbol.Schema];
|
|
318
318
|
return {
|
|
319
|
-
sql:
|
|
319
|
+
sql: u.table[Ve] || y === void 0 ? o(u.table[M.Symbol.Name]) + "." + o(f) : o(y) + "." + o(u.table[M.Symbol.Name]) + "." + o(f),
|
|
320
320
|
params: []
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
|
-
if (X(
|
|
324
|
-
const f =
|
|
323
|
+
if (X(u, Dt)) {
|
|
324
|
+
const f = u[Ae].schema, y = u[Ae].name;
|
|
325
325
|
return {
|
|
326
|
-
sql: f === void 0 ||
|
|
326
|
+
sql: f === void 0 || u[Ae].isAlias ? o(y) : o(f) + "." + o(y),
|
|
327
327
|
params: []
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
if (X(
|
|
331
|
-
if (X(
|
|
332
|
-
return { sql: l(c.value++,
|
|
333
|
-
const f =
|
|
330
|
+
if (X(u, Ce)) {
|
|
331
|
+
if (X(u.value, Be))
|
|
332
|
+
return { sql: l(c.value++, u), params: [u], typings: ["none"] };
|
|
333
|
+
const f = u.value === null ? null : u.encoder.mapToDriverValue(u.value);
|
|
334
334
|
if (X(f, De))
|
|
335
335
|
return this.buildQueryFromSourceParams([f], t);
|
|
336
|
-
if (
|
|
336
|
+
if (d)
|
|
337
337
|
return { sql: this.mapInlineParam(f, t), params: [] };
|
|
338
338
|
let y = ["none"];
|
|
339
|
-
return _ && (y = [_(
|
|
339
|
+
return _ && (y = [_(u.encoder)]), { sql: l(c.value++, f), params: [f], typings: y };
|
|
340
340
|
}
|
|
341
|
-
return X(
|
|
341
|
+
return X(u, Be) ? { sql: l(c.value++, u), params: [u], typings: ["none"] } : X(u, De.Aliased) && u.fieldAlias !== void 0 ? { sql: o(u.fieldAlias), params: [] } : X(u, xt) ? u._.isWith ? { sql: o(u._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
342
342
|
new Z("("),
|
|
343
|
-
|
|
343
|
+
u._.sql,
|
|
344
344
|
new Z(") "),
|
|
345
|
-
new Re(
|
|
346
|
-
], t) :
|
|
345
|
+
new Re(u._.alias)
|
|
346
|
+
], t) : Nr(u) ? u.schema ? { sql: o(u.schema) + "." + o(u.enumName), params: [] } : { sql: o(u.enumName), params: [] } : qi(u) ? (p = u.shouldOmitSQLParens) != null && p.call(u) ? this.buildQueryFromSourceParams([u.getSQL()], t) : this.buildQueryFromSourceParams([
|
|
347
347
|
new Z("("),
|
|
348
|
-
|
|
348
|
+
u.getSQL(),
|
|
349
349
|
new Z(")")
|
|
350
|
-
], t) :
|
|
350
|
+
], t) : d ? { sql: this.mapInlineParam(u, t), params: [] } : { sql: l(c.value++, u), params: [u], typings: ["none"] };
|
|
351
351
|
}));
|
|
352
352
|
}
|
|
353
353
|
mapInlineParam(i, { escapeString: e }) {
|
|
@@ -385,49 +385,49 @@ const De = class De {
|
|
|
385
385
|
return i ? this : void 0;
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
|
-
|
|
388
|
+
h(De, sn, "SQL");
|
|
389
389
|
let F = De;
|
|
390
|
-
var
|
|
391
|
-
|
|
390
|
+
var on;
|
|
391
|
+
on = v;
|
|
392
392
|
class Re {
|
|
393
393
|
constructor(i) {
|
|
394
|
-
|
|
394
|
+
h(this, "brand");
|
|
395
395
|
this.value = i;
|
|
396
396
|
}
|
|
397
397
|
getSQL() {
|
|
398
398
|
return new F([this]);
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
|
|
402
|
-
function
|
|
401
|
+
h(Re, on, "Name");
|
|
402
|
+
function xr(n) {
|
|
403
403
|
return typeof n == "object" && n !== null && "mapToDriverValue" in n && typeof n.mapToDriverValue == "function";
|
|
404
404
|
}
|
|
405
|
-
const
|
|
405
|
+
const Li = {
|
|
406
406
|
mapFromDriverValue: (n) => n
|
|
407
|
-
},
|
|
407
|
+
}, Ei = {
|
|
408
408
|
mapToDriverValue: (n) => n
|
|
409
409
|
};
|
|
410
410
|
({
|
|
411
|
-
...
|
|
412
|
-
...
|
|
411
|
+
...Li,
|
|
412
|
+
...Ei
|
|
413
413
|
});
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
class
|
|
414
|
+
var an;
|
|
415
|
+
an = v;
|
|
416
|
+
class Ce {
|
|
417
417
|
/**
|
|
418
418
|
* @param value - Parameter value
|
|
419
419
|
* @param encoder - Encoder to convert the value to a driver parameter
|
|
420
420
|
*/
|
|
421
|
-
constructor(i, e =
|
|
422
|
-
|
|
421
|
+
constructor(i, e = Ei) {
|
|
422
|
+
h(this, "brand");
|
|
423
423
|
this.value = i, this.encoder = e;
|
|
424
424
|
}
|
|
425
425
|
getSQL() {
|
|
426
426
|
return new F([this]);
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
|
|
430
|
-
function
|
|
429
|
+
h(Ce, an, "Param");
|
|
430
|
+
function N(n, ...i) {
|
|
431
431
|
const e = [];
|
|
432
432
|
(i.length > 0 || n.length > 0 && n[0] !== "") && e.push(new Z(n[0]));
|
|
433
433
|
for (const [t, r] of i.entries())
|
|
@@ -439,41 +439,41 @@ function w(n, ...i) {
|
|
|
439
439
|
return new F([]);
|
|
440
440
|
}
|
|
441
441
|
n.empty = i;
|
|
442
|
-
function e(
|
|
443
|
-
return new F(
|
|
442
|
+
function e(d) {
|
|
443
|
+
return new F(d);
|
|
444
444
|
}
|
|
445
445
|
n.fromList = e;
|
|
446
|
-
function t(
|
|
447
|
-
return new F([new Z(
|
|
446
|
+
function t(d) {
|
|
447
|
+
return new F([new Z(d)]);
|
|
448
448
|
}
|
|
449
449
|
n.raw = t;
|
|
450
|
-
function r(
|
|
451
|
-
const
|
|
452
|
-
for (const [
|
|
453
|
-
|
|
454
|
-
return new F(
|
|
450
|
+
function r(d, c) {
|
|
451
|
+
const u = [];
|
|
452
|
+
for (const [p, f] of d.entries())
|
|
453
|
+
p > 0 && c !== void 0 && u.push(c), u.push(f);
|
|
454
|
+
return new F(u);
|
|
455
455
|
}
|
|
456
456
|
n.join = r;
|
|
457
|
-
function o(
|
|
458
|
-
return new Re(
|
|
457
|
+
function o(d) {
|
|
458
|
+
return new Re(d);
|
|
459
459
|
}
|
|
460
460
|
n.identifier = o;
|
|
461
|
-
function l(
|
|
462
|
-
return new Be(
|
|
461
|
+
function l(d) {
|
|
462
|
+
return new Be(d);
|
|
463
463
|
}
|
|
464
464
|
n.placeholder = l;
|
|
465
|
-
function _(
|
|
466
|
-
return new
|
|
465
|
+
function _(d, c) {
|
|
466
|
+
return new Ce(d, c);
|
|
467
467
|
}
|
|
468
468
|
n.param = _;
|
|
469
|
-
})(
|
|
469
|
+
})(N || (N = {}));
|
|
470
470
|
((n) => {
|
|
471
471
|
var e;
|
|
472
472
|
e = v;
|
|
473
473
|
const t = class t {
|
|
474
474
|
constructor(o, l) {
|
|
475
475
|
/** @internal */
|
|
476
|
-
|
|
476
|
+
h(this, "isSelectionField", !1);
|
|
477
477
|
this.sql = o, this.fieldAlias = l;
|
|
478
478
|
}
|
|
479
479
|
getSQL() {
|
|
@@ -484,12 +484,12 @@ function w(n, ...i) {
|
|
|
484
484
|
return new t(this.sql, this.fieldAlias);
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
|
-
|
|
487
|
+
h(t, e, "SQL.Aliased");
|
|
488
488
|
let i = t;
|
|
489
489
|
n.Aliased = i;
|
|
490
490
|
})(F || (F = {}));
|
|
491
|
-
var
|
|
492
|
-
|
|
491
|
+
var ln;
|
|
492
|
+
ln = v;
|
|
493
493
|
class Be {
|
|
494
494
|
constructor(i) {
|
|
495
495
|
this.name = i;
|
|
@@ -498,17 +498,17 @@ class Be {
|
|
|
498
498
|
return new F([this]);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
|
|
502
|
-
const
|
|
503
|
-
var un, dn
|
|
504
|
-
|
|
501
|
+
h(Be, ln, "Placeholder");
|
|
502
|
+
const Dr = Symbol.for("drizzle:IsDrizzleView");
|
|
503
|
+
var _n, un, dn;
|
|
504
|
+
dn = v, un = Ae, _n = Dr;
|
|
505
505
|
class Dt {
|
|
506
506
|
constructor({ name: i, schema: e, selectedFields: t, query: r }) {
|
|
507
507
|
/** @internal */
|
|
508
|
-
|
|
508
|
+
h(this, un);
|
|
509
509
|
/** @internal */
|
|
510
|
-
|
|
511
|
-
this[
|
|
510
|
+
h(this, _n, !0);
|
|
511
|
+
this[Ae] = {
|
|
512
512
|
name: i,
|
|
513
513
|
originalName: i,
|
|
514
514
|
schema: e,
|
|
@@ -522,14 +522,14 @@ class Dt {
|
|
|
522
522
|
return new F([this]);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
|
|
525
|
+
h(Dt, dn, "View");
|
|
526
526
|
Qe.prototype.getSQL = function() {
|
|
527
527
|
return new F([this]);
|
|
528
528
|
};
|
|
529
529
|
M.prototype.getSQL = function() {
|
|
530
530
|
return new F([this]);
|
|
531
531
|
};
|
|
532
|
-
|
|
532
|
+
xt.prototype.getSQL = function() {
|
|
533
533
|
return new F([this]);
|
|
534
534
|
};
|
|
535
535
|
function Je(n, i) {
|
|
@@ -539,10 +539,10 @@ function Je(n, i) {
|
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
const Ai = typeof TextDecoder > "u" ? null : new TextDecoder();
|
|
542
|
-
function
|
|
543
|
-
return
|
|
542
|
+
function be(n, i) {
|
|
543
|
+
return xr(i) && !qi(n) && !X(n, Ce) && !X(n, Be) && !X(n, Qe) && !X(n, M) && !X(n, Dt) ? new Ce(n, i) : n;
|
|
544
544
|
}
|
|
545
|
-
const a = (n, i) =>
|
|
545
|
+
const a = (n, i) => N`${n} = ${be(i, n)}`, Or = (n, i) => N`${n} <> ${be(i, n)}`;
|
|
546
546
|
function g(...n) {
|
|
547
547
|
const i = n.filter(
|
|
548
548
|
(e) => e !== void 0
|
|
@@ -550,7 +550,7 @@ function g(...n) {
|
|
|
550
550
|
if (i.length !== 0)
|
|
551
551
|
return i.length === 1 ? new F(i) : new F([
|
|
552
552
|
new Z("("),
|
|
553
|
-
|
|
553
|
+
N.join(i, new Z(" and ")),
|
|
554
554
|
new Z(")")
|
|
555
555
|
]);
|
|
556
556
|
}
|
|
@@ -561,33 +561,33 @@ function de(...n) {
|
|
|
561
561
|
if (i.length !== 0)
|
|
562
562
|
return i.length === 1 ? new F(i) : new F([
|
|
563
563
|
new Z("("),
|
|
564
|
-
|
|
564
|
+
N.join(i, new Z(" or ")),
|
|
565
565
|
new Z(")")
|
|
566
566
|
]);
|
|
567
567
|
}
|
|
568
|
-
const We = (n, i) =>
|
|
568
|
+
const We = (n, i) => N`${n} > ${be(i, n)}`, He = (n, i) => N`${n} >= ${be(i, n)}`, we = (n, i) => N`${n} < ${be(i, n)}`, Oe = (n, i) => N`${n} <= ${be(i, n)}`;
|
|
569
569
|
function Ne(n, i) {
|
|
570
|
-
return Array.isArray(i) ? i.length === 0 ?
|
|
570
|
+
return Array.isArray(i) ? i.length === 0 ? N`false` : N`${n} in ${i.map((e) => be(e, n))}` : N`${n} in ${be(i, n)}`;
|
|
571
571
|
}
|
|
572
572
|
function me(n) {
|
|
573
|
-
return
|
|
573
|
+
return N`${n} is null`;
|
|
574
574
|
}
|
|
575
575
|
function Me(n) {
|
|
576
|
-
return
|
|
576
|
+
return N`${n} is not null`;
|
|
577
577
|
}
|
|
578
578
|
function Ie(n, i) {
|
|
579
|
-
return
|
|
579
|
+
return N`${n} like ${i}`;
|
|
580
580
|
}
|
|
581
581
|
function G(n) {
|
|
582
|
-
return
|
|
582
|
+
return N`${n} asc`;
|
|
583
583
|
}
|
|
584
584
|
function V(n) {
|
|
585
|
-
return
|
|
585
|
+
return N`${n} desc`;
|
|
586
586
|
}
|
|
587
587
|
function R(n) {
|
|
588
|
-
return
|
|
588
|
+
return N`count(${N.raw("*")})`.mapWith(Number);
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function kr() {
|
|
591
591
|
const n = (i) => {
|
|
592
592
|
throw new Error(
|
|
593
593
|
`Actions are not implemented in the Drizzle adapter (called ${i}). Use the Kysely adapter for tenants that require actions.`
|
|
@@ -601,16 +601,16 @@ function Ir() {
|
|
|
601
601
|
remove: () => n("remove")
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
|
-
var
|
|
605
|
-
|
|
606
|
-
class
|
|
604
|
+
var cn;
|
|
605
|
+
cn = v;
|
|
606
|
+
class Ci {
|
|
607
607
|
constructor(i, e) {
|
|
608
608
|
/** @internal */
|
|
609
|
-
|
|
609
|
+
h(this, "reference");
|
|
610
610
|
/** @internal */
|
|
611
|
-
|
|
611
|
+
h(this, "_onUpdate");
|
|
612
612
|
/** @internal */
|
|
613
|
-
|
|
613
|
+
h(this, "_onDelete");
|
|
614
614
|
this.reference = () => {
|
|
615
615
|
const { name: t, columns: r, foreignColumns: o } = i();
|
|
616
616
|
return { name: t, columns: r, foreignTable: o[0].table, foreignColumns: o };
|
|
@@ -624,17 +624,17 @@ class Bi {
|
|
|
624
624
|
}
|
|
625
625
|
/** @internal */
|
|
626
626
|
build(i) {
|
|
627
|
-
return new
|
|
627
|
+
return new Bi(i, this);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
|
|
631
|
-
var
|
|
632
|
-
|
|
633
|
-
class
|
|
630
|
+
h(Ci, cn, "SQLiteForeignKeyBuilder");
|
|
631
|
+
var gn;
|
|
632
|
+
gn = v;
|
|
633
|
+
class Bi {
|
|
634
634
|
constructor(i, e) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
635
|
+
h(this, "reference");
|
|
636
|
+
h(this, "onUpdate");
|
|
637
|
+
h(this, "onDelete");
|
|
638
638
|
this.table = i, this.reference = e.reference, this.onUpdate = e._onUpdate, this.onDelete = e._onDelete;
|
|
639
639
|
}
|
|
640
640
|
getName() {
|
|
@@ -647,15 +647,15 @@ class $i {
|
|
|
647
647
|
return i ?? `${l.join("_")}_fk`;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
|
|
651
|
-
function
|
|
650
|
+
h(Bi, gn, "SQLiteForeignKey");
|
|
651
|
+
function Ir(n, i) {
|
|
652
652
|
return `${n[ze]}_${i.join("_")}_unique`;
|
|
653
653
|
}
|
|
654
|
-
var
|
|
655
|
-
class ce extends (hn =
|
|
654
|
+
var fn, hn;
|
|
655
|
+
class ce extends (hn = Ti, fn = v, hn) {
|
|
656
656
|
constructor() {
|
|
657
657
|
super(...arguments);
|
|
658
|
-
|
|
658
|
+
h(this, "foreignKeyConfigs", []);
|
|
659
659
|
}
|
|
660
660
|
references(e, t = {}) {
|
|
661
661
|
return this.foreignKeyConfigs.push({ ref: e, actions: t }), this;
|
|
@@ -673,35 +673,35 @@ class ce extends (hn = qi, pn = v, hn) {
|
|
|
673
673
|
/** @internal */
|
|
674
674
|
buildForeignKeys(e, t) {
|
|
675
675
|
return this.foreignKeyConfigs.map(({ ref: r, actions: o }) => ((l, _) => {
|
|
676
|
-
const
|
|
676
|
+
const d = new Ci(() => {
|
|
677
677
|
const c = l();
|
|
678
678
|
return { columns: [e], foreignColumns: [c] };
|
|
679
679
|
});
|
|
680
|
-
return _.onUpdate &&
|
|
680
|
+
return _.onUpdate && d.onUpdate(_.onUpdate), _.onDelete && d.onDelete(_.onDelete), d.build(t);
|
|
681
681
|
})(r, o));
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
|
-
|
|
685
|
-
var
|
|
686
|
-
class ge extends (
|
|
684
|
+
h(ce, fn, "SQLiteColumnBuilder");
|
|
685
|
+
var pn, mn;
|
|
686
|
+
class ge extends (mn = Qe, pn = v, mn) {
|
|
687
687
|
constructor(i, e) {
|
|
688
|
-
e.uniqueName || (e.uniqueName =
|
|
688
|
+
e.uniqueName || (e.uniqueName = Ir(i, [e.name])), super(i, e), this.table = i;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
|
-
|
|
692
|
-
var
|
|
693
|
-
class
|
|
691
|
+
h(ge, pn, "SQLiteColumn");
|
|
692
|
+
var yn, wn;
|
|
693
|
+
class $i extends (wn = ce, yn = v, wn) {
|
|
694
694
|
constructor(i) {
|
|
695
695
|
super(i, "bigint", "SQLiteBigInt");
|
|
696
696
|
}
|
|
697
697
|
/** @internal */
|
|
698
698
|
build(i) {
|
|
699
|
-
return new
|
|
699
|
+
return new Qi(i, this.config);
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
|
-
|
|
703
|
-
var
|
|
704
|
-
class
|
|
702
|
+
h($i, yn, "SQLiteBigIntBuilder");
|
|
703
|
+
var Nn, vn;
|
|
704
|
+
class Qi extends (vn = ge, Nn = v, vn) {
|
|
705
705
|
getSQLType() {
|
|
706
706
|
return "blob";
|
|
707
707
|
}
|
|
@@ -716,23 +716,23 @@ class Ji extends (Sn = ge, vn = v, Sn) {
|
|
|
716
716
|
return Buffer.from(i.toString());
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
|
-
|
|
720
|
-
var
|
|
721
|
-
class
|
|
719
|
+
h(Qi, Nn, "SQLiteBigInt");
|
|
720
|
+
var Sn, bn;
|
|
721
|
+
class Ji extends (bn = ce, Sn = v, bn) {
|
|
722
722
|
constructor(i) {
|
|
723
723
|
super(i, "json", "SQLiteBlobJson");
|
|
724
724
|
}
|
|
725
725
|
/** @internal */
|
|
726
726
|
build(i) {
|
|
727
|
-
return new
|
|
727
|
+
return new Pi(
|
|
728
728
|
i,
|
|
729
729
|
this.config
|
|
730
730
|
);
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
|
|
734
|
-
var
|
|
735
|
-
class
|
|
733
|
+
h(Ji, Sn, "SQLiteBlobJsonBuilder");
|
|
734
|
+
var xn, Dn;
|
|
735
|
+
class Pi extends (Dn = ge, xn = v, Dn) {
|
|
736
736
|
getSQLType() {
|
|
737
737
|
return "blob";
|
|
738
738
|
}
|
|
@@ -747,20 +747,20 @@ class Fi extends (On = ge, Dn = v, On) {
|
|
|
747
747
|
return Buffer.from(JSON.stringify(i));
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
|
|
751
|
-
var
|
|
752
|
-
class
|
|
750
|
+
h(Pi, xn, "SQLiteBlobJson");
|
|
751
|
+
var On, kn;
|
|
752
|
+
class Fi extends (kn = ce, On = v, kn) {
|
|
753
753
|
constructor(i) {
|
|
754
754
|
super(i, "buffer", "SQLiteBlobBuffer");
|
|
755
755
|
}
|
|
756
756
|
/** @internal */
|
|
757
757
|
build(i) {
|
|
758
|
-
return new
|
|
758
|
+
return new Ui(i, this.config);
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
|
-
|
|
762
|
-
var
|
|
763
|
-
class
|
|
761
|
+
h(Fi, On, "SQLiteBlobBufferBuilder");
|
|
762
|
+
var In, zn;
|
|
763
|
+
class Ui extends (zn = ge, In = v, zn) {
|
|
764
764
|
mapFromDriverValue(i) {
|
|
765
765
|
return Buffer.isBuffer(i) ? i : Buffer.from(i);
|
|
766
766
|
}
|
|
@@ -768,32 +768,32 @@ class Ki extends (Tn = ge, zn = v, Tn) {
|
|
|
768
768
|
return "blob";
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
|
-
|
|
772
|
-
function
|
|
771
|
+
h(Ui, In, "SQLiteBlobBuffer");
|
|
772
|
+
function zr(n, i) {
|
|
773
773
|
const { name: e, config: t } = Je(n, i);
|
|
774
|
-
return (t == null ? void 0 : t.mode) === "json" ? new
|
|
774
|
+
return (t == null ? void 0 : t.mode) === "json" ? new Ji(e) : (t == null ? void 0 : t.mode) === "bigint" ? new $i(e) : new Fi(e);
|
|
775
775
|
}
|
|
776
|
-
var
|
|
777
|
-
class
|
|
776
|
+
var Tn, qn;
|
|
777
|
+
class Ki extends (qn = ce, Tn = v, qn) {
|
|
778
778
|
constructor(i, e, t) {
|
|
779
779
|
super(i, "custom", "SQLiteCustomColumn"), this.config.fieldConfig = e, this.config.customTypeParams = t;
|
|
780
780
|
}
|
|
781
781
|
/** @internal */
|
|
782
782
|
build(i) {
|
|
783
|
-
return new
|
|
783
|
+
return new ji(
|
|
784
784
|
i,
|
|
785
785
|
this.config
|
|
786
786
|
);
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
|
-
|
|
790
|
-
var
|
|
791
|
-
class
|
|
789
|
+
h(Ki, Tn, "SQLiteCustomColumnBuilder");
|
|
790
|
+
var Ln, En;
|
|
791
|
+
class ji extends (En = ge, Ln = v, En) {
|
|
792
792
|
constructor(e, t) {
|
|
793
793
|
super(e, t);
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
794
|
+
h(this, "sqlName");
|
|
795
|
+
h(this, "mapTo");
|
|
796
|
+
h(this, "mapFrom");
|
|
797
797
|
this.sqlName = t.customTypeParams.dataType(t.fieldConfig), this.mapTo = t.customTypeParams.toDriver, this.mapFrom = t.customTypeParams.fromDriver;
|
|
798
798
|
}
|
|
799
799
|
getSQLType() {
|
|
@@ -806,19 +806,19 @@ class Mi extends (Cn = ge, En = v, Cn) {
|
|
|
806
806
|
return typeof this.mapTo == "function" ? this.mapTo(e) : e;
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
|
|
810
|
-
function
|
|
809
|
+
h(ji, Ln, "SQLiteCustomColumn");
|
|
810
|
+
function Tr(n) {
|
|
811
811
|
return (i, e) => {
|
|
812
812
|
const { name: t, config: r } = Je(i, e);
|
|
813
|
-
return new
|
|
813
|
+
return new Ki(
|
|
814
814
|
t,
|
|
815
815
|
r,
|
|
816
816
|
n
|
|
817
817
|
);
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
|
-
var An,
|
|
821
|
-
class Ge extends (
|
|
820
|
+
var An, Cn;
|
|
821
|
+
class Ge extends (Cn = ce, An = v, Cn) {
|
|
822
822
|
constructor(i, e, t) {
|
|
823
823
|
super(i, e, t), this.config.autoIncrement = !1;
|
|
824
824
|
}
|
|
@@ -826,37 +826,37 @@ class Ge extends (Bn = ce, An = v, Bn) {
|
|
|
826
826
|
return i != null && i.autoIncrement && (this.config.autoIncrement = !0), this.config.hasDefault = !0, super.primaryKey();
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
|
-
|
|
830
|
-
var $n
|
|
831
|
-
class Ye extends (
|
|
829
|
+
h(Ge, An, "SQLiteBaseIntegerBuilder");
|
|
830
|
+
var Bn, $n;
|
|
831
|
+
class Ye extends ($n = ge, Bn = v, $n) {
|
|
832
832
|
constructor() {
|
|
833
833
|
super(...arguments);
|
|
834
|
-
|
|
834
|
+
h(this, "autoIncrement", this.config.autoIncrement);
|
|
835
835
|
}
|
|
836
836
|
getSQLType() {
|
|
837
837
|
return "integer";
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
|
|
841
|
-
var
|
|
842
|
-
class
|
|
840
|
+
h(Ye, Bn, "SQLiteBaseInteger");
|
|
841
|
+
var Qn, Jn;
|
|
842
|
+
class Mi extends (Jn = Ge, Qn = v, Jn) {
|
|
843
843
|
constructor(i) {
|
|
844
844
|
super(i, "number", "SQLiteInteger");
|
|
845
845
|
}
|
|
846
846
|
build(i) {
|
|
847
|
-
return new
|
|
847
|
+
return new Vi(
|
|
848
848
|
i,
|
|
849
849
|
this.config
|
|
850
850
|
);
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
|
-
|
|
854
|
-
var
|
|
855
|
-
class
|
|
853
|
+
h(Mi, Qn, "SQLiteIntegerBuilder");
|
|
854
|
+
var Pn, Fn;
|
|
855
|
+
class Vi extends (Fn = Ye, Pn = v, Fn) {
|
|
856
856
|
}
|
|
857
|
-
|
|
858
|
-
var
|
|
859
|
-
class
|
|
857
|
+
h(Vi, Pn, "SQLiteInteger");
|
|
858
|
+
var Un, Kn;
|
|
859
|
+
class Ri extends (Kn = Ge, Un = v, Kn) {
|
|
860
860
|
constructor(i, e) {
|
|
861
861
|
super(i, "date", "SQLiteTimestamp"), this.config.mode = e;
|
|
862
862
|
}
|
|
@@ -866,21 +866,21 @@ class Wi extends (jn = Ge, Kn = v, jn) {
|
|
|
866
866
|
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
|
|
867
867
|
*/
|
|
868
868
|
defaultNow() {
|
|
869
|
-
return this.default(
|
|
869
|
+
return this.default(N`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
|
|
870
870
|
}
|
|
871
871
|
build(i) {
|
|
872
|
-
return new
|
|
872
|
+
return new Wi(
|
|
873
873
|
i,
|
|
874
874
|
this.config
|
|
875
875
|
);
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
|
|
879
|
-
var
|
|
880
|
-
class
|
|
878
|
+
h(Ri, Un, "SQLiteTimestampBuilder");
|
|
879
|
+
var jn, Mn;
|
|
880
|
+
class Wi extends (Mn = Ye, jn = v, Mn) {
|
|
881
881
|
constructor() {
|
|
882
882
|
super(...arguments);
|
|
883
|
-
|
|
883
|
+
h(this, "mode", this.config.mode);
|
|
884
884
|
}
|
|
885
885
|
mapFromDriverValue(e) {
|
|
886
886
|
return this.config.mode === "timestamp" ? new Date(e * 1e3) : new Date(e);
|
|
@@ -890,25 +890,25 @@ class Hi extends (Vn = Ye, Mn = v, Vn) {
|
|
|
890
890
|
return this.config.mode === "timestamp" ? Math.floor(t / 1e3) : t;
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
-
|
|
894
|
-
var
|
|
895
|
-
class
|
|
893
|
+
h(Wi, jn, "SQLiteTimestamp");
|
|
894
|
+
var Vn, Rn;
|
|
895
|
+
class Hi extends (Rn = Ge, Vn = v, Rn) {
|
|
896
896
|
constructor(i, e) {
|
|
897
897
|
super(i, "boolean", "SQLiteBoolean"), this.config.mode = e;
|
|
898
898
|
}
|
|
899
899
|
build(i) {
|
|
900
|
-
return new
|
|
900
|
+
return new Gi(
|
|
901
901
|
i,
|
|
902
902
|
this.config
|
|
903
903
|
);
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
|
|
907
|
-
var
|
|
908
|
-
class
|
|
906
|
+
h(Hi, Vn, "SQLiteBooleanBuilder");
|
|
907
|
+
var Wn, Hn;
|
|
908
|
+
class Gi extends (Hn = Ye, Wn = v, Hn) {
|
|
909
909
|
constructor() {
|
|
910
910
|
super(...arguments);
|
|
911
|
-
|
|
911
|
+
h(this, "mode", this.config.mode);
|
|
912
912
|
}
|
|
913
913
|
mapFromDriverValue(e) {
|
|
914
914
|
return Number(e) === 1;
|
|
@@ -917,27 +917,27 @@ class Yi extends (Gn = Ye, Hn = v, Gn) {
|
|
|
917
917
|
return e ? 1 : 0;
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
|
|
920
|
+
h(Gi, Wn, "SQLiteBoolean");
|
|
921
921
|
function m(n, i) {
|
|
922
922
|
const { name: e, config: t } = Je(n, i);
|
|
923
|
-
return (t == null ? void 0 : t.mode) === "timestamp" || (t == null ? void 0 : t.mode) === "timestamp_ms" ? new
|
|
923
|
+
return (t == null ? void 0 : t.mode) === "timestamp" || (t == null ? void 0 : t.mode) === "timestamp_ms" ? new Ri(e, t.mode) : (t == null ? void 0 : t.mode) === "boolean" ? new Hi(e, t.mode) : new Mi(e);
|
|
924
924
|
}
|
|
925
|
-
var
|
|
926
|
-
class
|
|
925
|
+
var Gn, Yn;
|
|
926
|
+
class Yi extends (Yn = ce, Gn = v, Yn) {
|
|
927
927
|
constructor(i) {
|
|
928
928
|
super(i, "string", "SQLiteNumeric");
|
|
929
929
|
}
|
|
930
930
|
/** @internal */
|
|
931
931
|
build(i) {
|
|
932
|
-
return new
|
|
932
|
+
return new Xi(
|
|
933
933
|
i,
|
|
934
934
|
this.config
|
|
935
935
|
);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
|
|
939
|
-
var
|
|
940
|
-
class
|
|
938
|
+
h(Yi, Gn, "SQLiteNumericBuilder");
|
|
939
|
+
var Xn, Zn;
|
|
940
|
+
class Xi extends (Zn = ge, Xn = v, Zn) {
|
|
941
941
|
mapFromDriverValue(i) {
|
|
942
942
|
return typeof i == "string" ? i : String(i);
|
|
943
943
|
}
|
|
@@ -945,26 +945,26 @@ class Zi extends (ei = ge, Zn = v, ei) {
|
|
|
945
945
|
return "numeric";
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
|
|
949
|
-
var
|
|
950
|
-
class
|
|
948
|
+
h(Xi, Xn, "SQLiteNumeric");
|
|
949
|
+
var ei, ti;
|
|
950
|
+
class Zi extends (ti = ce, ei = v, ti) {
|
|
951
951
|
constructor(i) {
|
|
952
952
|
super(i, "number", "SQLiteNumericNumber");
|
|
953
953
|
}
|
|
954
954
|
/** @internal */
|
|
955
955
|
build(i) {
|
|
956
|
-
return new
|
|
956
|
+
return new er(
|
|
957
957
|
i,
|
|
958
958
|
this.config
|
|
959
959
|
);
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
|
-
|
|
963
|
-
var
|
|
964
|
-
class
|
|
962
|
+
h(Zi, ei, "SQLiteNumericNumberBuilder");
|
|
963
|
+
var ni, ii;
|
|
964
|
+
class er extends (ii = ge, ni = v, ii) {
|
|
965
965
|
constructor() {
|
|
966
966
|
super(...arguments);
|
|
967
|
-
|
|
967
|
+
h(this, "mapToDriverValue", String);
|
|
968
968
|
}
|
|
969
969
|
mapFromDriverValue(e) {
|
|
970
970
|
return typeof e == "number" ? e : Number(e);
|
|
@@ -973,100 +973,100 @@ class tr extends (ri = ge, ii = v, ri) {
|
|
|
973
973
|
return "numeric";
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
|
-
|
|
977
|
-
var
|
|
978
|
-
class
|
|
976
|
+
h(er, ni, "SQLiteNumericNumber");
|
|
977
|
+
var ri, si;
|
|
978
|
+
class tr extends (si = ce, ri = v, si) {
|
|
979
979
|
constructor(i) {
|
|
980
980
|
super(i, "bigint", "SQLiteNumericBigInt");
|
|
981
981
|
}
|
|
982
982
|
/** @internal */
|
|
983
983
|
build(i) {
|
|
984
|
-
return new
|
|
984
|
+
return new nr(
|
|
985
985
|
i,
|
|
986
986
|
this.config
|
|
987
987
|
);
|
|
988
988
|
}
|
|
989
989
|
}
|
|
990
|
-
|
|
991
|
-
var
|
|
992
|
-
class
|
|
990
|
+
h(tr, ri, "SQLiteNumericBigIntBuilder");
|
|
991
|
+
var oi, ai;
|
|
992
|
+
class nr extends (ai = ge, oi = v, ai) {
|
|
993
993
|
constructor() {
|
|
994
994
|
super(...arguments);
|
|
995
|
-
|
|
996
|
-
|
|
995
|
+
h(this, "mapFromDriverValue", BigInt);
|
|
996
|
+
h(this, "mapToDriverValue", String);
|
|
997
997
|
}
|
|
998
998
|
getSQLType() {
|
|
999
999
|
return "numeric";
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1003
|
-
function
|
|
1002
|
+
h(nr, oi, "SQLiteNumericBigInt");
|
|
1003
|
+
function qr(n, i) {
|
|
1004
1004
|
const { name: e, config: t } = Je(n, i), r = t == null ? void 0 : t.mode;
|
|
1005
|
-
return r === "number" ? new
|
|
1005
|
+
return r === "number" ? new Zi(e) : r === "bigint" ? new tr(e) : new Yi(e);
|
|
1006
1006
|
}
|
|
1007
|
-
var
|
|
1008
|
-
class
|
|
1007
|
+
var li, _i;
|
|
1008
|
+
class ir extends (_i = ce, li = v, _i) {
|
|
1009
1009
|
constructor(i) {
|
|
1010
1010
|
super(i, "number", "SQLiteReal");
|
|
1011
1011
|
}
|
|
1012
1012
|
/** @internal */
|
|
1013
1013
|
build(i) {
|
|
1014
|
-
return new
|
|
1014
|
+
return new rr(i, this.config);
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
|
|
1018
|
-
var
|
|
1019
|
-
class
|
|
1017
|
+
h(ir, li, "SQLiteRealBuilder");
|
|
1018
|
+
var ui, di;
|
|
1019
|
+
class rr extends (di = ge, ui = v, di) {
|
|
1020
1020
|
getSQLType() {
|
|
1021
1021
|
return "real";
|
|
1022
1022
|
}
|
|
1023
1023
|
}
|
|
1024
|
-
|
|
1025
|
-
function
|
|
1026
|
-
return new
|
|
1024
|
+
h(rr, ui, "SQLiteReal");
|
|
1025
|
+
function Lr(n) {
|
|
1026
|
+
return new ir(n ?? "");
|
|
1027
1027
|
}
|
|
1028
|
-
var
|
|
1029
|
-
class
|
|
1028
|
+
var ci, gi;
|
|
1029
|
+
class sr extends (gi = ce, ci = v, gi) {
|
|
1030
1030
|
constructor(i, e) {
|
|
1031
1031
|
super(i, "string", "SQLiteText"), this.config.enumValues = e.enum, this.config.length = e.length;
|
|
1032
1032
|
}
|
|
1033
1033
|
/** @internal */
|
|
1034
1034
|
build(i) {
|
|
1035
|
-
return new
|
|
1035
|
+
return new or(
|
|
1036
1036
|
i,
|
|
1037
1037
|
this.config
|
|
1038
1038
|
);
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
|
|
1042
|
-
var
|
|
1043
|
-
class
|
|
1041
|
+
h(sr, ci, "SQLiteTextBuilder");
|
|
1042
|
+
var fi, hi;
|
|
1043
|
+
class or extends (hi = ge, fi = v, hi) {
|
|
1044
1044
|
constructor(e, t) {
|
|
1045
1045
|
super(e, t);
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
h(this, "enumValues", this.config.enumValues);
|
|
1047
|
+
h(this, "length", this.config.length);
|
|
1048
1048
|
}
|
|
1049
1049
|
getSQLType() {
|
|
1050
1050
|
return `text${this.config.length ? `(${this.config.length})` : ""}`;
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
|
|
1054
|
-
var
|
|
1055
|
-
class
|
|
1053
|
+
h(or, fi, "SQLiteText");
|
|
1054
|
+
var pi, mi;
|
|
1055
|
+
class ar extends (mi = ce, pi = v, mi) {
|
|
1056
1056
|
constructor(i) {
|
|
1057
1057
|
super(i, "json", "SQLiteTextJson");
|
|
1058
1058
|
}
|
|
1059
1059
|
/** @internal */
|
|
1060
1060
|
build(i) {
|
|
1061
|
-
return new
|
|
1061
|
+
return new lr(
|
|
1062
1062
|
i,
|
|
1063
1063
|
this.config
|
|
1064
1064
|
);
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
|
|
1068
|
-
var
|
|
1069
|
-
class
|
|
1067
|
+
h(ar, pi, "SQLiteTextJsonBuilder");
|
|
1068
|
+
var yi, wi;
|
|
1069
|
+
class lr extends (wi = ge, yi = v, wi) {
|
|
1070
1070
|
getSQLType() {
|
|
1071
1071
|
return "text";
|
|
1072
1072
|
}
|
|
@@ -1077,67 +1077,67 @@ class _r extends (Ni = ge, wi = v, Ni) {
|
|
|
1077
1077
|
return JSON.stringify(i);
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
|
-
|
|
1080
|
+
h(lr, yi, "SQLiteTextJson");
|
|
1081
1081
|
function s(n, i = {}) {
|
|
1082
1082
|
const { name: e, config: t } = Je(n, i);
|
|
1083
|
-
return t.mode === "json" ? new
|
|
1083
|
+
return t.mode === "json" ? new ar(e) : new sr(e, t);
|
|
1084
1084
|
}
|
|
1085
|
-
function
|
|
1085
|
+
function Er() {
|
|
1086
1086
|
return {
|
|
1087
|
-
blob:
|
|
1088
|
-
customType:
|
|
1087
|
+
blob: zr,
|
|
1088
|
+
customType: Tr,
|
|
1089
1089
|
integer: m,
|
|
1090
|
-
numeric:
|
|
1091
|
-
real:
|
|
1090
|
+
numeric: qr,
|
|
1091
|
+
real: Lr,
|
|
1092
1092
|
text: s
|
|
1093
1093
|
};
|
|
1094
1094
|
}
|
|
1095
|
-
const
|
|
1096
|
-
var vi, Si,
|
|
1097
|
-
class $e extends (
|
|
1095
|
+
const pt = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
1096
|
+
var Ni, vi, Si, bi, xi;
|
|
1097
|
+
class $e extends (xi = M, bi = v, Si = M.Symbol.Columns, vi = pt, Ni = M.Symbol.ExtraConfigBuilder, xi) {
|
|
1098
1098
|
constructor() {
|
|
1099
1099
|
super(...arguments);
|
|
1100
1100
|
/** @internal */
|
|
1101
|
-
|
|
1101
|
+
h(this, Si);
|
|
1102
1102
|
/** @internal */
|
|
1103
|
-
|
|
1103
|
+
h(this, vi, []);
|
|
1104
1104
|
/** @internal */
|
|
1105
|
-
|
|
1105
|
+
h(this, Ni);
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
InlineForeignKeys:
|
|
1108
|
+
h($e, bi, "SQLiteTable"), /** @internal */
|
|
1109
|
+
h($e, "Symbol", Object.assign({}, M.Symbol, {
|
|
1110
|
+
InlineForeignKeys: pt
|
|
1111
1111
|
}));
|
|
1112
1112
|
function Ar(n, i, e, t, r = n) {
|
|
1113
|
-
const o = new $e(n, t, r), l = typeof i == "function" ? i(
|
|
1114
|
-
Object.entries(l).map(([c,
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
const f =
|
|
1118
|
-
return o[
|
|
1113
|
+
const o = new $e(n, t, r), l = typeof i == "function" ? i(Er()) : i, _ = Object.fromEntries(
|
|
1114
|
+
Object.entries(l).map(([c, u]) => {
|
|
1115
|
+
const p = u;
|
|
1116
|
+
p.setName(c);
|
|
1117
|
+
const f = p.build(o);
|
|
1118
|
+
return o[pt].push(...p.buildForeignKeys(f, o)), [c, f];
|
|
1119
1119
|
})
|
|
1120
|
-
),
|
|
1121
|
-
return
|
|
1120
|
+
), d = Object.assign(o, _);
|
|
1121
|
+
return d[M.Symbol.Columns] = _, d[M.Symbol.ExtraConfigColumns] = _, e && (d[$e.Symbol.ExtraConfigBuilder] = e), d;
|
|
1122
1122
|
}
|
|
1123
1123
|
const O = (n, i, e) => Ar(n, i, e);
|
|
1124
|
-
var
|
|
1125
|
-
|
|
1124
|
+
var Di;
|
|
1125
|
+
Di = v;
|
|
1126
1126
|
class Ot {
|
|
1127
1127
|
constructor(i, e) {
|
|
1128
1128
|
this.name = i, this.unique = e;
|
|
1129
1129
|
}
|
|
1130
1130
|
on(...i) {
|
|
1131
|
-
return new
|
|
1131
|
+
return new _r(this.name, i, this.unique);
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
|
|
1135
|
-
var
|
|
1136
|
-
|
|
1137
|
-
class
|
|
1134
|
+
h(Ot, Di, "SQLiteIndexBuilderOn");
|
|
1135
|
+
var Oi;
|
|
1136
|
+
Oi = v;
|
|
1137
|
+
class _r {
|
|
1138
1138
|
constructor(i, e, t) {
|
|
1139
1139
|
/** @internal */
|
|
1140
|
-
|
|
1140
|
+
h(this, "config");
|
|
1141
1141
|
this.config = {
|
|
1142
1142
|
name: i,
|
|
1143
1143
|
columns: e,
|
|
@@ -1153,19 +1153,19 @@ class ur {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
/** @internal */
|
|
1155
1155
|
build(i) {
|
|
1156
|
-
return new
|
|
1156
|
+
return new ur(this.config, i);
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
|
-
|
|
1160
|
-
var
|
|
1161
|
-
|
|
1162
|
-
class
|
|
1159
|
+
h(_r, Oi, "SQLiteIndexBuilder");
|
|
1160
|
+
var ki;
|
|
1161
|
+
ki = v;
|
|
1162
|
+
class ur {
|
|
1163
1163
|
constructor(i, e) {
|
|
1164
|
-
|
|
1164
|
+
h(this, "config");
|
|
1165
1165
|
this.config = { ...i, table: e };
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
h(ur, ki, "SQLiteIndex");
|
|
1169
1169
|
function S(n) {
|
|
1170
1170
|
return new Ot(n, !1);
|
|
1171
1171
|
}
|
|
@@ -1175,35 +1175,35 @@ function Te(n) {
|
|
|
1175
1175
|
function oe(...n) {
|
|
1176
1176
|
return n[0].columns ? new mt(n[0].columns, n[0].name) : new mt(n);
|
|
1177
1177
|
}
|
|
1178
|
-
var
|
|
1179
|
-
|
|
1178
|
+
var Ii;
|
|
1179
|
+
Ii = v;
|
|
1180
1180
|
class mt {
|
|
1181
1181
|
constructor(i, e) {
|
|
1182
1182
|
/** @internal */
|
|
1183
|
-
|
|
1183
|
+
h(this, "columns");
|
|
1184
1184
|
/** @internal */
|
|
1185
|
-
|
|
1185
|
+
h(this, "name");
|
|
1186
1186
|
this.columns = i, this.name = e;
|
|
1187
1187
|
}
|
|
1188
1188
|
/** @internal */
|
|
1189
1189
|
build(i) {
|
|
1190
|
-
return new
|
|
1190
|
+
return new dr(i, this.columns, this.name);
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
|
-
|
|
1194
|
-
var
|
|
1195
|
-
|
|
1196
|
-
class
|
|
1193
|
+
h(mt, Ii, "SQLitePrimaryKeyBuilder");
|
|
1194
|
+
var zi;
|
|
1195
|
+
zi = v;
|
|
1196
|
+
class dr {
|
|
1197
1197
|
constructor(i, e, t) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1198
|
+
h(this, "columns");
|
|
1199
|
+
h(this, "name");
|
|
1200
1200
|
this.table = i, this.columns = e, this.name = t;
|
|
1201
1201
|
}
|
|
1202
1202
|
getName() {
|
|
1203
1203
|
return this.name ?? `${this.table[$e.Symbol.Name]}_${this.columns.map((i) => i.name).join("_")}_pk`;
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
1206
|
-
|
|
1206
|
+
h(dr, zi, "SQLitePrimaryKey");
|
|
1207
1207
|
const D = O("tenants", {
|
|
1208
1208
|
id: s("id", { length: 191 }).primaryKey(),
|
|
1209
1209
|
name: s("name", { length: 255 }),
|
|
@@ -1332,7 +1332,7 @@ const D = O("tenants", {
|
|
|
1332
1332
|
n.provider
|
|
1333
1333
|
)
|
|
1334
1334
|
]
|
|
1335
|
-
),
|
|
1335
|
+
), C = O("passwords", {
|
|
1336
1336
|
id: s("id", { length: 21 }).primaryKey(),
|
|
1337
1337
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
1338
1338
|
user_id: s("user_id", { length: 255 }).notNull(),
|
|
@@ -1341,7 +1341,7 @@ const D = O("tenants", {
|
|
|
1341
1341
|
password: s("password", { length: 255 }).notNull(),
|
|
1342
1342
|
algorithm: s("algorithm", { length: 16 }).notNull().default("bcrypt"),
|
|
1343
1343
|
is_current: m("is_current").notNull().default(1)
|
|
1344
|
-
}),
|
|
1344
|
+
}), Q = O(
|
|
1345
1345
|
"sessions",
|
|
1346
1346
|
{
|
|
1347
1347
|
id: s("id", { length: 21 }).notNull(),
|
|
@@ -1365,7 +1365,7 @@ const D = O("tenants", {
|
|
|
1365
1365
|
S("idx_sessions_user_id").on(n.tenant_id, n.user_id),
|
|
1366
1366
|
S("idx_sessions_expires_at_ts").on(n.expires_at_ts)
|
|
1367
1367
|
]
|
|
1368
|
-
),
|
|
1368
|
+
), E = O(
|
|
1369
1369
|
"refresh_tokens",
|
|
1370
1370
|
{
|
|
1371
1371
|
id: s("id", { length: 21 }).notNull(),
|
|
@@ -1391,7 +1391,7 @@ const D = O("tenants", {
|
|
|
1391
1391
|
S("idx_refresh_tokens_login_id").on(n.login_id),
|
|
1392
1392
|
S("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
|
|
1393
1393
|
]
|
|
1394
|
-
),
|
|
1394
|
+
), q = O(
|
|
1395
1395
|
"login_sessions",
|
|
1396
1396
|
{
|
|
1397
1397
|
id: s("id", { length: 21 }).notNull(),
|
|
@@ -1460,7 +1460,7 @@ const D = O("tenants", {
|
|
|
1460
1460
|
}),
|
|
1461
1461
|
S("codes_expires_at_index").on(n.expires_at)
|
|
1462
1462
|
]
|
|
1463
|
-
),
|
|
1463
|
+
), Cr = O("authentication_codes", {
|
|
1464
1464
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
1465
1465
|
code: s("code", { length: 255 }).primaryKey(),
|
|
1466
1466
|
client_id: s("client_id", { length: 255 }).notNull(),
|
|
@@ -1474,7 +1474,7 @@ const D = O("tenants", {
|
|
|
1474
1474
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1475
1475
|
expires_at: s("expires_at", { length: 35 }).notNull(),
|
|
1476
1476
|
used_at: s("used_at", { length: 35 })
|
|
1477
|
-
}),
|
|
1477
|
+
}), Br = O(
|
|
1478
1478
|
"otps",
|
|
1479
1479
|
{
|
|
1480
1480
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1500,7 +1500,7 @@ const D = O("tenants", {
|
|
|
1500
1500
|
S("otps_email_index").on(n.email),
|
|
1501
1501
|
S("otps_expires_at_index").on(n.expires_at)
|
|
1502
1502
|
]
|
|
1503
|
-
),
|
|
1503
|
+
), $r = O("tickets", {
|
|
1504
1504
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
1505
1505
|
id: s("id", { length: 255 }).primaryKey(),
|
|
1506
1506
|
client_id: s("client_id", { length: 255 }).notNull(),
|
|
@@ -1652,7 +1652,7 @@ const D = O("tenants", {
|
|
|
1652
1652
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1653
1653
|
},
|
|
1654
1654
|
(n) => [Te("custom_domains_domain_unique").on(n.domain)]
|
|
1655
|
-
),
|
|
1655
|
+
), Qr = O("domains", {
|
|
1656
1656
|
id: s("id", { length: 255 }).primaryKey(),
|
|
1657
1657
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
1658
1658
|
domain: s("domain", { length: 255 }).notNull(),
|
|
@@ -1662,7 +1662,7 @@ const D = O("tenants", {
|
|
|
1662
1662
|
dkim_public_key: s("dkim_public_key", { length: 2048 }),
|
|
1663
1663
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1664
1664
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1665
|
-
}),
|
|
1665
|
+
}), L = O(
|
|
1666
1666
|
"organizations",
|
|
1667
1667
|
{
|
|
1668
1668
|
id: s("id", { length: 21 }).primaryKey(),
|
|
@@ -1820,7 +1820,7 @@ const D = O("tenants", {
|
|
|
1820
1820
|
S("user_roles_role_fk").on(n.tenant_id, n.role_id),
|
|
1821
1821
|
S("user_roles_organization_fk").on(n.organization_id)
|
|
1822
1822
|
]
|
|
1823
|
-
),
|
|
1823
|
+
), A = O(
|
|
1824
1824
|
"resource_servers",
|
|
1825
1825
|
{
|
|
1826
1826
|
id: s("id", { length: 21 }).notNull(),
|
|
@@ -2067,7 +2067,7 @@ const D = O("tenants", {
|
|
|
2067
2067
|
// only required for code type hooks
|
|
2068
2068
|
},
|
|
2069
2069
|
(n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
|
|
2070
|
-
),
|
|
2070
|
+
), he = O(
|
|
2071
2071
|
"hook_code",
|
|
2072
2072
|
{
|
|
2073
2073
|
id: s("id", { length: 21 }).primaryKey(),
|
|
@@ -2078,7 +2078,7 @@ const D = O("tenants", {
|
|
|
2078
2078
|
updated_at_ts: m("updated_at_ts").notNull()
|
|
2079
2079
|
},
|
|
2080
2080
|
(n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
|
|
2081
|
-
),
|
|
2081
|
+
), pe = O("keys", {
|
|
2082
2082
|
kid: s("kid", { length: 255 }).primaryKey(),
|
|
2083
2083
|
tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
|
|
2084
2084
|
onDelete: "cascade"
|
|
@@ -2135,7 +2135,7 @@ const D = O("tenants", {
|
|
|
2135
2135
|
),
|
|
2136
2136
|
S("authentication_methods_credential_id_idx").on(n.credential_id)
|
|
2137
2137
|
]
|
|
2138
|
-
),
|
|
2138
|
+
), T = O(
|
|
2139
2139
|
"logs",
|
|
2140
2140
|
{
|
|
2141
2141
|
log_id: s("log_id", { length: 21 }).primaryKey(),
|
|
@@ -2179,7 +2179,7 @@ const D = O("tenants", {
|
|
|
2179
2179
|
n.user_id
|
|
2180
2180
|
)
|
|
2181
2181
|
]
|
|
2182
|
-
),
|
|
2182
|
+
), x = O(
|
|
2183
2183
|
"outbox_events",
|
|
2184
2184
|
{
|
|
2185
2185
|
id: s("id", { length: 26 }).primaryKey(),
|
|
@@ -2214,7 +2214,7 @@ const D = O("tenants", {
|
|
|
2214
2214
|
]
|
|
2215
2215
|
), Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2216
2216
|
__proto__: null,
|
|
2217
|
-
authenticationCodes:
|
|
2217
|
+
authenticationCodes: Cr,
|
|
2218
2218
|
authenticationMethods: K,
|
|
2219
2219
|
branding: Le,
|
|
2220
2220
|
clientGrants: Y,
|
|
@@ -2223,67 +2223,67 @@ const D = O("tenants", {
|
|
|
2223
2223
|
connections: j,
|
|
2224
2224
|
customDomains: se,
|
|
2225
2225
|
customText: te,
|
|
2226
|
-
domains:
|
|
2226
|
+
domains: Qr,
|
|
2227
2227
|
emailProviders: Se,
|
|
2228
2228
|
flows: re,
|
|
2229
2229
|
forms: ie,
|
|
2230
|
-
hookCode:
|
|
2230
|
+
hookCode: he,
|
|
2231
2231
|
hooks: ee,
|
|
2232
2232
|
invites: ne,
|
|
2233
|
-
keys:
|
|
2234
|
-
loginSessions:
|
|
2235
|
-
logs:
|
|
2236
|
-
organizations:
|
|
2237
|
-
otps:
|
|
2238
|
-
outboxEvents:
|
|
2239
|
-
passwords:
|
|
2233
|
+
keys: pe,
|
|
2234
|
+
loginSessions: q,
|
|
2235
|
+
logs: T,
|
|
2236
|
+
organizations: L,
|
|
2237
|
+
otps: Br,
|
|
2238
|
+
outboxEvents: x,
|
|
2239
|
+
passwords: C,
|
|
2240
2240
|
promptSettings: Ee,
|
|
2241
|
-
refreshTokens:
|
|
2242
|
-
resourceServers:
|
|
2241
|
+
refreshTokens: E,
|
|
2242
|
+
resourceServers: A,
|
|
2243
2243
|
rolePermissions: le,
|
|
2244
2244
|
roles: U,
|
|
2245
|
-
sessions:
|
|
2245
|
+
sessions: Q,
|
|
2246
2246
|
tenants: D,
|
|
2247
2247
|
themes: fe,
|
|
2248
|
-
tickets:
|
|
2248
|
+
tickets: $r,
|
|
2249
2249
|
universalLoginTemplates: ve,
|
|
2250
2250
|
userOrganizations: P,
|
|
2251
2251
|
userPermissions: _e,
|
|
2252
2252
|
userRoles: ue,
|
|
2253
2253
|
users: k
|
|
2254
2254
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2255
|
-
function
|
|
2255
|
+
function z(n) {
|
|
2256
2256
|
if (n == null || typeof n != "object")
|
|
2257
2257
|
return n;
|
|
2258
2258
|
if (Array.isArray(n))
|
|
2259
2259
|
return n.map(
|
|
2260
|
-
(e) => e !== null && typeof e == "object" ?
|
|
2260
|
+
(e) => e !== null && typeof e == "object" ? z(e) : e
|
|
2261
2261
|
);
|
|
2262
2262
|
const i = { ...n };
|
|
2263
2263
|
for (const e in i) {
|
|
2264
2264
|
const t = i[e];
|
|
2265
2265
|
t === null ? delete i[e] : t !== null && typeof t == "object" && (Array.isArray(t) ? i[e] = t.map(
|
|
2266
|
-
(r) => r !== null && typeof r == "object" ?
|
|
2267
|
-
) : i[e] =
|
|
2266
|
+
(r) => r !== null && typeof r == "object" ? z(r) : r
|
|
2267
|
+
) : i[e] = z(t));
|
|
2268
2268
|
}
|
|
2269
2269
|
return i;
|
|
2270
2270
|
}
|
|
2271
|
-
function
|
|
2271
|
+
function Jr(n, i, e = { ...n }) {
|
|
2272
2272
|
for (const t of i)
|
|
2273
2273
|
n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
|
|
2274
2274
|
return e;
|
|
2275
2275
|
}
|
|
2276
|
-
function
|
|
2276
|
+
function Pr(n, i, e = n) {
|
|
2277
2277
|
for (const t of i)
|
|
2278
2278
|
n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
|
|
2279
2279
|
}
|
|
2280
|
-
function
|
|
2280
|
+
function cr(n) {
|
|
2281
2281
|
const i = {};
|
|
2282
2282
|
for (const e in n)
|
|
2283
2283
|
n[e] !== void 0 && n[e] !== null && (i[e] = n[e]);
|
|
2284
2284
|
return i;
|
|
2285
2285
|
}
|
|
2286
|
-
function
|
|
2286
|
+
function b(n, i) {
|
|
2287
2287
|
if (n == null)
|
|
2288
2288
|
return i;
|
|
2289
2289
|
if (typeof n == "string")
|
|
@@ -2302,7 +2302,7 @@ function yt(n, i = "", e = {}) {
|
|
|
2302
2302
|
}
|
|
2303
2303
|
return e;
|
|
2304
2304
|
}
|
|
2305
|
-
function
|
|
2305
|
+
function gr(n, i) {
|
|
2306
2306
|
const e = {};
|
|
2307
2307
|
for (const [t, r] of Object.entries(n)) {
|
|
2308
2308
|
const o = i.find(
|
|
@@ -2320,10 +2320,10 @@ function fr(n, i) {
|
|
|
2320
2320
|
}
|
|
2321
2321
|
return e;
|
|
2322
2322
|
}
|
|
2323
|
-
function
|
|
2323
|
+
function Fr(n) {
|
|
2324
2324
|
return typeof n == "string" ? parseInt(n, 10) : typeof n == "bigint" ? Number(n) : n;
|
|
2325
2325
|
}
|
|
2326
|
-
function
|
|
2326
|
+
function Ur(n) {
|
|
2327
2327
|
return {
|
|
2328
2328
|
async get(i) {
|
|
2329
2329
|
const e = await n.select().from(Le).where(a(Le.tenant_id, i)).get();
|
|
@@ -2334,34 +2334,34 @@ function Kr(n) {
|
|
|
2334
2334
|
colors_page_background_type: o,
|
|
2335
2335
|
colors_page_background_start: l,
|
|
2336
2336
|
colors_page_background_end: _,
|
|
2337
|
-
colors_page_background_angle_dev:
|
|
2337
|
+
colors_page_background_angle_dev: d,
|
|
2338
2338
|
font_url: c,
|
|
2339
|
-
...
|
|
2339
|
+
...u
|
|
2340
2340
|
} = e;
|
|
2341
|
-
return
|
|
2342
|
-
...
|
|
2341
|
+
return z({
|
|
2342
|
+
...u,
|
|
2343
2343
|
colors: {
|
|
2344
2344
|
primary: r,
|
|
2345
2345
|
page_background: {
|
|
2346
2346
|
type: o,
|
|
2347
2347
|
start: l,
|
|
2348
2348
|
end: _,
|
|
2349
|
-
angle_deg:
|
|
2349
|
+
angle_deg: d
|
|
2350
2350
|
}
|
|
2351
2351
|
},
|
|
2352
2352
|
font: c ? { url: c } : void 0
|
|
2353
2353
|
});
|
|
2354
2354
|
},
|
|
2355
2355
|
async set(i, e) {
|
|
2356
|
-
var _,
|
|
2356
|
+
var _, d, c, u, p, f, y, w;
|
|
2357
2357
|
const { colors: t, font: r, ...o } = e, l = {
|
|
2358
2358
|
...o,
|
|
2359
2359
|
tenant_id: i,
|
|
2360
2360
|
colors_primary: t == null ? void 0 : t.primary,
|
|
2361
2361
|
colors_page_background_type: (_ = t == null ? void 0 : t.page_background) == null ? void 0 : _.type,
|
|
2362
|
-
colors_page_background_start: (
|
|
2362
|
+
colors_page_background_start: (d = t == null ? void 0 : t.page_background) == null ? void 0 : d.start,
|
|
2363
2363
|
colors_page_background_end: (c = t == null ? void 0 : t.page_background) == null ? void 0 : c.end,
|
|
2364
|
-
colors_page_background_angle_dev: (
|
|
2364
|
+
colors_page_background_angle_dev: (u = t == null ? void 0 : t.page_background) == null ? void 0 : u.angle_deg,
|
|
2365
2365
|
font_url: r == null ? void 0 : r.url
|
|
2366
2366
|
};
|
|
2367
2367
|
await n.insert(Le).values(l).onConflictDoUpdate({
|
|
@@ -2369,17 +2369,17 @@ function Kr(n) {
|
|
|
2369
2369
|
set: {
|
|
2370
2370
|
...o,
|
|
2371
2371
|
colors_primary: t == null ? void 0 : t.primary,
|
|
2372
|
-
colors_page_background_type: (
|
|
2372
|
+
colors_page_background_type: (p = t == null ? void 0 : t.page_background) == null ? void 0 : p.type,
|
|
2373
2373
|
colors_page_background_start: (f = t == null ? void 0 : t.page_background) == null ? void 0 : f.start,
|
|
2374
2374
|
colors_page_background_end: (y = t == null ? void 0 : t.page_background) == null ? void 0 : y.end,
|
|
2375
|
-
colors_page_background_angle_dev: (
|
|
2375
|
+
colors_page_background_angle_dev: (w = t == null ? void 0 : t.page_background) == null ? void 0 : w.angle_deg,
|
|
2376
2376
|
font_url: r == null ? void 0 : r.url
|
|
2377
2377
|
}
|
|
2378
2378
|
});
|
|
2379
2379
|
}
|
|
2380
2380
|
};
|
|
2381
2381
|
}
|
|
2382
|
-
var
|
|
2382
|
+
var xe = class extends Error {
|
|
2383
2383
|
/**
|
|
2384
2384
|
* Creates an instance of `HTTPException`.
|
|
2385
2385
|
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
@@ -2387,8 +2387,8 @@ var be = class extends Error {
|
|
|
2387
2387
|
*/
|
|
2388
2388
|
constructor(i = 500, e) {
|
|
2389
2389
|
super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
|
|
2390
|
-
|
|
2391
|
-
|
|
2390
|
+
h(this, "res");
|
|
2391
|
+
h(this, "status");
|
|
2392
2392
|
this.res = e == null ? void 0 : e.res, this.status = i;
|
|
2393
2393
|
}
|
|
2394
2394
|
/**
|
|
@@ -2408,13 +2408,13 @@ var be = class extends Error {
|
|
|
2408
2408
|
function ye(n, i, e) {
|
|
2409
2409
|
const t = i.split(/ OR /i);
|
|
2410
2410
|
if (t.length > 1) {
|
|
2411
|
-
const c = t.map((
|
|
2412
|
-
const
|
|
2413
|
-
if (
|
|
2414
|
-
const [, f, y] =
|
|
2411
|
+
const c = t.map((u) => {
|
|
2412
|
+
const p = u.trim().match(/^([^:]+):(.+)$/);
|
|
2413
|
+
if (p) {
|
|
2414
|
+
const [, f, y] = p;
|
|
2415
2415
|
if (!f || !y) return null;
|
|
2416
|
-
const
|
|
2417
|
-
return B ? a(B,
|
|
2416
|
+
const w = y.replace(/^"(.*)"$/, "$1"), B = n[f.trim()];
|
|
2417
|
+
return B ? a(B, w.trim()) : null;
|
|
2418
2418
|
}
|
|
2419
2419
|
return null;
|
|
2420
2420
|
}).filter(Boolean);
|
|
@@ -2423,79 +2423,79 @@ function ye(n, i, e) {
|
|
|
2423
2423
|
const r = [];
|
|
2424
2424
|
let o = "", l = !1;
|
|
2425
2425
|
for (let c = 0; c < i.length; c++) {
|
|
2426
|
-
const
|
|
2427
|
-
|
|
2426
|
+
const u = i[c];
|
|
2427
|
+
u === '"' ? (l = !l, o += u) : u === " " && !l ? o.trim() && (r.push(o.trim()), o = "") : o += u;
|
|
2428
2428
|
}
|
|
2429
2429
|
o.trim() && r.push(o.trim());
|
|
2430
2430
|
const _ = r.map((c) => c.replace(/^([^:]+)=/g, "$1:")).map((c) => {
|
|
2431
|
-
let
|
|
2431
|
+
let u = c.startsWith("-"), p = null, f = "", y = !1, w;
|
|
2432
2432
|
if (c.startsWith("-_exists_:"))
|
|
2433
|
-
|
|
2433
|
+
p = c.substring(10), y = !0, u = !0;
|
|
2434
2434
|
else if (c.startsWith("_exists_:"))
|
|
2435
|
-
|
|
2435
|
+
p = c.substring(9), y = !0, u = !1;
|
|
2436
2436
|
else if (c.includes(":")) {
|
|
2437
|
-
const B =
|
|
2438
|
-
|
|
2437
|
+
const B = u ? c.substring(1) : c, W = B.indexOf(":");
|
|
2438
|
+
p = B.substring(0, W), f = B.substring(W + 1), y = !1, f.startsWith(">=") ? (w = ">=", f = f.substring(2)) : f.startsWith(">") ? (w = ">", f = f.substring(1)) : f.startsWith("<=") ? (w = "<=", f = f.substring(2)) : f.startsWith("<") ? (w = "<", f = f.substring(1)) : w = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
|
|
2439
2439
|
} else
|
|
2440
|
-
|
|
2441
|
-
return { key:
|
|
2442
|
-
}),
|
|
2443
|
-
for (const { key: c, value:
|
|
2440
|
+
p = null, f = c, y = !1;
|
|
2441
|
+
return { key: p, value: f, isNegation: u, isExistsQuery: y, operator: w };
|
|
2442
|
+
}), d = [];
|
|
2443
|
+
for (const { key: c, value: u, isNegation: p, isExistsQuery: f, operator: y } of _)
|
|
2444
2444
|
if (c) {
|
|
2445
|
-
const
|
|
2446
|
-
if (!
|
|
2447
|
-
f ?
|
|
2448
|
-
|
|
2449
|
-
) :
|
|
2450
|
-
|
|
2445
|
+
const w = n[c];
|
|
2446
|
+
if (!w) {
|
|
2447
|
+
f ? d.push(
|
|
2448
|
+
p ? N`${N.identifier(c)} IS NULL` : N`${N.identifier(c)} IS NOT NULL`
|
|
2449
|
+
) : d.push(
|
|
2450
|
+
N`${N.identifier(c)} ${N.raw(p ? "!=" : y ?? "=")} ${u}`
|
|
2451
2451
|
);
|
|
2452
2452
|
continue;
|
|
2453
2453
|
}
|
|
2454
2454
|
if (f)
|
|
2455
|
-
|
|
2456
|
-
else if (
|
|
2455
|
+
d.push(p ? me(w) : Me(w));
|
|
2456
|
+
else if (p)
|
|
2457
2457
|
switch (y) {
|
|
2458
2458
|
case ">":
|
|
2459
|
-
|
|
2459
|
+
d.push(Oe(w, u));
|
|
2460
2460
|
break;
|
|
2461
2461
|
case ">=":
|
|
2462
|
-
|
|
2462
|
+
d.push(we(w, u));
|
|
2463
2463
|
break;
|
|
2464
2464
|
case "<":
|
|
2465
|
-
|
|
2465
|
+
d.push(He(w, u));
|
|
2466
2466
|
break;
|
|
2467
2467
|
case "<=":
|
|
2468
|
-
|
|
2468
|
+
d.push(We(w, u));
|
|
2469
2469
|
break;
|
|
2470
2470
|
default:
|
|
2471
|
-
|
|
2471
|
+
d.push(Or(w, u));
|
|
2472
2472
|
}
|
|
2473
2473
|
else
|
|
2474
2474
|
switch (y) {
|
|
2475
2475
|
case ">":
|
|
2476
|
-
|
|
2476
|
+
d.push(We(w, u));
|
|
2477
2477
|
break;
|
|
2478
2478
|
case ">=":
|
|
2479
|
-
|
|
2479
|
+
d.push(He(w, u));
|
|
2480
2480
|
break;
|
|
2481
2481
|
case "<":
|
|
2482
|
-
|
|
2482
|
+
d.push(we(w, u));
|
|
2483
2483
|
break;
|
|
2484
2484
|
case "<=":
|
|
2485
|
-
|
|
2485
|
+
d.push(Oe(w, u));
|
|
2486
2486
|
break;
|
|
2487
2487
|
default:
|
|
2488
|
-
|
|
2488
|
+
d.push(a(w, u));
|
|
2489
2489
|
}
|
|
2490
|
-
} else if (
|
|
2491
|
-
const B = (
|
|
2490
|
+
} else if (u) {
|
|
2491
|
+
const B = (u.includes("|") ? [...e, "user_id"] : e).map((W) => {
|
|
2492
2492
|
const H = n[W];
|
|
2493
|
-
return H ? W === "user_id" ? a(H,
|
|
2493
|
+
return H ? W === "user_id" ? a(H, u) : Ie(H, `%${u}%`) : null;
|
|
2494
2494
|
}).filter(Boolean);
|
|
2495
|
-
B.length > 0 &&
|
|
2495
|
+
B.length > 0 && d.push(de(...B));
|
|
2496
2496
|
}
|
|
2497
|
-
if (
|
|
2498
|
-
return
|
|
2497
|
+
if (d.length !== 0)
|
|
2498
|
+
return d.length === 1 ? d[0] : g(...d);
|
|
2499
2499
|
}
|
|
2500
2500
|
const kt = [
|
|
2501
2501
|
"global",
|
|
@@ -2537,14 +2537,14 @@ function Fe(n) {
|
|
|
2537
2537
|
for (const o of kt)
|
|
2538
2538
|
r[o] = !!t[o];
|
|
2539
2539
|
for (const o of It)
|
|
2540
|
-
r[o] =
|
|
2540
|
+
r[o] = b(t[o], []);
|
|
2541
2541
|
for (const o of zt)
|
|
2542
|
-
r[o] =
|
|
2543
|
-
return r.connections =
|
|
2542
|
+
r[o] = b(t[o], {});
|
|
2543
|
+
return r.connections = b(e, []), z(r);
|
|
2544
2544
|
}
|
|
2545
|
-
function
|
|
2545
|
+
function At(n) {
|
|
2546
2546
|
const i = { ...n };
|
|
2547
|
-
|
|
2547
|
+
Pr(
|
|
2548
2548
|
n,
|
|
2549
2549
|
kt,
|
|
2550
2550
|
i
|
|
@@ -2553,9 +2553,9 @@ function Ct(n) {
|
|
|
2553
2553
|
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || []));
|
|
2554
2554
|
for (const e of zt)
|
|
2555
2555
|
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || {}));
|
|
2556
|
-
return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])),
|
|
2556
|
+
return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])), cr(i);
|
|
2557
2557
|
}
|
|
2558
|
-
function
|
|
2558
|
+
function Kr(n) {
|
|
2559
2559
|
return {
|
|
2560
2560
|
async create(i, e) {
|
|
2561
2561
|
var l, _;
|
|
@@ -2580,21 +2580,21 @@ function jr(n) {
|
|
|
2580
2580
|
created_at: t,
|
|
2581
2581
|
updated_at: t
|
|
2582
2582
|
};
|
|
2583
|
-
for (const
|
|
2584
|
-
r[
|
|
2583
|
+
for (const d of kt)
|
|
2584
|
+
r[d] = e[d] ?? !1;
|
|
2585
2585
|
r.oidc_conformant = e.oidc_conformant ?? !0, r.auth0_conformant = e.auth0_conformant ?? !0, r.sso_disabled = e.sso_disabled ?? !1;
|
|
2586
|
-
for (const
|
|
2587
|
-
r[
|
|
2588
|
-
for (const
|
|
2589
|
-
r[
|
|
2586
|
+
for (const d of It)
|
|
2587
|
+
r[d] = e[d] || [];
|
|
2588
|
+
for (const d of zt)
|
|
2589
|
+
r[d] = e[d] || {};
|
|
2590
2590
|
r.connections = e.connections || [];
|
|
2591
|
-
const o =
|
|
2591
|
+
const o = At(r);
|
|
2592
2592
|
try {
|
|
2593
2593
|
await n.insert(I).values({ ...o, tenant_id: i });
|
|
2594
|
-
} catch (
|
|
2595
|
-
throw (l =
|
|
2594
|
+
} catch (d) {
|
|
2595
|
+
throw (l = d == null ? void 0 : d.message) != null && l.includes("UNIQUE constraint failed") || (_ = d == null ? void 0 : d.message) != null && _.includes("duplicate key") ? new xe(409, {
|
|
2596
2596
|
message: "Client already exists"
|
|
2597
|
-
}) :
|
|
2597
|
+
}) : d;
|
|
2598
2598
|
}
|
|
2599
2599
|
return Fe({ ...o, tenant_id: i });
|
|
2600
2600
|
},
|
|
@@ -2615,7 +2615,7 @@ function jr(n) {
|
|
|
2615
2615
|
} : null;
|
|
2616
2616
|
},
|
|
2617
2617
|
async update(i, e, t) {
|
|
2618
|
-
const r =
|
|
2618
|
+
const r = At({
|
|
2619
2619
|
...t,
|
|
2620
2620
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2621
2621
|
});
|
|
@@ -2634,26 +2634,26 @@ function jr(n) {
|
|
|
2634
2634
|
sort: l,
|
|
2635
2635
|
q: _
|
|
2636
2636
|
} = e || {};
|
|
2637
|
-
let
|
|
2637
|
+
let d = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
|
|
2638
2638
|
if (_) {
|
|
2639
2639
|
const f = ye(I, _, ["name", "client_id"]);
|
|
2640
|
-
f && (
|
|
2640
|
+
f && (d = d.where(g(a(I.tenant_id, i), f)));
|
|
2641
2641
|
}
|
|
2642
2642
|
if (l != null && l.sort_by) {
|
|
2643
2643
|
const f = I[l.sort_by];
|
|
2644
|
-
f && (
|
|
2644
|
+
f && (d = d.orderBy(
|
|
2645
2645
|
l.sort_order === "desc" ? V(f) : G(f)
|
|
2646
2646
|
));
|
|
2647
2647
|
}
|
|
2648
|
-
const
|
|
2648
|
+
const u = (await d.offset(t * r).limit(r)).map(Fe);
|
|
2649
2649
|
if (!o)
|
|
2650
|
-
return { clients:
|
|
2651
|
-
const [
|
|
2650
|
+
return { clients: u };
|
|
2651
|
+
const [p] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
|
|
2652
2652
|
return {
|
|
2653
|
-
clients:
|
|
2653
|
+
clients: u,
|
|
2654
2654
|
start: t * r,
|
|
2655
2655
|
limit: r,
|
|
2656
|
-
length: Number((
|
|
2656
|
+
length: Number((p == null ? void 0 : p.count) ?? 0)
|
|
2657
2657
|
};
|
|
2658
2658
|
},
|
|
2659
2659
|
async remove(i, e) {
|
|
@@ -2666,16 +2666,16 @@ function jr(n) {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
};
|
|
2668
2668
|
}
|
|
2669
|
-
function
|
|
2669
|
+
function jr(n) {
|
|
2670
2670
|
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2671
|
-
return
|
|
2671
|
+
return z({
|
|
2672
2672
|
...o,
|
|
2673
|
-
options:
|
|
2674
|
-
metadata:
|
|
2673
|
+
options: b(t, {}),
|
|
2674
|
+
metadata: b(r),
|
|
2675
2675
|
is_system: e ? !0 : void 0
|
|
2676
2676
|
});
|
|
2677
2677
|
}
|
|
2678
|
-
function
|
|
2678
|
+
function Mr(n) {
|
|
2679
2679
|
return {
|
|
2680
2680
|
async listByClient(i, e) {
|
|
2681
2681
|
const t = await n.select({ connections: I.connections }).from(I).where(
|
|
@@ -2685,15 +2685,15 @@ function Vr(n) {
|
|
|
2685
2685
|
)
|
|
2686
2686
|
).get();
|
|
2687
2687
|
if (!t) return [];
|
|
2688
|
-
const r =
|
|
2688
|
+
const r = b(t.connections, []) || [];
|
|
2689
2689
|
if (r.length === 0) return [];
|
|
2690
2690
|
const l = (await n.select().from(j).where(
|
|
2691
2691
|
g(
|
|
2692
2692
|
a(j.tenant_id, i),
|
|
2693
2693
|
Ne(j.id, r)
|
|
2694
2694
|
)
|
|
2695
|
-
).all()).map(
|
|
2696
|
-
return r.map((_) => l.find((
|
|
2695
|
+
).all()).map(jr);
|
|
2696
|
+
return r.map((_) => l.find((d) => d.id === _)).filter(Boolean);
|
|
2697
2697
|
},
|
|
2698
2698
|
async updateByClient(i, e, t) {
|
|
2699
2699
|
return (await n.update(I).set({ connections: JSON.stringify([...new Set(t)]) }).where(
|
|
@@ -2707,7 +2707,7 @@ function Vr(n) {
|
|
|
2707
2707
|
return (await n.select({
|
|
2708
2708
|
client_id: I.client_id,
|
|
2709
2709
|
connections: I.connections
|
|
2710
|
-
}).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (
|
|
2710
|
+
}).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (b(r.connections, []) || []).includes(e)).map((r) => r.client_id);
|
|
2711
2711
|
},
|
|
2712
2712
|
async addClientToConnection(i, e, t) {
|
|
2713
2713
|
var _;
|
|
@@ -2718,7 +2718,7 @@ function Vr(n) {
|
|
|
2718
2718
|
)
|
|
2719
2719
|
).get()) return !1;
|
|
2720
2720
|
const o = await n.run(
|
|
2721
|
-
|
|
2721
|
+
N`UPDATE clients SET connections = CASE
|
|
2722
2722
|
WHEN connections IS NULL OR connections = '[]' OR connections = ''
|
|
2723
2723
|
THEN json_array(${e})
|
|
2724
2724
|
WHEN EXISTS (SELECT 1 FROM json_each(connections) WHERE value = ${e})
|
|
@@ -2732,7 +2732,7 @@ function Vr(n) {
|
|
|
2732
2732
|
async removeClientFromConnection(i, e, t) {
|
|
2733
2733
|
var l;
|
|
2734
2734
|
const r = await n.run(
|
|
2735
|
-
|
|
2735
|
+
N`UPDATE clients SET connections = (
|
|
2736
2736
|
SELECT COALESCE(json_group_array(je.value), '[]')
|
|
2737
2737
|
FROM json_each(COALESCE(connections, '[]')) AS je
|
|
2738
2738
|
WHERE je.value != ${e}
|
|
@@ -2743,7 +2743,7 @@ function Vr(n) {
|
|
|
2743
2743
|
}
|
|
2744
2744
|
};
|
|
2745
2745
|
}
|
|
2746
|
-
let
|
|
2746
|
+
let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (n) => crypto.getRandomValues(new Uint8Array(n)), Wr = (n, i, e) => {
|
|
2747
2747
|
let t = 256 - 256 % n.length;
|
|
2748
2748
|
if (t === 256) {
|
|
2749
2749
|
let o = n.length - 1;
|
|
@@ -2751,9 +2751,9 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
|
|
|
2751
2751
|
if (!l) return "";
|
|
2752
2752
|
let _ = "";
|
|
2753
2753
|
for (; ; ) {
|
|
2754
|
-
let
|
|
2754
|
+
let d = e(l), c = l;
|
|
2755
2755
|
for (; c--; )
|
|
2756
|
-
if (_ += n[
|
|
2756
|
+
if (_ += n[d[c] & o], _.length >= l) return _;
|
|
2757
2757
|
}
|
|
2758
2758
|
};
|
|
2759
2759
|
}
|
|
@@ -2762,16 +2762,16 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
|
|
|
2762
2762
|
if (!o) return "";
|
|
2763
2763
|
let l = "";
|
|
2764
2764
|
for (; ; ) {
|
|
2765
|
-
let _ = e(r),
|
|
2766
|
-
for (;
|
|
2767
|
-
if (_[
|
|
2765
|
+
let _ = e(r), d = r;
|
|
2766
|
+
for (; d--; )
|
|
2767
|
+
if (_[d] < t && (l += n[_[d] % n.length], l.length >= o))
|
|
2768
2768
|
return l;
|
|
2769
2769
|
}
|
|
2770
2770
|
};
|
|
2771
|
-
},
|
|
2771
|
+
}, Hr = (n, i = 21) => Wr(n, i | 0, Rr), ae = (n = 21) => {
|
|
2772
2772
|
let i = "", e = crypto.getRandomValues(new Uint8Array(n |= 0));
|
|
2773
2773
|
for (; n--; )
|
|
2774
|
-
i +=
|
|
2774
|
+
i += Vr[e[n] & 63];
|
|
2775
2775
|
return i;
|
|
2776
2776
|
};
|
|
2777
2777
|
function tt(n) {
|
|
@@ -2783,10 +2783,10 @@ function tt(n) {
|
|
|
2783
2783
|
is_system: o,
|
|
2784
2784
|
...l
|
|
2785
2785
|
} = n;
|
|
2786
|
-
return
|
|
2786
|
+
return z({
|
|
2787
2787
|
...l,
|
|
2788
|
-
scope:
|
|
2789
|
-
authorization_details_types:
|
|
2788
|
+
scope: b(e, []),
|
|
2789
|
+
authorization_details_types: b(
|
|
2790
2790
|
t,
|
|
2791
2791
|
[]
|
|
2792
2792
|
),
|
|
@@ -2794,7 +2794,7 @@ function tt(n) {
|
|
|
2794
2794
|
is_system: !!o
|
|
2795
2795
|
});
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function Gr(n) {
|
|
2798
2798
|
return {
|
|
2799
2799
|
async create(i, e) {
|
|
2800
2800
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -2827,9 +2827,9 @@ function Yr(n) {
|
|
|
2827
2827
|
authorization_details_types: o,
|
|
2828
2828
|
allow_any_organization: l,
|
|
2829
2829
|
is_system: _,
|
|
2830
|
-
...
|
|
2830
|
+
...d
|
|
2831
2831
|
} = t, c = {
|
|
2832
|
-
...
|
|
2832
|
+
...d,
|
|
2833
2833
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2834
2834
|
};
|
|
2835
2835
|
return r !== void 0 && (c.scope = JSON.stringify(r)), o !== void 0 && (c.authorization_details_types = JSON.stringify(
|
|
@@ -2845,16 +2845,16 @@ function Yr(n) {
|
|
|
2845
2845
|
include_totals: o = !1,
|
|
2846
2846
|
sort: l,
|
|
2847
2847
|
q: _
|
|
2848
|
-
} = e || {},
|
|
2849
|
-
let
|
|
2848
|
+
} = e || {}, d = _ ? ye(Y, _, ["client_id", "audience"]) : void 0, c = d ? g(a(Y.tenant_id, i), d) : a(Y.tenant_id, i);
|
|
2849
|
+
let u = n.select().from(Y).where(c).$dynamic();
|
|
2850
2850
|
if (l != null && l.sort_by) {
|
|
2851
|
-
const
|
|
2852
|
-
|
|
2853
|
-
l.sort_order === "desc" ? V(
|
|
2851
|
+
const w = Y[l.sort_by];
|
|
2852
|
+
w && (u = u.orderBy(
|
|
2853
|
+
l.sort_order === "desc" ? V(w) : G(w)
|
|
2854
2854
|
));
|
|
2855
2855
|
} else
|
|
2856
|
-
|
|
2857
|
-
const f = (await
|
|
2856
|
+
u = u.orderBy(G(Y.created_at));
|
|
2857
|
+
const f = (await u.offset(t * r).limit(r)).map(tt);
|
|
2858
2858
|
if (!o)
|
|
2859
2859
|
return { client_grants: f };
|
|
2860
2860
|
const [y] = await n.select({ count: R() }).from(Y).where(c);
|
|
@@ -2874,9 +2874,9 @@ function Yr(n) {
|
|
|
2874
2874
|
}
|
|
2875
2875
|
function nt(n) {
|
|
2876
2876
|
const { tenant_id: i, ...e } = n;
|
|
2877
|
-
return
|
|
2877
|
+
return z(e);
|
|
2878
2878
|
}
|
|
2879
|
-
function
|
|
2879
|
+
function Yr(n) {
|
|
2880
2880
|
return {
|
|
2881
2881
|
async create(i, e) {
|
|
2882
2882
|
const t = {
|
|
@@ -2908,20 +2908,20 @@ function Xr(n) {
|
|
|
2908
2908
|
} = e || {};
|
|
2909
2909
|
let _ = n.select().from(J).where(a(J.tenant_id, i)).$dynamic();
|
|
2910
2910
|
if (l != null && l.sort_by) {
|
|
2911
|
-
const
|
|
2912
|
-
|
|
2913
|
-
l.sort_order === "desc" ? V(
|
|
2911
|
+
const p = J[l.sort_by];
|
|
2912
|
+
p && (_ = _.orderBy(
|
|
2913
|
+
l.sort_order === "desc" ? V(p) : G(p)
|
|
2914
2914
|
));
|
|
2915
2915
|
}
|
|
2916
2916
|
const c = (await _.offset(t * r).limit(r)).map(nt);
|
|
2917
2917
|
if (!o)
|
|
2918
2918
|
return { codes: c };
|
|
2919
|
-
const [
|
|
2919
|
+
const [u] = await n.select({ count: R() }).from(J).where(a(J.tenant_id, i));
|
|
2920
2920
|
return {
|
|
2921
2921
|
codes: c,
|
|
2922
2922
|
start: t * r,
|
|
2923
2923
|
limit: r,
|
|
2924
|
-
length: Number((
|
|
2924
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
2925
2925
|
};
|
|
2926
2926
|
},
|
|
2927
2927
|
async used(i, e) {
|
|
@@ -2941,25 +2941,25 @@ function Xr(n) {
|
|
|
2941
2941
|
}
|
|
2942
2942
|
};
|
|
2943
2943
|
}
|
|
2944
|
-
function
|
|
2944
|
+
function Xr() {
|
|
2945
2945
|
const { customAlphabet: n } = require("nanoid");
|
|
2946
2946
|
return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2947
2947
|
}
|
|
2948
2948
|
function it(n) {
|
|
2949
2949
|
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2950
|
-
return
|
|
2950
|
+
return z({
|
|
2951
2951
|
...o,
|
|
2952
|
-
options:
|
|
2953
|
-
metadata:
|
|
2952
|
+
options: b(t, {}),
|
|
2953
|
+
metadata: b(r),
|
|
2954
2954
|
is_system: e ? !0 : void 0
|
|
2955
2955
|
});
|
|
2956
2956
|
}
|
|
2957
|
-
function
|
|
2957
|
+
function Zr(n) {
|
|
2958
2958
|
return {
|
|
2959
2959
|
async create(i, e) {
|
|
2960
2960
|
var o, l;
|
|
2961
2961
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
2962
|
-
id: e.id ||
|
|
2962
|
+
id: e.id || Xr(),
|
|
2963
2963
|
...e,
|
|
2964
2964
|
tenant_id: i,
|
|
2965
2965
|
options: JSON.stringify(e.options || {}),
|
|
@@ -2971,7 +2971,7 @@ function es(n) {
|
|
|
2971
2971
|
try {
|
|
2972
2972
|
await n.insert(j).values(r);
|
|
2973
2973
|
} catch (_) {
|
|
2974
|
-
throw (o = _ == null ? void 0 : _.message) != null && o.includes("UNIQUE constraint failed") || (l = _ == null ? void 0 : _.message) != null && l.includes("duplicate key") ? new
|
|
2974
|
+
throw (o = _ == null ? void 0 : _.message) != null && o.includes("UNIQUE constraint failed") || (l = _ == null ? void 0 : _.message) != null && l.includes("duplicate key") ? new xe(409, {
|
|
2975
2975
|
message: "Connection already exists"
|
|
2976
2976
|
}) : _;
|
|
2977
2977
|
}
|
|
@@ -3005,24 +3005,24 @@ function es(n) {
|
|
|
3005
3005
|
sort: l,
|
|
3006
3006
|
q: _
|
|
3007
3007
|
} = e || {};
|
|
3008
|
-
let
|
|
3008
|
+
let d = a(j.tenant_id, i);
|
|
3009
3009
|
if (_) {
|
|
3010
3010
|
const y = ye(j, _, ["name"]);
|
|
3011
|
-
y && (
|
|
3011
|
+
y && (d = g(d, y));
|
|
3012
3012
|
}
|
|
3013
|
-
let c = n.select().from(j).where(
|
|
3013
|
+
let c = n.select().from(j).where(d).$dynamic();
|
|
3014
3014
|
if (l != null && l.sort_by) {
|
|
3015
3015
|
const y = j[l.sort_by];
|
|
3016
3016
|
y && (c = c.orderBy(
|
|
3017
3017
|
l.sort_order === "desc" ? V(y) : G(y)
|
|
3018
3018
|
));
|
|
3019
3019
|
}
|
|
3020
|
-
const
|
|
3020
|
+
const p = (await c.offset(t * r).limit(r)).map(it);
|
|
3021
3021
|
if (!o)
|
|
3022
|
-
return { connections:
|
|
3023
|
-
const [f] = await n.select({ count: R() }).from(j).where(
|
|
3022
|
+
return { connections: p };
|
|
3023
|
+
const [f] = await n.select({ count: R() }).from(j).where(d);
|
|
3024
3024
|
return {
|
|
3025
|
-
connections:
|
|
3025
|
+
connections: p,
|
|
3026
3026
|
start: t * r,
|
|
3027
3027
|
limit: r,
|
|
3028
3028
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
@@ -3040,13 +3040,13 @@ function es(n) {
|
|
|
3040
3040
|
}
|
|
3041
3041
|
function Ue(n) {
|
|
3042
3042
|
const { tenant_id: i, domain_metadata: e, ...t } = n;
|
|
3043
|
-
return
|
|
3043
|
+
return z({
|
|
3044
3044
|
...t,
|
|
3045
3045
|
primary: !!t.primary,
|
|
3046
|
-
domain_metadata:
|
|
3046
|
+
domain_metadata: b(e)
|
|
3047
3047
|
});
|
|
3048
3048
|
}
|
|
3049
|
-
function
|
|
3049
|
+
function es(n) {
|
|
3050
3050
|
return {
|
|
3051
3051
|
async create(i, e) {
|
|
3052
3052
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -3106,7 +3106,7 @@ function ts(n) {
|
|
|
3106
3106
|
}
|
|
3107
3107
|
};
|
|
3108
3108
|
}
|
|
3109
|
-
function
|
|
3109
|
+
function ts(n) {
|
|
3110
3110
|
return {
|
|
3111
3111
|
async get(i, e, t) {
|
|
3112
3112
|
const r = await n.select().from(te).where(
|
|
@@ -3158,7 +3158,7 @@ function ns(n) {
|
|
|
3158
3158
|
}
|
|
3159
3159
|
};
|
|
3160
3160
|
}
|
|
3161
|
-
function
|
|
3161
|
+
function ns(n) {
|
|
3162
3162
|
return {
|
|
3163
3163
|
async create(i, e) {
|
|
3164
3164
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3177,11 +3177,11 @@ function is(n) {
|
|
|
3177
3177
|
const e = await n.select().from(Se).where(a(Se.tenant_id, i)).get();
|
|
3178
3178
|
if (!e) return null;
|
|
3179
3179
|
const { tenant_id: t, ...r } = e;
|
|
3180
|
-
return
|
|
3180
|
+
return z({
|
|
3181
3181
|
...r,
|
|
3182
3182
|
enabled: !!r.enabled,
|
|
3183
|
-
credentials:
|
|
3184
|
-
settings:
|
|
3183
|
+
credentials: b(r.credentials, {}),
|
|
3184
|
+
settings: b(r.settings, {})
|
|
3185
3185
|
});
|
|
3186
3186
|
},
|
|
3187
3187
|
async update(i, e) {
|
|
@@ -3195,7 +3195,7 @@ function is(n) {
|
|
|
3195
3195
|
}
|
|
3196
3196
|
};
|
|
3197
3197
|
}
|
|
3198
|
-
function
|
|
3198
|
+
function is(n) {
|
|
3199
3199
|
return {
|
|
3200
3200
|
async create(i, e) {
|
|
3201
3201
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = `af_${ae()}`;
|
|
@@ -3218,9 +3218,9 @@ function rs(n) {
|
|
|
3218
3218
|
const t = await n.select().from(re).where(g(a(re.tenant_id, i), a(re.id, e))).get();
|
|
3219
3219
|
if (!t) return null;
|
|
3220
3220
|
const { tenant_id: r, actions: o, ...l } = t;
|
|
3221
|
-
return
|
|
3221
|
+
return z({
|
|
3222
3222
|
...l,
|
|
3223
|
-
actions:
|
|
3223
|
+
actions: b(o, [])
|
|
3224
3224
|
});
|
|
3225
3225
|
},
|
|
3226
3226
|
async update(i, e, t) {
|
|
@@ -3238,26 +3238,26 @@ function rs(n) {
|
|
|
3238
3238
|
} = e || {};
|
|
3239
3239
|
let _ = n.select().from(re).where(a(re.tenant_id, i)).$dynamic();
|
|
3240
3240
|
if (l != null && l.sort_by) {
|
|
3241
|
-
const
|
|
3242
|
-
|
|
3243
|
-
l.sort_order === "desc" ? V(
|
|
3241
|
+
const p = re[l.sort_by];
|
|
3242
|
+
p && (_ = _.orderBy(
|
|
3243
|
+
l.sort_order === "desc" ? V(p) : G(p)
|
|
3244
3244
|
));
|
|
3245
3245
|
}
|
|
3246
|
-
const c = (await _.offset(t * r).limit(r)).map((
|
|
3247
|
-
const { tenant_id: f, actions: y, ...
|
|
3248
|
-
return
|
|
3249
|
-
...
|
|
3250
|
-
actions:
|
|
3246
|
+
const c = (await _.offset(t * r).limit(r)).map((p) => {
|
|
3247
|
+
const { tenant_id: f, actions: y, ...w } = p;
|
|
3248
|
+
return z({
|
|
3249
|
+
...w,
|
|
3250
|
+
actions: b(y, [])
|
|
3251
3251
|
});
|
|
3252
3252
|
});
|
|
3253
3253
|
if (!o)
|
|
3254
3254
|
return { flows: c };
|
|
3255
|
-
const [
|
|
3255
|
+
const [u] = await n.select({ count: R() }).from(re).where(a(re.tenant_id, i));
|
|
3256
3256
|
return {
|
|
3257
3257
|
flows: c,
|
|
3258
3258
|
start: t * r,
|
|
3259
3259
|
limit: r,
|
|
3260
|
-
length: Number((
|
|
3260
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3261
3261
|
};
|
|
3262
3262
|
},
|
|
3263
3263
|
async remove(i, e) {
|
|
@@ -3266,7 +3266,7 @@ function rs(n) {
|
|
|
3266
3266
|
};
|
|
3267
3267
|
}
|
|
3268
3268
|
const Ke = ["nodes", "start", "ending"];
|
|
3269
|
-
function
|
|
3269
|
+
function rs(n) {
|
|
3270
3270
|
return {
|
|
3271
3271
|
async create(i, e) {
|
|
3272
3272
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = ae(), o = {
|
|
@@ -3296,8 +3296,8 @@ function ss(n) {
|
|
|
3296
3296
|
if (!t) return null;
|
|
3297
3297
|
const { tenant_id: r, ...o } = t, l = { ...o };
|
|
3298
3298
|
for (const _ of Ke)
|
|
3299
|
-
l[_] =
|
|
3300
|
-
return
|
|
3299
|
+
l[_] = b(o[_]);
|
|
3300
|
+
return z(l);
|
|
3301
3301
|
},
|
|
3302
3302
|
async update(i, e, t) {
|
|
3303
3303
|
const r = {
|
|
@@ -3316,25 +3316,25 @@ function ss(n) {
|
|
|
3316
3316
|
} = e || {};
|
|
3317
3317
|
let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
|
|
3318
3318
|
if (l != null && l.sort_by) {
|
|
3319
|
-
const
|
|
3320
|
-
|
|
3321
|
-
l.sort_order === "desc" ? V(
|
|
3319
|
+
const p = ie[l.sort_by];
|
|
3320
|
+
p && (_ = _.orderBy(
|
|
3321
|
+
l.sort_order === "desc" ? V(p) : G(p)
|
|
3322
3322
|
));
|
|
3323
3323
|
}
|
|
3324
|
-
const c = (await _.offset(t * r).limit(r)).map((
|
|
3325
|
-
const { tenant_id: f, ...y } =
|
|
3324
|
+
const c = (await _.offset(t * r).limit(r)).map((p) => {
|
|
3325
|
+
const { tenant_id: f, ...y } = p, w = { ...y };
|
|
3326
3326
|
for (const B of Ke)
|
|
3327
|
-
|
|
3328
|
-
return
|
|
3327
|
+
w[B] = b(y[B]);
|
|
3328
|
+
return z(w);
|
|
3329
3329
|
});
|
|
3330
3330
|
if (!o)
|
|
3331
3331
|
return { forms: c };
|
|
3332
|
-
const [
|
|
3332
|
+
const [u] = await n.select({ count: R() }).from(ie).where(a(ie.tenant_id, i));
|
|
3333
3333
|
return {
|
|
3334
3334
|
forms: c,
|
|
3335
3335
|
start: t * r,
|
|
3336
3336
|
limit: r,
|
|
3337
|
-
length: Number((
|
|
3337
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3338
3338
|
};
|
|
3339
3339
|
},
|
|
3340
3340
|
async remove(i, e) {
|
|
@@ -3342,7 +3342,7 @@ function ss(n) {
|
|
|
3342
3342
|
}
|
|
3343
3343
|
};
|
|
3344
3344
|
}
|
|
3345
|
-
function
|
|
3345
|
+
function fr(n) {
|
|
3346
3346
|
if (n != null) {
|
|
3347
3347
|
if (typeof n == "number")
|
|
3348
3348
|
return new Date(n).toISOString();
|
|
@@ -3355,9 +3355,9 @@ function pr(n) {
|
|
|
3355
3355
|
}
|
|
3356
3356
|
}
|
|
3357
3357
|
function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
|
|
3358
|
-
return
|
|
3358
|
+
return fr(n) ?? i;
|
|
3359
3359
|
}
|
|
3360
|
-
function
|
|
3360
|
+
function $(n) {
|
|
3361
3361
|
if (!n || n === "")
|
|
3362
3362
|
return null;
|
|
3363
3363
|
const i = new Date(n);
|
|
@@ -3371,15 +3371,15 @@ function Pe(n, i, e = []) {
|
|
|
3371
3371
|
}
|
|
3372
3372
|
for (const r of e) {
|
|
3373
3373
|
const o = r.replace(/_ts$/, "");
|
|
3374
|
-
t[o] =
|
|
3374
|
+
t[o] = fr(n[r]);
|
|
3375
3375
|
}
|
|
3376
3376
|
return t;
|
|
3377
3377
|
}
|
|
3378
|
-
const
|
|
3379
|
-
function
|
|
3380
|
-
return `hc_${
|
|
3378
|
+
const ss = Hr("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3379
|
+
function os() {
|
|
3380
|
+
return `hc_${ss()}`;
|
|
3381
3381
|
}
|
|
3382
|
-
function
|
|
3382
|
+
function Ct(n) {
|
|
3383
3383
|
const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Pe({ created_at_ts: i, updated_at_ts: e }, [
|
|
3384
3384
|
"created_at_ts",
|
|
3385
3385
|
"updated_at_ts"
|
|
@@ -3390,35 +3390,35 @@ function At(n) {
|
|
|
3390
3390
|
secrets: t ? JSON.parse(t) : void 0
|
|
3391
3391
|
};
|
|
3392
3392
|
}
|
|
3393
|
-
function
|
|
3393
|
+
function as(n) {
|
|
3394
3394
|
return {
|
|
3395
3395
|
async create(i, e) {
|
|
3396
3396
|
const t = Date.now(), o = {
|
|
3397
|
-
id:
|
|
3397
|
+
id: os(),
|
|
3398
3398
|
tenant_id: i,
|
|
3399
3399
|
code: e.code,
|
|
3400
3400
|
secrets: e.secrets ? JSON.stringify(e.secrets) : null,
|
|
3401
3401
|
created_at_ts: t,
|
|
3402
3402
|
updated_at_ts: t
|
|
3403
3403
|
};
|
|
3404
|
-
return await n.insert(
|
|
3404
|
+
return await n.insert(he).values(o), Ct({ ...o, tenant_id: i });
|
|
3405
3405
|
},
|
|
3406
3406
|
async get(i, e) {
|
|
3407
|
-
const t = await n.select().from(
|
|
3408
|
-
return t ?
|
|
3407
|
+
const t = await n.select().from(he).where(g(a(he.tenant_id, i), a(he.id, e))).get();
|
|
3408
|
+
return t ? Ct(t) : null;
|
|
3409
3409
|
},
|
|
3410
3410
|
async update(i, e, t) {
|
|
3411
3411
|
const r = {
|
|
3412
3412
|
updated_at_ts: Date.now()
|
|
3413
3413
|
};
|
|
3414
|
-
return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(
|
|
3414
|
+
return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(he).set(r).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
|
|
3415
3415
|
},
|
|
3416
3416
|
async remove(i, e) {
|
|
3417
|
-
return (await n.delete(
|
|
3417
|
+
return (await n.delete(he).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
|
|
3418
3418
|
}
|
|
3419
3419
|
};
|
|
3420
3420
|
}
|
|
3421
|
-
function
|
|
3421
|
+
function ls() {
|
|
3422
3422
|
const { customAlphabet: n } = require("nanoid");
|
|
3423
3423
|
return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3424
3424
|
}
|
|
@@ -3427,18 +3427,18 @@ function rt(n) {
|
|
|
3427
3427
|
"created_at_ts",
|
|
3428
3428
|
"updated_at_ts"
|
|
3429
3429
|
]);
|
|
3430
|
-
return
|
|
3430
|
+
return z({
|
|
3431
3431
|
...r,
|
|
3432
3432
|
enabled: !!r.enabled,
|
|
3433
3433
|
synchronous: !!r.synchronous,
|
|
3434
3434
|
...o
|
|
3435
3435
|
});
|
|
3436
3436
|
}
|
|
3437
|
-
function
|
|
3437
|
+
function _s(n) {
|
|
3438
3438
|
return {
|
|
3439
3439
|
async create(i, e) {
|
|
3440
3440
|
const t = Date.now(), o = {
|
|
3441
|
-
hook_id: e.hook_id ||
|
|
3441
|
+
hook_id: e.hook_id || ls(),
|
|
3442
3442
|
tenant_id: i,
|
|
3443
3443
|
trigger_id: e.trigger_id,
|
|
3444
3444
|
url: e.url,
|
|
@@ -3470,20 +3470,20 @@ function us(n) {
|
|
|
3470
3470
|
include_totals: o = !1,
|
|
3471
3471
|
sort: l,
|
|
3472
3472
|
q: _
|
|
3473
|
-
} = e || {},
|
|
3473
|
+
} = e || {}, d = _ ? ye(ee, _, [
|
|
3474
3474
|
"url",
|
|
3475
3475
|
"form_id",
|
|
3476
3476
|
"template_id",
|
|
3477
3477
|
"code_id"
|
|
3478
|
-
]) : void 0, c =
|
|
3479
|
-
let
|
|
3478
|
+
]) : void 0, c = d ? g(a(ee.tenant_id, i), d) : a(ee.tenant_id, i);
|
|
3479
|
+
let u = n.select().from(ee).where(c).$dynamic();
|
|
3480
3480
|
if (l != null && l.sort_by) {
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3483
|
-
l.sort_order === "desc" ? V(
|
|
3481
|
+
const w = ee[l.sort_by];
|
|
3482
|
+
w && (u = u.orderBy(
|
|
3483
|
+
l.sort_order === "desc" ? V(w) : G(w)
|
|
3484
3484
|
));
|
|
3485
3485
|
}
|
|
3486
|
-
const f = (await
|
|
3486
|
+
const f = (await u.offset(t * r).limit(r)).map(rt);
|
|
3487
3487
|
if (!o)
|
|
3488
3488
|
return { hooks: f };
|
|
3489
3489
|
const [y] = await n.select({ count: R() }).from(ee).where(c);
|
|
@@ -3499,7 +3499,7 @@ function us(n) {
|
|
|
3499
3499
|
}
|
|
3500
3500
|
};
|
|
3501
3501
|
}
|
|
3502
|
-
function
|
|
3502
|
+
function us() {
|
|
3503
3503
|
const { customAlphabet: n } = require("nanoid");
|
|
3504
3504
|
return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3505
3505
|
}
|
|
@@ -3513,14 +3513,14 @@ const Nt = [
|
|
|
3513
3513
|
function st(n) {
|
|
3514
3514
|
const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
|
|
3515
3515
|
for (const o of Nt)
|
|
3516
|
-
r[o] =
|
|
3517
|
-
return r.send_invitation_email = !!e,
|
|
3516
|
+
r[o] = b(t[o], o === "roles" ? [] : {});
|
|
3517
|
+
return r.send_invitation_email = !!e, z(r);
|
|
3518
3518
|
}
|
|
3519
|
-
function
|
|
3519
|
+
function ds(n) {
|
|
3520
3520
|
return {
|
|
3521
3521
|
async create(i, e) {
|
|
3522
|
-
var
|
|
3523
|
-
const t = e.id ||
|
|
3522
|
+
var d, c;
|
|
3523
|
+
const t = e.id || us(), r = e.ttl_sec || 604800, o = /* @__PURE__ */ new Date(), l = new Date(o.getTime() + r * 1e3).toISOString(), _ = {
|
|
3524
3524
|
id: t,
|
|
3525
3525
|
tenant_id: i,
|
|
3526
3526
|
organization_id: e.organization_id,
|
|
@@ -3533,12 +3533,12 @@ function cs(n) {
|
|
|
3533
3533
|
created_at: o.toISOString(),
|
|
3534
3534
|
expires_at: l
|
|
3535
3535
|
};
|
|
3536
|
-
for (const
|
|
3537
|
-
e[
|
|
3536
|
+
for (const u of Nt)
|
|
3537
|
+
e[u] !== void 0 && (_[u] = JSON.stringify(e[u]));
|
|
3538
3538
|
try {
|
|
3539
3539
|
await n.insert(ne).values(_);
|
|
3540
|
-
} catch (
|
|
3541
|
-
throw (
|
|
3540
|
+
} catch (u) {
|
|
3541
|
+
throw (d = u == null ? void 0 : u.message) != null && d.includes("UNIQUE constraint failed") || (c = u == null ? void 0 : u.message) != null && c.includes("duplicate key") ? new xe(409, { message: "Invite already exists" }) : u;
|
|
3542
3542
|
}
|
|
3543
3543
|
return st({ ..._, tenant_id: i });
|
|
3544
3544
|
},
|
|
@@ -3563,20 +3563,20 @@ function cs(n) {
|
|
|
3563
3563
|
} = e || {};
|
|
3564
3564
|
let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
|
|
3565
3565
|
if (l != null && l.sort_by) {
|
|
3566
|
-
const
|
|
3567
|
-
|
|
3568
|
-
l.sort_order === "desc" ? V(
|
|
3566
|
+
const p = ne[l.sort_by];
|
|
3567
|
+
p && (_ = _.orderBy(
|
|
3568
|
+
l.sort_order === "desc" ? V(p) : G(p)
|
|
3569
3569
|
));
|
|
3570
3570
|
}
|
|
3571
3571
|
const c = (await _.offset(t * r).limit(r)).map(st);
|
|
3572
3572
|
if (!o)
|
|
3573
3573
|
return { invites: c };
|
|
3574
|
-
const [
|
|
3574
|
+
const [u] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
|
|
3575
3575
|
return {
|
|
3576
3576
|
invites: c,
|
|
3577
3577
|
start: t * r,
|
|
3578
3578
|
limit: r,
|
|
3579
|
-
length: Number((
|
|
3579
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3580
3580
|
};
|
|
3581
3581
|
},
|
|
3582
3582
|
async remove(i, e) {
|
|
@@ -3584,10 +3584,10 @@ function cs(n) {
|
|
|
3584
3584
|
}
|
|
3585
3585
|
};
|
|
3586
3586
|
}
|
|
3587
|
-
function
|
|
3587
|
+
function cs(n) {
|
|
3588
3588
|
return {
|
|
3589
3589
|
async create(i) {
|
|
3590
|
-
await n.insert(
|
|
3590
|
+
await n.insert(pe).values({
|
|
3591
3591
|
...i,
|
|
3592
3592
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
3593
3593
|
});
|
|
@@ -3599,34 +3599,34 @@ function gs(n) {
|
|
|
3599
3599
|
include_totals: r = !1,
|
|
3600
3600
|
sort: o
|
|
3601
3601
|
} = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
3602
|
-
let _ = n.select().from(
|
|
3602
|
+
let _ = n.select().from(pe).where(de(We(pe.revoked_at, l), me(pe.revoked_at))).$dynamic();
|
|
3603
3603
|
if (o != null && o.sort_by) {
|
|
3604
|
-
const
|
|
3605
|
-
|
|
3606
|
-
o.sort_order === "desc" ? V(
|
|
3604
|
+
const p = pe[o.sort_by];
|
|
3605
|
+
p && (_ = _.orderBy(
|
|
3606
|
+
o.sort_order === "desc" ? V(p) : G(p)
|
|
3607
3607
|
));
|
|
3608
3608
|
}
|
|
3609
|
-
const c = (await _.offset(e * t).limit(t)).map((
|
|
3610
|
-
const { created_at: f, ...y } =
|
|
3611
|
-
return
|
|
3609
|
+
const c = (await _.offset(e * t).limit(t)).map((p) => {
|
|
3610
|
+
const { created_at: f, ...y } = p;
|
|
3611
|
+
return z(y);
|
|
3612
3612
|
});
|
|
3613
3613
|
if (!r)
|
|
3614
3614
|
return { signingKeys: c };
|
|
3615
|
-
const [
|
|
3615
|
+
const [u] = await n.select({ count: R() }).from(pe).where(de(We(pe.revoked_at, l), me(pe.revoked_at)));
|
|
3616
3616
|
return {
|
|
3617
3617
|
signingKeys: c,
|
|
3618
3618
|
start: e * t,
|
|
3619
3619
|
limit: t,
|
|
3620
|
-
length:
|
|
3620
|
+
length: Fr((u == null ? void 0 : u.count) ?? 0)
|
|
3621
3621
|
};
|
|
3622
3622
|
},
|
|
3623
3623
|
async update(i, e) {
|
|
3624
|
-
return (await n.update(
|
|
3624
|
+
return (await n.update(pe).set(e).where(a(pe.kid, i)).returning()).length > 0;
|
|
3625
3625
|
}
|
|
3626
3626
|
};
|
|
3627
3627
|
}
|
|
3628
3628
|
const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ot = vt.length;
|
|
3629
|
-
function
|
|
3629
|
+
function gs() {
|
|
3630
3630
|
let e = Date.now(), t = "";
|
|
3631
3631
|
for (let o = 10; o > 0; o--)
|
|
3632
3632
|
t = vt.charAt(e % ot) + t, e = Math.floor(e / ot);
|
|
@@ -3645,26 +3645,26 @@ function Bt(n) {
|
|
|
3645
3645
|
state_data: o,
|
|
3646
3646
|
auth_params: l,
|
|
3647
3647
|
..._
|
|
3648
|
-
} = n,
|
|
3648
|
+
} = n, d = Pe(
|
|
3649
3649
|
{ created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
|
|
3650
3650
|
["created_at_ts", "updated_at_ts", "expires_at_ts"]
|
|
3651
3651
|
), c = {};
|
|
3652
|
-
for (const [
|
|
3653
|
-
f != null && (c[
|
|
3654
|
-
const
|
|
3655
|
-
return
|
|
3656
|
-
...d,
|
|
3657
|
-
authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
|
|
3652
|
+
for (const [p, f] of Object.entries(_))
|
|
3653
|
+
f != null && (c[p] = f);
|
|
3654
|
+
const u = gr(c, ["auth_strategy"]);
|
|
3655
|
+
return z({
|
|
3658
3656
|
...u,
|
|
3659
|
-
|
|
3657
|
+
authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
|
|
3658
|
+
...d,
|
|
3659
|
+
state_data: b(o)
|
|
3660
3660
|
});
|
|
3661
3661
|
}
|
|
3662
|
-
function
|
|
3662
|
+
function fs(n) {
|
|
3663
3663
|
return {
|
|
3664
3664
|
async create(i, e) {
|
|
3665
3665
|
var l, _;
|
|
3666
3666
|
const t = Date.now(), o = {
|
|
3667
|
-
id:
|
|
3667
|
+
id: gs(),
|
|
3668
3668
|
tenant_id: i,
|
|
3669
3669
|
session_id: e.session_id,
|
|
3670
3670
|
csrf_token: e.csrf_token,
|
|
@@ -3683,12 +3683,12 @@ function ps(n) {
|
|
|
3683
3683
|
authenticated_at: e.authenticated_at,
|
|
3684
3684
|
created_at_ts: t,
|
|
3685
3685
|
updated_at_ts: t,
|
|
3686
|
-
expires_at_ts: e.expires_at ?
|
|
3686
|
+
expires_at_ts: e.expires_at ? $(e.expires_at) : t + 1e3 * 60 * 60 * 24
|
|
3687
3687
|
};
|
|
3688
|
-
return await n.insert(
|
|
3688
|
+
return await n.insert(q).values(o), Bt({ ...o, tenant_id: i });
|
|
3689
3689
|
},
|
|
3690
3690
|
async get(i, e) {
|
|
3691
|
-
const t = i ? g(a(
|
|
3691
|
+
const t = i ? g(a(q.tenant_id, i), a(q.id, e)) : a(q.id, e), r = await n.select().from(q).where(t).get();
|
|
3692
3692
|
return r ? Bt(r) : null;
|
|
3693
3693
|
},
|
|
3694
3694
|
async update(i, e, t) {
|
|
@@ -3699,25 +3699,25 @@ function ps(n) {
|
|
|
3699
3699
|
if (t.session_id !== void 0 && (r.session_id = t.session_id), t.state !== void 0 && (r.state = t.state), t.state_data !== void 0 && (r.state_data = JSON.stringify(t.state_data)), t.failure_reason !== void 0 && (r.failure_reason = t.failure_reason), t.user_id !== void 0 && (r.user_id = t.user_id), t.auth_connection !== void 0 && (r.auth_connection = t.auth_connection), t.auth_strategy !== void 0 && (r.auth_strategy_strategy = (o = t.auth_strategy) == null ? void 0 : o.strategy, r.auth_strategy_strategy_type = (l = t.auth_strategy) == null ? void 0 : l.strategy_type), t.authenticated_at !== void 0 && (r.authenticated_at = t.authenticated_at), t.authorization_url !== void 0 && (r.authorization_url = (_ = t.authorization_url) == null ? void 0 : _.substring(
|
|
3700
3700
|
0,
|
|
3701
3701
|
1024
|
|
3702
|
-
)), t.expires_at !== void 0 && (r.expires_at_ts =
|
|
3703
|
-
const
|
|
3702
|
+
)), t.expires_at !== void 0 && (r.expires_at_ts = $(t.expires_at)), t.authParams !== void 0) {
|
|
3703
|
+
const d = await n.select({ auth_params: q.auth_params }).from(q).where(
|
|
3704
3704
|
g(
|
|
3705
|
-
a(
|
|
3706
|
-
a(
|
|
3705
|
+
a(q.tenant_id, i),
|
|
3706
|
+
a(q.id, e)
|
|
3707
3707
|
)
|
|
3708
|
-
).get(), c =
|
|
3708
|
+
).get(), c = d != null && d.auth_params && typeof d.auth_params == "string" && d.auth_params.length > 0 ? JSON.parse(d.auth_params) : {};
|
|
3709
3709
|
r.auth_params = JSON.stringify({
|
|
3710
3710
|
...c,
|
|
3711
3711
|
...t.authParams
|
|
3712
3712
|
});
|
|
3713
3713
|
}
|
|
3714
|
-
return await n.update(
|
|
3715
|
-
g(a(
|
|
3714
|
+
return await n.update(q).set(r).where(
|
|
3715
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
3716
3716
|
), !0;
|
|
3717
3717
|
},
|
|
3718
3718
|
async remove(i, e) {
|
|
3719
|
-
return (await n.delete(
|
|
3720
|
-
g(a(
|
|
3719
|
+
return (await n.delete(q).where(
|
|
3720
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
3721
3721
|
).returning()).length > 0;
|
|
3722
3722
|
}
|
|
3723
3723
|
};
|
|
@@ -3731,26 +3731,26 @@ function at(n) {
|
|
|
3731
3731
|
country_code: o,
|
|
3732
3732
|
city_name: l,
|
|
3733
3733
|
latitude: _,
|
|
3734
|
-
longitude:
|
|
3734
|
+
longitude: d,
|
|
3735
3735
|
time_zone: c,
|
|
3736
|
-
continent_code:
|
|
3737
|
-
scope:
|
|
3736
|
+
continent_code: u,
|
|
3737
|
+
scope: p,
|
|
3738
3738
|
...f
|
|
3739
3739
|
} = n, y = {
|
|
3740
3740
|
...f,
|
|
3741
3741
|
isMobile: !!e,
|
|
3742
|
-
auth0_client:
|
|
3743
|
-
details:
|
|
3744
|
-
scope:
|
|
3742
|
+
auth0_client: b(t),
|
|
3743
|
+
details: b(r),
|
|
3744
|
+
scope: p ? p.split(",") : void 0
|
|
3745
3745
|
};
|
|
3746
|
-
return o && (y.location_info =
|
|
3746
|
+
return o && (y.location_info = z({
|
|
3747
3747
|
country_code: o,
|
|
3748
3748
|
city_name: l,
|
|
3749
3749
|
latitude: _,
|
|
3750
|
-
longitude:
|
|
3750
|
+
longitude: d,
|
|
3751
3751
|
time_zone: c,
|
|
3752
|
-
continent_code:
|
|
3753
|
-
})),
|
|
3752
|
+
continent_code: u
|
|
3753
|
+
})), z(y);
|
|
3754
3754
|
}
|
|
3755
3755
|
function hs(n) {
|
|
3756
3756
|
return {
|
|
@@ -3779,7 +3779,7 @@ function hs(n) {
|
|
|
3779
3779
|
hostname: e.hostname,
|
|
3780
3780
|
session_connection: e.session_connection
|
|
3781
3781
|
};
|
|
3782
|
-
return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(
|
|
3782
|
+
return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(T).values(r), at({ ...r, tenant_id: i });
|
|
3783
3783
|
},
|
|
3784
3784
|
async list(i, e) {
|
|
3785
3785
|
const {
|
|
@@ -3789,42 +3789,42 @@ function hs(n) {
|
|
|
3789
3789
|
sort: l,
|
|
3790
3790
|
q: _
|
|
3791
3791
|
} = e || {};
|
|
3792
|
-
let
|
|
3792
|
+
let d = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
|
|
3793
3793
|
if (_) {
|
|
3794
|
-
const f = ye(
|
|
3794
|
+
const f = ye(T, _, [
|
|
3795
3795
|
"user_id",
|
|
3796
3796
|
"ip",
|
|
3797
3797
|
"type",
|
|
3798
3798
|
"client_id"
|
|
3799
3799
|
]);
|
|
3800
|
-
f && (
|
|
3800
|
+
f && (d = d.where(g(a(T.tenant_id, i), f)));
|
|
3801
3801
|
}
|
|
3802
3802
|
if (l != null && l.sort_by) {
|
|
3803
|
-
const f =
|
|
3804
|
-
f && (
|
|
3803
|
+
const f = T[l.sort_by];
|
|
3804
|
+
f && (d = d.orderBy(
|
|
3805
3805
|
l.sort_order === "desc" ? V(f) : G(f)
|
|
3806
3806
|
));
|
|
3807
3807
|
} else
|
|
3808
|
-
|
|
3809
|
-
const
|
|
3808
|
+
d = d.orderBy(V(T.date));
|
|
3809
|
+
const u = (await d.offset(t * r).limit(r)).map(at);
|
|
3810
3810
|
if (!o)
|
|
3811
|
-
return { logs:
|
|
3812
|
-
const [
|
|
3811
|
+
return { logs: u };
|
|
3812
|
+
const [p] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
|
|
3813
3813
|
return {
|
|
3814
|
-
logs:
|
|
3814
|
+
logs: u,
|
|
3815
3815
|
start: t * r,
|
|
3816
3816
|
limit: r,
|
|
3817
|
-
length: Number((
|
|
3817
|
+
length: Number((p == null ? void 0 : p.count) ?? 0)
|
|
3818
3818
|
};
|
|
3819
3819
|
},
|
|
3820
3820
|
async get(i, e) {
|
|
3821
|
-
const t = await n.select().from(
|
|
3821
|
+
const t = await n.select().from(T).where(g(a(T.tenant_id, i), a(T.log_id, e))).get();
|
|
3822
3822
|
return t ? at(t) : null;
|
|
3823
3823
|
}
|
|
3824
3824
|
};
|
|
3825
3825
|
}
|
|
3826
3826
|
const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", lt = St.length;
|
|
3827
|
-
function
|
|
3827
|
+
function ps() {
|
|
3828
3828
|
let e = Date.now(), t = "";
|
|
3829
3829
|
for (let o = 10; o > 0; o--)
|
|
3830
3830
|
t = St.charAt(e % lt) + t, e = Math.floor(e / lt);
|
|
@@ -3844,20 +3844,20 @@ function je(n) {
|
|
|
3844
3844
|
transports: l,
|
|
3845
3845
|
..._
|
|
3846
3846
|
} = n;
|
|
3847
|
-
return
|
|
3847
|
+
return z({
|
|
3848
3848
|
..._,
|
|
3849
3849
|
confirmed: !!o,
|
|
3850
3850
|
credential_backed_up: r != null ? !!r : void 0,
|
|
3851
|
-
transports:
|
|
3851
|
+
transports: b(l),
|
|
3852
3852
|
created_at: wt(e),
|
|
3853
3853
|
updated_at: wt(t)
|
|
3854
3854
|
});
|
|
3855
3855
|
}
|
|
3856
|
-
function
|
|
3856
|
+
function ms(n) {
|
|
3857
3857
|
return {
|
|
3858
3858
|
async create(i, e) {
|
|
3859
3859
|
const t = Date.now(), o = {
|
|
3860
|
-
id: e.id ||
|
|
3860
|
+
id: e.id || ps(),
|
|
3861
3861
|
tenant_id: i,
|
|
3862
3862
|
user_id: e.user_id,
|
|
3863
3863
|
type: e.type,
|
|
@@ -3928,7 +3928,7 @@ function ys(n) {
|
|
|
3928
3928
|
}
|
|
3929
3929
|
};
|
|
3930
3930
|
}
|
|
3931
|
-
function
|
|
3931
|
+
function ys() {
|
|
3932
3932
|
const { customAlphabet: n } = require("nanoid");
|
|
3933
3933
|
return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3934
3934
|
}
|
|
@@ -3941,20 +3941,20 @@ function _t(n) {
|
|
|
3941
3941
|
token_quota: o,
|
|
3942
3942
|
...l
|
|
3943
3943
|
} = n;
|
|
3944
|
-
return
|
|
3944
|
+
return z({
|
|
3945
3945
|
...l,
|
|
3946
|
-
branding:
|
|
3947
|
-
metadata:
|
|
3948
|
-
enabled_connections:
|
|
3949
|
-
token_quota:
|
|
3946
|
+
branding: b(e, {}),
|
|
3947
|
+
metadata: b(t, {}),
|
|
3948
|
+
enabled_connections: b(r, []),
|
|
3949
|
+
token_quota: b(o, {})
|
|
3950
3950
|
});
|
|
3951
3951
|
}
|
|
3952
|
-
function
|
|
3952
|
+
function ws(n) {
|
|
3953
3953
|
return {
|
|
3954
3954
|
async create(i, e) {
|
|
3955
3955
|
var l, _;
|
|
3956
3956
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3957
|
-
id: e.id ||
|
|
3957
|
+
id: e.id || ys(),
|
|
3958
3958
|
tenant_id: i,
|
|
3959
3959
|
name: e.name,
|
|
3960
3960
|
display_name: e.display_name,
|
|
@@ -3966,22 +3966,22 @@ function Ns(n) {
|
|
|
3966
3966
|
updated_at: t
|
|
3967
3967
|
};
|
|
3968
3968
|
try {
|
|
3969
|
-
await n.insert(
|
|
3970
|
-
} catch (
|
|
3971
|
-
throw (l =
|
|
3969
|
+
await n.insert(L).values(o);
|
|
3970
|
+
} catch (d) {
|
|
3971
|
+
throw (l = d == null ? void 0 : d.message) != null && l.includes("UNIQUE constraint failed") || (_ = d == null ? void 0 : d.message) != null && _.includes("AlreadyExists") ? new xe(409, {
|
|
3972
3972
|
message: "Organization already exists"
|
|
3973
|
-
}) :
|
|
3973
|
+
}) : d;
|
|
3974
3974
|
}
|
|
3975
3975
|
return _t({ ...o, tenant_id: i });
|
|
3976
3976
|
},
|
|
3977
3977
|
async get(i, e) {
|
|
3978
|
-
let t = await n.select().from(
|
|
3979
|
-
g(a(
|
|
3978
|
+
let t = await n.select().from(L).where(
|
|
3979
|
+
g(a(L.tenant_id, i), a(L.id, e))
|
|
3980
3980
|
).get();
|
|
3981
|
-
return t || (t = await n.select().from(
|
|
3981
|
+
return t || (t = await n.select().from(L).where(
|
|
3982
3982
|
g(
|
|
3983
|
-
a(
|
|
3984
|
-
a(
|
|
3983
|
+
a(L.tenant_id, i),
|
|
3984
|
+
a(L.name, e)
|
|
3985
3985
|
)
|
|
3986
3986
|
).get()), t ? _t(t) : null;
|
|
3987
3987
|
},
|
|
@@ -3991,8 +3991,8 @@ function Ns(n) {
|
|
|
3991
3991
|
};
|
|
3992
3992
|
return t.name !== void 0 && (r.name = t.name), t.display_name !== void 0 && (r.display_name = t.display_name), t.branding !== void 0 && (r.branding = JSON.stringify(t.branding)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.enabled_connections !== void 0 && (r.enabled_connections = JSON.stringify(
|
|
3993
3993
|
t.enabled_connections
|
|
3994
|
-
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(
|
|
3995
|
-
g(a(
|
|
3994
|
+
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(L).set(r).where(
|
|
3995
|
+
g(a(L.tenant_id, i), a(L.id, e))
|
|
3996
3996
|
).returning()).length > 0;
|
|
3997
3997
|
},
|
|
3998
3998
|
async list(i, e) {
|
|
@@ -4003,39 +4003,39 @@ function Ns(n) {
|
|
|
4003
4003
|
sort: l,
|
|
4004
4004
|
q: _
|
|
4005
4005
|
} = e || {};
|
|
4006
|
-
let
|
|
4007
|
-
if (_ && (
|
|
4006
|
+
let d = n.select().from(L).where(a(L.tenant_id, i)).$dynamic();
|
|
4007
|
+
if (_ && (d = d.where(
|
|
4008
4008
|
de(
|
|
4009
|
-
Ie(
|
|
4010
|
-
Ie(
|
|
4009
|
+
Ie(L.name, `%${_}%`),
|
|
4010
|
+
Ie(L.display_name, `%${_}%`)
|
|
4011
4011
|
)
|
|
4012
4012
|
)), l != null && l.sort_by) {
|
|
4013
|
-
const y =
|
|
4014
|
-
y && (
|
|
4013
|
+
const y = L[l.sort_by];
|
|
4014
|
+
y && (d = d.orderBy(
|
|
4015
4015
|
l.sort_order === "desc" ? V(y) : G(y)
|
|
4016
4016
|
));
|
|
4017
4017
|
}
|
|
4018
|
-
const
|
|
4018
|
+
const u = (await d.offset(t * r).limit(r)).map(_t);
|
|
4019
4019
|
if (!o)
|
|
4020
|
-
return { organizations:
|
|
4021
|
-
const
|
|
4022
|
-
_ &&
|
|
4020
|
+
return { organizations: u };
|
|
4021
|
+
const p = [a(L.tenant_id, i)];
|
|
4022
|
+
_ && p.push(
|
|
4023
4023
|
de(
|
|
4024
|
-
Ie(
|
|
4025
|
-
Ie(
|
|
4024
|
+
Ie(L.name, `%${_}%`),
|
|
4025
|
+
Ie(L.display_name, `%${_}%`)
|
|
4026
4026
|
)
|
|
4027
4027
|
);
|
|
4028
|
-
const [f] = await n.select({ count: R() }).from(
|
|
4028
|
+
const [f] = await n.select({ count: R() }).from(L).where(g(...p));
|
|
4029
4029
|
return {
|
|
4030
|
-
organizations:
|
|
4030
|
+
organizations: u,
|
|
4031
4031
|
start: t * r,
|
|
4032
4032
|
limit: r,
|
|
4033
4033
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
4034
4034
|
};
|
|
4035
4035
|
},
|
|
4036
4036
|
async remove(i, e) {
|
|
4037
|
-
return (await n.delete(
|
|
4038
|
-
g(a(
|
|
4037
|
+
return (await n.delete(L).where(
|
|
4038
|
+
g(a(L.tenant_id, i), a(L.id, e))
|
|
4039
4039
|
).returning()).length > 0;
|
|
4040
4040
|
}
|
|
4041
4041
|
};
|
|
@@ -4047,14 +4047,14 @@ function ut(n) {
|
|
|
4047
4047
|
is_current: !!e
|
|
4048
4048
|
};
|
|
4049
4049
|
}
|
|
4050
|
-
function
|
|
4050
|
+
function Ns(n) {
|
|
4051
4051
|
return {
|
|
4052
4052
|
async create(i, e) {
|
|
4053
4053
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
|
|
4054
|
-
e.is_current !== !1 && await n.update(
|
|
4054
|
+
e.is_current !== !1 && await n.update(C).set({ is_current: 0 }).where(
|
|
4055
4055
|
g(
|
|
4056
|
-
a(
|
|
4057
|
-
a(
|
|
4056
|
+
a(C.tenant_id, i),
|
|
4057
|
+
a(C.user_id, e.user_id)
|
|
4058
4058
|
)
|
|
4059
4059
|
);
|
|
4060
4060
|
const o = {
|
|
@@ -4067,47 +4067,47 @@ function vs(n) {
|
|
|
4067
4067
|
created_at: t,
|
|
4068
4068
|
updated_at: t
|
|
4069
4069
|
};
|
|
4070
|
-
return await n.insert(
|
|
4070
|
+
return await n.insert(C).values(o), ut({ ...o, tenant_id: i });
|
|
4071
4071
|
},
|
|
4072
4072
|
async get(i, e) {
|
|
4073
|
-
const t = await n.select().from(
|
|
4073
|
+
const t = await n.select().from(C).where(
|
|
4074
4074
|
g(
|
|
4075
|
-
a(
|
|
4076
|
-
a(
|
|
4077
|
-
a(
|
|
4075
|
+
a(C.tenant_id, i),
|
|
4076
|
+
a(C.user_id, e),
|
|
4077
|
+
a(C.is_current, 1)
|
|
4078
4078
|
)
|
|
4079
4079
|
).get();
|
|
4080
4080
|
return t ? ut(t) : null;
|
|
4081
4081
|
},
|
|
4082
4082
|
async list(i, e, t) {
|
|
4083
|
-
let r = n.select().from(
|
|
4083
|
+
let r = n.select().from(C).where(
|
|
4084
4084
|
g(
|
|
4085
|
-
a(
|
|
4086
|
-
a(
|
|
4085
|
+
a(C.tenant_id, i),
|
|
4086
|
+
a(C.user_id, e)
|
|
4087
4087
|
)
|
|
4088
|
-
).orderBy(V(
|
|
4088
|
+
).orderBy(V(C.created_at)).$dynamic();
|
|
4089
4089
|
return t && (r = r.limit(t)), (await r).map(ut);
|
|
4090
4090
|
},
|
|
4091
4091
|
async update(i, e) {
|
|
4092
4092
|
const t = {
|
|
4093
4093
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4094
4094
|
};
|
|
4095
|
-
return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(
|
|
4095
|
+
return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(C).set(t).where(
|
|
4096
4096
|
g(
|
|
4097
|
-
a(
|
|
4098
|
-
a(
|
|
4097
|
+
a(C.tenant_id, i),
|
|
4098
|
+
a(C.id, e.id)
|
|
4099
4099
|
)
|
|
4100
|
-
) : await n.update(
|
|
4100
|
+
) : await n.update(C).set(t).where(
|
|
4101
4101
|
g(
|
|
4102
|
-
a(
|
|
4103
|
-
a(
|
|
4104
|
-
a(
|
|
4102
|
+
a(C.tenant_id, i),
|
|
4103
|
+
a(C.user_id, e.user_id),
|
|
4104
|
+
a(C.is_current, 1)
|
|
4105
4105
|
)
|
|
4106
4106
|
), !0;
|
|
4107
4107
|
}
|
|
4108
4108
|
};
|
|
4109
4109
|
}
|
|
4110
|
-
function
|
|
4110
|
+
function vs(n) {
|
|
4111
4111
|
return {
|
|
4112
4112
|
async get(i) {
|
|
4113
4113
|
const e = await n.select().from(Ee).where(a(Ee.tenant_id, i)).get();
|
|
@@ -4151,10 +4151,10 @@ function dt(n) {
|
|
|
4151
4151
|
last_exchanged_at_ts: o,
|
|
4152
4152
|
revoked_at_ts: l,
|
|
4153
4153
|
device: _,
|
|
4154
|
-
resource_servers:
|
|
4154
|
+
resource_servers: d,
|
|
4155
4155
|
rotating: c,
|
|
4156
|
-
...
|
|
4157
|
-
} = n,
|
|
4156
|
+
...u
|
|
4157
|
+
} = n, p = Pe(
|
|
4158
4158
|
{
|
|
4159
4159
|
created_at_ts: e,
|
|
4160
4160
|
expires_at_ts: t,
|
|
@@ -4170,18 +4170,18 @@ function dt(n) {
|
|
|
4170
4170
|
"revoked_at_ts"
|
|
4171
4171
|
]
|
|
4172
4172
|
);
|
|
4173
|
-
return
|
|
4174
|
-
...
|
|
4175
|
-
...
|
|
4173
|
+
return z({
|
|
4174
|
+
...u,
|
|
4175
|
+
...p,
|
|
4176
4176
|
rotating: !!c,
|
|
4177
|
-
device:
|
|
4178
|
-
resource_servers:
|
|
4177
|
+
device: b(_, {}),
|
|
4178
|
+
resource_servers: b(d, [])
|
|
4179
4179
|
});
|
|
4180
4180
|
}
|
|
4181
|
-
function
|
|
4181
|
+
function Ss(n, i) {
|
|
4182
4182
|
return Math.max(n ?? 0, i ?? 0);
|
|
4183
4183
|
}
|
|
4184
|
-
function
|
|
4184
|
+
function bs(n) {
|
|
4185
4185
|
return {
|
|
4186
4186
|
async create(i, e) {
|
|
4187
4187
|
const t = Date.now(), r = {
|
|
@@ -4194,82 +4194,58 @@ function xs(n) {
|
|
|
4194
4194
|
resource_servers: JSON.stringify(e.resource_servers || []),
|
|
4195
4195
|
rotating: e.rotating ?? !1,
|
|
4196
4196
|
created_at_ts: t,
|
|
4197
|
-
expires_at_ts:
|
|
4198
|
-
idle_expires_at_ts:
|
|
4199
|
-
last_exchanged_at_ts:
|
|
4197
|
+
expires_at_ts: $(e.expires_at),
|
|
4198
|
+
idle_expires_at_ts: $(e.idle_expires_at),
|
|
4199
|
+
last_exchanged_at_ts: $(e.last_exchanged_at)
|
|
4200
4200
|
};
|
|
4201
|
-
await n.run(
|
|
4201
|
+
await n.run(N`BEGIN`);
|
|
4202
4202
|
try {
|
|
4203
|
-
await n.insert(
|
|
4204
|
-
const o =
|
|
4203
|
+
await n.insert(E).values(r);
|
|
4204
|
+
const o = Ss(
|
|
4205
4205
|
r.expires_at_ts,
|
|
4206
4206
|
r.idle_expires_at_ts
|
|
4207
4207
|
);
|
|
4208
|
-
o > 0 && r.login_id && await n.update(
|
|
4208
|
+
o > 0 && r.login_id && await n.update(q).set({
|
|
4209
4209
|
expires_at_ts: o,
|
|
4210
4210
|
updated_at_ts: t
|
|
4211
4211
|
}).where(
|
|
4212
4212
|
g(
|
|
4213
|
-
a(
|
|
4214
|
-
a(
|
|
4215
|
-
we(
|
|
4213
|
+
a(q.tenant_id, i),
|
|
4214
|
+
a(q.id, r.login_id),
|
|
4215
|
+
we(q.expires_at_ts, o)
|
|
4216
4216
|
)
|
|
4217
|
-
), await n.run(
|
|
4217
|
+
), await n.run(N`COMMIT`);
|
|
4218
4218
|
} catch (o) {
|
|
4219
|
-
throw await n.run(
|
|
4219
|
+
throw await n.run(N`ROLLBACK`), o;
|
|
4220
4220
|
}
|
|
4221
4221
|
return dt({ ...r, tenant_id: i });
|
|
4222
4222
|
},
|
|
4223
4223
|
async get(i, e) {
|
|
4224
|
-
const t = await n.select().from(
|
|
4225
|
-
g(a(
|
|
4224
|
+
const t = await n.select().from(E).where(
|
|
4225
|
+
g(a(E.tenant_id, i), a(E.id, e))
|
|
4226
4226
|
).get();
|
|
4227
4227
|
return t ? dt(t) : null;
|
|
4228
4228
|
},
|
|
4229
|
-
async update(i, e, t) {
|
|
4230
|
-
const
|
|
4231
|
-
t.device !== void 0 && (
|
|
4232
|
-
const
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
a(z.id, e)
|
|
4250
|
-
)
|
|
4251
|
-
).get();
|
|
4252
|
-
if (u != null && u.login_id) {
|
|
4253
|
-
const c = $t(
|
|
4254
|
-
u.expires_at_ts,
|
|
4255
|
-
u.idle_expires_at_ts
|
|
4256
|
-
);
|
|
4257
|
-
c > 0 && await n.update(L).set({
|
|
4258
|
-
expires_at_ts: c,
|
|
4259
|
-
updated_at_ts: Date.now()
|
|
4260
|
-
}).where(
|
|
4261
|
-
g(
|
|
4262
|
-
a(L.tenant_id, i),
|
|
4263
|
-
a(L.id, u.login_id),
|
|
4264
|
-
we(L.expires_at_ts, c)
|
|
4265
|
-
)
|
|
4266
|
-
);
|
|
4267
|
-
}
|
|
4268
|
-
}
|
|
4269
|
-
return await n.run(w`COMMIT`), _;
|
|
4270
|
-
} catch (l) {
|
|
4271
|
-
throw await n.run(w`ROLLBACK`), l;
|
|
4272
|
-
}
|
|
4229
|
+
async update(i, e, t, r) {
|
|
4230
|
+
const o = {};
|
|
4231
|
+
t.device !== void 0 && (o.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (o.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (o.rotating = t.rotating), t.expires_at !== void 0 && (o.expires_at_ts = $(t.expires_at)), t.idle_expires_at !== void 0 && (o.idle_expires_at_ts = $(t.idle_expires_at)), t.last_exchanged_at !== void 0 && (o.last_exchanged_at_ts = $(t.last_exchanged_at)), t.revoked_at !== void 0 && (o.revoked_at_ts = $(t.revoked_at));
|
|
4232
|
+
const l = r == null ? void 0 : r.loginSessionBump, _ = l ? $(l.expires_at) : null, d = await n.update(E).set(o).where(
|
|
4233
|
+
g(
|
|
4234
|
+
a(E.tenant_id, i),
|
|
4235
|
+
a(E.id, e)
|
|
4236
|
+
)
|
|
4237
|
+
).returning();
|
|
4238
|
+
return l != null && l.login_id && _ && _ > 0 && await n.update(q).set({
|
|
4239
|
+
expires_at_ts: _,
|
|
4240
|
+
updated_at_ts: Date.now()
|
|
4241
|
+
}).where(
|
|
4242
|
+
g(
|
|
4243
|
+
a(q.tenant_id, i),
|
|
4244
|
+
a(q.id, l.login_id),
|
|
4245
|
+
we(q.expires_at_ts, _)
|
|
4246
|
+
)
|
|
4247
|
+
).catch(() => {
|
|
4248
|
+
}), d.length > 0;
|
|
4273
4249
|
},
|
|
4274
4250
|
async list(i, e) {
|
|
4275
4251
|
const {
|
|
@@ -4279,55 +4255,55 @@ function xs(n) {
|
|
|
4279
4255
|
sort: l,
|
|
4280
4256
|
q: _
|
|
4281
4257
|
} = e || {};
|
|
4282
|
-
let
|
|
4258
|
+
let d = n.select().from(E).where(a(E.tenant_id, i)).$dynamic();
|
|
4283
4259
|
if (_) {
|
|
4284
|
-
const f = ye(
|
|
4285
|
-
f && (
|
|
4286
|
-
g(a(
|
|
4260
|
+
const f = ye(E, _, ["user_id"]);
|
|
4261
|
+
f && (d = d.where(
|
|
4262
|
+
g(a(E.tenant_id, i), f)
|
|
4287
4263
|
));
|
|
4288
4264
|
}
|
|
4289
4265
|
if (l != null && l.sort_by) {
|
|
4290
|
-
const f =
|
|
4291
|
-
f && (
|
|
4266
|
+
const f = E[l.sort_by];
|
|
4267
|
+
f && (d = d.orderBy(
|
|
4292
4268
|
l.sort_order === "desc" ? V(f) : G(f)
|
|
4293
4269
|
));
|
|
4294
4270
|
}
|
|
4295
|
-
const
|
|
4271
|
+
const u = (await d.offset(t * r).limit(r)).map(dt);
|
|
4296
4272
|
if (!o)
|
|
4297
|
-
return { refresh_tokens:
|
|
4298
|
-
const [
|
|
4273
|
+
return { refresh_tokens: u };
|
|
4274
|
+
const [p] = await n.select({ count: R() }).from(E).where(a(E.tenant_id, i));
|
|
4299
4275
|
return {
|
|
4300
|
-
refresh_tokens:
|
|
4276
|
+
refresh_tokens: u,
|
|
4301
4277
|
start: t * r,
|
|
4302
4278
|
limit: r,
|
|
4303
|
-
length: Number((
|
|
4279
|
+
length: Number((p == null ? void 0 : p.count) ?? 0)
|
|
4304
4280
|
};
|
|
4305
4281
|
},
|
|
4306
4282
|
async remove(i, e) {
|
|
4307
|
-
return (await n.delete(
|
|
4308
|
-
g(a(
|
|
4283
|
+
return (await n.delete(E).where(
|
|
4284
|
+
g(a(E.tenant_id, i), a(E.id, e))
|
|
4309
4285
|
).returning()).length > 0;
|
|
4310
4286
|
},
|
|
4311
4287
|
async revokeByLoginSession(i, e, t) {
|
|
4312
|
-
return (await n.update(
|
|
4288
|
+
return (await n.update(E).set({ revoked_at_ts: $(t) }).where(
|
|
4313
4289
|
g(
|
|
4314
|
-
a(
|
|
4315
|
-
a(
|
|
4316
|
-
me(
|
|
4290
|
+
a(E.tenant_id, i),
|
|
4291
|
+
a(E.login_id, e),
|
|
4292
|
+
me(E.revoked_at_ts)
|
|
4317
4293
|
)
|
|
4318
4294
|
).returning()).length;
|
|
4319
4295
|
}
|
|
4320
4296
|
};
|
|
4321
4297
|
}
|
|
4322
|
-
function
|
|
4298
|
+
function xs() {
|
|
4323
4299
|
const { customAlphabet: n } = require("nanoid");
|
|
4324
4300
|
return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
4325
4301
|
}
|
|
4326
|
-
const
|
|
4302
|
+
const bt = [
|
|
4327
4303
|
"skip_consent_for_verifiable_first_party_clients",
|
|
4328
4304
|
"allow_offline_access",
|
|
4329
4305
|
"is_system"
|
|
4330
|
-
],
|
|
4306
|
+
], $t = /* @__PURE__ */ new Set([
|
|
4331
4307
|
"id",
|
|
4332
4308
|
"tenant_id",
|
|
4333
4309
|
"identifier",
|
|
@@ -4355,16 +4331,16 @@ function ct(n) {
|
|
|
4355
4331
|
metadata: o,
|
|
4356
4332
|
...l
|
|
4357
4333
|
} = n, _ = { ...l };
|
|
4358
|
-
_.scopes =
|
|
4359
|
-
for (const
|
|
4360
|
-
l[
|
|
4361
|
-
return
|
|
4334
|
+
_.scopes = b(t, []), _.options = b(r, {}), _.metadata = b(o), e !== void 0 && (_.verificationKey = e);
|
|
4335
|
+
for (const d of bt)
|
|
4336
|
+
l[d] !== void 0 && l[d] !== null && (_[d] = !!l[d]);
|
|
4337
|
+
return z(_);
|
|
4362
4338
|
}
|
|
4363
4339
|
function Ds(n) {
|
|
4364
4340
|
return {
|
|
4365
4341
|
async create(i, e) {
|
|
4366
4342
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4367
|
-
id: e.id ||
|
|
4343
|
+
id: e.id || xs(),
|
|
4368
4344
|
tenant_id: i,
|
|
4369
4345
|
identifier: e.identifier,
|
|
4370
4346
|
name: e.name,
|
|
@@ -4379,15 +4355,15 @@ function Ds(n) {
|
|
|
4379
4355
|
created_at: t,
|
|
4380
4356
|
updated_at: t
|
|
4381
4357
|
};
|
|
4382
|
-
for (const l of
|
|
4358
|
+
for (const l of bt)
|
|
4383
4359
|
e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
|
|
4384
|
-
return o.is_system === void 0 && (o.is_system = 0), await n.insert(
|
|
4360
|
+
return o.is_system === void 0 && (o.is_system = 0), await n.insert(A).values(o), ct({ ...o, tenant_id: i });
|
|
4385
4361
|
},
|
|
4386
4362
|
async get(i, e) {
|
|
4387
|
-
const t = await n.select().from(
|
|
4363
|
+
const t = await n.select().from(A).where(
|
|
4388
4364
|
g(
|
|
4389
|
-
a(
|
|
4390
|
-
a(
|
|
4365
|
+
a(A.tenant_id, i),
|
|
4366
|
+
a(A.id, e)
|
|
4391
4367
|
)
|
|
4392
4368
|
).get();
|
|
4393
4369
|
return t ? ct(t) : null;
|
|
@@ -4396,13 +4372,13 @@ function Ds(n) {
|
|
|
4396
4372
|
const r = {
|
|
4397
4373
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4398
4374
|
};
|
|
4399
|
-
t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options =
|
|
4400
|
-
for (const l of
|
|
4375
|
+
t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = N`json_patch(COALESCE(${A.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
|
|
4376
|
+
for (const l of bt)
|
|
4401
4377
|
t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
|
|
4402
|
-
return (await n.update(
|
|
4378
|
+
return (await n.update(A).set(r).where(
|
|
4403
4379
|
g(
|
|
4404
|
-
a(
|
|
4405
|
-
a(
|
|
4380
|
+
a(A.tenant_id, i),
|
|
4381
|
+
a(A.id, e)
|
|
4406
4382
|
)
|
|
4407
4383
|
).returning()).length > 0;
|
|
4408
4384
|
},
|
|
@@ -4413,43 +4389,43 @@ function Ds(n) {
|
|
|
4413
4389
|
include_totals: o = !1,
|
|
4414
4390
|
sort: l,
|
|
4415
4391
|
q: _
|
|
4416
|
-
} = e || {},
|
|
4392
|
+
} = e || {}, d = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
|
|
4417
4393
|
Math.max(1, Math.floor(Number(r) || 50)),
|
|
4418
4394
|
500
|
|
4419
|
-
),
|
|
4395
|
+
), u = [a(A.tenant_id, i)];
|
|
4420
4396
|
if (_) {
|
|
4421
4397
|
const B = _.match(/^([^:]+):(.+)$/);
|
|
4422
4398
|
if (B) {
|
|
4423
4399
|
const [, W, H] = B, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
|
|
4424
|
-
if (qe &&
|
|
4425
|
-
const
|
|
4426
|
-
|
|
4400
|
+
if (qe && $t.has(qe) && !ke) {
|
|
4401
|
+
const mr = A[qe];
|
|
4402
|
+
u.push(Ie(mr, `%${H}%`));
|
|
4427
4403
|
}
|
|
4428
4404
|
}
|
|
4429
4405
|
}
|
|
4430
|
-
let
|
|
4431
|
-
if (l != null && l.sort_by &&
|
|
4432
|
-
const B =
|
|
4433
|
-
|
|
4406
|
+
let p = n.select().from(A).where(g(...u)).$dynamic();
|
|
4407
|
+
if (l != null && l.sort_by && $t.has(l.sort_by)) {
|
|
4408
|
+
const B = A[l.sort_by];
|
|
4409
|
+
p = p.orderBy(
|
|
4434
4410
|
l.sort_order === "desc" ? V(B) : G(B)
|
|
4435
4411
|
);
|
|
4436
4412
|
}
|
|
4437
|
-
const y = (await
|
|
4413
|
+
const y = (await p.offset(d * c).limit(c)).map(ct);
|
|
4438
4414
|
if (!o)
|
|
4439
4415
|
return { resource_servers: y };
|
|
4440
|
-
const [
|
|
4416
|
+
const [w] = await n.select({ count: R() }).from(A).where(g(...u));
|
|
4441
4417
|
return {
|
|
4442
4418
|
resource_servers: y,
|
|
4443
|
-
start:
|
|
4419
|
+
start: d * c,
|
|
4444
4420
|
limit: c,
|
|
4445
|
-
length: Number((
|
|
4421
|
+
length: Number((w == null ? void 0 : w.count) ?? 0)
|
|
4446
4422
|
};
|
|
4447
4423
|
},
|
|
4448
4424
|
async remove(i, e) {
|
|
4449
|
-
return (await n.delete(
|
|
4425
|
+
return (await n.delete(A).where(
|
|
4450
4426
|
g(
|
|
4451
|
-
a(
|
|
4452
|
-
a(
|
|
4427
|
+
a(A.tenant_id, i),
|
|
4428
|
+
a(A.id, e)
|
|
4453
4429
|
)
|
|
4454
4430
|
).returning()).length > 0;
|
|
4455
4431
|
}
|
|
@@ -4484,16 +4460,16 @@ function Os(n) {
|
|
|
4484
4460
|
], l = /* @__PURE__ */ new Map();
|
|
4485
4461
|
if (o.length > 0) {
|
|
4486
4462
|
const _ = await n.select({
|
|
4487
|
-
identifier:
|
|
4488
|
-
name:
|
|
4489
|
-
}).from(
|
|
4463
|
+
identifier: A.identifier,
|
|
4464
|
+
name: A.name
|
|
4465
|
+
}).from(A).where(
|
|
4490
4466
|
g(
|
|
4491
|
-
a(
|
|
4492
|
-
Ne(
|
|
4467
|
+
a(A.tenant_id, i),
|
|
4468
|
+
Ne(A.identifier, o)
|
|
4493
4469
|
)
|
|
4494
4470
|
).all();
|
|
4495
|
-
for (const
|
|
4496
|
-
l.set(
|
|
4471
|
+
for (const d of _)
|
|
4472
|
+
l.set(d.identifier, d.name);
|
|
4497
4473
|
}
|
|
4498
4474
|
return r.map((_) => ({
|
|
4499
4475
|
..._,
|
|
@@ -4548,18 +4524,18 @@ function ks(n) {
|
|
|
4548
4524
|
r && o.push(a(_e.organization_id, r));
|
|
4549
4525
|
const l = await n.select().from(_e).where(g(...o)).all();
|
|
4550
4526
|
return await Promise.all(
|
|
4551
|
-
l.map(async (
|
|
4552
|
-
const c = await n.select({ name:
|
|
4527
|
+
l.map(async (d) => {
|
|
4528
|
+
const c = await n.select({ name: A.name }).from(A).where(
|
|
4553
4529
|
g(
|
|
4554
|
-
a(
|
|
4555
|
-
a(
|
|
4530
|
+
a(A.tenant_id, i),
|
|
4531
|
+
a(A.identifier, d.resource_server_identifier)
|
|
4556
4532
|
)
|
|
4557
4533
|
).get();
|
|
4558
4534
|
return {
|
|
4559
|
-
resource_server_identifier:
|
|
4560
|
-
permission_name:
|
|
4561
|
-
resource_server_name: (c == null ? void 0 : c.name) ||
|
|
4562
|
-
organization_id:
|
|
4535
|
+
resource_server_identifier: d.resource_server_identifier,
|
|
4536
|
+
permission_name: d.permission_name,
|
|
4537
|
+
resource_server_name: (c == null ? void 0 : c.name) || d.resource_server_identifier,
|
|
4538
|
+
organization_id: d.organization_id === "" ? void 0 : d.organization_id
|
|
4563
4539
|
};
|
|
4564
4540
|
})
|
|
4565
4541
|
);
|
|
@@ -4582,10 +4558,10 @@ function ks(n) {
|
|
|
4582
4558
|
}
|
|
4583
4559
|
function gt(n) {
|
|
4584
4560
|
const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
|
|
4585
|
-
return
|
|
4561
|
+
return z({
|
|
4586
4562
|
...r,
|
|
4587
4563
|
is_system: e ? !0 : void 0,
|
|
4588
|
-
metadata:
|
|
4564
|
+
metadata: b(t)
|
|
4589
4565
|
});
|
|
4590
4566
|
}
|
|
4591
4567
|
function Is(n) {
|
|
@@ -4620,15 +4596,15 @@ function Is(n) {
|
|
|
4620
4596
|
include_totals: o = !1,
|
|
4621
4597
|
sort: l,
|
|
4622
4598
|
q: _
|
|
4623
|
-
} = e || {},
|
|
4624
|
-
let
|
|
4599
|
+
} = e || {}, d = _ ? ye(U, _, ["name"]) : void 0, c = d ? g(a(U.tenant_id, i), d) : a(U.tenant_id, i);
|
|
4600
|
+
let u = n.select().from(U).where(c).$dynamic();
|
|
4625
4601
|
if (l != null && l.sort_by) {
|
|
4626
|
-
const
|
|
4627
|
-
|
|
4628
|
-
l.sort_order === "desc" ? V(
|
|
4602
|
+
const w = U[l.sort_by];
|
|
4603
|
+
w && (u = u.orderBy(
|
|
4604
|
+
l.sort_order === "desc" ? V(w) : G(w)
|
|
4629
4605
|
));
|
|
4630
4606
|
}
|
|
4631
|
-
const f = (await
|
|
4607
|
+
const f = (await u.offset(t * r).limit(r)).map(gt);
|
|
4632
4608
|
if (!o)
|
|
4633
4609
|
return { roles: f };
|
|
4634
4610
|
const [y] = await n.select({ count: R() }).from(U).where(c);
|
|
@@ -4661,10 +4637,10 @@ function ft(n) {
|
|
|
4661
4637
|
idle_expires_at_ts: o,
|
|
4662
4638
|
authenticated_at_ts: l,
|
|
4663
4639
|
last_interaction_at_ts: _,
|
|
4664
|
-
used_at_ts:
|
|
4640
|
+
used_at_ts: d,
|
|
4665
4641
|
revoked_at_ts: c,
|
|
4666
|
-
device:
|
|
4667
|
-
clients:
|
|
4642
|
+
device: u,
|
|
4643
|
+
clients: p,
|
|
4668
4644
|
...f
|
|
4669
4645
|
} = n, y = Pe(
|
|
4670
4646
|
{
|
|
@@ -4674,17 +4650,17 @@ function ft(n) {
|
|
|
4674
4650
|
idle_expires_at_ts: o,
|
|
4675
4651
|
authenticated_at_ts: l,
|
|
4676
4652
|
last_interaction_at_ts: _,
|
|
4677
|
-
used_at_ts:
|
|
4653
|
+
used_at_ts: d,
|
|
4678
4654
|
revoked_at_ts: c
|
|
4679
4655
|
},
|
|
4680
4656
|
[...zs],
|
|
4681
4657
|
[...Ts]
|
|
4682
4658
|
);
|
|
4683
|
-
return
|
|
4659
|
+
return z({
|
|
4684
4660
|
...f,
|
|
4685
4661
|
...y,
|
|
4686
|
-
device:
|
|
4687
|
-
clients:
|
|
4662
|
+
device: b(u, {}),
|
|
4663
|
+
clients: b(p, [])
|
|
4688
4664
|
});
|
|
4689
4665
|
}
|
|
4690
4666
|
function qs(n) {
|
|
@@ -4699,26 +4675,26 @@ function qs(n) {
|
|
|
4699
4675
|
clients: JSON.stringify(e.clients || []),
|
|
4700
4676
|
created_at_ts: t,
|
|
4701
4677
|
updated_at_ts: t,
|
|
4702
|
-
expires_at_ts:
|
|
4703
|
-
idle_expires_at_ts:
|
|
4704
|
-
authenticated_at_ts: e.authenticated_at ?
|
|
4705
|
-
last_interaction_at_ts: e.last_interaction_at ?
|
|
4706
|
-
used_at_ts:
|
|
4707
|
-
revoked_at_ts:
|
|
4678
|
+
expires_at_ts: $(e.expires_at),
|
|
4679
|
+
idle_expires_at_ts: $(e.idle_expires_at),
|
|
4680
|
+
authenticated_at_ts: e.authenticated_at ? $(e.authenticated_at) : t,
|
|
4681
|
+
last_interaction_at_ts: e.last_interaction_at ? $(e.last_interaction_at) : t,
|
|
4682
|
+
used_at_ts: $(e.used_at),
|
|
4683
|
+
revoked_at_ts: $(e.revoked_at)
|
|
4708
4684
|
};
|
|
4709
|
-
return await n.insert(
|
|
4685
|
+
return await n.insert(Q).values(r), ft({ ...r, tenant_id: i });
|
|
4710
4686
|
},
|
|
4711
4687
|
async get(i, e) {
|
|
4712
|
-
const t = await n.select().from(
|
|
4688
|
+
const t = await n.select().from(Q).where(g(a(Q.tenant_id, i), a(Q.id, e))).get();
|
|
4713
4689
|
return t ? ft(t) : null;
|
|
4714
4690
|
},
|
|
4715
4691
|
async update(i, e, t) {
|
|
4716
4692
|
const r = {
|
|
4717
4693
|
updated_at_ts: Date.now()
|
|
4718
4694
|
};
|
|
4719
|
-
return t.user_id !== void 0 && (r.user_id = t.user_id), t.login_session_id !== void 0 && (r.login_session_id = t.login_session_id), t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.clients !== void 0 && (r.clients = JSON.stringify(t.clients)), t.expires_at !== void 0 && (r.expires_at_ts =
|
|
4695
|
+
return t.user_id !== void 0 && (r.user_id = t.user_id), t.login_session_id !== void 0 && (r.login_session_id = t.login_session_id), t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.clients !== void 0 && (r.clients = JSON.stringify(t.clients)), t.expires_at !== void 0 && (r.expires_at_ts = $(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = $(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = $(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = $(
|
|
4720
4696
|
t.last_interaction_at
|
|
4721
|
-
)), t.used_at !== void 0 && (r.used_at_ts =
|
|
4697
|
+
)), t.used_at !== void 0 && (r.used_at_ts = $(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = $(t.revoked_at)), (await n.update(Q).set(r).where(g(a(Q.tenant_id, i), a(Q.id, e))).returning()).length > 0;
|
|
4722
4698
|
},
|
|
4723
4699
|
async list(i, e) {
|
|
4724
4700
|
const {
|
|
@@ -4727,18 +4703,18 @@ function qs(n) {
|
|
|
4727
4703
|
include_totals: o = !1,
|
|
4728
4704
|
sort: l,
|
|
4729
4705
|
q: _
|
|
4730
|
-
} = e || {},
|
|
4731
|
-
let
|
|
4706
|
+
} = e || {}, d = _ ? ye(Q, _, ["user_id"]) : void 0, c = d ? g(a(Q.tenant_id, i), d) : a(Q.tenant_id, i);
|
|
4707
|
+
let u = n.select().from(Q).where(c).$dynamic();
|
|
4732
4708
|
if (l != null && l.sort_by) {
|
|
4733
|
-
const
|
|
4734
|
-
|
|
4735
|
-
l.sort_order === "desc" ? V(
|
|
4709
|
+
const w = Q[l.sort_by];
|
|
4710
|
+
w && (u = u.orderBy(
|
|
4711
|
+
l.sort_order === "desc" ? V(w) : G(w)
|
|
4736
4712
|
));
|
|
4737
4713
|
}
|
|
4738
|
-
const f = (await
|
|
4714
|
+
const f = (await u.offset(t * r).limit(r)).map(ft);
|
|
4739
4715
|
if (!o)
|
|
4740
4716
|
return { sessions: f };
|
|
4741
|
-
const [y] = await n.select({ count: R() }).from(
|
|
4717
|
+
const [y] = await n.select({ count: R() }).from(Q).where(c);
|
|
4742
4718
|
return {
|
|
4743
4719
|
sessions: f,
|
|
4744
4720
|
start: t * r,
|
|
@@ -4747,7 +4723,7 @@ function qs(n) {
|
|
|
4747
4723
|
};
|
|
4748
4724
|
},
|
|
4749
4725
|
async remove(i, e) {
|
|
4750
|
-
return (await n.delete(
|
|
4726
|
+
return (await n.delete(Q).where(g(a(Q.tenant_id, i), a(Q.id, e))).returning()).length > 0;
|
|
4751
4727
|
}
|
|
4752
4728
|
};
|
|
4753
4729
|
}
|
|
@@ -4767,30 +4743,30 @@ const hr = [
|
|
|
4767
4743
|
"acr_values_supported",
|
|
4768
4744
|
"mtls",
|
|
4769
4745
|
"mfa"
|
|
4770
|
-
],
|
|
4746
|
+
], pr = [
|
|
4771
4747
|
"allow_organization_name_in_authentication_api",
|
|
4772
4748
|
"customize_mfa_in_postlogin_action",
|
|
4773
4749
|
"pushed_authorization_requests_supported",
|
|
4774
4750
|
"authorization_response_iss_parameter_supported"
|
|
4775
4751
|
];
|
|
4776
|
-
function
|
|
4752
|
+
function Qt(n) {
|
|
4777
4753
|
const i = { ...n };
|
|
4778
4754
|
for (const e of hr)
|
|
4779
|
-
typeof i[e] == "string" && (i[e] =
|
|
4780
|
-
for (const e of
|
|
4755
|
+
typeof i[e] == "string" && (i[e] = b(i[e]));
|
|
4756
|
+
for (const e of pr)
|
|
4781
4757
|
i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
|
|
4782
|
-
return
|
|
4758
|
+
return z(i);
|
|
4783
4759
|
}
|
|
4784
|
-
function
|
|
4760
|
+
function Jt(n) {
|
|
4785
4761
|
const i = { ...n };
|
|
4786
|
-
|
|
4762
|
+
Jr(
|
|
4787
4763
|
n,
|
|
4788
4764
|
hr,
|
|
4789
4765
|
i
|
|
4790
4766
|
);
|
|
4791
|
-
for (const e of
|
|
4767
|
+
for (const e of pr)
|
|
4792
4768
|
n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
|
|
4793
|
-
return
|
|
4769
|
+
return cr(i);
|
|
4794
4770
|
}
|
|
4795
4771
|
function Ls(n) {
|
|
4796
4772
|
return {
|
|
@@ -4801,11 +4777,11 @@ function Ls(n) {
|
|
|
4801
4777
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4802
4778
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4803
4779
|
...i
|
|
4804
|
-
}, t =
|
|
4780
|
+
}, t = Jt(e);
|
|
4805
4781
|
try {
|
|
4806
4782
|
await n.insert(D).values(t);
|
|
4807
4783
|
} catch (l) {
|
|
4808
|
-
throw (r = l == null ? void 0 : l.message) != null && r.includes("UNIQUE constraint failed") || (o = l == null ? void 0 : l.message) != null && o.includes("duplicate key") || (l == null ? void 0 : l.code) === "SQLITE_CONSTRAINT" ? new
|
|
4784
|
+
throw (r = l == null ? void 0 : l.message) != null && r.includes("UNIQUE constraint failed") || (o = l == null ? void 0 : l.message) != null && o.includes("duplicate key") || (l == null ? void 0 : l.code) === "SQLITE_CONSTRAINT" ? new xe(409, {
|
|
4809
4785
|
message: `Tenant with ID '${e.id}' already exists`
|
|
4810
4786
|
}) : l;
|
|
4811
4787
|
}
|
|
@@ -4813,7 +4789,7 @@ function Ls(n) {
|
|
|
4813
4789
|
},
|
|
4814
4790
|
async get(i) {
|
|
4815
4791
|
const e = await n.select().from(D).where(a(D.id, i)).get();
|
|
4816
|
-
return e ?
|
|
4792
|
+
return e ? Qt(e) : null;
|
|
4817
4793
|
},
|
|
4818
4794
|
async list(i) {
|
|
4819
4795
|
const {
|
|
@@ -4825,28 +4801,28 @@ function Ls(n) {
|
|
|
4825
4801
|
} = i || {};
|
|
4826
4802
|
let _ = n.select().from(D).$dynamic();
|
|
4827
4803
|
if (l) {
|
|
4828
|
-
const
|
|
4829
|
-
|
|
4804
|
+
const p = ye(D, l, ["friendly_name"]);
|
|
4805
|
+
p && (_ = _.where(p));
|
|
4830
4806
|
}
|
|
4831
4807
|
if (o != null && o.sort_by) {
|
|
4832
|
-
const
|
|
4833
|
-
|
|
4834
|
-
o.sort_order === "desc" ? V(
|
|
4808
|
+
const p = D[o.sort_by];
|
|
4809
|
+
p && (_ = _.orderBy(
|
|
4810
|
+
o.sort_order === "desc" ? V(p) : G(p)
|
|
4835
4811
|
));
|
|
4836
4812
|
}
|
|
4837
|
-
const c = (await _.offset(e * t).limit(t)).map(
|
|
4813
|
+
const c = (await _.offset(e * t).limit(t)).map(Qt);
|
|
4838
4814
|
if (!r)
|
|
4839
4815
|
return { tenants: c };
|
|
4840
|
-
const [
|
|
4816
|
+
const [u] = await n.select({ count: R() }).from(D);
|
|
4841
4817
|
return {
|
|
4842
4818
|
tenants: c,
|
|
4843
4819
|
start: e * t,
|
|
4844
4820
|
limit: t,
|
|
4845
|
-
length: Number((
|
|
4821
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
4846
4822
|
};
|
|
4847
4823
|
},
|
|
4848
4824
|
async update(i, e) {
|
|
4849
|
-
const t =
|
|
4825
|
+
const t = Jt({
|
|
4850
4826
|
...e,
|
|
4851
4827
|
id: i,
|
|
4852
4828
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -4865,11 +4841,11 @@ const Es = [
|
|
|
4865
4841
|
"page_background",
|
|
4866
4842
|
"widget"
|
|
4867
4843
|
];
|
|
4868
|
-
function
|
|
4869
|
-
const { tenant_id: i, ...e } = n, t =
|
|
4870
|
-
return t.borders && (t.borders.show_widget_shadow = !!t.borders.show_widget_shadow), t.fonts && (t.fonts.links_bold = !!t.fonts.links_bold, t.fonts.subtitle_bold = !!t.fonts.subtitle_bold, t.fonts.title_bold = !!t.fonts.title_bold),
|
|
4844
|
+
function Pt(n) {
|
|
4845
|
+
const { tenant_id: i, ...e } = n, t = gr(e, Es);
|
|
4846
|
+
return t.borders && (t.borders.show_widget_shadow = !!t.borders.show_widget_shadow), t.fonts && (t.fonts.links_bold = !!t.fonts.links_bold, t.fonts.subtitle_bold = !!t.fonts.subtitle_bold, t.fonts.title_bold = !!t.fonts.title_bold), z(t);
|
|
4871
4847
|
}
|
|
4872
|
-
function
|
|
4848
|
+
function As(n) {
|
|
4873
4849
|
return {
|
|
4874
4850
|
async create(i, e, t) {
|
|
4875
4851
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
|
|
@@ -4879,13 +4855,13 @@ function Cs(n) {
|
|
|
4879
4855
|
created_at: r,
|
|
4880
4856
|
updated_at: r
|
|
4881
4857
|
};
|
|
4882
|
-
return await n.insert(fe).values(_),
|
|
4858
|
+
return await n.insert(fe).values(_), Pt({ ..._, tenant_id: i });
|
|
4883
4859
|
},
|
|
4884
4860
|
async get(i, e) {
|
|
4885
4861
|
const t = await n.select().from(fe).where(
|
|
4886
4862
|
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4887
4863
|
).get();
|
|
4888
|
-
return t ?
|
|
4864
|
+
return t ? Pt(t) : null;
|
|
4889
4865
|
},
|
|
4890
4866
|
async update(i, e, t) {
|
|
4891
4867
|
const r = yt(t);
|
|
@@ -4900,7 +4876,7 @@ function Cs(n) {
|
|
|
4900
4876
|
}
|
|
4901
4877
|
};
|
|
4902
4878
|
}
|
|
4903
|
-
function
|
|
4879
|
+
function Cs(n) {
|
|
4904
4880
|
return {
|
|
4905
4881
|
async get(i) {
|
|
4906
4882
|
const e = await n.select({ body: ve.body }).from(ve).where(a(ve.tenant_id, i)).get();
|
|
@@ -4926,7 +4902,7 @@ function As(n) {
|
|
|
4926
4902
|
}
|
|
4927
4903
|
};
|
|
4928
4904
|
}
|
|
4929
|
-
function
|
|
4905
|
+
function Ft(n, i) {
|
|
4930
4906
|
const e = {
|
|
4931
4907
|
connection: n.connection,
|
|
4932
4908
|
provider: n.provider,
|
|
@@ -4936,10 +4912,10 @@ function Ut(n, i) {
|
|
|
4936
4912
|
return i ? e.isPrimary = !0 : e.profileData = {
|
|
4937
4913
|
email: n.email,
|
|
4938
4914
|
email_verified: !!n.email_verified,
|
|
4939
|
-
...typeof n.profileData == "string" ?
|
|
4915
|
+
...typeof n.profileData == "string" ? b(n.profileData, {}) : {}
|
|
4940
4916
|
}, e;
|
|
4941
4917
|
}
|
|
4942
|
-
function
|
|
4918
|
+
function ht(n, i = []) {
|
|
4943
4919
|
const {
|
|
4944
4920
|
tenant_id: e,
|
|
4945
4921
|
app_metadata: t,
|
|
@@ -4947,26 +4923,26 @@ function pt(n, i = []) {
|
|
|
4947
4923
|
address: o,
|
|
4948
4924
|
email_verified: l,
|
|
4949
4925
|
phone_verified: _,
|
|
4950
|
-
is_social:
|
|
4926
|
+
is_social: d,
|
|
4951
4927
|
linked_to: c,
|
|
4952
|
-
profileData:
|
|
4953
|
-
...
|
|
4954
|
-
} = n, f =
|
|
4955
|
-
return
|
|
4956
|
-
...
|
|
4928
|
+
profileData: u,
|
|
4929
|
+
...p
|
|
4930
|
+
} = n, f = Ft(n, !0), y = i.map((w) => Ft(w, !1));
|
|
4931
|
+
return z({
|
|
4932
|
+
...p,
|
|
4957
4933
|
email: n.email || "",
|
|
4958
4934
|
email_verified: !!l,
|
|
4959
4935
|
phone_verified: _ != null ? !!_ : void 0,
|
|
4960
|
-
is_social: !!
|
|
4961
|
-
app_metadata:
|
|
4962
|
-
user_metadata:
|
|
4963
|
-
address:
|
|
4936
|
+
is_social: !!d,
|
|
4937
|
+
app_metadata: b(t, {}),
|
|
4938
|
+
user_metadata: b(r, {}),
|
|
4939
|
+
address: b(o),
|
|
4964
4940
|
identities: [f, ...y]
|
|
4965
4941
|
});
|
|
4966
4942
|
}
|
|
4967
4943
|
function Bs(n) {
|
|
4968
4944
|
const i = async (e, t) => {
|
|
4969
|
-
var _,
|
|
4945
|
+
var _, d;
|
|
4970
4946
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4971
4947
|
user_id: t.user_id,
|
|
4972
4948
|
tenant_id: e,
|
|
@@ -5005,9 +4981,9 @@ function Bs(n) {
|
|
|
5005
4981
|
}, l = t.password ? ae() : void 0;
|
|
5006
4982
|
try {
|
|
5007
4983
|
if (t.password && l) {
|
|
5008
|
-
await n.run(
|
|
4984
|
+
await n.run(N`BEGIN`);
|
|
5009
4985
|
try {
|
|
5010
|
-
await n.insert(k).values(o), await n.insert(
|
|
4986
|
+
await n.insert(k).values(o), await n.insert(C).values({
|
|
5011
4987
|
id: l,
|
|
5012
4988
|
tenant_id: e,
|
|
5013
4989
|
user_id: t.user_id,
|
|
@@ -5016,18 +4992,18 @@ function Bs(n) {
|
|
|
5016
4992
|
is_current: 1,
|
|
5017
4993
|
created_at: r,
|
|
5018
4994
|
updated_at: r
|
|
5019
|
-
}), await n.run(
|
|
4995
|
+
}), await n.run(N`COMMIT`);
|
|
5020
4996
|
} catch (c) {
|
|
5021
|
-
throw await n.run(
|
|
4997
|
+
throw await n.run(N`ROLLBACK`), c;
|
|
5022
4998
|
}
|
|
5023
4999
|
} else
|
|
5024
5000
|
await n.insert(k).values(o);
|
|
5025
5001
|
} catch (c) {
|
|
5026
|
-
throw (_ = c == null ? void 0 : c.message) != null && _.includes("UNIQUE constraint") || (
|
|
5002
|
+
throw (_ = c == null ? void 0 : c.message) != null && _.includes("UNIQUE constraint") || (d = c == null ? void 0 : c.message) != null && d.includes("AlreadyExists") ? new xe(409, { message: "User already exists" }) : (console.error("User upsert failed:", c == null ? void 0 : c.code, c == null ? void 0 : c.message), new xe(500, {
|
|
5027
5003
|
message: "Internal server error"
|
|
5028
5004
|
}));
|
|
5029
5005
|
}
|
|
5030
|
-
return
|
|
5006
|
+
return ht(o);
|
|
5031
5007
|
};
|
|
5032
5008
|
return {
|
|
5033
5009
|
create: i,
|
|
@@ -5038,7 +5014,7 @@ function Bs(n) {
|
|
|
5038
5014
|
const o = await n.select().from(k).where(
|
|
5039
5015
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
5040
5016
|
).all();
|
|
5041
|
-
return
|
|
5017
|
+
return ht(r, o);
|
|
5042
5018
|
},
|
|
5043
5019
|
async update(e, t, r) {
|
|
5044
5020
|
const o = {
|
|
@@ -5068,8 +5044,8 @@ function Bs(n) {
|
|
|
5068
5044
|
"birthdate",
|
|
5069
5045
|
"zoneinfo"
|
|
5070
5046
|
];
|
|
5071
|
-
for (const
|
|
5072
|
-
r[
|
|
5047
|
+
for (const d of l)
|
|
5048
|
+
r[d] !== void 0 && (o[d] = r[d]);
|
|
5073
5049
|
return r.email_verified !== void 0 && (o.email_verified = r.email_verified), r.phone_verified !== void 0 && (o.phone_verified = r.phone_verified), r.is_social !== void 0 && (o.is_social = r.is_social), r.app_metadata !== void 0 && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (o.user_metadata = JSON.stringify(r.user_metadata)), r.address !== void 0 && (o.address = JSON.stringify(r.address)), r.profileData !== void 0 && (o.profileData = JSON.stringify(r.profileData)), (await n.update(k).set(o).where(g(a(k.tenant_id, e), a(k.user_id, t))).returning()).length > 0;
|
|
5074
5050
|
},
|
|
5075
5051
|
async list(e, t) {
|
|
@@ -5078,13 +5054,13 @@ function Bs(n) {
|
|
|
5078
5054
|
per_page: o = 50,
|
|
5079
5055
|
include_totals: l = !1,
|
|
5080
5056
|
sort: _,
|
|
5081
|
-
q:
|
|
5057
|
+
q: d
|
|
5082
5058
|
} = t || {}, c = [
|
|
5083
5059
|
a(k.tenant_id, e),
|
|
5084
5060
|
me(k.linked_to)
|
|
5085
5061
|
];
|
|
5086
|
-
if (
|
|
5087
|
-
const H = ye(k,
|
|
5062
|
+
if (d) {
|
|
5063
|
+
const H = ye(k, d, [
|
|
5088
5064
|
"email",
|
|
5089
5065
|
"name",
|
|
5090
5066
|
"nickname",
|
|
@@ -5092,29 +5068,29 @@ function Bs(n) {
|
|
|
5092
5068
|
]);
|
|
5093
5069
|
H && c.push(H);
|
|
5094
5070
|
}
|
|
5095
|
-
const
|
|
5096
|
-
let
|
|
5071
|
+
const u = g(...c);
|
|
5072
|
+
let p = n.select().from(k).where(u).$dynamic();
|
|
5097
5073
|
if (_ != null && _.sort_by) {
|
|
5098
5074
|
const H = k[_.sort_by];
|
|
5099
|
-
H && (
|
|
5075
|
+
H && (p = p.orderBy(
|
|
5100
5076
|
_.sort_order === "desc" ? V(H) : G(H)
|
|
5101
5077
|
));
|
|
5102
5078
|
}
|
|
5103
|
-
const f = await
|
|
5104
|
-
let
|
|
5105
|
-
y.length > 0 && (
|
|
5079
|
+
const f = await p.offset(r * o).limit(o), y = f.map((H) => H.user_id);
|
|
5080
|
+
let w = [];
|
|
5081
|
+
y.length > 0 && (w = await n.select().from(k).where(
|
|
5106
5082
|
g(
|
|
5107
5083
|
a(k.tenant_id, e),
|
|
5108
5084
|
Ne(k.linked_to, y)
|
|
5109
5085
|
)
|
|
5110
5086
|
));
|
|
5111
5087
|
const B = f.map((H) => {
|
|
5112
|
-
const ke =
|
|
5113
|
-
return
|
|
5088
|
+
const ke = w.filter((qe) => qe.linked_to === H.user_id);
|
|
5089
|
+
return ht(H, ke);
|
|
5114
5090
|
});
|
|
5115
5091
|
if (!l)
|
|
5116
5092
|
return { users: B };
|
|
5117
|
-
const [W] = await n.select({ count: R() }).from(k).where(
|
|
5093
|
+
const [W] = await n.select({ count: R() }).from(k).where(u);
|
|
5118
5094
|
return {
|
|
5119
5095
|
users: B,
|
|
5120
5096
|
start: r * o,
|
|
@@ -5123,7 +5099,7 @@ function Bs(n) {
|
|
|
5123
5099
|
};
|
|
5124
5100
|
},
|
|
5125
5101
|
async remove(e, t) {
|
|
5126
|
-
await n.run(
|
|
5102
|
+
await n.run(N`BEGIN`);
|
|
5127
5103
|
try {
|
|
5128
5104
|
const r = await n.select({ user_id: k.user_id }).from(k).where(
|
|
5129
5105
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
@@ -5133,10 +5109,10 @@ function Bs(n) {
|
|
|
5133
5109
|
a(K.tenant_id, e),
|
|
5134
5110
|
Ne(K.user_id, o)
|
|
5135
5111
|
)
|
|
5136
|
-
), await n.delete(
|
|
5112
|
+
), await n.delete(C).where(
|
|
5137
5113
|
g(
|
|
5138
|
-
a(
|
|
5139
|
-
Ne(
|
|
5114
|
+
a(C.tenant_id, e),
|
|
5115
|
+
Ne(C.user_id, o)
|
|
5140
5116
|
)
|
|
5141
5117
|
), await n.delete(k).where(
|
|
5142
5118
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
@@ -5144,9 +5120,9 @@ function Bs(n) {
|
|
|
5144
5120
|
const l = await n.delete(k).where(
|
|
5145
5121
|
g(a(k.tenant_id, e), a(k.user_id, t))
|
|
5146
5122
|
).returning();
|
|
5147
|
-
return await n.run(
|
|
5123
|
+
return await n.run(N`COMMIT`), l.length > 0;
|
|
5148
5124
|
} catch (r) {
|
|
5149
|
-
throw await n.run(
|
|
5125
|
+
throw await n.run(N`ROLLBACK`), r;
|
|
5150
5126
|
}
|
|
5151
5127
|
},
|
|
5152
5128
|
async unlink(e, t, r, o) {
|
|
@@ -5190,16 +5166,16 @@ function $s(n) {
|
|
|
5190
5166
|
role_id: ue.role_id
|
|
5191
5167
|
}).from(ue).where(g(...o)).all();
|
|
5192
5168
|
return l.length === 0 ? [] : (await Promise.all(
|
|
5193
|
-
l.map(async (
|
|
5169
|
+
l.map(async (d) => {
|
|
5194
5170
|
const c = await n.select().from(U).where(
|
|
5195
|
-
g(a(U.tenant_id, i), a(U.id,
|
|
5171
|
+
g(a(U.tenant_id, i), a(U.id, d.role_id))
|
|
5196
5172
|
).get();
|
|
5197
5173
|
if (!c) return null;
|
|
5198
|
-
const { tenant_id:
|
|
5199
|
-
return
|
|
5174
|
+
const { tenant_id: u, is_system: p, metadata: f, ...y } = c;
|
|
5175
|
+
return z({
|
|
5200
5176
|
...y,
|
|
5201
|
-
is_system:
|
|
5202
|
-
metadata:
|
|
5177
|
+
is_system: p ? !0 : void 0,
|
|
5178
|
+
metadata: b(f)
|
|
5203
5179
|
});
|
|
5204
5180
|
})
|
|
5205
5181
|
)).filter(Boolean);
|
|
@@ -5219,7 +5195,7 @@ function $s(n) {
|
|
|
5219
5195
|
function Qs(n) {
|
|
5220
5196
|
return {
|
|
5221
5197
|
async create(i, e) {
|
|
5222
|
-
var
|
|
5198
|
+
var d, c;
|
|
5223
5199
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5224
5200
|
id: e.id || ae(),
|
|
5225
5201
|
tenant_id: i,
|
|
@@ -5230,10 +5206,10 @@ function Qs(n) {
|
|
|
5230
5206
|
};
|
|
5231
5207
|
try {
|
|
5232
5208
|
await n.insert(P).values(o);
|
|
5233
|
-
} catch (
|
|
5234
|
-
throw (
|
|
5209
|
+
} catch (u) {
|
|
5210
|
+
throw (d = u == null ? void 0 : u.message) != null && d.includes("UNIQUE constraint") || (c = u == null ? void 0 : u.message) != null && c.includes("duplicate key") ? new xe(409, {
|
|
5235
5211
|
message: "User organization already exists"
|
|
5236
|
-
}) :
|
|
5212
|
+
}) : u;
|
|
5237
5213
|
}
|
|
5238
5214
|
const { tenant_id: l, ..._ } = o;
|
|
5239
5215
|
return _;
|
|
@@ -5267,26 +5243,26 @@ function Qs(n) {
|
|
|
5267
5243
|
include_totals: o = !1,
|
|
5268
5244
|
q: l
|
|
5269
5245
|
} = e || {}, _ = a(P.tenant_id, i);
|
|
5270
|
-
let
|
|
5246
|
+
let d = _;
|
|
5271
5247
|
if (l) {
|
|
5272
5248
|
const f = ye(P, l, [
|
|
5273
5249
|
"user_id",
|
|
5274
5250
|
"organization_id"
|
|
5275
5251
|
]);
|
|
5276
|
-
f && (
|
|
5252
|
+
f && (d = g(_, f));
|
|
5277
5253
|
}
|
|
5278
|
-
const
|
|
5279
|
-
const { tenant_id: y, ...
|
|
5280
|
-
return
|
|
5254
|
+
const u = (await n.select().from(P).where(d).offset(t * r).limit(r)).map((f) => {
|
|
5255
|
+
const { tenant_id: y, ...w } = f;
|
|
5256
|
+
return w;
|
|
5281
5257
|
});
|
|
5282
5258
|
if (!o)
|
|
5283
|
-
return { userOrganizations:
|
|
5284
|
-
const [
|
|
5259
|
+
return { userOrganizations: u };
|
|
5260
|
+
const [p] = await n.select({ count: R() }).from(P).where(d);
|
|
5285
5261
|
return {
|
|
5286
|
-
userOrganizations:
|
|
5262
|
+
userOrganizations: u,
|
|
5287
5263
|
start: t * r,
|
|
5288
5264
|
limit: r,
|
|
5289
|
-
length: Number((
|
|
5265
|
+
length: Number((p == null ? void 0 : p.count) ?? 0)
|
|
5290
5266
|
};
|
|
5291
5267
|
},
|
|
5292
5268
|
async listUserOrganizations(i, e, t) {
|
|
@@ -5296,34 +5272,34 @@ function Qs(n) {
|
|
|
5296
5272
|
a(P.user_id, e)
|
|
5297
5273
|
)
|
|
5298
5274
|
).offset(r * o).limit(o).all(), c = (await Promise.all(
|
|
5299
|
-
_.map(async (
|
|
5300
|
-
const f = await n.select().from(
|
|
5275
|
+
_.map(async (p) => {
|
|
5276
|
+
const f = await n.select().from(L).where(
|
|
5301
5277
|
g(
|
|
5302
|
-
a(
|
|
5303
|
-
a(
|
|
5278
|
+
a(L.tenant_id, i),
|
|
5279
|
+
a(L.id, p.organization_id)
|
|
5304
5280
|
)
|
|
5305
5281
|
).get();
|
|
5306
5282
|
if (!f) return null;
|
|
5307
5283
|
const {
|
|
5308
5284
|
tenant_id: y,
|
|
5309
|
-
branding:
|
|
5285
|
+
branding: w,
|
|
5310
5286
|
metadata: B,
|
|
5311
5287
|
enabled_connections: W,
|
|
5312
5288
|
token_quota: H,
|
|
5313
5289
|
...ke
|
|
5314
5290
|
} = f;
|
|
5315
|
-
return
|
|
5291
|
+
return z({
|
|
5316
5292
|
...ke,
|
|
5317
|
-
branding:
|
|
5318
|
-
metadata:
|
|
5319
|
-
enabled_connections:
|
|
5320
|
-
token_quota:
|
|
5293
|
+
branding: b(w, {}),
|
|
5294
|
+
metadata: b(B, {}),
|
|
5295
|
+
enabled_connections: b(W, []),
|
|
5296
|
+
token_quota: b(H, {})
|
|
5321
5297
|
});
|
|
5322
5298
|
})
|
|
5323
5299
|
)).filter(Boolean);
|
|
5324
5300
|
if (!l)
|
|
5325
5301
|
return { organizations: c };
|
|
5326
|
-
const [
|
|
5302
|
+
const [u] = await n.select({ count: R() }).from(P).where(
|
|
5327
5303
|
g(
|
|
5328
5304
|
a(P.tenant_id, i),
|
|
5329
5305
|
a(P.user_id, e)
|
|
@@ -5333,7 +5309,7 @@ function Qs(n) {
|
|
|
5333
5309
|
organizations: c,
|
|
5334
5310
|
start: r * o,
|
|
5335
5311
|
limit: o,
|
|
5336
|
-
length: Number((
|
|
5312
|
+
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
5337
5313
|
};
|
|
5338
5314
|
},
|
|
5339
5315
|
async remove(i, e) {
|
|
@@ -5346,31 +5322,31 @@ function Qs(n) {
|
|
|
5346
5322
|
}
|
|
5347
5323
|
};
|
|
5348
5324
|
}
|
|
5349
|
-
const
|
|
5325
|
+
const Ut = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Js = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
5350
5326
|
function Ps(n) {
|
|
5351
5327
|
return {
|
|
5352
5328
|
async getDaily(i, e) {
|
|
5353
5329
|
const t = /* @__PURE__ */ new Date(), r = (e == null ? void 0 : e.from) || new Date(t.getTime() - 30 * 24 * 60 * 60 * 1e3).toISOString().split("T")[0], o = (e == null ? void 0 : e.to) || t.toISOString().split("T")[0];
|
|
5354
5330
|
return (await n.select({
|
|
5355
|
-
date:
|
|
5356
|
-
logins:
|
|
5357
|
-
|
|
5358
|
-
|
|
5331
|
+
date: N`substr(${T.date}, 1, 10)`.as("date"),
|
|
5332
|
+
logins: N`SUM(CASE WHEN ${T.type} IN (${N.join(
|
|
5333
|
+
Ut.map((_) => N`${_}`),
|
|
5334
|
+
N`, `
|
|
5359
5335
|
)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
5360
|
-
signups:
|
|
5336
|
+
signups: N`SUM(CASE WHEN ${T.type} = 'ss' THEN 1 ELSE 0 END)`.as(
|
|
5361
5337
|
"signups"
|
|
5362
5338
|
),
|
|
5363
|
-
leaked_passwords:
|
|
5364
|
-
Js.map((_) =>
|
|
5365
|
-
|
|
5339
|
+
leaked_passwords: N`SUM(CASE WHEN ${T.type} IN (${N.join(
|
|
5340
|
+
Js.map((_) => N`${_}`),
|
|
5341
|
+
N`, `
|
|
5366
5342
|
)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
5367
|
-
}).from(
|
|
5343
|
+
}).from(T).where(
|
|
5368
5344
|
g(
|
|
5369
|
-
a(
|
|
5370
|
-
He(
|
|
5371
|
-
Oe(
|
|
5345
|
+
a(T.tenant_id, i),
|
|
5346
|
+
He(T.date, r),
|
|
5347
|
+
Oe(T.date, `${o}T23:59:59.999Z`)
|
|
5372
5348
|
)
|
|
5373
|
-
).groupBy(
|
|
5349
|
+
).groupBy(N`substr(${T.date}, 1, 10)`).orderBy(N`substr(${T.date}, 1, 10)`).all()).map((_) => ({
|
|
5374
5350
|
date: _.date,
|
|
5375
5351
|
logins: Number(_.logins) || 0,
|
|
5376
5352
|
signups: Number(_.signups) || 0,
|
|
@@ -5383,14 +5359,14 @@ function Ps(n) {
|
|
|
5383
5359
|
const e = new Date(
|
|
5384
5360
|
Date.now() - 2592e6
|
|
5385
5361
|
).toISOString(), [t] = await n.select({
|
|
5386
|
-
count:
|
|
5387
|
-
}).from(
|
|
5362
|
+
count: N`COUNT(DISTINCT ${T.user_id})`.as("count")
|
|
5363
|
+
}).from(T).where(
|
|
5388
5364
|
g(
|
|
5389
|
-
a(
|
|
5390
|
-
He(
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5365
|
+
a(T.tenant_id, i),
|
|
5366
|
+
He(T.date, e),
|
|
5367
|
+
N`${T.type} IN (${N.join(
|
|
5368
|
+
Ut.map((r) => N`${r}`),
|
|
5369
|
+
N`, `
|
|
5394
5370
|
)})`
|
|
5395
5371
|
)
|
|
5396
5372
|
);
|
|
@@ -5398,17 +5374,17 @@ function Ps(n) {
|
|
|
5398
5374
|
}
|
|
5399
5375
|
};
|
|
5400
5376
|
}
|
|
5401
|
-
function
|
|
5377
|
+
function Kt(n) {
|
|
5402
5378
|
return {
|
|
5403
5379
|
...n,
|
|
5404
|
-
payload:
|
|
5380
|
+
payload: b(n.payload, {})
|
|
5405
5381
|
};
|
|
5406
5382
|
}
|
|
5407
5383
|
function Fs(n) {
|
|
5408
5384
|
return {
|
|
5409
5385
|
async create(i, e) {
|
|
5410
5386
|
const t = ae(), r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5411
|
-
return await n.insert(
|
|
5387
|
+
return await n.insert(x).values({
|
|
5412
5388
|
id: t,
|
|
5413
5389
|
tenant_id: i,
|
|
5414
5390
|
event_type: e.event_type,
|
|
@@ -5426,82 +5402,82 @@ function Fs(n) {
|
|
|
5426
5402
|
}), t;
|
|
5427
5403
|
},
|
|
5428
5404
|
async getByIds(i) {
|
|
5429
|
-
return i.length === 0 ? [] : (await n.select().from(
|
|
5405
|
+
return i.length === 0 ? [] : (await n.select().from(x).where(Ne(x.id, i)).all()).map(Kt);
|
|
5430
5406
|
},
|
|
5431
5407
|
async getUnprocessed(i) {
|
|
5432
5408
|
const e = (/* @__PURE__ */ new Date()).toISOString();
|
|
5433
|
-
return (await n.select().from(
|
|
5409
|
+
return (await n.select().from(x).where(
|
|
5434
5410
|
g(
|
|
5435
|
-
me(
|
|
5411
|
+
me(x.processed_at),
|
|
5436
5412
|
de(
|
|
5437
|
-
me(
|
|
5438
|
-
Oe(
|
|
5413
|
+
me(x.next_retry_at),
|
|
5414
|
+
Oe(x.next_retry_at, e)
|
|
5439
5415
|
),
|
|
5440
5416
|
de(
|
|
5441
|
-
me(
|
|
5442
|
-
Oe(
|
|
5417
|
+
me(x.claimed_by),
|
|
5418
|
+
Oe(x.claim_expires_at, e)
|
|
5443
5419
|
)
|
|
5444
5420
|
)
|
|
5445
|
-
).orderBy(
|
|
5421
|
+
).orderBy(x.created_at, x.id).limit(i).all()).map(Kt);
|
|
5446
5422
|
},
|
|
5447
5423
|
async claimEvents(i, e, t) {
|
|
5448
5424
|
if (i.length === 0) return [];
|
|
5449
5425
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = new Date(Date.now() + t).toISOString();
|
|
5450
|
-
return await n.update(
|
|
5426
|
+
return await n.update(x).set({
|
|
5451
5427
|
claimed_by: e,
|
|
5452
5428
|
claim_expires_at: o
|
|
5453
5429
|
}).where(
|
|
5454
5430
|
g(
|
|
5455
|
-
Ne(
|
|
5456
|
-
me(
|
|
5431
|
+
Ne(x.id, i),
|
|
5432
|
+
me(x.processed_at),
|
|
5457
5433
|
de(
|
|
5458
|
-
me(
|
|
5459
|
-
Oe(
|
|
5434
|
+
me(x.claimed_by),
|
|
5435
|
+
Oe(x.claim_expires_at, r)
|
|
5460
5436
|
)
|
|
5461
5437
|
)
|
|
5462
|
-
), (await n.select({ id:
|
|
5438
|
+
), (await n.select({ id: x.id }).from(x).where(
|
|
5463
5439
|
g(
|
|
5464
|
-
Ne(
|
|
5465
|
-
a(
|
|
5440
|
+
Ne(x.id, i),
|
|
5441
|
+
a(x.claimed_by, e)
|
|
5466
5442
|
)
|
|
5467
5443
|
).all()).map((_) => _.id);
|
|
5468
5444
|
},
|
|
5469
5445
|
async markProcessed(i) {
|
|
5470
|
-
i.length !== 0 && await n.update(
|
|
5446
|
+
i.length !== 0 && await n.update(x).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(Ne(x.id, i));
|
|
5471
5447
|
},
|
|
5472
5448
|
async markRetry(i, e, t) {
|
|
5473
|
-
await n.update(
|
|
5449
|
+
await n.update(x).set({
|
|
5474
5450
|
error: e,
|
|
5475
5451
|
next_retry_at: t,
|
|
5476
|
-
retry_count:
|
|
5452
|
+
retry_count: N`${x.retry_count} + 1`,
|
|
5477
5453
|
claimed_by: null,
|
|
5478
5454
|
claim_expires_at: null
|
|
5479
|
-
}).where(a(
|
|
5455
|
+
}).where(a(x.id, i));
|
|
5480
5456
|
},
|
|
5481
5457
|
async cleanup(i) {
|
|
5482
|
-
return (await n.delete(
|
|
5458
|
+
return (await n.delete(x).where(
|
|
5483
5459
|
g(
|
|
5484
|
-
|
|
5485
|
-
Oe(
|
|
5460
|
+
N`${x.processed_at} IS NOT NULL`,
|
|
5461
|
+
Oe(x.processed_at, i)
|
|
5486
5462
|
)
|
|
5487
5463
|
).returning()).length;
|
|
5488
5464
|
},
|
|
5489
5465
|
async deadLetter(i, e) {
|
|
5490
5466
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
5491
|
-
await n.update(
|
|
5467
|
+
await n.update(x).set({
|
|
5492
5468
|
processed_at: t,
|
|
5493
5469
|
dead_lettered_at: t,
|
|
5494
5470
|
final_error: e
|
|
5495
|
-
}).where(a(
|
|
5471
|
+
}).where(a(x.id, i));
|
|
5496
5472
|
},
|
|
5497
5473
|
async listFailed(i, e = {}) {
|
|
5498
|
-
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(
|
|
5474
|
+
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(x).where(
|
|
5499
5475
|
g(
|
|
5500
|
-
a(
|
|
5501
|
-
Me(
|
|
5476
|
+
a(x.tenant_id, i),
|
|
5477
|
+
Me(x.dead_lettered_at)
|
|
5502
5478
|
)
|
|
5503
|
-
).orderBy(V(
|
|
5504
|
-
...
|
|
5479
|
+
).orderBy(V(x.dead_lettered_at), G(x.id)).offset(t * r).limit(r).all()).map((c) => ({
|
|
5480
|
+
...b(c.payload, {}),
|
|
5505
5481
|
id: c.id,
|
|
5506
5482
|
created_at: c.created_at,
|
|
5507
5483
|
processed_at: c.processed_at,
|
|
@@ -5511,25 +5487,25 @@ function Fs(n) {
|
|
|
5511
5487
|
dead_lettered_at: c.dead_lettered_at,
|
|
5512
5488
|
final_error: c.final_error
|
|
5513
5489
|
}));
|
|
5514
|
-
let
|
|
5490
|
+
let d = _.length;
|
|
5515
5491
|
if (o) {
|
|
5516
|
-
const [c] = await n.select({ total: R() }).from(
|
|
5492
|
+
const [c] = await n.select({ total: R() }).from(x).where(
|
|
5517
5493
|
g(
|
|
5518
|
-
a(
|
|
5519
|
-
Me(
|
|
5494
|
+
a(x.tenant_id, i),
|
|
5495
|
+
Me(x.dead_lettered_at)
|
|
5520
5496
|
)
|
|
5521
5497
|
);
|
|
5522
|
-
|
|
5498
|
+
d = Number((c == null ? void 0 : c.total) ?? _.length);
|
|
5523
5499
|
}
|
|
5524
5500
|
return {
|
|
5525
5501
|
events: _,
|
|
5526
5502
|
start: t * r,
|
|
5527
5503
|
limit: r,
|
|
5528
|
-
length:
|
|
5504
|
+
length: d
|
|
5529
5505
|
};
|
|
5530
5506
|
},
|
|
5531
5507
|
async replay(i, e) {
|
|
5532
|
-
return (await n.update(
|
|
5508
|
+
return (await n.update(x).set({
|
|
5533
5509
|
processed_at: null,
|
|
5534
5510
|
dead_lettered_at: null,
|
|
5535
5511
|
final_error: null,
|
|
@@ -5538,9 +5514,9 @@ function Fs(n) {
|
|
|
5538
5514
|
error: null
|
|
5539
5515
|
}).where(
|
|
5540
5516
|
g(
|
|
5541
|
-
a(
|
|
5542
|
-
a(
|
|
5543
|
-
Me(
|
|
5517
|
+
a(x.id, i),
|
|
5518
|
+
a(x.tenant_id, e),
|
|
5519
|
+
Me(x.dead_lettered_at)
|
|
5544
5520
|
)
|
|
5545
5521
|
).returning()).length > 0;
|
|
5546
5522
|
}
|
|
@@ -5553,16 +5529,16 @@ function Ks(n) {
|
|
|
5553
5529
|
try {
|
|
5554
5530
|
let t = [
|
|
5555
5531
|
de(
|
|
5556
|
-
we(
|
|
5557
|
-
we(
|
|
5532
|
+
we(E.expires_at_ts, e),
|
|
5533
|
+
we(E.idle_expires_at_ts, e)
|
|
5558
5534
|
)
|
|
5559
5535
|
];
|
|
5560
|
-
i != null && i.tenant_id && t.push(a(
|
|
5536
|
+
i != null && i.tenant_id && t.push(a(E.tenant_id, i.tenant_id)), await n.delete(E).where(g(...t)), t = [
|
|
5561
5537
|
de(
|
|
5562
|
-
we(
|
|
5563
|
-
we(
|
|
5538
|
+
we(Q.expires_at_ts, e),
|
|
5539
|
+
we(Q.idle_expires_at_ts, e)
|
|
5564
5540
|
)
|
|
5565
|
-
], i != null && i.tenant_id && t.push(a(
|
|
5541
|
+
], i != null && i.tenant_id && t.push(a(Q.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a(Q.user_id, i.user_id)), await n.delete(Q).where(g(...t)), t = [we(q.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(q.tenant_id, i.tenant_id)), await n.delete(q).where(g(...t));
|
|
5566
5542
|
} catch (t) {
|
|
5567
5543
|
console.error("Session cleanup error:", t);
|
|
5568
5544
|
}
|
|
@@ -5570,29 +5546,29 @@ function Ks(n) {
|
|
|
5570
5546
|
}
|
|
5571
5547
|
function Vs(n, i = { useTransactions: !0 }) {
|
|
5572
5548
|
const e = {
|
|
5573
|
-
actions:
|
|
5574
|
-
branding:
|
|
5575
|
-
clients:
|
|
5576
|
-
clientConnections:
|
|
5577
|
-
clientGrants:
|
|
5578
|
-
codes:
|
|
5579
|
-
connections:
|
|
5580
|
-
customDomains:
|
|
5581
|
-
customText:
|
|
5582
|
-
emailProviders:
|
|
5583
|
-
flows:
|
|
5584
|
-
forms:
|
|
5585
|
-
hookCode:
|
|
5586
|
-
hooks:
|
|
5587
|
-
invites:
|
|
5588
|
-
keys:
|
|
5589
|
-
loginSessions:
|
|
5549
|
+
actions: kr(),
|
|
5550
|
+
branding: Ur(n),
|
|
5551
|
+
clients: Kr(n),
|
|
5552
|
+
clientConnections: Mr(n),
|
|
5553
|
+
clientGrants: Gr(n),
|
|
5554
|
+
codes: Yr(n),
|
|
5555
|
+
connections: Zr(n),
|
|
5556
|
+
customDomains: es(n),
|
|
5557
|
+
customText: ts(n),
|
|
5558
|
+
emailProviders: ns(n),
|
|
5559
|
+
flows: is(n),
|
|
5560
|
+
forms: rs(n),
|
|
5561
|
+
hookCode: as(n),
|
|
5562
|
+
hooks: _s(n),
|
|
5563
|
+
invites: ds(n),
|
|
5564
|
+
keys: cs(n),
|
|
5565
|
+
loginSessions: fs(n),
|
|
5590
5566
|
logs: hs(n),
|
|
5591
|
-
authenticationMethods:
|
|
5592
|
-
organizations:
|
|
5593
|
-
passwords:
|
|
5594
|
-
promptSettings:
|
|
5595
|
-
refreshTokens:
|
|
5567
|
+
authenticationMethods: ms(n),
|
|
5568
|
+
organizations: ws(n),
|
|
5569
|
+
passwords: Ns(n),
|
|
5570
|
+
promptSettings: vs(n),
|
|
5571
|
+
refreshTokens: bs(n),
|
|
5596
5572
|
resourceServers: Ds(n),
|
|
5597
5573
|
rolePermissions: Os(n),
|
|
5598
5574
|
userPermissions: ks(n),
|
|
@@ -5600,8 +5576,8 @@ function Vs(n, i = { useTransactions: !0 }) {
|
|
|
5600
5576
|
sessions: qs(n),
|
|
5601
5577
|
sessionCleanup: Ks(n),
|
|
5602
5578
|
tenants: Ls(n),
|
|
5603
|
-
themes:
|
|
5604
|
-
universalLoginTemplates:
|
|
5579
|
+
themes: As(n),
|
|
5580
|
+
universalLoginTemplates: Cs(n),
|
|
5605
5581
|
users: Bs(n),
|
|
5606
5582
|
userRoles: $s(n),
|
|
5607
5583
|
userOrganizations: Qs(n),
|
|
@@ -5610,12 +5586,12 @@ function Vs(n, i = { useTransactions: !0 }) {
|
|
|
5610
5586
|
async transaction(t) {
|
|
5611
5587
|
if (i.useTransactions === !1)
|
|
5612
5588
|
return t(e);
|
|
5613
|
-
await n.run(
|
|
5589
|
+
await n.run(N`BEGIN`);
|
|
5614
5590
|
try {
|
|
5615
5591
|
const r = await t(e);
|
|
5616
|
-
return await n.run(
|
|
5592
|
+
return await n.run(N`COMMIT`), r;
|
|
5617
5593
|
} catch (r) {
|
|
5618
|
-
throw await n.run(
|
|
5594
|
+
throw await n.run(N`ROLLBACK`), r;
|
|
5619
5595
|
}
|
|
5620
5596
|
}
|
|
5621
5597
|
};
|