@zintrust/core 0.4.41 → 0.4.42
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/package.json +3 -2
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +120 -0
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/Cache.js +25 -2
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +8 -0
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +2 -0
- package/src/cli/OptionalCliExtensions.d.ts.map +1 -1
- package/src/cli/OptionalCliExtensions.js +12 -0
- package/src/cli/cloudflare/CloudflareWranglerDevEnv.d.ts +24 -0
- package/src/cli/cloudflare/CloudflareWranglerDevEnv.d.ts.map +1 -0
- package/src/cli/cloudflare/CloudflareWranglerDevEnv.js +174 -0
- package/src/cli/commands/DebuggerCommand.d.ts +18 -0
- package/src/cli/commands/DebuggerCommand.d.ts.map +1 -0
- package/src/cli/commands/DebuggerCommand.js +6 -0
- package/src/cli/commands/DebuggerCommands.d.ts +25 -0
- package/src/cli/commands/DebuggerCommands.d.ts.map +1 -0
- package/src/cli/commands/DebuggerCommands.js +454 -0
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.js +56 -20
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +12 -94
- package/src/cli/commands/WranglerDevVarsCommand.d.ts +6 -0
- package/src/cli/commands/WranglerDevVarsCommand.d.ts.map +1 -0
- package/src/cli/commands/WranglerDevVarsCommand.js +52 -0
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/index.d.ts +1 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +1 -0
- package/src/cli.d.ts +1 -0
- package/src/cli.d.ts.map +1 -1
- package/src/cli.js +1 -0
- package/src/config/logger.d.ts +7 -0
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +37 -0
- package/src/debugger/SystemDebuggerBridge.d.ts +15 -0
- package/src/debugger/SystemDebuggerBridge.d.ts.map +1 -0
- package/src/debugger/SystemDebuggerBridge.js +109 -0
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +3 -0
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +27 -8
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +8 -0
- package/src/http/RequestContext.d.ts +1 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +9 -1
- package/src/index.d.ts +4 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +5 -3
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +2 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +0 -14
- package/src/orm/Model.d.ts +8 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +193 -109
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +85 -1
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -1
- package/src/runtime/WorkerAdapterImports.js +1 -6
- package/src/runtime/WorkerProjectPlugins.d.ts +6 -0
- package/src/runtime/WorkerProjectPlugins.d.ts.map +1 -0
- package/src/runtime/WorkerProjectPlugins.js +5 -0
- package/src/runtime/plugins/system-debugger-runtime.d.ts +19 -0
- package/src/runtime/plugins/system-debugger-runtime.d.ts.map +1 -0
- package/src/runtime/plugins/system-debugger-runtime.js +19 -0
- package/src/runtime/plugins/system-debugger.d.ts +2 -0
- package/src/runtime/plugins/system-debugger.d.ts.map +1 -0
- package/src/runtime/plugins/system-debugger.js +14 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +29 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +2 -0
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +7 -1
- package/src/tools/notification/Service.d.ts.map +1 -1
- package/src/tools/notification/Service.js +18 -6
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +2 -0
- package/src/zintrust.plugins.d.ts +1 -0
- package/src/zintrust.plugins.d.ts.map +1 -1
- package/src/zintrust.plugins.js +3 -21
- package/src/zintrust.plugins.wg.d.ts +1 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -1
- package/src/zintrust.plugins.wg.js +3 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
-
import {
|
|
2
|
+
import { withWranglerDevVarsSnapshot } from '../cloudflare/CloudflareWranglerDevEnv.js';
|
|
3
3
|
import { createDenoRunnerSource, createLambdaRunnerSource } from '../commands/runner/index.js';
|
|
4
4
|
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
5
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
@@ -7,7 +7,7 @@ import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
|
7
7
|
import * as Common from '../../common/index.js';
|
|
8
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
9
|
import { isNonEmptyString } from '../../helper/index.js';
|
|
10
|
-
import { existsSync, mkdirSync, readFileSync,
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
11
11
|
import * as path from '../../node-singletons/path.js';
|
|
12
12
|
import { ProjectRuntime } from '../../runtime/ProjectRuntime.js';
|
|
13
13
|
const isAsciiUppercaseLetter = (value) => value >= 'A' && value <= 'Z';
|
|
@@ -337,82 +337,6 @@ const buildStartEnv = (projectRoot) => ({
|
|
|
337
337
|
...process.env,
|
|
338
338
|
ZINTRUST_PROJECT_ROOT: projectRoot,
|
|
339
339
|
});
|
|
340
|
-
const WRANGLER_RUNTIME_ENV_KEYS = Object.freeze([
|
|
341
|
-
'APP_PORT',
|
|
342
|
-
'CLOUDFLARE_WORKER',
|
|
343
|
-
'DOCKER_WORKER',
|
|
344
|
-
'ENVIRONMENT',
|
|
345
|
-
'HOST',
|
|
346
|
-
'NODE_ENV',
|
|
347
|
-
'PORT',
|
|
348
|
-
'RUNTIME',
|
|
349
|
-
'SERVICE_DOMAIN',
|
|
350
|
-
'SERVICE_NAME',
|
|
351
|
-
'SERVICE_PORT',
|
|
352
|
-
'WORKER_ENABLED',
|
|
353
|
-
'ZINTRUST_PROJECT_ROOT',
|
|
354
|
-
]);
|
|
355
|
-
const buildWorkerDevVarsContent = (selectedKeys) => {
|
|
356
|
-
const allowedKeys = selectedKeys === undefined || selectedKeys.length === 0
|
|
357
|
-
? undefined
|
|
358
|
-
: new Set([...WRANGLER_RUNTIME_ENV_KEYS, ...selectedKeys]);
|
|
359
|
-
return (Object.entries(process.env)
|
|
360
|
-
.filter((entry) => {
|
|
361
|
-
const [key, value] = entry;
|
|
362
|
-
return (isWranglerVarName(key) &&
|
|
363
|
-
typeof value === 'string' &&
|
|
364
|
-
(allowedKeys === undefined || allowedKeys.has(key)));
|
|
365
|
-
})
|
|
366
|
-
.map(([key, value]) => `${key}=${JSON.stringify(value)}`)
|
|
367
|
-
.join('\n') + '\n');
|
|
368
|
-
};
|
|
369
|
-
const getWranglerEnvBackupPath = (targetPath) => `${targetPath}.disabled-by-zin`;
|
|
370
|
-
const reconcileWranglerEnvBackup = (targetPath, backupPath) => {
|
|
371
|
-
const hasTarget = existsSync(targetPath);
|
|
372
|
-
const hasBackup = existsSync(backupPath);
|
|
373
|
-
if (!hasBackup)
|
|
374
|
-
return;
|
|
375
|
-
if (!hasTarget) {
|
|
376
|
-
renameSync(backupPath, targetPath);
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
unlinkSync(backupPath);
|
|
380
|
-
};
|
|
381
|
-
async function withWranglerEnvSnapshot(cwd, envName, selectedKeys, fn) {
|
|
382
|
-
const normalizedEnv = typeof envName === 'string' ? envName.trim() : '';
|
|
383
|
-
const targetName = normalizedEnv === '' ? '.dev.vars' : `.dev.vars.${normalizedEnv}`;
|
|
384
|
-
const targetPath = path.join(cwd, targetName);
|
|
385
|
-
const backupPath = getWranglerEnvBackupPath(targetPath);
|
|
386
|
-
try {
|
|
387
|
-
reconcileWranglerEnvBackup(targetPath, backupPath);
|
|
388
|
-
}
|
|
389
|
-
catch {
|
|
390
|
-
// noop
|
|
391
|
-
}
|
|
392
|
-
if (existsSync(targetPath)) {
|
|
393
|
-
renameSync(targetPath, backupPath);
|
|
394
|
-
}
|
|
395
|
-
try {
|
|
396
|
-
writeFileSync(targetPath, buildWorkerDevVarsContent(selectedKeys), 'utf-8');
|
|
397
|
-
return await fn();
|
|
398
|
-
}
|
|
399
|
-
finally {
|
|
400
|
-
try {
|
|
401
|
-
if (existsSync(targetPath))
|
|
402
|
-
unlinkSync(targetPath);
|
|
403
|
-
}
|
|
404
|
-
catch {
|
|
405
|
-
// noop
|
|
406
|
-
}
|
|
407
|
-
try {
|
|
408
|
-
if (existsSync(backupPath))
|
|
409
|
-
renameSync(backupPath, targetPath);
|
|
410
|
-
}
|
|
411
|
-
catch {
|
|
412
|
-
// noop
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
340
|
const resolveManifestServiceEnvDir = (projectRoot, entry) => {
|
|
417
341
|
const configRoot = entry.configRoot;
|
|
418
342
|
if (isNonEmptyString(configRoot)) {
|
|
@@ -564,19 +488,7 @@ const buildWranglerDevArgs = (args) => {
|
|
|
564
488
|
}
|
|
565
489
|
return wranglerArgs;
|
|
566
490
|
};
|
|
567
|
-
const
|
|
568
|
-
const zintrustConfigPath = path.join(context.projectRoot, '.zintrust.json');
|
|
569
|
-
if (!existsSync(zintrustConfigPath))
|
|
570
|
-
return undefined;
|
|
571
|
-
return resolveCloudflareEnvKeys({
|
|
572
|
-
config: readZintrustConfig(context.projectRoot),
|
|
573
|
-
projectRoot: context.projectRoot,
|
|
574
|
-
cwd: context.cwd,
|
|
575
|
-
...(configPath === undefined ? {} : { configPath }),
|
|
576
|
-
...(envName === undefined ? {} : { wranglerEnv: envName }),
|
|
577
|
-
});
|
|
578
|
-
};
|
|
579
|
-
const executeWranglerStart = async (cmd, context, port, runtime, envName, wranglerConfig) => {
|
|
491
|
+
const executeWranglerStart = async (cmd, context, port, runtime, envName, wranglerConfig, envPath) => {
|
|
580
492
|
if (runtime !== undefined) {
|
|
581
493
|
throw ErrorFactory.createCliError('Error: --runtime is not supported with --wrangler (Wrangler controls Workers runtime).');
|
|
582
494
|
}
|
|
@@ -591,8 +503,13 @@ const executeWranglerStart = async (cmd, context, port, runtime, envName, wrangl
|
|
|
591
503
|
});
|
|
592
504
|
logMySqlProxyHint(cmd);
|
|
593
505
|
cmd.info('Starting in Wrangler dev mode...');
|
|
594
|
-
const
|
|
595
|
-
|
|
506
|
+
const exitCode = await withWranglerDevVarsSnapshot({
|
|
507
|
+
cwd: context.cwd,
|
|
508
|
+
projectRoot: context.projectRoot,
|
|
509
|
+
envName,
|
|
510
|
+
...(envPath === undefined ? {} : { envPath }),
|
|
511
|
+
...(configPath === undefined ? {} : { configPath }),
|
|
512
|
+
}, async () => {
|
|
596
513
|
const startEnv = {
|
|
597
514
|
...buildStartEnv(context.projectRoot),
|
|
598
515
|
WORKER_ENABLED: 'false',
|
|
@@ -805,7 +722,8 @@ const executeStart = async (options, cmd) => {
|
|
|
805
722
|
const wranglerConfig = typeof options.wranglerConfig === 'string' && options.wranglerConfig.trim() !== ''
|
|
806
723
|
? options.wranglerConfig.trim()
|
|
807
724
|
: undefined;
|
|
808
|
-
|
|
725
|
+
const envPath = resolveEnvPath(options, context.projectRoot);
|
|
726
|
+
await executeWranglerStart(cmd, context, port, runtime, envName === '' ? undefined : envName, wranglerConfig, envPath);
|
|
809
727
|
return;
|
|
810
728
|
}
|
|
811
729
|
if (envName !== '') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WranglerDevVarsCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerDevVarsCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA2DvF,eAAO,MAAM,sBAAsB;cACvB,YAAY;EAYtB,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { materializeWranglerDevVars } from '../cloudflare/CloudflareWranglerDevEnv.js';
|
|
3
|
+
const optionalTrimmed = (value) => {
|
|
4
|
+
if (typeof value !== 'string')
|
|
5
|
+
return undefined;
|
|
6
|
+
const trimmed = value.trim();
|
|
7
|
+
return trimmed === '' ? undefined : trimmed;
|
|
8
|
+
};
|
|
9
|
+
const addOptions = (command) => {
|
|
10
|
+
command
|
|
11
|
+
.option('--env <name>', 'Wrangler environment name used for .dev.vars.<env> output')
|
|
12
|
+
.option('--env-path <path>', 'Env file used as source values for generated Wrangler dev vars', '.env')
|
|
13
|
+
.option('--target <id>', 'Cloudflare worker target key from .zintrust.json cloudflare.targets')
|
|
14
|
+
.option('-c, --config <path>', 'Wrangler config file used for target inference (optional)');
|
|
15
|
+
};
|
|
16
|
+
const execute = async (cmd, options) => {
|
|
17
|
+
const result = await materializeWranglerDevVars({
|
|
18
|
+
cwd: process.cwd(),
|
|
19
|
+
projectRoot: process.cwd(),
|
|
20
|
+
...(optionalTrimmed(options.env) === undefined
|
|
21
|
+
? {}
|
|
22
|
+
: { envName: optionalTrimmed(options.env) }),
|
|
23
|
+
...(optionalTrimmed(options.envPath) === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { envPath: optionalTrimmed(options.envPath) }),
|
|
26
|
+
...(optionalTrimmed(options.target) === undefined
|
|
27
|
+
? {}
|
|
28
|
+
: { target: optionalTrimmed(options.target) }),
|
|
29
|
+
...(optionalTrimmed(options.config) === undefined
|
|
30
|
+
? {}
|
|
31
|
+
: { configPath: optionalTrimmed(options.config) }),
|
|
32
|
+
requireSelection: true,
|
|
33
|
+
});
|
|
34
|
+
cmd.success(`Wrangler dev vars prepared at ${result.filePath}`);
|
|
35
|
+
cmd.info(`Selected keys: ${result.selectedKeys.length}`);
|
|
36
|
+
if (result.missingKeys.length > 0) {
|
|
37
|
+
cmd.warn(`Missing keys: ${result.missingKeys.join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const WranglerDevVarsCommand = Object.freeze({
|
|
41
|
+
create() {
|
|
42
|
+
const cmd = BaseCommand.create({
|
|
43
|
+
name: 'wrangler:dev-vars',
|
|
44
|
+
description: 'Generate manifest-scoped Wrangler .dev.vars files for local Worker development',
|
|
45
|
+
aliases: ['cloudflare:dev-vars'],
|
|
46
|
+
addOptions,
|
|
47
|
+
execute: async (options) => execute(cmd, options),
|
|
48
|
+
});
|
|
49
|
+
return cmd;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
export default WranglerDevVarsCommand;
|
|
@@ -8,6 +8,7 @@ export { ContainerWorkersCommand } from '../commands/ContainerWorkersCommand';
|
|
|
8
8
|
export { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from '../commands/CreateCommand';
|
|
9
9
|
export { D1ProxyCommand } from '../commands/D1ProxyCommand';
|
|
10
10
|
export { DebugCommand } from '../commands/DebugCommand';
|
|
11
|
+
export { DebuggerCommands } from '../commands/DebuggerCommands';
|
|
11
12
|
export { JwtDevCommand } from '../commands/JwtDevCommand';
|
|
12
13
|
export { KvProxyCommand } from '../commands/KvProxyCommand';
|
|
13
14
|
export { LogsCleanupCommand } from '../commands/LogsCleanupCommand';
|
|
@@ -25,4 +26,5 @@ export { RoutesCommand } from '../commands/RoutesCommand';
|
|
|
25
26
|
export { SecretsCommand } from '../commands/SecretsCommand';
|
|
26
27
|
export { StartCommand } from '../commands/StartCommand';
|
|
27
28
|
export { TemplatesCommand } from '../commands/TemplatesCommand';
|
|
29
|
+
export { WranglerDevVarsCommand } from '../commands/WranglerDevVarsCommand';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAA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B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -8,6 +8,7 @@ export { ContainerWorkersCommand } from '../commands/ContainerWorkersCommand.js'
|
|
|
8
8
|
export { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from '../commands/CreateCommand.js';
|
|
9
9
|
export { D1ProxyCommand } from '../commands/D1ProxyCommand.js';
|
|
10
10
|
export { DebugCommand } from '../commands/DebugCommand.js';
|
|
11
|
+
export { DebuggerCommands } from '../commands/DebuggerCommands.js';
|
|
11
12
|
export { JwtDevCommand } from '../commands/JwtDevCommand.js';
|
|
12
13
|
export { KvProxyCommand } from '../commands/KvProxyCommand.js';
|
|
13
14
|
export { LogsCleanupCommand } from '../commands/LogsCleanupCommand.js';
|
|
@@ -25,3 +26,4 @@ export { RoutesCommand } from '../commands/RoutesCommand.js';
|
|
|
25
26
|
export { SecretsCommand } from '../commands/SecretsCommand.js';
|
|
26
27
|
export { StartCommand } from '../commands/StartCommand.js';
|
|
27
28
|
export { TemplatesCommand } from '../commands/TemplatesCommand.js';
|
|
29
|
+
export { WranglerDevVarsCommand } from '../commands/WranglerDevVarsCommand.js';
|
package/src/cli/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { AddCommand } from './commands/AddCommand';
|
|
|
10
10
|
export { ConfigCommand } from './commands/ConfigCommand';
|
|
11
11
|
export { D1ProxyCommand } from './commands/D1ProxyCommand';
|
|
12
12
|
export { DebugCommand } from './commands/DebugCommand';
|
|
13
|
+
export { DebuggerCommands } from './commands/DebuggerCommands';
|
|
13
14
|
export { KvProxyCommand } from './commands/KvProxyCommand';
|
|
14
15
|
export { MigrateCommand } from './commands/MigrateCommand';
|
|
15
16
|
export { MySqlProxyCommand } from './commands/MySqlProxyCommand';
|
package/src/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,YAAY,E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E,MAAM,8BAA8B,CAAC"}
|
package/src/cli/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { AddCommand } from './commands/AddCommand.js';
|
|
|
11
11
|
export { ConfigCommand } from './commands/ConfigCommand.js';
|
|
12
12
|
export { D1ProxyCommand } from './commands/D1ProxyCommand.js';
|
|
13
13
|
export { DebugCommand } from './commands/DebugCommand.js';
|
|
14
|
+
export { DebuggerCommands } from './commands/DebuggerCommands.js';
|
|
14
15
|
export { KvProxyCommand } from './commands/KvProxyCommand.js';
|
|
15
16
|
export { MigrateCommand } from './commands/MigrateCommand.js';
|
|
16
17
|
export { MySqlProxyCommand } from './commands/MySqlProxyCommand.js';
|
package/src/cli.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { BaseCommand } from './cli/BaseCommand';
|
|
|
2
2
|
export type { CommandOptions } from './cli/BaseCommand';
|
|
3
3
|
export { CLI } from './cli/CLI';
|
|
4
4
|
export { ErrorHandler, EXIT_CODES } from './cli/ErrorHandler';
|
|
5
|
+
export { DebuggerCommands } from './cli/commands/DebuggerCommands';
|
|
5
6
|
export { WorkerCommands } from './cli/commands/WorkerCommands';
|
|
6
7
|
export { OptionalCliCommandRegistry } from './cli/OptionalCliCommandRegistry';
|
|
7
8
|
export type { CliCommandProvider } from './cli/OptionalCliCommandRegistry';
|
package/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/src/cli.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
export { BaseCommand } from './cli/BaseCommand.js';
|
|
3
3
|
export { CLI } from './cli/CLI.js';
|
|
4
4
|
export { ErrorHandler, EXIT_CODES } from './cli/ErrorHandler.js';
|
|
5
|
+
export { DebuggerCommands } from './cli/commands/DebuggerCommands.js';
|
|
5
6
|
export { WorkerCommands } from './cli/commands/WorkerCommands.js';
|
|
6
7
|
export { OptionalCliCommandRegistry } from './cli/OptionalCliCommandRegistry.js';
|
package/src/config/logger.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LogLevel } from './type';
|
|
1
2
|
interface ILogger {
|
|
2
3
|
debug(message: string, data?: unknown, category?: string): void;
|
|
3
4
|
info(message: string, data?: unknown, category?: string): void;
|
|
@@ -5,6 +6,11 @@ interface ILogger {
|
|
|
5
6
|
error(message: string, error?: unknown, category?: string): void;
|
|
6
7
|
fatal(message: string, error?: unknown, category?: string): void;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* External log sink. Receives every log line after the built-in sinks have fired.
|
|
11
|
+
* Return value is ignored; errors are swallowed to protect the caller.
|
|
12
|
+
*/
|
|
13
|
+
export type LogSink = (level: LogLevel, message: string, context?: Record<string, unknown>) => void;
|
|
8
14
|
export declare const cleanLogsOnce: () => Promise<string[]>;
|
|
9
15
|
export declare const Logger: Readonly<{
|
|
10
16
|
debug: (message: string, data?: unknown, category?: string) => void;
|
|
@@ -14,6 +20,7 @@ export declare const Logger: Readonly<{
|
|
|
14
20
|
fatal: (message: string, error?: unknown, category?: string) => void;
|
|
15
21
|
cleanLogsOnce: () => Promise<string[]>;
|
|
16
22
|
scope: (scope: string) => ILogger;
|
|
23
|
+
addSink: (fn: LogSink) => (() => void);
|
|
17
24
|
}>;
|
|
18
25
|
export default Logger;
|
|
19
26
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/config/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/config/logger.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,UAAU,OAAO;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClE;AAubD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAkCpG,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,MAAM,EAAE,CAYtD,CAAC;AAEF,eAAO,MAAM,MAAM;qBA3MQ,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;oBAuBjD,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;oBAuBhD,MAAM,SAAS,OAAO,aAAa,MAAM,KAAG,IAAI;qBAuB/C,MAAM,UAAU,OAAO,aAAa,MAAM,KAAG,IAAI;qBA6BjD,MAAM,UAAU,OAAO,aAAa,MAAM,KAAG,IAAI;yBA2FrC,OAAO,CAAC,MAAM,EAAE,CAAC;mBA1DtB,MAAM,KAAG,OAAO;kBAiD7B,OAAO,KAAG,CAAC,MAAM,IAAI,CAAC;EAgCzC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/config/logger.js
CHANGED
|
@@ -283,6 +283,7 @@ const logDebug = (message, data, category) => {
|
|
|
283
283
|
category,
|
|
284
284
|
data: redactSensitiveData(data),
|
|
285
285
|
});
|
|
286
|
+
dispatchToSinks('debug', message, data);
|
|
286
287
|
};
|
|
287
288
|
const logInfo = (message, data, category) => {
|
|
288
289
|
if (!shouldEmit('info'))
|
|
@@ -304,6 +305,7 @@ const logInfo = (message, data, category) => {
|
|
|
304
305
|
category,
|
|
305
306
|
data: redactSensitiveData(data),
|
|
306
307
|
});
|
|
308
|
+
dispatchToSinks('info', message, data);
|
|
307
309
|
};
|
|
308
310
|
const logWarn = (message, data, category) => {
|
|
309
311
|
if (!shouldEmit('warn'))
|
|
@@ -325,6 +327,7 @@ const logWarn = (message, data, category) => {
|
|
|
325
327
|
category,
|
|
326
328
|
data: redactSensitiveData(data),
|
|
327
329
|
});
|
|
330
|
+
dispatchToSinks('warn', message, data);
|
|
328
331
|
};
|
|
329
332
|
const logError = (message, error, category) => {
|
|
330
333
|
if (!shouldEmit('error'))
|
|
@@ -352,6 +355,7 @@ const logError = (message, error, category) => {
|
|
|
352
355
|
category,
|
|
353
356
|
error: errorMessage,
|
|
354
357
|
});
|
|
358
|
+
dispatchToSinks('error', message, error);
|
|
355
359
|
};
|
|
356
360
|
const logFatal = (message, error, category) => {
|
|
357
361
|
if (!shouldEmit('fatal'))
|
|
@@ -379,6 +383,7 @@ const logFatal = (message, error, category) => {
|
|
|
379
383
|
category,
|
|
380
384
|
error: errorMessage,
|
|
381
385
|
});
|
|
386
|
+
dispatchToSinks('fatal', message, error);
|
|
382
387
|
if (isProduction() && typeof process !== 'undefined') {
|
|
383
388
|
process.exit(1);
|
|
384
389
|
}
|
|
@@ -402,6 +407,37 @@ const createLoggerScope = (scope) => {
|
|
|
402
407
|
},
|
|
403
408
|
};
|
|
404
409
|
};
|
|
410
|
+
const loggerSinks = [];
|
|
411
|
+
const dispatchToSinks = (level, message, data) => {
|
|
412
|
+
if (loggerSinks.length === 0)
|
|
413
|
+
return;
|
|
414
|
+
let context;
|
|
415
|
+
if (data !== null && typeof data === 'object' && !Array.isArray(data)) {
|
|
416
|
+
context = data;
|
|
417
|
+
}
|
|
418
|
+
else if (data === undefined) {
|
|
419
|
+
context = undefined;
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
context = { value: data };
|
|
423
|
+
}
|
|
424
|
+
for (const sink of loggerSinks) {
|
|
425
|
+
try {
|
|
426
|
+
sink(level, message, context);
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
// best-effort — sinks must never crash the caller
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const addSink = (fn) => {
|
|
434
|
+
loggerSinks.push(fn);
|
|
435
|
+
return () => {
|
|
436
|
+
const idx = loggerSinks.indexOf(fn);
|
|
437
|
+
if (idx !== -1)
|
|
438
|
+
loggerSinks.splice(idx, 1);
|
|
439
|
+
};
|
|
440
|
+
};
|
|
405
441
|
// Expose log cleanup API and sealed namespace with all logger functionality
|
|
406
442
|
export const cleanLogsOnce = async () => {
|
|
407
443
|
if (!shouldLogToFile())
|
|
@@ -425,5 +461,6 @@ export const Logger = Object.freeze({
|
|
|
425
461
|
fatal: logFatal,
|
|
426
462
|
cleanLogsOnce,
|
|
427
463
|
scope: createLoggerScope,
|
|
464
|
+
addSink,
|
|
428
465
|
});
|
|
429
466
|
export default Logger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const SystemDebuggerBridge: Readonly<{
|
|
2
|
+
preload: () => Promise<boolean>;
|
|
3
|
+
emitAuth: (event: "login" | "logout" | "failed", userId?: string) => void;
|
|
4
|
+
emitCache: (operation: "get" | "set" | "delete" | "clear" | "has", key: string, duration: number, hit?: boolean) => void;
|
|
5
|
+
emitCommand: (name: string, args: Record<string, unknown>, exitCode: number, duration: number, output?: string) => void;
|
|
6
|
+
emitEvent: (name: string, listenerCount: number, payload?: unknown) => void;
|
|
7
|
+
emitHttpClient: (method: string, url: string, requestHeaders: Record<string, string>, responseStatus: number, duration: number) => void;
|
|
8
|
+
emitJobDispatch: (name: string, queue: string, connection: string, data?: unknown) => void;
|
|
9
|
+
emitJobFailed: (name: string, error: Error) => void;
|
|
10
|
+
emitJobProcessed: (name: string) => void;
|
|
11
|
+
emitMail: (to: string, subject: string, template?: string) => void;
|
|
12
|
+
emitNotification: (notification: string, channels: string[], notifiable?: string) => void;
|
|
13
|
+
}>;
|
|
14
|
+
export default SystemDebuggerBridge;
|
|
15
|
+
//# sourceMappingURL=SystemDebuggerBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SystemDebuggerBridge.d.ts","sourceRoot":"","sources":["../../../src/debugger/SystemDebuggerBridge.ts"],"names":[],"mappings":"AA6KA,eAAO,MAAM,oBAAoB;mBALP,OAAO,CAAC,OAAO,CAAC;sBAlBjB,OAAO,GAAG,QAAQ,GAAG,QAAQ,WAAW,MAAM,KAAG,IAAI;2BA1DjE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,OAChD,MAAM,YACD,MAAM,QACV,OAAO,KACZ,IAAI;wBA6DC,MAAM,QACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACnB,MAAM,YACN,MAAM,WACP,MAAM,KACd,IAAI;sBAlBkB,MAAM,iBAAiB,MAAM,YAAY,OAAO,KAAG,IAAI;6BAXtE,MAAM,OACT,MAAM,kBACK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,kBACtB,MAAM,YACZ,MAAM,KACf,IAAI;4BApCwB,MAAM,SAAS,MAAM,cAAc,MAAM,SAAS,OAAO,KAAG,IAAI;0BAYlE,MAAM,SAAS,KAAK,KAAG,IAAI;6BANxB,MAAM,KAAG,IAAI;mBAkBvB,MAAM,WAAW,MAAM,aAAa,MAAM,KAAG,IAAI;qCAN/B,MAAM,YAAY,MAAM,EAAE,eAAe,MAAM,KAAG,IAAI;EAiE5F,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
let cachedModule;
|
|
2
|
+
let loadPromise = null;
|
|
3
|
+
const importSystemDebugger = async () => {
|
|
4
|
+
try {
|
|
5
|
+
return (await import('../../packages/system-debugger/src/index.js'));
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const loadSystemDebugger = async () => {
|
|
12
|
+
if (cachedModule !== undefined)
|
|
13
|
+
return cachedModule;
|
|
14
|
+
if (loadPromise !== null)
|
|
15
|
+
return loadPromise;
|
|
16
|
+
loadPromise = importSystemDebugger().then((loaded) => {
|
|
17
|
+
cachedModule = loaded;
|
|
18
|
+
loadPromise = null;
|
|
19
|
+
return loaded;
|
|
20
|
+
});
|
|
21
|
+
return loadPromise;
|
|
22
|
+
};
|
|
23
|
+
const withSystemDebugger = (run) => {
|
|
24
|
+
const invoke = (module) => {
|
|
25
|
+
if (module === null || module === undefined)
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
run(module);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Ignore optional debugger failures so core runtime behavior is unaffected.
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (cachedModule !== undefined) {
|
|
35
|
+
invoke(cachedModule);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
void loadSystemDebugger()
|
|
39
|
+
.then(invoke)
|
|
40
|
+
.catch(() => undefined);
|
|
41
|
+
};
|
|
42
|
+
const emitCache = (operation, key, duration, hit) => {
|
|
43
|
+
withSystemDebugger((module) => {
|
|
44
|
+
module.CacheWatcher?.emit(operation, key, duration, hit);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const emitJobDispatch = (name, queue, connection, data) => {
|
|
48
|
+
withSystemDebugger((module) => {
|
|
49
|
+
module.JobWatcher?.onDispatch(name, queue, connection, data);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const emitJobProcessed = (name) => {
|
|
53
|
+
withSystemDebugger((module) => {
|
|
54
|
+
module.JobWatcher?.onProcessed(name);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const emitJobFailed = (name, error) => {
|
|
58
|
+
withSystemDebugger((module) => {
|
|
59
|
+
module.JobWatcher?.onFailed(name, error);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const emitNotification = (notification, channels, notifiable) => {
|
|
63
|
+
withSystemDebugger((module) => {
|
|
64
|
+
module.NotificationWatcher?.emit(notification, channels, notifiable);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const emitMail = (to, subject, template) => {
|
|
68
|
+
withSystemDebugger((module) => {
|
|
69
|
+
module.MailWatcher?.emit(to, subject, template);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const emitHttpClient = (method, url, requestHeaders, responseStatus, duration) => {
|
|
73
|
+
withSystemDebugger((module) => {
|
|
74
|
+
module.HttpClientWatcher?.emit(method, url, requestHeaders, responseStatus, duration);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const emitEvent = (name, listenerCount, payload) => {
|
|
78
|
+
withSystemDebugger((module) => {
|
|
79
|
+
module.EventWatcher?.emit(name, listenerCount, payload);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const emitAuth = (event, userId) => {
|
|
83
|
+
withSystemDebugger((module) => {
|
|
84
|
+
module.AuthWatcher?.emit(event, userId);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const emitCommand = (name, args, exitCode, duration, output) => {
|
|
88
|
+
withSystemDebugger((module) => {
|
|
89
|
+
module.CommandWatcher?.emit(name, args, exitCode, duration, output);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const preload = async () => {
|
|
93
|
+
const loaded = await loadSystemDebugger();
|
|
94
|
+
return loaded !== null;
|
|
95
|
+
};
|
|
96
|
+
export const SystemDebuggerBridge = Object.freeze({
|
|
97
|
+
preload,
|
|
98
|
+
emitAuth,
|
|
99
|
+
emitCache,
|
|
100
|
+
emitCommand,
|
|
101
|
+
emitEvent,
|
|
102
|
+
emitHttpClient,
|
|
103
|
+
emitJobDispatch,
|
|
104
|
+
emitJobFailed,
|
|
105
|
+
emitJobProcessed,
|
|
106
|
+
emitMail,
|
|
107
|
+
emitNotification,
|
|
108
|
+
});
|
|
109
|
+
export default SystemDebuggerBridge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventDispatcher.d.ts","sourceRoot":"","sources":["../../../src/events/EventDispatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
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,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;CAC1D;AAwBD,eAAO,MAAM,eAAe;WACnB,OAAO,SAAS,QAAQ,gBAAgB,gBAAgB,CAAC,OAAO,CAAC;EAwGxE,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SystemDebuggerBridge } from '../debugger/SystemDebuggerBridge.js';
|
|
1
2
|
import { Logger } from '../config/logger.js';
|
|
2
3
|
function getOrCreateSet(store, event) {
|
|
3
4
|
const existing = store.get(event);
|
|
@@ -51,6 +52,7 @@ export const EventDispatcher = Object.freeze({
|
|
|
51
52
|
const set = listeners.get(event);
|
|
52
53
|
if (set === undefined)
|
|
53
54
|
return;
|
|
55
|
+
SystemDebuggerBridge.emitEvent(event, set.size, payload);
|
|
54
56
|
// Snapshot to avoid mutation during iteration affecting dispatch.
|
|
55
57
|
const snapshot = Array.from(set);
|
|
56
58
|
for (const listener of snapshot) {
|
|
@@ -61,6 +63,7 @@ export const EventDispatcher = Object.freeze({
|
|
|
61
63
|
const set = listeners.get(event);
|
|
62
64
|
if (set === undefined)
|
|
63
65
|
return;
|
|
66
|
+
SystemDebuggerBridge.emitEvent(event, set.size, payload);
|
|
64
67
|
const snapshot = Array.from(set);
|
|
65
68
|
const results = await Promise.allSettled(snapshot.map(async (listener) => {
|
|
66
69
|
await listener(payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/functions/cloudflare.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../../src/functions/cloudflare.ts"],"names":[],"mappings":";mBAqPuB,OAAO,QAAQ,OAAO,QAAQ,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADhF,wBAwCE"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { appConfig } from '../config/index.js';
|
|
2
|
+
import { Application } from '../boot/Application.js';
|
|
1
3
|
import { Logger } from '../config/logger.js';
|
|
2
4
|
import { clearMiddlewareConfigCache } from '../config/middleware.js';
|
|
5
|
+
import { Kernel } from '../http/Kernel.js';
|
|
3
6
|
import { CloudflareAdapter } from '../runtime/adapters/CloudflareAdapter.js';
|
|
4
7
|
import mergeOverrideValues from '../runtime/OverrideValueMerge.js';
|
|
5
8
|
import { ProjectRuntime } from '../runtime/ProjectRuntime.js';
|
|
@@ -171,6 +174,17 @@ const ensureStartupConfigOverridesLoaded = async () => {
|
|
|
171
174
|
startupConfigOverridesPromise ??= applyStartupConfigOverrides();
|
|
172
175
|
await startupConfigOverridesPromise;
|
|
173
176
|
};
|
|
177
|
+
const resolveRequestKernel = async () => {
|
|
178
|
+
if (!appConfig.isDevelopment()) {
|
|
179
|
+
return { kernel: await getKernel() };
|
|
180
|
+
}
|
|
181
|
+
const app = Application.create();
|
|
182
|
+
await app.boot();
|
|
183
|
+
return {
|
|
184
|
+
kernel: Kernel.create(app.getRouter(), app.getContainer()),
|
|
185
|
+
shutdown: app.shutdown,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
174
188
|
export default {
|
|
175
189
|
async fetch(request, _env, _ctx) {
|
|
176
190
|
try {
|
|
@@ -185,14 +199,19 @@ export default {
|
|
|
185
199
|
await ensureStartupConfigOverridesLoaded();
|
|
186
200
|
await WorkerAdapterImports.ready; // NOSONAR - Ensure adapter imports are ready before handling requests.
|
|
187
201
|
await injectIoredisModule();
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
const runtimeKernel = await resolveRequestKernel();
|
|
203
|
+
try {
|
|
204
|
+
const adapter = CloudflareAdapter.create({
|
|
205
|
+
handler: async (req, res) => {
|
|
206
|
+
await runtimeKernel.kernel.handle(req, res);
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const platformResponse = await adapter.handle(request);
|
|
210
|
+
return adapter.formatResponse(platformResponse);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
await runtimeKernel.shutdown?.();
|
|
214
|
+
}
|
|
196
215
|
}
|
|
197
216
|
catch (error) {
|
|
198
217
|
const err = error;
|
package/src/http/Kernel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../../src/http/Kernel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK7E,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../../src/http/Kernel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MA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