@zintrust/core 1.5.5 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/launcher.d.ts +6 -0
- package/bin/launcher.d.ts.map +1 -0
- package/bin/launcher.js +167 -0
- package/bin/z.js +2 -102
- package/bin/zin.js +2 -192
- package/bin/zintrust.d.ts +1 -1
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +3 -103
- package/bin/zt.d.ts +1 -1
- package/bin/zt.js +3 -100
- package/package.json +1 -1
- package/src/boot/registry/runtime.d.ts +4 -2
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +36 -30
- package/src/helper/ShutdownTrace.d.ts.map +1 -1
- package/src/helper/ShutdownTrace.js +2 -19
- package/src/index.js +3 -3
- package/src/zintrust.plugins.d.ts +3 -6
- package/src/zintrust.plugins.d.ts.map +1 -1
- package/src/zintrust.plugins.js +3 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../bin/launcher.ts"],"names":[],"mappings":"AAMA,KAAK,kBAAkB,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA6LF,eAAO,MAAM,aAAa,GAAU,QAAO,kBAAuB,KAAG,OAAO,CAAC,IAAI,CAoBhF,CAAC"}
|
package/bin/launcher.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
const CLI_SPAWN_TRACE_ENV_KEYS = ['CLI_SPAWN_TRACE', 'ZIN_SPAWN_TRACE'];
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const isCliSpawnTraceEnabled = () => {
|
|
10
|
+
return CLI_SPAWN_TRACE_ENV_KEYS.some((key) => {
|
|
11
|
+
const raw = process.env[key];
|
|
12
|
+
if (typeof raw !== 'string')
|
|
13
|
+
return false;
|
|
14
|
+
const normalized = raw.trim().toLowerCase();
|
|
15
|
+
return (normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on');
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const writeCliSpawnTrace = (input, label, details = {}) => {
|
|
19
|
+
if (input.traceName === undefined || !isCliSpawnTraceEnabled())
|
|
20
|
+
return;
|
|
21
|
+
process.stderr.write(`${JSON.stringify({ trace: input.traceName, label, pid: process.pid, details })}\n`);
|
|
22
|
+
};
|
|
23
|
+
const resolveNodeArgs = () => {
|
|
24
|
+
const tsTarget = path.join(here, 'zintrust-main.ts');
|
|
25
|
+
const jsTarget = path.join(here, 'zintrust-main.js');
|
|
26
|
+
const target = existsSync(tsTarget) ? tsTarget : jsTarget;
|
|
27
|
+
if (!target.endsWith('.ts')) {
|
|
28
|
+
return [target, ...process.argv.slice(2)];
|
|
29
|
+
}
|
|
30
|
+
return ['--import', require.resolve('tsx'), target, ...process.argv.slice(2)];
|
|
31
|
+
};
|
|
32
|
+
const getExitCode = (exitCode, signal) => {
|
|
33
|
+
if (typeof exitCode === 'number')
|
|
34
|
+
return exitCode;
|
|
35
|
+
if (signal === 'SIGINT' || signal === 'SIGTERM')
|
|
36
|
+
return 0;
|
|
37
|
+
return 1;
|
|
38
|
+
};
|
|
39
|
+
const attachOutputRelay = (input, child, stream) => {
|
|
40
|
+
const childStream = child[stream];
|
|
41
|
+
const targetStream = stream === 'stdout' ? process.stdout : process.stderr;
|
|
42
|
+
childStream?.on('data', (chunk) => {
|
|
43
|
+
writeCliSpawnTrace(input, `wrapper.child.${stream}.data`, {
|
|
44
|
+
childPid: child.pid,
|
|
45
|
+
bytes: typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.length,
|
|
46
|
+
});
|
|
47
|
+
targetStream.write(chunk);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const waitForChildClose = async (input, child, onBeforeResolve) => {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
let settled = false;
|
|
53
|
+
let childResult = {
|
|
54
|
+
exitCode: null,
|
|
55
|
+
signal: null,
|
|
56
|
+
};
|
|
57
|
+
const finalize = () => {
|
|
58
|
+
if (settled)
|
|
59
|
+
return;
|
|
60
|
+
settled = true;
|
|
61
|
+
onBeforeResolve();
|
|
62
|
+
child.off?.('error', reject);
|
|
63
|
+
child.off?.('exit', handleExit);
|
|
64
|
+
child.off?.('close', handleClose);
|
|
65
|
+
writeCliSpawnTrace(input, 'wrapper.child.finalize', {
|
|
66
|
+
childPid: child.pid,
|
|
67
|
+
exitCode: childResult.exitCode,
|
|
68
|
+
signal: childResult.signal,
|
|
69
|
+
});
|
|
70
|
+
resolve(childResult);
|
|
71
|
+
};
|
|
72
|
+
const handleExit = (exitCode, signal) => {
|
|
73
|
+
childResult = { exitCode, signal };
|
|
74
|
+
};
|
|
75
|
+
const handleClose = (exitCode, signal) => {
|
|
76
|
+
childResult = {
|
|
77
|
+
exitCode: childResult.exitCode ?? exitCode,
|
|
78
|
+
signal: childResult.signal ?? signal,
|
|
79
|
+
};
|
|
80
|
+
finalize();
|
|
81
|
+
};
|
|
82
|
+
child.once('error', reject);
|
|
83
|
+
child.once('exit', handleExit);
|
|
84
|
+
child.once('close', handleClose);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const registerSignalHandlers = (input, child) => {
|
|
88
|
+
let childClosed = false;
|
|
89
|
+
let delayedSignalTimer;
|
|
90
|
+
const clearDelayedSignal = () => {
|
|
91
|
+
if (delayedSignalTimer === undefined)
|
|
92
|
+
return;
|
|
93
|
+
clearTimeout(delayedSignalTimer);
|
|
94
|
+
delayedSignalTimer = undefined;
|
|
95
|
+
};
|
|
96
|
+
const forwardSignal = (signal) => {
|
|
97
|
+
if (childClosed)
|
|
98
|
+
return;
|
|
99
|
+
try {
|
|
100
|
+
writeCliSpawnTrace(input, 'wrapper.signal.forward', {
|
|
101
|
+
childPid: child.pid,
|
|
102
|
+
signal,
|
|
103
|
+
});
|
|
104
|
+
child.kill(signal);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// best-effort
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const scheduleSignalForward = (signal) => {
|
|
111
|
+
if (childClosed || delayedSignalTimer !== undefined)
|
|
112
|
+
return;
|
|
113
|
+
delayedSignalTimer = globalThis.setTimeout(() => {
|
|
114
|
+
delayedSignalTimer = undefined;
|
|
115
|
+
writeCliSpawnTrace(input, 'wrapper.signal.delay.fire', {
|
|
116
|
+
childPid: child.pid,
|
|
117
|
+
signal,
|
|
118
|
+
});
|
|
119
|
+
forwardSignal(signal);
|
|
120
|
+
}, 1500);
|
|
121
|
+
writeCliSpawnTrace(input, 'wrapper.signal.delay.schedule', {
|
|
122
|
+
childPid: child.pid,
|
|
123
|
+
signal,
|
|
124
|
+
delayMs: 1500,
|
|
125
|
+
});
|
|
126
|
+
delayedSignalTimer.unref?.();
|
|
127
|
+
};
|
|
128
|
+
const onSigint = () => {
|
|
129
|
+
if (process.stdin.isTTY === true) {
|
|
130
|
+
scheduleSignalForward('SIGINT');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
forwardSignal('SIGINT');
|
|
134
|
+
};
|
|
135
|
+
const onSigterm = () => {
|
|
136
|
+
if (process.stdin.isTTY === true) {
|
|
137
|
+
scheduleSignalForward('SIGTERM');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
forwardSignal('SIGTERM');
|
|
141
|
+
};
|
|
142
|
+
process.on('SIGINT', onSigint);
|
|
143
|
+
process.on('SIGTERM', onSigterm);
|
|
144
|
+
return () => {
|
|
145
|
+
childClosed = true;
|
|
146
|
+
clearDelayedSignal();
|
|
147
|
+
process.off('SIGINT', onSigint);
|
|
148
|
+
process.off('SIGTERM', onSigterm);
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
export const runCliWrapper = async (input = {}) => {
|
|
152
|
+
const nodeArgs = resolveNodeArgs();
|
|
153
|
+
const child = spawn(process.execPath, nodeArgs, {
|
|
154
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
155
|
+
env: process.env,
|
|
156
|
+
});
|
|
157
|
+
writeCliSpawnTrace(input, 'wrapper.child.started', {
|
|
158
|
+
childPid: child.pid,
|
|
159
|
+
command: process.execPath,
|
|
160
|
+
args: nodeArgs,
|
|
161
|
+
});
|
|
162
|
+
attachOutputRelay(input, child, 'stdout');
|
|
163
|
+
attachOutputRelay(input, child, 'stderr');
|
|
164
|
+
const unregisterSignalHandlers = registerSignalHandlers(input, child);
|
|
165
|
+
const result = await waitForChildClose(input, child, unregisterSignalHandlers);
|
|
166
|
+
process.exit(getExitCode(result.exitCode, result.signal));
|
|
167
|
+
};
|
package/bin/z.js
CHANGED
|
@@ -3,105 +3,5 @@
|
|
|
3
3
|
* ZinTrust CLI Shortcut - 'z'
|
|
4
4
|
* Mirrors bin/zintrust.ts for convenience
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { createRequire } from 'node:module';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { fileURLToPath } from 'node:url';
|
|
11
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const require = createRequire(import.meta.url);
|
|
13
|
-
const tsTarget = path.join(here, 'zintrust-main.ts');
|
|
14
|
-
const jsTarget = path.join(here, 'zintrust-main.js');
|
|
15
|
-
const target = existsSync(tsTarget) ? tsTarget : jsTarget;
|
|
16
|
-
const tsxImportPath = require.resolve('tsx');
|
|
17
|
-
const nodeArgs = target.endsWith('.ts')
|
|
18
|
-
? ['--import', tsxImportPath, target, ...process.argv.slice(2)]
|
|
19
|
-
: [target, ...process.argv.slice(2)];
|
|
20
|
-
const child = spawn(process.execPath, nodeArgs, {
|
|
21
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
22
|
-
env: process.env,
|
|
23
|
-
});
|
|
24
|
-
child.stdout?.on('data', (chunk) => {
|
|
25
|
-
process.stdout.write(chunk);
|
|
26
|
-
});
|
|
27
|
-
child.stderr?.on('data', (chunk) => {
|
|
28
|
-
process.stderr.write(chunk);
|
|
29
|
-
});
|
|
30
|
-
let childClosed = false;
|
|
31
|
-
let delayedSignalTimer;
|
|
32
|
-
const clearDelayedSignal = () => {
|
|
33
|
-
if (delayedSignalTimer === undefined)
|
|
34
|
-
return;
|
|
35
|
-
clearTimeout(delayedSignalTimer);
|
|
36
|
-
delayedSignalTimer = undefined;
|
|
37
|
-
};
|
|
38
|
-
const forwardSignal = (signal) => {
|
|
39
|
-
if (childClosed)
|
|
40
|
-
return;
|
|
41
|
-
try {
|
|
42
|
-
child.kill(signal);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// best-effort
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const scheduleSignalForward = (signal) => {
|
|
49
|
-
if (childClosed || delayedSignalTimer !== undefined)
|
|
50
|
-
return;
|
|
51
|
-
delayedSignalTimer = globalThis.setTimeout(() => {
|
|
52
|
-
delayedSignalTimer = undefined;
|
|
53
|
-
forwardSignal(signal);
|
|
54
|
-
}, 1500);
|
|
55
|
-
delayedSignalTimer.unref?.();
|
|
56
|
-
};
|
|
57
|
-
const onSigint = () => {
|
|
58
|
-
if (process.stdin.isTTY === true) {
|
|
59
|
-
scheduleSignalForward('SIGINT');
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
forwardSignal('SIGINT');
|
|
63
|
-
};
|
|
64
|
-
const onSigterm = () => {
|
|
65
|
-
if (process.stdin.isTTY === true) {
|
|
66
|
-
scheduleSignalForward('SIGTERM');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
forwardSignal('SIGTERM');
|
|
70
|
-
};
|
|
71
|
-
process.on('SIGINT', onSigint);
|
|
72
|
-
process.on('SIGTERM', onSigterm);
|
|
73
|
-
const result = await new Promise((resolve, reject) => {
|
|
74
|
-
let settled = false;
|
|
75
|
-
let childResult = {
|
|
76
|
-
exitCode: null,
|
|
77
|
-
signal: null,
|
|
78
|
-
};
|
|
79
|
-
const finalize = () => {
|
|
80
|
-
if (settled) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
settled = true;
|
|
84
|
-
childClosed = true;
|
|
85
|
-
clearDelayedSignal();
|
|
86
|
-
process.off('SIGINT', onSigint);
|
|
87
|
-
process.off('SIGTERM', onSigterm);
|
|
88
|
-
child.off?.('error', reject);
|
|
89
|
-
child.off?.('exit', handleExit);
|
|
90
|
-
child.off?.('close', handleClose);
|
|
91
|
-
resolve(childResult);
|
|
92
|
-
};
|
|
93
|
-
const handleExit = (exitCode, signal) => {
|
|
94
|
-
childResult = { exitCode, signal };
|
|
95
|
-
};
|
|
96
|
-
const handleClose = (exitCode, signal) => {
|
|
97
|
-
childResult = {
|
|
98
|
-
exitCode: childResult.exitCode ?? exitCode,
|
|
99
|
-
signal: childResult.signal ?? signal,
|
|
100
|
-
};
|
|
101
|
-
finalize();
|
|
102
|
-
};
|
|
103
|
-
child.once('error', reject);
|
|
104
|
-
child.once('exit', handleExit);
|
|
105
|
-
child.once('close', handleClose);
|
|
106
|
-
});
|
|
107
|
-
process.exit(result.exitCode ?? (result.signal === 'SIGINT' || result.signal === 'SIGTERM' ? 0 : 1));
|
|
6
|
+
import { runCliWrapper } from './launcher.js';
|
|
7
|
+
await runCliWrapper();
|
package/bin/zin.js
CHANGED
|
@@ -3,195 +3,5 @@
|
|
|
3
3
|
* ZinTrust CLI Shortcut - 'zin'
|
|
4
4
|
* Mirrors bin/zintrust.ts for convenience
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { createRequire } from 'node:module';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { fileURLToPath } from 'node:url';
|
|
11
|
-
const CLI_SPAWN_TRACE_ENV_KEYS = ['CLI_SPAWN_TRACE', 'ZIN_SPAWN_TRACE'];
|
|
12
|
-
const isCliSpawnTraceEnabled = () => {
|
|
13
|
-
return CLI_SPAWN_TRACE_ENV_KEYS.some((key) => {
|
|
14
|
-
const raw = process.env[key];
|
|
15
|
-
if (typeof raw !== 'string')
|
|
16
|
-
return false;
|
|
17
|
-
const normalized = raw.trim().toLowerCase();
|
|
18
|
-
return (normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on');
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const writeCliSpawnTrace = (label, details = {}) => {
|
|
22
|
-
if (!isCliSpawnTraceEnabled())
|
|
23
|
-
return;
|
|
24
|
-
process.stderr.write(`${JSON.stringify({ trace: 'cli-wrapper', label, pid: process.pid, details })}\n`);
|
|
25
|
-
};
|
|
26
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
27
|
-
const require = createRequire(import.meta.url);
|
|
28
|
-
const tsTarget = path.join(here, 'zintrust-main.ts');
|
|
29
|
-
const jsTarget = path.join(here, 'zintrust-main.js');
|
|
30
|
-
const target = existsSync(tsTarget) ? tsTarget : jsTarget;
|
|
31
|
-
const tsxImportPath = require.resolve('tsx');
|
|
32
|
-
const nodeArgs = target.endsWith('.ts')
|
|
33
|
-
? ['--import', tsxImportPath, target, ...process.argv.slice(2)]
|
|
34
|
-
: [target, ...process.argv.slice(2)];
|
|
35
|
-
const child = spawn(process.execPath, nodeArgs, {
|
|
36
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
37
|
-
env: process.env,
|
|
38
|
-
});
|
|
39
|
-
writeCliSpawnTrace('wrapper.child.started', {
|
|
40
|
-
childPid: child.pid,
|
|
41
|
-
command: process.execPath,
|
|
42
|
-
args: nodeArgs,
|
|
43
|
-
});
|
|
44
|
-
child.stdout?.on('data', (chunk) => {
|
|
45
|
-
writeCliSpawnTrace('wrapper.child.stdout.data', {
|
|
46
|
-
childPid: child.pid,
|
|
47
|
-
bytes: typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.length,
|
|
48
|
-
});
|
|
49
|
-
process.stdout.write(chunk);
|
|
50
|
-
});
|
|
51
|
-
child.stdout?.on('end', () => {
|
|
52
|
-
writeCliSpawnTrace('wrapper.child.stdout.end', {
|
|
53
|
-
childPid: child.pid,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
child.stdout?.on('close', () => {
|
|
57
|
-
writeCliSpawnTrace('wrapper.child.stdout.close', {
|
|
58
|
-
childPid: child.pid,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
child.stderr?.on('data', (chunk) => {
|
|
62
|
-
writeCliSpawnTrace('wrapper.child.stderr.data', {
|
|
63
|
-
childPid: child.pid,
|
|
64
|
-
bytes: typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.length,
|
|
65
|
-
});
|
|
66
|
-
process.stderr.write(chunk);
|
|
67
|
-
});
|
|
68
|
-
child.stderr?.on('end', () => {
|
|
69
|
-
writeCliSpawnTrace('wrapper.child.stderr.end', {
|
|
70
|
-
childPid: child.pid,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
child.stderr?.on('close', () => {
|
|
74
|
-
writeCliSpawnTrace('wrapper.child.stderr.close', {
|
|
75
|
-
childPid: child.pid,
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
let childClosed = false;
|
|
79
|
-
let delayedSignalTimer;
|
|
80
|
-
const clearDelayedSignal = () => {
|
|
81
|
-
if (delayedSignalTimer === undefined)
|
|
82
|
-
return;
|
|
83
|
-
clearTimeout(delayedSignalTimer);
|
|
84
|
-
delayedSignalTimer = undefined;
|
|
85
|
-
};
|
|
86
|
-
const forwardSignal = (signal) => {
|
|
87
|
-
if (childClosed)
|
|
88
|
-
return;
|
|
89
|
-
try {
|
|
90
|
-
writeCliSpawnTrace('wrapper.signal.forward.attempt', {
|
|
91
|
-
childPid: child.pid,
|
|
92
|
-
signal,
|
|
93
|
-
});
|
|
94
|
-
child.kill(signal);
|
|
95
|
-
writeCliSpawnTrace('wrapper.signal.forward.complete', {
|
|
96
|
-
childPid: child.pid,
|
|
97
|
-
signal,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
// best-effort
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const scheduleSignalForward = (signal) => {
|
|
105
|
-
if (childClosed || delayedSignalTimer !== undefined)
|
|
106
|
-
return;
|
|
107
|
-
delayedSignalTimer = globalThis.setTimeout(() => {
|
|
108
|
-
delayedSignalTimer = undefined;
|
|
109
|
-
writeCliSpawnTrace('wrapper.signal.delay.fire', {
|
|
110
|
-
childPid: child.pid,
|
|
111
|
-
signal,
|
|
112
|
-
});
|
|
113
|
-
forwardSignal(signal);
|
|
114
|
-
}, 1500);
|
|
115
|
-
writeCliSpawnTrace('wrapper.signal.delay.schedule', {
|
|
116
|
-
childPid: child.pid,
|
|
117
|
-
signal,
|
|
118
|
-
delayMs: 1500,
|
|
119
|
-
});
|
|
120
|
-
delayedSignalTimer.unref?.();
|
|
121
|
-
};
|
|
122
|
-
const onSigint = () => {
|
|
123
|
-
writeCliSpawnTrace('wrapper.signal.received', {
|
|
124
|
-
childPid: child.pid,
|
|
125
|
-
signal: 'SIGINT',
|
|
126
|
-
tty: process.stdin.isTTY === true,
|
|
127
|
-
});
|
|
128
|
-
if (process.stdin.isTTY === true) {
|
|
129
|
-
scheduleSignalForward('SIGINT');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
forwardSignal('SIGINT');
|
|
133
|
-
};
|
|
134
|
-
const onSigterm = () => {
|
|
135
|
-
writeCliSpawnTrace('wrapper.signal.received', {
|
|
136
|
-
childPid: child.pid,
|
|
137
|
-
signal: 'SIGTERM',
|
|
138
|
-
tty: process.stdin.isTTY === true,
|
|
139
|
-
});
|
|
140
|
-
if (process.stdin.isTTY === true) {
|
|
141
|
-
scheduleSignalForward('SIGTERM');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
forwardSignal('SIGTERM');
|
|
145
|
-
};
|
|
146
|
-
process.on('SIGINT', onSigint);
|
|
147
|
-
process.on('SIGTERM', onSigterm);
|
|
148
|
-
const result = await new Promise((resolve, reject) => {
|
|
149
|
-
let settled = false;
|
|
150
|
-
let childResult = {
|
|
151
|
-
exitCode: null,
|
|
152
|
-
signal: null,
|
|
153
|
-
};
|
|
154
|
-
const finalize = () => {
|
|
155
|
-
if (settled) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
settled = true;
|
|
159
|
-
writeCliSpawnTrace('wrapper.child.finalize', {
|
|
160
|
-
childPid: child.pid,
|
|
161
|
-
exitCode: childResult.exitCode,
|
|
162
|
-
signal: childResult.signal,
|
|
163
|
-
});
|
|
164
|
-
childClosed = true;
|
|
165
|
-
clearDelayedSignal();
|
|
166
|
-
process.off('SIGINT', onSigint);
|
|
167
|
-
process.off('SIGTERM', onSigterm);
|
|
168
|
-
child.off?.('error', reject);
|
|
169
|
-
child.off?.('exit', handleExit);
|
|
170
|
-
child.off?.('close', handleClose);
|
|
171
|
-
resolve(childResult);
|
|
172
|
-
};
|
|
173
|
-
const handleExit = (exitCode, signal) => {
|
|
174
|
-
writeCliSpawnTrace('wrapper.child.exit', {
|
|
175
|
-
childPid: child.pid,
|
|
176
|
-
exitCode,
|
|
177
|
-
signal,
|
|
178
|
-
});
|
|
179
|
-
childResult = { exitCode, signal };
|
|
180
|
-
};
|
|
181
|
-
const handleClose = (exitCode, signal) => {
|
|
182
|
-
writeCliSpawnTrace('wrapper.child.close', {
|
|
183
|
-
childPid: child.pid,
|
|
184
|
-
exitCode,
|
|
185
|
-
signal,
|
|
186
|
-
});
|
|
187
|
-
childResult = {
|
|
188
|
-
exitCode: childResult.exitCode ?? exitCode,
|
|
189
|
-
signal: childResult.signal ?? signal,
|
|
190
|
-
};
|
|
191
|
-
finalize();
|
|
192
|
-
};
|
|
193
|
-
child.once('error', reject);
|
|
194
|
-
child.once('exit', handleExit);
|
|
195
|
-
child.once('close', handleClose);
|
|
196
|
-
});
|
|
197
|
-
process.exit(result.exitCode ?? (result.signal === 'SIGINT' || result.signal === 'SIGTERM' ? 0 : 1));
|
|
6
|
+
import { runCliWrapper } from './launcher.js';
|
|
7
|
+
await runCliWrapper({ traceName: 'cli-wrapper' });
|
package/bin/zintrust.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This bin script is a thin wrapper around the hashbang-free implementation in
|
|
6
6
|
* bin/zintrust-main.ts. Keeping the implementation hashbang-free allows other
|
|
7
|
-
* shortcuts (zin/z/zt) to
|
|
7
|
+
* shortcuts (zin/z/zt) to reuse the same launcher behavior.
|
|
8
8
|
*/
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=zintrust.d.ts.map
|
package/bin/zintrust.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG"}
|
package/bin/zintrust.js
CHANGED
|
@@ -4,107 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This bin script is a thin wrapper around the hashbang-free implementation in
|
|
6
6
|
* bin/zintrust-main.ts. Keeping the implementation hashbang-free allows other
|
|
7
|
-
* shortcuts (zin/z/zt) to
|
|
7
|
+
* shortcuts (zin/z/zt) to reuse the same launcher behavior.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { createRequire } from 'node:module';
|
|
12
|
-
import path from 'node:path';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
14
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
const require = createRequire(import.meta.url);
|
|
16
|
-
const tsTarget = path.join(here, 'zintrust-main.ts');
|
|
17
|
-
const jsTarget = path.join(here, 'zintrust-main.js');
|
|
18
|
-
const target = existsSync(tsTarget) ? tsTarget : jsTarget;
|
|
19
|
-
const tsxImportPath = require.resolve('tsx');
|
|
20
|
-
const nodeArgs = target.endsWith('.ts')
|
|
21
|
-
? ['--import', tsxImportPath, target, ...process.argv.slice(2)]
|
|
22
|
-
: [target, ...process.argv.slice(2)];
|
|
23
|
-
const child = spawn(process.execPath, nodeArgs, {
|
|
24
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
25
|
-
env: process.env,
|
|
26
|
-
});
|
|
27
|
-
child.stdout?.on('data', (chunk) => {
|
|
28
|
-
process.stdout.write(chunk);
|
|
29
|
-
});
|
|
30
|
-
child.stderr?.on('data', (chunk) => {
|
|
31
|
-
process.stderr.write(chunk);
|
|
32
|
-
});
|
|
33
|
-
let childClosed = false;
|
|
34
|
-
let delayedSignalTimer;
|
|
35
|
-
const clearDelayedSignal = () => {
|
|
36
|
-
if (delayedSignalTimer === undefined)
|
|
37
|
-
return;
|
|
38
|
-
clearTimeout(delayedSignalTimer);
|
|
39
|
-
delayedSignalTimer = undefined;
|
|
40
|
-
};
|
|
41
|
-
const forwardSignal = (signal) => {
|
|
42
|
-
if (childClosed)
|
|
43
|
-
return;
|
|
44
|
-
try {
|
|
45
|
-
child.kill(signal);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
// best-effort
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const scheduleSignalForward = (signal) => {
|
|
52
|
-
if (childClosed || delayedSignalTimer !== undefined)
|
|
53
|
-
return;
|
|
54
|
-
delayedSignalTimer = globalThis.setTimeout(() => {
|
|
55
|
-
delayedSignalTimer = undefined;
|
|
56
|
-
forwardSignal(signal);
|
|
57
|
-
}, 1500);
|
|
58
|
-
delayedSignalTimer.unref?.();
|
|
59
|
-
};
|
|
60
|
-
const onSigint = () => {
|
|
61
|
-
if (process.stdin.isTTY === true) {
|
|
62
|
-
scheduleSignalForward('SIGINT');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
forwardSignal('SIGINT');
|
|
66
|
-
};
|
|
67
|
-
const onSigterm = () => {
|
|
68
|
-
if (process.stdin.isTTY === true) {
|
|
69
|
-
scheduleSignalForward('SIGTERM');
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
forwardSignal('SIGTERM');
|
|
73
|
-
};
|
|
74
|
-
process.on('SIGINT', onSigint);
|
|
75
|
-
process.on('SIGTERM', onSigterm);
|
|
76
|
-
const result = await new Promise((resolve, reject) => {
|
|
77
|
-
let settled = false;
|
|
78
|
-
let childResult = {
|
|
79
|
-
exitCode: null,
|
|
80
|
-
signal: null,
|
|
81
|
-
};
|
|
82
|
-
const finalize = () => {
|
|
83
|
-
if (settled) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
settled = true;
|
|
87
|
-
childClosed = true;
|
|
88
|
-
clearDelayedSignal();
|
|
89
|
-
process.off('SIGINT', onSigint);
|
|
90
|
-
process.off('SIGTERM', onSigterm);
|
|
91
|
-
child.off?.('error', reject);
|
|
92
|
-
child.off?.('exit', handleExit);
|
|
93
|
-
child.off?.('close', handleClose);
|
|
94
|
-
resolve(childResult);
|
|
95
|
-
};
|
|
96
|
-
const handleExit = (exitCode, signal) => {
|
|
97
|
-
childResult = { exitCode, signal };
|
|
98
|
-
};
|
|
99
|
-
const handleClose = (exitCode, signal) => {
|
|
100
|
-
childResult = {
|
|
101
|
-
exitCode: childResult.exitCode ?? exitCode,
|
|
102
|
-
signal: childResult.signal ?? signal,
|
|
103
|
-
};
|
|
104
|
-
finalize();
|
|
105
|
-
};
|
|
106
|
-
child.once('error', reject);
|
|
107
|
-
child.once('exit', handleExit);
|
|
108
|
-
child.once('close', handleClose);
|
|
109
|
-
});
|
|
110
|
-
process.exit(result.exitCode ?? (result.signal === 'SIGINT' || result.signal === 'SIGTERM' ? 0 : 1));
|
|
9
|
+
import { runCliWrapper } from './launcher.js';
|
|
10
|
+
await runCliWrapper();
|
package/bin/zt.d.ts
CHANGED
package/bin/zt.js
CHANGED
|
@@ -1,104 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* ZinTrust CLI Shortcut - '
|
|
3
|
+
* ZinTrust CLI Shortcut - 'zt'
|
|
4
4
|
* Mirrors bin/zintrust.ts for convenience
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const tsTarget = path.join(here, 'zintrust-main.ts');
|
|
12
|
-
const jsTarget = path.join(here, 'zintrust-main.js');
|
|
13
|
-
const target = existsSync(tsTarget) ? tsTarget : jsTarget;
|
|
14
|
-
const nodeArgs = target.endsWith('.ts')
|
|
15
|
-
? ['--import', 'tsx', target, ...process.argv.slice(2)]
|
|
16
|
-
: [target, ...process.argv.slice(2)];
|
|
17
|
-
const child = spawn(process.execPath, nodeArgs, {
|
|
18
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
19
|
-
env: process.env,
|
|
20
|
-
});
|
|
21
|
-
child.stdout?.on('data', (chunk) => {
|
|
22
|
-
process.stdout.write(chunk);
|
|
23
|
-
});
|
|
24
|
-
child.stderr?.on('data', (chunk) => {
|
|
25
|
-
process.stderr.write(chunk);
|
|
26
|
-
});
|
|
27
|
-
let childClosed = false;
|
|
28
|
-
let delayedSignalTimer;
|
|
29
|
-
const clearDelayedSignal = () => {
|
|
30
|
-
if (delayedSignalTimer === undefined)
|
|
31
|
-
return;
|
|
32
|
-
clearTimeout(delayedSignalTimer);
|
|
33
|
-
delayedSignalTimer = undefined;
|
|
34
|
-
};
|
|
35
|
-
const forwardSignal = (signal) => {
|
|
36
|
-
if (childClosed)
|
|
37
|
-
return;
|
|
38
|
-
try {
|
|
39
|
-
child.kill(signal);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
// best-effort
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const scheduleSignalForward = (signal) => {
|
|
46
|
-
if (childClosed || delayedSignalTimer !== undefined)
|
|
47
|
-
return;
|
|
48
|
-
delayedSignalTimer = globalThis.setTimeout(() => {
|
|
49
|
-
delayedSignalTimer = undefined;
|
|
50
|
-
forwardSignal(signal);
|
|
51
|
-
}, 1500);
|
|
52
|
-
delayedSignalTimer.unref?.();
|
|
53
|
-
};
|
|
54
|
-
const onSigint = () => {
|
|
55
|
-
if (process.stdin.isTTY === true) {
|
|
56
|
-
scheduleSignalForward('SIGINT');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
forwardSignal('SIGINT');
|
|
60
|
-
};
|
|
61
|
-
const onSigterm = () => {
|
|
62
|
-
if (process.stdin.isTTY === true) {
|
|
63
|
-
scheduleSignalForward('SIGTERM');
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
forwardSignal('SIGTERM');
|
|
67
|
-
};
|
|
68
|
-
process.on('SIGINT', onSigint);
|
|
69
|
-
process.on('SIGTERM', onSigterm);
|
|
70
|
-
const result = await new Promise((resolve, reject) => {
|
|
71
|
-
let settled = false;
|
|
72
|
-
let childResult = {
|
|
73
|
-
exitCode: null,
|
|
74
|
-
signal: null,
|
|
75
|
-
};
|
|
76
|
-
const finalize = () => {
|
|
77
|
-
if (settled) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
settled = true;
|
|
81
|
-
childClosed = true;
|
|
82
|
-
clearDelayedSignal();
|
|
83
|
-
process.off('SIGINT', onSigint);
|
|
84
|
-
process.off('SIGTERM', onSigterm);
|
|
85
|
-
child.off?.('error', reject);
|
|
86
|
-
child.off?.('exit', handleExit);
|
|
87
|
-
child.off?.('close', handleClose);
|
|
88
|
-
resolve(childResult);
|
|
89
|
-
};
|
|
90
|
-
const handleExit = (exitCode, signal) => {
|
|
91
|
-
childResult = { exitCode, signal };
|
|
92
|
-
};
|
|
93
|
-
const handleClose = (exitCode, signal) => {
|
|
94
|
-
childResult = {
|
|
95
|
-
exitCode: childResult.exitCode ?? exitCode,
|
|
96
|
-
signal: childResult.signal ?? signal,
|
|
97
|
-
};
|
|
98
|
-
finalize();
|
|
99
|
-
};
|
|
100
|
-
child.once('error', reject);
|
|
101
|
-
child.once('exit', handleExit);
|
|
102
|
-
child.once('close', handleClose);
|
|
103
|
-
});
|
|
104
|
-
process.exit(result.exitCode ?? (result.signal === 'SIGINT' || result.signal === 'SIGTERM' ? 0 : 1));
|
|
6
|
+
import { runCliWrapper } from './launcher.js';
|
|
7
|
+
await runCliWrapper();
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { IShutdownManager } from './type';
|
|
2
2
|
import type { IRouter } from '../../index.js';
|
|
3
3
|
export declare const registerFrameworkShutdownHooks: (shutdownManager: IShutdownManager) => void;
|
|
4
|
-
|
|
4
|
+
type LifecycleParams = {
|
|
5
5
|
environment: string;
|
|
6
6
|
resolvedBasePath: string;
|
|
7
7
|
router: IRouter;
|
|
8
8
|
shutdownManager: IShutdownManager;
|
|
9
9
|
getBooted: () => boolean;
|
|
10
10
|
setBooted: (value: boolean) => void;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
|
+
export declare const createLifecycle: (params: LifecycleParams) => {
|
|
12
13
|
boot: () => Promise<void>;
|
|
13
14
|
shutdown: () => Promise<void>;
|
|
14
15
|
};
|
|
16
|
+
export {};
|
|
15
17
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -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;AAUvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAkQ9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA6BlF,CAAC;AA8UF,
|
|
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;AAUvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAkQ9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA6BlF,CAAC;AA8UF,KAAK,eAAe,GAAG;IACrB,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,CAAC;AA4HF,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,KACtB;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAK5D,CAAC"}
|
|
@@ -495,8 +495,34 @@ const initializeSockets = (router) => {
|
|
|
495
495
|
Logger.info(`Transport: ${diagnostics.transport}`);
|
|
496
496
|
Logger.info(`Path: ${diagnostics.path}`);
|
|
497
497
|
};
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
const initializeRuntimeRoutes = async (params) => {
|
|
499
|
+
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
500
|
+
await registerMasterRoutes(params.resolvedBasePath, params.router);
|
|
501
|
+
initializeSockets(params.router);
|
|
502
|
+
await initializeSystemTrace(params.router);
|
|
503
|
+
if (Cloudflare.getWorkersEnv() === null && appConfig.dockerWorker === false) {
|
|
504
|
+
if (appConfig.worker === true) {
|
|
505
|
+
await initializeWorkers(params.router);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
Logger.info('Skipping worker route registration (WORKER_ENABLED=false).');
|
|
509
|
+
}
|
|
510
|
+
await initializeQueueMonitor(params.router);
|
|
511
|
+
if (appConfig.worker === true) {
|
|
512
|
+
await initializeQueueHttpGateway(params.router);
|
|
513
|
+
await initializeScheduleHttpGateway(params.router);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
Logger.info('Skipping worker execution/gateway initialization (WORKER_ENABLED=false).');
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (!appConfig.dockerWorker) {
|
|
521
|
+
Logger.info('Skipping local worker dashboards in Cloudflare Workers runtime.');
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
const createBootLifecycle = (params) => {
|
|
525
|
+
return async () => {
|
|
500
526
|
if (params.getBooted())
|
|
501
527
|
return;
|
|
502
528
|
Logger.info(`🚀 Booting ZinTrust Application in ${params.environment} mode...`);
|
|
@@ -515,7 +541,6 @@ export const createLifecycle = (params) => {
|
|
|
515
541
|
warnings: startupConfigValidation.warnings,
|
|
516
542
|
});
|
|
517
543
|
}
|
|
518
|
-
// Preload project-owned config overrides that must be available synchronously.
|
|
519
544
|
await StartupConfigFileRegistry.preload([
|
|
520
545
|
StartupConfigFile.Middleware,
|
|
521
546
|
StartupConfigFile.Cache,
|
|
@@ -529,35 +554,13 @@ export const createLifecycle = (params) => {
|
|
|
529
554
|
FeatureFlags.initialize();
|
|
530
555
|
await StartupHealthChecks.assertHealthy();
|
|
531
556
|
await registerFromRuntimeConfig();
|
|
532
|
-
await
|
|
533
|
-
await registerMasterRoutes(params.resolvedBasePath, params.router);
|
|
534
|
-
initializeSockets(params.router);
|
|
535
|
-
await initializeSystemTrace(params.router);
|
|
536
|
-
if (Cloudflare.getWorkersEnv() === null && appConfig.dockerWorker === false) {
|
|
537
|
-
if (appConfig.worker === true) {
|
|
538
|
-
await initializeWorkers(params.router);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
Logger.info('Skipping worker route registration (WORKER_ENABLED=false).');
|
|
542
|
-
}
|
|
543
|
-
await initializeQueueMonitor(params.router);
|
|
544
|
-
if (appConfig.worker === true) {
|
|
545
|
-
await initializeQueueHttpGateway(params.router);
|
|
546
|
-
await initializeScheduleHttpGateway(params.router);
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
Logger.info('Skipping worker execution/gateway initialization (WORKER_ENABLED=false).');
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
else if (!appConfig.dockerWorker) {
|
|
553
|
-
Logger.info('Skipping local worker dashboards in Cloudflare Workers runtime.');
|
|
554
|
-
}
|
|
555
|
-
// Register service providers
|
|
556
|
-
// Bootstrap services
|
|
557
|
+
await initializeRuntimeRoutes(params);
|
|
557
558
|
Logger.info('✅ Application booted successfully');
|
|
558
559
|
params.setBooted(true);
|
|
559
560
|
};
|
|
560
|
-
|
|
561
|
+
};
|
|
562
|
+
const createShutdownLifecycle = (params) => {
|
|
563
|
+
return async () => {
|
|
561
564
|
Logger.info('🛑 Shutting down application...');
|
|
562
565
|
ShutdownTrace.logHandles('runtime.lifecycle.shutdown.start');
|
|
563
566
|
QueueReliabilityOrchestrator.stop();
|
|
@@ -588,7 +591,6 @@ export const createLifecycle = (params) => {
|
|
|
588
591
|
error: error instanceof Error ? error.message : String(error),
|
|
589
592
|
});
|
|
590
593
|
}
|
|
591
|
-
// Ensure FileLogWriter.flush is attempted even if dynamic registration failed.
|
|
592
594
|
try {
|
|
593
595
|
const fileLogWriter = await tryImportOptional('@config/FileLogWriter');
|
|
594
596
|
fileLogWriter?.FileLogWriter?.flush?.();
|
|
@@ -599,5 +601,9 @@ export const createLifecycle = (params) => {
|
|
|
599
601
|
params.setBooted(false);
|
|
600
602
|
ShutdownTrace.logHandles('runtime.lifecycle.shutdown.complete');
|
|
601
603
|
};
|
|
604
|
+
};
|
|
605
|
+
export const createLifecycle = (params) => {
|
|
606
|
+
const boot = createBootLifecycle(params);
|
|
607
|
+
const shutdown = createShutdownLifecycle(params);
|
|
602
608
|
return { boot, shutdown };
|
|
603
609
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShutdownTrace.d.ts","sourceRoot":"","sources":["../../../src/helper/ShutdownTrace.ts"],"names":[],"mappings":"AAKA,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ShutdownTrace.d.ts","sourceRoot":"","sources":["../../../src/helper/ShutdownTrace.ts"],"names":[],"mappings":"AAKA,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAoLpD,eAAO,MAAM,aAAa;qBAnKJ,OAAO;iBAwFT,MAAM,YAAW,oBAAoB,KAAQ,IAAI;wBAY1C,MAAM,YAAW,oBAAoB,KAAQ,IAAI;6BA8BnE,MAAM,UACL,OAAO,YACN,oBAAoB,KAC5B,IAAI;EAmCL,CAAC"}
|
|
@@ -4,16 +4,12 @@ const writeLine = (line) => {
|
|
|
4
4
|
const nodeProcess = getNodeProcess();
|
|
5
5
|
if (nodeProcess?.stderr && typeof nodeProcess.stderr.write === 'function') {
|
|
6
6
|
nodeProcess.stderr.write(`${line}\n`);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (typeof console !== 'undefined' && typeof console.info === 'function') {
|
|
10
|
-
console.info(line);
|
|
11
7
|
}
|
|
12
8
|
};
|
|
13
9
|
const getNodeProcess = () => {
|
|
14
10
|
if (typeof process === 'undefined')
|
|
15
11
|
return null;
|
|
16
|
-
return process;
|
|
12
|
+
return process; // NOSONAR
|
|
17
13
|
};
|
|
18
14
|
const isEnabled = () => {
|
|
19
15
|
const nodeProcess = getNodeProcess();
|
|
@@ -99,20 +95,7 @@ const log = (label, details = {}) => {
|
|
|
99
95
|
const logHandles = (label, details = {}) => {
|
|
100
96
|
if (!isEnabled())
|
|
101
97
|
return;
|
|
102
|
-
const nodeProcess = getNodeProcess();
|
|
103
|
-
if (nodeProcess === null) {
|
|
104
|
-
writeLine(JSON.stringify({
|
|
105
|
-
level: 'info',
|
|
106
|
-
trace: 'shutdown',
|
|
107
|
-
label,
|
|
108
|
-
details: {
|
|
109
|
-
...details,
|
|
110
|
-
available: false,
|
|
111
|
-
reason: 'process unavailable',
|
|
112
|
-
},
|
|
113
|
-
}));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
98
|
+
const nodeProcess = getNodeProcess(); //NOSONAR
|
|
116
99
|
const handles = typeof nodeProcess._getActiveHandles === 'function' ? nodeProcess._getActiveHandles() : [];
|
|
117
100
|
const requests = typeof nodeProcess._getActiveRequests === 'function' ? nodeProcess._getActiveRequests() : [];
|
|
118
101
|
writeLine(JSON.stringify({
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v1.
|
|
2
|
+
* @zintrust/core v1.6.0
|
|
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-
|
|
8
|
+
* Built: 2026-04-29T16:55:46.596Z
|
|
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-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-04-29T16:55:46.563Z'; // 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,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
-
* optional adapters/drivers into core registries.
|
|
7
|
-
*
|
|
2
|
+
* Auto-generated fallback module.
|
|
3
|
+
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
|
+
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
8
5
|
*/
|
|
9
6
|
export type {};
|
|
10
7
|
export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,YAAY,EAAE,CAAC;AAgBf,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;;AACnE,wBAAkB"}
|
package/src/zintrust.plugins.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
-
* optional adapters/drivers into core registries.
|
|
7
|
-
*
|
|
2
|
+
* Auto-generated fallback module.
|
|
3
|
+
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
|
+
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
8
5
|
*/
|
|
9
6
|
import * as TraceRuntime from './runtime/plugins/trace-runtime.js';
|
|
10
7
|
globalThis.__zintrust_system_trace_plugin_requested__ = true;
|