@authhero/kysely-adapter 12.11.0 → 12.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -5237,8 +5237,16 @@ function po(e) {
|
|
|
5237
5237
|
};
|
|
5238
5238
|
}
|
|
5239
5239
|
//#endregion
|
|
5240
|
-
//#region src/outbox/
|
|
5240
|
+
//#region src/outbox/discard.ts
|
|
5241
5241
|
function mo(e) {
|
|
5242
|
+
return async (t, n) => {
|
|
5243
|
+
let r = await e.deleteFrom("outbox_events").where("id", "=", t).where("tenant_id", "=", n).where("dead_lettered_at", "is not", null).executeTakeFirst();
|
|
5244
|
+
return Number(r.numDeletedRows) > 0;
|
|
5245
|
+
};
|
|
5246
|
+
}
|
|
5247
|
+
//#endregion
|
|
5248
|
+
//#region src/outbox/cleanup.ts
|
|
5249
|
+
function ho(e) {
|
|
5242
5250
|
return async (t) => {
|
|
5243
5251
|
let n = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
|
|
5244
5252
|
return Number(n.numDeletedRows);
|
|
@@ -5246,7 +5254,7 @@ function mo(e) {
|
|
|
5246
5254
|
}
|
|
5247
5255
|
//#endregion
|
|
5248
5256
|
//#region src/outbox/index.ts
|
|
5249
|
-
function
|
|
5257
|
+
function go(e) {
|
|
5250
5258
|
return {
|
|
5251
5259
|
create: st(e),
|
|
5252
5260
|
getByIds: ao(e),
|
|
@@ -5257,12 +5265,13 @@ function ho(e) {
|
|
|
5257
5265
|
deadLetter: uo(e),
|
|
5258
5266
|
listFailed: fo(e),
|
|
5259
5267
|
replay: po(e),
|
|
5260
|
-
|
|
5268
|
+
discard: mo(e),
|
|
5269
|
+
cleanup: ho(e)
|
|
5261
5270
|
};
|
|
5262
5271
|
}
|
|
5263
5272
|
//#endregion
|
|
5264
5273
|
//#region src/log-streams/index.ts
|
|
5265
|
-
function
|
|
5274
|
+
function _o(e) {
|
|
5266
5275
|
return {
|
|
5267
5276
|
id: e.id,
|
|
5268
5277
|
name: e.name,
|
|
@@ -5275,7 +5284,7 @@ function go(e) {
|
|
|
5275
5284
|
updated_at: e.updated_at
|
|
5276
5285
|
};
|
|
5277
5286
|
}
|
|
5278
|
-
function
|
|
5287
|
+
function vo(e) {
|
|
5279
5288
|
return {
|
|
5280
5289
|
async create(n, r, i) {
|
|
5281
5290
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5290,14 +5299,14 @@ function _o(e) {
|
|
|
5290
5299
|
created_at: a?.created_at ?? o,
|
|
5291
5300
|
updated_at: a?.updated_at ?? o
|
|
5292
5301
|
};
|
|
5293
|
-
return await e.insertInto("log_streams").values(s).execute(),
|
|
5302
|
+
return await e.insertInto("log_streams").values(s).execute(), _o(s);
|
|
5294
5303
|
},
|
|
5295
5304
|
async get(t, n) {
|
|
5296
5305
|
let r = await e.selectFrom("log_streams").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5297
|
-
return r ?
|
|
5306
|
+
return r ? _o(r) : null;
|
|
5298
5307
|
},
|
|
5299
5308
|
async list(t) {
|
|
5300
|
-
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5309
|
+
return (await e.selectFrom("log_streams").where("tenant_id", "=", t).selectAll().execute()).map(_o);
|
|
5301
5310
|
},
|
|
5302
5311
|
async update(t, n, r) {
|
|
5303
5312
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5310,7 +5319,7 @@ function _o(e) {
|
|
|
5310
5319
|
}
|
|
5311
5320
|
//#endregion
|
|
5312
5321
|
//#region src/migrationSources/index.ts
|
|
5313
|
-
function
|
|
5322
|
+
function yo(e) {
|
|
5314
5323
|
return {
|
|
5315
5324
|
id: e.id,
|
|
5316
5325
|
name: e.name,
|
|
@@ -5322,7 +5331,7 @@ function vo(e) {
|
|
|
5322
5331
|
updated_at: e.updated_at
|
|
5323
5332
|
};
|
|
5324
5333
|
}
|
|
5325
|
-
function
|
|
5334
|
+
function bo(e) {
|
|
5326
5335
|
return {
|
|
5327
5336
|
async create(n, r, i) {
|
|
5328
5337
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id ?? r.id ?? `mig_${t()}`, c = r.enabled ?? !0, l = {
|
|
@@ -5336,14 +5345,14 @@ function yo(e) {
|
|
|
5336
5345
|
created_at: a?.created_at ?? o,
|
|
5337
5346
|
updated_at: a?.updated_at ?? o
|
|
5338
5347
|
};
|
|
5339
|
-
return await e.insertInto("migration_sources").values(l).execute(),
|
|
5348
|
+
return await e.insertInto("migration_sources").values(l).execute(), yo(l);
|
|
5340
5349
|
},
|
|
5341
5350
|
async get(t, n) {
|
|
5342
5351
|
let r = await e.selectFrom("migration_sources").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5343
|
-
return r ?
|
|
5352
|
+
return r ? yo(r) : null;
|
|
5344
5353
|
},
|
|
5345
5354
|
async list(t) {
|
|
5346
|
-
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(
|
|
5355
|
+
return (await e.selectFrom("migration_sources").where("tenant_id", "=", t).selectAll().execute()).map(yo);
|
|
5347
5356
|
},
|
|
5348
5357
|
async update(t, n, r) {
|
|
5349
5358
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5356,19 +5365,19 @@ function yo(e) {
|
|
|
5356
5365
|
}
|
|
5357
5366
|
//#endregion
|
|
5358
5367
|
//#region src/proxyRoutes/serialize.ts
|
|
5359
|
-
function
|
|
5368
|
+
function xo(e) {
|
|
5360
5369
|
return {
|
|
5361
5370
|
id: e.id,
|
|
5362
5371
|
tenant_id: e.tenant_id,
|
|
5363
5372
|
custom_domain_id: e.custom_domain_id,
|
|
5364
5373
|
priority: e.priority,
|
|
5365
|
-
match:
|
|
5366
|
-
handlers:
|
|
5374
|
+
match: So(e.match),
|
|
5375
|
+
handlers: Co(e.handlers),
|
|
5367
5376
|
created_at: e.created_at,
|
|
5368
5377
|
updated_at: e.updated_at
|
|
5369
5378
|
};
|
|
5370
5379
|
}
|
|
5371
|
-
function
|
|
5380
|
+
function So(e) {
|
|
5372
5381
|
if (!e) return { path: "/*" };
|
|
5373
5382
|
try {
|
|
5374
5383
|
let t = JSON.parse(e), n = ue.safeParse(t);
|
|
@@ -5376,7 +5385,7 @@ function xo(e) {
|
|
|
5376
5385
|
} catch {}
|
|
5377
5386
|
return { path: "/*" };
|
|
5378
5387
|
}
|
|
5379
|
-
function
|
|
5388
|
+
function Co(e) {
|
|
5380
5389
|
if (!e) return [];
|
|
5381
5390
|
try {
|
|
5382
5391
|
let t = JSON.parse(e);
|
|
@@ -5393,7 +5402,7 @@ function So(e) {
|
|
|
5393
5402
|
}
|
|
5394
5403
|
//#endregion
|
|
5395
5404
|
//#region src/proxyRoutes/adapter.ts
|
|
5396
|
-
function
|
|
5405
|
+
function wo(e) {
|
|
5397
5406
|
return {
|
|
5398
5407
|
async create(n, r, i) {
|
|
5399
5408
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = {
|
|
@@ -5419,14 +5428,14 @@ function Co(e) {
|
|
|
5419
5428
|
},
|
|
5420
5429
|
async get(t, n) {
|
|
5421
5430
|
let r = await e.selectFrom("proxy_routes").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5422
|
-
return r ?
|
|
5431
|
+
return r ? xo(r) : null;
|
|
5423
5432
|
},
|
|
5424
5433
|
async list(t, n = {}) {
|
|
5425
5434
|
let r = n.page ?? 0, i = n.per_page ?? 50, a = e.selectFrom("proxy_routes").where("tenant_id", "=", t);
|
|
5426
5435
|
n.custom_domain_id && (a = a.where("custom_domain_id", "=", n.custom_domain_id));
|
|
5427
5436
|
let o = await a.selectAll().orderBy("priority", "asc").orderBy("created_at", "asc").offset(r * i).limit(i).execute();
|
|
5428
5437
|
return {
|
|
5429
|
-
proxy_routes: o.map(
|
|
5438
|
+
proxy_routes: o.map(xo),
|
|
5430
5439
|
start: r * i,
|
|
5431
5440
|
limit: i,
|
|
5432
5441
|
length: o.length
|
|
@@ -5446,7 +5455,7 @@ function Co(e) {
|
|
|
5446
5455
|
}
|
|
5447
5456
|
//#endregion
|
|
5448
5457
|
//#region src/proxyRoutes/resolve-host.ts
|
|
5449
|
-
async function
|
|
5458
|
+
async function To(e, t) {
|
|
5450
5459
|
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([
|
|
5451
5460
|
"custom_domain_id",
|
|
5452
5461
|
"tenant_id",
|
|
@@ -5458,20 +5467,20 @@ async function wo(e, t) {
|
|
|
5458
5467
|
tenant_id: a.tenant_id,
|
|
5459
5468
|
custom_domain_id: a.custom_domain_id,
|
|
5460
5469
|
domain: a.domain,
|
|
5461
|
-
routes: o.map(
|
|
5470
|
+
routes: o.map(xo)
|
|
5462
5471
|
};
|
|
5463
5472
|
}
|
|
5464
5473
|
//#endregion
|
|
5465
5474
|
//#region src/proxyRoutes/index.ts
|
|
5466
|
-
function
|
|
5475
|
+
function Eo(e) {
|
|
5467
5476
|
return {
|
|
5468
|
-
proxyRoutes:
|
|
5469
|
-
resolveHost: (t) =>
|
|
5477
|
+
proxyRoutes: wo(e),
|
|
5478
|
+
resolveHost: (t) => To(e, t)
|
|
5470
5479
|
};
|
|
5471
5480
|
}
|
|
5472
5481
|
//#endregion
|
|
5473
5482
|
//#region src/tokenExchangeProfiles/serialize.ts
|
|
5474
|
-
function
|
|
5483
|
+
function Do(e) {
|
|
5475
5484
|
let t = {
|
|
5476
5485
|
id: e.id,
|
|
5477
5486
|
name: e.name,
|
|
@@ -5481,10 +5490,10 @@ function Eo(e) {
|
|
|
5481
5490
|
updated_at: e.updated_at
|
|
5482
5491
|
};
|
|
5483
5492
|
e.action_id && (t.action_id = e.action_id);
|
|
5484
|
-
let n =
|
|
5493
|
+
let n = Oo(e.jwt_verification);
|
|
5485
5494
|
return n && (t.jwt_verification = n), t;
|
|
5486
5495
|
}
|
|
5487
|
-
function
|
|
5496
|
+
function Oo(e) {
|
|
5488
5497
|
if (e) try {
|
|
5489
5498
|
let t = Te.safeParse(JSON.parse(e));
|
|
5490
5499
|
return t.success ? t.data : void 0;
|
|
@@ -5494,12 +5503,12 @@ function Do(e) {
|
|
|
5494
5503
|
}
|
|
5495
5504
|
//#endregion
|
|
5496
5505
|
//#region src/tokenExchangeProfiles/adapter.ts
|
|
5497
|
-
var
|
|
5498
|
-
function
|
|
5506
|
+
var ko = e("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
5507
|
+
function Ao(e) {
|
|
5499
5508
|
return {
|
|
5500
5509
|
async create(t, n, r) {
|
|
5501
5510
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
5502
|
-
id: i?.id ?? `tep_${
|
|
5511
|
+
id: i?.id ?? `tep_${ko()}`,
|
|
5503
5512
|
tenant_id: t,
|
|
5504
5513
|
name: n.name,
|
|
5505
5514
|
subject_token_type: n.subject_token_type,
|
|
@@ -5509,14 +5518,14 @@ function ko(e) {
|
|
|
5509
5518
|
created_at: i?.created_at ?? a,
|
|
5510
5519
|
updated_at: i?.updated_at ?? a
|
|
5511
5520
|
};
|
|
5512
|
-
return await e.insertInto("token_exchange_profiles").values(o).execute(),
|
|
5521
|
+
return await e.insertInto("token_exchange_profiles").values(o).execute(), Do(o);
|
|
5513
5522
|
},
|
|
5514
5523
|
async get(t, n) {
|
|
5515
5524
|
let r = await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).where("id", "=", n).selectAll().executeTakeFirst();
|
|
5516
|
-
return r ?
|
|
5525
|
+
return r ? Do(r) : null;
|
|
5517
5526
|
},
|
|
5518
5527
|
async list(t) {
|
|
5519
|
-
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(
|
|
5528
|
+
return (await e.selectFrom("token_exchange_profiles").where("tenant_id", "=", t).selectAll().orderBy("created_at", "asc").orderBy("id", "asc").execute()).map(Do);
|
|
5520
5529
|
},
|
|
5521
5530
|
async update(t, n, r) {
|
|
5522
5531
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5532,7 +5541,7 @@ function ko(e) {
|
|
|
5532
5541
|
}
|
|
5533
5542
|
//#endregion
|
|
5534
5543
|
//#region src/scim/adapter.ts
|
|
5535
|
-
function
|
|
5544
|
+
function jo(e) {
|
|
5536
5545
|
if (!e) return [];
|
|
5537
5546
|
try {
|
|
5538
5547
|
let t = JSON.parse(e);
|
|
@@ -5547,7 +5556,7 @@ function Ao(e) {
|
|
|
5547
5556
|
return [];
|
|
5548
5557
|
}
|
|
5549
5558
|
}
|
|
5550
|
-
function
|
|
5559
|
+
function Mo(e) {
|
|
5551
5560
|
if (!e) return [];
|
|
5552
5561
|
try {
|
|
5553
5562
|
let t = JSON.parse(e);
|
|
@@ -5556,16 +5565,16 @@ function jo(e) {
|
|
|
5556
5565
|
return [];
|
|
5557
5566
|
}
|
|
5558
5567
|
}
|
|
5559
|
-
function
|
|
5568
|
+
function No(e) {
|
|
5560
5569
|
return {
|
|
5561
5570
|
connection_id: e.connection_id,
|
|
5562
5571
|
user_id_attribute: e.user_id_attribute,
|
|
5563
|
-
mapping:
|
|
5572
|
+
mapping: jo(e.mapping),
|
|
5564
5573
|
created_at: e.created_at,
|
|
5565
5574
|
updated_at: e.updated_at
|
|
5566
5575
|
};
|
|
5567
5576
|
}
|
|
5568
|
-
function
|
|
5577
|
+
function Po(e) {
|
|
5569
5578
|
return {
|
|
5570
5579
|
async create(t, n) {
|
|
5571
5580
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5586,7 +5595,7 @@ function No(e) {
|
|
|
5586
5595
|
},
|
|
5587
5596
|
async get(t, n) {
|
|
5588
5597
|
let r = await e.selectFrom("scim_configurations").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().executeTakeFirst();
|
|
5589
|
-
return r ?
|
|
5598
|
+
return r ? No(r) : null;
|
|
5590
5599
|
},
|
|
5591
5600
|
async update(t, n, r) {
|
|
5592
5601
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -5600,18 +5609,18 @@ function No(e) {
|
|
|
5600
5609
|
}
|
|
5601
5610
|
};
|
|
5602
5611
|
}
|
|
5603
|
-
function
|
|
5612
|
+
function Fo(e) {
|
|
5604
5613
|
return {
|
|
5605
5614
|
token_id: e.token_id,
|
|
5606
5615
|
connection_id: e.connection_id,
|
|
5607
5616
|
token_hash: e.token_hash,
|
|
5608
|
-
scopes:
|
|
5617
|
+
scopes: Mo(e.scopes),
|
|
5609
5618
|
valid_until: e.valid_until ?? void 0,
|
|
5610
5619
|
created_at: e.created_at,
|
|
5611
5620
|
last_used_at: e.last_used_at ?? void 0
|
|
5612
5621
|
};
|
|
5613
5622
|
}
|
|
5614
|
-
function
|
|
5623
|
+
function Io(e) {
|
|
5615
5624
|
return {
|
|
5616
5625
|
async create(t, n) {
|
|
5617
5626
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5635,14 +5644,14 @@ function Fo(e) {
|
|
|
5635
5644
|
},
|
|
5636
5645
|
async get(t, n) {
|
|
5637
5646
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).selectAll().executeTakeFirst();
|
|
5638
|
-
return r ?
|
|
5647
|
+
return r ? Fo(r) : null;
|
|
5639
5648
|
},
|
|
5640
5649
|
async getByHash(t, n) {
|
|
5641
5650
|
let r = await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("token_hash", "=", n).selectAll().executeTakeFirst();
|
|
5642
|
-
return r ?
|
|
5651
|
+
return r ? Fo(r) : null;
|
|
5643
5652
|
},
|
|
5644
5653
|
async listByConnection(t, n) {
|
|
5645
|
-
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(
|
|
5654
|
+
return (await e.selectFrom("scim_tokens").where("tenant_id", "=", t).where("connection_id", "=", n).selectAll().execute()).map(Fo);
|
|
5646
5655
|
},
|
|
5647
5656
|
async markUsed(t, n, r) {
|
|
5648
5657
|
let i = await e.updateTable("scim_tokens").where("tenant_id", "=", t).where("token_id", "=", n).set({ last_used_at: r }).executeTakeFirst();
|
|
@@ -5654,7 +5663,7 @@ function Fo(e) {
|
|
|
5654
5663
|
}
|
|
5655
5664
|
};
|
|
5656
5665
|
}
|
|
5657
|
-
function
|
|
5666
|
+
function Lo(e) {
|
|
5658
5667
|
return {
|
|
5659
5668
|
connection_id: e.connection_id,
|
|
5660
5669
|
external_id: e.external_id,
|
|
@@ -5662,7 +5671,7 @@ function Io(e) {
|
|
|
5662
5671
|
created_at: e.created_at
|
|
5663
5672
|
};
|
|
5664
5673
|
}
|
|
5665
|
-
function
|
|
5674
|
+
function Ro(e) {
|
|
5666
5675
|
return {
|
|
5667
5676
|
async create(t, n) {
|
|
5668
5677
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5681,11 +5690,11 @@ function Lo(e) {
|
|
|
5681
5690
|
},
|
|
5682
5691
|
async getByExternalId(t, n, r) {
|
|
5683
5692
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("external_id", "=", r).selectAll().executeTakeFirst();
|
|
5684
|
-
return i ?
|
|
5693
|
+
return i ? Lo(i) : null;
|
|
5685
5694
|
},
|
|
5686
5695
|
async getByUserId(t, n, r) {
|
|
5687
5696
|
let i = await e.selectFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).selectAll().executeTakeFirst();
|
|
5688
|
-
return i ?
|
|
5697
|
+
return i ? Lo(i) : null;
|
|
5689
5698
|
},
|
|
5690
5699
|
async remove(t, n, r) {
|
|
5691
5700
|
let i = await e.deleteFrom("scim_external_ids").where("tenant_id", "=", t).where("connection_id", "=", n).where("user_id", "=", r).executeTakeFirst();
|
|
@@ -5695,7 +5704,7 @@ function Lo(e) {
|
|
|
5695
5704
|
}
|
|
5696
5705
|
//#endregion
|
|
5697
5706
|
//#region src/tenantOperations/index.ts
|
|
5698
|
-
function
|
|
5707
|
+
function zo(e) {
|
|
5699
5708
|
if (!e) return null;
|
|
5700
5709
|
try {
|
|
5701
5710
|
let t = JSON.parse(e);
|
|
@@ -5717,8 +5726,8 @@ function G(e) {
|
|
|
5717
5726
|
target_database_version: e.target_database_version,
|
|
5718
5727
|
error: e.error,
|
|
5719
5728
|
initiated_by: e.initiated_by,
|
|
5720
|
-
input:
|
|
5721
|
-
result:
|
|
5729
|
+
input: zo(e.input),
|
|
5730
|
+
result: zo(e.result),
|
|
5722
5731
|
claimed_by: e.claimed_by,
|
|
5723
5732
|
claim_expires_at: e.claim_expires_at,
|
|
5724
5733
|
created_at: e.created_at,
|
|
@@ -5726,7 +5735,7 @@ function G(e) {
|
|
|
5726
5735
|
finished_at: e.finished_at
|
|
5727
5736
|
});
|
|
5728
5737
|
}
|
|
5729
|
-
function
|
|
5738
|
+
function Bo(e) {
|
|
5730
5739
|
return {
|
|
5731
5740
|
async create(n) {
|
|
5732
5741
|
let r = xe.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -5809,27 +5818,27 @@ function zo(e) {
|
|
|
5809
5818
|
}
|
|
5810
5819
|
//#endregion
|
|
5811
5820
|
//#region src/utils/monotonic-id.ts
|
|
5812
|
-
var
|
|
5813
|
-
function
|
|
5821
|
+
var Vo = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ho = 32, Uo = 10, Wo = 4, Go = 10;
|
|
5822
|
+
function Ko(e, t) {
|
|
5814
5823
|
let n = "";
|
|
5815
|
-
for (let r = t; r > 0; r--) n =
|
|
5824
|
+
for (let r = t; r > 0; r--) n = Vo.charAt(e % Ho) + n, e = Math.floor(e / Ho);
|
|
5816
5825
|
return n;
|
|
5817
5826
|
}
|
|
5818
|
-
function
|
|
5819
|
-
let e = new Uint8Array(
|
|
5827
|
+
function qo() {
|
|
5828
|
+
let e = new Uint8Array(Go);
|
|
5820
5829
|
crypto.getRandomValues(e);
|
|
5821
5830
|
let t = "";
|
|
5822
|
-
for (let n = 0; n <
|
|
5831
|
+
for (let n = 0; n < Go; n++) t += Vo.charAt(e[n] % Ho);
|
|
5823
5832
|
return t;
|
|
5824
5833
|
}
|
|
5825
|
-
var
|
|
5826
|
-
function
|
|
5834
|
+
var Jo = 0, Yo = 0;
|
|
5835
|
+
function Xo() {
|
|
5827
5836
|
let e = Date.now();
|
|
5828
|
-
return e ===
|
|
5837
|
+
return e === Jo ? Yo++ : (Jo = e, Yo = 0), Ko(e, Uo) + Ko(Yo, Wo) + qo();
|
|
5829
5838
|
}
|
|
5830
5839
|
//#endregion
|
|
5831
5840
|
//#region src/tenantOperationEvents/index.ts
|
|
5832
|
-
function
|
|
5841
|
+
function Zo(e) {
|
|
5833
5842
|
if (!e) return null;
|
|
5834
5843
|
try {
|
|
5835
5844
|
let t = JSON.parse(e);
|
|
@@ -5837,22 +5846,22 @@ function Xo(e) {
|
|
|
5837
5846
|
} catch {}
|
|
5838
5847
|
return null;
|
|
5839
5848
|
}
|
|
5840
|
-
function
|
|
5849
|
+
function Qo(e) {
|
|
5841
5850
|
return be.parse({
|
|
5842
5851
|
id: e.id,
|
|
5843
5852
|
operation_id: e.operation_id,
|
|
5844
5853
|
step: e.step,
|
|
5845
5854
|
outcome: e.outcome,
|
|
5846
|
-
detail:
|
|
5855
|
+
detail: Zo(e.detail),
|
|
5847
5856
|
attempt: e.attempt,
|
|
5848
5857
|
created_at: e.created_at
|
|
5849
5858
|
});
|
|
5850
5859
|
}
|
|
5851
|
-
function
|
|
5860
|
+
function $o(e) {
|
|
5852
5861
|
return {
|
|
5853
5862
|
async create(t) {
|
|
5854
5863
|
let n = ye.parse(t), r = {
|
|
5855
|
-
id: `evt_${
|
|
5864
|
+
id: `evt_${Xo()}`,
|
|
5856
5865
|
operation_id: n.operation_id,
|
|
5857
5866
|
step: n.step,
|
|
5858
5867
|
outcome: n.outcome,
|
|
@@ -5860,12 +5869,12 @@ function Qo(e) {
|
|
|
5860
5869
|
attempt: n.attempt,
|
|
5861
5870
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5862
5871
|
};
|
|
5863
|
-
return await e.insertInto("tenant_operation_events").values(r).execute(),
|
|
5872
|
+
return await e.insertInto("tenant_operation_events").values(r).execute(), Qo(r);
|
|
5864
5873
|
},
|
|
5865
5874
|
async listByOperation(t, n = {}) {
|
|
5866
5875
|
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();
|
|
5867
5876
|
return {
|
|
5868
|
-
events: a.map(
|
|
5877
|
+
events: a.map(Qo),
|
|
5869
5878
|
start: r * i,
|
|
5870
5879
|
limit: i,
|
|
5871
5880
|
length: a.length
|
|
@@ -5875,16 +5884,16 @@ function Qo(e) {
|
|
|
5875
5884
|
}
|
|
5876
5885
|
//#endregion
|
|
5877
5886
|
//#region src/tenantOperationRows/index.ts
|
|
5878
|
-
var
|
|
5879
|
-
function
|
|
5887
|
+
var es = 50;
|
|
5888
|
+
function ts(e) {
|
|
5880
5889
|
let t = JSON.parse(e);
|
|
5881
5890
|
return t && typeof t == "object" && !Array.isArray(t) ? Object.fromEntries(Object.entries(t)) : {};
|
|
5882
5891
|
}
|
|
5883
|
-
function
|
|
5892
|
+
function ns(e) {
|
|
5884
5893
|
return Ce.parse({
|
|
5885
5894
|
operation_id: e.operation_id,
|
|
5886
5895
|
seq: e.seq,
|
|
5887
|
-
payload:
|
|
5896
|
+
payload: ts(e.payload),
|
|
5888
5897
|
status: e.status,
|
|
5889
5898
|
error_code: e.error_code,
|
|
5890
5899
|
error_message: e.error_message,
|
|
@@ -5894,7 +5903,7 @@ function ts(e) {
|
|
|
5894
5903
|
updated_at: e.updated_at
|
|
5895
5904
|
});
|
|
5896
5905
|
}
|
|
5897
|
-
function
|
|
5906
|
+
function rs(e) {
|
|
5898
5907
|
return {
|
|
5899
5908
|
async createMany(t) {
|
|
5900
5909
|
if (t.length === 0) return 0;
|
|
@@ -5913,11 +5922,11 @@ function ns(e) {
|
|
|
5913
5922
|
updated_at: n
|
|
5914
5923
|
};
|
|
5915
5924
|
});
|
|
5916
|
-
for (let t = 0; t < r.length; t +=
|
|
5925
|
+
for (let t = 0; t < r.length; t += es) await e.insertInto("tenant_operation_rows").values(r.slice(t, t + es)).execute();
|
|
5917
5926
|
return r.length;
|
|
5918
5927
|
},
|
|
5919
5928
|
async claimPending(t, n) {
|
|
5920
|
-
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(
|
|
5929
|
+
return (await e.selectFrom("tenant_operation_rows").where("operation_id", "=", t).where("status", "=", "pending").selectAll().orderBy("seq", "asc").limit(n).execute()).map(ns);
|
|
5921
5930
|
},
|
|
5922
5931
|
async recordOutcomes(t, n) {
|
|
5923
5932
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = 0;
|
|
@@ -5966,7 +5975,7 @@ function ns(e) {
|
|
|
5966
5975
|
}
|
|
5967
5976
|
let o = await a.selectAll().orderBy("seq", "asc").offset(r * i).limit(i).execute();
|
|
5968
5977
|
return {
|
|
5969
|
-
rows: o.map(
|
|
5978
|
+
rows: o.map(ns),
|
|
5970
5979
|
start: r * i,
|
|
5971
5980
|
limit: i,
|
|
5972
5981
|
length: o.length
|
|
@@ -5980,7 +5989,7 @@ function ns(e) {
|
|
|
5980
5989
|
}
|
|
5981
5990
|
//#endregion
|
|
5982
5991
|
//#region src/rollouts/index.ts
|
|
5983
|
-
function
|
|
5992
|
+
function is(e) {
|
|
5984
5993
|
if (!e) return null;
|
|
5985
5994
|
try {
|
|
5986
5995
|
return JSON.parse(e);
|
|
@@ -5988,7 +5997,7 @@ function rs(e) {
|
|
|
5988
5997
|
return null;
|
|
5989
5998
|
}
|
|
5990
5999
|
}
|
|
5991
|
-
function
|
|
6000
|
+
function as(e) {
|
|
5992
6001
|
return he.parse({
|
|
5993
6002
|
id: e.id,
|
|
5994
6003
|
kind: e.kind,
|
|
@@ -5996,15 +6005,15 @@ function is(e) {
|
|
|
5996
6005
|
target_worker_version: e.target_worker_version,
|
|
5997
6006
|
target_database_version: e.target_database_version,
|
|
5998
6007
|
wave_size: e.wave_size,
|
|
5999
|
-
canary_tenant_ids:
|
|
6000
|
-
filter:
|
|
6008
|
+
canary_tenant_ids: is(e.canary_tenant_ids),
|
|
6009
|
+
filter: is(e.filter),
|
|
6001
6010
|
initiated_by: e.initiated_by,
|
|
6002
6011
|
created_at: e.created_at,
|
|
6003
6012
|
updated_at: e.updated_at,
|
|
6004
6013
|
finished_at: e.finished_at
|
|
6005
6014
|
});
|
|
6006
6015
|
}
|
|
6007
|
-
function
|
|
6016
|
+
function os(e) {
|
|
6008
6017
|
return {
|
|
6009
6018
|
async create(n) {
|
|
6010
6019
|
let r = me.parse(n), i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
@@ -6021,16 +6030,16 @@ function as(e) {
|
|
|
6021
6030
|
updated_at: i,
|
|
6022
6031
|
finished_at: null
|
|
6023
6032
|
};
|
|
6024
|
-
return await e.insertInto("rollouts").values(a).execute(),
|
|
6033
|
+
return await e.insertInto("rollouts").values(a).execute(), as(a);
|
|
6025
6034
|
},
|
|
6026
6035
|
async get(t) {
|
|
6027
6036
|
let n = await e.selectFrom("rollouts").where("id", "=", t).selectAll().executeTakeFirst();
|
|
6028
|
-
return n ?
|
|
6037
|
+
return n ? as(n) : null;
|
|
6029
6038
|
},
|
|
6030
6039
|
async list(t = {}) {
|
|
6031
6040
|
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();
|
|
6032
6041
|
return {
|
|
6033
|
-
rollouts: i.map(
|
|
6042
|
+
rollouts: i.map(as),
|
|
6034
6043
|
start: n * r,
|
|
6035
6044
|
limit: r,
|
|
6036
6045
|
length: i.length
|
|
@@ -6050,7 +6059,7 @@ function as(e) {
|
|
|
6050
6059
|
}
|
|
6051
6060
|
//#endregion
|
|
6052
6061
|
//#region migrate/ReferenceMigrationProvider.ts
|
|
6053
|
-
var
|
|
6062
|
+
var ss = class {
|
|
6054
6063
|
migrations;
|
|
6055
6064
|
constructor(e) {
|
|
6056
6065
|
this.migrations = e;
|
|
@@ -6058,10 +6067,10 @@ var os = class {
|
|
|
6058
6067
|
async getMigrations() {
|
|
6059
6068
|
return this.migrations;
|
|
6060
6069
|
}
|
|
6061
|
-
},
|
|
6062
|
-
down: () =>
|
|
6063
|
-
up: () =>
|
|
6064
|
-
}),
|
|
6070
|
+
}, cs = /* @__PURE__ */ w({
|
|
6071
|
+
down: () => fs,
|
|
6072
|
+
up: () => ds
|
|
6073
|
+
}), ls = [
|
|
6065
6074
|
{
|
|
6066
6075
|
table: "authentication_methods",
|
|
6067
6076
|
name: "fk_authentication_methods_tenants",
|
|
@@ -6327,7 +6336,7 @@ var os = class {
|
|
|
6327
6336
|
onDelete: "cascade"
|
|
6328
6337
|
}
|
|
6329
6338
|
];
|
|
6330
|
-
async function
|
|
6339
|
+
async function us(e) {
|
|
6331
6340
|
try {
|
|
6332
6341
|
return await p`select sqlite_version()`.execute(e), !0;
|
|
6333
6342
|
} catch {
|
|
@@ -6336,14 +6345,14 @@ async function ls(e) {
|
|
|
6336
6345
|
}
|
|
6337
6346
|
function K(e, t) {
|
|
6338
6347
|
let n = e;
|
|
6339
|
-
for (let e of
|
|
6348
|
+
for (let e of ls) e.table === t && (n = n.addForeignKeyConstraint(e.name, e.columns, e.references, e.referencedColumns, (t) => {
|
|
6340
6349
|
let n = t;
|
|
6341
6350
|
return e.onDelete && (n = n.onDelete(e.onDelete)), e.onUpdate && (n = n.onUpdate(e.onUpdate)), n;
|
|
6342
6351
|
}));
|
|
6343
6352
|
return n;
|
|
6344
6353
|
}
|
|
6345
|
-
async function
|
|
6346
|
-
let t = await
|
|
6354
|
+
async function ds(e) {
|
|
6355
|
+
let t = await us(e);
|
|
6347
6356
|
await e.schema.createTable("tenants").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("audience", p`varchar(255)`).addColumn("sender_email", p`varchar(255)`).addColumn("sender_name", p`varchar(255)`).addColumn("created_at", p`varchar(255)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(255)`, (e) => e.notNull()).addColumn("support_url", p`varchar(255)`).addColumn("idle_session_lifetime", p`int`).addColumn("session_lifetime", p`int`).addColumn("session_cookie", p`text`).addColumn("allowed_logout_urls", p`text`).addColumn("ephemeral_session_lifetime", p`int`).addColumn("idle_ephemeral_session_lifetime", p`int`).addColumn("default_redirection_uri", p`text`).addColumn("enabled_locales", p`text`).addColumn("default_directory", p`varchar(255)`).addColumn("error_page", p`text`).addColumn("flags", p`text`).addColumn("friendly_name", p`varchar(255)`).addColumn("picture_url", p`text`).addColumn("support_email", p`varchar(255)`).addColumn("sandbox_version", p`varchar(50)`).addColumn("sandbox_versions_available", p`text`).addColumn("legacy_sandbox_version", p`varchar(50)`).addColumn("change_password", p`text`).addColumn("guardian_mfa_page", p`text`).addColumn("device_flow", p`text`).addColumn("default_token_quota", p`text`).addColumn("default_audience", p`varchar(255)`).addColumn("default_organization", p`varchar(255)`).addColumn("sessions", p`text`).addColumn("oidc_logout", p`text`).addColumn("allow_organization_name_in_authentication_api", p`int`).addColumn("customize_mfa_in_postlogin_action", p`int`).addColumn("acr_values_supported", p`text`).addColumn("mtls", p`text`).addColumn("pushed_authorization_requests_supported", p`int`).addColumn("authorization_response_iss_parameter_supported", p`int`).addColumn("mfa", p`text`).addColumn("attack_protection", p`text`).addColumn("default_client_id", p`varchar(255)`).addColumn("deployment_type", p`varchar(16)`, (e) => e.notNull().defaultTo("shared")).addColumn("provisioning_state", p`varchar(16)`, (e) => e.notNull().defaultTo("ready")).addColumn("provisioning_error", p`varchar(2048)`).addColumn("provisioning_state_changed_at", p`varchar(35)`).addColumn("bundle_configuration", p`varchar(64)`).addColumn("worker_version", p`varchar(64)`).addColumn("worker_script_name", p`varchar(255)`).addColumn("storage_kind", p`varchar(32)`).addColumn("d1_database_id", p`varchar(64)`).addColumn("database_version", p`varchar(64)`).addPrimaryKeyConstraint("tenants_pk", ["id"]).execute(), await e.schema.createTable("action_executions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("trigger_id", p`varchar(64)`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("results", p`text`, (e) => e.notNull()).addColumn("logs", p`text`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_executions_pk", ["id"]).execute(), await e.schema.createTable("action_versions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`, (e) => e.notNull()).addColumn("number", p`int`, (e) => e.notNull()).addColumn("code", p`text`, (e) => e.notNull()).addColumn("runtime", p`varchar(50)`).addColumn("secrets", p`text`).addColumn("dependencies", p`text`).addColumn("supported_triggers", p`text`).addColumn("deployed", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addPrimaryKeyConstraint("action_versions_pk", ["id"]).execute(), await e.schema.createTable("actions").addColumn("id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("code", p`text`, (e) => e.notNull()).addColumn("runtime", p`varchar(50)`).addColumn("status", p`varchar(50)`, (e) => e.defaultTo("built")).addColumn("secrets", p`text`).addColumn("dependencies", p`text`).addColumn("supported_triggers", p`text`).addColumn("deployed_at_ts", p`bigint`).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addColumn("is_system", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("inherit", p`int`, (e) => e.notNull().defaultTo(0)).addPrimaryKeyConstraint("actions_pk", ["id"]).execute();
|
|
6348
6357
|
{
|
|
6349
6358
|
let n = e.schema.createTable("authentication_methods").addColumn("id", p`varchar(26)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(191)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("type", p`varchar(32)`, (e) => e.notNull()).addColumn("phone_number", p`varchar(32)`).addColumn("totp_secret", p`varchar(255)`).addColumn("confirmed", p`int`, (e) => e.notNull().defaultTo(0)).addColumn("created_at_ts", p`bigint`, (e) => e.notNull()).addColumn("updated_at_ts", p`bigint`, (e) => e.notNull()).addColumn("credential_id", p`varchar(512)`).addColumn("public_key", p`text`).addColumn("sign_count", p`int`).addColumn("credential_backed_up", p`int`).addColumn("transports", p`varchar(512)`).addColumn("friendly_name", p`varchar(255)`).addPrimaryKeyConstraint("authentication_methods_pk", ["id"]);
|
|
@@ -6530,40 +6539,40 @@ async function us(e) {
|
|
|
6530
6539
|
"tenant_id",
|
|
6531
6540
|
"phone_number",
|
|
6532
6541
|
"provider"
|
|
6533
|
-
]).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
|
|
6542
|
+
]).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 ls) await e.schema.alterTable(t.table).addForeignKeyConstraint(t.name, t.columns, t.references, t.referencedColumns, (e) => {
|
|
6534
6543
|
let n = e;
|
|
6535
6544
|
return t.onDelete && (n = n.onDelete(t.onDelete)), t.onUpdate && (n = n.onUpdate(t.onUpdate)), n;
|
|
6536
6545
|
}).execute();
|
|
6537
6546
|
}
|
|
6538
|
-
async function
|
|
6547
|
+
async function fs(e) {
|
|
6539
6548
|
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();
|
|
6540
6549
|
}
|
|
6541
6550
|
//#endregion
|
|
6542
6551
|
//#region migrate/log.ts
|
|
6543
|
-
var
|
|
6552
|
+
var ps = !1;
|
|
6544
6553
|
function q(e) {
|
|
6545
|
-
|
|
6554
|
+
ps = e;
|
|
6546
6555
|
}
|
|
6547
6556
|
function J(...e) {
|
|
6548
|
-
|
|
6557
|
+
ps && console.log(...e);
|
|
6549
6558
|
}
|
|
6550
6559
|
function Y(...e) {
|
|
6551
6560
|
console.warn(...e);
|
|
6552
6561
|
}
|
|
6553
6562
|
//#endregion
|
|
6554
6563
|
//#region migrate/migrations/2026-07-16T15:00:00_codes_expires_at_ts.ts
|
|
6555
|
-
var
|
|
6556
|
-
down: () =>
|
|
6557
|
-
up: () =>
|
|
6558
|
-
}),
|
|
6559
|
-
async function
|
|
6564
|
+
var ms = /* @__PURE__ */ w({
|
|
6565
|
+
down: () => Ts,
|
|
6566
|
+
up: () => Ss
|
|
6567
|
+
}), hs = 5e4, gs = 500;
|
|
6568
|
+
async function _s(e) {
|
|
6560
6569
|
try {
|
|
6561
6570
|
return await p`SELECT VERSION()`.execute(e), "mysql";
|
|
6562
6571
|
} catch {
|
|
6563
6572
|
return "sqlite";
|
|
6564
6573
|
}
|
|
6565
6574
|
}
|
|
6566
|
-
async function
|
|
6575
|
+
async function vs(e, t, n) {
|
|
6567
6576
|
try {
|
|
6568
6577
|
await e.schema.alterTable(t).addColumn(n, "bigint").execute();
|
|
6569
6578
|
} catch (e) {
|
|
@@ -6574,7 +6583,7 @@ async function _s(e, t, n) {
|
|
|
6574
6583
|
throw e;
|
|
6575
6584
|
}
|
|
6576
6585
|
}
|
|
6577
|
-
async function
|
|
6586
|
+
async function ys(e, t, n, r) {
|
|
6578
6587
|
try {
|
|
6579
6588
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6580
6589
|
} catch (e) {
|
|
@@ -6585,21 +6594,21 @@ async function vs(e, t, n, r) {
|
|
|
6585
6594
|
throw e;
|
|
6586
6595
|
}
|
|
6587
6596
|
}
|
|
6588
|
-
async function
|
|
6597
|
+
async function bs(e, t) {
|
|
6589
6598
|
let n = (/* @__PURE__ */ new Date()).toISOString(), r = 0;
|
|
6590
6599
|
if (t === "sqlite") {
|
|
6591
6600
|
let t = await e.deleteFrom("codes").where("expires_at", "<", n).executeTakeFirst();
|
|
6592
6601
|
r = Number(t.numDeletedRows);
|
|
6593
6602
|
} else {
|
|
6594
|
-
let t =
|
|
6595
|
-
for (; t >=
|
|
6596
|
-
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(
|
|
6603
|
+
let t = hs;
|
|
6604
|
+
for (; t >= hs;) {
|
|
6605
|
+
let i = await e.deleteFrom("codes").where("expires_at", "<", n).limit(hs).executeTakeFirst();
|
|
6597
6606
|
t = Number(i.numDeletedRows), r += t, t > 0 && J(` Pruned ${r} expired codes row(s)...`);
|
|
6598
6607
|
}
|
|
6599
6608
|
}
|
|
6600
6609
|
return r;
|
|
6601
6610
|
}
|
|
6602
|
-
async function
|
|
6611
|
+
async function xs(e) {
|
|
6603
6612
|
let t = 0;
|
|
6604
6613
|
for (;;) {
|
|
6605
6614
|
let n = await e.selectFrom("codes").select([
|
|
@@ -6607,33 +6616,33 @@ async function bs(e) {
|
|
|
6607
6616
|
"code_type",
|
|
6608
6617
|
"tenant_id",
|
|
6609
6618
|
"expires_at"
|
|
6610
|
-
]).where("expires_at_ts", "is", null).limit(
|
|
6619
|
+
]).where("expires_at_ts", "is", null).limit(gs).execute();
|
|
6611
6620
|
if (n.length === 0) break;
|
|
6612
6621
|
for (let t of n) {
|
|
6613
6622
|
let n = Date.parse(t.expires_at);
|
|
6614
6623
|
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();
|
|
6615
6624
|
}
|
|
6616
|
-
if (t += n.length, n.length <
|
|
6625
|
+
if (t += n.length, n.length < gs) break;
|
|
6617
6626
|
}
|
|
6618
6627
|
return t;
|
|
6619
6628
|
}
|
|
6620
|
-
async function
|
|
6621
|
-
let t = await
|
|
6629
|
+
async function Ss(e) {
|
|
6630
|
+
let t = await _s(e);
|
|
6622
6631
|
try {
|
|
6623
|
-
let n = await
|
|
6632
|
+
let n = await bs(e, t);
|
|
6624
6633
|
J(n === 0 ? " No expired codes to prune" : ` Pruned ${n} expired codes row(s) total`);
|
|
6625
6634
|
} catch (e) {
|
|
6626
6635
|
Y(` Warning: Could not prune expired codes: ${e instanceof Error ? e.message : String(e)}`);
|
|
6627
6636
|
}
|
|
6628
|
-
await
|
|
6637
|
+
await vs(e, "codes", "expires_at_ts"), await ys(e, "idx_codes_expires_at_ts", "codes", "expires_at_ts");
|
|
6629
6638
|
try {
|
|
6630
|
-
let t = await
|
|
6639
|
+
let t = await xs(e);
|
|
6631
6640
|
J(t === 0 ? " No codes rows needed an expires_at_ts backfill" : ` Backfilled expires_at_ts for ${t} codes row(s)`);
|
|
6632
6641
|
} catch (e) {
|
|
6633
6642
|
Y(` Warning: Could not backfill codes.expires_at_ts: ${e instanceof Error ? e.message : String(e)}`);
|
|
6634
6643
|
}
|
|
6635
6644
|
}
|
|
6636
|
-
async function
|
|
6645
|
+
async function Cs(e, t, n) {
|
|
6637
6646
|
try {
|
|
6638
6647
|
await e.schema.dropIndex(t).on(n).execute();
|
|
6639
6648
|
} catch (e) {
|
|
@@ -6641,7 +6650,7 @@ async function Ss(e, t, n) {
|
|
|
6641
6650
|
throw e;
|
|
6642
6651
|
}
|
|
6643
6652
|
}
|
|
6644
|
-
async function
|
|
6653
|
+
async function ws(e, t, n) {
|
|
6645
6654
|
try {
|
|
6646
6655
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6647
6656
|
} catch (e) {
|
|
@@ -6649,16 +6658,16 @@ async function Cs(e, t, n) {
|
|
|
6649
6658
|
throw e;
|
|
6650
6659
|
}
|
|
6651
6660
|
}
|
|
6652
|
-
async function
|
|
6653
|
-
await
|
|
6661
|
+
async function Ts(e) {
|
|
6662
|
+
await Cs(e, "idx_codes_expires_at_ts", "codes"), await ws(e, "codes", "expires_at_ts");
|
|
6654
6663
|
}
|
|
6655
6664
|
//#endregion
|
|
6656
6665
|
//#region migrate/migrations/2026-08-04T12:00:00_scim_inbound_provisioning.ts
|
|
6657
|
-
var
|
|
6658
|
-
down: () =>
|
|
6659
|
-
up: () =>
|
|
6666
|
+
var Es = /* @__PURE__ */ w({
|
|
6667
|
+
down: () => Os,
|
|
6668
|
+
up: () => Ds
|
|
6660
6669
|
});
|
|
6661
|
-
async function
|
|
6670
|
+
async function Ds(e) {
|
|
6662
6671
|
await e.schema.createTable("scim_configurations").addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id_attribute", p`varchar(255)`, (e) => e.notNull().defaultTo("externalId")).addColumn("mapping", p`text`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_configurations_pk", ["tenant_id", "connection_id"]).execute(), await e.schema.createTable("scim_tokens").addColumn("token_id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("token_hash", p`varchar(128)`, (e) => e.notNull()).addColumn("scopes", p`text`, (e) => e.notNull()).addColumn("valid_until", p`varchar(35)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("last_used_at", p`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", p`varchar(255)`, (e) => e.notNull()).addColumn("connection_id", p`varchar(255)`, (e) => e.notNull()).addColumn("external_id", p`varchar(255)`, (e) => e.notNull()).addColumn("user_id", p`varchar(255)`, (e) => e.notNull()).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("scim_external_ids_pk", [
|
|
6663
6672
|
"tenant_id",
|
|
6664
6673
|
"connection_id",
|
|
@@ -6669,16 +6678,16 @@ async function Es(e) {
|
|
|
6669
6678
|
"external_id"
|
|
6670
6679
|
]).unique().execute();
|
|
6671
6680
|
}
|
|
6672
|
-
async function
|
|
6681
|
+
async function Os(e) {
|
|
6673
6682
|
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();
|
|
6674
6683
|
}
|
|
6675
6684
|
//#endregion
|
|
6676
6685
|
//#region migrate/migrations/2026-08-05T12:00:00_user_blocked.ts
|
|
6677
|
-
var
|
|
6678
|
-
down: () =>
|
|
6679
|
-
up: () =>
|
|
6686
|
+
var ks = /* @__PURE__ */ w({
|
|
6687
|
+
down: () => Ns,
|
|
6688
|
+
up: () => js
|
|
6680
6689
|
});
|
|
6681
|
-
async function
|
|
6690
|
+
async function As(e, t, n) {
|
|
6682
6691
|
try {
|
|
6683
6692
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6684
6693
|
} catch (e) {
|
|
@@ -6686,10 +6695,10 @@ async function ks(e, t, n) {
|
|
|
6686
6695
|
throw e;
|
|
6687
6696
|
}
|
|
6688
6697
|
}
|
|
6689
|
-
async function
|
|
6690
|
-
await
|
|
6698
|
+
async function js(e) {
|
|
6699
|
+
await As(e, "users", "blocked");
|
|
6691
6700
|
}
|
|
6692
|
-
async function
|
|
6701
|
+
async function Ms(e, t, n) {
|
|
6693
6702
|
try {
|
|
6694
6703
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6695
6704
|
} catch (e) {
|
|
@@ -6697,16 +6706,16 @@ async function js(e, t, n) {
|
|
|
6697
6706
|
throw e;
|
|
6698
6707
|
}
|
|
6699
6708
|
}
|
|
6700
|
-
async function
|
|
6701
|
-
await
|
|
6709
|
+
async function Ns(e) {
|
|
6710
|
+
await Ms(e, "users", "blocked");
|
|
6702
6711
|
}
|
|
6703
6712
|
//#endregion
|
|
6704
6713
|
//#region migrate/migrations/2026-08-09T12:00:00_prompt_settings_last_used.ts
|
|
6705
|
-
var
|
|
6706
|
-
down: () =>
|
|
6707
|
-
up: () =>
|
|
6714
|
+
var Ps = /* @__PURE__ */ w({
|
|
6715
|
+
down: () => Rs,
|
|
6716
|
+
up: () => Is
|
|
6708
6717
|
});
|
|
6709
|
-
async function
|
|
6718
|
+
async function Fs(e, t, n) {
|
|
6710
6719
|
try {
|
|
6711
6720
|
await e.schema.alterTable(t).addColumn(n, p`tinyint(1)`).execute();
|
|
6712
6721
|
} catch (e) {
|
|
@@ -6714,10 +6723,10 @@ async function Ps(e, t, n) {
|
|
|
6714
6723
|
throw e;
|
|
6715
6724
|
}
|
|
6716
6725
|
}
|
|
6717
|
-
async function
|
|
6718
|
-
await
|
|
6726
|
+
async function Is(e) {
|
|
6727
|
+
await Fs(e, "prompt_settings", "show_last_used_connection");
|
|
6719
6728
|
}
|
|
6720
|
-
async function
|
|
6729
|
+
async function Ls(e, t, n) {
|
|
6721
6730
|
try {
|
|
6722
6731
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6723
6732
|
} catch (e) {
|
|
@@ -6725,16 +6734,16 @@ async function Is(e, t, n) {
|
|
|
6725
6734
|
throw e;
|
|
6726
6735
|
}
|
|
6727
6736
|
}
|
|
6728
|
-
async function
|
|
6729
|
-
await
|
|
6737
|
+
async function Rs(e) {
|
|
6738
|
+
await Ls(e, "prompt_settings", "show_last_used_connection");
|
|
6730
6739
|
}
|
|
6731
6740
|
//#endregion
|
|
6732
6741
|
//#region migrate/migrations/2026-08-10T12:00:00_action_executions_created_at_index.ts
|
|
6733
|
-
var
|
|
6734
|
-
down: () =>
|
|
6735
|
-
up: () =>
|
|
6742
|
+
var zs = /* @__PURE__ */ w({
|
|
6743
|
+
down: () => Hs,
|
|
6744
|
+
up: () => Vs
|
|
6736
6745
|
});
|
|
6737
|
-
async function
|
|
6746
|
+
async function Bs(e, t, n, r) {
|
|
6738
6747
|
try {
|
|
6739
6748
|
await e.schema.createIndex(t).on(n).column(r).execute();
|
|
6740
6749
|
} catch (e) {
|
|
@@ -6745,10 +6754,10 @@ async function zs(e, t, n, r) {
|
|
|
6745
6754
|
throw e;
|
|
6746
6755
|
}
|
|
6747
6756
|
}
|
|
6748
|
-
async function Bs(e) {
|
|
6749
|
-
await zs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6750
|
-
}
|
|
6751
6757
|
async function Vs(e) {
|
|
6758
|
+
await Bs(e, "idx_action_executions_created_at_ts", "action_executions", "created_at_ts");
|
|
6759
|
+
}
|
|
6760
|
+
async function Hs(e) {
|
|
6752
6761
|
try {
|
|
6753
6762
|
await e.schema.dropIndex("idx_action_executions_created_at_ts").on("action_executions").execute();
|
|
6754
6763
|
} catch (e) {
|
|
@@ -6758,11 +6767,11 @@ async function Vs(e) {
|
|
|
6758
6767
|
}
|
|
6759
6768
|
//#endregion
|
|
6760
6769
|
//#region migrate/migrations/2026-08-11T12:00:00_page_hooks.ts
|
|
6761
|
-
var
|
|
6762
|
-
down: () =>
|
|
6763
|
-
up: () =>
|
|
6770
|
+
var Us = /* @__PURE__ */ w({
|
|
6771
|
+
down: () => qs,
|
|
6772
|
+
up: () => Gs
|
|
6764
6773
|
});
|
|
6765
|
-
async function
|
|
6774
|
+
async function Ws(e, t, n, r) {
|
|
6766
6775
|
try {
|
|
6767
6776
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6768
6777
|
} catch (e) {
|
|
@@ -6770,10 +6779,10 @@ async function Us(e, t, n, r) {
|
|
|
6770
6779
|
throw e;
|
|
6771
6780
|
}
|
|
6772
6781
|
}
|
|
6773
|
-
async function
|
|
6774
|
-
await
|
|
6782
|
+
async function Gs(e) {
|
|
6783
|
+
await Ws(e, "hooks", "page_id", p`varchar(64)`), await Ws(e, "hooks", "permission_required", p`varchar(255)`);
|
|
6775
6784
|
}
|
|
6776
|
-
async function
|
|
6785
|
+
async function Ks(e, t, n) {
|
|
6777
6786
|
try {
|
|
6778
6787
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6779
6788
|
} catch (e) {
|
|
@@ -6781,22 +6790,22 @@ async function Gs(e, t, n) {
|
|
|
6781
6790
|
throw e;
|
|
6782
6791
|
}
|
|
6783
6792
|
}
|
|
6784
|
-
async function
|
|
6785
|
-
await
|
|
6793
|
+
async function qs(e) {
|
|
6794
|
+
await Ks(e, "hooks", "permission_required"), await Ks(e, "hooks", "page_id");
|
|
6786
6795
|
}
|
|
6787
6796
|
//#endregion
|
|
6788
6797
|
//#region migrate/migrations/2026-08-20T12:00:00_refresh_token_session_id.ts
|
|
6789
|
-
var
|
|
6790
|
-
down: () =>
|
|
6791
|
-
up: () =>
|
|
6792
|
-
}),
|
|
6798
|
+
var Js = /* @__PURE__ */ w({
|
|
6799
|
+
down: () => ec,
|
|
6800
|
+
up: () => Qs
|
|
6801
|
+
}), Ys = [
|
|
6793
6802
|
["session_id", p`varchar(26)`],
|
|
6794
6803
|
["organization", p`varchar(191)`],
|
|
6795
6804
|
["auth_connection", p`varchar(255)`],
|
|
6796
6805
|
["auth_strategy_strategy", p`varchar(64)`],
|
|
6797
6806
|
["auth_strategy_strategy_type", p`varchar(64)`]
|
|
6798
6807
|
];
|
|
6799
|
-
async function
|
|
6808
|
+
async function Xs(e, t, n, r) {
|
|
6800
6809
|
try {
|
|
6801
6810
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6802
6811
|
} catch (e) {
|
|
@@ -6804,7 +6813,7 @@ async function Ys(e, t, n, r) {
|
|
|
6804
6813
|
throw e;
|
|
6805
6814
|
}
|
|
6806
6815
|
}
|
|
6807
|
-
async function
|
|
6816
|
+
async function Zs(e) {
|
|
6808
6817
|
try {
|
|
6809
6818
|
await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").columns(["tenant_id", "session_id"]).execute();
|
|
6810
6819
|
} catch (e) {
|
|
@@ -6812,11 +6821,11 @@ async function Xs(e) {
|
|
|
6812
6821
|
throw e;
|
|
6813
6822
|
}
|
|
6814
6823
|
}
|
|
6815
|
-
async function
|
|
6816
|
-
for (let [t, n] of
|
|
6817
|
-
await
|
|
6824
|
+
async function Qs(e) {
|
|
6825
|
+
for (let [t, n] of Ys) await Xs(e, "refresh_tokens", t, n);
|
|
6826
|
+
await Zs(e);
|
|
6818
6827
|
}
|
|
6819
|
-
async function
|
|
6828
|
+
async function $s(e, t, n) {
|
|
6820
6829
|
try {
|
|
6821
6830
|
await e.schema.alterTable(t).dropColumn(n).execute();
|
|
6822
6831
|
} catch (e) {
|
|
@@ -6824,23 +6833,23 @@ async function Qs(e, t, n) {
|
|
|
6824
6833
|
throw e;
|
|
6825
6834
|
}
|
|
6826
6835
|
}
|
|
6827
|
-
async function
|
|
6836
|
+
async function ec(e) {
|
|
6828
6837
|
try {
|
|
6829
6838
|
await e.schema.dropIndex("idx_refresh_tokens_session_id").execute();
|
|
6830
6839
|
} catch {}
|
|
6831
|
-
for (let [t] of
|
|
6840
|
+
for (let [t] of Ys) await $s(e, "refresh_tokens", t);
|
|
6832
6841
|
}
|
|
6833
6842
|
//#endregion
|
|
6834
6843
|
//#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
|
|
6835
|
-
var
|
|
6836
|
-
down: () =>
|
|
6837
|
-
up: () =>
|
|
6838
|
-
}),
|
|
6839
|
-
async function
|
|
6844
|
+
var tc = /* @__PURE__ */ w({
|
|
6845
|
+
down: () => sc,
|
|
6846
|
+
up: () => oc
|
|
6847
|
+
}), nc = 500, rc = 20, ic = 500, ac = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
|
|
6848
|
+
async function oc(e) {
|
|
6840
6849
|
try {
|
|
6841
6850
|
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);
|
|
6842
|
-
if (n >
|
|
6843
|
-
Y(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${
|
|
6851
|
+
if (n > ic) {
|
|
6852
|
+
Y(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${ic}. SKIPPING — run the bulk path instead: ${ac}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
|
|
6844
6853
|
return;
|
|
6845
6854
|
}
|
|
6846
6855
|
if (n === 0) {
|
|
@@ -6857,10 +6866,10 @@ async function ac(e) {
|
|
|
6857
6866
|
"login_sessions.auth_strategy_strategy as ls_strategy",
|
|
6858
6867
|
"login_sessions.auth_strategy_strategy_type as ls_strategy_type",
|
|
6859
6868
|
"login_sessions.auth_params as ls_auth_params"
|
|
6860
|
-
]).limit(
|
|
6869
|
+
]).limit(nc).execute();
|
|
6861
6870
|
if (t.length === 0) break;
|
|
6862
|
-
for (let n = 0; n < t.length; n +=
|
|
6863
|
-
let r = t.slice(n, n +
|
|
6871
|
+
for (let n = 0; n < t.length; n += rc) {
|
|
6872
|
+
let r = t.slice(n, n + rc);
|
|
6864
6873
|
await Promise.all(r.map(async (t) => {
|
|
6865
6874
|
let n = null;
|
|
6866
6875
|
if (t.ls_auth_params) try {
|
|
@@ -6877,19 +6886,19 @@ async function ac(e) {
|
|
|
6877
6886
|
}).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
|
|
6878
6887
|
}));
|
|
6879
6888
|
}
|
|
6880
|
-
if (r += t.length, J(`refresh_tokens backfill: ${r} rows populated so far`), t.length <
|
|
6889
|
+
if (r += t.length, J(`refresh_tokens backfill: ${r} rows populated so far`), t.length < nc) break;
|
|
6881
6890
|
}
|
|
6882
6891
|
J(`refresh_tokens backfill: done, ${r} rows updated`);
|
|
6883
6892
|
} catch (e) {
|
|
6884
6893
|
throw Y("refresh_tokens backfill failed:", e), e;
|
|
6885
6894
|
}
|
|
6886
6895
|
}
|
|
6887
|
-
async function
|
|
6896
|
+
async function sc() {}
|
|
6888
6897
|
//#endregion
|
|
6889
6898
|
//#region migrate/migrations/2026-09-01T12:00:00_tenant_operation_rows.ts
|
|
6890
|
-
var
|
|
6891
|
-
down: () =>
|
|
6892
|
-
up: () =>
|
|
6899
|
+
var cc = /* @__PURE__ */ w({
|
|
6900
|
+
down: () => dc,
|
|
6901
|
+
up: () => uc
|
|
6893
6902
|
});
|
|
6894
6903
|
async function X(e, t, n, r) {
|
|
6895
6904
|
try {
|
|
@@ -6899,7 +6908,7 @@ async function X(e, t, n, r) {
|
|
|
6899
6908
|
throw e;
|
|
6900
6909
|
}
|
|
6901
6910
|
}
|
|
6902
|
-
async function
|
|
6911
|
+
async function lc(e, t, n, r) {
|
|
6903
6912
|
try {
|
|
6904
6913
|
await e.schema.createIndex(t).on(n).columns(r).execute();
|
|
6905
6914
|
} catch (e) {
|
|
@@ -6907,12 +6916,12 @@ async function cc(e, t, n, r) {
|
|
|
6907
6916
|
throw e;
|
|
6908
6917
|
}
|
|
6909
6918
|
}
|
|
6910
|
-
async function
|
|
6911
|
-
await X(e, "tenant_operations", "input", p`text`), await X(e, "tenant_operations", "result", p`text`), await X(e, "tenant_operations", "claimed_by", p`varchar(255)`), await X(e, "tenant_operations", "claim_expires_at", p`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", p`varchar(255)`, (e) => e.notNull()).addColumn("seq", p`int`, (e) => e.notNull()).addColumn("payload", p`text`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("error_code", p`varchar(64)`).addColumn("error_message", p`text`).addColumn("error_path", p`varchar(255)`).addColumn("entity_id", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await
|
|
6919
|
+
async function uc(e) {
|
|
6920
|
+
await X(e, "tenant_operations", "input", p`text`), await X(e, "tenant_operations", "result", p`text`), await X(e, "tenant_operations", "claimed_by", p`varchar(255)`), await X(e, "tenant_operations", "claim_expires_at", p`varchar(35)`), await e.schema.createTable("tenant_operation_rows").ifNotExists().addColumn("operation_id", p`varchar(255)`, (e) => e.notNull()).addColumn("seq", p`int`, (e) => e.notNull()).addColumn("payload", p`text`, (e) => e.notNull()).addColumn("status", p`varchar(32)`, (e) => e.notNull()).addColumn("error_code", p`varchar(64)`).addColumn("error_message", p`text`).addColumn("error_path", p`varchar(255)`).addColumn("entity_id", p`varchar(255)`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("tenant_operation_rows_pk", ["operation_id", "seq"]).execute(), await lc(e, "tenant_operation_rows_operation_status_seq_idx", "tenant_operation_rows", [
|
|
6912
6921
|
"operation_id",
|
|
6913
6922
|
"status",
|
|
6914
6923
|
"seq"
|
|
6915
|
-
]), await
|
|
6924
|
+
]), await lc(e, "tenant_operations_kind_status_created_at_idx", "tenant_operations", [
|
|
6916
6925
|
"kind",
|
|
6917
6926
|
"status",
|
|
6918
6927
|
"created_at"
|
|
@@ -6926,7 +6935,7 @@ async function Z(e, t, n) {
|
|
|
6926
6935
|
throw e;
|
|
6927
6936
|
}
|
|
6928
6937
|
}
|
|
6929
|
-
async function
|
|
6938
|
+
async function dc(e) {
|
|
6930
6939
|
try {
|
|
6931
6940
|
await e.schema.dropIndex("tenant_operations_kind_status_created_at_idx").on("tenant_operations").execute();
|
|
6932
6941
|
} catch {}
|
|
@@ -6934,11 +6943,11 @@ async function uc(e) {
|
|
|
6934
6943
|
}
|
|
6935
6944
|
//#endregion
|
|
6936
6945
|
//#region migrate/migrations/2026-09-25T12:00:00_token_exchange_profiles.ts
|
|
6937
|
-
var
|
|
6938
|
-
down: () =>
|
|
6939
|
-
up: () =>
|
|
6946
|
+
var fc = /* @__PURE__ */ w({
|
|
6947
|
+
down: () => gc,
|
|
6948
|
+
up: () => hc
|
|
6940
6949
|
});
|
|
6941
|
-
async function
|
|
6950
|
+
async function pc(e, t, n, r) {
|
|
6942
6951
|
try {
|
|
6943
6952
|
await e.schema.alterTable(t).addColumn(n, r).execute();
|
|
6944
6953
|
} catch (e) {
|
|
@@ -6946,7 +6955,7 @@ async function fc(e, t, n, r) {
|
|
|
6946
6955
|
throw e;
|
|
6947
6956
|
}
|
|
6948
6957
|
}
|
|
6949
|
-
async function
|
|
6958
|
+
async function mc(e, t, n, r) {
|
|
6950
6959
|
try {
|
|
6951
6960
|
await e.schema.createIndex(t).on(n).columns(r).unique().execute();
|
|
6952
6961
|
} catch (e) {
|
|
@@ -6954,10 +6963,10 @@ async function pc(e, t, n, r) {
|
|
|
6954
6963
|
throw e;
|
|
6955
6964
|
}
|
|
6956
6965
|
}
|
|
6957
|
-
async function mc(e) {
|
|
6958
|
-
await e.schema.createTable("token_exchange_profiles").ifNotExists().addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("subject_token_type", p`varchar(255)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`).addColumn("type", p`varchar(64)`, (e) => e.notNull()).addColumn("jwt_verification", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("token_exchange_profiles_pk", ["id"]).execute(), await pc(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await fc(e, "clients", "token_exchange", p`text`);
|
|
6959
|
-
}
|
|
6960
6966
|
async function hc(e) {
|
|
6967
|
+
await e.schema.createTable("token_exchange_profiles").ifNotExists().addColumn("id", p`varchar(64)`, (e) => e.notNull()).addColumn("tenant_id", p`varchar(255)`, (e) => e.notNull()).addColumn("name", p`varchar(255)`, (e) => e.notNull()).addColumn("subject_token_type", p`varchar(255)`, (e) => e.notNull()).addColumn("action_id", p`varchar(255)`).addColumn("type", p`varchar(64)`, (e) => e.notNull()).addColumn("jwt_verification", p`text`).addColumn("created_at", p`varchar(35)`, (e) => e.notNull()).addColumn("updated_at", p`varchar(35)`, (e) => e.notNull()).addPrimaryKeyConstraint("token_exchange_profiles_pk", ["id"]).execute(), await mc(e, "token_exchange_profiles_tenant_subject_token_type_idx", "token_exchange_profiles", ["tenant_id", "subject_token_type"]), await pc(e, "clients", "token_exchange", p`text`);
|
|
6968
|
+
}
|
|
6969
|
+
async function gc(e) {
|
|
6961
6970
|
await e.schema.dropTable("token_exchange_profiles").ifExists().execute();
|
|
6962
6971
|
try {
|
|
6963
6972
|
await e.schema.alterTable("clients").dropColumn("token_exchange").execute();
|
|
@@ -6969,35 +6978,35 @@ async function hc(e) {
|
|
|
6969
6978
|
//#endregion
|
|
6970
6979
|
//#region migrate/migrations/index.ts
|
|
6971
6980
|
var Q = {
|
|
6972
|
-
"2026-07-16T14:00:00_baseline":
|
|
6973
|
-
"2026-07-16T15:00:00_codes_expires_at_ts":
|
|
6974
|
-
"2026-08-04T12:00:00_scim_inbound_provisioning":
|
|
6975
|
-
"2026-08-05T12:00:00_user_blocked":
|
|
6976
|
-
"2026-08-09T12:00:00_prompt_settings_last_used":
|
|
6977
|
-
"2026-08-10T12:00:00_action_executions_created_at_index":
|
|
6978
|
-
"2026-08-11T12:00:00_page_hooks":
|
|
6979
|
-
"2026-08-20T12:00:00_refresh_token_session_id":
|
|
6980
|
-
"2026-08-21T12:00:00_refresh_token_session_id_backfill":
|
|
6981
|
-
"2026-09-01T12:00:00_tenant_operation_rows":
|
|
6982
|
-
"2026-09-25T12:00:00_token_exchange_profiles":
|
|
6981
|
+
"2026-07-16T14:00:00_baseline": cs,
|
|
6982
|
+
"2026-07-16T15:00:00_codes_expires_at_ts": ms,
|
|
6983
|
+
"2026-08-04T12:00:00_scim_inbound_provisioning": Es,
|
|
6984
|
+
"2026-08-05T12:00:00_user_blocked": ks,
|
|
6985
|
+
"2026-08-09T12:00:00_prompt_settings_last_used": Ps,
|
|
6986
|
+
"2026-08-10T12:00:00_action_executions_created_at_index": zs,
|
|
6987
|
+
"2026-08-11T12:00:00_page_hooks": Us,
|
|
6988
|
+
"2026-08-20T12:00:00_refresh_token_session_id": Js,
|
|
6989
|
+
"2026-08-21T12:00:00_refresh_token_session_id_backfill": tc,
|
|
6990
|
+
"2026-09-01T12:00:00_tenant_operation_rows": cc,
|
|
6991
|
+
"2026-09-25T12:00:00_token_exchange_profiles": fc
|
|
6983
6992
|
};
|
|
6984
6993
|
//#endregion
|
|
6985
6994
|
//#region migrate/migrate.ts
|
|
6986
|
-
async function
|
|
6995
|
+
async function _c(e, t = !1) {
|
|
6987
6996
|
q(t), t && console.log("migrating...");
|
|
6988
6997
|
let { error: n, results: r } = await new ke({
|
|
6989
6998
|
db: e,
|
|
6990
|
-
provider: new
|
|
6999
|
+
provider: new ss(Q)
|
|
6991
7000
|
}).migrateToLatest();
|
|
6992
7001
|
if (r?.forEach((e) => {
|
|
6993
7002
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
6994
7003
|
}), n) throw console.error("failed to migrate"), console.error(n), n;
|
|
6995
7004
|
}
|
|
6996
|
-
async function
|
|
7005
|
+
async function vc(e, t = !1) {
|
|
6997
7006
|
q(t), t && console.log("migrating...");
|
|
6998
7007
|
let { error: n, results: r } = await new ke({
|
|
6999
7008
|
db: e,
|
|
7000
|
-
provider: new
|
|
7009
|
+
provider: new ss(Q)
|
|
7001
7010
|
}).migrateDown();
|
|
7002
7011
|
if (r?.forEach((e) => {
|
|
7003
7012
|
e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
|
|
@@ -7005,22 +7014,22 @@ async function _c(e, t = !1) {
|
|
|
7005
7014
|
}
|
|
7006
7015
|
//#endregion
|
|
7007
7016
|
//#region migrate/plan.ts
|
|
7008
|
-
var
|
|
7009
|
-
function
|
|
7017
|
+
var yc = 5e3, bc = class extends Error {};
|
|
7018
|
+
function xc(e) {
|
|
7010
7019
|
if (e.query.kind === "SelectQueryNode") return !0;
|
|
7011
7020
|
if (e.query.kind !== "RawNode") return !1;
|
|
7012
7021
|
let t = e.sql.trimStart();
|
|
7013
7022
|
return /^(select|show|explain|describe|desc)\b/i.test(t) ? !0 : /^pragma\b/i.test(t) && !t.includes("=");
|
|
7014
7023
|
}
|
|
7015
|
-
var
|
|
7024
|
+
var Sc = class {
|
|
7016
7025
|
inner;
|
|
7017
7026
|
captured;
|
|
7018
7027
|
constructor(e, t) {
|
|
7019
7028
|
this.inner = e, this.captured = t;
|
|
7020
7029
|
}
|
|
7021
7030
|
async executeQuery(e) {
|
|
7022
|
-
if (
|
|
7023
|
-
if (this.captured.length >=
|
|
7031
|
+
if (xc(e)) return this.inner.executeQuery(e);
|
|
7032
|
+
if (this.captured.length >= yc) throw new bc(`stopped after ${yc} statements`);
|
|
7024
7033
|
return this.captured.push({
|
|
7025
7034
|
sql: e.sql,
|
|
7026
7035
|
parameters: e.parameters
|
|
@@ -7036,7 +7045,7 @@ var xc = class {
|
|
|
7036
7045
|
function $() {
|
|
7037
7046
|
throw Error("not available in a migration dry run");
|
|
7038
7047
|
}
|
|
7039
|
-
var
|
|
7048
|
+
var Cc = {
|
|
7040
7049
|
init: async () => {},
|
|
7041
7050
|
acquireConnection: $,
|
|
7042
7051
|
beginTransaction: $,
|
|
@@ -7045,25 +7054,25 @@ var Sc = {
|
|
|
7045
7054
|
releaseConnection: $,
|
|
7046
7055
|
destroy: async () => {}
|
|
7047
7056
|
};
|
|
7048
|
-
function
|
|
7049
|
-
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new
|
|
7057
|
+
function wc(e, t) {
|
|
7058
|
+
let n = e.getExecutor(), r = n.withConnectionProvider({ provideConnection: (e) => n.provideConnection((n) => e(new Sc(n, t))) }), i = {
|
|
7050
7059
|
createAdapter: () => n.adapter,
|
|
7051
|
-
createDriver: () =>
|
|
7060
|
+
createDriver: () => Cc,
|
|
7052
7061
|
createQueryCompiler: () => $(),
|
|
7053
7062
|
createIntrospector: () => $()
|
|
7054
7063
|
};
|
|
7055
7064
|
return new f({
|
|
7056
7065
|
config: { dialect: i },
|
|
7057
7066
|
dialect: i,
|
|
7058
|
-
driver:
|
|
7067
|
+
driver: Cc,
|
|
7059
7068
|
executor: r
|
|
7060
7069
|
});
|
|
7061
7070
|
}
|
|
7062
|
-
async function
|
|
7071
|
+
async function Tc(e) {
|
|
7063
7072
|
q(!1);
|
|
7064
7073
|
let t = await new ke({
|
|
7065
7074
|
db: e,
|
|
7066
|
-
provider: new
|
|
7075
|
+
provider: new ss(Q)
|
|
7067
7076
|
}).getMigrations(), n = t.filter((e) => e.executedAt).map((e) => e.name), r = t.filter((e) => !e.executedAt), i = n[n.length - 1], a = i ? r.find((e) => e.name < i) : void 0;
|
|
7068
7077
|
if (a) throw Error(`pending migration "${a.name}" sorts before already-executed "${i}"; migrateToLatest would refuse to run`);
|
|
7069
7078
|
let o = [];
|
|
@@ -7073,9 +7082,9 @@ async function wc(e) {
|
|
|
7073
7082
|
statements: n
|
|
7074
7083
|
};
|
|
7075
7084
|
try {
|
|
7076
|
-
await t.migration.up(
|
|
7085
|
+
await t.migration.up(wc(e, n));
|
|
7077
7086
|
} catch (e) {
|
|
7078
|
-
r.error = e instanceof Error ? e.message : String(e), e instanceof
|
|
7087
|
+
r.error = e instanceof Error ? e.message : String(e), e instanceof bc && (r.truncated = !0);
|
|
7079
7088
|
}
|
|
7080
7089
|
o.push(r);
|
|
7081
7090
|
}
|
|
@@ -7084,7 +7093,7 @@ async function wc(e) {
|
|
|
7084
7093
|
pending: o
|
|
7085
7094
|
};
|
|
7086
7095
|
}
|
|
7087
|
-
function
|
|
7096
|
+
function Ec(e) {
|
|
7088
7097
|
if (e.pending.length === 0) return `-- Database is up to date (${e.executed.length} migrations executed).`;
|
|
7089
7098
|
let t = [`-- ${e.pending.length} pending migration(s); ${e.executed.length} already executed.`];
|
|
7090
7099
|
for (let n of e.pending) {
|
|
@@ -7099,7 +7108,7 @@ function Tc(e) {
|
|
|
7099
7108
|
}
|
|
7100
7109
|
//#endregion
|
|
7101
7110
|
//#region src/index.ts
|
|
7102
|
-
function
|
|
7111
|
+
function Dc(e, t = { useTransactions: !0 }) {
|
|
7103
7112
|
let n = {
|
|
7104
7113
|
actions: Xe(e),
|
|
7105
7114
|
actionExecutions: rt(e),
|
|
@@ -7122,15 +7131,15 @@ function Ec(e, t = { useTransactions: !0 }) {
|
|
|
7122
7131
|
keys: lr(e),
|
|
7123
7132
|
loginSessions: Xr(e),
|
|
7124
7133
|
logs: Zt(e),
|
|
7125
|
-
logStreams:
|
|
7126
|
-
migrationSources:
|
|
7134
|
+
logStreams: vo(e),
|
|
7135
|
+
migrationSources: bo(e),
|
|
7127
7136
|
authenticationMethods: io(e),
|
|
7128
7137
|
passwords: ln(e),
|
|
7129
7138
|
promptSettings: ei(e),
|
|
7130
|
-
proxyRoutes:
|
|
7131
|
-
scimConfigurations:
|
|
7132
|
-
scimTokens:
|
|
7133
|
-
scimExternalIds:
|
|
7139
|
+
proxyRoutes: wo(e),
|
|
7140
|
+
scimConfigurations: Po(e),
|
|
7141
|
+
scimTokens: Io(e),
|
|
7142
|
+
scimExternalIds: Ro(e),
|
|
7134
7143
|
refreshTokens: Ci(e),
|
|
7135
7144
|
resourceServers: Ri(e),
|
|
7136
7145
|
rolePermissions: Xi(e),
|
|
@@ -7141,11 +7150,11 @@ function Ec(e, t = { useTransactions: !0 }) {
|
|
|
7141
7150
|
sessions: rn(e),
|
|
7142
7151
|
sessionCleanup: Ti(e),
|
|
7143
7152
|
tenants: Ut(e),
|
|
7144
|
-
tenantOperations:
|
|
7145
|
-
tenantOperationEvents:
|
|
7146
|
-
tenantOperationRows:
|
|
7147
|
-
tokenExchangeProfiles:
|
|
7148
|
-
rollouts:
|
|
7153
|
+
tenantOperations: Bo(e),
|
|
7154
|
+
tenantOperationEvents: $o(e),
|
|
7155
|
+
tenantOperationRows: rs(e),
|
|
7156
|
+
tokenExchangeProfiles: Ao(e),
|
|
7157
|
+
rollouts: os(e),
|
|
7149
7158
|
themes: zr(e),
|
|
7150
7159
|
universalLoginTemplates: Cr(e),
|
|
7151
7160
|
customText: Za(e),
|
|
@@ -7156,9 +7165,9 @@ function Ec(e, t = { useTransactions: !0 }) {
|
|
|
7156
7165
|
userOrganizations: Da(e),
|
|
7157
7166
|
stats: Ra(e),
|
|
7158
7167
|
analytics: Xa(e),
|
|
7159
|
-
outbox:
|
|
7168
|
+
outbox: go(e),
|
|
7160
7169
|
async transaction(r) {
|
|
7161
|
-
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(
|
|
7170
|
+
return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Dc(e, {
|
|
7162
7171
|
...t,
|
|
7163
7172
|
useTransactions: !1
|
|
7164
7173
|
})));
|
|
@@ -7167,4 +7176,4 @@ function Ec(e, t = { useTransactions: !0 }) {
|
|
|
7167
7176
|
return n;
|
|
7168
7177
|
}
|
|
7169
7178
|
//#endregion
|
|
7170
|
-
export {
|
|
7179
|
+
export { Eo as createProxyDataAdapter, wo as createProxyRoutesAdapter, Dc as default, Ec as formatMigrationPlan, vc as migrateDown, _c as migrateToLatest, Tc as planMigrations };
|