@authhero/drizzle 0.36.0 → 0.37.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 +1123 -1125
- package/package.json +2 -2
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");
|
|
@@ -1301,33 +1301,33 @@ const D = O("tenants", {
|
|
|
1301
1301
|
// OIDC address claim (OIDC Core 5.1.1) - stored as JSON string
|
|
1302
1302
|
address: s("address")
|
|
1303
1303
|
},
|
|
1304
|
-
(
|
|
1304
|
+
(n) => [
|
|
1305
1305
|
se({
|
|
1306
|
-
columns: [
|
|
1306
|
+
columns: [n.user_id, n.tenant_id],
|
|
1307
1307
|
name: "users_tenants"
|
|
1308
1308
|
}),
|
|
1309
1309
|
Te("unique_email_provider").on(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1310
|
+
n.email,
|
|
1311
|
+
n.provider,
|
|
1312
|
+
n.tenant_id
|
|
1313
1313
|
),
|
|
1314
1314
|
Te("unique_phone_provider").on(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1315
|
+
n.phone_number,
|
|
1316
|
+
n.provider,
|
|
1317
|
+
n.tenant_id
|
|
1318
1318
|
),
|
|
1319
1319
|
Te("unique_username_provider").on(
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1320
|
+
n.username,
|
|
1321
|
+
n.provider,
|
|
1322
|
+
n.tenant_id
|
|
1323
1323
|
),
|
|
1324
|
-
S("users_email_index").on(
|
|
1325
|
-
S("users_linked_to_index").on(
|
|
1326
|
-
S("users_name_index").on(
|
|
1324
|
+
S("users_email_index").on(n.email),
|
|
1325
|
+
S("users_linked_to_index").on(n.linked_to),
|
|
1326
|
+
S("users_name_index").on(n.name),
|
|
1327
1327
|
S("users_phone_tenant_provider_index").on(
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1328
|
+
n.tenant_id,
|
|
1329
|
+
n.phone_number,
|
|
1330
|
+
n.provider
|
|
1331
1331
|
)
|
|
1332
1332
|
]
|
|
1333
1333
|
), E = O("passwords", {
|
|
@@ -1357,11 +1357,11 @@ const D = O("tenants", {
|
|
|
1357
1357
|
clients: s("clients").notNull(),
|
|
1358
1358
|
login_session_id: s("login_session_id", { length: 21 })
|
|
1359
1359
|
},
|
|
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(
|
|
1360
|
+
(n) => [
|
|
1361
|
+
se({ columns: [n.tenant_id, n.id], name: "sessions_pk" }),
|
|
1362
|
+
S("IDX_sessions_login_session_id").on(n.login_session_id),
|
|
1363
|
+
S("idx_sessions_user_id").on(n.tenant_id, n.user_id),
|
|
1364
|
+
S("idx_sessions_expires_at_ts").on(n.expires_at_ts)
|
|
1365
1365
|
]
|
|
1366
1366
|
), C = O(
|
|
1367
1367
|
"refresh_tokens",
|
|
@@ -1379,14 +1379,14 @@ const D = O("tenants", {
|
|
|
1379
1379
|
idle_expires_at_ts: p("idle_expires_at_ts"),
|
|
1380
1380
|
last_exchanged_at_ts: p("last_exchanged_at_ts")
|
|
1381
1381
|
},
|
|
1382
|
-
(
|
|
1382
|
+
(n) => [
|
|
1383
1383
|
se({
|
|
1384
|
-
columns: [
|
|
1384
|
+
columns: [n.tenant_id, n.id],
|
|
1385
1385
|
name: "refresh_tokens_pk"
|
|
1386
1386
|
}),
|
|
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(
|
|
1387
|
+
S("idx_refresh_tokens_user_id").on(n.tenant_id, n.user_id),
|
|
1388
|
+
S("idx_refresh_tokens_login_id").on(n.login_id),
|
|
1389
|
+
S("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
|
|
1390
1390
|
]
|
|
1391
1391
|
), oe = O(
|
|
1392
1392
|
"login_sessions",
|
|
@@ -1431,19 +1431,19 @@ const D = O("tenants", {
|
|
|
1431
1431
|
user_id: s("user_id", { length: 255 }),
|
|
1432
1432
|
auth_connection: s("auth_connection", { length: 255 })
|
|
1433
1433
|
},
|
|
1434
|
-
(
|
|
1434
|
+
(n) => [
|
|
1435
1435
|
se({
|
|
1436
|
-
columns: [
|
|
1436
|
+
columns: [n.tenant_id, n.id],
|
|
1437
1437
|
name: "login_sessions_pk"
|
|
1438
1438
|
}),
|
|
1439
|
-
S("login_sessions_id_index").on(
|
|
1440
|
-
S("login_sessions_state_idx").on(
|
|
1439
|
+
S("login_sessions_id_index").on(n.id),
|
|
1440
|
+
S("login_sessions_state_idx").on(n.state),
|
|
1441
1441
|
S("login_sessions_state_updated_idx").on(
|
|
1442
|
-
|
|
1443
|
-
|
|
1442
|
+
n.state,
|
|
1443
|
+
n.updated_at_ts
|
|
1444
1444
|
),
|
|
1445
|
-
S("login_sessions_tenant_user_idx").on(
|
|
1446
|
-
S("idx_login_sessions_expires_at_ts").on(
|
|
1445
|
+
S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
|
|
1446
|
+
S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
|
|
1447
1447
|
]
|
|
1448
1448
|
), B = O(
|
|
1449
1449
|
"codes",
|
|
@@ -1464,12 +1464,12 @@ const D = O("tenants", {
|
|
|
1464
1464
|
nonce: s("nonce", { length: 1024 }),
|
|
1465
1465
|
state: s("state", { length: 2048 })
|
|
1466
1466
|
},
|
|
1467
|
-
(
|
|
1467
|
+
(n) => [
|
|
1468
1468
|
se({
|
|
1469
|
-
columns: [
|
|
1469
|
+
columns: [n.code_id, n.code_type],
|
|
1470
1470
|
name: "PK_codes_code_id_code_type"
|
|
1471
1471
|
}),
|
|
1472
|
-
S("codes_expires_at_index").on(
|
|
1472
|
+
S("codes_expires_at_index").on(n.expires_at)
|
|
1473
1473
|
]
|
|
1474
1474
|
), Cr = O("authentication_codes", {
|
|
1475
1475
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1507,9 +1507,9 @@ const D = O("tenants", {
|
|
|
1507
1507
|
audience: s("audience", { length: 255 }),
|
|
1508
1508
|
ip: s("ip", { length: 64 })
|
|
1509
1509
|
},
|
|
1510
|
-
(
|
|
1511
|
-
S("otps_email_index").on(
|
|
1512
|
-
S("otps_expires_at_index").on(
|
|
1510
|
+
(n) => [
|
|
1511
|
+
S("otps_email_index").on(n.email),
|
|
1512
|
+
S("otps_expires_at_index").on(n.expires_at)
|
|
1513
1513
|
]
|
|
1514
1514
|
), Br = O("tickets", {
|
|
1515
1515
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1590,9 +1590,9 @@ const D = O("tenants", {
|
|
|
1590
1590
|
updated_at: s("updated_at", { length: 35 }).notNull(),
|
|
1591
1591
|
connections: s("connections").notNull().default("[]")
|
|
1592
1592
|
},
|
|
1593
|
-
(
|
|
1593
|
+
(n) => [
|
|
1594
1594
|
se({
|
|
1595
|
-
columns: [
|
|
1595
|
+
columns: [n.tenant_id, n.client_id],
|
|
1596
1596
|
name: "clients_tenant_id_client_id"
|
|
1597
1597
|
})
|
|
1598
1598
|
]
|
|
@@ -1614,12 +1614,12 @@ const D = O("tenants", {
|
|
|
1614
1614
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1615
1615
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1616
1616
|
},
|
|
1617
|
-
(
|
|
1617
|
+
(n) => [
|
|
1618
1618
|
se({
|
|
1619
|
-
columns: [
|
|
1619
|
+
columns: [n.tenant_id, n.id],
|
|
1620
1620
|
name: "pk_client_grants"
|
|
1621
1621
|
}),
|
|
1622
|
-
S("idx_client_grants_audience").on(
|
|
1622
|
+
S("idx_client_grants_audience").on(n.audience)
|
|
1623
1623
|
]
|
|
1624
1624
|
), U = O(
|
|
1625
1625
|
"connections",
|
|
@@ -1639,11 +1639,11 @@ const D = O("tenants", {
|
|
|
1639
1639
|
is_system: p("is_system").notNull().default(0),
|
|
1640
1640
|
metadata: s("metadata", { length: 4096 })
|
|
1641
1641
|
},
|
|
1642
|
-
(
|
|
1643
|
-
se({ columns: [
|
|
1644
|
-
S("connections_tenant_id_index").on(
|
|
1642
|
+
(n) => [
|
|
1643
|
+
se({ columns: [n.tenant_id, n.id] }),
|
|
1644
|
+
S("connections_tenant_id_index").on(n.tenant_id),
|
|
1645
1645
|
// Required for keys.connection foreign key reference
|
|
1646
|
-
Te("connections_id_unique").on(
|
|
1646
|
+
Te("connections_id_unique").on(n.id)
|
|
1647
1647
|
]
|
|
1648
1648
|
), re = O(
|
|
1649
1649
|
"custom_domains",
|
|
@@ -1662,7 +1662,7 @@ const D = O("tenants", {
|
|
|
1662
1662
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1663
1663
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1664
1664
|
},
|
|
1665
|
-
(
|
|
1665
|
+
(n) => [Te("custom_domains_domain_unique").on(n.domain)]
|
|
1666
1666
|
), Pr = O("domains", {
|
|
1667
1667
|
id: s("id", { length: 255 }).primaryKey(),
|
|
1668
1668
|
tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
|
|
@@ -1687,7 +1687,7 @@ const D = O("tenants", {
|
|
|
1687
1687
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1688
1688
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1689
1689
|
},
|
|
1690
|
-
(
|
|
1690
|
+
(n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
|
|
1691
1691
|
), P = O(
|
|
1692
1692
|
"user_organizations",
|
|
1693
1693
|
{
|
|
@@ -1698,15 +1698,15 @@ const D = O("tenants", {
|
|
|
1698
1698
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1699
1699
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1700
1700
|
},
|
|
1701
|
-
(
|
|
1701
|
+
(n) => [
|
|
1702
1702
|
Te("user_organizations_unique").on(
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1703
|
+
n.tenant_id,
|
|
1704
|
+
n.user_id,
|
|
1705
|
+
n.organization_id
|
|
1706
1706
|
),
|
|
1707
|
-
S("idx_user_organizations_tenant_id").on(
|
|
1708
|
-
S("idx_user_organizations_user_id").on(
|
|
1709
|
-
S("idx_user_organizations_organization_id").on(
|
|
1707
|
+
S("idx_user_organizations_tenant_id").on(n.tenant_id),
|
|
1708
|
+
S("idx_user_organizations_user_id").on(n.user_id),
|
|
1709
|
+
S("idx_user_organizations_organization_id").on(n.organization_id)
|
|
1710
1710
|
]
|
|
1711
1711
|
), te = O(
|
|
1712
1712
|
"invites",
|
|
@@ -1728,11 +1728,11 @@ const D = O("tenants", {
|
|
|
1728
1728
|
ttl_sec: p("ttl_sec"),
|
|
1729
1729
|
send_invitation_email: p("send_invitation_email")
|
|
1730
1730
|
},
|
|
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(
|
|
1731
|
+
(n) => [
|
|
1732
|
+
S("idx_invites_tenant_id").on(n.tenant_id),
|
|
1733
|
+
S("idx_invites_organization_id").on(n.organization_id),
|
|
1734
|
+
S("idx_invites_expires_at").on(n.expires_at),
|
|
1735
|
+
S("idx_invites_tenant_created").on(n.tenant_id, n.created_at)
|
|
1736
1736
|
]
|
|
1737
1737
|
), J = O(
|
|
1738
1738
|
"roles",
|
|
@@ -1746,8 +1746,8 @@ const D = O("tenants", {
|
|
|
1746
1746
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1747
1747
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1748
1748
|
},
|
|
1749
|
-
(
|
|
1750
|
-
se({ columns: [
|
|
1749
|
+
(n) => [
|
|
1750
|
+
se({ columns: [n.tenant_id, n.id], name: "roles_pk" })
|
|
1751
1751
|
]
|
|
1752
1752
|
), le = O(
|
|
1753
1753
|
"role_permissions",
|
|
@@ -1760,21 +1760,21 @@ const D = O("tenants", {
|
|
|
1760
1760
|
permission_name: s("permission_name", { length: 191 }).notNull(),
|
|
1761
1761
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1762
1762
|
},
|
|
1763
|
-
(
|
|
1763
|
+
(n) => [
|
|
1764
1764
|
se({
|
|
1765
1765
|
columns: [
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1766
|
+
n.tenant_id,
|
|
1767
|
+
n.role_id,
|
|
1768
|
+
n.resource_server_identifier,
|
|
1769
|
+
n.permission_name
|
|
1770
1770
|
],
|
|
1771
1771
|
name: "role_permissions_pk"
|
|
1772
1772
|
}),
|
|
1773
|
-
S("role_permissions_role_fk").on(
|
|
1773
|
+
S("role_permissions_role_fk").on(n.tenant_id, n.role_id),
|
|
1774
1774
|
S("role_permissions_permission_fk").on(
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1775
|
+
n.tenant_id,
|
|
1776
|
+
n.resource_server_identifier,
|
|
1777
|
+
n.permission_name
|
|
1778
1778
|
)
|
|
1779
1779
|
]
|
|
1780
1780
|
), _e = O(
|
|
@@ -1789,24 +1789,24 @@ const D = O("tenants", {
|
|
|
1789
1789
|
organization_id: s("organization_id", { length: 21 }).notNull().default(""),
|
|
1790
1790
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1791
1791
|
},
|
|
1792
|
-
(
|
|
1792
|
+
(n) => [
|
|
1793
1793
|
se({
|
|
1794
1794
|
columns: [
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1795
|
+
n.tenant_id,
|
|
1796
|
+
n.user_id,
|
|
1797
|
+
n.resource_server_identifier,
|
|
1798
|
+
n.permission_name,
|
|
1799
|
+
n.organization_id
|
|
1800
1800
|
],
|
|
1801
1801
|
name: "user_permissions_pk"
|
|
1802
1802
|
}),
|
|
1803
|
-
S("user_permissions_user_fk").on(
|
|
1803
|
+
S("user_permissions_user_fk").on(n.tenant_id, n.user_id),
|
|
1804
1804
|
S("user_permissions_permission_fk").on(
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1805
|
+
n.tenant_id,
|
|
1806
|
+
n.resource_server_identifier,
|
|
1807
|
+
n.permission_name
|
|
1808
1808
|
),
|
|
1809
|
-
S("user_permissions_organization_fk").on(
|
|
1809
|
+
S("user_permissions_organization_fk").on(n.organization_id)
|
|
1810
1810
|
]
|
|
1811
1811
|
), ue = O(
|
|
1812
1812
|
"user_roles",
|
|
@@ -1817,19 +1817,19 @@ const D = O("tenants", {
|
|
|
1817
1817
|
organization_id: s("organization_id", { length: 191 }).notNull().default(""),
|
|
1818
1818
|
created_at: s("created_at", { length: 35 }).notNull()
|
|
1819
1819
|
},
|
|
1820
|
-
(
|
|
1820
|
+
(n) => [
|
|
1821
1821
|
se({
|
|
1822
1822
|
columns: [
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1823
|
+
n.tenant_id,
|
|
1824
|
+
n.user_id,
|
|
1825
|
+
n.role_id,
|
|
1826
|
+
n.organization_id
|
|
1827
1827
|
],
|
|
1828
1828
|
name: "user_roles_pk"
|
|
1829
1829
|
}),
|
|
1830
|
-
S("user_roles_user_fk").on(
|
|
1831
|
-
S("user_roles_role_fk").on(
|
|
1832
|
-
S("user_roles_organization_fk").on(
|
|
1830
|
+
S("user_roles_user_fk").on(n.tenant_id, n.user_id),
|
|
1831
|
+
S("user_roles_role_fk").on(n.tenant_id, n.role_id),
|
|
1832
|
+
S("user_roles_organization_fk").on(n.organization_id)
|
|
1833
1833
|
]
|
|
1834
1834
|
), L = O(
|
|
1835
1835
|
"resource_servers",
|
|
@@ -1854,9 +1854,9 @@ const D = O("tenants", {
|
|
|
1854
1854
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
1855
1855
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
1856
1856
|
},
|
|
1857
|
-
(
|
|
1857
|
+
(n) => [
|
|
1858
1858
|
se({
|
|
1859
|
-
columns: [
|
|
1859
|
+
columns: [n.tenant_id, n.id],
|
|
1860
1860
|
name: "resource_servers_pk"
|
|
1861
1861
|
})
|
|
1862
1862
|
]
|
|
@@ -2005,12 +2005,12 @@ const D = O("tenants", {
|
|
|
2005
2005
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2006
2006
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2007
2007
|
},
|
|
2008
|
-
(
|
|
2008
|
+
(n) => [
|
|
2009
2009
|
se({
|
|
2010
|
-
columns: [
|
|
2010
|
+
columns: [n.tenant_id, n.themeId],
|
|
2011
2011
|
name: "themes_pkey"
|
|
2012
2012
|
}),
|
|
2013
|
-
S("themes_tenant_id_idx").on(
|
|
2013
|
+
S("themes_tenant_id_idx").on(n.tenant_id)
|
|
2014
2014
|
]
|
|
2015
2015
|
), ne = O(
|
|
2016
2016
|
"forms",
|
|
@@ -2028,7 +2028,7 @@ const D = O("tenants", {
|
|
|
2028
2028
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2029
2029
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2030
2030
|
},
|
|
2031
|
-
(
|
|
2031
|
+
(n) => [S("forms_tenant_id_idx").on(n.tenant_id)]
|
|
2032
2032
|
), ie = O(
|
|
2033
2033
|
"flows",
|
|
2034
2034
|
{
|
|
@@ -2039,7 +2039,7 @@ const D = O("tenants", {
|
|
|
2039
2039
|
created_at: s("created_at", { length: 35 }).notNull(),
|
|
2040
2040
|
updated_at: s("updated_at", { length: 35 }).notNull()
|
|
2041
2041
|
},
|
|
2042
|
-
(
|
|
2042
|
+
(n) => [S("flows_tenant_id_idx").on(n.tenant_id)]
|
|
2043
2043
|
), Ee = O("prompt_settings", {
|
|
2044
2044
|
tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
|
|
2045
2045
|
universal_login_experience: s("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
@@ -2077,7 +2077,7 @@ const D = O("tenants", {
|
|
|
2077
2077
|
code_id: s("code_id", { length: 21 })
|
|
2078
2078
|
// only required for code type hooks
|
|
2079
2079
|
},
|
|
2080
|
-
(
|
|
2080
|
+
(n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
|
|
2081
2081
|
), me = O(
|
|
2082
2082
|
"hook_code",
|
|
2083
2083
|
{
|
|
@@ -2088,7 +2088,7 @@ const D = O("tenants", {
|
|
|
2088
2088
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2089
2089
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2090
2090
|
},
|
|
2091
|
-
(
|
|
2091
|
+
(n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
|
|
2092
2092
|
), he = O("keys", {
|
|
2093
2093
|
kid: s("kid", { length: 255 }).primaryKey(),
|
|
2094
2094
|
tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
|
|
@@ -2117,8 +2117,8 @@ const D = O("tenants", {
|
|
|
2117
2117
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2118
2118
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2119
2119
|
},
|
|
2120
|
-
(
|
|
2121
|
-
se({ columns: [
|
|
2120
|
+
(n) => [
|
|
2121
|
+
se({ columns: [n.tenant_id, n.prompt, n.language] })
|
|
2122
2122
|
]
|
|
2123
2123
|
), F = O(
|
|
2124
2124
|
"authentication_methods",
|
|
@@ -2139,12 +2139,12 @@ const D = O("tenants", {
|
|
|
2139
2139
|
created_at_ts: p("created_at_ts").notNull(),
|
|
2140
2140
|
updated_at_ts: p("updated_at_ts").notNull()
|
|
2141
2141
|
},
|
|
2142
|
-
(
|
|
2142
|
+
(n) => [
|
|
2143
2143
|
S("authentication_methods_tenant_user_idx").on(
|
|
2144
|
-
|
|
2145
|
-
|
|
2144
|
+
n.tenant_id,
|
|
2145
|
+
n.user_id
|
|
2146
2146
|
),
|
|
2147
|
-
S("authentication_methods_credential_id_idx").on(
|
|
2147
|
+
S("authentication_methods_credential_id_idx").on(n.credential_id)
|
|
2148
2148
|
]
|
|
2149
2149
|
), T = O(
|
|
2150
2150
|
"logs",
|
|
@@ -2179,15 +2179,15 @@ const D = O("tenants", {
|
|
|
2179
2179
|
time_zone: s("time_zone", { length: 255 }),
|
|
2180
2180
|
continent_code: s("continent_code", { length: 2 })
|
|
2181
2181
|
},
|
|
2182
|
-
(
|
|
2183
|
-
S("logs_user_id").on(
|
|
2184
|
-
S("logs_tenant_id").on(
|
|
2185
|
-
S("logs_date").on(
|
|
2182
|
+
(n) => [
|
|
2183
|
+
S("logs_user_id").on(n.user_id),
|
|
2184
|
+
S("logs_tenant_id").on(n.tenant_id),
|
|
2185
|
+
S("logs_date").on(n.date),
|
|
2186
2186
|
S("IDX_logs_tenant_date_type_user").on(
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2187
|
+
n.tenant_id,
|
|
2188
|
+
n.date,
|
|
2189
|
+
n.type,
|
|
2190
|
+
n.user_id
|
|
2191
2191
|
)
|
|
2192
2192
|
]
|
|
2193
2193
|
), x = O(
|
|
@@ -2210,17 +2210,17 @@ const D = O("tenants", {
|
|
|
2210
2210
|
dead_lettered_at: s("dead_lettered_at", { length: 35 }),
|
|
2211
2211
|
final_error: s("final_error")
|
|
2212
2212
|
},
|
|
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(
|
|
2213
|
+
(n) => [
|
|
2214
|
+
S("idx_outbox_events_tenant_id").on(n.tenant_id),
|
|
2215
|
+
S("idx_outbox_events_processed_at").on(n.processed_at),
|
|
2216
|
+
S("idx_outbox_events_claimed_by").on(n.claimed_by),
|
|
2217
2217
|
// Composite index for the failed-events management endpoints
|
|
2218
2218
|
// (`listFailed` query: tenant_id equality + dead_lettered_at IS NOT NULL
|
|
2219
2219
|
// + ORDER BY dead_lettered_at DESC). Equality column first so the
|
|
2220
2220
|
// optimizer can seek directly to the tenant's dead-letter slice.
|
|
2221
2221
|
S("idx_outbox_events_tenant_dead_lettered").on(
|
|
2222
|
-
|
|
2223
|
-
|
|
2222
|
+
n.tenant_id,
|
|
2223
|
+
n.dead_lettered_at
|
|
2224
2224
|
)
|
|
2225
2225
|
]
|
|
2226
2226
|
), js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -2263,60 +2263,60 @@ const D = O("tenants", {
|
|
|
2263
2263
|
userRoles: ue,
|
|
2264
2264
|
users: k
|
|
2265
2265
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2266
|
-
function z(
|
|
2267
|
-
if (
|
|
2268
|
-
return
|
|
2269
|
-
if (Array.isArray(
|
|
2270
|
-
return
|
|
2266
|
+
function z(n) {
|
|
2267
|
+
if (n == null || typeof n != "object")
|
|
2268
|
+
return n;
|
|
2269
|
+
if (Array.isArray(n))
|
|
2270
|
+
return n.map(
|
|
2271
2271
|
(e) => e !== null && typeof e == "object" ? z(e) : e
|
|
2272
2272
|
);
|
|
2273
|
-
const
|
|
2274
|
-
for (const e in
|
|
2275
|
-
const t =
|
|
2276
|
-
t === null ? delete
|
|
2273
|
+
const i = { ...n };
|
|
2274
|
+
for (const e in i) {
|
|
2275
|
+
const t = i[e];
|
|
2276
|
+
t === null ? delete i[e] : t !== null && typeof t == "object" && (Array.isArray(t) ? i[e] = t.map(
|
|
2277
2277
|
(r) => r !== null && typeof r == "object" ? z(r) : r
|
|
2278
|
-
) :
|
|
2278
|
+
) : i[e] = z(t));
|
|
2279
2279
|
}
|
|
2280
|
-
return
|
|
2280
|
+
return i;
|
|
2281
2281
|
}
|
|
2282
|
-
function Qr(
|
|
2283
|
-
for (const t of
|
|
2284
|
-
|
|
2282
|
+
function Qr(n, i, e = { ...n }) {
|
|
2283
|
+
for (const t of i)
|
|
2284
|
+
n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
|
|
2285
2285
|
return e;
|
|
2286
2286
|
}
|
|
2287
|
-
function Jr(
|
|
2288
|
-
for (const t of
|
|
2289
|
-
|
|
2287
|
+
function Jr(n, i, e = n) {
|
|
2288
|
+
for (const t of i)
|
|
2289
|
+
n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
|
|
2290
2290
|
}
|
|
2291
|
-
function cr(
|
|
2292
|
-
const
|
|
2293
|
-
for (const e in
|
|
2294
|
-
|
|
2295
|
-
return
|
|
2291
|
+
function cr(n) {
|
|
2292
|
+
const i = {};
|
|
2293
|
+
for (const e in n)
|
|
2294
|
+
n[e] !== void 0 && n[e] !== null && (i[e] = n[e]);
|
|
2295
|
+
return i;
|
|
2296
2296
|
}
|
|
2297
|
-
function b(
|
|
2298
|
-
if (
|
|
2299
|
-
return
|
|
2300
|
-
if (typeof
|
|
2297
|
+
function b(n, i) {
|
|
2298
|
+
if (n == null)
|
|
2299
|
+
return i;
|
|
2300
|
+
if (typeof n == "string")
|
|
2301
2301
|
try {
|
|
2302
|
-
return JSON.parse(
|
|
2302
|
+
return JSON.parse(n);
|
|
2303
2303
|
} catch {
|
|
2304
|
-
return
|
|
2304
|
+
return i;
|
|
2305
2305
|
}
|
|
2306
|
-
return
|
|
2306
|
+
return n;
|
|
2307
2307
|
}
|
|
2308
|
-
function Pe(
|
|
2309
|
-
for (const t in
|
|
2310
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
2311
|
-
const r =
|
|
2308
|
+
function Pe(n, i = "", e = {}) {
|
|
2309
|
+
for (const t in n)
|
|
2310
|
+
if (Object.prototype.hasOwnProperty.call(n, t)) {
|
|
2311
|
+
const r = i ? `${i}_${t}` : t, o = n[t];
|
|
2312
2312
|
typeof o == "object" && o !== null && !Array.isArray(o) ? Pe(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
|
|
2313
2313
|
}
|
|
2314
2314
|
return e;
|
|
2315
2315
|
}
|
|
2316
|
-
function gr(
|
|
2316
|
+
function gr(n, i) {
|
|
2317
2317
|
const e = {};
|
|
2318
|
-
for (const [t, r] of Object.entries(
|
|
2319
|
-
const o =
|
|
2318
|
+
for (const [t, r] of Object.entries(n)) {
|
|
2319
|
+
const o = i.find(
|
|
2320
2320
|
(l) => t.startsWith(`${l}_`)
|
|
2321
2321
|
);
|
|
2322
2322
|
if (!o)
|
|
@@ -2331,13 +2331,13 @@ function gr(i, n) {
|
|
|
2331
2331
|
}
|
|
2332
2332
|
return e;
|
|
2333
2333
|
}
|
|
2334
|
-
function Fr(
|
|
2335
|
-
return typeof
|
|
2334
|
+
function Fr(n) {
|
|
2335
|
+
return typeof n == "string" ? parseInt(n, 10) : typeof n == "bigint" ? Number(n) : n;
|
|
2336
2336
|
}
|
|
2337
|
-
function Ur(
|
|
2337
|
+
function Ur(n) {
|
|
2338
2338
|
return {
|
|
2339
|
-
async get(
|
|
2340
|
-
const e = await
|
|
2339
|
+
async get(i) {
|
|
2340
|
+
const e = await n.select().from(Le).where(a(Le.tenant_id, i)).get();
|
|
2341
2341
|
if (!e) return null;
|
|
2342
2342
|
const {
|
|
2343
2343
|
tenant_id: t,
|
|
@@ -2363,11 +2363,11 @@ function Ur(i) {
|
|
|
2363
2363
|
font: c ? { url: c } : void 0
|
|
2364
2364
|
});
|
|
2365
2365
|
},
|
|
2366
|
-
async set(
|
|
2366
|
+
async set(i, e) {
|
|
2367
2367
|
var _, d, c, u, h, f, y, w;
|
|
2368
2368
|
const { colors: t, font: r, ...o } = e, l = {
|
|
2369
2369
|
...o,
|
|
2370
|
-
tenant_id:
|
|
2370
|
+
tenant_id: i,
|
|
2371
2371
|
colors_primary: t == null ? void 0 : t.primary,
|
|
2372
2372
|
colors_page_background_type: (_ = t == null ? void 0 : t.page_background) == null ? void 0 : _.type,
|
|
2373
2373
|
colors_page_background_start: (d = t == null ? void 0 : t.page_background) == null ? void 0 : d.start,
|
|
@@ -2375,7 +2375,7 @@ function Ur(i) {
|
|
|
2375
2375
|
colors_page_background_angle_dev: (u = t == null ? void 0 : t.page_background) == null ? void 0 : u.angle_deg,
|
|
2376
2376
|
font_url: r == null ? void 0 : r.url
|
|
2377
2377
|
};
|
|
2378
|
-
await
|
|
2378
|
+
await n.insert(Le).values(l).onConflictDoUpdate({
|
|
2379
2379
|
target: Le.tenant_id,
|
|
2380
2380
|
set: {
|
|
2381
2381
|
...o,
|
|
@@ -2396,11 +2396,11 @@ var be = class extends Error {
|
|
|
2396
2396
|
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
2397
2397
|
* @param options - Additional options for the exception.
|
|
2398
2398
|
*/
|
|
2399
|
-
constructor(
|
|
2399
|
+
constructor(i = 500, e) {
|
|
2400
2400
|
super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
|
|
2401
2401
|
m(this, "res");
|
|
2402
2402
|
m(this, "status");
|
|
2403
|
-
this.res = e == null ? void 0 : e.res, this.status =
|
|
2403
|
+
this.res = e == null ? void 0 : e.res, this.status = i;
|
|
2404
2404
|
}
|
|
2405
2405
|
/**
|
|
2406
2406
|
* Returns the response object associated with the exception.
|
|
@@ -2416,15 +2416,15 @@ var be = class extends Error {
|
|
|
2416
2416
|
});
|
|
2417
2417
|
}
|
|
2418
2418
|
};
|
|
2419
|
-
function pe(
|
|
2420
|
-
const t =
|
|
2419
|
+
function pe(n, i, e) {
|
|
2420
|
+
const t = i.split(/ OR /i);
|
|
2421
2421
|
if (t.length > 1) {
|
|
2422
2422
|
const c = t.map((u) => {
|
|
2423
2423
|
const h = u.trim().match(/^([^:]+):(.+)$/);
|
|
2424
2424
|
if (h) {
|
|
2425
2425
|
const [, f, y] = h;
|
|
2426
2426
|
if (!f || !y) return null;
|
|
2427
|
-
const w = y.replace(/^"(.*)"$/, "$1"), A =
|
|
2427
|
+
const w = y.replace(/^"(.*)"$/, "$1"), A = n[f.trim()];
|
|
2428
2428
|
return A ? a(A, w.trim()) : null;
|
|
2429
2429
|
}
|
|
2430
2430
|
return null;
|
|
@@ -2433,8 +2433,8 @@ function pe(i, n, e) {
|
|
|
2433
2433
|
}
|
|
2434
2434
|
const r = [];
|
|
2435
2435
|
let o = "", l = !1;
|
|
2436
|
-
for (let c = 0; c <
|
|
2437
|
-
const u =
|
|
2436
|
+
for (let c = 0; c < i.length; c++) {
|
|
2437
|
+
const u = i[c];
|
|
2438
2438
|
u === '"' ? (l = !l, o += u) : u === " " && !l ? o.trim() && (r.push(o.trim()), o = "") : o += u;
|
|
2439
2439
|
}
|
|
2440
2440
|
o.trim() && r.push(o.trim());
|
|
@@ -2453,7 +2453,7 @@ function pe(i, n, e) {
|
|
|
2453
2453
|
}), d = [];
|
|
2454
2454
|
for (const { key: c, value: u, isNegation: h, isExistsQuery: f, operator: y } of _)
|
|
2455
2455
|
if (c) {
|
|
2456
|
-
const w =
|
|
2456
|
+
const w = n[c];
|
|
2457
2457
|
if (!w) {
|
|
2458
2458
|
f ? d.push(
|
|
2459
2459
|
h ? N`${N.identifier(c)} IS NULL` : N`${N.identifier(c)} IS NOT NULL`
|
|
@@ -2500,7 +2500,7 @@ function pe(i, n, e) {
|
|
|
2500
2500
|
}
|
|
2501
2501
|
} else if (u) {
|
|
2502
2502
|
const A = (u.includes("|") ? [...e, "user_id"] : e).map((R) => {
|
|
2503
|
-
const W =
|
|
2503
|
+
const W = n[R];
|
|
2504
2504
|
return W ? R === "user_id" ? a(W, u) : Ie(W, `%${u}%`) : null;
|
|
2505
2505
|
}).filter(Boolean);
|
|
2506
2506
|
A.length > 0 && d.push(de(...A));
|
|
@@ -2543,8 +2543,8 @@ const kt = [
|
|
|
2543
2543
|
"signed_request_object",
|
|
2544
2544
|
"token_quota"
|
|
2545
2545
|
];
|
|
2546
|
-
function Ue(
|
|
2547
|
-
const { tenant_id:
|
|
2546
|
+
function Ue(n) {
|
|
2547
|
+
const { tenant_id: i, connections: e, ...t } = n, r = { ...t };
|
|
2548
2548
|
for (const o of kt)
|
|
2549
2549
|
r[o] = !!t[o];
|
|
2550
2550
|
for (const o of It)
|
|
@@ -2553,26 +2553,26 @@ function Ue(i) {
|
|
|
2553
2553
|
r[o] = b(t[o], {});
|
|
2554
2554
|
return r.connections = b(e, []), z(r);
|
|
2555
2555
|
}
|
|
2556
|
-
function At(
|
|
2557
|
-
const
|
|
2556
|
+
function At(n) {
|
|
2557
|
+
const i = { ...n };
|
|
2558
2558
|
Jr(
|
|
2559
|
-
|
|
2559
|
+
n,
|
|
2560
2560
|
kt,
|
|
2561
|
-
|
|
2561
|
+
i
|
|
2562
2562
|
);
|
|
2563
2563
|
for (const e of It)
|
|
2564
|
-
|
|
2564
|
+
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || []));
|
|
2565
2565
|
for (const e of zt)
|
|
2566
|
-
|
|
2567
|
-
return
|
|
2566
|
+
n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || {}));
|
|
2567
|
+
return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])), cr(i);
|
|
2568
2568
|
}
|
|
2569
|
-
function Kr(
|
|
2569
|
+
function Kr(n) {
|
|
2570
2570
|
return {
|
|
2571
|
-
async create(
|
|
2571
|
+
async create(i, e) {
|
|
2572
2572
|
var l, _;
|
|
2573
2573
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
2574
2574
|
client_id: e.client_id,
|
|
2575
|
-
tenant_id:
|
|
2575
|
+
tenant_id: i,
|
|
2576
2576
|
name: e.name,
|
|
2577
2577
|
description: e.description,
|
|
2578
2578
|
app_type: e.app_type ?? "regular_web",
|
|
@@ -2601,43 +2601,43 @@ function Kr(i) {
|
|
|
2601
2601
|
r.connections = e.connections || [];
|
|
2602
2602
|
const o = At(r);
|
|
2603
2603
|
try {
|
|
2604
|
-
await
|
|
2604
|
+
await n.insert(I).values({ ...o, tenant_id: i });
|
|
2605
2605
|
} catch (d) {
|
|
2606
2606
|
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
2607
|
message: "Client already exists"
|
|
2608
2608
|
}) : d;
|
|
2609
2609
|
}
|
|
2610
|
-
return Ue({ ...o, tenant_id:
|
|
2610
|
+
return Ue({ ...o, tenant_id: i });
|
|
2611
2611
|
},
|
|
2612
|
-
async get(
|
|
2613
|
-
const t = await
|
|
2612
|
+
async get(i, e) {
|
|
2613
|
+
const t = await n.select().from(I).where(
|
|
2614
2614
|
g(
|
|
2615
|
-
a(I.tenant_id,
|
|
2615
|
+
a(I.tenant_id, i),
|
|
2616
2616
|
a(I.client_id, e)
|
|
2617
2617
|
)
|
|
2618
2618
|
).get();
|
|
2619
2619
|
return t ? Ue(t) : null;
|
|
2620
2620
|
},
|
|
2621
|
-
async getByClientId(
|
|
2622
|
-
const e = await
|
|
2621
|
+
async getByClientId(i) {
|
|
2622
|
+
const e = await n.select().from(I).where(a(I.client_id, i)).get();
|
|
2623
2623
|
return e ? {
|
|
2624
2624
|
...Ue(e),
|
|
2625
2625
|
tenant_id: e.tenant_id
|
|
2626
2626
|
} : null;
|
|
2627
2627
|
},
|
|
2628
|
-
async update(
|
|
2628
|
+
async update(i, e, t) {
|
|
2629
2629
|
const r = At({
|
|
2630
2630
|
...t,
|
|
2631
2631
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2632
2632
|
});
|
|
2633
|
-
return delete r.client_id, delete r.tenant_id, await
|
|
2633
|
+
return delete r.client_id, delete r.tenant_id, await n.update(I).set(r).where(
|
|
2634
2634
|
g(
|
|
2635
|
-
a(I.tenant_id,
|
|
2635
|
+
a(I.tenant_id, i),
|
|
2636
2636
|
a(I.client_id, e)
|
|
2637
2637
|
)
|
|
2638
2638
|
), !0;
|
|
2639
2639
|
},
|
|
2640
|
-
async list(
|
|
2640
|
+
async list(i, e) {
|
|
2641
2641
|
const {
|
|
2642
2642
|
page: t = 0,
|
|
2643
2643
|
per_page: r = 50,
|
|
@@ -2645,10 +2645,10 @@ function Kr(i) {
|
|
|
2645
2645
|
sort: l,
|
|
2646
2646
|
q: _
|
|
2647
2647
|
} = e || {};
|
|
2648
|
-
let d =
|
|
2648
|
+
let d = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
|
|
2649
2649
|
if (_) {
|
|
2650
2650
|
const f = pe(I, _, ["name", "client_id"]);
|
|
2651
|
-
f && (d = d.where(g(a(I.tenant_id,
|
|
2651
|
+
f && (d = d.where(g(a(I.tenant_id, i), f)));
|
|
2652
2652
|
}
|
|
2653
2653
|
if (l != null && l.sort_by) {
|
|
2654
2654
|
const f = I[l.sort_by];
|
|
@@ -2659,7 +2659,7 @@ function Kr(i) {
|
|
|
2659
2659
|
const u = (await d.offset(t * r).limit(r)).map(Ue);
|
|
2660
2660
|
if (!o)
|
|
2661
2661
|
return { clients: u };
|
|
2662
|
-
const [h] = await
|
|
2662
|
+
const [h] = await n.select({ count: V() }).from(I).where(a(I.tenant_id, i));
|
|
2663
2663
|
return {
|
|
2664
2664
|
clients: u,
|
|
2665
2665
|
start: t * r,
|
|
@@ -2667,18 +2667,18 @@ function Kr(i) {
|
|
|
2667
2667
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
2668
2668
|
};
|
|
2669
2669
|
},
|
|
2670
|
-
async remove(
|
|
2671
|
-
return (await
|
|
2670
|
+
async remove(i, e) {
|
|
2671
|
+
return (await n.delete(I).where(
|
|
2672
2672
|
g(
|
|
2673
|
-
a(I.tenant_id,
|
|
2673
|
+
a(I.tenant_id, i),
|
|
2674
2674
|
a(I.client_id, e)
|
|
2675
2675
|
)
|
|
2676
2676
|
).returning()).length > 0;
|
|
2677
2677
|
}
|
|
2678
2678
|
};
|
|
2679
2679
|
}
|
|
2680
|
-
function jr(
|
|
2681
|
-
const { tenant_id:
|
|
2680
|
+
function jr(n) {
|
|
2681
|
+
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2682
2682
|
return z({
|
|
2683
2683
|
...o,
|
|
2684
2684
|
options: b(t, {}),
|
|
@@ -2686,49 +2686,49 @@ function jr(i) {
|
|
|
2686
2686
|
is_system: e ? !0 : void 0
|
|
2687
2687
|
});
|
|
2688
2688
|
}
|
|
2689
|
-
function Mr(
|
|
2689
|
+
function Mr(n) {
|
|
2690
2690
|
return {
|
|
2691
|
-
async listByClient(
|
|
2692
|
-
const t = await
|
|
2691
|
+
async listByClient(i, e) {
|
|
2692
|
+
const t = await n.select({ connections: I.connections }).from(I).where(
|
|
2693
2693
|
g(
|
|
2694
|
-
a(I.tenant_id,
|
|
2694
|
+
a(I.tenant_id, i),
|
|
2695
2695
|
a(I.client_id, e)
|
|
2696
2696
|
)
|
|
2697
2697
|
).get();
|
|
2698
2698
|
if (!t) return [];
|
|
2699
2699
|
const r = b(t.connections, []) || [];
|
|
2700
2700
|
if (r.length === 0) return [];
|
|
2701
|
-
const l = (await
|
|
2701
|
+
const l = (await n.select().from(U).where(
|
|
2702
2702
|
g(
|
|
2703
|
-
a(U.tenant_id,
|
|
2703
|
+
a(U.tenant_id, i),
|
|
2704
2704
|
we(U.id, r)
|
|
2705
2705
|
)
|
|
2706
2706
|
).all()).map(jr);
|
|
2707
2707
|
return r.map((_) => l.find((d) => d.id === _)).filter(Boolean);
|
|
2708
2708
|
},
|
|
2709
|
-
async updateByClient(
|
|
2710
|
-
return (await
|
|
2709
|
+
async updateByClient(i, e, t) {
|
|
2710
|
+
return (await n.update(I).set({ connections: JSON.stringify([...new Set(t)]) }).where(
|
|
2711
2711
|
g(
|
|
2712
|
-
a(I.tenant_id,
|
|
2712
|
+
a(I.tenant_id, i),
|
|
2713
2713
|
a(I.client_id, e)
|
|
2714
2714
|
)
|
|
2715
2715
|
).returning()).length > 0;
|
|
2716
2716
|
},
|
|
2717
|
-
async listByConnection(
|
|
2718
|
-
return (await
|
|
2717
|
+
async listByConnection(i, e) {
|
|
2718
|
+
return (await n.select({
|
|
2719
2719
|
client_id: I.client_id,
|
|
2720
2720
|
connections: I.connections
|
|
2721
|
-
}).from(I).where(a(I.tenant_id,
|
|
2721
|
+
}).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (b(r.connections, []) || []).includes(e)).map((r) => r.client_id);
|
|
2722
2722
|
},
|
|
2723
|
-
async addClientToConnection(
|
|
2723
|
+
async addClientToConnection(i, e, t) {
|
|
2724
2724
|
var _;
|
|
2725
|
-
if (!await
|
|
2725
|
+
if (!await n.select({ client_id: I.client_id }).from(I).where(
|
|
2726
2726
|
g(
|
|
2727
|
-
a(I.tenant_id,
|
|
2727
|
+
a(I.tenant_id, i),
|
|
2728
2728
|
a(I.client_id, t)
|
|
2729
2729
|
)
|
|
2730
2730
|
).get()) return !1;
|
|
2731
|
-
const o = await
|
|
2731
|
+
const o = await n.run(
|
|
2732
2732
|
N`UPDATE clients SET connections = CASE
|
|
2733
2733
|
WHEN connections IS NULL OR connections = '[]' OR connections = ''
|
|
2734
2734
|
THEN json_array(${e})
|
|
@@ -2736,64 +2736,64 @@ function Mr(i) {
|
|
|
2736
2736
|
THEN connections
|
|
2737
2737
|
ELSE json_insert(connections, '$[#]', ${e})
|
|
2738
2738
|
END
|
|
2739
|
-
WHERE tenant_id = ${
|
|
2739
|
+
WHERE tenant_id = ${i} AND client_id = ${t}`
|
|
2740
2740
|
);
|
|
2741
2741
|
return (o.changes ?? ((_ = o.meta) == null ? void 0 : _.changes) ?? 0) > 0;
|
|
2742
2742
|
},
|
|
2743
|
-
async removeClientFromConnection(
|
|
2743
|
+
async removeClientFromConnection(i, e, t) {
|
|
2744
2744
|
var l;
|
|
2745
|
-
const r = await
|
|
2745
|
+
const r = await n.run(
|
|
2746
2746
|
N`UPDATE clients SET connections = (
|
|
2747
2747
|
SELECT COALESCE(json_group_array(je.value), '[]')
|
|
2748
2748
|
FROM json_each(COALESCE(connections, '[]')) AS je
|
|
2749
2749
|
WHERE je.value != ${e}
|
|
2750
2750
|
)
|
|
2751
|
-
WHERE tenant_id = ${
|
|
2751
|
+
WHERE tenant_id = ${i} AND client_id = ${t}`
|
|
2752
2752
|
);
|
|
2753
2753
|
return (r.changes ?? ((l = r.meta) == null ? void 0 : l.changes) ?? 0) > 0;
|
|
2754
2754
|
}
|
|
2755
2755
|
};
|
|
2756
2756
|
}
|
|
2757
|
-
let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (
|
|
2758
|
-
let t = 256 - 256 %
|
|
2757
|
+
let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (n) => crypto.getRandomValues(new Uint8Array(n)), Wr = (n, i, e) => {
|
|
2758
|
+
let t = 256 - 256 % n.length;
|
|
2759
2759
|
if (t === 256) {
|
|
2760
|
-
let o =
|
|
2761
|
-
return (l =
|
|
2760
|
+
let o = n.length - 1;
|
|
2761
|
+
return (l = i) => {
|
|
2762
2762
|
if (!l) return "";
|
|
2763
2763
|
let _ = "";
|
|
2764
2764
|
for (; ; ) {
|
|
2765
2765
|
let d = e(l), c = l;
|
|
2766
2766
|
for (; c--; )
|
|
2767
|
-
if (_ +=
|
|
2767
|
+
if (_ += n[d[c] & o], _.length >= l) return _;
|
|
2768
2768
|
}
|
|
2769
2769
|
};
|
|
2770
2770
|
}
|
|
2771
|
-
let r = Math.ceil(1.6 * 256 *
|
|
2772
|
-
return (o =
|
|
2771
|
+
let r = Math.ceil(1.6 * 256 * i / t);
|
|
2772
|
+
return (o = i) => {
|
|
2773
2773
|
if (!o) return "";
|
|
2774
2774
|
let l = "";
|
|
2775
2775
|
for (; ; ) {
|
|
2776
2776
|
let _ = e(r), d = r;
|
|
2777
2777
|
for (; d--; )
|
|
2778
|
-
if (_[d] < t && (l +=
|
|
2778
|
+
if (_[d] < t && (l += n[_[d] % n.length], l.length >= o))
|
|
2779
2779
|
return l;
|
|
2780
2780
|
}
|
|
2781
2781
|
};
|
|
2782
|
-
}, Hr = (
|
|
2783
|
-
let
|
|
2784
|
-
for (;
|
|
2785
|
-
|
|
2786
|
-
return
|
|
2782
|
+
}, Hr = (n, i = 21) => Wr(n, i | 0, Rr), ae = (n = 21) => {
|
|
2783
|
+
let i = "", e = crypto.getRandomValues(new Uint8Array(n |= 0));
|
|
2784
|
+
for (; n--; )
|
|
2785
|
+
i += Vr[e[n] & 63];
|
|
2786
|
+
return i;
|
|
2787
2787
|
};
|
|
2788
|
-
function nt(
|
|
2788
|
+
function nt(n) {
|
|
2789
2789
|
const {
|
|
2790
|
-
tenant_id:
|
|
2790
|
+
tenant_id: i,
|
|
2791
2791
|
scope: e,
|
|
2792
2792
|
authorization_details_types: t,
|
|
2793
2793
|
allow_any_organization: r,
|
|
2794
2794
|
is_system: o,
|
|
2795
2795
|
...l
|
|
2796
|
-
} =
|
|
2796
|
+
} = n;
|
|
2797
2797
|
return z({
|
|
2798
2798
|
...l,
|
|
2799
2799
|
scope: b(e, []),
|
|
@@ -2805,12 +2805,12 @@ function nt(i) {
|
|
|
2805
2805
|
is_system: !!o
|
|
2806
2806
|
});
|
|
2807
2807
|
}
|
|
2808
|
-
function Gr(
|
|
2808
|
+
function Gr(n) {
|
|
2809
2809
|
return {
|
|
2810
|
-
async create(
|
|
2810
|
+
async create(i, e) {
|
|
2811
2811
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
2812
2812
|
id: e.id || ae(),
|
|
2813
|
-
tenant_id:
|
|
2813
|
+
tenant_id: i,
|
|
2814
2814
|
client_id: e.client_id,
|
|
2815
2815
|
audience: e.audience,
|
|
2816
2816
|
scope: JSON.stringify(e.scope || []),
|
|
@@ -2824,15 +2824,15 @@ function Gr(i) {
|
|
|
2824
2824
|
created_at: t,
|
|
2825
2825
|
updated_at: t
|
|
2826
2826
|
};
|
|
2827
|
-
return await
|
|
2827
|
+
return await n.insert(G).values(o), nt({ ...o, tenant_id: i });
|
|
2828
2828
|
},
|
|
2829
|
-
async get(
|
|
2830
|
-
const t = await
|
|
2831
|
-
g(a(G.tenant_id,
|
|
2829
|
+
async get(i, e) {
|
|
2830
|
+
const t = await n.select().from(G).where(
|
|
2831
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2832
2832
|
).get();
|
|
2833
2833
|
return t ? nt(t) : null;
|
|
2834
2834
|
},
|
|
2835
|
-
async update(
|
|
2835
|
+
async update(i, e, t) {
|
|
2836
2836
|
const {
|
|
2837
2837
|
scope: r,
|
|
2838
2838
|
authorization_details_types: o,
|
|
@@ -2845,19 +2845,19 @@ function Gr(i) {
|
|
|
2845
2845
|
};
|
|
2846
2846
|
return r !== void 0 && (c.scope = JSON.stringify(r)), o !== void 0 && (c.authorization_details_types = JSON.stringify(
|
|
2847
2847
|
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,
|
|
2848
|
+
)), l !== void 0 && (c.allow_any_organization = l ? 1 : 0), _ !== void 0 && (c.is_system = _ ? 1 : 0), (await n.update(G).set(c).where(
|
|
2849
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2850
2850
|
).returning()).length > 0;
|
|
2851
2851
|
},
|
|
2852
|
-
async list(
|
|
2852
|
+
async list(i, e) {
|
|
2853
2853
|
const {
|
|
2854
2854
|
page: t = 0,
|
|
2855
2855
|
per_page: r = 50,
|
|
2856
2856
|
include_totals: o = !1,
|
|
2857
2857
|
sort: l,
|
|
2858
2858
|
q: _
|
|
2859
|
-
} = e || {}, d = _ ? pe(G, _, ["client_id", "audience"]) : void 0, c = d ? g(a(G.tenant_id,
|
|
2860
|
-
let u =
|
|
2859
|
+
} = e || {}, d = _ ? pe(G, _, ["client_id", "audience"]) : void 0, c = d ? g(a(G.tenant_id, i), d) : a(G.tenant_id, i);
|
|
2860
|
+
let u = n.select().from(G).where(c).$dynamic();
|
|
2861
2861
|
if (l != null && l.sort_by) {
|
|
2862
2862
|
const w = G[l.sort_by];
|
|
2863
2863
|
w && (u = u.orderBy(
|
|
@@ -2868,7 +2868,7 @@ function Gr(i) {
|
|
|
2868
2868
|
const f = (await u.offset(t * r).limit(r)).map(nt);
|
|
2869
2869
|
if (!o)
|
|
2870
2870
|
return { client_grants: f };
|
|
2871
|
-
const [y] = await
|
|
2871
|
+
const [y] = await n.select({ count: V() }).from(G).where(c);
|
|
2872
2872
|
return {
|
|
2873
2873
|
client_grants: f,
|
|
2874
2874
|
start: t * r,
|
|
@@ -2876,48 +2876,48 @@ function Gr(i) {
|
|
|
2876
2876
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
2877
2877
|
};
|
|
2878
2878
|
},
|
|
2879
|
-
async remove(
|
|
2880
|
-
return (await
|
|
2881
|
-
g(a(G.tenant_id,
|
|
2879
|
+
async remove(i, e) {
|
|
2880
|
+
return (await n.delete(G).where(
|
|
2881
|
+
g(a(G.tenant_id, i), a(G.id, e))
|
|
2882
2882
|
).returning()).length > 0;
|
|
2883
2883
|
}
|
|
2884
2884
|
};
|
|
2885
2885
|
}
|
|
2886
|
-
function it(
|
|
2887
|
-
const { tenant_id:
|
|
2886
|
+
function it(n) {
|
|
2887
|
+
const { tenant_id: i, ...e } = n;
|
|
2888
2888
|
return z(e);
|
|
2889
2889
|
}
|
|
2890
|
-
function Yr(
|
|
2890
|
+
function Yr(n) {
|
|
2891
2891
|
return {
|
|
2892
|
-
async create(
|
|
2892
|
+
async create(i, e) {
|
|
2893
2893
|
const t = {
|
|
2894
2894
|
...e,
|
|
2895
|
-
tenant_id:
|
|
2895
|
+
tenant_id: i,
|
|
2896
2896
|
created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
2897
2897
|
expires_at: e.expires_at
|
|
2898
2898
|
};
|
|
2899
|
-
return await
|
|
2899
|
+
return await n.insert(B).values(t), it(t);
|
|
2900
2900
|
},
|
|
2901
|
-
async get(
|
|
2902
|
-
if (!
|
|
2901
|
+
async get(i, e, t) {
|
|
2902
|
+
if (!i)
|
|
2903
2903
|
throw new Error("tenant_id is required");
|
|
2904
|
-
const r = await
|
|
2904
|
+
const r = await n.select().from(B).where(
|
|
2905
2905
|
g(
|
|
2906
|
-
a(B.tenant_id,
|
|
2906
|
+
a(B.tenant_id, i),
|
|
2907
2907
|
a(B.code_id, e),
|
|
2908
2908
|
a(B.code_type, t)
|
|
2909
2909
|
)
|
|
2910
2910
|
).get();
|
|
2911
2911
|
return r ? it(r) : null;
|
|
2912
2912
|
},
|
|
2913
|
-
async list(
|
|
2913
|
+
async list(i, e) {
|
|
2914
2914
|
const {
|
|
2915
2915
|
page: t = 0,
|
|
2916
2916
|
per_page: r = 50,
|
|
2917
2917
|
include_totals: o = !1,
|
|
2918
2918
|
sort: l
|
|
2919
2919
|
} = e || {};
|
|
2920
|
-
let _ =
|
|
2920
|
+
let _ = n.select().from(B).where(a(B.tenant_id, i)).$dynamic();
|
|
2921
2921
|
if (l != null && l.sort_by) {
|
|
2922
2922
|
const h = B[l.sort_by];
|
|
2923
2923
|
h && (_ = _.orderBy(
|
|
@@ -2927,7 +2927,7 @@ function Yr(i) {
|
|
|
2927
2927
|
const c = (await _.offset(t * r).limit(r)).map(it);
|
|
2928
2928
|
if (!o)
|
|
2929
2929
|
return { codes: c };
|
|
2930
|
-
const [u] = await
|
|
2930
|
+
const [u] = await n.select({ count: V() }).from(B).where(a(B.tenant_id, i));
|
|
2931
2931
|
return {
|
|
2932
2932
|
codes: c,
|
|
2933
2933
|
start: t * r,
|
|
@@ -2935,29 +2935,29 @@ function Yr(i) {
|
|
|
2935
2935
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
2936
2936
|
};
|
|
2937
2937
|
},
|
|
2938
|
-
async used(
|
|
2939
|
-
return (await
|
|
2938
|
+
async used(i, e) {
|
|
2939
|
+
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
2940
|
},
|
|
2941
|
-
async consume(
|
|
2942
|
-
return (await
|
|
2941
|
+
async consume(i, e) {
|
|
2942
|
+
return (await n.update(B).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
|
|
2943
2943
|
g(
|
|
2944
|
-
a(B.tenant_id,
|
|
2944
|
+
a(B.tenant_id, i),
|
|
2945
2945
|
a(B.code_id, e),
|
|
2946
2946
|
ye(B.used_at)
|
|
2947
2947
|
)
|
|
2948
2948
|
).returning()).length > 0;
|
|
2949
2949
|
},
|
|
2950
|
-
async remove(
|
|
2951
|
-
return (await
|
|
2950
|
+
async remove(i, e) {
|
|
2951
|
+
return (await n.delete(B).where(g(a(B.tenant_id, i), a(B.code_id, e))).returning()).length > 0;
|
|
2952
2952
|
}
|
|
2953
2953
|
};
|
|
2954
2954
|
}
|
|
2955
2955
|
function Xr() {
|
|
2956
|
-
const { customAlphabet:
|
|
2957
|
-
return `con_${
|
|
2956
|
+
const { customAlphabet: n } = require("nanoid");
|
|
2957
|
+
return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2958
2958
|
}
|
|
2959
|
-
function rt(
|
|
2960
|
-
const { tenant_id:
|
|
2959
|
+
function rt(n) {
|
|
2960
|
+
const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
|
|
2961
2961
|
return z({
|
|
2962
2962
|
...o,
|
|
2963
2963
|
options: b(t, {}),
|
|
@@ -2965,14 +2965,14 @@ function rt(i) {
|
|
|
2965
2965
|
is_system: e ? !0 : void 0
|
|
2966
2966
|
});
|
|
2967
2967
|
}
|
|
2968
|
-
function Zr(
|
|
2968
|
+
function Zr(n) {
|
|
2969
2969
|
return {
|
|
2970
|
-
async create(
|
|
2970
|
+
async create(i, e) {
|
|
2971
2971
|
var o, l;
|
|
2972
2972
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
|
|
2973
2973
|
id: e.id || Xr(),
|
|
2974
2974
|
...e,
|
|
2975
|
-
tenant_id:
|
|
2975
|
+
tenant_id: i,
|
|
2976
2976
|
options: JSON.stringify(e.options || {}),
|
|
2977
2977
|
metadata: e.metadata ? JSON.stringify(e.metadata) : void 0,
|
|
2978
2978
|
is_system: e.is_system ? 1 : 0,
|
|
@@ -2980,7 +2980,7 @@ function Zr(i) {
|
|
|
2980
2980
|
updated_at: t
|
|
2981
2981
|
};
|
|
2982
2982
|
try {
|
|
2983
|
-
await
|
|
2983
|
+
await n.insert(U).values(r);
|
|
2984
2984
|
} catch (_) {
|
|
2985
2985
|
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
2986
|
message: "Connection already exists"
|
|
@@ -2988,27 +2988,27 @@ function Zr(i) {
|
|
|
2988
2988
|
}
|
|
2989
2989
|
return rt(r);
|
|
2990
2990
|
},
|
|
2991
|
-
async get(
|
|
2992
|
-
const t = await
|
|
2991
|
+
async get(i, e) {
|
|
2992
|
+
const t = await n.select().from(U).where(
|
|
2993
2993
|
g(
|
|
2994
|
-
a(U.tenant_id,
|
|
2994
|
+
a(U.tenant_id, i),
|
|
2995
2995
|
a(U.id, e)
|
|
2996
2996
|
)
|
|
2997
2997
|
).get();
|
|
2998
2998
|
return t ? rt(t) : null;
|
|
2999
2999
|
},
|
|
3000
|
-
async update(
|
|
3000
|
+
async update(i, e, t) {
|
|
3001
3001
|
const r = {
|
|
3002
3002
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3003
3003
|
};
|
|
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
|
|
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 n.update(U).set(r).where(
|
|
3005
3005
|
g(
|
|
3006
|
-
a(U.tenant_id,
|
|
3006
|
+
a(U.tenant_id, i),
|
|
3007
3007
|
a(U.id, e)
|
|
3008
3008
|
)
|
|
3009
3009
|
), !0;
|
|
3010
3010
|
},
|
|
3011
|
-
async list(
|
|
3011
|
+
async list(i, e) {
|
|
3012
3012
|
const {
|
|
3013
3013
|
page: t = 0,
|
|
3014
3014
|
per_page: r = 50,
|
|
@@ -3016,12 +3016,12 @@ function Zr(i) {
|
|
|
3016
3016
|
sort: l,
|
|
3017
3017
|
q: _
|
|
3018
3018
|
} = e || {};
|
|
3019
|
-
let d = a(U.tenant_id,
|
|
3019
|
+
let d = a(U.tenant_id, i);
|
|
3020
3020
|
if (_) {
|
|
3021
3021
|
const y = pe(U, _, ["name"]);
|
|
3022
3022
|
y && (d = g(d, y));
|
|
3023
3023
|
}
|
|
3024
|
-
let c =
|
|
3024
|
+
let c = n.select().from(U).where(d).$dynamic();
|
|
3025
3025
|
if (l != null && l.sort_by) {
|
|
3026
3026
|
const y = U[l.sort_by];
|
|
3027
3027
|
y && (c = c.orderBy(
|
|
@@ -3031,7 +3031,7 @@ function Zr(i) {
|
|
|
3031
3031
|
const h = (await c.offset(t * r).limit(r)).map(rt);
|
|
3032
3032
|
if (!o)
|
|
3033
3033
|
return { connections: h };
|
|
3034
|
-
const [f] = await
|
|
3034
|
+
const [f] = await n.select({ count: V() }).from(U).where(d);
|
|
3035
3035
|
return {
|
|
3036
3036
|
connections: h,
|
|
3037
3037
|
start: t * r,
|
|
@@ -3039,30 +3039,30 @@ function Zr(i) {
|
|
|
3039
3039
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
3040
3040
|
};
|
|
3041
3041
|
},
|
|
3042
|
-
async remove(
|
|
3043
|
-
return (await
|
|
3042
|
+
async remove(i, e) {
|
|
3043
|
+
return (await n.delete(U).where(
|
|
3044
3044
|
g(
|
|
3045
|
-
a(U.tenant_id,
|
|
3045
|
+
a(U.tenant_id, i),
|
|
3046
3046
|
a(U.id, e)
|
|
3047
3047
|
)
|
|
3048
3048
|
).returning()).length > 0;
|
|
3049
3049
|
}
|
|
3050
3050
|
};
|
|
3051
3051
|
}
|
|
3052
|
-
function Ke(
|
|
3053
|
-
const { tenant_id:
|
|
3052
|
+
function Ke(n) {
|
|
3053
|
+
const { tenant_id: i, domain_metadata: e, ...t } = n;
|
|
3054
3054
|
return z({
|
|
3055
3055
|
...t,
|
|
3056
3056
|
primary: !!t.primary,
|
|
3057
3057
|
domain_metadata: b(e)
|
|
3058
3058
|
});
|
|
3059
3059
|
}
|
|
3060
|
-
function es(
|
|
3060
|
+
function es(n) {
|
|
3061
3061
|
return {
|
|
3062
|
-
async create(
|
|
3062
|
+
async create(i, e) {
|
|
3063
3063
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3064
3064
|
custom_domain_id: e.custom_domain_id || ae(),
|
|
3065
|
-
tenant_id:
|
|
3065
|
+
tenant_id: i,
|
|
3066
3066
|
domain: e.domain,
|
|
3067
3067
|
primary: e.primary ?? !1,
|
|
3068
3068
|
status: e.status || "pending",
|
|
@@ -3075,54 +3075,54 @@ function es(i) {
|
|
|
3075
3075
|
created_at: t,
|
|
3076
3076
|
updated_at: t
|
|
3077
3077
|
};
|
|
3078
|
-
return await
|
|
3078
|
+
return await n.insert(re).values(o), Ke({ ...o, tenant_id: i });
|
|
3079
3079
|
},
|
|
3080
|
-
async get(
|
|
3081
|
-
const t = await
|
|
3080
|
+
async get(i, e) {
|
|
3081
|
+
const t = await n.select().from(re).where(
|
|
3082
3082
|
g(
|
|
3083
|
-
a(re.tenant_id,
|
|
3083
|
+
a(re.tenant_id, i),
|
|
3084
3084
|
a(re.custom_domain_id, e)
|
|
3085
3085
|
)
|
|
3086
3086
|
).get();
|
|
3087
3087
|
return t ? Ke(t) : null;
|
|
3088
3088
|
},
|
|
3089
|
-
async getByDomain(
|
|
3090
|
-
const e = await
|
|
3089
|
+
async getByDomain(i) {
|
|
3090
|
+
const e = await n.select().from(re).where(a(re.domain, i)).get();
|
|
3091
3091
|
return e ? {
|
|
3092
3092
|
...Ke(e),
|
|
3093
3093
|
tenant_id: e.tenant_id
|
|
3094
3094
|
} : null;
|
|
3095
3095
|
},
|
|
3096
|
-
async list(
|
|
3097
|
-
return (await
|
|
3096
|
+
async list(i) {
|
|
3097
|
+
return (await n.select().from(re).where(a(re.tenant_id, i)).all()).map(Ke);
|
|
3098
3098
|
},
|
|
3099
|
-
async update(
|
|
3099
|
+
async update(i, e, t) {
|
|
3100
3100
|
const r = {
|
|
3101
3101
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3102
3102
|
};
|
|
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
|
|
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 n.update(re).set(r).where(
|
|
3104
3104
|
g(
|
|
3105
|
-
a(re.tenant_id,
|
|
3105
|
+
a(re.tenant_id, i),
|
|
3106
3106
|
a(re.custom_domain_id, e)
|
|
3107
3107
|
)
|
|
3108
3108
|
).returning()).length > 0;
|
|
3109
3109
|
},
|
|
3110
|
-
async remove(
|
|
3111
|
-
return (await
|
|
3110
|
+
async remove(i, e) {
|
|
3111
|
+
return (await n.delete(re).where(
|
|
3112
3112
|
g(
|
|
3113
|
-
a(re.tenant_id,
|
|
3113
|
+
a(re.tenant_id, i),
|
|
3114
3114
|
a(re.custom_domain_id, e)
|
|
3115
3115
|
)
|
|
3116
3116
|
).returning()).length > 0;
|
|
3117
3117
|
}
|
|
3118
3118
|
};
|
|
3119
3119
|
}
|
|
3120
|
-
function ts(
|
|
3120
|
+
function ts(n) {
|
|
3121
3121
|
return {
|
|
3122
|
-
async get(
|
|
3123
|
-
const r = await
|
|
3122
|
+
async get(i, e, t) {
|
|
3123
|
+
const r = await n.select().from(ee).where(
|
|
3124
3124
|
g(
|
|
3125
|
-
a(ee.tenant_id,
|
|
3125
|
+
a(ee.tenant_id, i),
|
|
3126
3126
|
a(ee.prompt, e),
|
|
3127
3127
|
a(ee.language, t)
|
|
3128
3128
|
)
|
|
@@ -3134,10 +3134,10 @@ function ts(i) {
|
|
|
3134
3134
|
return null;
|
|
3135
3135
|
}
|
|
3136
3136
|
},
|
|
3137
|
-
async set(
|
|
3137
|
+
async set(i, e, t, r) {
|
|
3138
3138
|
const o = Date.now(), l = JSON.stringify(r);
|
|
3139
|
-
await
|
|
3140
|
-
tenant_id:
|
|
3139
|
+
await n.insert(ee).values({
|
|
3140
|
+
tenant_id: i,
|
|
3141
3141
|
prompt: e,
|
|
3142
3142
|
language: t,
|
|
3143
3143
|
custom_text: l,
|
|
@@ -3152,29 +3152,29 @@ function ts(i) {
|
|
|
3152
3152
|
set: { custom_text: l, updated_at_ts: o }
|
|
3153
3153
|
});
|
|
3154
3154
|
},
|
|
3155
|
-
async delete(
|
|
3156
|
-
await
|
|
3155
|
+
async delete(i, e, t) {
|
|
3156
|
+
await n.delete(ee).where(
|
|
3157
3157
|
g(
|
|
3158
|
-
a(ee.tenant_id,
|
|
3158
|
+
a(ee.tenant_id, i),
|
|
3159
3159
|
a(ee.prompt, e),
|
|
3160
3160
|
a(ee.language, t)
|
|
3161
3161
|
)
|
|
3162
3162
|
);
|
|
3163
3163
|
},
|
|
3164
|
-
async list(
|
|
3165
|
-
return await
|
|
3164
|
+
async list(i) {
|
|
3165
|
+
return await n.select({
|
|
3166
3166
|
prompt: ee.prompt,
|
|
3167
3167
|
language: ee.language
|
|
3168
|
-
}).from(ee).where(a(ee.tenant_id,
|
|
3168
|
+
}).from(ee).where(a(ee.tenant_id, i)).all();
|
|
3169
3169
|
}
|
|
3170
3170
|
};
|
|
3171
3171
|
}
|
|
3172
|
-
function ns(
|
|
3172
|
+
function ns(n) {
|
|
3173
3173
|
return {
|
|
3174
|
-
async create(
|
|
3174
|
+
async create(i, e) {
|
|
3175
3175
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
3176
|
-
await
|
|
3177
|
-
tenant_id:
|
|
3176
|
+
await n.insert(ve).values({
|
|
3177
|
+
tenant_id: i,
|
|
3178
3178
|
name: e.name,
|
|
3179
3179
|
enabled: e.enabled,
|
|
3180
3180
|
default_from_address: e.default_from_address,
|
|
@@ -3184,8 +3184,8 @@ function ns(i) {
|
|
|
3184
3184
|
updated_at: t
|
|
3185
3185
|
});
|
|
3186
3186
|
},
|
|
3187
|
-
async get(
|
|
3188
|
-
const e = await
|
|
3187
|
+
async get(i) {
|
|
3188
|
+
const e = await n.select().from(ve).where(a(ve.tenant_id, i)).get();
|
|
3189
3189
|
if (!e) return null;
|
|
3190
3190
|
const { tenant_id: t, ...r } = e;
|
|
3191
3191
|
return z({
|
|
@@ -3195,24 +3195,24 @@ function ns(i) {
|
|
|
3195
3195
|
settings: b(r.settings, {})
|
|
3196
3196
|
});
|
|
3197
3197
|
},
|
|
3198
|
-
async update(
|
|
3198
|
+
async update(i, e) {
|
|
3199
3199
|
const t = {
|
|
3200
3200
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3201
3201
|
};
|
|
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
|
|
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 n.update(ve).set(t).where(a(ve.tenant_id, i));
|
|
3203
3203
|
},
|
|
3204
|
-
async remove(
|
|
3205
|
-
await
|
|
3204
|
+
async remove(i) {
|
|
3205
|
+
await n.delete(ve).where(a(ve.tenant_id, i));
|
|
3206
3206
|
}
|
|
3207
3207
|
};
|
|
3208
3208
|
}
|
|
3209
|
-
function is(
|
|
3209
|
+
function is(n) {
|
|
3210
3210
|
return {
|
|
3211
|
-
async create(
|
|
3211
|
+
async create(i, e) {
|
|
3212
3212
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = `af_${ae()}`;
|
|
3213
|
-
return await
|
|
3213
|
+
return await n.insert(ie).values({
|
|
3214
3214
|
id: r,
|
|
3215
|
-
tenant_id:
|
|
3215
|
+
tenant_id: i,
|
|
3216
3216
|
name: e.name,
|
|
3217
3217
|
actions: JSON.stringify(e.actions || []),
|
|
3218
3218
|
created_at: t,
|
|
@@ -3225,8 +3225,8 @@ function is(i) {
|
|
|
3225
3225
|
updated_at: t
|
|
3226
3226
|
};
|
|
3227
3227
|
},
|
|
3228
|
-
async get(
|
|
3229
|
-
const t = await
|
|
3228
|
+
async get(i, e) {
|
|
3229
|
+
const t = await n.select().from(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).get();
|
|
3230
3230
|
if (!t) return null;
|
|
3231
3231
|
const { tenant_id: r, actions: o, ...l } = t;
|
|
3232
3232
|
return z({
|
|
@@ -3234,20 +3234,20 @@ function is(i) {
|
|
|
3234
3234
|
actions: b(o, [])
|
|
3235
3235
|
});
|
|
3236
3236
|
},
|
|
3237
|
-
async update(
|
|
3237
|
+
async update(i, e, t) {
|
|
3238
3238
|
const r = {
|
|
3239
3239
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3240
3240
|
};
|
|
3241
|
-
return t.name !== void 0 && (r.name = t.name), t.actions !== void 0 && (r.actions = JSON.stringify(t.actions)), (await
|
|
3241
|
+
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
3242
|
},
|
|
3243
|
-
async list(
|
|
3243
|
+
async list(i, e) {
|
|
3244
3244
|
const {
|
|
3245
3245
|
page: t = 0,
|
|
3246
3246
|
per_page: r = 50,
|
|
3247
3247
|
include_totals: o = !1,
|
|
3248
3248
|
sort: l
|
|
3249
3249
|
} = e || {};
|
|
3250
|
-
let _ =
|
|
3250
|
+
let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
|
|
3251
3251
|
if (l != null && l.sort_by) {
|
|
3252
3252
|
const h = ie[l.sort_by];
|
|
3253
3253
|
h && (_ = _.orderBy(
|
|
@@ -3263,7 +3263,7 @@ function is(i) {
|
|
|
3263
3263
|
});
|
|
3264
3264
|
if (!o)
|
|
3265
3265
|
return { flows: c };
|
|
3266
|
-
const [u] = await
|
|
3266
|
+
const [u] = await n.select({ count: V() }).from(ie).where(a(ie.tenant_id, i));
|
|
3267
3267
|
return {
|
|
3268
3268
|
flows: c,
|
|
3269
3269
|
start: t * r,
|
|
@@ -3271,18 +3271,18 @@ function is(i) {
|
|
|
3271
3271
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3272
3272
|
};
|
|
3273
3273
|
},
|
|
3274
|
-
async remove(
|
|
3275
|
-
return (await
|
|
3274
|
+
async remove(i, e) {
|
|
3275
|
+
return (await n.delete(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length > 0;
|
|
3276
3276
|
}
|
|
3277
3277
|
};
|
|
3278
3278
|
}
|
|
3279
3279
|
const je = ["nodes", "start", "ending"];
|
|
3280
|
-
function rs(
|
|
3280
|
+
function rs(n) {
|
|
3281
3281
|
return {
|
|
3282
|
-
async create(
|
|
3282
|
+
async create(i, e) {
|
|
3283
3283
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = ae(), o = {
|
|
3284
3284
|
id: r,
|
|
3285
|
-
tenant_id:
|
|
3285
|
+
tenant_id: i,
|
|
3286
3286
|
name: e.name,
|
|
3287
3287
|
messages: e.messages,
|
|
3288
3288
|
languages: e.languages,
|
|
@@ -3295,37 +3295,37 @@ function rs(i) {
|
|
|
3295
3295
|
o[l] = JSON.stringify(
|
|
3296
3296
|
e[l] || (l === "nodes" ? [] : {})
|
|
3297
3297
|
);
|
|
3298
|
-
return await
|
|
3298
|
+
return await n.insert(ne).values(o), {
|
|
3299
3299
|
id: r,
|
|
3300
3300
|
...e,
|
|
3301
3301
|
created_at: t,
|
|
3302
3302
|
updated_at: t
|
|
3303
3303
|
};
|
|
3304
3304
|
},
|
|
3305
|
-
async get(
|
|
3306
|
-
const t = await
|
|
3305
|
+
async get(i, e) {
|
|
3306
|
+
const t = await n.select().from(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).get();
|
|
3307
3307
|
if (!t) return null;
|
|
3308
3308
|
const { tenant_id: r, ...o } = t, l = { ...o };
|
|
3309
3309
|
for (const _ of je)
|
|
3310
3310
|
l[_] = b(o[_]);
|
|
3311
3311
|
return z(l);
|
|
3312
3312
|
},
|
|
3313
|
-
async update(
|
|
3313
|
+
async update(i, e, t) {
|
|
3314
3314
|
const r = {
|
|
3315
3315
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3316
3316
|
};
|
|
3317
3317
|
for (const [l, _] of Object.entries(t))
|
|
3318
3318
|
_ !== void 0 && (je.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
|
|
3319
|
-
return (await
|
|
3319
|
+
return (await n.update(ne).set(r).where(g(a(ne.tenant_id, i), a(ne.id, e))).returning()).length > 0;
|
|
3320
3320
|
},
|
|
3321
|
-
async list(
|
|
3321
|
+
async list(i, e) {
|
|
3322
3322
|
const {
|
|
3323
3323
|
page: t = 0,
|
|
3324
3324
|
per_page: r = 50,
|
|
3325
3325
|
include_totals: o = !1,
|
|
3326
3326
|
sort: l
|
|
3327
3327
|
} = e || {};
|
|
3328
|
-
let _ =
|
|
3328
|
+
let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
|
|
3329
3329
|
if (l != null && l.sort_by) {
|
|
3330
3330
|
const h = ne[l.sort_by];
|
|
3331
3331
|
h && (_ = _.orderBy(
|
|
@@ -3340,7 +3340,7 @@ function rs(i) {
|
|
|
3340
3340
|
});
|
|
3341
3341
|
if (!o)
|
|
3342
3342
|
return { forms: c };
|
|
3343
|
-
const [u] = await
|
|
3343
|
+
const [u] = await n.select({ count: V() }).from(ne).where(a(ne.tenant_id, i));
|
|
3344
3344
|
return {
|
|
3345
3345
|
forms: c,
|
|
3346
3346
|
start: t * r,
|
|
@@ -3348,41 +3348,41 @@ function rs(i) {
|
|
|
3348
3348
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3349
3349
|
};
|
|
3350
3350
|
},
|
|
3351
|
-
async remove(
|
|
3352
|
-
return (await
|
|
3351
|
+
async remove(i, e) {
|
|
3352
|
+
return (await n.delete(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).returning()).length > 0;
|
|
3353
3353
|
}
|
|
3354
3354
|
};
|
|
3355
3355
|
}
|
|
3356
|
-
function fr(
|
|
3357
|
-
if (
|
|
3358
|
-
if (typeof
|
|
3359
|
-
return new Date(
|
|
3360
|
-
if (typeof
|
|
3361
|
-
if (
|
|
3356
|
+
function fr(n) {
|
|
3357
|
+
if (n != null) {
|
|
3358
|
+
if (typeof n == "number")
|
|
3359
|
+
return new Date(n).toISOString();
|
|
3360
|
+
if (typeof n == "string") {
|
|
3361
|
+
if (n === "")
|
|
3362
3362
|
return;
|
|
3363
|
-
const
|
|
3364
|
-
return !isNaN(
|
|
3363
|
+
const i = parseFloat(n);
|
|
3364
|
+
return !isNaN(i) && /^\d+(\.\d+)?$/.test(n) ? new Date(i).toISOString() : n;
|
|
3365
3365
|
}
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
|
-
function wt(
|
|
3369
|
-
return fr(
|
|
3368
|
+
function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
|
|
3369
|
+
return fr(n) ?? i;
|
|
3370
3370
|
}
|
|
3371
|
-
function K(
|
|
3372
|
-
if (!
|
|
3371
|
+
function K(n) {
|
|
3372
|
+
if (!n || n === "")
|
|
3373
3373
|
return null;
|
|
3374
|
-
const
|
|
3375
|
-
return isNaN(
|
|
3374
|
+
const i = new Date(n);
|
|
3375
|
+
return isNaN(i.getTime()) ? null : i.getTime();
|
|
3376
3376
|
}
|
|
3377
|
-
function Fe(
|
|
3377
|
+
function Fe(n, i, e = []) {
|
|
3378
3378
|
const t = {};
|
|
3379
|
-
for (const r of
|
|
3379
|
+
for (const r of i) {
|
|
3380
3380
|
const o = r.replace(/_ts$/, "");
|
|
3381
|
-
t[o] = wt(
|
|
3381
|
+
t[o] = wt(n[r]);
|
|
3382
3382
|
}
|
|
3383
3383
|
for (const r of e) {
|
|
3384
3384
|
const o = r.replace(/_ts$/, "");
|
|
3385
|
-
t[o] = fr(
|
|
3385
|
+
t[o] = fr(n[r]);
|
|
3386
3386
|
}
|
|
3387
3387
|
return t;
|
|
3388
3388
|
}
|
|
@@ -3393,8 +3393,8 @@ const ss = Hr(
|
|
|
3393
3393
|
function os() {
|
|
3394
3394
|
return `hc_${ss()}`;
|
|
3395
3395
|
}
|
|
3396
|
-
function Ct(
|
|
3397
|
-
const { created_at_ts:
|
|
3396
|
+
function Ct(n) {
|
|
3397
|
+
const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Fe({ created_at_ts: i, updated_at_ts: e }, [
|
|
3398
3398
|
"created_at_ts",
|
|
3399
3399
|
"updated_at_ts"
|
|
3400
3400
|
]);
|
|
@@ -3404,40 +3404,40 @@ function Ct(i) {
|
|
|
3404
3404
|
secrets: t ? JSON.parse(t) : void 0
|
|
3405
3405
|
};
|
|
3406
3406
|
}
|
|
3407
|
-
function as(
|
|
3407
|
+
function as(n) {
|
|
3408
3408
|
return {
|
|
3409
|
-
async create(
|
|
3409
|
+
async create(i, e) {
|
|
3410
3410
|
const t = Date.now(), o = {
|
|
3411
3411
|
id: os(),
|
|
3412
|
-
tenant_id:
|
|
3412
|
+
tenant_id: i,
|
|
3413
3413
|
code: e.code,
|
|
3414
3414
|
secrets: e.secrets ? JSON.stringify(e.secrets) : null,
|
|
3415
3415
|
created_at_ts: t,
|
|
3416
3416
|
updated_at_ts: t
|
|
3417
3417
|
};
|
|
3418
|
-
return await
|
|
3418
|
+
return await n.insert(me).values(o), Ct({ ...o, tenant_id: i });
|
|
3419
3419
|
},
|
|
3420
|
-
async get(
|
|
3421
|
-
const t = await
|
|
3420
|
+
async get(i, e) {
|
|
3421
|
+
const t = await n.select().from(me).where(g(a(me.tenant_id, i), a(me.id, e))).get();
|
|
3422
3422
|
return t ? Ct(t) : null;
|
|
3423
3423
|
},
|
|
3424
|
-
async update(
|
|
3424
|
+
async update(i, e, t) {
|
|
3425
3425
|
const r = {
|
|
3426
3426
|
updated_at_ts: Date.now()
|
|
3427
3427
|
};
|
|
3428
|
-
return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await
|
|
3428
|
+
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
3429
|
},
|
|
3430
|
-
async remove(
|
|
3431
|
-
return (await
|
|
3430
|
+
async remove(i, e) {
|
|
3431
|
+
return (await n.delete(me).where(g(a(me.tenant_id, i), a(me.id, e))).returning()).length > 0;
|
|
3432
3432
|
}
|
|
3433
3433
|
};
|
|
3434
3434
|
}
|
|
3435
3435
|
function ls() {
|
|
3436
|
-
const { customAlphabet:
|
|
3437
|
-
return `h_${
|
|
3436
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3437
|
+
return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3438
3438
|
}
|
|
3439
|
-
function st(
|
|
3440
|
-
const { tenant_id:
|
|
3439
|
+
function st(n) {
|
|
3440
|
+
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
3441
|
"created_at_ts",
|
|
3442
3442
|
"updated_at_ts"
|
|
3443
3443
|
]);
|
|
@@ -3448,12 +3448,12 @@ function st(i) {
|
|
|
3448
3448
|
...o
|
|
3449
3449
|
});
|
|
3450
3450
|
}
|
|
3451
|
-
function _s(
|
|
3451
|
+
function _s(n) {
|
|
3452
3452
|
return {
|
|
3453
|
-
async create(
|
|
3453
|
+
async create(i, e) {
|
|
3454
3454
|
const t = Date.now(), o = {
|
|
3455
3455
|
hook_id: e.hook_id || ls(),
|
|
3456
|
-
tenant_id:
|
|
3456
|
+
tenant_id: i,
|
|
3457
3457
|
trigger_id: e.trigger_id,
|
|
3458
3458
|
url: e.url,
|
|
3459
3459
|
enabled: e.enabled ?? !0,
|
|
@@ -3465,19 +3465,19 @@ function _s(i) {
|
|
|
3465
3465
|
created_at_ts: t,
|
|
3466
3466
|
updated_at_ts: t
|
|
3467
3467
|
};
|
|
3468
|
-
return await
|
|
3468
|
+
return await n.insert(Z).values(o), st({ ...o, tenant_id: i });
|
|
3469
3469
|
},
|
|
3470
|
-
async get(
|
|
3471
|
-
const t = await
|
|
3470
|
+
async get(i, e) {
|
|
3471
|
+
const t = await n.select().from(Z).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).get();
|
|
3472
3472
|
return t ? st(t) : null;
|
|
3473
3473
|
},
|
|
3474
|
-
async update(
|
|
3474
|
+
async update(i, e, t) {
|
|
3475
3475
|
const r = {
|
|
3476
3476
|
updated_at_ts: Date.now()
|
|
3477
3477
|
};
|
|
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
|
|
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 n.update(Z).set(r).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).returning()).length > 0;
|
|
3479
3479
|
},
|
|
3480
|
-
async list(
|
|
3480
|
+
async list(i, e) {
|
|
3481
3481
|
const {
|
|
3482
3482
|
page: t = 0,
|
|
3483
3483
|
per_page: r = 50,
|
|
@@ -3489,8 +3489,8 @@ function _s(i) {
|
|
|
3489
3489
|
"form_id",
|
|
3490
3490
|
"template_id",
|
|
3491
3491
|
"code_id"
|
|
3492
|
-
]) : void 0, c = d ? g(a(Z.tenant_id,
|
|
3493
|
-
let u =
|
|
3492
|
+
]) : void 0, c = d ? g(a(Z.tenant_id, i), d) : a(Z.tenant_id, i);
|
|
3493
|
+
let u = n.select().from(Z).where(c).$dynamic();
|
|
3494
3494
|
if (l != null && l.sort_by) {
|
|
3495
3495
|
const w = Z[l.sort_by];
|
|
3496
3496
|
w && (u = u.orderBy(
|
|
@@ -3500,7 +3500,7 @@ function _s(i) {
|
|
|
3500
3500
|
const f = (await u.offset(t * r).limit(r)).map(st);
|
|
3501
3501
|
if (!o)
|
|
3502
3502
|
return { hooks: f };
|
|
3503
|
-
const [y] = await
|
|
3503
|
+
const [y] = await n.select({ count: V() }).from(Z).where(c);
|
|
3504
3504
|
return {
|
|
3505
3505
|
hooks: f,
|
|
3506
3506
|
start: t * r,
|
|
@@ -3508,14 +3508,14 @@ function _s(i) {
|
|
|
3508
3508
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
3509
3509
|
};
|
|
3510
3510
|
},
|
|
3511
|
-
async remove(
|
|
3512
|
-
return (await
|
|
3511
|
+
async remove(i, e) {
|
|
3512
|
+
return (await n.delete(Z).where(g(a(Z.tenant_id, i), a(Z.hook_id, e))).returning()).length > 0;
|
|
3513
3513
|
}
|
|
3514
3514
|
};
|
|
3515
3515
|
}
|
|
3516
3516
|
function us() {
|
|
3517
|
-
const { customAlphabet:
|
|
3518
|
-
return `inv_${
|
|
3517
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3518
|
+
return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3519
3519
|
}
|
|
3520
3520
|
const Nt = [
|
|
3521
3521
|
"inviter",
|
|
@@ -3524,19 +3524,19 @@ const Nt = [
|
|
|
3524
3524
|
"user_metadata",
|
|
3525
3525
|
"roles"
|
|
3526
3526
|
];
|
|
3527
|
-
function ot(
|
|
3528
|
-
const { tenant_id:
|
|
3527
|
+
function ot(n) {
|
|
3528
|
+
const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
|
|
3529
3529
|
for (const o of Nt)
|
|
3530
3530
|
r[o] = b(t[o], o === "roles" ? [] : {});
|
|
3531
3531
|
return r.send_invitation_email = !!e, z(r);
|
|
3532
3532
|
}
|
|
3533
|
-
function ds(
|
|
3533
|
+
function ds(n) {
|
|
3534
3534
|
return {
|
|
3535
|
-
async create(
|
|
3535
|
+
async create(i, e) {
|
|
3536
3536
|
var d, c;
|
|
3537
3537
|
const t = e.id || us(), r = e.ttl_sec || 604800, o = /* @__PURE__ */ new Date(), l = new Date(o.getTime() + r * 1e3).toISOString(), _ = {
|
|
3538
3538
|
id: t,
|
|
3539
|
-
tenant_id:
|
|
3539
|
+
tenant_id: i,
|
|
3540
3540
|
organization_id: e.organization_id,
|
|
3541
3541
|
client_id: e.client_id,
|
|
3542
3542
|
connection_id: e.connection_id,
|
|
@@ -3550,32 +3550,32 @@ function ds(i) {
|
|
|
3550
3550
|
for (const u of Nt)
|
|
3551
3551
|
e[u] !== void 0 && (_[u] = JSON.stringify(e[u]));
|
|
3552
3552
|
try {
|
|
3553
|
-
await
|
|
3553
|
+
await n.insert(te).values(_);
|
|
3554
3554
|
} catch (u) {
|
|
3555
3555
|
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
3556
|
}
|
|
3557
|
-
return ot({ ..._, tenant_id:
|
|
3557
|
+
return ot({ ..._, tenant_id: i });
|
|
3558
3558
|
},
|
|
3559
|
-
async get(
|
|
3560
|
-
const t = await
|
|
3559
|
+
async get(i, e) {
|
|
3560
|
+
const t = await n.select().from(te).where(g(a(te.tenant_id, i), a(te.id, e))).get();
|
|
3561
3561
|
return t ? ot(t) : null;
|
|
3562
3562
|
},
|
|
3563
|
-
async update(
|
|
3563
|
+
async update(i, e, t) {
|
|
3564
3564
|
const r = {};
|
|
3565
3565
|
for (const l of Nt)
|
|
3566
3566
|
t[l] !== void 0 && (r[l] = JSON.stringify(t[l]));
|
|
3567
3567
|
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
3568
|
Date.now() + t.ttl_sec * 1e3
|
|
3569
|
-
).toISOString()), (await
|
|
3569
|
+
).toISOString()), (await n.update(te).set(r).where(g(a(te.tenant_id, i), a(te.id, e))).returning()).length > 0;
|
|
3570
3570
|
},
|
|
3571
|
-
async list(
|
|
3571
|
+
async list(i, e) {
|
|
3572
3572
|
const {
|
|
3573
3573
|
page: t = 0,
|
|
3574
3574
|
per_page: r = 50,
|
|
3575
3575
|
include_totals: o = !1,
|
|
3576
3576
|
sort: l
|
|
3577
3577
|
} = e || {};
|
|
3578
|
-
let _ =
|
|
3578
|
+
let _ = n.select().from(te).where(a(te.tenant_id, i)).$dynamic();
|
|
3579
3579
|
if (l != null && l.sort_by) {
|
|
3580
3580
|
const h = te[l.sort_by];
|
|
3581
3581
|
h && (_ = _.orderBy(
|
|
@@ -3585,7 +3585,7 @@ function ds(i) {
|
|
|
3585
3585
|
const c = (await _.offset(t * r).limit(r)).map(ot);
|
|
3586
3586
|
if (!o)
|
|
3587
3587
|
return { invites: c };
|
|
3588
|
-
const [u] = await
|
|
3588
|
+
const [u] = await n.select({ count: V() }).from(te).where(a(te.tenant_id, i));
|
|
3589
3589
|
return {
|
|
3590
3590
|
invites: c,
|
|
3591
3591
|
start: t * r,
|
|
@@ -3593,27 +3593,27 @@ function ds(i) {
|
|
|
3593
3593
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
3594
3594
|
};
|
|
3595
3595
|
},
|
|
3596
|
-
async remove(
|
|
3597
|
-
return (await
|
|
3596
|
+
async remove(i, e) {
|
|
3597
|
+
return (await n.delete(te).where(g(a(te.tenant_id, i), a(te.id, e))).returning()).length > 0;
|
|
3598
3598
|
}
|
|
3599
3599
|
};
|
|
3600
3600
|
}
|
|
3601
|
-
function cs(
|
|
3601
|
+
function cs(n) {
|
|
3602
3602
|
return {
|
|
3603
|
-
async create(
|
|
3604
|
-
await
|
|
3605
|
-
...
|
|
3603
|
+
async create(i) {
|
|
3604
|
+
await n.insert(he).values({
|
|
3605
|
+
...i,
|
|
3606
3606
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
3607
3607
|
});
|
|
3608
3608
|
},
|
|
3609
|
-
async list(
|
|
3609
|
+
async list(i) {
|
|
3610
3610
|
const {
|
|
3611
3611
|
page: e = 0,
|
|
3612
3612
|
per_page: t = 50,
|
|
3613
3613
|
include_totals: r = !1,
|
|
3614
3614
|
sort: o
|
|
3615
|
-
} =
|
|
3616
|
-
let _ =
|
|
3615
|
+
} = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
3616
|
+
let _ = n.select().from(he).where(de(He(he.revoked_at, l), ye(he.revoked_at))).$dynamic();
|
|
3617
3617
|
if (o != null && o.sort_by) {
|
|
3618
3618
|
const h = he[o.sort_by];
|
|
3619
3619
|
h && (_ = _.orderBy(
|
|
@@ -3626,7 +3626,7 @@ function cs(i) {
|
|
|
3626
3626
|
});
|
|
3627
3627
|
if (!r)
|
|
3628
3628
|
return { signingKeys: c };
|
|
3629
|
-
const [u] = await
|
|
3629
|
+
const [u] = await n.select({ count: V() }).from(he).where(de(He(he.revoked_at, l), ye(he.revoked_at)));
|
|
3630
3630
|
return {
|
|
3631
3631
|
signingKeys: c,
|
|
3632
3632
|
start: e * t,
|
|
@@ -3634,8 +3634,8 @@ function cs(i) {
|
|
|
3634
3634
|
length: Fr((u == null ? void 0 : u.count) ?? 0)
|
|
3635
3635
|
};
|
|
3636
3636
|
},
|
|
3637
|
-
async update(
|
|
3638
|
-
return (await
|
|
3637
|
+
async update(i, e) {
|
|
3638
|
+
return (await n.update(he).set(e).where(a(he.kid, i)).returning()).length > 0;
|
|
3639
3639
|
}
|
|
3640
3640
|
};
|
|
3641
3641
|
}
|
|
@@ -3650,15 +3650,15 @@ function gs() {
|
|
|
3650
3650
|
t += vt.charAt(r[o] % at);
|
|
3651
3651
|
return t;
|
|
3652
3652
|
}
|
|
3653
|
-
function $t(
|
|
3653
|
+
function $t(n) {
|
|
3654
3654
|
const {
|
|
3655
|
-
tenant_id:
|
|
3655
|
+
tenant_id: i,
|
|
3656
3656
|
created_at_ts: e,
|
|
3657
3657
|
updated_at_ts: t,
|
|
3658
3658
|
expires_at_ts: r,
|
|
3659
3659
|
state_data: o,
|
|
3660
3660
|
...l
|
|
3661
|
-
} =
|
|
3661
|
+
} = n, _ = Fe(
|
|
3662
3662
|
{ created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
|
|
3663
3663
|
["created_at_ts", "updated_at_ts", "expires_at_ts"]
|
|
3664
3664
|
), d = gr(l, ["authParams"]);
|
|
@@ -3668,15 +3668,15 @@ function $t(i) {
|
|
|
3668
3668
|
state_data: b(o)
|
|
3669
3669
|
});
|
|
3670
3670
|
}
|
|
3671
|
-
function fs(
|
|
3671
|
+
function fs(n) {
|
|
3672
3672
|
return {
|
|
3673
|
-
async create(
|
|
3673
|
+
async create(i, e) {
|
|
3674
3674
|
const t = Date.now(), r = gs(), o = Pe(
|
|
3675
3675
|
{ authParams: e.authParams || {} },
|
|
3676
3676
|
"authParams"
|
|
3677
3677
|
), l = {
|
|
3678
3678
|
id: r,
|
|
3679
|
-
tenant_id:
|
|
3679
|
+
tenant_id: i,
|
|
3680
3680
|
session_id: e.session_id,
|
|
3681
3681
|
csrf_token: e.csrf_token,
|
|
3682
3682
|
authorization_url: e.authorization_url ? e.authorization_url.substring(0, 1024) : void 0,
|
|
@@ -3694,15 +3694,15 @@ function fs(i) {
|
|
|
3694
3694
|
};
|
|
3695
3695
|
for (const [_, d] of Object.entries(o))
|
|
3696
3696
|
l[_] = d;
|
|
3697
|
-
return await
|
|
3697
|
+
return await n.insert(oe).values(l), $t({ ...l, tenant_id: i });
|
|
3698
3698
|
},
|
|
3699
|
-
async get(
|
|
3700
|
-
const t = await
|
|
3701
|
-
g(a(oe.tenant_id,
|
|
3699
|
+
async get(i, e) {
|
|
3700
|
+
const t = await n.select().from(oe).where(
|
|
3701
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3702
3702
|
).get();
|
|
3703
3703
|
return t ? $t(t) : null;
|
|
3704
3704
|
},
|
|
3705
|
-
async update(
|
|
3705
|
+
async update(i, e, t) {
|
|
3706
3706
|
var o;
|
|
3707
3707
|
const r = {
|
|
3708
3708
|
updated_at_ts: Date.now()
|
|
@@ -3717,20 +3717,20 @@ function fs(i) {
|
|
|
3717
3717
|
);
|
|
3718
3718
|
Object.assign(r, l);
|
|
3719
3719
|
}
|
|
3720
|
-
return await
|
|
3721
|
-
g(a(oe.tenant_id,
|
|
3720
|
+
return await n.update(oe).set(r).where(
|
|
3721
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3722
3722
|
), !0;
|
|
3723
3723
|
},
|
|
3724
|
-
async remove(
|
|
3725
|
-
return (await
|
|
3726
|
-
g(a(oe.tenant_id,
|
|
3724
|
+
async remove(i, e) {
|
|
3725
|
+
return (await n.delete(oe).where(
|
|
3726
|
+
g(a(oe.tenant_id, i), a(oe.id, e))
|
|
3727
3727
|
).returning()).length > 0;
|
|
3728
3728
|
}
|
|
3729
3729
|
};
|
|
3730
3730
|
}
|
|
3731
|
-
function lt(
|
|
3731
|
+
function lt(n) {
|
|
3732
3732
|
const {
|
|
3733
|
-
tenant_id:
|
|
3733
|
+
tenant_id: i,
|
|
3734
3734
|
isMobile: e,
|
|
3735
3735
|
auth0_client: t,
|
|
3736
3736
|
details: r,
|
|
@@ -3742,7 +3742,7 @@ function lt(i) {
|
|
|
3742
3742
|
continent_code: u,
|
|
3743
3743
|
scope: h,
|
|
3744
3744
|
...f
|
|
3745
|
-
} =
|
|
3745
|
+
} = n, y = {
|
|
3746
3746
|
...f,
|
|
3747
3747
|
isMobile: !!e,
|
|
3748
3748
|
auth0_client: b(t),
|
|
@@ -3758,13 +3758,13 @@ function lt(i) {
|
|
|
3758
3758
|
continent_code: u
|
|
3759
3759
|
})), z(y);
|
|
3760
3760
|
}
|
|
3761
|
-
function ms(
|
|
3761
|
+
function ms(n) {
|
|
3762
3762
|
return {
|
|
3763
|
-
async create(
|
|
3763
|
+
async create(i, e) {
|
|
3764
3764
|
var o, l;
|
|
3765
3765
|
const r = {
|
|
3766
3766
|
log_id: e.log_id || ae(),
|
|
3767
|
-
tenant_id:
|
|
3767
|
+
tenant_id: i,
|
|
3768
3768
|
type: e.type,
|
|
3769
3769
|
date: e.date || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3770
3770
|
category: e.category,
|
|
@@ -3785,9 +3785,9 @@ function ms(i) {
|
|
|
3785
3785
|
hostname: e.hostname,
|
|
3786
3786
|
session_connection: e.session_connection
|
|
3787
3787
|
};
|
|
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
|
|
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 n.insert(T).values(r), lt({ ...r, tenant_id: i });
|
|
3789
3789
|
},
|
|
3790
|
-
async list(
|
|
3790
|
+
async list(i, e) {
|
|
3791
3791
|
const {
|
|
3792
3792
|
page: t = 0,
|
|
3793
3793
|
per_page: r = 50,
|
|
@@ -3795,7 +3795,7 @@ function ms(i) {
|
|
|
3795
3795
|
sort: l,
|
|
3796
3796
|
q: _
|
|
3797
3797
|
} = e || {};
|
|
3798
|
-
let d =
|
|
3798
|
+
let d = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
|
|
3799
3799
|
if (_) {
|
|
3800
3800
|
const f = pe(T, _, [
|
|
3801
3801
|
"user_id",
|
|
@@ -3803,7 +3803,7 @@ function ms(i) {
|
|
|
3803
3803
|
"type",
|
|
3804
3804
|
"client_id"
|
|
3805
3805
|
]);
|
|
3806
|
-
f && (d = d.where(g(a(T.tenant_id,
|
|
3806
|
+
f && (d = d.where(g(a(T.tenant_id, i), f)));
|
|
3807
3807
|
}
|
|
3808
3808
|
if (l != null && l.sort_by) {
|
|
3809
3809
|
const f = T[l.sort_by];
|
|
@@ -3815,7 +3815,7 @@ function ms(i) {
|
|
|
3815
3815
|
const u = (await d.offset(t * r).limit(r)).map(lt);
|
|
3816
3816
|
if (!o)
|
|
3817
3817
|
return { logs: u };
|
|
3818
|
-
const [h] = await
|
|
3818
|
+
const [h] = await n.select({ count: V() }).from(T).where(a(T.tenant_id, i));
|
|
3819
3819
|
return {
|
|
3820
3820
|
logs: u,
|
|
3821
3821
|
start: t * r,
|
|
@@ -3823,8 +3823,8 @@ function ms(i) {
|
|
|
3823
3823
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
3824
3824
|
};
|
|
3825
3825
|
},
|
|
3826
|
-
async get(
|
|
3827
|
-
const t = await
|
|
3826
|
+
async get(i, e) {
|
|
3827
|
+
const t = await n.select().from(T).where(g(a(T.tenant_id, i), a(T.log_id, e))).get();
|
|
3828
3828
|
return t ? lt(t) : null;
|
|
3829
3829
|
}
|
|
3830
3830
|
};
|
|
@@ -3840,16 +3840,16 @@ function hs() {
|
|
|
3840
3840
|
t += St.charAt(r[o] % _t);
|
|
3841
3841
|
return t;
|
|
3842
3842
|
}
|
|
3843
|
-
function Me(
|
|
3843
|
+
function Me(n) {
|
|
3844
3844
|
const {
|
|
3845
|
-
tenant_id:
|
|
3845
|
+
tenant_id: i,
|
|
3846
3846
|
created_at_ts: e,
|
|
3847
3847
|
updated_at_ts: t,
|
|
3848
3848
|
credential_backed_up: r,
|
|
3849
3849
|
confirmed: o,
|
|
3850
3850
|
transports: l,
|
|
3851
3851
|
..._
|
|
3852
|
-
} =
|
|
3852
|
+
} = n;
|
|
3853
3853
|
return z({
|
|
3854
3854
|
..._,
|
|
3855
3855
|
confirmed: !!o,
|
|
@@ -3859,12 +3859,12 @@ function Me(i) {
|
|
|
3859
3859
|
updated_at: wt(t)
|
|
3860
3860
|
});
|
|
3861
3861
|
}
|
|
3862
|
-
function ps(
|
|
3862
|
+
function ps(n) {
|
|
3863
3863
|
return {
|
|
3864
|
-
async create(
|
|
3864
|
+
async create(i, e) {
|
|
3865
3865
|
const t = Date.now(), o = {
|
|
3866
3866
|
id: e.id || hs(),
|
|
3867
|
-
tenant_id:
|
|
3867
|
+
tenant_id: i,
|
|
3868
3868
|
user_id: e.user_id,
|
|
3869
3869
|
type: e.type,
|
|
3870
3870
|
phone_number: e.phone_number,
|
|
@@ -3879,55 +3879,55 @@ function ps(i) {
|
|
|
3879
3879
|
created_at_ts: t,
|
|
3880
3880
|
updated_at_ts: t
|
|
3881
3881
|
};
|
|
3882
|
-
return await
|
|
3882
|
+
return await n.insert(F).values(o), Me({ ...o, tenant_id: i });
|
|
3883
3883
|
},
|
|
3884
|
-
async get(
|
|
3885
|
-
const t = await
|
|
3884
|
+
async get(i, e) {
|
|
3885
|
+
const t = await n.select().from(F).where(
|
|
3886
3886
|
g(
|
|
3887
|
-
a(F.tenant_id,
|
|
3887
|
+
a(F.tenant_id, i),
|
|
3888
3888
|
a(F.id, e)
|
|
3889
3889
|
)
|
|
3890
3890
|
).get();
|
|
3891
3891
|
return t ? Me(t) : null;
|
|
3892
3892
|
},
|
|
3893
|
-
async getByCredentialId(
|
|
3894
|
-
const t = await
|
|
3893
|
+
async getByCredentialId(i, e) {
|
|
3894
|
+
const t = await n.select().from(F).where(
|
|
3895
3895
|
g(
|
|
3896
|
-
a(F.tenant_id,
|
|
3896
|
+
a(F.tenant_id, i),
|
|
3897
3897
|
a(F.credential_id, e)
|
|
3898
3898
|
)
|
|
3899
3899
|
).get();
|
|
3900
3900
|
return t ? Me(t) : null;
|
|
3901
3901
|
},
|
|
3902
|
-
async list(
|
|
3903
|
-
return (await
|
|
3902
|
+
async list(i, e) {
|
|
3903
|
+
return (await n.select().from(F).where(
|
|
3904
3904
|
g(
|
|
3905
|
-
a(F.tenant_id,
|
|
3905
|
+
a(F.tenant_id, i),
|
|
3906
3906
|
a(F.user_id, e)
|
|
3907
3907
|
)
|
|
3908
3908
|
).all()).map(Me);
|
|
3909
3909
|
},
|
|
3910
|
-
async update(
|
|
3910
|
+
async update(i, e, t) {
|
|
3911
3911
|
const r = {
|
|
3912
3912
|
updated_at_ts: Date.now()
|
|
3913
3913
|
};
|
|
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
|
|
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 n.update(F).set(r).where(
|
|
3915
3915
|
g(
|
|
3916
|
-
a(F.tenant_id,
|
|
3916
|
+
a(F.tenant_id, i),
|
|
3917
3917
|
a(F.id, e)
|
|
3918
3918
|
)
|
|
3919
3919
|
);
|
|
3920
|
-
const o = await this.get(
|
|
3920
|
+
const o = await this.get(i, e);
|
|
3921
3921
|
if (!o)
|
|
3922
3922
|
throw new Error(
|
|
3923
3923
|
`Authentication method ${e} not found after update`
|
|
3924
3924
|
);
|
|
3925
3925
|
return o;
|
|
3926
3926
|
},
|
|
3927
|
-
async remove(
|
|
3928
|
-
return (await
|
|
3927
|
+
async remove(i, e) {
|
|
3928
|
+
return (await n.delete(F).where(
|
|
3929
3929
|
g(
|
|
3930
|
-
a(F.tenant_id,
|
|
3930
|
+
a(F.tenant_id, i),
|
|
3931
3931
|
a(F.id, e)
|
|
3932
3932
|
)
|
|
3933
3933
|
).returning()).length > 0;
|
|
@@ -3935,18 +3935,18 @@ function ps(i) {
|
|
|
3935
3935
|
};
|
|
3936
3936
|
}
|
|
3937
3937
|
function ys() {
|
|
3938
|
-
const { customAlphabet:
|
|
3939
|
-
return `org_${
|
|
3938
|
+
const { customAlphabet: n } = require("nanoid");
|
|
3939
|
+
return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3940
3940
|
}
|
|
3941
|
-
function ut(
|
|
3941
|
+
function ut(n) {
|
|
3942
3942
|
const {
|
|
3943
|
-
tenant_id:
|
|
3943
|
+
tenant_id: i,
|
|
3944
3944
|
branding: e,
|
|
3945
3945
|
metadata: t,
|
|
3946
3946
|
enabled_connections: r,
|
|
3947
3947
|
token_quota: o,
|
|
3948
3948
|
...l
|
|
3949
|
-
} =
|
|
3949
|
+
} = n;
|
|
3950
3950
|
return z({
|
|
3951
3951
|
...l,
|
|
3952
3952
|
branding: b(e, {}),
|
|
@@ -3955,13 +3955,13 @@ function ut(i) {
|
|
|
3955
3955
|
token_quota: b(o, {})
|
|
3956
3956
|
});
|
|
3957
3957
|
}
|
|
3958
|
-
function ws(
|
|
3958
|
+
function ws(n) {
|
|
3959
3959
|
return {
|
|
3960
|
-
async create(
|
|
3960
|
+
async create(i, e) {
|
|
3961
3961
|
var l, _;
|
|
3962
3962
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3963
3963
|
id: e.id || ys(),
|
|
3964
|
-
tenant_id:
|
|
3964
|
+
tenant_id: i,
|
|
3965
3965
|
name: e.name,
|
|
3966
3966
|
display_name: e.display_name,
|
|
3967
3967
|
branding: JSON.stringify(e.branding || {}),
|
|
@@ -3972,36 +3972,36 @@ function ws(i) {
|
|
|
3972
3972
|
updated_at: t
|
|
3973
3973
|
};
|
|
3974
3974
|
try {
|
|
3975
|
-
await
|
|
3975
|
+
await n.insert(q).values(o);
|
|
3976
3976
|
} catch (d) {
|
|
3977
3977
|
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
3978
|
message: "Organization already exists"
|
|
3979
3979
|
}) : d;
|
|
3980
3980
|
}
|
|
3981
|
-
return ut({ ...o, tenant_id:
|
|
3981
|
+
return ut({ ...o, tenant_id: i });
|
|
3982
3982
|
},
|
|
3983
|
-
async get(
|
|
3984
|
-
let t = await
|
|
3985
|
-
g(a(q.tenant_id,
|
|
3983
|
+
async get(i, e) {
|
|
3984
|
+
let t = await n.select().from(q).where(
|
|
3985
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
3986
3986
|
).get();
|
|
3987
|
-
return t || (t = await
|
|
3987
|
+
return t || (t = await n.select().from(q).where(
|
|
3988
3988
|
g(
|
|
3989
|
-
a(q.tenant_id,
|
|
3989
|
+
a(q.tenant_id, i),
|
|
3990
3990
|
a(q.name, e)
|
|
3991
3991
|
)
|
|
3992
3992
|
).get()), t ? ut(t) : null;
|
|
3993
3993
|
},
|
|
3994
|
-
async update(
|
|
3994
|
+
async update(i, e, t) {
|
|
3995
3995
|
const r = {
|
|
3996
3996
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3997
3997
|
};
|
|
3998
3998
|
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
3999
|
t.enabled_connections
|
|
4000
|
-
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await
|
|
4001
|
-
g(a(q.tenant_id,
|
|
4000
|
+
)), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(q).set(r).where(
|
|
4001
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
4002
4002
|
).returning()).length > 0;
|
|
4003
4003
|
},
|
|
4004
|
-
async list(
|
|
4004
|
+
async list(i, e) {
|
|
4005
4005
|
const {
|
|
4006
4006
|
page: t = 0,
|
|
4007
4007
|
per_page: r = 50,
|
|
@@ -4009,7 +4009,7 @@ function ws(i) {
|
|
|
4009
4009
|
sort: l,
|
|
4010
4010
|
q: _
|
|
4011
4011
|
} = e || {};
|
|
4012
|
-
let d =
|
|
4012
|
+
let d = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
|
|
4013
4013
|
if (_ && (d = d.where(
|
|
4014
4014
|
de(
|
|
4015
4015
|
Ie(q.name, `%${_}%`),
|
|
@@ -4024,14 +4024,14 @@ function ws(i) {
|
|
|
4024
4024
|
const u = (await d.offset(t * r).limit(r)).map(ut);
|
|
4025
4025
|
if (!o)
|
|
4026
4026
|
return { organizations: u };
|
|
4027
|
-
const h = [a(q.tenant_id,
|
|
4027
|
+
const h = [a(q.tenant_id, i)];
|
|
4028
4028
|
_ && h.push(
|
|
4029
4029
|
de(
|
|
4030
4030
|
Ie(q.name, `%${_}%`),
|
|
4031
4031
|
Ie(q.display_name, `%${_}%`)
|
|
4032
4032
|
)
|
|
4033
4033
|
);
|
|
4034
|
-
const [f] = await
|
|
4034
|
+
const [f] = await n.select({ count: V() }).from(q).where(g(...h));
|
|
4035
4035
|
return {
|
|
4036
4036
|
organizations: u,
|
|
4037
4037
|
start: t * r,
|
|
@@ -4039,33 +4039,33 @@ function ws(i) {
|
|
|
4039
4039
|
length: Number((f == null ? void 0 : f.count) ?? 0)
|
|
4040
4040
|
};
|
|
4041
4041
|
},
|
|
4042
|
-
async remove(
|
|
4043
|
-
return (await
|
|
4044
|
-
g(a(q.tenant_id,
|
|
4042
|
+
async remove(i, e) {
|
|
4043
|
+
return (await n.delete(q).where(
|
|
4044
|
+
g(a(q.tenant_id, i), a(q.id, e))
|
|
4045
4045
|
).returning()).length > 0;
|
|
4046
4046
|
}
|
|
4047
4047
|
};
|
|
4048
4048
|
}
|
|
4049
|
-
function dt(
|
|
4050
|
-
const { tenant_id:
|
|
4049
|
+
function dt(n) {
|
|
4050
|
+
const { tenant_id: i, is_current: e, ...t } = n;
|
|
4051
4051
|
return {
|
|
4052
4052
|
...t,
|
|
4053
4053
|
is_current: !!e
|
|
4054
4054
|
};
|
|
4055
4055
|
}
|
|
4056
|
-
function Ns(
|
|
4056
|
+
function Ns(n) {
|
|
4057
4057
|
return {
|
|
4058
|
-
async create(
|
|
4058
|
+
async create(i, e) {
|
|
4059
4059
|
const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
|
|
4060
|
-
e.is_current !== !1 && await
|
|
4060
|
+
e.is_current !== !1 && await n.update(E).set({ is_current: 0 }).where(
|
|
4061
4061
|
g(
|
|
4062
|
-
a(E.tenant_id,
|
|
4062
|
+
a(E.tenant_id, i),
|
|
4063
4063
|
a(E.user_id, e.user_id)
|
|
4064
4064
|
)
|
|
4065
4065
|
);
|
|
4066
4066
|
const o = {
|
|
4067
4067
|
id: r,
|
|
4068
|
-
tenant_id:
|
|
4068
|
+
tenant_id: i,
|
|
4069
4069
|
user_id: e.user_id,
|
|
4070
4070
|
password: e.password,
|
|
4071
4071
|
algorithm: e.algorithm || "bcrypt",
|
|
@@ -4073,39 +4073,39 @@ function Ns(i) {
|
|
|
4073
4073
|
created_at: t,
|
|
4074
4074
|
updated_at: t
|
|
4075
4075
|
};
|
|
4076
|
-
return await
|
|
4076
|
+
return await n.insert(E).values(o), dt({ ...o, tenant_id: i });
|
|
4077
4077
|
},
|
|
4078
|
-
async get(
|
|
4079
|
-
const t = await
|
|
4078
|
+
async get(i, e) {
|
|
4079
|
+
const t = await n.select().from(E).where(
|
|
4080
4080
|
g(
|
|
4081
|
-
a(E.tenant_id,
|
|
4081
|
+
a(E.tenant_id, i),
|
|
4082
4082
|
a(E.user_id, e),
|
|
4083
4083
|
a(E.is_current, 1)
|
|
4084
4084
|
)
|
|
4085
4085
|
).get();
|
|
4086
4086
|
return t ? dt(t) : null;
|
|
4087
4087
|
},
|
|
4088
|
-
async list(
|
|
4089
|
-
let r =
|
|
4088
|
+
async list(i, e, t) {
|
|
4089
|
+
let r = n.select().from(E).where(
|
|
4090
4090
|
g(
|
|
4091
|
-
a(E.tenant_id,
|
|
4091
|
+
a(E.tenant_id, i),
|
|
4092
4092
|
a(E.user_id, e)
|
|
4093
4093
|
)
|
|
4094
4094
|
).orderBy(M(E.created_at)).$dynamic();
|
|
4095
4095
|
return t && (r = r.limit(t)), (await r).map(dt);
|
|
4096
4096
|
},
|
|
4097
|
-
async update(
|
|
4097
|
+
async update(i, e) {
|
|
4098
4098
|
const t = {
|
|
4099
4099
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4100
4100
|
};
|
|
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
|
|
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 n.update(E).set(t).where(
|
|
4102
4102
|
g(
|
|
4103
|
-
a(E.tenant_id,
|
|
4103
|
+
a(E.tenant_id, i),
|
|
4104
4104
|
a(E.id, e.id)
|
|
4105
4105
|
)
|
|
4106
|
-
) : await
|
|
4106
|
+
) : await n.update(E).set(t).where(
|
|
4107
4107
|
g(
|
|
4108
|
-
a(E.tenant_id,
|
|
4108
|
+
a(E.tenant_id, i),
|
|
4109
4109
|
a(E.user_id, e.user_id),
|
|
4110
4110
|
a(E.is_current, 1)
|
|
4111
4111
|
)
|
|
@@ -4113,10 +4113,10 @@ function Ns(i) {
|
|
|
4113
4113
|
}
|
|
4114
4114
|
};
|
|
4115
4115
|
}
|
|
4116
|
-
function vs(
|
|
4116
|
+
function vs(n) {
|
|
4117
4117
|
return {
|
|
4118
|
-
async get(
|
|
4119
|
-
const e = await
|
|
4118
|
+
async get(i) {
|
|
4119
|
+
const e = await n.select().from(Ee).where(a(Ee.tenant_id, i)).get();
|
|
4120
4120
|
return e ? {
|
|
4121
4121
|
universal_login_experience: e.universal_login_experience,
|
|
4122
4122
|
identifier_first: !!e.identifier_first,
|
|
@@ -4129,9 +4129,9 @@ function vs(i) {
|
|
|
4129
4129
|
webauthn_platform_first_factor: !1
|
|
4130
4130
|
};
|
|
4131
4131
|
},
|
|
4132
|
-
async set(
|
|
4133
|
-
await
|
|
4134
|
-
tenant_id:
|
|
4132
|
+
async set(i, e) {
|
|
4133
|
+
await n.insert(Ee).values({
|
|
4134
|
+
tenant_id: i,
|
|
4135
4135
|
universal_login_experience: e.universal_login_experience,
|
|
4136
4136
|
identifier_first: e.identifier_first,
|
|
4137
4137
|
password_first: e.password_first,
|
|
@@ -4148,9 +4148,9 @@ function vs(i) {
|
|
|
4148
4148
|
}
|
|
4149
4149
|
};
|
|
4150
4150
|
}
|
|
4151
|
-
function ct(
|
|
4151
|
+
function ct(n) {
|
|
4152
4152
|
const {
|
|
4153
|
-
tenant_id:
|
|
4153
|
+
tenant_id: i,
|
|
4154
4154
|
created_at_ts: e,
|
|
4155
4155
|
expires_at_ts: t,
|
|
4156
4156
|
idle_expires_at_ts: r,
|
|
@@ -4159,7 +4159,7 @@ function ct(i) {
|
|
|
4159
4159
|
resource_servers: _,
|
|
4160
4160
|
rotating: d,
|
|
4161
4161
|
...c
|
|
4162
|
-
} =
|
|
4162
|
+
} = n, u = Fe(
|
|
4163
4163
|
{ created_at_ts: e, expires_at_ts: t, idle_expires_at_ts: r, last_exchanged_at_ts: o },
|
|
4164
4164
|
["created_at_ts"],
|
|
4165
4165
|
["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
|
|
@@ -4172,12 +4172,12 @@ function ct(i) {
|
|
|
4172
4172
|
resource_servers: b(_, [])
|
|
4173
4173
|
});
|
|
4174
4174
|
}
|
|
4175
|
-
function Ss(
|
|
4175
|
+
function Ss(n) {
|
|
4176
4176
|
return {
|
|
4177
|
-
async create(
|
|
4177
|
+
async create(i, e) {
|
|
4178
4178
|
const t = Date.now(), r = {
|
|
4179
4179
|
id: e.id || ae(),
|
|
4180
|
-
tenant_id:
|
|
4180
|
+
tenant_id: i,
|
|
4181
4181
|
client_id: e.client_id,
|
|
4182
4182
|
login_id: e.login_id,
|
|
4183
4183
|
user_id: e.user_id,
|
|
@@ -4189,21 +4189,21 @@ function Ss(i) {
|
|
|
4189
4189
|
idle_expires_at_ts: K(e.idle_expires_at),
|
|
4190
4190
|
last_exchanged_at_ts: K(e.last_exchanged_at)
|
|
4191
4191
|
};
|
|
4192
|
-
return await
|
|
4192
|
+
return await n.insert(C).values(r), ct({ ...r, tenant_id: i });
|
|
4193
4193
|
},
|
|
4194
|
-
async get(
|
|
4195
|
-
const t = await
|
|
4196
|
-
g(a(C.tenant_id,
|
|
4194
|
+
async get(i, e) {
|
|
4195
|
+
const t = await n.select().from(C).where(
|
|
4196
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4197
4197
|
).get();
|
|
4198
4198
|
return t ? ct(t) : null;
|
|
4199
4199
|
},
|
|
4200
|
-
async update(
|
|
4200
|
+
async update(i, e, t) {
|
|
4201
4201
|
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,
|
|
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 n.update(C).set(r).where(
|
|
4203
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4204
4204
|
).returning()).length > 0;
|
|
4205
4205
|
},
|
|
4206
|
-
async list(
|
|
4206
|
+
async list(i, e) {
|
|
4207
4207
|
const {
|
|
4208
4208
|
page: t = 0,
|
|
4209
4209
|
per_page: r = 50,
|
|
@@ -4211,11 +4211,11 @@ function Ss(i) {
|
|
|
4211
4211
|
sort: l,
|
|
4212
4212
|
q: _
|
|
4213
4213
|
} = e || {};
|
|
4214
|
-
let d =
|
|
4214
|
+
let d = n.select().from(C).where(a(C.tenant_id, i)).$dynamic();
|
|
4215
4215
|
if (_) {
|
|
4216
4216
|
const f = pe(C, _, ["user_id"]);
|
|
4217
4217
|
f && (d = d.where(
|
|
4218
|
-
g(a(C.tenant_id,
|
|
4218
|
+
g(a(C.tenant_id, i), f)
|
|
4219
4219
|
));
|
|
4220
4220
|
}
|
|
4221
4221
|
if (l != null && l.sort_by) {
|
|
@@ -4227,7 +4227,7 @@ function Ss(i) {
|
|
|
4227
4227
|
const u = (await d.offset(t * r).limit(r)).map(ct);
|
|
4228
4228
|
if (!o)
|
|
4229
4229
|
return { refresh_tokens: u };
|
|
4230
|
-
const [h] = await
|
|
4230
|
+
const [h] = await n.select({ count: V() }).from(C).where(a(C.tenant_id, i));
|
|
4231
4231
|
return {
|
|
4232
4232
|
refresh_tokens: u,
|
|
4233
4233
|
start: t * r,
|
|
@@ -4235,16 +4235,16 @@ function Ss(i) {
|
|
|
4235
4235
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
4236
4236
|
};
|
|
4237
4237
|
},
|
|
4238
|
-
async remove(
|
|
4239
|
-
return (await
|
|
4240
|
-
g(a(C.tenant_id,
|
|
4238
|
+
async remove(i, e) {
|
|
4239
|
+
return (await n.delete(C).where(
|
|
4240
|
+
g(a(C.tenant_id, i), a(C.id, e))
|
|
4241
4241
|
).returning()).length > 0;
|
|
4242
4242
|
}
|
|
4243
4243
|
};
|
|
4244
4244
|
}
|
|
4245
4245
|
function bs() {
|
|
4246
|
-
const { customAlphabet:
|
|
4247
|
-
return `api_${
|
|
4246
|
+
const { customAlphabet: n } = require("nanoid");
|
|
4247
|
+
return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
4248
4248
|
}
|
|
4249
4249
|
const bt = [
|
|
4250
4250
|
"skip_consent_for_verifiable_first_party_clients",
|
|
@@ -4269,26 +4269,26 @@ const bt = [
|
|
|
4269
4269
|
"created_at",
|
|
4270
4270
|
"updated_at"
|
|
4271
4271
|
]);
|
|
4272
|
-
function gt(
|
|
4272
|
+
function gt(n) {
|
|
4273
4273
|
const {
|
|
4274
|
-
tenant_id:
|
|
4274
|
+
tenant_id: i,
|
|
4275
4275
|
verification_key: e,
|
|
4276
4276
|
scopes: t,
|
|
4277
4277
|
options: r,
|
|
4278
4278
|
metadata: o,
|
|
4279
4279
|
...l
|
|
4280
|
-
} =
|
|
4280
|
+
} = n, _ = { ...l };
|
|
4281
4281
|
_.scopes = b(t, []), _.options = b(r, {}), _.metadata = b(o), e !== void 0 && (_.verificationKey = e);
|
|
4282
4282
|
for (const d of bt)
|
|
4283
4283
|
l[d] !== void 0 && l[d] !== null && (_[d] = !!l[d]);
|
|
4284
4284
|
return z(_);
|
|
4285
4285
|
}
|
|
4286
|
-
function xs(
|
|
4286
|
+
function xs(n) {
|
|
4287
4287
|
return {
|
|
4288
|
-
async create(
|
|
4288
|
+
async create(i, e) {
|
|
4289
4289
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4290
4290
|
id: e.id || bs(),
|
|
4291
|
-
tenant_id:
|
|
4291
|
+
tenant_id: i,
|
|
4292
4292
|
identifier: e.identifier,
|
|
4293
4293
|
name: e.name,
|
|
4294
4294
|
signing_alg: e.signing_alg,
|
|
@@ -4304,32 +4304,32 @@ function xs(i) {
|
|
|
4304
4304
|
};
|
|
4305
4305
|
for (const l of bt)
|
|
4306
4306
|
e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
|
|
4307
|
-
return o.is_system === void 0 && (o.is_system = 0), await
|
|
4307
|
+
return o.is_system === void 0 && (o.is_system = 0), await n.insert(L).values(o), gt({ ...o, tenant_id: i });
|
|
4308
4308
|
},
|
|
4309
|
-
async get(
|
|
4310
|
-
const t = await
|
|
4309
|
+
async get(i, e) {
|
|
4310
|
+
const t = await n.select().from(L).where(
|
|
4311
4311
|
g(
|
|
4312
|
-
a(L.tenant_id,
|
|
4312
|
+
a(L.tenant_id, i),
|
|
4313
4313
|
a(L.id, e)
|
|
4314
4314
|
)
|
|
4315
4315
|
).get();
|
|
4316
4316
|
return t ? gt(t) : null;
|
|
4317
4317
|
},
|
|
4318
|
-
async update(
|
|
4318
|
+
async update(i, e, t) {
|
|
4319
4319
|
const r = {
|
|
4320
4320
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4321
4321
|
};
|
|
4322
4322
|
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
4323
|
for (const l of bt)
|
|
4324
4324
|
t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
|
|
4325
|
-
return (await
|
|
4325
|
+
return (await n.update(L).set(r).where(
|
|
4326
4326
|
g(
|
|
4327
|
-
a(L.tenant_id,
|
|
4327
|
+
a(L.tenant_id, i),
|
|
4328
4328
|
a(L.id, e)
|
|
4329
4329
|
)
|
|
4330
4330
|
).returning()).length > 0;
|
|
4331
4331
|
},
|
|
4332
|
-
async list(
|
|
4332
|
+
async list(i, e) {
|
|
4333
4333
|
const {
|
|
4334
4334
|
page: t = 0,
|
|
4335
4335
|
per_page: r = 50,
|
|
@@ -4339,7 +4339,7 @@ function xs(i) {
|
|
|
4339
4339
|
} = e || {}, d = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
|
|
4340
4340
|
Math.max(1, Math.floor(Number(r) || 50)),
|
|
4341
4341
|
500
|
|
4342
|
-
), u = [a(L.tenant_id,
|
|
4342
|
+
), u = [a(L.tenant_id, i)];
|
|
4343
4343
|
if (_) {
|
|
4344
4344
|
const A = _.match(/^([^:]+):(.+)$/);
|
|
4345
4345
|
if (A) {
|
|
@@ -4350,7 +4350,7 @@ function xs(i) {
|
|
|
4350
4350
|
}
|
|
4351
4351
|
}
|
|
4352
4352
|
}
|
|
4353
|
-
let h =
|
|
4353
|
+
let h = n.select().from(L).where(g(...u)).$dynamic();
|
|
4354
4354
|
if (l != null && l.sort_by && Bt.has(l.sort_by)) {
|
|
4355
4355
|
const A = L[l.sort_by];
|
|
4356
4356
|
h = h.orderBy(
|
|
@@ -4360,7 +4360,7 @@ function xs(i) {
|
|
|
4360
4360
|
const y = (await h.offset(d * c).limit(c)).map(gt);
|
|
4361
4361
|
if (!o)
|
|
4362
4362
|
return { resource_servers: y };
|
|
4363
|
-
const [w] = await
|
|
4363
|
+
const [w] = await n.select({ count: V() }).from(L).where(g(...u));
|
|
4364
4364
|
return {
|
|
4365
4365
|
resource_servers: y,
|
|
4366
4366
|
start: d * c,
|
|
@@ -4368,23 +4368,23 @@ function xs(i) {
|
|
|
4368
4368
|
length: Number((w == null ? void 0 : w.count) ?? 0)
|
|
4369
4369
|
};
|
|
4370
4370
|
},
|
|
4371
|
-
async remove(
|
|
4372
|
-
return (await
|
|
4371
|
+
async remove(i, e) {
|
|
4372
|
+
return (await n.delete(L).where(
|
|
4373
4373
|
g(
|
|
4374
|
-
a(L.tenant_id,
|
|
4374
|
+
a(L.tenant_id, i),
|
|
4375
4375
|
a(L.id, e)
|
|
4376
4376
|
)
|
|
4377
4377
|
).returning()).length > 0;
|
|
4378
4378
|
}
|
|
4379
4379
|
};
|
|
4380
4380
|
}
|
|
4381
|
-
function Ds(
|
|
4381
|
+
function Ds(n) {
|
|
4382
4382
|
return {
|
|
4383
|
-
async assign(
|
|
4383
|
+
async assign(i, e, t) {
|
|
4384
4384
|
const r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4385
|
-
return await
|
|
4385
|
+
return await n.insert(le).values(
|
|
4386
4386
|
t.map((o) => ({
|
|
4387
|
-
tenant_id:
|
|
4387
|
+
tenant_id: i,
|
|
4388
4388
|
role_id: e,
|
|
4389
4389
|
resource_server_identifier: o.resource_server_identifier,
|
|
4390
4390
|
permission_name: o.permission_name,
|
|
@@ -4392,26 +4392,26 @@ function Ds(i) {
|
|
|
4392
4392
|
}))
|
|
4393
4393
|
).onConflictDoNothing(), !0;
|
|
4394
4394
|
},
|
|
4395
|
-
async list(
|
|
4396
|
-
const r = await
|
|
4395
|
+
async list(i, e, t) {
|
|
4396
|
+
const r = await n.select({
|
|
4397
4397
|
resource_server_identifier: le.resource_server_identifier,
|
|
4398
4398
|
permission_name: le.permission_name,
|
|
4399
4399
|
created_at: le.created_at
|
|
4400
4400
|
}).from(le).where(
|
|
4401
4401
|
g(
|
|
4402
|
-
a(le.tenant_id,
|
|
4402
|
+
a(le.tenant_id, i),
|
|
4403
4403
|
a(le.role_id, e)
|
|
4404
4404
|
)
|
|
4405
4405
|
).all(), o = [
|
|
4406
4406
|
...new Set(r.map((_) => _.resource_server_identifier))
|
|
4407
4407
|
], l = /* @__PURE__ */ new Map();
|
|
4408
4408
|
if (o.length > 0) {
|
|
4409
|
-
const _ = await
|
|
4409
|
+
const _ = await n.select({
|
|
4410
4410
|
identifier: L.identifier,
|
|
4411
4411
|
name: L.name
|
|
4412
4412
|
}).from(L).where(
|
|
4413
4413
|
g(
|
|
4414
|
-
a(L.tenant_id,
|
|
4414
|
+
a(L.tenant_id, i),
|
|
4415
4415
|
we(L.identifier, o)
|
|
4416
4416
|
)
|
|
4417
4417
|
).all();
|
|
@@ -4423,7 +4423,7 @@ function Ds(i) {
|
|
|
4423
4423
|
resource_server_name: l.get(_.resource_server_identifier) || _.resource_server_identifier
|
|
4424
4424
|
}));
|
|
4425
4425
|
},
|
|
4426
|
-
async remove(
|
|
4426
|
+
async remove(i, e, t) {
|
|
4427
4427
|
const r = t.map(
|
|
4428
4428
|
(l) => g(
|
|
4429
4429
|
a(
|
|
@@ -4433,9 +4433,9 @@ function Ds(i) {
|
|
|
4433
4433
|
a(le.permission_name, l.permission_name)
|
|
4434
4434
|
)
|
|
4435
4435
|
);
|
|
4436
|
-
return (await
|
|
4436
|
+
return (await n.delete(le).where(
|
|
4437
4437
|
g(
|
|
4438
|
-
a(le.tenant_id,
|
|
4438
|
+
a(le.tenant_id, i),
|
|
4439
4439
|
a(le.role_id, e),
|
|
4440
4440
|
de(...r)
|
|
4441
4441
|
)
|
|
@@ -4443,13 +4443,13 @@ function Ds(i) {
|
|
|
4443
4443
|
}
|
|
4444
4444
|
};
|
|
4445
4445
|
}
|
|
4446
|
-
function Os(
|
|
4446
|
+
function Os(n) {
|
|
4447
4447
|
return {
|
|
4448
|
-
async create(
|
|
4448
|
+
async create(i, e, t, r) {
|
|
4449
4449
|
var o, l;
|
|
4450
4450
|
try {
|
|
4451
|
-
await
|
|
4452
|
-
tenant_id:
|
|
4451
|
+
await n.insert(_e).values({
|
|
4452
|
+
tenant_id: i,
|
|
4453
4453
|
user_id: e,
|
|
4454
4454
|
resource_server_identifier: t.resource_server_identifier,
|
|
4455
4455
|
permission_name: t.permission_name,
|
|
@@ -4463,18 +4463,18 @@ function Os(i) {
|
|
|
4463
4463
|
}
|
|
4464
4464
|
return !0;
|
|
4465
4465
|
},
|
|
4466
|
-
async list(
|
|
4466
|
+
async list(i, e, t, r) {
|
|
4467
4467
|
let o = [
|
|
4468
|
-
a(_e.tenant_id,
|
|
4468
|
+
a(_e.tenant_id, i),
|
|
4469
4469
|
a(_e.user_id, e)
|
|
4470
4470
|
];
|
|
4471
4471
|
r && o.push(a(_e.organization_id, r));
|
|
4472
|
-
const l = await
|
|
4472
|
+
const l = await n.select().from(_e).where(g(...o)).all();
|
|
4473
4473
|
return await Promise.all(
|
|
4474
4474
|
l.map(async (d) => {
|
|
4475
|
-
const c = await
|
|
4475
|
+
const c = await n.select({ name: L.name }).from(L).where(
|
|
4476
4476
|
g(
|
|
4477
|
-
a(L.tenant_id,
|
|
4477
|
+
a(L.tenant_id, i),
|
|
4478
4478
|
a(L.identifier, d.resource_server_identifier)
|
|
4479
4479
|
)
|
|
4480
4480
|
).get();
|
|
@@ -4487,10 +4487,10 @@ function Os(i) {
|
|
|
4487
4487
|
})
|
|
4488
4488
|
);
|
|
4489
4489
|
},
|
|
4490
|
-
async remove(
|
|
4491
|
-
return (await
|
|
4490
|
+
async remove(i, e, t, r) {
|
|
4491
|
+
return (await n.delete(_e).where(
|
|
4492
4492
|
g(
|
|
4493
|
-
a(_e.tenant_id,
|
|
4493
|
+
a(_e.tenant_id, i),
|
|
4494
4494
|
a(_e.user_id, e),
|
|
4495
4495
|
a(
|
|
4496
4496
|
_e.resource_server_identifier,
|
|
@@ -4503,20 +4503,20 @@ function Os(i) {
|
|
|
4503
4503
|
}
|
|
4504
4504
|
};
|
|
4505
4505
|
}
|
|
4506
|
-
function ft(
|
|
4507
|
-
const { tenant_id:
|
|
4506
|
+
function ft(n) {
|
|
4507
|
+
const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
|
|
4508
4508
|
return z({
|
|
4509
4509
|
...r,
|
|
4510
4510
|
is_system: e ? !0 : void 0,
|
|
4511
4511
|
metadata: b(t)
|
|
4512
4512
|
});
|
|
4513
4513
|
}
|
|
4514
|
-
function ks(
|
|
4514
|
+
function ks(n) {
|
|
4515
4515
|
return {
|
|
4516
|
-
async create(
|
|
4516
|
+
async create(i, e) {
|
|
4517
4517
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4518
4518
|
id: e.id || ae(),
|
|
4519
|
-
tenant_id:
|
|
4519
|
+
tenant_id: i,
|
|
4520
4520
|
name: e.name,
|
|
4521
4521
|
description: e.description,
|
|
4522
4522
|
is_system: e.is_system ? 1 : 0,
|
|
@@ -4524,27 +4524,27 @@ function ks(i) {
|
|
|
4524
4524
|
created_at: t,
|
|
4525
4525
|
updated_at: t
|
|
4526
4526
|
};
|
|
4527
|
-
return await
|
|
4527
|
+
return await n.insert(J).values(o), ft({ ...o, tenant_id: i });
|
|
4528
4528
|
},
|
|
4529
|
-
async get(
|
|
4530
|
-
const t = await
|
|
4529
|
+
async get(i, e) {
|
|
4530
|
+
const t = await n.select().from(J).where(g(a(J.tenant_id, i), a(J.id, e))).get();
|
|
4531
4531
|
return t ? ft(t) : null;
|
|
4532
4532
|
},
|
|
4533
|
-
async update(
|
|
4533
|
+
async update(i, e, t) {
|
|
4534
4534
|
const r = {
|
|
4535
4535
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4536
4536
|
};
|
|
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
|
|
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 n.update(J).set(r).where(g(a(J.tenant_id, i), a(J.id, e))).returning()).length > 0;
|
|
4538
4538
|
},
|
|
4539
|
-
async list(
|
|
4539
|
+
async list(i, e) {
|
|
4540
4540
|
const {
|
|
4541
4541
|
page: t = 0,
|
|
4542
4542
|
per_page: r = 50,
|
|
4543
4543
|
include_totals: o = !1,
|
|
4544
4544
|
sort: l,
|
|
4545
4545
|
q: _
|
|
4546
|
-
} = e || {}, d = _ ? pe(J, _, ["name"]) : void 0, c = d ? g(a(J.tenant_id,
|
|
4547
|
-
let u =
|
|
4546
|
+
} = e || {}, d = _ ? pe(J, _, ["name"]) : void 0, c = d ? g(a(J.tenant_id, i), d) : a(J.tenant_id, i);
|
|
4547
|
+
let u = n.select().from(J).where(c).$dynamic();
|
|
4548
4548
|
if (l != null && l.sort_by) {
|
|
4549
4549
|
const w = J[l.sort_by];
|
|
4550
4550
|
w && (u = u.orderBy(
|
|
@@ -4554,7 +4554,7 @@ function ks(i) {
|
|
|
4554
4554
|
const f = (await u.offset(t * r).limit(r)).map(ft);
|
|
4555
4555
|
if (!o)
|
|
4556
4556
|
return { roles: f };
|
|
4557
|
-
const [y] = await
|
|
4557
|
+
const [y] = await n.select({ count: V() }).from(J).where(c);
|
|
4558
4558
|
return {
|
|
4559
4559
|
roles: f,
|
|
4560
4560
|
start: t * r,
|
|
@@ -4562,8 +4562,8 @@ function ks(i) {
|
|
|
4562
4562
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
4563
4563
|
};
|
|
4564
4564
|
},
|
|
4565
|
-
async remove(
|
|
4566
|
-
return (await
|
|
4565
|
+
async remove(i, e) {
|
|
4566
|
+
return (await n.delete(J).where(g(a(J.tenant_id, i), a(J.id, e))).returning()).length > 0;
|
|
4567
4567
|
}
|
|
4568
4568
|
};
|
|
4569
4569
|
}
|
|
@@ -4575,9 +4575,9 @@ const Is = ["created_at_ts", "updated_at_ts"], zs = [
|
|
|
4575
4575
|
"used_at_ts",
|
|
4576
4576
|
"revoked_at_ts"
|
|
4577
4577
|
];
|
|
4578
|
-
function mt(
|
|
4578
|
+
function mt(n) {
|
|
4579
4579
|
const {
|
|
4580
|
-
tenant_id:
|
|
4580
|
+
tenant_id: i,
|
|
4581
4581
|
created_at_ts: e,
|
|
4582
4582
|
updated_at_ts: t,
|
|
4583
4583
|
expires_at_ts: r,
|
|
@@ -4589,7 +4589,7 @@ function mt(i) {
|
|
|
4589
4589
|
device: u,
|
|
4590
4590
|
clients: h,
|
|
4591
4591
|
...f
|
|
4592
|
-
} =
|
|
4592
|
+
} = n, y = Fe(
|
|
4593
4593
|
{
|
|
4594
4594
|
created_at_ts: e,
|
|
4595
4595
|
updated_at_ts: t,
|
|
@@ -4610,12 +4610,12 @@ function mt(i) {
|
|
|
4610
4610
|
clients: b(h, [])
|
|
4611
4611
|
});
|
|
4612
4612
|
}
|
|
4613
|
-
function Ts(
|
|
4613
|
+
function Ts(n) {
|
|
4614
4614
|
return {
|
|
4615
|
-
async create(
|
|
4615
|
+
async create(i, e) {
|
|
4616
4616
|
const t = Date.now(), r = {
|
|
4617
4617
|
id: e.id || ae(),
|
|
4618
|
-
tenant_id:
|
|
4618
|
+
tenant_id: i,
|
|
4619
4619
|
user_id: e.user_id,
|
|
4620
4620
|
login_session_id: e.login_session_id,
|
|
4621
4621
|
device: JSON.stringify(e.device || {}),
|
|
@@ -4629,29 +4629,29 @@ function Ts(i) {
|
|
|
4629
4629
|
used_at_ts: K(e.used_at),
|
|
4630
4630
|
revoked_at_ts: K(e.revoked_at)
|
|
4631
4631
|
};
|
|
4632
|
-
return await
|
|
4632
|
+
return await n.insert($).values(r), mt({ ...r, tenant_id: i });
|
|
4633
4633
|
},
|
|
4634
|
-
async get(
|
|
4635
|
-
const t = await
|
|
4634
|
+
async get(i, e) {
|
|
4635
|
+
const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
|
|
4636
4636
|
return t ? mt(t) : null;
|
|
4637
4637
|
},
|
|
4638
|
-
async update(
|
|
4638
|
+
async update(i, e, t) {
|
|
4639
4639
|
const r = {
|
|
4640
4640
|
updated_at_ts: Date.now()
|
|
4641
4641
|
};
|
|
4642
4642
|
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
4643
|
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
|
|
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 n.update($).set(r).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
|
|
4645
4645
|
},
|
|
4646
|
-
async list(
|
|
4646
|
+
async list(i, e) {
|
|
4647
4647
|
const {
|
|
4648
4648
|
page: t = 0,
|
|
4649
4649
|
per_page: r = 50,
|
|
4650
4650
|
include_totals: o = !1,
|
|
4651
4651
|
sort: l,
|
|
4652
4652
|
q: _
|
|
4653
|
-
} = e || {}, d = _ ? pe($, _, ["user_id"]) : void 0, c = d ? g(a($.tenant_id,
|
|
4654
|
-
let u =
|
|
4653
|
+
} = e || {}, d = _ ? pe($, _, ["user_id"]) : void 0, c = d ? g(a($.tenant_id, i), d) : a($.tenant_id, i);
|
|
4654
|
+
let u = n.select().from($).where(c).$dynamic();
|
|
4655
4655
|
if (l != null && l.sort_by) {
|
|
4656
4656
|
const w = $[l.sort_by];
|
|
4657
4657
|
w && (u = u.orderBy(
|
|
@@ -4661,7 +4661,7 @@ function Ts(i) {
|
|
|
4661
4661
|
const f = (await u.offset(t * r).limit(r)).map(mt);
|
|
4662
4662
|
if (!o)
|
|
4663
4663
|
return { sessions: f };
|
|
4664
|
-
const [y] = await
|
|
4664
|
+
const [y] = await n.select({ count: V() }).from($).where(c);
|
|
4665
4665
|
return {
|
|
4666
4666
|
sessions: f,
|
|
4667
4667
|
start: t * r,
|
|
@@ -4669,8 +4669,8 @@ function Ts(i) {
|
|
|
4669
4669
|
length: Number((y == null ? void 0 : y.count) ?? 0)
|
|
4670
4670
|
};
|
|
4671
4671
|
},
|
|
4672
|
-
async remove(
|
|
4673
|
-
return (await
|
|
4672
|
+
async remove(i, e) {
|
|
4673
|
+
return (await n.delete($).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
|
|
4674
4674
|
}
|
|
4675
4675
|
};
|
|
4676
4676
|
}
|
|
@@ -4696,39 +4696,37 @@ const mr = [
|
|
|
4696
4696
|
"pushed_authorization_requests_supported",
|
|
4697
4697
|
"authorization_response_iss_parameter_supported"
|
|
4698
4698
|
];
|
|
4699
|
-
function Pt(
|
|
4700
|
-
const
|
|
4699
|
+
function Pt(n) {
|
|
4700
|
+
const i = { ...n };
|
|
4701
4701
|
for (const e of mr)
|
|
4702
|
-
typeof
|
|
4702
|
+
typeof i[e] == "string" && (i[e] = b(i[e]));
|
|
4703
4703
|
for (const e of hr)
|
|
4704
|
-
|
|
4705
|
-
return
|
|
4704
|
+
i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
|
|
4705
|
+
return z(i);
|
|
4706
4706
|
}
|
|
4707
|
-
function Qt(
|
|
4708
|
-
const
|
|
4707
|
+
function Qt(n) {
|
|
4708
|
+
const i = { ...n };
|
|
4709
4709
|
Qr(
|
|
4710
|
-
|
|
4710
|
+
n,
|
|
4711
4711
|
mr,
|
|
4712
|
-
|
|
4712
|
+
i
|
|
4713
4713
|
);
|
|
4714
4714
|
for (const e of hr)
|
|
4715
|
-
|
|
4716
|
-
return cr(
|
|
4715
|
+
n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
|
|
4716
|
+
return cr(i);
|
|
4717
4717
|
}
|
|
4718
|
-
function qs(
|
|
4718
|
+
function qs(n) {
|
|
4719
4719
|
return {
|
|
4720
|
-
async create(
|
|
4720
|
+
async create(i) {
|
|
4721
4721
|
var r, o;
|
|
4722
4722
|
const e = {
|
|
4723
|
-
id:
|
|
4724
|
-
session_lifetime: 168,
|
|
4725
|
-
idle_session_lifetime: 72,
|
|
4723
|
+
id: i.id || ae(),
|
|
4726
4724
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4727
4725
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4728
|
-
...
|
|
4726
|
+
...i
|
|
4729
4727
|
}, t = Qt(e);
|
|
4730
4728
|
try {
|
|
4731
|
-
await
|
|
4729
|
+
await n.insert(D).values(t);
|
|
4732
4730
|
} catch (l) {
|
|
4733
4731
|
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
4732
|
message: `Tenant with ID '${e.id}' already exists`
|
|
@@ -4736,19 +4734,19 @@ function qs(i) {
|
|
|
4736
4734
|
}
|
|
4737
4735
|
return e;
|
|
4738
4736
|
},
|
|
4739
|
-
async get(
|
|
4740
|
-
const e = await
|
|
4737
|
+
async get(i) {
|
|
4738
|
+
const e = await n.select().from(D).where(a(D.id, i)).get();
|
|
4741
4739
|
return e ? Pt(e) : null;
|
|
4742
4740
|
},
|
|
4743
|
-
async list(
|
|
4741
|
+
async list(i) {
|
|
4744
4742
|
const {
|
|
4745
4743
|
page: e = 0,
|
|
4746
4744
|
per_page: t = 50,
|
|
4747
4745
|
include_totals: r = !1,
|
|
4748
4746
|
sort: o,
|
|
4749
4747
|
q: l
|
|
4750
|
-
} =
|
|
4751
|
-
let _ =
|
|
4748
|
+
} = i || {};
|
|
4749
|
+
let _ = n.select().from(D).$dynamic();
|
|
4752
4750
|
if (l) {
|
|
4753
4751
|
const h = pe(D, l, ["friendly_name"]);
|
|
4754
4752
|
h && (_ = _.where(h));
|
|
@@ -4762,7 +4760,7 @@ function qs(i) {
|
|
|
4762
4760
|
const c = (await _.offset(e * t).limit(t)).map(Pt);
|
|
4763
4761
|
if (!r)
|
|
4764
4762
|
return { tenants: c };
|
|
4765
|
-
const [u] = await
|
|
4763
|
+
const [u] = await n.select({ count: V() }).from(D);
|
|
4766
4764
|
return {
|
|
4767
4765
|
tenants: c,
|
|
4768
4766
|
start: e * t,
|
|
@@ -4770,16 +4768,16 @@ function qs(i) {
|
|
|
4770
4768
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
4771
4769
|
};
|
|
4772
4770
|
},
|
|
4773
|
-
async update(
|
|
4771
|
+
async update(i, e) {
|
|
4774
4772
|
const t = Qt({
|
|
4775
4773
|
...e,
|
|
4776
|
-
id:
|
|
4774
|
+
id: i,
|
|
4777
4775
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4778
4776
|
});
|
|
4779
|
-
await
|
|
4777
|
+
await n.update(D).set(t).where(a(D.id, i));
|
|
4780
4778
|
},
|
|
4781
|
-
async remove(
|
|
4782
|
-
return (await
|
|
4779
|
+
async remove(i) {
|
|
4780
|
+
return (await n.delete(D).where(a(D.id, i)).returning()).length > 0;
|
|
4783
4781
|
}
|
|
4784
4782
|
};
|
|
4785
4783
|
}
|
|
@@ -4790,51 +4788,51 @@ const Ls = [
|
|
|
4790
4788
|
"page_background",
|
|
4791
4789
|
"widget"
|
|
4792
4790
|
];
|
|
4793
|
-
function Jt(
|
|
4794
|
-
const { tenant_id:
|
|
4791
|
+
function Jt(n) {
|
|
4792
|
+
const { tenant_id: i, ...e } = n, t = gr(e, Ls);
|
|
4795
4793
|
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
4794
|
}
|
|
4797
|
-
function Es(
|
|
4795
|
+
function Es(n) {
|
|
4798
4796
|
return {
|
|
4799
|
-
async create(
|
|
4797
|
+
async create(i, e, t) {
|
|
4800
4798
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
|
|
4801
4799
|
...Pe(e),
|
|
4802
|
-
tenant_id:
|
|
4800
|
+
tenant_id: i,
|
|
4803
4801
|
themeId: o,
|
|
4804
4802
|
created_at: r,
|
|
4805
4803
|
updated_at: r
|
|
4806
4804
|
};
|
|
4807
|
-
return await
|
|
4805
|
+
return await n.insert(fe).values(_), Jt({ ..._, tenant_id: i });
|
|
4808
4806
|
},
|
|
4809
|
-
async get(
|
|
4810
|
-
const t = await
|
|
4811
|
-
g(a(fe.tenant_id,
|
|
4807
|
+
async get(i, e) {
|
|
4808
|
+
const t = await n.select().from(fe).where(
|
|
4809
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4812
4810
|
).get();
|
|
4813
4811
|
return t ? Jt(t) : null;
|
|
4814
4812
|
},
|
|
4815
|
-
async update(
|
|
4813
|
+
async update(i, e, t) {
|
|
4816
4814
|
const r = Pe(t);
|
|
4817
|
-
return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await
|
|
4818
|
-
g(a(fe.tenant_id,
|
|
4815
|
+
return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await n.update(fe).set(r).where(
|
|
4816
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4819
4817
|
), !0;
|
|
4820
4818
|
},
|
|
4821
|
-
async remove(
|
|
4822
|
-
return (await
|
|
4823
|
-
g(a(fe.tenant_id,
|
|
4819
|
+
async remove(i, e) {
|
|
4820
|
+
return (await n.delete(fe).where(
|
|
4821
|
+
g(a(fe.tenant_id, i), a(fe.themeId, e))
|
|
4824
4822
|
).returning()).length > 0;
|
|
4825
4823
|
}
|
|
4826
4824
|
};
|
|
4827
4825
|
}
|
|
4828
|
-
function As(
|
|
4826
|
+
function As(n) {
|
|
4829
4827
|
return {
|
|
4830
|
-
async get(
|
|
4831
|
-
const e = await
|
|
4828
|
+
async get(i) {
|
|
4829
|
+
const e = await n.select({ body: Ne.body }).from(Ne).where(a(Ne.tenant_id, i)).get();
|
|
4832
4830
|
return e ? { body: e.body } : null;
|
|
4833
4831
|
},
|
|
4834
|
-
async set(
|
|
4832
|
+
async set(i, e) {
|
|
4835
4833
|
const t = Date.now();
|
|
4836
|
-
await
|
|
4837
|
-
tenant_id:
|
|
4834
|
+
await n.insert(Ne).values({
|
|
4835
|
+
tenant_id: i,
|
|
4838
4836
|
body: e.body,
|
|
4839
4837
|
created_at_ts: t,
|
|
4840
4838
|
updated_at_ts: t
|
|
@@ -4846,25 +4844,25 @@ function As(i) {
|
|
|
4846
4844
|
}
|
|
4847
4845
|
});
|
|
4848
4846
|
},
|
|
4849
|
-
async delete(
|
|
4850
|
-
await
|
|
4847
|
+
async delete(i) {
|
|
4848
|
+
await n.delete(Ne).where(a(Ne.tenant_id, i));
|
|
4851
4849
|
}
|
|
4852
4850
|
};
|
|
4853
4851
|
}
|
|
4854
|
-
function Ft(
|
|
4852
|
+
function Ft(n, i) {
|
|
4855
4853
|
const e = {
|
|
4856
|
-
connection:
|
|
4857
|
-
provider:
|
|
4858
|
-
user_id:
|
|
4859
|
-
isSocial: !!
|
|
4854
|
+
connection: n.connection,
|
|
4855
|
+
provider: n.provider,
|
|
4856
|
+
user_id: n.user_id,
|
|
4857
|
+
isSocial: !!n.is_social
|
|
4860
4858
|
};
|
|
4861
|
-
return
|
|
4862
|
-
email:
|
|
4863
|
-
email_verified: !!
|
|
4864
|
-
...typeof
|
|
4859
|
+
return i ? e.isPrimary = !0 : e.profileData = {
|
|
4860
|
+
email: n.email,
|
|
4861
|
+
email_verified: !!n.email_verified,
|
|
4862
|
+
...typeof n.profileData == "string" ? b(n.profileData, {}) : {}
|
|
4865
4863
|
}, e;
|
|
4866
4864
|
}
|
|
4867
|
-
function ht(
|
|
4865
|
+
function ht(n, i = []) {
|
|
4868
4866
|
const {
|
|
4869
4867
|
tenant_id: e,
|
|
4870
4868
|
app_metadata: t,
|
|
@@ -4876,10 +4874,10 @@ function ht(i, n = []) {
|
|
|
4876
4874
|
linked_to: c,
|
|
4877
4875
|
profileData: u,
|
|
4878
4876
|
...h
|
|
4879
|
-
} =
|
|
4877
|
+
} = n, f = Ft(n, !0), y = i.map((w) => Ft(w, !1));
|
|
4880
4878
|
return z({
|
|
4881
4879
|
...h,
|
|
4882
|
-
email:
|
|
4880
|
+
email: n.email || "",
|
|
4883
4881
|
email_verified: !!l,
|
|
4884
4882
|
phone_verified: _ != null ? !!_ : void 0,
|
|
4885
4883
|
is_social: !!d,
|
|
@@ -4889,8 +4887,8 @@ function ht(i, n = []) {
|
|
|
4889
4887
|
identities: [f, ...y]
|
|
4890
4888
|
});
|
|
4891
4889
|
}
|
|
4892
|
-
function Cs(
|
|
4893
|
-
const
|
|
4890
|
+
function Cs(n) {
|
|
4891
|
+
const i = async (e, t) => {
|
|
4894
4892
|
var _, d;
|
|
4895
4893
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4896
4894
|
user_id: t.user_id,
|
|
@@ -4930,9 +4928,9 @@ function Cs(i) {
|
|
|
4930
4928
|
}, l = t.password ? ae() : void 0;
|
|
4931
4929
|
try {
|
|
4932
4930
|
if (t.password && l) {
|
|
4933
|
-
|
|
4931
|
+
n.run(N`BEGIN`);
|
|
4934
4932
|
try {
|
|
4935
|
-
await
|
|
4933
|
+
await n.insert(k).values(o), await n.insert(E).values({
|
|
4936
4934
|
id: l,
|
|
4937
4935
|
tenant_id: e,
|
|
4938
4936
|
user_id: t.user_id,
|
|
@@ -4941,12 +4939,12 @@ function Cs(i) {
|
|
|
4941
4939
|
is_current: 1,
|
|
4942
4940
|
created_at: r,
|
|
4943
4941
|
updated_at: r
|
|
4944
|
-
}),
|
|
4942
|
+
}), n.run(N`COMMIT`);
|
|
4945
4943
|
} catch (c) {
|
|
4946
|
-
throw
|
|
4944
|
+
throw n.run(N`ROLLBACK`), c;
|
|
4947
4945
|
}
|
|
4948
4946
|
} else
|
|
4949
|
-
await
|
|
4947
|
+
await n.insert(k).values(o);
|
|
4950
4948
|
} catch (c) {
|
|
4951
4949
|
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
4950
|
message: "Internal server error"
|
|
@@ -4955,12 +4953,12 @@ function Cs(i) {
|
|
|
4955
4953
|
return ht(o);
|
|
4956
4954
|
};
|
|
4957
4955
|
return {
|
|
4958
|
-
create:
|
|
4959
|
-
rawCreate:
|
|
4956
|
+
create: i,
|
|
4957
|
+
rawCreate: i,
|
|
4960
4958
|
async get(e, t) {
|
|
4961
|
-
const r = await
|
|
4959
|
+
const r = await n.select().from(k).where(g(a(k.tenant_id, e), a(k.user_id, t))).get();
|
|
4962
4960
|
if (!r) return null;
|
|
4963
|
-
const o = await
|
|
4961
|
+
const o = await n.select().from(k).where(
|
|
4964
4962
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
4965
4963
|
).all();
|
|
4966
4964
|
return ht(r, o);
|
|
@@ -4995,7 +4993,7 @@ function Cs(i) {
|
|
|
4995
4993
|
];
|
|
4996
4994
|
for (const d of l)
|
|
4997
4995
|
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
|
|
4996
|
+
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
4997
|
},
|
|
5000
4998
|
async list(e, t) {
|
|
5001
4999
|
const {
|
|
@@ -5018,7 +5016,7 @@ function Cs(i) {
|
|
|
5018
5016
|
W && c.push(W);
|
|
5019
5017
|
}
|
|
5020
5018
|
const u = g(...c);
|
|
5021
|
-
let h =
|
|
5019
|
+
let h = n.select().from(k).where(u).$dynamic();
|
|
5022
5020
|
if (_ != null && _.sort_by) {
|
|
5023
5021
|
const W = k[_.sort_by];
|
|
5024
5022
|
W && (h = h.orderBy(
|
|
@@ -5027,7 +5025,7 @@ function Cs(i) {
|
|
|
5027
5025
|
}
|
|
5028
5026
|
const f = await h.offset(r * o).limit(o), y = f.map((W) => W.user_id);
|
|
5029
5027
|
let w = [];
|
|
5030
|
-
y.length > 0 && (w = await
|
|
5028
|
+
y.length > 0 && (w = await n.select().from(k).where(
|
|
5031
5029
|
g(
|
|
5032
5030
|
a(k.tenant_id, e),
|
|
5033
5031
|
we(k.linked_to, y)
|
|
@@ -5039,7 +5037,7 @@ function Cs(i) {
|
|
|
5039
5037
|
});
|
|
5040
5038
|
if (!l)
|
|
5041
5039
|
return { users: A };
|
|
5042
|
-
const [R] = await
|
|
5040
|
+
const [R] = await n.select({ count: V() }).from(k).where(u);
|
|
5043
5041
|
return {
|
|
5044
5042
|
users: A,
|
|
5045
5043
|
start: r * o,
|
|
@@ -5048,35 +5046,35 @@ function Cs(i) {
|
|
|
5048
5046
|
};
|
|
5049
5047
|
},
|
|
5050
5048
|
async remove(e, t) {
|
|
5051
|
-
|
|
5049
|
+
n.run(N`BEGIN`);
|
|
5052
5050
|
try {
|
|
5053
|
-
const r = await
|
|
5051
|
+
const r = await n.select({ user_id: k.user_id }).from(k).where(
|
|
5054
5052
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
5055
5053
|
), o = [t, ...r.map((_) => _.user_id)];
|
|
5056
|
-
await
|
|
5054
|
+
await n.delete(F).where(
|
|
5057
5055
|
g(
|
|
5058
5056
|
a(F.tenant_id, e),
|
|
5059
5057
|
we(F.user_id, o)
|
|
5060
5058
|
)
|
|
5061
|
-
), await
|
|
5059
|
+
), await n.delete(E).where(
|
|
5062
5060
|
g(
|
|
5063
5061
|
a(E.tenant_id, e),
|
|
5064
5062
|
we(E.user_id, o)
|
|
5065
5063
|
)
|
|
5066
|
-
), await
|
|
5064
|
+
), await n.delete(k).where(
|
|
5067
5065
|
g(a(k.tenant_id, e), a(k.linked_to, t))
|
|
5068
5066
|
);
|
|
5069
|
-
const l = await
|
|
5067
|
+
const l = await n.delete(k).where(
|
|
5070
5068
|
g(a(k.tenant_id, e), a(k.user_id, t))
|
|
5071
5069
|
).returning();
|
|
5072
|
-
return
|
|
5070
|
+
return n.run(N`COMMIT`), l.length > 0;
|
|
5073
5071
|
} catch (r) {
|
|
5074
|
-
throw
|
|
5072
|
+
throw n.run(N`ROLLBACK`), r;
|
|
5075
5073
|
}
|
|
5076
5074
|
},
|
|
5077
5075
|
async unlink(e, t, r, o) {
|
|
5078
5076
|
const l = `${r}|${o}`;
|
|
5079
|
-
return (await
|
|
5077
|
+
return (await n.update(k).set({ linked_to: null }).where(
|
|
5080
5078
|
g(
|
|
5081
5079
|
a(k.tenant_id, e),
|
|
5082
5080
|
a(k.user_id, l),
|
|
@@ -5086,13 +5084,13 @@ function Cs(i) {
|
|
|
5086
5084
|
}
|
|
5087
5085
|
};
|
|
5088
5086
|
}
|
|
5089
|
-
function $s(
|
|
5087
|
+
function $s(n) {
|
|
5090
5088
|
return {
|
|
5091
|
-
async create(
|
|
5089
|
+
async create(i, e, t, r) {
|
|
5092
5090
|
var o, l;
|
|
5093
5091
|
try {
|
|
5094
|
-
await
|
|
5095
|
-
tenant_id:
|
|
5092
|
+
await n.insert(ue).values({
|
|
5093
|
+
tenant_id: i,
|
|
5096
5094
|
user_id: e,
|
|
5097
5095
|
role_id: t,
|
|
5098
5096
|
organization_id: r || "",
|
|
@@ -5105,19 +5103,19 @@ function $s(i) {
|
|
|
5105
5103
|
}
|
|
5106
5104
|
return !0;
|
|
5107
5105
|
},
|
|
5108
|
-
async list(
|
|
5106
|
+
async list(i, e, t, r) {
|
|
5109
5107
|
let o = [
|
|
5110
|
-
a(ue.tenant_id,
|
|
5108
|
+
a(ue.tenant_id, i),
|
|
5111
5109
|
a(ue.user_id, e)
|
|
5112
5110
|
];
|
|
5113
5111
|
r && o.push(a(ue.organization_id, r));
|
|
5114
|
-
const l = await
|
|
5112
|
+
const l = await n.select({
|
|
5115
5113
|
role_id: ue.role_id
|
|
5116
5114
|
}).from(ue).where(g(...o)).all();
|
|
5117
5115
|
return l.length === 0 ? [] : (await Promise.all(
|
|
5118
5116
|
l.map(async (d) => {
|
|
5119
|
-
const c = await
|
|
5120
|
-
g(a(J.tenant_id,
|
|
5117
|
+
const c = await n.select().from(J).where(
|
|
5118
|
+
g(a(J.tenant_id, i), a(J.id, d.role_id))
|
|
5121
5119
|
).get();
|
|
5122
5120
|
if (!c) return null;
|
|
5123
5121
|
const { tenant_id: u, is_system: h, metadata: f, ...y } = c;
|
|
@@ -5129,10 +5127,10 @@ function $s(i) {
|
|
|
5129
5127
|
})
|
|
5130
5128
|
)).filter(Boolean);
|
|
5131
5129
|
},
|
|
5132
|
-
async remove(
|
|
5133
|
-
return (await
|
|
5130
|
+
async remove(i, e, t, r) {
|
|
5131
|
+
return (await n.delete(ue).where(
|
|
5134
5132
|
g(
|
|
5135
|
-
a(ue.tenant_id,
|
|
5133
|
+
a(ue.tenant_id, i),
|
|
5136
5134
|
a(ue.user_id, e),
|
|
5137
5135
|
a(ue.role_id, t),
|
|
5138
5136
|
a(ue.organization_id, r || "")
|
|
@@ -5141,20 +5139,20 @@ function $s(i) {
|
|
|
5141
5139
|
}
|
|
5142
5140
|
};
|
|
5143
5141
|
}
|
|
5144
|
-
function Bs(
|
|
5142
|
+
function Bs(n) {
|
|
5145
5143
|
return {
|
|
5146
|
-
async create(
|
|
5144
|
+
async create(i, e) {
|
|
5147
5145
|
var d, c;
|
|
5148
5146
|
const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5149
5147
|
id: e.id || ae(),
|
|
5150
|
-
tenant_id:
|
|
5148
|
+
tenant_id: i,
|
|
5151
5149
|
user_id: e.user_id,
|
|
5152
5150
|
organization_id: e.organization_id,
|
|
5153
5151
|
created_at: t,
|
|
5154
5152
|
updated_at: t
|
|
5155
5153
|
};
|
|
5156
5154
|
try {
|
|
5157
|
-
await
|
|
5155
|
+
await n.insert(P).values(o);
|
|
5158
5156
|
} catch (u) {
|
|
5159
5157
|
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
5158
|
message: "User organization already exists"
|
|
@@ -5163,10 +5161,10 @@ function Bs(i) {
|
|
|
5163
5161
|
const { tenant_id: l, ..._ } = o;
|
|
5164
5162
|
return _;
|
|
5165
5163
|
},
|
|
5166
|
-
async get(
|
|
5167
|
-
const t = await
|
|
5164
|
+
async get(i, e) {
|
|
5165
|
+
const t = await n.select().from(P).where(
|
|
5168
5166
|
g(
|
|
5169
|
-
a(P.tenant_id,
|
|
5167
|
+
a(P.tenant_id, i),
|
|
5170
5168
|
a(P.id, e)
|
|
5171
5169
|
)
|
|
5172
5170
|
).get();
|
|
@@ -5174,24 +5172,24 @@ function Bs(i) {
|
|
|
5174
5172
|
const { tenant_id: r, ...o } = t;
|
|
5175
5173
|
return o;
|
|
5176
5174
|
},
|
|
5177
|
-
async update(
|
|
5175
|
+
async update(i, e, t) {
|
|
5178
5176
|
const r = {
|
|
5179
5177
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5180
5178
|
};
|
|
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
|
|
5179
|
+
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
5180
|
g(
|
|
5183
|
-
a(P.tenant_id,
|
|
5181
|
+
a(P.tenant_id, i),
|
|
5184
5182
|
a(P.id, e)
|
|
5185
5183
|
)
|
|
5186
5184
|
).returning()).length > 0;
|
|
5187
5185
|
},
|
|
5188
|
-
async list(
|
|
5186
|
+
async list(i, e) {
|
|
5189
5187
|
const {
|
|
5190
5188
|
page: t = 0,
|
|
5191
5189
|
per_page: r = 50,
|
|
5192
5190
|
include_totals: o = !1,
|
|
5193
5191
|
q: l
|
|
5194
|
-
} = e || {}, _ = a(P.tenant_id,
|
|
5192
|
+
} = e || {}, _ = a(P.tenant_id, i);
|
|
5195
5193
|
let d = _;
|
|
5196
5194
|
if (l) {
|
|
5197
5195
|
const f = pe(P, l, [
|
|
@@ -5200,13 +5198,13 @@ function Bs(i) {
|
|
|
5200
5198
|
]);
|
|
5201
5199
|
f && (d = g(_, f));
|
|
5202
5200
|
}
|
|
5203
|
-
const u = (await
|
|
5201
|
+
const u = (await n.select().from(P).where(d).offset(t * r).limit(r)).map((f) => {
|
|
5204
5202
|
const { tenant_id: y, ...w } = f;
|
|
5205
5203
|
return w;
|
|
5206
5204
|
});
|
|
5207
5205
|
if (!o)
|
|
5208
5206
|
return { userOrganizations: u };
|
|
5209
|
-
const [h] = await
|
|
5207
|
+
const [h] = await n.select({ count: V() }).from(P).where(d);
|
|
5210
5208
|
return {
|
|
5211
5209
|
userOrganizations: u,
|
|
5212
5210
|
start: t * r,
|
|
@@ -5214,17 +5212,17 @@ function Bs(i) {
|
|
|
5214
5212
|
length: Number((h == null ? void 0 : h.count) ?? 0)
|
|
5215
5213
|
};
|
|
5216
5214
|
},
|
|
5217
|
-
async listUserOrganizations(
|
|
5218
|
-
const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await
|
|
5215
|
+
async listUserOrganizations(i, e, t) {
|
|
5216
|
+
const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(P).where(
|
|
5219
5217
|
g(
|
|
5220
|
-
a(P.tenant_id,
|
|
5218
|
+
a(P.tenant_id, i),
|
|
5221
5219
|
a(P.user_id, e)
|
|
5222
5220
|
)
|
|
5223
5221
|
).offset(r * o).limit(o).all(), c = (await Promise.all(
|
|
5224
5222
|
_.map(async (h) => {
|
|
5225
|
-
const f = await
|
|
5223
|
+
const f = await n.select().from(q).where(
|
|
5226
5224
|
g(
|
|
5227
|
-
a(q.tenant_id,
|
|
5225
|
+
a(q.tenant_id, i),
|
|
5228
5226
|
a(q.id, h.organization_id)
|
|
5229
5227
|
)
|
|
5230
5228
|
).get();
|
|
@@ -5248,9 +5246,9 @@ function Bs(i) {
|
|
|
5248
5246
|
)).filter(Boolean);
|
|
5249
5247
|
if (!l)
|
|
5250
5248
|
return { organizations: c };
|
|
5251
|
-
const [u] = await
|
|
5249
|
+
const [u] = await n.select({ count: V() }).from(P).where(
|
|
5252
5250
|
g(
|
|
5253
|
-
a(P.tenant_id,
|
|
5251
|
+
a(P.tenant_id, i),
|
|
5254
5252
|
a(P.user_id, e)
|
|
5255
5253
|
)
|
|
5256
5254
|
);
|
|
@@ -5261,10 +5259,10 @@ function Bs(i) {
|
|
|
5261
5259
|
length: Number((u == null ? void 0 : u.count) ?? 0)
|
|
5262
5260
|
};
|
|
5263
5261
|
},
|
|
5264
|
-
async remove(
|
|
5265
|
-
return (await
|
|
5262
|
+
async remove(i, e) {
|
|
5263
|
+
return (await n.delete(P).where(
|
|
5266
5264
|
g(
|
|
5267
|
-
a(P.tenant_id,
|
|
5265
|
+
a(P.tenant_id, i),
|
|
5268
5266
|
a(P.id, e)
|
|
5269
5267
|
)
|
|
5270
5268
|
).returning()).length > 0;
|
|
@@ -5272,11 +5270,11 @@ function Bs(i) {
|
|
|
5272
5270
|
};
|
|
5273
5271
|
}
|
|
5274
5272
|
const Ut = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Ps = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
5275
|
-
function Qs(
|
|
5273
|
+
function Qs(n) {
|
|
5276
5274
|
return {
|
|
5277
|
-
async getDaily(
|
|
5275
|
+
async getDaily(i, e) {
|
|
5278
5276
|
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
|
|
5277
|
+
return (await n.select({
|
|
5280
5278
|
date: N`substr(${T.date}, 1, 10)`.as("date"),
|
|
5281
5279
|
logins: N`SUM(CASE WHEN ${T.type} IN (${N.join(
|
|
5282
5280
|
Ut.map((_) => N`${_}`),
|
|
@@ -5291,7 +5289,7 @@ function Qs(i) {
|
|
|
5291
5289
|
)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
5292
5290
|
}).from(T).where(
|
|
5293
5291
|
g(
|
|
5294
|
-
a(T.tenant_id,
|
|
5292
|
+
a(T.tenant_id, i),
|
|
5295
5293
|
Ge(T.date, r),
|
|
5296
5294
|
Oe(T.date, `${o}T23:59:59.999Z`)
|
|
5297
5295
|
)
|
|
@@ -5304,14 +5302,14 @@ function Qs(i) {
|
|
|
5304
5302
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5305
5303
|
}));
|
|
5306
5304
|
},
|
|
5307
|
-
async getActiveUsers(
|
|
5305
|
+
async getActiveUsers(i) {
|
|
5308
5306
|
const e = new Date(
|
|
5309
5307
|
Date.now() - 2592e6
|
|
5310
|
-
).toISOString(), [t] = await
|
|
5308
|
+
).toISOString(), [t] = await n.select({
|
|
5311
5309
|
count: N`COUNT(DISTINCT ${T.user_id})`.as("count")
|
|
5312
5310
|
}).from(T).where(
|
|
5313
5311
|
g(
|
|
5314
|
-
a(T.tenant_id,
|
|
5312
|
+
a(T.tenant_id, i),
|
|
5315
5313
|
Ge(T.date, e),
|
|
5316
5314
|
N`${T.type} IN (${N.join(
|
|
5317
5315
|
Ut.map((r) => N`${r}`),
|
|
@@ -5323,19 +5321,19 @@ function Qs(i) {
|
|
|
5323
5321
|
}
|
|
5324
5322
|
};
|
|
5325
5323
|
}
|
|
5326
|
-
function Kt(
|
|
5324
|
+
function Kt(n) {
|
|
5327
5325
|
return {
|
|
5328
|
-
...
|
|
5329
|
-
payload: b(
|
|
5326
|
+
...n,
|
|
5327
|
+
payload: b(n.payload, {})
|
|
5330
5328
|
};
|
|
5331
5329
|
}
|
|
5332
|
-
function Js(
|
|
5330
|
+
function Js(n) {
|
|
5333
5331
|
return {
|
|
5334
|
-
async create(
|
|
5332
|
+
async create(i, e) {
|
|
5335
5333
|
const t = ae(), r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5336
|
-
return await
|
|
5334
|
+
return await n.insert(x).values({
|
|
5337
5335
|
id: t,
|
|
5338
|
-
tenant_id:
|
|
5336
|
+
tenant_id: i,
|
|
5339
5337
|
event_type: e.event_type,
|
|
5340
5338
|
log_type: e.log_type,
|
|
5341
5339
|
aggregate_type: e.aggregate_type,
|
|
@@ -5350,12 +5348,12 @@ function Js(i) {
|
|
|
5350
5348
|
claim_expires_at: null
|
|
5351
5349
|
}), t;
|
|
5352
5350
|
},
|
|
5353
|
-
async getByIds(
|
|
5354
|
-
return
|
|
5351
|
+
async getByIds(i) {
|
|
5352
|
+
return i.length === 0 ? [] : (await n.select().from(x).where(we(x.id, i)).all()).map(Kt);
|
|
5355
5353
|
},
|
|
5356
|
-
async getUnprocessed(
|
|
5354
|
+
async getUnprocessed(i) {
|
|
5357
5355
|
const e = (/* @__PURE__ */ new Date()).toISOString();
|
|
5358
|
-
return (await
|
|
5356
|
+
return (await n.select().from(x).where(
|
|
5359
5357
|
g(
|
|
5360
5358
|
ye(x.processed_at),
|
|
5361
5359
|
de(
|
|
@@ -5367,62 +5365,62 @@ function Js(i) {
|
|
|
5367
5365
|
Oe(x.claim_expires_at, e)
|
|
5368
5366
|
)
|
|
5369
5367
|
)
|
|
5370
|
-
).orderBy(x.created_at, x.id).limit(
|
|
5368
|
+
).orderBy(x.created_at, x.id).limit(i).all()).map(Kt);
|
|
5371
5369
|
},
|
|
5372
|
-
async claimEvents(
|
|
5373
|
-
if (
|
|
5370
|
+
async claimEvents(i, e, t) {
|
|
5371
|
+
if (i.length === 0) return [];
|
|
5374
5372
|
const r = (/* @__PURE__ */ new Date()).toISOString(), o = new Date(Date.now() + t).toISOString();
|
|
5375
|
-
return await
|
|
5373
|
+
return await n.update(x).set({
|
|
5376
5374
|
claimed_by: e,
|
|
5377
5375
|
claim_expires_at: o
|
|
5378
5376
|
}).where(
|
|
5379
5377
|
g(
|
|
5380
|
-
we(x.id,
|
|
5378
|
+
we(x.id, i),
|
|
5381
5379
|
ye(x.processed_at),
|
|
5382
5380
|
de(
|
|
5383
5381
|
ye(x.claimed_by),
|
|
5384
5382
|
Oe(x.claim_expires_at, r)
|
|
5385
5383
|
)
|
|
5386
5384
|
)
|
|
5387
|
-
), (await
|
|
5385
|
+
), (await n.select({ id: x.id }).from(x).where(
|
|
5388
5386
|
g(
|
|
5389
|
-
we(x.id,
|
|
5387
|
+
we(x.id, i),
|
|
5390
5388
|
a(x.claimed_by, e)
|
|
5391
5389
|
)
|
|
5392
5390
|
).all()).map((_) => _.id);
|
|
5393
5391
|
},
|
|
5394
|
-
async markProcessed(
|
|
5395
|
-
|
|
5392
|
+
async markProcessed(i) {
|
|
5393
|
+
i.length !== 0 && await n.update(x).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(we(x.id, i));
|
|
5396
5394
|
},
|
|
5397
|
-
async markRetry(
|
|
5398
|
-
await
|
|
5395
|
+
async markRetry(i, e, t) {
|
|
5396
|
+
await n.update(x).set({
|
|
5399
5397
|
error: e,
|
|
5400
5398
|
next_retry_at: t,
|
|
5401
5399
|
retry_count: N`${x.retry_count} + 1`,
|
|
5402
5400
|
claimed_by: null,
|
|
5403
5401
|
claim_expires_at: null
|
|
5404
|
-
}).where(a(x.id,
|
|
5402
|
+
}).where(a(x.id, i));
|
|
5405
5403
|
},
|
|
5406
|
-
async cleanup(
|
|
5407
|
-
return (await
|
|
5404
|
+
async cleanup(i) {
|
|
5405
|
+
return (await n.delete(x).where(
|
|
5408
5406
|
g(
|
|
5409
5407
|
N`${x.processed_at} IS NOT NULL`,
|
|
5410
|
-
Oe(x.processed_at,
|
|
5408
|
+
Oe(x.processed_at, i)
|
|
5411
5409
|
)
|
|
5412
5410
|
).returning()).length;
|
|
5413
5411
|
},
|
|
5414
|
-
async deadLetter(
|
|
5412
|
+
async deadLetter(i, e) {
|
|
5415
5413
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
5416
|
-
await
|
|
5414
|
+
await n.update(x).set({
|
|
5417
5415
|
processed_at: t,
|
|
5418
5416
|
dead_lettered_at: t,
|
|
5419
5417
|
final_error: e
|
|
5420
|
-
}).where(a(x.id,
|
|
5418
|
+
}).where(a(x.id, i));
|
|
5421
5419
|
},
|
|
5422
|
-
async listFailed(
|
|
5423
|
-
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await
|
|
5420
|
+
async listFailed(i, e = {}) {
|
|
5421
|
+
const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(x).where(
|
|
5424
5422
|
g(
|
|
5425
|
-
a(x.tenant_id,
|
|
5423
|
+
a(x.tenant_id, i),
|
|
5426
5424
|
Ve(x.dead_lettered_at)
|
|
5427
5425
|
)
|
|
5428
5426
|
).orderBy(M(x.dead_lettered_at), H(x.id)).offset(t * r).limit(r).all()).map((c) => ({
|
|
@@ -5438,9 +5436,9 @@ function Js(i) {
|
|
|
5438
5436
|
}));
|
|
5439
5437
|
let d = _.length;
|
|
5440
5438
|
if (o) {
|
|
5441
|
-
const [c] = await
|
|
5439
|
+
const [c] = await n.select({ total: V() }).from(x).where(
|
|
5442
5440
|
g(
|
|
5443
|
-
a(x.tenant_id,
|
|
5441
|
+
a(x.tenant_id, i),
|
|
5444
5442
|
Ve(x.dead_lettered_at)
|
|
5445
5443
|
)
|
|
5446
5444
|
);
|
|
@@ -5453,8 +5451,8 @@ function Js(i) {
|
|
|
5453
5451
|
length: d
|
|
5454
5452
|
};
|
|
5455
5453
|
},
|
|
5456
|
-
async replay(
|
|
5457
|
-
return (await
|
|
5454
|
+
async replay(i, e) {
|
|
5455
|
+
return (await n.update(x).set({
|
|
5458
5456
|
processed_at: null,
|
|
5459
5457
|
dead_lettered_at: null,
|
|
5460
5458
|
final_error: null,
|
|
@@ -5463,7 +5461,7 @@ function Js(i) {
|
|
|
5463
5461
|
error: null
|
|
5464
5462
|
}).where(
|
|
5465
5463
|
g(
|
|
5466
|
-
a(x.id,
|
|
5464
|
+
a(x.id, i),
|
|
5467
5465
|
a(x.tenant_id, e),
|
|
5468
5466
|
Ve(x.dead_lettered_at)
|
|
5469
5467
|
)
|
|
@@ -5472,8 +5470,8 @@ function Js(i) {
|
|
|
5472
5470
|
};
|
|
5473
5471
|
}
|
|
5474
5472
|
const Fs = 7 * 24 * 60 * 60 * 1e3;
|
|
5475
|
-
function Us(
|
|
5476
|
-
return async (
|
|
5473
|
+
function Us(n) {
|
|
5474
|
+
return async (i) => {
|
|
5477
5475
|
const e = Date.now() - Fs;
|
|
5478
5476
|
try {
|
|
5479
5477
|
let t = [
|
|
@@ -5482,65 +5480,65 @@ function Us(i) {
|
|
|
5482
5480
|
xe(C.idle_expires_at_ts, e)
|
|
5483
5481
|
)
|
|
5484
5482
|
];
|
|
5485
|
-
|
|
5483
|
+
i != null && i.tenant_id && t.push(a(C.tenant_id, i.tenant_id)), await n.delete(C).where(g(...t)), t = [
|
|
5486
5484
|
de(
|
|
5487
5485
|
xe($.expires_at_ts, e),
|
|
5488
5486
|
xe($.idle_expires_at_ts, e)
|
|
5489
5487
|
)
|
|
5490
|
-
],
|
|
5488
|
+
], 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
5489
|
} catch (t) {
|
|
5492
5490
|
console.error("Session cleanup error:", t);
|
|
5493
5491
|
}
|
|
5494
5492
|
};
|
|
5495
5493
|
}
|
|
5496
|
-
function Ms(
|
|
5494
|
+
function Ms(n, i = { useTransactions: !0 }) {
|
|
5497
5495
|
const e = {
|
|
5498
5496
|
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(
|
|
5497
|
+
branding: Ur(n),
|
|
5498
|
+
clients: Kr(n),
|
|
5499
|
+
clientConnections: Mr(n),
|
|
5500
|
+
clientGrants: Gr(n),
|
|
5501
|
+
codes: Yr(n),
|
|
5502
|
+
connections: Zr(n),
|
|
5503
|
+
customDomains: es(n),
|
|
5504
|
+
customText: ts(n),
|
|
5505
|
+
emailProviders: ns(n),
|
|
5506
|
+
flows: is(n),
|
|
5507
|
+
forms: rs(n),
|
|
5508
|
+
hookCode: as(n),
|
|
5509
|
+
hooks: _s(n),
|
|
5510
|
+
invites: ds(n),
|
|
5511
|
+
keys: cs(n),
|
|
5512
|
+
loginSessions: fs(n),
|
|
5513
|
+
logs: ms(n),
|
|
5514
|
+
authenticationMethods: ps(n),
|
|
5515
|
+
organizations: ws(n),
|
|
5516
|
+
passwords: Ns(n),
|
|
5517
|
+
promptSettings: vs(n),
|
|
5518
|
+
refreshTokens: Ss(n),
|
|
5519
|
+
resourceServers: xs(n),
|
|
5520
|
+
rolePermissions: Ds(n),
|
|
5521
|
+
userPermissions: Os(n),
|
|
5522
|
+
roles: ks(n),
|
|
5523
|
+
sessions: Ts(n),
|
|
5524
|
+
sessionCleanup: Us(n),
|
|
5525
|
+
tenants: qs(n),
|
|
5526
|
+
themes: Es(n),
|
|
5527
|
+
universalLoginTemplates: As(n),
|
|
5528
|
+
users: Cs(n),
|
|
5529
|
+
userRoles: $s(n),
|
|
5530
|
+
userOrganizations: Bs(n),
|
|
5531
|
+
stats: Qs(n),
|
|
5532
|
+
outbox: Js(n),
|
|
5535
5533
|
async transaction(t) {
|
|
5536
|
-
if (
|
|
5534
|
+
if (i.useTransactions === !1)
|
|
5537
5535
|
return t(e);
|
|
5538
|
-
|
|
5536
|
+
n.run(N`BEGIN`);
|
|
5539
5537
|
try {
|
|
5540
5538
|
const r = await t(e);
|
|
5541
|
-
return
|
|
5539
|
+
return n.run(N`COMMIT`), r;
|
|
5542
5540
|
} catch (r) {
|
|
5543
|
-
throw
|
|
5541
|
+
throw n.run(N`ROLLBACK`), r;
|
|
5544
5542
|
}
|
|
5545
5543
|
}
|
|
5546
5544
|
};
|