@authhero/drizzle 0.36.0 → 0.38.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 +1127 -1130
- package/package.json +2 -2
- package/src/schema/sqlite/users.ts +3 -1
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var yr = Object.defineProperty;
|
|
2
|
-
var wr = (
|
|
3
|
-
var m = (
|
|
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 m = (n, i, e) => wr(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
const v = Symbol.for("drizzle:entityKind");
|
|
5
|
-
function Y(
|
|
6
|
-
if (!
|
|
5
|
+
function Y(n, i) {
|
|
6
|
+
if (!n || typeof n != "object")
|
|
7
7
|
return !1;
|
|
8
|
-
if (
|
|
8
|
+
if (n instanceof i)
|
|
9
9
|
return !0;
|
|
10
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
10
|
+
if (!Object.prototype.hasOwnProperty.call(i, v))
|
|
11
11
|
throw new Error(
|
|
12
|
-
`Class "${
|
|
12
|
+
`Class "${i.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
|
|
13
13
|
);
|
|
14
|
-
let e = Object.getPrototypeOf(
|
|
14
|
+
let e = Object.getPrototypeOf(n).constructor;
|
|
15
15
|
if (e)
|
|
16
16
|
for (; e; ) {
|
|
17
|
-
if (v in e && e[v] ===
|
|
17
|
+
if (v in e && e[v] === i[v])
|
|
18
18
|
return !0;
|
|
19
19
|
e = Object.getPrototypeOf(e);
|
|
20
20
|
}
|
|
@@ -23,7 +23,7 @@ function Y(i, n) {
|
|
|
23
23
|
var jt;
|
|
24
24
|
jt = v;
|
|
25
25
|
class Qe {
|
|
26
|
-
constructor(
|
|
26
|
+
constructor(i, e) {
|
|
27
27
|
m(this, "name");
|
|
28
28
|
m(this, "keyAsName");
|
|
29
29
|
m(this, "primary");
|
|
@@ -41,13 +41,13 @@ class Qe {
|
|
|
41
41
|
m(this, "generated");
|
|
42
42
|
m(this, "generatedIdentity");
|
|
43
43
|
m(this, "config");
|
|
44
|
-
this.table =
|
|
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
|
-
mapFromDriverValue(
|
|
47
|
-
return
|
|
46
|
+
mapFromDriverValue(i) {
|
|
47
|
+
return i;
|
|
48
48
|
}
|
|
49
|
-
mapToDriverValue(
|
|
50
|
-
return
|
|
49
|
+
mapToDriverValue(i) {
|
|
50
|
+
return i;
|
|
51
51
|
}
|
|
52
52
|
// ** @internal */
|
|
53
53
|
shouldDisableInsert() {
|
|
@@ -58,7 +58,7 @@ m(Qe, jt, "Column");
|
|
|
58
58
|
var Mt;
|
|
59
59
|
Mt = v;
|
|
60
60
|
class Ti {
|
|
61
|
-
constructor(
|
|
61
|
+
constructor(i, e, t) {
|
|
62
62
|
m(this, "config");
|
|
63
63
|
/**
|
|
64
64
|
* Alias for {@link $defaultFn}.
|
|
@@ -69,8 +69,8 @@ class Ti {
|
|
|
69
69
|
*/
|
|
70
70
|
m(this, "$onUpdate", this.$onUpdateFn);
|
|
71
71
|
this.config = {
|
|
72
|
-
name:
|
|
73
|
-
keyAsName:
|
|
72
|
+
name: i,
|
|
73
|
+
keyAsName: i === "",
|
|
74
74
|
notNull: !1,
|
|
75
75
|
default: void 0,
|
|
76
76
|
hasDefault: !1,
|
|
@@ -112,8 +112,8 @@ class Ti {
|
|
|
112
112
|
*
|
|
113
113
|
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
114
114
|
*/
|
|
115
|
-
default(
|
|
116
|
-
return this.config.default =
|
|
115
|
+
default(i) {
|
|
116
|
+
return this.config.default = i, this.config.hasDefault = !0, this;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Adds a dynamic default value to the column.
|
|
@@ -121,8 +121,8 @@ class Ti {
|
|
|
121
121
|
*
|
|
122
122
|
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
123
123
|
*/
|
|
124
|
-
$defaultFn(
|
|
125
|
-
return this.config.defaultFn =
|
|
124
|
+
$defaultFn(i) {
|
|
125
|
+
return this.config.defaultFn = i, this.config.hasDefault = !0, this;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Adds a dynamic update value to the column.
|
|
@@ -131,8 +131,8 @@ class Ti {
|
|
|
131
131
|
*
|
|
132
132
|
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
133
133
|
*/
|
|
134
|
-
$onUpdateFn(
|
|
135
|
-
return this.config.onUpdateFn =
|
|
134
|
+
$onUpdateFn(i) {
|
|
135
|
+
return this.config.onUpdateFn = i, this.config.hasDefault = !0, this;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
@@ -143,22 +143,22 @@ class Ti {
|
|
|
143
143
|
return this.config.primaryKey = !0, this.config.notNull = !0, this;
|
|
144
144
|
}
|
|
145
145
|
/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
|
|
146
|
-
setName(
|
|
147
|
-
this.config.name === "" && (this.config.name =
|
|
146
|
+
setName(i) {
|
|
147
|
+
this.config.name === "" && (this.config.name = i);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
m(Ti, Mt, "ColumnBuilder");
|
|
151
151
|
const ze = Symbol.for("drizzle:Name"), Tt = Symbol.for("drizzle:isPgEnum");
|
|
152
|
-
function Nr(
|
|
153
|
-
return !!
|
|
152
|
+
function Nr(n) {
|
|
153
|
+
return !!n && typeof n == "function" && Tt in n && n[Tt] === !0;
|
|
154
154
|
}
|
|
155
155
|
var Vt;
|
|
156
156
|
Vt = v;
|
|
157
157
|
class xt {
|
|
158
|
-
constructor(
|
|
158
|
+
constructor(i, e, t, r = !1, o = []) {
|
|
159
159
|
this._ = {
|
|
160
160
|
brand: "Subquery",
|
|
161
|
-
sql:
|
|
161
|
+
sql: i,
|
|
162
162
|
selectedFields: e,
|
|
163
163
|
alias: t,
|
|
164
164
|
isWith: r,
|
|
@@ -171,14 +171,14 @@ class xt {
|
|
|
171
171
|
}
|
|
172
172
|
m(xt, Vt, "Subquery");
|
|
173
173
|
const vr = {
|
|
174
|
-
startActiveSpan(
|
|
175
|
-
return
|
|
174
|
+
startActiveSpan(n, i) {
|
|
175
|
+
return i();
|
|
176
176
|
}
|
|
177
177
|
}, Ae = Symbol.for("drizzle:ViewBaseConfig"), Ze = Symbol.for("drizzle:Schema"), qt = Symbol.for("drizzle:Columns"), Lt = Symbol.for("drizzle:ExtraConfigColumns"), et = Symbol.for("drizzle:OriginalName"), tt = Symbol.for("drizzle:BaseName"), Re = Symbol.for("drizzle:IsAlias"), Et = Symbol.for("drizzle:ExtraConfigBuilder"), Sr = Symbol.for("drizzle:IsDrizzleTable");
|
|
178
178
|
var Rt, Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn;
|
|
179
179
|
nn = v, tn = ze, en = et, Zt = Ze, Xt = qt, Yt = Lt, Gt = tt, Ht = Re, Wt = Sr, Rt = Et;
|
|
180
180
|
class j {
|
|
181
|
-
constructor(
|
|
181
|
+
constructor(i, e, t) {
|
|
182
182
|
/**
|
|
183
183
|
* @internal
|
|
184
184
|
* Can be changed if the table is aliased.
|
|
@@ -206,7 +206,7 @@ class j {
|
|
|
206
206
|
m(this, Wt, !0);
|
|
207
207
|
/** @internal */
|
|
208
208
|
m(this, Rt);
|
|
209
|
-
this[ze] = this[et] =
|
|
209
|
+
this[ze] = this[et] = i, this[Ze] = e, this[tt] = t;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
m(j, nn, "Table"), /** @internal */
|
|
@@ -220,22 +220,22 @@ m(j, "Symbol", {
|
|
|
220
220
|
IsAlias: Re,
|
|
221
221
|
ExtraConfigBuilder: Et
|
|
222
222
|
});
|
|
223
|
-
function qi(
|
|
224
|
-
return
|
|
223
|
+
function qi(n) {
|
|
224
|
+
return n != null && typeof n.getSQL == "function";
|
|
225
225
|
}
|
|
226
|
-
function br(
|
|
226
|
+
function br(n) {
|
|
227
227
|
var e;
|
|
228
|
-
const
|
|
229
|
-
for (const t of
|
|
230
|
-
|
|
231
|
-
return
|
|
228
|
+
const i = { sql: "", params: [] };
|
|
229
|
+
for (const t of n)
|
|
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
|
+
return i;
|
|
232
232
|
}
|
|
233
233
|
var rn;
|
|
234
234
|
rn = v;
|
|
235
235
|
class X {
|
|
236
|
-
constructor(
|
|
236
|
+
constructor(i) {
|
|
237
237
|
m(this, "value");
|
|
238
|
-
this.value = Array.isArray(
|
|
238
|
+
this.value = Array.isArray(i) ? i : [i];
|
|
239
239
|
}
|
|
240
240
|
getSQL() {
|
|
241
241
|
return new Q([this]);
|
|
@@ -245,14 +245,14 @@ m(X, rn, "StringChunk");
|
|
|
245
245
|
var sn;
|
|
246
246
|
sn = v;
|
|
247
247
|
const De = class De {
|
|
248
|
-
constructor(
|
|
248
|
+
constructor(i) {
|
|
249
249
|
/** @internal */
|
|
250
250
|
m(this, "decoder", Li);
|
|
251
251
|
m(this, "shouldInlineParams", !1);
|
|
252
252
|
/** @internal */
|
|
253
253
|
m(this, "usedTables", []);
|
|
254
|
-
this.queryChunks =
|
|
255
|
-
for (const e of
|
|
254
|
+
this.queryChunks = i;
|
|
255
|
+
for (const e of i)
|
|
256
256
|
if (Y(e, j)) {
|
|
257
257
|
const t = e[j.Symbol.Schema];
|
|
258
258
|
this.usedTables.push(
|
|
@@ -260,19 +260,19 @@ const De = class De {
|
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
append(
|
|
264
|
-
return this.queryChunks.push(...
|
|
263
|
+
append(i) {
|
|
264
|
+
return this.queryChunks.push(...i.queryChunks), this;
|
|
265
265
|
}
|
|
266
|
-
toQuery(
|
|
266
|
+
toQuery(i) {
|
|
267
267
|
return vr.startActiveSpan("drizzle.buildSQL", (e) => {
|
|
268
|
-
const t = this.buildQueryFromSourceParams(this.queryChunks,
|
|
268
|
+
const t = this.buildQueryFromSourceParams(this.queryChunks, i);
|
|
269
269
|
return e == null || e.setAttributes({
|
|
270
270
|
"drizzle.query.text": t.sql,
|
|
271
271
|
"drizzle.query.params": JSON.stringify(t.params)
|
|
272
272
|
}), t;
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
buildQueryFromSourceParams(
|
|
275
|
+
buildQueryFromSourceParams(i, e) {
|
|
276
276
|
const t = Object.assign({}, e, {
|
|
277
277
|
inlineParams: e.inlineParams || this.shouldInlineParams,
|
|
278
278
|
paramStartIndex: e.paramStartIndex || { value: 0 }
|
|
@@ -284,7 +284,7 @@ const De = class De {
|
|
|
284
284
|
inlineParams: d,
|
|
285
285
|
paramStartIndex: c
|
|
286
286
|
} = t;
|
|
287
|
-
return br(
|
|
287
|
+
return br(i.map((u) => {
|
|
288
288
|
var h;
|
|
289
289
|
if (Y(u, X))
|
|
290
290
|
return { sql: u.value.join(""), params: [] };
|
|
@@ -350,27 +350,27 @@ const De = class De {
|
|
|
350
350
|
], t) : d ? { sql: this.mapInlineParam(u, t), params: [] } : { sql: l(c.value++, u), params: [u], typings: ["none"] };
|
|
351
351
|
}));
|
|
352
352
|
}
|
|
353
|
-
mapInlineParam(
|
|
354
|
-
if (
|
|
353
|
+
mapInlineParam(i, { escapeString: e }) {
|
|
354
|
+
if (i === null)
|
|
355
355
|
return "null";
|
|
356
|
-
if (typeof
|
|
357
|
-
return
|
|
358
|
-
if (typeof
|
|
359
|
-
return e(
|
|
360
|
-
if (typeof
|
|
361
|
-
const t =
|
|
362
|
-
return e(t === "[object Object]" ? JSON.stringify(
|
|
356
|
+
if (typeof i == "number" || typeof i == "boolean")
|
|
357
|
+
return i.toString();
|
|
358
|
+
if (typeof i == "string")
|
|
359
|
+
return e(i);
|
|
360
|
+
if (typeof i == "object") {
|
|
361
|
+
const t = i.toString();
|
|
362
|
+
return e(t === "[object Object]" ? JSON.stringify(i) : t);
|
|
363
363
|
}
|
|
364
|
-
throw new Error("Unexpected param value: " +
|
|
364
|
+
throw new Error("Unexpected param value: " + i);
|
|
365
365
|
}
|
|
366
366
|
getSQL() {
|
|
367
367
|
return this;
|
|
368
368
|
}
|
|
369
|
-
as(
|
|
370
|
-
return
|
|
369
|
+
as(i) {
|
|
370
|
+
return i === void 0 ? this : new De.Aliased(this, i);
|
|
371
371
|
}
|
|
372
|
-
mapWith(
|
|
373
|
-
return this.decoder = typeof
|
|
372
|
+
mapWith(i) {
|
|
373
|
+
return this.decoder = typeof i == "function" ? { mapFromDriverValue: i } : i, this;
|
|
374
374
|
}
|
|
375
375
|
inlineParams() {
|
|
376
376
|
return this.shouldInlineParams = !0, this;
|
|
@@ -381,8 +381,8 @@ const De = class De {
|
|
|
381
381
|
* @param condition - Condition to check
|
|
382
382
|
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
383
383
|
*/
|
|
384
|
-
if(
|
|
385
|
-
return
|
|
384
|
+
if(i) {
|
|
385
|
+
return i ? this : void 0;
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
m(De, sn, "SQL");
|
|
@@ -390,22 +390,22 @@ let Q = De;
|
|
|
390
390
|
var on;
|
|
391
391
|
on = v;
|
|
392
392
|
class We {
|
|
393
|
-
constructor(
|
|
393
|
+
constructor(i) {
|
|
394
394
|
m(this, "brand");
|
|
395
|
-
this.value =
|
|
395
|
+
this.value = i;
|
|
396
396
|
}
|
|
397
397
|
getSQL() {
|
|
398
398
|
return new Q([this]);
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
m(We, on, "Name");
|
|
402
|
-
function xr(
|
|
403
|
-
return typeof
|
|
402
|
+
function xr(n) {
|
|
403
|
+
return typeof n == "object" && n !== null && "mapToDriverValue" in n && typeof n.mapToDriverValue == "function";
|
|
404
404
|
}
|
|
405
405
|
const Li = {
|
|
406
|
-
mapFromDriverValue: (
|
|
406
|
+
mapFromDriverValue: (n) => n
|
|
407
407
|
}, Ei = {
|
|
408
|
-
mapToDriverValue: (
|
|
408
|
+
mapToDriverValue: (n) => n
|
|
409
409
|
};
|
|
410
410
|
({
|
|
411
411
|
...Li,
|
|
@@ -418,56 +418,56 @@ class Ce {
|
|
|
418
418
|
* @param value - Parameter value
|
|
419
419
|
* @param encoder - Encoder to convert the value to a driver parameter
|
|
420
420
|
*/
|
|
421
|
-
constructor(
|
|
421
|
+
constructor(i, e = Ei) {
|
|
422
422
|
m(this, "brand");
|
|
423
|
-
this.value =
|
|
423
|
+
this.value = i, this.encoder = e;
|
|
424
424
|
}
|
|
425
425
|
getSQL() {
|
|
426
426
|
return new Q([this]);
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
m(Ce, an, "Param");
|
|
430
|
-
function N(
|
|
430
|
+
function N(n, ...i) {
|
|
431
431
|
const e = [];
|
|
432
|
-
(
|
|
433
|
-
for (const [t, r] of
|
|
434
|
-
e.push(r, new X(
|
|
432
|
+
(i.length > 0 || n.length > 0 && n[0] !== "") && e.push(new X(n[0]));
|
|
433
|
+
for (const [t, r] of i.entries())
|
|
434
|
+
e.push(r, new X(n[t + 1]));
|
|
435
435
|
return new Q(e);
|
|
436
436
|
}
|
|
437
|
-
((
|
|
438
|
-
function
|
|
437
|
+
((n) => {
|
|
438
|
+
function i() {
|
|
439
439
|
return new Q([]);
|
|
440
440
|
}
|
|
441
|
-
|
|
441
|
+
n.empty = i;
|
|
442
442
|
function e(d) {
|
|
443
443
|
return new Q(d);
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
n.fromList = e;
|
|
446
446
|
function t(d) {
|
|
447
447
|
return new Q([new X(d)]);
|
|
448
448
|
}
|
|
449
|
-
|
|
449
|
+
n.raw = t;
|
|
450
450
|
function r(d, c) {
|
|
451
451
|
const u = [];
|
|
452
452
|
for (const [h, f] of d.entries())
|
|
453
453
|
h > 0 && c !== void 0 && u.push(c), u.push(f);
|
|
454
454
|
return new Q(u);
|
|
455
455
|
}
|
|
456
|
-
|
|
456
|
+
n.join = r;
|
|
457
457
|
function o(d) {
|
|
458
458
|
return new We(d);
|
|
459
459
|
}
|
|
460
|
-
|
|
460
|
+
n.identifier = o;
|
|
461
461
|
function l(d) {
|
|
462
462
|
return new $e(d);
|
|
463
463
|
}
|
|
464
|
-
|
|
464
|
+
n.placeholder = l;
|
|
465
465
|
function _(d, c) {
|
|
466
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 {
|
|
@@ -485,14 +485,14 @@ function N(i, ...n) {
|
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
m(t, e, "SQL.Aliased");
|
|
488
|
-
let
|
|
489
|
-
|
|
488
|
+
let i = t;
|
|
489
|
+
n.Aliased = i;
|
|
490
490
|
})(Q || (Q = {}));
|
|
491
491
|
var ln;
|
|
492
492
|
ln = v;
|
|
493
493
|
class $e {
|
|
494
|
-
constructor(
|
|
495
|
-
this.name =
|
|
494
|
+
constructor(i) {
|
|
495
|
+
this.name = i;
|
|
496
496
|
}
|
|
497
497
|
getSQL() {
|
|
498
498
|
return new Q([this]);
|
|
@@ -503,14 +503,14 @@ const Dr = Symbol.for("drizzle:IsDrizzleView");
|
|
|
503
503
|
var _n, un, dn;
|
|
504
504
|
dn = v, un = Ae, _n = Dr;
|
|
505
505
|
class Dt {
|
|
506
|
-
constructor({ name:
|
|
506
|
+
constructor({ name: i, schema: e, selectedFields: t, query: r }) {
|
|
507
507
|
/** @internal */
|
|
508
508
|
m(this, un);
|
|
509
509
|
/** @internal */
|
|
510
510
|
m(this, _n, !0);
|
|
511
511
|
this[Ae] = {
|
|
512
|
-
name:
|
|
513
|
-
originalName:
|
|
512
|
+
name: i,
|
|
513
|
+
originalName: i,
|
|
514
514
|
schema: e,
|
|
515
515
|
selectedFields: t,
|
|
516
516
|
query: r,
|
|
@@ -532,79 +532,79 @@ j.prototype.getSQL = function() {
|
|
|
532
532
|
xt.prototype.getSQL = function() {
|
|
533
533
|
return new Q([this]);
|
|
534
534
|
};
|
|
535
|
-
function Je(
|
|
535
|
+
function Je(n, i) {
|
|
536
536
|
return {
|
|
537
|
-
name: typeof
|
|
538
|
-
config: typeof
|
|
537
|
+
name: typeof n == "string" && n.length > 0 ? n : "",
|
|
538
|
+
config: typeof n == "object" ? n : i
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
const Ai = typeof TextDecoder > "u" ? null : new TextDecoder();
|
|
542
|
-
function Se(
|
|
543
|
-
return xr(
|
|
542
|
+
function Se(n, i) {
|
|
543
|
+
return xr(i) && !qi(n) && !Y(n, Ce) && !Y(n, $e) && !Y(n, Qe) && !Y(n, j) && !Y(n, Dt) ? new Ce(n, i) : n;
|
|
544
544
|
}
|
|
545
|
-
const a = (
|
|
546
|
-
function g(...
|
|
547
|
-
const
|
|
545
|
+
const a = (n, i) => N`${n} = ${Se(i, n)}`, Or = (n, i) => N`${n} <> ${Se(i, n)}`;
|
|
546
|
+
function g(...n) {
|
|
547
|
+
const i = n.filter(
|
|
548
548
|
(e) => e !== void 0
|
|
549
549
|
);
|
|
550
|
-
if (
|
|
551
|
-
return
|
|
550
|
+
if (i.length !== 0)
|
|
551
|
+
return i.length === 1 ? new Q(i) : new Q([
|
|
552
552
|
new X("("),
|
|
553
|
-
N.join(
|
|
553
|
+
N.join(i, new X(" and ")),
|
|
554
554
|
new X(")")
|
|
555
555
|
]);
|
|
556
556
|
}
|
|
557
|
-
function de(...
|
|
558
|
-
const
|
|
557
|
+
function de(...n) {
|
|
558
|
+
const i = n.filter(
|
|
559
559
|
(e) => e !== void 0
|
|
560
560
|
);
|
|
561
|
-
if (
|
|
562
|
-
return
|
|
561
|
+
if (i.length !== 0)
|
|
562
|
+
return i.length === 1 ? new Q(i) : new Q([
|
|
563
563
|
new X("("),
|
|
564
|
-
N.join(
|
|
564
|
+
N.join(i, new X(" or ")),
|
|
565
565
|
new X(")")
|
|
566
566
|
]);
|
|
567
567
|
}
|
|
568
|
-
const He = (
|
|
569
|
-
function we(
|
|
570
|
-
return Array.isArray(
|
|
568
|
+
const He = (n, i) => N`${n} > ${Se(i, n)}`, Ge = (n, i) => N`${n} >= ${Se(i, n)}`, xe = (n, i) => N`${n} < ${Se(i, n)}`, Oe = (n, i) => N`${n} <= ${Se(i, n)}`;
|
|
569
|
+
function we(n, i) {
|
|
570
|
+
return Array.isArray(i) ? i.length === 0 ? N`false` : N`${n} in ${i.map((e) => Se(e, n))}` : N`${n} in ${Se(i, n)}`;
|
|
571
571
|
}
|
|
572
|
-
function ye(
|
|
573
|
-
return N`${
|
|
572
|
+
function ye(n) {
|
|
573
|
+
return N`${n} is null`;
|
|
574
574
|
}
|
|
575
|
-
function Ve(
|
|
576
|
-
return N`${
|
|
575
|
+
function Ve(n) {
|
|
576
|
+
return N`${n} is not null`;
|
|
577
577
|
}
|
|
578
|
-
function Ie(
|
|
579
|
-
return N`${
|
|
578
|
+
function Ie(n, i) {
|
|
579
|
+
return N`${n} like ${i}`;
|
|
580
580
|
}
|
|
581
|
-
function H(
|
|
582
|
-
return N`${
|
|
581
|
+
function H(n) {
|
|
582
|
+
return N`${n} asc`;
|
|
583
583
|
}
|
|
584
|
-
function M(
|
|
585
|
-
return N`${
|
|
584
|
+
function M(n) {
|
|
585
|
+
return N`${n} desc`;
|
|
586
586
|
}
|
|
587
|
-
function V(
|
|
587
|
+
function V(n) {
|
|
588
588
|
return N`count(${N.raw("*")})`.mapWith(Number);
|
|
589
589
|
}
|
|
590
590
|
function kr() {
|
|
591
|
-
const
|
|
591
|
+
const n = (i) => {
|
|
592
592
|
throw new Error(
|
|
593
|
-
`Actions are not implemented in the Drizzle adapter (called ${
|
|
593
|
+
`Actions are not implemented in the Drizzle adapter (called ${i}). Use the Kysely adapter for tenants that require actions.`
|
|
594
594
|
);
|
|
595
595
|
};
|
|
596
596
|
return {
|
|
597
|
-
create: () =>
|
|
598
|
-
get: () =>
|
|
599
|
-
list: () =>
|
|
600
|
-
update: () =>
|
|
601
|
-
remove: () =>
|
|
597
|
+
create: () => n("create"),
|
|
598
|
+
get: () => n("get"),
|
|
599
|
+
list: () => n("list"),
|
|
600
|
+
update: () => n("update"),
|
|
601
|
+
remove: () => n("remove")
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
var cn;
|
|
605
605
|
cn = v;
|
|
606
606
|
class Ci {
|
|
607
|
-
constructor(
|
|
607
|
+
constructor(i, e) {
|
|
608
608
|
/** @internal */
|
|
609
609
|
m(this, "reference");
|
|
610
610
|
/** @internal */
|
|
@@ -612,44 +612,44 @@ class Ci {
|
|
|
612
612
|
/** @internal */
|
|
613
613
|
m(this, "_onDelete");
|
|
614
614
|
this.reference = () => {
|
|
615
|
-
const { name: t, columns: r, foreignColumns: o } =
|
|
615
|
+
const { name: t, columns: r, foreignColumns: o } = i();
|
|
616
616
|
return { name: t, columns: r, foreignTable: o[0].table, foreignColumns: o };
|
|
617
617
|
}, e && (this._onUpdate = e.onUpdate, this._onDelete = e.onDelete);
|
|
618
618
|
}
|
|
619
|
-
onUpdate(
|
|
620
|
-
return this._onUpdate =
|
|
619
|
+
onUpdate(i) {
|
|
620
|
+
return this._onUpdate = i, this;
|
|
621
621
|
}
|
|
622
|
-
onDelete(
|
|
623
|
-
return this._onDelete =
|
|
622
|
+
onDelete(i) {
|
|
623
|
+
return this._onDelete = i, this;
|
|
624
624
|
}
|
|
625
625
|
/** @internal */
|
|
626
|
-
build(
|
|
627
|
-
return new $i(
|
|
626
|
+
build(i) {
|
|
627
|
+
return new $i(i, this);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
m(Ci, cn, "SQLiteForeignKeyBuilder");
|
|
631
631
|
var gn;
|
|
632
632
|
gn = v;
|
|
633
633
|
class $i {
|
|
634
|
-
constructor(
|
|
634
|
+
constructor(i, e) {
|
|
635
635
|
m(this, "reference");
|
|
636
636
|
m(this, "onUpdate");
|
|
637
637
|
m(this, "onDelete");
|
|
638
|
-
this.table =
|
|
638
|
+
this.table = i, this.reference = e.reference, this.onUpdate = e._onUpdate, this.onDelete = e._onDelete;
|
|
639
639
|
}
|
|
640
640
|
getName() {
|
|
641
|
-
const { name:
|
|
641
|
+
const { name: i, columns: e, foreignColumns: t } = this.reference(), r = e.map((_) => _.name), o = t.map((_) => _.name), l = [
|
|
642
642
|
this.table[ze],
|
|
643
643
|
...r,
|
|
644
644
|
t[0].table[ze],
|
|
645
645
|
...o
|
|
646
646
|
];
|
|
647
|
-
return
|
|
647
|
+
return i ?? `${l.join("_")}_fk`;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
m($i, gn, "SQLiteForeignKey");
|
|
651
|
-
function Ir(
|
|
652
|
-
return `${
|
|
651
|
+
function Ir(n, i) {
|
|
652
|
+
return `${n[ze]}_${i.join("_")}_unique`;
|
|
653
653
|
}
|
|
654
654
|
var fn, mn;
|
|
655
655
|
class ce extends (mn = Ti, fn = v, mn) {
|
|
@@ -684,19 +684,19 @@ class ce extends (mn = Ti, fn = v, mn) {
|
|
|
684
684
|
m(ce, fn, "SQLiteColumnBuilder");
|
|
685
685
|
var hn, pn;
|
|
686
686
|
class ge extends (pn = Qe, hn = v, pn) {
|
|
687
|
-
constructor(
|
|
688
|
-
e.uniqueName || (e.uniqueName = Ir(
|
|
687
|
+
constructor(i, e) {
|
|
688
|
+
e.uniqueName || (e.uniqueName = Ir(i, [e.name])), super(i, e), this.table = i;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
m(ge, hn, "SQLiteColumn");
|
|
692
692
|
var yn, wn;
|
|
693
693
|
class Bi extends (wn = ce, yn = v, wn) {
|
|
694
|
-
constructor(
|
|
695
|
-
super(
|
|
694
|
+
constructor(i) {
|
|
695
|
+
super(i, "bigint", "SQLiteBigInt");
|
|
696
696
|
}
|
|
697
697
|
/** @internal */
|
|
698
|
-
build(
|
|
699
|
-
return new Pi(
|
|
698
|
+
build(i) {
|
|
699
|
+
return new Pi(i, this.config);
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
702
|
m(Bi, yn, "SQLiteBigIntBuilder");
|
|
@@ -705,27 +705,27 @@ class Pi extends (vn = ge, Nn = v, vn) {
|
|
|
705
705
|
getSQLType() {
|
|
706
706
|
return "blob";
|
|
707
707
|
}
|
|
708
|
-
mapFromDriverValue(
|
|
708
|
+
mapFromDriverValue(i) {
|
|
709
709
|
if (typeof Buffer < "u" && Buffer.from) {
|
|
710
|
-
const e = Buffer.isBuffer(
|
|
710
|
+
const e = Buffer.isBuffer(i) ? i : i instanceof ArrayBuffer ? Buffer.from(i) : i.buffer ? Buffer.from(i.buffer, i.byteOffset, i.byteLength) : Buffer.from(i);
|
|
711
711
|
return BigInt(e.toString("utf8"));
|
|
712
712
|
}
|
|
713
|
-
return BigInt(Ai.decode(
|
|
713
|
+
return BigInt(Ai.decode(i));
|
|
714
714
|
}
|
|
715
|
-
mapToDriverValue(
|
|
716
|
-
return Buffer.from(
|
|
715
|
+
mapToDriverValue(i) {
|
|
716
|
+
return Buffer.from(i.toString());
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
m(Pi, Nn, "SQLiteBigInt");
|
|
720
720
|
var Sn, bn;
|
|
721
721
|
class Qi extends (bn = ce, Sn = v, bn) {
|
|
722
|
-
constructor(
|
|
723
|
-
super(
|
|
722
|
+
constructor(i) {
|
|
723
|
+
super(i, "json", "SQLiteBlobJson");
|
|
724
724
|
}
|
|
725
725
|
/** @internal */
|
|
726
|
-
build(
|
|
726
|
+
build(i) {
|
|
727
727
|
return new Ji(
|
|
728
|
-
|
|
728
|
+
i,
|
|
729
729
|
this.config
|
|
730
730
|
);
|
|
731
731
|
}
|
|
@@ -736,52 +736,52 @@ class Ji extends (Dn = ge, xn = v, Dn) {
|
|
|
736
736
|
getSQLType() {
|
|
737
737
|
return "blob";
|
|
738
738
|
}
|
|
739
|
-
mapFromDriverValue(
|
|
739
|
+
mapFromDriverValue(i) {
|
|
740
740
|
if (typeof Buffer < "u" && Buffer.from) {
|
|
741
|
-
const e = Buffer.isBuffer(
|
|
741
|
+
const e = Buffer.isBuffer(i) ? i : i instanceof ArrayBuffer ? Buffer.from(i) : i.buffer ? Buffer.from(i.buffer, i.byteOffset, i.byteLength) : Buffer.from(i);
|
|
742
742
|
return JSON.parse(e.toString("utf8"));
|
|
743
743
|
}
|
|
744
|
-
return JSON.parse(Ai.decode(
|
|
744
|
+
return JSON.parse(Ai.decode(i));
|
|
745
745
|
}
|
|
746
|
-
mapToDriverValue(
|
|
747
|
-
return Buffer.from(JSON.stringify(
|
|
746
|
+
mapToDriverValue(i) {
|
|
747
|
+
return Buffer.from(JSON.stringify(i));
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
750
|
m(Ji, xn, "SQLiteBlobJson");
|
|
751
751
|
var On, kn;
|
|
752
752
|
class Fi extends (kn = ce, On = v, kn) {
|
|
753
|
-
constructor(
|
|
754
|
-
super(
|
|
753
|
+
constructor(i) {
|
|
754
|
+
super(i, "buffer", "SQLiteBlobBuffer");
|
|
755
755
|
}
|
|
756
756
|
/** @internal */
|
|
757
|
-
build(
|
|
758
|
-
return new Ui(
|
|
757
|
+
build(i) {
|
|
758
|
+
return new Ui(i, this.config);
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
m(Fi, On, "SQLiteBlobBufferBuilder");
|
|
762
762
|
var In, zn;
|
|
763
763
|
class Ui extends (zn = ge, In = v, zn) {
|
|
764
|
-
mapFromDriverValue(
|
|
765
|
-
return Buffer.isBuffer(
|
|
764
|
+
mapFromDriverValue(i) {
|
|
765
|
+
return Buffer.isBuffer(i) ? i : Buffer.from(i);
|
|
766
766
|
}
|
|
767
767
|
getSQLType() {
|
|
768
768
|
return "blob";
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
m(Ui, In, "SQLiteBlobBuffer");
|
|
772
|
-
function zr(
|
|
773
|
-
const { name: e, config: t } = Je(
|
|
772
|
+
function zr(n, i) {
|
|
773
|
+
const { name: e, config: t } = Je(n, i);
|
|
774
774
|
return (t == null ? void 0 : t.mode) === "json" ? new Qi(e) : (t == null ? void 0 : t.mode) === "bigint" ? new Bi(e) : new Fi(e);
|
|
775
775
|
}
|
|
776
776
|
var Tn, qn;
|
|
777
777
|
class Ki extends (qn = ce, Tn = v, qn) {
|
|
778
|
-
constructor(
|
|
779
|
-
super(
|
|
778
|
+
constructor(i, e, t) {
|
|
779
|
+
super(i, "custom", "SQLiteCustomColumn"), this.config.fieldConfig = e, this.config.customTypeParams = t;
|
|
780
780
|
}
|
|
781
781
|
/** @internal */
|
|
782
|
-
build(
|
|
782
|
+
build(i) {
|
|
783
783
|
return new ji(
|
|
784
|
-
|
|
784
|
+
i,
|
|
785
785
|
this.config
|
|
786
786
|
);
|
|
787
787
|
}
|
|
@@ -807,23 +807,23 @@ class ji extends (En = ge, Ln = v, En) {
|
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
m(ji, Ln, "SQLiteCustomColumn");
|
|
810
|
-
function Tr(
|
|
811
|
-
return (
|
|
812
|
-
const { name: t, config: r } = Je(
|
|
810
|
+
function Tr(n) {
|
|
811
|
+
return (i, e) => {
|
|
812
|
+
const { name: t, config: r } = Je(i, e);
|
|
813
813
|
return new Ki(
|
|
814
814
|
t,
|
|
815
815
|
r,
|
|
816
|
-
|
|
816
|
+
n
|
|
817
817
|
);
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
820
|
var An, Cn;
|
|
821
821
|
class Ye extends (Cn = ce, An = v, Cn) {
|
|
822
|
-
constructor(
|
|
823
|
-
super(
|
|
822
|
+
constructor(i, e, t) {
|
|
823
|
+
super(i, e, t), this.config.autoIncrement = !1;
|
|
824
824
|
}
|
|
825
|
-
primaryKey(
|
|
826
|
-
return
|
|
825
|
+
primaryKey(i) {
|
|
826
|
+
return i != null && i.autoIncrement && (this.config.autoIncrement = !0), this.config.hasDefault = !0, super.primaryKey();
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
m(Ye, An, "SQLiteBaseIntegerBuilder");
|
|
@@ -840,12 +840,12 @@ class Xe extends (Bn = ge, $n = v, Bn) {
|
|
|
840
840
|
m(Xe, $n, "SQLiteBaseInteger");
|
|
841
841
|
var Pn, Qn;
|
|
842
842
|
class Mi extends (Qn = Ye, Pn = v, Qn) {
|
|
843
|
-
constructor(
|
|
844
|
-
super(
|
|
843
|
+
constructor(i) {
|
|
844
|
+
super(i, "number", "SQLiteInteger");
|
|
845
845
|
}
|
|
846
|
-
build(
|
|
846
|
+
build(i) {
|
|
847
847
|
return new Vi(
|
|
848
|
-
|
|
848
|
+
i,
|
|
849
849
|
this.config
|
|
850
850
|
);
|
|
851
851
|
}
|
|
@@ -857,8 +857,8 @@ class Vi extends (Fn = Xe, Jn = v, Fn) {
|
|
|
857
857
|
m(Vi, Jn, "SQLiteInteger");
|
|
858
858
|
var Un, Kn;
|
|
859
859
|
class Ri extends (Kn = Ye, Un = v, Kn) {
|
|
860
|
-
constructor(
|
|
861
|
-
super(
|
|
860
|
+
constructor(i, e) {
|
|
861
|
+
super(i, "date", "SQLiteTimestamp"), this.config.mode = e;
|
|
862
862
|
}
|
|
863
863
|
/**
|
|
864
864
|
* @deprecated Use `default()` with your own expression instead.
|
|
@@ -868,9 +868,9 @@ class Ri extends (Kn = Ye, Un = v, Kn) {
|
|
|
868
868
|
defaultNow() {
|
|
869
869
|
return this.default(N`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
|
|
870
870
|
}
|
|
871
|
-
build(
|
|
871
|
+
build(i) {
|
|
872
872
|
return new Wi(
|
|
873
|
-
|
|
873
|
+
i,
|
|
874
874
|
this.config
|
|
875
875
|
);
|
|
876
876
|
}
|
|
@@ -893,12 +893,12 @@ class Wi extends (Mn = Xe, jn = v, Mn) {
|
|
|
893
893
|
m(Wi, jn, "SQLiteTimestamp");
|
|
894
894
|
var Vn, Rn;
|
|
895
895
|
class Hi extends (Rn = Ye, Vn = v, Rn) {
|
|
896
|
-
constructor(
|
|
897
|
-
super(
|
|
896
|
+
constructor(i, e) {
|
|
897
|
+
super(i, "boolean", "SQLiteBoolean"), this.config.mode = e;
|
|
898
898
|
}
|
|
899
|
-
build(
|
|
899
|
+
build(i) {
|
|
900
900
|
return new Gi(
|
|
901
|
-
|
|
901
|
+
i,
|
|
902
902
|
this.config
|
|
903
903
|
);
|
|
904
904
|
}
|
|
@@ -918,19 +918,19 @@ class Gi extends (Hn = Xe, Wn = v, Hn) {
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
m(Gi, Wn, "SQLiteBoolean");
|
|
921
|
-
function p(
|
|
922
|
-
const { name: e, config: t } = Je(
|
|
921
|
+
function p(n, i) {
|
|
922
|
+
const { name: e, config: t } = Je(n, i);
|
|
923
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
925
|
var Gn, Yn;
|
|
926
926
|
class Yi extends (Yn = ce, Gn = v, Yn) {
|
|
927
|
-
constructor(
|
|
928
|
-
super(
|
|
927
|
+
constructor(i) {
|
|
928
|
+
super(i, "string", "SQLiteNumeric");
|
|
929
929
|
}
|
|
930
930
|
/** @internal */
|
|
931
|
-
build(
|
|
931
|
+
build(i) {
|
|
932
932
|
return new Xi(
|
|
933
|
-
|
|
933
|
+
i,
|
|
934
934
|
this.config
|
|
935
935
|
);
|
|
936
936
|
}
|
|
@@ -938,8 +938,8 @@ class Yi extends (Yn = ce, Gn = v, Yn) {
|
|
|
938
938
|
m(Yi, Gn, "SQLiteNumericBuilder");
|
|
939
939
|
var Xn, Zn;
|
|
940
940
|
class Xi extends (Zn = ge, Xn = v, Zn) {
|
|
941
|
-
mapFromDriverValue(
|
|
942
|
-
return typeof
|
|
941
|
+
mapFromDriverValue(i) {
|
|
942
|
+
return typeof i == "string" ? i : String(i);
|
|
943
943
|
}
|
|
944
944
|
getSQLType() {
|
|
945
945
|
return "numeric";
|
|
@@ -948,13 +948,13 @@ class Xi extends (Zn = ge, Xn = v, Zn) {
|
|
|
948
948
|
m(Xi, Xn, "SQLiteNumeric");
|
|
949
949
|
var ei, ti;
|
|
950
950
|
class Zi extends (ti = ce, ei = v, ti) {
|
|
951
|
-
constructor(
|
|
952
|
-
super(
|
|
951
|
+
constructor(i) {
|
|
952
|
+
super(i, "number", "SQLiteNumericNumber");
|
|
953
953
|
}
|
|
954
954
|
/** @internal */
|
|
955
|
-
build(
|
|
955
|
+
build(i) {
|
|
956
956
|
return new er(
|
|
957
|
-
|
|
957
|
+
i,
|
|
958
958
|
this.config
|
|
959
959
|
);
|
|
960
960
|
}
|
|
@@ -976,13 +976,13 @@ class er extends (ii = ge, ni = v, ii) {
|
|
|
976
976
|
m(er, ni, "SQLiteNumericNumber");
|
|
977
977
|
var ri, si;
|
|
978
978
|
class tr extends (si = ce, ri = v, si) {
|
|
979
|
-
constructor(
|
|
980
|
-
super(
|
|
979
|
+
constructor(i) {
|
|
980
|
+
super(i, "bigint", "SQLiteNumericBigInt");
|
|
981
981
|
}
|
|
982
982
|
/** @internal */
|
|
983
|
-
build(
|
|
983
|
+
build(i) {
|
|
984
984
|
return new nr(
|
|
985
|
-
|
|
985
|
+
i,
|
|
986
986
|
this.config
|
|
987
987
|
);
|
|
988
988
|
}
|
|
@@ -1000,18 +1000,18 @@ class nr extends (ai = ge, oi = v, ai) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
m(nr, oi, "SQLiteNumericBigInt");
|
|
1003
|
-
function qr(
|
|
1004
|
-
const { name: e, config: t } = Je(
|
|
1003
|
+
function qr(n, i) {
|
|
1004
|
+
const { name: e, config: t } = Je(n, i), r = t == null ? void 0 : t.mode;
|
|
1005
1005
|
return r === "number" ? new Zi(e) : r === "bigint" ? new tr(e) : new Yi(e);
|
|
1006
1006
|
}
|
|
1007
1007
|
var li, _i;
|
|
1008
1008
|
class ir extends (_i = ce, li = v, _i) {
|
|
1009
|
-
constructor(
|
|
1010
|
-
super(
|
|
1009
|
+
constructor(i) {
|
|
1010
|
+
super(i, "number", "SQLiteReal");
|
|
1011
1011
|
}
|
|
1012
1012
|
/** @internal */
|
|
1013
|
-
build(
|
|
1014
|
-
return new rr(
|
|
1013
|
+
build(i) {
|
|
1014
|
+
return new rr(i, this.config);
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
1017
|
m(ir, li, "SQLiteRealBuilder");
|
|
@@ -1022,18 +1022,18 @@ class rr extends (di = ge, ui = v, di) {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
}
|
|
1024
1024
|
m(rr, ui, "SQLiteReal");
|
|
1025
|
-
function Lr(
|
|
1026
|
-
return new ir(
|
|
1025
|
+
function Lr(n) {
|
|
1026
|
+
return new ir(n ?? "");
|
|
1027
1027
|
}
|
|
1028
1028
|
var ci, gi;
|
|
1029
1029
|
class sr extends (gi = ce, ci = v, gi) {
|
|
1030
|
-
constructor(
|
|
1031
|
-
super(
|
|
1030
|
+
constructor(i, e) {
|
|
1031
|
+
super(i, "string", "SQLiteText"), this.config.enumValues = e.enum, this.config.length = e.length;
|
|
1032
1032
|
}
|
|
1033
1033
|
/** @internal */
|
|
1034
|
-
build(
|
|
1034
|
+
build(i) {
|
|
1035
1035
|
return new or(
|
|
1036
|
-
|
|
1036
|
+
i,
|
|
1037
1037
|
this.config
|
|
1038
1038
|
);
|
|
1039
1039
|
}
|
|
@@ -1053,13 +1053,13 @@ class or extends (mi = ge, fi = v, mi) {
|
|
|
1053
1053
|
m(or, fi, "SQLiteText");
|
|
1054
1054
|
var hi, pi;
|
|
1055
1055
|
class ar extends (pi = ce, hi = v, pi) {
|
|
1056
|
-
constructor(
|
|
1057
|
-
super(
|
|
1056
|
+
constructor(i) {
|
|
1057
|
+
super(i, "json", "SQLiteTextJson");
|
|
1058
1058
|
}
|
|
1059
1059
|
/** @internal */
|
|
1060
|
-
build(
|
|
1060
|
+
build(i) {
|
|
1061
1061
|
return new lr(
|
|
1062
|
-
|
|
1062
|
+
i,
|
|
1063
1063
|
this.config
|
|
1064
1064
|
);
|
|
1065
1065
|
}
|
|
@@ -1070,16 +1070,16 @@ class lr extends (wi = ge, yi = v, wi) {
|
|
|
1070
1070
|
getSQLType() {
|
|
1071
1071
|
return "text";
|
|
1072
1072
|
}
|
|
1073
|
-
mapFromDriverValue(
|
|
1074
|
-
return JSON.parse(
|
|
1073
|
+
mapFromDriverValue(i) {
|
|
1074
|
+
return JSON.parse(i);
|
|
1075
1075
|
}
|
|
1076
|
-
mapToDriverValue(
|
|
1077
|
-
return JSON.stringify(
|
|
1076
|
+
mapToDriverValue(i) {
|
|
1077
|
+
return JSON.stringify(i);
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
1080
|
m(lr, yi, "SQLiteTextJson");
|
|
1081
|
-
function s(
|
|
1082
|
-
const { name: e, config: t } = Je(
|
|
1081
|
+
function s(n, i = {}) {
|
|
1082
|
+
const { name: e, config: t } = Je(n, i);
|
|
1083
1083
|
return t.mode === "json" ? new ar(e) : new sr(e, t);
|
|
1084
1084
|
}
|
|
1085
1085
|
function Er() {
|
|
@@ -1109,8 +1109,8 @@ m(Be, bi, "SQLiteTable"), /** @internal */
|
|
|
1109
1109
|
m(Be, "Symbol", Object.assign({}, j.Symbol, {
|
|
1110
1110
|
InlineForeignKeys: pt
|
|
1111
1111
|
}));
|
|
1112
|
-
function Ar(
|
|
1113
|
-
const o = new Be(
|
|
1112
|
+
function Ar(n, i, e, t, r = n) {
|
|
1113
|
+
const o = new Be(n, t, r), l = typeof i == "function" ? i(Er()) : i, _ = Object.fromEntries(
|
|
1114
1114
|
Object.entries(l).map(([c, u]) => {
|
|
1115
1115
|
const h = u;
|
|
1116
1116
|
h.setName(c);
|
|
@@ -1120,26 +1120,26 @@ function Ar(i, n, e, t, r = i) {
|
|
|
1120
1120
|
), d = Object.assign(o, _);
|
|
1121
1121
|
return d[j.Symbol.Columns] = _, d[j.Symbol.ExtraConfigColumns] = _, e && (d[Be.Symbol.ExtraConfigBuilder] = e), d;
|
|
1122
1122
|
}
|
|
1123
|
-
const O = (
|
|
1123
|
+
const O = (n, i, e) => Ar(n, i, e);
|
|
1124
1124
|
var Di;
|
|
1125
1125
|
Di = v;
|
|
1126
1126
|
class Ot {
|
|
1127
|
-
constructor(
|
|
1128
|
-
this.name =
|
|
1127
|
+
constructor(i, e) {
|
|
1128
|
+
this.name = i, this.unique = e;
|
|
1129
1129
|
}
|
|
1130
|
-
on(...
|
|
1131
|
-
return new _r(this.name,
|
|
1130
|
+
on(...i) {
|
|
1131
|
+
return new _r(this.name, i, this.unique);
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
1134
|
m(Ot, Di, "SQLiteIndexBuilderOn");
|
|
1135
1135
|
var Oi;
|
|
1136
1136
|
Oi = v;
|
|
1137
1137
|
class _r {
|
|
1138
|
-
constructor(
|
|
1138
|
+
constructor(i, e, t) {
|
|
1139
1139
|
/** @internal */
|
|
1140
1140
|
m(this, "config");
|
|
1141
1141
|
this.config = {
|
|
1142
|
-
name:
|
|
1142
|
+
name: i,
|
|
1143
1143
|
columns: e,
|
|
1144
1144
|
unique: t,
|
|
1145
1145
|
where: void 0
|
|
@@ -1148,59 +1148,59 @@ class _r {
|
|
|
1148
1148
|
/**
|
|
1149
1149
|
* Condition for partial index.
|
|
1150
1150
|
*/
|
|
1151
|
-
where(
|
|
1152
|
-
return this.config.where =
|
|
1151
|
+
where(i) {
|
|
1152
|
+
return this.config.where = i, this;
|
|
1153
1153
|
}
|
|
1154
1154
|
/** @internal */
|
|
1155
|
-
build(
|
|
1156
|
-
return new ur(this.config,
|
|
1155
|
+
build(i) {
|
|
1156
|
+
return new ur(this.config, i);
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
1159
|
m(_r, Oi, "SQLiteIndexBuilder");
|
|
1160
1160
|
var ki;
|
|
1161
1161
|
ki = v;
|
|
1162
1162
|
class ur {
|
|
1163
|
-
constructor(
|
|
1163
|
+
constructor(i, e) {
|
|
1164
1164
|
m(this, "config");
|
|
1165
|
-
this.config = { ...
|
|
1165
|
+
this.config = { ...i, table: e };
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
m(ur, ki, "SQLiteIndex");
|
|
1169
|
-
function S(
|
|
1170
|
-
return new Ot(
|
|
1169
|
+
function S(n) {
|
|
1170
|
+
return new Ot(n, !1);
|
|
1171
1171
|
}
|
|
1172
|
-
function Te(
|
|
1173
|
-
return new Ot(
|
|
1172
|
+
function Te(n) {
|
|
1173
|
+
return new Ot(n, !0);
|
|
1174
1174
|
}
|
|
1175
|
-
function se(...
|
|
1176
|
-
return
|
|
1175
|
+
function se(...n) {
|
|
1176
|
+
return n[0].columns ? new yt(n[0].columns, n[0].name) : new yt(n);
|
|
1177
1177
|
}
|
|
1178
1178
|
var Ii;
|
|
1179
1179
|
Ii = v;
|
|
1180
1180
|
class yt {
|
|
1181
|
-
constructor(
|
|
1181
|
+
constructor(i, e) {
|
|
1182
1182
|
/** @internal */
|
|
1183
1183
|
m(this, "columns");
|
|
1184
1184
|
/** @internal */
|
|
1185
1185
|
m(this, "name");
|
|
1186
|
-
this.columns =
|
|
1186
|
+
this.columns = i, this.name = e;
|
|
1187
1187
|
}
|
|
1188
1188
|
/** @internal */
|
|
1189
|
-
build(
|
|
1190
|
-
return new dr(
|
|
1189
|
+
build(i) {
|
|
1190
|
+
return new dr(i, this.columns, this.name);
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
1193
|
m(yt, Ii, "SQLitePrimaryKeyBuilder");
|
|
1194
1194
|
var zi;
|
|
1195
1195
|
zi = v;
|
|
1196
1196
|
class dr {
|
|
1197
|
-
constructor(
|
|
1197
|
+
constructor(i, e, t) {
|
|
1198
1198
|
m(this, "columns");
|
|
1199
1199
|
m(this, "name");
|
|
1200
|
-
this.table =
|
|
1200
|
+
this.table = i, this.columns = e, this.name = t;
|
|
1201
1201
|
}
|
|
1202
1202
|
getName() {
|
|
1203
|
-
return this.name ?? `${this.table[Be.Symbol.Name]}_${this.columns.map((
|
|
1203
|
+
return this.name ?? `${this.table[Be.Symbol.Name]}_${this.columns.map((i) => i.name).join("_")}_pk`;
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
1206
1206
|
m(dr, zi, "SQLitePrimaryKey");
|
|
@@ -1277,7 +1277,9 @@ const D = O("tenants", {
|
|
|
1277
1277
|
last_ip: s("last_ip", { length: 255 }),
|
|
1278
1278
|
login_count: p("login_count").notNull(),
|
|
1279
1279
|
last_login: s("last_login", { length: 255 }),
|
|
1280
|
-
registration_completed_at: s("registration_completed_at", {
|
|
1280
|
+
registration_completed_at: s("registration_completed_at", {
|
|
1281
|
+
length: 35
|
|
1282
|
+
}),
|
|
1281
1283
|
provider: s("provider", { length: 255 }).notNull(),
|
|
1282
1284
|
connection: s("connection", { length: 255 }),
|
|
1283
1285
|
email_verified: p("email_verified", { mode: "boolean" }).notNull(),
|
|
@@ -1301,33 +1303,33 @@ const D = O("tenants", {
|
|
|
1301
1303
|
// OIDC address claim (OIDC Core 5.1.1) - stored as JSON string
|
|
1302
1304
|
address: s("address")
|
|
1303
1305
|
},
|
|
1304
|
-
(
|
|
1306
|
+
(n) => [
|
|
1305
1307
|
se({
|
|
1306
|
-
columns: [
|
|
1308
|
+
columns: [n.user_id, n.tenant_id],
|
|
1307
1309
|
name: "users_tenants"
|
|
1308
1310
|
}),
|
|
1309
1311
|
Te("unique_email_provider").on(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1312
|
+
n.email,
|
|
1313
|
+
n.provider,
|
|
1314
|
+
n.tenant_id
|
|
1313
1315
|
),
|
|
1314
1316
|
Te("unique_phone_provider").on(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1317
|
+
n.phone_number,
|
|
1318
|
+
n.provider,
|
|
1319
|
+
n.tenant_id
|
|
1318
1320
|
),
|
|
1319
1321
|
Te("unique_username_provider").on(
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1322
|
+
n.username,
|
|
1323
|
+
n.provider,
|
|
1324
|
+
n.tenant_id
|
|
1323
1325
|
),
|
|
1324
|
-
S("users_email_index").on(
|
|
1325
|
-
S("users_linked_to_index").on(
|
|
1326
|
-
S("users_name_index").on(
|
|
1326
|
+
S("users_email_index").on(n.email),
|
|
1327
|
+
S("users_linked_to_index").on(n.linked_to),
|
|
1328
|
+
S("users_name_index").on(n.name),
|
|
1327
1329
|
S("users_phone_tenant_provider_index").on(
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1330
|
+
n.tenant_id,
|
|
1331
|
+
n.phone_number,
|
|
1332
|
+
n.provider
|
|
1331
1333
|
)
|
|
1332
1334
|
]
|
|
1333
1335
|
), E = O("passwords", {
|
|
@@ -1357,11 +1359,11 @@ const D = O("tenants", {
|
|
|
1357
1359
|
clients: s("clients").notNull(),
|
|
1358
1360
|
login_session_id: s("login_session_id", { length: 21 })
|
|
1359
1361
|
},
|
|
1360
|
-
(
|
|
1361
|
-
se({ columns: [
|
|
1362
|
-
S("IDX_sessions_login_session_id").on(
|
|
1363
|
-
S("idx_sessions_user_id").on(
|
|
1364
|
-
S("idx_sessions_expires_at_ts").on(
|
|
1362
|
+
(n) => [
|
|
1363
|
+
se({ columns: [n.tenant_id, n.id], name: "sessions_pk" }),
|
|
1364
|
+
S("IDX_sessions_login_session_id").on(n.login_session_id),
|
|
1365
|
+
S("idx_sessions_user_id").on(n.tenant_id, n.user_id),
|
|
1366
|
+
S("idx_sessions_expires_at_ts").on(n.expires_at_ts)
|
|
1365
1367
|
]
|
|
1366
1368
|
), C = O(
|
|
1367
1369
|
"refresh_tokens",
|
|
@@ -1379,14 +1381,14 @@ const D = O("tenants", {
|
|
|
1379
1381
|
idle_expires_at_ts: p("idle_expires_at_ts"),
|
|
1380
1382
|
last_exchanged_at_ts: p("last_exchanged_at_ts")
|
|
1381
1383
|
},
|
|
1382
|
-
(
|
|
1384
|
+
(n) => [
|
|
1383
1385
|
se({
|
|
1384
|
-
columns: [
|
|
1386
|
+
columns: [n.tenant_id, n.id],
|
|
1385
1387
|
name: "refresh_tokens_pk"
|
|
1386
1388
|
}),
|
|
1387
|
-
S("idx_refresh_tokens_user_id").on(
|
|
1388
|
-
S("idx_refresh_tokens_login_id").on(
|
|
1389
|
-
S("idx_refresh_tokens_expires_at_ts").on(
|
|
1389
|
+
S("idx_refresh_tokens_user_id").on(n.tenant_id, n.user_id),
|
|
1390
|
+
S("idx_refresh_tokens_login_id").on(n.login_id),
|
|
1391
|
+
S("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
|
|
1390
1392
|
]
|
|
1391
1393
|
), oe = O(
|
|
1392
1394
|
"login_sessions",
|
|
@@ -1431,19 +1433,19 @@ const D = O("tenants", {
|
|
|
1431
1433
|
user_id: s("user_id", { length: 255 }),
|
|
1432
1434
|
auth_connection: s("auth_connection", { length: 255 })
|
|
1433
1435
|
},
|
|
1434
|
-
(
|
|
1436
|
+
(n) => [
|
|
1435
1437
|
se({
|
|
1436
|
-
columns: [
|
|
1438
|
+
columns: [n.tenant_id, n.id],
|
|
1437
1439
|
name: "login_sessions_pk"
|
|
1438
1440
|
}),
|
|
1439
|
-
S("login_sessions_id_index").on(
|
|
1440
|
-
S("login_sessions_state_idx").on(
|
|
1441
|
+
S("login_sessions_id_index").on(n.id),
|
|
1442
|
+
S("login_sessions_state_idx").on(n.state),
|
|
1441
1443
|
S("login_sessions_state_updated_idx").on(
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
+
n.state,
|
|
1445
|
+
n.updated_at_ts
|
|
1444
1446
|
),
|
|
1445
|
-
S("login_sessions_tenant_user_idx").on(
|
|
1446
|
-
S("idx_login_sessions_expires_at_ts").on(
|
|
1447
|
+
S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
|
|
1448
|
+
S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
|
|
1447
1449
|
]
|
|
1448
1450
|
), B = O(
|
|
1449
1451
|
"codes",
|
|
@@ -1464,12 +1466,12 @@ const D = O("tenants", {
|
|
|
1464
1466
|
nonce: s("nonce", { length: 1024 }),
|
|
1465
1467
|
state: s("state", { length: 2048 })
|
|
1466
1468
|
},
|
|
1467
|
-
(
|
|
1469
|
+
(n) => [
|
|
1468
1470
|
se({
|
|
1469
|
-
columns: [
|
|
1471
|
+
columns: [n.code_id, n.code_type],
|
|
1470
1472
|
name: "PK_codes_code_id_code_type"
|
|
1471
1473
|
}),
|
|
1472
|
-
S("codes_expires_at_index").on(
|
|
1474
|
+
S("codes_expires_at_index").on(n.expires_at)
|
|
1473
1475
|
]
|
|
1474
1476
|
), Cr = O("authentication_codes", {
|
|
1475
1477
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1507,9 +1509,9 @@ const D = O("tenants", {
|
|
|
1507
1509
|
audience: s("audience", { length: 255 }),
|
|
1508
1510
|
ip: s("ip", { length: 64 })
|
|
1509
1511
|
},
|
|
1510
|
-
(
|
|
1511
|
-
S("otps_email_index").on(
|
|
1512
|
-
S("otps_expires_at_index").on(
|
|
1512
|
+
(n) => [
|
|
1513
|
+
S("otps_email_index").on(n.email),
|
|
1514
|
+
S("otps_expires_at_index").on(n.expires_at)
|
|
1513
1515
|
]
|
|
1514
1516
|
), Br = O("tickets", {
|
|
1515
1517
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1590,9 +1592,9 @@ const D = O("tenants", {
|
|
|
1590
1592
|
updated_at: s("updated_at", { length: 35 }).notNull(),
|
|
1591
1593
|
connections: s("connections").notNull().default("[]")
|
|
1592
1594
|
},
|
|
1593
|
-
(
|
|
1595
|
+
(n) => [
|
|
1594
1596
|
se({
|
|
1595
|
-
columns: [
|
|
1597
|
+
columns: [n.tenant_id, n.client_id],
|
|
1596
1598
|
name: "clients_tenant_id_client_id"
|
|
1597
1599
|
})
|
|
1598
1600
|
]
|
|
@@ -1614,12 +1616,12 @@ const D = O("tenants", {
|
|
|
1614
1616
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1615
1617
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1616
1618
|
},
|
|
1617
|
-
(
|
|
1619
|
+
(n) => [
|
|
1618
1620
|
se({
|
|
1619
|
-
columns: [
|
|
1621
|
+
columns: [n.tenant_id, n.id],
|
|
1620
1622
|
name: "pk_client_grants"
|
|
1621
1623
|
}),
|
|
1622
|
-
S("idx_client_grants_audience").on(
|
|
1624
|
+
S("idx_client_grants_audience").on(n.audience)
|
|
1623
1625
|
]
|
|
1624
1626
|
), U = O(
|
|
1625
1627
|
"connections",
|
|
@@ -1639,11 +1641,11 @@ const D = O("tenants", {
|
|
|
1639
1641
|
is_system: p("is_system").notNull().default(0),
|
|
1640
1642
|
metadata: s("metadata", { length: 4096 })
|
|
1641
1643
|
},
|
|
1642
|
-
(
|
|
1643
|
-
se({ columns: [
|
|
1644
|
-
S("connections_tenant_id_index").on(
|
|
1644
|
+
(n) => [
|
|
1645
|
+
se({ columns: [n.tenant_id, n.id] }),
|
|
1646
|
+
S("connections_tenant_id_index").on(n.tenant_id),
|
|
1645
1647
|
// Required for keys.connection foreign key reference
|
|
1646
|
-
Te("connections_id_unique").on(
|
|
1648
|
+
Te("connections_id_unique").on(n.id)
|
|
1647
1649
|
]
|
|
1648
1650
|
), re = O(
|
|
1649
1651
|
"custom_domains",
|
|
@@ -1662,7 +1664,7 @@ const D = O("tenants", {
|
|
|
1662
1664
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1663
1665
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1664
1666
|
},
|
|
1665
|
-
(
|
|
1667
|
+
(n) => [Te("custom_domains_domain_unique").on(n.domain)]
|
|
1666
1668
|
), Pr = O("domains", {
|
|
1667
1669
|
id: s("id", { length: 255 }).primaryKey(),
|
|
1668
1670
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1687,7 +1689,7 @@ const D = O("tenants", {
|
|
|
1687
1689
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1688
1690
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1689
1691
|
},
|
|
1690
|
-
(
|
|
1692
|
+
(n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
|
|
1691
1693
|
), P = O(
|
|
1692
1694
|
"user_organizations",
|
|
1693
1695
|
{
|
|
@@ -1698,15 +1700,15 @@ const D = O("tenants", {
|
|
|
1698
1700
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1699
1701
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1700
1702
|
},
|
|
1701
|
-
(
|
|
1703
|
+
(n) => [
|
|
1702
1704
|
Te("user_organizations_unique").on(
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1705
|
+
n.tenant_id,
|
|
1706
|
+
n.user_id,
|
|
1707
|
+
n.organization_id
|
|
1706
1708
|
),
|
|
1707
|
-
S("idx_user_organizations_tenant_id").on(
|
|
1708
|
-
S("idx_user_organizations_user_id").on(
|
|
1709
|
-
S("idx_user_organizations_organization_id").on(
|
|
1709
|
+
S("idx_user_organizations_tenant_id").on(n.tenant_id),
|
|
1710
|
+
S("idx_user_organizations_user_id").on(n.user_id),
|
|
1711
|
+
S("idx_user_organizations_organization_id").on(n.organization_id)
|
|
1710
1712
|
]
|
|
1711
1713
|
), te = O(
|
|
1712
1714
|
"invites",
|
|
@@ -1728,11 +1730,11 @@ const D = O("tenants", {
|
|
|
1728
1730
|
ttl_sec: p("ttl_sec"),
|
|
1729
1731
|
send_invitation_email: p("send_invitation_email")
|
|
1730
1732
|
},
|
|
1731
|
-
(
|
|
1732
|
-
S("idx_invites_tenant_id").on(
|
|
1733
|
-
S("idx_invites_organization_id").on(
|
|
1734
|
-
S("idx_invites_expires_at").on(
|
|
1735
|
-
S("idx_invites_tenant_created").on(
|
|
1733
|
+
(n) => [
|
|
1734
|
+
S("idx_invites_tenant_id").on(n.tenant_id),
|
|
1735
|
+
S("idx_invites_organization_id").on(n.organization_id),
|
|
1736
|
+
S("idx_invites_expires_at").on(n.expires_at),
|
|
1737
|
+
S("idx_invites_tenant_created").on(n.tenant_id, n.created_at)
|
|
1736
1738
|
]
|
|
1737
1739
|
), J = O(
|
|
1738
1740
|
"roles",
|
|
@@ -1746,8 +1748,8 @@ const D = O("tenants", {
|
|
|
1746
1748
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1747
1749
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1748
1750
|
},
|
|
1749
|
-
(
|
|
1750
|
-
se({ columns: [
|
|
1751
|
+
(n) => [
|
|
1752
|
+
se({ columns: [n.tenant_id, n.id], name: "roles_pk" })
|
|
1751
1753
|
]
|
|
1752
1754
|
), le = O(
|
|
1753
1755
|
"role_permissions",
|
|
@@ -1760,21 +1762,21 @@ const D = O("tenants", {
|
|
|
1760
1762
|
permission_name: s("permission_name", { length: 191 }).notNull(),
|
|
1761
1763
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1762
1764
|
},
|
|
1763
|
-
(
|
|
1765
|
+
(n) => [
|
|
1764
1766
|
se({
|
|
1765
1767
|
columns: [
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1768
|
+
n.tenant_id,
|
|
1769
|
+
n.role_id,
|
|
1770
|
+
n.resource_server_identifier,
|
|
1771
|
+
n.permission_name
|
|
1770
1772
|
],
|
|
1771
1773
|
name: "role_permissions_pk"
|
|
1772
1774
|
}),
|
|
1773
|
-
S("role_permissions_role_fk").on(
|
|
1775
|
+
S("role_permissions_role_fk").on(n.tenant_id, n.role_id),
|
|
1774
1776
|
S("role_permissions_permission_fk").on(
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1777
|
+
n.tenant_id,
|
|
1778
|
+
n.resource_server_identifier,
|
|
1779
|
+
n.permission_name
|
|
1778
1780
|
)
|
|
1779
1781
|
]
|
|
1780
1782
|
), _e = O(
|
|
@@ -1789,24 +1791,24 @@ const D = O("tenants", {
|
|
|
1789
1791
|
organization_id: s("organization_id", { length: 21 }).notNull().default(""),
|
|
1790
1792
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1791
1793
|
},
|
|
1792
|
-
(
|
|
1794
|
+
(n) => [
|
|
1793
1795
|
se({
|
|
1794
1796
|
columns: [
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1797
|
+
n.tenant_id,
|
|
1798
|
+
n.user_id,
|
|
1799
|
+
n.resource_server_identifier,
|
|
1800
|
+
n.permission_name,
|
|
1801
|
+
n.organization_id
|
|
1800
1802
|
],
|
|
1801
1803
|
name: "user_permissions_pk"
|
|
1802
1804
|
}),
|
|
1803
|
-
S("user_permissions_user_fk").on(
|
|
1805
|
+
S("user_permissions_user_fk").on(n.tenant_id, n.user_id),
|
|
1804
1806
|
S("user_permissions_permission_fk").on(
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1807
|
+
n.tenant_id,
|
|
1808
|
+
n.resource_server_identifier,
|
|
1809
|
+
n.permission_name
|
|
1808
1810
|
),
|
|
1809
|
-
S("user_permissions_organization_fk").on(
|
|
1811
|
+
S("user_permissions_organization_fk").on(n.organization_id)
|
|
1810
1812
|
]
|
|
1811
1813
|
), ue = O(
|
|
1812
1814
|
"user_roles",
|
|
@@ -1817,19 +1819,19 @@ const D = O("tenants", {
|
|
|
1817
1819
|
organization_id: s("organization_id", { length: 191 }).notNull().default(""),
|
|
1818
1820
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1819
1821
|
},
|
|
1820
|
-
(
|
|
1822
|
+
(n) => [
|
|
1821
1823
|
se({
|
|
1822
1824
|
columns: [
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1825
|
+
n.tenant_id,
|
|
1826
|
+
n.user_id,
|
|
1827
|
+
n.role_id,
|
|
1828
|
+
n.organization_id
|
|
1827
1829
|
],
|
|
1828
1830
|
name: "user_roles_pk"
|
|
1829
1831
|
}),
|
|
1830
|
-
S("user_roles_user_fk").on(
|
|
1831
|
-
S("user_roles_role_fk").on(
|
|
1832
|
-
S("user_roles_organization_fk").on(
|
|
1832
|
+
S("user_roles_user_fk").on(n.tenant_id, n.user_id),
|
|
1833
|
+
S("user_roles_role_fk").on(n.tenant_id, n.role_id),
|
|
1834
|
+
S("user_roles_organization_fk").on(n.organization_id)
|
|
1833
1835
|
]
|
|
1834
1836
|
), L = O(
|
|
1835
1837
|
"resource_servers",
|
|
@@ -1854,9 +1856,9 @@ const D = O("tenants", {
|
|
|
1854
1856
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1855
1857
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1856
1858
|
},
|
|
1857
|
-
(
|
|
1859
|
+
(n) => [
|
|
1858
1860
|
se({
|
|
1859
|
-
columns: [
|
|
1861
|
+
columns: [n.tenant_id, n.id],
|
|
1860
1862
|
name: "resource_servers_pk"
|
|
1861
1863
|
})
|
|
1862
1864
|
]
|
|
@@ -2005,12 +2007,12 @@ const D = O("tenants", {
|
|
|
2005
2007
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2006
2008
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2007
2009
|
},
|
|
2008
|
-
(
|
|
2010
|
+
(n) => [
|
|
2009
2011
|
se({
|
|
2010
|
-
columns: [
|
|
2012
|
+
columns: [n.tenant_id, n.themeId],
|
|
2011
2013
|
name: "themes_pkey"
|
|
2012
2014
|
}),
|
|
2013
|
-
S("themes_tenant_id_idx").on(
|
|
2015
|
+
S("themes_tenant_id_idx").on(n.tenant_id)
|
|
2014
2016
|
]
|
|
2015
2017
|
), ne = O(
|
|
2016
2018
|
"forms",
|
|
@@ -2028,7 +2030,7 @@ const D = O("tenants", {
|
|
|
2028
2030
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2029
2031
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2030
2032
|
},
|
|
2031
|
-
(
|
|
2033
|
+
(n) => [S("forms_tenant_id_idx").on(n.tenant_id)]
|
|
2032
2034
|
), ie = O(
|
|
2033
2035
|
"flows",
|
|
2034
2036
|
{
|
|
@@ -2039,7 +2041,7 @@ const D = O("tenants", {
|
|
|
2039
2041
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2040
2042
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2041
2043
|
},
|
|
2042
|
-
(
|
|
2044
|
+
(n) => [S("flows_tenant_id_idx").on(n.tenant_id)]
|
|
2043
2045
|
), Ee = O("prompt_settings", {
|
|
2044
2046
|
tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
|
|
2045
2047
|
universal_login_experience: s("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
@@ -2077,7 +2079,7 @@ const D = O("tenants", {
|
|
|
2077
2079
|
code_id: s("code_id", { length: 21 })
|
|
2078
2080
|
// only required for code type hooks
|
|
2079
2081
|
},
|
|
2080
|
-
(
|
|
2082
|
+
(n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
|
|
2081
2083
|
), me = O(
|
|
2082
2084
|
"hook_code",
|
|
2083
2085
|
{
|
|
@@ -2088,7 +2090,7 @@ const D = O("tenants", {
|
|
|
2088
2090
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2089
2091
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2090
2092
|
},
|
|
2091
|
-
(
|
|
2093
|
+
(n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
|
|
2092
2094
|
), he = O("keys", {
|
|
2093
2095
|
kid: s("kid", { length: 255 }).primaryKey(),
|
|
2094
2096
|
tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
|
|
@@ -2117,8 +2119,8 @@ const D = O("tenants", {
|
|
|
2117
2119
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2118
2120
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2119
2121
|
},
|
|
2120
|
-
(
|
|
2121
|
-
se({ columns: [
|
|
2122
|
+
(n) => [
|
|
2123
|
+
se({ columns: [n.tenant_id, n.prompt, n.language] })
|
|
2122
2124
|
]
|
|
2123
2125
|
), F = O(
|
|
2124
2126
|
"authentication_methods",
|
|
@@ -2139,12 +2141,12 @@ const D = O("tenants", {
|
|
|
2139
2141
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2140
2142
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2141
2143
|
},
|
|
2142
|
-
(
|
|
2144
|
+
(n) => [
|
|
2143
2145
|
S("authentication_methods_tenant_user_idx").on(
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
+
n.tenant_id,
|
|
2147
|
+
n.user_id
|
|
2146
2148
|
),
|
|
2147
|
-
S("authentication_methods_credential_id_idx").on(
|
|
2149
|
+
S("authentication_methods_credential_id_idx").on(n.credential_id)
|
|
2148
2150
|
]
|
|
2149
2151
|
), T = O(
|
|
2150
2152
|
"logs",
|
|
@@ -2179,15 +2181,15 @@ const D = O("tenants", {
|
|
|
2179
2181
|
time_zone: s("time_zone", { length: 255 }),
|
|
2180
2182
|
continent_code: s("continent_code", { length: 2 })
|
|
2181
2183
|
},
|
|
2182
|
-
(
|
|
2183
|
-
S("logs_user_id").on(
|
|
2184
|
-
S("logs_tenant_id").on(
|
|
2185
|
-
S("logs_date").on(
|
|
2184
|
+
(n) => [
|
|
2185
|
+
S("logs_user_id").on(n.user_id),
|
|
2186
|
+
S("logs_tenant_id").on(n.tenant_id),
|
|
2187
|
+
S("logs_date").on(n.date),
|
|
2186
2188
|
S("IDX_logs_tenant_date_type_user").on(
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2189
|
+
n.tenant_id,
|
|
2190
|
+
n.date,
|
|
2191
|
+
n.type,
|
|
2192
|
+
n.user_id
|
|
2191
2193
|
)
|
|
2192
2194
|
]
|
|
2193
2195
|
), x = O(
|
|
@@ -2210,17 +2212,17 @@ const D = O("tenants", {
|
|
|
2210
2212
|
dead_lettered_at: s("dead_lettered_at", { length: 35 }),
|
|
2211
2213
|
final_error: s("final_error")
|
|
2212
2214
|
},
|
|
2213
|
-
(
|
|
2214
|
-
S("idx_outbox_events_tenant_id").on(
|
|
2215
|
-
S("idx_outbox_events_processed_at").on(
|
|
2216
|
-
S("idx_outbox_events_claimed_by").on(
|
|
2215
|
+
(n) => [
|
|
2216
|
+
S("idx_outbox_events_tenant_id").on(n.tenant_id),
|
|
2217
|
+
S("idx_outbox_events_processed_at").on(n.processed_at),
|
|
2218
|
+
S("idx_outbox_events_claimed_by").on(n.claimed_by),
|
|
2217
2219
|
// Composite index for the failed-events management endpoints
|
|
2218
2220
|
// (`listFailed` query: tenant_id equality + dead_lettered_at IS NOT NULL
|
|
2219
2221
|
// + ORDER BY dead_lettered_at DESC). Equality column first so the
|
|
2220
2222
|
// optimizer can seek directly to the tenant's dead-letter slice.
|
|
2221
2223
|
S("idx_outbox_events_tenant_dead_lettered").on(
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
+
n.tenant_id,
|
|
2225
|
+
n.dead_lettered_at
|
|
2224
2226
|
)
|
|
2225
2227
|
]
|
|
2226
2228
|
), js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -2263,60 +2265,60 @@ const D = O("tenants", {
|
|
|
2263
2265
|
userRoles: ue,
|
|
2264
2266
|
users: k
|
|
2265
2267
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2266
|
-
function z(
|
|
2267
|
-
if (
|
|
2268
|
-
return
|
|
2269
|
-
if (Array.isArray(
|
|
2270
|
-
return
|
|
2268
|
+
function z(n) {
|
|
2269
|
+
if (n == null || typeof n != "object")
|
|
2270
|
+
return n;
|
|
2271
|
+
if (Array.isArray(n))
|
|
2272
|
+
return n.map(
|
|
2271
2273
|
(e) => e !== null && typeof e == "object" ? z(e) : e
|
|
2272
2274
|
);
|
|
2273
|
-
const
|
|
2274
|
-
for (const e in
|
|
2275
|
-
const t =
|
|
2276
|
-
t === null ? delete
|
|
2275
|
+
const i = { ...n };
|
|
2276
|
+
for (const e in i) {
|
|
2277
|
+
const t = i[e];
|
|
2278
|
+
t === null ? delete i[e] : t !== null && typeof t == "object" && (Array.isArray(t) ? i[e] = t.map(
|
|
2277
2279
|
(r) => r !== null && typeof r == "object" ? z(r) : r
|
|
2278
|
-
) :
|
|
2280
|
+
) : i[e] = z(t));
|
|
2279
2281
|
}
|
|
2280
|
-
return
|
|
2282
|
+
return i;
|
|
2281
2283
|
}
|
|
2282
|
-
function Qr(
|
|
2283
|
-
for (const t of
|
|
2284
|
-
|
|
2284
|
+
function Qr(n, i, e = { ...n }) {
|
|
2285
|
+
for (const t of i)
|
|
2286
|
+
n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
|
|
2285
2287
|
return e;
|
|
2286
2288
|
}
|
|
2287
|
-
function Jr(
|
|
2288
|
-
for (const t of
|
|
2289
|
-
|
|
2289
|
+
function Jr(n, i, e = n) {
|
|
2290
|
+
for (const t of i)
|
|
2291
|
+
n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
|
|
2290
2292
|
}
|
|
2291
|
-
function cr(
|
|
2292
|
-
const
|
|
2293
|
-
for (const e in
|
|
2294
|
-
|
|
2295
|
-
return
|
|
2293
|
+
function cr(n) {
|
|
2294
|
+
const i = {};
|
|
2295
|
+
for (const e in n)
|
|
2296
|
+
n[e] !== void 0 && n[e] !== null && (i[e] = n[e]);
|
|
2297
|
+
return i;
|
|
2296
2298
|
}
|
|
2297
|
-
function b(
|
|
2298
|
-
if (
|
|
2299
|
-
return
|
|
2300
|
-
if (typeof
|
|
2299
|
+
function b(n, i) {
|
|
2300
|
+
if (n == null)
|
|
2301
|
+
return i;
|
|
2302
|
+
if (typeof n == "string")
|
|
2301
2303
|
try {
|
|
2302
|
-
return JSON.parse(
|
|
2304
|
+
return JSON.parse(n);
|
|
2303
2305
|
} catch {
|
|
2304
|
-
return
|
|
2306
|
+
return i;
|
|
2305
2307
|
}
|
|
2306
|
-
return
|
|
2308
|
+
return n;
|
|
2307
2309
|
}
|
|
2308
|
-
function Pe(
|
|
2309
|
-
for (const t in
|
|
2310
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
2311
|
-
const r =
|
|
2310
|
+
function Pe(n, i = "", e = {}) {
|
|
2311
|
+
for (const t in n)
|
|
2312
|
+
if (Object.prototype.hasOwnProperty.call(n, t)) {
|
|
2313
|
+
const r = i ? `${i}_${t}` : t, o = n[t];
|
|
2312
2314
|
typeof o == "object" && o !== null && !Array.isArray(o) ? Pe(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
|
|
2313
2315
|
}
|
|
2314
2316
|
return e;
|
|
2315
2317
|
}
|
|
2316
|
-
function gr(
|
|
2318
|
+
function gr(n, i) {
|
|
2317
2319
|
const e = {};
|
|
2318
|
-
for (const [t, r] of Object.entries(
|
|
2319
|
-
const o =
|
|
2320
|
+
for (const [t, r] of Object.entries(n)) {
|
|
2321
|
+
const o = i.find(
|
|
2320
2322
|
(l) => t.startsWith(`${l}_`)
|
|
2321
2323
|
);
|
|
2322
2324
|
if (!o)
|
|
@@ -2331,13 +2333,13 @@ function gr(i, n) {
|
|
|
2331
2333
|
}
|
|
2332
2334
|
return e;
|
|
2333
2335
|
}
|
|
2334
|
-
function Fr(
|
|
2335
|
-
return typeof
|
|
2336
|
+
function Fr(n) {
|
|
2337
|
+
return typeof n == "string" ? parseInt(n, 10) : typeof n == "bigint" ? Number(n) : n;
|
|
2336
2338
|
}
|
|
2337
|
-
function Ur(
|
|
2339
|
+
function Ur(n) {
|
|
2338
2340
|
return {
|
|
2339
|
-
async get(
|
|
2340
|
-
const e = await
|
|
2341
|
+
async get(i) {
|
|
2342
|
+
const e = await n.select().from(Le).where(a(Le.tenant_id, i)).get();
|
|
2341
2343
|
if (!e) return null;
|
|
2342
2344
|
const {
|
|
2343
2345
|
tenant_id: t,
|
|
@@ -2363,11 +2365,11 @@ function Ur(i) {
|
|
|
2363
2365
|
font: c ? { url: c } : void 0
|
|
2364
2366
|
});
|
|
2365
2367
|
},
|
|
2366
|
-
async set(
|
|
2368
|
+
async set(i, e) {
|
|
2367
2369
|
var _, d, c, u, h, f, y, w;
|
|
2368
2370
|
const { colors: t, font: r, ...o } = e, l = {
|
|
2369
2371
|
...o,
|
|
2370
|
-
tenant_id:
|
|
2372
|
+
tenant_id: i,
|
|
2371
2373
|
colors_primary: t == null ? void 0 : t.primary,
|
|
2372
2374
|
colors_page_background_type: (_ = t == null ? void 0 : t.page_background) == null ? void 0 : _.type,
|
|
2373
2375
|
colors_page_background_start: (d = t == null ? void 0 : t.page_background) == null ? void 0 : d.start,
|
|
@@ -2375,7 +2377,7 @@ function Ur(i) {
|
|
|
2375
2377
|
colors_page_background_angle_dev: (u = t == null ? void 0 : t.page_background) == null ? void 0 : u.angle_deg,
|
|
2376
2378
|
font_url: r == null ? void 0 : r.url
|
|
2377
2379
|
};
|
|
2378
|
-
await
|
|
2380
|
+
await n.insert(Le).values(l).onConflictDoUpdate({
|
|
2379
2381
|
target: Le.tenant_id,
|
|
2380
2382
|
set: {
|
|
2381
2383
|
...o,
|
|
@@ -2396,11 +2398,11 @@ var be = class extends Error {
|
|
|
2396
2398
|
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
2397
2399
|
* @param options - Additional options for the exception.
|
|
2398
2400
|
*/
|
|
2399
|
-
constructor(
|
|
2401
|
+
constructor(i = 500, e) {
|
|
2400
2402
|
super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
|
|
2401
2403
|
m(this, "res");
|
|
2402
2404
|
m(this, "status");
|
|
2403
|
-
this.res = e == null ? void 0 : e.res, this.status =
|
|
2405
|
+
this.res = e == null ? void 0 : e.res, this.status = i;
|
|
2404
2406
|
}
|
|
2405
2407
|
/**
|
|
2406
2408
|
* Returns the response object associated with the exception.
|
|
@@ -2416,15 +2418,15 @@ var be = class extends Error {
|
|
|
2416
2418
|
});
|
|
2417
2419
|
}
|
|
2418
2420
|
};
|
|
2419
|
-
function pe(
|
|
2420
|
-
const t =
|
|
2421
|
+
function pe(n, i, e) {
|
|
2422
|
+
const t = i.split(/ OR /i);
|
|
2421
2423
|
if (t.length > 1) {
|
|
2422
2424
|
const c = t.map((u) => {
|
|
2423
2425
|
const h = u.trim().match(/^([^:]+):(.+)$/);
|
|
2424
2426
|
if (h) {
|
|
2425
2427
|
const [, f, y] = h;
|
|
2426
2428
|
if (!f || !y) return null;
|
|
2427
|
-
const w = y.replace(/^"(.*)"$/, "$1"), A =
|
|
2429
|
+
const w = y.replace(/^"(.*)"$/, "$1"), A = n[f.trim()];
|
|
2428
2430
|
return A ? a(A, w.trim()) : null;
|
|
2429
2431
|
}
|
|
2430
2432
|
return null;
|
|
@@ -2433,8 +2435,8 @@ function pe(i, n, e) {
|
|
|
2433
2435
|
}
|
|
2434
2436
|
const r = [];
|
|
2435
2437
|
let o = "", l = !1;
|
|
2436
|
-
for (let c = 0; c <
|
|
2437
|
-
const u =
|
|
2438
|
+
for (let c = 0; c < i.length; c++) {
|
|
2439
|
+
const u = i[c];
|
|
2438
2440
|
u === '"' ? (l = !l, o += u) : u === " " && !l ? o.trim() && (r.push(o.trim()), o = "") : o += u;
|
|
2439
2441
|
}
|
|
2440
2442
|
o.trim() && r.push(o.trim());
|
|
@@ -2453,7 +2455,7 @@ function pe(i, n, e) {
|
|
|
2453
2455
|
}), d = [];
|
|
2454
2456
|
for (const { key: c, value: u, isNegation: h, isExistsQuery: f, operator: y } of _)
|
|
2455
2457
|
if (c) {
|
|
2456
|
-
const w =
|
|
2458
|
+
const w = n[c];
|
|
2457
2459
|
if (!w) {
|
|
2458
2460
|
f ? d.push(
|
|
2459
2461
|
h ? N`${N.identifier(c)} IS NULL` : N`${N.identifier(c)} IS NOT NULL`
|
|
@@ -2500,7 +2502,7 @@ function pe(i, n, e) {
|
|
|
2500
2502
|
}
|
|
2501
2503
|
} else if (u) {
|
|
2502
2504
|
const A = (u.includes("|") ? [...e, "user_id"] : e).map((R) => {
|
|
2503
|
-
const W =
|
|
2505
|
+
const W = n[R];
|
|
2504
2506
|
return W ? R === "user_id" ? a(W, u) : Ie(W, `%${u}%`) : null;
|
|
2505
2507
|
}).filter(Boolean);
|
|
2506
2508
|
A.length > 0 && d.push(de(...A));
|
|
@@ -2543,8 +2545,8 @@ const kt = [
|
|
|
2543
2545
|
"signed_request_object",
|
|
2544
2546
|
"token_quota"
|
|
2545
2547
|
];
|
|
2546
|
-
function Ue(
|
|
2547
|
-
const { tenant_id:
|
|
2548
|
+
function Ue(n) {
|
|
2549
|
+
const { tenant_id: i, connections: e, ...t } = n, r = { ...t };
|
|
2548
2550
|
for (const o of kt)
|
|
2549
2551
|
r[o] = !!t[o];
|
|
2550
2552
|
for (const o of It)
|
|
@@ -2553,26 +2555,26 @@ function Ue(i) {
|
|
|
2553
2555
|
r[o] = b(t[o], {});
|
|
2554
2556
|
return r.connections = b(e, []), z(r);
|
|
2555
2557
|
}
|
|
2556
|
-
function At(
|
|
2557
|
-
const
|
|
2558
|
+
function At(n) {
|
|
2559
|
+
const i = { ...n };
|
|
2558
2560
|
Jr(
|
|
2559
|
-
|
|
2561
|
+
n,
|
|
2560
2562
|
kt,
|
|
2561
|
-
|
|
2563
|
+
i
|
|
2562
2564
|
);
|
|
2563
2565
|
for (const e of It)
|
|
2564
|
-
|
|
2566
|
+
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || []));
|
|
2565
2567
|
for (const e of zt)
|
|
2566
|
-
|
|
2567
|
-
return
|
|
2568
|
+
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || {}));
|
|
2569
|
+
return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])), cr(i);
|
|
2568
2570
|
}
|
|
2569
|
-
function Kr(
|
|
2571
|
+
function Kr(n) {
|
|
2570
2572
|
return {
|
|
2571
|
-
async create(
|
|
2573
|
+
async create(i, e) {
|
|
2572
2574
|
var l, _;
|
|
2573
2575
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
2574
2576
|
client_id: e.client_id,
|
|
2575
|
-
tenant_id:
|
|
2577
|
+
tenant_id: i,
|
|
2576
2578
|
name: e.name,
|
|
2577
2579
|
description: e.description,
|
|
2578
2580
|
app_type: e.app_type ?? "regular_web",
|
|
@@ -2601,43 +2603,43 @@ function Kr(i) {
|
|
|
2601
2603
|
r.connections = e.connections || [];
|
|
2602
2604
|
const o = At(r);
|
|
2603
2605
|
try {
|
|
2604
|
-
await
|
|
2606
|
+
await n.insert(I).values({ ...o, tenant_id: i });
|
|
2605
2607
|
} catch (d) {
|
|
2606
2608
|
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 be(409, {
|
|
2607
2609
|
message: "Client already exists"
|
|
2608
2610
|
}) : d;
|
|
2609
2611
|
}
|
|
2610
|
-
return Ue({ ...o, tenant_id:
|
|
2612
|
+
return Ue({ ...o, tenant_id: i });
|
|
2611
2613
|
},
|
|
2612
|
-
async get(
|
|
2613
|
-
const t = await
|
|
2614
|
+
async get(i, e) {
|
|
2615
|
+
const t = await n.select().from(I).where(
|
|
2614
2616
|
g(
|
|
2615
|
-
a(I.tenant_id,
|
|
2617
|
+
a(I.tenant_id, i),
|
|
2616
2618
|
a(I.client_id, e)
|
|
2617
2619
|
)
|
|
2618
2620
|
).get();
|
|
2619
2621
|
return t ? Ue(t) : null;
|
|
2620
2622
|
},
|
|
2621
|
-
async getByClientId(
|
|
2622
|
-
const e = await
|
|
2623
|
+
async getByClientId(i) {
|
|
2624
|
+
const e = await n.select().from(I).where(a(I.client_id, i)).get();
|
|
2623
2625
|
return e ? {
|
|
2624
2626
|
...Ue(e),
|
|
2625
2627
|
tenant_id: e.tenant_id
|
|
2626
2628
|
} : null;
|
|
2627
2629
|
},
|
|
2628
|
-
async update(
|
|
2630
|
+
async update(i, e, t) {
|
|
2629
2631
|
const r = At({
|
|
2630
2632
|
...t,
|
|
2631
2633
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2632
2634
|
});
|
|
2633
|
-
return delete r.client_id, delete r.tenant_id, await
|
|
2635
|
+
return delete r.client_id, delete r.tenant_id, await n.update(I).set(r).where(
|
|
2634
2636
|
g(
|
|
2635
|
-
a(I.tenant_id,
|
|
2637
|
+
a(I.tenant_id, i),
|
|
2636
2638
|
a(I.client_id, e)
|
|
2637
2639
|
)
|
|
2638
2640
|
), !0;
|
|
2639
2641
|
},
|
|
2640
|
-
async list(
|
|
2642
|
+
async list(i, e) {
|
|
2641
2643
|
const {
|
|
2642
2644
|
page: t = 0,
|
|
2643
2645
|
per_page: r = 50,
|
|
@@ -2645,10 +2647,10 @@ function Kr(i) {
|
|
|
2645
2647
|
sort: l,
|
|
2646
2648
|
q: _
|
|
2647
2649
|
} = e || {};
|
|
2648
|
-
let d =
|
|
2650
|
+
let d = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
|
|
2649
2651
|
if (_) {
|
|
2650
2652
|
const f = pe(I, _, ["name", "client_id"]);
|
|
2651
|
-
f && (d = d.where(g(a(I.tenant_id,
|
|
2653
|
+
f && (d = d.where(g(a(I.tenant_id, i), f)));
|
|
2652
2654
|
}
|
|
2653
2655
|
if (l != null && l.sort_by) {
|
|
2654
2656
|
const f = I[l.sort_by];
|
|
@@ -2659,7 +2661,7 @@ function Kr(i) {
|
|
|
2659
2661
|
const u = (await d.offset(t * r).limit(r)).map(Ue);
|
|
2660
2662
|
if (!o)
|
|
2661
2663
|
return { clients: u };
|
|
2662
|
-
const [h] = await
|
|
2664
|
+
const [h] = await n.select({ count: V() }).from(I).where(a(I.tenant_id, i));
|
|
2663
2665
|
return {
|
|
2664
2666
|
clients: u,
|
|
2665
2667
|
start: t * r,
|
|
@@ -2667,18 +2669,18 @@ function Kr(i) {
|
|
|
2667
2669
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
2668
2670
|
};
|
|
2669
2671
|
},
|
|
2670
|
-
async remove(
|
|
2671
|
-
return (await
|
|
2672
|
+
async remove(i, e) {
|
|
2673
|
+
return (await n.delete(I).where(
|
|
2672
2674
|
g(
|
|
2673
|
-
a(I.tenant_id,
|
|
2675
|
+
a(I.tenant_id, i),
|
|
2674
2676
|
a(I.client_id, e)
|
|
2675
2677
|
)
|
|
2676
2678
|
).returning()).length > 0;
|
|
2677
2679
|
}
|
|
2678
2680
|
};
|
|
2679
2681
|
}
|
|
2680
|
-
function jr(
|
|
2681
|
-
const { tenant_id:
|
|
2682
|
+
function jr(n) {
|
|
2683
|
+
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2682
2684
|
return z({
|
|
2683
2685
|
...o,
|
|
2684
2686
|
options: b(t, {}),
|
|
@@ -2686,49 +2688,49 @@ function jr(i) {
|
|
|
2686
2688
|
is_system: e ? !0 : void 0
|
|
2687
2689
|
});
|
|
2688
2690
|
}
|
|
2689
|
-
function Mr(
|
|
2691
|
+
function Mr(n) {
|
|
2690
2692
|
return {
|
|
2691
|
-
async listByClient(
|
|
2692
|
-
const t = await
|
|
2693
|
+
async listByClient(i, e) {
|
|
2694
|
+
const t = await n.select({ connections: I.connections }).from(I).where(
|
|
2693
2695
|
g(
|
|
2694
|
-
a(I.tenant_id,
|
|
2696
|
+
a(I.tenant_id, i),
|
|
2695
2697
|
a(I.client_id, e)
|
|
2696
2698
|
)
|
|
2697
2699
|
).get();
|
|
2698
2700
|
if (!t) return [];
|
|
2699
2701
|
const r = b(t.connections, []) || [];
|
|
2700
2702
|
if (r.length === 0) return [];
|
|
2701
|
-
const l = (await
|
|
2703
|
+
const l = (await n.select().from(U).where(
|
|
2702
2704
|
g(
|
|
2703
|
-
a(U.tenant_id,
|
|
2705
|
+
a(U.tenant_id, i),
|
|
2704
2706
|
we(U.id, r)
|
|
2705
2707
|
)
|
|
2706
2708
|
).all()).map(jr);
|
|
2707
2709
|
return r.map((_) => l.find((d) => d.id === _)).filter(Boolean);
|
|
2708
2710
|
},
|
|
2709
|
-
async updateByClient(
|
|
2710
|
-
return (await
|
|
2711
|
+
async updateByClient(i, e, t) {
|
|
2712
|
+
return (await n.update(I).set({ connections: JSON.stringify([...new Set(t)]) }).where(
|
|
2711
2713
|
g(
|
|
2712
|
-
a(I.tenant_id,
|
|
2714
|
+
a(I.tenant_id, i),
|
|
2713
2715
|
a(I.client_id, e)
|
|
2714
2716
|
)
|
|
2715
2717
|
).returning()).length > 0;
|
|
2716
2718
|
},
|
|
2717
|
-
async listByConnection(
|
|
2718
|
-
return (await
|
|
2719
|
+
async listByConnection(i, e) {
|
|
2720
|
+
return (await n.select({
|
|
2719
2721
|
client_id: I.client_id,
|
|
2720
2722
|
connections: I.connections
|
|
2721
|
-
}).from(I).where(a(I.tenant_id,
|
|
2723
|
+
}).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (b(r.connections, []) || []).includes(e)).map((r) => r.client_id);
|
|
2722
2724
|
},
|
|
2723
|
-
async addClientToConnection(
|
|
2725
|
+
async addClientToConnection(i, e, t) {
|
|
2724
2726
|
var _;
|
|
2725
|
-
if (!await
|
|
2727
|
+
if (!await n.select({ client_id: I.client_id }).from(I).where(
|
|
2726
2728
|
g(
|
|
2727
|
-
a(I.tenant_id,
|
|
2729
|
+
a(I.tenant_id, i),
|
|
2728
2730
|
a(I.client_id, t)
|
|
2729
2731
|
)
|
|
2730
2732
|
).get()) return !1;
|
|
2731
|
-
const o = await
|
|
2733
|
+
const o = await n.run(
|
|
2732
2734
|
N`UPDATE clients SET connections = CASE
|
|
2733
2735
|
WHEN connections IS NULL OR connections = '[]' OR connections = ''
|
|
2734
2736
|
THEN json_array(${e})
|
|
@@ -2736,64 +2738,64 @@ function Mr(i) {
|
|
|
2736
2738
|
THEN connections
|
|
2737
2739
|
ELSE json_insert(connections, '$[#]', ${e})
|
|
2738
2740
|
END
|
|
2739
|
-
WHERE tenant_id = ${
|
|
2741
|
+
WHERE tenant_id = ${i} AND client_id = ${t}`
|
|
2740
2742
|
);
|
|
2741
2743
|
return (o.changes ?? ((_ = o.meta) == null ? void 0 : _.changes) ?? 0) > 0;
|
|
2742
2744
|
},
|
|
2743
|
-
async removeClientFromConnection(
|
|
2745
|
+
async removeClientFromConnection(i, e, t) {
|
|
2744
2746
|
var l;
|
|
2745
|
-
const r = await
|
|
2747
|
+
const r = await n.run(
|
|
2746
2748
|
N`UPDATE clients SET connections = (
|
|
2747
2749
|
SELECT COALESCE(json_group_array(je.value), '[]')
|
|
2748
2750
|
FROM json_each(COALESCE(connections, '[]')) AS je
|
|
2749
2751
|
WHERE je.value != ${e}
|
|
2750
2752
|
)
|
|
2751
|
-
WHERE tenant_id = ${
|
|
2753
|
+
WHERE tenant_id = ${i} AND client_id = ${t}`
|
|
2752
2754
|
);
|
|
2753
2755
|
return (r.changes ?? ((l = r.meta) == null ? void 0 : l.changes) ?? 0) > 0;
|
|
2754
2756
|
}
|
|
2755
2757
|
};
|
|
2756
2758
|
}
|
|
2757
|
-
let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (
|
|
2758
|
-
let t = 256 - 256 %
|
|
2759
|
+
let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (n) => crypto.getRandomValues(new Uint8Array(n)), Wr = (n, i, e) => {
|
|
2760
|
+
let t = 256 - 256 % n.length;
|
|
2759
2761
|
if (t === 256) {
|
|
2760
|
-
let o =
|
|
2761
|
-
return (l =
|
|
2762
|
+
let o = n.length - 1;
|
|
2763
|
+
return (l = i) => {
|
|
2762
2764
|
if (!l) return "";
|
|
2763
2765
|
let _ = "";
|
|
2764
2766
|
for (; ; ) {
|
|
2765
2767
|
let d = e(l), c = l;
|
|
2766
2768
|
for (; c--; )
|
|
2767
|
-
if (_ +=
|
|
2769
|
+
if (_ += n[d[c] & o], _.length >= l) return _;
|
|
2768
2770
|
}
|
|
2769
2771
|
};
|
|
2770
2772
|
}
|
|
2771
|
-
let r = Math.ceil(1.6 * 256 *
|
|
2772
|
-
return (o =
|
|
2773
|
+
let r = Math.ceil(1.6 * 256 * i / t);
|
|
2774
|
+
return (o = i) => {
|
|
2773
2775
|
if (!o) return "";
|
|
2774
2776
|
let l = "";
|
|
2775
2777
|
for (; ; ) {
|
|
2776
2778
|
let _ = e(r), d = r;
|
|
2777
2779
|
for (; d--; )
|
|
2778
|
-
if (_[d] < t && (l +=
|
|
2780
|
+
if (_[d] < t && (l += n[_[d] % n.length], l.length >= o))
|
|
2779
2781
|
return l;
|
|
2780
2782
|
}
|
|
2781
2783
|
};
|
|
2782
|
-
}, Hr = (
|
|
2783
|
-
let
|
|
2784
|
-
for (;
|
|
2785
|
-
|
|
2786
|
-
return
|
|
2784
|
+
}, Hr = (n, i = 21) => Wr(n, i | 0, Rr), ae = (n = 21) => {
|
|
2785
|
+
let i = "", e = crypto.getRandomValues(new Uint8Array(n |= 0));
|
|
2786
|
+
for (; n--; )
|
|
2787
|
+
i += Vr[e[n] & 63];
|
|
2788
|
+
return i;
|
|
2787
2789
|
};
|
|
2788
|
-
function nt(
|
|
2790
|
+
function nt(n) {
|
|
2789
2791
|
const {
|
|
2790
|
-
tenant_id:
|
|
2792
|
+
tenant_id: i,
|
|
2791
2793
|
scope: e,
|
|
2792
2794
|
authorization_details_types: t,
|
|
2793
2795
|
allow_any_organization: r,
|
|
2794
2796
|
is_system: o,
|
|
2795
2797
|
...l
|
|
2796
|
-
} =
|
|
2798
|
+
} = n;
|
|
2797
2799
|
return z({
|
|
2798
2800
|
...l,
|
|
2799
2801
|
scope: b(e, []),
|
|
@@ -2805,12 +2807,12 @@ function nt(i) {
|
|
|
2805
2807
|
is_system: !!o
|
|
2806
2808
|
});
|
|
2807
2809
|
}
|
|
2808
|
-
function Gr(
|
|
2810
|
+
function Gr(n) {
|
|
2809
2811
|
return {
|
|
2810
|
-
async create(
|
|
2812
|
+
async create(i, e) {
|
|
2811
2813
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
2812
2814
|
id: e.id || ae(),
|
|
2813
|
-
tenant_id:
|
|
2815
|
+
tenant_id: i,
|
|
2814
2816
|
client_id: e.client_id,
|
|
2815
2817
|
audience: e.audience,
|
|
2816
2818
|
scope: JSON.stringify(e.scope || []),
|
|
@@ -2824,15 +2826,15 @@ function Gr(i) {
|
|
|
2824
2826
|
created_at: t,
|
|
2825
2827
|
updated_at: t
|
|
2826
2828
|
};
|
|
2827
|
-
return await
|
|
2829
|
+
return await n.insert(G).values(o), nt({ ...o, tenant_id: i });
|
|
2828
2830
|
},
|
|
2829
|
-
async get(
|
|
2830
|
-
const t = await
|
|
2831
|
-
g(a(G.tenant_id,
|
|
2831
|
+
async get(i, e) {
|
|
2832
|
+
const t = await n.select().from(G).where(
|
|
2833
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2832
2834
|
).get();
|
|
2833
2835
|
return t ? nt(t) : null;
|
|
2834
2836
|
},
|
|
2835
|
-
async update(
|
|
2837
|
+
async update(i, e, t) {
|
|
2836
2838
|
const {
|
|
2837
2839
|
scope: r,
|
|
2838
2840
|
authorization_details_types: o,
|
|
@@ -2845,19 +2847,19 @@ function Gr(i) {
|
|
|
2845
2847
|
};
|
|
2846
2848
|
return r !== void 0 && (c.scope = JSON.stringify(r)), o !== void 0 && (c.authorization_details_types = JSON.stringify(
|
|
2847
2849
|
o
|
|
2848
|
-
)), l !== void 0 && (c.allow_any_organization = l ? 1 : 0), _ !== void 0 && (c.is_system = _ ? 1 : 0), (await
|
|
2849
|
-
g(a(G.tenant_id,
|
|
2850
|
+
)), l !== void 0 && (c.allow_any_organization = l ? 1 : 0), _ !== void 0 && (c.is_system = _ ? 1 : 0), (await n.update(G).set(c).where(
|
|
2851
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2850
2852
|
).returning()).length > 0;
|
|
2851
2853
|
},
|
|
2852
|
-
async list(
|
|
2854
|
+
async list(i, e) {
|
|
2853
2855
|
const {
|
|
2854
2856
|
page: t = 0,
|
|
2855
2857
|
per_page: r = 50,
|
|
2856
2858
|
include_totals: o = !1,
|
|
2857
2859
|
sort: l,
|
|
2858
2860
|
q: _
|
|
2859
|
-
} = e || {}, d = _ ? pe(G, _, ["client_id", "audience"]) : void 0, c = d ? g(a(G.tenant_id,
|
|
2860
|
-
let u =
|
|
2861
|
+
} = e || {}, d = _ ? pe(G, _, ["client_id", "audience"]) : void 0, c = d ? g(a(G.tenant_id, i), d) : a(G.tenant_id, i);
|
|
2862
|
+
let u = n.select().from(G).where(c).$dynamic();
|
|
2861
2863
|
if (l != null && l.sort_by) {
|
|
2862
2864
|
const w = G[l.sort_by];
|
|
2863
2865
|
w && (u = u.orderBy(
|
|
@@ -2868,7 +2870,7 @@ function Gr(i) {
|
|
|
2868
2870
|
const f = (await u.offset(t * r).limit(r)).map(nt);
|
|
2869
2871
|
if (!o)
|
|
2870
2872
|
return { client_grants: f };
|
|
2871
|
-
const [y] = await
|
|
2873
|
+
const [y] = await n.select({ count: V() }).from(G).where(c);
|
|
2872
2874
|
return {
|
|
2873
2875
|
client_grants: f,
|
|
2874
2876
|
start: t * r,
|
|
@@ -2876,48 +2878,48 @@ function Gr(i) {
|
|
|
2876
2878
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
2877
2879
|
};
|
|
2878
2880
|
},
|
|
2879
|
-
async remove(
|
|
2880
|
-
return (await
|
|
2881
|
-
g(a(G.tenant_id,
|
|
2881
|
+
async remove(i, e) {
|
|
2882
|
+
return (await n.delete(G).where(
|
|
2883
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2882
2884
|
).returning()).length > 0;
|
|
2883
2885
|
}
|
|
2884
2886
|
};
|
|
2885
2887
|
}
|
|
2886
|
-
function it(
|
|
2887
|
-
const { tenant_id:
|
|
2888
|
+
function it(n) {
|
|
2889
|
+
const { tenant_id: i, ...e } = n;
|
|
2888
2890
|
return z(e);
|
|
2889
2891
|
}
|
|
2890
|
-
function Yr(
|
|
2892
|
+
function Yr(n) {
|
|
2891
2893
|
return {
|
|
2892
|
-
async create(
|
|
2894
|
+
async create(i, e) {
|
|
2893
2895
|
const t = {
|
|
2894
2896
|
...e,
|
|
2895
|
-
tenant_id:
|
|
2897
|
+
tenant_id: i,
|
|
2896
2898
|
created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
2897
2899
|
expires_at: e.expires_at
|
|
2898
2900
|
};
|
|
2899
|
-
return await
|
|
2901
|
+
return await n.insert(B).values(t), it(t);
|
|
2900
2902
|
},
|
|
2901
|
-
async get(
|
|
2902
|
-
if (!
|
|
2903
|
+
async get(i, e, t) {
|
|
2904
|
+
if (!i)
|
|
2903
2905
|
throw new Error("tenant_id is required");
|
|
2904
|
-
const r = await
|
|
2906
|
+
const r = await n.select().from(B).where(
|
|
2905
2907
|
g(
|
|
2906
|
-
a(B.tenant_id,
|
|
2908
|
+
a(B.tenant_id, i),
|
|
2907
2909
|
a(B.code_id, e),
|
|
2908
2910
|
a(B.code_type, t)
|
|
2909
2911
|
)
|
|
2910
2912
|
).get();
|
|
2911
2913
|
return r ? it(r) : null;
|
|
2912
2914
|
},
|
|
2913
|
-
async list(
|
|
2915
|
+
async list(i, e) {
|
|
2914
2916
|
const {
|
|
2915
2917
|
page: t = 0,
|
|
2916
2918
|
per_page: r = 50,
|
|
2917
2919
|
include_totals: o = !1,
|
|
2918
2920
|
sort: l
|
|
2919
2921
|
} = e || {};
|
|
2920
|
-
let _ =
|
|
2922
|
+
let _ = n.select().from(B).where(a(B.tenant_id, i)).$dynamic();
|
|
2921
2923
|
if (l != null && l.sort_by) {
|
|
2922
2924
|
const h = B[l.sort_by];
|
|
2923
2925
|
h && (_ = _.orderBy(
|
|
@@ -2927,7 +2929,7 @@ function Yr(i) {
|
|
|
2927
2929
|
const c = (await _.offset(t * r).limit(r)).map(it);
|
|
2928
2930
|
if (!o)
|
|
2929
2931
|
return { codes: c };
|
|
2930
|
-
const [u] = await
|
|
2932
|
+
const [u] = await n.select({ count: V() }).from(B).where(a(B.tenant_id, i));
|
|
2931
2933
|
return {
|
|
2932
2934
|
codes: c,
|
|
2933
2935
|
start: t * r,
|
|
@@ -2935,29 +2937,29 @@ function Yr(i) {
|
|
|
2935
2937
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
2936
2938
|
};
|
|
2937
2939
|
},
|
|
2938
|
-
async used(
|
|
2939
|
-
return (await
|
|
2940
|
+
async used(i, e) {
|
|
2941
|
+
return (await n.update(B).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(B.tenant_id, i), a(B.code_id, e))).returning()).length > 0;
|
|
2940
2942
|
},
|
|
2941
|
-
async consume(
|
|
2942
|
-
return (await
|
|
2943
|
+
async consume(i, e) {
|
|
2944
|
+
return (await n.update(B).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
|
|
2943
2945
|
g(
|
|
2944
|
-
a(B.tenant_id,
|
|
2946
|
+
a(B.tenant_id, i),
|
|
2945
2947
|
a(B.code_id, e),
|
|
2946
2948
|
ye(B.used_at)
|
|
2947
2949
|
)
|
|
2948
2950
|
).returning()).length > 0;
|
|
2949
2951
|
},
|
|
2950
|
-
async remove(
|
|
2951
|
-
return (await
|
|
2952
|
+
async remove(i, e) {
|
|
2953
|
+
return (await n.delete(B).where(g(a(B.tenant_id, i), a(B.code_id, e))).returning()).length > 0;
|
|
2952
2954
|
}
|
|
2953
2955
|
};
|
|
2954
2956
|
}
|
|
2955
2957
|
function Xr() {
|
|
2956
|
-
const { customAlphabet:
|
|
2957
|
-
return `con_${
|
|
2958
|
+
const { customAlphabet: n } = require("nanoid");
|
|
2959
|
+
return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2958
2960
|
}
|
|
2959
|
-
function rt(
|
|
2960
|
-
const { tenant_id:
|
|
2961
|
+
function rt(n) {
|
|
2962
|
+
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2961
2963
|
return z({
|
|
2962
2964
|
...o,
|
|
2963
2965
|
options: b(t, {}),
|
|
@@ -2965,14 +2967,14 @@ function rt(i) {
|
|
|
2965
2967
|
is_system: e ? !0 : void 0
|
|
2966
2968
|
});
|
|
2967
2969
|
}
|
|
2968
|
-
function Zr(
|
|
2970
|
+
function Zr(n) {
|
|
2969
2971
|
return {
|
|
2970
|
-
async create(
|
|
2972
|
+
async create(i, e) {
|
|
2971
2973
|
var o, l;
|
|
2972
2974
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
2973
2975
|
id: e.id || Xr(),
|
|
2974
2976
|
...e,
|
|
2975
|
-
tenant_id:
|
|
2977
|
+
tenant_id: i,
|
|
2976
2978
|
options: JSON.stringify(e.options || {}),
|
|
2977
2979
|
metadata: e.metadata ? JSON.stringify(e.metadata) : void 0,
|
|
2978
2980
|
is_system: e.is_system ? 1 : 0,
|
|
@@ -2980,7 +2982,7 @@ function Zr(i) {
|
|
|
2980
2982
|
updated_at: t
|
|
2981
2983
|
};
|
|
2982
2984
|
try {
|
|
2983
|
-
await
|
|
2985
|
+
await n.insert(U).values(r);
|
|
2984
2986
|
} catch (_) {
|
|
2985
2987
|
throw (o = _ == null ? void 0 : _.message) != null && o.includes("UNIQUE constraint failed") || (l = _ == null ? void 0 : _.message) != null && l.includes("duplicate key") ? new be(409, {
|
|
2986
2988
|
message: "Connection already exists"
|
|
@@ -2988,27 +2990,27 @@ function Zr(i) {
|
|
|
2988
2990
|
}
|
|
2989
2991
|
return rt(r);
|
|
2990
2992
|
},
|
|
2991
|
-
async get(
|
|
2992
|
-
const t = await
|
|
2993
|
+
async get(i, e) {
|
|
2994
|
+
const t = await n.select().from(U).where(
|
|
2993
2995
|
g(
|
|
2994
|
-
a(U.tenant_id,
|
|
2996
|
+
a(U.tenant_id, i),
|
|
2995
2997
|
a(U.id, e)
|
|
2996
2998
|
)
|
|
2997
2999
|
).get();
|
|
2998
3000
|
return t ? rt(t) : null;
|
|
2999
3001
|
},
|
|
3000
|
-
async update(
|
|
3002
|
+
async update(i, e, t) {
|
|
3001
3003
|
const r = {
|
|
3002
3004
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3003
3005
|
};
|
|
3004
|
-
return t.name !== void 0 && (r.name = t.name), t.strategy !== void 0 && (r.strategy = t.strategy), t.options !== void 0 && (r.options = JSON.stringify(t.options)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.display_name !== void 0 && (r.display_name = t.display_name), t.response_type !== void 0 && (r.response_type = t.response_type), t.response_mode !== void 0 && (r.response_mode = t.response_mode), await
|
|
3006
|
+
return t.name !== void 0 && (r.name = t.name), t.strategy !== void 0 && (r.strategy = t.strategy), t.options !== void 0 && (r.options = JSON.stringify(t.options)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.display_name !== void 0 && (r.display_name = t.display_name), t.response_type !== void 0 && (r.response_type = t.response_type), t.response_mode !== void 0 && (r.response_mode = t.response_mode), await n.update(U).set(r).where(
|
|
3005
3007
|
g(
|
|
3006
|
-
a(U.tenant_id,
|
|
3008
|
+
a(U.tenant_id, i),
|
|
3007
3009
|
a(U.id, e)
|
|
3008
3010
|
)
|
|
3009
3011
|
), !0;
|
|
3010
3012
|
},
|
|
3011
|
-
async list(
|
|
3013
|
+
async list(i, e) {
|
|
3012
3014
|
const {
|
|
3013
3015
|
page: t = 0,
|
|
3014
3016
|
per_page: r = 50,
|
|
@@ -3016,12 +3018,12 @@ function Zr(i) {
|
|
|
3016
3018
|
sort: l,
|
|
3017
3019
|
q: _
|
|
3018
3020
|
} = e || {};
|
|
3019
|
-
let d = a(U.tenant_id,
|
|
3021
|
+
let d = a(U.tenant_id, i);
|
|
3020
3022
|
if (_) {
|
|
3021
3023
|
const y = pe(U, _, ["name"]);
|
|
3022
3024
|
y && (d = g(d, y));
|
|
3023
3025
|
}
|
|
3024
|
-
let c =
|
|
3026
|
+
let c = n.select().from(U).where(d).$dynamic();
|
|
3025
3027
|
if (l != null && l.sort_by) {
|
|
3026
3028
|
const y = U[l.sort_by];
|
|
3027
3029
|
y && (c = c.orderBy(
|
|
@@ -3031,7 +3033,7 @@ function Zr(i) {
|
|
|
3031
3033
|
const h = (await c.offset(t * r).limit(r)).map(rt);
|
|
3032
3034
|
if (!o)
|
|
3033
3035
|
return { connections: h };
|
|
3034
|
-
const [f] = await
|
|
3036
|
+
const [f] = await n.select({ count: V() }).from(U).where(d);
|
|
3035
3037
|
return {
|
|
3036
3038
|
connections: h,
|
|
3037
3039
|
start: t * r,
|
|
@@ -3039,30 +3041,30 @@ function Zr(i) {
|
|
|
3039
3041
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
3040
3042
|
};
|
|
3041
3043
|
},
|
|
3042
|
-
async remove(
|
|
3043
|
-
return (await
|
|
3044
|
+
async remove(i, e) {
|
|
3045
|
+
return (await n.delete(U).where(
|
|
3044
3046
|
g(
|
|
3045
|
-
a(U.tenant_id,
|
|
3047
|
+
a(U.tenant_id, i),
|
|
3046
3048
|
a(U.id, e)
|
|
3047
3049
|
)
|
|
3048
3050
|
).returning()).length > 0;
|
|
3049
3051
|
}
|
|
3050
3052
|
};
|
|
3051
3053
|
}
|
|
3052
|
-
function Ke(
|
|
3053
|
-
const { tenant_id:
|
|
3054
|
+
function Ke(n) {
|
|
3055
|
+
const { tenant_id: i, domain_metadata: e, ...t } = n;
|
|
3054
3056
|
return z({
|
|
3055
3057
|
...t,
|
|
3056
3058
|
primary: !!t.primary,
|
|
3057
3059
|
domain_metadata: b(e)
|
|
3058
3060
|
});
|
|
3059
3061
|
}
|
|
3060
|
-
function es(
|
|
3062
|
+
function es(n) {
|
|
3061
3063
|
return {
|
|
3062
|
-
async create(
|
|
3064
|
+
async create(i, e) {
|
|
3063
3065
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3064
3066
|
custom_domain_id: e.custom_domain_id || ae(),
|
|
3065
|
-
tenant_id:
|
|
3067
|
+
tenant_id: i,
|
|
3066
3068
|
domain: e.domain,
|
|
3067
3069
|
primary: e.primary ?? !1,
|
|
3068
3070
|
status: e.status || "pending",
|
|
@@ -3075,54 +3077,54 @@ function es(i) {
|
|
|
3075
3077
|
created_at: t,
|
|
3076
3078
|
updated_at: t
|
|
3077
3079
|
};
|
|
3078
|
-
return await
|
|
3080
|
+
return await n.insert(re).values(o), Ke({ ...o, tenant_id: i });
|
|
3079
3081
|
},
|
|
3080
|
-
async get(
|
|
3081
|
-
const t = await
|
|
3082
|
+
async get(i, e) {
|
|
3083
|
+
const t = await n.select().from(re).where(
|
|
3082
3084
|
g(
|
|
3083
|
-
a(re.tenant_id,
|
|
3085
|
+
a(re.tenant_id, i),
|
|
3084
3086
|
a(re.custom_domain_id, e)
|
|
3085
3087
|
)
|
|
3086
3088
|
).get();
|
|
3087
3089
|
return t ? Ke(t) : null;
|
|
3088
3090
|
},
|
|
3089
|
-
async getByDomain(
|
|
3090
|
-
const e = await
|
|
3091
|
+
async getByDomain(i) {
|
|
3092
|
+
const e = await n.select().from(re).where(a(re.domain, i)).get();
|
|
3091
3093
|
return e ? {
|
|
3092
3094
|
...Ke(e),
|
|
3093
3095
|
tenant_id: e.tenant_id
|
|
3094
3096
|
} : null;
|
|
3095
3097
|
},
|
|
3096
|
-
async list(
|
|
3097
|
-
return (await
|
|
3098
|
+
async list(i) {
|
|
3099
|
+
return (await n.select().from(re).where(a(re.tenant_id, i)).all()).map(Ke);
|
|
3098
3100
|
},
|
|
3099
|
-
async update(
|
|
3101
|
+
async update(i, e, t) {
|
|
3100
3102
|
const r = {
|
|
3101
3103
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3102
3104
|
};
|
|
3103
|
-
return t.domain !== void 0 && (r.domain = t.domain), t.primary !== void 0 && (r.primary = t.primary), t.status !== void 0 && (r.status = t.status), t.type !== void 0 && (r.type = t.type), t.origin_domain_name !== void 0 && (r.origin_domain_name = t.origin_domain_name), t.verification !== void 0 && (r.verification = t.verification), t.custom_client_ip_header !== void 0 && (r.custom_client_ip_header = t.custom_client_ip_header), t.tls_policy !== void 0 && (r.tls_policy = t.tls_policy), t.domain_metadata !== void 0 && (r.domain_metadata = JSON.stringify(t.domain_metadata)), (await
|
|
3105
|
+
return t.domain !== void 0 && (r.domain = t.domain), t.primary !== void 0 && (r.primary = t.primary), t.status !== void 0 && (r.status = t.status), t.type !== void 0 && (r.type = t.type), t.origin_domain_name !== void 0 && (r.origin_domain_name = t.origin_domain_name), t.verification !== void 0 && (r.verification = t.verification), t.custom_client_ip_header !== void 0 && (r.custom_client_ip_header = t.custom_client_ip_header), t.tls_policy !== void 0 && (r.tls_policy = t.tls_policy), t.domain_metadata !== void 0 && (r.domain_metadata = JSON.stringify(t.domain_metadata)), (await n.update(re).set(r).where(
|
|
3104
3106
|
g(
|
|
3105
|
-
a(re.tenant_id,
|
|
3107
|
+
a(re.tenant_id, i),
|
|
3106
3108
|
a(re.custom_domain_id, e)
|
|
3107
3109
|
)
|
|
3108
3110
|
).returning()).length > 0;
|
|
3109
3111
|
},
|
|
3110
|
-
async remove(
|
|
3111
|
-
return (await
|
|
3112
|
+
async remove(i, e) {
|
|
3113
|
+
return (await n.delete(re).where(
|
|
3112
3114
|
g(
|
|
3113
|
-
a(re.tenant_id,
|
|
3115
|
+
a(re.tenant_id, i),
|
|
3114
3116
|
a(re.custom_domain_id, e)
|
|
3115
3117
|
)
|
|
3116
3118
|
).returning()).length > 0;
|
|
3117
3119
|
}
|
|
3118
3120
|
};
|
|
3119
3121
|
}
|
|
3120
|
-
function ts(
|
|
3122
|
+
function ts(n) {
|
|
3121
3123
|
return {
|
|
3122
|
-
async get(
|
|
3123
|
-
const r = await
|
|
3124
|
+
async get(i, e, t) {
|
|
3125
|
+
const r = await n.select().from(ee).where(
|
|
3124
3126
|
g(
|
|
3125
|
-
a(ee.tenant_id,
|
|
3127
|
+
a(ee.tenant_id, i),
|
|
3126
3128
|
a(ee.prompt, e),
|
|
3127
3129
|
a(ee.language, t)
|
|
3128
3130
|
)
|
|
@@ -3134,10 +3136,10 @@ function ts(i) {
|
|
|
3134
3136
|
return null;
|
|
3135
3137
|
}
|
|
3136
3138
|
},
|
|
3137
|
-
async set(
|
|
3139
|
+
async set(i, e, t, r) {
|
|
3138
3140
|
const o = Date.now(), l = JSON.stringify(r);
|
|
3139
|
-
await
|
|
3140
|
-
tenant_id:
|
|
3141
|
+
await n.insert(ee).values({
|
|
3142
|
+
tenant_id: i,
|
|
3141
3143
|
prompt: e,
|
|
3142
3144
|
language: t,
|
|
3143
3145
|
custom_text: l,
|
|
@@ -3152,29 +3154,29 @@ function ts(i) {
|
|
|
3152
3154
|
set: { custom_text: l, updated_at_ts: o }
|
|
3153
3155
|
});
|
|
3154
3156
|
},
|
|
3155
|
-
async delete(
|
|
3156
|
-
await
|
|
3157
|
+
async delete(i, e, t) {
|
|
3158
|
+
await n.delete(ee).where(
|
|
3157
3159
|
g(
|
|
3158
|
-
a(ee.tenant_id,
|
|
3160
|
+
a(ee.tenant_id, i),
|
|
3159
3161
|
a(ee.prompt, e),
|
|
3160
3162
|
a(ee.language, t)
|
|
3161
3163
|
)
|
|
3162
3164
|
);
|
|
3163
3165
|
},
|
|
3164
|
-
async list(
|
|
3165
|
-
return await
|
|
3166
|
+
async list(i) {
|
|
3167
|
+
return await n.select({
|
|
3166
3168
|
prompt: ee.prompt,
|
|
3167
3169
|
language: ee.language
|
|
3168
|
-
}).from(ee).where(a(ee.tenant_id,
|
|
3170
|
+
}).from(ee).where(a(ee.tenant_id, i)).all();
|
|
3169
3171
|
}
|
|
3170
3172
|
};
|
|
3171
3173
|
}
|
|
3172
|
-
function ns(
|
|
3174
|
+
function ns(n) {
|
|
3173
3175
|
return {
|
|
3174
|
-
async create(
|
|
3176
|
+
async create(i, e) {
|
|
3175
3177
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
3176
|
-
await
|
|
3177
|
-
tenant_id:
|
|
3178
|
+
await n.insert(ve).values({
|
|
3179
|
+
tenant_id: i,
|
|
3178
3180
|
name: e.name,
|
|
3179
3181
|
enabled: e.enabled,
|
|
3180
3182
|
default_from_address: e.default_from_address,
|
|
@@ -3184,8 +3186,8 @@ function ns(i) {
|
|
|
3184
3186
|
updated_at: t
|
|
3185
3187
|
});
|
|
3186
3188
|
},
|
|
3187
|
-
async get(
|
|
3188
|
-
const e = await
|
|
3189
|
+
async get(i) {
|
|
3190
|
+
const e = await n.select().from(ve).where(a(ve.tenant_id, i)).get();
|
|
3189
3191
|
if (!e) return null;
|
|
3190
3192
|
const { tenant_id: t, ...r } = e;
|
|
3191
3193
|
return z({
|
|
@@ -3195,24 +3197,24 @@ function ns(i) {
|
|
|
3195
3197
|
settings: b(r.settings, {})
|
|
3196
3198
|
});
|
|
3197
3199
|
},
|
|
3198
|
-
async update(
|
|
3200
|
+
async update(i, e) {
|
|
3199
3201
|
const t = {
|
|
3200
3202
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3201
3203
|
};
|
|
3202
|
-
e.name !== void 0 && (t.name = e.name), e.enabled !== void 0 && (t.enabled = e.enabled), e.default_from_address !== void 0 && (t.default_from_address = e.default_from_address), e.credentials !== void 0 && (t.credentials = JSON.stringify(e.credentials)), e.settings !== void 0 && (t.settings = JSON.stringify(e.settings)), await
|
|
3204
|
+
e.name !== void 0 && (t.name = e.name), e.enabled !== void 0 && (t.enabled = e.enabled), e.default_from_address !== void 0 && (t.default_from_address = e.default_from_address), e.credentials !== void 0 && (t.credentials = JSON.stringify(e.credentials)), e.settings !== void 0 && (t.settings = JSON.stringify(e.settings)), await n.update(ve).set(t).where(a(ve.tenant_id, i));
|
|
3203
3205
|
},
|
|
3204
|
-
async remove(
|
|
3205
|
-
await
|
|
3206
|
+
async remove(i) {
|
|
3207
|
+
await n.delete(ve).where(a(ve.tenant_id, i));
|
|
3206
3208
|
}
|
|
3207
3209
|
};
|
|
3208
3210
|
}
|
|
3209
|
-
function is(
|
|
3211
|
+
function is(n) {
|
|
3210
3212
|
return {
|
|
3211
|
-
async create(
|
|
3213
|
+
async create(i, e) {
|
|
3212
3214
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = `af_${ae()}`;
|
|
3213
|
-
return await
|
|
3215
|
+
return await n.insert(ie).values({
|
|
3214
3216
|
id: r,
|
|
3215
|
-
tenant_id:
|
|
3217
|
+
tenant_id: i,
|
|
3216
3218
|
name: e.name,
|
|
3217
3219
|
actions: JSON.stringify(e.actions || []),
|
|
3218
3220
|
created_at: t,
|
|
@@ -3225,8 +3227,8 @@ function is(i) {
|
|
|
3225
3227
|
updated_at: t
|
|
3226
3228
|
};
|
|
3227
3229
|
},
|
|
3228
|
-
async get(
|
|
3229
|
-
const t = await
|
|
3230
|
+
async get(i, e) {
|
|
3231
|
+
const t = await n.select().from(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).get();
|
|
3230
3232
|
if (!t) return null;
|
|
3231
3233
|
const { tenant_id: r, actions: o, ...l } = t;
|
|
3232
3234
|
return z({
|
|
@@ -3234,20 +3236,20 @@ function is(i) {
|
|
|
3234
3236
|
actions: b(o, [])
|
|
3235
3237
|
});
|
|
3236
3238
|
},
|
|
3237
|
-
async update(
|
|
3239
|
+
async update(i, e, t) {
|
|
3238
3240
|
const r = {
|
|
3239
3241
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3240
3242
|
};
|
|
3241
|
-
return t.name !== void 0 && (r.name = t.name), t.actions !== void 0 && (r.actions = JSON.stringify(t.actions)), (await
|
|
3243
|
+
return t.name !== void 0 && (r.name = t.name), t.actions !== void 0 && (r.actions = JSON.stringify(t.actions)), (await n.update(ie).set(r).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length === 0 ? null : this.get(i, e);
|
|
3242
3244
|
},
|
|
3243
|
-
async list(
|
|
3245
|
+
async list(i, e) {
|
|
3244
3246
|
const {
|
|
3245
3247
|
page: t = 0,
|
|
3246
3248
|
per_page: r = 50,
|
|
3247
3249
|
include_totals: o = !1,
|
|
3248
3250
|
sort: l
|
|
3249
3251
|
} = e || {};
|
|
3250
|
-
let _ =
|
|
3252
|
+
let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
|
|
3251
3253
|
if (l != null && l.sort_by) {
|
|
3252
3254
|
const h = ie[l.sort_by];
|
|
3253
3255
|
h && (_ = _.orderBy(
|
|
@@ -3263,7 +3265,7 @@ function is(i) {
|
|
|
3263
3265
|
});
|
|
3264
3266
|
if (!o)
|
|
3265
3267
|
return { flows: c };
|
|
3266
|
-
const [u] = await
|
|
3268
|
+
const [u] = await n.select({ count: V() }).from(ie).where(a(ie.tenant_id, i));
|
|
3267
3269
|
return {
|
|
3268
3270
|
flows: c,
|
|
3269
3271
|
start: t * r,
|
|
@@ -3271,18 +3273,18 @@ function is(i) {
|
|
|
3271
3273
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3272
3274
|
};
|
|
3273
3275
|
},
|
|
3274
|
-
async remove(
|
|
3275
|
-
return (await
|
|
3276
|
+
async remove(i, e) {
|
|
3277
|
+
return (await n.delete(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length > 0;
|
|
3276
3278
|
}
|
|
3277
3279
|
};
|
|
3278
3280
|
}
|
|
3279
3281
|
const je = ["nodes", "start", "ending"];
|
|
3280
|
-
function rs(
|
|
3282
|
+
function rs(n) {
|
|
3281
3283
|
return {
|
|
3282
|
-
async create(
|
|
3284
|
+
async create(i, e) {
|
|
3283
3285
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = ae(), o = {
|
|
3284
3286
|
id: r,
|
|
3285
|
-
tenant_id:
|
|
3287
|
+
tenant_id: i,
|
|
3286
3288
|
name: e.name,
|
|
3287
3289
|
messages: e.messages,
|
|
3288
3290
|
languages: e.languages,
|
|
@@ -3295,37 +3297,37 @@ function rs(i) {
|
|
|
3295
3297
|
o[l] = JSON.stringify(
|
|
3296
3298
|
e[l] || (l === "nodes" ? [] : {})
|
|
3297
3299
|
);
|
|
3298
|
-
return await
|
|
3300
|
+
return await n.insert(ne).values(o), {
|
|
3299
3301
|
id: r,
|
|
3300
3302
|
...e,
|
|
3301
3303
|
created_at: t,
|
|
3302
3304
|
updated_at: t
|
|
3303
3305
|
};
|
|
3304
3306
|
},
|
|
3305
|
-
async get(
|
|
3306
|
-
const t = await
|
|
3307
|
+
async get(i, e) {
|
|
3308
|
+
const t = await n.select().from(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).get();
|
|
3307
3309
|
if (!t) return null;
|
|
3308
3310
|
const { tenant_id: r, ...o } = t, l = { ...o };
|
|
3309
3311
|
for (const _ of je)
|
|
3310
3312
|
l[_] = b(o[_]);
|
|
3311
3313
|
return z(l);
|
|
3312
3314
|
},
|
|
3313
|
-
async update(
|
|
3315
|
+
async update(i, e, t) {
|
|
3314
3316
|
const r = {
|
|
3315
3317
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3316
3318
|
};
|
|
3317
3319
|
for (const [l, _] of Object.entries(t))
|
|
3318
3320
|
_ !== void 0 && (je.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
|
|
3319
|
-
return (await
|
|
3321
|
+
return (await n.update(ne).set(r).where(g(a(ne.tenant_id, i), a(ne.id, e))).returning()).length > 0;
|
|
3320
3322
|
},
|
|
3321
|
-
async list(
|
|
3323
|
+
async list(i, e) {
|
|
3322
3324
|
const {
|
|
3323
3325
|
page: t = 0,
|
|
3324
3326
|
per_page: r = 50,
|
|
3325
3327
|
include_totals: o = !1,
|
|
3326
3328
|
sort: l
|
|
3327
3329
|
} = e || {};
|
|
3328
|
-
let _ =
|
|
3330
|
+
let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
|
|
3329
3331
|
if (l != null && l.sort_by) {
|
|
3330
3332
|
const h = ne[l.sort_by];
|
|
3331
3333
|
h && (_ = _.orderBy(
|
|
@@ -3340,7 +3342,7 @@ function rs(i) {
|
|
|
3340
3342
|
});
|
|
3341
3343
|
if (!o)
|
|
3342
3344
|
return { forms: c };
|
|
3343
|
-
const [u] = await
|
|
3345
|
+
const [u] = await n.select({ count: V() }).from(ne).where(a(ne.tenant_id, i));
|
|
3344
3346
|
return {
|
|
3345
3347
|
forms: c,
|
|
3346
3348
|
start: t * r,
|
|
@@ -3348,53 +3350,50 @@ function rs(i) {
|
|
|
3348
3350
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3349
3351
|
};
|
|
3350
3352
|
},
|
|
3351
|
-
async remove(
|
|
3352
|
-
return (await
|
|
3353
|
+
async remove(i, e) {
|
|
3354
|
+
return (await n.delete(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).returning()).length > 0;
|
|
3353
3355
|
}
|
|
3354
3356
|
};
|
|
3355
3357
|
}
|
|
3356
|
-
function fr(
|
|
3357
|
-
if (
|
|
3358
|
-
if (typeof
|
|
3359
|
-
return new Date(
|
|
3360
|
-
if (typeof
|
|
3361
|
-
if (
|
|
3358
|
+
function fr(n) {
|
|
3359
|
+
if (n != null) {
|
|
3360
|
+
if (typeof n == "number")
|
|
3361
|
+
return new Date(n).toISOString();
|
|
3362
|
+
if (typeof n == "string") {
|
|
3363
|
+
if (n === "")
|
|
3362
3364
|
return;
|
|
3363
|
-
const
|
|
3364
|
-
return !isNaN(
|
|
3365
|
+
const i = parseFloat(n);
|
|
3366
|
+
return !isNaN(i) && /^\d+(\.\d+)?$/.test(n) ? new Date(i).toISOString() : n;
|
|
3365
3367
|
}
|
|
3366
3368
|
}
|
|
3367
3369
|
}
|
|
3368
|
-
function wt(
|
|
3369
|
-
return fr(
|
|
3370
|
+
function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
|
|
3371
|
+
return fr(n) ?? i;
|
|
3370
3372
|
}
|
|
3371
|
-
function K(
|
|
3372
|
-
if (!
|
|
3373
|
+
function K(n) {
|
|
3374
|
+
if (!n || n === "")
|
|
3373
3375
|
return null;
|
|
3374
|
-
const
|
|
3375
|
-
return isNaN(
|
|
3376
|
+
const i = new Date(n);
|
|
3377
|
+
return isNaN(i.getTime()) ? null : i.getTime();
|
|
3376
3378
|
}
|
|
3377
|
-
function Fe(
|
|
3379
|
+
function Fe(n, i, e = []) {
|
|
3378
3380
|
const t = {};
|
|
3379
|
-
for (const r of
|
|
3381
|
+
for (const r of i) {
|
|
3380
3382
|
const o = r.replace(/_ts$/, "");
|
|
3381
|
-
t[o] = wt(
|
|
3383
|
+
t[o] = wt(n[r]);
|
|
3382
3384
|
}
|
|
3383
3385
|
for (const r of e) {
|
|
3384
3386
|
const o = r.replace(/_ts$/, "");
|
|
3385
|
-
t[o] = fr(
|
|
3387
|
+
t[o] = fr(n[r]);
|
|
3386
3388
|
}
|
|
3387
3389
|
return t;
|
|
3388
3390
|
}
|
|
3389
|
-
const ss = Hr(
|
|
3390
|
-
"0123456789abcdefghijklmnopqrstuvwxyz",
|
|
3391
|
-
17
|
|
3392
|
-
);
|
|
3391
|
+
const ss = Hr("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3393
3392
|
function os() {
|
|
3394
3393
|
return `hc_${ss()}`;
|
|
3395
3394
|
}
|
|
3396
|
-
function Ct(
|
|
3397
|
-
const { created_at_ts:
|
|
3395
|
+
function Ct(n) {
|
|
3396
|
+
const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Fe({ created_at_ts: i, updated_at_ts: e }, [
|
|
3398
3397
|
"created_at_ts",
|
|
3399
3398
|
"updated_at_ts"
|
|
3400
3399
|
]);
|
|
@@ -3404,40 +3403,40 @@ function Ct(i) {
|
|
|
3404
3403
|
secrets: t ? JSON.parse(t) : void 0
|
|
3405
3404
|
};
|
|
3406
3405
|
}
|
|
3407
|
-
function as(
|
|
3406
|
+
function as(n) {
|
|
3408
3407
|
return {
|
|
3409
|
-
async create(
|
|
3408
|
+
async create(i, e) {
|
|
3410
3409
|
const t = Date.now(), o = {
|
|
3411
3410
|
id: os(),
|
|
3412
|
-
tenant_id:
|
|
3411
|
+
tenant_id: i,
|
|
3413
3412
|
code: e.code,
|
|
3414
3413
|
secrets: e.secrets ? JSON.stringify(e.secrets) : null,
|
|
3415
3414
|
created_at_ts: t,
|
|
3416
3415
|
updated_at_ts: t
|
|
3417
3416
|
};
|
|
3418
|
-
return await
|
|
3417
|
+
return await n.insert(me).values(o), Ct({ ...o, tenant_id: i });
|
|
3419
3418
|
},
|
|
3420
|
-
async get(
|
|
3421
|
-
const t = await
|
|
3419
|
+
async get(i, e) {
|
|
3420
|
+
const t = await n.select().from(me).where(g(a(me.tenant_id, i), a(me.id, e))).get();
|
|
3422
3421
|
return t ? Ct(t) : null;
|
|
3423
3422
|
},
|
|
3424
|
-
async update(
|
|
3423
|
+
async update(i, e, t) {
|
|
3425
3424
|
const r = {
|
|
3426
3425
|
updated_at_ts: Date.now()
|
|
3427
3426
|
};
|
|
3428
|
-
return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await
|
|
3427
|
+
return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(me).set(r).where(g(a(me.tenant_id, i), a(me.id, e))).returning()).length > 0;
|
|
3429
3428
|
},
|
|
3430
|
-
async remove(
|
|
3431
|
-
return (await
|
|
3429
|
+
async remove(i, e) {
|
|
3430
|
+
return (await n.delete(me).where(g(a(me.tenant_id, i), a(me.id, e))).returning()).length > 0;
|
|
3432
3431
|
}
|
|
3433
3432
|
};
|
|
3434
3433
|
}
|
|
3435
3434
|
function ls() {
|
|
3436
|
-
const { customAlphabet:
|
|
3437
|
-
return `h_${
|
|
3435
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3436
|
+
return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3438
3437
|
}
|
|
3439
|
-
function st(
|
|
3440
|
-
const { tenant_id:
|
|
3438
|
+
function st(n) {
|
|
3439
|
+
const { tenant_id: i, created_at_ts: e, updated_at_ts: t, ...r } = n, o = Fe({ created_at_ts: e, updated_at_ts: t }, [
|
|
3441
3440
|
"created_at_ts",
|
|
3442
3441
|
"updated_at_ts"
|
|
3443
3442
|
]);
|
|
@@ -3448,12 +3447,12 @@ function st(i) {
|
|
|
3448
3447
|
...o
|
|
3449
3448
|
});
|
|
3450
3449
|
}
|
|
3451
|
-
function _s(
|
|
3450
|
+
function _s(n) {
|
|
3452
3451
|
return {
|
|
3453
|
-
async create(
|
|
3452
|
+
async create(i, e) {
|
|
3454
3453
|
const t = Date.now(), o = {
|
|
3455
3454
|
hook_id: e.hook_id || ls(),
|
|
3456
|
-
tenant_id:
|
|
3455
|
+
tenant_id: i,
|
|
3457
3456
|
trigger_id: e.trigger_id,
|
|
3458
3457
|
url: e.url,
|
|
3459
3458
|
enabled: e.enabled ?? !0,
|
|
@@ -3465,19 +3464,19 @@ function _s(i) {
|
|
|
3465
3464
|
created_at_ts: t,
|
|
3466
3465
|
updated_at_ts: t
|
|
3467
3466
|
};
|
|
3468
|
-
return await
|
|
3467
|
+
return await n.insert(Z).values(o), st({ ...o, tenant_id: i });
|
|
3469
3468
|
},
|
|
3470
|
-
async get(
|
|
3471
|
-
const t = await
|
|
3469
|
+
async get(i, e) {
|
|
3470
|
+
const t = await n.select().from(Z).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).get();
|
|
3472
3471
|
return t ? st(t) : null;
|
|
3473
3472
|
},
|
|
3474
|
-
async update(
|
|
3473
|
+
async update(i, e, t) {
|
|
3475
3474
|
const r = {
|
|
3476
3475
|
updated_at_ts: Date.now()
|
|
3477
3476
|
};
|
|
3478
|
-
return t.trigger_id !== void 0 && (r.trigger_id = t.trigger_id), t.url !== void 0 && (r.url = t.url), t.enabled !== void 0 && (r.enabled = t.enabled), t.synchronous !== void 0 && (r.synchronous = t.synchronous), t.priority !== void 0 && (r.priority = t.priority), t.form_id !== void 0 && (r.form_id = t.form_id), t.template_id !== void 0 && (r.template_id = t.template_id), t.code_id !== void 0 && (r.code_id = t.code_id), (await
|
|
3477
|
+
return t.trigger_id !== void 0 && (r.trigger_id = t.trigger_id), t.url !== void 0 && (r.url = t.url), t.enabled !== void 0 && (r.enabled = t.enabled), t.synchronous !== void 0 && (r.synchronous = t.synchronous), t.priority !== void 0 && (r.priority = t.priority), t.form_id !== void 0 && (r.form_id = t.form_id), t.template_id !== void 0 && (r.template_id = t.template_id), t.code_id !== void 0 && (r.code_id = t.code_id), (await n.update(Z).set(r).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).returning()).length > 0;
|
|
3479
3478
|
},
|
|
3480
|
-
async list(
|
|
3479
|
+
async list(i, e) {
|
|
3481
3480
|
const {
|
|
3482
3481
|
page: t = 0,
|
|
3483
3482
|
per_page: r = 50,
|
|
@@ -3489,8 +3488,8 @@ function _s(i) {
|
|
|
3489
3488
|
"form_id",
|
|
3490
3489
|
"template_id",
|
|
3491
3490
|
"code_id"
|
|
3492
|
-
]) : void 0, c = d ? g(a(Z.tenant_id,
|
|
3493
|
-
let u =
|
|
3491
|
+
]) : void 0, c = d ? g(a(Z.tenant_id, i), d) : a(Z.tenant_id, i);
|
|
3492
|
+
let u = n.select().from(Z).where(c).$dynamic();
|
|
3494
3493
|
if (l != null && l.sort_by) {
|
|
3495
3494
|
const w = Z[l.sort_by];
|
|
3496
3495
|
w && (u = u.orderBy(
|
|
@@ -3500,7 +3499,7 @@ function _s(i) {
|
|
|
3500
3499
|
const f = (await u.offset(t * r).limit(r)).map(st);
|
|
3501
3500
|
if (!o)
|
|
3502
3501
|
return { hooks: f };
|
|
3503
|
-
const [y] = await
|
|
3502
|
+
const [y] = await n.select({ count: V() }).from(Z).where(c);
|
|
3504
3503
|
return {
|
|
3505
3504
|
hooks: f,
|
|
3506
3505
|
start: t * r,
|
|
@@ -3508,14 +3507,14 @@ function _s(i) {
|
|
|
3508
3507
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
3509
3508
|
};
|
|
3510
3509
|
},
|
|
3511
|
-
async remove(
|
|
3512
|
-
return (await
|
|
3510
|
+
async remove(i, e) {
|
|
3511
|
+
return (await n.delete(Z).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).returning()).length > 0;
|
|
3513
3512
|
}
|
|
3514
3513
|
};
|
|
3515
3514
|
}
|
|
3516
3515
|
function us() {
|
|
3517
|
-
const { customAlphabet:
|
|
3518
|
-
return `inv_${
|
|
3516
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3517
|
+
return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3519
3518
|
}
|
|
3520
3519
|
const Nt = [
|
|
3521
3520
|
"inviter",
|
|
@@ -3524,19 +3523,19 @@ const Nt = [
|
|
|
3524
3523
|
"user_metadata",
|
|
3525
3524
|
"roles"
|
|
3526
3525
|
];
|
|
3527
|
-
function ot(
|
|
3528
|
-
const { tenant_id:
|
|
3526
|
+
function ot(n) {
|
|
3527
|
+
const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
|
|
3529
3528
|
for (const o of Nt)
|
|
3530
3529
|
r[o] = b(t[o], o === "roles" ? [] : {});
|
|
3531
3530
|
return r.send_invitation_email = !!e, z(r);
|
|
3532
3531
|
}
|
|
3533
|
-
function ds(
|
|
3532
|
+
function ds(n) {
|
|
3534
3533
|
return {
|
|
3535
|
-
async create(
|
|
3534
|
+
async create(i, e) {
|
|
3536
3535
|
var d, c;
|
|
3537
3536
|
const t = e.id || us(), r = e.ttl_sec || 604800, o = /* @__PURE__ */ new Date(), l = new Date(o.getTime() + r * 1e3).toISOString(), _ = {
|
|
3538
3537
|
id: t,
|
|
3539
|
-
tenant_id:
|
|
3538
|
+
tenant_id: i,
|
|
3540
3539
|
organization_id: e.organization_id,
|
|
3541
3540
|
client_id: e.client_id,
|
|
3542
3541
|
connection_id: e.connection_id,
|
|
@@ -3550,32 +3549,32 @@ function ds(i) {
|
|
|
3550
3549
|
for (const u of Nt)
|
|
3551
3550
|
e[u] !== void 0 && (_[u] = JSON.stringify(e[u]));
|
|
3552
3551
|
try {
|
|
3553
|
-
await
|
|
3552
|
+
await n.insert(te).values(_);
|
|
3554
3553
|
} catch (u) {
|
|
3555
3554
|
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 be(409, { message: "Invite already exists" }) : u;
|
|
3556
3555
|
}
|
|
3557
|
-
return ot({ ..._, tenant_id:
|
|
3556
|
+
return ot({ ..._, tenant_id: i });
|
|
3558
3557
|
},
|
|
3559
|
-
async get(
|
|
3560
|
-
const t = await
|
|
3558
|
+
async get(i, e) {
|
|
3559
|
+
const t = await n.select().from(te).where(g(a(te.tenant_id, i), a(te.id, e))).get();
|
|
3561
3560
|
return t ? ot(t) : null;
|
|
3562
3561
|
},
|
|
3563
|
-
async update(
|
|
3562
|
+
async update(i, e, t) {
|
|
3564
3563
|
const r = {};
|
|
3565
3564
|
for (const l of Nt)
|
|
3566
3565
|
t[l] !== void 0 && (r[l] = JSON.stringify(t[l]));
|
|
3567
3566
|
return t.connection_id !== void 0 && (r.connection_id = t.connection_id), t.ttl_sec !== void 0 && (r.ttl_sec = t.ttl_sec, r.expires_at = new Date(
|
|
3568
3567
|
Date.now() + t.ttl_sec * 1e3
|
|
3569
|
-
).toISOString()), (await
|
|
3568
|
+
).toISOString()), (await n.update(te).set(r).where(g(a(te.tenant_id, i), a(te.id, e))).returning()).length > 0;
|
|
3570
3569
|
},
|
|
3571
|
-
async list(
|
|
3570
|
+
async list(i, e) {
|
|
3572
3571
|
const {
|
|
3573
3572
|
page: t = 0,
|
|
3574
3573
|
per_page: r = 50,
|
|
3575
3574
|
include_totals: o = !1,
|
|
3576
3575
|
sort: l
|
|
3577
3576
|
} = e || {};
|
|
3578
|
-
let _ =
|
|
3577
|
+
let _ = n.select().from(te).where(a(te.tenant_id, i)).$dynamic();
|
|
3579
3578
|
if (l != null && l.sort_by) {
|
|
3580
3579
|
const h = te[l.sort_by];
|
|
3581
3580
|
h && (_ = _.orderBy(
|
|
@@ -3585,7 +3584,7 @@ function ds(i) {
|
|
|
3585
3584
|
const c = (await _.offset(t * r).limit(r)).map(ot);
|
|
3586
3585
|
if (!o)
|
|
3587
3586
|
return { invites: c };
|
|
3588
|
-
const [u] = await
|
|
3587
|
+
const [u] = await n.select({ count: V() }).from(te).where(a(te.tenant_id, i));
|
|
3589
3588
|
return {
|
|
3590
3589
|
invites: c,
|
|
3591
3590
|
start: t * r,
|
|
@@ -3593,27 +3592,27 @@ function ds(i) {
|
|
|
3593
3592
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3594
3593
|
};
|
|
3595
3594
|
},
|
|
3596
|
-
async remove(
|
|
3597
|
-
return (await
|
|
3595
|
+
async remove(i, e) {
|
|
3596
|
+
return (await n.delete(te).where(g(a(te.tenant_id, i), a(te.id, e))).returning()).length > 0;
|
|
3598
3597
|
}
|
|
3599
3598
|
};
|
|
3600
3599
|
}
|
|
3601
|
-
function cs(
|
|
3600
|
+
function cs(n) {
|
|
3602
3601
|
return {
|
|
3603
|
-
async create(
|
|
3604
|
-
await
|
|
3605
|
-
...
|
|
3602
|
+
async create(i) {
|
|
3603
|
+
await n.insert(he).values({
|
|
3604
|
+
...i,
|
|
3606
3605
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
3607
3606
|
});
|
|
3608
3607
|
},
|
|
3609
|
-
async list(
|
|
3608
|
+
async list(i) {
|
|
3610
3609
|
const {
|
|
3611
3610
|
page: e = 0,
|
|
3612
3611
|
per_page: t = 50,
|
|
3613
3612
|
include_totals: r = !1,
|
|
3614
3613
|
sort: o
|
|
3615
|
-
} =
|
|
3616
|
-
let _ =
|
|
3614
|
+
} = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
3615
|
+
let _ = n.select().from(he).where(de(He(he.revoked_at, l), ye(he.revoked_at))).$dynamic();
|
|
3617
3616
|
if (o != null && o.sort_by) {
|
|
3618
3617
|
const h = he[o.sort_by];
|
|
3619
3618
|
h && (_ = _.orderBy(
|
|
@@ -3626,7 +3625,7 @@ function cs(i) {
|
|
|
3626
3625
|
});
|
|
3627
3626
|
if (!r)
|
|
3628
3627
|
return { signingKeys: c };
|
|
3629
|
-
const [u] = await
|
|
3628
|
+
const [u] = await n.select({ count: V() }).from(he).where(de(He(he.revoked_at, l), ye(he.revoked_at)));
|
|
3630
3629
|
return {
|
|
3631
3630
|
signingKeys: c,
|
|
3632
3631
|
start: e * t,
|
|
@@ -3634,8 +3633,8 @@ function cs(i) {
|
|
|
3634
3633
|
length: Fr((u == null ? void 0 : u.count) ?? 0)
|
|
3635
3634
|
};
|
|
3636
3635
|
},
|
|
3637
|
-
async update(
|
|
3638
|
-
return (await
|
|
3636
|
+
async update(i, e) {
|
|
3637
|
+
return (await n.update(he).set(e).where(a(he.kid, i)).returning()).length > 0;
|
|
3639
3638
|
}
|
|
3640
3639
|
};
|
|
3641
3640
|
}
|
|
@@ -3650,15 +3649,15 @@ function gs() {
|
|
|
3650
3649
|
t += vt.charAt(r[o] % at);
|
|
3651
3650
|
return t;
|
|
3652
3651
|
}
|
|
3653
|
-
function $t(
|
|
3652
|
+
function $t(n) {
|
|
3654
3653
|
const {
|
|
3655
|
-
tenant_id:
|
|
3654
|
+
tenant_id: i,
|
|
3656
3655
|
created_at_ts: e,
|
|
3657
3656
|
updated_at_ts: t,
|
|
3658
3657
|
expires_at_ts: r,
|
|
3659
3658
|
state_data: o,
|
|
3660
3659
|
...l
|
|
3661
|
-
} =
|
|
3660
|
+
} = n, _ = Fe(
|
|
3662
3661
|
{ created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
|
|
3663
3662
|
["created_at_ts", "updated_at_ts", "expires_at_ts"]
|
|
3664
3663
|
), d = gr(l, ["authParams"]);
|
|
@@ -3668,15 +3667,15 @@ function $t(i) {
|
|
|
3668
3667
|
state_data: b(o)
|
|
3669
3668
|
});
|
|
3670
3669
|
}
|
|
3671
|
-
function fs(
|
|
3670
|
+
function fs(n) {
|
|
3672
3671
|
return {
|
|
3673
|
-
async create(
|
|
3672
|
+
async create(i, e) {
|
|
3674
3673
|
const t = Date.now(), r = gs(), o = Pe(
|
|
3675
3674
|
{ authParams: e.authParams || {} },
|
|
3676
3675
|
"authParams"
|
|
3677
3676
|
), l = {
|
|
3678
3677
|
id: r,
|
|
3679
|
-
tenant_id:
|
|
3678
|
+
tenant_id: i,
|
|
3680
3679
|
session_id: e.session_id,
|
|
3681
3680
|
csrf_token: e.csrf_token,
|
|
3682
3681
|
authorization_url: e.authorization_url ? e.authorization_url.substring(0, 1024) : void 0,
|
|
@@ -3694,15 +3693,15 @@ function fs(i) {
|
|
|
3694
3693
|
};
|
|
3695
3694
|
for (const [_, d] of Object.entries(o))
|
|
3696
3695
|
l[_] = d;
|
|
3697
|
-
return await
|
|
3696
|
+
return await n.insert(oe).values(l), $t({ ...l, tenant_id: i });
|
|
3698
3697
|
},
|
|
3699
|
-
async get(
|
|
3700
|
-
const t = await
|
|
3701
|
-
g(a(oe.tenant_id,
|
|
3698
|
+
async get(i, e) {
|
|
3699
|
+
const t = await n.select().from(oe).where(
|
|
3700
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3702
3701
|
).get();
|
|
3703
3702
|
return t ? $t(t) : null;
|
|
3704
3703
|
},
|
|
3705
|
-
async update(
|
|
3704
|
+
async update(i, e, t) {
|
|
3706
3705
|
var o;
|
|
3707
3706
|
const r = {
|
|
3708
3707
|
updated_at_ts: Date.now()
|
|
@@ -3717,20 +3716,20 @@ function fs(i) {
|
|
|
3717
3716
|
);
|
|
3718
3717
|
Object.assign(r, l);
|
|
3719
3718
|
}
|
|
3720
|
-
return await
|
|
3721
|
-
g(a(oe.tenant_id,
|
|
3719
|
+
return await n.update(oe).set(r).where(
|
|
3720
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3722
3721
|
), !0;
|
|
3723
3722
|
},
|
|
3724
|
-
async remove(
|
|
3725
|
-
return (await
|
|
3726
|
-
g(a(oe.tenant_id,
|
|
3723
|
+
async remove(i, e) {
|
|
3724
|
+
return (await n.delete(oe).where(
|
|
3725
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3727
3726
|
).returning()).length > 0;
|
|
3728
3727
|
}
|
|
3729
3728
|
};
|
|
3730
3729
|
}
|
|
3731
|
-
function lt(
|
|
3730
|
+
function lt(n) {
|
|
3732
3731
|
const {
|
|
3733
|
-
tenant_id:
|
|
3732
|
+
tenant_id: i,
|
|
3734
3733
|
isMobile: e,
|
|
3735
3734
|
auth0_client: t,
|
|
3736
3735
|
details: r,
|
|
@@ -3742,7 +3741,7 @@ function lt(i) {
|
|
|
3742
3741
|
continent_code: u,
|
|
3743
3742
|
scope: h,
|
|
3744
3743
|
...f
|
|
3745
|
-
} =
|
|
3744
|
+
} = n, y = {
|
|
3746
3745
|
...f,
|
|
3747
3746
|
isMobile: !!e,
|
|
3748
3747
|
auth0_client: b(t),
|
|
@@ -3758,13 +3757,13 @@ function lt(i) {
|
|
|
3758
3757
|
continent_code: u
|
|
3759
3758
|
})), z(y);
|
|
3760
3759
|
}
|
|
3761
|
-
function ms(
|
|
3760
|
+
function ms(n) {
|
|
3762
3761
|
return {
|
|
3763
|
-
async create(
|
|
3762
|
+
async create(i, e) {
|
|
3764
3763
|
var o, l;
|
|
3765
3764
|
const r = {
|
|
3766
3765
|
log_id: e.log_id || ae(),
|
|
3767
|
-
tenant_id:
|
|
3766
|
+
tenant_id: i,
|
|
3768
3767
|
type: e.type,
|
|
3769
3768
|
date: e.date || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3770
3769
|
category: e.category,
|
|
@@ -3785,9 +3784,9 @@ function ms(i) {
|
|
|
3785
3784
|
hostname: e.hostname,
|
|
3786
3785
|
session_connection: e.session_connection
|
|
3787
3786
|
};
|
|
3788
|
-
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
|
|
3787
|
+
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), lt({ ...r, tenant_id: i });
|
|
3789
3788
|
},
|
|
3790
|
-
async list(
|
|
3789
|
+
async list(i, e) {
|
|
3791
3790
|
const {
|
|
3792
3791
|
page: t = 0,
|
|
3793
3792
|
per_page: r = 50,
|
|
@@ -3795,7 +3794,7 @@ function ms(i) {
|
|
|
3795
3794
|
sort: l,
|
|
3796
3795
|
q: _
|
|
3797
3796
|
} = e || {};
|
|
3798
|
-
let d =
|
|
3797
|
+
let d = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
|
|
3799
3798
|
if (_) {
|
|
3800
3799
|
const f = pe(T, _, [
|
|
3801
3800
|
"user_id",
|
|
@@ -3803,7 +3802,7 @@ function ms(i) {
|
|
|
3803
3802
|
"type",
|
|
3804
3803
|
"client_id"
|
|
3805
3804
|
]);
|
|
3806
|
-
f && (d = d.where(g(a(T.tenant_id,
|
|
3805
|
+
f && (d = d.where(g(a(T.tenant_id, i), f)));
|
|
3807
3806
|
}
|
|
3808
3807
|
if (l != null && l.sort_by) {
|
|
3809
3808
|
const f = T[l.sort_by];
|
|
@@ -3815,7 +3814,7 @@ function ms(i) {
|
|
|
3815
3814
|
const u = (await d.offset(t * r).limit(r)).map(lt);
|
|
3816
3815
|
if (!o)
|
|
3817
3816
|
return { logs: u };
|
|
3818
|
-
const [h] = await
|
|
3817
|
+
const [h] = await n.select({ count: V() }).from(T).where(a(T.tenant_id, i));
|
|
3819
3818
|
return {
|
|
3820
3819
|
logs: u,
|
|
3821
3820
|
start: t * r,
|
|
@@ -3823,8 +3822,8 @@ function ms(i) {
|
|
|
3823
3822
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
3824
3823
|
};
|
|
3825
3824
|
},
|
|
3826
|
-
async get(
|
|
3827
|
-
const t = await
|
|
3825
|
+
async get(i, e) {
|
|
3826
|
+
const t = await n.select().from(T).where(g(a(T.tenant_id, i), a(T.log_id, e))).get();
|
|
3828
3827
|
return t ? lt(t) : null;
|
|
3829
3828
|
}
|
|
3830
3829
|
};
|
|
@@ -3840,16 +3839,16 @@ function hs() {
|
|
|
3840
3839
|
t += St.charAt(r[o] % _t);
|
|
3841
3840
|
return t;
|
|
3842
3841
|
}
|
|
3843
|
-
function Me(
|
|
3842
|
+
function Me(n) {
|
|
3844
3843
|
const {
|
|
3845
|
-
tenant_id:
|
|
3844
|
+
tenant_id: i,
|
|
3846
3845
|
created_at_ts: e,
|
|
3847
3846
|
updated_at_ts: t,
|
|
3848
3847
|
credential_backed_up: r,
|
|
3849
3848
|
confirmed: o,
|
|
3850
3849
|
transports: l,
|
|
3851
3850
|
..._
|
|
3852
|
-
} =
|
|
3851
|
+
} = n;
|
|
3853
3852
|
return z({
|
|
3854
3853
|
..._,
|
|
3855
3854
|
confirmed: !!o,
|
|
@@ -3859,12 +3858,12 @@ function Me(i) {
|
|
|
3859
3858
|
updated_at: wt(t)
|
|
3860
3859
|
});
|
|
3861
3860
|
}
|
|
3862
|
-
function ps(
|
|
3861
|
+
function ps(n) {
|
|
3863
3862
|
return {
|
|
3864
|
-
async create(
|
|
3863
|
+
async create(i, e) {
|
|
3865
3864
|
const t = Date.now(), o = {
|
|
3866
3865
|
id: e.id || hs(),
|
|
3867
|
-
tenant_id:
|
|
3866
|
+
tenant_id: i,
|
|
3868
3867
|
user_id: e.user_id,
|
|
3869
3868
|
type: e.type,
|
|
3870
3869
|
phone_number: e.phone_number,
|
|
@@ -3879,55 +3878,55 @@ function ps(i) {
|
|
|
3879
3878
|
created_at_ts: t,
|
|
3880
3879
|
updated_at_ts: t
|
|
3881
3880
|
};
|
|
3882
|
-
return await
|
|
3881
|
+
return await n.insert(F).values(o), Me({ ...o, tenant_id: i });
|
|
3883
3882
|
},
|
|
3884
|
-
async get(
|
|
3885
|
-
const t = await
|
|
3883
|
+
async get(i, e) {
|
|
3884
|
+
const t = await n.select().from(F).where(
|
|
3886
3885
|
g(
|
|
3887
|
-
a(F.tenant_id,
|
|
3886
|
+
a(F.tenant_id, i),
|
|
3888
3887
|
a(F.id, e)
|
|
3889
3888
|
)
|
|
3890
3889
|
).get();
|
|
3891
3890
|
return t ? Me(t) : null;
|
|
3892
3891
|
},
|
|
3893
|
-
async getByCredentialId(
|
|
3894
|
-
const t = await
|
|
3892
|
+
async getByCredentialId(i, e) {
|
|
3893
|
+
const t = await n.select().from(F).where(
|
|
3895
3894
|
g(
|
|
3896
|
-
a(F.tenant_id,
|
|
3895
|
+
a(F.tenant_id, i),
|
|
3897
3896
|
a(F.credential_id, e)
|
|
3898
3897
|
)
|
|
3899
3898
|
).get();
|
|
3900
3899
|
return t ? Me(t) : null;
|
|
3901
3900
|
},
|
|
3902
|
-
async list(
|
|
3903
|
-
return (await
|
|
3901
|
+
async list(i, e) {
|
|
3902
|
+
return (await n.select().from(F).where(
|
|
3904
3903
|
g(
|
|
3905
|
-
a(F.tenant_id,
|
|
3904
|
+
a(F.tenant_id, i),
|
|
3906
3905
|
a(F.user_id, e)
|
|
3907
3906
|
)
|
|
3908
3907
|
).all()).map(Me);
|
|
3909
3908
|
},
|
|
3910
|
-
async update(
|
|
3909
|
+
async update(i, e, t) {
|
|
3911
3910
|
const r = {
|
|
3912
3911
|
updated_at_ts: Date.now()
|
|
3913
3912
|
};
|
|
3914
|
-
t.type !== void 0 && (r.type = t.type), t.phone_number !== void 0 && (r.phone_number = t.phone_number), t.totp_secret !== void 0 && (r.totp_secret = t.totp_secret), t.credential_id !== void 0 && (r.credential_id = t.credential_id), t.public_key !== void 0 && (r.public_key = t.public_key), t.sign_count !== void 0 && (r.sign_count = t.sign_count), t.credential_backed_up !== void 0 && (r.credential_backed_up = t.credential_backed_up ? 1 : 0), t.transports !== void 0 && (r.transports = JSON.stringify(t.transports)), t.friendly_name !== void 0 && (r.friendly_name = t.friendly_name), t.confirmed !== void 0 && (r.confirmed = t.confirmed ? 1 : 0), await
|
|
3913
|
+
t.type !== void 0 && (r.type = t.type), t.phone_number !== void 0 && (r.phone_number = t.phone_number), t.totp_secret !== void 0 && (r.totp_secret = t.totp_secret), t.credential_id !== void 0 && (r.credential_id = t.credential_id), t.public_key !== void 0 && (r.public_key = t.public_key), t.sign_count !== void 0 && (r.sign_count = t.sign_count), t.credential_backed_up !== void 0 && (r.credential_backed_up = t.credential_backed_up ? 1 : 0), t.transports !== void 0 && (r.transports = JSON.stringify(t.transports)), t.friendly_name !== void 0 && (r.friendly_name = t.friendly_name), t.confirmed !== void 0 && (r.confirmed = t.confirmed ? 1 : 0), await n.update(F).set(r).where(
|
|
3915
3914
|
g(
|
|
3916
|
-
a(F.tenant_id,
|
|
3915
|
+
a(F.tenant_id, i),
|
|
3917
3916
|
a(F.id, e)
|
|
3918
3917
|
)
|
|
3919
3918
|
);
|
|
3920
|
-
const o = await this.get(
|
|
3919
|
+
const o = await this.get(i, e);
|
|
3921
3920
|
if (!o)
|
|
3922
3921
|
throw new Error(
|
|
3923
3922
|
`Authentication method ${e} not found after update`
|
|
3924
3923
|
);
|
|
3925
3924
|
return o;
|
|
3926
3925
|
},
|
|
3927
|
-
async remove(
|
|
3928
|
-
return (await
|
|
3926
|
+
async remove(i, e) {
|
|
3927
|
+
return (await n.delete(F).where(
|
|
3929
3928
|
g(
|
|
3930
|
-
a(F.tenant_id,
|
|
3929
|
+
a(F.tenant_id, i),
|
|
3931
3930
|
a(F.id, e)
|
|
3932
3931
|
)
|
|
3933
3932
|
).returning()).length > 0;
|
|
@@ -3935,18 +3934,18 @@ function ps(i) {
|
|
|
3935
3934
|
};
|
|
3936
3935
|
}
|
|
3937
3936
|
function ys() {
|
|
3938
|
-
const { customAlphabet:
|
|
3939
|
-
return `org_${
|
|
3937
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3938
|
+
return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3940
3939
|
}
|
|
3941
|
-
function ut(
|
|
3940
|
+
function ut(n) {
|
|
3942
3941
|
const {
|
|
3943
|
-
tenant_id:
|
|
3942
|
+
tenant_id: i,
|
|
3944
3943
|
branding: e,
|
|
3945
3944
|
metadata: t,
|
|
3946
3945
|
enabled_connections: r,
|
|
3947
3946
|
token_quota: o,
|
|
3948
3947
|
...l
|
|
3949
|
-
} =
|
|
3948
|
+
} = n;
|
|
3950
3949
|
return z({
|
|
3951
3950
|
...l,
|
|
3952
3951
|
branding: b(e, {}),
|
|
@@ -3955,13 +3954,13 @@ function ut(i) {
|
|
|
3955
3954
|
token_quota: b(o, {})
|
|
3956
3955
|
});
|
|
3957
3956
|
}
|
|
3958
|
-
function ws(
|
|
3957
|
+
function ws(n) {
|
|
3959
3958
|
return {
|
|
3960
|
-
async create(
|
|
3959
|
+
async create(i, e) {
|
|
3961
3960
|
var l, _;
|
|
3962
3961
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3963
3962
|
id: e.id || ys(),
|
|
3964
|
-
tenant_id:
|
|
3963
|
+
tenant_id: i,
|
|
3965
3964
|
name: e.name,
|
|
3966
3965
|
display_name: e.display_name,
|
|
3967
3966
|
branding: JSON.stringify(e.branding || {}),
|
|
@@ -3972,36 +3971,36 @@ function ws(i) {
|
|
|
3972
3971
|
updated_at: t
|
|
3973
3972
|
};
|
|
3974
3973
|
try {
|
|
3975
|
-
await
|
|
3974
|
+
await n.insert(q).values(o);
|
|
3976
3975
|
} catch (d) {
|
|
3977
3976
|
throw (l = d == null ? void 0 : d.message) != null && l.includes("UNIQUE constraint failed") || (_ = d == null ? void 0 : d.message) != null && _.includes("AlreadyExists") ? new be(409, {
|
|
3978
3977
|
message: "Organization already exists"
|
|
3979
3978
|
}) : d;
|
|
3980
3979
|
}
|
|
3981
|
-
return ut({ ...o, tenant_id:
|
|
3980
|
+
return ut({ ...o, tenant_id: i });
|
|
3982
3981
|
},
|
|
3983
|
-
async get(
|
|
3984
|
-
let t = await
|
|
3985
|
-
g(a(q.tenant_id,
|
|
3982
|
+
async get(i, e) {
|
|
3983
|
+
let t = await n.select().from(q).where(
|
|
3984
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
3986
3985
|
).get();
|
|
3987
|
-
return t || (t = await
|
|
3986
|
+
return t || (t = await n.select().from(q).where(
|
|
3988
3987
|
g(
|
|
3989
|
-
a(q.tenant_id,
|
|
3988
|
+
a(q.tenant_id, i),
|
|
3990
3989
|
a(q.name, e)
|
|
3991
3990
|
)
|
|
3992
3991
|
).get()), t ? ut(t) : null;
|
|
3993
3992
|
},
|
|
3994
|
-
async update(
|
|
3993
|
+
async update(i, e, t) {
|
|
3995
3994
|
const r = {
|
|
3996
3995
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3997
3996
|
};
|
|
3998
3997
|
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(
|
|
3999
3998
|
t.enabled_connections
|
|
4000
|
-
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await
|
|
4001
|
-
g(a(q.tenant_id,
|
|
3999
|
+
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(q).set(r).where(
|
|
4000
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
4002
4001
|
).returning()).length > 0;
|
|
4003
4002
|
},
|
|
4004
|
-
async list(
|
|
4003
|
+
async list(i, e) {
|
|
4005
4004
|
const {
|
|
4006
4005
|
page: t = 0,
|
|
4007
4006
|
per_page: r = 50,
|
|
@@ -4009,7 +4008,7 @@ function ws(i) {
|
|
|
4009
4008
|
sort: l,
|
|
4010
4009
|
q: _
|
|
4011
4010
|
} = e || {};
|
|
4012
|
-
let d =
|
|
4011
|
+
let d = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
|
|
4013
4012
|
if (_ && (d = d.where(
|
|
4014
4013
|
de(
|
|
4015
4014
|
Ie(q.name, `%${_}%`),
|
|
@@ -4024,14 +4023,14 @@ function ws(i) {
|
|
|
4024
4023
|
const u = (await d.offset(t * r).limit(r)).map(ut);
|
|
4025
4024
|
if (!o)
|
|
4026
4025
|
return { organizations: u };
|
|
4027
|
-
const h = [a(q.tenant_id,
|
|
4026
|
+
const h = [a(q.tenant_id, i)];
|
|
4028
4027
|
_ && h.push(
|
|
4029
4028
|
de(
|
|
4030
4029
|
Ie(q.name, `%${_}%`),
|
|
4031
4030
|
Ie(q.display_name, `%${_}%`)
|
|
4032
4031
|
)
|
|
4033
4032
|
);
|
|
4034
|
-
const [f] = await
|
|
4033
|
+
const [f] = await n.select({ count: V() }).from(q).where(g(...h));
|
|
4035
4034
|
return {
|
|
4036
4035
|
organizations: u,
|
|
4037
4036
|
start: t * r,
|
|
@@ -4039,33 +4038,33 @@ function ws(i) {
|
|
|
4039
4038
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
4040
4039
|
};
|
|
4041
4040
|
},
|
|
4042
|
-
async remove(
|
|
4043
|
-
return (await
|
|
4044
|
-
g(a(q.tenant_id,
|
|
4041
|
+
async remove(i, e) {
|
|
4042
|
+
return (await n.delete(q).where(
|
|
4043
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
4045
4044
|
).returning()).length > 0;
|
|
4046
4045
|
}
|
|
4047
4046
|
};
|
|
4048
4047
|
}
|
|
4049
|
-
function dt(
|
|
4050
|
-
const { tenant_id:
|
|
4048
|
+
function dt(n) {
|
|
4049
|
+
const { tenant_id: i, is_current: e, ...t } = n;
|
|
4051
4050
|
return {
|
|
4052
4051
|
...t,
|
|
4053
4052
|
is_current: !!e
|
|
4054
4053
|
};
|
|
4055
4054
|
}
|
|
4056
|
-
function Ns(
|
|
4055
|
+
function Ns(n) {
|
|
4057
4056
|
return {
|
|
4058
|
-
async create(
|
|
4057
|
+
async create(i, e) {
|
|
4059
4058
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
|
|
4060
|
-
e.is_current !== !1 && await
|
|
4059
|
+
e.is_current !== !1 && await n.update(E).set({ is_current: 0 }).where(
|
|
4061
4060
|
g(
|
|
4062
|
-
a(E.tenant_id,
|
|
4061
|
+
a(E.tenant_id, i),
|
|
4063
4062
|
a(E.user_id, e.user_id)
|
|
4064
4063
|
)
|
|
4065
4064
|
);
|
|
4066
4065
|
const o = {
|
|
4067
4066
|
id: r,
|
|
4068
|
-
tenant_id:
|
|
4067
|
+
tenant_id: i,
|
|
4069
4068
|
user_id: e.user_id,
|
|
4070
4069
|
password: e.password,
|
|
4071
4070
|
algorithm: e.algorithm || "bcrypt",
|
|
@@ -4073,39 +4072,39 @@ function Ns(i) {
|
|
|
4073
4072
|
created_at: t,
|
|
4074
4073
|
updated_at: t
|
|
4075
4074
|
};
|
|
4076
|
-
return await
|
|
4075
|
+
return await n.insert(E).values(o), dt({ ...o, tenant_id: i });
|
|
4077
4076
|
},
|
|
4078
|
-
async get(
|
|
4079
|
-
const t = await
|
|
4077
|
+
async get(i, e) {
|
|
4078
|
+
const t = await n.select().from(E).where(
|
|
4080
4079
|
g(
|
|
4081
|
-
a(E.tenant_id,
|
|
4080
|
+
a(E.tenant_id, i),
|
|
4082
4081
|
a(E.user_id, e),
|
|
4083
4082
|
a(E.is_current, 1)
|
|
4084
4083
|
)
|
|
4085
4084
|
).get();
|
|
4086
4085
|
return t ? dt(t) : null;
|
|
4087
4086
|
},
|
|
4088
|
-
async list(
|
|
4089
|
-
let r =
|
|
4087
|
+
async list(i, e, t) {
|
|
4088
|
+
let r = n.select().from(E).where(
|
|
4090
4089
|
g(
|
|
4091
|
-
a(E.tenant_id,
|
|
4090
|
+
a(E.tenant_id, i),
|
|
4092
4091
|
a(E.user_id, e)
|
|
4093
4092
|
)
|
|
4094
4093
|
).orderBy(M(E.created_at)).$dynamic();
|
|
4095
4094
|
return t && (r = r.limit(t)), (await r).map(dt);
|
|
4096
4095
|
},
|
|
4097
|
-
async update(
|
|
4096
|
+
async update(i, e) {
|
|
4098
4097
|
const t = {
|
|
4099
4098
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4100
4099
|
};
|
|
4101
|
-
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
|
|
4100
|
+
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(E).set(t).where(
|
|
4102
4101
|
g(
|
|
4103
|
-
a(E.tenant_id,
|
|
4102
|
+
a(E.tenant_id, i),
|
|
4104
4103
|
a(E.id, e.id)
|
|
4105
4104
|
)
|
|
4106
|
-
) : await
|
|
4105
|
+
) : await n.update(E).set(t).where(
|
|
4107
4106
|
g(
|
|
4108
|
-
a(E.tenant_id,
|
|
4107
|
+
a(E.tenant_id, i),
|
|
4109
4108
|
a(E.user_id, e.user_id),
|
|
4110
4109
|
a(E.is_current, 1)
|
|
4111
4110
|
)
|
|
@@ -4113,10 +4112,10 @@ function Ns(i) {
|
|
|
4113
4112
|
}
|
|
4114
4113
|
};
|
|
4115
4114
|
}
|
|
4116
|
-
function vs(
|
|
4115
|
+
function vs(n) {
|
|
4117
4116
|
return {
|
|
4118
|
-
async get(
|
|
4119
|
-
const e = await
|
|
4117
|
+
async get(i) {
|
|
4118
|
+
const e = await n.select().from(Ee).where(a(Ee.tenant_id, i)).get();
|
|
4120
4119
|
return e ? {
|
|
4121
4120
|
universal_login_experience: e.universal_login_experience,
|
|
4122
4121
|
identifier_first: !!e.identifier_first,
|
|
@@ -4129,9 +4128,9 @@ function vs(i) {
|
|
|
4129
4128
|
webauthn_platform_first_factor: !1
|
|
4130
4129
|
};
|
|
4131
4130
|
},
|
|
4132
|
-
async set(
|
|
4133
|
-
await
|
|
4134
|
-
tenant_id:
|
|
4131
|
+
async set(i, e) {
|
|
4132
|
+
await n.insert(Ee).values({
|
|
4133
|
+
tenant_id: i,
|
|
4135
4134
|
universal_login_experience: e.universal_login_experience,
|
|
4136
4135
|
identifier_first: e.identifier_first,
|
|
4137
4136
|
password_first: e.password_first,
|
|
@@ -4148,9 +4147,9 @@ function vs(i) {
|
|
|
4148
4147
|
}
|
|
4149
4148
|
};
|
|
4150
4149
|
}
|
|
4151
|
-
function ct(
|
|
4150
|
+
function ct(n) {
|
|
4152
4151
|
const {
|
|
4153
|
-
tenant_id:
|
|
4152
|
+
tenant_id: i,
|
|
4154
4153
|
created_at_ts: e,
|
|
4155
4154
|
expires_at_ts: t,
|
|
4156
4155
|
idle_expires_at_ts: r,
|
|
@@ -4159,7 +4158,7 @@ function ct(i) {
|
|
|
4159
4158
|
resource_servers: _,
|
|
4160
4159
|
rotating: d,
|
|
4161
4160
|
...c
|
|
4162
|
-
} =
|
|
4161
|
+
} = n, u = Fe(
|
|
4163
4162
|
{ created_at_ts: e, expires_at_ts: t, idle_expires_at_ts: r, last_exchanged_at_ts: o },
|
|
4164
4163
|
["created_at_ts"],
|
|
4165
4164
|
["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
|
|
@@ -4172,12 +4171,12 @@ function ct(i) {
|
|
|
4172
4171
|
resource_servers: b(_, [])
|
|
4173
4172
|
});
|
|
4174
4173
|
}
|
|
4175
|
-
function Ss(
|
|
4174
|
+
function Ss(n) {
|
|
4176
4175
|
return {
|
|
4177
|
-
async create(
|
|
4176
|
+
async create(i, e) {
|
|
4178
4177
|
const t = Date.now(), r = {
|
|
4179
4178
|
id: e.id || ae(),
|
|
4180
|
-
tenant_id:
|
|
4179
|
+
tenant_id: i,
|
|
4181
4180
|
client_id: e.client_id,
|
|
4182
4181
|
login_id: e.login_id,
|
|
4183
4182
|
user_id: e.user_id,
|
|
@@ -4189,21 +4188,21 @@ function Ss(i) {
|
|
|
4189
4188
|
idle_expires_at_ts: K(e.idle_expires_at),
|
|
4190
4189
|
last_exchanged_at_ts: K(e.last_exchanged_at)
|
|
4191
4190
|
};
|
|
4192
|
-
return await
|
|
4191
|
+
return await n.insert(C).values(r), ct({ ...r, tenant_id: i });
|
|
4193
4192
|
},
|
|
4194
|
-
async get(
|
|
4195
|
-
const t = await
|
|
4196
|
-
g(a(C.tenant_id,
|
|
4193
|
+
async get(i, e) {
|
|
4194
|
+
const t = await n.select().from(C).where(
|
|
4195
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4197
4196
|
).get();
|
|
4198
4197
|
return t ? ct(t) : null;
|
|
4199
4198
|
},
|
|
4200
|
-
async update(
|
|
4199
|
+
async update(i, e, t) {
|
|
4201
4200
|
const r = {};
|
|
4202
|
-
return t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (r.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (r.rotating = t.rotating), t.expires_at !== void 0 && (r.expires_at_ts = K(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = K(t.idle_expires_at)), t.last_exchanged_at !== void 0 && (r.last_exchanged_at_ts = K(t.last_exchanged_at)), (await
|
|
4203
|
-
g(a(C.tenant_id,
|
|
4201
|
+
return t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (r.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (r.rotating = t.rotating), t.expires_at !== void 0 && (r.expires_at_ts = K(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = K(t.idle_expires_at)), t.last_exchanged_at !== void 0 && (r.last_exchanged_at_ts = K(t.last_exchanged_at)), (await n.update(C).set(r).where(
|
|
4202
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4204
4203
|
).returning()).length > 0;
|
|
4205
4204
|
},
|
|
4206
|
-
async list(
|
|
4205
|
+
async list(i, e) {
|
|
4207
4206
|
const {
|
|
4208
4207
|
page: t = 0,
|
|
4209
4208
|
per_page: r = 50,
|
|
@@ -4211,11 +4210,11 @@ function Ss(i) {
|
|
|
4211
4210
|
sort: l,
|
|
4212
4211
|
q: _
|
|
4213
4212
|
} = e || {};
|
|
4214
|
-
let d =
|
|
4213
|
+
let d = n.select().from(C).where(a(C.tenant_id, i)).$dynamic();
|
|
4215
4214
|
if (_) {
|
|
4216
4215
|
const f = pe(C, _, ["user_id"]);
|
|
4217
4216
|
f && (d = d.where(
|
|
4218
|
-
g(a(C.tenant_id,
|
|
4217
|
+
g(a(C.tenant_id, i), f)
|
|
4219
4218
|
));
|
|
4220
4219
|
}
|
|
4221
4220
|
if (l != null && l.sort_by) {
|
|
@@ -4227,7 +4226,7 @@ function Ss(i) {
|
|
|
4227
4226
|
const u = (await d.offset(t * r).limit(r)).map(ct);
|
|
4228
4227
|
if (!o)
|
|
4229
4228
|
return { refresh_tokens: u };
|
|
4230
|
-
const [h] = await
|
|
4229
|
+
const [h] = await n.select({ count: V() }).from(C).where(a(C.tenant_id, i));
|
|
4231
4230
|
return {
|
|
4232
4231
|
refresh_tokens: u,
|
|
4233
4232
|
start: t * r,
|
|
@@ -4235,16 +4234,16 @@ function Ss(i) {
|
|
|
4235
4234
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
4236
4235
|
};
|
|
4237
4236
|
},
|
|
4238
|
-
async remove(
|
|
4239
|
-
return (await
|
|
4240
|
-
g(a(C.tenant_id,
|
|
4237
|
+
async remove(i, e) {
|
|
4238
|
+
return (await n.delete(C).where(
|
|
4239
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4241
4240
|
).returning()).length > 0;
|
|
4242
4241
|
}
|
|
4243
4242
|
};
|
|
4244
4243
|
}
|
|
4245
4244
|
function bs() {
|
|
4246
|
-
const { customAlphabet:
|
|
4247
|
-
return `api_${
|
|
4245
|
+
const { customAlphabet: n } = require("nanoid");
|
|
4246
|
+
return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
4248
4247
|
}
|
|
4249
4248
|
const bt = [
|
|
4250
4249
|
"skip_consent_for_verifiable_first_party_clients",
|
|
@@ -4269,26 +4268,26 @@ const bt = [
|
|
|
4269
4268
|
"created_at",
|
|
4270
4269
|
"updated_at"
|
|
4271
4270
|
]);
|
|
4272
|
-
function gt(
|
|
4271
|
+
function gt(n) {
|
|
4273
4272
|
const {
|
|
4274
|
-
tenant_id:
|
|
4273
|
+
tenant_id: i,
|
|
4275
4274
|
verification_key: e,
|
|
4276
4275
|
scopes: t,
|
|
4277
4276
|
options: r,
|
|
4278
4277
|
metadata: o,
|
|
4279
4278
|
...l
|
|
4280
|
-
} =
|
|
4279
|
+
} = n, _ = { ...l };
|
|
4281
4280
|
_.scopes = b(t, []), _.options = b(r, {}), _.metadata = b(o), e !== void 0 && (_.verificationKey = e);
|
|
4282
4281
|
for (const d of bt)
|
|
4283
4282
|
l[d] !== void 0 && l[d] !== null && (_[d] = !!l[d]);
|
|
4284
4283
|
return z(_);
|
|
4285
4284
|
}
|
|
4286
|
-
function xs(
|
|
4285
|
+
function xs(n) {
|
|
4287
4286
|
return {
|
|
4288
|
-
async create(
|
|
4287
|
+
async create(i, e) {
|
|
4289
4288
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4290
4289
|
id: e.id || bs(),
|
|
4291
|
-
tenant_id:
|
|
4290
|
+
tenant_id: i,
|
|
4292
4291
|
identifier: e.identifier,
|
|
4293
4292
|
name: e.name,
|
|
4294
4293
|
signing_alg: e.signing_alg,
|
|
@@ -4304,32 +4303,32 @@ function xs(i) {
|
|
|
4304
4303
|
};
|
|
4305
4304
|
for (const l of bt)
|
|
4306
4305
|
e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
|
|
4307
|
-
return o.is_system === void 0 && (o.is_system = 0), await
|
|
4306
|
+
return o.is_system === void 0 && (o.is_system = 0), await n.insert(L).values(o), gt({ ...o, tenant_id: i });
|
|
4308
4307
|
},
|
|
4309
|
-
async get(
|
|
4310
|
-
const t = await
|
|
4308
|
+
async get(i, e) {
|
|
4309
|
+
const t = await n.select().from(L).where(
|
|
4311
4310
|
g(
|
|
4312
|
-
a(L.tenant_id,
|
|
4311
|
+
a(L.tenant_id, i),
|
|
4313
4312
|
a(L.id, e)
|
|
4314
4313
|
)
|
|
4315
4314
|
).get();
|
|
4316
4315
|
return t ? gt(t) : null;
|
|
4317
4316
|
},
|
|
4318
|
-
async update(
|
|
4317
|
+
async update(i, e, t) {
|
|
4319
4318
|
const r = {
|
|
4320
4319
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4321
4320
|
};
|
|
4322
4321
|
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(${L.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
|
|
4323
4322
|
for (const l of bt)
|
|
4324
4323
|
t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
|
|
4325
|
-
return (await
|
|
4324
|
+
return (await n.update(L).set(r).where(
|
|
4326
4325
|
g(
|
|
4327
|
-
a(L.tenant_id,
|
|
4326
|
+
a(L.tenant_id, i),
|
|
4328
4327
|
a(L.id, e)
|
|
4329
4328
|
)
|
|
4330
4329
|
).returning()).length > 0;
|
|
4331
4330
|
},
|
|
4332
|
-
async list(
|
|
4331
|
+
async list(i, e) {
|
|
4333
4332
|
const {
|
|
4334
4333
|
page: t = 0,
|
|
4335
4334
|
per_page: r = 50,
|
|
@@ -4339,7 +4338,7 @@ function xs(i) {
|
|
|
4339
4338
|
} = e || {}, d = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
|
|
4340
4339
|
Math.max(1, Math.floor(Number(r) || 50)),
|
|
4341
4340
|
500
|
|
4342
|
-
), u = [a(L.tenant_id,
|
|
4341
|
+
), u = [a(L.tenant_id, i)];
|
|
4343
4342
|
if (_) {
|
|
4344
4343
|
const A = _.match(/^([^:]+):(.+)$/);
|
|
4345
4344
|
if (A) {
|
|
@@ -4350,7 +4349,7 @@ function xs(i) {
|
|
|
4350
4349
|
}
|
|
4351
4350
|
}
|
|
4352
4351
|
}
|
|
4353
|
-
let h =
|
|
4352
|
+
let h = n.select().from(L).where(g(...u)).$dynamic();
|
|
4354
4353
|
if (l != null && l.sort_by && Bt.has(l.sort_by)) {
|
|
4355
4354
|
const A = L[l.sort_by];
|
|
4356
4355
|
h = h.orderBy(
|
|
@@ -4360,7 +4359,7 @@ function xs(i) {
|
|
|
4360
4359
|
const y = (await h.offset(d * c).limit(c)).map(gt);
|
|
4361
4360
|
if (!o)
|
|
4362
4361
|
return { resource_servers: y };
|
|
4363
|
-
const [w] = await
|
|
4362
|
+
const [w] = await n.select({ count: V() }).from(L).where(g(...u));
|
|
4364
4363
|
return {
|
|
4365
4364
|
resource_servers: y,
|
|
4366
4365
|
start: d * c,
|
|
@@ -4368,23 +4367,23 @@ function xs(i) {
|
|
|
4368
4367
|
length: Number((w == null ? void 0 : w.count) ?? 0)
|
|
4369
4368
|
};
|
|
4370
4369
|
},
|
|
4371
|
-
async remove(
|
|
4372
|
-
return (await
|
|
4370
|
+
async remove(i, e) {
|
|
4371
|
+
return (await n.delete(L).where(
|
|
4373
4372
|
g(
|
|
4374
|
-
a(L.tenant_id,
|
|
4373
|
+
a(L.tenant_id, i),
|
|
4375
4374
|
a(L.id, e)
|
|
4376
4375
|
)
|
|
4377
4376
|
).returning()).length > 0;
|
|
4378
4377
|
}
|
|
4379
4378
|
};
|
|
4380
4379
|
}
|
|
4381
|
-
function Ds(
|
|
4380
|
+
function Ds(n) {
|
|
4382
4381
|
return {
|
|
4383
|
-
async assign(
|
|
4382
|
+
async assign(i, e, t) {
|
|
4384
4383
|
const r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4385
|
-
return await
|
|
4384
|
+
return await n.insert(le).values(
|
|
4386
4385
|
t.map((o) => ({
|
|
4387
|
-
tenant_id:
|
|
4386
|
+
tenant_id: i,
|
|
4388
4387
|
role_id: e,
|
|
4389
4388
|
resource_server_identifier: o.resource_server_identifier,
|
|
4390
4389
|
permission_name: o.permission_name,
|
|
@@ -4392,26 +4391,26 @@ function Ds(i) {
|
|
|
4392
4391
|
}))
|
|
4393
4392
|
).onConflictDoNothing(), !0;
|
|
4394
4393
|
},
|
|
4395
|
-
async list(
|
|
4396
|
-
const r = await
|
|
4394
|
+
async list(i, e, t) {
|
|
4395
|
+
const r = await n.select({
|
|
4397
4396
|
resource_server_identifier: le.resource_server_identifier,
|
|
4398
4397
|
permission_name: le.permission_name,
|
|
4399
4398
|
created_at: le.created_at
|
|
4400
4399
|
}).from(le).where(
|
|
4401
4400
|
g(
|
|
4402
|
-
a(le.tenant_id,
|
|
4401
|
+
a(le.tenant_id, i),
|
|
4403
4402
|
a(le.role_id, e)
|
|
4404
4403
|
)
|
|
4405
4404
|
).all(), o = [
|
|
4406
4405
|
...new Set(r.map((_) => _.resource_server_identifier))
|
|
4407
4406
|
], l = /* @__PURE__ */ new Map();
|
|
4408
4407
|
if (o.length > 0) {
|
|
4409
|
-
const _ = await
|
|
4408
|
+
const _ = await n.select({
|
|
4410
4409
|
identifier: L.identifier,
|
|
4411
4410
|
name: L.name
|
|
4412
4411
|
}).from(L).where(
|
|
4413
4412
|
g(
|
|
4414
|
-
a(L.tenant_id,
|
|
4413
|
+
a(L.tenant_id, i),
|
|
4415
4414
|
we(L.identifier, o)
|
|
4416
4415
|
)
|
|
4417
4416
|
).all();
|
|
@@ -4423,7 +4422,7 @@ function Ds(i) {
|
|
|
4423
4422
|
resource_server_name: l.get(_.resource_server_identifier) || _.resource_server_identifier
|
|
4424
4423
|
}));
|
|
4425
4424
|
},
|
|
4426
|
-
async remove(
|
|
4425
|
+
async remove(i, e, t) {
|
|
4427
4426
|
const r = t.map(
|
|
4428
4427
|
(l) => g(
|
|
4429
4428
|
a(
|
|
@@ -4433,9 +4432,9 @@ function Ds(i) {
|
|
|
4433
4432
|
a(le.permission_name, l.permission_name)
|
|
4434
4433
|
)
|
|
4435
4434
|
);
|
|
4436
|
-
return (await
|
|
4435
|
+
return (await n.delete(le).where(
|
|
4437
4436
|
g(
|
|
4438
|
-
a(le.tenant_id,
|
|
4437
|
+
a(le.tenant_id, i),
|
|
4439
4438
|
a(le.role_id, e),
|
|
4440
4439
|
de(...r)
|
|
4441
4440
|
)
|
|
@@ -4443,13 +4442,13 @@ function Ds(i) {
|
|
|
4443
4442
|
}
|
|
4444
4443
|
};
|
|
4445
4444
|
}
|
|
4446
|
-
function Os(
|
|
4445
|
+
function Os(n) {
|
|
4447
4446
|
return {
|
|
4448
|
-
async create(
|
|
4447
|
+
async create(i, e, t, r) {
|
|
4449
4448
|
var o, l;
|
|
4450
4449
|
try {
|
|
4451
|
-
await
|
|
4452
|
-
tenant_id:
|
|
4450
|
+
await n.insert(_e).values({
|
|
4451
|
+
tenant_id: i,
|
|
4453
4452
|
user_id: e,
|
|
4454
4453
|
resource_server_identifier: t.resource_server_identifier,
|
|
4455
4454
|
permission_name: t.permission_name,
|
|
@@ -4463,18 +4462,18 @@ function Os(i) {
|
|
|
4463
4462
|
}
|
|
4464
4463
|
return !0;
|
|
4465
4464
|
},
|
|
4466
|
-
async list(
|
|
4465
|
+
async list(i, e, t, r) {
|
|
4467
4466
|
let o = [
|
|
4468
|
-
a(_e.tenant_id,
|
|
4467
|
+
a(_e.tenant_id, i),
|
|
4469
4468
|
a(_e.user_id, e)
|
|
4470
4469
|
];
|
|
4471
4470
|
r && o.push(a(_e.organization_id, r));
|
|
4472
|
-
const l = await
|
|
4471
|
+
const l = await n.select().from(_e).where(g(...o)).all();
|
|
4473
4472
|
return await Promise.all(
|
|
4474
4473
|
l.map(async (d) => {
|
|
4475
|
-
const c = await
|
|
4474
|
+
const c = await n.select({ name: L.name }).from(L).where(
|
|
4476
4475
|
g(
|
|
4477
|
-
a(L.tenant_id,
|
|
4476
|
+
a(L.tenant_id, i),
|
|
4478
4477
|
a(L.identifier, d.resource_server_identifier)
|
|
4479
4478
|
)
|
|
4480
4479
|
).get();
|
|
@@ -4487,10 +4486,10 @@ function Os(i) {
|
|
|
4487
4486
|
})
|
|
4488
4487
|
);
|
|
4489
4488
|
},
|
|
4490
|
-
async remove(
|
|
4491
|
-
return (await
|
|
4489
|
+
async remove(i, e, t, r) {
|
|
4490
|
+
return (await n.delete(_e).where(
|
|
4492
4491
|
g(
|
|
4493
|
-
a(_e.tenant_id,
|
|
4492
|
+
a(_e.tenant_id, i),
|
|
4494
4493
|
a(_e.user_id, e),
|
|
4495
4494
|
a(
|
|
4496
4495
|
_e.resource_server_identifier,
|
|
@@ -4503,20 +4502,20 @@ function Os(i) {
|
|
|
4503
4502
|
}
|
|
4504
4503
|
};
|
|
4505
4504
|
}
|
|
4506
|
-
function ft(
|
|
4507
|
-
const { tenant_id:
|
|
4505
|
+
function ft(n) {
|
|
4506
|
+
const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
|
|
4508
4507
|
return z({
|
|
4509
4508
|
...r,
|
|
4510
4509
|
is_system: e ? !0 : void 0,
|
|
4511
4510
|
metadata: b(t)
|
|
4512
4511
|
});
|
|
4513
4512
|
}
|
|
4514
|
-
function ks(
|
|
4513
|
+
function ks(n) {
|
|
4515
4514
|
return {
|
|
4516
|
-
async create(
|
|
4515
|
+
async create(i, e) {
|
|
4517
4516
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4518
4517
|
id: e.id || ae(),
|
|
4519
|
-
tenant_id:
|
|
4518
|
+
tenant_id: i,
|
|
4520
4519
|
name: e.name,
|
|
4521
4520
|
description: e.description,
|
|
4522
4521
|
is_system: e.is_system ? 1 : 0,
|
|
@@ -4524,27 +4523,27 @@ function ks(i) {
|
|
|
4524
4523
|
created_at: t,
|
|
4525
4524
|
updated_at: t
|
|
4526
4525
|
};
|
|
4527
|
-
return await
|
|
4526
|
+
return await n.insert(J).values(o), ft({ ...o, tenant_id: i });
|
|
4528
4527
|
},
|
|
4529
|
-
async get(
|
|
4530
|
-
const t = await
|
|
4528
|
+
async get(i, e) {
|
|
4529
|
+
const t = await n.select().from(J).where(g(a(J.tenant_id, i), a(J.id, e))).get();
|
|
4531
4530
|
return t ? ft(t) : null;
|
|
4532
4531
|
},
|
|
4533
|
-
async update(
|
|
4532
|
+
async update(i, e, t) {
|
|
4534
4533
|
const r = {
|
|
4535
4534
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4536
4535
|
};
|
|
4537
|
-
return t.name !== void 0 && (r.name = t.name), t.description !== void 0 && (r.description = t.description), t.is_system !== void 0 && (r.is_system = t.is_system ? 1 : 0), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), (await
|
|
4536
|
+
return t.name !== void 0 && (r.name = t.name), t.description !== void 0 && (r.description = t.description), t.is_system !== void 0 && (r.is_system = t.is_system ? 1 : 0), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), (await n.update(J).set(r).where(g(a(J.tenant_id, i), a(J.id, e))).returning()).length > 0;
|
|
4538
4537
|
},
|
|
4539
|
-
async list(
|
|
4538
|
+
async list(i, e) {
|
|
4540
4539
|
const {
|
|
4541
4540
|
page: t = 0,
|
|
4542
4541
|
per_page: r = 50,
|
|
4543
4542
|
include_totals: o = !1,
|
|
4544
4543
|
sort: l,
|
|
4545
4544
|
q: _
|
|
4546
|
-
} = e || {}, d = _ ? pe(J, _, ["name"]) : void 0, c = d ? g(a(J.tenant_id,
|
|
4547
|
-
let u =
|
|
4545
|
+
} = e || {}, d = _ ? pe(J, _, ["name"]) : void 0, c = d ? g(a(J.tenant_id, i), d) : a(J.tenant_id, i);
|
|
4546
|
+
let u = n.select().from(J).where(c).$dynamic();
|
|
4548
4547
|
if (l != null && l.sort_by) {
|
|
4549
4548
|
const w = J[l.sort_by];
|
|
4550
4549
|
w && (u = u.orderBy(
|
|
@@ -4554,7 +4553,7 @@ function ks(i) {
|
|
|
4554
4553
|
const f = (await u.offset(t * r).limit(r)).map(ft);
|
|
4555
4554
|
if (!o)
|
|
4556
4555
|
return { roles: f };
|
|
4557
|
-
const [y] = await
|
|
4556
|
+
const [y] = await n.select({ count: V() }).from(J).where(c);
|
|
4558
4557
|
return {
|
|
4559
4558
|
roles: f,
|
|
4560
4559
|
start: t * r,
|
|
@@ -4562,8 +4561,8 @@ function ks(i) {
|
|
|
4562
4561
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
4563
4562
|
};
|
|
4564
4563
|
},
|
|
4565
|
-
async remove(
|
|
4566
|
-
return (await
|
|
4564
|
+
async remove(i, e) {
|
|
4565
|
+
return (await n.delete(J).where(g(a(J.tenant_id, i), a(J.id, e))).returning()).length > 0;
|
|
4567
4566
|
}
|
|
4568
4567
|
};
|
|
4569
4568
|
}
|
|
@@ -4575,9 +4574,9 @@ const Is = ["created_at_ts", "updated_at_ts"], zs = [
|
|
|
4575
4574
|
"used_at_ts",
|
|
4576
4575
|
"revoked_at_ts"
|
|
4577
4576
|
];
|
|
4578
|
-
function mt(
|
|
4577
|
+
function mt(n) {
|
|
4579
4578
|
const {
|
|
4580
|
-
tenant_id:
|
|
4579
|
+
tenant_id: i,
|
|
4581
4580
|
created_at_ts: e,
|
|
4582
4581
|
updated_at_ts: t,
|
|
4583
4582
|
expires_at_ts: r,
|
|
@@ -4589,7 +4588,7 @@ function mt(i) {
|
|
|
4589
4588
|
device: u,
|
|
4590
4589
|
clients: h,
|
|
4591
4590
|
...f
|
|
4592
|
-
} =
|
|
4591
|
+
} = n, y = Fe(
|
|
4593
4592
|
{
|
|
4594
4593
|
created_at_ts: e,
|
|
4595
4594
|
updated_at_ts: t,
|
|
@@ -4610,12 +4609,12 @@ function mt(i) {
|
|
|
4610
4609
|
clients: b(h, [])
|
|
4611
4610
|
});
|
|
4612
4611
|
}
|
|
4613
|
-
function Ts(
|
|
4612
|
+
function Ts(n) {
|
|
4614
4613
|
return {
|
|
4615
|
-
async create(
|
|
4614
|
+
async create(i, e) {
|
|
4616
4615
|
const t = Date.now(), r = {
|
|
4617
4616
|
id: e.id || ae(),
|
|
4618
|
-
tenant_id:
|
|
4617
|
+
tenant_id: i,
|
|
4619
4618
|
user_id: e.user_id,
|
|
4620
4619
|
login_session_id: e.login_session_id,
|
|
4621
4620
|
device: JSON.stringify(e.device || {}),
|
|
@@ -4629,29 +4628,29 @@ function Ts(i) {
|
|
|
4629
4628
|
used_at_ts: K(e.used_at),
|
|
4630
4629
|
revoked_at_ts: K(e.revoked_at)
|
|
4631
4630
|
};
|
|
4632
|
-
return await
|
|
4631
|
+
return await n.insert($).values(r), mt({ ...r, tenant_id: i });
|
|
4633
4632
|
},
|
|
4634
|
-
async get(
|
|
4635
|
-
const t = await
|
|
4633
|
+
async get(i, e) {
|
|
4634
|
+
const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
|
|
4636
4635
|
return t ? mt(t) : null;
|
|
4637
4636
|
},
|
|
4638
|
-
async update(
|
|
4637
|
+
async update(i, e, t) {
|
|
4639
4638
|
const r = {
|
|
4640
4639
|
updated_at_ts: Date.now()
|
|
4641
4640
|
};
|
|
4642
4641
|
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 = K(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = K(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = K(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = K(
|
|
4643
4642
|
t.last_interaction_at
|
|
4644
|
-
)), t.used_at !== void 0 && (r.used_at_ts = K(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = K(t.revoked_at)), (await
|
|
4643
|
+
)), t.used_at !== void 0 && (r.used_at_ts = K(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = K(t.revoked_at)), (await n.update($).set(r).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
|
|
4645
4644
|
},
|
|
4646
|
-
async list(
|
|
4645
|
+
async list(i, e) {
|
|
4647
4646
|
const {
|
|
4648
4647
|
page: t = 0,
|
|
4649
4648
|
per_page: r = 50,
|
|
4650
4649
|
include_totals: o = !1,
|
|
4651
4650
|
sort: l,
|
|
4652
4651
|
q: _
|
|
4653
|
-
} = e || {}, d = _ ? pe($, _, ["user_id"]) : void 0, c = d ? g(a($.tenant_id,
|
|
4654
|
-
let u =
|
|
4652
|
+
} = e || {}, d = _ ? pe($, _, ["user_id"]) : void 0, c = d ? g(a($.tenant_id, i), d) : a($.tenant_id, i);
|
|
4653
|
+
let u = n.select().from($).where(c).$dynamic();
|
|
4655
4654
|
if (l != null && l.sort_by) {
|
|
4656
4655
|
const w = $[l.sort_by];
|
|
4657
4656
|
w && (u = u.orderBy(
|
|
@@ -4661,7 +4660,7 @@ function Ts(i) {
|
|
|
4661
4660
|
const f = (await u.offset(t * r).limit(r)).map(mt);
|
|
4662
4661
|
if (!o)
|
|
4663
4662
|
return { sessions: f };
|
|
4664
|
-
const [y] = await
|
|
4663
|
+
const [y] = await n.select({ count: V() }).from($).where(c);
|
|
4665
4664
|
return {
|
|
4666
4665
|
sessions: f,
|
|
4667
4666
|
start: t * r,
|
|
@@ -4669,8 +4668,8 @@ function Ts(i) {
|
|
|
4669
4668
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
4670
4669
|
};
|
|
4671
4670
|
},
|
|
4672
|
-
async remove(
|
|
4673
|
-
return (await
|
|
4671
|
+
async remove(i, e) {
|
|
4672
|
+
return (await n.delete($).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
|
|
4674
4673
|
}
|
|
4675
4674
|
};
|
|
4676
4675
|
}
|
|
@@ -4696,39 +4695,37 @@ const mr = [
|
|
|
4696
4695
|
"pushed_authorization_requests_supported",
|
|
4697
4696
|
"authorization_response_iss_parameter_supported"
|
|
4698
4697
|
];
|
|
4699
|
-
function Pt(
|
|
4700
|
-
const
|
|
4698
|
+
function Pt(n) {
|
|
4699
|
+
const i = { ...n };
|
|
4701
4700
|
for (const e of mr)
|
|
4702
|
-
typeof
|
|
4701
|
+
typeof i[e] == "string" && (i[e] = b(i[e]));
|
|
4703
4702
|
for (const e of hr)
|
|
4704
|
-
|
|
4705
|
-
return
|
|
4703
|
+
i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
|
|
4704
|
+
return z(i);
|
|
4706
4705
|
}
|
|
4707
|
-
function Qt(
|
|
4708
|
-
const
|
|
4706
|
+
function Qt(n) {
|
|
4707
|
+
const i = { ...n };
|
|
4709
4708
|
Qr(
|
|
4710
|
-
|
|
4709
|
+
n,
|
|
4711
4710
|
mr,
|
|
4712
|
-
|
|
4711
|
+
i
|
|
4713
4712
|
);
|
|
4714
4713
|
for (const e of hr)
|
|
4715
|
-
|
|
4716
|
-
return cr(
|
|
4714
|
+
n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
|
|
4715
|
+
return cr(i);
|
|
4717
4716
|
}
|
|
4718
|
-
function qs(
|
|
4717
|
+
function qs(n) {
|
|
4719
4718
|
return {
|
|
4720
|
-
async create(
|
|
4719
|
+
async create(i) {
|
|
4721
4720
|
var r, o;
|
|
4722
4721
|
const e = {
|
|
4723
|
-
id:
|
|
4724
|
-
session_lifetime: 168,
|
|
4725
|
-
idle_session_lifetime: 72,
|
|
4722
|
+
id: i.id || ae(),
|
|
4726
4723
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4727
4724
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4728
|
-
...
|
|
4725
|
+
...i
|
|
4729
4726
|
}, t = Qt(e);
|
|
4730
4727
|
try {
|
|
4731
|
-
await
|
|
4728
|
+
await n.insert(D).values(t);
|
|
4732
4729
|
} catch (l) {
|
|
4733
4730
|
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 be(409, {
|
|
4734
4731
|
message: `Tenant with ID '${e.id}' already exists`
|
|
@@ -4736,19 +4733,19 @@ function qs(i) {
|
|
|
4736
4733
|
}
|
|
4737
4734
|
return e;
|
|
4738
4735
|
},
|
|
4739
|
-
async get(
|
|
4740
|
-
const e = await
|
|
4736
|
+
async get(i) {
|
|
4737
|
+
const e = await n.select().from(D).where(a(D.id, i)).get();
|
|
4741
4738
|
return e ? Pt(e) : null;
|
|
4742
4739
|
},
|
|
4743
|
-
async list(
|
|
4740
|
+
async list(i) {
|
|
4744
4741
|
const {
|
|
4745
4742
|
page: e = 0,
|
|
4746
4743
|
per_page: t = 50,
|
|
4747
4744
|
include_totals: r = !1,
|
|
4748
4745
|
sort: o,
|
|
4749
4746
|
q: l
|
|
4750
|
-
} =
|
|
4751
|
-
let _ =
|
|
4747
|
+
} = i || {};
|
|
4748
|
+
let _ = n.select().from(D).$dynamic();
|
|
4752
4749
|
if (l) {
|
|
4753
4750
|
const h = pe(D, l, ["friendly_name"]);
|
|
4754
4751
|
h && (_ = _.where(h));
|
|
@@ -4762,7 +4759,7 @@ function qs(i) {
|
|
|
4762
4759
|
const c = (await _.offset(e * t).limit(t)).map(Pt);
|
|
4763
4760
|
if (!r)
|
|
4764
4761
|
return { tenants: c };
|
|
4765
|
-
const [u] = await
|
|
4762
|
+
const [u] = await n.select({ count: V() }).from(D);
|
|
4766
4763
|
return {
|
|
4767
4764
|
tenants: c,
|
|
4768
4765
|
start: e * t,
|
|
@@ -4770,16 +4767,16 @@ function qs(i) {
|
|
|
4770
4767
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
4771
4768
|
};
|
|
4772
4769
|
},
|
|
4773
|
-
async update(
|
|
4770
|
+
async update(i, e) {
|
|
4774
4771
|
const t = Qt({
|
|
4775
4772
|
...e,
|
|
4776
|
-
id:
|
|
4773
|
+
id: i,
|
|
4777
4774
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4778
4775
|
});
|
|
4779
|
-
await
|
|
4776
|
+
await n.update(D).set(t).where(a(D.id, i));
|
|
4780
4777
|
},
|
|
4781
|
-
async remove(
|
|
4782
|
-
return (await
|
|
4778
|
+
async remove(i) {
|
|
4779
|
+
return (await n.delete(D).where(a(D.id, i)).returning()).length > 0;
|
|
4783
4780
|
}
|
|
4784
4781
|
};
|
|
4785
4782
|
}
|
|
@@ -4790,51 +4787,51 @@ const Ls = [
|
|
|
4790
4787
|
"page_background",
|
|
4791
4788
|
"widget"
|
|
4792
4789
|
];
|
|
4793
|
-
function Jt(
|
|
4794
|
-
const { tenant_id:
|
|
4790
|
+
function Jt(n) {
|
|
4791
|
+
const { tenant_id: i, ...e } = n, t = gr(e, Ls);
|
|
4795
4792
|
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);
|
|
4796
4793
|
}
|
|
4797
|
-
function Es(
|
|
4794
|
+
function Es(n) {
|
|
4798
4795
|
return {
|
|
4799
|
-
async create(
|
|
4796
|
+
async create(i, e, t) {
|
|
4800
4797
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
|
|
4801
4798
|
...Pe(e),
|
|
4802
|
-
tenant_id:
|
|
4799
|
+
tenant_id: i,
|
|
4803
4800
|
themeId: o,
|
|
4804
4801
|
created_at: r,
|
|
4805
4802
|
updated_at: r
|
|
4806
4803
|
};
|
|
4807
|
-
return await
|
|
4804
|
+
return await n.insert(fe).values(_), Jt({ ..._, tenant_id: i });
|
|
4808
4805
|
},
|
|
4809
|
-
async get(
|
|
4810
|
-
const t = await
|
|
4811
|
-
g(a(fe.tenant_id,
|
|
4806
|
+
async get(i, e) {
|
|
4807
|
+
const t = await n.select().from(fe).where(
|
|
4808
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4812
4809
|
).get();
|
|
4813
4810
|
return t ? Jt(t) : null;
|
|
4814
4811
|
},
|
|
4815
|
-
async update(
|
|
4812
|
+
async update(i, e, t) {
|
|
4816
4813
|
const r = Pe(t);
|
|
4817
|
-
return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await
|
|
4818
|
-
g(a(fe.tenant_id,
|
|
4814
|
+
return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await n.update(fe).set(r).where(
|
|
4815
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4819
4816
|
), !0;
|
|
4820
4817
|
},
|
|
4821
|
-
async remove(
|
|
4822
|
-
return (await
|
|
4823
|
-
g(a(fe.tenant_id,
|
|
4818
|
+
async remove(i, e) {
|
|
4819
|
+
return (await n.delete(fe).where(
|
|
4820
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4824
4821
|
).returning()).length > 0;
|
|
4825
4822
|
}
|
|
4826
4823
|
};
|
|
4827
4824
|
}
|
|
4828
|
-
function As(
|
|
4825
|
+
function As(n) {
|
|
4829
4826
|
return {
|
|
4830
|
-
async get(
|
|
4831
|
-
const e = await
|
|
4827
|
+
async get(i) {
|
|
4828
|
+
const e = await n.select({ body: Ne.body }).from(Ne).where(a(Ne.tenant_id, i)).get();
|
|
4832
4829
|
return e ? { body: e.body } : null;
|
|
4833
4830
|
},
|
|
4834
|
-
async set(
|
|
4831
|
+
async set(i, e) {
|
|
4835
4832
|
const t = Date.now();
|
|
4836
|
-
await
|
|
4837
|
-
tenant_id:
|
|
4833
|
+
await n.insert(Ne).values({
|
|
4834
|
+
tenant_id: i,
|
|
4838
4835
|
body: e.body,
|
|
4839
4836
|
created_at_ts: t,
|
|
4840
4837
|
updated_at_ts: t
|
|
@@ -4846,25 +4843,25 @@ function As(i) {
|
|
|
4846
4843
|
}
|
|
4847
4844
|
});
|
|
4848
4845
|
},
|
|
4849
|
-
async delete(
|
|
4850
|
-
await
|
|
4846
|
+
async delete(i) {
|
|
4847
|
+
await n.delete(Ne).where(a(Ne.tenant_id, i));
|
|
4851
4848
|
}
|
|
4852
4849
|
};
|
|
4853
4850
|
}
|
|
4854
|
-
function Ft(
|
|
4851
|
+
function Ft(n, i) {
|
|
4855
4852
|
const e = {
|
|
4856
|
-
connection:
|
|
4857
|
-
provider:
|
|
4858
|
-
user_id:
|
|
4859
|
-
isSocial: !!
|
|
4853
|
+
connection: n.connection,
|
|
4854
|
+
provider: n.provider,
|
|
4855
|
+
user_id: n.user_id,
|
|
4856
|
+
isSocial: !!n.is_social
|
|
4860
4857
|
};
|
|
4861
|
-
return
|
|
4862
|
-
email:
|
|
4863
|
-
email_verified: !!
|
|
4864
|
-
...typeof
|
|
4858
|
+
return i ? e.isPrimary = !0 : e.profileData = {
|
|
4859
|
+
email: n.email,
|
|
4860
|
+
email_verified: !!n.email_verified,
|
|
4861
|
+
...typeof n.profileData == "string" ? b(n.profileData, {}) : {}
|
|
4865
4862
|
}, e;
|
|
4866
4863
|
}
|
|
4867
|
-
function ht(
|
|
4864
|
+
function ht(n, i = []) {
|
|
4868
4865
|
const {
|
|
4869
4866
|
tenant_id: e,
|
|
4870
4867
|
app_metadata: t,
|
|
@@ -4876,10 +4873,10 @@ function ht(i, n = []) {
|
|
|
4876
4873
|
linked_to: c,
|
|
4877
4874
|
profileData: u,
|
|
4878
4875
|
...h
|
|
4879
|
-
} =
|
|
4876
|
+
} = n, f = Ft(n, !0), y = i.map((w) => Ft(w, !1));
|
|
4880
4877
|
return z({
|
|
4881
4878
|
...h,
|
|
4882
|
-
email:
|
|
4879
|
+
email: n.email || "",
|
|
4883
4880
|
email_verified: !!l,
|
|
4884
4881
|
phone_verified: _ != null ? !!_ : void 0,
|
|
4885
4882
|
is_social: !!d,
|
|
@@ -4889,8 +4886,8 @@ function ht(i, n = []) {
|
|
|
4889
4886
|
identities: [f, ...y]
|
|
4890
4887
|
});
|
|
4891
4888
|
}
|
|
4892
|
-
function Cs(
|
|
4893
|
-
const
|
|
4889
|
+
function Cs(n) {
|
|
4890
|
+
const i = async (e, t) => {
|
|
4894
4891
|
var _, d;
|
|
4895
4892
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4896
4893
|
user_id: t.user_id,
|
|
@@ -4930,9 +4927,9 @@ function Cs(i) {
|
|
|
4930
4927
|
}, l = t.password ? ae() : void 0;
|
|
4931
4928
|
try {
|
|
4932
4929
|
if (t.password && l) {
|
|
4933
|
-
|
|
4930
|
+
n.run(N`BEGIN`);
|
|
4934
4931
|
try {
|
|
4935
|
-
await
|
|
4932
|
+
await n.insert(k).values(o), await n.insert(E).values({
|
|
4936
4933
|
id: l,
|
|
4937
4934
|
tenant_id: e,
|
|
4938
4935
|
user_id: t.user_id,
|
|
@@ -4941,12 +4938,12 @@ function Cs(i) {
|
|
|
4941
4938
|
is_current: 1,
|
|
4942
4939
|
created_at: r,
|
|
4943
4940
|
updated_at: r
|
|
4944
|
-
}),
|
|
4941
|
+
}), n.run(N`COMMIT`);
|
|
4945
4942
|
} catch (c) {
|
|
4946
|
-
throw
|
|
4943
|
+
throw n.run(N`ROLLBACK`), c;
|
|
4947
4944
|
}
|
|
4948
4945
|
} else
|
|
4949
|
-
await
|
|
4946
|
+
await n.insert(k).values(o);
|
|
4950
4947
|
} catch (c) {
|
|
4951
4948
|
throw (_ = c == null ? void 0 : c.message) != null && _.includes("UNIQUE constraint") || (d = c == null ? void 0 : c.message) != null && d.includes("AlreadyExists") ? new be(409, { message: "User already exists" }) : (console.error("User upsert failed:", c == null ? void 0 : c.code, c == null ? void 0 : c.message), new be(500, {
|
|
4952
4949
|
message: "Internal server error"
|
|
@@ -4955,12 +4952,12 @@ function Cs(i) {
|
|
|
4955
4952
|
return ht(o);
|
|
4956
4953
|
};
|
|
4957
4954
|
return {
|
|
4958
|
-
create:
|
|
4959
|
-
rawCreate:
|
|
4955
|
+
create: i,
|
|
4956
|
+
rawCreate: i,
|
|
4960
4957
|
async get(e, t) {
|
|
4961
|
-
const r = await
|
|
4958
|
+
const r = await n.select().from(k).where(g(a(k.tenant_id, e), a(k.user_id, t))).get();
|
|
4962
4959
|
if (!r) return null;
|
|
4963
|
-
const o = await
|
|
4960
|
+
const o = await n.select().from(k).where(
|
|
4964
4961
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
4965
4962
|
).all();
|
|
4966
4963
|
return ht(r, o);
|
|
@@ -4995,7 +4992,7 @@ function Cs(i) {
|
|
|
4995
4992
|
];
|
|
4996
4993
|
for (const d of l)
|
|
4997
4994
|
r[d] !== void 0 && (o[d] = r[d]);
|
|
4998
|
-
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
|
|
4995
|
+
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;
|
|
4999
4996
|
},
|
|
5000
4997
|
async list(e, t) {
|
|
5001
4998
|
const {
|
|
@@ -5018,7 +5015,7 @@ function Cs(i) {
|
|
|
5018
5015
|
W && c.push(W);
|
|
5019
5016
|
}
|
|
5020
5017
|
const u = g(...c);
|
|
5021
|
-
let h =
|
|
5018
|
+
let h = n.select().from(k).where(u).$dynamic();
|
|
5022
5019
|
if (_ != null && _.sort_by) {
|
|
5023
5020
|
const W = k[_.sort_by];
|
|
5024
5021
|
W && (h = h.orderBy(
|
|
@@ -5027,7 +5024,7 @@ function Cs(i) {
|
|
|
5027
5024
|
}
|
|
5028
5025
|
const f = await h.offset(r * o).limit(o), y = f.map((W) => W.user_id);
|
|
5029
5026
|
let w = [];
|
|
5030
|
-
y.length > 0 && (w = await
|
|
5027
|
+
y.length > 0 && (w = await n.select().from(k).where(
|
|
5031
5028
|
g(
|
|
5032
5029
|
a(k.tenant_id, e),
|
|
5033
5030
|
we(k.linked_to, y)
|
|
@@ -5039,7 +5036,7 @@ function Cs(i) {
|
|
|
5039
5036
|
});
|
|
5040
5037
|
if (!l)
|
|
5041
5038
|
return { users: A };
|
|
5042
|
-
const [R] = await
|
|
5039
|
+
const [R] = await n.select({ count: V() }).from(k).where(u);
|
|
5043
5040
|
return {
|
|
5044
5041
|
users: A,
|
|
5045
5042
|
start: r * o,
|
|
@@ -5048,35 +5045,35 @@ function Cs(i) {
|
|
|
5048
5045
|
};
|
|
5049
5046
|
},
|
|
5050
5047
|
async remove(e, t) {
|
|
5051
|
-
|
|
5048
|
+
n.run(N`BEGIN`);
|
|
5052
5049
|
try {
|
|
5053
|
-
const r = await
|
|
5050
|
+
const r = await n.select({ user_id: k.user_id }).from(k).where(
|
|
5054
5051
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
5055
5052
|
), o = [t, ...r.map((_) => _.user_id)];
|
|
5056
|
-
await
|
|
5053
|
+
await n.delete(F).where(
|
|
5057
5054
|
g(
|
|
5058
5055
|
a(F.tenant_id, e),
|
|
5059
5056
|
we(F.user_id, o)
|
|
5060
5057
|
)
|
|
5061
|
-
), await
|
|
5058
|
+
), await n.delete(E).where(
|
|
5062
5059
|
g(
|
|
5063
5060
|
a(E.tenant_id, e),
|
|
5064
5061
|
we(E.user_id, o)
|
|
5065
5062
|
)
|
|
5066
|
-
), await
|
|
5063
|
+
), await n.delete(k).where(
|
|
5067
5064
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
5068
5065
|
);
|
|
5069
|
-
const l = await
|
|
5066
|
+
const l = await n.delete(k).where(
|
|
5070
5067
|
g(a(k.tenant_id, e), a(k.user_id, t))
|
|
5071
5068
|
).returning();
|
|
5072
|
-
return
|
|
5069
|
+
return n.run(N`COMMIT`), l.length > 0;
|
|
5073
5070
|
} catch (r) {
|
|
5074
|
-
throw
|
|
5071
|
+
throw n.run(N`ROLLBACK`), r;
|
|
5075
5072
|
}
|
|
5076
5073
|
},
|
|
5077
5074
|
async unlink(e, t, r, o) {
|
|
5078
5075
|
const l = `${r}|${o}`;
|
|
5079
|
-
return (await
|
|
5076
|
+
return (await n.update(k).set({ linked_to: null }).where(
|
|
5080
5077
|
g(
|
|
5081
5078
|
a(k.tenant_id, e),
|
|
5082
5079
|
a(k.user_id, l),
|
|
@@ -5086,13 +5083,13 @@ function Cs(i) {
|
|
|
5086
5083
|
}
|
|
5087
5084
|
};
|
|
5088
5085
|
}
|
|
5089
|
-
function $s(
|
|
5086
|
+
function $s(n) {
|
|
5090
5087
|
return {
|
|
5091
|
-
async create(
|
|
5088
|
+
async create(i, e, t, r) {
|
|
5092
5089
|
var o, l;
|
|
5093
5090
|
try {
|
|
5094
|
-
await
|
|
5095
|
-
tenant_id:
|
|
5091
|
+
await n.insert(ue).values({
|
|
5092
|
+
tenant_id: i,
|
|
5096
5093
|
user_id: e,
|
|
5097
5094
|
role_id: t,
|
|
5098
5095
|
organization_id: r || "",
|
|
@@ -5105,19 +5102,19 @@ function $s(i) {
|
|
|
5105
5102
|
}
|
|
5106
5103
|
return !0;
|
|
5107
5104
|
},
|
|
5108
|
-
async list(
|
|
5105
|
+
async list(i, e, t, r) {
|
|
5109
5106
|
let o = [
|
|
5110
|
-
a(ue.tenant_id,
|
|
5107
|
+
a(ue.tenant_id, i),
|
|
5111
5108
|
a(ue.user_id, e)
|
|
5112
5109
|
];
|
|
5113
5110
|
r && o.push(a(ue.organization_id, r));
|
|
5114
|
-
const l = await
|
|
5111
|
+
const l = await n.select({
|
|
5115
5112
|
role_id: ue.role_id
|
|
5116
5113
|
}).from(ue).where(g(...o)).all();
|
|
5117
5114
|
return l.length === 0 ? [] : (await Promise.all(
|
|
5118
5115
|
l.map(async (d) => {
|
|
5119
|
-
const c = await
|
|
5120
|
-
g(a(J.tenant_id,
|
|
5116
|
+
const c = await n.select().from(J).where(
|
|
5117
|
+
g(a(J.tenant_id, i), a(J.id, d.role_id))
|
|
5121
5118
|
).get();
|
|
5122
5119
|
if (!c) return null;
|
|
5123
5120
|
const { tenant_id: u, is_system: h, metadata: f, ...y } = c;
|
|
@@ -5129,10 +5126,10 @@ function $s(i) {
|
|
|
5129
5126
|
})
|
|
5130
5127
|
)).filter(Boolean);
|
|
5131
5128
|
},
|
|
5132
|
-
async remove(
|
|
5133
|
-
return (await
|
|
5129
|
+
async remove(i, e, t, r) {
|
|
5130
|
+
return (await n.delete(ue).where(
|
|
5134
5131
|
g(
|
|
5135
|
-
a(ue.tenant_id,
|
|
5132
|
+
a(ue.tenant_id, i),
|
|
5136
5133
|
a(ue.user_id, e),
|
|
5137
5134
|
a(ue.role_id, t),
|
|
5138
5135
|
a(ue.organization_id, r || "")
|
|
@@ -5141,20 +5138,20 @@ function $s(i) {
|
|
|
5141
5138
|
}
|
|
5142
5139
|
};
|
|
5143
5140
|
}
|
|
5144
|
-
function Bs(
|
|
5141
|
+
function Bs(n) {
|
|
5145
5142
|
return {
|
|
5146
|
-
async create(
|
|
5143
|
+
async create(i, e) {
|
|
5147
5144
|
var d, c;
|
|
5148
5145
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5149
5146
|
id: e.id || ae(),
|
|
5150
|
-
tenant_id:
|
|
5147
|
+
tenant_id: i,
|
|
5151
5148
|
user_id: e.user_id,
|
|
5152
5149
|
organization_id: e.organization_id,
|
|
5153
5150
|
created_at: t,
|
|
5154
5151
|
updated_at: t
|
|
5155
5152
|
};
|
|
5156
5153
|
try {
|
|
5157
|
-
await
|
|
5154
|
+
await n.insert(P).values(o);
|
|
5158
5155
|
} catch (u) {
|
|
5159
5156
|
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 be(409, {
|
|
5160
5157
|
message: "User organization already exists"
|
|
@@ -5163,10 +5160,10 @@ function Bs(i) {
|
|
|
5163
5160
|
const { tenant_id: l, ..._ } = o;
|
|
5164
5161
|
return _;
|
|
5165
5162
|
},
|
|
5166
|
-
async get(
|
|
5167
|
-
const t = await
|
|
5163
|
+
async get(i, e) {
|
|
5164
|
+
const t = await n.select().from(P).where(
|
|
5168
5165
|
g(
|
|
5169
|
-
a(P.tenant_id,
|
|
5166
|
+
a(P.tenant_id, i),
|
|
5170
5167
|
a(P.id, e)
|
|
5171
5168
|
)
|
|
5172
5169
|
).get();
|
|
@@ -5174,24 +5171,24 @@ function Bs(i) {
|
|
|
5174
5171
|
const { tenant_id: r, ...o } = t;
|
|
5175
5172
|
return o;
|
|
5176
5173
|
},
|
|
5177
|
-
async update(
|
|
5174
|
+
async update(i, e, t) {
|
|
5178
5175
|
const r = {
|
|
5179
5176
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5180
5177
|
};
|
|
5181
|
-
return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await
|
|
5178
|
+
return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await n.update(P).set(r).where(
|
|
5182
5179
|
g(
|
|
5183
|
-
a(P.tenant_id,
|
|
5180
|
+
a(P.tenant_id, i),
|
|
5184
5181
|
a(P.id, e)
|
|
5185
5182
|
)
|
|
5186
5183
|
).returning()).length > 0;
|
|
5187
5184
|
},
|
|
5188
|
-
async list(
|
|
5185
|
+
async list(i, e) {
|
|
5189
5186
|
const {
|
|
5190
5187
|
page: t = 0,
|
|
5191
5188
|
per_page: r = 50,
|
|
5192
5189
|
include_totals: o = !1,
|
|
5193
5190
|
q: l
|
|
5194
|
-
} = e || {}, _ = a(P.tenant_id,
|
|
5191
|
+
} = e || {}, _ = a(P.tenant_id, i);
|
|
5195
5192
|
let d = _;
|
|
5196
5193
|
if (l) {
|
|
5197
5194
|
const f = pe(P, l, [
|
|
@@ -5200,13 +5197,13 @@ function Bs(i) {
|
|
|
5200
5197
|
]);
|
|
5201
5198
|
f && (d = g(_, f));
|
|
5202
5199
|
}
|
|
5203
|
-
const u = (await
|
|
5200
|
+
const u = (await n.select().from(P).where(d).offset(t * r).limit(r)).map((f) => {
|
|
5204
5201
|
const { tenant_id: y, ...w } = f;
|
|
5205
5202
|
return w;
|
|
5206
5203
|
});
|
|
5207
5204
|
if (!o)
|
|
5208
5205
|
return { userOrganizations: u };
|
|
5209
|
-
const [h] = await
|
|
5206
|
+
const [h] = await n.select({ count: V() }).from(P).where(d);
|
|
5210
5207
|
return {
|
|
5211
5208
|
userOrganizations: u,
|
|
5212
5209
|
start: t * r,
|
|
@@ -5214,17 +5211,17 @@ function Bs(i) {
|
|
|
5214
5211
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
5215
5212
|
};
|
|
5216
5213
|
},
|
|
5217
|
-
async listUserOrganizations(
|
|
5218
|
-
const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await
|
|
5214
|
+
async listUserOrganizations(i, e, t) {
|
|
5215
|
+
const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(P).where(
|
|
5219
5216
|
g(
|
|
5220
|
-
a(P.tenant_id,
|
|
5217
|
+
a(P.tenant_id, i),
|
|
5221
5218
|
a(P.user_id, e)
|
|
5222
5219
|
)
|
|
5223
5220
|
).offset(r * o).limit(o).all(), c = (await Promise.all(
|
|
5224
5221
|
_.map(async (h) => {
|
|
5225
|
-
const f = await
|
|
5222
|
+
const f = await n.select().from(q).where(
|
|
5226
5223
|
g(
|
|
5227
|
-
a(q.tenant_id,
|
|
5224
|
+
a(q.tenant_id, i),
|
|
5228
5225
|
a(q.id, h.organization_id)
|
|
5229
5226
|
)
|
|
5230
5227
|
).get();
|
|
@@ -5248,9 +5245,9 @@ function Bs(i) {
|
|
|
5248
5245
|
)).filter(Boolean);
|
|
5249
5246
|
if (!l)
|
|
5250
5247
|
return { organizations: c };
|
|
5251
|
-
const [u] = await
|
|
5248
|
+
const [u] = await n.select({ count: V() }).from(P).where(
|
|
5252
5249
|
g(
|
|
5253
|
-
a(P.tenant_id,
|
|
5250
|
+
a(P.tenant_id, i),
|
|
5254
5251
|
a(P.user_id, e)
|
|
5255
5252
|
)
|
|
5256
5253
|
);
|
|
@@ -5261,10 +5258,10 @@ function Bs(i) {
|
|
|
5261
5258
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
5262
5259
|
};
|
|
5263
5260
|
},
|
|
5264
|
-
async remove(
|
|
5265
|
-
return (await
|
|
5261
|
+
async remove(i, e) {
|
|
5262
|
+
return (await n.delete(P).where(
|
|
5266
5263
|
g(
|
|
5267
|
-
a(P.tenant_id,
|
|
5264
|
+
a(P.tenant_id, i),
|
|
5268
5265
|
a(P.id, e)
|
|
5269
5266
|
)
|
|
5270
5267
|
).returning()).length > 0;
|
|
@@ -5272,11 +5269,11 @@ function Bs(i) {
|
|
|
5272
5269
|
};
|
|
5273
5270
|
}
|
|
5274
5271
|
const Ut = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Ps = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
5275
|
-
function Qs(
|
|
5272
|
+
function Qs(n) {
|
|
5276
5273
|
return {
|
|
5277
|
-
async getDaily(
|
|
5274
|
+
async getDaily(i, e) {
|
|
5278
5275
|
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];
|
|
5279
|
-
return (await
|
|
5276
|
+
return (await n.select({
|
|
5280
5277
|
date: N`substr(${T.date}, 1, 10)`.as("date"),
|
|
5281
5278
|
logins: N`SUM(CASE WHEN ${T.type} IN (${N.join(
|
|
5282
5279
|
Ut.map((_) => N`${_}`),
|
|
@@ -5291,7 +5288,7 @@ function Qs(i) {
|
|
|
5291
5288
|
)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
5292
5289
|
}).from(T).where(
|
|
5293
5290
|
g(
|
|
5294
|
-
a(T.tenant_id,
|
|
5291
|
+
a(T.tenant_id, i),
|
|
5295
5292
|
Ge(T.date, r),
|
|
5296
5293
|
Oe(T.date, `${o}T23:59:59.999Z`)
|
|
5297
5294
|
)
|
|
@@ -5304,14 +5301,14 @@ function Qs(i) {
|
|
|
5304
5301
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5305
5302
|
}));
|
|
5306
5303
|
},
|
|
5307
|
-
async getActiveUsers(
|
|
5304
|
+
async getActiveUsers(i) {
|
|
5308
5305
|
const e = new Date(
|
|
5309
5306
|
Date.now() - 2592e6
|
|
5310
|
-
).toISOString(), [t] = await
|
|
5307
|
+
).toISOString(), [t] = await n.select({
|
|
5311
5308
|
count: N`COUNT(DISTINCT ${T.user_id})`.as("count")
|
|
5312
5309
|
}).from(T).where(
|
|
5313
5310
|
g(
|
|
5314
|
-
a(T.tenant_id,
|
|
5311
|
+
a(T.tenant_id, i),
|
|
5315
5312
|
Ge(T.date, e),
|
|
5316
5313
|
N`${T.type} IN (${N.join(
|
|
5317
5314
|
Ut.map((r) => N`${r}`),
|
|
@@ -5323,19 +5320,19 @@ function Qs(i) {
|
|
|
5323
5320
|
}
|
|
5324
5321
|
};
|
|
5325
5322
|
}
|
|
5326
|
-
function Kt(
|
|
5323
|
+
function Kt(n) {
|
|
5327
5324
|
return {
|
|
5328
|
-
...
|
|
5329
|
-
payload: b(
|
|
5325
|
+
...n,
|
|
5326
|
+
payload: b(n.payload, {})
|
|
5330
5327
|
};
|
|
5331
5328
|
}
|
|
5332
|
-
function Js(
|
|
5329
|
+
function Js(n) {
|
|
5333
5330
|
return {
|
|
5334
|
-
async create(
|
|
5331
|
+
async create(i, e) {
|
|
5335
5332
|
const t = ae(), r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5336
|
-
return await
|
|
5333
|
+
return await n.insert(x).values({
|
|
5337
5334
|
id: t,
|
|
5338
|
-
tenant_id:
|
|
5335
|
+
tenant_id: i,
|
|
5339
5336
|
event_type: e.event_type,
|
|
5340
5337
|
log_type: e.log_type,
|
|
5341
5338
|
aggregate_type: e.aggregate_type,
|
|
@@ -5350,12 +5347,12 @@ function Js(i) {
|
|
|
5350
5347
|
claim_expires_at: null
|
|
5351
5348
|
}), t;
|
|
5352
5349
|
},
|
|
5353
|
-
async getByIds(
|
|
5354
|
-
return
|
|
5350
|
+
async getByIds(i) {
|
|
5351
|
+
return i.length === 0 ? [] : (await n.select().from(x).where(we(x.id, i)).all()).map(Kt);
|
|
5355
5352
|
},
|
|
5356
|
-
async getUnprocessed(
|
|
5353
|
+
async getUnprocessed(i) {
|
|
5357
5354
|
const e = (/* @__PURE__ */ new Date()).toISOString();
|
|
5358
|
-
return (await
|
|
5355
|
+
return (await n.select().from(x).where(
|
|
5359
5356
|
g(
|
|
5360
5357
|
ye(x.processed_at),
|
|
5361
5358
|
de(
|
|
@@ -5367,62 +5364,62 @@ function Js(i) {
|
|
|
5367
5364
|
Oe(x.claim_expires_at, e)
|
|
5368
5365
|
)
|
|
5369
5366
|
)
|
|
5370
|
-
).orderBy(x.created_at, x.id).limit(
|
|
5367
|
+
).orderBy(x.created_at, x.id).limit(i).all()).map(Kt);
|
|
5371
5368
|
},
|
|
5372
|
-
async claimEvents(
|
|
5373
|
-
if (
|
|
5369
|
+
async claimEvents(i, e, t) {
|
|
5370
|
+
if (i.length === 0) return [];
|
|
5374
5371
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = new Date(Date.now() + t).toISOString();
|
|
5375
|
-
return await
|
|
5372
|
+
return await n.update(x).set({
|
|
5376
5373
|
claimed_by: e,
|
|
5377
5374
|
claim_expires_at: o
|
|
5378
5375
|
}).where(
|
|
5379
5376
|
g(
|
|
5380
|
-
we(x.id,
|
|
5377
|
+
we(x.id, i),
|
|
5381
5378
|
ye(x.processed_at),
|
|
5382
5379
|
de(
|
|
5383
5380
|
ye(x.claimed_by),
|
|
5384
5381
|
Oe(x.claim_expires_at, r)
|
|
5385
5382
|
)
|
|
5386
5383
|
)
|
|
5387
|
-
), (await
|
|
5384
|
+
), (await n.select({ id: x.id }).from(x).where(
|
|
5388
5385
|
g(
|
|
5389
|
-
we(x.id,
|
|
5386
|
+
we(x.id, i),
|
|
5390
5387
|
a(x.claimed_by, e)
|
|
5391
5388
|
)
|
|
5392
5389
|
).all()).map((_) => _.id);
|
|
5393
5390
|
},
|
|
5394
|
-
async markProcessed(
|
|
5395
|
-
|
|
5391
|
+
async markProcessed(i) {
|
|
5392
|
+
i.length !== 0 && await n.update(x).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(we(x.id, i));
|
|
5396
5393
|
},
|
|
5397
|
-
async markRetry(
|
|
5398
|
-
await
|
|
5394
|
+
async markRetry(i, e, t) {
|
|
5395
|
+
await n.update(x).set({
|
|
5399
5396
|
error: e,
|
|
5400
5397
|
next_retry_at: t,
|
|
5401
5398
|
retry_count: N`${x.retry_count} + 1`,
|
|
5402
5399
|
claimed_by: null,
|
|
5403
5400
|
claim_expires_at: null
|
|
5404
|
-
}).where(a(x.id,
|
|
5401
|
+
}).where(a(x.id, i));
|
|
5405
5402
|
},
|
|
5406
|
-
async cleanup(
|
|
5407
|
-
return (await
|
|
5403
|
+
async cleanup(i) {
|
|
5404
|
+
return (await n.delete(x).where(
|
|
5408
5405
|
g(
|
|
5409
5406
|
N`${x.processed_at} IS NOT NULL`,
|
|
5410
|
-
Oe(x.processed_at,
|
|
5407
|
+
Oe(x.processed_at, i)
|
|
5411
5408
|
)
|
|
5412
5409
|
).returning()).length;
|
|
5413
5410
|
},
|
|
5414
|
-
async deadLetter(
|
|
5411
|
+
async deadLetter(i, e) {
|
|
5415
5412
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
5416
|
-
await
|
|
5413
|
+
await n.update(x).set({
|
|
5417
5414
|
processed_at: t,
|
|
5418
5415
|
dead_lettered_at: t,
|
|
5419
5416
|
final_error: e
|
|
5420
|
-
}).where(a(x.id,
|
|
5417
|
+
}).where(a(x.id, i));
|
|
5421
5418
|
},
|
|
5422
|
-
async listFailed(
|
|
5423
|
-
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await
|
|
5419
|
+
async listFailed(i, e = {}) {
|
|
5420
|
+
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(x).where(
|
|
5424
5421
|
g(
|
|
5425
|
-
a(x.tenant_id,
|
|
5422
|
+
a(x.tenant_id, i),
|
|
5426
5423
|
Ve(x.dead_lettered_at)
|
|
5427
5424
|
)
|
|
5428
5425
|
).orderBy(M(x.dead_lettered_at), H(x.id)).offset(t * r).limit(r).all()).map((c) => ({
|
|
@@ -5438,9 +5435,9 @@ function Js(i) {
|
|
|
5438
5435
|
}));
|
|
5439
5436
|
let d = _.length;
|
|
5440
5437
|
if (o) {
|
|
5441
|
-
const [c] = await
|
|
5438
|
+
const [c] = await n.select({ total: V() }).from(x).where(
|
|
5442
5439
|
g(
|
|
5443
|
-
a(x.tenant_id,
|
|
5440
|
+
a(x.tenant_id, i),
|
|
5444
5441
|
Ve(x.dead_lettered_at)
|
|
5445
5442
|
)
|
|
5446
5443
|
);
|
|
@@ -5453,8 +5450,8 @@ function Js(i) {
|
|
|
5453
5450
|
length: d
|
|
5454
5451
|
};
|
|
5455
5452
|
},
|
|
5456
|
-
async replay(
|
|
5457
|
-
return (await
|
|
5453
|
+
async replay(i, e) {
|
|
5454
|
+
return (await n.update(x).set({
|
|
5458
5455
|
processed_at: null,
|
|
5459
5456
|
dead_lettered_at: null,
|
|
5460
5457
|
final_error: null,
|
|
@@ -5463,7 +5460,7 @@ function Js(i) {
|
|
|
5463
5460
|
error: null
|
|
5464
5461
|
}).where(
|
|
5465
5462
|
g(
|
|
5466
|
-
a(x.id,
|
|
5463
|
+
a(x.id, i),
|
|
5467
5464
|
a(x.tenant_id, e),
|
|
5468
5465
|
Ve(x.dead_lettered_at)
|
|
5469
5466
|
)
|
|
@@ -5472,8 +5469,8 @@ function Js(i) {
|
|
|
5472
5469
|
};
|
|
5473
5470
|
}
|
|
5474
5471
|
const Fs = 7 * 24 * 60 * 60 * 1e3;
|
|
5475
|
-
function Us(
|
|
5476
|
-
return async (
|
|
5472
|
+
function Us(n) {
|
|
5473
|
+
return async (i) => {
|
|
5477
5474
|
const e = Date.now() - Fs;
|
|
5478
5475
|
try {
|
|
5479
5476
|
let t = [
|
|
@@ -5482,65 +5479,65 @@ function Us(i) {
|
|
|
5482
5479
|
xe(C.idle_expires_at_ts, e)
|
|
5483
5480
|
)
|
|
5484
5481
|
];
|
|
5485
|
-
|
|
5482
|
+
i != null && i.tenant_id && t.push(a(C.tenant_id, i.tenant_id)), await n.delete(C).where(g(...t)), t = [
|
|
5486
5483
|
de(
|
|
5487
5484
|
xe($.expires_at_ts, e),
|
|
5488
5485
|
xe($.idle_expires_at_ts, e)
|
|
5489
5486
|
)
|
|
5490
|
-
],
|
|
5487
|
+
], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [xe(oe.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(oe.tenant_id, i.tenant_id)), await n.delete(oe).where(g(...t));
|
|
5491
5488
|
} catch (t) {
|
|
5492
5489
|
console.error("Session cleanup error:", t);
|
|
5493
5490
|
}
|
|
5494
5491
|
};
|
|
5495
5492
|
}
|
|
5496
|
-
function Ms(
|
|
5493
|
+
function Ms(n, i = { useTransactions: !0 }) {
|
|
5497
5494
|
const e = {
|
|
5498
5495
|
actions: kr(),
|
|
5499
|
-
branding: Ur(
|
|
5500
|
-
clients: Kr(
|
|
5501
|
-
clientConnections: Mr(
|
|
5502
|
-
clientGrants: Gr(
|
|
5503
|
-
codes: Yr(
|
|
5504
|
-
connections: Zr(
|
|
5505
|
-
customDomains: es(
|
|
5506
|
-
customText: ts(
|
|
5507
|
-
emailProviders: ns(
|
|
5508
|
-
flows: is(
|
|
5509
|
-
forms: rs(
|
|
5510
|
-
hookCode: as(
|
|
5511
|
-
hooks: _s(
|
|
5512
|
-
invites: ds(
|
|
5513
|
-
keys: cs(
|
|
5514
|
-
loginSessions: fs(
|
|
5515
|
-
logs: ms(
|
|
5516
|
-
authenticationMethods: ps(
|
|
5517
|
-
organizations: ws(
|
|
5518
|
-
passwords: Ns(
|
|
5519
|
-
promptSettings: vs(
|
|
5520
|
-
refreshTokens: Ss(
|
|
5521
|
-
resourceServers: xs(
|
|
5522
|
-
rolePermissions: Ds(
|
|
5523
|
-
userPermissions: Os(
|
|
5524
|
-
roles: ks(
|
|
5525
|
-
sessions: Ts(
|
|
5526
|
-
sessionCleanup: Us(
|
|
5527
|
-
tenants: qs(
|
|
5528
|
-
themes: Es(
|
|
5529
|
-
universalLoginTemplates: As(
|
|
5530
|
-
users: Cs(
|
|
5531
|
-
userRoles: $s(
|
|
5532
|
-
userOrganizations: Bs(
|
|
5533
|
-
stats: Qs(
|
|
5534
|
-
outbox: Js(
|
|
5496
|
+
branding: Ur(n),
|
|
5497
|
+
clients: Kr(n),
|
|
5498
|
+
clientConnections: Mr(n),
|
|
5499
|
+
clientGrants: Gr(n),
|
|
5500
|
+
codes: Yr(n),
|
|
5501
|
+
connections: Zr(n),
|
|
5502
|
+
customDomains: es(n),
|
|
5503
|
+
customText: ts(n),
|
|
5504
|
+
emailProviders: ns(n),
|
|
5505
|
+
flows: is(n),
|
|
5506
|
+
forms: rs(n),
|
|
5507
|
+
hookCode: as(n),
|
|
5508
|
+
hooks: _s(n),
|
|
5509
|
+
invites: ds(n),
|
|
5510
|
+
keys: cs(n),
|
|
5511
|
+
loginSessions: fs(n),
|
|
5512
|
+
logs: ms(n),
|
|
5513
|
+
authenticationMethods: ps(n),
|
|
5514
|
+
organizations: ws(n),
|
|
5515
|
+
passwords: Ns(n),
|
|
5516
|
+
promptSettings: vs(n),
|
|
5517
|
+
refreshTokens: Ss(n),
|
|
5518
|
+
resourceServers: xs(n),
|
|
5519
|
+
rolePermissions: Ds(n),
|
|
5520
|
+
userPermissions: Os(n),
|
|
5521
|
+
roles: ks(n),
|
|
5522
|
+
sessions: Ts(n),
|
|
5523
|
+
sessionCleanup: Us(n),
|
|
5524
|
+
tenants: qs(n),
|
|
5525
|
+
themes: Es(n),
|
|
5526
|
+
universalLoginTemplates: As(n),
|
|
5527
|
+
users: Cs(n),
|
|
5528
|
+
userRoles: $s(n),
|
|
5529
|
+
userOrganizations: Bs(n),
|
|
5530
|
+
stats: Qs(n),
|
|
5531
|
+
outbox: Js(n),
|
|
5535
5532
|
async transaction(t) {
|
|
5536
|
-
if (
|
|
5533
|
+
if (i.useTransactions === !1)
|
|
5537
5534
|
return t(e);
|
|
5538
|
-
|
|
5535
|
+
n.run(N`BEGIN`);
|
|
5539
5536
|
try {
|
|
5540
5537
|
const r = await t(e);
|
|
5541
|
-
return
|
|
5538
|
+
return n.run(N`COMMIT`), r;
|
|
5542
5539
|
} catch (r) {
|
|
5543
|
-
throw
|
|
5540
|
+
throw n.run(N`ROLLBACK`), r;
|
|
5544
5541
|
}
|
|
5545
5542
|
}
|
|
5546
5543
|
};
|