@zintrust/core 0.4.79 → 0.4.80

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.
@@ -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;AAQH,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAuVF,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzC;AAED,eAAO,MAAM,mBAAmB;;qCArUQ,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;EAiTlC,CAAC;AAEH,OAAO,EAAE,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * be imported by other bin shortcuts (zin/z/zt) without parse errors.
6
6
  */
7
7
  import { Logger } from '../src/config/logger.js';
8
- import { spawnSync } from 'node:child_process';
8
+ import { spawn } from 'node:child_process';
9
9
  import fs from 'node:fs';
10
10
  import path from 'node:path';
11
11
  import { fileURLToPath } from 'node:url';
@@ -65,24 +65,55 @@ const resolveProjectLocalCliHandoff = (cwd, currentPackageRoot, env = process.en
65
65
  }
66
66
  return target;
67
67
  };
68
- const handoffToProjectLocalCli = (target, rawArgs) => {
69
- const result = spawnSync(process.execPath, [target.binPath, ...rawArgs], {
68
+ const getHandoffExitCode = (exitCode, signal) => {
69
+ if (typeof exitCode === 'number')
70
+ return exitCode;
71
+ if (signal === 'SIGINT' || signal === 'SIGTERM')
72
+ return 0;
73
+ return 1;
74
+ };
75
+ const handoffToProjectLocalCli = async (target, rawArgs) => {
76
+ const child = spawn(process.execPath, [target.binPath, ...rawArgs], {
70
77
  stdio: 'inherit',
71
78
  env: {
72
79
  ...process.env,
73
80
  [CLI_HANDOFF_ENV_KEY]: '1',
74
81
  },
75
82
  });
76
- if (result.error !== undefined) {
77
- throw result.error;
83
+ const forwardSignals = !process.stdin.isTTY;
84
+ const forwardSignal = (signal) => {
85
+ if (!forwardSignals)
86
+ return;
87
+ try {
88
+ child.kill(signal);
89
+ }
90
+ catch {
91
+ // best-effort forwarding during CLI handoff
92
+ }
93
+ };
94
+ const onSigint = () => forwardSignal('SIGINT');
95
+ const onSigterm = () => forwardSignal('SIGTERM');
96
+ process.on('SIGINT', onSigint);
97
+ process.on('SIGTERM', onSigterm);
98
+ try {
99
+ const result = await new Promise((resolve, reject) => {
100
+ child.once('error', reject);
101
+ child.once('close', (exitCode, signal) => {
102
+ resolve({ exitCode, signal });
103
+ });
104
+ });
105
+ process.exit(getHandoffExitCode(result.exitCode, result.signal));
106
+ }
107
+ finally {
108
+ process.off('SIGINT', onSigint);
109
+ process.off('SIGTERM', onSigterm);
78
110
  }
79
- process.exit(typeof result.status === 'number' ? result.status : 1);
80
111
  };
81
- const maybeHandoffToProjectLocalCli = (rawArgs) => {
112
+ const maybeHandoffToProjectLocalCli = async (rawArgs) => {
82
113
  const localCliTarget = resolveProjectLocalCliHandoff(process.cwd(), getCurrentPackageRoot());
83
114
  if (localCliTarget === undefined)
84
115
  return false;
85
- handoffToProjectLocalCli(localCliTarget, rawArgs);
116
+ await handoffToProjectLocalCli(localCliTarget, rawArgs);
86
117
  return true;
87
118
  };
88
119
  const loadPackageVersionFast = () => {
@@ -195,7 +226,7 @@ const handleCliFatal = async (error, context) => {
195
226
  };
196
227
  const runCliInternal = async () => {
197
228
  const { rawArgs: rawArgs0, args: args0 } = getArgsFromProcess();
198
- if (maybeHandoffToProjectLocalCli(rawArgs0)) {
229
+ if (await maybeHandoffToProjectLocalCli(rawArgs0)) {
199
230
  return;
200
231
  }
201
232
  // Fast path: print version and exit without bootstrapping the CLI.
@@ -266,8 +297,11 @@ export async function run() {
266
297
  export const CliLauncherInternal = Object.freeze({
267
298
  CLI_HANDOFF_ENV_KEY,
268
299
  findProjectLocalCliTarget,
300
+ getHandoffExitCode,
269
301
  getCurrentPackageRoot,
270
302
  getRealPath,
303
+ handoffToProjectLocalCli,
271
304
  isWithinDirectory,
305
+ maybeHandoffToProjectLocalCli,
272
306
  resolveProjectLocalCliHandoff,
273
307
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/core",
3
- "version": "0.4.79",
3
+ "version": "0.4.80",
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":"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,cAA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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;AA0BF,eAAO,MAAM,0BAA0B,GAAI,OAAO,EAAE,QAAQ,SAAS,2BAA2B,EAC9F,OAAO,+BAA+B,CAAC,OAAO,EAAE,QAAQ,CAAC,KACxD,YAsFF,CAAC"}
@@ -1,15 +1,38 @@
1
1
  import { BaseCommand } from '../BaseCommand.js';
2
+ import { withWranglerDevVarsSnapshot } from '../cloudflare/CloudflareWranglerDevEnv.js';
2
3
  import { maybeRunProxyWatchMode, parseIntOption } from '../commands/ProxyCommandUtils.js';
3
4
  import { ensureProxyEntrypoint, ensureWranglerConfig, renderProxyWranglerDevConfig, resolveConfigPath, } from '../commands/ProxyScaffoldUtils.js';
5
+ import { EnvFileLoader } from '../utils/EnvFileLoader.js';
4
6
  import { SpawnUtil } from '../utils/spawn.js';
5
7
  import { Logger } from '../../config/logger.js';
6
- import { mkdirSync, writeFileSync } from '../../node-singletons/fs.js';
7
- import { join } from '../../node-singletons/path.js';
8
+ import { existsSync, mkdirSync, writeFileSync } from '../../node-singletons/fs.js';
9
+ import { dirname, join } from '../../node-singletons/path.js';
8
10
  export const addWranglerProxyBaseOptions = (command, defaultConfig) => {
9
11
  command.option('-c, --config <path>', 'Wrangler config file', defaultConfig);
10
12
  command.option('--port <port>', 'Local Wrangler dev port');
11
13
  command.option('--watch', 'Auto-restart proxy on file changes');
12
14
  };
15
+ const findNearestPackageJsonDir = (cwd) => {
16
+ let current = cwd;
17
+ while (true) {
18
+ if (existsSync(join(current, 'package.json')))
19
+ return current;
20
+ const parent = dirname(current);
21
+ if (parent === current)
22
+ return undefined;
23
+ current = parent;
24
+ }
25
+ };
26
+ const resolveProxyProjectRoot = (cwd) => {
27
+ return findNearestPackageJsonDir(cwd) ?? cwd;
28
+ };
29
+ const ensureProxyEnvLoaded = (cwd, projectRoot) => {
30
+ EnvFileLoader.ensureLoaded({
31
+ cwd: projectRoot,
32
+ includeCwd: true,
33
+ ...(cwd === projectRoot ? {} : { extraCwds: [cwd] }),
34
+ });
35
+ };
13
36
  export const createWranglerProxyCommand = (input) => {
14
37
  return BaseCommand.create({
15
38
  name: input.name,
@@ -21,6 +44,8 @@ export const createWranglerProxyCommand = (input) => {
21
44
  await maybeRunProxyWatchMode(typedOptions.watch);
22
45
  const port = parseIntOption(typedOptions.port, 'port');
23
46
  const cwd = process.cwd();
47
+ const projectRoot = resolveProxyProjectRoot(cwd);
48
+ ensureProxyEnvLoaded(cwd, projectRoot);
24
49
  const entrypoint = ensureProxyEntrypoint({
25
50
  cwd,
26
51
  entryFile: input.entryFile,
@@ -61,11 +86,19 @@ export const createWranglerProxyCommand = (input) => {
61
86
  if (port !== undefined) {
62
87
  args.push('--port', String(port));
63
88
  }
64
- const exitCode = await SpawnUtil.spawnAndWait({
65
- command: 'wrangler',
66
- args,
67
- env: process.env,
68
- forwardSignals: false,
89
+ const exitCode = await withWranglerDevVarsSnapshot({
90
+ cwd,
91
+ projectRoot,
92
+ envName: input.envName,
93
+ configPath,
94
+ runtimeEnv: process.env,
95
+ }, async () => {
96
+ return SpawnUtil.spawnAndWait({
97
+ command: 'wrangler',
98
+ args,
99
+ env: process.env,
100
+ forwardSignals: false,
101
+ });
69
102
  });
70
103
  if (exitCode !== 0) {
71
104
  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.80
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-08T12:38:34.978Z
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-08T12:38:34.943Z'; // 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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,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);