@authhero/kysely-adapter 12.7.0 → 12.8.1
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/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.mjs +975 -828
- package/dist/types/src/cleanup.d.ts +20 -0
- package/dist/types/src/helpers/database-type.d.ts +15 -0
- package/dist/types/src/users/createMany.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -91,14 +91,14 @@ function Le(e) {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/actions/get.ts
|
|
94
|
-
function
|
|
94
|
+
function D(e) {
|
|
95
95
|
if (e) try {
|
|
96
96
|
return JSON.parse(e);
|
|
97
97
|
} catch {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Re(e) {
|
|
102
102
|
return async (t, n) => {
|
|
103
103
|
let i = await e.selectFrom("actions").where("actions.tenant_id", "=", t).where("actions.id", "=", n).selectAll().executeTakeFirst();
|
|
104
104
|
if (!i) return null;
|
|
@@ -113,9 +113,9 @@ function ze(e) {
|
|
|
113
113
|
runtime: m.runtime ?? void 0,
|
|
114
114
|
status: m.status || "built",
|
|
115
115
|
deployed_at: s ? new Date(Number(s)).toISOString() : void 0,
|
|
116
|
-
secrets:
|
|
117
|
-
dependencies:
|
|
118
|
-
supported_triggers:
|
|
116
|
+
secrets: D(c),
|
|
117
|
+
dependencies: D(l),
|
|
118
|
+
supported_triggers: D(u),
|
|
119
119
|
is_system: !!d,
|
|
120
120
|
inherit: !!f
|
|
121
121
|
};
|
|
@@ -123,16 +123,16 @@ function ze(e) {
|
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/helpers/filter.ts
|
|
126
|
-
function
|
|
126
|
+
function ze(e) {
|
|
127
127
|
return f`coalesce(${f.ref(e.column)}, ${f.lit(e.defaultValue)})`;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function O(e, t, n, r, i = [], a = {}) {
|
|
130
130
|
let o = new Set(i), { ref: s } = e.dynamic, c = (e) => {
|
|
131
131
|
let t = a[e];
|
|
132
132
|
return t === void 0 ? e : typeof t == "string" ? t : t.column;
|
|
133
133
|
}, l = (e) => {
|
|
134
134
|
let t = a[e];
|
|
135
|
-
return t === void 0 || typeof t == "string" ? s(t ?? e) :
|
|
135
|
+
return t === void 0 || typeof t == "string" ? s(t ?? e) : ze(t);
|
|
136
136
|
}, u = (e, t) => {
|
|
137
137
|
let n = a[e];
|
|
138
138
|
if (n === void 0 || typeof n == "string") return t;
|
|
@@ -199,17 +199,17 @@ function D(e, t, n, r, i = [], a = {}) {
|
|
|
199
199
|
}
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/actions/list.ts
|
|
202
|
-
function
|
|
202
|
+
function k(e) {
|
|
203
203
|
if (e) try {
|
|
204
204
|
return JSON.parse(e);
|
|
205
205
|
} catch {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Be(e) {
|
|
210
210
|
return async (t, n = {}) => {
|
|
211
211
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, q: c } = n, l = e.selectFrom("actions").where("actions.tenant_id", "=", t);
|
|
212
|
-
c && (l =
|
|
212
|
+
c && (l = O(e, l, c, ["name"]));
|
|
213
213
|
let u = (await l.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
214
214
|
let { created_at_ts: n, updated_at_ts: i, deployed_at_ts: a, secrets: o, dependencies: s, supported_triggers: c, is_system: l, inherit: u, tenant_id: d, ...f } = e, p = r({
|
|
215
215
|
created_at_ts: n,
|
|
@@ -222,9 +222,9 @@ function He(e) {
|
|
|
222
222
|
runtime: f.runtime ?? void 0,
|
|
223
223
|
status: f.status || "built",
|
|
224
224
|
deployed_at: a ? new Date(Number(a)).toISOString() : void 0,
|
|
225
|
-
secrets:
|
|
226
|
-
dependencies:
|
|
227
|
-
supported_triggers:
|
|
225
|
+
secrets: k(o),
|
|
226
|
+
dependencies: k(s),
|
|
227
|
+
supported_triggers: k(c),
|
|
228
228
|
is_system: !!l,
|
|
229
229
|
inherit: !!u
|
|
230
230
|
};
|
|
@@ -246,7 +246,7 @@ function He(e) {
|
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/actions/update.ts
|
|
249
|
-
function
|
|
249
|
+
function Ve(e) {
|
|
250
250
|
if (!e) return [];
|
|
251
251
|
try {
|
|
252
252
|
let t = JSON.parse(e);
|
|
@@ -255,11 +255,11 @@ function Ue(e) {
|
|
|
255
255
|
return [];
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function He(e) {
|
|
259
259
|
return async (t, n, r) => {
|
|
260
260
|
let i = { updated_at_ts: Date.now() };
|
|
261
261
|
if (r.name !== void 0 && (i.name = r.name), r.code !== void 0 && (i.code = r.code), r.runtime !== void 0 && (i.runtime = r.runtime), r.secrets !== void 0) {
|
|
262
|
-
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(
|
|
262
|
+
let a = await e.selectFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).select("secrets").executeTakeFirst(), o = new Map(Ve(a?.secrets).map((e) => [e.name, e])), s = r.secrets.map((e) => e.value === void 0 ? {
|
|
263
263
|
name: e.name,
|
|
264
264
|
value: o.get(e.name)?.value
|
|
265
265
|
} : e);
|
|
@@ -274,23 +274,23 @@ function We(e) {
|
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
276
|
//#region src/actions/remove.ts
|
|
277
|
-
function
|
|
277
|
+
function Ue(e) {
|
|
278
278
|
return async (t, n) => (await e.deleteFrom("actions").where("actions.id", "=", n).where("actions.tenant_id", "=", t).executeTakeFirst()).numDeletedRows > 0;
|
|
279
279
|
}
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/actions/index.ts
|
|
282
|
-
function
|
|
282
|
+
function We(e) {
|
|
283
283
|
return {
|
|
284
284
|
create: Le(e),
|
|
285
|
-
get:
|
|
286
|
-
list:
|
|
287
|
-
update:
|
|
288
|
-
remove:
|
|
285
|
+
get: Re(e),
|
|
286
|
+
list: Be(e),
|
|
287
|
+
update: He(e),
|
|
288
|
+
remove: Ue(e)
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/actionExecutions/create.ts
|
|
293
|
-
function
|
|
293
|
+
function Ge(e) {
|
|
294
294
|
return async (t, n) => {
|
|
295
295
|
let r = Date.now();
|
|
296
296
|
return await e.insertInto("action_executions").values({
|
|
@@ -316,14 +316,14 @@ function qe(e) {
|
|
|
316
316
|
}
|
|
317
317
|
//#endregion
|
|
318
318
|
//#region src/actionExecutions/get.ts
|
|
319
|
-
function
|
|
319
|
+
function Ke(e) {
|
|
320
320
|
if (e) try {
|
|
321
321
|
return JSON.parse(e);
|
|
322
322
|
} catch {
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function qe(e) {
|
|
327
327
|
return async (t, n) => {
|
|
328
328
|
let r = await e.selectFrom("action_executions").where("action_executions.tenant_id", "=", t).where("action_executions.id", "=", n).selectAll().executeTakeFirst();
|
|
329
329
|
return r ? {
|
|
@@ -331,35 +331,37 @@ function Ye(e) {
|
|
|
331
331
|
tenant_id: r.tenant_id,
|
|
332
332
|
trigger_id: r.trigger_id,
|
|
333
333
|
status: r.status,
|
|
334
|
-
results:
|
|
335
|
-
logs:
|
|
334
|
+
results: Ke(r.results) ?? [],
|
|
335
|
+
logs: Ke(r.logs),
|
|
336
336
|
created_at: new Date(Number(r.created_at_ts)).toISOString(),
|
|
337
337
|
updated_at: new Date(Number(r.updated_at_ts)).toISOString()
|
|
338
338
|
} : null;
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
342
|
-
//#region src/
|
|
343
|
-
|
|
344
|
-
async function Ze(e) {
|
|
342
|
+
//#region src/helpers/database-type.ts
|
|
343
|
+
async function Je(e) {
|
|
345
344
|
try {
|
|
346
345
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
347
346
|
} catch {
|
|
348
347
|
return "sqlite";
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
|
-
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/actionExecutions/cleanup.ts
|
|
352
|
+
var Ye = 5e4;
|
|
353
|
+
function Xe(e) {
|
|
352
354
|
let t;
|
|
353
355
|
return async (n) => {
|
|
354
356
|
let r = Date.parse(n);
|
|
355
357
|
if (Number.isNaN(r)) throw Error(`Invalid olderThan date: ${n}`);
|
|
356
|
-
if (t ??= await
|
|
358
|
+
if (t ??= await Je(e), t === "sqlite") {
|
|
357
359
|
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).executeTakeFirst();
|
|
358
360
|
return Number(t.numDeletedRows);
|
|
359
361
|
}
|
|
360
|
-
let i = 0, a =
|
|
361
|
-
for (; a >=
|
|
362
|
-
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(
|
|
362
|
+
let i = 0, a = Ye;
|
|
363
|
+
for (; a >= Ye;) {
|
|
364
|
+
let t = await e.deleteFrom("action_executions").where("created_at_ts", "<", r).limit(Ye).executeTakeFirst();
|
|
363
365
|
a = Number(t.numDeletedRows), i += a;
|
|
364
366
|
}
|
|
365
367
|
return i;
|
|
@@ -367,36 +369,36 @@ function Qe(e) {
|
|
|
367
369
|
}
|
|
368
370
|
//#endregion
|
|
369
371
|
//#region src/actionExecutions/index.ts
|
|
370
|
-
function
|
|
372
|
+
function Ze(e) {
|
|
371
373
|
return {
|
|
372
|
-
create:
|
|
373
|
-
get:
|
|
374
|
-
cleanup:
|
|
374
|
+
create: Ge(e),
|
|
375
|
+
get: qe(e),
|
|
376
|
+
cleanup: Xe(e)
|
|
375
377
|
};
|
|
376
378
|
}
|
|
377
379
|
//#endregion
|
|
378
380
|
//#region src/actionVersions/index.ts
|
|
379
|
-
function
|
|
381
|
+
function Qe(e) {
|
|
380
382
|
if (e) try {
|
|
381
383
|
return JSON.parse(e);
|
|
382
384
|
} catch {
|
|
383
385
|
return;
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
|
-
function
|
|
388
|
+
function $e(e) {
|
|
387
389
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
388
390
|
return {
|
|
389
391
|
...c,
|
|
390
392
|
runtime: s ?? void 0,
|
|
391
393
|
deployed: !!o,
|
|
392
|
-
secrets:
|
|
393
|
-
dependencies:
|
|
394
|
-
supported_triggers:
|
|
394
|
+
secrets: Qe(r),
|
|
395
|
+
dependencies: Qe(i),
|
|
396
|
+
supported_triggers: Qe(a),
|
|
395
397
|
created_at: new Date(Number(t)).toISOString(),
|
|
396
398
|
updated_at: new Date(Number(n)).toISOString()
|
|
397
399
|
};
|
|
398
400
|
}
|
|
399
|
-
function
|
|
401
|
+
function et(e) {
|
|
400
402
|
return {
|
|
401
403
|
async create(t, n, r) {
|
|
402
404
|
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : i ? o : a, c = i?.id ?? Me(), l = n.deployed !== !1, u = await e.transaction().execute(async (e) => {
|
|
@@ -436,10 +438,10 @@ function nt(e) {
|
|
|
436
438
|
},
|
|
437
439
|
async get(t, n, r) {
|
|
438
440
|
let i = await e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n).where("id", "=", r).selectAll().executeTakeFirst();
|
|
439
|
-
return i ?
|
|
441
|
+
return i ? $e(i) : null;
|
|
440
442
|
},
|
|
441
443
|
async list(t, n, r = {}) {
|
|
442
|
-
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map(
|
|
444
|
+
let { page: i = 0, per_page: a = 50, include_totals: s = !1 } = r, c = e.selectFrom("action_versions").where("tenant_id", "=", t).where("action_id", "=", n), l = (await c.orderBy("number", "desc").offset(i * a).limit(a).selectAll().execute()).map($e);
|
|
443
445
|
if (!s) return {
|
|
444
446
|
versions: l,
|
|
445
447
|
start: 0,
|
|
@@ -462,7 +464,7 @@ function nt(e) {
|
|
|
462
464
|
}
|
|
463
465
|
//#endregion
|
|
464
466
|
//#region src/outbox/create.ts
|
|
465
|
-
async function
|
|
467
|
+
async function A(e, t, n, r) {
|
|
466
468
|
await e.insertInto("outbox_events").values({
|
|
467
469
|
id: n,
|
|
468
470
|
tenant_id: t,
|
|
@@ -481,15 +483,15 @@ async function O(e, t, n, r) {
|
|
|
481
483
|
error: null
|
|
482
484
|
}).execute();
|
|
483
485
|
}
|
|
484
|
-
function
|
|
486
|
+
function tt(e) {
|
|
485
487
|
return async (n, r) => {
|
|
486
488
|
let i = t();
|
|
487
|
-
return await
|
|
489
|
+
return await A(e, n, i, r), i;
|
|
488
490
|
};
|
|
489
491
|
}
|
|
490
492
|
//#endregion
|
|
491
493
|
//#region src/users/create.ts
|
|
492
|
-
function
|
|
494
|
+
function nt(e) {
|
|
493
495
|
return async (n, r, i) => {
|
|
494
496
|
let a = i?.importMetadata, { identities: o, phone_verified: s, password: c, last_login: l, last_ip: u, login_count: d, ...f } = r, p = (/* @__PURE__ */ new Date()).toISOString(), m = {
|
|
495
497
|
...f,
|
|
@@ -524,7 +526,7 @@ function it(e) {
|
|
|
524
526
|
};
|
|
525
527
|
await e.insertInto("passwords").values(r).execute();
|
|
526
528
|
}
|
|
527
|
-
for (let t of i?.outboxEvents ?? []) await
|
|
529
|
+
for (let t of i?.outboxEvents ?? []) await A(e, n, t.id, t);
|
|
528
530
|
};
|
|
529
531
|
try {
|
|
530
532
|
e.isTransaction ? await h(e) : await e.transaction().execute(h);
|
|
@@ -548,6 +550,70 @@ function it(e) {
|
|
|
548
550
|
};
|
|
549
551
|
}
|
|
550
552
|
//#endregion
|
|
553
|
+
//#region src/users/createMany.ts
|
|
554
|
+
var j = 500;
|
|
555
|
+
function rt(e) {
|
|
556
|
+
let t = e;
|
|
557
|
+
return t.identities !== void 0 || t.last_login !== void 0 || t.last_ip !== void 0 || t.login_count !== void 0;
|
|
558
|
+
}
|
|
559
|
+
function it(e) {
|
|
560
|
+
return async (n, r, i) => {
|
|
561
|
+
if (r.length === 0) return [];
|
|
562
|
+
if (i?.outboxEvents?.length) throw new w(400, { message: "createMany does not persist outbox events; use create for those users" });
|
|
563
|
+
if (r.find(rt)) throw new w(400, { message: "createMany does not write identities or activity counters; use create for those users" });
|
|
564
|
+
let a = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => {
|
|
565
|
+
let { identities: r, phone_verified: i, password: o, last_login: s, last_ip: c, login_count: l, ...u } = e, d = {
|
|
566
|
+
...u,
|
|
567
|
+
created_at: u.created_at ?? a,
|
|
568
|
+
updated_at: u.updated_at ?? a,
|
|
569
|
+
user_id: u.user_id,
|
|
570
|
+
tenant_id: n,
|
|
571
|
+
email_verified: +!!e.email_verified,
|
|
572
|
+
phone_verified: i === void 0 ? null : +!!i,
|
|
573
|
+
is_social: +!!e.is_social,
|
|
574
|
+
blocked: +!!e.blocked,
|
|
575
|
+
app_metadata: JSON.stringify(e.app_metadata),
|
|
576
|
+
user_metadata: JSON.stringify(e.user_metadata),
|
|
577
|
+
address: e.address ? JSON.stringify(e.address) : null
|
|
578
|
+
};
|
|
579
|
+
return {
|
|
580
|
+
sqlUser: d,
|
|
581
|
+
passwordRecord: o && d.user_id ? {
|
|
582
|
+
id: t(),
|
|
583
|
+
user_id: d.user_id,
|
|
584
|
+
password: o.hash,
|
|
585
|
+
algorithm: o.algorithm,
|
|
586
|
+
is_current: 1,
|
|
587
|
+
created_at: a,
|
|
588
|
+
updated_at: a,
|
|
589
|
+
tenant_id: n
|
|
590
|
+
} : void 0,
|
|
591
|
+
original: e
|
|
592
|
+
};
|
|
593
|
+
}), s = o.map((e) => e.sqlUser), c = o.map((e) => e.passwordRecord).filter((e) => e !== void 0), l = async (e) => {
|
|
594
|
+
for (let t = 0; t < s.length; t += j) await e.insertInto("users").values(s.slice(t, t + j)).execute();
|
|
595
|
+
for (let t = 0; t < c.length; t += j) await e.insertInto("passwords").values(c.slice(t, t + j)).execute();
|
|
596
|
+
};
|
|
597
|
+
try {
|
|
598
|
+
e.isTransaction ? await l(e) : await e.transaction().execute(l);
|
|
599
|
+
} catch (e) {
|
|
600
|
+
let t = e?.code, n = e instanceof Error ? e.message : String(e);
|
|
601
|
+
throw t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || n.includes("AlreadyExists") ? new w(409, { message: "User already exists" }) : new w(500, { message: `${String(t)}, ${n}` });
|
|
602
|
+
}
|
|
603
|
+
return o.map(({ sqlUser: e, original: t }) => ({
|
|
604
|
+
...e,
|
|
605
|
+
login_count: 0,
|
|
606
|
+
email_verified: !!e.email_verified,
|
|
607
|
+
is_social: !!e.is_social,
|
|
608
|
+
blocked: !!e.blocked,
|
|
609
|
+
phone_verified: e.phone_verified === null ? void 0 : !!e.phone_verified,
|
|
610
|
+
app_metadata: t.app_metadata,
|
|
611
|
+
user_metadata: t.user_metadata,
|
|
612
|
+
address: t.address
|
|
613
|
+
}));
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
551
617
|
//#region src/users/user-to-identity.ts
|
|
552
618
|
var at = [
|
|
553
619
|
"email",
|
|
@@ -556,7 +622,7 @@ var at = [
|
|
|
556
622
|
"phone_verified",
|
|
557
623
|
"username"
|
|
558
624
|
];
|
|
559
|
-
function
|
|
625
|
+
function M(e, t = !1) {
|
|
560
626
|
let n = {
|
|
561
627
|
connection: e.connection,
|
|
562
628
|
provider: e.provider,
|
|
@@ -603,20 +669,20 @@ function ot(e) {
|
|
|
603
669
|
app_metadata: JSON.parse(r.app_metadata),
|
|
604
670
|
user_metadata: JSON.parse(r.user_metadata),
|
|
605
671
|
address: r.address ? JSON.parse(r.address) : void 0,
|
|
606
|
-
identities: [
|
|
672
|
+
identities: [M(r, !0), ...i.map((e) => M(e))]
|
|
607
673
|
});
|
|
608
674
|
};
|
|
609
675
|
}
|
|
610
676
|
//#endregion
|
|
611
677
|
//#region src/helpers/paginate.ts
|
|
612
|
-
function
|
|
678
|
+
function N(e) {
|
|
613
679
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
614
680
|
}
|
|
615
681
|
function st(e, t) {
|
|
616
682
|
let n = typeof e == "number" && Number.isFinite(e) ? Math.floor(e) : NaN;
|
|
617
683
|
return n >= 1 ? n : t;
|
|
618
684
|
}
|
|
619
|
-
async function
|
|
685
|
+
async function P(e, t, n) {
|
|
620
686
|
let { sortColumn: r, sortOrder: i } = n, a = n.idColumn ?? "id", o = st(t?.take, 50), s = e.orderBy(f.ref(r), i).orderBy(f.ref(a), i), c = t?.from ? te(t.from) : null;
|
|
621
687
|
if (c && c.k !== n.sortKey) throw new w(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
622
688
|
if (c) if (c.s === void 0 || c.s === null) s = s.where(f.ref(a), i === "asc" ? ">" : "<", c.i);
|
|
@@ -691,7 +757,7 @@ async function ft(e, t, n) {
|
|
|
691
757
|
app_metadata: JSON.parse(e.app_metadata),
|
|
692
758
|
user_metadata: JSON.parse(e.user_metadata),
|
|
693
759
|
address: e.address ? JSON.parse(e.address) : void 0,
|
|
694
|
-
identities: [
|
|
760
|
+
identities: [M(e, !0), ...t.map((e) => M(e))]
|
|
695
761
|
});
|
|
696
762
|
});
|
|
697
763
|
}
|
|
@@ -700,11 +766,11 @@ function pt(e) {
|
|
|
700
766
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("users").leftJoin("user_activity", (e) => e.onRef("user_activity.tenant_id", "=", "users.tenant_id").onRef("user_activity.user_id", "=", "users.user_id")).where("users.tenant_id", "=", t);
|
|
701
767
|
if (c) {
|
|
702
768
|
let t = S(c, ct);
|
|
703
|
-
t && (l =
|
|
769
|
+
t && (l = O(e, l, t, dt, [], ut));
|
|
704
770
|
}
|
|
705
|
-
if (
|
|
771
|
+
if (N(n)) {
|
|
706
772
|
if (s?.sort_by && s.sort_by !== "created_at") throw new w(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
707
|
-
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await
|
|
773
|
+
let r = s?.sort_order === "asc" ? "asc" : "desc", { rows: i, limit: a, next: o } = await P(l.where("users.linked_to", "is", null).selectAll("users").select([
|
|
708
774
|
"user_activity.last_login",
|
|
709
775
|
"user_activity.last_ip",
|
|
710
776
|
"user_activity.login_count"
|
|
@@ -726,7 +792,7 @@ function pt(e) {
|
|
|
726
792
|
let t = ut[s.sort_by];
|
|
727
793
|
if (t) {
|
|
728
794
|
let { ref: n } = e.dynamic;
|
|
729
|
-
l = l.orderBy(typeof t == "string" ? n(t) :
|
|
795
|
+
l = l.orderBy(typeof t == "string" ? n(t) : ze(t), s.sort_order);
|
|
730
796
|
}
|
|
731
797
|
}
|
|
732
798
|
let u = l.offset(r * i).limit(i), [d, f] = await Promise.all([u.selectAll("users").select([
|
|
@@ -756,7 +822,7 @@ function mt(e) {
|
|
|
756
822
|
let i = async (e) => {
|
|
757
823
|
await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "in", (e) => e.selectFrom("users").select("users.user_id").where("users.tenant_id", "=", t).where((e) => e.or([e("users.user_id", "=", n), e("users.linked_to", "=", n)]))).execute(), await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.linked_to", "=", n).execute();
|
|
758
824
|
let i = await e.deleteFrom("users").where("users.tenant_id", "=", t).where("users.user_id", "=", n).execute();
|
|
759
|
-
for (let n of r?.outboxEvents ?? []) await
|
|
825
|
+
for (let n of r?.outboxEvents ?? []) await A(e, t, n.id, n);
|
|
760
826
|
return i.length === 1;
|
|
761
827
|
};
|
|
762
828
|
return r?.outboxEvents?.length && !e.isTransaction ? e.transaction().execute(i) : i(e);
|
|
@@ -764,10 +830,10 @@ function mt(e) {
|
|
|
764
830
|
}
|
|
765
831
|
//#endregion
|
|
766
832
|
//#region src/utils/flatten.ts
|
|
767
|
-
function
|
|
833
|
+
function F(e, t = "", n = {}) {
|
|
768
834
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
769
835
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
770
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
836
|
+
typeof a == "object" && a && !Array.isArray(a) ? F(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
771
837
|
}
|
|
772
838
|
return n;
|
|
773
839
|
}
|
|
@@ -833,7 +899,7 @@ function vt(e) {
|
|
|
833
899
|
//#region src/users/update.ts
|
|
834
900
|
function yt(e) {
|
|
835
901
|
return async (t, n, r, i) => {
|
|
836
|
-
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l =
|
|
902
|
+
let { last_login: a, last_ip: o, login_count: s, ...c } = r, l = F({
|
|
837
903
|
...c,
|
|
838
904
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
839
905
|
app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
|
|
@@ -849,7 +915,7 @@ function yt(e) {
|
|
|
849
915
|
last_ip: o,
|
|
850
916
|
login_count: s
|
|
851
917
|
});
|
|
852
|
-
for (let n of i?.outboxEvents ?? []) await
|
|
918
|
+
for (let n of i?.outboxEvents ?? []) await A(e, t, n.id, n);
|
|
853
919
|
return !0;
|
|
854
920
|
};
|
|
855
921
|
return e.isTransaction ? u(e) : e.transaction().execute(u);
|
|
@@ -863,10 +929,11 @@ function bt(e) {
|
|
|
863
929
|
//#endregion
|
|
864
930
|
//#region src/users/index.ts
|
|
865
931
|
function xt(e) {
|
|
866
|
-
let t =
|
|
932
|
+
let t = nt(e);
|
|
867
933
|
return {
|
|
868
934
|
create: t,
|
|
869
935
|
rawCreate: t,
|
|
936
|
+
createMany: it(e),
|
|
870
937
|
remove: mt(e),
|
|
871
938
|
get: ot(e),
|
|
872
939
|
list: pt(e),
|
|
@@ -894,7 +961,7 @@ function St(e) {
|
|
|
894
961
|
}
|
|
895
962
|
//#endregion
|
|
896
963
|
//#region src/helpers/parse.ts
|
|
897
|
-
function
|
|
964
|
+
function I(e, t) {
|
|
898
965
|
if (!e) return t;
|
|
899
966
|
try {
|
|
900
967
|
return JSON.parse(e);
|
|
@@ -911,7 +978,7 @@ function Ct(e) {
|
|
|
911
978
|
}
|
|
912
979
|
}
|
|
913
980
|
function wt(e, t, n = { ...e }) {
|
|
914
|
-
for (let r in t) r in e && (n[r] =
|
|
981
|
+
for (let r in t) r in e && (n[r] = I(e[r], t[r]));
|
|
915
982
|
return n;
|
|
916
983
|
}
|
|
917
984
|
//#endregion
|
|
@@ -922,7 +989,7 @@ function Tt(e) {
|
|
|
922
989
|
if (!r) return null;
|
|
923
990
|
let i = {
|
|
924
991
|
...r,
|
|
925
|
-
actions:
|
|
992
|
+
actions: I(r.actions, [])
|
|
926
993
|
};
|
|
927
994
|
return b.parse(l(i));
|
|
928
995
|
};
|
|
@@ -932,11 +999,11 @@ function Tt(e) {
|
|
|
932
999
|
function Et(e) {
|
|
933
1000
|
return async (t, n = {}) => {
|
|
934
1001
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("flows").where("tenant_id", "=", t);
|
|
935
|
-
s && (c =
|
|
1002
|
+
s && (c = O(e, c, s, []));
|
|
936
1003
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
937
1004
|
let t = {
|
|
938
1005
|
...e,
|
|
939
|
-
actions:
|
|
1006
|
+
actions: I(e.actions, [])
|
|
940
1007
|
};
|
|
941
1008
|
return b.parse(l(t));
|
|
942
1009
|
});
|
|
@@ -1052,7 +1119,7 @@ function Pt(e) {
|
|
|
1052
1119
|
let { ref: t } = e.dynamic;
|
|
1053
1120
|
n = n.orderBy(t(s.sort_by), s.sort_order);
|
|
1054
1121
|
}
|
|
1055
|
-
c && (n =
|
|
1122
|
+
c && (n = O(e, n, c, ["friendly_name"]));
|
|
1056
1123
|
let l = (await n.offset(r * i).limit(i).selectAll().execute()).map(At);
|
|
1057
1124
|
if (!a) return { tenants: l };
|
|
1058
1125
|
let { count: u } = await n.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = o(u);
|
|
@@ -1134,7 +1201,7 @@ function Vt(e) {
|
|
|
1134
1201
|
return e;
|
|
1135
1202
|
}
|
|
1136
1203
|
}
|
|
1137
|
-
function
|
|
1204
|
+
function L(e) {
|
|
1138
1205
|
return {
|
|
1139
1206
|
...e,
|
|
1140
1207
|
client_id: e.client_id,
|
|
@@ -1187,20 +1254,20 @@ function Ut(e) {
|
|
|
1187
1254
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, from_date: l, to_date: u } = n, d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
|
|
1188
1255
|
if (c) {
|
|
1189
1256
|
let t = S(c, Ht);
|
|
1190
|
-
t && (d =
|
|
1257
|
+
t && (d = O(e, d, t, [
|
|
1191
1258
|
"user_id",
|
|
1192
1259
|
"ip",
|
|
1193
1260
|
"description"
|
|
1194
1261
|
], ["description"]));
|
|
1195
1262
|
}
|
|
1196
|
-
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())),
|
|
1263
|
+
if (typeof l == "number" && Number.isFinite(l) && (d = d.where("logs.date", ">=", (/* @__PURE__ */ new Date(Math.floor(l) * 1e3)).toISOString())), typeof u == "number" && Number.isFinite(u) && (d = d.where("logs.date", "<=", (/* @__PURE__ */ new Date(Math.floor(u) * 1e3 + 999)).toISOString())), N(n)) {
|
|
1197
1264
|
if (s?.sort_by && s.sort_by !== "date") throw new w(400, { message: `Sorting by ${s.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
1198
|
-
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await
|
|
1265
|
+
let e = s?.sort_order === "asc" ? "asc" : "desc", { rows: t, limit: r, next: i } = await P(d.selectAll(), n, {
|
|
1199
1266
|
sortColumn: "date",
|
|
1200
1267
|
sortOrder: e,
|
|
1201
1268
|
idColumn: "log_id",
|
|
1202
1269
|
sortKey: `date:${e}`
|
|
1203
|
-
}), a = t.map(
|
|
1270
|
+
}), a = t.map(L);
|
|
1204
1271
|
return {
|
|
1205
1272
|
logs: a,
|
|
1206
1273
|
start: 0,
|
|
@@ -1215,7 +1282,7 @@ function Ut(e) {
|
|
|
1215
1282
|
f = f.orderBy(t(s.sort_by), s.sort_order);
|
|
1216
1283
|
}
|
|
1217
1284
|
f = f.offset(r * i).limit(i);
|
|
1218
|
-
let p = (await f.selectAll().execute()).map(
|
|
1285
|
+
let p = (await f.selectAll().execute()).map(L);
|
|
1219
1286
|
if (!a) return {
|
|
1220
1287
|
logs: p,
|
|
1221
1288
|
start: 0,
|
|
@@ -1236,7 +1303,7 @@ function Ut(e) {
|
|
|
1236
1303
|
function Wt(e) {
|
|
1237
1304
|
return async (t, n) => {
|
|
1238
1305
|
let r = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", n).selectAll().executeTakeFirst();
|
|
1239
|
-
return r ?
|
|
1306
|
+
return r ? L(r) : null;
|
|
1240
1307
|
};
|
|
1241
1308
|
}
|
|
1242
1309
|
//#endregion
|
|
@@ -1345,7 +1412,7 @@ function Yt(e) {
|
|
|
1345
1412
|
function Xt(e) {
|
|
1346
1413
|
return async (t, n = {}) => {
|
|
1347
1414
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: l } = n, u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
|
|
1348
|
-
l && (u =
|
|
1415
|
+
l && (u = O(e, u, l, ["user_id", "session_id"]));
|
|
1349
1416
|
let d = u;
|
|
1350
1417
|
if (c && c.sort_by) {
|
|
1351
1418
|
let { ref: t } = e.dynamic;
|
|
@@ -1476,7 +1543,7 @@ function nn(e) {
|
|
|
1476
1543
|
function rn(e) {
|
|
1477
1544
|
return async (t, n = {}) => {
|
|
1478
1545
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("codes").where("codes.tenant_id", "=", t);
|
|
1479
|
-
s && (c =
|
|
1546
|
+
s && (c = O(e, c, s, ["code", "login_id"]));
|
|
1480
1547
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
1481
1548
|
let { tenant_id: t, ...n } = e;
|
|
1482
1549
|
return ee.parse(l(n));
|
|
@@ -1544,15 +1611,34 @@ function un(e) {
|
|
|
1544
1611
|
}
|
|
1545
1612
|
//#endregion
|
|
1546
1613
|
//#region src/codes/cleanup.ts
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1614
|
+
var R = 5e4;
|
|
1615
|
+
async function dn(e, t) {
|
|
1616
|
+
if (!t) return e();
|
|
1617
|
+
let n = 0, r = R;
|
|
1618
|
+
for (; r >= R;) r = await e(R), n += r;
|
|
1619
|
+
return n;
|
|
1620
|
+
}
|
|
1621
|
+
function fn(e) {
|
|
1622
|
+
let t;
|
|
1623
|
+
return async (n) => {
|
|
1624
|
+
t ??= await Je(e);
|
|
1625
|
+
let r = t === "mysql";
|
|
1626
|
+
return await dn(async (t) => {
|
|
1627
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "<", an(n));
|
|
1628
|
+
t !== void 0 && (r = r.limit(t));
|
|
1629
|
+
let i = await r.executeTakeFirst();
|
|
1630
|
+
return Number(i.numDeletedRows);
|
|
1631
|
+
}, r) + await dn(async (t) => {
|
|
1632
|
+
let r = e.deleteFrom("codes").where("expires_at_ts", "is", null).where("expires_at", "<", n);
|
|
1633
|
+
t !== void 0 && (r = r.limit(t));
|
|
1634
|
+
let i = await r.executeTakeFirst();
|
|
1635
|
+
return Number(i.numDeletedRows);
|
|
1636
|
+
}, r);
|
|
1551
1637
|
};
|
|
1552
1638
|
}
|
|
1553
1639
|
//#endregion
|
|
1554
1640
|
//#region src/codes/index.ts
|
|
1555
|
-
function
|
|
1641
|
+
function pn(e) {
|
|
1556
1642
|
return {
|
|
1557
1643
|
create: on(e),
|
|
1558
1644
|
list: rn(e),
|
|
@@ -1560,12 +1646,12 @@ function fn(e) {
|
|
|
1560
1646
|
used: ln(e),
|
|
1561
1647
|
consume: un(e),
|
|
1562
1648
|
get: cn(e),
|
|
1563
|
-
cleanup:
|
|
1649
|
+
cleanup: fn(e)
|
|
1564
1650
|
};
|
|
1565
1651
|
}
|
|
1566
1652
|
//#endregion
|
|
1567
1653
|
//#region src/connections/create.ts
|
|
1568
|
-
function
|
|
1654
|
+
function mn(e) {
|
|
1569
1655
|
return async (t, n, r) => {
|
|
1570
1656
|
let i = r?.importMetadata, { is_system: a, ...o } = n;
|
|
1571
1657
|
delete o.enabled_clients;
|
|
@@ -1586,7 +1672,7 @@ function pn(e) {
|
|
|
1586
1672
|
}
|
|
1587
1673
|
//#endregion
|
|
1588
1674
|
//#region src/connections/transform.ts
|
|
1589
|
-
function
|
|
1675
|
+
function z(e) {
|
|
1590
1676
|
let { is_system: t, ...n } = e;
|
|
1591
1677
|
return l({
|
|
1592
1678
|
...n,
|
|
@@ -1594,16 +1680,29 @@ function F(e) {
|
|
|
1594
1680
|
options: typeof e.options == "string" ? JSON.parse(e.options) : {}
|
|
1595
1681
|
});
|
|
1596
1682
|
}
|
|
1597
|
-
function
|
|
1598
|
-
return e.map(
|
|
1683
|
+
function hn(e) {
|
|
1684
|
+
return e.map(z);
|
|
1599
1685
|
}
|
|
1600
1686
|
//#endregion
|
|
1601
1687
|
//#region src/connections/list.ts
|
|
1602
|
-
function
|
|
1688
|
+
function gn(e) {
|
|
1603
1689
|
return async (t, n = {}) => {
|
|
1604
1690
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("connections").where("connections.tenant_id", "=", t);
|
|
1605
|
-
s && (c =
|
|
1606
|
-
|
|
1691
|
+
if (s && (c = O(e, c, s, ["user_id", "ip"])), N(n)) {
|
|
1692
|
+
let { rows: e, limit: t, next: r } = await P(c.selectAll(), n, {
|
|
1693
|
+
sortColumn: "created_at",
|
|
1694
|
+
sortOrder: "desc",
|
|
1695
|
+
idColumn: "id"
|
|
1696
|
+
}), i = hn(e);
|
|
1697
|
+
return {
|
|
1698
|
+
connections: i,
|
|
1699
|
+
start: 0,
|
|
1700
|
+
limit: t,
|
|
1701
|
+
length: i.length,
|
|
1702
|
+
next: r
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
let l = hn(await c.offset(r * i).limit(i).selectAll().execute());
|
|
1607
1706
|
if (!a) return {
|
|
1608
1707
|
connections: l,
|
|
1609
1708
|
start: 0,
|
|
@@ -1621,20 +1720,20 @@ function hn(e) {
|
|
|
1621
1720
|
}
|
|
1622
1721
|
//#endregion
|
|
1623
1722
|
//#region src/connections/remove.ts
|
|
1624
|
-
function
|
|
1723
|
+
function _n(e) {
|
|
1625
1724
|
return async (t, n) => (await e.deleteFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1626
1725
|
}
|
|
1627
1726
|
//#endregion
|
|
1628
1727
|
//#region src/connections/get.ts
|
|
1629
|
-
function
|
|
1728
|
+
function vn(e) {
|
|
1630
1729
|
return async (t, n) => {
|
|
1631
1730
|
let r = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "=", n).selectAll().executeTakeFirst();
|
|
1632
|
-
return r ?
|
|
1731
|
+
return r ? z(r) : null;
|
|
1633
1732
|
};
|
|
1634
1733
|
}
|
|
1635
1734
|
//#endregion
|
|
1636
1735
|
//#region src/connections/update.ts
|
|
1637
|
-
function
|
|
1736
|
+
function yn(e) {
|
|
1638
1737
|
return async (t, n, r) => {
|
|
1639
1738
|
let { is_system: i, ...a } = r;
|
|
1640
1739
|
delete a.enabled_clients;
|
|
@@ -1651,18 +1750,18 @@ function vn(e) {
|
|
|
1651
1750
|
}
|
|
1652
1751
|
//#endregion
|
|
1653
1752
|
//#region src/connections/index.ts
|
|
1654
|
-
function
|
|
1753
|
+
function bn(e) {
|
|
1655
1754
|
return {
|
|
1656
|
-
create:
|
|
1657
|
-
get:
|
|
1658
|
-
list:
|
|
1659
|
-
remove:
|
|
1660
|
-
update:
|
|
1755
|
+
create: mn(e),
|
|
1756
|
+
get: vn(e),
|
|
1757
|
+
list: gn(e),
|
|
1758
|
+
remove: _n(e),
|
|
1759
|
+
update: yn(e)
|
|
1661
1760
|
};
|
|
1662
1761
|
}
|
|
1663
1762
|
//#endregion
|
|
1664
1763
|
//#region src/clients/create.ts
|
|
1665
|
-
function
|
|
1764
|
+
function xn(e) {
|
|
1666
1765
|
return async (r, i, a) => {
|
|
1667
1766
|
let o = a?.importMetadata, s = o?.id ?? i.client_id ?? t(), c = (/* @__PURE__ */ new Date()).toISOString(), l = {
|
|
1668
1767
|
...i,
|
|
@@ -1727,7 +1826,7 @@ function bn(e) {
|
|
|
1727
1826
|
}
|
|
1728
1827
|
//#endregion
|
|
1729
1828
|
//#region src/clients/get.ts
|
|
1730
|
-
function
|
|
1829
|
+
function Sn(e) {
|
|
1731
1830
|
return async (t, n) => {
|
|
1732
1831
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).selectAll().executeTakeFirst();
|
|
1733
1832
|
if (!r) return null;
|
|
@@ -1773,7 +1872,7 @@ function xn(e) {
|
|
|
1773
1872
|
}
|
|
1774
1873
|
//#endregion
|
|
1775
1874
|
//#region src/clients/getByClientId.ts
|
|
1776
|
-
function
|
|
1875
|
+
function Cn(e) {
|
|
1777
1876
|
return async (t) => {
|
|
1778
1877
|
let n = await e.selectFrom("clients").where("clients.client_id", "=", t).selectAll().executeTakeFirst();
|
|
1779
1878
|
return n ? l({
|
|
@@ -1817,7 +1916,7 @@ function Sn(e) {
|
|
|
1817
1916
|
}
|
|
1818
1917
|
//#endregion
|
|
1819
1918
|
//#region src/clients/list.ts
|
|
1820
|
-
function
|
|
1919
|
+
function wn(e) {
|
|
1821
1920
|
return l({
|
|
1822
1921
|
...e,
|
|
1823
1922
|
global: !!e.global,
|
|
@@ -1856,7 +1955,7 @@ function Cn(e) {
|
|
|
1856
1955
|
registration_metadata: e.registration_metadata ? JSON.parse(e.registration_metadata) : void 0
|
|
1857
1956
|
});
|
|
1858
1957
|
}
|
|
1859
|
-
function
|
|
1958
|
+
function Tn(e) {
|
|
1860
1959
|
let t = Ce(e);
|
|
1861
1960
|
if (t.length !== 1) return null;
|
|
1862
1961
|
let n = t[0].match(/^([a-zA-Z_][a-zA-Z0-9_]*):(.+)$/);
|
|
@@ -1867,22 +1966,22 @@ function wn(e) {
|
|
|
1867
1966
|
value: r
|
|
1868
1967
|
} : null;
|
|
1869
1968
|
}
|
|
1870
|
-
function
|
|
1969
|
+
function En(e) {
|
|
1871
1970
|
return async (t, n) => {
|
|
1872
1971
|
let r = e.selectFrom("clients").where("clients.tenant_id", "=", t), i = new Set(["owner_user_id", "registration_type"]);
|
|
1873
1972
|
if (n?.q) {
|
|
1874
|
-
let e =
|
|
1973
|
+
let e = Tn(n.q);
|
|
1875
1974
|
if (e && i.has(e.field)) {
|
|
1876
1975
|
let t = e.field;
|
|
1877
1976
|
r = r.where(t, "=", e.value);
|
|
1878
1977
|
} else r = r.where((e) => e.or([e("name", "like", `%${n.q}%`), e("client_id", "like", `%${n.q}%`)]));
|
|
1879
1978
|
}
|
|
1880
|
-
if (
|
|
1881
|
-
let { rows: e, limit: t, next: i } = await
|
|
1979
|
+
if (N(n)) {
|
|
1980
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
1882
1981
|
sortColumn: "created_at",
|
|
1883
1982
|
sortOrder: "desc",
|
|
1884
1983
|
idColumn: "client_id"
|
|
1885
|
-
}), a = e.map(
|
|
1984
|
+
}), a = e.map(wn);
|
|
1886
1985
|
return {
|
|
1887
1986
|
clients: a,
|
|
1888
1987
|
totals: {
|
|
@@ -1906,7 +2005,7 @@ function Tn(e) {
|
|
|
1906
2005
|
if (n?.include_totals) {
|
|
1907
2006
|
let r = e.selectFrom("clients").select(f`count(*)`.as("count")).where("clients.tenant_id", "=", t);
|
|
1908
2007
|
if (n?.q) {
|
|
1909
|
-
let e =
|
|
2008
|
+
let e = Tn(n.q);
|
|
1910
2009
|
if (e && i.has(e.field)) {
|
|
1911
2010
|
let t = e.field;
|
|
1912
2011
|
r = r.where(t, "=", e.value);
|
|
@@ -1915,7 +2014,7 @@ function Tn(e) {
|
|
|
1915
2014
|
let a = await r.executeTakeFirst();
|
|
1916
2015
|
c = Number(a?.count || 0);
|
|
1917
2016
|
}
|
|
1918
|
-
let l = s.map(
|
|
2017
|
+
let l = s.map(wn);
|
|
1919
2018
|
return {
|
|
1920
2019
|
clients: l,
|
|
1921
2020
|
totals: {
|
|
@@ -1929,12 +2028,12 @@ function Tn(e) {
|
|
|
1929
2028
|
}
|
|
1930
2029
|
//#endregion
|
|
1931
2030
|
//#region src/clients/remove.ts
|
|
1932
|
-
function
|
|
2031
|
+
function Dn(e) {
|
|
1933
2032
|
return async (t, n) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
1934
2033
|
}
|
|
1935
2034
|
//#endregion
|
|
1936
2035
|
//#region src/clients/update.ts
|
|
1937
|
-
function
|
|
2036
|
+
function On(e) {
|
|
1938
2037
|
return async (t, r, i) => {
|
|
1939
2038
|
let a = {
|
|
1940
2039
|
...i,
|
|
@@ -1981,31 +2080,31 @@ function Dn(e) {
|
|
|
1981
2080
|
}
|
|
1982
2081
|
//#endregion
|
|
1983
2082
|
//#region src/clients/index.ts
|
|
1984
|
-
function
|
|
2083
|
+
function kn(e) {
|
|
1985
2084
|
return {
|
|
1986
|
-
create:
|
|
1987
|
-
get:
|
|
1988
|
-
getByClientId:
|
|
1989
|
-
list:
|
|
1990
|
-
remove:
|
|
1991
|
-
update:
|
|
2085
|
+
create: xn(e),
|
|
2086
|
+
get: Sn(e),
|
|
2087
|
+
getByClientId: Cn(e),
|
|
2088
|
+
list: En(e),
|
|
2089
|
+
remove: Dn(e),
|
|
2090
|
+
update: On(e)
|
|
1992
2091
|
};
|
|
1993
2092
|
}
|
|
1994
2093
|
//#endregion
|
|
1995
2094
|
//#region src/clientConnections/listByClient.ts
|
|
1996
|
-
function
|
|
2095
|
+
function An(e) {
|
|
1997
2096
|
return async (t, n) => {
|
|
1998
2097
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", n).select("connections").executeTakeFirst();
|
|
1999
2098
|
if (!r) return [];
|
|
2000
2099
|
let i = JSON.parse(r.connections || "[]");
|
|
2001
2100
|
if (i.length === 0) return [];
|
|
2002
|
-
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id,
|
|
2101
|
+
let a = await e.selectFrom("connections").where("connections.tenant_id", "=", t).where("connections.id", "in", i).selectAll().execute(), o = new Map(a.map((e) => [e.id, z(e)]));
|
|
2003
2102
|
return i.map((e) => o.get(e)).filter((e) => e !== void 0);
|
|
2004
2103
|
};
|
|
2005
2104
|
}
|
|
2006
2105
|
//#endregion
|
|
2007
2106
|
//#region src/clientConnections/updateByClient.ts
|
|
2008
|
-
function
|
|
2107
|
+
function jn(e) {
|
|
2009
2108
|
return async (t, n, r) => (await e.updateTable("clients").set({
|
|
2010
2109
|
connections: JSON.stringify(r),
|
|
2011
2110
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -2013,7 +2112,7 @@ function An(e) {
|
|
|
2013
2112
|
}
|
|
2014
2113
|
//#endregion
|
|
2015
2114
|
//#region src/clientConnections/listByConnection.ts
|
|
2016
|
-
function
|
|
2115
|
+
function Mn(e) {
|
|
2017
2116
|
return async (t, n) => {
|
|
2018
2117
|
let r = await e.selectFrom("clients").where("clients.tenant_id", "=", t).select(["client_id", "connections"]).execute(), i = [];
|
|
2019
2118
|
for (let e of r) JSON.parse(e.connections || "[]").includes(n) && i.push(e.client_id);
|
|
@@ -2022,7 +2121,7 @@ function jn(e) {
|
|
|
2022
2121
|
}
|
|
2023
2122
|
//#endregion
|
|
2024
2123
|
//#region src/clientConnections/addClientToConnection.ts
|
|
2025
|
-
function
|
|
2124
|
+
function Nn(e) {
|
|
2026
2125
|
return async (t, n, r) => {
|
|
2027
2126
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2028
2127
|
if (!i) return !1;
|
|
@@ -2035,7 +2134,7 @@ function Mn(e) {
|
|
|
2035
2134
|
}
|
|
2036
2135
|
//#endregion
|
|
2037
2136
|
//#region src/clientConnections/removeClientFromConnection.ts
|
|
2038
|
-
function
|
|
2137
|
+
function Pn(e) {
|
|
2039
2138
|
return async (t, n, r) => {
|
|
2040
2139
|
let i = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", r).select("connections").executeTakeFirst();
|
|
2041
2140
|
if (!i) return !1;
|
|
@@ -2048,18 +2147,18 @@ function Nn(e) {
|
|
|
2048
2147
|
}
|
|
2049
2148
|
//#endregion
|
|
2050
2149
|
//#region src/clientConnections/index.ts
|
|
2051
|
-
function
|
|
2150
|
+
function Fn(e) {
|
|
2052
2151
|
return {
|
|
2053
|
-
listByClient:
|
|
2054
|
-
updateByClient:
|
|
2055
|
-
listByConnection:
|
|
2056
|
-
addClientToConnection:
|
|
2057
|
-
removeClientFromConnection:
|
|
2152
|
+
listByClient: An(e),
|
|
2153
|
+
updateByClient: jn(e),
|
|
2154
|
+
listByConnection: Mn(e),
|
|
2155
|
+
addClientToConnection: Nn(e),
|
|
2156
|
+
removeClientFromConnection: Pn(e)
|
|
2058
2157
|
};
|
|
2059
2158
|
}
|
|
2060
2159
|
//#endregion
|
|
2061
2160
|
//#region src/clientGrants/create.ts
|
|
2062
|
-
function
|
|
2161
|
+
function In(e) {
|
|
2063
2162
|
return async (n, r, i) => {
|
|
2064
2163
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? t(), c = a?.created_at ?? o, u = a?.updated_at ?? a?.created_at ?? o, { scope: d, authorization_details_types: f, ...p } = r, m = {
|
|
2065
2164
|
id: s,
|
|
@@ -2087,7 +2186,7 @@ function Fn(e) {
|
|
|
2087
2186
|
}
|
|
2088
2187
|
//#endregion
|
|
2089
2188
|
//#region src/clientGrants/get.ts
|
|
2090
|
-
function
|
|
2189
|
+
function Ln(e) {
|
|
2091
2190
|
return async (t, n) => {
|
|
2092
2191
|
let r = await e.selectFrom("client_grants").selectAll().where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst();
|
|
2093
2192
|
return r ? l({
|
|
@@ -2107,7 +2206,7 @@ function In(e) {
|
|
|
2107
2206
|
}
|
|
2108
2207
|
//#endregion
|
|
2109
2208
|
//#region src/clientGrants/list.ts
|
|
2110
|
-
function
|
|
2209
|
+
function Rn(e) {
|
|
2111
2210
|
return v.parse(l({
|
|
2112
2211
|
...e,
|
|
2113
2212
|
scope: e.scope ? JSON.parse(e.scope) : [],
|
|
@@ -2116,7 +2215,7 @@ function Ln(e) {
|
|
|
2116
2215
|
authorization_details_types: e.authorization_details_types ? JSON.parse(e.authorization_details_types) : []
|
|
2117
2216
|
}));
|
|
2118
2217
|
}
|
|
2119
|
-
function
|
|
2218
|
+
function zn(e) {
|
|
2120
2219
|
return async (t, n = {}) => {
|
|
2121
2220
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s, sort: c } = n, l = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
|
|
2122
2221
|
if (s) {
|
|
@@ -2127,13 +2226,13 @@ function Rn(e) {
|
|
|
2127
2226
|
let e = +(a === "true");
|
|
2128
2227
|
l = l.where(o, t ? "!=" : "=", e);
|
|
2129
2228
|
} else l = l.where(o, t ? "!=" : "=", a);
|
|
2130
|
-
} else l =
|
|
2229
|
+
} else l = O(e, l, t, []);
|
|
2131
2230
|
}
|
|
2132
|
-
if (
|
|
2133
|
-
let { rows: e, limit: t, next: r } = await
|
|
2231
|
+
if (N(n)) {
|
|
2232
|
+
let { rows: e, limit: t, next: r } = await P(l.selectAll(), n, {
|
|
2134
2233
|
sortColumn: "created_at",
|
|
2135
2234
|
sortOrder: "desc"
|
|
2136
|
-
}), i = e.map(
|
|
2235
|
+
}), i = e.map(Rn);
|
|
2137
2236
|
return {
|
|
2138
2237
|
client_grants: i,
|
|
2139
2238
|
start: 0,
|
|
@@ -2146,8 +2245,8 @@ function Rn(e) {
|
|
|
2146
2245
|
if (c) {
|
|
2147
2246
|
let { ref: t } = e.dynamic;
|
|
2148
2247
|
u = u.orderBy(t(c.sort_by), c.sort_order);
|
|
2149
|
-
} else u = u.orderBy("client_grants.created_at", "desc");
|
|
2150
|
-
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(
|
|
2248
|
+
} else u = u.orderBy("client_grants.created_at", "desc").orderBy("client_grants.id", "desc");
|
|
2249
|
+
let d = (await u.selectAll().limit(i).offset(r * i).execute()).map(Rn);
|
|
2151
2250
|
if (!a) return {
|
|
2152
2251
|
client_grants: d,
|
|
2153
2252
|
start: 0,
|
|
@@ -2165,12 +2264,12 @@ function Rn(e) {
|
|
|
2165
2264
|
}
|
|
2166
2265
|
//#endregion
|
|
2167
2266
|
//#region src/clientGrants/remove.ts
|
|
2168
|
-
function
|
|
2267
|
+
function Bn(e) {
|
|
2169
2268
|
return async (t, n) => ((await e.deleteFrom("client_grants").where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", n).executeTakeFirst()).numDeletedRows ?? 0n) > 0n;
|
|
2170
2269
|
}
|
|
2171
2270
|
//#endregion
|
|
2172
2271
|
//#region src/clientGrants/update.ts
|
|
2173
|
-
function
|
|
2272
|
+
function Vn(e) {
|
|
2174
2273
|
return async (t, n, r) => {
|
|
2175
2274
|
let i = (/* @__PURE__ */ new Date()).toISOString(), { scope: a, authorization_details_types: o, ...s } = r, c = {
|
|
2176
2275
|
...s,
|
|
@@ -2181,18 +2280,18 @@ function Bn(e) {
|
|
|
2181
2280
|
}
|
|
2182
2281
|
//#endregion
|
|
2183
2282
|
//#region src/clientGrants/index.ts
|
|
2184
|
-
function
|
|
2283
|
+
function Hn(e) {
|
|
2185
2284
|
return {
|
|
2186
|
-
create:
|
|
2187
|
-
get:
|
|
2188
|
-
list:
|
|
2189
|
-
remove:
|
|
2190
|
-
update:
|
|
2285
|
+
create: In(e),
|
|
2286
|
+
get: Ln(e),
|
|
2287
|
+
list: zn(e),
|
|
2288
|
+
remove: Bn(e),
|
|
2289
|
+
update: Vn(e)
|
|
2191
2290
|
};
|
|
2192
2291
|
}
|
|
2193
2292
|
//#endregion
|
|
2194
2293
|
//#region src/clientRegistrationTokens/create.ts
|
|
2195
|
-
function
|
|
2294
|
+
function Un(e) {
|
|
2196
2295
|
return async (t, n) => {
|
|
2197
2296
|
let r = Date.now();
|
|
2198
2297
|
return await e.insertInto("client_registration_tokens").values({
|
|
@@ -2223,12 +2322,12 @@ function Hn(e) {
|
|
|
2223
2322
|
}
|
|
2224
2323
|
//#endregion
|
|
2225
2324
|
//#region src/clientRegistrationTokens/row-mapper.ts
|
|
2226
|
-
function
|
|
2325
|
+
function Wn(e) {
|
|
2227
2326
|
let t = y.safeParse(e);
|
|
2228
2327
|
if (!t.success) throw Error(`Unknown client_registration_tokens.type: ${e}`);
|
|
2229
2328
|
return t.data;
|
|
2230
2329
|
}
|
|
2231
|
-
function
|
|
2330
|
+
function Gn(e) {
|
|
2232
2331
|
if (!e) return;
|
|
2233
2332
|
let t;
|
|
2234
2333
|
try {
|
|
@@ -2238,14 +2337,14 @@ function Wn(e) {
|
|
|
2238
2337
|
}
|
|
2239
2338
|
return oe(t) ? t : void 0;
|
|
2240
2339
|
}
|
|
2241
|
-
function
|
|
2340
|
+
function B(e) {
|
|
2242
2341
|
return {
|
|
2243
2342
|
id: e.id,
|
|
2244
2343
|
token_hash: e.token_hash,
|
|
2245
|
-
type:
|
|
2344
|
+
type: Wn(e.type),
|
|
2246
2345
|
client_id: e.client_id ?? void 0,
|
|
2247
2346
|
sub: e.sub ?? void 0,
|
|
2248
|
-
constraints:
|
|
2347
|
+
constraints: Gn(e.constraints),
|
|
2249
2348
|
single_use: !!e.single_use,
|
|
2250
2349
|
expires_at: i(e.expires_at_ts),
|
|
2251
2350
|
used_at: i(e.used_at_ts),
|
|
@@ -2255,38 +2354,38 @@ function I(e) {
|
|
|
2255
2354
|
}
|
|
2256
2355
|
//#endregion
|
|
2257
2356
|
//#region src/clientRegistrationTokens/get.ts
|
|
2258
|
-
function
|
|
2357
|
+
function Kn(e) {
|
|
2259
2358
|
return async (t, n) => {
|
|
2260
2359
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
2261
|
-
return r ?
|
|
2360
|
+
return r ? B(r) : null;
|
|
2262
2361
|
};
|
|
2263
2362
|
}
|
|
2264
2363
|
//#endregion
|
|
2265
2364
|
//#region src/clientRegistrationTokens/getByHash.ts
|
|
2266
|
-
function
|
|
2365
|
+
function qn(e) {
|
|
2267
2366
|
return async (t, n) => {
|
|
2268
2367
|
let r = await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
2269
|
-
return r ?
|
|
2368
|
+
return r ? B(r) : null;
|
|
2270
2369
|
};
|
|
2271
2370
|
}
|
|
2272
2371
|
//#endregion
|
|
2273
2372
|
//#region src/clientRegistrationTokens/listByClient.ts
|
|
2274
|
-
function
|
|
2275
|
-
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(
|
|
2373
|
+
function Jn(e) {
|
|
2374
|
+
return async (t, n) => (await e.selectFrom("client_registration_tokens").where("tenant_id", "=", t).where("client_id", "=", n).orderBy("created_at_ts", "desc").selectAll().execute()).map(B);
|
|
2276
2375
|
}
|
|
2277
2376
|
//#endregion
|
|
2278
2377
|
//#region src/clientRegistrationTokens/markUsed.ts
|
|
2279
|
-
function
|
|
2378
|
+
function Yn(e) {
|
|
2280
2379
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ used_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("used_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2281
2380
|
}
|
|
2282
2381
|
//#endregion
|
|
2283
2382
|
//#region src/clientRegistrationTokens/revoke.ts
|
|
2284
|
-
function
|
|
2383
|
+
function Xn(e) {
|
|
2285
2384
|
return async (t, n, r) => (await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst()).numUpdatedRows > 0;
|
|
2286
2385
|
}
|
|
2287
2386
|
//#endregion
|
|
2288
2387
|
//#region src/clientRegistrationTokens/revokeByClient.ts
|
|
2289
|
-
function
|
|
2388
|
+
function Zn(e) {
|
|
2290
2389
|
return async (t, n, r) => {
|
|
2291
2390
|
let i = await e.updateTable("client_registration_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("client_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
2292
2391
|
return Number(i.numUpdatedRows);
|
|
@@ -2294,29 +2393,29 @@ function Xn(e) {
|
|
|
2294
2393
|
}
|
|
2295
2394
|
//#endregion
|
|
2296
2395
|
//#region src/clientRegistrationTokens/remove.ts
|
|
2297
|
-
function
|
|
2396
|
+
function Qn(e) {
|
|
2298
2397
|
return async (t, n) => (await e.deleteFrom("client_registration_tokens").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2299
2398
|
}
|
|
2300
2399
|
//#endregion
|
|
2301
2400
|
//#region src/clientRegistrationTokens/index.ts
|
|
2302
|
-
function
|
|
2401
|
+
function $n(e) {
|
|
2303
2402
|
return {
|
|
2304
|
-
create:
|
|
2305
|
-
get:
|
|
2306
|
-
getByHash:
|
|
2307
|
-
listByClient:
|
|
2308
|
-
markUsed:
|
|
2309
|
-
revoke:
|
|
2310
|
-
revokeByClient:
|
|
2311
|
-
remove:
|
|
2403
|
+
create: Un(e),
|
|
2404
|
+
get: Kn(e),
|
|
2405
|
+
getByHash: qn(e),
|
|
2406
|
+
listByClient: Jn(e),
|
|
2407
|
+
markUsed: Yn(e),
|
|
2408
|
+
revoke: Xn(e),
|
|
2409
|
+
revokeByClient: Zn(e),
|
|
2410
|
+
remove: Qn(e)
|
|
2312
2411
|
};
|
|
2313
2412
|
}
|
|
2314
2413
|
//#endregion
|
|
2315
2414
|
//#region src/keys/list.ts
|
|
2316
|
-
function
|
|
2415
|
+
function er(e) {
|
|
2317
2416
|
return async (t = {}) => {
|
|
2318
2417
|
let { page: n = 0, per_page: r = 100, include_totals: i = !1, sort: a, q: s } = t, c = e.selectFrom("keys").where((e) => e.or([e("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()), e("revoked_at", "is", null)]));
|
|
2319
|
-
s && (c =
|
|
2418
|
+
s && (c = O(e, c, s, [
|
|
2320
2419
|
"kid",
|
|
2321
2420
|
"tenant_id",
|
|
2322
2421
|
"connection",
|
|
@@ -2342,7 +2441,7 @@ function $n(e) {
|
|
|
2342
2441
|
}
|
|
2343
2442
|
//#endregion
|
|
2344
2443
|
//#region src/keys/create.ts
|
|
2345
|
-
function
|
|
2444
|
+
function tr(e) {
|
|
2346
2445
|
return async (t, n) => {
|
|
2347
2446
|
let r = n?.importMetadata;
|
|
2348
2447
|
await e.insertInto("keys").values({
|
|
@@ -2354,21 +2453,21 @@ function er(e) {
|
|
|
2354
2453
|
}
|
|
2355
2454
|
//#endregion
|
|
2356
2455
|
//#region src/keys/update.ts
|
|
2357
|
-
function
|
|
2456
|
+
function nr(e) {
|
|
2358
2457
|
return async (t, n) => !!(await e.updateTable("keys").set(n).where("kid", "=", t).execute()).length;
|
|
2359
2458
|
}
|
|
2360
2459
|
//#endregion
|
|
2361
2460
|
//#region src/keys/index.ts
|
|
2362
|
-
function
|
|
2461
|
+
function rr(e) {
|
|
2363
2462
|
return {
|
|
2364
|
-
create:
|
|
2365
|
-
list:
|
|
2366
|
-
update:
|
|
2463
|
+
create: tr(e),
|
|
2464
|
+
list: er(e),
|
|
2465
|
+
update: nr(e)
|
|
2367
2466
|
};
|
|
2368
2467
|
}
|
|
2369
2468
|
//#endregion
|
|
2370
2469
|
//#region src/customDomains/create.ts
|
|
2371
|
-
function
|
|
2470
|
+
function ir(e) {
|
|
2372
2471
|
return async (n, r, i) => {
|
|
2373
2472
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
2374
2473
|
status: "pending",
|
|
@@ -2389,35 +2488,35 @@ function rr(e) {
|
|
|
2389
2488
|
}
|
|
2390
2489
|
//#endregion
|
|
2391
2490
|
//#region src/customDomains/list.ts
|
|
2392
|
-
function
|
|
2491
|
+
function ar(e) {
|
|
2393
2492
|
return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((e) => ({
|
|
2394
2493
|
...e,
|
|
2395
2494
|
primary: e.primary === 1,
|
|
2396
|
-
domain_metadata:
|
|
2397
|
-
verification:
|
|
2495
|
+
domain_metadata: I(e.domain_metadata, void 0),
|
|
2496
|
+
verification: I(e.verification, void 0)
|
|
2398
2497
|
}));
|
|
2399
2498
|
}
|
|
2400
2499
|
//#endregion
|
|
2401
2500
|
//#region src/customDomains/remove.ts
|
|
2402
|
-
function
|
|
2501
|
+
function or(e) {
|
|
2403
2502
|
return async (t, n) => (await e.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).execute()).length > 0;
|
|
2404
2503
|
}
|
|
2405
2504
|
//#endregion
|
|
2406
2505
|
//#region src/customDomains/get.ts
|
|
2407
|
-
function
|
|
2506
|
+
function sr(e) {
|
|
2408
2507
|
return async (t, n) => {
|
|
2409
2508
|
let r = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", n).selectAll().executeTakeFirst();
|
|
2410
2509
|
return r ? {
|
|
2411
2510
|
...r,
|
|
2412
2511
|
primary: r.primary === 1,
|
|
2413
|
-
domain_metadata:
|
|
2414
|
-
verification:
|
|
2512
|
+
domain_metadata: I(r.domain_metadata, void 0),
|
|
2513
|
+
verification: I(r.verification, void 0)
|
|
2415
2514
|
} : null;
|
|
2416
2515
|
};
|
|
2417
2516
|
}
|
|
2418
2517
|
//#endregion
|
|
2419
2518
|
//#region src/customDomains/update.ts
|
|
2420
|
-
function
|
|
2519
|
+
function cr(e) {
|
|
2421
2520
|
return async (t, n, r) => {
|
|
2422
2521
|
let { verification: i, domain_metadata: a, primary: o, ...s } = r, c = {
|
|
2423
2522
|
...s,
|
|
@@ -2431,32 +2530,32 @@ function sr(e) {
|
|
|
2431
2530
|
}
|
|
2432
2531
|
//#endregion
|
|
2433
2532
|
//#region src/customDomains/getByDomain.ts
|
|
2434
|
-
function
|
|
2533
|
+
function lr(e) {
|
|
2435
2534
|
return async (t) => {
|
|
2436
2535
|
let n = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
|
|
2437
2536
|
return n ? {
|
|
2438
2537
|
...n,
|
|
2439
2538
|
primary: n.primary === 1,
|
|
2440
|
-
domain_metadata:
|
|
2441
|
-
verification:
|
|
2539
|
+
domain_metadata: I(n.domain_metadata, void 0),
|
|
2540
|
+
verification: I(n.verification, void 0)
|
|
2442
2541
|
} : null;
|
|
2443
2542
|
};
|
|
2444
2543
|
}
|
|
2445
2544
|
//#endregion
|
|
2446
2545
|
//#region src/customDomains/index.ts
|
|
2447
|
-
function
|
|
2546
|
+
function ur(e) {
|
|
2448
2547
|
return {
|
|
2449
|
-
create:
|
|
2450
|
-
get:
|
|
2451
|
-
getByDomain:
|
|
2452
|
-
list:
|
|
2453
|
-
remove:
|
|
2454
|
-
update:
|
|
2548
|
+
create: ir(e),
|
|
2549
|
+
get: sr(e),
|
|
2550
|
+
getByDomain: lr(e),
|
|
2551
|
+
list: ar(e),
|
|
2552
|
+
remove: or(e),
|
|
2553
|
+
update: cr(e)
|
|
2455
2554
|
};
|
|
2456
2555
|
}
|
|
2457
2556
|
//#endregion
|
|
2458
2557
|
//#region src/branding/get.ts
|
|
2459
|
-
function
|
|
2558
|
+
function dr(e) {
|
|
2460
2559
|
return async (t) => {
|
|
2461
2560
|
let [n] = await e.selectFrom("branding").where("branding.tenant_id", "=", t).selectAll().execute();
|
|
2462
2561
|
if (!n) return null;
|
|
@@ -2478,7 +2577,7 @@ function ur(e) {
|
|
|
2478
2577
|
}
|
|
2479
2578
|
//#endregion
|
|
2480
2579
|
//#region src/branding/set.ts
|
|
2481
|
-
function
|
|
2580
|
+
function fr(e) {
|
|
2482
2581
|
return async (t, n) => {
|
|
2483
2582
|
let { colors: r, font: i, ...a } = n, o = r?.page_background, s = o && typeof o == "object" ? o : void 0;
|
|
2484
2583
|
try {
|
|
@@ -2507,15 +2606,15 @@ function dr(e) {
|
|
|
2507
2606
|
}
|
|
2508
2607
|
//#endregion
|
|
2509
2608
|
//#region src/branding/index.ts
|
|
2510
|
-
function
|
|
2609
|
+
function pr(e) {
|
|
2511
2610
|
return {
|
|
2512
|
-
get:
|
|
2513
|
-
set:
|
|
2611
|
+
get: dr(e),
|
|
2612
|
+
set: fr(e)
|
|
2514
2613
|
};
|
|
2515
2614
|
}
|
|
2516
2615
|
//#endregion
|
|
2517
2616
|
//#region src/universalLoginTemplates/get.ts
|
|
2518
|
-
function
|
|
2617
|
+
function mr(e) {
|
|
2519
2618
|
return async (t) => {
|
|
2520
2619
|
let n = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
|
|
2521
2620
|
return n ? { body: n.body } : null;
|
|
@@ -2523,7 +2622,7 @@ function pr(e) {
|
|
|
2523
2622
|
}
|
|
2524
2623
|
//#endregion
|
|
2525
2624
|
//#region src/universalLoginTemplates/set.ts
|
|
2526
|
-
function
|
|
2625
|
+
function hr(e) {
|
|
2527
2626
|
return async (t, n, r) => {
|
|
2528
2627
|
let i = r?.importMetadata, a = Date.now(), o = i?.created_at ? new Date(i.created_at).getTime() : a, s = i?.updated_at ? new Date(i.updated_at).getTime() : a;
|
|
2529
2628
|
try {
|
|
@@ -2544,26 +2643,26 @@ function mr(e) {
|
|
|
2544
2643
|
}
|
|
2545
2644
|
//#endregion
|
|
2546
2645
|
//#region src/universalLoginTemplates/delete.ts
|
|
2547
|
-
function
|
|
2646
|
+
function gr(e) {
|
|
2548
2647
|
return async (t) => {
|
|
2549
2648
|
await e.deleteFrom("universal_login_templates").where("tenant_id", "=", t).execute();
|
|
2550
2649
|
};
|
|
2551
2650
|
}
|
|
2552
2651
|
//#endregion
|
|
2553
2652
|
//#region src/universalLoginTemplates/index.ts
|
|
2554
|
-
function
|
|
2653
|
+
function _r(e) {
|
|
2555
2654
|
return {
|
|
2556
|
-
get:
|
|
2557
|
-
set:
|
|
2558
|
-
delete:
|
|
2655
|
+
get: mr(e),
|
|
2656
|
+
set: hr(e),
|
|
2657
|
+
delete: gr(e)
|
|
2559
2658
|
};
|
|
2560
2659
|
}
|
|
2561
2660
|
//#endregion
|
|
2562
2661
|
//#region src/hooks/list.ts
|
|
2563
|
-
function
|
|
2662
|
+
function vr(e) {
|
|
2564
2663
|
return async (t, n = {}) => {
|
|
2565
2664
|
let { page: i = 0, per_page: a = 50, include_totals: s = !1, sort: c, q: u } = n, d = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
|
|
2566
|
-
if (u && (d =
|
|
2665
|
+
if (u && (d = O(e, d, u, [
|
|
2567
2666
|
"url",
|
|
2568
2667
|
"form_id",
|
|
2569
2668
|
"template_id",
|
|
@@ -2602,7 +2701,7 @@ function _r(e) {
|
|
|
2602
2701
|
}
|
|
2603
2702
|
//#endregion
|
|
2604
2703
|
//#region src/hooks/get.ts
|
|
2605
|
-
function
|
|
2704
|
+
function yr(e) {
|
|
2606
2705
|
return async (t, n) => {
|
|
2607
2706
|
let i = await e.selectFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
|
|
2608
2707
|
if (!i) return null;
|
|
@@ -2621,12 +2720,12 @@ function vr(e) {
|
|
|
2621
2720
|
}
|
|
2622
2721
|
//#endregion
|
|
2623
2722
|
//#region src/hooks/remove.ts
|
|
2624
|
-
function
|
|
2723
|
+
function br(e) {
|
|
2625
2724
|
return async (t, n) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2626
2725
|
}
|
|
2627
2726
|
//#endregion
|
|
2628
2727
|
//#region src/hooks/create.ts
|
|
2629
|
-
function
|
|
2728
|
+
function xr(e) {
|
|
2630
2729
|
return async (t, n, r) => {
|
|
2631
2730
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? (n.hook_id || Ne()), { hook_id: l, enabled: u, synchronous: d, metadata: f, ...p } = n;
|
|
2632
2731
|
return await e.insertInto("hooks").values({
|
|
@@ -2651,7 +2750,7 @@ function br(e) {
|
|
|
2651
2750
|
}
|
|
2652
2751
|
//#endregion
|
|
2653
2752
|
//#region src/hooks/update.ts
|
|
2654
|
-
function
|
|
2753
|
+
function Sr(e) {
|
|
2655
2754
|
return async (t, n, r) => {
|
|
2656
2755
|
let { hook_id: i, metadata: a, ...o } = r, s = {
|
|
2657
2756
|
...o,
|
|
@@ -2665,18 +2764,18 @@ function xr(e) {
|
|
|
2665
2764
|
}
|
|
2666
2765
|
//#endregion
|
|
2667
2766
|
//#region src/hooks/index.ts
|
|
2668
|
-
function
|
|
2767
|
+
function Cr(e) {
|
|
2669
2768
|
return {
|
|
2670
|
-
create:
|
|
2671
|
-
get:
|
|
2672
|
-
list:
|
|
2673
|
-
update:
|
|
2674
|
-
remove:
|
|
2769
|
+
create: xr(e),
|
|
2770
|
+
get: yr(e),
|
|
2771
|
+
list: vr(e),
|
|
2772
|
+
update: Sr(e),
|
|
2773
|
+
remove: br(e)
|
|
2675
2774
|
};
|
|
2676
2775
|
}
|
|
2677
2776
|
//#endregion
|
|
2678
2777
|
//#region src/hook-code/create.ts
|
|
2679
|
-
function
|
|
2778
|
+
function wr(e) {
|
|
2680
2779
|
return async (t, n, r) => {
|
|
2681
2780
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = i?.id ?? Fe();
|
|
2682
2781
|
return await e.insertInto("hook_code").values({
|
|
@@ -2698,7 +2797,7 @@ function Cr(e) {
|
|
|
2698
2797
|
}
|
|
2699
2798
|
//#endregion
|
|
2700
2799
|
//#region src/hook-code/get.ts
|
|
2701
|
-
function
|
|
2800
|
+
function Tr(e) {
|
|
2702
2801
|
return async (t, n) => {
|
|
2703
2802
|
let i = await e.selectFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).selectAll().executeTakeFirst();
|
|
2704
2803
|
if (!i) return null;
|
|
@@ -2722,7 +2821,7 @@ function wr(e) {
|
|
|
2722
2821
|
}
|
|
2723
2822
|
//#endregion
|
|
2724
2823
|
//#region src/hook-code/update.ts
|
|
2725
|
-
function
|
|
2824
|
+
function Er(e) {
|
|
2726
2825
|
return async (t, n, r) => {
|
|
2727
2826
|
let i = { updated_at_ts: Date.now() };
|
|
2728
2827
|
return r.code !== void 0 && (i.code = r.code), r.secrets !== void 0 && (i.secrets = JSON.stringify(r.secrets)), (await e.updateTable("hook_code").set(i).where("hook_code.id", "=", n).where("hook_code.tenant_id", "=", t).executeTakeFirst()).numUpdatedRows > 0;
|
|
@@ -2730,22 +2829,22 @@ function Tr(e) {
|
|
|
2730
2829
|
}
|
|
2731
2830
|
//#endregion
|
|
2732
2831
|
//#region src/hook-code/remove.ts
|
|
2733
|
-
function
|
|
2832
|
+
function Dr(e) {
|
|
2734
2833
|
return async (t, n) => (await e.deleteFrom("hook_code").where("hook_code.tenant_id", "=", t).where("hook_code.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2735
2834
|
}
|
|
2736
2835
|
//#endregion
|
|
2737
2836
|
//#region src/hook-code/index.ts
|
|
2738
|
-
function
|
|
2837
|
+
function Or(e) {
|
|
2739
2838
|
return {
|
|
2740
|
-
create:
|
|
2741
|
-
get:
|
|
2742
|
-
update:
|
|
2743
|
-
remove:
|
|
2839
|
+
create: wr(e),
|
|
2840
|
+
get: Tr(e),
|
|
2841
|
+
update: Er(e),
|
|
2842
|
+
remove: Dr(e)
|
|
2744
2843
|
};
|
|
2745
2844
|
}
|
|
2746
2845
|
//#endregion
|
|
2747
2846
|
//#region src/themes/create.ts
|
|
2748
|
-
function
|
|
2847
|
+
function kr(e) {
|
|
2749
2848
|
return async (n, r, i, a) => {
|
|
2750
2849
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
2751
2850
|
themeId: o?.id || i || t(),
|
|
@@ -2756,17 +2855,17 @@ function Or(e) {
|
|
|
2756
2855
|
...c,
|
|
2757
2856
|
tenant_id: n
|
|
2758
2857
|
};
|
|
2759
|
-
return await e.insertInto("themes").values(
|
|
2858
|
+
return await e.insertInto("themes").values(F(l)).execute(), c;
|
|
2760
2859
|
};
|
|
2761
2860
|
}
|
|
2762
2861
|
//#endregion
|
|
2763
2862
|
//#region src/themes/remove.ts
|
|
2764
|
-
function
|
|
2863
|
+
function Ar(e) {
|
|
2765
2864
|
return async (t, n) => (await e.deleteFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
2766
2865
|
}
|
|
2767
2866
|
//#endregion
|
|
2768
2867
|
//#region src/themes/get.ts
|
|
2769
|
-
function
|
|
2868
|
+
function jr(e) {
|
|
2770
2869
|
return async (t, n) => {
|
|
2771
2870
|
let r = await e.selectFrom("themes").where("themes.tenant_id", "=", t).where("themes.themeId", "=", n).selectAll().executeTakeFirst();
|
|
2772
2871
|
return r ? l(ht({
|
|
@@ -2789,9 +2888,9 @@ function Ar(e) {
|
|
|
2789
2888
|
}
|
|
2790
2889
|
//#endregion
|
|
2791
2890
|
//#region src/themes/update.ts
|
|
2792
|
-
function
|
|
2891
|
+
function Mr(e) {
|
|
2793
2892
|
return async (t, n, r) => {
|
|
2794
|
-
let { themeId: i, ...a } = r, o =
|
|
2893
|
+
let { themeId: i, ...a } = r, o = F({
|
|
2795
2894
|
...a,
|
|
2796
2895
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2797
2896
|
});
|
|
@@ -2800,17 +2899,17 @@ function jr(e) {
|
|
|
2800
2899
|
}
|
|
2801
2900
|
//#endregion
|
|
2802
2901
|
//#region src/themes/index.ts
|
|
2803
|
-
function
|
|
2902
|
+
function Nr(e) {
|
|
2804
2903
|
return {
|
|
2805
|
-
create:
|
|
2806
|
-
get:
|
|
2807
|
-
remove:
|
|
2808
|
-
update:
|
|
2904
|
+
create: kr(e),
|
|
2905
|
+
get: jr(e),
|
|
2906
|
+
remove: Ar(e),
|
|
2907
|
+
update: Mr(e)
|
|
2809
2908
|
};
|
|
2810
2909
|
}
|
|
2811
2910
|
//#endregion
|
|
2812
2911
|
//#region src/loginSessions/get.ts
|
|
2813
|
-
function
|
|
2912
|
+
function Pr(e) {
|
|
2814
2913
|
return async (t, n) => {
|
|
2815
2914
|
let i = await e.selectFrom("login_sessions").where("login_sessions.id", "=", n).selectAll().executeTakeFirst();
|
|
2816
2915
|
if (!i) return null;
|
|
@@ -2834,28 +2933,28 @@ function Nr(e) {
|
|
|
2834
2933
|
}
|
|
2835
2934
|
//#endregion
|
|
2836
2935
|
//#region src/utils/ulid.ts
|
|
2837
|
-
var
|
|
2838
|
-
function
|
|
2936
|
+
var Fr = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", V = 32, Ir = 10, Lr = 16;
|
|
2937
|
+
function Rr(e) {
|
|
2839
2938
|
let t = "";
|
|
2840
|
-
for (let n =
|
|
2939
|
+
for (let n = Ir; n > 0; n--) t = Fr.charAt(e % V) + t, e = Math.floor(e / V);
|
|
2841
2940
|
return t;
|
|
2842
2941
|
}
|
|
2843
|
-
function
|
|
2844
|
-
let e = new Uint8Array(
|
|
2942
|
+
function zr() {
|
|
2943
|
+
let e = new Uint8Array(Lr);
|
|
2845
2944
|
crypto.getRandomValues(e);
|
|
2846
2945
|
let t = "";
|
|
2847
|
-
for (let n = 0; n <
|
|
2946
|
+
for (let n = 0; n < Lr; n++) t += Fr.charAt(e[n] % V);
|
|
2848
2947
|
return t;
|
|
2849
2948
|
}
|
|
2850
|
-
function
|
|
2851
|
-
return
|
|
2949
|
+
function Br() {
|
|
2950
|
+
return Rr(Date.now()) + zr();
|
|
2852
2951
|
}
|
|
2853
2952
|
//#endregion
|
|
2854
2953
|
//#region src/loginSessions/create.ts
|
|
2855
|
-
function
|
|
2954
|
+
function Vr(e) {
|
|
2856
2955
|
return async (t, n) => {
|
|
2857
2956
|
let r = c(), i = {
|
|
2858
|
-
id:
|
|
2957
|
+
id: Br(),
|
|
2859
2958
|
...n,
|
|
2860
2959
|
authorization_url: n.authorization_url?.slice(0, 1024),
|
|
2861
2960
|
created_at: r,
|
|
@@ -2863,7 +2962,7 @@ function Br(e) {
|
|
|
2863
2962
|
state: n.state || p.PENDING,
|
|
2864
2963
|
state_data: n.state_data,
|
|
2865
2964
|
failure_reason: n.failure_reason
|
|
2866
|
-
}, { authParams: a, ...o } = i, s = Date.now(), l =
|
|
2965
|
+
}, { authParams: a, ...o } = i, s = Date.now(), l = F(o);
|
|
2867
2966
|
return delete l.created_at, delete l.updated_at, delete l.expires_at, await e.insertInto("login_sessions").values({
|
|
2868
2967
|
...l,
|
|
2869
2968
|
tenant_id: t,
|
|
@@ -2876,7 +2975,7 @@ function Br(e) {
|
|
|
2876
2975
|
}
|
|
2877
2976
|
//#endregion
|
|
2878
2977
|
//#region src/loginSessions/update.ts
|
|
2879
|
-
function
|
|
2978
|
+
function Hr(e) {
|
|
2880
2979
|
return async (t, n, r) => {
|
|
2881
2980
|
let { created_at: i, updated_at: a, expires_at: o, authParams: c, ...l } = r, u = {};
|
|
2882
2981
|
if (c !== void 0) {
|
|
@@ -2886,7 +2985,7 @@ function Vr(e) {
|
|
|
2886
2985
|
...c
|
|
2887
2986
|
}) };
|
|
2888
2987
|
}
|
|
2889
|
-
let d =
|
|
2988
|
+
let d = F(l);
|
|
2890
2989
|
return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
|
|
2891
2990
|
...d,
|
|
2892
2991
|
...u,
|
|
@@ -2897,22 +2996,22 @@ function Vr(e) {
|
|
|
2897
2996
|
}
|
|
2898
2997
|
//#endregion
|
|
2899
2998
|
//#region src/loginSessions/remove.ts
|
|
2900
|
-
function
|
|
2999
|
+
function Ur(e) {
|
|
2901
3000
|
return async (t, n) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", n).execute()).length > 0;
|
|
2902
3001
|
}
|
|
2903
3002
|
//#endregion
|
|
2904
3003
|
//#region src/loginSessions/index.ts
|
|
2905
|
-
function
|
|
3004
|
+
function Wr(e) {
|
|
2906
3005
|
return {
|
|
2907
|
-
create:
|
|
2908
|
-
get:
|
|
2909
|
-
update:
|
|
2910
|
-
remove:
|
|
3006
|
+
create: Vr(e),
|
|
3007
|
+
get: Pr(e),
|
|
3008
|
+
update: Hr(e),
|
|
3009
|
+
remove: Ur(e)
|
|
2911
3010
|
};
|
|
2912
3011
|
}
|
|
2913
3012
|
//#endregion
|
|
2914
3013
|
//#region src/promptSettings/get.ts
|
|
2915
|
-
function
|
|
3014
|
+
function Gr(e) {
|
|
2916
3015
|
return async (t) => {
|
|
2917
3016
|
let [n] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
|
|
2918
3017
|
return l({
|
|
@@ -2926,13 +3025,13 @@ function Wr(e) {
|
|
|
2926
3025
|
}
|
|
2927
3026
|
//#endregion
|
|
2928
3027
|
//#region src/promptSettings/set.ts
|
|
2929
|
-
function
|
|
3028
|
+
function Kr(e) {
|
|
2930
3029
|
let t = {};
|
|
2931
3030
|
return typeof e.identifier_first == "boolean" && (t.identifier_first = +!!e.identifier_first), typeof e.password_first == "boolean" && (t.password_first = +!!e.password_first), typeof e.webauthn_platform_first_factor == "boolean" && (t.webauthn_platform_first_factor = +!!e.webauthn_platform_first_factor), typeof e.show_last_used_connection == "boolean" && (t.show_last_used_connection = +!!e.show_last_used_connection), e.universal_login_experience && (t.universal_login_experience = e.universal_login_experience), t;
|
|
2932
3031
|
}
|
|
2933
|
-
function
|
|
3032
|
+
function qr(e) {
|
|
2934
3033
|
return async (t, n) => {
|
|
2935
|
-
let r =
|
|
3034
|
+
let r = Kr(n);
|
|
2936
3035
|
try {
|
|
2937
3036
|
await e.insertInto("prompt_settings").values({
|
|
2938
3037
|
tenant_id: t,
|
|
@@ -2950,15 +3049,15 @@ function Kr(e) {
|
|
|
2950
3049
|
}
|
|
2951
3050
|
//#endregion
|
|
2952
3051
|
//#region src/promptSettings/index.ts
|
|
2953
|
-
function
|
|
3052
|
+
function Jr(e) {
|
|
2954
3053
|
return {
|
|
2955
|
-
get:
|
|
2956
|
-
set:
|
|
3054
|
+
get: Gr(e),
|
|
3055
|
+
set: qr(e)
|
|
2957
3056
|
};
|
|
2958
3057
|
}
|
|
2959
3058
|
//#endregion
|
|
2960
3059
|
//#region src/emailProvideres/get.ts
|
|
2961
|
-
function
|
|
3060
|
+
function Yr(e) {
|
|
2962
3061
|
return async (t) => {
|
|
2963
3062
|
let [n] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
|
|
2964
3063
|
if (!n) return null;
|
|
@@ -2973,7 +3072,7 @@ function Jr(e) {
|
|
|
2973
3072
|
}
|
|
2974
3073
|
//#endregion
|
|
2975
3074
|
//#region src/emailProvideres/update.ts
|
|
2976
|
-
function
|
|
3075
|
+
function Xr(e) {
|
|
2977
3076
|
return async (t, n) => {
|
|
2978
3077
|
let { credentials: r, settings: i, enabled: a, ...o } = n;
|
|
2979
3078
|
await e.updateTable("email_providers").set({
|
|
@@ -2986,7 +3085,7 @@ function Yr(e) {
|
|
|
2986
3085
|
}
|
|
2987
3086
|
//#endregion
|
|
2988
3087
|
//#region src/emailProvideres/create.ts
|
|
2989
|
-
function
|
|
3088
|
+
function Zr(e) {
|
|
2990
3089
|
return async (t, n, r) => {
|
|
2991
3090
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), { credentials: o, settings: s, enabled: c, ...l } = n;
|
|
2992
3091
|
await e.insertInto("email_providers").values({
|
|
@@ -3002,24 +3101,24 @@ function Xr(e) {
|
|
|
3002
3101
|
}
|
|
3003
3102
|
//#endregion
|
|
3004
3103
|
//#region src/emailProvideres/remove.ts
|
|
3005
|
-
function
|
|
3104
|
+
function Qr(e) {
|
|
3006
3105
|
return async (t) => {
|
|
3007
3106
|
await e.deleteFrom("email_providers").where("tenant_id", "=", t).execute();
|
|
3008
3107
|
};
|
|
3009
3108
|
}
|
|
3010
3109
|
//#endregion
|
|
3011
3110
|
//#region src/emailProvideres/index.ts
|
|
3012
|
-
function
|
|
3111
|
+
function $r(e) {
|
|
3013
3112
|
return {
|
|
3014
|
-
get:
|
|
3015
|
-
create:
|
|
3016
|
-
update:
|
|
3017
|
-
remove:
|
|
3113
|
+
get: Yr(e),
|
|
3114
|
+
create: Zr(e),
|
|
3115
|
+
update: Xr(e),
|
|
3116
|
+
remove: Qr(e)
|
|
3018
3117
|
};
|
|
3019
3118
|
}
|
|
3020
3119
|
//#endregion
|
|
3021
3120
|
//#region src/emailTemplates/row.ts
|
|
3022
|
-
function
|
|
3121
|
+
function ei(e) {
|
|
3023
3122
|
let t = {
|
|
3024
3123
|
template: e.template,
|
|
3025
3124
|
body: e.body,
|
|
@@ -3033,20 +3132,20 @@ function $r(e) {
|
|
|
3033
3132
|
}
|
|
3034
3133
|
//#endregion
|
|
3035
3134
|
//#region src/emailTemplates/get.ts
|
|
3036
|
-
function
|
|
3135
|
+
function ti(e) {
|
|
3037
3136
|
return async (t, n) => {
|
|
3038
3137
|
let r = await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).selectAll().executeTakeFirst();
|
|
3039
|
-
return r ? ne.parse(
|
|
3138
|
+
return r ? ne.parse(ei(r)) : null;
|
|
3040
3139
|
};
|
|
3041
3140
|
}
|
|
3042
3141
|
//#endregion
|
|
3043
3142
|
//#region src/emailTemplates/list.ts
|
|
3044
|
-
function
|
|
3045
|
-
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(
|
|
3143
|
+
function ni(e) {
|
|
3144
|
+
return async (t) => (await e.selectFrom("email_templates").where("tenant_id", "=", t).orderBy("template", "asc").selectAll().execute()).map((e) => ne.parse(ei(e)));
|
|
3046
3145
|
}
|
|
3047
3146
|
//#endregion
|
|
3048
3147
|
//#region src/emailTemplates/create.ts
|
|
3049
|
-
function
|
|
3148
|
+
function ri(e) {
|
|
3050
3149
|
return async (t, n, r) => {
|
|
3051
3150
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? i?.created_at ?? a;
|
|
3052
3151
|
return await e.insertInto("email_templates").values({
|
|
@@ -3067,7 +3166,7 @@ function ni(e) {
|
|
|
3067
3166
|
}
|
|
3068
3167
|
//#endregion
|
|
3069
3168
|
//#region src/emailTemplates/update.ts
|
|
3070
|
-
function
|
|
3169
|
+
function ii(e) {
|
|
3071
3170
|
return async (t, n, r) => {
|
|
3072
3171
|
let i = {};
|
|
3073
3172
|
if (r.body !== void 0 && (i.body = r.body), r.from !== void 0 && (i.from = r.from), r.subject !== void 0 && (i.subject = r.subject), r.syntax !== void 0 && (i.syntax = r.syntax), r.resultUrl !== void 0 && (i.result_url = r.resultUrl), r.urlLifetimeInSeconds !== void 0 && (i.url_lifetime_in_seconds = r.urlLifetimeInSeconds), r.includeEmailInRedirect !== void 0 && (i.include_email_in_redirect = +!!r.includeEmailInRedirect), r.enabled !== void 0 && (i.enabled = +!!r.enabled), Object.keys(i).length === 0) return await e.selectFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).select("template").executeTakeFirst() !== void 0;
|
|
@@ -3078,7 +3177,7 @@ function ri(e) {
|
|
|
3078
3177
|
}
|
|
3079
3178
|
//#endregion
|
|
3080
3179
|
//#region src/emailTemplates/remove.ts
|
|
3081
|
-
function
|
|
3180
|
+
function ai(e) {
|
|
3082
3181
|
return async (t, n) => {
|
|
3083
3182
|
let r = await e.deleteFrom("email_templates").where("tenant_id", "=", t).where("template", "=", n).executeTakeFirst();
|
|
3084
3183
|
return Number(r.numDeletedRows ?? 0) > 0;
|
|
@@ -3086,18 +3185,18 @@ function ii(e) {
|
|
|
3086
3185
|
}
|
|
3087
3186
|
//#endregion
|
|
3088
3187
|
//#region src/emailTemplates/index.ts
|
|
3089
|
-
function
|
|
3188
|
+
function oi(e) {
|
|
3090
3189
|
return {
|
|
3091
|
-
get:
|
|
3092
|
-
list:
|
|
3093
|
-
create:
|
|
3094
|
-
update:
|
|
3095
|
-
remove:
|
|
3190
|
+
get: ti(e),
|
|
3191
|
+
list: ni(e),
|
|
3192
|
+
create: ri(e),
|
|
3193
|
+
update: ii(e),
|
|
3194
|
+
remove: ai(e)
|
|
3096
3195
|
};
|
|
3097
3196
|
}
|
|
3098
3197
|
//#endregion
|
|
3099
3198
|
//#region src/refreshTokens/to-refresh-token.ts
|
|
3100
|
-
function
|
|
3199
|
+
function H(e) {
|
|
3101
3200
|
let { tenant_id: t, created_at_ts: n, expires_at_ts: i, idle_expires_at_ts: a, last_exchanged_at_ts: o, revoked_at_ts: s, rotated_at_ts: c, auth_strategy_strategy: u, auth_strategy_strategy_type: d, ...f } = e, p = r({
|
|
3102
3201
|
created_at_ts: n,
|
|
3103
3202
|
expires_at_ts: i,
|
|
@@ -3126,23 +3225,23 @@ function R(e) {
|
|
|
3126
3225
|
}
|
|
3127
3226
|
//#endregion
|
|
3128
3227
|
//#region src/refreshTokens/get.ts
|
|
3129
|
-
function
|
|
3228
|
+
function si(e) {
|
|
3130
3229
|
return async (t, n) => {
|
|
3131
3230
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.id", "=", n).selectAll().executeTakeFirst();
|
|
3132
|
-
return r ?
|
|
3231
|
+
return r ? H(r) : null;
|
|
3133
3232
|
};
|
|
3134
3233
|
}
|
|
3135
3234
|
//#endregion
|
|
3136
3235
|
//#region src/refreshTokens/getByLookup.ts
|
|
3137
|
-
function
|
|
3236
|
+
function ci(e) {
|
|
3138
3237
|
return async (t, n) => {
|
|
3139
3238
|
let r = await e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t).where("refresh_tokens.token_lookup", "=", n).selectAll().executeTakeFirst();
|
|
3140
|
-
return r ?
|
|
3239
|
+
return r ? H(r) : null;
|
|
3141
3240
|
};
|
|
3142
3241
|
}
|
|
3143
3242
|
//#endregion
|
|
3144
3243
|
//#region src/refreshTokens/create.ts
|
|
3145
|
-
function
|
|
3244
|
+
function li(e) {
|
|
3146
3245
|
return async (t, n) => {
|
|
3147
3246
|
let r = c(), i = {
|
|
3148
3247
|
...n,
|
|
@@ -3174,12 +3273,12 @@ function ci(e) {
|
|
|
3174
3273
|
}
|
|
3175
3274
|
//#endregion
|
|
3176
3275
|
//#region src/refreshTokens/remove.ts
|
|
3177
|
-
function
|
|
3276
|
+
function ui(e) {
|
|
3178
3277
|
return async (t, n) => !!(await e.deleteFrom("refresh_tokens").where("tenant_id", "=", t).where("refresh_tokens.id", "=", n).execute()).length;
|
|
3179
3278
|
}
|
|
3180
3279
|
//#endregion
|
|
3181
3280
|
//#region src/refreshTokens/revokeByLoginSession.ts
|
|
3182
|
-
function
|
|
3281
|
+
function di(e) {
|
|
3183
3282
|
return async (t, n, r) => {
|
|
3184
3283
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("login_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3185
3284
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3187,7 +3286,7 @@ function ui(e) {
|
|
|
3187
3286
|
}
|
|
3188
3287
|
//#endregion
|
|
3189
3288
|
//#region src/refreshTokens/revokeBySession.ts
|
|
3190
|
-
function
|
|
3289
|
+
function fi(e) {
|
|
3191
3290
|
return async (t, n, r) => {
|
|
3192
3291
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("session_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3193
3292
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3195,7 +3294,7 @@ function di(e) {
|
|
|
3195
3294
|
}
|
|
3196
3295
|
//#endregion
|
|
3197
3296
|
//#region src/refreshTokens/revokeByUser.ts
|
|
3198
|
-
function
|
|
3297
|
+
function pi(e) {
|
|
3199
3298
|
return async (t, n, r) => {
|
|
3200
3299
|
let i = await e.updateTable("refresh_tokens").set({ revoked_at_ts: s(r) }).where("tenant_id", "=", t).where("user_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3201
3300
|
return Number(i.numUpdatedRows ?? 0);
|
|
@@ -3203,7 +3302,7 @@ function fi(e) {
|
|
|
3203
3302
|
}
|
|
3204
3303
|
//#endregion
|
|
3205
3304
|
//#region src/refreshTokens/revokeFamily.ts
|
|
3206
|
-
function
|
|
3305
|
+
function mi(e) {
|
|
3207
3306
|
return async (t, n, r) => {
|
|
3208
3307
|
let i = s(r), a = await e.updateTable("refresh_tokens").set({ revoked_at_ts: i }).where("tenant_id", "=", t).where("family_id", "=", n).where("revoked_at_ts", "is", null).executeTakeFirst();
|
|
3209
3308
|
return Number(a.numUpdatedRows ?? 0);
|
|
@@ -3211,7 +3310,7 @@ function pi(e) {
|
|
|
3211
3310
|
}
|
|
3212
3311
|
//#endregion
|
|
3213
3312
|
//#region src/refreshTokens/update.ts
|
|
3214
|
-
function
|
|
3313
|
+
function hi(e) {
|
|
3215
3314
|
return async (t, n, r, i) => {
|
|
3216
3315
|
let { created_at: a, expires_at: o, idle_expires_at: c, last_exchanged_at: l, revoked_at: u, rotated_at: d, device: f, resource_servers: p, rotating: m, ...h } = r, g = {
|
|
3217
3316
|
...h,
|
|
@@ -3232,14 +3331,14 @@ function mi(e) {
|
|
|
3232
3331
|
}
|
|
3233
3332
|
//#endregion
|
|
3234
3333
|
//#region src/refreshTokens/list.ts
|
|
3235
|
-
function
|
|
3334
|
+
function gi(e) {
|
|
3236
3335
|
return async (t, n = {}) => {
|
|
3237
3336
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c, user_id: l } = n, u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
|
|
3238
|
-
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u =
|
|
3239
|
-
let { rows: e, limit: t, next: r } = await
|
|
3337
|
+
if (l !== void 0 && (u = u.where("refresh_tokens.user_id", "=", l)), c && (u = O(e, u, c, ["token", "login_id"])), N(n)) {
|
|
3338
|
+
let { rows: e, limit: t, next: r } = await P(u.selectAll(), n, {
|
|
3240
3339
|
sortColumn: "created_at_ts",
|
|
3241
3340
|
sortOrder: "desc"
|
|
3242
|
-
}), i = e.map(
|
|
3341
|
+
}), i = e.map(H);
|
|
3243
3342
|
return {
|
|
3244
3343
|
refresh_tokens: i,
|
|
3245
3344
|
start: 0,
|
|
@@ -3254,7 +3353,7 @@ function hi(e) {
|
|
|
3254
3353
|
d = d.orderBy(t(s.sort_by), s.sort_order);
|
|
3255
3354
|
}
|
|
3256
3355
|
d = d.offset(r * i).limit(i);
|
|
3257
|
-
let f = (await d.selectAll().execute()).map(
|
|
3356
|
+
let f = (await d.selectAll().execute()).map(H);
|
|
3258
3357
|
if (!a) return {
|
|
3259
3358
|
refresh_tokens: f,
|
|
3260
3359
|
start: 0,
|
|
@@ -3272,57 +3371,90 @@ function hi(e) {
|
|
|
3272
3371
|
}
|
|
3273
3372
|
//#endregion
|
|
3274
3373
|
//#region src/refreshTokens/index.ts
|
|
3275
|
-
function
|
|
3374
|
+
function _i(e) {
|
|
3276
3375
|
return {
|
|
3277
|
-
create:
|
|
3278
|
-
get:
|
|
3279
|
-
getByLookup:
|
|
3280
|
-
list:
|
|
3281
|
-
remove:
|
|
3282
|
-
revokeByLoginSession:
|
|
3283
|
-
revokeBySession:
|
|
3284
|
-
revokeByUser:
|
|
3285
|
-
revokeFamily:
|
|
3286
|
-
update:
|
|
3376
|
+
create: li(e),
|
|
3377
|
+
get: si(e),
|
|
3378
|
+
getByLookup: ci(e),
|
|
3379
|
+
list: gi(e),
|
|
3380
|
+
remove: ui(e),
|
|
3381
|
+
revokeByLoginSession: di(e),
|
|
3382
|
+
revokeBySession: fi(e),
|
|
3383
|
+
revokeByUser: pi(e),
|
|
3384
|
+
revokeFamily: mi(e),
|
|
3385
|
+
update: hi(e)
|
|
3287
3386
|
};
|
|
3288
3387
|
}
|
|
3289
3388
|
//#endregion
|
|
3290
3389
|
//#region src/cleanup.ts
|
|
3291
|
-
var
|
|
3292
|
-
function
|
|
3390
|
+
var vi = 10080 * 60 * 1e3, U = 1e3;
|
|
3391
|
+
function yi(e) {
|
|
3293
3392
|
return async (t) => {
|
|
3294
|
-
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() -
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3393
|
+
let { tenant_id: n, user_id: r } = t || {}, i = Date.now() - vi, a = (t) => async () => {
|
|
3394
|
+
let a = e.deleteFrom("refresh_tokens").where(t, "<", i);
|
|
3395
|
+
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3396
|
+
let o = await a.limit(U).execute();
|
|
3397
|
+
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3398
|
+
}, o = (t) => async () => {
|
|
3399
|
+
let a = e.deleteFrom("sessions").where(t, "<", i);
|
|
3400
|
+
n && (a = a.where("tenant_id", "=", n)), r && (a = a.where("user_id", "=", r));
|
|
3401
|
+
let o = await a.limit(U).execute();
|
|
3402
|
+
return Number(o[0]?.numDeletedRows ?? 0);
|
|
3403
|
+
}, s = [
|
|
3404
|
+
{
|
|
3405
|
+
table: "login_sessions",
|
|
3406
|
+
label: "login_sessions.expires_at_ts",
|
|
3407
|
+
deleteBatch: async () => {
|
|
3408
|
+
let t = e.deleteFrom("login_sessions").where("expires_at_ts", "<", i);
|
|
3409
|
+
n && (t = t.where("tenant_id", "=", n)), r && (t = t.where("user_id", "=", r));
|
|
3410
|
+
let a = await t.limit(U).execute();
|
|
3411
|
+
return Number(a[0]?.numDeletedRows ?? 0);
|
|
3412
|
+
}
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
table: "refresh_tokens",
|
|
3416
|
+
label: "refresh_tokens.expires_at_ts",
|
|
3417
|
+
deleteBatch: a("expires_at_ts")
|
|
3418
|
+
},
|
|
3419
|
+
{
|
|
3420
|
+
table: "refresh_tokens",
|
|
3421
|
+
label: "refresh_tokens.idle_expires_at_ts",
|
|
3422
|
+
deleteBatch: a("idle_expires_at_ts")
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
table: "sessions",
|
|
3426
|
+
label: "sessions.expires_at_ts",
|
|
3427
|
+
deleteBatch: o("expires_at_ts")
|
|
3428
|
+
},
|
|
3429
|
+
{
|
|
3430
|
+
table: "sessions",
|
|
3431
|
+
label: "sessions.idle_expires_at_ts",
|
|
3432
|
+
deleteBatch: o("idle_expires_at_ts")
|
|
3309
3433
|
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3434
|
+
].map((e) => ({
|
|
3435
|
+
...e,
|
|
3436
|
+
deleted: 0,
|
|
3437
|
+
drained: !1,
|
|
3438
|
+
failed: !1
|
|
3439
|
+
})), c = 0;
|
|
3440
|
+
for (; c < 300 && s.some((e) => !e.drained);) for (let e of s) if (!(e.drained || c >= 300)) {
|
|
3441
|
+
c += 1;
|
|
3442
|
+
try {
|
|
3443
|
+
let t = await e.deleteBatch();
|
|
3444
|
+
e.deleted += t, t < U && (e.drained = !0);
|
|
3445
|
+
} catch (t) {
|
|
3446
|
+
e.failed = !0, e.drained = !0, console.error(`Error during session cleanup (${e.label}):`, t);
|
|
3316
3447
|
}
|
|
3317
|
-
(t > 0 || o > 0 || s > 0) && console.log(`Session cleanup: deleted ${t} refresh_tokens, ${o} sessions, ${s} login_sessions`);
|
|
3318
|
-
} catch (e) {
|
|
3319
|
-
console.error("Error during session cleanup:", e);
|
|
3320
3448
|
}
|
|
3449
|
+
let l = /* @__PURE__ */ new Map();
|
|
3450
|
+
for (let e of s) l.set(e.table, (l.get(e.table) ?? 0) + e.deleted);
|
|
3451
|
+
let u = [...l].map(([e, t]) => `${t} ${e}`).join(", "), d = s.filter((e) => e.failed).map((e) => e.label), f = s.filter((e) => !e.drained).map((e) => e.label);
|
|
3452
|
+
d.length > 0 ? console.warn(`Session cleanup: ${d.join(", ")} failed. Deleted ${u}`) : f.length > 0 ? console.warn(`Session cleanup: batch budget of 300 exhausted before ${f.join(", ")} drained. Deleted ${u}`) : s.some((e) => e.deleted > 0) && console.log(`Session cleanup: deleted ${u}`);
|
|
3321
3453
|
};
|
|
3322
3454
|
}
|
|
3323
3455
|
//#endregion
|
|
3324
3456
|
//#region src/forms/create.ts
|
|
3325
|
-
function
|
|
3457
|
+
function bi(e) {
|
|
3326
3458
|
return async (n, r, i) => {
|
|
3327
3459
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = x.parse({
|
|
3328
3460
|
id: a?.id ?? t(),
|
|
@@ -3341,10 +3473,10 @@ function yi(e) {
|
|
|
3341
3473
|
}
|
|
3342
3474
|
//#endregion
|
|
3343
3475
|
//#region src/forms/list.ts
|
|
3344
|
-
function
|
|
3476
|
+
function xi(e) {
|
|
3345
3477
|
return async (t, n = {}) => {
|
|
3346
3478
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("forms").where("tenant_id", "=", t);
|
|
3347
|
-
s && (c =
|
|
3479
|
+
s && (c = O(e, c, s, []));
|
|
3348
3480
|
let u = (await c.offset(r * i).limit(i).selectAll().execute()).map((e) => {
|
|
3349
3481
|
let t = { ...e };
|
|
3350
3482
|
if (typeof t.nodes == "string") try {
|
|
@@ -3375,7 +3507,7 @@ function bi(e) {
|
|
|
3375
3507
|
}
|
|
3376
3508
|
//#endregion
|
|
3377
3509
|
//#region src/forms/remove.ts
|
|
3378
|
-
function
|
|
3510
|
+
function Si(e) {
|
|
3379
3511
|
return async (t, n) => {
|
|
3380
3512
|
let { numDeletedRows: r } = await e.deleteFrom("forms").where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3381
3513
|
return r > 0;
|
|
@@ -3383,7 +3515,7 @@ function xi(e) {
|
|
|
3383
3515
|
}
|
|
3384
3516
|
//#endregion
|
|
3385
3517
|
//#region src/forms/get.ts
|
|
3386
|
-
function
|
|
3518
|
+
function Ci(e) {
|
|
3387
3519
|
return async (t, n) => {
|
|
3388
3520
|
let r = await e.selectFrom("forms").selectAll().where("forms.id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
3389
3521
|
if (!r) return null;
|
|
@@ -3402,7 +3534,7 @@ function Si(e) {
|
|
|
3402
3534
|
}
|
|
3403
3535
|
//#endregion
|
|
3404
3536
|
//#region src/forms/update.ts
|
|
3405
|
-
function
|
|
3537
|
+
function wi(e) {
|
|
3406
3538
|
return async (t, n, r) => {
|
|
3407
3539
|
let i = {
|
|
3408
3540
|
...r,
|
|
@@ -3419,18 +3551,18 @@ function Ci(e) {
|
|
|
3419
3551
|
}
|
|
3420
3552
|
//#endregion
|
|
3421
3553
|
//#region src/forms/index.ts
|
|
3422
|
-
function
|
|
3554
|
+
function Ti(e) {
|
|
3423
3555
|
return {
|
|
3424
|
-
create:
|
|
3425
|
-
get:
|
|
3426
|
-
list:
|
|
3427
|
-
remove:
|
|
3428
|
-
update:
|
|
3556
|
+
create: bi(e),
|
|
3557
|
+
get: Ci(e),
|
|
3558
|
+
list: xi(e),
|
|
3559
|
+
remove: Si(e),
|
|
3560
|
+
update: wi(e)
|
|
3429
3561
|
};
|
|
3430
3562
|
}
|
|
3431
3563
|
//#endregion
|
|
3432
3564
|
//#region src/resourceServers/create.ts
|
|
3433
|
-
function
|
|
3565
|
+
function Ei(e) {
|
|
3434
3566
|
return async (t, n, r) => {
|
|
3435
3567
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = i?.created_at ?? a, s = i?.updated_at ?? a, c = {
|
|
3436
3568
|
...n,
|
|
@@ -3455,7 +3587,7 @@ function Ti(e) {
|
|
|
3455
3587
|
}
|
|
3456
3588
|
//#endregion
|
|
3457
3589
|
//#region src/resourceServers/get.ts
|
|
3458
|
-
function
|
|
3590
|
+
function Di(e) {
|
|
3459
3591
|
return async (t, n) => {
|
|
3460
3592
|
let r = await e.selectFrom("resource_servers").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3461
3593
|
if (!r) return null;
|
|
@@ -3474,7 +3606,20 @@ function Ei(e) {
|
|
|
3474
3606
|
}
|
|
3475
3607
|
//#endregion
|
|
3476
3608
|
//#region src/resourceServers/list.ts
|
|
3477
|
-
function
|
|
3609
|
+
function Oi(e) {
|
|
3610
|
+
let { verification_key: t, scopes: n, options: r, skip_consent_for_verifiable_first_party_clients: i, allow_offline_access: a, is_system: o, metadata: s, ...c } = e, u = l({
|
|
3611
|
+
...c,
|
|
3612
|
+
scopes: n ? JSON.parse(n) : [],
|
|
3613
|
+
options: r ? JSON.parse(r) : {},
|
|
3614
|
+
skip_consent_for_verifiable_first_party_clients: !!i,
|
|
3615
|
+
allow_offline_access: !!a,
|
|
3616
|
+
is_system: o ? !0 : void 0,
|
|
3617
|
+
metadata: s ? JSON.parse(s) : void 0,
|
|
3618
|
+
verificationKey: t
|
|
3619
|
+
});
|
|
3620
|
+
return u.token_lifetime ??= 86400, u.token_lifetime_for_web ??= 7200, u;
|
|
3621
|
+
}
|
|
3622
|
+
function ki(e) {
|
|
3478
3623
|
return async (t, n = {}) => {
|
|
3479
3624
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, q: s } = n, c = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
|
|
3480
3625
|
if (s) {
|
|
@@ -3482,39 +3627,41 @@ function Di(e) {
|
|
|
3482
3627
|
if (i && !o) {
|
|
3483
3628
|
let e = !!i[1], t = i[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
|
|
3484
3629
|
c = e ? c.where(t, "not like", `%${a}%`) : c.where(t, "like", `%${a}%`);
|
|
3485
|
-
} else c =
|
|
3630
|
+
} else c = O(e, c, t, ["resource_servers.name", "resource_servers.identifier"]);
|
|
3486
3631
|
}
|
|
3487
|
-
|
|
3488
|
-
let {
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3632
|
+
if (N(n)) {
|
|
3633
|
+
let { rows: e, limit: t, next: r } = await P(c.selectAll(), n, {
|
|
3634
|
+
sortColumn: "created_at",
|
|
3635
|
+
sortOrder: "desc",
|
|
3636
|
+
idColumn: "id"
|
|
3637
|
+
}), i = e.map(Oi);
|
|
3638
|
+
return {
|
|
3639
|
+
resource_servers: i,
|
|
3640
|
+
start: 0,
|
|
3641
|
+
limit: t,
|
|
3642
|
+
length: i.length,
|
|
3643
|
+
next: r
|
|
3644
|
+
};
|
|
3645
|
+
}
|
|
3646
|
+
let l = (await c.offset(r * i).limit(i).selectAll().execute()).map(Oi);
|
|
3500
3647
|
if (!a) return {
|
|
3501
|
-
resource_servers:
|
|
3648
|
+
resource_servers: l,
|
|
3502
3649
|
start: 0,
|
|
3503
3650
|
limit: 0,
|
|
3504
3651
|
length: 0
|
|
3505
3652
|
};
|
|
3506
|
-
let { count:
|
|
3653
|
+
let { count: u } = await c.select((e) => e.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
3507
3654
|
return {
|
|
3508
|
-
resource_servers:
|
|
3655
|
+
resource_servers: l,
|
|
3509
3656
|
start: r * i,
|
|
3510
3657
|
limit: i,
|
|
3511
|
-
length: o(
|
|
3658
|
+
length: o(u)
|
|
3512
3659
|
};
|
|
3513
3660
|
};
|
|
3514
3661
|
}
|
|
3515
3662
|
//#endregion
|
|
3516
3663
|
//#region src/resourceServers/remove.ts
|
|
3517
|
-
function
|
|
3664
|
+
function Ai(e) {
|
|
3518
3665
|
return async (t, n) => {
|
|
3519
3666
|
let r = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3520
3667
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3522,7 +3669,7 @@ function Oi(e) {
|
|
|
3522
3669
|
}
|
|
3523
3670
|
//#endregion
|
|
3524
3671
|
//#region src/resourceServers/update.ts
|
|
3525
|
-
function
|
|
3672
|
+
function ji(e) {
|
|
3526
3673
|
return async (t, n, r) => {
|
|
3527
3674
|
let { verificationKey: i, scopes: a, options: o, skip_consent_for_verifiable_first_party_clients: s, allow_offline_access: c, is_system: l, metadata: u, ...d } = r, f = {
|
|
3528
3675
|
...d,
|
|
@@ -3542,18 +3689,18 @@ function ki(e) {
|
|
|
3542
3689
|
}
|
|
3543
3690
|
//#endregion
|
|
3544
3691
|
//#region src/resourceServers/index.ts
|
|
3545
|
-
function
|
|
3692
|
+
function Mi(e) {
|
|
3546
3693
|
return {
|
|
3547
|
-
create:
|
|
3548
|
-
get:
|
|
3549
|
-
list:
|
|
3550
|
-
remove:
|
|
3551
|
-
update:
|
|
3694
|
+
create: Ei(e),
|
|
3695
|
+
get: Di(e),
|
|
3696
|
+
list: ki(e),
|
|
3697
|
+
remove: Ai(e),
|
|
3698
|
+
update: ji(e)
|
|
3552
3699
|
};
|
|
3553
3700
|
}
|
|
3554
3701
|
//#endregion
|
|
3555
3702
|
//#region src/roles/create.ts
|
|
3556
|
-
function
|
|
3703
|
+
function Ni(e) {
|
|
3557
3704
|
return async (n, r, i) => {
|
|
3558
3705
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.created_at ?? o, c = a?.updated_at ?? o, l = a?.id || r.id || t(), { is_system: u, id: d, metadata: f, ...p } = r, m = {
|
|
3559
3706
|
id: l,
|
|
@@ -3576,7 +3723,7 @@ function ji(e) {
|
|
|
3576
3723
|
}
|
|
3577
3724
|
//#endregion
|
|
3578
3725
|
//#region src/roles/get.ts
|
|
3579
|
-
function
|
|
3726
|
+
function Pi(e) {
|
|
3580
3727
|
return async (t, n) => {
|
|
3581
3728
|
let r = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", n).executeTakeFirst();
|
|
3582
3729
|
if (!r) return null;
|
|
@@ -3590,10 +3737,10 @@ function Mi(e) {
|
|
|
3590
3737
|
}
|
|
3591
3738
|
//#endregion
|
|
3592
3739
|
//#region src/roles/list.ts
|
|
3593
|
-
function
|
|
3740
|
+
function Fi(e) {
|
|
3594
3741
|
return async (t, n) => {
|
|
3595
3742
|
let r = e.selectFrom("roles").where("roles.tenant_id", "=", t), { page: i = 0, per_page: a = 50, include_totals: s = !1 } = n;
|
|
3596
|
-
n.q && (r =
|
|
3743
|
+
n.q && (r = O(e, r, n.q, ["name"]));
|
|
3597
3744
|
let c = (await r.offset(i * a).limit(a).selectAll().execute()).map((e) => {
|
|
3598
3745
|
let { is_system: t, tenant_id: n, metadata: r, ...i } = e;
|
|
3599
3746
|
return {
|
|
@@ -3619,7 +3766,7 @@ function Ni(e) {
|
|
|
3619
3766
|
}
|
|
3620
3767
|
//#endregion
|
|
3621
3768
|
//#region src/roles/update.ts
|
|
3622
|
-
function
|
|
3769
|
+
function Ii(e) {
|
|
3623
3770
|
return async (t, n, r) => {
|
|
3624
3771
|
let { is_system: i, metadata: a, ...o } = r, s = {
|
|
3625
3772
|
...o,
|
|
@@ -3632,7 +3779,7 @@ function Pi(e) {
|
|
|
3632
3779
|
}
|
|
3633
3780
|
//#endregion
|
|
3634
3781
|
//#region src/roles/remove.ts
|
|
3635
|
-
function
|
|
3782
|
+
function Li(e) {
|
|
3636
3783
|
return async (t, n) => {
|
|
3637
3784
|
let r = await e.deleteFrom("roles").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
3638
3785
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -3640,23 +3787,23 @@ function Fi(e) {
|
|
|
3640
3787
|
}
|
|
3641
3788
|
//#endregion
|
|
3642
3789
|
//#region src/roles/index.ts
|
|
3643
|
-
function
|
|
3790
|
+
function Ri(e) {
|
|
3644
3791
|
return {
|
|
3645
|
-
create:
|
|
3646
|
-
get:
|
|
3647
|
-
list:
|
|
3648
|
-
update:
|
|
3649
|
-
remove:
|
|
3792
|
+
create: Ni(e),
|
|
3793
|
+
get: Pi(e),
|
|
3794
|
+
list: Fi(e),
|
|
3795
|
+
update: Ii(e),
|
|
3796
|
+
remove: Li(e)
|
|
3650
3797
|
};
|
|
3651
3798
|
}
|
|
3652
3799
|
//#endregion
|
|
3653
3800
|
//#region src/role-permissions/assign.ts
|
|
3654
|
-
function
|
|
3801
|
+
function zi(e) {
|
|
3655
3802
|
if (typeof e != "object" || !e) return !1;
|
|
3656
3803
|
let { code: t, message: n } = e;
|
|
3657
3804
|
return t === "SQLITE_CONSTRAINT" || t === "SQLITE_CONSTRAINT_PRIMARYKEY" || t === "SQLITE_CONSTRAINT_UNIQUE" || t === "ER_DUP_ENTRY" || t === "23505" ? !0 : typeof n == "string" && (n.includes("UNIQUE constraint failed") || n.includes("Duplicate entry") || n.includes("duplicate key") || n.includes("AlreadyExists"));
|
|
3658
3805
|
}
|
|
3659
|
-
function
|
|
3806
|
+
function Bi(e) {
|
|
3660
3807
|
return async (t, n, r, i) => {
|
|
3661
3808
|
if (r.length === 0) return !0;
|
|
3662
3809
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3673,7 +3820,7 @@ function Ri(e) {
|
|
|
3673
3820
|
try {
|
|
3674
3821
|
await e.insertInto("role_permissions").values(r).execute();
|
|
3675
3822
|
} catch (e) {
|
|
3676
|
-
if (
|
|
3823
|
+
if (zi(e)) continue;
|
|
3677
3824
|
throw e;
|
|
3678
3825
|
}
|
|
3679
3826
|
}
|
|
@@ -3685,7 +3832,7 @@ function Ri(e) {
|
|
|
3685
3832
|
}
|
|
3686
3833
|
//#endregion
|
|
3687
3834
|
//#region src/role-permissions/remove.ts
|
|
3688
|
-
function
|
|
3835
|
+
function Vi(e) {
|
|
3689
3836
|
return async (t, n, r) => {
|
|
3690
3837
|
if (r.length === 0) return !0;
|
|
3691
3838
|
try {
|
|
@@ -3697,7 +3844,7 @@ function zi(e) {
|
|
|
3697
3844
|
}
|
|
3698
3845
|
//#endregion
|
|
3699
3846
|
//#region src/role-permissions/list.ts
|
|
3700
|
-
function
|
|
3847
|
+
function Hi(e) {
|
|
3701
3848
|
return async (t, n, r = {}) => {
|
|
3702
3849
|
let { page: i = 0, per_page: a = 50, include_totals: o = !1 } = r, s = e.selectFrom("role_permissions").leftJoin("resource_servers", (e) => e.onRef("role_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("role_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3703
3850
|
"role_permissions.role_id",
|
|
@@ -3718,16 +3865,16 @@ function Bi(e) {
|
|
|
3718
3865
|
}
|
|
3719
3866
|
//#endregion
|
|
3720
3867
|
//#region src/role-permissions/index.ts
|
|
3721
|
-
function
|
|
3868
|
+
function Ui(e) {
|
|
3722
3869
|
return {
|
|
3723
|
-
assign:
|
|
3724
|
-
remove:
|
|
3725
|
-
list:
|
|
3870
|
+
assign: Bi(e),
|
|
3871
|
+
remove: Vi(e),
|
|
3872
|
+
list: Hi(e)
|
|
3726
3873
|
};
|
|
3727
3874
|
}
|
|
3728
3875
|
//#endregion
|
|
3729
3876
|
//#region src/grants/create.ts
|
|
3730
|
-
function
|
|
3877
|
+
function Wi(e) {
|
|
3731
3878
|
return async (n, r) => {
|
|
3732
3879
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = r.scope ?? [], o = r.audience ?? "", s = await e.selectFrom("grants").where("tenant_id", "=", n).where("user_id", "=", r.user_id).where("client_id", "=", r.clientID).where("audience", "=", o).selectAll().executeTakeFirst();
|
|
3733
3880
|
if (s) {
|
|
@@ -3764,7 +3911,7 @@ function Hi(e) {
|
|
|
3764
3911
|
}
|
|
3765
3912
|
//#endregion
|
|
3766
3913
|
//#region src/grants/get.ts
|
|
3767
|
-
function
|
|
3914
|
+
function Gi(e) {
|
|
3768
3915
|
return async (t, n, r, i) => {
|
|
3769
3916
|
let a = await e.selectFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).where("client_id", "=", r).where("audience", "=", i ?? "").selectAll().executeTakeFirst();
|
|
3770
3917
|
return a ? {
|
|
@@ -3778,10 +3925,10 @@ function Ui(e) {
|
|
|
3778
3925
|
}
|
|
3779
3926
|
//#endregion
|
|
3780
3927
|
//#region src/grants/list.ts
|
|
3781
|
-
function
|
|
3928
|
+
function Ki(e) {
|
|
3782
3929
|
return async (t, n = {}) => {
|
|
3783
3930
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: s, q: c } = n, l = e.selectFrom("grants").where("grants.tenant_id", "=", t);
|
|
3784
|
-
c && (l =
|
|
3931
|
+
c && (l = O(e, l, c, [
|
|
3785
3932
|
"user_id",
|
|
3786
3933
|
"client_id",
|
|
3787
3934
|
"audience"
|
|
@@ -3816,26 +3963,26 @@ function Wi(e) {
|
|
|
3816
3963
|
}
|
|
3817
3964
|
//#endregion
|
|
3818
3965
|
//#region src/grants/remove.ts
|
|
3819
|
-
function
|
|
3966
|
+
function qi(e) {
|
|
3820
3967
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3821
3968
|
}
|
|
3822
|
-
function
|
|
3969
|
+
function Ji(e) {
|
|
3823
3970
|
return async (t, n) => (await e.deleteFrom("grants").where("tenant_id", "=", t).where("user_id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
3824
3971
|
}
|
|
3825
3972
|
//#endregion
|
|
3826
3973
|
//#region src/grants/index.ts
|
|
3827
|
-
function
|
|
3974
|
+
function Yi(e) {
|
|
3828
3975
|
return {
|
|
3829
|
-
create:
|
|
3830
|
-
get:
|
|
3831
|
-
list:
|
|
3832
|
-
remove:
|
|
3833
|
-
removeByUser:
|
|
3976
|
+
create: Wi(e),
|
|
3977
|
+
get: Gi(e),
|
|
3978
|
+
list: Ki(e),
|
|
3979
|
+
remove: qi(e),
|
|
3980
|
+
removeByUser: Ji(e)
|
|
3834
3981
|
};
|
|
3835
3982
|
}
|
|
3836
3983
|
//#endregion
|
|
3837
3984
|
//#region src/user-permissions/create.ts
|
|
3838
|
-
function
|
|
3985
|
+
function Xi(e) {
|
|
3839
3986
|
return async (t, n, r, i, a) => {
|
|
3840
3987
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3841
3988
|
try {
|
|
@@ -3855,7 +4002,7 @@ function Ji(e) {
|
|
|
3855
4002
|
}
|
|
3856
4003
|
//#endregion
|
|
3857
4004
|
//#region src/user-permissions/remove.ts
|
|
3858
|
-
function
|
|
4005
|
+
function Zi(e) {
|
|
3859
4006
|
return async (t, n, r, i) => {
|
|
3860
4007
|
try {
|
|
3861
4008
|
let a = e.deleteFrom("user_permissions").where("tenant_id", "=", t).where("user_id", "=", n).where("resource_server_identifier", "=", r.resource_server_identifier).where("permission_name", "=", r.permission_name);
|
|
@@ -3867,7 +4014,7 @@ function Yi(e) {
|
|
|
3867
4014
|
}
|
|
3868
4015
|
//#endregion
|
|
3869
4016
|
//#region src/user-permissions/list.ts
|
|
3870
|
-
function
|
|
4017
|
+
function Qi(e) {
|
|
3871
4018
|
return async (t, n, r, i) => {
|
|
3872
4019
|
let a = e.selectFrom("user_permissions").leftJoin("resource_servers", (e) => e.onRef("user_permissions.tenant_id", "=", "resource_servers.tenant_id").onRef("user_permissions.resource_server_identifier", "=", "resource_servers.id")).select([
|
|
3873
4020
|
"user_permissions.resource_server_identifier",
|
|
@@ -3890,17 +4037,17 @@ function Xi(e) {
|
|
|
3890
4037
|
}
|
|
3891
4038
|
//#endregion
|
|
3892
4039
|
//#region src/user-permissions/index.ts
|
|
3893
|
-
function
|
|
4040
|
+
function $i(e) {
|
|
3894
4041
|
return {
|
|
3895
|
-
create:
|
|
3896
|
-
remove:
|
|
3897
|
-
list:
|
|
4042
|
+
create: Xi(e),
|
|
4043
|
+
remove: Zi(e),
|
|
4044
|
+
list: Qi(e)
|
|
3898
4045
|
};
|
|
3899
4046
|
}
|
|
3900
4047
|
//#endregion
|
|
3901
4048
|
//#region src/user-permissions/adapter.ts
|
|
3902
|
-
function
|
|
3903
|
-
let t =
|
|
4049
|
+
function ea(e) {
|
|
4050
|
+
let t = $i(e);
|
|
3904
4051
|
return {
|
|
3905
4052
|
create: (e, n, r, i) => t.create(e, n, r, i),
|
|
3906
4053
|
remove: (e, n, r, i) => t.remove(e, n, r, i),
|
|
@@ -3909,7 +4056,7 @@ function Qi(e) {
|
|
|
3909
4056
|
}
|
|
3910
4057
|
//#endregion
|
|
3911
4058
|
//#region src/user-roles/list.ts
|
|
3912
|
-
function
|
|
4059
|
+
function ta(e) {
|
|
3913
4060
|
return async (t, n, r, i) => {
|
|
3914
4061
|
let a = e.selectFrom("user_roles as ur").innerJoin("roles as r", (e) => e.onRef("ur.role_id", "=", "r.id").onRef("ur.tenant_id", "=", "r.tenant_id")).select([
|
|
3915
4062
|
"r.id",
|
|
@@ -3923,11 +4070,11 @@ function $i(e) {
|
|
|
3923
4070
|
}
|
|
3924
4071
|
//#endregion
|
|
3925
4072
|
//#region src/user-roles/list-users.ts
|
|
3926
|
-
function
|
|
4073
|
+
function na(e) {
|
|
3927
4074
|
return async (t, n, r) => {
|
|
3928
4075
|
let i = e.selectFrom("user_roles").select("user_id").distinct().where("tenant_id", "=", t).where("role_id", "=", n);
|
|
3929
|
-
if (
|
|
3930
|
-
let { rows: e, limit: t, next: n } = await
|
|
4076
|
+
if (N(r)) {
|
|
4077
|
+
let { rows: e, limit: t, next: n } = await P(i, r, {
|
|
3931
4078
|
sortColumn: "user_id",
|
|
3932
4079
|
sortOrder: "asc",
|
|
3933
4080
|
idColumn: "user_id"
|
|
@@ -3951,7 +4098,7 @@ function ea(e) {
|
|
|
3951
4098
|
}
|
|
3952
4099
|
//#endregion
|
|
3953
4100
|
//#region src/user-roles/create.ts
|
|
3954
|
-
function
|
|
4101
|
+
function ra(e) {
|
|
3955
4102
|
return async (t, n, r, i, a) => {
|
|
3956
4103
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString();
|
|
3957
4104
|
try {
|
|
@@ -3969,7 +4116,7 @@ function ta(e) {
|
|
|
3969
4116
|
}
|
|
3970
4117
|
//#endregion
|
|
3971
4118
|
//#region src/user-roles/remove.ts
|
|
3972
|
-
function
|
|
4119
|
+
function ia(e) {
|
|
3973
4120
|
return async (t, n, r, i) => {
|
|
3974
4121
|
try {
|
|
3975
4122
|
let a = e.deleteFrom("user_roles").where("tenant_id", "=", t).where("user_id", "=", n).where("role_id", "=", r);
|
|
@@ -3981,18 +4128,18 @@ function na(e) {
|
|
|
3981
4128
|
}
|
|
3982
4129
|
//#endregion
|
|
3983
4130
|
//#region src/user-roles/index.ts
|
|
3984
|
-
function
|
|
4131
|
+
function aa(e) {
|
|
3985
4132
|
return {
|
|
3986
|
-
list:
|
|
3987
|
-
listUsers:
|
|
3988
|
-
create:
|
|
3989
|
-
remove:
|
|
4133
|
+
list: ta(e),
|
|
4134
|
+
listUsers: na(e),
|
|
4135
|
+
create: ra(e),
|
|
4136
|
+
remove: ia(e)
|
|
3990
4137
|
};
|
|
3991
4138
|
}
|
|
3992
4139
|
//#endregion
|
|
3993
4140
|
//#region src/user-roles/adapter.ts
|
|
3994
|
-
function
|
|
3995
|
-
let t =
|
|
4141
|
+
function oa(e) {
|
|
4142
|
+
let t = aa(e);
|
|
3996
4143
|
return {
|
|
3997
4144
|
list: (e, n, r, i) => t.list(e, n, r, i),
|
|
3998
4145
|
listUsers: (e, n, r) => t.listUsers(e, n, r),
|
|
@@ -4002,7 +4149,7 @@ function ia(e) {
|
|
|
4002
4149
|
}
|
|
4003
4150
|
//#endregion
|
|
4004
4151
|
//#region src/organizations/create.ts
|
|
4005
|
-
function
|
|
4152
|
+
function sa(e) {
|
|
4006
4153
|
return async (t, n, r) => {
|
|
4007
4154
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
4008
4155
|
...n,
|
|
@@ -4030,7 +4177,7 @@ function aa(e) {
|
|
|
4030
4177
|
}
|
|
4031
4178
|
//#endregion
|
|
4032
4179
|
//#region src/organizations/get.ts
|
|
4033
|
-
function
|
|
4180
|
+
function ca(e) {
|
|
4034
4181
|
return async (t, n) => {
|
|
4035
4182
|
let r = await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4036
4183
|
return r ||= await e.selectFrom("organizations").selectAll().where("tenant_id", "=", t).where("name", "=", n).executeTakeFirst(), r ? l({
|
|
@@ -4044,16 +4191,16 @@ function oa(e) {
|
|
|
4044
4191
|
}
|
|
4045
4192
|
//#endregion
|
|
4046
4193
|
//#region src/organizations/list.ts
|
|
4047
|
-
var
|
|
4048
|
-
function
|
|
4194
|
+
var W = ["name", "display_name"];
|
|
4195
|
+
function la(e) {
|
|
4049
4196
|
return async (t, n) => {
|
|
4050
4197
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4051
4198
|
if (n?.q) {
|
|
4052
|
-
let t = S(n.q,
|
|
4053
|
-
t && (r =
|
|
4199
|
+
let t = S(n.q, W);
|
|
4200
|
+
t && (r = O(e, r, t, W));
|
|
4054
4201
|
}
|
|
4055
|
-
if (
|
|
4056
|
-
let { rows: e, limit: t, next: i } = await
|
|
4202
|
+
if (N(n)) {
|
|
4203
|
+
let { rows: e, limit: t, next: i } = await P(r.selectAll(), n, {
|
|
4057
4204
|
sortColumn: "created_at",
|
|
4058
4205
|
sortOrder: "desc"
|
|
4059
4206
|
}), a = e.map((e) => l({
|
|
@@ -4086,8 +4233,8 @@ function sa(e) {
|
|
|
4086
4233
|
if (n?.include_totals) {
|
|
4087
4234
|
let r = e.selectFrom("organizations").where("tenant_id", "=", t);
|
|
4088
4235
|
if (n?.q) {
|
|
4089
|
-
let t = S(n.q,
|
|
4090
|
-
t && (r =
|
|
4236
|
+
let t = S(n.q, W);
|
|
4237
|
+
t && (r = O(e, r, t, W));
|
|
4091
4238
|
}
|
|
4092
4239
|
let i = await r.select(f`count(*)`.as("count")).executeTakeFirst();
|
|
4093
4240
|
u = Number(i?.count || 0);
|
|
@@ -4110,7 +4257,7 @@ function sa(e) {
|
|
|
4110
4257
|
}
|
|
4111
4258
|
//#endregion
|
|
4112
4259
|
//#region src/organizations/remove.ts
|
|
4113
|
-
function
|
|
4260
|
+
function ua(e) {
|
|
4114
4261
|
return async (t, n) => {
|
|
4115
4262
|
let r = await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4116
4263
|
return Number(r.numDeletedRows) > 0;
|
|
@@ -4118,7 +4265,7 @@ function ca(e) {
|
|
|
4118
4265
|
}
|
|
4119
4266
|
//#endregion
|
|
4120
4267
|
//#region src/organizations/update.ts
|
|
4121
|
-
function
|
|
4268
|
+
function da(e) {
|
|
4122
4269
|
return async (t, n, r) => {
|
|
4123
4270
|
let { branding: i, metadata: a, enabled_connections: o, token_quota: s, ...c } = r, l = {
|
|
4124
4271
|
...c,
|
|
@@ -4134,18 +4281,18 @@ function la(e) {
|
|
|
4134
4281
|
}
|
|
4135
4282
|
//#endregion
|
|
4136
4283
|
//#region src/organizations/index.ts
|
|
4137
|
-
function
|
|
4284
|
+
function fa(e) {
|
|
4138
4285
|
return {
|
|
4139
|
-
create:
|
|
4140
|
-
get:
|
|
4141
|
-
list:
|
|
4142
|
-
remove:
|
|
4143
|
-
update:
|
|
4286
|
+
create: sa(e),
|
|
4287
|
+
get: ca(e),
|
|
4288
|
+
list: la(e),
|
|
4289
|
+
remove: ua(e),
|
|
4290
|
+
update: da(e)
|
|
4144
4291
|
};
|
|
4145
4292
|
}
|
|
4146
4293
|
//#endregion
|
|
4147
4294
|
//#region src/organization-connections/index.ts
|
|
4148
|
-
function
|
|
4295
|
+
function G(e, t) {
|
|
4149
4296
|
return {
|
|
4150
4297
|
connection_id: e.connection_id,
|
|
4151
4298
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -4159,14 +4306,14 @@ function B(e, t) {
|
|
|
4159
4306
|
updated_at: e.updated_at
|
|
4160
4307
|
};
|
|
4161
4308
|
}
|
|
4162
|
-
async function
|
|
4309
|
+
async function K(e, t, n) {
|
|
4163
4310
|
let r = await e.selectFrom("connections").select(["name", "strategy"]).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4164
4311
|
if (r) return {
|
|
4165
4312
|
name: r.name,
|
|
4166
4313
|
strategy: typeof r.strategy == "string" ? r.strategy : void 0
|
|
4167
4314
|
};
|
|
4168
4315
|
}
|
|
4169
|
-
function
|
|
4316
|
+
function pa(e) {
|
|
4170
4317
|
return {
|
|
4171
4318
|
async create(t, n, r, i) {
|
|
4172
4319
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -4179,19 +4326,19 @@ function da(e) {
|
|
|
4179
4326
|
created_at: a?.created_at ?? o,
|
|
4180
4327
|
updated_at: a?.updated_at ?? o
|
|
4181
4328
|
};
|
|
4182
|
-
return await e.insertInto("organization_connections").values(s).execute(),
|
|
4329
|
+
return await e.insertInto("organization_connections").values(s).execute(), G(s, await K(e, t, r.connection_id));
|
|
4183
4330
|
},
|
|
4184
4331
|
async list(t, n) {
|
|
4185
4332
|
let r = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).execute(), i = [];
|
|
4186
4333
|
for (let n of r) {
|
|
4187
|
-
let r = await
|
|
4188
|
-
i.push(
|
|
4334
|
+
let r = await K(e, t, n.connection_id);
|
|
4335
|
+
i.push(G(n, r));
|
|
4189
4336
|
}
|
|
4190
4337
|
return i;
|
|
4191
4338
|
},
|
|
4192
4339
|
async get(t, n, r) {
|
|
4193
4340
|
let i = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4194
|
-
return i ?
|
|
4341
|
+
return i ? G(i, await K(e, t, r)) : null;
|
|
4195
4342
|
},
|
|
4196
4343
|
async update(t, n, r, i) {
|
|
4197
4344
|
let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4199,7 +4346,7 @@ function da(e) {
|
|
|
4199
4346
|
let o = await e.updateTable("organization_connections").set(a).where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4200
4347
|
if (Number(o.numUpdatedRows ?? 0) === 0) return null;
|
|
4201
4348
|
let s = await e.selectFrom("organization_connections").selectAll().where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
4202
|
-
return s ?
|
|
4349
|
+
return s ? G(s, await K(e, t, r)) : null;
|
|
4203
4350
|
},
|
|
4204
4351
|
async remove(t, n, r) {
|
|
4205
4352
|
let i = await e.deleteFrom("organization_connections").where("tenant_id", "=", t).where("organization_id", "=", n).where("connection_id", "=", r).executeTakeFirst();
|
|
@@ -4209,7 +4356,7 @@ function da(e) {
|
|
|
4209
4356
|
}
|
|
4210
4357
|
//#endregion
|
|
4211
4358
|
//#region src/user-organizations/create.ts
|
|
4212
|
-
function
|
|
4359
|
+
function ma(e) {
|
|
4213
4360
|
return async (n, r, i) => {
|
|
4214
4361
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
4215
4362
|
id: a?.id ?? t(),
|
|
@@ -4229,7 +4376,7 @@ function fa(e) {
|
|
|
4229
4376
|
}
|
|
4230
4377
|
//#endregion
|
|
4231
4378
|
//#region src/user-organizations/get.ts
|
|
4232
|
-
function
|
|
4379
|
+
function ha(e) {
|
|
4233
4380
|
return async (t, n) => {
|
|
4234
4381
|
let r = await e.selectFrom("user_organizations").selectAll().where("id", "=", n).where("tenant_id", "=", t).executeTakeFirst();
|
|
4235
4382
|
return r ? {
|
|
@@ -4243,13 +4390,13 @@ function pa(e) {
|
|
|
4243
4390
|
}
|
|
4244
4391
|
//#endregion
|
|
4245
4392
|
//#region src/user-organizations/list.ts
|
|
4246
|
-
function
|
|
4393
|
+
function q(e, t) {
|
|
4247
4394
|
return C(e.slice(t.length + 1));
|
|
4248
4395
|
}
|
|
4249
|
-
function
|
|
4396
|
+
function ga(e) {
|
|
4250
4397
|
return async (t, n) => {
|
|
4251
4398
|
let r = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
|
|
4252
|
-
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=",
|
|
4399
|
+
n?.q && (n.q.startsWith("user_id:") ? r = r.where("user_id", "=", q(n.q, "user_id")) : n.q.startsWith("organization_id:") && (r = r.where("organization_id", "=", q(n.q, "organization_id"))));
|
|
4253
4400
|
let i = (e) => ({
|
|
4254
4401
|
id: e.id,
|
|
4255
4402
|
user_id: e.user_id,
|
|
@@ -4257,8 +4404,8 @@ function ma(e) {
|
|
|
4257
4404
|
created_at: e.created_at,
|
|
4258
4405
|
updated_at: e.updated_at
|
|
4259
4406
|
});
|
|
4260
|
-
if (
|
|
4261
|
-
let { rows: e, limit: t, next: a } = await
|
|
4407
|
+
if (N(n)) {
|
|
4408
|
+
let { rows: e, limit: t, next: a } = await P(r, n, {
|
|
4262
4409
|
sortColumn: "created_at",
|
|
4263
4410
|
sortOrder: "desc"
|
|
4264
4411
|
});
|
|
@@ -4271,7 +4418,7 @@ function ma(e) {
|
|
|
4271
4418
|
};
|
|
4272
4419
|
}
|
|
4273
4420
|
let a = n?.page || 0, o = n?.per_page || 50, s = a * o, c = await r.orderBy("created_at", "desc").limit(o).offset(s).execute(), l = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
|
|
4274
|
-
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=",
|
|
4421
|
+
n?.q && (n.q.startsWith("user_id:") ? l = l.where("user_id", "=", q(n.q, "user_id")) : n.q.startsWith("organization_id:") && (l = l.where("organization_id", "=", q(n.q, "organization_id"))));
|
|
4275
4422
|
let u = await l.executeTakeFirst();
|
|
4276
4423
|
return {
|
|
4277
4424
|
userOrganizations: c.map(i),
|
|
@@ -4283,7 +4430,7 @@ function ma(e) {
|
|
|
4283
4430
|
}
|
|
4284
4431
|
//#endregion
|
|
4285
4432
|
//#region src/user-organizations/listUserOrganizations.ts
|
|
4286
|
-
function
|
|
4433
|
+
function _a(e) {
|
|
4287
4434
|
return async (t, n, r) => {
|
|
4288
4435
|
let i = r?.page || 0, a = r?.per_page || 50, o = i * a, s = e.selectFrom("user_organizations").innerJoin("organizations", (e) => e.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)).select([
|
|
4289
4436
|
"organizations.id",
|
|
@@ -4320,12 +4467,12 @@ function ha(e) {
|
|
|
4320
4467
|
}
|
|
4321
4468
|
//#endregion
|
|
4322
4469
|
//#region src/user-organizations/remove.ts
|
|
4323
|
-
function
|
|
4470
|
+
function va(e) {
|
|
4324
4471
|
return async (t, n) => (await e.deleteFrom("user_organizations").where("id", "=", n).where("tenant_id", "=", t).execute()).length > 0;
|
|
4325
4472
|
}
|
|
4326
4473
|
//#endregion
|
|
4327
4474
|
//#region src/user-organizations/update.ts
|
|
4328
|
-
function
|
|
4475
|
+
function ya(e) {
|
|
4329
4476
|
return async (t, n, r) => {
|
|
4330
4477
|
let i = {
|
|
4331
4478
|
...r,
|
|
@@ -4336,19 +4483,19 @@ function _a(e) {
|
|
|
4336
4483
|
}
|
|
4337
4484
|
//#endregion
|
|
4338
4485
|
//#region src/user-organizations/index.ts
|
|
4339
|
-
function
|
|
4486
|
+
function ba(e) {
|
|
4340
4487
|
return {
|
|
4341
|
-
create:
|
|
4342
|
-
get:
|
|
4343
|
-
list:
|
|
4344
|
-
listUserOrganizations:
|
|
4345
|
-
remove:
|
|
4346
|
-
update:
|
|
4488
|
+
create: ma(e),
|
|
4489
|
+
get: ha(e),
|
|
4490
|
+
list: ga(e),
|
|
4491
|
+
listUserOrganizations: _a(e),
|
|
4492
|
+
remove: va(e),
|
|
4493
|
+
update: ya(e)
|
|
4347
4494
|
};
|
|
4348
4495
|
}
|
|
4349
4496
|
//#endregion
|
|
4350
4497
|
//#region src/invites/create.ts
|
|
4351
|
-
function
|
|
4498
|
+
function xa(e) {
|
|
4352
4499
|
return async (t, n, r) => {
|
|
4353
4500
|
let i = r?.importMetadata, a = i?.id ?? n.id ?? Ie(), o = i?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(), s = n.ttl_sec || 604800, c = new Date(new Date(o).getTime() + s * 1e3).toISOString(), l = {
|
|
4354
4501
|
id: a,
|
|
@@ -4394,7 +4541,7 @@ function ya(e) {
|
|
|
4394
4541
|
}
|
|
4395
4542
|
//#endregion
|
|
4396
4543
|
//#region src/invites/get.ts
|
|
4397
|
-
function
|
|
4544
|
+
function Sa(e) {
|
|
4398
4545
|
return async (t, n) => {
|
|
4399
4546
|
let r = await e.selectFrom("invites").selectAll().where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst();
|
|
4400
4547
|
return r ? l({
|
|
@@ -4411,7 +4558,7 @@ function ba(e) {
|
|
|
4411
4558
|
}
|
|
4412
4559
|
//#endregion
|
|
4413
4560
|
//#region src/invites/list.ts
|
|
4414
|
-
function
|
|
4561
|
+
function Ca(e) {
|
|
4415
4562
|
return async (t, n) => {
|
|
4416
4563
|
let r = e.selectFrom("invites").selectAll().where("tenant_id", "=", t).orderBy("created_at", "desc");
|
|
4417
4564
|
if (n?.per_page && (r = r.limit(n.per_page)), n?.page) {
|
|
@@ -4438,12 +4585,12 @@ function xa(e) {
|
|
|
4438
4585
|
}
|
|
4439
4586
|
//#endregion
|
|
4440
4587
|
//#region src/invites/remove.ts
|
|
4441
|
-
function
|
|
4588
|
+
function wa(e) {
|
|
4442
4589
|
return async (t, n) => (await e.deleteFrom("invites").where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numDeletedRows > 0n;
|
|
4443
4590
|
}
|
|
4444
4591
|
//#endregion
|
|
4445
4592
|
//#region src/invites/update.ts
|
|
4446
|
-
function
|
|
4593
|
+
function Ta(e) {
|
|
4447
4594
|
return async (t, n, r) => {
|
|
4448
4595
|
let i = {};
|
|
4449
4596
|
return r.inviter !== void 0 && (i.inviter = JSON.stringify(r.inviter)), r.invitee !== void 0 && (i.invitee = JSON.stringify(r.invitee)), r.client_id !== void 0 && (i.client_id = r.client_id), r.connection_id !== void 0 && (i.connection_id = r.connection_id), r.app_metadata !== void 0 && (i.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (i.user_metadata = JSON.stringify(r.user_metadata)), r.roles !== void 0 && (i.roles = JSON.stringify(r.roles)), r.ttl_sec !== void 0 && (i.ttl_sec = r.ttl_sec, i.expires_at = new Date(Date.now() + r.ttl_sec * 1e3).toISOString()), r.send_invitation_email !== void 0 && (i.send_invitation_email = +!!r.send_invitation_email), Object.keys(i).length === 0 ? !0 : (await e.updateTable("invites").set(i).where("tenant_id", "=", t).where("id", "=", n).executeTakeFirst()).numUpdatedRows > 0n;
|
|
@@ -4451,35 +4598,35 @@ function Ca(e) {
|
|
|
4451
4598
|
}
|
|
4452
4599
|
//#endregion
|
|
4453
4600
|
//#region src/invites/index.ts
|
|
4454
|
-
function
|
|
4601
|
+
function Ea(e) {
|
|
4455
4602
|
return {
|
|
4456
|
-
create:
|
|
4457
|
-
get:
|
|
4458
|
-
list:
|
|
4459
|
-
remove:
|
|
4460
|
-
update:
|
|
4603
|
+
create: xa(e),
|
|
4604
|
+
get: Sa(e),
|
|
4605
|
+
list: Ca(e),
|
|
4606
|
+
remove: wa(e),
|
|
4607
|
+
update: Ta(e)
|
|
4461
4608
|
};
|
|
4462
4609
|
}
|
|
4463
4610
|
//#endregion
|
|
4464
4611
|
//#region src/stats/index.ts
|
|
4465
|
-
var
|
|
4466
|
-
function
|
|
4612
|
+
var Da = ["s"], Oa = ["pwd_leak"];
|
|
4613
|
+
function ka(e) {
|
|
4467
4614
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4468
4615
|
}
|
|
4469
|
-
function
|
|
4616
|
+
function Aa(e) {
|
|
4470
4617
|
return e.toISOString().split("T")[0];
|
|
4471
4618
|
}
|
|
4472
|
-
function
|
|
4619
|
+
function ja(e) {
|
|
4473
4620
|
return {
|
|
4474
4621
|
async getDaily(t, n = {}) {
|
|
4475
4622
|
let { from: r, to: i } = n, a = /* @__PURE__ */ new Date(), o = new Date(a);
|
|
4476
4623
|
o.setDate(o.getDate() - 30);
|
|
4477
|
-
let s = r ?
|
|
4624
|
+
let s = r ? ka(r) : Aa(o), c = i ? ka(i) : Aa(a), l = f`DATE(logs.date)`;
|
|
4478
4625
|
return (await e.selectFrom("logs").where("tenant_id", "=", t).where(l, ">=", s).where(l, "<=", c).select((e) => [
|
|
4479
4626
|
l.as("date"),
|
|
4480
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4627
|
+
e.fn.sum(e.case().when("type", "in", Da).then(1).else(0).end()).as("logins"),
|
|
4481
4628
|
e.fn.sum(e.case().when("type", "=", "ss").then(1).else(0).end()).as("signups"),
|
|
4482
|
-
e.fn.sum(e.case().when("type", "in",
|
|
4629
|
+
e.fn.sum(e.case().when("type", "in", Oa).then(1).else(0).end()).as("leaked_passwords"),
|
|
4483
4630
|
e.fn.min("date").as("first_event"),
|
|
4484
4631
|
e.fn.max("date").as("last_event")
|
|
4485
4632
|
]).groupBy(l).orderBy("date", "asc").execute()).map((e) => ({
|
|
@@ -4493,13 +4640,13 @@ function ka(e) {
|
|
|
4493
4640
|
},
|
|
4494
4641
|
async getActiveUsers(t) {
|
|
4495
4642
|
let n = /* @__PURE__ */ new Date();
|
|
4496
|
-
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in",
|
|
4643
|
+
return n.setDate(n.getDate() - 30), (await e.selectFrom("logs").where("tenant_id", "=", t).where("date", ">=", n.toISOString()).where("type", "in", Da).where("user_id", "is not", null).select((e) => e.fn.count("user_id").distinct().as("count")).executeTakeFirstOrThrow()).count || 0;
|
|
4497
4644
|
}
|
|
4498
4645
|
};
|
|
4499
4646
|
}
|
|
4500
4647
|
//#endregion
|
|
4501
4648
|
//#region src/analytics/index.ts
|
|
4502
|
-
var
|
|
4649
|
+
var Ma = {
|
|
4503
4650
|
"active-users": ["s", "seacft"],
|
|
4504
4651
|
logins: [
|
|
4505
4652
|
"s",
|
|
@@ -4529,7 +4676,7 @@ var Aa = {
|
|
|
4529
4676
|
"fvr"
|
|
4530
4677
|
],
|
|
4531
4678
|
"codes-sent": ["cls", "cs"]
|
|
4532
|
-
},
|
|
4679
|
+
}, Na = {
|
|
4533
4680
|
"active-users": {
|
|
4534
4681
|
alias: "active_users",
|
|
4535
4682
|
type: "UInt64",
|
|
@@ -4586,14 +4733,14 @@ var Aa = {
|
|
|
4586
4733
|
agg: "count"
|
|
4587
4734
|
}
|
|
4588
4735
|
};
|
|
4589
|
-
async function
|
|
4736
|
+
async function Pa(e) {
|
|
4590
4737
|
try {
|
|
4591
4738
|
return await f`SELECT @@version_comment`.execute(e), "mysql";
|
|
4592
4739
|
} catch {
|
|
4593
4740
|
return "sqlite";
|
|
4594
4741
|
}
|
|
4595
4742
|
}
|
|
4596
|
-
function
|
|
4743
|
+
function Fa(e, t) {
|
|
4597
4744
|
let n = new Intl.DateTimeFormat("en-US", {
|
|
4598
4745
|
timeZone: e,
|
|
4599
4746
|
year: "numeric",
|
|
@@ -4608,7 +4755,7 @@ function U(e, t) {
|
|
|
4608
4755
|
let i = r.hour === "24" ? "00" : r.hour, a = Date.UTC(Number(r.year), Number(r.month) - 1, Number(r.day), Number(i), Number(r.minute), Number(r.second)), o = Math.round((a - t.getTime()) / 6e4), s = o >= 0 ? "+" : "-", c = Math.abs(o);
|
|
4609
4756
|
return `${s}${String(Math.floor(c / 60)).padStart(2, "0")}:${String(c % 60).padStart(2, "0")}`;
|
|
4610
4757
|
}
|
|
4611
|
-
var
|
|
4758
|
+
var Ia = [
|
|
4612
4759
|
"January",
|
|
4613
4760
|
"February",
|
|
4614
4761
|
"March",
|
|
@@ -4622,22 +4769,22 @@ var Na = [
|
|
|
4622
4769
|
"November",
|
|
4623
4770
|
"December"
|
|
4624
4771
|
];
|
|
4625
|
-
function
|
|
4626
|
-
let n = t.getUTCFullYear(), r =
|
|
4772
|
+
function La(e, t) {
|
|
4773
|
+
let n = t.getUTCFullYear(), r = Fa(e, new Date(Date.UTC(n, 0, 1)));
|
|
4627
4774
|
for (let t = 1; t < 12; t++) {
|
|
4628
|
-
let i =
|
|
4629
|
-
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${
|
|
4775
|
+
let i = Fa(e, new Date(Date.UTC(n, t, 1)));
|
|
4776
|
+
if (i !== r) throw Error(`Timezone '${e}' is DST-varying (offset ${r} in January vs ${i} in ${Ia[t]}) and cannot be bucketed with a single fixed offset by the SQL analytics adapter. Use a fixed-offset zone (e.g. 'UTC' or '+02:00').`);
|
|
4630
4777
|
}
|
|
4631
4778
|
}
|
|
4632
|
-
function
|
|
4779
|
+
function Ra(e) {
|
|
4633
4780
|
let t = e.startsWith("-") ? -1 : 1, [n, r] = e.slice(1).split(":");
|
|
4634
4781
|
return t * (Number(n) * 60 + Number(r));
|
|
4635
4782
|
}
|
|
4636
|
-
function
|
|
4783
|
+
function za(e, t) {
|
|
4637
4784
|
let n;
|
|
4638
4785
|
if (t === "+00:00") n = f`${f.ref("logs.date")}`;
|
|
4639
4786
|
else {
|
|
4640
|
-
let e =
|
|
4787
|
+
let e = Ra(t), r = `${e >= 0 ? "+" : "-"}${Math.abs(e)} minutes`;
|
|
4641
4788
|
n = f`datetime(${f.ref("logs.date")}, ${r})`;
|
|
4642
4789
|
}
|
|
4643
4790
|
switch (e) {
|
|
@@ -4648,7 +4795,7 @@ function Ia(e, t) {
|
|
|
4648
4795
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4649
4796
|
}
|
|
4650
4797
|
}
|
|
4651
|
-
function
|
|
4798
|
+
function Ba(e, t) {
|
|
4652
4799
|
if (t === "+00:00") switch (e) {
|
|
4653
4800
|
case "hour": return f`substring(${f.ref("logs.date")}, 1, 13)`;
|
|
4654
4801
|
case "day": return f`substring(${f.ref("logs.date")}, 1, 10)`;
|
|
@@ -4659,7 +4806,7 @@ function La(e, t) {
|
|
|
4659
4806
|
}
|
|
4660
4807
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4661
4808
|
}
|
|
4662
|
-
let n =
|
|
4809
|
+
let n = Ra(t), r = f`date_add(str_to_date(substring(${f.ref("logs.date")}, 1, 19), '%Y-%m-%dT%H:%i:%s'), interval ${f.lit(n)} minute)`;
|
|
4663
4810
|
switch (e) {
|
|
4664
4811
|
case "hour": return f`date_format(${r}, '%Y-%m-%dT%H')`;
|
|
4665
4812
|
case "day": return f`date_format(${r}, '%Y-%m-%d')`;
|
|
@@ -4668,12 +4815,12 @@ function La(e, t) {
|
|
|
4668
4815
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4669
4816
|
}
|
|
4670
4817
|
}
|
|
4671
|
-
function
|
|
4672
|
-
|
|
4673
|
-
let i =
|
|
4674
|
-
return r === "mysql" ?
|
|
4818
|
+
function Va(e, t, n, r) {
|
|
4819
|
+
La(t, n);
|
|
4820
|
+
let i = Fa(t, n);
|
|
4821
|
+
return r === "mysql" ? Ba(e, i) : za(e, i);
|
|
4675
4822
|
}
|
|
4676
|
-
function
|
|
4823
|
+
function Ha(e) {
|
|
4677
4824
|
switch (e) {
|
|
4678
4825
|
case "connection": return "logs.connection";
|
|
4679
4826
|
case "client_id": return "logs.client_id";
|
|
@@ -4682,15 +4829,15 @@ function za(e) {
|
|
|
4682
4829
|
case "time": throw Error("time dimension is handled separately");
|
|
4683
4830
|
}
|
|
4684
4831
|
}
|
|
4685
|
-
function
|
|
4686
|
-
let t = null, n = () => (t ||=
|
|
4832
|
+
function Ua(e) {
|
|
4833
|
+
let t = null, n = () => (t ||= Pa(e), t);
|
|
4687
4834
|
return {
|
|
4688
4835
|
async query(t, r, i) {
|
|
4689
|
-
let a = Date.now(), o =
|
|
4836
|
+
let a = Date.now(), o = Ma[r], s = Na[r], c = await n(), l = [], u = e.selectFrom("logs").where("tenant_id", "=", t);
|
|
4690
4837
|
u = u.where("date", ">=", i.from).where("date", "<", i.to), u = u.where("type", "in", o), i.filters.connection?.length && (u = u.where("connection", "in", i.filters.connection)), i.filters.client_id?.length && (u = u.where("client_id", "in", i.filters.client_id)), i.filters.user_type?.length && (u = u.where("strategy_type", "in", i.filters.user_type)), i.filters.user_id?.length && (u = u.where("user_id", "in", i.filters.user_id));
|
|
4691
4838
|
let d = [], p = [];
|
|
4692
4839
|
for (let e of i.group_by) if (e === "time") {
|
|
4693
|
-
let e =
|
|
4840
|
+
let e = Va(i.interval, i.tz, new Date(i.from), c);
|
|
4694
4841
|
p.push({
|
|
4695
4842
|
alias: "time",
|
|
4696
4843
|
expr: e
|
|
@@ -4699,7 +4846,7 @@ function Ba(e) {
|
|
|
4699
4846
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4700
4847
|
});
|
|
4701
4848
|
} else {
|
|
4702
|
-
let t =
|
|
4849
|
+
let t = Ha(e);
|
|
4703
4850
|
p.push({
|
|
4704
4851
|
alias: e,
|
|
4705
4852
|
expr: f`${f.ref(t)}`
|
|
@@ -4774,7 +4921,7 @@ function Ba(e) {
|
|
|
4774
4921
|
}
|
|
4775
4922
|
//#endregion
|
|
4776
4923
|
//#region src/customText/index.ts
|
|
4777
|
-
function
|
|
4924
|
+
function Wa(e) {
|
|
4778
4925
|
return {
|
|
4779
4926
|
async get(t, n, r) {
|
|
4780
4927
|
let i = await e.selectFrom("custom_text").selectAll().where("tenant_id", "=", t).where("prompt", "=", n).where("language", "=", r).executeTakeFirst();
|
|
@@ -4813,9 +4960,9 @@ function Va(e) {
|
|
|
4813
4960
|
}
|
|
4814
4961
|
//#endregion
|
|
4815
4962
|
//#region src/authenticationMethods/create.ts
|
|
4816
|
-
function
|
|
4963
|
+
function Ga(e) {
|
|
4817
4964
|
return async (t, n, r) => {
|
|
4818
|
-
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ??
|
|
4965
|
+
let i = r?.importMetadata, a = i?.created_at ? new Date(i.created_at).getTime() : Date.now(), o = i?.updated_at ? new Date(i.updated_at).getTime() : a, s = i?.id ?? Br();
|
|
4819
4966
|
return await e.insertInto("authentication_methods").values({
|
|
4820
4967
|
id: s,
|
|
4821
4968
|
tenant_id: t,
|
|
@@ -4852,7 +4999,7 @@ function Ha(e) {
|
|
|
4852
4999
|
}
|
|
4853
5000
|
//#endregion
|
|
4854
5001
|
//#region src/authenticationMethods/get.ts
|
|
4855
|
-
function
|
|
5002
|
+
function Ka(e) {
|
|
4856
5003
|
return async (t, n) => {
|
|
4857
5004
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).selectAll().executeTakeFirst();
|
|
4858
5005
|
return r ? {
|
|
@@ -4875,7 +5022,7 @@ function Ua(e) {
|
|
|
4875
5022
|
}
|
|
4876
5023
|
//#endregion
|
|
4877
5024
|
//#region src/authenticationMethods/getByCredentialId.ts
|
|
4878
|
-
function
|
|
5025
|
+
function qa(e) {
|
|
4879
5026
|
return async (t, n) => {
|
|
4880
5027
|
let r = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", n).selectAll().executeTakeFirst();
|
|
4881
5028
|
return r ? {
|
|
@@ -4898,7 +5045,7 @@ function Wa(e) {
|
|
|
4898
5045
|
}
|
|
4899
5046
|
//#endregion
|
|
4900
5047
|
//#region src/authenticationMethods/list.ts
|
|
4901
|
-
function
|
|
5048
|
+
function Ja(e) {
|
|
4902
5049
|
return async (t, n) => (await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "=", n).selectAll().execute()).map((e) => ({
|
|
4903
5050
|
id: e.id,
|
|
4904
5051
|
user_id: e.user_id,
|
|
@@ -4918,35 +5065,35 @@ function Ga(e) {
|
|
|
4918
5065
|
}
|
|
4919
5066
|
//#endregion
|
|
4920
5067
|
//#region src/authenticationMethods/update.ts
|
|
4921
|
-
function
|
|
5068
|
+
function Ya(e) {
|
|
4922
5069
|
return async (t, n, r) => {
|
|
4923
5070
|
let i = { updated_at_ts: Date.now() };
|
|
4924
5071
|
r.phone_number !== void 0 && (i.phone_number = r.phone_number), r.totp_secret !== void 0 && (i.totp_secret = r.totp_secret), r.credential_id !== void 0 && (i.credential_id = r.credential_id), r.public_key !== void 0 && (i.public_key = r.public_key), r.sign_count !== void 0 && (i.sign_count = r.sign_count), r.credential_backed_up !== void 0 && (i.credential_backed_up = +!!r.credential_backed_up), r.transports !== void 0 && (i.transports = JSON.stringify(r.transports)), r.friendly_name !== void 0 && (i.friendly_name = r.friendly_name), r.confirmed !== void 0 && (i.confirmed = +!!r.confirmed), await e.updateTable("authentication_methods").set(i).where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).execute();
|
|
4925
|
-
let a = await
|
|
5072
|
+
let a = await Ka(e)(t, n);
|
|
4926
5073
|
if (!a) throw Error(`Authentication method ${n} not found`);
|
|
4927
5074
|
return a;
|
|
4928
5075
|
};
|
|
4929
5076
|
}
|
|
4930
5077
|
//#endregion
|
|
4931
5078
|
//#region src/authenticationMethods/remove.ts
|
|
4932
|
-
function
|
|
5079
|
+
function Xa(e) {
|
|
4933
5080
|
return async (t, n) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", n).executeTakeFirst()).numDeletedRows > 0;
|
|
4934
5081
|
}
|
|
4935
5082
|
//#endregion
|
|
4936
5083
|
//#region src/authenticationMethods/index.ts
|
|
4937
|
-
function
|
|
5084
|
+
function Za(e) {
|
|
4938
5085
|
return {
|
|
4939
|
-
create:
|
|
4940
|
-
get:
|
|
4941
|
-
getByCredentialId:
|
|
4942
|
-
list:
|
|
4943
|
-
update:
|
|
4944
|
-
remove:
|
|
5086
|
+
create: Ga(e),
|
|
5087
|
+
get: Ka(e),
|
|
5088
|
+
getByCredentialId: qa(e),
|
|
5089
|
+
list: Ja(e),
|
|
5090
|
+
update: Ya(e),
|
|
5091
|
+
remove: Xa(e)
|
|
4945
5092
|
};
|
|
4946
5093
|
}
|
|
4947
5094
|
//#endregion
|
|
4948
5095
|
//#region src/outbox/getByIds.ts
|
|
4949
|
-
function
|
|
5096
|
+
function Qa(e) {
|
|
4950
5097
|
return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((e) => ({
|
|
4951
5098
|
...JSON.parse(e.payload),
|
|
4952
5099
|
id: e.id,
|
|
@@ -4959,7 +5106,7 @@ function Ya(e) {
|
|
|
4959
5106
|
}
|
|
4960
5107
|
//#endregion
|
|
4961
5108
|
//#region src/outbox/getUnprocessed.ts
|
|
4962
|
-
function
|
|
5109
|
+
function $a(e) {
|
|
4963
5110
|
return async (t) => {
|
|
4964
5111
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
4965
5112
|
return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where((e) => e.or([e("next_retry_at", "is", null), e("next_retry_at", "<=", n)])).where((e) => e.or([e("claimed_by", "is", null), e("claim_expires_at", "<=", n)])).orderBy("created_at", "asc").orderBy("id", "asc").limit(t).execute()).map((e) => ({
|
|
@@ -4975,7 +5122,7 @@ function Xa(e) {
|
|
|
4975
5122
|
}
|
|
4976
5123
|
//#endregion
|
|
4977
5124
|
//#region src/outbox/claimEvents.ts
|
|
4978
|
-
function
|
|
5125
|
+
function eo(e) {
|
|
4979
5126
|
return async (t, n, r) => {
|
|
4980
5127
|
if (t.length === 0) return [];
|
|
4981
5128
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = new Date(Date.now() + r).toISOString();
|
|
@@ -4987,7 +5134,7 @@ function Za(e) {
|
|
|
4987
5134
|
}
|
|
4988
5135
|
//#endregion
|
|
4989
5136
|
//#region src/outbox/markProcessed.ts
|
|
4990
|
-
function
|
|
5137
|
+
function to(e) {
|
|
4991
5138
|
return async (t) => {
|
|
4992
5139
|
if (t.length === 0) return;
|
|
4993
5140
|
let n = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4996,7 +5143,7 @@ function Qa(e) {
|
|
|
4996
5143
|
}
|
|
4997
5144
|
//#endregion
|
|
4998
5145
|
//#region src/outbox/markRetry.ts
|
|
4999
|
-
function
|
|
5146
|
+
function no(e) {
|
|
5000
5147
|
return async (t, n, r) => {
|
|
5001
5148
|
await e.updateTable("outbox_events").set({
|
|
5002
5149
|
error: n,
|
|
@@ -5009,7 +5156,7 @@ function $a(e) {
|
|
|
5009
5156
|
}
|
|
5010
5157
|
//#endregion
|
|
5011
5158
|
//#region src/outbox/deadLetter.ts
|
|
5012
|
-
function
|
|
5159
|
+
function ro(e) {
|
|
5013
5160
|
return async (t, n) => {
|
|
5014
5161
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
5015
5162
|
await e.updateTable("outbox_events").set({
|
|
@@ -5021,7 +5168,7 @@ function eo(e) {
|
|
|
5021
5168
|
}
|
|
5022
5169
|
//#endregion
|
|
5023
5170
|
//#region src/outbox/listFailed.ts
|
|
5024
|
-
function
|
|
5171
|
+
function io(e) {
|
|
5025
5172
|
return async (t, n = {}) => {
|
|
5026
5173
|
let { page: r = 0, per_page: i = 50, include_totals: a = !1 } = n, o = (await e.selectFrom("outbox_events").selectAll().where("tenant_id", "=", t).where("dead_lettered_at", "is not", null).orderBy("dead_lettered_at", "desc").orderBy("id", "asc").offset(r * i).limit(i).execute()).flatMap((e) => {
|
|
5027
5174
|
let t;
|
|
@@ -5056,7 +5203,7 @@ function to(e) {
|
|
|
5056
5203
|
}
|
|
5057
5204
|
//#endregion
|
|
5058
5205
|
//#region src/outbox/replay.ts
|
|
5059
|
-
function
|
|
5206
|
+
function ao(e) {
|
|
5060
5207
|
return async (t, n) => {
|
|
5061
5208
|
let r = await e.updateTable("outbox_events").set({
|
|
5062
5209
|
processed_at: null,
|
|
@@ -5073,7 +5220,7 @@ function no(e) {
|
|
|
5073
5220
|
}
|
|
5074
5221
|
//#endregion
|
|
5075
5222
|
//#region src/outbox/cleanup.ts
|
|
5076
|
-
function
|
|
5223
|
+
function oo(e) {
|
|
5077
5224
|
return async (t) => {
|
|
5078
5225
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5079
5226
|
return Number(n.numDeletedRows);
|
|
@@ -5081,23 +5228,23 @@ function ro(e) {
|
|
|
5081
5228
|
}
|
|
5082
5229
|
//#endregion
|
|
5083
5230
|
//#region src/outbox/index.ts
|
|
5084
|
-
function
|
|
5231
|
+
function so(e) {
|
|
5085
5232
|
return {
|
|
5086
|
-
create:
|
|
5087
|
-
getByIds:
|
|
5088
|
-
getUnprocessed:
|
|
5089
|
-
claimEvents:
|
|
5090
|
-
markProcessed:
|
|
5091
|
-
markRetry:
|
|
5092
|
-
deadLetter:
|
|
5093
|
-
listFailed:
|
|
5094
|
-
replay:
|
|
5095
|
-
cleanup:
|
|
5233
|
+
create: tt(e),
|
|
5234
|
+
getByIds: Qa(e),
|
|
5235
|
+
getUnprocessed: $a(e),
|
|
5236
|
+
claimEvents: eo(e),
|
|
5237
|
+
markProcessed: to(e),
|
|
5238
|
+
markRetry: no(e),
|
|
5239
|
+
deadLetter: ro(e),
|
|
5240
|
+
listFailed: io(e),
|
|
5241
|
+
replay: ao(e),
|
|
5242
|
+
cleanup: oo(e)
|
|
5096
5243
|
};
|
|
5097
5244
|
}
|
|
5098
5245
|
//#endregion
|
|
5099
5246
|
//#region src/log-streams/index.ts
|
|
5100
|
-
function
|
|
5247
|
+
function co(e) {
|
|
5101
5248
|
return {
|
|
5102
5249
|
id: e.id,
|
|
5103
5250
|
name: e.name,
|
|
@@ -5110,7 +5257,7 @@ function W(e) {
|
|
|
5110
5257
|
updated_at: e.updated_at
|
|
5111
5258
|
};
|
|
5112
5259
|
}
|
|
5113
|
-
function
|
|
5260
|
+
function lo(e) {
|
|
5114
5261
|
return {
|
|
5115
5262
|
async create(n, r, i) {
|
|
5116
5263
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5125,14 +5272,14 @@ function ao(e) {
|
|
|
5125
5272
|
created_at: a?.created_at ?? o,
|
|
5126
5273
|
updated_at: a?.updated_at ?? o
|
|
5127
5274
|
};
|
|
5128
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5275
|
+
return await e.insertInto("log_streams").values(s).execute(), co(s);
|
|
5129
5276
|
},
|
|
5130
5277
|
async get(t, n) {
|
|
5131
5278
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5132
|
-
return r ?
|
|
5279
|
+
return r ? co(r) : null;
|
|
5133
5280
|
},
|
|
5134
5281
|
async list(t) {
|
|
5135
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5282
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(co);
|
|
5136
5283
|
},
|
|
5137
5284
|
async update(t, n, r) {
|
|
5138
5285
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5145,7 +5292,7 @@ function ao(e) {
|
|
|
5145
5292
|
}
|
|
5146
5293
|
//#endregion
|
|
5147
5294
|
//#region src/migrationSources/index.ts
|
|
5148
|
-
function
|
|
5295
|
+
function uo(e) {
|
|
5149
5296
|
return {
|
|
5150
5297
|
id: e.id,
|
|
5151
5298
|
name: e.name,
|
|
@@ -5157,7 +5304,7 @@ function G(e) {
|
|
|
5157
5304
|
updated_at: e.updated_at
|
|
5158
5305
|
};
|
|
5159
5306
|
}
|
|
5160
|
-
function
|
|
5307
|
+
function fo(e) {
|
|
5161
5308
|
return {
|
|
5162
5309
|
async create(n, r, i) {
|
|
5163
5310
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5171,14 +5318,14 @@ function oo(e) {
|
|
|
5171
5318
|
created_at: a?.created_at ?? o,
|
|
5172
5319
|
updated_at: a?.updated_at ?? o
|
|
5173
5320
|
};
|
|
5174
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5321
|
+
return await e.insertInto("migration_sources").values(l).execute(), uo(l);
|
|
5175
5322
|
},
|
|
5176
5323
|
async get(t, n) {
|
|
5177
5324
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5178
|
-
return r ?
|
|
5325
|
+
return r ? uo(r) : null;
|
|
5179
5326
|
},
|
|
5180
5327
|
async list(t) {
|
|
5181
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5328
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(uo);
|
|
5182
5329
|
},
|
|
5183
5330
|
async update(t, n, r) {
|
|
5184
5331
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5191,19 +5338,19 @@ function oo(e) {
|
|
|
5191
5338
|
}
|
|
5192
5339
|
//#endregion
|
|
5193
5340
|
//#region src/proxyRoutes/serialize.ts
|
|
5194
|
-
function
|
|
5341
|
+
function po(e) {
|
|
5195
5342
|
return {
|
|
5196
5343
|
id: e.id,
|
|
5197
5344
|
tenant_id: e.tenant_id,
|
|
5198
5345
|
custom_domain_id: e.custom_domain_id,
|
|
5199
5346
|
priority: e.priority,
|
|
5200
|
-
match:
|
|
5201
|
-
handlers:
|
|
5347
|
+
match: mo(e.match),
|
|
5348
|
+
handlers: ho(e.handlers),
|
|
5202
5349
|
created_at: e.created_at,
|
|
5203
5350
|
updated_at: e.updated_at
|
|
5204
5351
|
};
|
|
5205
5352
|
}
|
|
5206
|
-
function
|
|
5353
|
+
function mo(e) {
|
|
5207
5354
|
if (!e) return { path: "/*" };
|
|
5208
5355
|
try {
|
|
5209
5356
|
let t = JSON.parse(e), n = ce.safeParse(t);
|
|
@@ -5211,7 +5358,7 @@ function so(e) {
|
|
|
5211
5358
|
} catch {}
|
|
5212
5359
|
return { path: "/*" };
|
|
5213
5360
|
}
|
|
5214
|
-
function
|
|
5361
|
+
function ho(e) {
|
|
5215
5362
|
if (!e) return [];
|
|
5216
5363
|
try {
|
|
5217
5364
|
let t = JSON.parse(e);
|
|
@@ -5228,7 +5375,7 @@ function co(e) {
|
|
|
5228
5375
|
}
|
|
5229
5376
|
//#endregion
|
|
5230
5377
|
//#region src/proxyRoutes/adapter.ts
|
|
5231
|
-
function
|
|
5378
|
+
function go(e) {
|
|
5232
5379
|
return {
|
|
5233
5380
|
async create(n, r, i) {
|
|
5234
5381
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5254,14 +5401,14 @@ function q(e) {
|
|
|
5254
5401
|
},
|
|
5255
5402
|
async get(t, n) {
|
|
5256
5403
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5257
|
-
return r ?
|
|
5404
|
+
return r ? po(r) : null;
|
|
5258
5405
|
},
|
|
5259
5406
|
async list(t, n = {}) {
|
|
5260
5407
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5261
5408
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5262
5409
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5263
5410
|
return {
|
|
5264
|
-
proxy_routes: o.map(
|
|
5411
|
+
proxy_routes: o.map(po),
|
|
5265
5412
|
start: r * i,
|
|
5266
5413
|
limit: i,
|
|
5267
5414
|
length: o.length
|
|
@@ -5281,7 +5428,7 @@ function q(e) {
|
|
|
5281
5428
|
}
|
|
5282
5429
|
//#endregion
|
|
5283
5430
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5284
|
-
async function
|
|
5431
|
+
async function _o(e, t) {
|
|
5285
5432
|
let n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n), i = (r.endsWith(".") ? r.slice(0, -1) : r).toLowerCase(), a = await e.selectFrom("custom_domains").where("domain", "=", i).select([
|
|
5286
5433
|
"custom_domain_id",
|
|
5287
5434
|
"tenant_id",
|
|
@@ -5293,20 +5440,20 @@ async function lo(e, t) {
|
|
|
5293
5440
|
tenant_id: a.tenant_id,
|
|
5294
5441
|
custom_domain_id: a.custom_domain_id,
|
|
5295
5442
|
domain: a.domain,
|
|
5296
|
-
routes: o.map(
|
|
5443
|
+
routes: o.map(po)
|
|
5297
5444
|
};
|
|
5298
5445
|
}
|
|
5299
5446
|
//#endregion
|
|
5300
5447
|
//#region src/proxyRoutes/index.ts
|
|
5301
|
-
function
|
|
5448
|
+
function vo(e) {
|
|
5302
5449
|
return {
|
|
5303
|
-
proxyRoutes:
|
|
5304
|
-
resolveHost: (t) =>
|
|
5450
|
+
proxyRoutes: go(e),
|
|
5451
|
+
resolveHost: (t) => _o(e, t)
|
|
5305
5452
|
};
|
|
5306
5453
|
}
|
|
5307
5454
|
//#endregion
|
|
5308
5455
|
//#region src/scim/adapter.ts
|
|
5309
|
-
function
|
|
5456
|
+
function yo(e) {
|
|
5310
5457
|
if (!e) return [];
|
|
5311
5458
|
try {
|
|
5312
5459
|
let t = JSON.parse(e);
|
|
@@ -5321,7 +5468,7 @@ function fo(e) {
|
|
|
5321
5468
|
return [];
|
|
5322
5469
|
}
|
|
5323
5470
|
}
|
|
5324
|
-
function
|
|
5471
|
+
function bo(e) {
|
|
5325
5472
|
if (!e) return [];
|
|
5326
5473
|
try {
|
|
5327
5474
|
let t = JSON.parse(e);
|
|
@@ -5330,16 +5477,16 @@ function po(e) {
|
|
|
5330
5477
|
return [];
|
|
5331
5478
|
}
|
|
5332
5479
|
}
|
|
5333
|
-
function
|
|
5480
|
+
function xo(e) {
|
|
5334
5481
|
return {
|
|
5335
5482
|
connection_id: e.connection_id,
|
|
5336
5483
|
user_id_attribute: e.user_id_attribute,
|
|
5337
|
-
mapping:
|
|
5484
|
+
mapping: yo(e.mapping),
|
|
5338
5485
|
created_at: e.created_at,
|
|
5339
5486
|
updated_at: e.updated_at
|
|
5340
5487
|
};
|
|
5341
5488
|
}
|
|
5342
|
-
function
|
|
5489
|
+
function So(e) {
|
|
5343
5490
|
return {
|
|
5344
5491
|
async create(t, n) {
|
|
5345
5492
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5360,7 +5507,7 @@ function ho(e) {
|
|
|
5360
5507
|
},
|
|
5361
5508
|
async get(t, n) {
|
|
5362
5509
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5363
|
-
return r ?
|
|
5510
|
+
return r ? xo(r) : null;
|
|
5364
5511
|
},
|
|
5365
5512
|
async update(t, n, r) {
|
|
5366
5513
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5374,18 +5521,18 @@ function ho(e) {
|
|
|
5374
5521
|
}
|
|
5375
5522
|
};
|
|
5376
5523
|
}
|
|
5377
|
-
function
|
|
5524
|
+
function Co(e) {
|
|
5378
5525
|
return {
|
|
5379
5526
|
token_id: e.token_id,
|
|
5380
5527
|
connection_id: e.connection_id,
|
|
5381
5528
|
token_hash: e.token_hash,
|
|
5382
|
-
scopes:
|
|
5529
|
+
scopes: bo(e.scopes),
|
|
5383
5530
|
valid_until: e.valid_until ?? void 0,
|
|
5384
5531
|
created_at: e.created_at,
|
|
5385
5532
|
last_used_at: e.last_used_at ?? void 0
|
|
5386
5533
|
};
|
|
5387
5534
|
}
|
|
5388
|
-
function
|
|
5535
|
+
function wo(e) {
|
|
5389
5536
|
return {
|
|
5390
5537
|
async create(t, n) {
|
|
5391
5538
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5409,14 +5556,14 @@ function _o(e) {
|
|
|
5409
5556
|
},
|
|
5410
5557
|
async get(t, n) {
|
|
5411
5558
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5412
|
-
return r ?
|
|
5559
|
+
return r ? Co(r) : null;
|
|
5413
5560
|
},
|
|
5414
5561
|
async getByHash(t, n) {
|
|
5415
5562
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5416
|
-
return r ?
|
|
5563
|
+
return r ? Co(r) : null;
|
|
5417
5564
|
},
|
|
5418
5565
|
async listByConnection(t, n) {
|
|
5419
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5566
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Co);
|
|
5420
5567
|
},
|
|
5421
5568
|
async markUsed(t, n, r) {
|
|
5422
5569
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5428,7 +5575,7 @@ function _o(e) {
|
|
|
5428
5575
|
}
|
|
5429
5576
|
};
|
|
5430
5577
|
}
|
|
5431
|
-
function
|
|
5578
|
+
function To(e) {
|
|
5432
5579
|
return {
|
|
5433
5580
|
connection_id: e.connection_id,
|
|
5434
5581
|
external_id: e.external_id,
|
|
@@ -5436,7 +5583,7 @@ function vo(e) {
|
|
|
5436
5583
|
created_at: e.created_at
|
|
5437
5584
|
};
|
|
5438
5585
|
}
|
|
5439
|
-
function
|
|
5586
|
+
function Eo(e) {
|
|
5440
5587
|
return {
|
|
5441
5588
|
async create(t, n) {
|
|
5442
5589
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5455,11 +5602,11 @@ function yo(e) {
|
|
|
5455
5602
|
},
|
|
5456
5603
|
async getByExternalId(t, n, r) {
|
|
5457
5604
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5458
|
-
return i ?
|
|
5605
|
+
return i ? To(i) : null;
|
|
5459
5606
|
},
|
|
5460
5607
|
async getByUserId(t, n, r) {
|
|
5461
5608
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5462
|
-
return i ?
|
|
5609
|
+
return i ? To(i) : null;
|
|
5463
5610
|
},
|
|
5464
5611
|
async remove(t, n, r) {
|
|
5465
5612
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5469,7 +5616,7 @@ function yo(e) {
|
|
|
5469
5616
|
}
|
|
5470
5617
|
//#endregion
|
|
5471
5618
|
//#region src/tenantOperations/index.ts
|
|
5472
|
-
function
|
|
5619
|
+
function Do(e) {
|
|
5473
5620
|
if (!e) return null;
|
|
5474
5621
|
try {
|
|
5475
5622
|
let t = JSON.parse(e);
|
|
@@ -5491,8 +5638,8 @@ function J(e) {
|
|
|
5491
5638
|
target_database_version: e.target_database_version,
|
|
5492
5639
|
error: e.error,
|
|
5493
5640
|
initiated_by: e.initiated_by,
|
|
5494
|
-
input:
|
|
5495
|
-
result:
|
|
5641
|
+
input: Do(e.input),
|
|
5642
|
+
result: Do(e.result),
|
|
5496
5643
|
claimed_by: e.claimed_by,
|
|
5497
5644
|
claim_expires_at: e.claim_expires_at,
|
|
5498
5645
|
created_at: e.created_at,
|
|
@@ -5500,7 +5647,7 @@ function J(e) {
|
|
|
5500
5647
|
finished_at: e.finished_at
|
|
5501
5648
|
});
|
|
5502
5649
|
}
|
|
5503
|
-
function
|
|
5650
|
+
function Oo(e) {
|
|
5504
5651
|
return {
|
|
5505
5652
|
async create(n) {
|
|
5506
5653
|
let r = ye.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5583,27 +5730,27 @@ function xo(e) {
|
|
|
5583
5730
|
}
|
|
5584
5731
|
//#endregion
|
|
5585
5732
|
//#region src/utils/monotonic-id.ts
|
|
5586
|
-
var
|
|
5587
|
-
function
|
|
5733
|
+
var ko = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ao = 32, jo = 10, Mo = 4, No = 10;
|
|
5734
|
+
function Po(e, t) {
|
|
5588
5735
|
let n = "";
|
|
5589
|
-
for (let r = t; r > 0; r--) n =
|
|
5736
|
+
for (let r = t; r > 0; r--) n = ko.charAt(e % Ao) + n, e = Math.floor(e / Ao);
|
|
5590
5737
|
return n;
|
|
5591
5738
|
}
|
|
5592
|
-
function
|
|
5593
|
-
let e = new Uint8Array(
|
|
5739
|
+
function Fo() {
|
|
5740
|
+
let e = new Uint8Array(No);
|
|
5594
5741
|
crypto.getRandomValues(e);
|
|
5595
5742
|
let t = "";
|
|
5596
|
-
for (let n = 0; n <
|
|
5743
|
+
for (let n = 0; n < No; n++) t += ko.charAt(e[n] % Ao);
|
|
5597
5744
|
return t;
|
|
5598
5745
|
}
|
|
5599
|
-
var
|
|
5600
|
-
function
|
|
5746
|
+
var Io = 0, Lo = 0;
|
|
5747
|
+
function Ro() {
|
|
5601
5748
|
let e = Date.now();
|
|
5602
|
-
return e ===
|
|
5749
|
+
return e === Io ? Lo++ : (Io = e, Lo = 0), Po(e, jo) + Po(Lo, Mo) + Fo();
|
|
5603
5750
|
}
|
|
5604
5751
|
//#endregion
|
|
5605
5752
|
//#region src/tenantOperationEvents/index.ts
|
|
5606
|
-
function
|
|
5753
|
+
function zo(e) {
|
|
5607
5754
|
if (!e) return null;
|
|
5608
5755
|
try {
|
|
5609
5756
|
let t = JSON.parse(e);
|
|
@@ -5611,22 +5758,22 @@ function Mo(e) {
|
|
|
5611
5758
|
} catch {}
|
|
5612
5759
|
return null;
|
|
5613
5760
|
}
|
|
5614
|
-
function
|
|
5761
|
+
function Bo(e) {
|
|
5615
5762
|
return ve.parse({
|
|
5616
5763
|
id: e.id,
|
|
5617
5764
|
operation_id: e.operation_id,
|
|
5618
5765
|
step: e.step,
|
|
5619
5766
|
outcome: e.outcome,
|
|
5620
|
-
detail:
|
|
5767
|
+
detail: zo(e.detail),
|
|
5621
5768
|
attempt: e.attempt,
|
|
5622
5769
|
created_at: e.created_at
|
|
5623
5770
|
});
|
|
5624
5771
|
}
|
|
5625
|
-
function
|
|
5772
|
+
function Vo(e) {
|
|
5626
5773
|
return {
|
|
5627
5774
|
async create(t) {
|
|
5628
5775
|
let n = _e.parse(t), r = {
|
|
5629
|
-
id: `evt_${
|
|
5776
|
+
id: `evt_${Ro()}`,
|
|
5630
5777
|
operation_id: n.operation_id,
|
|
5631
5778
|
step: n.step,
|
|
5632
5779
|
outcome: n.outcome,
|
|
@@ -5634,12 +5781,12 @@ function Po(e) {
|
|
|
5634
5781
|
attempt: n.attempt,
|
|
5635
5782
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5636
5783
|
};
|
|
5637
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5784
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Bo(r);
|
|
5638
5785
|
},
|
|
5639
5786
|
async listByOperation(t, n = {}) {
|
|
5640
5787
|
let r = n.page ?? 0, i = n.per_page ?? 100, a = await e.selectFrom("tenant_operation_events").where("operation_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").offset(r * i).limit(i).execute();
|
|
5641
5788
|
return {
|
|
5642
|
-
events: a.map(
|
|
5789
|
+
events: a.map(Bo),
|
|
5643
5790
|
start: r * i,
|
|
5644
5791
|
limit: i,
|
|
5645
5792
|
length: a.length
|
|
@@ -5649,16 +5796,16 @@ function Po(e) {
|
|
|
5649
5796
|
}
|
|
5650
5797
|
//#endregion
|
|
5651
5798
|
//#region src/tenantOperationRows/index.ts
|
|
5652
|
-
var
|
|
5653
|
-
function
|
|
5799
|
+
var Ho = 50;
|
|
5800
|
+
function Uo(e) {
|
|
5654
5801
|
let t = JSON.parse(e);
|
|
5655
5802
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5656
5803
|
}
|
|
5657
|
-
function
|
|
5804
|
+
function Wo(e) {
|
|
5658
5805
|
return xe.parse({
|
|
5659
5806
|
operation_id: e.operation_id,
|
|
5660
5807
|
seq: e.seq,
|
|
5661
|
-
payload:
|
|
5808
|
+
payload: Uo(e.payload),
|
|
5662
5809
|
status: e.status,
|
|
5663
5810
|
error_code: e.error_code,
|
|
5664
5811
|
error_message: e.error_message,
|
|
@@ -5668,7 +5815,7 @@ function Lo(e) {
|
|
|
5668
5815
|
updated_at: e.updated_at
|
|
5669
5816
|
});
|
|
5670
5817
|
}
|
|
5671
|
-
function
|
|
5818
|
+
function Go(e) {
|
|
5672
5819
|
return {
|
|
5673
5820
|
async createMany(t) {
|
|
5674
5821
|
if (t.length === 0) return 0;
|
|
@@ -5687,11 +5834,11 @@ function Ro(e) {
|
|
|
5687
5834
|
updated_at: n
|
|
5688
5835
|
};
|
|
5689
5836
|
});
|
|
5690
|
-
for (let t = 0; t < r.length; t +=
|
|
5837
|
+
for (let t = 0; t < r.length; t += Ho) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + Ho)).execute();
|
|
5691
5838
|
return r.length;
|
|
5692
5839
|
},
|
|
5693
5840
|
async claimPending(t, n) {
|
|
5694
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5841
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(Wo);
|
|
5695
5842
|
},
|
|
5696
5843
|
async recordOutcomes(t, n) {
|
|
5697
5844
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5740,7 +5887,7 @@ function Ro(e) {
|
|
|
5740
5887
|
}
|
|
5741
5888
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5742
5889
|
return {
|
|
5743
|
-
rows: o.map(
|
|
5890
|
+
rows: o.map(Wo),
|
|
5744
5891
|
start: r * i,
|
|
5745
5892
|
limit: i,
|
|
5746
5893
|
length: o.length
|
|
@@ -5754,7 +5901,7 @@ function Ro(e) {
|
|
|
5754
5901
|
}
|
|
5755
5902
|
//#endregion
|
|
5756
5903
|
//#region src/rollouts/index.ts
|
|
5757
|
-
function
|
|
5904
|
+
function Ko(e) {
|
|
5758
5905
|
if (!e) return null;
|
|
5759
5906
|
try {
|
|
5760
5907
|
return JSON.parse(e);
|
|
@@ -5762,7 +5909,7 @@ function zo(e) {
|
|
|
5762
5909
|
return null;
|
|
5763
5910
|
}
|
|
5764
5911
|
}
|
|
5765
|
-
function
|
|
5912
|
+
function qo(e) {
|
|
5766
5913
|
return pe.parse({
|
|
5767
5914
|
id: e.id,
|
|
5768
5915
|
kind: e.kind,
|
|
@@ -5770,15 +5917,15 @@ function Bo(e) {
|
|
|
5770
5917
|
target_worker_version: e.target_worker_version,
|
|
5771
5918
|
target_database_version: e.target_database_version,
|
|
5772
5919
|
wave_size: e.wave_size,
|
|
5773
|
-
canary_tenant_ids:
|
|
5774
|
-
filter:
|
|
5920
|
+
canary_tenant_ids: Ko(e.canary_tenant_ids),
|
|
5921
|
+
filter: Ko(e.filter),
|
|
5775
5922
|
initiated_by: e.initiated_by,
|
|
5776
5923
|
created_at: e.created_at,
|
|
5777
5924
|
updated_at: e.updated_at,
|
|
5778
5925
|
finished_at: e.finished_at
|
|
5779
5926
|
});
|
|
5780
5927
|
}
|
|
5781
|
-
function
|
|
5928
|
+
function Jo(e) {
|
|
5782
5929
|
return {
|
|
5783
5930
|
async create(n) {
|
|
5784
5931
|
let r = fe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5795,16 +5942,16 @@ function Vo(e) {
|
|
|
5795
5942
|
updated_at: i,
|
|
5796
5943
|
finished_at: null
|
|
5797
5944
|
};
|
|
5798
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
5945
|
+
return await e.insertInto("rollouts").values(a).execute(), qo(a);
|
|
5799
5946
|
},
|
|
5800
5947
|
async get(t) {
|
|
5801
5948
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
5802
|
-
return n ?
|
|
5949
|
+
return n ? qo(n) : null;
|
|
5803
5950
|
},
|
|
5804
5951
|
async list(t = {}) {
|
|
5805
5952
|
let n = t.page ?? 0, r = t.per_page ?? 50, i = await e.selectFrom("rollouts").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").offset(n * r).limit(r).execute();
|
|
5806
5953
|
return {
|
|
5807
|
-
rollouts: i.map(
|
|
5954
|
+
rollouts: i.map(qo),
|
|
5808
5955
|
start: n * r,
|
|
5809
5956
|
limit: r,
|
|
5810
5957
|
length: i.length
|
|
@@ -5824,7 +5971,7 @@ function Vo(e) {
|
|
|
5824
5971
|
}
|
|
5825
5972
|
//#endregion
|
|
5826
5973
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
5827
|
-
var
|
|
5974
|
+
var Yo = class {
|
|
5828
5975
|
migrations;
|
|
5829
5976
|
constructor(e) {
|
|
5830
5977
|
this.migrations = e;
|
|
@@ -5832,10 +5979,10 @@ var Ho = class {
|
|
|
5832
5979
|
async getMigrations() {
|
|
5833
5980
|
return this.migrations;
|
|
5834
5981
|
}
|
|
5835
|
-
},
|
|
5836
|
-
down: () =>
|
|
5837
|
-
up: () =>
|
|
5838
|
-
}),
|
|
5982
|
+
}, Xo = /* @__PURE__ */ T({
|
|
5983
|
+
down: () => es,
|
|
5984
|
+
up: () => $o
|
|
5985
|
+
}), Zo = [
|
|
5839
5986
|
{
|
|
5840
5987
|
table: "authentication_methods",
|
|
5841
5988
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6101,7 +6248,7 @@ var Ho = class {
|
|
|
6101
6248
|
onDelete: "cascade"
|
|
6102
6249
|
}
|
|
6103
6250
|
];
|
|
6104
|
-
async function
|
|
6251
|
+
async function Qo(e) {
|
|
6105
6252
|
try {
|
|
6106
6253
|
return await f`select sqlite_version()`.execute(e), !0;
|
|
6107
6254
|
} catch {
|
|
@@ -6110,14 +6257,14 @@ async function Go(e) {
|
|
|
6110
6257
|
}
|
|
6111
6258
|
function Y(e, t) {
|
|
6112
6259
|
let n = e;
|
|
6113
|
-
for (let e of
|
|
6260
|
+
for (let e of Zo) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6114
6261
|
let n = t;
|
|
6115
6262
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6116
6263
|
}));
|
|
6117
6264
|
return n;
|
|
6118
6265
|
}
|
|
6119
|
-
async function
|
|
6120
|
-
let t = await
|
|
6266
|
+
async function $o(e) {
|
|
6267
|
+
let t = await Qo(e);
|
|
6121
6268
|
await e.schema.createTable("tenants").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("audience", f`varchar(255)`).addColumn("sender_email", f`varchar(255)`).addColumn("sender_name", f`varchar(255)`).addColumn("created_at", f`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(255)`, (e) => e.notNull()).addColumn("support_url", f`varchar(255)`).addColumn("idle_session_lifetime", f`int`).addColumn("session_lifetime", f`int`).addColumn("session_cookie", f`text`).addColumn("allowed_logout_urls", f`text`).addColumn("ephemeral_session_lifetime", f`int`).addColumn("idle_ephemeral_session_lifetime", f`int`).addColumn("default_redirection_uri", f`text`).addColumn("enabled_locales", f`text`).addColumn("default_directory", f`varchar(255)`).addColumn("error_page", f`text`).addColumn("flags", f`text`).addColumn("friendly_name", f`varchar(255)`).addColumn("picture_url", f`text`).addColumn("support_email", f`varchar(255)`).addColumn("sandbox_version", f`varchar(50)`).addColumn("sandbox_versions_available", f`text`).addColumn("legacy_sandbox_version", f`varchar(50)`).addColumn("change_password", f`text`).addColumn("guardian_mfa_page", f`text`).addColumn("device_flow", f`text`).addColumn("default_token_quota", f`text`).addColumn("default_audience", f`varchar(255)`).addColumn("default_organization", f`varchar(255)`).addColumn("sessions", f`text`).addColumn("oidc_logout", f`text`).addColumn("allow_organization_name_in_authentication_api", f`int`).addColumn("customize_mfa_in_postlogin_action", f`int`).addColumn("acr_values_supported", f`text`).addColumn("mtls", f`text`).addColumn("pushed_authorization_requests_supported", f`int`).addColumn("authorization_response_iss_parameter_supported", f`int`).addColumn("mfa", f`text`).addColumn("attack_protection", f`text`).addColumn("default_client_id", f`varchar(255)`).addColumn("deployment_type", f`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", f`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", f`varchar(2048)`).addColumn("provisioning_state_changed_at", f`varchar(35)`).addColumn("bundle_configuration", f`varchar(64)`).addColumn("worker_version", f`varchar(64)`).addColumn("worker_script_name", f`varchar(255)`).addColumn("storage_kind", f`varchar(32)`).addColumn("d1_database_id", f`varchar(64)`).addColumn("database_version", f`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", f`varchar(64)`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("results", f`text`, (e) => e.notNull()).addColumn("logs", f`text`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("action_id", f`varchar(255)`, (e) => e.notNull()).addColumn("number", f`int`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("name", f`varchar(255)`, (e) => e.notNull()).addColumn("code", f`text`, (e) => e.notNull()).addColumn("runtime", f`varchar(50)`).addColumn("status", f`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", f`text`).addColumn("dependencies", f`text`).addColumn("supported_triggers", f`text`).addColumn("deployed_at_ts", f`bigint`).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("is_system", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", f`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
6122
6269
|
{
|
|
6123
6270
|
let n = e.schema.createTable("authentication_methods").addColumn("id", f`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(191)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("type", f`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", f`varchar(32)`).addColumn("totp_secret", f`varchar(255)`).addColumn("confirmed", f`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", f`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", f`bigint`, (e) => e.notNull()).addColumn("credential_id", f`varchar(512)`).addColumn("public_key", f`text`).addColumn("sign_count", f`int`).addColumn("credential_backed_up", f`int`).addColumn("transports", f`varchar(512)`).addColumn("friendly_name", f`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
@@ -6304,40 +6451,40 @@ async function Ko(e) {
|
|
|
6304
6451
|
"tenant_id",
|
|
6305
6452
|
"phone_number",
|
|
6306
6453
|
"provider"
|
|
6307
|
-
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of
|
|
6454
|
+
]).execute(), await e.schema.createIndex("users_user_id_tenant_id").on("users").columns(["user_id", "tenant_id"]).execute(), t && (await e.schema.createIndex("FK_codes_user_id_tenant_id_constraint").on("codes").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("grants_user_id_constraint").on("grants").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("login_sessions_session_fk").on("login_sessions").columns(["tenant_id", "session_id"]).execute(), await e.schema.createIndex("organization_connections_organization_fk").on("organization_connections").columns(["organization_id"]).execute(), await e.schema.createIndex("password_history_user_id_tenant_id_constraint").on("passwords").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("refresh_tokens_client_fk").on("refresh_tokens").columns(["tenant_id", "client_id"]).execute(), await e.schema.createIndex("sessions_user_fk").on("sessions").columns(["user_id", "tenant_id"]).execute(), await e.schema.createIndex("user_activity_user_id_constraint").on("user_activity").columns(["user_id", "tenant_id"]).execute()), !t) for (let t of Zo) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6308
6455
|
let n = e;
|
|
6309
6456
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6310
6457
|
}).execute();
|
|
6311
6458
|
}
|
|
6312
|
-
async function
|
|
6459
|
+
async function es(e) {
|
|
6313
6460
|
await e.schema.dropTable("user_roles").ifExists().execute(), await e.schema.dropTable("user_permissions").ifExists().execute(), await e.schema.dropTable("user_organizations").ifExists().execute(), await e.schema.dropTable("user_activity").ifExists().execute(), await e.schema.dropTable("universal_login_templates").ifExists().execute(), await e.schema.dropTable("themes").ifExists().execute(), await e.schema.dropTable("tenant_operation_events").ifExists().execute(), await e.schema.dropTable("tenant_operations").ifExists().execute(), await e.schema.dropTable("rollouts").ifExists().execute(), await e.schema.dropTable("roles").ifExists().execute(), await e.schema.dropTable("role_permissions").ifExists().execute(), await e.schema.dropTable("resource_servers").ifExists().execute(), await e.schema.dropTable("refresh_tokens").ifExists().execute(), await e.schema.dropTable("proxy_routes").ifExists().execute(), await e.schema.dropTable("prompt_settings").ifExists().execute(), await e.schema.dropTable("passwords").ifExists().execute(), await e.schema.dropTable("outbox_events").ifExists().execute(), await e.schema.dropTable("organization_connections").ifExists().execute(), await e.schema.dropTable("organizations").ifExists().execute(), await e.schema.dropTable("migrations").ifExists().execute(), await e.schema.dropTable("migration_sources").ifExists().execute(), await e.schema.dropTable("logs").ifExists().execute(), await e.schema.dropTable("login_sessions").ifExists().execute(), await e.schema.dropTable("sessions").ifExists().execute(), await e.schema.dropTable("log_streams").ifExists().execute(), await e.schema.dropTable("keys").ifExists().execute(), await e.schema.dropTable("invites").ifExists().execute(), await e.schema.dropTable("hooks").ifExists().execute(), await e.schema.dropTable("hook_code").ifExists().execute(), await e.schema.dropTable("grants").ifExists().execute(), await e.schema.dropTable("forms").ifExists().execute(), await e.schema.dropTable("flows").ifExists().execute(), await e.schema.dropTable("email_templates").ifExists().execute(), await e.schema.dropTable("email_providers").ifExists().execute(), await e.schema.dropTable("custom_text").ifExists().execute(), await e.schema.dropTable("custom_domains").ifExists().execute(), await e.schema.dropTable("control_plane_comm_keys").ifExists().execute(), await e.schema.dropTable("connections").ifExists().execute(), await e.schema.dropTable("codes").ifExists().execute(), await e.schema.dropTable("users").ifExists().execute(), await e.schema.dropTable("client_registration_tokens").ifExists().execute(), await e.schema.dropTable("client_grants").ifExists().execute(), await e.schema.dropTable("clients").ifExists().execute(), await e.schema.dropTable("branding").ifExists().execute(), await e.schema.dropTable("authentication_methods").ifExists().execute(), await e.schema.dropTable("actions").ifExists().execute(), await e.schema.dropTable("action_versions").ifExists().execute(), await e.schema.dropTable("action_executions").ifExists().execute(), await e.schema.dropTable("tenants").ifExists().execute();
|
|
6314
6461
|
}
|
|
6315
6462
|
//#endregion
|
|
6316
6463
|
//#region migrate/log.ts
|
|
6317
|
-
var
|
|
6318
|
-
function
|
|
6319
|
-
|
|
6464
|
+
var ts = !1;
|
|
6465
|
+
function ns(e) {
|
|
6466
|
+
ts = e;
|
|
6320
6467
|
}
|
|
6321
6468
|
function X(...e) {
|
|
6322
|
-
|
|
6469
|
+
ts && console.log(...e);
|
|
6323
6470
|
}
|
|
6324
6471
|
function Z(...e) {
|
|
6325
6472
|
console.warn(...e);
|
|
6326
6473
|
}
|
|
6327
6474
|
//#endregion
|
|
6328
6475
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6329
|
-
var
|
|
6330
|
-
down: () =>
|
|
6331
|
-
up: () =>
|
|
6332
|
-
}),
|
|
6333
|
-
async function
|
|
6476
|
+
var rs = /* @__PURE__ */ T({
|
|
6477
|
+
down: () => ms,
|
|
6478
|
+
up: () => ds
|
|
6479
|
+
}), is = 5e4, as = 500;
|
|
6480
|
+
async function os(e) {
|
|
6334
6481
|
try {
|
|
6335
6482
|
return await f`SELECT VERSION()`.execute(e), "mysql";
|
|
6336
6483
|
} catch {
|
|
6337
6484
|
return "sqlite";
|
|
6338
6485
|
}
|
|
6339
6486
|
}
|
|
6340
|
-
async function
|
|
6487
|
+
async function ss(e, t, n) {
|
|
6341
6488
|
try {
|
|
6342
6489
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6343
6490
|
} catch (e) {
|
|
@@ -6348,7 +6495,7 @@ async function es(e, t, n) {
|
|
|
6348
6495
|
throw e;
|
|
6349
6496
|
}
|
|
6350
6497
|
}
|
|
6351
|
-
async function
|
|
6498
|
+
async function cs(e, t, n, r) {
|
|
6352
6499
|
try {
|
|
6353
6500
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6354
6501
|
} catch (e) {
|
|
@@ -6359,21 +6506,21 @@ async function ts(e, t, n, r) {
|
|
|
6359
6506
|
throw e;
|
|
6360
6507
|
}
|
|
6361
6508
|
}
|
|
6362
|
-
async function
|
|
6509
|
+
async function ls(e, t) {
|
|
6363
6510
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6364
6511
|
if (t === "sqlite") {
|
|
6365
6512
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6366
6513
|
r = Number(t.numDeletedRows);
|
|
6367
6514
|
} else {
|
|
6368
|
-
let t =
|
|
6369
|
-
for (; t >=
|
|
6370
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6515
|
+
let t = is;
|
|
6516
|
+
for (; t >= is;) {
|
|
6517
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(is).executeTakeFirst();
|
|
6371
6518
|
t = Number(i.numDeletedRows), r += t, t > 0 && X(` Pruned ${r} expired codes row(s)...`);
|
|
6372
6519
|
}
|
|
6373
6520
|
}
|
|
6374
6521
|
return r;
|
|
6375
6522
|
}
|
|
6376
|
-
async function
|
|
6523
|
+
async function us(e) {
|
|
6377
6524
|
let t = 0;
|
|
6378
6525
|
for (;;) {
|
|
6379
6526
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6381,33 +6528,33 @@ async function rs(e) {
|
|
|
6381
6528
|
"code_type",
|
|
6382
6529
|
"tenant_id",
|
|
6383
6530
|
"expires_at"
|
|
6384
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6531
|
+
]).where("expires_at_ts", "is", null).limit(as).execute();
|
|
6385
6532
|
if (n.length === 0) break;
|
|
6386
6533
|
for (let t of n) {
|
|
6387
6534
|
let n = Date.parse(t.expires_at);
|
|
6388
6535
|
await e.updateTable("codes").set({ expires_at_ts: Number.isNaN(n) ? 0 : n }).where("code_id", "=", t.code_id).where("code_type", "=", t.code_type).where("tenant_id", "=", t.tenant_id).execute();
|
|
6389
6536
|
}
|
|
6390
|
-
if (t += n.length, n.length <
|
|
6537
|
+
if (t += n.length, n.length < as) break;
|
|
6391
6538
|
}
|
|
6392
6539
|
return t;
|
|
6393
6540
|
}
|
|
6394
|
-
async function
|
|
6395
|
-
let t = await
|
|
6541
|
+
async function ds(e) {
|
|
6542
|
+
let t = await os(e);
|
|
6396
6543
|
try {
|
|
6397
|
-
let n = await
|
|
6544
|
+
let n = await ls(e, t);
|
|
6398
6545
|
X(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6399
6546
|
} catch (e) {
|
|
6400
6547
|
Z(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6401
6548
|
}
|
|
6402
|
-
await
|
|
6549
|
+
await ss(e, "codes", "expires_at_ts"), await cs(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6403
6550
|
try {
|
|
6404
|
-
let t = await
|
|
6551
|
+
let t = await us(e);
|
|
6405
6552
|
X(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6406
6553
|
} catch (e) {
|
|
6407
6554
|
Z(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6408
6555
|
}
|
|
6409
6556
|
}
|
|
6410
|
-
async function
|
|
6557
|
+
async function fs(e, t, n) {
|
|
6411
6558
|
try {
|
|
6412
6559
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6413
6560
|
} catch (e) {
|
|
@@ -6415,7 +6562,7 @@ async function as(e, t, n) {
|
|
|
6415
6562
|
throw e;
|
|
6416
6563
|
}
|
|
6417
6564
|
}
|
|
6418
|
-
async function
|
|
6565
|
+
async function ps(e, t, n) {
|
|
6419
6566
|
try {
|
|
6420
6567
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6421
6568
|
} catch (e) {
|
|
@@ -6423,16 +6570,16 @@ async function os(e, t, n) {
|
|
|
6423
6570
|
throw e;
|
|
6424
6571
|
}
|
|
6425
6572
|
}
|
|
6426
|
-
async function
|
|
6427
|
-
await
|
|
6573
|
+
async function ms(e) {
|
|
6574
|
+
await fs(e, "idx_codes_expires_at_ts", "codes"), await ps(e, "codes", "expires_at_ts");
|
|
6428
6575
|
}
|
|
6429
6576
|
//#endregion
|
|
6430
6577
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6431
|
-
var
|
|
6432
|
-
down: () =>
|
|
6433
|
-
up: () =>
|
|
6578
|
+
var hs = /* @__PURE__ */ T({
|
|
6579
|
+
down: () => _s,
|
|
6580
|
+
up: () => gs
|
|
6434
6581
|
});
|
|
6435
|
-
async function
|
|
6582
|
+
async function gs(e) {
|
|
6436
6583
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", f`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", f`text`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", f`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", f`varchar(128)`, (e) => e.notNull()).addColumn("scopes", f`text`, (e) => e.notNull()).addColumn("valid_until", f`varchar(35)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", f`varchar(35)`).addPrimaryKeyConstraint("scim_tokens_pk", ["tenant_id", "token_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_connection_idx").on("scim_tokens").columns(["tenant_id", "connection_id"]).execute(), await e.schema.createIndex("scim_tokens_tenant_hash_idx").on("scim_tokens").columns(["tenant_id", "token_hash"]).unique().execute(), await e.schema.createTable("scim_external_ids").addColumn("tenant_id", f`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", f`varchar(255)`, (e) => e.notNull()).addColumn("external_id", f`varchar(255)`, (e) => e.notNull()).addColumn("user_id", f`varchar(255)`, (e) => e.notNull()).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6437
6584
|
"tenant_id",
|
|
6438
6585
|
"connection_id",
|
|
@@ -6443,16 +6590,16 @@ async function ls(e) {
|
|
|
6443
6590
|
"external_id"
|
|
6444
6591
|
]).unique().execute();
|
|
6445
6592
|
}
|
|
6446
|
-
async function
|
|
6593
|
+
async function _s(e) {
|
|
6447
6594
|
await e.schema.dropTable("scim_external_ids").ifExists().execute(), await e.schema.dropTable("scim_tokens").ifExists().execute(), await e.schema.dropTable("scim_configurations").ifExists().execute();
|
|
6448
6595
|
}
|
|
6449
6596
|
//#endregion
|
|
6450
6597
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6451
|
-
var
|
|
6452
|
-
down: () =>
|
|
6453
|
-
up: () =>
|
|
6598
|
+
var vs = /* @__PURE__ */ T({
|
|
6599
|
+
down: () => Ss,
|
|
6600
|
+
up: () => bs
|
|
6454
6601
|
});
|
|
6455
|
-
async function
|
|
6602
|
+
async function ys(e, t, n) {
|
|
6456
6603
|
try {
|
|
6457
6604
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6458
6605
|
} catch (e) {
|
|
@@ -6460,10 +6607,10 @@ async function fs(e, t, n) {
|
|
|
6460
6607
|
throw e;
|
|
6461
6608
|
}
|
|
6462
6609
|
}
|
|
6463
|
-
async function
|
|
6464
|
-
await
|
|
6610
|
+
async function bs(e) {
|
|
6611
|
+
await ys(e, "users", "blocked");
|
|
6465
6612
|
}
|
|
6466
|
-
async function
|
|
6613
|
+
async function xs(e, t, n) {
|
|
6467
6614
|
try {
|
|
6468
6615
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6469
6616
|
} catch (e) {
|
|
@@ -6471,16 +6618,16 @@ async function ms(e, t, n) {
|
|
|
6471
6618
|
throw e;
|
|
6472
6619
|
}
|
|
6473
6620
|
}
|
|
6474
|
-
async function
|
|
6475
|
-
await
|
|
6621
|
+
async function Ss(e) {
|
|
6622
|
+
await xs(e, "users", "blocked");
|
|
6476
6623
|
}
|
|
6477
6624
|
//#endregion
|
|
6478
6625
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6479
|
-
var
|
|
6480
|
-
down: () =>
|
|
6481
|
-
up: () =>
|
|
6626
|
+
var Cs = /* @__PURE__ */ T({
|
|
6627
|
+
down: () => Ds,
|
|
6628
|
+
up: () => Ts
|
|
6482
6629
|
});
|
|
6483
|
-
async function
|
|
6630
|
+
async function ws(e, t, n) {
|
|
6484
6631
|
try {
|
|
6485
6632
|
await e.schema.alterTable(t).addColumn(n, f`tinyint(1)`).execute();
|
|
6486
6633
|
} catch (e) {
|
|
@@ -6488,10 +6635,10 @@ async function _s(e, t, n) {
|
|
|
6488
6635
|
throw e;
|
|
6489
6636
|
}
|
|
6490
6637
|
}
|
|
6491
|
-
async function
|
|
6492
|
-
await
|
|
6638
|
+
async function Ts(e) {
|
|
6639
|
+
await ws(e, "prompt_settings", "show_last_used_connection");
|
|
6493
6640
|
}
|
|
6494
|
-
async function
|
|
6641
|
+
async function Es(e, t, n) {
|
|
6495
6642
|
try {
|
|
6496
6643
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6497
6644
|
} catch (e) {
|
|
@@ -6499,16 +6646,16 @@ async function ys(e, t, n) {
|
|
|
6499
6646
|
throw e;
|
|
6500
6647
|
}
|
|
6501
6648
|
}
|
|
6502
|
-
async function
|
|
6503
|
-
await
|
|
6649
|
+
async function Ds(e) {
|
|
6650
|
+
await Es(e, "prompt_settings", "show_last_used_connection");
|
|
6504
6651
|
}
|
|
6505
6652
|
//#endregion
|
|
6506
6653
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6507
|
-
var
|
|
6508
|
-
down: () =>
|
|
6509
|
-
up: () =>
|
|
6654
|
+
var Os = /* @__PURE__ */ T({
|
|
6655
|
+
down: () => js,
|
|
6656
|
+
up: () => As
|
|
6510
6657
|
});
|
|
6511
|
-
async function
|
|
6658
|
+
async function ks(e, t, n, r) {
|
|
6512
6659
|
try {
|
|
6513
6660
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6514
6661
|
} catch (e) {
|
|
@@ -6519,10 +6666,10 @@ async function Ss(e, t, n, r) {
|
|
|
6519
6666
|
throw e;
|
|
6520
6667
|
}
|
|
6521
6668
|
}
|
|
6522
|
-
async function
|
|
6523
|
-
await
|
|
6669
|
+
async function As(e) {
|
|
6670
|
+
await ks(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6524
6671
|
}
|
|
6525
|
-
async function
|
|
6672
|
+
async function js(e) {
|
|
6526
6673
|
try {
|
|
6527
6674
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6528
6675
|
} catch (e) {
|
|
@@ -6532,11 +6679,11 @@ async function ws(e) {
|
|
|
6532
6679
|
}
|
|
6533
6680
|
//#endregion
|
|
6534
6681
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6535
|
-
var
|
|
6536
|
-
down: () =>
|
|
6537
|
-
up: () =>
|
|
6682
|
+
var Ms = /* @__PURE__ */ T({
|
|
6683
|
+
down: () => Is,
|
|
6684
|
+
up: () => Ps
|
|
6538
6685
|
});
|
|
6539
|
-
async function
|
|
6686
|
+
async function Ns(e, t, n, r) {
|
|
6540
6687
|
try {
|
|
6541
6688
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6542
6689
|
} catch (e) {
|
|
@@ -6544,10 +6691,10 @@ async function Es(e, t, n, r) {
|
|
|
6544
6691
|
throw e;
|
|
6545
6692
|
}
|
|
6546
6693
|
}
|
|
6547
|
-
async function
|
|
6548
|
-
await
|
|
6694
|
+
async function Ps(e) {
|
|
6695
|
+
await Ns(e, "hooks", "page_id", f`varchar(64)`), await Ns(e, "hooks", "permission_required", f`varchar(255)`);
|
|
6549
6696
|
}
|
|
6550
|
-
async function
|
|
6697
|
+
async function Fs(e, t, n) {
|
|
6551
6698
|
try {
|
|
6552
6699
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6553
6700
|
} catch (e) {
|
|
@@ -6555,22 +6702,22 @@ async function Os(e, t, n) {
|
|
|
6555
6702
|
throw e;
|
|
6556
6703
|
}
|
|
6557
6704
|
}
|
|
6558
|
-
async function
|
|
6559
|
-
await
|
|
6705
|
+
async function Is(e) {
|
|
6706
|
+
await Fs(e, "hooks", "permission_required"), await Fs(e, "hooks", "page_id");
|
|
6560
6707
|
}
|
|
6561
6708
|
//#endregion
|
|
6562
6709
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6563
|
-
var
|
|
6564
|
-
down: () =>
|
|
6565
|
-
up: () =>
|
|
6566
|
-
}),
|
|
6710
|
+
var Ls = /* @__PURE__ */ T({
|
|
6711
|
+
down: () => Us,
|
|
6712
|
+
up: () => Vs
|
|
6713
|
+
}), Rs = [
|
|
6567
6714
|
["session_id", f`varchar(26)`],
|
|
6568
6715
|
["organization", f`varchar(191)`],
|
|
6569
6716
|
["auth_connection", f`varchar(255)`],
|
|
6570
6717
|
["auth_strategy_strategy", f`varchar(64)`],
|
|
6571
6718
|
["auth_strategy_strategy_type", f`varchar(64)`]
|
|
6572
6719
|
];
|
|
6573
|
-
async function
|
|
6720
|
+
async function zs(e, t, n, r) {
|
|
6574
6721
|
try {
|
|
6575
6722
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6576
6723
|
} catch (e) {
|
|
@@ -6578,7 +6725,7 @@ async function Ms(e, t, n, r) {
|
|
|
6578
6725
|
throw e;
|
|
6579
6726
|
}
|
|
6580
6727
|
}
|
|
6581
|
-
async function
|
|
6728
|
+
async function Bs(e) {
|
|
6582
6729
|
try {
|
|
6583
6730
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6584
6731
|
} catch (e) {
|
|
@@ -6586,11 +6733,11 @@ async function Ns(e) {
|
|
|
6586
6733
|
throw e;
|
|
6587
6734
|
}
|
|
6588
6735
|
}
|
|
6589
|
-
async function
|
|
6590
|
-
for (let [t, n] of
|
|
6591
|
-
await
|
|
6736
|
+
async function Vs(e) {
|
|
6737
|
+
for (let [t, n] of Rs) await zs(e, "refresh_tokens", t, n);
|
|
6738
|
+
await Bs(e);
|
|
6592
6739
|
}
|
|
6593
|
-
async function
|
|
6740
|
+
async function Hs(e, t, n) {
|
|
6594
6741
|
try {
|
|
6595
6742
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6596
6743
|
} catch (e) {
|
|
@@ -6598,23 +6745,23 @@ async function Fs(e, t, n) {
|
|
|
6598
6745
|
throw e;
|
|
6599
6746
|
}
|
|
6600
6747
|
}
|
|
6601
|
-
async function
|
|
6748
|
+
async function Us(e) {
|
|
6602
6749
|
try {
|
|
6603
6750
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6604
6751
|
} catch {}
|
|
6605
|
-
for (let [t] of
|
|
6752
|
+
for (let [t] of Rs) await Hs(e, "refresh_tokens", t);
|
|
6606
6753
|
}
|
|
6607
6754
|
//#endregion
|
|
6608
6755
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6609
|
-
var
|
|
6610
|
-
down: () =>
|
|
6611
|
-
up: () =>
|
|
6612
|
-
}),
|
|
6613
|
-
async function
|
|
6756
|
+
var Ws = /* @__PURE__ */ T({
|
|
6757
|
+
down: () => Xs,
|
|
6758
|
+
up: () => Ys
|
|
6759
|
+
}), Gs = 500, Ks = 20, qs = 500, Js = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6760
|
+
async function Ys(e) {
|
|
6614
6761
|
try {
|
|
6615
6762
|
let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select((e) => e.fn.countAll().as("count")).executeTakeFirst(), n = Number(t?.count ?? 0);
|
|
6616
|
-
if (n >
|
|
6617
|
-
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6763
|
+
if (n > qs) {
|
|
6764
|
+
Z(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${qs}. SKIPPING — run the bulk path instead: ${Js}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6618
6765
|
return;
|
|
6619
6766
|
}
|
|
6620
6767
|
if (n === 0) {
|
|
@@ -6631,10 +6778,10 @@ async function Hs(e) {
|
|
|
6631
6778
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6632
6779
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6633
6780
|
"login_sessions.auth_params as ls_auth_params"
|
|
6634
|
-
]).limit(
|
|
6781
|
+
]).limit(Gs).execute();
|
|
6635
6782
|
if (t.length === 0) break;
|
|
6636
|
-
for (let n = 0; n < t.length; n +=
|
|
6637
|
-
let r = t.slice(n, n +
|
|
6783
|
+
for (let n = 0; n < t.length; n += Ks) {
|
|
6784
|
+
let r = t.slice(n, n + Ks);
|
|
6638
6785
|
await Promise.all(r.map(async (t) => {
|
|
6639
6786
|
let n = null;
|
|
6640
6787
|
if (t.ls_auth_params) try {
|
|
@@ -6651,19 +6798,19 @@ async function Hs(e) {
|
|
|
6651
6798
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6652
6799
|
}));
|
|
6653
6800
|
}
|
|
6654
|
-
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6801
|
+
if (r += t.length, X(`refresh_tokens backfill: ${r} rows populated so far`), t.length < Gs) break;
|
|
6655
6802
|
}
|
|
6656
6803
|
X(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6657
6804
|
} catch (e) {
|
|
6658
6805
|
throw Z("refresh_tokens backfill failed:", e), e;
|
|
6659
6806
|
}
|
|
6660
6807
|
}
|
|
6661
|
-
async function
|
|
6808
|
+
async function Xs() {}
|
|
6662
6809
|
//#endregion
|
|
6663
6810
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6664
|
-
var
|
|
6665
|
-
down: () =>
|
|
6666
|
-
up: () =>
|
|
6811
|
+
var Zs = /* @__PURE__ */ T({
|
|
6812
|
+
down: () => ec,
|
|
6813
|
+
up: () => $s
|
|
6667
6814
|
});
|
|
6668
6815
|
async function Q(e, t, n, r) {
|
|
6669
6816
|
try {
|
|
@@ -6673,7 +6820,7 @@ async function Q(e, t, n, r) {
|
|
|
6673
6820
|
throw e;
|
|
6674
6821
|
}
|
|
6675
6822
|
}
|
|
6676
|
-
async function
|
|
6823
|
+
async function Qs(e, t, n, r) {
|
|
6677
6824
|
try {
|
|
6678
6825
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6679
6826
|
} catch (e) {
|
|
@@ -6681,12 +6828,12 @@ async function Gs(e, t, n, r) {
|
|
|
6681
6828
|
throw e;
|
|
6682
6829
|
}
|
|
6683
6830
|
}
|
|
6684
|
-
async function
|
|
6685
|
-
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await
|
|
6831
|
+
async function $s(e) {
|
|
6832
|
+
await Q(e, "tenant_operations", "input", f`text`), await Q(e, "tenant_operations", "result", f`text`), await Q(e, "tenant_operations", "claimed_by", f`varchar(255)`), await Q(e, "tenant_operations", "claim_expires_at", f`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", f`varchar(255)`, (e) => e.notNull()).addColumn("seq", f`int`, (e) => e.notNull()).addColumn("payload", f`text`, (e) => e.notNull()).addColumn("status", f`varchar(32)`, (e) => e.notNull()).addColumn("error_code", f`varchar(64)`).addColumn("error_message", f`text`).addColumn("error_path", f`varchar(255)`).addColumn("entity_id", f`varchar(255)`).addColumn("created_at", f`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", f`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await Qs(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6686
6833
|
"operation_id",
|
|
6687
6834
|
"status",
|
|
6688
6835
|
"seq"
|
|
6689
|
-
]), await
|
|
6836
|
+
]), await Qs(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6690
6837
|
"kind",
|
|
6691
6838
|
"status",
|
|
6692
6839
|
"created_at"
|
|
@@ -6700,7 +6847,7 @@ async function $(e, t, n) {
|
|
|
6700
6847
|
throw e;
|
|
6701
6848
|
}
|
|
6702
6849
|
}
|
|
6703
|
-
async function
|
|
6850
|
+
async function ec(e) {
|
|
6704
6851
|
try {
|
|
6705
6852
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6706
6853
|
} catch {}
|
|
@@ -6708,35 +6855,35 @@ async function qs(e) {
|
|
|
6708
6855
|
}
|
|
6709
6856
|
//#endregion
|
|
6710
6857
|
//#region migrate/migrations/index.ts
|
|
6711
|
-
var
|
|
6712
|
-
"2026-07-16T14:00:00_baseline":
|
|
6713
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6714
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6715
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6716
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6717
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6718
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6719
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6720
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6721
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
6858
|
+
var tc = {
|
|
6859
|
+
"2026-07-16T14:00:00_baseline": Xo,
|
|
6860
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": rs,
|
|
6861
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": hs,
|
|
6862
|
+
"2026-08-05T12:00:00_user_blocked": vs,
|
|
6863
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Cs,
|
|
6864
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": Os,
|
|
6865
|
+
"2026-08-11T12:00:00_page_hooks": Ms,
|
|
6866
|
+
"2026-08-20T12:00:00_refresh_token_session_id": Ls,
|
|
6867
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": Ws,
|
|
6868
|
+
"2026-09-01T12:00:00_tenant_operation_rows": Zs
|
|
6722
6869
|
};
|
|
6723
6870
|
//#endregion
|
|
6724
6871
|
//#region migrate/migrate.ts
|
|
6725
|
-
async function
|
|
6726
|
-
|
|
6872
|
+
async function nc(e, t = !1) {
|
|
6873
|
+
ns(t), t && console.log("migrating...");
|
|
6727
6874
|
let { error: n, results: r } = await new Te({
|
|
6728
6875
|
db: e,
|
|
6729
|
-
provider: new
|
|
6876
|
+
provider: new Yo(tc)
|
|
6730
6877
|
}).migrateToLatest();
|
|
6731
6878
|
if (r?.forEach((e) => {
|
|
6732
6879
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6733
6880
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6734
6881
|
}
|
|
6735
|
-
async function
|
|
6736
|
-
|
|
6882
|
+
async function rc(e, t = !1) {
|
|
6883
|
+
ns(t), t && console.log("migrating...");
|
|
6737
6884
|
let { error: n, results: r } = await new Te({
|
|
6738
6885
|
db: e,
|
|
6739
|
-
provider: new
|
|
6886
|
+
provider: new Yo(tc)
|
|
6740
6887
|
}).migrateDown();
|
|
6741
6888
|
if (r?.forEach((e) => {
|
|
6742
6889
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -6744,65 +6891,65 @@ async function Xs(e, t = !1) {
|
|
|
6744
6891
|
}
|
|
6745
6892
|
//#endregion
|
|
6746
6893
|
//#region src/index.ts
|
|
6747
|
-
function
|
|
6894
|
+
function ic(e, t = { useTransactions: !0 }) {
|
|
6748
6895
|
let n = {
|
|
6749
|
-
actions:
|
|
6750
|
-
actionExecutions:
|
|
6751
|
-
actionVersions:
|
|
6752
|
-
branding:
|
|
6753
|
-
clients:
|
|
6754
|
-
clientConnections:
|
|
6755
|
-
clientGrants:
|
|
6756
|
-
clientRegistrationTokens:
|
|
6757
|
-
codes:
|
|
6758
|
-
connections:
|
|
6759
|
-
emailProviders:
|
|
6760
|
-
emailTemplates:
|
|
6761
|
-
customDomains:
|
|
6896
|
+
actions: We(e),
|
|
6897
|
+
actionExecutions: Ze(e),
|
|
6898
|
+
actionVersions: et(e),
|
|
6899
|
+
branding: pr(e),
|
|
6900
|
+
clients: kn(e),
|
|
6901
|
+
clientConnections: Fn(e),
|
|
6902
|
+
clientGrants: Hn(e),
|
|
6903
|
+
clientRegistrationTokens: $n(e),
|
|
6904
|
+
codes: pn(e),
|
|
6905
|
+
connections: bn(e),
|
|
6906
|
+
emailProviders: $r(e),
|
|
6907
|
+
emailTemplates: oi(e),
|
|
6908
|
+
customDomains: ur(e),
|
|
6762
6909
|
flows: kt(e),
|
|
6763
|
-
forms:
|
|
6764
|
-
hookCode:
|
|
6765
|
-
hooks:
|
|
6766
|
-
invites:
|
|
6767
|
-
keys:
|
|
6768
|
-
loginSessions:
|
|
6910
|
+
forms: Ti(e),
|
|
6911
|
+
hookCode: Or(e),
|
|
6912
|
+
hooks: Cr(e),
|
|
6913
|
+
invites: Ea(e),
|
|
6914
|
+
keys: rr(e),
|
|
6915
|
+
loginSessions: Wr(e),
|
|
6769
6916
|
logs: Gt(e),
|
|
6770
|
-
logStreams:
|
|
6771
|
-
migrationSources:
|
|
6772
|
-
authenticationMethods:
|
|
6917
|
+
logStreams: lo(e),
|
|
6918
|
+
migrationSources: fo(e),
|
|
6919
|
+
authenticationMethods: Za(e),
|
|
6773
6920
|
passwords: nn(e),
|
|
6774
|
-
promptSettings:
|
|
6775
|
-
proxyRoutes:
|
|
6776
|
-
scimConfigurations:
|
|
6777
|
-
scimTokens:
|
|
6778
|
-
scimExternalIds:
|
|
6779
|
-
refreshTokens:
|
|
6780
|
-
resourceServers:
|
|
6781
|
-
rolePermissions:
|
|
6782
|
-
grants:
|
|
6783
|
-
userPermissions:
|
|
6784
|
-
userRoles:
|
|
6785
|
-
roles:
|
|
6921
|
+
promptSettings: Jr(e),
|
|
6922
|
+
proxyRoutes: go(e),
|
|
6923
|
+
scimConfigurations: So(e),
|
|
6924
|
+
scimTokens: wo(e),
|
|
6925
|
+
scimExternalIds: Eo(e),
|
|
6926
|
+
refreshTokens: _i(e),
|
|
6927
|
+
resourceServers: Mi(e),
|
|
6928
|
+
rolePermissions: Ui(e),
|
|
6929
|
+
grants: Yi(e),
|
|
6930
|
+
userPermissions: ea(e),
|
|
6931
|
+
userRoles: oa(e),
|
|
6932
|
+
roles: Ri(e),
|
|
6786
6933
|
sessions: Zt(e),
|
|
6787
|
-
sessionCleanup:
|
|
6934
|
+
sessionCleanup: yi(e),
|
|
6788
6935
|
tenants: Lt(e),
|
|
6789
|
-
tenantOperations:
|
|
6790
|
-
tenantOperationEvents:
|
|
6791
|
-
tenantOperationRows:
|
|
6792
|
-
rollouts:
|
|
6793
|
-
themes:
|
|
6794
|
-
universalLoginTemplates:
|
|
6795
|
-
customText:
|
|
6936
|
+
tenantOperations: Oo(e),
|
|
6937
|
+
tenantOperationEvents: Vo(e),
|
|
6938
|
+
tenantOperationRows: Go(e),
|
|
6939
|
+
rollouts: Jo(e),
|
|
6940
|
+
themes: Nr(e),
|
|
6941
|
+
universalLoginTemplates: _r(e),
|
|
6942
|
+
customText: Wa(e),
|
|
6796
6943
|
users: xt(e),
|
|
6797
6944
|
userActivity: vt(e),
|
|
6798
|
-
organizations:
|
|
6799
|
-
organizationConnections:
|
|
6800
|
-
userOrganizations:
|
|
6801
|
-
stats:
|
|
6802
|
-
analytics:
|
|
6803
|
-
outbox:
|
|
6945
|
+
organizations: fa(e),
|
|
6946
|
+
organizationConnections: pa(e),
|
|
6947
|
+
userOrganizations: ba(e),
|
|
6948
|
+
stats: ja(e),
|
|
6949
|
+
analytics: Ua(e),
|
|
6950
|
+
outbox: so(e),
|
|
6804
6951
|
async transaction(r) {
|
|
6805
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
6952
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(ic(e, {
|
|
6806
6953
|
...t,
|
|
6807
6954
|
useTransactions: !1
|
|
6808
6955
|
})));
|
|
@@ -6811,4 +6958,4 @@ function Zs(e, t = { useTransactions: !0 }) {
|
|
|
6811
6958
|
return n;
|
|
6812
6959
|
}
|
|
6813
6960
|
//#endregion
|
|
6814
|
-
export {
|
|
6961
|
+
export { vo as createProxyDataAdapter, go as createProxyRoutesAdapter, ic as default, rc as migrateDown, nc as migrateToLatest };
|