@playcademy/sandbox 0.3.9 → 0.3.10

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/server.js CHANGED
@@ -1223,7 +1223,7 @@ var package_default;
1223
1223
  var init_package = __esm(() => {
1224
1224
  package_default = {
1225
1225
  name: "@playcademy/sandbox",
1226
- version: "0.3.9",
1226
+ version: "0.3.10",
1227
1227
  description: "Local development server for Playcademy game development",
1228
1228
  type: "module",
1229
1229
  exports: {
@@ -5719,7 +5719,7 @@ function isProduction2(config2) {
5719
5719
  var stageSchema, ltiConfigSchema, realtimeConfigSchema, apiConfigSchema;
5720
5720
  var init_schema = __esm(() => {
5721
5721
  init_esm();
5722
- stageSchema = exports_external.enum(["production", "staging", "local"]);
5722
+ stageSchema = exports_external.enum(["production", "dev", "local"]);
5723
5723
  ltiConfigSchema = exports_external.object({
5724
5724
  audience: exports_external.string(),
5725
5725
  jwksUrl: exports_external.string().url(),
@@ -13457,7 +13457,7 @@ class DeployService {
13457
13457
  }
13458
13458
  return cf;
13459
13459
  }
13460
- async createAndPersistApiKey(user, slug2, game, keyName) {
13460
+ async createApiKey(user, slug2, keyName) {
13461
13461
  const { id, key: apiKey } = await this.ctx.providers.auth.createApiKey({
13462
13462
  userId: user.id,
13463
13463
  name: keyName,
@@ -13466,16 +13466,6 @@ class DeployService {
13466
13466
  games: [`read:${slug2}`, `write:${slug2}`]
13467
13467
  }
13468
13468
  });
13469
- try {
13470
- const existingSecrets = await this.ctx.providers.secrets.readSecrets(game.id) || {};
13471
- await this.ctx.providers.secrets.writeSecrets(game.id, {
13472
- ...existingSecrets,
13473
- PLAYCADEMY_API_KEY: apiKey
13474
- });
13475
- logger8.debug("Persisted API key to secrets", { gameId: game.id });
13476
- } catch (error) {
13477
- logger8.warn("Failed to persist API key to secrets", { error });
13478
- }
13479
13469
  logger8.info("Created new game-scoped API key", {
13480
13470
  userId: user.id,
13481
13471
  slug: slug2,
@@ -13483,48 +13473,47 @@ class DeployService {
13483
13473
  });
13484
13474
  return apiKey;
13485
13475
  }
13486
- async retrieveApiKeyFromSecrets(gameId) {
13487
- try {
13488
- const secrets = await this.ctx.providers.secrets.readSecrets(gameId);
13489
- if (secrets?.PLAYCADEMY_API_KEY) {
13490
- logger8.debug("Retrieved API key from secrets");
13491
- return secrets.PLAYCADEMY_API_KEY;
13492
- }
13493
- return null;
13494
- } catch (error) {
13495
- logger8.warn("Failed to retrieve secrets", { error });
13496
- return null;
13497
- }
13498
- }
13499
- async regenerateAndPersistApiKey(user, slug2, game, existingKeyId, keyName) {
13500
- logger8.info("Regenerating API key (migration)", {
13501
- userId: user.id,
13502
- slug: slug2,
13503
- oldKeyId: existingKeyId
13504
- });
13505
- try {
13506
- await this.ctx.providers.auth.deleteApiKey(existingKeyId);
13507
- logger8.debug("Revoked old API key", { keyId: existingKeyId });
13508
- } catch (error) {
13509
- logger8.warn("Failed to revoke old API key", {
13510
- keyId: existingKeyId,
13511
- error
13476
+ async regenerateApiKey(user, slug2, existingKeyId, keyName) {
13477
+ if (existingKeyId) {
13478
+ logger8.info("Regenerating API key", {
13479
+ userId: user.id,
13480
+ slug: slug2,
13481
+ oldKeyId: existingKeyId
13512
13482
  });
13483
+ try {
13484
+ await this.ctx.providers.auth.deleteApiKey(existingKeyId);
13485
+ logger8.debug("Revoked old API key", { keyId: existingKeyId });
13486
+ } catch (error) {
13487
+ logger8.warn("Failed to revoke old API key", {
13488
+ keyId: existingKeyId,
13489
+ error
13490
+ });
13491
+ }
13513
13492
  }
13514
- return this.createAndPersistApiKey(user, slug2, game, keyName);
13493
+ return this.createApiKey(user, slug2, keyName);
13515
13494
  }
13516
- async resolveApiKeyForDeployment(user, slug2, game, headers) {
13495
+ async ensureApiKeyOnWorker(user, slug2, deploymentId, headers) {
13496
+ const cf = this.getCloudflare();
13517
13497
  const keyName = getGameWorkerApiKeyName(slug2);
13518
13498
  const existingKeys = await this.ctx.providers.auth.listApiKeys(headers);
13519
13499
  const existingKey = existingKeys.find((k) => k.name === keyName);
13500
+ let apiKey;
13520
13501
  if (!existingKey) {
13521
- return this.createAndPersistApiKey(user, slug2, game, keyName);
13522
- }
13523
- const apiKey = await this.retrieveApiKeyFromSecrets(game.id);
13524
- if (apiKey) {
13525
- return apiKey;
13502
+ apiKey = await this.createApiKey(user, slug2, keyName);
13503
+ } else {
13504
+ try {
13505
+ const workerSecrets = await cf.listSecrets(deploymentId);
13506
+ if (workerSecrets.includes("PLAYCADEMY_API_KEY")) {
13507
+ logger8.debug("API key already on worker", { slug: slug2, deploymentId });
13508
+ return;
13509
+ }
13510
+ } catch (error) {
13511
+ logger8.warn("Could not check worker secrets, will regenerate key", { error });
13512
+ }
13513
+ apiKey = await this.regenerateApiKey(user, slug2, existingKey.id, keyName);
13526
13514
  }
13527
- return this.regenerateAndPersistApiKey(user, slug2, game, existingKey.id, keyName);
13515
+ await cf.setSecrets(deploymentId, { PLAYCADEMY_API_KEY: apiKey });
13516
+ logger8.info("Set API key on worker", { slug: slug2, deploymentId });
13528
13517
  }
13529
13518
  async* deploy(slug2, request, user, uploadDeps, extractZip) {
13530
13519
  const cf = this.getCloudflare();
@@ -13572,9 +13561,7 @@ class DeployService {
13572
13561
  }
13573
13562
  const env = {
13574
13563
  GAME_ID: game.id,
13575
- PLAYCADEMY_BASE_URL: playcademyBaseUrl,
13576
- ...request._gameApiKey && { PLAYCADEMY_API_KEY: request._gameApiKey },
13577
- ...request.secrets && { secrets: request.secrets }
13564
+ PLAYCADEMY_BASE_URL: playcademyBaseUrl
13578
13565
  };
13579
13566
  const deployMsg = hasBackend ? "Deploying backend code" : "Deploying to platform";
13580
13567
  yield { type: "status", data: { message: deployMsg } };
@@ -13597,6 +13584,10 @@ class DeployService {
13597
13584
  }
13598
13585
  const codeHash = hasBackend ? await generateDeploymentHash(request.code) : null;
13599
13586
  await this.saveDeployment(game.id, result.deploymentId, result.url, codeHash, result.resources);
13587
+ if (hasBackend && request._headers) {
13588
+ yield { type: "status", data: { message: "Configuring worker secrets" } };
13589
+ await this.ensureApiKeyOnWorker(user, slug2, result.deploymentId, request._headers);
13590
+ }
13600
13591
  yield { type: "status", data: { message: "Finalizing deployment" } };
13601
13592
  if (hasMetadata || hasFrontend) {
13602
13593
  const updates = { updatedAt: new Date };
@@ -14080,12 +14071,6 @@ class GameService {
14080
14071
  } catch (keyError) {
14081
14072
  logger11.warn("Failed to cleanup API key", { gameId, error: keyError });
14082
14073
  }
14083
- try {
14084
- await this.ctx.providers.secrets.deleteSecrets(gameId);
14085
- logger11.info("Cleaned up secrets for deleted game", { gameId });
14086
- } catch (secretsError) {
14087
- logger11.warn("Failed to cleanup secrets", { gameId, error: secretsError });
14088
- }
14089
14074
  }
14090
14075
  return {
14091
14076
  slug: gameToDelete.slug,
@@ -15035,1090 +15020,12 @@ var init_logs_service = __esm(() => {
15035
15020
  logger16 = log.scope("LogsService");
15036
15021
  });
15037
15022
 
15038
- // ../../node_modules/aws-jwt-verify/dist/esm/error.js
15039
- var JwtBaseError, FailedAssertionError, JwtParseError, ParameterValidationError, JwtInvalidSignatureError, JwtInvalidSignatureAlgorithmError, JwtInvalidClaimError, JwtInvalidIssuerError, JwtInvalidAudienceError, JwtInvalidScopeError, JwtExpiredError, JwtNotBeforeError, CognitoJwtInvalidGroupError, CognitoJwtInvalidTokenUseError, CognitoJwtInvalidClientIdError, JwksValidationError, JwkValidationError, JwtWithoutValidKidError, KidNotFoundInJwksError, WaitPeriodNotYetEndedJwkError, JwksNotAvailableInCacheError, JwkInvalidUseError, JwkInvalidKtyError, FetchError, NonRetryableFetchError;
15040
- var init_error = __esm(() => {
15041
- JwtBaseError = class JwtBaseError extends Error {
15042
- };
15043
- FailedAssertionError = class FailedAssertionError extends JwtBaseError {
15044
- constructor(msg, actual, expected) {
15045
- super(msg);
15046
- this.failedAssertion = {
15047
- actual,
15048
- expected
15049
- };
15050
- }
15051
- };
15052
- JwtParseError = class JwtParseError extends JwtBaseError {
15053
- constructor(msg, error) {
15054
- const message = error != null ? `${msg}: ${error}` : msg;
15055
- super(message);
15056
- }
15057
- };
15058
- ParameterValidationError = class ParameterValidationError extends JwtBaseError {
15059
- };
15060
- JwtInvalidSignatureError = class JwtInvalidSignatureError extends JwtBaseError {
15061
- };
15062
- JwtInvalidSignatureAlgorithmError = class JwtInvalidSignatureAlgorithmError extends FailedAssertionError {
15063
- };
15064
- JwtInvalidClaimError = class JwtInvalidClaimError extends FailedAssertionError {
15065
- withRawJwt({ header, payload }) {
15066
- this.rawJwt = {
15067
- header,
15068
- payload
15069
- };
15070
- return this;
15071
- }
15072
- };
15073
- JwtInvalidIssuerError = class JwtInvalidIssuerError extends JwtInvalidClaimError {
15074
- };
15075
- JwtInvalidAudienceError = class JwtInvalidAudienceError extends JwtInvalidClaimError {
15076
- };
15077
- JwtInvalidScopeError = class JwtInvalidScopeError extends JwtInvalidClaimError {
15078
- };
15079
- JwtExpiredError = class JwtExpiredError extends JwtInvalidClaimError {
15080
- };
15081
- JwtNotBeforeError = class JwtNotBeforeError extends JwtInvalidClaimError {
15082
- };
15083
- CognitoJwtInvalidGroupError = class CognitoJwtInvalidGroupError extends JwtInvalidClaimError {
15084
- };
15085
- CognitoJwtInvalidTokenUseError = class CognitoJwtInvalidTokenUseError extends JwtInvalidClaimError {
15086
- };
15087
- CognitoJwtInvalidClientIdError = class CognitoJwtInvalidClientIdError extends JwtInvalidClaimError {
15088
- };
15089
- JwksValidationError = class JwksValidationError extends JwtBaseError {
15090
- };
15091
- JwkValidationError = class JwkValidationError extends JwtBaseError {
15092
- };
15093
- JwtWithoutValidKidError = class JwtWithoutValidKidError extends JwtBaseError {
15094
- };
15095
- KidNotFoundInJwksError = class KidNotFoundInJwksError extends JwtBaseError {
15096
- };
15097
- WaitPeriodNotYetEndedJwkError = class WaitPeriodNotYetEndedJwkError extends JwtBaseError {
15098
- };
15099
- JwksNotAvailableInCacheError = class JwksNotAvailableInCacheError extends JwtBaseError {
15100
- };
15101
- JwkInvalidUseError = class JwkInvalidUseError extends FailedAssertionError {
15102
- };
15103
- JwkInvalidKtyError = class JwkInvalidKtyError extends FailedAssertionError {
15104
- };
15105
- FetchError = class FetchError extends JwtBaseError {
15106
- constructor(uri, msg) {
15107
- super(`Failed to fetch ${uri}: ${msg}`);
15108
- }
15109
- };
15110
- NonRetryableFetchError = class NonRetryableFetchError extends FetchError {
15111
- };
15112
- });
15113
-
15114
- // ../../node_modules/aws-jwt-verify/dist/esm/https-node.js
15115
- import { request } from "https";
15116
- import { pipeline } from "stream";
15117
- async function fetch2(uri, requestOptions, data) {
15118
- let responseTimeout;
15119
- return new Promise((resolve, reject) => {
15120
- const req = request(uri, {
15121
- method: "GET",
15122
- ...requestOptions
15123
- }, (response) => {
15124
- if (response.statusCode !== 200) {
15125
- done(new NonRetryableFetchError(uri, `Status code is ${response.statusCode}, expected 200`));
15126
- return;
15127
- }
15128
- pipeline(response, async (responseBody) => {
15129
- const chunks = [];
15130
- for await (const chunk of responseBody) {
15131
- chunks.push(chunk);
15132
- }
15133
- return Buffer.concat(chunks);
15134
- }, done);
15135
- });
15136
- if (requestOptions?.responseTimeout) {
15137
- responseTimeout = setTimeout(() => done(new FetchError(uri, `Response time-out (after ${requestOptions.responseTimeout} ms.)`)), requestOptions.responseTimeout);
15138
- responseTimeout.unref();
15139
- }
15140
- function done(err2, data2) {
15141
- if (responseTimeout)
15142
- clearTimeout(responseTimeout);
15143
- if (err2 == null) {
15144
- resolve(data2);
15145
- return;
15146
- }
15147
- req.socket?.emit("agentRemove");
15148
- if (!(err2 instanceof FetchError)) {
15149
- err2 = new FetchError(uri, err2.message);
15150
- }
15151
- req.destroy();
15152
- reject(err2);
15153
- }
15154
- req.on("error", done);
15155
- req.end(data);
15156
- });
15157
- }
15158
- var init_https_node = __esm(() => {
15159
- init_error();
15160
- });
15161
-
15162
- // ../../node_modules/aws-jwt-verify/dist/esm/node-web-compat-node.js
15163
- import { createPublicKey, createVerify, verify } from "crypto";
15164
- var JwtSignatureAlgorithmHashNames, nodeWebCompat;
15165
- var init_node_web_compat_node = __esm(() => {
15166
- init_https_node();
15167
- (function(JwtSignatureAlgorithmHashNames2) {
15168
- JwtSignatureAlgorithmHashNames2["RS256"] = "RSA-SHA256";
15169
- JwtSignatureAlgorithmHashNames2["RS384"] = "RSA-SHA384";
15170
- JwtSignatureAlgorithmHashNames2["RS512"] = "RSA-SHA512";
15171
- JwtSignatureAlgorithmHashNames2["ES256"] = "RSA-SHA256";
15172
- JwtSignatureAlgorithmHashNames2["ES384"] = "RSA-SHA384";
15173
- JwtSignatureAlgorithmHashNames2["ES512"] = "RSA-SHA512";
15174
- })(JwtSignatureAlgorithmHashNames || (JwtSignatureAlgorithmHashNames = {}));
15175
- nodeWebCompat = {
15176
- fetch: fetch2,
15177
- transformJwkToKeyObjectSync: (jwk) => createPublicKey({
15178
- key: jwk,
15179
- format: "jwk"
15180
- }),
15181
- transformJwkToKeyObjectAsync: async (jwk) => createPublicKey({
15182
- key: jwk,
15183
- format: "jwk"
15184
- }),
15185
- parseB64UrlString: (b64) => Buffer.from(b64, "base64").toString("utf8"),
15186
- verifySignatureSync: ({ alg, keyObject, jwsSigningInput, signature }) => alg !== "EdDSA" ? createVerify(JwtSignatureAlgorithmHashNames[alg]).update(jwsSigningInput).verify({
15187
- key: keyObject,
15188
- dsaEncoding: "ieee-p1363"
15189
- }, signature, "base64") : verify(null, Buffer.from(jwsSigningInput), keyObject, Buffer.from(signature, "base64")),
15190
- verifySignatureAsync: async (args2) => nodeWebCompat.verifySignatureSync(args2),
15191
- defaultFetchTimeouts: {
15192
- socketIdle: 1500,
15193
- response: 3000
15194
- },
15195
- setTimeoutUnref: (...args2) => setTimeout(...args2).unref(),
15196
- transformPemToJwk: async (pem) => {
15197
- return createPublicKey({
15198
- key: Buffer.from(pem),
15199
- format: "pem"
15200
- }).export({
15201
- format: "jwk"
15202
- });
15203
- }
15204
- };
15205
- });
15206
-
15207
- // ../../node_modules/aws-jwt-verify/dist/esm/https.js
15208
- class SimpleFetcher {
15209
- constructor(props) {
15210
- this.defaultRequestOptions = {
15211
- timeout: nodeWebCompat.defaultFetchTimeouts.socketIdle,
15212
- responseTimeout: nodeWebCompat.defaultFetchTimeouts.response,
15213
- ...props?.defaultRequestOptions
15214
- };
15215
- }
15216
- async fetch(uri, requestOptions, data) {
15217
- requestOptions = { ...this.defaultRequestOptions, ...requestOptions };
15218
- try {
15219
- return await fetch3(uri, requestOptions, data);
15220
- } catch (err2) {
15221
- if (err2 instanceof NonRetryableFetchError) {
15222
- throw err2;
15223
- }
15224
- return fetch3(uri, requestOptions, data);
15225
- }
15226
- }
15227
- }
15228
- var fetch3;
15229
- var init_https = __esm(() => {
15230
- init_error();
15231
- init_node_web_compat_node();
15232
- fetch3 = nodeWebCompat.fetch.bind(undefined);
15233
- });
15234
-
15235
- // ../../node_modules/aws-jwt-verify/dist/esm/safe-json-parse.js
15236
- function isJsonObject(j) {
15237
- return typeof j === "object" && !Array.isArray(j) && j !== null;
15238
- }
15239
- function safeJsonParse(s) {
15240
- return JSON.parse(s, (_, value) => {
15241
- if (typeof value === "object" && !Array.isArray(value) && value !== null) {
15242
- delete value.__proto__;
15243
- delete value.constructor;
15244
- }
15245
- return value;
15246
- });
15247
- }
15248
-
15249
- // ../../node_modules/aws-jwt-verify/dist/esm/assert.js
15250
- function assertStringEquals(name3, actual, expected, errorConstructor = FailedAssertionError) {
15251
- if (!actual) {
15252
- throw new errorConstructor(`Missing ${name3}. Expected: ${expected}`, actual, expected);
15253
- }
15254
- if (typeof actual !== "string") {
15255
- throw new errorConstructor(`${name3} is not of type string`, actual, expected);
15256
- }
15257
- if (expected !== actual) {
15258
- throw new errorConstructor(`${name3} not allowed: ${actual}. Expected: ${expected}`, actual, expected);
15259
- }
15260
- }
15261
- function assertStringArrayContainsString(name3, actual, expected, errorConstructor = FailedAssertionError) {
15262
- if (!actual) {
15263
- throw new errorConstructor(`Missing ${name3}. ${expectationMessage(expected)}`, actual, expected);
15264
- }
15265
- if (typeof actual !== "string") {
15266
- throw new errorConstructor(`${name3} is not of type string`, actual, expected);
15267
- }
15268
- return assertStringArraysOverlap(name3, actual, expected, errorConstructor);
15269
- }
15270
- function assertStringArraysOverlap(name3, actual, expected, errorConstructor = FailedAssertionError) {
15271
- if (!actual) {
15272
- throw new errorConstructor(`Missing ${name3}. ${expectationMessage(expected)}`, actual, expected);
15273
- }
15274
- const expectedAsSet = new Set(Array.isArray(expected) ? expected : [expected]);
15275
- if (typeof actual === "string") {
15276
- actual = [actual];
15277
- }
15278
- if (!Array.isArray(actual)) {
15279
- throw new errorConstructor(`${name3} is not an array`, actual, expected);
15280
- }
15281
- const overlaps = actual.some((actualItem) => {
15282
- if (typeof actualItem !== "string") {
15283
- throw new errorConstructor(`${name3} includes elements that are not of type string`, actual, expected);
15284
- }
15285
- return expectedAsSet.has(actualItem);
15286
- });
15287
- if (!overlaps) {
15288
- throw new errorConstructor(`${name3} not allowed: ${actual.join(", ")}. ${expectationMessage(expected)}`, actual, expected);
15289
- }
15290
- }
15291
- function expectationMessage(expected) {
15292
- if (Array.isArray(expected)) {
15293
- if (expected.length > 1) {
15294
- return `Expected one of: ${expected.join(", ")}`;
15295
- }
15296
- return `Expected: ${expected[0]}`;
15297
- }
15298
- return `Expected: ${expected}`;
15299
- }
15300
- function assertIsNotPromise(actual, errorFactory) {
15301
- if (actual && typeof actual.then === "function") {
15302
- throw errorFactory();
15303
- }
15304
- }
15305
- var init_assert = __esm(() => {
15306
- init_error();
15307
- });
15308
-
15309
- // ../../node_modules/aws-jwt-verify/dist/esm/jwk.js
15310
- function findJwkInJwks(jwks, kid) {
15311
- return jwks.keys.find((jwk) => jwk.kid != null && jwk.kid === kid);
15312
- }
15313
- function assertIsJwks(jwks) {
15314
- if (!jwks) {
15315
- throw new JwksValidationError("JWKS empty");
15316
- }
15317
- if (!isJsonObject(jwks)) {
15318
- throw new JwksValidationError("JWKS should be an object");
15319
- }
15320
- if (!Object.keys(jwks).includes("keys")) {
15321
- throw new JwksValidationError("JWKS does not include keys");
15322
- }
15323
- if (!Array.isArray(jwks.keys)) {
15324
- throw new JwksValidationError("JWKS keys should be an array");
15325
- }
15326
- for (const jwk of jwks.keys) {
15327
- assertIsJwk(jwk);
15328
- }
15329
- }
15330
- function assertIsSignatureJwk(jwk) {
15331
- assertStringArrayContainsString("JWK kty", jwk.kty, ["EC", "RSA", "OKP"], JwkInvalidKtyError);
15332
- if (jwk.kty === "EC") {
15333
- assertIsEsSignatureJwk(jwk);
15334
- } else if (jwk.kty === "RSA") {
15335
- assertIsRsaSignatureJwk(jwk);
15336
- } else if (jwk.kty === "OKP") {
15337
- assertIsEdDSASignatureJwk(jwk);
15338
- }
15339
- }
15340
- function assertIsEdDSASignatureJwk(jwk) {
15341
- if (jwk.use) {
15342
- assertStringEquals("JWK use", jwk.use, "sig", JwkInvalidUseError);
15343
- }
15344
- assertStringEquals("JWK kty", jwk.kty, "OKP", JwkInvalidKtyError);
15345
- if (!jwk.crv)
15346
- throw new JwkValidationError("Missing Curve (crv)");
15347
- if (!jwk.x)
15348
- throw new JwkValidationError("Missing X Coordinate (x)");
15349
- }
15350
- function assertIsEsSignatureJwk(jwk) {
15351
- if (jwk.use) {
15352
- assertStringEquals("JWK use", jwk.use, "sig", JwkInvalidUseError);
15353
- }
15354
- assertStringEquals("JWK kty", jwk.kty, "EC", JwkInvalidKtyError);
15355
- if (!jwk.crv)
15356
- throw new JwkValidationError("Missing Curve (crv)");
15357
- if (!jwk.x)
15358
- throw new JwkValidationError("Missing X Coordinate (x)");
15359
- if (!jwk.y)
15360
- throw new JwkValidationError("Missing Y Coordinate (y)");
15361
- }
15362
- function assertIsRsaSignatureJwk(jwk) {
15363
- if (jwk.use) {
15364
- assertStringEquals("JWK use", jwk.use, "sig", JwkInvalidUseError);
15365
- }
15366
- assertStringEquals("JWK kty", jwk.kty, "RSA", JwkInvalidKtyError);
15367
- if (!jwk.n)
15368
- throw new JwkValidationError("Missing modulus (n)");
15369
- if (!jwk.e)
15370
- throw new JwkValidationError("Missing exponent (e)");
15371
- }
15372
- function assertIsJwk(jwk) {
15373
- if (!jwk) {
15374
- throw new JwkValidationError("JWK empty");
15375
- }
15376
- if (!isJsonObject(jwk)) {
15377
- throw new JwkValidationError("JWK should be an object");
15378
- }
15379
- for (const field of mandatoryJwkFieldNames) {
15380
- if (typeof jwk[field] !== "string") {
15381
- throw new JwkValidationError(`JWK ${field} should be a string`);
15382
- }
15383
- }
15384
- for (const field of optionalJwkFieldNames) {
15385
- if (field in jwk && typeof jwk[field] !== "string") {
15386
- throw new JwkValidationError(`JWK ${field} should be a string`);
15387
- }
15388
- }
15389
- }
15390
- function isJwks(jwks) {
15391
- try {
15392
- assertIsJwks(jwks);
15393
- return true;
15394
- } catch {
15395
- return false;
15396
- }
15397
- }
15398
- function isJwk(jwk) {
15399
- try {
15400
- assertIsJwk(jwk);
15401
- return true;
15402
- } catch {
15403
- return false;
15404
- }
15405
- }
15406
-
15407
- class SimplePenaltyBox {
15408
- constructor(props) {
15409
- this.waitingUris = new Map;
15410
- this.waitSeconds = props?.waitSeconds ?? 10;
15411
- }
15412
- async wait(jwksUri) {
15413
- if (this.waitingUris.has(jwksUri)) {
15414
- throw new WaitPeriodNotYetEndedJwkError("Not allowed to fetch JWKS yet, still waiting for back off period to end");
15415
- }
15416
- }
15417
- release(jwksUri) {
15418
- const i2 = this.waitingUris.get(jwksUri);
15419
- if (i2) {
15420
- clearTimeout(i2);
15421
- this.waitingUris.delete(jwksUri);
15422
- }
15423
- }
15424
- registerFailedAttempt(jwksUri) {
15425
- const i2 = nodeWebCompat.setTimeoutUnref(() => {
15426
- this.waitingUris.delete(jwksUri);
15427
- }, this.waitSeconds * 1000);
15428
- this.waitingUris.set(jwksUri, i2);
15429
- }
15430
- registerSuccessfulAttempt(jwksUri) {
15431
- this.release(jwksUri);
15432
- }
15433
- }
15434
-
15435
- class SimpleJwksCache {
15436
- constructor(props) {
15437
- this.jwksCache = new Map;
15438
- this.fetchingJwks = new Map;
15439
- this.penaltyBox = props?.penaltyBox ?? new SimplePenaltyBox;
15440
- this.fetcher = props?.fetcher ?? new SimpleFetcher;
15441
- this.jwksParser = props?.jwksParser ?? parseJwks;
15442
- }
15443
- addJwks(jwksUri, jwks) {
15444
- this.jwksCache.set(jwksUri, jwks);
15445
- }
15446
- async getJwks(jwksUri) {
15447
- const existingFetch = this.fetchingJwks.get(jwksUri);
15448
- if (existingFetch) {
15449
- return existingFetch;
15450
- }
15451
- const jwksPromise = this.fetcher.fetch(jwksUri).then(this.jwksParser);
15452
- this.fetchingJwks.set(jwksUri, jwksPromise);
15453
- let jwks;
15454
- try {
15455
- jwks = await jwksPromise;
15456
- } finally {
15457
- this.fetchingJwks.delete(jwksUri);
15458
- }
15459
- this.jwksCache.set(jwksUri, jwks);
15460
- return jwks;
15461
- }
15462
- getCachedJwk(jwksUri, decomposedJwt) {
15463
- if (typeof decomposedJwt.header.kid !== "string") {
15464
- throw new JwtWithoutValidKidError("JWT header does not have valid kid claim");
15465
- }
15466
- if (!this.jwksCache.has(jwksUri)) {
15467
- throw new JwksNotAvailableInCacheError(`JWKS for uri ${jwksUri} not yet available in cache`);
15468
- }
15469
- const jwk = findJwkInJwks(this.jwksCache.get(jwksUri), decomposedJwt.header.kid);
15470
- if (!jwk) {
15471
- throw new KidNotFoundInJwksError(`JWK for kid ${decomposedJwt.header.kid} not found in the JWKS`);
15472
- }
15473
- return jwk;
15474
- }
15475
- async getJwk(jwksUri, decomposedJwt) {
15476
- if (typeof decomposedJwt.header.kid !== "string") {
15477
- throw new JwtWithoutValidKidError("JWT header does not have valid kid claim");
15478
- }
15479
- const cachedJwks = this.jwksCache.get(jwksUri);
15480
- if (cachedJwks) {
15481
- const cachedJwk = findJwkInJwks(cachedJwks, decomposedJwt.header.kid);
15482
- if (cachedJwk) {
15483
- return cachedJwk;
15484
- }
15485
- }
15486
- await this.penaltyBox.wait(jwksUri, decomposedJwt.header.kid);
15487
- const jwks = await this.getJwks(jwksUri);
15488
- const jwk = findJwkInJwks(jwks, decomposedJwt.header.kid);
15489
- if (!jwk) {
15490
- this.penaltyBox.registerFailedAttempt(jwksUri, decomposedJwt.header.kid);
15491
- throw new KidNotFoundInJwksError(`JWK for kid "${decomposedJwt.header.kid}" not found in the JWKS`);
15492
- } else {
15493
- this.penaltyBox.registerSuccessfulAttempt(jwksUri, decomposedJwt.header.kid);
15494
- }
15495
- return jwk;
15496
- }
15497
- }
15498
- var optionalJwkFieldNames, mandatoryJwkFieldNames, parseJwks = function(jwksBin) {
15499
- let jwks;
15500
- try {
15501
- const jwksText = new TextDecoder("utf8", {
15502
- fatal: true,
15503
- ignoreBOM: true
15504
- }).decode(jwksBin);
15505
- jwks = safeJsonParse(jwksText);
15506
- } catch (err2) {
15507
- throw new JwksValidationError(`JWKS could not be parsed as JSON: ${err2}`);
15508
- }
15509
- assertIsJwks(jwks);
15510
- return jwks;
15511
- };
15512
- var init_jwk = __esm(() => {
15513
- init_https();
15514
- init_error();
15515
- init_node_web_compat_node();
15516
- init_assert();
15517
- optionalJwkFieldNames = [
15518
- "use",
15519
- "alg",
15520
- "kid",
15521
- "n",
15522
- "e",
15523
- "x",
15524
- "y",
15525
- "crv"
15526
- ];
15527
- mandatoryJwkFieldNames = [
15528
- "kty"
15529
- ];
15530
- });
15531
-
15532
- // ../../node_modules/aws-jwt-verify/dist/esm/jwt.js
15533
- function assertJwtHeader(header) {
15534
- if (!isJsonObject(header)) {
15535
- throw new JwtParseError("JWT header is not an object");
15536
- }
15537
- if (header.alg !== undefined && typeof header.alg !== "string") {
15538
- throw new JwtParseError("JWT header alg claim is not a string");
15539
- }
15540
- if (header.kid !== undefined && typeof header.kid !== "string") {
15541
- throw new JwtParseError("JWT header kid claim is not a string");
15542
- }
15543
- }
15544
- function assertJwtPayload(payload) {
15545
- if (!isJsonObject(payload)) {
15546
- throw new JwtParseError("JWT payload is not an object");
15547
- }
15548
- if (payload.exp !== undefined && !Number.isFinite(payload.exp)) {
15549
- throw new JwtParseError("JWT payload exp claim is not a number");
15550
- }
15551
- if (payload.iss !== undefined && typeof payload.iss !== "string") {
15552
- throw new JwtParseError("JWT payload iss claim is not a string");
15553
- }
15554
- if (payload.sub !== undefined && typeof payload.sub !== "string") {
15555
- throw new JwtParseError("JWT payload sub claim is not a string");
15556
- }
15557
- if (payload.aud !== undefined && typeof payload.aud !== "string" && (!Array.isArray(payload.aud) || payload.aud.some((aud) => typeof aud !== "string"))) {
15558
- throw new JwtParseError("JWT payload aud claim is not a string or array of strings");
15559
- }
15560
- if (payload.nbf !== undefined && !Number.isFinite(payload.nbf)) {
15561
- throw new JwtParseError("JWT payload nbf claim is not a number");
15562
- }
15563
- if (payload.iat !== undefined && !Number.isFinite(payload.iat)) {
15564
- throw new JwtParseError("JWT payload iat claim is not a number");
15565
- }
15566
- if (payload.scope !== undefined && typeof payload.scope !== "string") {
15567
- throw new JwtParseError("JWT payload scope claim is not a string");
15568
- }
15569
- if (payload.jti !== undefined && typeof payload.jti !== "string") {
15570
- throw new JwtParseError("JWT payload jti claim is not a string");
15571
- }
15572
- }
15573
- function decomposeUnverifiedJwt(jwt) {
15574
- if (!jwt) {
15575
- throw new JwtParseError("Empty JWT");
15576
- }
15577
- if (typeof jwt !== "string") {
15578
- throw new JwtParseError("JWT is not a string");
15579
- }
15580
- if (!JWT_REGEX.test(jwt)) {
15581
- throw new JwtParseError("JWT string does not consist of exactly 3 parts (header, payload, signature)");
15582
- }
15583
- const [headerB64, payloadB64, signatureB64] = jwt.split(".");
15584
- const [headerString, payloadString] = [headerB64, payloadB64].map(nodeWebCompat.parseB64UrlString);
15585
- let header;
15586
- try {
15587
- header = safeJsonParse(headerString);
15588
- } catch (err2) {
15589
- throw new JwtParseError("Invalid JWT. Header is not a valid JSON object", err2);
15590
- }
15591
- assertJwtHeader(header);
15592
- let payload;
15593
- try {
15594
- payload = safeJsonParse(payloadString);
15595
- } catch (err2) {
15596
- throw new JwtParseError("Invalid JWT. Payload is not a valid JSON object", err2);
15597
- }
15598
- assertJwtPayload(payload);
15599
- return {
15600
- header,
15601
- headerB64,
15602
- payload,
15603
- payloadB64,
15604
- signatureB64
15605
- };
15606
- }
15607
- function validateJwtFields(payload, options) {
15608
- if (payload.exp !== undefined) {
15609
- if (payload.exp + (options.graceSeconds ?? 0) < Date.now() / 1000) {
15610
- throw new JwtExpiredError(`Token expired at ${new Date(payload.exp * 1000).toISOString()}`, payload.exp);
15611
- }
15612
- }
15613
- if (payload.nbf !== undefined) {
15614
- if (payload.nbf - (options.graceSeconds ?? 0) > Date.now() / 1000) {
15615
- throw new JwtNotBeforeError(`Token can't be used before ${new Date(payload.nbf * 1000).toISOString()}`, payload.nbf);
15616
- }
15617
- }
15618
- if (options.issuer !== null) {
15619
- if (options.issuer === undefined) {
15620
- throw new ParameterValidationError("issuer must be provided or set to null explicitly");
15621
- }
15622
- assertStringArrayContainsString("Issuer", payload.iss, options.issuer, JwtInvalidIssuerError);
15623
- }
15624
- if (options.audience !== null) {
15625
- if (options.audience === undefined) {
15626
- throw new ParameterValidationError("audience must be provided or set to null explicitly");
15627
- }
15628
- assertStringArraysOverlap("Audience", payload.aud, options.audience, JwtInvalidAudienceError);
15629
- }
15630
- if (options.scope != null) {
15631
- assertStringArraysOverlap("Scope", payload.scope?.split(" "), options.scope, JwtInvalidScopeError);
15632
- }
15633
- }
15634
- var JWT_REGEX;
15635
- var init_jwt = __esm(() => {
15636
- init_assert();
15637
- init_error();
15638
- init_node_web_compat_node();
15639
- JWT_REGEX = /^[A-Za-z0-9_-]+={0,2}\.[A-Za-z0-9_-]+={0,2}\.[A-Za-z0-9_-]+={0,2}$/;
15640
- });
15641
-
15642
- // ../../node_modules/aws-jwt-verify/dist/esm/jwt-verifier.js
15643
- function validateJwtHeaderAndJwk(header, jwk) {
15644
- assertIsSignatureJwk(jwk);
15645
- if (jwk.alg) {
15646
- assertStringEquals("JWT signature algorithm", header.alg, jwk.alg, JwtInvalidSignatureAlgorithmError);
15647
- }
15648
- assertStringArrayContainsString("JWT signature algorithm", header.alg, supportedSignatureAlgorithms, JwtInvalidSignatureAlgorithmError);
15649
- }
15650
- async function verifyDecomposedJwt(decomposedJwt, jwksUri, options, jwkFetcher, transformJwkToKeyObjectFn) {
15651
- const { header, headerB64, payload, payloadB64, signatureB64 } = decomposedJwt;
15652
- const jwk = await jwkFetcher(jwksUri, decomposedJwt);
15653
- validateJwtHeaderAndJwk(decomposedJwt.header, jwk);
15654
- const keyObject = await transformJwkToKeyObjectFn(jwk, header.alg, payload.iss);
15655
- const valid = await nodeWebCompat.verifySignatureAsync({
15656
- jwsSigningInput: `${headerB64}.${payloadB64}`,
15657
- signature: signatureB64,
15658
- alg: header.alg,
15659
- keyObject
15660
- });
15661
- if (!valid) {
15662
- throw new JwtInvalidSignatureError("Invalid signature");
15663
- }
15664
- try {
15665
- validateJwtFields(payload, options);
15666
- if (options.customJwtCheck) {
15667
- await options.customJwtCheck({ header, payload, jwk });
15668
- }
15669
- } catch (err2) {
15670
- if (options.includeRawJwtInErrors && err2 instanceof JwtInvalidClaimError) {
15671
- throw err2.withRawJwt(decomposedJwt);
15672
- }
15673
- throw err2;
15674
- }
15675
- return payload;
15676
- }
15677
- function verifyDecomposedJwtSync(decomposedJwt, jwkOrJwks, options, transformJwkToKeyObjectFn) {
15678
- const { header, headerB64, payload, payloadB64, signatureB64 } = decomposedJwt;
15679
- let jwk;
15680
- if (isJwk(jwkOrJwks)) {
15681
- jwk = jwkOrJwks;
15682
- } else if (isJwks(jwkOrJwks)) {
15683
- const locatedJwk = header.kid ? findJwkInJwks(jwkOrJwks, header.kid) : undefined;
15684
- if (!locatedJwk) {
15685
- throw new KidNotFoundInJwksError(`JWK for kid ${header.kid} not found in the JWKS`);
15686
- }
15687
- jwk = locatedJwk;
15688
- } else {
15689
- throw new ParameterValidationError([
15690
- `Expected a valid JWK or JWKS (parsed as JavaScript object), but received: ${jwkOrJwks}.`,
15691
- "If you're passing a JWKS URI, use the async verify() method instead, it will download and parse the JWKS for you"
15692
- ].join());
15693
- }
15694
- validateJwtHeaderAndJwk(decomposedJwt.header, jwk);
15695
- const keyObject = transformJwkToKeyObjectFn(jwk, header.alg, payload.iss);
15696
- const valid = nodeWebCompat.verifySignatureSync({
15697
- jwsSigningInput: `${headerB64}.${payloadB64}`,
15698
- signature: signatureB64,
15699
- alg: header.alg,
15700
- keyObject
15701
- });
15702
- if (!valid) {
15703
- throw new JwtInvalidSignatureError("Invalid signature");
15704
- }
15705
- try {
15706
- validateJwtFields(payload, options);
15707
- if (options.customJwtCheck) {
15708
- const res = options.customJwtCheck({ header, payload, jwk });
15709
- assertIsNotPromise(res, () => new ParameterValidationError("Custom JWT checks must be synchronous but a promise was returned"));
15710
- }
15711
- } catch (err2) {
15712
- if (options.includeRawJwtInErrors && err2 instanceof JwtInvalidClaimError) {
15713
- throw err2.withRawJwt(decomposedJwt);
15714
- }
15715
- throw err2;
15716
- }
15717
- return payload;
15718
- }
15719
-
15720
- class JwtVerifierBase {
15721
- constructor(verifyProperties, jwksCache = new SimpleJwksCache) {
15722
- this.jwksCache = jwksCache;
15723
- this.issuersConfig = new Map;
15724
- this.publicKeyCache = new KeyObjectCache;
15725
- if (Array.isArray(verifyProperties)) {
15726
- if (!verifyProperties.length) {
15727
- throw new ParameterValidationError("Provide at least one issuer configuration");
15728
- }
15729
- verifyProperties.forEach((prop, index2) => {
15730
- if (this.issuersConfig.has(prop.issuer)) {
15731
- throw new ParameterValidationError(`issuer ${prop.issuer} supplied multiple times`);
15732
- } else if (prop.issuer === null && verifyProperties.length >= 2) {
15733
- throw new ParameterValidationError(`issuer cannot be null when multiple issuers are supplied (at issuer: ${index2})`);
15734
- }
15735
- this.issuersConfig.set(prop.issuer, this.withJwksUri(prop));
15736
- });
15737
- } else {
15738
- this.issuersConfig.set(verifyProperties.issuer, this.withJwksUri(verifyProperties));
15739
- }
15740
- }
15741
- getIssuerConfig(issuer) {
15742
- if (this.issuersConfig.size === 1) {
15743
- issuer = this.issuersConfig.keys().next().value;
15744
- }
15745
- if (issuer === undefined) {
15746
- throw new ParameterValidationError("issuer must be provided");
15747
- }
15748
- const config2 = this.issuersConfig.get(issuer);
15749
- if (!config2) {
15750
- throw new ParameterValidationError(`issuer not configured: ${issuer}`);
15751
- }
15752
- return config2;
15753
- }
15754
- cacheJwks(...[jwks, issuer]) {
15755
- const issuerConfig = this.getIssuerConfig(issuer);
15756
- this.jwksCache.addJwks(issuerConfig.jwksUri, jwks);
15757
- this.publicKeyCache.clearCache(issuerConfig.issuer);
15758
- }
15759
- async hydrate() {
15760
- const jwksFetches = Array.from(this.issuersConfig.values()).map(({ jwksUri }) => this.jwksCache.getJwks(jwksUri));
15761
- await Promise.all(jwksFetches);
15762
- }
15763
- verifySync(...[jwt, properties]) {
15764
- const { decomposedJwt, jwksUri, verifyProperties } = this.getVerifyParameters(jwt, properties);
15765
- return this.verifyDecomposedJwtSync(decomposedJwt, jwksUri, verifyProperties);
15766
- }
15767
- verifyDecomposedJwtSync(decomposedJwt, jwksUri, verifyProperties) {
15768
- const jwk = this.jwksCache.getCachedJwk(jwksUri, decomposedJwt);
15769
- return verifyDecomposedJwtSync(decomposedJwt, jwk, verifyProperties, this.publicKeyCache.transformJwkToKeyObjectSync.bind(this.publicKeyCache));
15770
- }
15771
- async verify(...[jwt, properties]) {
15772
- const { decomposedJwt, jwksUri, verifyProperties } = this.getVerifyParameters(jwt, properties);
15773
- return this.verifyDecomposedJwt(decomposedJwt, jwksUri, verifyProperties);
15774
- }
15775
- verifyDecomposedJwt(decomposedJwt, jwksUri, verifyProperties) {
15776
- return verifyDecomposedJwt(decomposedJwt, jwksUri, verifyProperties, this.jwksCache.getJwk.bind(this.jwksCache), this.publicKeyCache.transformJwkToKeyObjectAsync.bind(this.publicKeyCache));
15777
- }
15778
- getVerifyParameters(jwt, verifyProperties) {
15779
- const decomposedJwt = decomposeUnverifiedJwt(jwt);
15780
- const issuerConfig = this.getIssuerConfig(decomposedJwt.payload.iss);
15781
- return {
15782
- decomposedJwt,
15783
- jwksUri: issuerConfig.jwksUri,
15784
- verifyProperties: {
15785
- ...issuerConfig,
15786
- ...verifyProperties
15787
- }
15788
- };
15789
- }
15790
- withJwksUri(config2) {
15791
- if (config2.jwksUri) {
15792
- return config2;
15793
- }
15794
- const issuer = config2.issuer;
15795
- if (!issuer) {
15796
- throw new ParameterValidationError("jwksUri must be provided for issuer null");
15797
- }
15798
- const issuerUri = new URL(issuer).pathname.replace(/\/$/, "");
15799
- return {
15800
- jwksUri: new URL(`${issuerUri}/.well-known/jwks.json`, issuer).href,
15801
- ...config2
15802
- };
15803
- }
15804
- }
15805
-
15806
- class KeyObjectCache {
15807
- constructor(transformJwkToKeyObjectSyncFn = nodeWebCompat.transformJwkToKeyObjectSync, transformJwkToKeyObjectAsyncFn = nodeWebCompat.transformJwkToKeyObjectAsync) {
15808
- this.transformJwkToKeyObjectSyncFn = transformJwkToKeyObjectSyncFn;
15809
- this.transformJwkToKeyObjectAsyncFn = transformJwkToKeyObjectAsyncFn;
15810
- this.publicKeys = new Map;
15811
- }
15812
- transformJwkToKeyObjectSync(jwk, jwtHeaderAlg, issuer) {
15813
- const alg = jwk.alg ?? jwtHeaderAlg;
15814
- if (!issuer || !jwk.kid || !alg) {
15815
- return this.transformJwkToKeyObjectSyncFn(jwk, alg, issuer);
15816
- }
15817
- const fromCache = this.publicKeys.get(issuer)?.get(jwk.kid)?.get(alg);
15818
- if (fromCache)
15819
- return fromCache;
15820
- const publicKey = this.transformJwkToKeyObjectSyncFn(jwk, alg, issuer);
15821
- this.putKeyObjectInCache(issuer, jwk.kid, alg, publicKey);
15822
- return publicKey;
15823
- }
15824
- async transformJwkToKeyObjectAsync(jwk, jwtHeaderAlg, issuer) {
15825
- const alg = jwk.alg ?? jwtHeaderAlg;
15826
- if (!issuer || !jwk.kid || !alg) {
15827
- return this.transformJwkToKeyObjectAsyncFn(jwk, alg, issuer);
15828
- }
15829
- const fromCache = this.publicKeys.get(issuer)?.get(jwk.kid)?.get(alg);
15830
- if (fromCache)
15831
- return fromCache;
15832
- const publicKey = await this.transformJwkToKeyObjectAsyncFn(jwk, alg, issuer);
15833
- this.putKeyObjectInCache(issuer, jwk.kid, alg, publicKey);
15834
- return publicKey;
15835
- }
15836
- putKeyObjectInCache(issuer, kid, alg, publicKey) {
15837
- const cachedIssuer = this.publicKeys.get(issuer);
15838
- const cachedIssuerKid = cachedIssuer?.get(kid);
15839
- if (cachedIssuerKid) {
15840
- cachedIssuerKid.set(alg, publicKey);
15841
- } else if (cachedIssuer) {
15842
- cachedIssuer.set(kid, new Map([[alg, publicKey]]));
15843
- } else {
15844
- this.publicKeys.set(issuer, new Map([[kid, new Map([[alg, publicKey]])]]));
15845
- }
15846
- }
15847
- clearCache(issuer) {
15848
- this.publicKeys.delete(issuer);
15849
- }
15850
- }
15851
- var supportedSignatureAlgorithms, JwtVerifier;
15852
- var init_jwt_verifier = __esm(() => {
15853
- init_jwk();
15854
- init_assert();
15855
- init_jwt();
15856
- init_error();
15857
- init_node_web_compat_node();
15858
- supportedSignatureAlgorithms = [
15859
- "RS256",
15860
- "RS384",
15861
- "RS512",
15862
- "ES256",
15863
- "ES384",
15864
- "ES512",
15865
- "EdDSA"
15866
- ];
15867
- JwtVerifier = class JwtVerifier extends JwtVerifierBase {
15868
- static create(verifyProperties, additionalProperties) {
15869
- return new this(verifyProperties, additionalProperties?.jwksCache);
15870
- }
15871
- };
15872
- });
15873
-
15874
- // ../../node_modules/aws-jwt-verify/dist/esm/cognito-verifier.js
15875
- function validateCognitoJwtFields(payload, options) {
15876
- if (options.groups != null) {
15877
- assertStringArraysOverlap("Cognito group", payload["cognito:groups"], options.groups, CognitoJwtInvalidGroupError);
15878
- }
15879
- assertStringArrayContainsString("Token use", payload.token_use, ["id", "access"], CognitoJwtInvalidTokenUseError);
15880
- if (options.tokenUse !== null) {
15881
- if (options.tokenUse === undefined) {
15882
- throw new ParameterValidationError("tokenUse must be provided or set to null explicitly");
15883
- }
15884
- assertStringEquals("Token use", payload.token_use, options.tokenUse, CognitoJwtInvalidTokenUseError);
15885
- }
15886
- if (options.clientId !== null) {
15887
- if (options.clientId === undefined) {
15888
- throw new ParameterValidationError("clientId must be provided or set to null explicitly");
15889
- }
15890
- if (payload.token_use === "id") {
15891
- assertStringArrayContainsString('Client ID ("audience")', payload.aud, options.clientId, CognitoJwtInvalidClientIdError);
15892
- } else {
15893
- assertStringArrayContainsString("Client ID", payload.client_id, options.clientId, CognitoJwtInvalidClientIdError);
15894
- }
15895
- }
15896
- }
15897
- var CognitoJwtVerifier;
15898
- var init_cognito_verifier = __esm(() => {
15899
- init_error();
15900
- init_jwt_verifier();
15901
- init_assert();
15902
- CognitoJwtVerifier = class CognitoJwtVerifier extends JwtVerifierBase {
15903
- constructor(props, jwksCache) {
15904
- const issuerConfig = Array.isArray(props) ? props.map((p) => ({
15905
- ...p,
15906
- ...CognitoJwtVerifier.parseUserPoolId(p.userPoolId),
15907
- audience: null
15908
- })) : {
15909
- ...props,
15910
- ...CognitoJwtVerifier.parseUserPoolId(props.userPoolId),
15911
- audience: null
15912
- };
15913
- super(issuerConfig, jwksCache);
15914
- }
15915
- static parseUserPoolId(userPoolId) {
15916
- const match = userPoolId.match(this.USER_POOL_ID_REGEX);
15917
- if (!match) {
15918
- throw new ParameterValidationError(`Invalid Cognito User Pool ID: ${userPoolId}`);
15919
- }
15920
- const region = match.groups.region;
15921
- const issuer = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}`;
15922
- return {
15923
- issuer,
15924
- jwksUri: `${issuer}/.well-known/jwks.json`
15925
- };
15926
- }
15927
- static create(verifyProperties, additionalProperties) {
15928
- return new this(verifyProperties, additionalProperties?.jwksCache);
15929
- }
15930
- verifySync(...[jwt, properties]) {
15931
- const { decomposedJwt, jwksUri, verifyProperties } = this.getVerifyParameters(jwt, properties);
15932
- this.verifyDecomposedJwtSync(decomposedJwt, jwksUri, verifyProperties);
15933
- try {
15934
- validateCognitoJwtFields(decomposedJwt.payload, verifyProperties);
15935
- } catch (err2) {
15936
- if (verifyProperties.includeRawJwtInErrors && err2 instanceof JwtInvalidClaimError) {
15937
- throw err2.withRawJwt(decomposedJwt);
15938
- }
15939
- throw err2;
15940
- }
15941
- return decomposedJwt.payload;
15942
- }
15943
- async verify(...[jwt, properties]) {
15944
- const { decomposedJwt, jwksUri, verifyProperties } = this.getVerifyParameters(jwt, properties);
15945
- await this.verifyDecomposedJwt(decomposedJwt, jwksUri, verifyProperties);
15946
- try {
15947
- validateCognitoJwtFields(decomposedJwt.payload, verifyProperties);
15948
- } catch (err2) {
15949
- if (verifyProperties.includeRawJwtInErrors && err2 instanceof JwtInvalidClaimError) {
15950
- throw err2.withRawJwt(decomposedJwt);
15951
- }
15952
- throw err2;
15953
- }
15954
- return decomposedJwt.payload;
15955
- }
15956
- cacheJwks(...[jwks, userPoolId]) {
15957
- let issuer;
15958
- if (userPoolId !== undefined) {
15959
- issuer = CognitoJwtVerifier.parseUserPoolId(userPoolId).issuer;
15960
- } else if (Array.from(this.issuersConfig).length > 1) {
15961
- throw new ParameterValidationError("userPoolId must be provided");
15962
- }
15963
- const issuerConfig = this.getIssuerConfig(issuer);
15964
- super.cacheJwks(jwks, issuerConfig.issuer);
15965
- }
15966
- };
15967
- CognitoJwtVerifier.USER_POOL_ID_REGEX = /^(?<region>[a-z]{2}-(gov-)?[a-z]+-\d)_[a-zA-Z0-9]+$/;
15968
- });
15969
- // ../../node_modules/aws-jwt-verify/dist/esm/alb-cache.js
15970
- var init_alb_cache = __esm(() => {
15971
- init_error();
15972
- init_https();
15973
- init_node_web_compat_node();
15974
- });
15975
-
15976
- // ../../node_modules/aws-jwt-verify/dist/esm/alb-verifier.js
15977
- var init_alb_verifier = __esm(() => {
15978
- init_alb_cache();
15979
- init_assert();
15980
- init_error();
15981
- init_jwt_verifier();
15982
- });
15983
-
15984
- // ../../node_modules/aws-jwt-verify/dist/esm/index.js
15985
- var init_esm2 = __esm(() => {
15986
- init_jwt_verifier();
15987
- init_cognito_verifier();
15988
- init_alb_verifier();
15989
- init_jwt_verifier();
15990
- });
15991
-
15992
- // ../api-core/src/utils/lti.util.ts
15993
- function generateUsername(email) {
15994
- const baseUsername = (email.split("@")[0] || "user").toLowerCase();
15995
- const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
15996
- const randomSuffix = Math.random().toString(36).substring(2, 7);
15997
- return `${cleanUsername}_${randomSuffix}`;
15998
- }
15999
- function extractRedirectPath(targetUri, currentHost) {
16000
- try {
16001
- const targetUrl = new URL(targetUri);
16002
- if (targetUrl.hostname === currentHost) {
16003
- return targetUrl.pathname + targetUrl.search;
16004
- }
16005
- } catch {}
16006
- return "/";
16007
- }
16008
- function getLtiRoles(claims) {
16009
- return claims["https://purl.imsglobal.org/spec/lti/claim/roles"] || [];
16010
- }
16011
- function hasLtiRole(claims, role) {
16012
- return getLtiRoles(claims).some((r) => r.includes(role));
16013
- }
16014
- function validateLtiClaims(claims) {
16015
- const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
16016
- const version2 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
16017
- if (messageType !== "LtiResourceLinkRequest") {
16018
- return `Invalid LTI message type: ${messageType}`;
16019
- }
16020
- if (version2 !== "1.3.0") {
16021
- return `Unsupported LTI version: ${version2}`;
16022
- }
16023
- return null;
16024
- }
16025
- var LtiRoleChecks;
16026
- var init_lti_util = __esm(() => {
16027
- LtiRoleChecks = {
16028
- isLearner: (claims) => hasLtiRole(claims, "Learner"),
16029
- isInstructor: (claims) => hasLtiRole(claims, "Instructor"),
16030
- isAdministrator: (claims) => hasLtiRole(claims, "Administrator"),
16031
- isContentDeveloper: (claims) => hasLtiRole(claims, "ContentDeveloper"),
16032
- isMentor: (claims) => hasLtiRole(claims, "Mentor")
16033
- };
16034
- });
16035
-
16036
15023
  // ../api-core/src/services/lti.service.ts
16037
- import * as crypto4 from "node:crypto";
16038
-
16039
15024
  class LtiService {
16040
15025
  ctx;
16041
- verifier = null;
16042
15026
  constructor(ctx) {
16043
15027
  this.ctx = ctx;
16044
15028
  }
16045
- getConfig() {
16046
- if (!this.ctx.config.lti) {
16047
- logger17.error("LTI configuration not available");
16048
- throw new ValidationError("LTI is not configured");
16049
- }
16050
- return this.ctx.config.lti;
16051
- }
16052
- getVerifier() {
16053
- if (!this.verifier) {
16054
- const lti = this.getConfig();
16055
- this.verifier = JwtVerifier.create({
16056
- issuer: lti.issuer,
16057
- audience: lti.audience,
16058
- jwksUri: lti.jwksUrl
16059
- });
16060
- }
16061
- return this.verifier;
16062
- }
16063
- async verifyToken(idToken) {
16064
- if (this.ctx.config.ltiTestMode) {
16065
- if (!idToken.startsWith("mock:")) {
16066
- throw new ValidationError("Invalid LTI token");
16067
- }
16068
- try {
16069
- const jsonStr = Buffer.from(idToken.slice(5), "base64").toString();
16070
- return JSON.parse(jsonStr);
16071
- } catch {
16072
- throw new ValidationError("Invalid LTI token format");
16073
- }
16074
- }
16075
- try {
16076
- const verifier = this.getVerifier();
16077
- const claims = await verifier.verify(idToken);
16078
- logger17.info("Verified token", {
16079
- sub: claims.sub,
16080
- email: claims.email,
16081
- roles: claims["https://purl.imsglobal.org/spec/lti/claim/roles"]
16082
- });
16083
- return claims;
16084
- } catch (error) {
16085
- logger17.error("Token verification failed", {
16086
- error: error instanceof Error ? error.message : String(error)
16087
- });
16088
- throw new ValidationError("Invalid LTI token");
16089
- }
16090
- }
16091
- async processLaunch(idToken, currentHost) {
16092
- const claims = await this.verifyToken(idToken);
16093
- const validationError = validateLtiClaims(claims);
16094
- if (validationError) {
16095
- logger17.warn("LTI claims validation failed", {
16096
- error: validationError,
16097
- sub: claims.sub
16098
- });
16099
- throw new ValidationError(validationError);
16100
- }
16101
- const user = await this.provisionUser(claims);
16102
- logger17.info("Processed launch roles", {
16103
- userId: user.id,
16104
- isLearner: LtiRoleChecks.isLearner(claims),
16105
- isInstructor: LtiRoleChecks.isInstructor(claims),
16106
- isAdministrator: LtiRoleChecks.isAdministrator(claims),
16107
- allRoles: claims["https://purl.imsglobal.org/spec/lti/claim/roles"]
16108
- });
16109
- const sessionToken = await this.createSession(user.id);
16110
- const targetUri = claims["https://purl.imsglobal.org/spec/lti/claim/target_link_uri"];
16111
- const redirectPath = extractRedirectPath(targetUri, currentHost);
16112
- logger17.info("Launch processed", { userId: user.id, redirectPath });
16113
- const userInfo = {
16114
- sub: user.id,
16115
- email: user.email,
16116
- name: user.name,
16117
- email_verified: user.emailVerified,
16118
- timeback_id: user.timebackId ?? undefined
16119
- };
16120
- return { user: userInfo, redirectPath, sessionToken };
16121
- }
16122
15029
  async getStatus(user) {
16123
15030
  const db2 = this.ctx.db;
16124
15031
  const [ltiAccount, oauthAccount, userRecord] = await Promise.all([
@@ -16142,134 +15049,11 @@ class LtiService {
16142
15049
  userId: user.id
16143
15050
  };
16144
15051
  }
16145
- async createSession(userId) {
16146
- const db2 = this.ctx.db;
16147
- const sessionToken = crypto4.randomUUID();
16148
- const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);
16149
- const [session2] = await db2.insert(sessions).values({
16150
- id: crypto4.randomUUID(),
16151
- userId,
16152
- token: sessionToken,
16153
- expiresAt,
16154
- createdAt: new Date,
16155
- updatedAt: new Date
16156
- }).returning({ id: sessions.id });
16157
- if (!session2) {
16158
- logger17.error("Session insert returned no rows", { userId });
16159
- throw new InternalError("Failed to create session");
16160
- }
16161
- logger17.info("Created session", {
16162
- userId,
16163
- providerId: AUTH_PROVIDER_IDS.TIMEBACK_LTI
16164
- });
16165
- return sessionToken;
16166
- }
16167
- async provisionUser(claims) {
16168
- const db2 = this.ctx.db;
16169
- const email = claims.email;
16170
- const ltiTimebackId = claims.sub;
16171
- const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
16172
- if (!email) {
16173
- throw new ValidationError("Email is required in LTI claims");
16174
- }
16175
- const existingAccount = await db2.query.accounts.findFirst({
16176
- where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
16177
- });
16178
- if (existingAccount) {
16179
- const user = await db2.query.users.findFirst({
16180
- where: eq(users.id, existingAccount.userId)
16181
- });
16182
- if (user) {
16183
- logger17.info("Found user by account", {
16184
- userId: user.id,
16185
- ltiTimebackId
16186
- });
16187
- return user;
16188
- }
16189
- }
16190
- const existingUser = await db2.query.users.findFirst({
16191
- where: eq(users.email, email)
16192
- });
16193
- if (existingUser) {
16194
- await db2.transaction(async (tx) => {
16195
- const existingLtiAccount = await tx.query.accounts.findFirst({
16196
- where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
16197
- });
16198
- if (!existingLtiAccount) {
16199
- const [account] = await tx.insert(accounts).values({
16200
- id: crypto4.randomUUID(),
16201
- userId: existingUser.id,
16202
- accountId: ltiTimebackId,
16203
- providerId,
16204
- accessToken: null,
16205
- refreshToken: null,
16206
- accessTokenExpiresAt: null,
16207
- refreshTokenExpiresAt: null,
16208
- createdAt: new Date,
16209
- updatedAt: new Date
16210
- }).returning({ id: accounts.id });
16211
- if (!account) {
16212
- logger17.error("LTI account link insert returned no rows", {
16213
- userId: existingUser.id,
16214
- ltiTimebackId
16215
- });
16216
- throw new InternalError("Failed to link LTI account");
16217
- }
16218
- logger17.info("Linked existing user", {
16219
- userId: existingUser.id,
16220
- ltiTimebackId
16221
- });
16222
- }
16223
- });
16224
- return existingUser;
16225
- }
16226
- const newUserId = crypto4.randomUUID();
16227
- const createdUser = await db2.transaction(async (tx) => {
16228
- const [insertedUser] = await tx.insert(users).values({
16229
- id: newUserId,
16230
- email,
16231
- emailVerified: true,
16232
- timebackId: ltiTimebackId,
16233
- username: generateUsername(email),
16234
- name: claims.name || claims.given_name || email.split("@")[0] || "Timeback User",
16235
- createdAt: new Date,
16236
- updatedAt: new Date
16237
- }).returning();
16238
- if (!insertedUser) {
16239
- logger17.error("LTI user insert returned no rows", { email, ltiTimebackId });
16240
- throw new InternalError("Failed to create user");
16241
- }
16242
- await tx.insert(accounts).values({
16243
- id: crypto4.randomUUID(),
16244
- userId: newUserId,
16245
- accountId: ltiTimebackId,
16246
- providerId,
16247
- accessToken: null,
16248
- refreshToken: null,
16249
- accessTokenExpiresAt: null,
16250
- refreshTokenExpiresAt: null,
16251
- createdAt: new Date,
16252
- updatedAt: new Date
16253
- });
16254
- logger17.info("Provisioned user", {
16255
- userId: insertedUser.id,
16256
- ltiTimebackId
16257
- });
16258
- return insertedUser;
16259
- });
16260
- return createdUser;
16261
- }
16262
15052
  }
16263
- var logger17;
16264
15053
  var init_lti_service = __esm(() => {
16265
- init_esm2();
16266
15054
  init_drizzle_orm();
16267
15055
  init_src();
16268
15056
  init_tables_index();
16269
- init_src2();
16270
- init_errors();
16271
- init_lti_util();
16272
- logger17 = log.scope("LtiService");
16273
15057
  });
16274
15058
 
16275
15059
  // ../api-core/src/services/map.service.ts
@@ -16286,7 +15070,7 @@ class MapService {
16286
15070
  if (!mapDetails) {
16287
15071
  throw new NotFoundError("Map", identifier);
16288
15072
  }
16289
- logger18.debug("Retrieved map", { identifier });
15073
+ logger17.debug("Retrieved map", { identifier });
16290
15074
  return mapDetails;
16291
15075
  }
16292
15076
  async getElements(mapId) {
@@ -16302,7 +15086,7 @@ class MapService {
16302
15086
  }
16303
15087
  }
16304
15088
  });
16305
- logger18.debug("Retrieved elements", { mapId, count: elements.length });
15089
+ logger17.debug("Retrieved elements", { mapId, count: elements.length });
16306
15090
  return elements;
16307
15091
  }
16308
15092
  async getObjects(mapId, userId) {
@@ -16323,7 +15107,7 @@ class MapService {
16323
15107
  }
16324
15108
  }
16325
15109
  });
16326
- logger18.debug("Retrieved objects", { mapId, userId, count: objects.length });
15110
+ logger17.debug("Retrieved objects", { mapId, userId, count: objects.length });
16327
15111
  return objects.map((object) => this.formatMapObjectWithItem(object));
16328
15112
  }
16329
15113
  async createObject(mapId, data, user) {
@@ -16350,7 +15134,7 @@ class MapService {
16350
15134
  throw new NotFoundError("Item", data.itemId);
16351
15135
  }
16352
15136
  if (!item.isPlaceable) {
16353
- logger18.warn("Attempted to place non-placeable item", {
15137
+ logger17.warn("Attempted to place non-placeable item", {
16354
15138
  userId: user.id,
16355
15139
  itemId: data.itemId,
16356
15140
  mapId
@@ -16364,7 +15148,7 @@ class MapService {
16364
15148
  };
16365
15149
  const [createdObject] = await db2.insert(mapObjects).values(objectData).returning();
16366
15150
  if (!createdObject) {
16367
- logger18.error("Map object insert returned no rows", {
15151
+ logger17.error("Map object insert returned no rows", {
16368
15152
  userId: user.id,
16369
15153
  mapId,
16370
15154
  itemId: data.itemId
@@ -16388,12 +15172,12 @@ class MapService {
16388
15172
  }
16389
15173
  });
16390
15174
  if (!objectWithItem) {
16391
- logger18.error("Map object query after insert returned no rows", {
15175
+ logger17.error("Map object query after insert returned no rows", {
16392
15176
  objectId: createdObject.id
16393
15177
  });
16394
15178
  throw new InternalError("Failed to retrieve created object");
16395
15179
  }
16396
- logger18.info("Created object", {
15180
+ logger17.info("Created object", {
16397
15181
  userId: user.id,
16398
15182
  mapId,
16399
15183
  objectId: createdObject.id,
@@ -16417,7 +15201,7 @@ class MapService {
16417
15201
  if (result.length === 0) {
16418
15202
  throw new NotFoundError("MapObject", objectId);
16419
15203
  }
16420
- logger18.info("Deleted object", {
15204
+ logger17.info("Deleted object", {
16421
15205
  userId: user.id,
16422
15206
  mapId,
16423
15207
  objectId
@@ -16446,13 +15230,13 @@ class MapService {
16446
15230
  };
16447
15231
  }
16448
15232
  }
16449
- var logger18;
15233
+ var logger17;
16450
15234
  var init_map_service = __esm(() => {
16451
15235
  init_drizzle_orm();
16452
15236
  init_tables_index();
16453
15237
  init_src2();
16454
15238
  init_errors();
16455
- logger18 = log.scope("MapService");
15239
+ logger17 = log.scope("MapService");
16456
15240
  });
16457
15241
 
16458
15242
  // ../realtime/src/server/domain/events.ts
@@ -16473,13 +15257,13 @@ async function publishToUser(baseUrl, secret, userId, type, payload) {
16473
15257
  });
16474
15258
  if (!res.ok) {
16475
15259
  const text3 = await res.text().catch(() => "");
16476
- logger19.warn("Failed to publish to user", {
15260
+ logger18.warn("Failed to publish to user", {
16477
15261
  status: res.status,
16478
15262
  body: text3
16479
15263
  });
16480
15264
  }
16481
15265
  } catch (error) {
16482
- logger19.error("Publish to user error", { error });
15266
+ logger18.error("Publish to user error", { error });
16483
15267
  }
16484
15268
  }
16485
15269
 
@@ -16499,7 +15283,7 @@ class NotificationService {
16499
15283
  if (type)
16500
15284
  conditions2.push(eq(notifications.type, type));
16501
15285
  const results = await this.ctx.db.select().from(notifications).where(and(...conditions2)).orderBy(desc(notifications.createdAt)).limit(limit).offset(offset);
16502
- logger19.debug("Listed notifications", { userId: user.id, count: results.length });
15286
+ logger18.debug("Listed notifications", { userId: user.id, count: results.length });
16503
15287
  return results;
16504
15288
  }
16505
15289
  async updateStatus(notificationId, status, method) {
@@ -16517,7 +15301,7 @@ class NotificationService {
16517
15301
  if (!updated) {
16518
15302
  throw new NotFoundError("Notification", notificationId);
16519
15303
  }
16520
- logger19.debug("Updated status", { notificationId, status });
15304
+ logger18.debug("Updated status", { notificationId, status });
16521
15305
  return updated;
16522
15306
  }
16523
15307
  async getStats(user, options) {
@@ -16541,7 +15325,7 @@ class NotificationService {
16541
15325
  const clicked = statsMap.clicked || 0;
16542
15326
  const dismissed = statsMap.dismissed || 0;
16543
15327
  const expired = statsMap.expired || 0;
16544
- logger19.debug("Retrieved stats", { userId: user.id, total });
15328
+ logger18.debug("Retrieved stats", { userId: user.id, total });
16545
15329
  return {
16546
15330
  total,
16547
15331
  delivered,
@@ -16587,7 +15371,7 @@ class NotificationService {
16587
15371
  metadata: metadata2
16588
15372
  });
16589
15373
  }
16590
- logger19.debug("Created notification", {
15374
+ logger18.debug("Created notification", {
16591
15375
  userId,
16592
15376
  type,
16593
15377
  id: notificationId,
@@ -16595,14 +15379,14 @@ class NotificationService {
16595
15379
  });
16596
15380
  return notificationId;
16597
15381
  } catch (error) {
16598
- logger19.error("Failed to create notification", { userId, type, error });
15382
+ logger18.error("Failed to create notification", { userId, type, error });
16599
15383
  return null;
16600
15384
  }
16601
15385
  }
16602
15386
  async publish(userId, notificationId, type, title, message, options) {
16603
15387
  const realtimeConfig = this.ctx.config.realtime;
16604
15388
  if (!realtimeConfig) {
16605
- logger19.warn("No realtime config for publish");
15389
+ logger18.warn("No realtime config for publish");
16606
15390
  return;
16607
15391
  }
16608
15392
  const { relayUrl, publishSecret } = realtimeConfig;
@@ -16644,13 +15428,13 @@ class NotificationService {
16644
15428
  metadata: data.metadata || {}
16645
15429
  }).returning();
16646
15430
  if (!notification) {
16647
- logger19.error("Notification insert returned no rows", {
15431
+ logger18.error("Notification insert returned no rows", {
16648
15432
  userId: data.userId,
16649
15433
  type: data.type
16650
15434
  });
16651
15435
  throw new InternalError("Failed to create notification");
16652
15436
  }
16653
- logger19.info("Inserted notification", {
15437
+ logger18.info("Inserted notification", {
16654
15438
  notificationId: notification.id,
16655
15439
  userId: notification.userId,
16656
15440
  type: notification.type
@@ -16660,7 +15444,7 @@ class NotificationService {
16660
15444
  async deliverPending(userId) {
16661
15445
  const realtimeConfig = this.ctx.config.realtime;
16662
15446
  if (!realtimeConfig) {
16663
- logger19.warn("No realtime config for delivery");
15447
+ logger18.warn("No realtime config for delivery");
16664
15448
  return;
16665
15449
  }
16666
15450
  const { relayUrl, publishSecret } = realtimeConfig;
@@ -16687,13 +15471,13 @@ class NotificationService {
16687
15471
  metadata: notification.metadata,
16688
15472
  clickUrl: notification.clickUrl
16689
15473
  });
16690
- logger19.info("Delivered notification", {
15474
+ logger18.info("Delivered notification", {
16691
15475
  notificationId: notification.id,
16692
15476
  userId,
16693
15477
  type: notification.type
16694
15478
  });
16695
15479
  } catch (error) {
16696
- logger19.warn("Failed to deliver", {
15480
+ logger18.warn("Failed to deliver", {
16697
15481
  notificationId: notification.id,
16698
15482
  error
16699
15483
  });
@@ -16701,7 +15485,7 @@ class NotificationService {
16701
15485
  }
16702
15486
  }
16703
15487
  }
16704
- var logger19;
15488
+ var logger18;
16705
15489
  var init_notification_service = __esm(() => {
16706
15490
  init_drizzle_orm();
16707
15491
  init_src();
@@ -16710,7 +15494,7 @@ var init_notification_service = __esm(() => {
16710
15494
  init_events();
16711
15495
  init_notification();
16712
15496
  init_errors();
16713
- logger19 = log.scope("NotificationService");
15497
+ logger18 = log.scope("NotificationService");
16714
15498
  });
16715
15499
 
16716
15500
  // ../api-core/src/services/realtime.service.ts
@@ -16745,20 +15529,20 @@ class RealtimeService {
16745
15529
  }
16746
15530
  const displayName = user.username || (user.name ? user.name.split(" ")[0] : undefined) || undefined;
16747
15531
  const token = await this.ctx.providers.auth.mintRealtimeToken(user.id, resolvedGameId, displayName, user.role);
16748
- logger20.info("Generated token", {
15532
+ logger19.info("Generated token", {
16749
15533
  userId: user.id,
16750
15534
  gameId: resolvedGameId || "global"
16751
15535
  });
16752
15536
  return { token };
16753
15537
  }
16754
15538
  }
16755
- var logger20;
15539
+ var logger19;
16756
15540
  var init_realtime_service = __esm(() => {
16757
15541
  init_drizzle_orm();
16758
15542
  init_tables_index();
16759
15543
  init_src2();
16760
15544
  init_errors();
16761
- logger20 = log.scope("RealtimeService");
15545
+ logger19 = log.scope("RealtimeService");
16762
15546
  });
16763
15547
 
16764
15548
  // ../api-core/src/services/secrets.service.ts
@@ -16767,60 +15551,92 @@ class SecretsService {
16767
15551
  constructor(ctx) {
16768
15552
  this.ctx = ctx;
16769
15553
  }
16770
- async listKeys(slug2, user) {
16771
- const game = await this.ctx.services.game.validateDeveloperAccessBySlug(user, slug2);
16772
- const secrets = await this.ctx.providers.secrets.readSecrets(game.id);
16773
- const keys = secrets ? Object.keys(secrets).filter((k) => !INTERNAL_SECRET_KEYS.includes(k)) : [];
16774
- logger21.debug("Listed secret keys", { gameId: game.id, slug: slug2, keyCount: keys.length });
16775
- return keys;
15554
+ getCloudflare() {
15555
+ if (!this.ctx.cloudflare) {
15556
+ throw new ValidationError("Secrets management requires Cloudflare provider");
15557
+ }
15558
+ return this.ctx.cloudflare;
15559
+ }
15560
+ getDeploymentId(slug2) {
15561
+ const isProd = isProduction2(this.ctx.config);
15562
+ return getDeploymentId(slug2, isProd);
16776
15563
  }
16777
- async getValues(slug2, user) {
15564
+ async listKeys(slug2, user) {
16778
15565
  const game = await this.ctx.services.game.validateDeveloperAccessBySlug(user, slug2);
16779
- const secrets = await this.ctx.providers.secrets.readSecrets(game.id);
16780
- if (!secrets) {
16781
- return {};
16782
- }
16783
- const filtered = {};
16784
- for (const [key, value] of Object.entries(secrets)) {
16785
- if (!INTERNAL_SECRET_KEYS.includes(key)) {
16786
- filtered[key] = value;
15566
+ const cf = this.getCloudflare();
15567
+ const deploymentId = this.getDeploymentId(slug2);
15568
+ try {
15569
+ const allKeys = await cf.listSecrets(deploymentId);
15570
+ const keys = allKeys.filter((k) => k.startsWith(SECRETS_PREFIX)).map((k) => k.slice(SECRETS_PREFIX.length));
15571
+ logger20.debug("Listed secret keys", { gameId: game.id, slug: slug2, keyCount: keys.length });
15572
+ return keys;
15573
+ } catch (error) {
15574
+ const message = error instanceof Error ? error.message : String(error);
15575
+ if (message.includes("not found") || message.includes("10007")) {
15576
+ logger20.debug("Worker not found, returning empty secrets list", {
15577
+ gameId: game.id,
15578
+ slug: slug2
15579
+ });
15580
+ return [];
16787
15581
  }
15582
+ throw error;
16788
15583
  }
16789
- logger21.debug("Retrieved secret values", { gameId: game.id, slug: slug2 });
16790
- return filtered;
16791
15584
  }
16792
15585
  async setSecrets(slug2, newSecrets, user) {
16793
15586
  const game = await this.ctx.services.game.validateDeveloperAccessBySlug(user, slug2);
15587
+ const cf = this.getCloudflare();
15588
+ const deploymentId = this.getDeploymentId(slug2);
16794
15589
  const secretKeys = Object.keys(newSecrets);
16795
15590
  if (secretKeys.length === 0) {
15591
+ logger20.warn("No secrets provided", { userId: user.id, slug: slug2 });
16796
15592
  throw new ValidationError("At least one secret must be provided");
16797
15593
  }
16798
15594
  for (const [key, value] of Object.entries(newSecrets)) {
16799
15595
  if (typeof value !== "string") {
15596
+ logger20.warn("Secret value must be a string", { userId: user.id, slug: slug2, key });
16800
15597
  throw new ValidationError(`Secret value for "${key}" must be a string`);
16801
15598
  }
16802
15599
  if (INTERNAL_SECRET_KEYS.includes(key)) {
16803
- logger21.warn("Attempted to set reserved secret", {
16804
- userId: user.id,
15600
+ logger20.warn("Attempted to set reserved secret", { userId: user.id, slug: slug2, key });
15601
+ throw new ValidationError(`Cannot set reserved secret "${key}"`);
15602
+ }
15603
+ }
15604
+ try {
15605
+ const prefixedSecrets = {};
15606
+ for (const [key, value] of Object.entries(newSecrets)) {
15607
+ prefixedSecrets[`${SECRETS_PREFIX}${key}`] = value;
15608
+ }
15609
+ await cf.setSecrets(deploymentId, prefixedSecrets);
15610
+ logger20.info("Set secrets", {
15611
+ gameId: game.id,
15612
+ slug: slug2,
15613
+ deploymentId,
15614
+ keys: secretKeys
15615
+ });
15616
+ const allKeys = await cf.listSecrets(deploymentId);
15617
+ return allKeys.filter((k) => k.startsWith(SECRETS_PREFIX)).map((k) => k.slice(SECRETS_PREFIX.length));
15618
+ } catch (error) {
15619
+ const message = error instanceof Error ? error.message : String(error);
15620
+ if (message.includes("not found") || message.includes("10007")) {
15621
+ logger20.warn("Cannot set secrets - game not deployed", {
16805
15622
  gameId: game.id,
16806
- key
15623
+ slug: slug2,
15624
+ deploymentId
16807
15625
  });
16808
- throw new ValidationError(`Cannot set reserved secret "${key}"`);
15626
+ throw new ValidationError("Game must be deployed before setting secrets. Run `playcademy deploy` first.");
16809
15627
  }
15628
+ logger20.error("Failed to set secrets", {
15629
+ gameId: game.id,
15630
+ slug: slug2,
15631
+ deploymentId,
15632
+ error: message
15633
+ });
15634
+ throw error;
16810
15635
  }
16811
- const existingSecrets = await this.ctx.providers.secrets.readSecrets(game.id) || {};
16812
- const updatedSecrets = { ...existingSecrets, ...newSecrets };
16813
- await this.ctx.providers.secrets.writeSecrets(game.id, updatedSecrets);
16814
- logger21.info("Set secrets", {
16815
- gameId: game.id,
16816
- slug: slug2,
16817
- addedKeys: secretKeys
16818
- });
16819
- return Object.keys(updatedSecrets).filter((k) => !INTERNAL_SECRET_KEYS.includes(k));
16820
15636
  }
16821
15637
  async deleteSecret(slug2, key, user) {
16822
15638
  if (INTERNAL_SECRET_KEYS.includes(key)) {
16823
- logger21.warn("Attempted to delete reserved secret", {
15639
+ logger20.warn("Attempted to delete reserved secret", {
16824
15640
  userId: user.id,
16825
15641
  slug: slug2,
16826
15642
  key
@@ -16828,25 +15644,53 @@ class SecretsService {
16828
15644
  throw new ValidationError(`Cannot delete reserved secret "${key}"`);
16829
15645
  }
16830
15646
  const game = await this.ctx.services.game.validateDeveloperAccessBySlug(user, slug2);
16831
- const secrets = await this.ctx.providers.secrets.readSecrets(game.id);
16832
- if (!secrets || !(key in secrets)) {
16833
- throw new NotFoundError("Secret", key);
16834
- }
16835
- delete secrets[key];
16836
- if (Object.keys(secrets).length > 0) {
16837
- await this.ctx.providers.secrets.writeSecrets(game.id, secrets);
16838
- } else {
16839
- await this.ctx.providers.secrets.deleteSecrets(game.id);
15647
+ const cf = this.getCloudflare();
15648
+ const deploymentId = this.getDeploymentId(slug2);
15649
+ try {
15650
+ const prefixedKey = `${SECRETS_PREFIX}${key}`;
15651
+ const existingKeys = await cf.listSecrets(deploymentId);
15652
+ if (!existingKeys.includes(prefixedKey)) {
15653
+ throw new NotFoundError("Secret", key);
15654
+ }
15655
+ await cf.deleteSecret(deploymentId, prefixedKey);
15656
+ logger20.info("Deleted secret", {
15657
+ gameId: game.id,
15658
+ slug: slug2,
15659
+ deploymentId,
15660
+ key
15661
+ });
15662
+ } catch (error) {
15663
+ if (error instanceof NotFoundError) {
15664
+ throw error;
15665
+ }
15666
+ const message = error instanceof Error ? error.message : String(error);
15667
+ if (message.includes("not found") || message.includes("10007")) {
15668
+ logger20.warn("Cannot delete secret - game not deployed", {
15669
+ gameId: game.id,
15670
+ slug: slug2,
15671
+ deploymentId
15672
+ });
15673
+ throw new ValidationError("Game must be deployed before managing secrets. Run `playcademy deploy` first.");
15674
+ }
15675
+ logger20.error("Failed to delete secret", {
15676
+ gameId: game.id,
15677
+ slug: slug2,
15678
+ deploymentId,
15679
+ key,
15680
+ error: message
15681
+ });
15682
+ throw error;
16840
15683
  }
16841
- logger21.info("Deleted secret", { gameId: game.id, slug: slug2, key });
16842
15684
  }
16843
15685
  }
16844
- var logger21, INTERNAL_SECRET_KEYS;
15686
+ var logger20, SECRETS_PREFIX = "secrets_", INTERNAL_SECRET_KEYS;
16845
15687
  var init_secrets_service = __esm(() => {
16846
15688
  init_src2();
15689
+ init_config2();
16847
15690
  init_errors();
16848
- logger21 = log.scope("SecretsService");
16849
- INTERNAL_SECRET_KEYS = ["PLAYCADEMY_API_KEY"];
15691
+ init_deployment_util();
15692
+ logger20 = log.scope("SecretsService");
15693
+ INTERNAL_SECRET_KEYS = ["PLAYCADEMY_API_KEY", "GAME_ID", "PLAYCADEMY_BASE_URL"];
16850
15694
  });
16851
15695
 
16852
15696
  // ../api-core/src/services/seed.service.ts
@@ -16858,7 +15702,7 @@ class SeedService {
16858
15702
  getCloudflare() {
16859
15703
  const cf = this.ctx.cloudflare;
16860
15704
  if (!cf) {
16861
- logger22.error("Cloudflare provider not available for seeding");
15705
+ logger21.error("Cloudflare provider not available for seeding");
16862
15706
  throw new ValidationError("Cloudflare provider not configured");
16863
15707
  }
16864
15708
  return cf;
@@ -16870,7 +15714,7 @@ class SeedService {
16870
15714
  const deploymentId = getDeploymentId(slug2, isProd);
16871
15715
  const uniqueSuffix = Date.now().toString(36);
16872
15716
  const seedDeploymentId = `seed-${deploymentId}-${uniqueSuffix}`;
16873
- logger22.debug("Seeding database", {
15717
+ logger21.debug("Seeding database", {
16874
15718
  userId: user.id,
16875
15719
  gameId: game.id,
16876
15720
  slug: slug2,
@@ -16879,7 +15723,7 @@ class SeedService {
16879
15723
  });
16880
15724
  try {
16881
15725
  const workerResponse = await this.deployAndExecuteSeedWorker(cf, seedDeploymentId, game.id, deploymentId, code);
16882
- logger22.info("Seed completed", {
15726
+ logger21.info("Seed completed", {
16883
15727
  gameId: game.id,
16884
15728
  slug: slug2,
16885
15729
  deploymentId,
@@ -16895,7 +15739,7 @@ class SeedService {
16895
15739
  };
16896
15740
  } catch (error) {
16897
15741
  const errorMessage = error instanceof Error ? error.message : String(error);
16898
- logger22.error("Seed failed", {
15742
+ logger21.error("Seed failed", {
16899
15743
  slug: slug2,
16900
15744
  error: errorMessage
16901
15745
  });
@@ -16905,7 +15749,7 @@ class SeedService {
16905
15749
  error: errorMessage,
16906
15750
  developer: { id: user.id, email: user.email }
16907
15751
  }).catch((err2) => {
16908
- logger22.warn("Failed to send failure alert", { error: err2 });
15752
+ logger21.warn("Failed to send failure alert", { error: err2 });
16909
15753
  });
16910
15754
  if (error instanceof Error) {
16911
15755
  if (error.message.includes("timed out") || error.message.includes("AbortError")) {
@@ -16959,7 +15803,7 @@ class SeedService {
16959
15803
  bindings: { d1: [deploymentId], r2: [], kv: [] },
16960
15804
  keepAssets: false
16961
15805
  });
16962
- logger22.info("Worker deployed", { seedDeploymentId, url: result.url });
15806
+ logger21.info("Worker deployed", { seedDeploymentId, url: result.url });
16963
15807
  return await this.executeSeedWorker(result.url, seedDeploymentId);
16964
15808
  } finally {
16965
15809
  await this.cleanupSeedWorker(cf, seedDeploymentId);
@@ -16975,7 +15819,7 @@ class SeedService {
16975
15819
  await new Promise((resolve) => setTimeout(resolve, INITIAL_DELAY));
16976
15820
  for (let attempt = 0;attempt < MAX_RETRIES; attempt++) {
16977
15821
  if (attempt > 0) {
16978
- logger22.debug("Retrying seed execution", {
15822
+ logger21.debug("Retrying seed execution", {
16979
15823
  attempt: attempt + 1,
16980
15824
  maxRetries: MAX_RETRIES,
16981
15825
  nextRetryIn: `${RETRY_INTERVAL / 1000}s`
@@ -16995,14 +15839,14 @@ class SeedService {
16995
15839
  const isRetryable = response.status === 404 || response.status >= 500;
16996
15840
  if (isRetryable && attempt < MAX_RETRIES - 1) {
16997
15841
  lastError = new Error(`Worker returned ${response.status}`);
16998
- logger22.debug("Worker not ready, will retry", {
15842
+ logger21.debug("Worker not ready, will retry", {
16999
15843
  status: response.status,
17000
15844
  attempt: attempt + 1,
17001
15845
  errorBody: errorBody?.substring(0, 500)
17002
15846
  });
17003
15847
  continue;
17004
15848
  }
17005
- logger22.error("Worker returned error", {
15849
+ logger21.error("Worker returned error", {
17006
15850
  status: response.status,
17007
15851
  statusText: response.statusText,
17008
15852
  errorBody
@@ -17012,7 +15856,7 @@ class SeedService {
17012
15856
  const data = await response.json();
17013
15857
  if (!data.success) {
17014
15858
  const error = data.error || "Seed execution failed";
17015
- logger22.error("Seed execution failed", {
15859
+ logger21.error("Seed execution failed", {
17016
15860
  error,
17017
15861
  stack: data.stack,
17018
15862
  details: data.details,
@@ -17033,7 +15877,7 @@ class SeedService {
17033
15877
  };
17034
15878
  throw new InternalError(detailedMessage, errorDetails);
17035
15879
  }
17036
- logger22.info("Seed executed successfully", {
15880
+ logger21.info("Seed executed successfully", {
17037
15881
  seedDeploymentId,
17038
15882
  duration: data.duration,
17039
15883
  logCount: data.logs?.length ?? 0
@@ -17043,7 +15887,7 @@ class SeedService {
17043
15887
  clearTimeout(timeout);
17044
15888
  if (error instanceof Error && error.name === "AbortError") {
17045
15889
  lastError = new Error("Seed execution timed out");
17046
- logger22.debug("Seed execution timed out, will retry", {
15890
+ logger21.debug("Seed execution timed out, will retry", {
17047
15891
  attempt: attempt + 1
17048
15892
  });
17049
15893
  if (attempt < MAX_RETRIES - 1)
@@ -17054,7 +15898,7 @@ class SeedService {
17054
15898
  }
17055
15899
  lastError = error instanceof Error ? error : new Error(String(error));
17056
15900
  if (attempt < MAX_RETRIES - 1) {
17057
- logger22.debug("Network error, will retry", {
15901
+ logger21.debug("Network error, will retry", {
17058
15902
  error: lastError.message,
17059
15903
  attempt: attempt + 1
17060
15904
  });
@@ -17067,19 +15911,19 @@ class SeedService {
17067
15911
  async cleanupSeedWorker(cf, seedDeploymentId) {
17068
15912
  try {
17069
15913
  await cf.delete(seedDeploymentId);
17070
- logger22.info("Worker deleted", { seedDeploymentId });
15914
+ logger21.info("Worker deleted", { seedDeploymentId });
17071
15915
  } catch (error) {
17072
- logger22.warn("Failed to cleanup worker", { seedDeploymentId, error });
15916
+ logger21.warn("Failed to cleanup worker", { seedDeploymentId, error });
17073
15917
  }
17074
15918
  }
17075
15919
  }
17076
- var logger22;
15920
+ var logger21;
17077
15921
  var init_seed_service = __esm(() => {
17078
15922
  init_src2();
17079
15923
  init_config2();
17080
15924
  init_errors();
17081
15925
  init_deployment_util();
17082
- logger22 = log.scope("SeedService");
15926
+ logger21 = log.scope("SeedService");
17083
15927
  });
17084
15928
 
17085
15929
  // ../api-core/src/services/session.service.ts
@@ -17114,10 +15958,10 @@ class SessionService {
17114
15958
  };
17115
15959
  const [newSession] = await db2.insert(gameSessions).values(sessionToInsert).returning({ sessionId: gameSessions.id });
17116
15960
  if (!newSession?.sessionId) {
17117
- logger23.error("Game session insert returned no rows", { userId, gameId });
15961
+ logger22.error("Game session insert returned no rows", { userId, gameId });
17118
15962
  throw new InternalError("Failed to create game session");
17119
15963
  }
17120
- logger23.info("Started new session", {
15964
+ logger22.info("Started new session", {
17121
15965
  sessionId: newSession.sessionId,
17122
15966
  gameId,
17123
15967
  userId
@@ -17138,23 +15982,23 @@ class SessionService {
17138
15982
  return { success: true, message: "Session already ended" };
17139
15983
  }
17140
15984
  await db2.update(gameSessions).set({ endedAt: new Date }).where(eq(gameSessions.id, sessionId));
17141
- logger23.info("Ended session", { sessionId, gameId, userId });
15985
+ logger22.info("Ended session", { sessionId, gameId, userId });
17142
15986
  return { success: true };
17143
15987
  }
17144
15988
  async mintToken(gameIdOrSlug, userId) {
17145
15989
  const gameId = await this.resolveGameId(gameIdOrSlug);
17146
15990
  const result = await this.ctx.providers.auth.mintGameToken(gameId, userId);
17147
- logger23.debug("Minted game token", { gameId, userId });
15991
+ logger22.debug("Minted game token", { gameId, userId });
17148
15992
  return result;
17149
15993
  }
17150
15994
  }
17151
- var logger23;
15995
+ var logger22;
17152
15996
  var init_session_service = __esm(() => {
17153
15997
  init_drizzle_orm();
17154
15998
  init_tables_index();
17155
15999
  init_src2();
17156
16000
  init_errors();
17157
- logger23 = log.scope("SessionService");
16001
+ logger22 = log.scope("SessionService");
17158
16002
  });
17159
16003
 
17160
16004
  // ../api-core/src/services/shop-listing.service.ts
@@ -17166,7 +16010,7 @@ class ShopListingService {
17166
16010
  async list() {
17167
16011
  const db2 = this.ctx.db;
17168
16012
  const allListings = await db2.query.shopListings.findMany();
17169
- logger24.debug("Listed shop listings", { count: allListings.length });
16013
+ logger23.debug("Listed shop listings", { count: allListings.length });
17170
16014
  return allListings;
17171
16015
  }
17172
16016
  async getById(listingId) {
@@ -17177,7 +16021,7 @@ class ShopListingService {
17177
16021
  if (!listing) {
17178
16022
  throw new NotFoundError("ShopListing", listingId);
17179
16023
  }
17180
- logger24.debug("Retrieved listing", { listingId });
16024
+ logger23.debug("Retrieved listing", { listingId });
17181
16025
  return listing;
17182
16026
  }
17183
16027
  async create(data) {
@@ -17188,13 +16032,13 @@ class ShopListingService {
17188
16032
  price: data.price
17189
16033
  }).returning();
17190
16034
  if (!newListing) {
17191
- logger24.error("Shop listing insert returned no rows", {
16035
+ logger23.error("Shop listing insert returned no rows", {
17192
16036
  itemId: data.itemId,
17193
16037
  currencyId: data.currencyId
17194
16038
  });
17195
16039
  throw new InternalError("Failed to create shop listing");
17196
16040
  }
17197
- logger24.info("Created listing", {
16041
+ logger23.info("Created listing", {
17198
16042
  listingId: newListing.id,
17199
16043
  itemId: newListing.itemId,
17200
16044
  currencyId: newListing.currencyId,
@@ -17237,7 +16081,7 @@ class ShopListingService {
17237
16081
  if (!updatedListing) {
17238
16082
  throw new NotFoundError("ShopListing", listingId);
17239
16083
  }
17240
- logger24.info("Updated listing", {
16084
+ logger23.info("Updated listing", {
17241
16085
  listingId: updatedListing.id,
17242
16086
  updatedFields: Object.keys(updateData)
17243
16087
  });
@@ -17267,7 +16111,7 @@ class ShopListingService {
17267
16111
  if (result.length === 0) {
17268
16112
  throw new NotFoundError("ShopListing", listingId);
17269
16113
  }
17270
- logger24.info("Deleted listing", { listingId });
16114
+ logger23.info("Deleted listing", { listingId });
17271
16115
  }
17272
16116
  async listByGame(gameId, user) {
17273
16117
  await this.ctx.services.game.validateOwnership(user, gameId);
@@ -17285,7 +16129,7 @@ class ShopListingService {
17285
16129
  item: true
17286
16130
  }
17287
16131
  });
17288
- logger24.debug("Listed game listings", {
16132
+ logger23.debug("Listed game listings", {
17289
16133
  gameId,
17290
16134
  count: listings.length
17291
16135
  });
@@ -17315,14 +16159,14 @@ class ShopListingService {
17315
16159
  currencyId: currency.id
17316
16160
  }).returning();
17317
16161
  if (!newListing) {
17318
- logger24.error("Game item listing insert returned no rows", {
16162
+ logger23.error("Game item listing insert returned no rows", {
17319
16163
  gameId,
17320
16164
  itemId,
17321
16165
  currencyId: currency.id
17322
16166
  });
17323
16167
  throw new InternalError("Failed to create shop listing");
17324
16168
  }
17325
- logger24.info("Created game item listing", {
16169
+ logger23.info("Created game item listing", {
17326
16170
  listingId: newListing.id,
17327
16171
  gameId,
17328
16172
  itemId,
@@ -17363,7 +16207,7 @@ class ShopListingService {
17363
16207
  if (!updatedListing) {
17364
16208
  throw new NotFoundError("ShopListing", `for item ${itemId}`);
17365
16209
  }
17366
- logger24.info("Updated game item listing", {
16210
+ logger23.info("Updated game item listing", {
17367
16211
  listingId: updatedListing.id,
17368
16212
  gameId,
17369
16213
  itemId,
@@ -17388,7 +16232,7 @@ class ShopListingService {
17388
16232
  if (result.length === 0) {
17389
16233
  throw new NotFoundError("ShopListing", `for item ${itemId}`);
17390
16234
  }
17391
- logger24.info("Deleted game item listing", {
16235
+ logger23.info("Deleted game item listing", {
17392
16236
  listingId: result[0].id,
17393
16237
  gameId,
17394
16238
  itemId
@@ -17405,13 +16249,13 @@ class ShopListingService {
17405
16249
  }
17406
16250
  }
17407
16251
  }
17408
- var logger24;
16252
+ var logger23;
17409
16253
  var init_shop_listing_service = __esm(() => {
17410
16254
  init_drizzle_orm();
17411
16255
  init_tables_index();
17412
16256
  init_src2();
17413
16257
  init_errors();
17414
- logger24 = log.scope("ShopListingService");
16258
+ logger23 = log.scope("ShopListingService");
17415
16259
  });
17416
16260
 
17417
16261
  // ../api-core/src/services/shop.service.ts
@@ -17457,7 +16301,7 @@ class ShopService {
17457
16301
  const shopItems = [];
17458
16302
  for (const listing of listingsWithRelations) {
17459
16303
  if (!listing.item || !listing.currency) {
17460
- logger25.warn("Listing missing item or currency, skipping", {
16304
+ logger24.warn("Listing missing item or currency, skipping", {
17461
16305
  listingId: listing.id
17462
16306
  });
17463
16307
  continue;
@@ -17474,7 +16318,7 @@ class ShopService {
17474
16318
  sellBackPercentage: listing.sellBackPercentage
17475
16319
  });
17476
16320
  }
17477
- logger25.debug("Retrieved shop view", {
16321
+ logger24.debug("Retrieved shop view", {
17478
16322
  userId: user.id,
17479
16323
  itemCount: shopItems.length,
17480
16324
  currencyCount: shopCurrencies.length
@@ -17485,12 +16329,12 @@ class ShopService {
17485
16329
  };
17486
16330
  }
17487
16331
  }
17488
- var logger25;
16332
+ var logger24;
17489
16333
  var init_shop_service = __esm(() => {
17490
16334
  init_drizzle_orm();
17491
16335
  init_tables_index();
17492
16336
  init_src2();
17493
- logger25 = log.scope("ShopService");
16337
+ logger24 = log.scope("ShopService");
17494
16338
  });
17495
16339
 
17496
16340
  // ../api-core/src/services/sprite.service.ts
@@ -17507,17 +16351,17 @@ class SpriteService {
17507
16351
  if (!template) {
17508
16352
  throw new NotFoundError("SpriteTemplate", slug2);
17509
16353
  }
17510
- logger26.debug("Retrieved sprite", { slug: slug2 });
16354
+ logger25.debug("Retrieved sprite", { slug: slug2 });
17511
16355
  return template;
17512
16356
  }
17513
16357
  }
17514
- var logger26;
16358
+ var logger25;
17515
16359
  var init_sprite_service = __esm(() => {
17516
16360
  init_drizzle_orm();
17517
16361
  init_tables_index();
17518
16362
  init_src2();
17519
16363
  init_errors();
17520
- logger26 = log.scope("SpriteService");
16364
+ logger25 = log.scope("SpriteService");
17521
16365
  });
17522
16366
 
17523
16367
  // ../timeback/dist/types.js
@@ -17960,7 +16804,7 @@ class TimebackService {
17960
16804
  }
17961
16805
  requireClient() {
17962
16806
  if (!this.ctx.timeback) {
17963
- logger27.error("Timeback client not available in context");
16807
+ logger26.error("Timeback client not available in context");
17964
16808
  throw new ValidationError("Timeback integration not available in this environment");
17965
16809
  }
17966
16810
  return this.ctx.timeback;
@@ -18013,7 +16857,7 @@ class TimebackService {
18013
16857
  set: { xp: sql`excluded.xp`, updatedAt: new Date }
18014
16858
  }).returning({ xp: timebackDailyXp.xp, date: timebackDailyXp.date });
18015
16859
  if (!result) {
18016
- logger27.error("Daily XP upsert returned no rows", { userId, date: targetDate });
16860
+ logger26.error("Daily XP upsert returned no rows", { userId, date: targetDate });
18017
16861
  throw new InternalError("Failed to update daily XP record");
18018
16862
  }
18019
16863
  return { xp: result.xp, date: result.date.toISOString() };
@@ -18044,7 +16888,7 @@ class TimebackService {
18044
16888
  columns: { id: true, timebackId: true }
18045
16889
  });
18046
16890
  if (dbUser?.timebackId) {
18047
- logger27.info("Student already onboarded", { userId: user.id });
16891
+ logger26.info("Student already onboarded", { userId: user.id });
18048
16892
  return { status: "already_populated" };
18049
16893
  }
18050
16894
  let timebackId;
@@ -18053,7 +16897,7 @@ class TimebackService {
18053
16897
  const existingUser = await client.oneroster.users.findByEmail(user.email);
18054
16898
  timebackId = existingUser.sourcedId;
18055
16899
  name3 = `${existingUser.givenName} ${existingUser.familyName}`;
18056
- logger27.info("Found existing student in OneRoster", {
16900
+ logger26.info("Found existing student in OneRoster", {
18057
16901
  userId: user.id,
18058
16902
  timebackId
18059
16903
  });
@@ -18082,7 +16926,7 @@ class TimebackService {
18082
16926
  }
18083
16927
  timebackId = response.sourcedIdPairs.allocatedSourcedId;
18084
16928
  name3 = `${providedNames.firstName} ${providedNames.lastName}`;
18085
- logger27.info("Created student in OneRoster", { userId: user.id, timebackId });
16929
+ logger26.info("Created student in OneRoster", { userId: user.id, timebackId });
18086
16930
  }
18087
16931
  const assessments = await this.fetchAssessments(timebackId);
18088
16932
  await db2.transaction(async (tx) => {
@@ -18116,7 +16960,7 @@ class TimebackService {
18116
16960
  }
18117
16961
  const [updated] = await tx.update(users).set({ timebackId, name: name3 }).where(eq(users.id, user.id)).returning({ id: users.id });
18118
16962
  if (!updated) {
18119
- logger27.error("User Timeback ID update returned no rows", {
16963
+ logger26.error("User Timeback ID update returned no rows", {
18120
16964
  userId: user.id,
18121
16965
  timebackId
18122
16966
  });
@@ -18139,13 +16983,13 @@ class TimebackService {
18139
16983
  break;
18140
16984
  offset += limit;
18141
16985
  }
18142
- logger27.debug("Fetched assessments", {
16986
+ logger26.debug("Fetched assessments", {
18143
16987
  studentSourcedId,
18144
16988
  totalCount: allAssessments.length
18145
16989
  });
18146
16990
  return allAssessments;
18147
16991
  } catch (error) {
18148
- logger27.warn("Failed to fetch assessments", { studentSourcedId, error });
16992
+ logger26.warn("Failed to fetch assessments", { studentSourcedId, error });
18149
16993
  return [];
18150
16994
  }
18151
16995
  }
@@ -18230,11 +17074,11 @@ class TimebackService {
18230
17074
  return [];
18231
17075
  }
18232
17076
  }
18233
- async setupIntegration(gameId, request2, user) {
17077
+ async setupIntegration(gameId, request, user) {
18234
17078
  const client = this.requireClient();
18235
17079
  const db2 = this.ctx.db;
18236
17080
  await this.ctx.services.game.validateDeveloperAccess(user, gameId);
18237
- const { courses, baseConfig, verbose } = request2;
17081
+ const { courses, baseConfig, verbose } = request;
18238
17082
  const existing = await db2.query.gameTimebackIntegrations.findMany({
18239
17083
  where: eq(gameTimebackIntegrations.gameId, gameId)
18240
17084
  });
@@ -18252,7 +17096,7 @@ class TimebackService {
18252
17096
  masterableUnits: derivedMasterableUnits
18253
17097
  } = courseConfig;
18254
17098
  if (!isTimebackSubject(subjectInput)) {
18255
- logger27.warn("Invalid Timeback subject in course config", {
17099
+ logger26.warn("Invalid Timeback subject in course config", {
18256
17100
  subject: subjectInput,
18257
17101
  courseCode,
18258
17102
  title
@@ -18260,7 +17104,7 @@ class TimebackService {
18260
17104
  throw new ValidationError(`Invalid subject "${subjectInput}"`);
18261
17105
  }
18262
17106
  if (!isTimebackGrade(grade)) {
18263
- logger27.warn("Invalid Timeback grade in course config", {
17107
+ logger26.warn("Invalid Timeback grade in course config", {
18264
17108
  grade,
18265
17109
  courseCode,
18266
17110
  title
@@ -18272,7 +17116,7 @@ class TimebackService {
18272
17116
  const totalXp = derivedTotalXp ?? courseMetadata?.metrics?.totalXp;
18273
17117
  const masterableUnits = derivedMasterableUnits ?? (isPlaycademyResourceMetadata(courseMetadata?.playcademy) ? courseMetadata?.playcademy?.mastery?.masterableUnits : undefined);
18274
17118
  if (typeof totalXp !== "number") {
18275
- logger27.warn("Course missing totalXp in Timeback config", {
17119
+ logger26.warn("Course missing totalXp in Timeback config", {
18276
17120
  courseCode,
18277
17121
  title
18278
17122
  });
@@ -18443,7 +17287,7 @@ class TimebackService {
18443
17287
  courseName: activityData.courseName,
18444
17288
  studentEmail: activityData.studentEmail
18445
17289
  });
18446
- logger27.info("Recorded activity completion", {
17290
+ logger26.info("Recorded activity completion", {
18447
17291
  gameId,
18448
17292
  courseId: integration.courseId,
18449
17293
  studentId,
@@ -18460,7 +17304,7 @@ class TimebackService {
18460
17304
  };
18461
17305
  }
18462
17306
  }
18463
- var logger27;
17307
+ var logger26;
18464
17308
  var init_timeback_service = __esm(() => {
18465
17309
  init_drizzle_orm();
18466
17310
  init_src();
@@ -18470,7 +17314,7 @@ var init_timeback_service = __esm(() => {
18470
17314
  init_src4();
18471
17315
  init_errors();
18472
17316
  init_timeback_util();
18473
- logger27 = log.scope("TimebackService");
17317
+ logger26 = log.scope("TimebackService");
18474
17318
  });
18475
17319
 
18476
17320
  // ../api-core/src/services/upload.service.ts
@@ -18479,19 +17323,19 @@ class UploadService {
18479
17323
  constructor(ctx) {
18480
17324
  this.ctx = ctx;
18481
17325
  }
18482
- async initiate(request2, user) {
18483
- const { fileName, gameId } = request2;
17326
+ async initiate(request, user) {
17327
+ const { fileName, gameId } = request;
18484
17328
  const bucketName = this.ctx.config.uploadBucket;
18485
17329
  if (!bucketName) {
18486
- logger28.error("Upload bucket not configured in environment");
17330
+ logger27.error("Upload bucket not configured in environment");
18487
17331
  throw new ValidationError("Upload bucket not configured");
18488
17332
  }
18489
17333
  await this.ctx.services.game.validateDeveloperAccess(user, gameId);
18490
17334
  const version2 = ulid();
18491
17335
  const tempS3Key = `uploads-temp/${gameId}/${version2}/${fileName}`;
18492
- logger28.debug("Initiating upload", { userId: user.id, gameId, fileName, version: version2 });
17336
+ logger27.debug("Initiating upload", { userId: user.id, gameId, fileName, version: version2 });
18493
17337
  const presignedUrl = await this.ctx.providers.storage.generatePresignedPutUrl(bucketName, tempS3Key, "application/zip");
18494
- logger28.info("Presigned URL generated", {
17338
+ logger27.info("Presigned URL generated", {
18495
17339
  userId: user.id,
18496
17340
  gameId,
18497
17341
  version: version2
@@ -18504,12 +17348,12 @@ class UploadService {
18504
17348
  };
18505
17349
  }
18506
17350
  }
18507
- var logger28;
17351
+ var logger27;
18508
17352
  var init_upload_service = __esm(() => {
18509
17353
  init_node();
18510
17354
  init_src2();
18511
17355
  init_errors();
18512
- logger28 = log.scope("UploadService");
17356
+ logger27 = log.scope("UploadService");
18513
17357
  });
18514
17358
 
18515
17359
  // ../api-core/src/services/user.service.ts
@@ -18524,12 +17368,12 @@ class UserService {
18524
17368
  where: eq(users.id, user.id)
18525
17369
  });
18526
17370
  if (!userData) {
18527
- logger29.error("User not found", { userId: user.id });
17371
+ logger28.error("User not found", { userId: user.id });
18528
17372
  throw new NotFoundError("User", user.id);
18529
17373
  }
18530
17374
  const timeback2 = userData.timebackId ? await this.fetchTimebackData(userData.timebackId, gameId) : undefined;
18531
17375
  if (gameId) {
18532
- logger29.debug("Fetched user profile (game context)", { userId: user.id, gameId });
17376
+ logger28.debug("Fetched user profile (game context)", { userId: user.id, gameId });
18533
17377
  return {
18534
17378
  id: userData.id,
18535
17379
  name: userData.name,
@@ -18542,7 +17386,7 @@ class UserService {
18542
17386
  const timebackAccount = await db2.query.accounts.findFirst({
18543
17387
  where: and(eq(accounts.userId, user.id), eq(accounts.providerId, "timeback"))
18544
17388
  });
18545
- logger29.debug("Fetched user profile (platform context)", { userId: user.id });
17389
+ logger28.debug("Fetched user profile (platform context)", { userId: user.id });
18546
17390
  return {
18547
17391
  id: userData.id,
18548
17392
  name: userData.name,
@@ -18566,7 +17410,7 @@ class UserService {
18566
17410
  ]);
18567
17411
  const enrollments = gameId ? this.filterEnrollmentsByGame(allEnrollments, gameId) : allEnrollments;
18568
17412
  const organizations = gameId ? this.filterOrganizationsByEnrollments(allOrganizations, enrollments) : allOrganizations;
18569
- logger29.debug("Fetched Timeback data", {
17413
+ logger28.debug("Fetched Timeback data", {
18570
17414
  timebackId,
18571
17415
  role,
18572
17416
  enrollmentCount: enrollments.length,
@@ -18575,9 +17419,9 @@ class UserService {
18575
17419
  return { id: timebackId, role, enrollments, organizations };
18576
17420
  }
18577
17421
  async fetchStudentProfile(timebackId) {
18578
- logger29.debug("Fetching student profile", { timebackId });
17422
+ logger28.debug("Fetching student profile", { timebackId });
18579
17423
  if (!this.ctx.timeback) {
18580
- logger29.warn("Timeback client not available");
17424
+ logger28.warn("Timeback client not available");
18581
17425
  return { role: "student", organizations: [] };
18582
17426
  }
18583
17427
  try {
@@ -18605,14 +17449,14 @@ class UserService {
18605
17449
  }
18606
17450
  return { role, organizations: Array.from(orgMap.values()) };
18607
17451
  } catch (error) {
18608
- logger29.warn("Failed to fetch student profile", { error, timebackId });
17452
+ logger28.warn("Failed to fetch student profile", { error, timebackId });
18609
17453
  return { role: "student", organizations: [] };
18610
17454
  }
18611
17455
  }
18612
17456
  async fetchEnrollments(timebackId) {
18613
- logger29.debug("Fetching enrollments", { timebackId });
17457
+ logger28.debug("Fetching enrollments", { timebackId });
18614
17458
  if (!this.ctx.timeback) {
18615
- logger29.warn("Timeback client not available");
17459
+ logger28.warn("Timeback client not available");
18616
17460
  return [];
18617
17461
  }
18618
17462
  try {
@@ -18632,7 +17476,7 @@ class UserService {
18632
17476
  orgId: courseToSchool.get(i2.courseId)
18633
17477
  }));
18634
17478
  } catch (error) {
18635
- logger29.warn("Failed to fetch enrollments", { error, timebackId });
17479
+ logger28.warn("Failed to fetch enrollments", { error, timebackId });
18636
17480
  return [];
18637
17481
  }
18638
17482
  }
@@ -18646,13 +17490,13 @@ class UserService {
18646
17490
  return organizations.filter((o) => enrollmentOrgIds.has(o.id));
18647
17491
  }
18648
17492
  }
18649
- var logger29;
17493
+ var logger28;
18650
17494
  var init_user_service = __esm(() => {
18651
17495
  init_drizzle_orm();
18652
17496
  init_tables_index();
18653
17497
  init_src2();
18654
17498
  init_errors();
18655
- logger29 = log.scope("UserService");
17499
+ logger28 = log.scope("UserService");
18656
17500
  });
18657
17501
 
18658
17502
  // ../api-core/src/services/verify.service.ts
@@ -18662,16 +17506,16 @@ class VerifyService {
18662
17506
  this.ctx = ctx;
18663
17507
  }
18664
17508
  async verifyGameToken(token) {
18665
- logger30.debug("Verifying game token");
17509
+ logger29.debug("Verifying game token");
18666
17510
  const payload = await this.ctx.providers.auth.validateGameToken(token);
18667
17511
  if (!payload) {
18668
- logger30.warn("Invalid or expired game token presented");
17512
+ logger29.warn("Invalid or expired game token presented");
18669
17513
  throw new ValidationError("Invalid or expired token");
18670
17514
  }
18671
17515
  const gameId = payload.sub;
18672
17516
  const userId = payload.uid;
18673
17517
  if (typeof gameId !== "string" || typeof userId !== "string") {
18674
- logger30.warn("Game token missing required claims", {
17518
+ logger29.warn("Game token missing required claims", {
18675
17519
  hasGameId: typeof gameId === "string",
18676
17520
  hasUserId: typeof userId === "string"
18677
17521
  });
@@ -18682,7 +17526,7 @@ class VerifyService {
18682
17526
  where: eq(users.id, userId)
18683
17527
  });
18684
17528
  if (!userData) {
18685
- logger30.error("User not found for valid token", {
17529
+ logger29.error("User not found for valid token", {
18686
17530
  userId
18687
17531
  });
18688
17532
  throw new NotFoundError("User", userId);
@@ -18696,7 +17540,7 @@ class VerifyService {
18696
17540
  family_name: undefined,
18697
17541
  timeback_id: userData.timebackId || undefined
18698
17542
  };
18699
- logger30.info("Token verified", { gameId, userId });
17543
+ logger29.info("Token verified", { gameId, userId });
18700
17544
  return {
18701
17545
  claims: payload,
18702
17546
  gameId,
@@ -18704,13 +17548,13 @@ class VerifyService {
18704
17548
  };
18705
17549
  }
18706
17550
  }
18707
- var logger30;
17551
+ var logger29;
18708
17552
  var init_verify_service = __esm(() => {
18709
17553
  init_drizzle_orm();
18710
17554
  init_tables_index();
18711
17555
  init_src2();
18712
17556
  init_errors();
18713
- logger30 = log.scope("VerifyService");
17557
+ logger29 = log.scope("VerifyService");
18714
17558
  });
18715
17559
 
18716
17560
  // ../api-core/src/services/index.ts
@@ -18946,35 +17790,6 @@ var init_cache_provider = __esm(() => {
18946
17790
  gameOrigins = [];
18947
17791
  });
18948
17792
 
18949
- // src/infrastructure/api/providers/secrets.provider.ts
18950
- function createSandboxSecretsProvider() {
18951
- return {
18952
- async readSecrets(gameId) {
18953
- const secrets = secretsStorage.get(gameId);
18954
- return secrets ?? null;
18955
- },
18956
- async writeSecrets(gameId, secrets) {
18957
- secretsStorage.set(gameId, { ...secrets });
18958
- log.debug("[SandboxSecretsProvider] Stored secrets", {
18959
- gameId,
18960
- keyCount: Object.keys(secrets).length
18961
- });
18962
- },
18963
- async deleteSecrets(gameId) {
18964
- secretsStorage.delete(gameId);
18965
- log.debug("[SandboxSecretsProvider] Deleted secrets", { gameId });
18966
- }
18967
- };
18968
- }
18969
- function clearSandboxSecrets() {
18970
- secretsStorage.clear();
18971
- }
18972
- var secretsStorage;
18973
- var init_secrets_provider = __esm(() => {
18974
- init_src2();
18975
- secretsStorage = new Map;
18976
- });
18977
-
18978
17793
  // src/infrastructure/api/providers/storage.provider.ts
18979
17794
  function getBucket(bucketName) {
18980
17795
  let bucket = storage.get(bucketName);
@@ -19049,7 +17864,6 @@ var init_storage_provider = __esm(() => {
19049
17864
  var init_providers = __esm(() => {
19050
17865
  init_auth_provider();
19051
17866
  init_cache_provider();
19052
- init_secrets_provider();
19053
17867
  init_storage_provider();
19054
17868
  });
19055
17869
 
@@ -19068,7 +17882,6 @@ function buildProviders() {
19068
17882
  return {
19069
17883
  auth: createSandboxAuthProvider(),
19070
17884
  storage: createSandboxStorageProvider(),
19071
- secrets: createSandboxSecretsProvider(),
19072
17885
  cache: createSandboxCacheProvider()
19073
17886
  };
19074
17887
  }
@@ -19209,8 +18022,8 @@ var init_constants3 = __esm(() => {
19209
18022
  });
19210
18023
 
19211
18024
  // ../../node_modules/hono/dist/utils/body.js
19212
- async function parseFormData(request2, options) {
19213
- const formData = await request2.formData();
18025
+ async function parseFormData(request, options) {
18026
+ const formData = await request.formData();
19214
18027
  if (formData) {
19215
18028
  return convertFormDataToBodyData(formData, options);
19216
18029
  }
@@ -19237,12 +18050,12 @@ function convertFormDataToBodyData(formData, options) {
19237
18050
  }
19238
18051
  return form;
19239
18052
  }
19240
- var parseBody = async (request2, options = /* @__PURE__ */ Object.create(null)) => {
18053
+ var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
19241
18054
  const { all = false, dot = false } = options;
19242
- const headers = request2 instanceof HonoRequest ? request2.raw.headers : request2.headers;
18055
+ const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
19243
18056
  const contentType = headers.get("Content-Type");
19244
18057
  if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) {
19245
- return parseFormData(request2, { all, dot });
18058
+ return parseFormData(request, { all, dot });
19246
18059
  }
19247
18060
  return {};
19248
18061
  }, handleParsingAllValues = (form, key, value) => {
@@ -19336,8 +18149,8 @@ var splitPath = (path) => {
19336
18149
  }
19337
18150
  });
19338
18151
  }
19339
- }, tryDecodeURI = (str) => tryDecode(str, decodeURI), getPath = (request2) => {
19340
- const url = request2.url;
18152
+ }, tryDecodeURI = (str) => tryDecode(str, decodeURI), getPath = (request) => {
18153
+ const url = request.url;
19341
18154
  const start2 = url.indexOf("/", url.indexOf(":") + 4);
19342
18155
  let i2 = start2;
19343
18156
  for (;i2 < url.length; i2++) {
@@ -19351,8 +18164,8 @@ var splitPath = (path) => {
19351
18164
  }
19352
18165
  }
19353
18166
  return url.slice(start2, i2);
19354
- }, getPathNoStrict = (request2) => {
19355
- const result = getPath(request2);
18167
+ }, getPathNoStrict = (request) => {
18168
+ const result = getPath(request);
19356
18169
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
19357
18170
  }, mergePath = (base, sub, ...rest) => {
19358
18171
  if (rest.length) {
@@ -19478,8 +18291,8 @@ var init_request = __esm(() => {
19478
18291
  routeIndex = 0;
19479
18292
  path;
19480
18293
  bodyCache = {};
19481
- constructor(request2, path = "/", matchResult = [[]]) {
19482
- this.raw = request2;
18294
+ constructor(request, path = "/", matchResult = [[]]) {
18295
+ this.raw = request;
19483
18296
  this.path = path;
19484
18297
  this.#matchResult = matchResult;
19485
18298
  this.#validatedData = {};
@@ -19915,7 +18728,7 @@ var notFoundHandler = (c) => {
19915
18728
  } else {
19916
18729
  optionHandler = options.optionHandler;
19917
18730
  if (options.replaceRequest === false) {
19918
- replaceRequest = (request2) => request2;
18731
+ replaceRequest = (request) => request;
19919
18732
  } else {
19920
18733
  replaceRequest = options.replaceRequest;
19921
18734
  }
@@ -19934,10 +18747,10 @@ var notFoundHandler = (c) => {
19934
18747
  replaceRequest ||= (() => {
19935
18748
  const mergedPath = mergePath(this._basePath, path);
19936
18749
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
19937
- return (request2) => {
19938
- const url = new URL(request2.url);
18750
+ return (request) => {
18751
+ const url = new URL(request.url);
19939
18752
  url.pathname = url.pathname.slice(pathPrefixLength) || "/";
19940
- return new Request(url, request2);
18753
+ return new Request(url, request);
19941
18754
  };
19942
18755
  })();
19943
18756
  const handler = async (c, next) => {
@@ -19963,13 +18776,13 @@ var notFoundHandler = (c) => {
19963
18776
  }
19964
18777
  throw err2;
19965
18778
  }
19966
- #dispatch(request2, executionCtx, env, method) {
18779
+ #dispatch(request, executionCtx, env, method) {
19967
18780
  if (method === "HEAD") {
19968
- return (async () => new Response(null, await this.#dispatch(request2, executionCtx, env, "GET")))();
18781
+ return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
19969
18782
  }
19970
- const path = this.getPath(request2, { env });
18783
+ const path = this.getPath(request, { env });
19971
18784
  const matchResult = this.router.match(method, path);
19972
- const c = new Context(request2, {
18785
+ const c = new Context(request, {
19973
18786
  path,
19974
18787
  matchResult,
19975
18788
  env,
@@ -20000,8 +18813,8 @@ var notFoundHandler = (c) => {
20000
18813
  }
20001
18814
  })();
20002
18815
  }
20003
- fetch = (request2, ...rest) => {
20004
- return this.#dispatch(request2, rest[1], rest[0], request2.method);
18816
+ fetch = (request, ...rest) => {
18817
+ return this.#dispatch(request, rest[1], rest[0], request.method);
20005
18818
  };
20006
18819
  request = (input, requestInit, Env, executionCtx) => {
20007
18820
  if (input instanceof Request) {
@@ -20873,7 +19686,7 @@ var humanize = (times) => {
20873
19686
  }
20874
19687
  }
20875
19688
  return `${status}`;
20876
- }, logger31 = (fn = console.log) => {
19689
+ }, logger30 = (fn = console.log) => {
20877
19690
  return async function logger2(c, next) {
20878
19691
  const { method, url } = c.req;
20879
19692
  const path = url.slice(url.indexOf("/", 8));
@@ -21050,7 +19863,7 @@ function createApp(db2, options) {
21050
19863
  const app = new Hono2;
21051
19864
  app.use("*", cors({ origin: "*", credentials: true }));
21052
19865
  if (options.verbose && !options.quiet) {
21053
- app.use("*", logger31());
19866
+ app.use("*", logger30());
21054
19867
  }
21055
19868
  app.use("/api/*", async (c, next) => {
21056
19869
  c.set("db", db2);
@@ -27523,12 +26336,12 @@ var init_session2 = __esm(() => {
27523
26336
  init_utils();
27524
26337
  init_dist4();
27525
26338
  PglitePreparedQuery = class PglitePreparedQuery extends PgPreparedQuery {
27526
- constructor(client, queryString, params, logger32, fields, name3, _isResponseInArrayMode, customResultMapper) {
26339
+ constructor(client, queryString, params, logger31, fields, name3, _isResponseInArrayMode, customResultMapper) {
27527
26340
  super({ sql: queryString, params });
27528
26341
  this.client = client;
27529
26342
  this.queryString = queryString;
27530
26343
  this.params = params;
27531
- this.logger = logger32;
26344
+ this.logger = logger31;
27532
26345
  this.fields = fields;
27533
26346
  this._isResponseInArrayMode = _isResponseInArrayMode;
27534
26347
  this.customResultMapper = customResultMapper;
@@ -27632,11 +26445,11 @@ var init_session2 = __esm(() => {
27632
26445
  // ../../node_modules/drizzle-orm/pglite/driver.js
27633
26446
  function construct(client, config2 = {}) {
27634
26447
  const dialect2 = new PgDialect({ casing: config2.casing });
27635
- let logger32;
26448
+ let logger31;
27636
26449
  if (config2.logger === true) {
27637
- logger32 = new DefaultLogger;
26450
+ logger31 = new DefaultLogger;
27638
26451
  } else if (config2.logger !== false) {
27639
- logger32 = config2.logger;
26452
+ logger31 = config2.logger;
27640
26453
  }
27641
26454
  let schema2;
27642
26455
  if (config2.schema) {
@@ -27647,7 +26460,7 @@ function construct(client, config2 = {}) {
27647
26460
  tableNamesMap: tablesConfig.tableNamesMap
27648
26461
  };
27649
26462
  }
27650
- const driver = new PgliteDriver(client, dialect2, { logger: logger32 });
26463
+ const driver = new PgliteDriver(client, dialect2, { logger: logger31 });
27651
26464
  const session2 = driver.createSession(schema2);
27652
26465
  const db2 = new PgliteDatabase(dialect2, session2, schema2);
27653
26466
  db2.$client = client;
@@ -28444,24 +27257,24 @@ is not a problem with esbuild. You need to fix your environment instead.
28444
27257
  throw new Error("The service is no longer running" + closeData.reason);
28445
27258
  streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
28446
27259
  };
28447
- let handleRequest = async (id, request2) => {
27260
+ let handleRequest = async (id, request) => {
28448
27261
  try {
28449
- if (request2.command === "ping") {
27262
+ if (request.command === "ping") {
28450
27263
  sendResponse(id, {});
28451
27264
  return;
28452
27265
  }
28453
- if (typeof request2.key === "number") {
28454
- const requestCallbacks = requestCallbacksByKey[request2.key];
27266
+ if (typeof request.key === "number") {
27267
+ const requestCallbacks = requestCallbacksByKey[request.key];
28455
27268
  if (!requestCallbacks) {
28456
27269
  return;
28457
27270
  }
28458
- const callback = requestCallbacks[request2.command];
27271
+ const callback = requestCallbacks[request.command];
28459
27272
  if (callback) {
28460
- await callback(id, request2);
27273
+ await callback(id, request);
28461
27274
  return;
28462
27275
  }
28463
27276
  }
28464
- throw new Error(`Invalid command: ` + request2.command);
27277
+ throw new Error(`Invalid command: ` + request.command);
28465
27278
  } catch (e) {
28466
27279
  const errors3 = [extractErrorMessageV8(e, streamIn, null, undefined, "")];
28467
27280
  try {
@@ -28530,15 +27343,15 @@ is not a problem with esbuild. You need to fix your environment instead.
28530
27343
  flags: flags2,
28531
27344
  mangleCache
28532
27345
  } = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
28533
- let request2 = {
27346
+ let request = {
28534
27347
  command: "transform",
28535
27348
  flags: flags2,
28536
27349
  inputFS: inputPath !== null,
28537
27350
  input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
28538
27351
  };
28539
27352
  if (mangleCache)
28540
- request2.mangleCache = mangleCache;
28541
- sendRequest(refs, request2, (error, response) => {
27353
+ request.mangleCache = mangleCache;
27354
+ sendRequest(refs, request, (error, response) => {
28542
27355
  if (error)
28543
27356
  return callback(new Error(error), null);
28544
27357
  let errors3 = replaceDetailsInMessages(response.errors, details);
@@ -28616,16 +27429,16 @@ is not a problem with esbuild. You need to fix your environment instead.
28616
27429
  throw new Error(`Missing "kind" in ${callName}() call`);
28617
27430
  if (kind !== "error" && kind !== "warning")
28618
27431
  throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
28619
- let request2 = {
27432
+ let request = {
28620
27433
  command: "format-msgs",
28621
27434
  messages: sanitizeMessages(messages, "messages", null, "", terminalWidth),
28622
27435
  isWarning: kind === "warning"
28623
27436
  };
28624
27437
  if (color !== undefined)
28625
- request2.color = color;
27438
+ request.color = color;
28626
27439
  if (terminalWidth !== undefined)
28627
- request2.terminalWidth = terminalWidth;
28628
- sendRequest(refs, request2, (error, response) => {
27440
+ request.terminalWidth = terminalWidth;
27441
+ sendRequest(refs, request, (error, response) => {
28629
27442
  if (error)
28630
27443
  return callback(new Error(error), null);
28631
27444
  callback(null, response.messages);
@@ -28638,15 +27451,15 @@ is not a problem with esbuild. You need to fix your environment instead.
28638
27451
  let color = getFlag(options, keys, "color", mustBeBoolean);
28639
27452
  let verbose = getFlag(options, keys, "verbose", mustBeBoolean);
28640
27453
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
28641
- let request2 = {
27454
+ let request = {
28642
27455
  command: "analyze-metafile",
28643
27456
  metafile
28644
27457
  };
28645
27458
  if (color !== undefined)
28646
- request2.color = color;
27459
+ request.color = color;
28647
27460
  if (verbose !== undefined)
28648
- request2.verbose = verbose;
28649
- sendRequest(refs, request2, (error, response) => {
27461
+ request.verbose = verbose;
27462
+ sendRequest(refs, request, (error, response) => {
28650
27463
  if (error)
28651
27464
  return callback(new Error(error), null);
28652
27465
  callback(null, response.result);
@@ -28719,7 +27532,7 @@ is not a problem with esbuild. You need to fix your environment instead.
28719
27532
  } = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
28720
27533
  if (write && !streamIn.hasFS)
28721
27534
  throw new Error(`The "write" option is unavailable in this environment`);
28722
- const request2 = {
27535
+ const request = {
28723
27536
  command: "build",
28724
27537
  key: buildKey,
28725
27538
  entries,
@@ -28732,9 +27545,9 @@ is not a problem with esbuild. You need to fix your environment instead.
28732
27545
  context: isContext
28733
27546
  };
28734
27547
  if (requestPlugins)
28735
- request2.plugins = requestPlugins;
27548
+ request.plugins = requestPlugins;
28736
27549
  if (mangleCache)
28737
- request2.mangleCache = mangleCache;
27550
+ request.mangleCache = mangleCache;
28738
27551
  const buildResponseToResult = (response, callback2) => {
28739
27552
  const result = {
28740
27553
  errors: replaceDetailsInMessages(response.errors, details),
@@ -28764,8 +27577,8 @@ is not a problem with esbuild. You need to fix your environment instead.
28764
27577
  let latestResultPromise;
28765
27578
  let provideLatestResult;
28766
27579
  if (isContext)
28767
- requestCallbacks["on-end"] = (id, request22) => new Promise((resolve2) => {
28768
- buildResponseToResult(request22, (err2, result, onEndErrors, onEndWarnings) => {
27580
+ requestCallbacks["on-end"] = (id, request2) => new Promise((resolve2) => {
27581
+ buildResponseToResult(request2, (err2, result, onEndErrors, onEndWarnings) => {
28769
27582
  const response = {
28770
27583
  errors: onEndErrors,
28771
27584
  warnings: onEndWarnings
@@ -28778,7 +27591,7 @@ is not a problem with esbuild. You need to fix your environment instead.
28778
27591
  resolve2();
28779
27592
  });
28780
27593
  });
28781
- sendRequest(refs, request2, (error, response) => {
27594
+ sendRequest(refs, request, (error, response) => {
28782
27595
  if (error)
28783
27596
  return callback(new Error(error), null);
28784
27597
  if (!isContext) {
@@ -28801,11 +27614,11 @@ is not a problem with esbuild. You need to fix your environment instead.
28801
27614
  settlePromise = () => err2 ? reject(err2) : resolve2(result2);
28802
27615
  };
28803
27616
  const triggerAnotherBuild = () => {
28804
- const request22 = {
27617
+ const request2 = {
28805
27618
  command: "rebuild",
28806
27619
  key: buildKey
28807
27620
  };
28808
- sendRequest(refs, request22, (error2, response2) => {
27621
+ sendRequest(refs, request2, (error2, response2) => {
28809
27622
  if (error2) {
28810
27623
  reject(new Error(error2));
28811
27624
  } else if (settlePromise) {
@@ -28825,13 +27638,13 @@ is not a problem with esbuild. You need to fix your environment instead.
28825
27638
  const keys = {};
28826
27639
  const delay = getFlag(options2, keys, "delay", mustBeInteger);
28827
27640
  checkForInvalidFlags(options2, keys, `in watch() call`);
28828
- const request22 = {
27641
+ const request2 = {
28829
27642
  command: "watch",
28830
27643
  key: buildKey
28831
27644
  };
28832
27645
  if (delay)
28833
- request22.delay = delay;
28834
- sendRequest(refs, request22, (error2) => {
27646
+ request2.delay = delay;
27647
+ sendRequest(refs, request2, (error2) => {
28835
27648
  if (error2)
28836
27649
  reject(new Error(error2));
28837
27650
  else
@@ -28851,33 +27664,33 @@ is not a problem with esbuild. You need to fix your environment instead.
28851
27664
  const cors2 = getFlag(options2, keys, "cors", mustBeObject);
28852
27665
  const onRequest = getFlag(options2, keys, "onRequest", mustBeFunction);
28853
27666
  checkForInvalidFlags(options2, keys, `in serve() call`);
28854
- const request22 = {
27667
+ const request2 = {
28855
27668
  command: "serve",
28856
27669
  key: buildKey,
28857
27670
  onRequest: !!onRequest
28858
27671
  };
28859
27672
  if (port !== undefined)
28860
- request22.port = port;
27673
+ request2.port = port;
28861
27674
  if (host !== undefined)
28862
- request22.host = host;
27675
+ request2.host = host;
28863
27676
  if (servedir !== undefined)
28864
- request22.servedir = servedir;
27677
+ request2.servedir = servedir;
28865
27678
  if (keyfile !== undefined)
28866
- request22.keyfile = keyfile;
27679
+ request2.keyfile = keyfile;
28867
27680
  if (certfile !== undefined)
28868
- request22.certfile = certfile;
27681
+ request2.certfile = certfile;
28869
27682
  if (fallback !== undefined)
28870
- request22.fallback = fallback;
27683
+ request2.fallback = fallback;
28871
27684
  if (cors2) {
28872
27685
  const corsKeys = {};
28873
27686
  const origin = getFlag(cors2, corsKeys, "origin", mustBeStringOrArrayOfStrings);
28874
27687
  checkForInvalidFlags(cors2, corsKeys, `on "cors" object`);
28875
27688
  if (Array.isArray(origin))
28876
- request22.corsOrigin = origin;
27689
+ request2.corsOrigin = origin;
28877
27690
  else if (origin !== undefined)
28878
- request22.corsOrigin = [origin];
27691
+ request2.corsOrigin = [origin];
28879
27692
  }
28880
- sendRequest(refs, request22, (error2, response2) => {
27693
+ sendRequest(refs, request2, (error2, response2) => {
28881
27694
  if (error2)
28882
27695
  return reject(new Error(error2));
28883
27696
  if (onRequest) {
@@ -28892,11 +27705,11 @@ is not a problem with esbuild. You need to fix your environment instead.
28892
27705
  cancel: () => new Promise((resolve2) => {
28893
27706
  if (didDispose)
28894
27707
  return resolve2();
28895
- const request22 = {
27708
+ const request2 = {
28896
27709
  command: "cancel",
28897
27710
  key: buildKey
28898
27711
  };
28899
- sendRequest(refs, request22, () => {
27712
+ sendRequest(refs, request2, () => {
28900
27713
  resolve2();
28901
27714
  });
28902
27715
  }),
@@ -28904,11 +27717,11 @@ is not a problem with esbuild. You need to fix your environment instead.
28904
27717
  if (didDispose)
28905
27718
  return resolve2();
28906
27719
  didDispose = true;
28907
- const request22 = {
27720
+ const request2 = {
28908
27721
  command: "dispose",
28909
27722
  key: buildKey
28910
27723
  };
28911
- sendRequest(refs, request22, () => {
27724
+ sendRequest(refs, request2, () => {
28912
27725
  resolve2();
28913
27726
  scheduleOnDisposeCallbacks();
28914
27727
  refs.unref();
@@ -28966,29 +27779,29 @@ is not a problem with esbuild. You need to fix your environment instead.
28966
27779
  let importAttributes = getFlag(options, keys2, "with", mustBeObject);
28967
27780
  checkForInvalidFlags(options, keys2, "in resolve() call");
28968
27781
  return new Promise((resolve22, reject) => {
28969
- const request2 = {
27782
+ const request = {
28970
27783
  command: "resolve",
28971
27784
  path: path3,
28972
27785
  key: buildKey,
28973
27786
  pluginName: name3
28974
27787
  };
28975
27788
  if (pluginName != null)
28976
- request2.pluginName = pluginName;
27789
+ request.pluginName = pluginName;
28977
27790
  if (importer != null)
28978
- request2.importer = importer;
27791
+ request.importer = importer;
28979
27792
  if (namespace != null)
28980
- request2.namespace = namespace;
27793
+ request.namespace = namespace;
28981
27794
  if (resolveDir != null)
28982
- request2.resolveDir = resolveDir;
27795
+ request.resolveDir = resolveDir;
28983
27796
  if (kind != null)
28984
- request2.kind = kind;
27797
+ request.kind = kind;
28985
27798
  else
28986
27799
  throw new Error(`Must specify "kind" when calling "resolve"`);
28987
27800
  if (pluginData != null)
28988
- request2.pluginData = details.store(pluginData);
27801
+ request.pluginData = details.store(pluginData);
28989
27802
  if (importAttributes != null)
28990
- request2.with = sanitizeStringMap(importAttributes, "with");
28991
- sendRequest(refs, request2, (error, response) => {
27803
+ request.with = sanitizeStringMap(importAttributes, "with");
27804
+ sendRequest(refs, request, (error, response) => {
28992
27805
  if (error !== null)
28993
27806
  reject(new Error(error));
28994
27807
  else
@@ -29058,7 +27871,7 @@ is not a problem with esbuild. You need to fix your environment instead.
29058
27871
  return { ok: false, error: e, pluginName: name3 };
29059
27872
  }
29060
27873
  }
29061
- requestCallbacks["on-start"] = async (id, request2) => {
27874
+ requestCallbacks["on-start"] = async (id, request) => {
29062
27875
  details.clear();
29063
27876
  let response = { errors: [], warnings: [] };
29064
27877
  await Promise.all(onStartCallbacks.map(async ({ name: name3, callback, note }) => {
@@ -29082,19 +27895,19 @@ is not a problem with esbuild. You need to fix your environment instead.
29082
27895
  }));
29083
27896
  sendResponse(id, response);
29084
27897
  };
29085
- requestCallbacks["on-resolve"] = async (id, request2) => {
27898
+ requestCallbacks["on-resolve"] = async (id, request) => {
29086
27899
  let response = {}, name3 = "", callback, note;
29087
- for (let id2 of request2.ids) {
27900
+ for (let id2 of request.ids) {
29088
27901
  try {
29089
27902
  ({ name: name3, callback, note } = onResolveCallbacks[id2]);
29090
27903
  let result = await callback({
29091
- path: request2.path,
29092
- importer: request2.importer,
29093
- namespace: request2.namespace,
29094
- resolveDir: request2.resolveDir,
29095
- kind: request2.kind,
29096
- pluginData: details.load(request2.pluginData),
29097
- with: request2.with
27904
+ path: request.path,
27905
+ importer: request.importer,
27906
+ namespace: request.namespace,
27907
+ resolveDir: request.resolveDir,
27908
+ kind: request.kind,
27909
+ pluginData: details.load(request.pluginData),
27910
+ with: request.with
29098
27911
  });
29099
27912
  if (result != null) {
29100
27913
  if (typeof result !== "object")
@@ -29144,17 +27957,17 @@ is not a problem with esbuild. You need to fix your environment instead.
29144
27957
  }
29145
27958
  sendResponse(id, response);
29146
27959
  };
29147
- requestCallbacks["on-load"] = async (id, request2) => {
27960
+ requestCallbacks["on-load"] = async (id, request) => {
29148
27961
  let response = {}, name3 = "", callback, note;
29149
- for (let id2 of request2.ids) {
27962
+ for (let id2 of request.ids) {
29150
27963
  try {
29151
27964
  ({ name: name3, callback, note } = onLoadCallbacks[id2]);
29152
27965
  let result = await callback({
29153
- path: request2.path,
29154
- namespace: request2.namespace,
29155
- suffix: request2.suffix,
29156
- pluginData: details.load(request2.pluginData),
29157
- with: request2.with
27966
+ path: request.path,
27967
+ namespace: request.namespace,
27968
+ suffix: request.suffix,
27969
+ pluginData: details.load(request.pluginData),
27970
+ with: request.with
29158
27971
  });
29159
27972
  if (result != null) {
29160
27973
  if (typeof result !== "object")
@@ -29679,7 +28492,7 @@ for your current platform.`);
29679
28492
  return { binPath, isWASM };
29680
28493
  }
29681
28494
  var child_process = __require("child_process");
29682
- var crypto5 = __require("crypto");
28495
+ var crypto4 = __require("crypto");
29683
28496
  var path2 = __require("path");
29684
28497
  var fs22 = __require("fs");
29685
28498
  var os2 = __require("os");
@@ -29993,7 +28806,7 @@ More information: The file containing the code for esbuild's JavaScript API (${_
29993
28806
  afterClose(null);
29994
28807
  };
29995
28808
  var randomFileName = () => {
29996
- return path2.join(os2.tmpdir(), `esbuild-${crypto5.randomBytes(32).toString("hex")}`);
28809
+ return path2.join(os2.tmpdir(), `esbuild-${crypto4.randomBytes(32).toString("hex")}`);
29997
28810
  };
29998
28811
  var workerThreadService = null;
29999
28812
  var startWorkerThreadService = (worker_threads2) => {
@@ -32596,8 +31409,8 @@ var require_node2 = __commonJS((exports) => {
32596
31409
  }
32597
31410
  } catch (err2) {}
32598
31411
  var bufferFrom = require_buffer_from();
32599
- function dynamicRequire(mod, request2) {
32600
- return mod.require(request2);
31412
+ function dynamicRequire(mod, request) {
31413
+ return mod.require(request);
32601
31414
  }
32602
31415
  var errorFormatterInstalled = false;
32603
31416
  var uncaughtShimInstalled = false;
@@ -35401,10 +34214,10 @@ If you have no idea what this means or what Pirates is, let me explain: Pirates
35401
34214
  var Module2 = __require("module");
35402
34215
  var originalResolveFilename = Module2._resolveFilename;
35403
34216
  var coreModules = getCoreModules(Module2.builtinModules);
35404
- Module2._resolveFilename = function(request2, _parent) {
35405
- var isCoreModule = coreModules.hasOwnProperty(request2);
34217
+ Module2._resolveFilename = function(request, _parent) {
34218
+ var isCoreModule = coreModules.hasOwnProperty(request);
35406
34219
  if (!isCoreModule) {
35407
- var found = matchPath(request2);
34220
+ var found = matchPath(request);
35408
34221
  if (found) {
35409
34222
  var modifiedArguments = __spreadArray([found], [].slice.call(arguments, 1), true);
35410
34223
  return originalResolveFilename.apply(this, modifiedArguments);
@@ -35571,10 +34384,10 @@ If you have no idea what this means or what Pirates is, let me explain: Pirates
35571
34384
  const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
35572
34385
  const Module2 = __require("module");
35573
34386
  const originalResolveFilename = Module2._resolveFilename;
35574
- Module2._resolveFilename = function(request2, _parent) {
35575
- const isCoreModule = _module2.builtinModules.includes(request2);
34387
+ Module2._resolveFilename = function(request, _parent) {
34388
+ const isCoreModule = _module2.builtinModules.includes(request);
35576
34389
  if (!isCoreModule) {
35577
- const found = matchPath(request2);
34390
+ const found = matchPath(request);
35578
34391
  if (found) {
35579
34392
  const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
35580
34393
  return originalResolveFilename.apply(this, modifiedArguments);
@@ -35722,7 +34535,7 @@ __export(exports_api, {
35722
34535
  import process2 from "process";
35723
34536
  import os from "os";
35724
34537
  import tty from "tty";
35725
- import { randomUUID as randomUUID2 } from "crypto";
34538
+ import { randomUUID } from "crypto";
35726
34539
  function assembleStyles() {
35727
34540
  const codes = /* @__PURE__ */ new Map;
35728
34541
  for (const [groupName, group] of Object.entries(styles2)) {
@@ -38397,7 +37210,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
38397
37210
  __defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
38398
37211
  }
38399
37212
  return to;
38400
- }, __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles2, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default, init_ansi_styles, env, flagForceColor, supportsColor, supports_color_default, init_supports_color, init_utilities, stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles22, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default, init_source, require_old, require_fs, require_path, require_balanced_match, require_brace_expansion, require_minimatch, require_inherits_browser, require_inherits, require_common2, require_sync, require_wrappy, require_once, require_inflight, require_glob, require_readline, require_src2, require_utils, require_lodash, require_hanji, originUUID, snapshotVersion, mapValues, mapKeys, mapEntries, customMapEntries, init_global2, util3, objectUtil2, ZodParsedType2, getParsedType2, init_util2, ZodIssueCode2, ZodError3, init_ZodError2, errorMap2, en_default2, init_en2, overrideErrorMap2, init_errors4, makeIssue2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, init_parseUtil2, init_typeAliases2, errorUtil2, init_errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, coerce2, init_types8, init_external2, init_v32, init_esm3, enumSchema, enumSchemaV1, indexColumn, index2, fk, sequenceSchema, roleSchema, sequenceSquashed, column2, checkConstraint, columnSquashed, compositePK, uniqueConstraint, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, table15, schemaHash, kitInternals, gelSchemaExternal, gelSchemaInternal, tableSquashed, gelSchemaSquashed, gelSchema, dryGel, init_gelSchema, index22, fk2, column22, tableV3, compositePK2, uniqueConstraint2, checkConstraint2, tableV4, table22, viewMeta, view22, kitInternals2, dialect2, schemaHash2, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed2, viewSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql, init_mysqlSchema, indexV2, columnV2, tableV2, enumSchemaV12, enumSchema2, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn2, index3, indexV4, indexV5, indexV6, fk3, sequenceSchema2, roleSchema2, sequenceSquashed2, columnV7, column3, checkConstraint3, columnSquashed2, tableV32, compositePK3, uniqueConstraint3, policy2, policySquashed2, viewWithOption2, matViewWithOption2, mergedViewWithOption2, view3, tableV42, tableV5, tableV6, tableV7, table32, schemaHash3, kitInternals3, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed3, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg, init_pgSchema, index4, column4, compositePK4, uniqueConstraint4, table42, viewMeta2, kitInternals4, dialect22, schemaHash4, schemaInternal2, schema22, tableSquashed4, schemaSquashed2, SingleStoreSquasher, squashSingleStoreScheme, singlestoreSchema, singlestoreSchemaSquashed, backwardCompatibleSingleStoreSchema, drySingleStore, init_singlestoreSchema, index5, fk4, compositePK5, column5, tableV33, uniqueConstraint5, checkConstraint4, table52, view4, dialect3, schemaHash5, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals5, latestVersion, schemaInternal3, schemaV32, schemaV42, schemaV52, schema3, tableSquashed5, schemaSquashed3, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema, init_sqliteSchema, copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, init_utils5, import_hanji, warning, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner2, ProgressView, init_views, glob, init_serializer, fillPgSnapshot, init_migrationPreparator, require_heap, require_heap2, require_difflib, require_difflib2, require_util, require_styles, require_has_flag2, require_supports_colors, require_trap, require_zalgo, require_america, require_zebra, require_rainbow, require_random, require_colors, require_safe, require_colorize, require_lib, import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn, init_jsonDiffer, parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SingleStoreCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, SingleStoreAlterTableAddUniqueConstraintConvertor, SingleStoreAlterTableDropUniqueConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SingleStoreDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, SingleStoreRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SingleStoreAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SingleStoreAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SingleStoreAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, SingleStoreAlterTableAlterColumnAlterrGeneratedConvertor, SingleStoreAlterTableAddPk, SingleStoreAlterTableDropPk, SingleStoreModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSingleStoreIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SingleStoreDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, SingleStoreRecreateTableConvertor, convertors, init_sqlgenerator, _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn, init_sqlitePushUtils, preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSingleStoreCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView, init_jsonStatements, prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements, prepareSingleStoreRecreateTable, singleStoreCombineStatements, init_statementCombiner, snapshotsDiffer_exports, makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema3, changedEnumSchema, tableScheme, alteredTableScheme, alteredViewCommon, alteredPgViewSchema, alteredMySqlViewSchema, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSingleStore, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySingleStoreSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff, init_snapshotsDiffer, init_words, dialects, dialect4, commonSquashedSchema, commonSchema, init_schemaValidator, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, casingTypes, casingType, sqliteDriver, postgresDriver, driver2, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, init_common2, withStyle, init_outputs, import_hanji2, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, init_migrate, posixClasses, braceEscape, regexpEscape, rangesToString, parseClass, init_brace_expressions, escape, init_escape, unescape, init_unescape, import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match2, globUnescape, globMagic, regExpEscape, Minimatch, init_mjs, entityKind2, hasOwnEntityKind2, init_entity2, _a, Column2, init_column2, _a2, ColumnBuilder2, init_column_builder2, TableName2, init_table_utils2, _a3, ForeignKeyBuilder2, _a4, ForeignKey2, init_foreign_keys2, init_tracing_utils2, _a5, UniqueConstraintBuilder, _a6, UniqueOnConstraintBuilder, _a7, UniqueConstraint, init_unique_constraint2, init_array2, _a8, _b, PgColumnBuilder2, _a9, _b2, PgColumn2, _a10, _b3, ExtraConfigColumn2, _a11, IndexedColumn2, _a12, _b4, PgArrayBuilder2, _a13, _b5, _PgArray, PgArray2, init_common22, _a14, _b6, PgEnumObjectColumnBuilder2, _a15, _b7, PgEnumObjectColumn2, isPgEnumSym2, _a16, _b8, PgEnumColumnBuilder2, _a17, _b9, PgEnumColumn2, init_enum2, _a18, Subquery2, _a19, _b10, WithSubquery2, init_subquery2, version2, init_version2, otel2, rawTracer2, tracer2, init_tracing2, ViewBaseConfig2, init_view_common3, Schema2, Columns2, ExtraConfigColumns2, OriginalName2, BaseName2, IsAlias2, ExtraConfigBuilder2, IsDrizzleTable2, _a20, _b11, _c, _d, _e2, _f, _g, _h, _i, _j, Table2, init_table15, _a21, FakePrimitiveParam, _a22, StringChunk2, _a23, _SQL, SQL2, _a24, Name2, noopDecoder2, noopEncoder2, noopMapper2, _a25, Param2, _a26, Placeholder2, IsDrizzleView2, _a27, _b12, _c2, View3, init_sql3, _a28, ColumnAliasProxyHandler2, _a29, TableAliasProxyHandler2, _a30, RelationTableAliasProxyHandler, init_alias3, _a31, _b13, DrizzleError2, DrizzleQueryError, _a32, _b14, TransactionRollbackError2, init_errors22, _a33, ConsoleLogWriter2, _a34, DefaultLogger2, _a35, NoopLogger2, init_logger3, init_operations, _a36, _b15, QueryPromise2, init_query_promise2, textDecoder, init_utils22, _a37, _b16, PgIntColumnBaseBuilder2, init_int_common2, _a38, _b17, PgBigInt53Builder2, _a39, _b18, PgBigInt532, _a40, _b19, PgBigInt64Builder2, _a41, _b20, PgBigInt642, init_bigint2, _a42, _b21, PgBigSerial53Builder2, _a43, _b22, PgBigSerial532, _a44, _b23, PgBigSerial64Builder2, _a45, _b24, PgBigSerial642, init_bigserial2, _a46, _b25, PgBooleanBuilder2, _a47, _b26, PgBoolean2, init_boolean2, _a48, _b27, PgCharBuilder2, _a49, _b28, PgChar2, init_char2, _a50, _b29, PgCidrBuilder2, _a51, _b30, PgCidr2, init_cidr2, _a52, _b31, PgCustomColumnBuilder2, _a53, _b32, PgCustomColumn2, init_custom2, _a54, _b33, PgDateColumnBaseBuilder2, init_date_common2, _a55, _b34, PgDateBuilder2, _a56, _b35, PgDate2, _a57, _b36, PgDateStringBuilder2, _a58, _b37, PgDateString2, init_date2, _a59, _b38, PgDoublePrecisionBuilder2, _a60, _b39, PgDoublePrecision2, init_double_precision2, _a61, _b40, PgInetBuilder2, _a62, _b41, PgInet2, init_inet2, _a63, _b42, PgIntegerBuilder2, _a64, _b43, PgInteger2, init_integer2, _a65, _b44, PgIntervalBuilder2, _a66, _b45, PgInterval2, init_interval2, _a67, _b46, PgJsonBuilder2, _a68, _b47, PgJson2, init_json2, _a69, _b48, PgJsonbBuilder2, _a70, _b49, PgJsonb2, init_jsonb2, _a71, _b50, PgLineBuilder2, _a72, _b51, PgLineTuple2, _a73, _b52, PgLineABCBuilder2, _a74, _b53, PgLineABC2, init_line2, _a75, _b54, PgMacaddrBuilder2, _a76, _b55, PgMacaddr2, init_macaddr2, _a77, _b56, PgMacaddr8Builder2, _a78, _b57, PgMacaddr82, init_macaddr82, _a79, _b58, PgNumericBuilder2, _a80, _b59, PgNumeric2, _a81, _b60, PgNumericNumberBuilder2, _a82, _b61, PgNumericNumber2, _a83, _b62, PgNumericBigIntBuilder2, _a84, _b63, PgNumericBigInt2, init_numeric2, _a85, _b64, PgPointTupleBuilder2, _a86, _b65, PgPointTuple2, _a87, _b66, PgPointObjectBuilder2, _a88, _b67, PgPointObject2, init_point2, init_utils32, _a89, _b68, PgGeometryBuilder2, _a90, _b69, PgGeometry2, _a91, _b70, PgGeometryObjectBuilder2, _a92, _b71, PgGeometryObject2, init_geometry2, _a93, _b72, PgRealBuilder2, _a94, _b73, PgReal2, init_real2, _a95, _b74, PgSerialBuilder2, _a96, _b75, PgSerial2, init_serial2, _a97, _b76, PgSmallIntBuilder2, _a98, _b77, PgSmallInt2, init_smallint2, _a99, _b78, PgSmallSerialBuilder2, _a100, _b79, PgSmallSerial2, init_smallserial2, _a101, _b80, PgTextBuilder2, _a102, _b81, PgText2, init_text2, _a103, _b82, PgTimeBuilder2, _a104, _b83, PgTime2, init_time2, _a105, _b84, PgTimestampBuilder2, _a106, _b85, PgTimestamp2, _a107, _b86, PgTimestampStringBuilder2, _a108, _b87, PgTimestampString2, init_timestamp2, _a109, _b88, PgUUIDBuilder2, _a110, _b89, PgUUID2, init_uuid3, _a111, _b90, PgVarcharBuilder2, _a112, _b91, PgVarchar2, init_varchar2, _a113, _b92, PgBinaryVectorBuilder2, _a114, _b93, PgBinaryVector2, init_bit2, _a115, _b94, PgHalfVectorBuilder2, _a116, _b95, PgHalfVector2, init_halfvec2, _a117, _b96, PgSparseVectorBuilder2, _a118, _b97, PgSparseVector2, init_sparsevec2, _a119, _b98, PgVectorBuilder2, _a120, _b99, PgVector2, init_vector3, init_all2, InlineForeignKeys2, EnableRLS2, _a121, _b100, _c3, _d2, _e22, _f2, PgTable2, pgTable2, init_table22, _a122, PrimaryKeyBuilder2, _a123, PrimaryKey2, init_primary_keys2, eq2, ne3, gt3, gte2, lt3, lte2, init_conditions2, init_select3, init_expressions2, _a124, Relation2, _a125, Relations2, _a126, _b101, _One, One2, _a127, _b102, _Many, Many2, init_relations2, init_aggregate2, init_vector22, init_functions2, init_sql22, dist_exports, init_dist5, init_alias22, _a128, CheckBuilder, _a129, Check, init_checks2, init_columns2, _a130, _SelectionProxyHandler, SelectionProxyHandler2, init_selection_proxy2, _a131, IndexBuilderOn2, _a132, IndexBuilder2, _a133, Index2, init_indexes2, _a134, PgPolicy, init_policies2, PgViewConfig2, init_view_common22, _a135, CasingCache2, init_casing2, _a136, _b103, PgViewBase2, init_view_base2, _a137, PgDialect2, init_dialect2, _a138, TypedQueryBuilder2, init_query_builder3, _a139, PgSelectBuilder2, _a140, _b104, PgSelectQueryBuilderBase2, _a141, _b105, PgSelectBase2, getPgSetOperators2, union2, unionAll2, intersect2, intersectAll2, except2, exceptAll2, init_select22, _a142, QueryBuilder2, init_query_builder22, _a143, DefaultViewBuilderCore, _a144, _b106, ViewBuilder, _a145, _b107, ManualViewBuilder, _a146, MaterializedViewBuilderCore, _a147, _b108, MaterializedViewBuilder, _a148, _b109, ManualMaterializedViewBuilder, _a149, _b110, _c4, PgView2, PgMaterializedViewConfig2, _a150, _b111, _c5, PgMaterializedView, init_view2, init_utils42, _a151, _b112, PgDeleteBase2, init_delete2, _a152, PgInsertBuilder2, _a153, _b113, PgInsertBase2, init_insert2, _a154, _b114, PgRefreshMaterializedView2, init_refresh_materialized_view2, init_select_types, _a155, PgUpdateBuilder2, _a156, _b115, PgUpdateBase2, init_update2, init_query_builders2, _a157, _b116, _c6, _PgCountBuilder, PgCountBuilder2, init_count2, _a158, RelationalQueryBuilder2, _a159, _b117, PgRelationalQuery2, init_query2, _a160, _b118, PgRaw2, init_raw2, _a161, PgDatabase2, init_db2, _a162, PgRole, init_roles2, _a163, PgSequence, init_sequence2, _a164, PgSchema5, init_schema3, _a165, Cache, _a166, _b119, NoopCache, init_cache, _a167, PgPreparedQuery2, _a168, PgSession2, _a169, _b120, PgTransaction2, init_session3, init_subquery22, init_utils52, init_pg_core2, vectorOps, init_vector32, sqlToStr, init_utils6, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn, getColumnsInfoQuery, init_pgSerializer, import_hanji4, Select, init_selector_ui, init_alias32, _a170, CheckBuilder2, _a171, Check2, init_checks22, _a172, ForeignKeyBuilder22, _a173, ForeignKey22, init_foreign_keys22, _a174, UniqueConstraintBuilder2, _a175, UniqueOnConstraintBuilder2, _a176, UniqueConstraint2, init_unique_constraint22, _a177, _b121, SQLiteColumnBuilder, _a178, _b122, SQLiteColumn, init_common3, _a179, _b123, SQLiteBigIntBuilder, _a180, _b124, SQLiteBigInt, _a181, _b125, SQLiteBlobJsonBuilder, _a182, _b126, SQLiteBlobJson, _a183, _b127, SQLiteBlobBufferBuilder, _a184, _b128, SQLiteBlobBuffer, init_blob, _a185, _b129, SQLiteCustomColumnBuilder, _a186, _b130, SQLiteCustomColumn, init_custom22, _a187, _b131, SQLiteBaseIntegerBuilder, _a188, _b132, SQLiteBaseInteger, _a189, _b133, SQLiteIntegerBuilder, _a190, _b134, SQLiteInteger, _a191, _b135, SQLiteTimestampBuilder, _a192, _b136, SQLiteTimestamp, _a193, _b137, SQLiteBooleanBuilder, _a194, _b138, SQLiteBoolean, init_integer22, _a195, _b139, SQLiteNumericBuilder, _a196, _b140, SQLiteNumeric, _a197, _b141, SQLiteNumericNumberBuilder, _a198, _b142, SQLiteNumericNumber, _a199, _b143, SQLiteNumericBigIntBuilder, _a200, _b144, SQLiteNumericBigInt, init_numeric22, _a201, _b145, SQLiteRealBuilder, _a202, _b146, SQLiteReal, init_real22, _a203, _b147, SQLiteTextBuilder, _a204, _b148, SQLiteText, _a205, _b149, SQLiteTextJsonBuilder, _a206, _b150, SQLiteTextJson, init_text22, init_columns22, init_all22, InlineForeignKeys22, _a207, _b151, _c7, _d3, _e3, SQLiteTable, sqliteTable, init_table32, _a208, IndexBuilderOn22, _a209, IndexBuilder22, _a210, Index4, init_indexes22, _a211, PrimaryKeyBuilder22, _a212, PrimaryKey22, init_primary_keys22, init_utils7, _a213, _b152, SQLiteDeleteBase, init_delete22, _a214, _b153, SQLiteViewBase, init_view_base22, _a215, SQLiteDialect, _a216, _b154, SQLiteSyncDialect, _a217, _b155, SQLiteAsyncDialect, init_dialect22, _a218, SQLiteSelectBuilder, _a219, _b156, SQLiteSelectQueryBuilderBase, _a220, _b157, SQLiteSelectBase, getSQLiteSetOperators, union3, unionAll22, intersect22, except22, init_select32, _a221, QueryBuilder22, init_query_builder32, _a222, SQLiteInsertBuilder, _a223, _b158, SQLiteInsertBase, init_insert22, init_select_types2, _a224, SQLiteUpdateBuilder, _a225, _b159, SQLiteUpdateBase, init_update22, init_query_builders22, _a226, _b160, _c8, _SQLiteCountBuilder, SQLiteCountBuilder, init_count22, _a227, RelationalQueryBuilder22, _a228, _b161, SQLiteRelationalQuery, _a229, _b162, SQLiteSyncRelationalQuery, init_query22, _a230, _b163, SQLiteRaw, init_raw22, _a231, BaseSQLiteDatabase, init_db22, _a232, _b164, ExecuteResultSync, _a233, SQLitePreparedQuery, _a234, SQLiteSession, _a235, _b165, SQLiteTransaction, init_session22, init_subquery3, _a236, ViewBuilderCore, _a237, _b166, ViewBuilder2, _a238, _b167, ManualViewBuilder2, _a239, _b168, SQLiteView2, init_view22, init_sqlite_core, generateSqliteSnapshot, fromDatabase2, init_sqliteSerializer, getTablesFilterByExtensions, init_getTablesFilterByExtensions, init_alias4, _a240, CheckBuilder3, _a241, Check3, init_checks3, _a242, ForeignKeyBuilder3, _a243, ForeignKey3, init_foreign_keys3, _a244, UniqueConstraintBuilder3, _a245, UniqueOnConstraintBuilder3, _a246, UniqueConstraint3, init_unique_constraint3, _a247, _b169, MySqlColumnBuilder, _a248, _b170, MySqlColumn, _a249, _b171, MySqlColumnBuilderWithAutoIncrement, _a250, _b172, MySqlColumnWithAutoIncrement, init_common4, _a251, _b173, MySqlBigInt53Builder, _a252, _b174, MySqlBigInt53, _a253, _b175, MySqlBigInt64Builder, _a254, _b176, MySqlBigInt64, init_bigint22, _a255, _b177, MySqlBinaryBuilder, _a256, _b178, MySqlBinary, init_binary, _a257, _b179, MySqlBooleanBuilder, _a258, _b180, MySqlBoolean, init_boolean22, _a259, _b181, MySqlCharBuilder, _a260, _b182, MySqlChar, init_char22, _a261, _b183, MySqlCustomColumnBuilder, _a262, _b184, MySqlCustomColumn, init_custom3, _a263, _b185, MySqlDateBuilder, _a264, _b186, MySqlDate, _a265, _b187, MySqlDateStringBuilder, _a266, _b188, MySqlDateString, init_date22, _a267, _b189, MySqlDateTimeBuilder, _a268, _b190, MySqlDateTime, _a269, _b191, MySqlDateTimeStringBuilder, _a270, _b192, MySqlDateTimeString, init_datetime, _a271, _b193, MySqlDecimalBuilder, _a272, _b194, MySqlDecimal, _a273, _b195, MySqlDecimalNumberBuilder, _a274, _b196, MySqlDecimalNumber, _a275, _b197, MySqlDecimalBigIntBuilder, _a276, _b198, MySqlDecimalBigInt, init_decimal, _a277, _b199, MySqlDoubleBuilder, _a278, _b200, MySqlDouble, init_double, _a279, _b201, MySqlEnumColumnBuilder, _a280, _b202, MySqlEnumColumn, _a281, _b203, MySqlEnumObjectColumnBuilder, _a282, _b204, MySqlEnumObjectColumn, init_enum22, _a283, _b205, MySqlFloatBuilder, _a284, _b206, MySqlFloat, init_float, _a285, _b207, MySqlIntBuilder, _a286, _b208, MySqlInt, init_int, _a287, _b209, MySqlJsonBuilder, _a288, _b210, MySqlJson, init_json22, _a289, _b211, MySqlMediumIntBuilder, _a290, _b212, MySqlMediumInt, init_mediumint, _a291, _b213, MySqlRealBuilder, _a292, _b214, MySqlReal, init_real3, _a293, _b215, MySqlSerialBuilder, _a294, _b216, MySqlSerial, init_serial22, _a295, _b217, MySqlSmallIntBuilder, _a296, _b218, MySqlSmallInt, init_smallint22, _a297, _b219, MySqlTextBuilder, _a298, _b220, MySqlText, init_text3, _a299, _b221, MySqlTimeBuilder, _a300, _b222, MySqlTime, init_time22, _a301, _b223, MySqlDateColumnBaseBuilder, _a302, _b224, MySqlDateBaseColumn, init_date_common22, _a303, _b225, MySqlTimestampBuilder, _a304, _b226, MySqlTimestamp, _a305, _b227, MySqlTimestampStringBuilder, _a306, _b228, MySqlTimestampString, init_timestamp22, _a307, _b229, MySqlTinyIntBuilder, _a308, _b230, MySqlTinyInt, init_tinyint, _a309, _b231, MySqlVarBinaryBuilder, _a310, _b232, MySqlVarBinary, init_varbinary, _a311, _b233, MySqlVarCharBuilder, _a312, _b234, MySqlVarChar, init_varchar22, _a313, _b235, MySqlYearBuilder, _a314, _b236, MySqlYear, init_year, init_columns3, _a315, _b237, _c9, _MySqlCountBuilder, MySqlCountBuilder, init_count3, _a316, IndexBuilderOn3, _a317, IndexBuilder3, _a318, Index5, init_indexes3, init_all3, InlineForeignKeys3, _a319, _b238, _c10, _d4, _e4, MySqlTable, mysqlTable, init_table42, _a320, PrimaryKeyBuilder3, _a321, PrimaryKey3, init_primary_keys3, MySqlViewConfig, init_view_common32, init_utils8, _a322, _b239, MySqlDeleteBase, init_delete3, _a323, _b240, MySqlViewBase, init_view_base3, _a324, MySqlDialect, init_dialect3, _a325, MySqlSelectBuilder, _a326, _b241, MySqlSelectQueryBuilderBase, _a327, _b242, MySqlSelectBase, getMySqlSetOperators, union4, unionAll3, intersect3, intersectAll22, except3, exceptAll22, init_select4, _a328, QueryBuilder3, init_query_builder4, _a329, MySqlInsertBuilder, _a330, _b243, MySqlInsertBase, init_insert3, init_select_types3, _a331, MySqlUpdateBuilder, _a332, _b244, MySqlUpdateBase, init_update3, init_query_builders3, _a333, RelationalQueryBuilder3, _a334, _b245, MySqlRelationalQuery, init_query3, _a335, MySqlDatabase, init_db3, _a336, ViewBuilderCore2, _a337, _b246, ViewBuilder3, _a338, _b247, ManualViewBuilder3, _a339, _b248, _c11, MySqlView2, init_view3, _a340, MySqlSchema5, init_schema22, _a341, MySqlPreparedQuery, _a342, MySqlSession, _a343, _b249, MySqlTransaction, init_session32, init_subquery4, init_mysql_core, handleEnumType, generateMySqlSnapshot, fromDatabase3, init_mysqlSerializer, cliConfigGenerate, pushParams, pullParams, configCheck, cliConfigCheck, init_cli, gelCredentials, init_gel, libSQLCredentials, init_libsql, mysqlCredentials, init_mysql, postgresCredentials, init_postgres, singlestoreCredentials, init_singlestore, sqliteCredentials, init_sqlite, credentials, studioCliParams, studioConfig, init_studio, es5_exports, _3, es5_default, init_es5, import_hanji7, assertES5, safeRegister, migrateConfig, init_utils9, prepareFromExports, init_pgImports, init_alias5, _a344, UniqueConstraintBuilder4, _a345, UniqueOnConstraintBuilder4, _a346, UniqueConstraint4, init_unique_constraint4, _a347, _b250, SingleStoreColumnBuilder, _a348, _b251, SingleStoreColumn, _a349, _b252, SingleStoreColumnBuilderWithAutoIncrement, _a350, _b253, SingleStoreColumnWithAutoIncrement, init_common5, _a351, _b254, SingleStoreBigInt53Builder, _a352, _b255, SingleStoreBigInt53, _a353, _b256, SingleStoreBigInt64Builder, _a354, _b257, SingleStoreBigInt64, init_bigint3, _a355, _b258, SingleStoreBinaryBuilder, _a356, _b259, SingleStoreBinary, init_binary2, _a357, _b260, SingleStoreBooleanBuilder, _a358, _b261, SingleStoreBoolean, init_boolean3, _a359, _b262, SingleStoreCharBuilder, _a360, _b263, SingleStoreChar, init_char3, _a361, _b264, SingleStoreCustomColumnBuilder, _a362, _b265, SingleStoreCustomColumn, init_custom4, _a363, _b266, SingleStoreDateBuilder, _a364, _b267, SingleStoreDate, _a365, _b268, SingleStoreDateStringBuilder, _a366, _b269, SingleStoreDateString, init_date3, _a367, _b270, SingleStoreDateTimeBuilder, _a368, _b271, SingleStoreDateTime, _a369, _b272, SingleStoreDateTimeStringBuilder, _a370, _b273, SingleStoreDateTimeString, init_datetime2, _a371, _b274, SingleStoreDecimalBuilder, _a372, _b275, SingleStoreDecimal, _a373, _b276, SingleStoreDecimalNumberBuilder, _a374, _b277, SingleStoreDecimalNumber, _a375, _b278, SingleStoreDecimalBigIntBuilder, _a376, _b279, SingleStoreDecimalBigInt, init_decimal2, _a377, _b280, SingleStoreDoubleBuilder, _a378, _b281, SingleStoreDouble, init_double2, _a379, _b282, SingleStoreEnumColumnBuilder, _a380, _b283, SingleStoreEnumColumn, init_enum3, _a381, _b284, SingleStoreFloatBuilder, _a382, _b285, SingleStoreFloat, init_float2, _a383, _b286, SingleStoreIntBuilder, _a384, _b287, SingleStoreInt, init_int2, _a385, _b288, SingleStoreJsonBuilder, _a386, _b289, SingleStoreJson, init_json3, _a387, _b290, SingleStoreMediumIntBuilder, _a388, _b291, SingleStoreMediumInt, init_mediumint2, _a389, _b292, SingleStoreRealBuilder, _a390, _b293, SingleStoreReal, init_real4, _a391, _b294, SingleStoreSerialBuilder, _a392, _b295, SingleStoreSerial, init_serial3, _a393, _b296, SingleStoreSmallIntBuilder, _a394, _b297, SingleStoreSmallInt, init_smallint3, _a395, _b298, SingleStoreTextBuilder, _a396, _b299, SingleStoreText, init_text4, _a397, _b300, SingleStoreTimeBuilder, _a398, _b301, SingleStoreTime, init_time3, _a399, _b302, SingleStoreDateColumnBaseBuilder, _a400, _b303, SingleStoreDateBaseColumn, init_date_common3, _a401, _b304, SingleStoreTimestampBuilder, _a402, _b305, SingleStoreTimestamp, _a403, _b306, SingleStoreTimestampStringBuilder, _a404, _b307, SingleStoreTimestampString, init_timestamp3, _a405, _b308, SingleStoreTinyIntBuilder, _a406, _b309, SingleStoreTinyInt, init_tinyint2, _a407, _b310, SingleStoreVarBinaryBuilder, _a408, _b311, SingleStoreVarBinary, init_varbinary2, _a409, _b312, SingleStoreVarCharBuilder, _a410, _b313, SingleStoreVarChar, init_varchar3, _a411, _b314, SingleStoreVectorBuilder, _a412, _b315, SingleStoreVector, init_vector4, _a413, _b316, SingleStoreYearBuilder, _a414, _b317, SingleStoreYear, init_year2, init_columns4, _a415, _b318, _c12, _SingleStoreCountBuilder, SingleStoreCountBuilder, init_count4, _a416, IndexBuilderOn4, _a417, IndexBuilder4, _a418, Index6, init_indexes4, init_all4, _a419, _b319, _c13, _d5, SingleStoreTable, init_table52, _a420, PrimaryKeyBuilder4, _a421, PrimaryKey4, init_primary_keys4, init_utils10, _a422, _b320, SingleStoreDeleteBase, init_delete4, _a423, SingleStoreInsertBuilder, _a424, _b321, SingleStoreInsertBase, init_insert4, _a425, SingleStoreDialect, init_dialect4, _a426, SingleStoreSelectBuilder, _a427, _b322, SingleStoreSelectQueryBuilderBase, _a428, _b323, SingleStoreSelectBase, getSingleStoreSetOperators, union5, unionAll4, intersect4, except4, minus, init_select5, _a429, QueryBuilder4, init_query_builder5, init_select_types4, _a430, SingleStoreUpdateBuilder, _a431, _b324, SingleStoreUpdateBase, init_update4, init_query_builders4, _a432, SingleStoreDatabase, init_db4, _a433, SingleStoreSchema5, init_schema32, _a434, SingleStorePreparedQuery, _a435, SingleStoreSession, _a436, _b325, SingleStoreTransaction, init_session4, init_subquery5, init_singlestore_core, dialect5, generateSingleStoreSnapshot, fromDatabase4, init_singlestoreSerializer, sqliteImports_exports, prepareFromExports2, prepareFromSqliteImports, init_sqliteImports, mysqlImports_exports, prepareFromExports3, prepareFromMySqlImports, init_mysqlImports, mysqlPushUtils_exports, import_hanji8, filterStatements, logSuggestionsAndReturn2, init_mysqlPushUtils, mysqlIntrospect_exports, import_hanji9, mysqlPushIntrospect, init_mysqlIntrospect, singlestoreImports_exports, prepareFromExports4, prepareFromSingleStoreImports, init_singlestoreImports, singlestorePushUtils_exports, import_hanji10, filterStatements2, logSuggestionsAndReturn3, init_singlestorePushUtils, singlestoreIntrospect_exports, import_hanji11, singlestorePushIntrospect, init_singlestoreIntrospect, import_hanji3, pgPushIntrospect = async (db2, filters, schemaFilters, entities, tsSchema) => {
37213
+ }, __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles2, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default, init_ansi_styles, env, flagForceColor, supportsColor, supports_color_default, init_supports_color, init_utilities, stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles22, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default, init_source, require_old, require_fs, require_path, require_balanced_match, require_brace_expansion, require_minimatch, require_inherits_browser, require_inherits, require_common2, require_sync, require_wrappy, require_once, require_inflight, require_glob, require_readline, require_src2, require_utils, require_lodash, require_hanji, originUUID, snapshotVersion, mapValues, mapKeys, mapEntries, customMapEntries, init_global2, util3, objectUtil2, ZodParsedType2, getParsedType2, init_util2, ZodIssueCode2, ZodError3, init_ZodError2, errorMap2, en_default2, init_en2, overrideErrorMap2, init_errors4, makeIssue2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, init_parseUtil2, init_typeAliases2, errorUtil2, init_errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, coerce2, init_types8, init_external2, init_v32, init_esm2, enumSchema, enumSchemaV1, indexColumn, index2, fk, sequenceSchema, roleSchema, sequenceSquashed, column2, checkConstraint, columnSquashed, compositePK, uniqueConstraint, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, table15, schemaHash, kitInternals, gelSchemaExternal, gelSchemaInternal, tableSquashed, gelSchemaSquashed, gelSchema, dryGel, init_gelSchema, index22, fk2, column22, tableV3, compositePK2, uniqueConstraint2, checkConstraint2, tableV4, table22, viewMeta, view22, kitInternals2, dialect2, schemaHash2, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed2, viewSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql, init_mysqlSchema, indexV2, columnV2, tableV2, enumSchemaV12, enumSchema2, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn2, index3, indexV4, indexV5, indexV6, fk3, sequenceSchema2, roleSchema2, sequenceSquashed2, columnV7, column3, checkConstraint3, columnSquashed2, tableV32, compositePK3, uniqueConstraint3, policy2, policySquashed2, viewWithOption2, matViewWithOption2, mergedViewWithOption2, view3, tableV42, tableV5, tableV6, tableV7, table32, schemaHash3, kitInternals3, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed3, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg, init_pgSchema, index4, column4, compositePK4, uniqueConstraint4, table42, viewMeta2, kitInternals4, dialect22, schemaHash4, schemaInternal2, schema22, tableSquashed4, schemaSquashed2, SingleStoreSquasher, squashSingleStoreScheme, singlestoreSchema, singlestoreSchemaSquashed, backwardCompatibleSingleStoreSchema, drySingleStore, init_singlestoreSchema, index5, fk4, compositePK5, column5, tableV33, uniqueConstraint5, checkConstraint4, table52, view4, dialect3, schemaHash5, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals5, latestVersion, schemaInternal3, schemaV32, schemaV42, schemaV52, schema3, tableSquashed5, schemaSquashed3, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema, init_sqliteSchema, copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, init_utils5, import_hanji, warning, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner2, ProgressView, init_views, glob, init_serializer, fillPgSnapshot, init_migrationPreparator, require_heap, require_heap2, require_difflib, require_difflib2, require_util, require_styles, require_has_flag2, require_supports_colors, require_trap, require_zalgo, require_america, require_zebra, require_rainbow, require_random, require_colors, require_safe, require_colorize, require_lib, import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn, init_jsonDiffer, parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SingleStoreCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, SingleStoreAlterTableAddUniqueConstraintConvertor, SingleStoreAlterTableDropUniqueConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SingleStoreDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, SingleStoreRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SingleStoreAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SingleStoreAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SingleStoreAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, SingleStoreAlterTableAlterColumnAlterrGeneratedConvertor, SingleStoreAlterTableAddPk, SingleStoreAlterTableDropPk, SingleStoreModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSingleStoreIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SingleStoreDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, SingleStoreRecreateTableConvertor, convertors, init_sqlgenerator, _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn, init_sqlitePushUtils, preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSingleStoreCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView, init_jsonStatements, prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements, prepareSingleStoreRecreateTable, singleStoreCombineStatements, init_statementCombiner, snapshotsDiffer_exports, makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema3, changedEnumSchema, tableScheme, alteredTableScheme, alteredViewCommon, alteredPgViewSchema, alteredMySqlViewSchema, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSingleStore, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySingleStoreSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff, init_snapshotsDiffer, init_words, dialects, dialect4, commonSquashedSchema, commonSchema, init_schemaValidator, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, casingTypes, casingType, sqliteDriver, postgresDriver, driver2, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, init_common2, withStyle, init_outputs, import_hanji2, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, init_migrate, posixClasses, braceEscape, regexpEscape, rangesToString, parseClass, init_brace_expressions, escape, init_escape, unescape, init_unescape, import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match2, globUnescape, globMagic, regExpEscape, Minimatch, init_mjs, entityKind2, hasOwnEntityKind2, init_entity2, _a, Column2, init_column2, _a2, ColumnBuilder2, init_column_builder2, TableName2, init_table_utils2, _a3, ForeignKeyBuilder2, _a4, ForeignKey2, init_foreign_keys2, init_tracing_utils2, _a5, UniqueConstraintBuilder, _a6, UniqueOnConstraintBuilder, _a7, UniqueConstraint, init_unique_constraint2, init_array2, _a8, _b, PgColumnBuilder2, _a9, _b2, PgColumn2, _a10, _b3, ExtraConfigColumn2, _a11, IndexedColumn2, _a12, _b4, PgArrayBuilder2, _a13, _b5, _PgArray, PgArray2, init_common22, _a14, _b6, PgEnumObjectColumnBuilder2, _a15, _b7, PgEnumObjectColumn2, isPgEnumSym2, _a16, _b8, PgEnumColumnBuilder2, _a17, _b9, PgEnumColumn2, init_enum2, _a18, Subquery2, _a19, _b10, WithSubquery2, init_subquery2, version2, init_version2, otel2, rawTracer2, tracer2, init_tracing2, ViewBaseConfig2, init_view_common3, Schema2, Columns2, ExtraConfigColumns2, OriginalName2, BaseName2, IsAlias2, ExtraConfigBuilder2, IsDrizzleTable2, _a20, _b11, _c, _d, _e2, _f, _g, _h, _i, _j, Table2, init_table15, _a21, FakePrimitiveParam, _a22, StringChunk2, _a23, _SQL, SQL2, _a24, Name2, noopDecoder2, noopEncoder2, noopMapper2, _a25, Param2, _a26, Placeholder2, IsDrizzleView2, _a27, _b12, _c2, View3, init_sql3, _a28, ColumnAliasProxyHandler2, _a29, TableAliasProxyHandler2, _a30, RelationTableAliasProxyHandler, init_alias3, _a31, _b13, DrizzleError2, DrizzleQueryError, _a32, _b14, TransactionRollbackError2, init_errors22, _a33, ConsoleLogWriter2, _a34, DefaultLogger2, _a35, NoopLogger2, init_logger3, init_operations, _a36, _b15, QueryPromise2, init_query_promise2, textDecoder, init_utils22, _a37, _b16, PgIntColumnBaseBuilder2, init_int_common2, _a38, _b17, PgBigInt53Builder2, _a39, _b18, PgBigInt532, _a40, _b19, PgBigInt64Builder2, _a41, _b20, PgBigInt642, init_bigint2, _a42, _b21, PgBigSerial53Builder2, _a43, _b22, PgBigSerial532, _a44, _b23, PgBigSerial64Builder2, _a45, _b24, PgBigSerial642, init_bigserial2, _a46, _b25, PgBooleanBuilder2, _a47, _b26, PgBoolean2, init_boolean2, _a48, _b27, PgCharBuilder2, _a49, _b28, PgChar2, init_char2, _a50, _b29, PgCidrBuilder2, _a51, _b30, PgCidr2, init_cidr2, _a52, _b31, PgCustomColumnBuilder2, _a53, _b32, PgCustomColumn2, init_custom2, _a54, _b33, PgDateColumnBaseBuilder2, init_date_common2, _a55, _b34, PgDateBuilder2, _a56, _b35, PgDate2, _a57, _b36, PgDateStringBuilder2, _a58, _b37, PgDateString2, init_date2, _a59, _b38, PgDoublePrecisionBuilder2, _a60, _b39, PgDoublePrecision2, init_double_precision2, _a61, _b40, PgInetBuilder2, _a62, _b41, PgInet2, init_inet2, _a63, _b42, PgIntegerBuilder2, _a64, _b43, PgInteger2, init_integer2, _a65, _b44, PgIntervalBuilder2, _a66, _b45, PgInterval2, init_interval2, _a67, _b46, PgJsonBuilder2, _a68, _b47, PgJson2, init_json2, _a69, _b48, PgJsonbBuilder2, _a70, _b49, PgJsonb2, init_jsonb2, _a71, _b50, PgLineBuilder2, _a72, _b51, PgLineTuple2, _a73, _b52, PgLineABCBuilder2, _a74, _b53, PgLineABC2, init_line2, _a75, _b54, PgMacaddrBuilder2, _a76, _b55, PgMacaddr2, init_macaddr2, _a77, _b56, PgMacaddr8Builder2, _a78, _b57, PgMacaddr82, init_macaddr82, _a79, _b58, PgNumericBuilder2, _a80, _b59, PgNumeric2, _a81, _b60, PgNumericNumberBuilder2, _a82, _b61, PgNumericNumber2, _a83, _b62, PgNumericBigIntBuilder2, _a84, _b63, PgNumericBigInt2, init_numeric2, _a85, _b64, PgPointTupleBuilder2, _a86, _b65, PgPointTuple2, _a87, _b66, PgPointObjectBuilder2, _a88, _b67, PgPointObject2, init_point2, init_utils32, _a89, _b68, PgGeometryBuilder2, _a90, _b69, PgGeometry2, _a91, _b70, PgGeometryObjectBuilder2, _a92, _b71, PgGeometryObject2, init_geometry2, _a93, _b72, PgRealBuilder2, _a94, _b73, PgReal2, init_real2, _a95, _b74, PgSerialBuilder2, _a96, _b75, PgSerial2, init_serial2, _a97, _b76, PgSmallIntBuilder2, _a98, _b77, PgSmallInt2, init_smallint2, _a99, _b78, PgSmallSerialBuilder2, _a100, _b79, PgSmallSerial2, init_smallserial2, _a101, _b80, PgTextBuilder2, _a102, _b81, PgText2, init_text2, _a103, _b82, PgTimeBuilder2, _a104, _b83, PgTime2, init_time2, _a105, _b84, PgTimestampBuilder2, _a106, _b85, PgTimestamp2, _a107, _b86, PgTimestampStringBuilder2, _a108, _b87, PgTimestampString2, init_timestamp2, _a109, _b88, PgUUIDBuilder2, _a110, _b89, PgUUID2, init_uuid3, _a111, _b90, PgVarcharBuilder2, _a112, _b91, PgVarchar2, init_varchar2, _a113, _b92, PgBinaryVectorBuilder2, _a114, _b93, PgBinaryVector2, init_bit2, _a115, _b94, PgHalfVectorBuilder2, _a116, _b95, PgHalfVector2, init_halfvec2, _a117, _b96, PgSparseVectorBuilder2, _a118, _b97, PgSparseVector2, init_sparsevec2, _a119, _b98, PgVectorBuilder2, _a120, _b99, PgVector2, init_vector3, init_all2, InlineForeignKeys2, EnableRLS2, _a121, _b100, _c3, _d2, _e22, _f2, PgTable2, pgTable2, init_table22, _a122, PrimaryKeyBuilder2, _a123, PrimaryKey2, init_primary_keys2, eq2, ne3, gt3, gte2, lt3, lte2, init_conditions2, init_select3, init_expressions2, _a124, Relation2, _a125, Relations2, _a126, _b101, _One, One2, _a127, _b102, _Many, Many2, init_relations2, init_aggregate2, init_vector22, init_functions2, init_sql22, dist_exports, init_dist5, init_alias22, _a128, CheckBuilder, _a129, Check, init_checks2, init_columns2, _a130, _SelectionProxyHandler, SelectionProxyHandler2, init_selection_proxy2, _a131, IndexBuilderOn2, _a132, IndexBuilder2, _a133, Index2, init_indexes2, _a134, PgPolicy, init_policies2, PgViewConfig2, init_view_common22, _a135, CasingCache2, init_casing2, _a136, _b103, PgViewBase2, init_view_base2, _a137, PgDialect2, init_dialect2, _a138, TypedQueryBuilder2, init_query_builder3, _a139, PgSelectBuilder2, _a140, _b104, PgSelectQueryBuilderBase2, _a141, _b105, PgSelectBase2, getPgSetOperators2, union2, unionAll2, intersect2, intersectAll2, except2, exceptAll2, init_select22, _a142, QueryBuilder2, init_query_builder22, _a143, DefaultViewBuilderCore, _a144, _b106, ViewBuilder, _a145, _b107, ManualViewBuilder, _a146, MaterializedViewBuilderCore, _a147, _b108, MaterializedViewBuilder, _a148, _b109, ManualMaterializedViewBuilder, _a149, _b110, _c4, PgView2, PgMaterializedViewConfig2, _a150, _b111, _c5, PgMaterializedView, init_view2, init_utils42, _a151, _b112, PgDeleteBase2, init_delete2, _a152, PgInsertBuilder2, _a153, _b113, PgInsertBase2, init_insert2, _a154, _b114, PgRefreshMaterializedView2, init_refresh_materialized_view2, init_select_types, _a155, PgUpdateBuilder2, _a156, _b115, PgUpdateBase2, init_update2, init_query_builders2, _a157, _b116, _c6, _PgCountBuilder, PgCountBuilder2, init_count2, _a158, RelationalQueryBuilder2, _a159, _b117, PgRelationalQuery2, init_query2, _a160, _b118, PgRaw2, init_raw2, _a161, PgDatabase2, init_db2, _a162, PgRole, init_roles2, _a163, PgSequence, init_sequence2, _a164, PgSchema5, init_schema3, _a165, Cache, _a166, _b119, NoopCache, init_cache, _a167, PgPreparedQuery2, _a168, PgSession2, _a169, _b120, PgTransaction2, init_session3, init_subquery22, init_utils52, init_pg_core2, vectorOps, init_vector32, sqlToStr, init_utils6, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn, getColumnsInfoQuery, init_pgSerializer, import_hanji4, Select, init_selector_ui, init_alias32, _a170, CheckBuilder2, _a171, Check2, init_checks22, _a172, ForeignKeyBuilder22, _a173, ForeignKey22, init_foreign_keys22, _a174, UniqueConstraintBuilder2, _a175, UniqueOnConstraintBuilder2, _a176, UniqueConstraint2, init_unique_constraint22, _a177, _b121, SQLiteColumnBuilder, _a178, _b122, SQLiteColumn, init_common3, _a179, _b123, SQLiteBigIntBuilder, _a180, _b124, SQLiteBigInt, _a181, _b125, SQLiteBlobJsonBuilder, _a182, _b126, SQLiteBlobJson, _a183, _b127, SQLiteBlobBufferBuilder, _a184, _b128, SQLiteBlobBuffer, init_blob, _a185, _b129, SQLiteCustomColumnBuilder, _a186, _b130, SQLiteCustomColumn, init_custom22, _a187, _b131, SQLiteBaseIntegerBuilder, _a188, _b132, SQLiteBaseInteger, _a189, _b133, SQLiteIntegerBuilder, _a190, _b134, SQLiteInteger, _a191, _b135, SQLiteTimestampBuilder, _a192, _b136, SQLiteTimestamp, _a193, _b137, SQLiteBooleanBuilder, _a194, _b138, SQLiteBoolean, init_integer22, _a195, _b139, SQLiteNumericBuilder, _a196, _b140, SQLiteNumeric, _a197, _b141, SQLiteNumericNumberBuilder, _a198, _b142, SQLiteNumericNumber, _a199, _b143, SQLiteNumericBigIntBuilder, _a200, _b144, SQLiteNumericBigInt, init_numeric22, _a201, _b145, SQLiteRealBuilder, _a202, _b146, SQLiteReal, init_real22, _a203, _b147, SQLiteTextBuilder, _a204, _b148, SQLiteText, _a205, _b149, SQLiteTextJsonBuilder, _a206, _b150, SQLiteTextJson, init_text22, init_columns22, init_all22, InlineForeignKeys22, _a207, _b151, _c7, _d3, _e3, SQLiteTable, sqliteTable, init_table32, _a208, IndexBuilderOn22, _a209, IndexBuilder22, _a210, Index4, init_indexes22, _a211, PrimaryKeyBuilder22, _a212, PrimaryKey22, init_primary_keys22, init_utils7, _a213, _b152, SQLiteDeleteBase, init_delete22, _a214, _b153, SQLiteViewBase, init_view_base22, _a215, SQLiteDialect, _a216, _b154, SQLiteSyncDialect, _a217, _b155, SQLiteAsyncDialect, init_dialect22, _a218, SQLiteSelectBuilder, _a219, _b156, SQLiteSelectQueryBuilderBase, _a220, _b157, SQLiteSelectBase, getSQLiteSetOperators, union3, unionAll22, intersect22, except22, init_select32, _a221, QueryBuilder22, init_query_builder32, _a222, SQLiteInsertBuilder, _a223, _b158, SQLiteInsertBase, init_insert22, init_select_types2, _a224, SQLiteUpdateBuilder, _a225, _b159, SQLiteUpdateBase, init_update22, init_query_builders22, _a226, _b160, _c8, _SQLiteCountBuilder, SQLiteCountBuilder, init_count22, _a227, RelationalQueryBuilder22, _a228, _b161, SQLiteRelationalQuery, _a229, _b162, SQLiteSyncRelationalQuery, init_query22, _a230, _b163, SQLiteRaw, init_raw22, _a231, BaseSQLiteDatabase, init_db22, _a232, _b164, ExecuteResultSync, _a233, SQLitePreparedQuery, _a234, SQLiteSession, _a235, _b165, SQLiteTransaction, init_session22, init_subquery3, _a236, ViewBuilderCore, _a237, _b166, ViewBuilder2, _a238, _b167, ManualViewBuilder2, _a239, _b168, SQLiteView2, init_view22, init_sqlite_core, generateSqliteSnapshot, fromDatabase2, init_sqliteSerializer, getTablesFilterByExtensions, init_getTablesFilterByExtensions, init_alias4, _a240, CheckBuilder3, _a241, Check3, init_checks3, _a242, ForeignKeyBuilder3, _a243, ForeignKey3, init_foreign_keys3, _a244, UniqueConstraintBuilder3, _a245, UniqueOnConstraintBuilder3, _a246, UniqueConstraint3, init_unique_constraint3, _a247, _b169, MySqlColumnBuilder, _a248, _b170, MySqlColumn, _a249, _b171, MySqlColumnBuilderWithAutoIncrement, _a250, _b172, MySqlColumnWithAutoIncrement, init_common4, _a251, _b173, MySqlBigInt53Builder, _a252, _b174, MySqlBigInt53, _a253, _b175, MySqlBigInt64Builder, _a254, _b176, MySqlBigInt64, init_bigint22, _a255, _b177, MySqlBinaryBuilder, _a256, _b178, MySqlBinary, init_binary, _a257, _b179, MySqlBooleanBuilder, _a258, _b180, MySqlBoolean, init_boolean22, _a259, _b181, MySqlCharBuilder, _a260, _b182, MySqlChar, init_char22, _a261, _b183, MySqlCustomColumnBuilder, _a262, _b184, MySqlCustomColumn, init_custom3, _a263, _b185, MySqlDateBuilder, _a264, _b186, MySqlDate, _a265, _b187, MySqlDateStringBuilder, _a266, _b188, MySqlDateString, init_date22, _a267, _b189, MySqlDateTimeBuilder, _a268, _b190, MySqlDateTime, _a269, _b191, MySqlDateTimeStringBuilder, _a270, _b192, MySqlDateTimeString, init_datetime, _a271, _b193, MySqlDecimalBuilder, _a272, _b194, MySqlDecimal, _a273, _b195, MySqlDecimalNumberBuilder, _a274, _b196, MySqlDecimalNumber, _a275, _b197, MySqlDecimalBigIntBuilder, _a276, _b198, MySqlDecimalBigInt, init_decimal, _a277, _b199, MySqlDoubleBuilder, _a278, _b200, MySqlDouble, init_double, _a279, _b201, MySqlEnumColumnBuilder, _a280, _b202, MySqlEnumColumn, _a281, _b203, MySqlEnumObjectColumnBuilder, _a282, _b204, MySqlEnumObjectColumn, init_enum22, _a283, _b205, MySqlFloatBuilder, _a284, _b206, MySqlFloat, init_float, _a285, _b207, MySqlIntBuilder, _a286, _b208, MySqlInt, init_int, _a287, _b209, MySqlJsonBuilder, _a288, _b210, MySqlJson, init_json22, _a289, _b211, MySqlMediumIntBuilder, _a290, _b212, MySqlMediumInt, init_mediumint, _a291, _b213, MySqlRealBuilder, _a292, _b214, MySqlReal, init_real3, _a293, _b215, MySqlSerialBuilder, _a294, _b216, MySqlSerial, init_serial22, _a295, _b217, MySqlSmallIntBuilder, _a296, _b218, MySqlSmallInt, init_smallint22, _a297, _b219, MySqlTextBuilder, _a298, _b220, MySqlText, init_text3, _a299, _b221, MySqlTimeBuilder, _a300, _b222, MySqlTime, init_time22, _a301, _b223, MySqlDateColumnBaseBuilder, _a302, _b224, MySqlDateBaseColumn, init_date_common22, _a303, _b225, MySqlTimestampBuilder, _a304, _b226, MySqlTimestamp, _a305, _b227, MySqlTimestampStringBuilder, _a306, _b228, MySqlTimestampString, init_timestamp22, _a307, _b229, MySqlTinyIntBuilder, _a308, _b230, MySqlTinyInt, init_tinyint, _a309, _b231, MySqlVarBinaryBuilder, _a310, _b232, MySqlVarBinary, init_varbinary, _a311, _b233, MySqlVarCharBuilder, _a312, _b234, MySqlVarChar, init_varchar22, _a313, _b235, MySqlYearBuilder, _a314, _b236, MySqlYear, init_year, init_columns3, _a315, _b237, _c9, _MySqlCountBuilder, MySqlCountBuilder, init_count3, _a316, IndexBuilderOn3, _a317, IndexBuilder3, _a318, Index5, init_indexes3, init_all3, InlineForeignKeys3, _a319, _b238, _c10, _d4, _e4, MySqlTable, mysqlTable, init_table42, _a320, PrimaryKeyBuilder3, _a321, PrimaryKey3, init_primary_keys3, MySqlViewConfig, init_view_common32, init_utils8, _a322, _b239, MySqlDeleteBase, init_delete3, _a323, _b240, MySqlViewBase, init_view_base3, _a324, MySqlDialect, init_dialect3, _a325, MySqlSelectBuilder, _a326, _b241, MySqlSelectQueryBuilderBase, _a327, _b242, MySqlSelectBase, getMySqlSetOperators, union4, unionAll3, intersect3, intersectAll22, except3, exceptAll22, init_select4, _a328, QueryBuilder3, init_query_builder4, _a329, MySqlInsertBuilder, _a330, _b243, MySqlInsertBase, init_insert3, init_select_types3, _a331, MySqlUpdateBuilder, _a332, _b244, MySqlUpdateBase, init_update3, init_query_builders3, _a333, RelationalQueryBuilder3, _a334, _b245, MySqlRelationalQuery, init_query3, _a335, MySqlDatabase, init_db3, _a336, ViewBuilderCore2, _a337, _b246, ViewBuilder3, _a338, _b247, ManualViewBuilder3, _a339, _b248, _c11, MySqlView2, init_view3, _a340, MySqlSchema5, init_schema22, _a341, MySqlPreparedQuery, _a342, MySqlSession, _a343, _b249, MySqlTransaction, init_session32, init_subquery4, init_mysql_core, handleEnumType, generateMySqlSnapshot, fromDatabase3, init_mysqlSerializer, cliConfigGenerate, pushParams, pullParams, configCheck, cliConfigCheck, init_cli, gelCredentials, init_gel, libSQLCredentials, init_libsql, mysqlCredentials, init_mysql, postgresCredentials, init_postgres, singlestoreCredentials, init_singlestore, sqliteCredentials, init_sqlite, credentials, studioCliParams, studioConfig, init_studio, es5_exports, _3, es5_default, init_es5, import_hanji7, assertES5, safeRegister, migrateConfig, init_utils9, prepareFromExports, init_pgImports, init_alias5, _a344, UniqueConstraintBuilder4, _a345, UniqueOnConstraintBuilder4, _a346, UniqueConstraint4, init_unique_constraint4, _a347, _b250, SingleStoreColumnBuilder, _a348, _b251, SingleStoreColumn, _a349, _b252, SingleStoreColumnBuilderWithAutoIncrement, _a350, _b253, SingleStoreColumnWithAutoIncrement, init_common5, _a351, _b254, SingleStoreBigInt53Builder, _a352, _b255, SingleStoreBigInt53, _a353, _b256, SingleStoreBigInt64Builder, _a354, _b257, SingleStoreBigInt64, init_bigint3, _a355, _b258, SingleStoreBinaryBuilder, _a356, _b259, SingleStoreBinary, init_binary2, _a357, _b260, SingleStoreBooleanBuilder, _a358, _b261, SingleStoreBoolean, init_boolean3, _a359, _b262, SingleStoreCharBuilder, _a360, _b263, SingleStoreChar, init_char3, _a361, _b264, SingleStoreCustomColumnBuilder, _a362, _b265, SingleStoreCustomColumn, init_custom4, _a363, _b266, SingleStoreDateBuilder, _a364, _b267, SingleStoreDate, _a365, _b268, SingleStoreDateStringBuilder, _a366, _b269, SingleStoreDateString, init_date3, _a367, _b270, SingleStoreDateTimeBuilder, _a368, _b271, SingleStoreDateTime, _a369, _b272, SingleStoreDateTimeStringBuilder, _a370, _b273, SingleStoreDateTimeString, init_datetime2, _a371, _b274, SingleStoreDecimalBuilder, _a372, _b275, SingleStoreDecimal, _a373, _b276, SingleStoreDecimalNumberBuilder, _a374, _b277, SingleStoreDecimalNumber, _a375, _b278, SingleStoreDecimalBigIntBuilder, _a376, _b279, SingleStoreDecimalBigInt, init_decimal2, _a377, _b280, SingleStoreDoubleBuilder, _a378, _b281, SingleStoreDouble, init_double2, _a379, _b282, SingleStoreEnumColumnBuilder, _a380, _b283, SingleStoreEnumColumn, init_enum3, _a381, _b284, SingleStoreFloatBuilder, _a382, _b285, SingleStoreFloat, init_float2, _a383, _b286, SingleStoreIntBuilder, _a384, _b287, SingleStoreInt, init_int2, _a385, _b288, SingleStoreJsonBuilder, _a386, _b289, SingleStoreJson, init_json3, _a387, _b290, SingleStoreMediumIntBuilder, _a388, _b291, SingleStoreMediumInt, init_mediumint2, _a389, _b292, SingleStoreRealBuilder, _a390, _b293, SingleStoreReal, init_real4, _a391, _b294, SingleStoreSerialBuilder, _a392, _b295, SingleStoreSerial, init_serial3, _a393, _b296, SingleStoreSmallIntBuilder, _a394, _b297, SingleStoreSmallInt, init_smallint3, _a395, _b298, SingleStoreTextBuilder, _a396, _b299, SingleStoreText, init_text4, _a397, _b300, SingleStoreTimeBuilder, _a398, _b301, SingleStoreTime, init_time3, _a399, _b302, SingleStoreDateColumnBaseBuilder, _a400, _b303, SingleStoreDateBaseColumn, init_date_common3, _a401, _b304, SingleStoreTimestampBuilder, _a402, _b305, SingleStoreTimestamp, _a403, _b306, SingleStoreTimestampStringBuilder, _a404, _b307, SingleStoreTimestampString, init_timestamp3, _a405, _b308, SingleStoreTinyIntBuilder, _a406, _b309, SingleStoreTinyInt, init_tinyint2, _a407, _b310, SingleStoreVarBinaryBuilder, _a408, _b311, SingleStoreVarBinary, init_varbinary2, _a409, _b312, SingleStoreVarCharBuilder, _a410, _b313, SingleStoreVarChar, init_varchar3, _a411, _b314, SingleStoreVectorBuilder, _a412, _b315, SingleStoreVector, init_vector4, _a413, _b316, SingleStoreYearBuilder, _a414, _b317, SingleStoreYear, init_year2, init_columns4, _a415, _b318, _c12, _SingleStoreCountBuilder, SingleStoreCountBuilder, init_count4, _a416, IndexBuilderOn4, _a417, IndexBuilder4, _a418, Index6, init_indexes4, init_all4, _a419, _b319, _c13, _d5, SingleStoreTable, init_table52, _a420, PrimaryKeyBuilder4, _a421, PrimaryKey4, init_primary_keys4, init_utils10, _a422, _b320, SingleStoreDeleteBase, init_delete4, _a423, SingleStoreInsertBuilder, _a424, _b321, SingleStoreInsertBase, init_insert4, _a425, SingleStoreDialect, init_dialect4, _a426, SingleStoreSelectBuilder, _a427, _b322, SingleStoreSelectQueryBuilderBase, _a428, _b323, SingleStoreSelectBase, getSingleStoreSetOperators, union5, unionAll4, intersect4, except4, minus, init_select5, _a429, QueryBuilder4, init_query_builder5, init_select_types4, _a430, SingleStoreUpdateBuilder, _a431, _b324, SingleStoreUpdateBase, init_update4, init_query_builders4, _a432, SingleStoreDatabase, init_db4, _a433, SingleStoreSchema5, init_schema32, _a434, SingleStorePreparedQuery, _a435, SingleStoreSession, _a436, _b325, SingleStoreTransaction, init_session4, init_subquery5, init_singlestore_core, dialect5, generateSingleStoreSnapshot, fromDatabase4, init_singlestoreSerializer, sqliteImports_exports, prepareFromExports2, prepareFromSqliteImports, init_sqliteImports, mysqlImports_exports, prepareFromExports3, prepareFromMySqlImports, init_mysqlImports, mysqlPushUtils_exports, import_hanji8, filterStatements, logSuggestionsAndReturn2, init_mysqlPushUtils, mysqlIntrospect_exports, import_hanji9, mysqlPushIntrospect, init_mysqlIntrospect, singlestoreImports_exports, prepareFromExports4, prepareFromSingleStoreImports, init_singlestoreImports, singlestorePushUtils_exports, import_hanji10, filterStatements2, logSuggestionsAndReturn3, init_singlestorePushUtils, singlestoreIntrospect_exports, import_hanji11, singlestorePushIntrospect, init_singlestoreIntrospect, import_hanji3, pgPushIntrospect = async (db2, filters, schemaFilters, entities, tsSchema) => {
38401
37214
  const matchers = filters.map((it2) => {
38402
37215
  return new Minimatch(it2);
38403
37216
  });
@@ -38654,7 +37467,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
38654
37467
  return { schema: schema5 };
38655
37468
  }, generateDrizzleJson = (imports, prevId, schemaFilters, casing2) => {
38656
37469
  const prepared = prepareFromExports(imports);
38657
- const id = randomUUID2();
37470
+ const id = randomUUID();
38658
37471
  const snapshot = generatePgSnapshot(prepared.tables, prepared.enums, prepared.schemas, prepared.sequences, prepared.roles, prepared.policies, prepared.views, prepared.matViews, casing2, schemaFilters);
38659
37472
  return fillPgSnapshot({
38660
37473
  serialized: snapshot,
@@ -38700,7 +37513,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
38700
37513
  }, generateSQLiteDrizzleJson = async (imports, prevId, casing2) => {
38701
37514
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_sqliteImports(), sqliteImports_exports));
38702
37515
  const prepared = prepareFromExports5(imports);
38703
- const id = randomUUID2();
37516
+ const id = randomUUID();
38704
37517
  const snapshot = generateSqliteSnapshot(prepared.tables, prepared.views, casing2);
38705
37518
  return {
38706
37519
  ...snapshot,
@@ -38748,7 +37561,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
38748
37561
  }, generateMySQLDrizzleJson = async (imports, prevId, casing2) => {
38749
37562
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_mysqlImports(), mysqlImports_exports));
38750
37563
  const prepared = prepareFromExports5(imports);
38751
- const id = randomUUID2();
37564
+ const id = randomUUID();
38752
37565
  const snapshot = generateMySqlSnapshot(prepared.tables, prepared.views, casing2);
38753
37566
  return {
38754
37567
  ...snapshot,
@@ -38795,7 +37608,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
38795
37608
  }, generateSingleStoreDrizzleJson = async (imports, prevId, casing2) => {
38796
37609
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_singlestoreImports(), singlestoreImports_exports));
38797
37610
  const prepared = prepareFromExports5(imports);
38798
- const id = randomUUID2();
37611
+ const id = randomUUID();
38799
37612
  const snapshot = generateSingleStoreSnapshot(prepared.tables, casing2);
38800
37613
  return {
38801
37614
  ...snapshot,
@@ -45582,7 +44395,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
45582
44395
  init_external2();
45583
44396
  }
45584
44397
  });
45585
- init_esm3 = __esm3({
44398
+ init_esm2 = __esm3({
45586
44399
  "../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/index.js"() {
45587
44400
  init_v32();
45588
44401
  init_v32();
@@ -45591,7 +44404,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
45591
44404
  init_gelSchema = __esm3({
45592
44405
  "src/serializer/gelSchema.ts"() {
45593
44406
  init_global2();
45594
- init_esm3();
44407
+ init_esm2();
45595
44408
  enumSchema = objectType2({
45596
44409
  name: stringType2(),
45597
44410
  schema: stringType2(),
@@ -45845,7 +44658,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
45845
44658
  });
45846
44659
  init_mysqlSchema = __esm3({
45847
44660
  "src/serializer/mysqlSchema.ts"() {
45848
- init_esm3();
44661
+ init_esm2();
45849
44662
  init_global2();
45850
44663
  index22 = objectType2({
45851
44664
  name: stringType2(),
@@ -46151,7 +44964,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
46151
44964
  init_pgSchema = __esm3({
46152
44965
  "src/serializer/pgSchema.ts"() {
46153
44966
  init_global2();
46154
- init_esm3();
44967
+ init_esm2();
46155
44968
  indexV2 = objectType2({
46156
44969
  name: stringType2(),
46157
44970
  columns: recordType2(stringType2(), objectType2({
@@ -46872,7 +45685,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
46872
45685
  });
46873
45686
  init_singlestoreSchema = __esm3({
46874
45687
  "src/serializer/singlestoreSchema.ts"() {
46875
- init_esm3();
45688
+ init_esm2();
46876
45689
  init_global2();
46877
45690
  index4 = objectType2({
46878
45691
  name: stringType2(),
@@ -47031,7 +45844,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
47031
45844
  });
47032
45845
  init_sqliteSchema = __esm3({
47033
45846
  "src/serializer/sqliteSchema.ts"() {
47034
- init_esm3();
45847
+ init_esm2();
47035
45848
  init_global2();
47036
45849
  index5 = objectType2({
47037
45850
  name: stringType2(),
@@ -54709,7 +53522,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
54709
53522
  });
54710
53523
  init_snapshotsDiffer = __esm3({
54711
53524
  "src/snapshotsDiffer.ts"() {
54712
- init_esm3();
53525
+ init_esm2();
54713
53526
  init_jsonDiffer();
54714
53527
  init_sqlgenerator();
54715
53528
  init_jsonStatements();
@@ -56820,7 +55633,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
56820
55633
  });
56821
55634
  init_schemaValidator = __esm3({
56822
55635
  "src/schemaValidator.ts"() {
56823
- init_esm3();
55636
+ init_esm2();
56824
55637
  init_mysqlSchema();
56825
55638
  init_pgSchema();
56826
55639
  init_singlestoreSchema();
@@ -56838,7 +55651,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
56838
55651
  });
56839
55652
  init_common2 = __esm3({
56840
55653
  "src/cli/validations/common.ts"() {
56841
- init_esm3();
55654
+ init_esm2();
56842
55655
  init_schemaValidator();
56843
55656
  init_outputs();
56844
55657
  sqliteDriversLiterals = [
@@ -72040,7 +70853,7 @@ AND
72040
70853
  });
72041
70854
  init_cli = __esm3({
72042
70855
  "src/cli/validations/cli.ts"() {
72043
- init_esm3();
70856
+ init_esm2();
72044
70857
  init_schemaValidator();
72045
70858
  init_common2();
72046
70859
  cliConfigGenerate = objectType2({
@@ -72101,7 +70914,7 @@ AND
72101
70914
  });
72102
70915
  init_gel = __esm3({
72103
70916
  "src/cli/validations/gel.ts"() {
72104
- init_esm3();
70917
+ init_esm2();
72105
70918
  init_views();
72106
70919
  init_common2();
72107
70920
  gelCredentials = unionType2([
@@ -72145,7 +70958,7 @@ AND
72145
70958
  });
72146
70959
  init_libsql = __esm3({
72147
70960
  "src/cli/validations/libsql.ts"() {
72148
- init_esm3();
70961
+ init_esm2();
72149
70962
  init_views();
72150
70963
  init_common2();
72151
70964
  libSQLCredentials = objectType2({
@@ -72156,7 +70969,7 @@ AND
72156
70969
  });
72157
70970
  init_mysql = __esm3({
72158
70971
  "src/cli/validations/mysql.ts"() {
72159
- init_esm3();
70972
+ init_esm2();
72160
70973
  init_views();
72161
70974
  init_common2();
72162
70975
  init_outputs();
@@ -72189,7 +71002,7 @@ AND
72189
71002
  });
72190
71003
  init_postgres = __esm3({
72191
71004
  "src/cli/validations/postgres.ts"() {
72192
- init_esm3();
71005
+ init_esm2();
72193
71006
  init_views();
72194
71007
  init_common2();
72195
71008
  postgresCredentials = unionType2([
@@ -72234,7 +71047,7 @@ AND
72234
71047
  });
72235
71048
  init_singlestore = __esm3({
72236
71049
  "src/cli/validations/singlestore.ts"() {
72237
- init_esm3();
71050
+ init_esm2();
72238
71051
  init_views();
72239
71052
  init_common2();
72240
71053
  init_outputs();
@@ -72268,7 +71081,7 @@ AND
72268
71081
  init_sqlite = __esm3({
72269
71082
  "src/cli/validations/sqlite.ts"() {
72270
71083
  init_global2();
72271
- init_esm3();
71084
+ init_esm2();
72272
71085
  init_views();
72273
71086
  init_common2();
72274
71087
  sqliteCredentials = unionType2([
@@ -72295,7 +71108,7 @@ AND
72295
71108
  });
72296
71109
  init_studio = __esm3({
72297
71110
  "src/cli/validations/studio.ts"() {
72298
- init_esm3();
71111
+ init_esm2();
72299
71112
  init_schemaValidator();
72300
71113
  init_common2();
72301
71114
  init_mysql();
@@ -72327,7 +71140,7 @@ AND
72327
71140
  init_utils9 = __esm3({
72328
71141
  "src/cli/commands/utils.ts"() {
72329
71142
  import_hanji7 = __toESM2(require_hanji());
72330
- init_esm3();
71143
+ init_esm2();
72331
71144
  init_getTablesFilterByExtensions();
72332
71145
  init_global2();
72333
71146
  init_schemaValidator();
@@ -76228,8 +75041,8 @@ var init_currencies = __esm(() => {
76228
75041
  });
76229
75042
 
76230
75043
  // src/lib/logging/adapter.ts
76231
- function setLogger(logger32) {
76232
- customLogger = logger32;
75044
+ function setLogger(logger31) {
75045
+ customLogger = logger31;
76233
75046
  }
76234
75047
  function getLogger() {
76235
75048
  if (customLogger) {
@@ -76241,10 +75054,10 @@ function getLogger() {
76241
75054
  error: (msg) => console.error(msg)
76242
75055
  };
76243
75056
  }
76244
- var customLogger, logger32;
75057
+ var customLogger, logger31;
76245
75058
  var init_adapter = __esm(() => {
76246
75059
  init_config();
76247
- logger32 = {
75060
+ logger31 = {
76248
75061
  info: (msg) => {
76249
75062
  if (customLogger || !config.embedded) {
76250
75063
  getLogger().info(msg);
@@ -76331,7 +75144,7 @@ async function seedCoreGames(db2) {
76331
75144
  try {
76332
75145
  await db2.insert(games).values(gameData).onConflictDoNothing();
76333
75146
  } catch (error2) {
76334
- logger32.error(`Error seeding core game '${gameData.slug}': ${error2}`);
75147
+ logger31.error(`Error seeding core game '${gameData.slug}': ${error2}`);
76335
75148
  }
76336
75149
  }
76337
75150
  }
@@ -76372,7 +75185,7 @@ async function seedCurrentProjectGame(db2, project) {
76372
75185
  }
76373
75186
  return newGame;
76374
75187
  } catch (error2) {
76375
- logger32.error(`❌ Error seeding project game: ${error2}`);
75188
+ logger31.error(`❌ Error seeding project game: ${error2}`);
76376
75189
  throw error2;
76377
75190
  }
76378
75191
  }
@@ -77782,6 +76595,142 @@ var init_auth_util = __esm(() => {
77782
76595
  init_types9();
77783
76596
  });
77784
76597
 
76598
+ // ../api-core/src/utils/lti.util.ts
76599
+ function generateUsername(email) {
76600
+ const baseUsername = (email.split("@")[0] || "user").toLowerCase();
76601
+ const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
76602
+ const randomSuffix = Math.random().toString(36).substring(2, 7);
76603
+ return `${cleanUsername}_${randomSuffix}`;
76604
+ }
76605
+ function extractRedirectPath(targetUri, currentHost) {
76606
+ try {
76607
+ const targetUrl = new URL(targetUri);
76608
+ if (targetUrl.hostname === currentHost) {
76609
+ return targetUrl.pathname + targetUrl.search;
76610
+ }
76611
+ } catch {}
76612
+ return "/";
76613
+ }
76614
+ function validateLtiClaims(claims) {
76615
+ const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
76616
+ const version4 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
76617
+ if (messageType !== "LtiResourceLinkRequest") {
76618
+ return `Invalid LTI message type: ${messageType}`;
76619
+ }
76620
+ if (version4 !== "1.3.0") {
76621
+ return `Unsupported LTI version: ${version4}`;
76622
+ }
76623
+ return null;
76624
+ }
76625
+ var init_lti_util = () => {};
76626
+
76627
+ // ../api-core/src/utils/lti-provisioning.ts
76628
+ import * as crypto4 from "node:crypto";
76629
+ async function provisionLtiUser(db2, claims) {
76630
+ const database2 = db2;
76631
+ const email = claims.email;
76632
+ const ltiTimebackId = claims.sub;
76633
+ const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
76634
+ if (!email) {
76635
+ throw new ValidationError("Email is required in LTI claims");
76636
+ }
76637
+ const existingAccount = await database2.query.accounts.findFirst({
76638
+ where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
76639
+ });
76640
+ if (existingAccount) {
76641
+ const user = await database2.query.users.findFirst({
76642
+ where: eq(users.id, existingAccount.userId)
76643
+ });
76644
+ if (user) {
76645
+ logger32.info("Found user by LTI account", {
76646
+ userId: user.id,
76647
+ ltiTimebackId
76648
+ });
76649
+ return user;
76650
+ }
76651
+ }
76652
+ const existingUser = await database2.query.users.findFirst({
76653
+ where: eq(users.email, email)
76654
+ });
76655
+ if (existingUser) {
76656
+ await database2.transaction(async (tx) => {
76657
+ const existingLtiAccount = await tx.query.accounts.findFirst({
76658
+ where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
76659
+ });
76660
+ if (!existingLtiAccount) {
76661
+ const [account] = await tx.insert(accounts).values({
76662
+ id: crypto4.randomUUID(),
76663
+ userId: existingUser.id,
76664
+ accountId: ltiTimebackId,
76665
+ providerId,
76666
+ accessToken: null,
76667
+ refreshToken: null,
76668
+ accessTokenExpiresAt: null,
76669
+ refreshTokenExpiresAt: null,
76670
+ createdAt: new Date,
76671
+ updatedAt: new Date
76672
+ }).returning({ id: accounts.id });
76673
+ if (!account) {
76674
+ logger32.error("LTI account link insert returned no rows", {
76675
+ userId: existingUser.id,
76676
+ ltiTimebackId
76677
+ });
76678
+ throw new InternalError("Failed to link LTI account");
76679
+ }
76680
+ logger32.info("Linked LTI account to existing user", {
76681
+ userId: existingUser.id,
76682
+ ltiTimebackId
76683
+ });
76684
+ }
76685
+ });
76686
+ return existingUser;
76687
+ }
76688
+ const newUserId = crypto4.randomUUID();
76689
+ const createdUser = await database2.transaction(async (tx) => {
76690
+ const [insertedUser] = await tx.insert(users).values({
76691
+ id: newUserId,
76692
+ email,
76693
+ emailVerified: true,
76694
+ username: generateUsername(email),
76695
+ name: claims.name || claims.given_name || email.split("@")[0] || "Timeback User",
76696
+ createdAt: new Date,
76697
+ updatedAt: new Date
76698
+ }).returning();
76699
+ if (!insertedUser) {
76700
+ logger32.error("LTI user insert returned no rows", { email, ltiTimebackId });
76701
+ throw new InternalError("Failed to create user");
76702
+ }
76703
+ await tx.insert(accounts).values({
76704
+ id: crypto4.randomUUID(),
76705
+ userId: newUserId,
76706
+ accountId: ltiTimebackId,
76707
+ providerId,
76708
+ accessToken: null,
76709
+ refreshToken: null,
76710
+ accessTokenExpiresAt: null,
76711
+ refreshTokenExpiresAt: null,
76712
+ createdAt: new Date,
76713
+ updatedAt: new Date
76714
+ });
76715
+ logger32.info("Provisioned new user from LTI", {
76716
+ userId: insertedUser.id,
76717
+ ltiTimebackId
76718
+ });
76719
+ return insertedUser;
76720
+ });
76721
+ return createdUser;
76722
+ }
76723
+ var logger32;
76724
+ var init_lti_provisioning = __esm(() => {
76725
+ init_drizzle_orm();
76726
+ init_src();
76727
+ init_tables_index();
76728
+ init_src2();
76729
+ init_errors();
76730
+ init_lti_util();
76731
+ logger32 = log.scope("LtiProvisioning");
76732
+ });
76733
+
77785
76734
  // ../api-core/src/utils/validation.util.ts
77786
76735
  function formatZodError(error2) {
77787
76736
  const flat = error2.flatten();
@@ -77806,6 +76755,7 @@ var init_utils11 = __esm(() => {
77806
76755
  init_deployment_util();
77807
76756
  init_leaderboard_util();
77808
76757
  init_lti_util();
76758
+ init_lti_provisioning();
77809
76759
  init_scope_util();
77810
76760
  init_timeback_util();
77811
76761
  });
@@ -87964,20 +86914,9 @@ var init_logs_controller = __esm(() => {
87964
86914
  });
87965
86915
 
87966
86916
  // ../api-core/src/controllers/lti.controller.ts
87967
- async function launch(ctx) {
87968
- const formData = await ctx.request.formData();
87969
- const idToken = formData.get("id_token");
87970
- if (!idToken || typeof idToken !== "string") {
87971
- throw ApiError.badRequest("Missing or invalid id_token");
87972
- }
87973
- const currentHost = ctx.url.hostname;
87974
- logger48.debug("Processing launch", { host: currentHost });
87975
- return ctx.services.lti.processLaunch(idToken, currentHost);
87976
- }
87977
86917
  var logger48, getStatus3, lti;
87978
86918
  var init_lti_controller = __esm(() => {
87979
86919
  init_src2();
87980
- init_errors();
87981
86920
  init_utils11();
87982
86921
  logger48 = log.scope("LtiController");
87983
86922
  getStatus3 = requireAuth(async (ctx) => {
@@ -87985,7 +86924,6 @@ var init_lti_controller = __esm(() => {
87985
86924
  return ctx.services.lti.getStatus(ctx.user);
87986
86925
  });
87987
86926
  lti = {
87988
- launch,
87989
86927
  getStatus: getStatus3
87990
86928
  };
87991
86929
  });
@@ -88217,7 +87155,7 @@ var init_realtime_controller = __esm(() => {
88217
87155
  });
88218
87156
 
88219
87157
  // ../api-core/src/controllers/secrets.controller.ts
88220
- var logger52, listKeys, getValues, setSecrets, deleteSecret, secrets;
87158
+ var logger52, listKeys, setSecrets, deleteSecret, secrets;
88221
87159
  var init_secrets_controller = __esm(() => {
88222
87160
  init_esm();
88223
87161
  init_schemas_index();
@@ -88234,15 +87172,6 @@ var init_secrets_controller = __esm(() => {
88234
87172
  const keys = await ctx.services.secrets.listKeys(slug2, ctx.user);
88235
87173
  return { keys };
88236
87174
  });
88237
- getValues = requireDeveloper(async (ctx) => {
88238
- const slug2 = ctx.params.slug;
88239
- if (!slug2) {
88240
- throw ApiError.badRequest("Missing game slug");
88241
- }
88242
- logger52.debug("Getting secret values", { userId: ctx.user.id, slug: slug2 });
88243
- const secrets = await ctx.services.secrets.getValues(slug2, ctx.user);
88244
- return { secrets };
88245
- });
88246
87175
  setSecrets = requireDeveloper(async (ctx) => {
88247
87176
  const slug2 = ctx.params.slug;
88248
87177
  if (!slug2) {
@@ -88283,7 +87212,6 @@ var init_secrets_controller = __esm(() => {
88283
87212
  });
88284
87213
  secrets = {
88285
87214
  listKeys,
88286
- getValues,
88287
87215
  setSecrets,
88288
87216
  deleteSecret
88289
87217
  };
@@ -89383,7 +88311,6 @@ var init_secrets = __esm(() => {
89383
88311
  init_api();
89384
88312
  gameSecretsRouter = new Hono2;
89385
88313
  gameSecretsRouter.get("/:slug/secrets", handle2(secrets.listKeys));
89386
- gameSecretsRouter.get("/:slug/secrets/values", handle2(secrets.getValues));
89387
88314
  gameSecretsRouter.post("/:slug/secrets", handle2(secrets.setSecrets));
89388
88315
  gameSecretsRouter.delete("/:slug/secrets/:key", handle2(secrets.deleteSecret));
89389
88316
  });
@@ -89920,51 +88847,85 @@ var init_timeback6 = __esm(() => {
89920
88847
  });
89921
88848
 
89922
88849
  // src/routes/integrations/lti.ts
89923
- var ltiRouter;
88850
+ function verifyMockToken(idToken) {
88851
+ if (!idToken.startsWith("mock:")) {
88852
+ throw new Error("Invalid LTI token - must be mock token in sandbox");
88853
+ }
88854
+ try {
88855
+ const jsonStr = Buffer.from(idToken.slice(5), "base64").toString();
88856
+ return JSON.parse(jsonStr);
88857
+ } catch {
88858
+ throw new Error("Invalid LTI token format");
88859
+ }
88860
+ }
88861
+ var logger62, ltiRouter;
89924
88862
  var init_lti = __esm(() => {
89925
88863
  init_drizzle_orm();
89926
88864
  init_dist3();
89927
88865
  init_controllers();
89928
- init_errors();
88866
+ init_utils11();
89929
88867
  init_tables_index();
88868
+ init_src2();
89930
88869
  init_constants();
89931
88870
  init_api();
89932
- init_context();
88871
+ logger62 = log.scope("SandboxLti");
89933
88872
  ltiRouter = new Hono2;
89934
- ltiRouter.all("/launch", async (c2) => {
89935
- if (c2.req.method !== "POST") {
89936
- return c2.json({
89937
- error: "method_not_allowed",
89938
- message: "LTI launches must use POST method"
89939
- }, 405);
89940
- }
89941
- const sandboxCtx = getSandboxContext();
89942
- const ctx = {
89943
- db: sandboxCtx.db,
89944
- config: sandboxCtx.config,
89945
- providers: sandboxCtx.providers,
89946
- services: sandboxCtx.services,
89947
- user: undefined,
89948
- params: {},
89949
- url: new URL(c2.req.url),
89950
- request: c2.req.raw
89951
- };
88873
+ ltiRouter.post("/launch", async (c2) => {
88874
+ const db2 = c2.get("db");
89952
88875
  try {
89953
- const result = await lti.launch(ctx);
89954
- c2.header("Set-Cookie", `better-auth.session=${result.sessionToken}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${30 * 24 * 60 * 60}`);
89955
- return c2.redirect(result.redirectPath);
89956
- } catch (error2) {
89957
- if (error2 instanceof ApiError) {
88876
+ const formData = await c2.req.formData();
88877
+ const idToken = formData.get("id_token");
88878
+ if (!idToken || typeof idToken !== "string") {
89958
88879
  return c2.json({
89959
- error: "lti_launch_failed",
89960
- message: error2.message,
89961
- code: error2.code,
89962
- details: error2.details
89963
- }, error2.status);
88880
+ error: "missing_token",
88881
+ message: "Missing or invalid id_token in request"
88882
+ }, 400);
89964
88883
  }
88884
+ let claims;
88885
+ try {
88886
+ claims = verifyMockToken(idToken);
88887
+ } catch (error2) {
88888
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
88889
+ logger62.error("LTI token verification failed", { error: errorMessage });
88890
+ return c2.json({
88891
+ error: "invalid_token",
88892
+ message: errorMessage
88893
+ }, 401);
88894
+ }
88895
+ const validationError = validateLtiClaims(claims);
88896
+ if (validationError) {
88897
+ logger62.warn("LTI claims validation failed", {
88898
+ error: validationError,
88899
+ sub: claims.sub
88900
+ });
88901
+ return c2.json({
88902
+ error: "invalid_claims",
88903
+ message: validationError
88904
+ }, 400);
88905
+ }
88906
+ const user = await provisionLtiUser(db2, claims);
88907
+ const sessionToken = crypto.randomUUID();
88908
+ const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);
88909
+ await db2.insert(sessions).values({
88910
+ id: crypto.randomUUID(),
88911
+ userId: user.id,
88912
+ token: sessionToken,
88913
+ expiresAt,
88914
+ createdAt: new Date,
88915
+ updatedAt: new Date
88916
+ });
88917
+ logger62.info("LTI launch successful", { userId: user.id });
88918
+ const targetUri = claims["https://purl.imsglobal.org/spec/lti/claim/target_link_uri"];
88919
+ const currentHost = new URL(c2.req.url).hostname;
88920
+ const redirectPath = extractRedirectPath(targetUri, currentHost);
88921
+ c2.header("Set-Cookie", `sandbox-session=${sessionToken}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${30 * 24 * 60 * 60}`);
88922
+ return c2.redirect(redirectPath);
88923
+ } catch (error2) {
88924
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
88925
+ logger62.error("Unexpected error during LTI launch", { error: errorMessage });
89965
88926
  return c2.json({
89966
88927
  error: "unexpected_error",
89967
- message: "An unexpected error occurred during LTI launch. Please try again or contact support."
88928
+ message: "An unexpected error occurred during LTI launch"
89968
88929
  }, 500);
89969
88930
  }
89970
88931
  });
@@ -90094,7 +89055,6 @@ async function startServer(port, project, options = {}) {
90094
89055
  resetSandboxContext();
90095
89056
  resetHandlers();
90096
89057
  clearSandboxCache();
90097
- clearSandboxSecrets();
90098
89058
  clearSandboxStorage();
90099
89059
  const db2 = await setupServerDatabase(processedOptions, project);
90100
89060
  createSandboxContext({ db: db2, port });
@@ -90121,7 +89081,6 @@ async function startServer(port, project, options = {}) {
90121
89081
  resetSandboxContext();
90122
89082
  resetHandlers();
90123
89083
  clearSandboxCache();
90124
- clearSandboxSecrets();
90125
89084
  clearSandboxStorage();
90126
89085
  }
90127
89086
  };