@zintrust/core 0.4.79 → 0.4.81

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.
Files changed (29) hide show
  1. package/bin/zintrust-main.d.ts +3 -0
  2. package/bin/zintrust-main.d.ts.map +1 -1
  3. package/bin/zintrust-main.js +62 -16
  4. package/package.json +1 -1
  5. package/src/boot/bootstrap.js +1 -0
  6. package/src/boot/registry/runtime.d.ts.map +1 -1
  7. package/src/boot/registry/runtime.js +0 -1
  8. package/src/cli/commands/D1ProxyCommand.d.ts.map +1 -1
  9. package/src/cli/commands/D1ProxyCommand.js +12 -1
  10. package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -1
  11. package/src/cli/commands/MongoDBProxyCommand.js +3 -1
  12. package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -1
  13. package/src/cli/commands/MySqlProxyCommand.js +9 -7
  14. package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -1
  15. package/src/cli/commands/PostgresProxyCommand.js +9 -7
  16. package/src/cli/commands/ProxyCommandUtils.d.ts +2 -0
  17. package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -1
  18. package/src/cli/commands/ProxyCommandUtils.js +25 -0
  19. package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -1
  20. package/src/cli/commands/RedisProxyCommand.js +3 -2
  21. package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -1
  22. package/src/cli/commands/SmtpProxyCommand.js +2 -1
  23. package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -1
  24. package/src/cli/commands/SqlServerProxyCommand.js +3 -1
  25. package/src/cli/commands/WranglerProxyCommandUtils.d.ts.map +1 -1
  26. package/src/cli/commands/WranglerProxyCommandUtils.js +27 -15
  27. package/src/index.js +3 -3
  28. package/src/orm/migrations/MigrationStore.d.ts.map +1 -1
  29. package/src/orm/migrations/MigrationStore.js +38 -28
@@ -12,9 +12,12 @@ export declare function run(): Promise<void>;
12
12
  export declare const CliLauncherInternal: Readonly<{
13
13
  CLI_HANDOFF_ENV_KEY: "ZINTRUST_CLI_HANDOFF";
14
14
  findProjectLocalCliTarget: (cwd: string) => ProjectLocalCliTarget | undefined;
15
+ getHandoffExitCode: (exitCode: number | null, signal: NodeJS.Signals | null) => number;
15
16
  getCurrentPackageRoot: () => string;
16
17
  getRealPath: (targetPath: string) => string;
18
+ handoffToProjectLocalCli: (target: ProjectLocalCliTarget, rawArgs: string[]) => Promise<never>;
17
19
  isWithinDirectory: (targetPath: string, possibleParentPath: string) => boolean;
20
+ maybeHandoffToProjectLocalCli: (rawArgs: string[]) => Promise<boolean>;
18
21
  resolveProjectLocalCliHandoff: (cwd: string, currentPackageRoot: string, env?: NodeJS.ProcessEnv) => ProjectLocalCliTarget | undefined;
19
22
  }>;
20
23
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAmTF,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzC;AAED,eAAO,MAAM,mBAAmB;;qCAjSQ,MAAM,KAAG,qBAAqB,GAAG,SAAS;iCAtBhD,MAAM;8BAIP,MAAM,KAAG,MAAM;oCAQT,MAAM,sBAAsB,MAAM,KAAG,OAAO;yCAqC5E,MAAM,sBACS,MAAM,QACrB,MAAM,CAAC,UAAU,KACrB,qBAAqB,GAAG,SAAS;EA0QlC,CAAC;AAEH,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA0WF,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzC;AAED,eAAO,MAAM,mBAAmB;;qCAzUQ,MAAM,KAAG,qBAAqB,GAAG,SAAS;mCA6C5C,MAAM,GAAG,IAAI,UAAU,MAAM,CAAC,OAAO,GAAG,IAAI,KAAG,MAAM;iCAnEzD,MAAM;8BAIP,MAAM,KAAG,MAAM;uCAsEtC,qBAAqB,WACpB,MAAM,EAAE,KAChB,OAAO,CAAC,KAAK,CAAC;oCAhEsB,MAAM,sBAAsB,MAAM,KAAG,OAAO;6CA2G7B,MAAM,EAAE,KAAG,OAAO,CAAC,OAAO,CAAC;yCAtE1E,MAAM,sBACS,MAAM,QACrB,MAAM,CAAC,UAAU,KACrB,qBAAqB,GAAG,SAAS;EAqTlC,CAAC;AAEH,OAAO,EAAE,CAAC"}
@@ -4,12 +4,20 @@
4
4
  * This module contains the CLI implementation without a hashbang so that it can
5
5
  * be imported by other bin shortcuts (zin/z/zt) without parse errors.
6
6
  */
7
- import { Logger } from '../src/config/logger.js';
8
- import { spawnSync } from 'node:child_process';
7
+ import { spawn } from 'node:child_process';
9
8
  import fs from 'node:fs';
10
9
  import path from 'node:path';
11
10
  import { fileURLToPath } from 'node:url';
12
11
  const CLI_HANDOFF_ENV_KEY = 'ZINTRUST_CLI_HANDOFF';
12
+ const loadLogger = async () => {
13
+ try {
14
+ const { Logger } = await import('../src/config/logger.js');
15
+ return Logger;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ };
13
21
  const getCurrentPackageRoot = () => {
14
22
  return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
15
23
  };
@@ -65,24 +73,55 @@ const resolveProjectLocalCliHandoff = (cwd, currentPackageRoot, env = process.en
65
73
  }
66
74
  return target;
67
75
  };
68
- const handoffToProjectLocalCli = (target, rawArgs) => {
69
- const result = spawnSync(process.execPath, [target.binPath, ...rawArgs], {
76
+ const getHandoffExitCode = (exitCode, signal) => {
77
+ if (typeof exitCode === 'number')
78
+ return exitCode;
79
+ if (signal === 'SIGINT' || signal === 'SIGTERM')
80
+ return 0;
81
+ return 1;
82
+ };
83
+ const handoffToProjectLocalCli = async (target, rawArgs) => {
84
+ const child = spawn(process.execPath, [target.binPath, ...rawArgs], {
70
85
  stdio: 'inherit',
71
86
  env: {
72
87
  ...process.env,
73
88
  [CLI_HANDOFF_ENV_KEY]: '1',
74
89
  },
75
90
  });
76
- if (result.error !== undefined) {
77
- throw result.error;
91
+ const forwardSignals = !process.stdin.isTTY;
92
+ const forwardSignal = (signal) => {
93
+ if (!forwardSignals)
94
+ return;
95
+ try {
96
+ child.kill(signal);
97
+ }
98
+ catch {
99
+ // best-effort forwarding during CLI handoff
100
+ }
101
+ };
102
+ const onSigint = () => forwardSignal('SIGINT');
103
+ const onSigterm = () => forwardSignal('SIGTERM');
104
+ process.on('SIGINT', onSigint);
105
+ process.on('SIGTERM', onSigterm);
106
+ try {
107
+ const result = await new Promise((resolve, reject) => {
108
+ child.once('error', reject);
109
+ child.once('close', (exitCode, signal) => {
110
+ resolve({ exitCode, signal });
111
+ });
112
+ });
113
+ process.exit(getHandoffExitCode(result.exitCode, result.signal));
114
+ }
115
+ finally {
116
+ process.off('SIGINT', onSigint);
117
+ process.off('SIGTERM', onSigterm);
78
118
  }
79
- process.exit(typeof result.status === 'number' ? result.status : 1);
80
119
  };
81
- const maybeHandoffToProjectLocalCli = (rawArgs) => {
120
+ const maybeHandoffToProjectLocalCli = async (rawArgs) => {
82
121
  const localCliTarget = resolveProjectLocalCliHandoff(process.cwd(), getCurrentPackageRoot());
83
122
  if (localCliTarget === undefined)
84
123
  return false;
85
- handoffToProjectLocalCli(localCliTarget, rawArgs);
124
+ await handoffToProjectLocalCli(localCliTarget, rawArgs);
86
125
  return true;
87
126
  };
88
127
  const loadPackageVersionFast = () => {
@@ -168,18 +207,22 @@ const shouldDeferPluginAutoImportWarnings = (args) => {
168
207
  const command = getPrimaryCommand(args);
169
208
  return command === 'start' || command === 's';
170
209
  };
171
- const logPluginAutoImportFailure = (args, scope, details) => {
210
+ const logPluginAutoImportFailure = async (args, scope, details) => {
211
+ const logger = await loadLogger();
212
+ if (logger === undefined)
213
+ return;
172
214
  if (shouldDeferPluginAutoImportWarnings(args)) {
173
- Logger.debug(`${scope} plugin auto-import advisory deferred to runtime bootstrap`, {
215
+ logger.debug(`${scope} plugin auto-import advisory deferred to runtime bootstrap`, {
174
216
  details,
175
217
  });
176
218
  return;
177
219
  }
178
- Logger.warn(`${scope} plugin auto-imports failed:`, details);
220
+ logger.warn(`${scope} plugin auto-imports failed:`, details);
179
221
  };
180
222
  const handleCliFatal = async (error, context) => {
181
223
  try {
182
- Logger.error(context, error);
224
+ const logger = await loadLogger();
225
+ logger?.error(context, error);
183
226
  }
184
227
  catch {
185
228
  // best-effort logging
@@ -195,7 +238,7 @@ const handleCliFatal = async (error, context) => {
195
238
  };
196
239
  const runCliInternal = async () => {
197
240
  const { rawArgs: rawArgs0, args: args0 } = getArgsFromProcess();
198
- if (maybeHandoffToProjectLocalCli(rawArgs0)) {
241
+ if (await maybeHandoffToProjectLocalCli(rawArgs0)) {
199
242
  return;
200
243
  }
201
244
  // Fast path: print version and exit without bootstrapping the CLI.
@@ -228,11 +271,11 @@ const runCliInternal = async () => {
228
271
  const runtimeImportMode = process.env['DOCKER_WORKER'] === 'true' ? 'worker' : 'base';
229
272
  const officialImports = await PluginAutoImports.tryImportRuntimeAutoImports(runtimeImportMode);
230
273
  if (!officialImports.ok) {
231
- logPluginAutoImportFailure(args0, 'Official', officialImports.errorMessage);
274
+ await logPluginAutoImportFailure(args0, 'Official', officialImports.errorMessage);
232
275
  }
233
276
  const projectImports = await PluginAutoImports.tryImportProjectAutoImports();
234
277
  if (!projectImports.ok && projectImports.reason !== 'not-found') {
235
- logPluginAutoImportFailure(args0, 'Project', projectImports.errorMessage);
278
+ await logPluginAutoImportFailure(args0, 'Project', projectImports.errorMessage);
236
279
  }
237
280
  }
238
281
  catch {
@@ -266,8 +309,11 @@ export async function run() {
266
309
  export const CliLauncherInternal = Object.freeze({
267
310
  CLI_HANDOFF_ENV_KEY,
268
311
  findProjectLocalCliTarget,
312
+ getHandoffExitCode,
269
313
  getCurrentPackageRoot,
270
314
  getRealPath,
315
+ handoffToProjectLocalCli,
271
316
  isWithinDirectory,
317
+ maybeHandoffToProjectLocalCli,
272
318
  resolveProjectLocalCliHandoff,
273
319
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "0.4.79",
3
+ "version": "0.4.81",
4
4
  "description": "Production-grade TypeScript backend framework for JavaScript",
5
5
  "homepage": "https://zintrust.com",
6
6
  "repository": {
@@ -145,6 +145,7 @@ const gracefulShutdown = async (signal) => {
145
145
  catch (error) {
146
146
  Logger.warn('Redis connection shutdown failed (continuing with app shutdown)', error);
147
147
  }
148
+ Logger.info('✅ Application shut down successfully');
148
149
  })(), shutdownBudgetMs, 'Graceful shutdown timed out');
149
150
  globalThis.clearTimeout(forceExitTimer);
150
151
  process.exit(0);
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA2O9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA6BlF,CAAC;AAqUF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA0F7D,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA2O9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA6BlF,CAAC;AAqUF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAyF7D,CAAC"}
@@ -545,7 +545,6 @@ export const createLifecycle = (params) => {
545
545
  /* best-effort */
546
546
  }
547
547
  params.setBooted(false);
548
- Logger.info('✅ Application shut down successfully');
549
548
  };
550
549
  return { boot, shutdown };
551
550
  };
@@ -1 +1 @@
1
- {"version":3,"file":"D1ProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1ProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmHrD,eAAO,MAAM,cAAc;cACf,YAAY;EAkBtB,CAAC;AAEH,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"D1ProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1ProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkIrD,eAAO,MAAM,cAAc;cACf,YAAY;EAkBtB,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -66,6 +66,17 @@ const warnOnPlaceholderDatabaseId = (values) => {
66
66
  return;
67
67
  Logger.warn('Could not resolve a D1 database id automatically. Update wrangler.jsonc or pass --database-id before relying on the generated d1-proxy environment.');
68
68
  };
69
+ const warnOnMissingSigningSecret = () => {
70
+ const directSecret = trimNonEmptyOption(Env.get('D1_REMOTE_SECRET', ''));
71
+ const fallbackSecret = trimNonEmptyOption(Env.get('APP_KEY', ''));
72
+ if (directSecret !== undefined || fallbackSecret !== undefined)
73
+ return;
74
+ Logger.warn('D1 proxy signing will fail: the resolved project env does not expose D1_REMOTE_SECRET or APP_KEY to the Worker runtime. Signed requests will be rejected with 401 CONFIG_ERROR until one of those keys is set.');
75
+ };
76
+ const runD1ProxyDiagnostics = (values) => {
77
+ warnOnPlaceholderDatabaseId(values);
78
+ warnOnMissingSigningSecret();
79
+ };
69
80
  const addOptions = (command) => {
70
81
  addWranglerProxyBaseOptions(command, DEFAULT_CONFIG);
71
82
  command.option('--binding <name>', 'D1 binding name', DEFAULT_BINDING);
@@ -88,7 +99,7 @@ export const D1ProxyCommand = Object.freeze({
88
99
  addOptions,
89
100
  resolveValues: resolveConfigValues,
90
101
  renderEnvBlock: renderD1ProxyEnvBlock,
91
- afterConfigResolved: warnOnPlaceholderDatabaseId,
102
+ afterConfigResolved: runD1ProxyDiagnostics,
92
103
  });
93
104
  },
94
105
  });
@@ -1 +1 @@
1
- {"version":3,"file":"MongoDBProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MongoDBProxyCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4DpC,eAAO,MAAM,mBAAmB;cACpB,OAAO;EAoEjB,CAAC"}
1
+ {"version":3,"file":"MongoDBProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MongoDBProxyCommand.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4DpC,eAAO,MAAM,mBAAmB;cACpB,OAAO;EA0EjB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { Env } from '../../config/env.js';
2
2
  import { Logger } from '../../config/logger.js';
3
3
  import { ErrorFactory } from '../../exceptions/ZintrustError.js';
4
+ import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
4
5
  import { Command } from 'commander';
5
6
  const startWatchMode = async (options) => {
6
7
  Logger.info('Starting MongoDB proxy in watch mode...');
@@ -57,13 +58,14 @@ export const MongoDBProxyCommand = Object.freeze({
57
58
  const cmd = new Command('proxy:mongodb');
58
59
  cmd.description('Start MongoDB HTTP proxy server');
59
60
  const configureOptions = () => {
61
+ ensureProxyEnvLoadedForCwd();
60
62
  cmd.option('--host <host>', 'Proxy host', Env.get('MONGODB_PROXY_HOST', '127.0.0.1'));
61
63
  cmd.option('--port <port>', 'Proxy port', String(Env.getInt('MONGODB_PROXY_PORT', 8792)));
62
64
  cmd.option('--mongo-uri <uri>', 'MongoDB connection URI', Env.get('MONGO_URI', ''));
63
65
  cmd.option('--mongo-db <database>', 'MongoDB database name', Env.get('MONGO_DB', ''));
64
66
  cmd.option('--key-id <keyId>', 'Signing key ID', Env.get('MONGODB_PROXY_KEY_ID', 'default'));
65
67
  cmd.option('--secret <secret>', 'Signing secret', Env.get('MONGODB_PROXY_SECRET', ''));
66
- cmd.option('--require-signing', 'Require request signing', Env.MONGODB_PROXY_REQUIRE_SIGNING);
68
+ cmd.option('--require-signing', 'Require request signing', Env.getBool('MONGODB_PROXY_REQUIRE_SIGNING', true));
67
69
  cmd.option('--signing-window-ms <ms>', 'Signing window in milliseconds', String(Env.getInt('MONGODB_PROXY_SIGNING_WINDOW_MS', 60000)));
68
70
  cmd.option('--watch', 'Watch mode: restart on file changes');
69
71
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MySqlProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MySqlProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAatB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"MySqlProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MySqlProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgCrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAatB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
@@ -1,17 +1,19 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
+ import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
2
3
  import { addSqlProxyOptions, runSqlProxyCommand, } from '../commands/SqlProxyCommandUtils.js';
3
4
  import { Env } from '../../config/env.js';
4
5
  import { MySqlProxyServer } from '../../proxy/mysql/MySqlProxyServer.js';
5
6
  const addOptions = (command) => {
7
+ ensureProxyEnvLoadedForCwd();
6
8
  addSqlProxyOptions(command, {
7
- hostDefault: Env.MYSQL_PROXY_HOST,
8
- portDefault: Env.MYSQL_PROXY_PORT,
9
- maxBodyBytesDefault: Env.MYSQL_PROXY_MAX_BODY_BYTES,
9
+ hostDefault: Env.get('MYSQL_PROXY_HOST', '127.0.0.1'),
10
+ portDefault: Env.getInt('MYSQL_PROXY_PORT', 8789),
11
+ maxBodyBytesDefault: Env.getInt('MYSQL_PROXY_MAX_BODY_BYTES', 131072),
10
12
  dbVendorLabel: 'MySQL',
11
- requireSigningDefault: Env.MYSQL_PROXY_REQUIRE_SIGNING,
12
- keyIdDefault: Env.MYSQL_PROXY_KEY_ID,
13
- secretDefault: Env.MYSQL_PROXY_SECRET,
14
- signingWindowMsDefault: Env.MYSQL_PROXY_SIGNING_WINDOW_MS,
13
+ requireSigningDefault: Env.getBool('MYSQL_PROXY_REQUIRE_SIGNING', true),
14
+ keyIdDefault: Env.get('MYSQL_PROXY_KEY_ID', Env.get('APP_NAME', 'ZinTrust')),
15
+ secretDefault: Env.get('MYSQL_PROXY_SECRET', Env.get('APP_KEY', '')),
16
+ signingWindowMsDefault: Env.getInt('MYSQL_PROXY_SIGNING_WINDOW_MS', Env.getInt('ZT_PROXY_SIGNING_WINDOW_MS', 60000)),
15
17
  });
16
18
  };
17
19
  export const MySqlProxyCommand = Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PostgresProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0BrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAatB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"PostgresProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PostgresProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgCrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAatB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
@@ -1,17 +1,19 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
+ import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
2
3
  import { addSqlProxyOptions, runSqlProxyCommand, } from '../commands/SqlProxyCommandUtils.js';
3
4
  import { Env } from '../../config/env.js';
4
5
  import { PostgresProxyServer } from '../../proxy/postgres/PostgresProxyServer.js';
5
6
  const addOptions = (command) => {
7
+ ensureProxyEnvLoadedForCwd();
6
8
  addSqlProxyOptions(command, {
7
- hostDefault: Env.POSTGRES_PROXY_HOST,
8
- portDefault: Env.POSTGRES_PROXY_PORT,
9
- maxBodyBytesDefault: Env.POSTGRES_PROXY_MAX_BODY_BYTES,
9
+ hostDefault: Env.get('POSTGRES_PROXY_HOST', '127.0.0.1'),
10
+ portDefault: Env.getInt('POSTGRES_PROXY_PORT', 8790),
11
+ maxBodyBytesDefault: Env.getInt('POSTGRES_PROXY_MAX_BODY_BYTES', 131072),
10
12
  dbVendorLabel: 'PostgreSQL',
11
- requireSigningDefault: Env.POSTGRES_PROXY_REQUIRE_SIGNING,
12
- keyIdDefault: Env.POSTGRES_PROXY_KEY_ID,
13
- secretDefault: Env.POSTGRES_PROXY_SECRET,
14
- signingWindowMsDefault: Env.POSTGRES_PROXY_SIGNING_WINDOW_MS,
13
+ requireSigningDefault: Env.getBool('POSTGRES_PROXY_REQUIRE_SIGNING', true),
14
+ keyIdDefault: Env.get('POSTGRES_PROXY_KEY_ID', Env.get('APP_NAME', 'ZinTrust')),
15
+ secretDefault: Env.get('POSTGRES_PROXY_SECRET', Env.get('APP_KEY', '')),
16
+ signingWindowMsDefault: Env.getInt('POSTGRES_PROXY_SIGNING_WINDOW_MS', Env.getInt('ZT_PROXY_SIGNING_WINDOW_MS', 60000)),
15
17
  });
16
18
  };
17
19
  export const PostgresProxyCommand = Object.freeze({
@@ -1,6 +1,8 @@
1
1
  type NumberExpectation = 'positive' | 'non-negative';
2
2
  export declare const parseIntOption: (raw: string | undefined, name: string, expectation?: NumberExpectation) => number | undefined;
3
3
  export declare const trimOption: (value: string | undefined) => string | undefined;
4
+ export declare const resolveProxyProjectRoot: (cwd: string) => string;
5
+ export declare const ensureProxyEnvLoadedForCwd: (cwd?: string) => string;
4
6
  export declare const maybeRunProxyWatchMode: (watch: boolean | undefined) => Promise<void>;
5
7
  export {};
6
8
  //# sourceMappingURL=ProxyCommandUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ProxyCommandUtils.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG,UAAU,GAAG,cAAc,CAAC;AAErD,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,MAAM,EACZ,cAAa,iBAA8B,KAC1C,MAAM,GAAG,SAeX,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAA0B,CAAC;AAU3F,eAAO,MAAM,sBAAsB,GAAU,OAAO,OAAO,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAerF,CAAC"}
1
+ {"version":3,"file":"ProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ProxyCommandUtils.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG,UAAU,GAAG,cAAc,CAAC;AAErD,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,MAAM,EACZ,cAAa,iBAA8B,KAC1C,MAAM,GAAG,SAeX,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAA0B,CAAC;AAc3F,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,KAAG,MAErD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,MAAK,MAAsB,KAAG,MAUxE,CAAC;AAUF,eAAO,MAAM,sBAAsB,GAAU,OAAO,OAAO,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAerF,CAAC"}
@@ -1,5 +1,7 @@
1
+ import { EnvFileLoader } from '../utils/EnvFileLoader.js';
1
2
  import { SpawnUtil } from '../utils/spawn.js';
2
3
  import { ErrorFactory } from '../../exceptions/ZintrustError.js';
4
+ import { existsSync } from '../../node-singletons/fs.js';
3
5
  import * as path from '../../node-singletons/path.js';
4
6
  export const parseIntOption = (raw, name, expectation = 'positive') => {
5
7
  if (raw === undefined)
@@ -15,6 +17,29 @@ export const parseIntOption = (raw, name, expectation = 'positive') => {
15
17
  return parsed;
16
18
  };
17
19
  export const trimOption = (value) => value?.trim();
20
+ const findNearestPackageJsonDir = (cwd) => {
21
+ let current = cwd;
22
+ while (true) {
23
+ if (existsSync(path.join(current, 'package.json')))
24
+ return current;
25
+ const parent = path.dirname(current);
26
+ if (parent === current)
27
+ return undefined;
28
+ current = parent;
29
+ }
30
+ };
31
+ export const resolveProxyProjectRoot = (cwd) => {
32
+ return findNearestPackageJsonDir(cwd) ?? cwd;
33
+ };
34
+ export const ensureProxyEnvLoadedForCwd = (cwd = process.cwd()) => {
35
+ const projectRoot = resolveProxyProjectRoot(cwd);
36
+ EnvFileLoader.ensureLoaded({
37
+ cwd: projectRoot,
38
+ includeCwd: true,
39
+ ...(cwd === projectRoot ? {} : { extraCwds: [cwd] }),
40
+ });
41
+ return projectRoot;
42
+ };
18
43
  const isWatchChild = () => process.env['ZINTRUST_PROXY_WATCH_CHILD'] === '1';
19
44
  const buildWatchArgs = () => {
20
45
  const rawArgs = process.argv.slice(2);
@@ -1 +1 @@
1
- {"version":3,"file":"RedisProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RedisProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmDrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAoCtB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"RedisProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RedisProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0DrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAoCtB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
- import { maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
2
+ import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
3
3
  import { Env } from '../../config/env.js';
4
4
  import { RedisProxyServer } from '../../proxy/redis/RedisProxyServer.js';
5
5
  const addOptions = (command) => {
6
+ ensureProxyEnvLoadedForCwd();
6
7
  command.option('--host <host>', 'Host to bind', Env.get('REDIS_PROXY_HOST', '127.0.0.1'));
7
8
  command.option('--port <port>', 'Port to bind', String(Env.getInt('REDIS_PROXY_PORT', 8791)));
8
9
  command.option('--max-body-bytes <bytes>', 'Max request size in bytes', String(Env.getInt('REDIS_PROXY_MAX_BODY_BYTES', 131072)));
@@ -11,7 +12,7 @@ const addOptions = (command) => {
11
12
  command.option('--redis-port <port>', 'Redis port');
12
13
  command.option('--redis-password <password>', 'Redis password');
13
14
  command.option('--redis-db <db>', 'Redis database');
14
- command.option('--require-signing', 'Require signed requests', Env.REDIS_PROXY_REQUIRE_SIGNING);
15
+ command.option('--require-signing', 'Require signed requests', Env.getBool('REDIS_PROXY_REQUIRE_SIGNING', true));
15
16
  command.option('--key-id <id>', 'Signing key id', Env.get('REDIS_PROXY_KEY_ID', ''));
16
17
  command.option('--secret <secret>', 'Signing secret', Env.get('REDIS_PROXY_SECRET', ''));
17
18
  command.option('--signing-window-ms <ms>', 'Signing time window in ms', String(Env.getInt('REDIS_PROXY_SIGNING_WINDOW_MS', 60000)));
@@ -1 +1 @@
1
- {"version":3,"file":"SmtpProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SmtpProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyDrE,eAAO,MAAM,gBAAgB;cACjB,YAAY;EAsCtB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SmtpProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SmtpProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4DrE,eAAO,MAAM,gBAAgB;cACjB,YAAY;EAsCtB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
- import { maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
2
+ import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
3
3
  import { Env } from '../../config/env.js';
4
4
  import { SmtpProxyServer } from '../../proxy/smtp/SmtpProxyServer.js';
5
5
  const addOptions = (command) => {
6
+ ensureProxyEnvLoadedForCwd();
6
7
  command.option('--host <host>', 'Host to bind', Env.get('SMTP_PROXY_HOST', '127.0.0.1'));
7
8
  command.option('--port <port>', 'Port to bind', String(Env.getInt('SMTP_PROXY_PORT', 8794)));
8
9
  command.option('--max-body-bytes <bytes>', 'Max request size in bytes', String(Env.getInt('SMTP_PROXY_MAX_BODY_BYTES', 131072)));
@@ -1 +1 @@
1
- {"version":3,"file":"SqlServerProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SqlServerProxyCommand.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2DpC,eAAO,MAAM,qBAAqB;cACtB,OAAO;EAsEjB,CAAC"}
1
+ {"version":3,"file":"SqlServerProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SqlServerProxyCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2DpC,eAAO,MAAM,qBAAqB;cACtB,OAAO;EAwEjB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Env } from '../../config/env.js';
2
+ import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
2
3
  import { Logger } from '../../config/logger.js';
3
4
  import { Command } from 'commander';
4
5
  const startWatchMode = async (options) => {
@@ -39,6 +40,7 @@ export const SqlServerProxyCommand = Object.freeze({
39
40
  const cmd = new Command('proxy:sqlserver');
40
41
  cmd.description('Start SQL Server HTTP proxy server');
41
42
  const configureOptions = () => {
43
+ ensureProxyEnvLoadedForCwd();
42
44
  cmd.option('--host <host>', 'Proxy host', Env.get('SQLSERVER_PROXY_HOST', '127.0.0.1'));
43
45
  cmd.option('--port <port>', 'Proxy port', String(Env.getInt('SQLSERVER_PROXY_PORT', 8793)));
44
46
  cmd.option('--db-host <host>', 'SQL Server host', Env.get('DB_HOST_MSSQL', '127.0.0.1'));
@@ -49,7 +51,7 @@ export const SqlServerProxyCommand = Object.freeze({
49
51
  cmd.option('--connection-limit <limit>', 'Connection pool limit', String(Env.getInt('SQLSERVER_PROXY_POOL_LIMIT', 10)));
50
52
  cmd.option('--key-id <keyId>', 'Signing key ID', Env.get('SQLSERVER_PROXY_KEY_ID', 'default'));
51
53
  cmd.option('--secret <secret>', 'Signing secret', Env.get('SQLSERVER_PROXY_SECRET', ''));
52
- cmd.option('--require-signing', 'Require request signing', Env.SQLSERVER_PROXY_REQUIRE_SIGNING);
54
+ cmd.option('--require-signing', 'Require request signing', Env.getBool('SQLSERVER_PROXY_REQUIRE_SIGNING', true));
53
55
  cmd.option('--signing-window-ms <ms>', 'Signing window in milliseconds', String(Env.getInt('SQLSERVER_PROXY_SIGNING_WINDOW_MS', 60000)));
54
56
  cmd.option('--watch', 'Watch mode: restart on file changes');
55
57
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WranglerProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerProxyCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,CAAC,OAAO,EAAE,QAAQ,SAAS,2BAA2B,IAAI;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC3E,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC5C,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,eAAe,MAAM,KAAG,IAIrF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,EAAE,QAAQ,SAAS,2BAA2B,EAC9F,OAAO,+BAA+B,CAAC,OAAO,EAAE,QAAQ,CAAC,KACxD,YAuEF,CAAC"}
1
+ {"version":3,"file":"WranglerProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerProxyCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkBrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,CAAC,OAAO,EAAE,QAAQ,SAAS,2BAA2B,IAAI;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC3E,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC5C,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,eAAe,MAAM,KAAG,IAIrF,CAAC;AAMF,eAAO,MAAM,0BAA0B,GAAI,OAAO,EAAE,QAAQ,SAAS,2BAA2B,EAC9F,OAAO,+BAA+B,CAAC,OAAO,EAAE,QAAQ,CAAC,KACxD,YAoFF,CAAC"}
@@ -1,15 +1,19 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
- import { maybeRunProxyWatchMode, parseIntOption } from '../commands/ProxyCommandUtils.js';
2
+ import { withWranglerDevVarsSnapshot } from '../cloudflare/CloudflareWranglerDevEnv.js';
3
+ import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, } from '../commands/ProxyCommandUtils.js';
3
4
  import { ensureProxyEntrypoint, ensureWranglerConfig, renderProxyWranglerDevConfig, resolveConfigPath, } from '../commands/ProxyScaffoldUtils.js';
4
5
  import { SpawnUtil } from '../utils/spawn.js';
5
6
  import { Logger } from '../../config/logger.js';
6
7
  import { mkdirSync, writeFileSync } from '../../node-singletons/fs.js';
7
- import { join } from '../../node-singletons/path.js';
8
+ import { dirname, join } from '../../node-singletons/path.js';
8
9
  export const addWranglerProxyBaseOptions = (command, defaultConfig) => {
9
10
  command.option('-c, --config <path>', 'Wrangler config file', defaultConfig);
10
11
  command.option('--port <port>', 'Local Wrangler dev port');
11
12
  command.option('--watch', 'Auto-restart proxy on file changes');
12
13
  };
14
+ const toRootedProxyConfigContent = (content) => {
15
+ return content.replaceAll('": "../../', '": "./');
16
+ };
13
17
  export const createWranglerProxyCommand = (input) => {
14
18
  return BaseCommand.create({
15
19
  name: input.name,
@@ -21,6 +25,7 @@ export const createWranglerProxyCommand = (input) => {
21
25
  await maybeRunProxyWatchMode(typedOptions.watch);
22
26
  const port = parseIntOption(typedOptions.port, 'port');
23
27
  const cwd = process.cwd();
28
+ const projectRoot = ensureProxyEnvLoadedForCwd(cwd);
24
29
  const entrypoint = ensureProxyEntrypoint({
25
30
  cwd,
26
31
  entryFile: input.entryFile,
@@ -47,25 +52,32 @@ export const createWranglerProxyCommand = (input) => {
47
52
  }
48
53
  input.afterConfigResolved?.(result.values);
49
54
  const proxyConfigContent = renderProxyWranglerDevConfig(result.content, input.envName);
50
- const proxyConfigDir = join(cwd, '.wrangler', 'tmp');
51
- const proxyConfigPath = join(proxyConfigDir, `zin.proxy.${input.envName}.jsonc`);
55
+ const proxyConfigDir = cwd;
56
+ const proxyConfigPath = join(proxyConfigDir, `.zin.proxy.${input.envName}.jsonc`);
52
57
  if (proxyConfigContent !== undefined) {
53
58
  mkdirSync(proxyConfigDir, { recursive: true });
54
- writeFileSync(proxyConfigPath, proxyConfigContent, 'utf-8');
59
+ writeFileSync(proxyConfigPath, toRootedProxyConfigContent(proxyConfigContent), 'utf-8');
55
60
  }
56
- const args = [
57
- 'dev',
58
- '--config',
59
- proxyConfigContent === undefined ? configPath : proxyConfigPath,
60
- ];
61
+ const wranglerRunConfigPath = proxyConfigContent === undefined ? configPath : proxyConfigPath;
62
+ const wranglerDevVarsCwd = proxyConfigContent === undefined ? cwd : dirname(proxyConfigPath);
63
+ const wranglerDevVarsEnvName = proxyConfigContent === undefined ? input.envName : '';
64
+ const args = ['dev', '--config', wranglerRunConfigPath];
61
65
  if (port !== undefined) {
62
66
  args.push('--port', String(port));
63
67
  }
64
- const exitCode = await SpawnUtil.spawnAndWait({
65
- command: 'wrangler',
66
- args,
67
- env: process.env,
68
- forwardSignals: false,
68
+ const exitCode = await withWranglerDevVarsSnapshot({
69
+ cwd: wranglerDevVarsCwd,
70
+ projectRoot,
71
+ envName: wranglerDevVarsEnvName,
72
+ configPath,
73
+ runtimeEnv: process.env,
74
+ }, async () => {
75
+ return SpawnUtil.spawnAndWait({
76
+ command: 'wrangler',
77
+ args,
78
+ env: process.env,
79
+ forwardSignals: false,
80
+ });
69
81
  });
70
82
  if (exitCode !== 0) {
71
83
  process.exit(exitCode);
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @zintrust/core v0.4.79
2
+ * @zintrust/core v0.4.81
3
3
  *
4
4
  * ZinTrust Framework - Production-Grade TypeScript Backend
5
5
  * Built for performance, type safety, and exceptional developer experience
6
6
  *
7
7
  * Build Information:
8
- * Built: 2026-04-08T11:45:55.486Z
8
+ * Built: 2026-04-08T13:57:15.723Z
9
9
  * Node: >=20.0.0
10
10
  * License: MIT
11
11
  *
@@ -21,7 +21,7 @@
21
21
  * Available at runtime for debugging and health checks
22
22
  */
23
23
  export const ZINTRUST_VERSION = '0.1.41';
24
- export const ZINTRUST_BUILD_DATE = '2026-04-08T11:45:55.451Z'; // Replaced during build
24
+ export const ZINTRUST_BUILD_DATE = '2026-04-08T13:57:15.665Z'; // Replaced during build
25
25
  export { Application } from './boot/Application.js';
26
26
  export { AwsSigV4 } from './common/index.js';
27
27
  export { SignedRequest } from './security/SignedRequest.js';
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationStore.d.ts","sourceRoot":"","sources":["../../../../src/orm/migrations/MigrationStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA6dhG,eAAO,MAAM,cAAc;oBACH,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;8BAKzC,SAAS,UACN,cAAc,YACZ,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;sBA4BZ,SAAS,SACN,cAAc,WACZ,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;sBAmDlC,SAAS,UACL;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC9E,OAAO,CAAC,IAAI,CAAC;mBA2DV,SAAS,UACL;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,cAAc,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,qBAAqB,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,GACA,OAAO,CAAC,IAAI,CAAC;kCAmDV,SAAS,UACL;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACnE,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;8BA6C5C,SAAS,UACL;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,MAAM,EAAE,CAAC;qBA0Bd,SAAS,UACL;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAC/D,OAAO,CAAC,IAAI,CAAC;EAmBhB,CAAC"}
1
+ {"version":3,"file":"MigrationStore.d.ts","sourceRoot":"","sources":["../../../../src/orm/migrations/MigrationStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAkhBhG,eAAO,MAAM,cAAc;oBACH,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;8BAKzC,SAAS,UACN,cAAc,YACZ,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;sBA4BZ,SAAS,SACN,cAAc,WACZ,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;sBAsBlC,SAAS,UACL;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC9E,OAAO,CAAC,IAAI,CAAC;mBA2DV,SAAS,UACL;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,cAAc,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,qBAAqB,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,GACA,OAAO,CAAC,IAAI,CAAC;kCAmDV,SAAS,UACL;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACnE,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;8BA6C5C,SAAS,UACL;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,MAAM,EAAE,CAAC;qBA0Bd,SAAS,UACL;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAC/D,OAAO,CAAC,IAAI,CAAC;EAmBhB,CAAC"}
@@ -205,6 +205,42 @@ const getLegacyBatch = (row) => {
205
205
  const getLegacyAppliedAt = (row) => {
206
206
  return typeof row['applied_at'] === 'string' ? row['applied_at'] : null;
207
207
  };
208
+ const toLegacyMigrationRecord = (row, layout, scope, normalizedService) => {
209
+ const name = normalizeLegacyName(row);
210
+ const batch = getLegacyBatch(row);
211
+ if (name === '' || !Number.isFinite(batch))
212
+ return undefined;
213
+ return {
214
+ name,
215
+ scope: layout.hasScope ? scope : 'global',
216
+ service: layout.hasService ? normalizedService : '',
217
+ batch,
218
+ status: typeof row['status'] === 'string' ? row['status'] : 'completed',
219
+ appliedAt: getLegacyAppliedAt(row),
220
+ };
221
+ };
222
+ const buildLegacyAppliedMap = (rows, layout, scope, normalizedService) => {
223
+ const map = new Map();
224
+ for (const row of rows) {
225
+ const record = toLegacyMigrationRecord(row, layout, scope, normalizedService);
226
+ if (record === undefined)
227
+ continue;
228
+ map.set(record.name, record);
229
+ }
230
+ return map;
231
+ };
232
+ const buildAppliedMap = (rows) => {
233
+ const map = new Map();
234
+ for (const row of rows) {
235
+ if (typeof row.name !== 'string' || row.name.length === 0)
236
+ continue;
237
+ map.set(row.name, {
238
+ ...row,
239
+ service: toSafeService(row.service),
240
+ });
241
+ }
242
+ return map;
243
+ };
208
244
  const getLegacyAppliedRows = async (db, layout, scope, service) => {
209
245
  const normalizedService = toSafeService(service);
210
246
  assertCompatibleTrackingTarget(layout, scope, normalizedService);
@@ -339,24 +375,7 @@ export const MigrationStore = Object.freeze({
339
375
  const layout = await resolveTableLayout(db);
340
376
  if (layout.requiresCompatibilityMode) {
341
377
  const rows = await getLegacyAppliedRows(db, layout, scope, normalizedService);
342
- const map = new Map();
343
- for (const row of rows) {
344
- const name = normalizeLegacyName(row);
345
- const batch = getLegacyBatch(row);
346
- if (name === '' || !Number.isFinite(batch))
347
- continue;
348
- map.set(name, {
349
- name,
350
- scope: layout.hasScope ? scope : 'global',
351
- service: layout.hasService ? normalizedService : '',
352
- batch,
353
- status: typeof row['status'] === 'string'
354
- ? row['status']
355
- : 'completed',
356
- appliedAt: getLegacyAppliedAt(row),
357
- });
358
- }
359
- return map;
378
+ return buildLegacyAppliedMap(rows, layout, scope, normalizedService);
360
379
  }
361
380
  const rows = await QueryBuilder.create('migrations', db)
362
381
  .select('name', 'scope', 'service', 'batch', 'status')
@@ -364,16 +383,7 @@ export const MigrationStore = Object.freeze({
364
383
  .where('scope', '=', scope)
365
384
  .andWhere('service', '=', normalizedService)
366
385
  .get();
367
- const map = new Map();
368
- for (const r of rows) {
369
- if (typeof r.name === 'string' && r.name.length > 0) {
370
- map.set(r.name, {
371
- ...r,
372
- service: toSafeService(r.service),
373
- });
374
- }
375
- }
376
- return map;
386
+ return buildAppliedMap(rows);
377
387
  },
378
388
  async insertRunning(db, params) {
379
389
  assertDbSupportsMigrations(db);